source: tests/poly-o-cycle.cfa

Last change on this file was fd54fef, checked in by Michael Brooks <mlbrooks@…>, 3 years ago

Converting the project to use the new syntax for otype, dtype and ttytpe.

Changed prelude (gen), libcfa and test suite to use it. Added a simple deprecation rule of the old syntax to the parser; we might wish to support both syntaxes "officially," like with an extra CLI switch, but this measure should serve as a simple reminder for our team to try the new syntax.

  • Property mode set to 100644
File size: 436 bytes
RevLine 
[91131689]1// Check that a cycle of polymorphic otype structures can be instancated.
[3f06c05]2
[fd54fef]3forall(T)
[3f06c05]4struct func_table;
5
[fd54fef]6forall(U)
[3f06c05]7struct object {
8        func_table(U) * virtual_table;
9};
10
[fd54fef]11forall(T)
[3f06c05]12struct func_table {
13        void (*object_func)(object(T) *);
14};
15
16void func(object(int) *) {
17        printf("Success!\n");
18}
19
20func_table(int) an_instance = { func };
21
22int main(int argc, char * argv[]) {
23        object(int) x = { 0p };
24        an_instance.object_func( &x );
25        return 0;
26}
Note: See TracBrowser for help on using the repository browser.