Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
# Code generation
module objc_generator
# Code generation
module objc_generator
+redef class Sys
+ # Path to the output file
+ var opt_output = new OptionString("Output file", "-o")
+end
+
class CodeGenerator
# Merge the calls to `alloc` and `init...` in a single constructor?
#
class CodeGenerator
# Merge the calls to `alloc` and `init...` in a single constructor?
#
var init_with_alloc = true is writable
fun generator(classes: Array[nullable ObjcClass]) do
var init_with_alloc = true is writable
fun generator(classes: Array[nullable ObjcClass]) do
+ # Open specified path or stdin
+ var file
+ var path = opt_output.value
+ if path != null then
+ if path.file_extension != "nit" then
+ print_error "Warning: output file path does not end with '.nit'"
+ end
+
+ file = new FileWriter.open(path)
+ else
+ file = stdout
+ end
+
+ # Generate code
- var file = new FileWriter.open(classe.name + ".nit")
nit_class_generator(classe, file, init_with_alloc)
nit_class_generator(classe, file, init_with_alloc)
+
+ if path != null then file.close
end
fun type_convertor(type_word: String): String do
end
fun type_convertor(type_word: String): String do