From: Jean Privat Date: Wed, 18 Jun 2014 00:42:51 +0000 (-0400) Subject: Merge: SharedPreferences: Nit API wrapping android SharedPreferences class X-Git-Tag: v0.6.6~26 X-Git-Url: http://nitlanguage.org?hp=-c Merge: SharedPreferences: Nit API wrapping android SharedPreferences class A module wrapping 'android.content.SharedPreferences' allowing to load/save data to internal storage for the android platform. Some tests have been added to the mnit_simple example. The compiler has been slightly modified to ignore ' ' in java extern types. As asked by @privat and @xymus to store persistant game data. Signed-off-by: Frédéric Vachon Pull-Request: #495 Reviewed-by: Jean Privat Reviewed-by: Alexis Laferrière Reviewed-by: Alexandre Terrasa Reviewed-by: Romain Chanoir --- 34eefe9b154081809f663d7159068613bd6e41dc diff --combined src/common_ffi/java.nit index 68ba1e9,e220db4..f6e44f7 --- a/src/common_ffi/java.nit +++ b/src/common_ffi/java.nit @@@ -290,10 -290,8 +290,10 @@@ redef class AExternPropde var sys_class = modelbuilder.try_get_mclass_by_name(self, mmodule, "Sys") assert sys_class != null var sys_jni_env_meth = modelbuilder.try_get_mproperty_by_name2(self, mmodule, sys_class.mclass_type, "jni_env") - assert sys_jni_env_meth != null - assert sys_jni_env_meth isa MMethod + 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") + return + end explicit_call = new MExplicitCall(sys_class.mclass_type, sys_jni_env_meth, mmodule) fcc.callbacks.add(explicit_call) @@@ -351,7 -349,7 +351,7 @@@ class JavaFil super ExternFile redef fun makefile_rule_name do return "{filename.basename(".java")}.class" - redef fun makefile_rule_content do return "javac {filename} -d ." + redef fun makefile_rule_content do return "javac {filename.basename("")} -d ." redef fun add_to_jar do return true end @@@ -465,7 -463,7 +465,7 @@@ redef class MClassTyp do var ftype = mclass.ftype if ftype isa ForeignJavaType then return ftype.java_type. - replace('/', ".").replace('$', ".").replace(' ', "") + replace('/', ".").replace('$', ".").replace(' ', "").replace('\n',"") if mclass.name == "Bool" then return "boolean" if mclass.name == "Char" then return "char" if mclass.name == "Int" then return "int" @@@ -487,7 -485,7 +487,7 @@@ redef fun jni_format do var ftype = mclass.ftype - if ftype isa ForeignJavaType then return "L{ftype.java_type.replace('.', "/").replace(' ', "")};" + if ftype isa ForeignJavaType then return "L{ftype.java_type.replace('.', "/").replace(' ', "").replace('\n', "")};" if mclass.name == "Bool" then return "Z" if mclass.name == "Char" then return "C" if mclass.name == "Int" then return "I"