[pypy-commit] creflect default: fixes

arigo noreply at buildbot.pypy.org
Mon Nov 17 22:45:03 CET 2014


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r56:7911f7d90ae1
Date: 2014-11-17 22:45 +0100
http://bitbucket.org/cffi/creflect/changeset/7911f7d90ae1/

Log:	fixes

diff --git a/test/codegen/005d.c b/test/codegen/005d.c
--- a/test/codegen/005d.c
+++ b/test/codegen/005d.c
@@ -2,15 +2,12 @@
 
 # ____________________________________________________________
 
-int test005d(char *r)
+void test005d(crx_builder_t *cb)
 {
-    int r1 = 0;
-    if (!r)
-        return 57 + 59 + 64 + 68 + 8 + 18 + 120;
+    crx_type_t *t1, *t2, *t3, *t4, *t5, *t6, *t7, *t8, *t9, *t10;
     {
         foo_t *p1;
         char *p4;
-        char *r0 = r;
         char *p5;
         char *p6;
         char *p9;
@@ -18,69 +15,39 @@
         char b[sizeof(**********p1)];  /* check that '**(***foo_t[][])[][]' is a valid type */
         p1 = (void *)&p4;
         if ((void *)p1 != (void *)*p1) {
-            r = r0;
-            r += sprintf(r, "#error type 'foo_t' is not an array, but a pointer type\n");
-            r1 = -1;
-            goto f2;
+            cb->error(cb, "type 'foo_t' is not an array, but a pointer type");
+            return;
         }
         if ((void *)*p1 != (void *)**p1) {
-            r = r0;
-            r += sprintf(r, "#error type 'foo_t[]' is not an array, but a pointer type\n");
-            r1 = -1;
-            goto f2;
+            cb->error(cb, "type 'foo_t[]' is not an array, but a pointer type");
+            return;
         }
         ***p1 = (void *)&p5;  /* check that 'foo_t[][]' is a pointer type */
         ****p1 = (void *)&p6;  /* check that '*foo_t[][]' is a pointer type */
         *****p1 = (void *)&p9;  /* check that '**foo_t[][]' is a pointer type */
         if ((void *)*****p1 != (void *)******p1) {
-            r = r0;
-            r += sprintf(r, "#error type '***foo_t[][]' is not an array, but a pointer type\n");
-            r1 = -1;
-            goto f2;
+            cb->error(cb, "type '***foo_t[][]' is not an array, but a pointer type");
+            return;
         }
         if ((void *)******p1 != (void *)*******p1) {
-            r = r0;
-            r += sprintf(r, "#error type '(***foo_t[][])[]' is not an array, but a pointer type\n");
-            r1 = -1;
-            goto f2;
+            cb->error(cb, "type '(***foo_t[][])[]' is not an array, but a pointer type");
+            return;
         }
         ********p1 = (void *)&p10;  /* check that '(***foo_t[][])[][]' is a pointer type */
         *********p1 = (void *)b;    /* check that '*(***foo_t[][])[][]' is a pointer type */
         (void)(**********p1 << 1);  /* check that '**(***foo_t[][])[][]' is an integer type */
-        r += sprintf(r, "typedef ");
         **********p1 = -1;  /* check that '**(***foo_t[][])[][]' is not declared 'const' */
-        if (**********p1 > 0) {
-            if (sizeof(**********p1) == 1 && **********p1 == 1)
-                r += sprintf(r, "_Bool");
-            else if (sizeof(**********p1) == sizeof(unsigned int))
-                r += sprintf(r, "unsigned int");
-            else if (sizeof(**********p1) == sizeof(unsigned short))
-                r += sprintf(r, "unsigned short");
-            else if (sizeof(**********p1) == sizeof(unsigned char))
-                r += sprintf(r, "unsigned char");
-            else if (sizeof(**********p1) == sizeof(unsigned long))
-                r += sprintf(r, "unsigned long");
-            else if (sizeof(**********p1) == sizeof(unsigned long long))
-                r += sprintf(r, "unsigned long long");
-            else
-                r += sprintf(r, "uint%u_t", (int)sizeof(**********p1) * 8);
-        }
-        else {
-            if (sizeof(**********p1) == sizeof(int))
-                r += sprintf(r, "int");
-            else if (sizeof(**********p1) == sizeof(short))
-                r += sprintf(r, "short");
-            else if (sizeof(**********p1) == sizeof(signed char))
-                r += sprintf(r, "signed char");
-            else if (sizeof(**********p1) == sizeof(long))
-                r += sprintf(r, "long");
-            else if (sizeof(**********p1) == sizeof(long long))
-                r += sprintf(r, "long long");
-            else
-                r += sprintf(r, "int%u_t", (int)sizeof(**********p1) * 8);
-        }
-        r += sprintf(r, " **(***foo_t[%lld][%lld])[%lld][%lld];\n", (long long)(sizeof(*p1) / sizeof(**p1)), (long long)(sizeof(**p1) / sizeof(***p1)), (long long)(sizeof(******p1) / sizeof(*******p1)), (long long)(sizeof(*******p1) / sizeof(********p1)));
-        f2:;
+        t1 = CRX_INT_TYPE(cb, **********p1, "int");
+        t2 = cb->get_pointer_type(cb, t1);
+        t3 = cb->get_pointer_type(cb, t2);
+        t4 = cb->get_array_type(cb, t3, sizeof(*******p1) / sizeof(********p1));
+        t5 = cb->get_array_type(cb, t4, sizeof(******p1) / sizeof(*******p1));
+        t6 = cb->get_pointer_type(cb, t5);
+        t7 = cb->get_pointer_type(cb, t6);
+        t8 = cb->get_pointer_type(cb, t7);
+        t9 = cb->get_array_type(cb, t8, sizeof(**p1) / sizeof(***p1));
+        t10 = cb->get_array_type(cb, t9, sizeof(*p1) / sizeof(**p1));
+        cb->define_type(cb, "foo_t", t10);
+#expect TYPEDEF foo_t = ARRAY[4] ARRAY[3] PTR PTR PTR ARRAY[27] ARRAY[91] PTR PTR int
     }
-    return r1;
 }
