From: Alexis Laferrière Date: Tue, 1 Sep 2015 15:37:09 +0000 (-0400) Subject: contrib/objcwrapper: generate minimal doc above generated properties X-Git-Tag: v0.7.8~42^2~14 X-Git-Url: http://nitlanguage.org contrib/objcwrapper: generate minimal doc above generated properties Signed-off-by: Alexis Laferrière --- 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