var with_attributes: Bool
var comment_unknown_types: Bool
- var file_out: OFStream
+ var file_out: FileWriter
var java_class: JavaClass
var nb_params: Int
- var module_name: String
+ var module_name: nullable String = null
init (file_name: String, jclass: JavaClass, with_attributes, comment: Bool)
do
- file_out = new OFStream.open(file_name)
- module_name = file_name.substring(0, file_name.search(".nit").from)
+ file_out = new FileWriter.open(file_name)
+
+ var nit_ext = ".nit"
+ if file_name.has_suffix(nit_ext) then
+ # Output file ends with .nit, we expect it to be a valid name
+ module_name = file_name.strip_extension(nit_ext)
+
+ # Otherwise, it may be anything so do not declare a module
+ end
+
self.java_class = jclass
self.with_attributes = with_attributes
self.comment_unknown_types = comment
end
file_out.write(gen_licence)
- file_out.write("module {module_name}\n")
+
+ var module_name = module_name
+ if module_name != null then file_out.write "module {module_name}\n"
+
+ file_out.write("\n")
file_out.write(imports.join(""))
file_out.write("\n")
file_out.write(class_content.join(""))
fun gen_licence: String
do
- return """# This file is part of NIT (http://www.nitlanguage.org).
-#
-# Copyright [Year] [Author name] <Author e-mail>
+ return """
+# This file is part of NIT (http://www.nitlanguage.org).
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# See the License for the specific language governing permissions and
# limitations under the License.
-# This code has been generated using `javap`
+# This code has been generated using `jwrapper`
"""
end