Merge: FFI clean up
authorJean Privat <jean@pryen.org>
Mon, 8 Jun 2015 15:03:10 +0000 (11:03 -0400)
committerJean Privat <jean@pryen.org>
Mon, 8 Jun 2015 15:03:10 +0000 (11:03 -0400)
Pull-Request: #1442
Reviewed-by: Jean Privat <jean@pryen.org>
Reviewed-by: Romain Chanoir <chanoir.romain@courrier.uqam.ca>
Reviewed-by: Alexandre Terrasa <alexandre@moz-code.org>

src/c_tools.nit
src/ffi/java.nit
src/nitni/nitni_base.nit

index df2ddd8..0b80817 100644 (file)
@@ -47,7 +47,7 @@ class CCompilationUnit
        # files to compile TODO check is appropriate
        var files = new Array[String]
 
-       # Add `c_function` as a `static` function local to this unit
+       # Add a `static` `c_function` to be strictly local to this unit
        fun add_local_function(c_function: CFunction)
        do
                body_decl.add "static {c_function.signature};\n"
@@ -55,10 +55,10 @@ class CCompilationUnit
                body_impl.add c_function.to_writer
        end
 
-       # Add `c_function` as a public function to this unit
+       # Add a public `c_function` accessible from outside this compilation unit
        fun add_exported_function(c_function: CFunction)
        do
-               header_decl.add "{c_function.signature};\n"
+               body_decl.add "{c_function.signature};\n"
                body_impl.add "\n"
                body_impl.add c_function.to_writer
        end
index d5852f6..c26fea2 100644 (file)
@@ -243,7 +243,6 @@ redef class MModule
        private fun insert_compiler_options
        do
                cflags.add_one("", "-I $(JAVA_HOME)/include/ -I $(JAVA_HOME)/include/linux/")
-               ldflags.add_one("", "-L $(JNI_LIB_PATH) -ljvm")
        end
 
        # Name of the generated Java class where to store all implementation methods of this module
index 188284f..f5cccc0 100644 (file)
@@ -71,14 +71,15 @@ redef class MType
 
        # Representation of this type in C for the internal of the system
        # Hides extern types.
-       fun cname_blind: String is abstract
+       fun cname_blind: String do return "struct nitni_instance *"
 
        # Representation of this type in mangled C
        #   Object -> Object
        #   Pointer -> Pointer
        fun mangled_cname: String is abstract
 
-       # Does this types has a primitive reprensentation
+       # Does this type have a primitive representation?
+       #
        #   type Object is_primitive? false
        #   type Pointer is_primitive? true
        fun is_cprimitive: Bool is abstract
@@ -111,7 +112,7 @@ redef class MClassType
                if name == "Byte" then return "unsigned char"
                if name == "NativeString" then return "unsigned char*"
                if mclass.kind == extern_kind then return "void*"
-               return "struct nitni_instance *"
+               return super
        end
 
        # Name of this type in C for normal classes (not extern and not primitive)
@@ -125,13 +126,12 @@ end
 
 redef class MNullableType
        redef fun cname do return mangled_cname
-       redef fun cname_blind do return "struct nitni_instance *"
        redef fun mangled_cname do return "nullable_{mtype.mangled_cname}"
        redef fun is_cprimitive do return false
 end
 
 redef class MVirtualType
-       redef fun mangled_cname: String do return to_s
+       redef fun mangled_cname do return to_s
 end
 
 redef class MGenericType