rename `NativeString` to `CString`
[nit.git] / contrib / jwrapper / src / model.nit
index 9013bff..e2c8ac8 100644 (file)
@@ -93,7 +93,7 @@ class JavaType
                        end
                else
                        # Use the prefix and the short class name
-                       # e.g. given the prefix Native: java.lang.String -> NativeString
+                       # e.g. given the prefix Native: java.lang.String -> CString
                        name = prefix + id
                end
 
@@ -107,16 +107,16 @@ class JavaType
        end
 
        # Short name of the class, mangled to remove `$` (e.g. `Set`)
-       fun id: String do return identifier.last.replace("$", "")
+       var id: String is lazy do return identifier.last.replace("$", "")
 
        # Full name of this class as used in java code (e.g. `java.lang.Set`)
-       fun java_full_name: String do return identifier.join(".").replace("$", ".")
+       var java_full_name: String is lazy do return identifier.join(".").replace("$", ".")
 
        # Full name of this class as used by jni (e.g. `android.graphics.BitmapFactory$Options`)
-       fun jni_full_name: String do return identifier.join(".")
+       var jni_full_name: String is lazy do return identifier.join(".")
 
        # Name of this class for the extern declaration in Nit (e.g. `java.lang.Set[]`)
-       fun extern_equivalent: String do return jni_full_name + "[]" * array_dimension
+       var extern_equivalent: String is lazy do return jni_full_name + "[]" * array_dimension
 
        # Full name of this class with arrays and generic values (e.g. `java.lang.Set<E>[]`)
        redef fun to_s do
@@ -157,7 +157,7 @@ class NitType
        var identifier: String
 
        # If this NitType was found in `lib/android`, contains the module name to import
-       var mod: nullable NitModule
+       var mod: nullable NitModuleRef
 
        # Is this type known, wrapped and available in Nit?
        var is_known: Bool = true
@@ -183,7 +183,7 @@ class JavaClass
        var constructors = new Array[JavaConstructor]
 
        # Importations from this class
-       var imports = new HashSet[NitModule]
+       var imports = new HashSet[NitModuleRef]
 
        # Interfaces implemented by this class
        var implements = new HashSet[JavaType]
@@ -261,7 +261,7 @@ class JavaModel
        # All classes, from this pass and from other passes
        var all_classes: HashMap[String, JavaClass] is noserialize, lazy do
                var classes = new HashMap[String, JavaClass]
-               classes.recover_with self.classes
+               classes.add_all self.classes
 
                for model_path in sys.opt_load_models.value do
                        if not model_path.file_exists then
@@ -284,7 +284,7 @@ class JavaModel
                                continue
                        end
 
-                       classes.recover_with model.classes
+                       classes.add_all model.classes
                end
 
                return classes
@@ -482,7 +482,7 @@ class JavaConstructor
 end
 
 # A Nit module, use to import the referenced extern classes
-class NitModule
+class NitModuleRef
        # Relative path to the module
        var path: String
 
@@ -490,7 +490,7 @@ class NitModule
        var name: String is lazy do return path.basename(".nit")
 
        redef fun to_s do return self.name
-       redef fun ==(other) do return other isa NitModule and self.path == other.path
+       redef fun ==(other) do return other isa NitModuleRef and self.path == other.path
        redef fun hash do return self.path.hash
 end
 
@@ -501,7 +501,7 @@ redef class Sys
        # * The value is the corresponding `NitType`.
        var find_extern_class: DefaultMap[String, nullable NitType] is lazy do
                var map = new DefaultMap[String, nullable NitType](null)
-               var modules = new HashMap[String, NitModule]
+               var modules = new HashMap[String, NitModuleRef]
 
                var lib_paths = opt_libs.value
                if lib_paths == null then lib_paths = new Array[String]
@@ -543,7 +543,7 @@ redef class Sys
 
                                var mod = modules.get_or_null(path)
                                if mod == null then
-                                       mod = new NitModule(path)
+                                       mod = new NitModuleRef(path)
                                        modules[path] = mod
                                end