[pypy-commit] cffi cffi-1.0: FILE in the recompiler

arigo noreply at buildbot.pypy.org
Sun Apr 26 15:59:38 CEST 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1847:1e0789c75797
Date: 2015-04-26 15:56 +0200
http://bitbucket.org/cffi/cffi/changeset/1e0789c75797/

Log:	FILE in the recompiler

diff --git a/_cffi1/realize_c_type.c b/_cffi1/realize_c_type.c
--- a/_cffi1/realize_c_type.c
+++ b/_cffi1/realize_c_type.c
@@ -409,6 +409,9 @@
             _realize_name(name,
                           (s->flags & _CFFI_F_UNION) ? "union " : "struct ",
                           s->name);
+            if (strcmp(name, "struct _IO_FILE") == 0)
+                flags |= CT_IS_FILE;
+
             x = new_struct_or_union_type(name, flags);
 
             CTypeDescrObject *ct = NULL;
diff --git a/_cffi1/recompiler.py b/_cffi1/recompiler.py
--- a/_cffi1/recompiler.py
+++ b/_cffi1/recompiler.py
@@ -308,10 +308,13 @@
     def _generate_cpy_typedef_decl(self, tp, name):
         pass
 
-    def _generate_cpy_typedef_ctx(self, tp, name):
+    def _typedef_ctx(self, tp, name):
         type_index = self._typesdict[tp]
         self._lsts["typename"].append(
             '  { "%s", %d },' % (name, type_index))
+
+    def _generate_cpy_typedef_ctx(self, tp, name):
+        self._typedef_ctx(tp, name)
         if getattr(tp, "origin", None) == "unknown_type":
             self._struct_ctx(tp, tp.name, approxname=None)
         elif isinstance(tp, model.NamedPointerType):
@@ -521,8 +524,15 @@
                     raise NotImplementedError("internal inconsistency: %r is "
                                               "partial but was not seen at "
                                               "this point" % (tp,))
-                assert tp.name.startswith('$') and tp.name[1:].isdigit()
-                self._struct_ctx(tp, None, tp.name[1:])
+                if tp.name.startswith('$') and tp.name[1:].isdigit():
+                    approxname = tp.name[1:]
+                elif tp.name == '_IO_FILE' and tp.forcename == 'FILE':
+                    approxname = 'FILE'
+                    self._typedef_ctx(tp, 'FILE')
+                else:
+                    raise NotImplementedError("internal inconsistency: %r" %
+                                              (tp,))
+                self._struct_ctx(tp, None, approxname)
 
     def _fix_final_field_list(self, lst):
         count = 0


More information about the pypy-commit mailing list