Changeset 280
- Timestamp:
- Mar 30, 2007, 10:31:24 PM (18 years ago)
- Location:
- trunk/idl-compiler
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/idl-compiler/c/emitter.c
r278 r280 54 54 { 55 55 int b; 56 gchar *chrType; 56 57 PMETHODPARAM pm=(PMETHODPARAM)g_ptr_array_index(pArray, a); 58 59 chrType= pm->chrType; 60 61 /* For old IDL files using orbit IDL compiler */ 62 if(!strcmp(pm->chrType, "string")) 63 chrType="CORBA_char*"; 64 if(!strcmp(pm->chrType, "long")) 65 chrType="CORBA_long"; 57 66 58 67 switch(pm->uiDirection) 59 68 { 60 69 case PARM_DIRECTION_IN: 61 fprintf(fh, " const %s", pm->chrType);70 fprintf(fh, " const %s", chrType); 62 71 break; 63 72 case PARM_DIRECTION_OUT: 64 fprintf(fh, " %s*", pm->chrType);73 fprintf(fh, " %s*", chrType); 65 74 break; 66 75 case PARM_DIRECTION_INOUT: 67 76 fprintf(fh, " %s*", chrType); 68 77 break; 69 78 default: 70 fprintf(fh, " %s*", pm->chrType); 79 71 80 break; 72 81 } … … 91 100 } 92 101 } 102 103 /** 104 This function emits the return type of a method. It translates CORBA identifiers 105 into another representation e.g. long->glong. At the moment it's used to be compatible 106 with old source written using the orbit IDL compiler. 107 */ 108 void emitReturnType(PPARSEINFO pLocalPI, PINTERFACE pif, PMETHOD pm) 109 { 110 FILE* fh=pLocalPI->outFile; 111 int b; 112 gchar* chrType; 113 114 chrType= pm->mpReturn.chrType; 115 116 /* Support for orbit IDL files */ 117 if(!strcmp(pm->mpReturn.chrType, "long")) 118 chrType="CORBA_long"; 119 else if(!strcmp(pm->mpReturn.chrType, "boolean")) 120 chrType="CORBA_boolean"; 121 122 fprintf(fh, "%s", chrType); 123 for(b=0;b<pm->mpReturn.uiStar;b++) 124 fprintf(fh, "*"); 125 } -
trunk/idl-compiler/c/nom-idl-compiler.c
r278 r280 548 548 } 549 549 550 #if 0 550 551 for(a=0; a<argc; a++) 551 552 { 552 553 g_message("arg %d: %s", a, argv[a]); 553 554 } 554 555 #endif 555 556 556 557 /*** Create output path name ****/ -
trunk/idl-compiler/h-emitter_c/h_file_emitter.c
r278 r280 80 80 /* Include header of parent */ 81 81 if(pifParent){ 82 char* chrTemp=strlwr(g_strdup(pifParent->chrName));83 82 fprintf(fh, "/* Include for the parent class */\n"); 84 fprintf(fh, "#include \"%s.h\"\n\n", chrTemp);85 g_free(chrTemp);83 if(pifParent->chrFileStem) 84 fprintf(fh, "#include \"%s.h\"\n\n", pifParent->chrFileStem); 86 85 } 87 86 } … … 110 109 fprintf(fh, " nomMToken %s;\n", pm->chrName); 111 110 } 112 fprintf(fh, "}%sClassData \n\n", pif->chrName);111 fprintf(fh, "}%sClassData;\n\n", pif->chrName); 113 112 114 113 fprintf(fh, "NOMEXTERN struct %sCClassDataStructure {\n", pif->chrName); … … 124 123 FILE* fh=pLocalPI->outFile; 125 124 126 fprintf(fh, "/* This function is used to check if a given object is valid and the\n"); 127 fprintf(fh, " object supports the method */\n"); 128 fprintf(fh, "NOMEXTERN gboolean NOMLINK nomCheckObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n"); 125 if(strcmp(pif->chrName , "NOMObject")) 126 { 127 fprintf(fh, "/* This function is used to check if a given object is valid and the\n"); 128 fprintf(fh, " object supports the method */\n"); 129 fprintf(fh, "NOMEXTERN gboolean NOMLINK nomCheckObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n"); 130 } 131 else 132 { 133 fprintf(fh, "/* This function is used to check if the given object is valid and a NOMObject */\n"); 134 fprintf(fh, "NOMEXTERN gboolean NOMLINK nomCheckNOMObjectPtr(NOMObject *nomSelf, NOMClass* nomClass, gchar* chrMethodName, CORBA_Environment *ev);\n\n"); 135 } 129 136 } 130 137 … … 157 164 emitMethodParams(pLocalPI, pif, pm->pParamArray); 158 165 159 fprintf(fh, " C orba_Environment *ev);\n");160 fprintf(fh, "typedef nomTP_%s_%s *nomTD_%s_%s \n", pif->chrName, pm->chrName,166 fprintf(fh, " CORBA_Environment *ev);\n"); 167 fprintf(fh, "typedef nomTP_%s_%s *nomTD_%s_%s;\n", pif->chrName, pm->chrName, 161 168 pif->chrName, pm->chrName); 162 169 fprintf(fh, "/* define the name for this method */\n"); … … 173 180 /* Do parameters */ 174 181 emitMethodParams(pLocalPI, pif, pm->pParamArray); 175 fprintf(fh, " C orba_Environment *ev);\n");182 fprintf(fh, " CORBA_Environment *ev);\n"); 176 183 177 184 fprintf(fh, "#define %s_%s(nomSelf,", pif->chrName, pm->chrName); … … 193 200 emitMethodParamsNoTypes(pLocalPI, pif, pm->pParamArray); 194 201 fprintf(fh, " ev) \\\n"); 195 fprintf(fh, " (nomCheckObjectPtr((NOMObject*)nomSelf, %sClassData.classObject,",pif->chrName); 202 if(strcmp(pif->chrName , "NOMObject")) 203 fprintf(fh, " (nomCheckObjectPtr((NOMObject*)nomSelf, %sClassData.classObject,",pif->chrName); 204 else 205 fprintf(fh, " (nomCheckNOMObjectPtr(nomSelf, %sClassData.classObject,",pif->chrName); 196 206 fprintf(fh, "\"%s_%s\", ev) ? \\\n", pif->chrName, pm->chrName); 197 207 … … 200 210 /* Do parameters */ 201 211 emitMethodParamsNoTypes(pLocalPI, pif, pm->pParamArray); 202 fprintf(fh, " ev)) : (gpointer) NULL)\n"); 212 fprintf(fh, " ev)) : (%s", pm->mpReturn.chrType); 213 for(b=0;b<pm->mpReturn.uiStar;b++) 214 fprintf(fh, "*"); 215 fprintf(fh, ") NULL)\n"); 203 216 fprintf(fh, "#endif\n"); 204 217 fprintf(fh, "#else /* NOM_NO_PARAM_CHECK */\n"); … … 285 298 chrTemp=g_strconcat(pif->chrFileStem, ".h", NULL); 286 299 287 printInterface(pif);300 //printInterface(pif); 288 301 if((pLocalPI->outFile=openOutfile(gScanner, chrTemp))!=NULLHANDLE) 289 302 { -
trunk/idl-compiler/ih-emitter_c/ih_file_emitter.c
r279 r280 103 103 PMETHODPARAM piv=(PMETHODPARAM)g_ptr_array_index(pArray, a); 104 104 105 fprintf(fh, "#define _%s (nomThis->%s) ;\n", piv->chrName, piv->chrName);105 fprintf(fh, "#define _%s (nomThis->%s)\n", piv->chrName, piv->chrName); 106 106 } 107 107 fprintf(fh, "\n"); … … 187 187 fprintf(fh, "#if !defined(_decl_impl_%s_%s_)\n", pif->chrName, pm->chrName); 188 188 fprintf(fh, "#define _decl_impl_%s_%s_ 1\n", pif->chrName, pm->chrName); 189 fprintf(fh, "NOM_Scope %s ", pm->mpReturn.chrType); 190 fprintf(fh, "NOMLINK impl_%s_%s(%s *nomSelf,\n", pif->chrName, pm->chrName, pif->chrName); 189 fprintf(fh, "NOM_Scope "); 190 emitReturnType(pLocalPI, pif, pm); 191 fprintf(fh, " NOMLINK impl_%s_%s(%s *nomSelf,\n", pif->chrName, pm->chrName, pif->chrName); 191 192 /* Do parameters */ 192 193 emitMethodParams(pLocalPI, pif, pm->pParamArray); … … 202 203 fprintf(fh, " \"%s\", /* Return type */\n {\n", pm->mpReturn.chrType); 203 204 emitMethodParamStrings(pLocalPI, pif, pm->pParamArray); 204 fprintf(fh, " }\n} \n");205 fprintf(fh, " }\n};\n"); 205 206 206 207 fprintf(fh, "#endif /* _decl_impl_%s_%s_ */\n\n", pif->chrName, pm->chrName); … … 252 253 emitMethodParamsNoTypes(pLocalPI, pif, pm->pParamArray); 253 254 fprintf(fh, " ev) \\\n"); 254 fprintf(fh, " (((nomTD_%s_%s) \\\n", pif ->chrName, pom->chrName);255 fprintf(fh, " (((nomTD_%s_%s) \\\n", pifIntroduced->chrName, pom->chrName); 255 256 256 257 fprintf(fh, " %s_%s_parent_resolved)((%s*)nomSelf,", … … 269 270 270 271 fprintf(fh, "/* Table of the overriden methods by this class */\n"); 271 fprintf(fh, "static nomOverridenMethodDesc nomOverridenMethods WPRootFolder[] = {\n");272 fprintf(fh, "static nomOverridenMethodDesc nomOverridenMethods%s[] = {\n", pif->chrName); 272 273 273 274 for(a=0;a<pArray->len;a++) … … 324 325 FILE* fh=pLocalPI->outFile; 325 326 326 fprintf(fh, "/* The meta class for this class */\n"); 327 fprintf(fh, "static char * nomIdStringMetaClass_%s = \"%s\";\n\n", pif->chrName, pif->chrMetaClass); 327 if(pif->chrMetaClass) 328 { 329 fprintf(fh, "/* The meta class for this class */\n"); 330 fprintf(fh, "static char * nomIdStringMetaClass_%s = \"%s\";\n\n", pif->chrName, pif->chrMetaClass); 331 } 328 332 } 329 333 … … 347 351 int a; 348 352 349 fprintf(fh, "/* Array of parent names (chain of parents) */\n"); 350 fprintf(fh, "static char* nomParentClassNames%s[]=\n{\n", pif->chrName); 351 /* Emit the parents. We have to output them sorted beginning from the 352 leftmost parent. */ 353 while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULLHANDLE) 354 { 355 g_ptr_array_add(pArray, (gpointer) pifParent); 356 } 357 358 for(a=pArray->len-1; a>=0; a--) 359 { 360 pifParent=(PINTERFACE)g_ptr_array_index(pArray, a); 361 fprintf(fh, " \"%s\",\n", pifParent->chrName); 362 } 363 g_ptr_array_free(pArray, TRUE); 364 fprintf(fh, "};\n\n"); 365 366 fprintf(fh, "static char * nomIdString_Parent_%s = \"%s\";\n\n", pif->chrParent, pif->chrParent); 367 368 fprintf(fh, "/* Array of parent IDs (direct parents, for now NOM only support single inheritance) */\n"); 369 fprintf(fh, "static nomID nomParentClasses%s[]=\n", pif->chrName); 370 fprintf(fh, "{\n"); 371 fprintf(fh, " &nomIdString_Parent_%s,\n", pif->chrParent); 372 fprintf(fh, "};\n\n"); 353 if(pif->chrParent) 354 { 355 fprintf(fh, "/* Array of parent names (chain of parents) */\n"); 356 fprintf(fh, "static char* nomParentClassNames%s[]=\n{\n", pif->chrName); 357 /* Emit the parents. We have to output them sorted beginning from the 358 leftmost parent. */ 359 while(pifParent->chrParent && (pifParent=findInterfaceFromName(pifParent->chrParent))!=NULLHANDLE) 360 { 361 g_ptr_array_add(pArray, (gpointer) pifParent); 362 } 363 364 for(a=pArray->len-1; a>=0; a--) 365 { 366 pifParent=(PINTERFACE)g_ptr_array_index(pArray, a); 367 fprintf(fh, " \"%s\",\n", pifParent->chrName); 368 } 369 g_ptr_array_free(pArray, TRUE); 370 fprintf(fh, "};\n\n"); 371 372 fprintf(fh, "static char * nomIdString_Parent_%s = \"%s\";\n\n", pif->chrParent, pif->chrParent); 373 374 fprintf(fh, "/* Array of parent IDs (direct parents, for now NOM only support single inheritance) */\n"); 375 fprintf(fh, "static nomID nomParentClasses%s[]=\n", pif->chrName); 376 fprintf(fh, "{\n"); 377 fprintf(fh, " &nomIdString_Parent_%s,\n", pif->chrParent); 378 fprintf(fh, "};\n\n"); 379 } 373 380 } 374 381 … … 443 450 FILE* fh=pLocalPI->outFile; 444 451 452 fprintf(fh, "/* Identify this class */\n"); 453 fprintf(fh, "static char * nomIdString_%s = \"%s\";\n\n", pif->chrName, pif->chrName); 454 445 455 fprintf(fh, "static nomStaticClassInfo %sSCI = {\n", pif->chrName); 446 456 fprintf(fh, " 0, /* Version */\n"); … … 461 471 fprintf(fh, " (nomStaticMethodDesc*)&nomStaticMethods%s,\n", pif->chrName); 462 472 if(pif->chrParent) 473 { 463 474 fprintf(fh, " nomParentClasses%s,\n", pif->chrName); 475 fprintf(fh, " nomParentClassNames%s, /* Name of all the parent classes in chain */\n", pif->chrName); 476 } 464 477 else 465 fprintf(fh, " NULL,\n"); 466 fprintf(fh, " nomParentClassNames%s, /* Name of all the parent classes in chain */\n", pif->chrName); 478 { 479 fprintf(fh, " (void*)NULL,\n"); 480 fprintf(fh, " (void*)NULL,\n"); 481 } 482 467 483 fprintf(fh, " %ld, /* Number of parents in the chain of classes */\n", 468 484 getNumberOfParentsInChain( pLocalPI, pif)); … … 521 537 pif->chrMetaClass, pif->chrMetaClass, pif->chrMetaClass); 522 538 } 523 fprintf(fh, " %sNewClass(%s_MajorVersion, %s_MinorVersion);\n", 524 pif->chrParent, pif->chrParent, pif->chrParent); 539 if(pif->chrParent) 540 { 541 fprintf(fh, " /* Create the parent class */\n"); 542 fprintf(fh, " %sNewClass(%s_MajorVersion, %s_MinorVersion);\n", 543 pif->chrParent, pif->chrParent, pif->chrParent); 544 } 525 545 fprintf(fh, " result = nomBuildClass(1, &%sSCI, ulMajor, ulMinor);\n\n", pif->chrName); 526 546 fprintf(fh, " return result;\n"); … … 548 568 gchar* chrTemp; 549 569 550 printInterface(pif);570 //printInterface(pif); 551 571 552 572 chrTemp=g_strconcat(pif->chrFileStem, ".ih", NULL); -
trunk/idl-compiler/include/parser.h
r278 r280 183 183 void emitMethodParams(PPARSEINFO pLocalPI, PINTERFACE pif, GPtrArray *pArray); 184 184 void emitMethodParamsNoTypes(PPARSEINFO pLocalPI, PINTERFACE pif, GPtrArray *pArray); 185 void emitReturnType(PPARSEINFO pLocalPI, PINTERFACE pif, PMETHOD pm); 185 186 186 187 /* In printdata.c */
Note:
See TracChangeset
for help on using the changeset viewer.