# HG changeset patch # User Nobuyasu Oshiro # Date 1339673424 -32400 # Node ID 7ad14f4461359cc36969ecd237f979112edb96a7 # Parent a3a2f64cf8f4ca387af7a7b3558e40ac1246ba77 add CbC-example/rectypeTest/ diff -r a3a2f64cf8f4 -r 7ad14f446135 CbC-examples/rectypeTest/struct2.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CbC-examples/rectypeTest/struct2.cbc Thu Jun 14 20:30:24 2012 +0900 @@ -0,0 +1,33 @@ + +struct interface { + __code (*next)(); + __rectype child; + // __rectype *child; + // struct interface *child; +}; + +#include +__code csA() +{ + printf("csA\n"); +} + +__code csB() +{ + printf("csB\n"); +} + +int main() +{ + struct interface p; + p.next = csA; + + struct interface pp; + pp.next = csB; + p.child = &pp; + + // goto p.child->next(); + goto p.child->next(); + + return 0; +} diff -r a3a2f64cf8f4 -r 7ad14f446135 CbC-examples/rectypeTest/typedef2.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CbC-examples/rectypeTest/typedef2.cbc Thu Jun 14 20:30:24 2012 +0900 @@ -0,0 +1,24 @@ +typedef __code (*csPtr)(__rectype); + +//typedef __code (*csPtr)(__code(*p)()); +//typedef __code (csPtr)(__code(*p)()); // csPtr *p + +#include +__code cs_end(csPtr p) +{ + printf("end\n"); +} + +__code cs(csPtr p) +{ + csPtr b; + goto p(b); + // goto p(3); // note: expected ‘void (*)()’ but argument is of type ‘int’ +} + +int main() { + csPtr p; + p = cs_end; + goto cs(p); + return 0; +} diff -r a3a2f64cf8f4 -r 7ad14f446135 CbC-examples/rectypeTest/typedef3.cbc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/CbC-examples/rectypeTest/typedef3.cbc Thu Jun 14 20:30:24 2012 +0900 @@ -0,0 +1,21 @@ +typedef __code (*csPtr)(__rectype*); + +#include +__code cs_end(csPtr *p) +{ + printf("end\n"); +} + +__code cs(csPtr p) +{ + csPtr *b; // <- This declaration please care. + goto p(b); + // goto p(3); // note: expected ‘void (**’ but argument is of type ‘int’ +} + +int main() { + csPtr p; + p = cs_end; + goto cs(p); + return 0; +}