ObjC FFI: use bridged cast to store Objective-C objects in pointers
authorAlexis Laferrière <alexis.laf@xymus.net>
Thu, 15 Jan 2015 16:06:29 +0000 (11:06 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 16 Jan 2015 04:28:35 +0000 (23:28 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/ffi/objc.nit

index 5c7eeeb..a804141 100644 (file)
@@ -211,6 +211,13 @@ end
 private class FromObjCCallContext
        super ObjCCallContext
 
+       redef fun cast_to(mtype, name)
+       do
+               if mtype isa MClassType and mtype.mclass.ftype isa ForeignObjCType then
+                       return "(__bridge void*)({name})"
+               else return name
+       end
+
        redef fun cast_from(mtype, name)
        do
                if mtype isa MClassType and mtype.mclass.ftype isa ForeignObjCType then