diff options
author | Colin Walters <walters@verbum.org> | 2015-09-27 14:32:38 -0400 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-09-27 14:32:45 -0400 |
commit | 7c37a16ade424cf063414ce0dd4d170fd2f9c9b1 (patch) | |
tree | 0b09436c3e8c6dafd98c2e539fc9d2d8c8aecd6e /giscanner/codegen.py | |
parent | 4d9453f218074d03a5c44dbd44eeadb8e9e89f6c (diff) | |
download | gobject-introspection-7c37a16ade424cf063414ce0dd4d170fd2f9c9b1.tar.gz |
scanner: Warn and ignore on incorrect transfer annotations
This reverts commit 232f3c831260f596e36159112292897962a505b4.
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 |