Rename REAMDE to README.md
[nit.git] / src / ffi / java.nit
index 7827dac..ae37d9d 100644 (file)
@@ -296,7 +296,7 @@ redef class AMethPropdef
                assert sys_class != null
                var sys_jni_env_meth = modelbuilder.try_get_mproperty_by_name2(self, mmodule, sys_class.mclass_type, "jni_env")
                if sys_jni_env_meth == null or not sys_jni_env_meth isa MMethod then
-                       toolcontext.error(self.location, "Java FFI error: you must import the `java` module when using the FFI with Java")
+                       toolcontext.error(self.location, "Java FFI Error: you must import the `java` module when using the FFI with Java")
                        return
                end
 
@@ -424,7 +424,7 @@ redef class MExplicitCall
                var csignature = mproperty.build_c_implementation_signature(recv_mtype, mmodule, "___indirect", long_signature, from_java_call_context)
                var cf = new CFunction("JNIEXPORT {csignature}")
                cf.exprs.add "\t{mproperty.build_ccall(recv_mtype, mainmodule, null, long_signature, from_java_call_context, null)}\n"
-               ccu.add_local_function cf
+               ccu.add_non_static_local_function cf
 
                # In Java, declare the extern method as a private static local method
                var java_signature = mproperty.build_csignature(recv_mtype, mainmodule, null, short_signature, java_call_context)
@@ -651,3 +651,17 @@ end
 private fun java_call_context: JavaCallContext do return new JavaCallContext
 private fun to_java_call_context: ToJavaCallContext do return new ToJavaCallContext
 private fun from_java_call_context: FromJavaCallContext do return new FromJavaCallContext
+
+redef class CCompilationUnit
+       # Similar to `add_local_function` but not `static`
+       #
+       # Used when the signature contains a visibility attribute.
+       private fun add_non_static_local_function(c_function: CFunction)
+       do
+               body_decl.add c_function.signature
+               body_decl.add ";\n"
+
+               body_impl.add "\n"
+               body_impl.add c_function.to_writer
+       end
+end