[gobject-introspection/wip/transformer] [codegen] Fix to actually write again; add passthrough test
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection/wip/transformer] [codegen] Fix to actually write again; add passthrough test
- Date: Fri, 30 Jul 2010 21:38:00 +0000 (UTC)
commit 5b17018ea270f9bfea1cb675709a6678e418cc0e
Author: Colin Walters <walters verbum org>
Date: Fri Jul 30 11:21:24 2010 -0400
[codegen] Fix to actually write again; add passthrough test
giscanner/codegen.py | 45 ++++-----------------------------------------
giscanner/testcodegen.py | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 41 deletions(-)
---
diff --git a/giscanner/codegen.py b/giscanner/codegen.py
index 1f4b56c..b17026b 100644
--- a/giscanner/codegen.py
+++ b/giscanner/codegen.py
@@ -128,46 +128,9 @@ class CCodeGenerator(object):
for node in self.namespace.itervalues():
if isinstance(node, Function):
with self._function(node):
- yield (node, out_c)
-
- # First pass, generate constant returns
- prefix = 'const return '
- for typeval in INTROSPECTABLE_BASIC:
- name = uscore_from_type(typeval)
- sym = self._gen_symbol(prefix + typeval.target_fundamental)
- func = Function(name, Return(typeval, transfer=PARAM_TRANSFER_NONE),
- [], False, sym)
- with self._function(func):
- default = get_default_for_typeval(typeval)
- self.out_c.write(" return %s;\n" % (default, ))
-
- # Void return, one parameter
- prefix = 'oneparam '
- for typeval in INTROSPECTABLE_BASIC:
- if typeval is TYPE_NONE:
- continue
- name = uscore_from_type(typeval)
- sym = self._gen_symbol(prefix + typeval.target_fundamental)
- func = Function(name, Return(TYPE_NONE, transfer=PARAM_TRANSFER_NONE),
- [Parameter('arg0', typeval, transfer=PARAM_TRANSFER_NONE,
- direction=PARAM_DIRECTION_IN)], False, sym)
- with self._function(func):
- self.out_c.write(" return;\n")
-
- # Void return, one (out) parameter
- prefix = 'one_outparam '
- for typeval in INTROSPECTABLE_BASIC:
- if typeval is TYPE_NONE:
- continue
- name = uscore_from_type(typeval)
- sym = self._gen_symbol(prefix + typeval.target_fundamental)
- func = Function(name, Return(TYPE_NONE, transfer=PARAM_TRANSFER_NONE),
- [Parameter('arg0', typeval, transfer=PARAM_TRANSFER_NONE,
- direction=PARAM_DIRECTION_OUT)], False, sym)
- with self._function(func):
- default = get_default_for_typeval(func.retval)
- self.out_c.write(" *arg0 = %s;\n" % (default, ))
- self.out_c.write(" return;\n")
-
+ body = self._function_bodies.get(node)
+ if not body:
+ body = ''
+ self.out_c.write(body)
self._codegen_end()
diff --git a/giscanner/testcodegen.py b/giscanner/testcodegen.py
index 3dfb4d4..a5aeb10 100644
--- a/giscanner/testcodegen.py
+++ b/giscanner/testcodegen.py
@@ -96,3 +96,21 @@ class EverythingCodeGenerator(object):
body.write(" return;\n")
self.gen.set_function_body(func, body.getvalue())
+ # Passthrough one para
+ prefix = 'passthrough_one '
+ for typeval in INTROSPECTABLE_BASIC:
+ if typeval is TYPE_NONE:
+ continue
+ name = prefix + uscore_from_type(typeval)
+ sym = self.gen.gen_symbol(name)
+ func = Function(name, Return(typeval, transfer=PARAM_TRANSFER_NONE),
+ [Parameter('arg0', typeval, transfer=PARAM_TRANSFER_NONE,
+ direction=PARAM_DIRECTION_IN)], False, sym)
+ self.namespace.append(func)
+ body = StringIO('w')
+ default = get_default_for_typeval(func.retval)
+ body.write(" return arg0;\n")
+ self.gen.set_function_body(func, body.getvalue())
+
+ self.gen.codegen()
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]