X-Git-Url: http://nitlanguage.org diff --git a/src/native_interface/frontier.nit b/src/native_interface/frontier.nit index 56e1bcf..3d12896 100644 --- a/src/native_interface/frontier.nit +++ b/src/native_interface/frontier.nit @@ -36,7 +36,7 @@ abstract class NiVariable fun needs_preparation : Bool do return ni_type.local_class.primitive_info == null or - ni_type.local_class.primitive_info.tagged or + not ni_type.local_class.primitive_info.tagged or ni_type.is_nullable end @@ -146,6 +146,9 @@ redef class MMSrcModule v.body.add( "#include \"{path}\"\n" ) v.header.add( "#include \"{path}\"\n" ) end + if uses_ffi then + v.header.add( "#include <{cname}._ffi.h>\n" ) + end for local_class in local_classes do ### extern methods @@ -159,6 +162,8 @@ redef class MMSrcModule end end + v.compile_cached + v.header.add( "#endif\n" ) end end @@ -374,6 +379,7 @@ class FrontierVisitor var cprogram : CProgram + # compiles cached types and callbacks fun compile_cached do # types @@ -527,7 +533,7 @@ redef class MMType # To be nested within a condition. fun compile_condition_isa( var_name : String ) : String do - return "( ISOBJ( {var_name} ) ? OBJISA( {var_name}, {local_class.cname} ): VALISA( {var_name}, {local_class.cname} ) )" + return "( ISOBJ( {var_name} ) ? ISNULL( {var_name} ) || OBJISA( {var_name}, {local_class.cname} ): VALISA( {var_name}, {local_class.cname} ) )" end # Defines a friendly type in C for a given Nit type.