From bf78709aa3e9b2b5a246e5bcc693adb0a1542854 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alexis=20Laferri=C3=A8re?= Date: Tue, 1 Sep 2015 11:37:09 -0400 Subject: [PATCH] contrib/objcwrapper: generate minimal doc above generated properties 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 ++++++++++++++++ contrib/objcwrapper/src/objc_model.nit | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/contrib/objcwrapper/src/objc_generator.nit b/contrib/objcwrapper/src/objc_generator.nit index d50795b..408d731 100644 --- a/contrib/objcwrapper/src/objc_generator.nit +++ b/contrib/objcwrapper/src/objc_generator.nit @@ -195,6 +195,7 @@ end file.write """ +{{{attribute.doc}}} {{{c}}} fun {{{nit_attr_name}}}: {{{nit_attr_type}}} in "ObjC" `{ {{{c}}} return [self {{{attribute.name}}}]; {{{c}}} `} @@ -210,6 +211,7 @@ end file.write """ +{{{attribute.doc}}} {{{c}}} fun {{{nit_attr_name}}}=(value: {{{nit_attr_type}}}) in "ObjC" `{ {{{c}}} return self.{{{attribute.name}}} = value; {{{c}}} `} @@ -256,6 +258,7 @@ end file.write """ +{{{method.doc}}} {{{c}}}{{{fun_keyword}}} {{{name}}}{{{params_with_par}}}{{{ret}}} in "ObjC" `{ """ end @@ -324,10 +327,23 @@ redef class ObjcProperty private fun comment_str: String do if is_commented then return "#" else return "" + + # Full documentation to be generated for the Nit code + private fun doc: String is abstract end redef class ObjcMethod private fun indent: String do return if is_class_property then "" else "\t" redef fun comment_str do return indent + super + + redef fun doc + do + var recv = if is_class_property then objc_class.name else "self" + return "{indent}# Wraps: `[{recv} {params.join(" ")}]`" + end +end + +redef class ObjcAttribute + redef fun doc do return "\t# Wraps: `{objc_class.name}.{name}`" end diff --git a/contrib/objcwrapper/src/objc_model.nit b/contrib/objcwrapper/src/objc_model.nit index 21a34fa..3777f07 100644 --- a/contrib/objcwrapper/src/objc_model.nit +++ b/contrib/objcwrapper/src/objc_model.nit @@ -119,4 +119,10 @@ class ObjcParam # Is this a parameter with only a `name`? var is_single = false is writable + + redef fun to_s + do + if is_single then return name + return "{name}:({return_type}){variable_name}" + end end -- 1.7.9.5