[pypy-svn] r31385 - in pypy/dist/pypy: rpython translator/c

ac at codespeak.net ac at codespeak.net
Thu Aug 17 23:06:50 CEST 2006


Author: ac
Date: Thu Aug 17 23:06:49 2006
New Revision: 31385

Modified:
   pypy/dist/pypy/rpython/rcpy.py
   pypy/dist/pypy/translator/c/node.py
Log:
Support typedef defined external structs/unions.

Modified: pypy/dist/pypy/rpython/rcpy.py
==============================================================================
--- pypy/dist/pypy/rpython/rcpy.py	(original)
+++ pypy/dist/pypy/rpython/rcpy.py	Thu Aug 17 23:06:49 2006
@@ -152,14 +152,11 @@
 
 PyObjPtr = lltype.Ptr(lltype.PyObject)
 PyNumberMethods = lltype.Struct('PyNumberMethods',
-    ('data', lltype.FixedSizeArray(lltype.Signed, 38))
-)
+    hints={'c_name': 'PyNumberMethods', 'external': True, 'typedef': True})
 PyMappingMethods = lltype.Struct('PyMappingMethods',
-    ('data', lltype.FixedSizeArray(lltype.Signed, 3))
-)
+    hints={'c_name': 'PyMappingMethods', 'external': True, 'typedef': True})
 PySequenceMethods = lltype.Struct('PySequenceMethods',
-    ('data', lltype.FixedSizeArray(lltype.Signed, 10))
-)
+    hints={'c_name': 'PySequenceMethods', 'external': True, 'typedef': True})
 PY_TYPE_OBJECT = lltype.PyForwardReference()
 PY_TYPE_OBJECT.become(lltype.PyStruct(
     'PyTypeObject',
@@ -213,7 +210,7 @@
                        #lltype.Ptr(lltype.FuncType([llmemory.Address],
                        #                           lltype.Void))),
 
-    hints={'c_name': '_typeobject', 'external': True, 'inline_head': True}))
+    hints={'c_name': 'PyTypeObject', 'external': True, 'typedef': True, 'inline_head': True}))
 # XXX 'c_name' should be 'PyTypeObject' but genc inserts 'struct' :-(
 
 def ll_tp_dealloc(p):

Modified: pypy/dist/pypy/translator/c/node.py
==============================================================================
--- pypy/dist/pypy/translator/c/node.py	(original)
+++ pypy/dist/pypy/translator/c/node.py	Thu Aug 17 23:06:49 2006
@@ -52,6 +52,9 @@
         if STRUCT._hints.get('union'):
             self.typetag = 'union'
             assert STRUCT._gckind == 'raw'   # not supported: "GcUnion"
+        if STRUCT._hints.get('typedef'):
+            self.typetag = ''
+            assert STRUCT._hints.get('external')
         if STRUCT._hints.get('c_name'):
             self.barename = self.name = STRUCT._hints['c_name']
             self.c_struct_field_name = self.verbatim_field_name



More information about the Pypy-commit mailing list