// Very simple code to understand how tlcc works #include #include #include #include #include #include using namespace std; #ifndef _TLMP_tlmpprogram #error TLMP module tlmpprogram unknown #endif #ifndef _F_tlmpprogram_init #error Unknown logical function init for module/class tlmpprogram #endif #ifndef _F_tlmpprogram_main #error Unknown logical function main for module/class tlmpprogram #endif #ifndef _TLMP_TCPSERVER #error TLMP class TCPSERVER unknown #endif #ifndef _F_TCPSERVER_newclient #error Unknown logical function newclient for module/class TCPSERVER #endif #ifndef _F_TCPSERVER_endclient #error Unknown logical function endclient for module/class TCPSERVER #endif #ifndef _F_TCPSERVER_receive #error Unknown logical function receive for module/class TCPSERVER #endif #line 11 "obj2.tlcc" int main (int argc, char *argv[]) { #line 15 "obj2.tlcc" struct __gl_tests_obj2_tlcc_GLOCAL1_1{ #line 14 "obj2.tlcc" int ret ; }; { // Inserted to support nested glocals __gl_tests_obj2_tlcc_GLOCAL1_1 B_glocal; #line 14 "obj2.tlcc" B_glocal.ret= -1; #line 15 "obj2.tlcc" class __sc_tests_obj2_tlcc1: public _F_tlmpprogram{ public: __gl_tests_obj2_tlcc_GLOCAL1_1 &glocal; __sc_tests_obj2_tlcc1 (__gl_tests_obj2_tlcc_GLOCAL1_1 &g) : glocal(g) { } _F_tlmpprogram_init( ) { #line 16 "obj2.tlcc" setproginfo ("obj2","0.0","..."); } // #line 18 "obj2.tlcc" _F_tlmpprogram_main( ) { #line 19 "obj2.tlcc" int ret = -1; struct HANDLE_INFO: public ARRAY_OBJ{ unsigned count = 0; }; struct __gl_tests_obj2_tlcc_GLOCAL1_2{ __gl_tests_obj2_tlcc_GLOCAL1_1 &glocal; _F_tlmpprogram &tlmpprogram; __gl_tests_obj2_tlcc_GLOCAL1_2(__gl_tests_obj2_tlcc_GLOCAL1_1 &gl,_F_tlmpprogram *_c) : glocal(gl),tlmpprogram(*_c) {} }; { // Inserted to support nested glocals __gl_tests_obj2_tlcc_GLOCAL1_2 B_glocal(this->glocal,this); class __sc_tests_obj2_tlcc2: public _F_TCPSERVER{ public: __gl_tests_obj2_tlcc_GLOCAL1_2 &glocal; __sc_tests_obj2_tlcc2 (__gl_tests_obj2_tlcc_GLOCAL1_2 &g) : glocal(g) { } _F_TCPSERVER_newclient( ) { #line 25 "obj2.tlcc" info.data = new HANDLE_INFO; } // #line 27 "obj2.tlcc" _F_TCPSERVER_endclient( ) { #line 28 "obj2.tlcc" } // #line 29 "obj2.tlcc" _F_TCPSERVER_receive( ) { #line 30 "obj2.tlcc" HANDLE_INFO *n = (HANDLE_INFO*)info.data; n->count++; sendf ("echo %s\n",line); sendf ("count=%u\n",n->count); if (strcmp(line,"quit")==0){ endclient = true; }else if (strcmp(line,"end")==0){ endserver = true; } } // #line 40 "obj2.tlcc" }; __sc_tests_obj2_tlcc2 _scopeobj2(B_glocal); #line 24 "obj2.tlcc" TCPSERVER o(_scopeobj2,"4000",10); #line 24 "obj2.tlcc" #line 41 "obj2.tlcc" o.loop(); return ret; } // #line 44 "obj2.tlcc" } // For nested glocals 2 -> 1 }; __sc_tests_obj2_tlcc1 _scopeobj1(B_glocal); #line 15 "obj2.tlcc" B_glocal.ret = #line 15 "obj2.tlcc" ::tlmpprogram(_scopeobj1,argc,argv); #line 45 "obj2.tlcc" return B_glocal.ret; } } // For nested glocals 1 -> 0 #line 48 "obj2.tlcc"