Author: Ronan Lamy <[email protected]>
Branch: rffi-parser
Changeset: r89127:69eba1948840
Date: 2016-12-18 01:16 +0000
http://bitbucket.org/pypy/pypy/changeset/69eba1948840/
Log: pointers to DelayedStruct
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
@@ -661,12 +661,13 @@
return CNAME_TO_LLTYPE[name]
class DelayedStruct(object):
- def __init__(self, name, fields):
+ def __init__(self, name, fields, TYPE):
self.struct_name = name
self.fields = fields
+ self.TYPE = TYPE
def __repr__(self):
- return "<struct {struct_name}>".format(vars(self))
+ return "<struct {struct_name}>".format(**vars(self))
class ParsedSource(object):
@@ -695,12 +696,12 @@
def new_struct(self, obj):
if obj.fldtypes is None:
- return lltype.ForwardReference()
+ fields = None
else:
fields = zip(
obj.fldnames,
[self.convert_type(field) for field in obj.fldtypes])
- return DelayedStruct(obj.name, fields)
+ return DelayedStruct(obj.name, fields, lltype.ForwardReference())
def realize_struct(self, struct, type_name):
from pypy.module.cpyext.api import CConfig, TYPES
@@ -729,6 +730,8 @@
TO = self.convert_type(obj.totype)
if TO is lltype.Void:
return rffi.VOIDP
+ elif isinstance(TO, DelayedStruct):
+ TO = TO.TYPE
return lltype.Ptr(TO)
elif isinstance(obj, model.FunctionPtrType):
if obj.ellipsis:
diff --git a/pypy/module/cpyext/typeobjectdefs.py
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -31,6 +31,7 @@
initproc = P(FT([PyO, PyO, PyO], rffi.INT_real))
newfunc = P(FT([PyTypeObjectPtr, PyO, PyO], PyO))
allocfunc = P(FT([PyTypeObjectPtr, Py_ssize_t], PyO))
+
unaryfunc = P(FT([PyO], PyO))
binaryfunc = P(FT([PyO, PyO], PyO))
ternaryfunc = P(FT([PyO, PyO, PyO], PyO))
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit