From: Jean Privat Date: Mon, 8 Jun 2015 15:03:10 +0000 (-0400) Subject: Merge: FFI clean up X-Git-Tag: v0.7.6~59 X-Git-Url: http://nitlanguage.org?hp=089c943e33ad9f35e5a737c9114a97058a292d63 Merge: FFI clean up Pull-Request: #1442 Reviewed-by: Jean Privat Reviewed-by: Romain Chanoir Reviewed-by: Alexandre Terrasa --- diff --git a/src/c_tools.nit b/src/c_tools.nit index df2ddd8..0b80817 100644 --- a/src/c_tools.nit +++ b/src/c_tools.nit @@ -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 diff --git a/src/ffi/java.nit b/src/ffi/java.nit index d5852f6..c26fea2 100644 --- a/src/ffi/java.nit +++ b/src/ffi/java.nit @@ -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 diff --git a/src/nitni/nitni_base.nit b/src/nitni/nitni_base.nit index 188284f..f5cccc0 100644 --- a/src/nitni/nitni_base.nit +++ b/src/nitni/nitni_base.nit @@ -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