[pypy-commit] cffi cffi-1.0: Return structs via a hidden pointer argument
arigo
noreply at buildbot.pypy.org
Sat May 9 19:15:39 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1951:0f4f79d96d65
Date: 2015-05-09 19:11 +0200
http://bitbucket.org/cffi/cffi/changeset/0f4f79d96d65/
Log: Return structs via a hidden pointer argument
diff --git a/_cffi1/recompiler.py b/_cffi1/recompiler.py
--- a/_cffi1/recompiler.py
+++ b/_cffi1/recompiler.py
@@ -455,6 +455,7 @@
# arg that is a pointer to the result.
arguments = []
call_arguments = []
+ context = 'argument of %s' % name
for i, type in enumerate(tp.args):
indirection = ''
if isinstance(type, model.StructOrUnion):
@@ -462,10 +463,18 @@
arg = type.get_c_name(' %sx%d' % (indirection, i), context)
arguments.append(arg)
call_arguments.append('%sx%d' % (indirection, i))
+ tp_result = tp.result
+ if isinstance(tp_result, model.StructOrUnion):
+ context = 'result of %s' % name
+ arg = tp_result.get_c_name(' *x', context)
+ arguments.insert(0, arg)
+ tp_result = model.void_type
+ result_decl = None
+ result_code = '*x = '
repr_arguments = ', '.join(arguments)
repr_arguments = repr_arguments or 'void'
name_and_arguments = '_cffi_f_%s(%s)' % (name, repr_arguments)
- prnt('static %s' % (tp.result.get_c_name(name_and_arguments),))
+ prnt('static %s' % (tp_result.get_c_name(name_and_arguments),))
prnt('{')
if result_decl:
prnt(result_decl)
More information about the pypy-commit
mailing list