source: doc/proposals/modules-gen-hdr/coop/chicken.src.c

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

Add POC illustrating generating headers from compile units

  • Property mode set to 100644
File size: 585 bytes
RevLine 
[b28ce93]1#import auto & egg
2
3
4//# @
5struct chicken {
6 struct egg * hatchedFrom;
7};
8
9//# $f
10void ctor_chicken( struct chicken * this, struct egg * hatchedFrom ) { // probably autogen
11 this->hatchedFrom = hatchedFrom; // ctor_pointer$
12}
13
14//# $f
15void live( struct chicken * this ) {
16 int printf( const char *, ... ); // scaffold
17 void exit( int );
18
19 // scaffold
20 static int calls = 0;
21 if ((calls += 1) > 10) exit(0);
22
23 printf( "chicken %p hatched from egg %p\n", this, this->hatchedFrom );
24 struct egg laid; // not a pointer
25 ctor_egg( & laid, this );
26 hatch( & laid );
27}
Note: See TracBrowser for help on using the repository browser.