[pypy-commit] cffi default: partial unions: not supported

arigo noreply at buildbot.pypy.org
Tue Jun 26 11:03:56 CEST 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r520:59540f119bdd
Date: 2012-06-26 11:03 +0200
http://bitbucket.org/cffi/cffi/changeset/59540f119bdd/

Log:	partial unions: not supported

diff --git a/cffi/cparser.py b/cffi/cparser.py
--- a/cffi/cparser.py
+++ b/cffi/cparser.py
@@ -320,7 +320,7 @@
                 # XXX pycparser is inconsistent: 'names' should be a list
                 # of strings, but is sometimes just one string.  Use
                 # str.join() as a way to cope with both.
-                tp.partial = True
+                self._make_partial(tp)
                 continue
             if decl.bitsize is None:
                 bitsize = -1
@@ -329,17 +329,22 @@
             self._partial_length = False
             type = self._get_type(decl.type, partial_length_ok=True)
             if self._partial_length:
-                tp.partial = True
+                self._make_partial(tp)
             fldnames.append(decl.name)
             fldtypes.append(type)
             fldbitsize.append(bitsize)
-        if tp.partial and not tp.has_c_name():
-            raise api.CDefError("%s is partial but has no C name" % (tp,))
         tp.fldnames = tuple(fldnames)
         tp.fldtypes = tuple(fldtypes)
         tp.fldbitsize = tuple(fldbitsize)
         return tp
 
+    def _make_partial(self, tp):
+        if not isinstance(tp, model.StructType):
+            raise api.CDefError("%s cannot be partial" % (tp,))
+        if not tp.has_c_name():
+            raise api.CDefError("%s is partial but has no C name" % (tp,))
+        tp.partial = True
+
     def _parse_constant(self, exprnode, partial_length_ok=False):
         # for now, limited to expressions that are an immediate number
         # or negative number


More information about the pypy-commit mailing list