[pypy-commit] creflect default: Declare opaque structs

arigo noreply at buildbot.pypy.org
Sat Dec 6 21:40:20 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r191:1471bfadbc0f
Date: 2014-12-06 20:25 +0100
http://bitbucket.org/cffi/creflect/changeset/1471bfadbc0f/

Log:	Declare opaque structs

diff --git a/creflect/model.py b/creflect/model.py
--- a/creflect/model.py
+++ b/creflect/model.py
@@ -659,6 +659,8 @@
         self.fldbitsize = None
 
     def write_declaration(self, funcblock):
+        if self.fldnames is None:
+            return     # opaque
         tp = "%s %s" % (self.type.kind, self.type.name)
         if not self.type.name.startswith('$'):
             realtp = tp
diff --git a/creflect/test/codegen/struct-007.c b/creflect/test/codegen/struct-007.c
new file mode 100644
--- /dev/null
+++ b/creflect/test/codegen/struct-007.c
@@ -0,0 +1,13 @@
+typedef struct mystruct_s foo_t;
+
+# ____________________________________________________________
+
+void teststruct_007(_crx_builder_t *cb)
+{
+    _crx_type_t *t1;
+    {
+        t1 = cb->get_struct_type(cb, "mystruct_s");
+        cb->define_type(cb, "foo_t", t1, 0);
+#expect TYPEDEF foo_t = STRUCT mystruct_s
+    }
+}


More information about the pypy-commit mailing list