Author: Armin Rigo <[email protected]>
Branch:
Changeset: r65:f27c87f990ac
Date: 2014-11-18 00:58 +0100
http://bitbucket.org/cffi/creflect/changeset/f27c87f990ac/
Log: Pass the next test
diff --git a/test/codegen/func-001b.c b/test/codegen/func-001b.c
--- a/test/codegen/func-001b.c
+++ b/test/codegen/func-001b.c
@@ -1,46 +1,63 @@
-unsigned int f(long long);
+unsigned int f(long);
long g(int, int);
long h(int, int);
# ____________________________________________________________
-unsigned int f(long long a) { return (unsigned int)(a / 1291); }
+unsigned int f(long a) { return (unsigned int)(a / 1291); }
long g(int a, int b) { return b - a; }
long h(int a, int b) { return b * (long)a; }
# ____________________________________________________________
-static void __creflect_t1(void *func, void *args[], void *result) {
- unsigned int(*f)(long long) = func;
- *(unsigned int *)result = f(*(long long *)args[0]);
+static void testfunc_001b__c_f(void *func, void *args[], void *result) {
+ *(unsigned int *)result = f(*(long *)args[0]);
}
-static unsigned int __creflect_d_f(long long a0) {
+static unsigned int testfunc_001b__d_f(long a0) {
return f(a0);
}
-static void __creflect_t2(void *func, void *args[], void *result) {
- long(*f)(int, int) = func;
- *(long *)result = f(*(int *)args[0], *(int *)args[1]);
+static void testfunc_001b__c_g(void *func, void *args[], void *result) {
+ *(long *)result = g(*(int *)args[0], *(int *)args[1]);
}
-static long __creflect_d_g(int a0, int a1) {
+static long testfunc_001b__d_g(int a0, int a1) {
return g(a0, a1);
}
-static long __creflect_d_h(int a0, int a1) {
+static void testfunc_001b__c_h(void *func, void *args[], void *result) {
+ *(long *)result = h(*(int *)args[0], *(int *)args[1]);
+}
+
+static long testfunc_001b__d_h(int a0, int a1) {
return h(a0, a1);
}
-int testfunc_002(char *r)
+void testfunc_001b(crx_builder_t *cb)
{
- if (!r)
- return 3 + 999 + 1;
- r += sprintf(r, "unsigned int");
- r += sprintf(r, " /*%p*/f(long long)/*%p*/;\n", &__creflect_d_f,
&__creflect_t1);
- r += sprintf(r, "long");
- r += sprintf(r, " /*%p*/g(int, int)/*%p*/;\n", &__creflect_d_g,
&__creflect_t2);
- r += sprintf(r, "long");
- r += sprintf(r, " /*%p*/h(int, int)/*%p*/;\n", &__creflect_d_h,
&__creflect_t2);
- return 0;
+ crx_type_t *t1, *t2, *a3[1], *t4, *t5, *a6[2], *t7, *a8[2], *t9;
+ {
+ t1 = cb->get_unsigned_type(cb, sizeof(unsigned int), "unsigned int");
+ t2 = cb->get_signed_type(cb, sizeof(long), "long");
+ a3[0] = t2;
+ t4 = cb->get_function_type(cb, t1, a3, 1, &testfunc_001b__c_f);
+ cb->define_var(cb, "f", t4, &testfunc_001b__d_f);
+#expect VAR f: FUNC( long -> unsigned int )
+ }
+ {
+ t5 = cb->get_signed_type(cb, sizeof(int), "int");
+ a6[0] = t5;
+ a6[1] = t5;
+ t7 = cb->get_function_type(cb, t2, a6, 2, &testfunc_001b__c_g);
+ cb->define_var(cb, "g", t7, &testfunc_001b__d_g);
+#expect VAR g: FUNC( int -> int -> long )
+ }
+ {
+ a8[0] = t5;
+ a8[1] = t5;
+ t9 = cb->get_function_type(cb, t2, a8, 2, &testfunc_001b__c_h);
+ cb->define_var(cb, "h", t9, &testfunc_001b__d_h);
+#expect VAR h: FUNC( int -> int -> long )
+ }
}
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit