rust - How do I determine the actual values of certain Objective-C constants? -


i'm using objective-c functions in rust application through layer of different bindings. far simple call objective-c functions , implement required functionality without problems. seems found impediment don't know how solve, of functions coregraphics require several constants work properly.

so question how can actual value of particular constant? instance, let's want value of cgrectinfinite constant (coregraphics), possible it?

for integer constants/enums quite simple -- opened xcode , navigated appropriate header file, contained required values, copy-pasted values application. if constant cgrect?

extern const in c can declared in rust static.

extern {     pub static cgrectinfinite: cgrect; } 

the use of cgrectinfinite unsafe. you'd better provide safe wrapper access it.

impl cgrect {     pub fn infinite() -> cgrect {         unsafe { cgrectinfinite }     } } 

the actual value of cgrectinfinite, way, is:

#[cfg(target_pointer_width="64")] pub const cgrectinfinite: cgrect = cgrect {     origin: cgpoint {         x: -0.5 * f64::max,         y: -0.5 * f64::max,     },     size: cgsize {         width: f64::max,         height: f64::max,     }, };  // similar on 32-bit, replacing f64 f32. 

but should not rely on actual value of constant.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -