Merge: SharedPreferences: Nit API wrapping android SharedPreferences class
[nit.git] / src / common_ffi / common_ffi.nit
index 2a9e7d4..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?
@@ -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