[pypy-commit] pypy hpy: Fix cparser issue with struct types appearing in function arguments
rlamy
pypy.commits at gmail.com
Sat Nov 16 08:15:09 EST 2019
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: hpy
Changeset: r98071:e2a687fd8ab3
Date: 2019-11-16 14:13 +0100
http://bitbucket.org/pypy/pypy/changeset/e2a687fd8ab3/
Log: Fix cparser issue with struct types appearing in function arguments
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -732,6 +732,7 @@
if tp.type_name is None:
tp.type_name = name
tp = self.realize_struct(tp)
+ self.structs[obj.realtype] = tp
self.definitions[name] = tp
def add_macro(self, name, value):
diff --git a/pypy/module/cpyext/test/test_cparser.py b/pypy/module/cpyext/test/test_cparser.py
--- a/pypy/module/cpyext/test/test_cparser.py
+++ b/pypy/module/cpyext/test/test_cparser.py
@@ -204,6 +204,16 @@
assert func_decl.get_llresult(cts) == cts.gettype('func_t*')
assert func_decl.get_llargs(cts) == [cts.gettype('TestFloatObject *')]
+def test_struct_in_func_args():
+ decl = """
+ typedef struct {int x;} obj;
+ typedef int (*func)(obj x);
+ """
+ cts = parse_source(decl)
+ OBJ = cts.gettype('obj')
+ FUNCPTR = cts.gettype('func')
+ assert FUNCPTR.TO.ARGS == (OBJ,)
+
def test_write_func():
from ..api import ApiFunction
from rpython.translator.c.database import LowLevelDatabase
@@ -231,7 +241,6 @@
obj.c_x = lltype.nullptr(rffi.CWCHARP.TO)
lltype.free(obj, flavor='raw')
-
def test_translate_cast():
cdef = "typedef ssize_t Py_ssize_t;"
cts = parse_source(cdef)
More information about the pypy-commit
mailing list