diff options
author | Garrett Regier <garrett.regier@riftio.com> | 2015-09-26 11:55:09 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-09-26 11:55:09 -0400 |
commit | 5ae7bd58b6266997b61d897ad6562118eeb59210 (patch) | |
tree | c68c962a7c690969471531369b07ea4dbef9a77a /giscanner/codegen.py | |
parent | b503f31c7cfa3329456de9bff5a2c816a607285e (diff) | |
download | gobject-introspection-5ae7bd58b6266997b61d897ad6562118eeb59210.tar.gz |
scanner: Warn and ignore on incorrect transfer annotations
This is an issue in various code bases and tends
to confuse newcomers.
https://bugzilla.gnome.org/show_bug.cgi?id=752047
Signed-off-by: Garrett Regier <garrett.regier@riftio.com>
Diffstat (limited to 'giscanner/codegen.py')
-rw-r--r-- | giscanner/codegen.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/giscanner/codegen.py b/giscanner/codegen.py index e0eb182f..fcf1fc51 100644 --- a/giscanner/codegen.py +++ b/giscanner/codegen.py @@ -84,28 +84,30 @@ class CCodeGenerator(object): self._write_prelude(self.out_h, func) self.out_h.write(";\n\n") - def _write_annotation_transfer(self, transfer): - self.out_c.write("(transfer %s)" % (transfer, )) + def _write_annotation_transfer(self, node): + if (node.type not in ast.BASIC_TYPES or + node.type.ctype.endswith('*')): + self.out_c.write(" (transfer %s)" % (node.transfer, )) def _write_docs(self, func): self.out_c.write("/**\n * %s:\n" % (func.symbol, )) for param in func.parameters: - self.out_c.write(" * @%s: " % (param.argname, )) + self.out_c.write(" * @%s" % (param.argname, )) if param.direction in (ast.PARAM_DIRECTION_OUT, ast.PARAM_DIRECTION_INOUT): if param.caller_allocates: allocate_string = ' caller-allocates' else: allocate_string = '' - self.out_c.write("(%s%s) " % (param.direction, - allocate_string)) - self._write_annotation_transfer(param.transfer) + self.out_c.write(": (%s%s) " % (param.direction, + allocate_string)) + self._write_annotation_transfer(param) self.out_c.write(":\n") self.out_c.write(' *\n') self.out_c.write(' * Undocumented.\n') self.out_c.write(' *\n') - self.out_c.write(' * Returns: ') - self._write_annotation_transfer(func.retval.transfer) + self.out_c.write(' * Returns:') + self._write_annotation_transfer(func.retval) self.out_c.write('\n */') @contextmanager |