[pypy-commit] creflect default: Pass the base case of a global function declaration.
arigo
noreply at buildbot.pypy.org
Tue Nov 18 00:48:55 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r63:364e932db77a
Date: 2014-11-18 00:49 +0100
http://bitbucket.org/cffi/creflect/changeset/364e932db77a/
Log: Pass the base case of a global function declaration.
diff --git a/creflect/model.py b/creflect/model.py
--- a/creflect/model.py
+++ b/creflect/model.py
@@ -27,6 +27,9 @@
if inspect is not None and inspect.started:
inspect.assign_to_p1('0')
+ def shadow_global_var(self, top_level_block, name):
+ return name
+
def __eq__(self, other):
return (self.__class__ == other.__class__ and
self._get_items() == other._get_items())
@@ -199,6 +202,20 @@
t1, a2, len(t_args), crx_func_name)
return block.write_crx_type_var(expr)
+ def shadow_global_var(self, top_level_block, fnname):
+ shadowname = '%s__d_%s' % (top_level_block.crx_func_name, fnname)
+ wrline = top_level_block.writeline
+ args = [arg.get_c_name('a%d' % i) for i, arg in enumerate(self.args)]
+ decl = '%s(%s)' % (shadowname, ', '.join(args) or 'void')
+ wrline('static %s {' % self.result.get_c_name(decl))
+ args = ['a%d' % i for i, arg in enumerate(self.args)]
+ wrline(' %s%s(%s);' % ('' if isinstance(self.result, VoidType)
+ else 'return ',
+ fnname, ', '.join(args)))
+ wrline('}')
+ wrline('')
+ return shadowname
+
class PointerType(BaseType):
_attrs_ = ('totype',)
@@ -491,5 +508,7 @@
inspect = TypeInspector(block, None, varname=self.name)
t1 = self.type.inspect_type(block, inspect)
inspect.stop()
- block.writeline('cb->define_var(cb, "%s", %s, &xxx);' % (self.name, t1))
+ shadow = self.type.shadow_global_var(block.crx_top_level, self.name)
+ block.writeline('cb->define_var(cb, "%s", %s, &%s);' % (
+ self.name, t1, shadow))
funcblock.write_subblock(block)
More information about the pypy-commit
mailing list