[pypy-commit] creflect default: next test
arigo
noreply at buildbot.pypy.org
Tue Nov 18 19:06:52 CET 2014
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r81:08ca9b65dbb0
Date: 2014-11-18 19:07 +0100
http://bitbucket.org/cffi/creflect/changeset/08ca9b65dbb0/
Log: next test
diff --git a/test/codegen/struct-001b.c b/test/codegen/struct-001b.c
--- a/test/codegen/struct-001b.c
+++ b/test/codegen/struct-001b.c
@@ -1,56 +1,32 @@
-struct foo_s /*4,4*/{
- /*0*/const int aa;
+struct foo_s {
+ const int aa;
};
# ____________________________________________________________
-#include <string.h>
-int teststruct_001b(char *r)
+void teststruct_001b(crx_builder_t *cb)
{
- if (!r)
- return 100;
- r += sprintf(r, "struct foo_s /*%lld,%lld*/{\n", (long long)sizeof(struct foo_s), (long long)(((char *)&((struct{char a; struct foo_s b;} *)0)->b) - (char *)0));
+ crx_type_t *t1, *t2, *t3;
+ crx_field_t d1[1];
+ t1 = cb->get_struct_type(cb, "foo_s");
{
struct foo_s *p1;
- long long o = ((char *)&((struct foo_s *)0)->aa) - (char *)0; /* check that 'struct foo_s::aa' is not an array */
+ size_t o = ((char *)&((struct foo_s *)0)->aa) - (char *)0; /* check that 'struct foo_s::aa' is not an array */
char b[sizeof(p1->aa)];
memset(b, -1, sizeof(b));
- r += sprintf(r, " /*%lld*/", o);
p1 = (void *)(((char *)b) - o);
(void)(p1->aa << 1); /* check that 'struct foo_s::aa' is an integer type */
- r += sprintf(r, "const ");
- if (p1->aa > 0) {
- if (sizeof(p1->aa) == 1 && p1->aa == 1)
- r += sprintf(r, "_Bool");
- else if (sizeof(p1->aa) == sizeof(unsigned int))
- r += sprintf(r, "unsigned int");
- else if (sizeof(p1->aa) == sizeof(unsigned short))
- r += sprintf(r, "unsigned short");
- else if (sizeof(p1->aa) == sizeof(unsigned char))
- r += sprintf(r, "unsigned char");
- else if (sizeof(p1->aa) == sizeof(unsigned long))
- r += sprintf(r, "unsigned long");
- else if (sizeof(p1->aa) == sizeof(unsigned long long))
- r += sprintf(r, "unsigned long long");
- else
- r += sprintf(r, "uint%u_t", (int)sizeof(p1->aa) * 8);
- }
- else {
- if (sizeof(p1->aa) == sizeof(int))
- r += sprintf(r, "int");
- else if (sizeof(p1->aa) == sizeof(short))
- r += sprintf(r, "short");
- else if (sizeof(p1->aa) == sizeof(signed char))
- r += sprintf(r, "signed char");
- else if (sizeof(p1->aa) == sizeof(long))
- r += sprintf(r, "long");
- else if (sizeof(p1->aa) == sizeof(long long))
- r += sprintf(r, "long long");
- else
- r += sprintf(r, "int%u_t", (int)sizeof(p1->aa) * 8);
- }
- r += sprintf(r, " aa;\n");
+ t2 = CRX_INT_TYPE(cb, p1->aa, "int");
+ t3 = cb->get_const_type(cb, t2);
+ d1[0].name = "aa";
+ d1[0].type = t3;
+ d1[0].offset = o;
+ d1[0].numbits = -1;
+ d1[0].bitshift = -1;
}
- r += sprintf(r, "};\n");
- return 0;
+ cb->complete(cb, t1, sizeof(struct foo_s),
+ ((char *)&((struct{char a; struct foo_s b;} *)0)->b) - (char *)0,
+ d1, 1);
+#expect STRUCT foo_s:
+#expect | aa: CONST int
}
More information about the pypy-commit
mailing list