Skip to content

Calling an Objective C IMP with floating point parameters

Nat! edited this page Mar 17, 2017 · 4 revisions

Floating point parameters are always passed via the stack. Remember that float gets promoted to double.

Convert:

   (*method)( obj, sel, (float) 0.0); return; 
``

to

static void perform_imp( NSArray *self, SEL sel, IMP method, id arg1, id arg2) { #ifdef MULLE_OBJC mulle_objc_metaabi_param_block( double,
void *) param; param.p.arg = 0.0; (*method)( *obj, sel, &param); #else (*method)( *obj, sel, (float) 0.0); #endif }

Clone this wiki locally