ni: use special mangled name in ni generated code to support extern classes
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 14 Feb 2012 01:06:19 +0000 (20:06 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Fri, 24 Feb 2012 18:33:03 +0000 (13:33 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

src/native_interface/frontier.nit
src/native_interface/ni_metamodel.nit

index 450fe3c..232dbfb 100644 (file)
@@ -475,7 +475,7 @@ redef class MMType
 
                        # add null version, as a struct
                        if is_nullable then
-                               var null_getter = "null_{as_notnull.friendly_extern_name}"
+                               var null_getter = "null_{as_notnull.mangled_name}"
                                var null_getter_local = "{mmmodule.to_s}_{null_getter}"
 
                                v.header.add( "{name} {null_getter_local}();\n" )
index 8fab011..f39fc9b 100644 (file)
@@ -39,6 +39,16 @@ redef class MMType
                end
        end
 
+       fun mangled_name: String
+       do
+               var pi = local_class.primitive_info
+               if is_nullable then
+                       return "nullable_{local_class.name.to_s}"
+               else
+                       return local_class.name.to_s
+               end
+       end
+
        # Return the expression to convert this type from its native version.
        fun from_native( name : String ) : String
        do
@@ -219,16 +229,16 @@ redef class MMImportedCast
                if is_about_nullable_only then
                        if is_not_null_to_nullable  then # to null
                                # nullable_Object Object_as_nullable( Object o )
-                               return "{from.friendly_extern_name}_as_nullable"
+                               return "{from.mangled_name}_as_nullable"
                        else if is_nullable_to_not_null then # from null
                                # Object Object_as_not_null( nullable_Object o )
-                               return "{to.friendly_extern_name}_as_not_null"
+                               return "{to.mangled_name}_as_not_null"
                        else
                                abort
                        end
                else # inter types
                        # String Object_as_String( Object o )
-                       return "{from.friendly_extern_name}_as_{to.friendly_extern_name}"
+                       return "{from.mangled_name}_as_{to.mangled_name}"
                end
        end
 
@@ -253,13 +263,13 @@ redef class MMImportedCast
                        else if is_nullable_to_not_null then # from null
                                # Object_is_null( nullable_Object o )
                                # is opposite from others
-                               return "{to.local_class}_is_null"
+                               return "{to.mangled_name}_is_null"
                        else
                                abort
                        end
                else # inter types
                        # Object_is_a_String( Object o )
-                       return "{from.friendly_extern_name}_is_a_{to.friendly_extern_name}"
+                       return "{from.mangled_name}_is_a_{to.mangled_name}"
                end
        end