[pypy-commit] pypy rffi-parser-2: pointers to DelayedStruct

rlamy pypy.commits at gmail.com
Mon Dec 26 09:59:11 EST 2016


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: rffi-parser-2
Changeset: r89227:c72102095ceb
Date: 2016-12-18 01:16 +0000
http://bitbucket.org/pypy/pypy/changeset/c72102095ceb/

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,9 +661,10 @@
     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))
@@ -702,10 +703,7 @@
         self.macros[name] = value
 
     def new_struct(self, obj):
-        if obj.fldtypes is None:
-            struct = lltype.ForwardReference()
-        else:
-            struct = DelayedStruct(obj.name, None)
+        struct = DelayedStruct(obj.name, None, lltype.ForwardReference())
         # Cache it early, to avoid infinite recursion
         self.structs[obj] = struct
         if obj.fldtypes is not None:
@@ -740,6 +738,8 @@
                 return rffi.VOIDP
             elif isinstance(obj.totype, model.PrimitiveType):
                 return rffi.CArrayPtr(TO)
+            elif isinstance(TO, DelayedStruct):
+                TO = TO.TYPE
             return lltype.Ptr(TO)
         elif isinstance(obj, model.FunctionPtrType):
             if obj.ellipsis:


More information about the pypy-commit mailing list