Merge: Include extra Java files in a project
[nit.git] / src / common_ffi / common_ffi.nit
index ae2734a..c22180c 100644 (file)
@@ -32,6 +32,7 @@ import c_compiler_options
 import c
 import cpp
 import java
+import extra_java_files
 
 redef class MModule
        # Does this module uses the FFI?
@@ -46,7 +47,7 @@ redef class MModule
        # Complete the compilation of the FFI code
        fun finalize_ffi_wrapper(compdir: String, mainmodule: MModule)
        do
-               for language in present_languages do if ffi_callbacks.keys.has(language) then
+               for language in ffi_callbacks.keys do
                        for callback in ffi_callbacks[language] do
                                language.compile_callback(callback, self, mainmodule, ffi_ccu.as(not null))
                        end
@@ -87,6 +88,13 @@ redef class AModule
 
                ffi_ccu.header_c_base.add( "#include \"{mmodule.name}._nitni.h\"\n" )
 
+               ffi_ccu.body_decl.add("#ifdef ANDROID\n")
+               ffi_ccu.body_decl.add(" #include <android/log.h>\n")
+               ffi_ccu.body_decl.add(" #define PRINT_ERROR(...) (void)__android_log_print(ANDROID_LOG_WARN, \"Nit\", __VA_ARGS__)\n")
+               ffi_ccu.body_decl.add("#else\n")
+               ffi_ccu.body_decl.add(" #define PRINT_ERROR(...) fprintf(stderr, __VA_ARGS__)\n")
+               ffi_ccu.body_decl.add("#endif\n")
+
                for nclassdef in n_classdefs do
                        # Does it declares an extern type?
                        if nclassdef isa AStdClassdef and nclassdef.n_extern_code_block != null then
@@ -101,7 +109,7 @@ redef class AModule
        end
 end
 
-redef class AExternPropdef
+redef class AMethPropdef
        private var ffi_has_been_compiled = false
 
        # Compile the necessary wrapper around this extern method or constructor