diff --git a/test/codegen/005e.c b/test/codegen/005e.c
deleted file mode 100644
--- a/test/codegen/005e.c
+++ /dev/null
@@ -1,106 +0,0 @@
-typedef int foo_t[55];
-typedef int bar_t[66];
-
-# ____________________________________________________________
-
-int test005e(char *r)
-{
-    int r1 = 0;
-    if (!r)
-        return 57 + 8 + 18 + 35 + 57 + 8 + 18 + 35;
-    {
-        foo_t *p1;
-        char b[sizeof(**p1)];  /* check that 'foo_t[]' is a valid type */
-        char *r0 = r;
-        p1 = (void *)b;
-        if ((void *)p1 != (void *)*p1) {
-            r = r0;
-            r += sprintf(r, "#error type 'foo_t' is not an array, but a pointer type\n");
-            r1 = -1;
-            goto f2;
-        }
-        (void)(**p1 << 1);  /* check that 'foo_t[]' is an integer type */
-        r += sprintf(r, "typedef ");
-        **p1 = -1;  /* check that 'foo_t[]' is not declared 'const' */
-        if (**p1 > 0) {
-            if (sizeof(**p1) == 1 && **p1 == 1)
-                r += sprintf(r, "_Bool");
-            else if (sizeof(**p1) == sizeof(unsigned int))
-                r += sprintf(r, "unsigned int");
-            else if (sizeof(**p1) == sizeof(unsigned short))
-                r += sprintf(r, "unsigned short");
-            else if (sizeof(**p1) == sizeof(unsigned char))
-                r += sprintf(r, "unsigned char");
-            else if (sizeof(**p1) == sizeof(unsigned long))
-                r += sprintf(r, "unsigned long");
-            else if (sizeof(**p1) == sizeof(unsigned long long))
-                r += sprintf(r, "unsigned long long");
-            else
-                r += sprintf(r, "uint%u_t", (int)sizeof(**p1) * 8);
-        }
-        else {
-            if (sizeof(**p1) == sizeof(int))
-                r += sprintf(r, "int");
-            else if (sizeof(**p1) == sizeof(short))
-                r += sprintf(r, "short");
-            else if (sizeof(**p1) == sizeof(signed char))
-                r += sprintf(r, "signed char");
-            else if (sizeof(**p1) == sizeof(long))
-                r += sprintf(r, "long");
-            else if (sizeof(**p1) == sizeof(long long))
-                r += sprintf(r, "long long");
-            else
-                r += sprintf(r, "int%u_t", (int)sizeof(**p1) * 8);
-        }
-        r += sprintf(r, " foo_t[%lld];\n", (long long)(sizeof(*p1) / sizeof(**p1)));
-        f2:;
-    }
-    {
-        bar_t *p1;
-        char b[sizeof(**p1)];  /* check that 'bar_t[]' is a valid type */
-        char *r0 = r;
-        p1 = (void *)b;
-        if ((void *)p1 != (void *)*p1) {
-            r = r0;
-            r += sprintf(r, "#error type 'bar_t' is not an array, but a pointer type\n");
-            r1 = -1;
-            goto f3;
-        }
-        (void)(**p1 << 1);  /* check that 'bar_t[]' is an integer type */
-        r += sprintf(r, "typedef ");
-        **p1 = -1;  /* check that 'bar_t[]' is not declared 'const' */
-        if (**p1 > 0) {
-            if (sizeof(**p1) == 1 && **p1 == 1)
-                r += sprintf(r, "_Bool");
-            else if (sizeof(**p1) == sizeof(unsigned int))
-                r += sprintf(r, "unsigned int");
-            else if (sizeof(**p1) == sizeof(unsigned short))
-                r += sprintf(r, "unsigned short");
-            else if (sizeof(**p1) == sizeof(unsigned char))
-                r += sprintf(r, "unsigned char");
-            else if (sizeof(**p1) == sizeof(unsigned long))
-                r += sprintf(r, "unsigned long");
-            else if (sizeof(**p1) == sizeof(unsigned long long))
-                r += sprintf(r, "unsigned long long");
-            else
-                r += sprintf(r, "uint%u_t", (int)sizeof(**p1) * 8);
-        }
-        else {
-            if (sizeof(**p1) == sizeof(int))
-                r += sprintf(r, "int");
-            else if (sizeof(**p1) == sizeof(short))
-                r += sprintf(r, "short");
-            else if (sizeof(**p1) == sizeof(signed char))
-                r += sprintf(r, "signed char");
-            else if (sizeof(**p1) == sizeof(long))
-                r += sprintf(r, "long");
-            else if (sizeof(**p1) == sizeof(long long))
-                r += sprintf(r, "long long");
-            else
-                r += sprintf(r, "int%u_t", (int)sizeof(**p1) * 8);
-        }
-        r += sprintf(r, " bar_t[%lld];\n", (long long)(sizeof(*p1) / sizeof(**p1)));
-        f3:;
-    }
-    return r1;
-}


More information about the pypy-commit mailing list