From bb51f5635bcb3e83ab13c995f7a0025cb92993f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Thu, 20 Aug 2015 16:01:28 -0400 Subject: [PATCH] contrib/objcwrapper: refactor `init_with_alloc` as an attribute MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Alexis Laferrière --- contrib/objcwrapper/src/objc_generator.nit | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/contrib/objcwrapper/src/objc_generator.nit b/contrib/objcwrapper/src/objc_generator.nit index 89e8237..673e306 100644 --- a/contrib/objcwrapper/src/objc_generator.nit +++ b/contrib/objcwrapper/src/objc_generator.nit @@ -18,8 +18,22 @@ module objc_generator import objc_model class CodeGenerator + # Merge the calls to `alloc` and `init...` in a single constructor? + # + # If `true`, also the default behavior, initializing an extern Objective-C object looks like: + # ~~~nitish + # var o = new NSArray.init_with_array(some_other_array) + # ~~~ + # + # If `false`, the object must first be allocated and then initialized. + # This is closer to the Objective-C behavior: + # ~~~nitish + # var o = new NSArray + # o.init_with_array(some_other_array) + # ~~~ + var init_with_alloc = true is writable + fun generator(classes: Array[nullable ObjcClass]) do - var init_with_alloc = true for classe in classes do var file = new FileWriter.open(classe.name + ".nit") nit_class_generator(classe, file, init_with_alloc) -- 1.7.9.5