[pypy-svn] r13207 - pypy/branch/translator-without-old-genc/c

arigo at codespeak.net arigo at codespeak.net
Thu Jun 9 00:34:26 CEST 2005


Author: arigo
Date: Thu Jun  9 00:34:24 2005
New Revision: 13207

Modified:
   pypy/branch/translator-without-old-genc/c/node.py
Log:
Ignore 'void' fields in structures.


Modified: pypy/branch/translator-without-old-genc/c/node.py
==============================================================================
--- pypy/branch/translator-without-old-genc/c/node.py	(original)
+++ pypy/branch/translator-without-old-genc/c/node.py	Thu Jun  9 00:34:24 2005
@@ -1,9 +1,10 @@
 from __future__ import generators
 from pypy.rpython.lltype import Struct, Array, FuncType, PyObjectType, typeOf
 from pypy.rpython.lltype import GcStruct, GcArray, GC_CONTAINER, ContainerType
-from pypy.rpython.lltype import parentlink, Ptr, PyObject
+from pypy.rpython.lltype import parentlink, Ptr, PyObject, Void
 from pypy.translator.c.funcgen import FunctionCodeGenerator
 from pypy.translator.c.support import cdecl, somelettersfrom
+from pypy.translator.c.primitive import PrimitiveType
 
 
 def needs_refcount(T):
@@ -76,7 +77,10 @@
             if needs_refcount(self.STRUCT):
                 yield '\tlong refcount;'
             for name, typename in self.fields:
-                yield '\t%s;' % cdecl(typename, name)
+                line = '%s;' % cdecl(typename, name)
+                if typename == PrimitiveType[Void]:
+                    line = '/* %s */' % line
+                yield '\t' + line
             yield '};'
         elif phase == 2 and self.deallocator:
             yield 'void %s(struct %s *p) {' % (self.deallocator, self.name)
@@ -243,6 +247,7 @@
                 expr = '\n'.join(node.initializationexpr(prefix+name+'.'))
                 expr += ','
             else:
+                comma = ','
                 if typeOf(value) == Ptr(PyObject) and value:
                     # cannot just write 'gxxx' as a constant in a structure :-(
                     node = self.db.getcontainernode(value._obj)
@@ -251,9 +256,12 @@
                     node.where_to_copy_me.append('&%s.%s' % (self.name, c_name))
                 else:
                     expr = self.db.get(value)
+                    if typeOf(value) == Void:
+                        comma = ''
                 i = expr.find('\n')
                 if i<0: i = len(expr)
-                expr = '%s,\t/* %s%s */%s' % (expr[:i], prefix, name, expr[i:])
+                expr = '%s%s\t/* %s%s */%s' % (expr[:i], comma,
+                                               prefix, name, expr[i:])
             expr = expr.replace('\n', '\n\t')      # indentation
             yield '\t%s' % expr
         yield '}'



More information about the Pypy-commit mailing list