src/ffi: add a check before compiling FFI methods to see if supported
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 8 May 2015 13:07:19 +0000 (09:07 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 8 May 2015 14:32:42 +0000 (10:32 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/compiler/compiler_ffi/light.nit

index 345377a..c7e3b0e 100644 (file)
@@ -98,11 +98,18 @@ redef class AMethPropdef
                mmodule.ensure_compile_nitni_base(v)
        end
 
+       # Should we compile the extern method `self`?
+       #
+       # Returns false when restricting to the light FFI on methods using callbacks.
+       fun accept_externmeth: Bool do return true
+
        redef fun compile_externmeth_to_c(v, mpropdef, arguments)
        do
                # if using the old native interface fallback on previous implementation
                if n_extern_code_block == null then return super
 
+               if not accept_externmeth then return false
+
                var mmodule = mpropdef.mclassdef.mmodule
                mmodule.uses_ffi = true
 
@@ -164,6 +171,8 @@ redef class AMethPropdef
                # if using the old native interface fallback on previous implementation
                if n_extern_code_block == null then return super
 
+               if not accept_externmeth then return false
+
                var mmodule = mpropdef.mclassdef.mmodule
                mmodule.uses_ffi = true