#ifndef HX_OBJC_HELPERS_INCLUDED #define HX_OBJC_HELPERS_INCLUDED @interface NSHaxeWrapperClass : NSObject { @public hx::Object *haxeObject; } - (id)init:(hx::Object *) inHaxe; - (void)dealloc; @end NSDictionary *_hx_obj_to_nsdictionary(Dynamic d); id _hx_value_to_objc(Dynamic d); Dynamic _hx_nsdictionary_to_obj(NSDictionary *inDictionary); Dynamic _hx_objc_to_dynamic(id inValue); Array _hx_objc_to_bytes(id value); namespace hx { // 0 args struct TObjcBlockVoidVoid { typedef void (^t)(); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^ { wrapper->haxeObject->__run(); }; return wrap; } }; template struct TObjcBlockRetVoid { typedef Ret (^t)(); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^() { return (Ret) wrapper->haxeObject->__run(); }; return wrap; } }; // 1 arg template struct TObjcBlockVoidArgs1 { typedef void (^t)(Arg0 a); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0) { wrapper->haxeObject->__run(a0); }; return wrap; } }; template struct TObjcBlockRetArgs1 { typedef Ret (^t)(Arg0 a); inline static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0) { return (Ret) wrapper->haxeObject->__run(a0); } ; } }; // 2 arg template struct TObjcBlockVoidArgs2 { typedef void (^t)(Arg0 a0, Arg1 a1); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1) { wrapper->haxeObject->__run(a0,a1); }; return wrap; } }; template struct TObjcBlockRetArgs2 { typedef Ret (^t)(Arg0 a0, Arg1 a1); inline static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1) { return (Ret) wrapper->haxeObject->__run(a0,a1); } ; } }; // 3 arg template struct TObjcBlockVoidArgs3 { typedef void (^t)(Arg0 a0, Arg1 a1, Arg2 a2); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1, Arg2 a2) { wrapper->haxeObject->__run(a0,a1,a2); }; return wrap; } }; template struct TObjcBlockRetArgs3 { typedef Ret (^t)(Arg0 a0, Arg1 a1, Arg2 a2); inline static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1, Arg2 a2) { return (Ret) wrapper->haxeObject->__run(a0,a1,a2); } ; } }; // 4 arg template struct TObjcBlockVoidArgs4 { typedef void (^t)(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3) { wrapper->haxeObject->__run(a0,a1,a2,a3); }; return wrap; } }; template struct TObjcBlockRetArgs4 { typedef Ret (^t)(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3); inline static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3) { return (Ret) wrapper->haxeObject->__run(a0,a1,a2,a3); } ; } }; // 5 arg template struct TObjcBlockVoidArgs5 { typedef void (^t)(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4); static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4) { wrapper->haxeObject->__run(a0,a1,a2,a3,a4); }; return wrap; } }; template struct TObjcBlockRetArgs5 { typedef Ret (^t)(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4); inline static t create(Dynamic func) { NSHaxeWrapperClass *wrapper = [[NSHaxeWrapperClass alloc] init:func.mPtr]; t wrap = ^(Arg0 a0, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4) { return (Ret) wrapper->haxeObject->__run(a0,a1,a2,a3,a4); } ; } }; } #endif