contrib/jwrapper: generate doc above extern methods
authorAlexis Laferrière <alexis.laf@xymus.net>
Mon, 20 Jul 2015 16:26:29 +0000 (12:26 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 21 Jul 2015 15:05:59 +0000 (11:05 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

contrib/jwrapper/src/code_generator.nit
contrib/jwrapper/src/model.nit

index 0520c23..dcaba43 100644 (file)
@@ -112,8 +112,10 @@ class CodeGenerator
        fun gen_class_header(jtype: JavaType): String
        do
                var temp = new Array[String]
-               temp.add("extern class Native{jtype.id} in \"Java\" `\{ {jtype} `\}\n")
-               temp.add("\tsuper JavaObject\n\n")
+               var nit_type = jtype.to_nit_type
+               temp.add "# Java class: {jtype.to_package_name}\n"
+               temp.add "extern class {nit_type} in \"Java\" `\{ {jtype.to_package_name} `\}\n"
+               temp.add "\tsuper JavaObject\n\n"
 
                return temp.join
        end
@@ -179,6 +181,9 @@ class CodeGenerator
                        nit_id_no += 1
                end
 
+               # Method documentation
+               var doc = "\t# Java implementation: {java_class}.{jmethod_id}\n"
+
                # Method identifier
                var method_id = nmethod_id.to_nit_method_name
                var nit_signature = new Array[String]
@@ -212,9 +217,9 @@ class CodeGenerator
 
                var temp = new Array[String]
 
+               temp.add doc
                temp.add(comment + nit_signature.join)
 
-               # FIXME : This huge `if` block is only necessary to copy primitive arrays as long as there's no better way to do it
                if comment == "#" then
                        temp.add(" in \"Java\" `\{\n{comment}\t\tself.{jmethod_id}({java_params});\n{comment}\t`\}\n")
                # Methods with return type
index b776186..0f62c4f 100644 (file)
@@ -297,6 +297,8 @@ class JavaClass
 
        # Importations from this class
        var imports = new HashSet[NitModule]
+
+       redef fun to_s do return class_type.to_s
 end
 
 # Model of all the Java class analyzed in one run