[pypy-commit] creflect default: pass the remaining func tests
arigo
noreply at buildbot.pypy.org
Tue Nov 18 18:08:57 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r77:2120ff969e43
Date: 2014-11-18 18:09 +0100
http://bitbucket.org/cffi/creflect/changeset/2120ff969e43/
Log: pass the remaining func tests
diff --git a/creflect/model.py b/creflect/model.py
--- a/creflect/model.py
+++ b/creflect/model.py
@@ -204,11 +204,11 @@
def inspect_type(self, block, inspect):
# this class overrides inspect_type() instead of
# inspect_nonconst_type(), to avoid the extra call to get_const_type()
+ inspect.flush()
+
if self.ellipsis:
return self.inspect_type_ellipsis(block, inspect)
- inspect.flush()
-
if (isinstance(inspect, TypeInspector) and inspect.started and
inspect.levels == ['*']): # common case
decl = '%s f' % inspect.typename
@@ -231,14 +231,20 @@
return block.write_crx_type_var(expr)
def inspect_type_ellipsis(self, block, inspect):
- if not isinstance(inspect, TypeInspector):
- XXX
- else:
- star_p1 = inspect.fetch_star_p1()
- xxx
+ if isinstance(inspect, VarInspector):
+ decl = self.get_c_name("(*p1)")
+ block.writeline("%s = &%s; /* check that '%s' is a function with"
+ " exactly the given signature */" % (
+ decl, inspect.varname, inspect.varname))
+ block.writeline("(void)p1;")
+ t1, a2 = self._get_arg_ret_types(block)
+ expr = 'cb->get_ellipsis_function_type(cb, %s, %s, %d)' % (
+ t1, a2, len(self.args))
return block.write_crx_type_var(expr)
def shadow_global_var(self, top_level_block, fnname):
+ if self.ellipsis:
+ return 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)]
@@ -318,7 +324,7 @@
" constant */" % (inspect.varname,
inspect.varname))
else:
- decl = self.totype.get_c_name("(**p1)")
+ decl = self.get_c_name("*p1")
block.writeline("%s = &%s; /* check that '%s' is of type '%s'"
" */" % (decl, inspect.varname,
inspect.varname, self.get_c_name()))
diff --git a/test/codegen/func-002.c b/test/codegen/func-002.c
--- a/test/codegen/func-002.c
+++ b/test/codegen/func-002.c
@@ -11,11 +11,12 @@
{
crx_type_t *t1, *a2[1], *t3;
{
- int (*p1)(int, ...) = f; /* check that 'f' is a function with exactly the given signature */
+ int (*p1)(int, ...) = &f; /* check that 'f' is a function with exactly the given signature */
+ (void)p1;
t1 = cb->get_signed_type(cb, sizeof(int), "int");
a2[0] = t1;
t3 = cb->get_ellipsis_function_type(cb, t1, a2, 1);
- cb->define_var(cb, "f", t3, p1);
+ cb->define_var(cb, "f", t3, &f);
#expect VAR f: FUNC( int -> ... -> int )
}
}
diff --git a/test/codegen/glob-002d.c b/test/codegen/glob-002d.c
--- a/test/codegen/glob-002d.c
+++ b/test/codegen/glob-002d.c
@@ -6,7 +6,7 @@
{
crx_type_t *t1, *t2;
{
- int (**p1) = &someglob; /* check that 'someglob' is of type 'int *' */
+ int **p1 = &someglob; /* check that 'someglob' is of type 'int *' */
(void)p1;
t1 = cb->get_signed_type(cb, sizeof(int), "int");
t2 = cb->get_pointer_type(cb, t1);
More information about the pypy-commit
mailing list