Changeset 253
- Timestamp:
- Mar 11, 2007, 11:31:49 PM (18 years ago)
- Location:
- trunk/ORBit2-2.14.0/src/idl-compiler
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-headers.c
r212 r253 636 636 } 637 637 638 #if 0 639 static gchar* mySkipSpaces(char* theString) 640 { 641 if(!theString) /* Huh???*/ 642 return ""; 643 644 while(*theString) 645 theString++; 646 647 return theString 648 } 649 #endif 650 651 #include <string.h> 652 /* 653 This function extracts the return vlaue from the string which is created by 654 the parameter check macro. The string is of the form: 655 656 "retval, parm1, parm2,..." 657 658 */ 659 static gchar* VoyagerExtractRetValFromParmCheck(gchar* theString) 660 { 661 gchar* ptr, *ptr2; 662 663 if(NULL==(ptr=strchr(theString, ','))) 664 { 665 /* No ',' so no parameters provided */ 666 return g_strdup(theString); 667 } 668 *ptr='\0'; 669 ptr2=g_strdup(theString); 670 *ptr=','; 671 return ptr2; 672 }; 673 /* 674 This functions puts constants into the header file. For Voyager we 675 use constants to encode some special information e.g. the metaclass name 676 or info about which parameters to check for methods. This information is 677 marked by special strings in the constants name. 678 */ 638 679 static void 639 680 ch_output_const_dcl(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci) … … 642 683 IDL_tree ident; 643 684 IDL_tree typespec; 685 gchar *ptr; 644 686 645 687 ident = IDL_CONST_DCL (tree).ident; 646 688 id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS (ident), "_", 0); 647 689 648 fprintf(ci->fh, "#ifndef %s\n", id); 649 fprintf(ci->fh, "#define %s ", id); 650 651 orbit_cbe_write_const(ci->fh, 652 IDL_CONST_DCL(tree).const_exp); 653 654 typespec = orbit_cbe_get_typespec (IDL_CONST_DCL(tree).const_type); 655 if (IDL_NODE_TYPE (typespec) == IDLN_TYPE_INTEGER && 656 !IDL_TYPE_INTEGER (typespec).f_signed) 657 fprintf(ci->fh, "U"); 658 659 fprintf(ci->fh, "\n"); 660 fprintf(ci->fh, "#endif /* !%s */\n\n", id); 661 662 /* Get the name of our explicit metaclass if any */ 690 ptr=strstr( id , NOM_PARMCHECK_STRING); 691 /* Enable parameter check for a method */ 692 if(ptr) 693 { 694 gchar *retVal; 695 *ptr='\0'; 696 //printf(" %d --- > %s %s Params: %s\n", 697 //__LINE__, id, IDL_IDENT(ident).str, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value); 698 fprintf(ci->fh, "/* %s: %s line %d */\n", __FILE__, __FUNCTION__, __LINE__); 699 fprintf(ci->fh, "/* Value: %s */\n", IDL_STRING(IDL_CONST_DCL(tree).const_exp).value); 700 fprintf(ci->fh, "#ifndef %s_ParmCheck_h\n", id); 701 fprintf(ci->fh, "#define %s_ParmCheck_h\n", id); 702 retVal=VoyagerExtractRetValFromParmCheck(IDL_STRING(IDL_CONST_DCL(tree).const_exp).value); 703 fprintf(ci->fh, "#define %s_retval %s\n", id, retVal); 704 g_free(retVal); 705 fprintf(ci->fh, "#endif /* !%s */\n\n", id); 706 *ptr='_'; 707 } 708 else 709 { 710 fprintf(ci->fh, "#ifndef %s\n", id); 711 fprintf(ci->fh, "#define %s ", id); 712 713 orbit_cbe_write_const(ci->fh, 714 IDL_CONST_DCL(tree).const_exp); 715 716 typespec = orbit_cbe_get_typespec (IDL_CONST_DCL(tree).const_type); 717 if (IDL_NODE_TYPE (typespec) == IDLN_TYPE_INTEGER && 718 !IDL_TYPE_INTEGER (typespec).f_signed) 719 fprintf(ci->fh, "U"); 720 721 fprintf(ci->fh, "\n"); 722 fprintf(ci->fh, "#endif /* !%s */\n\n", id); 723 } 724 663 725 if(IDLN_STRING==IDL_NODE_TYPE(IDL_CONST_DCL(tree).const_exp)) 664 726 { 727 /* Get the name of our explicit metaclass if any */ 665 728 /* Our metaclass info is a string */ 666 729 if(strstr( IDL_IDENT(ident).str, NOM_METACLASS_STRING)) … … 671 734 // __LINE__, id, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value, gsMetaClassName[ulCurInterface]); 672 735 } 673 }736 } 674 737 g_free(id); 675 738 } … … 1193 1256 /* define method call as a macro */ 1194 1257 fprintf(of, "/* define method call as a macro */\n"); 1195 fprintf(of, "#define %s(vomSelf, ", id); 1258 fprintf(of, "#ifdef %s_ParmCheck_h /* Parameter check */\n", id); 1259 /* Forward declaration */ 1260 fprintf(of, "NOMEXTERN "); 1261 fprintf(of, "gboolean NOMLINK parmCheckFunc_%s(%s *nomSelf, \n",id, id2); 1262 op = tree; 1263 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1264 curitem; curitem = IDL_LIST(curitem).next) { 1265 IDL_tree tr; 1266 tr = IDL_LIST(curitem).data; 1267 /* Write list of params */ 1268 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1269 { 1270 fprintf(of, " "); 1271 orbit_cbe_write_param_typespec(of, tr); 1272 fprintf(of, " %s,\n", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1273 } 1274 } 1275 tree=op; 1276 fprintf(of, "CORBA_Environment *ev)"); 1277 fprintf(of, ";\n"); 1278 1279 /* Macro to be used when parameters are checked */ 1280 fprintf(of, "#define %s(nomSelf, ", id); 1196 1281 /* add the parms */ 1197 1198 1282 op = tree; 1199 1283 for(curitem = IDL_OP_DCL(tree).parameter_dcls; … … 1208 1292 } 1209 1293 tree=op; 1210 1211 // fprintf(of, "CORBA_Environment *ev) \\\n");1212 1294 fprintf(of, "ev) \\\n"); 1213 fprintf(of, " (NOM_Resolve(vomSelf, %s, %s) \\\n", id2, id3); 1214 fprintf(of, " (vomSelf,"); 1295 fprintf(of, " (parmCheckFunc_%s(nomSelf, ", id); 1296 /* Parameters for call */ 1297 op = tree; 1298 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1299 curitem; curitem = IDL_LIST(curitem).next) { 1300 IDL_tree tr; 1301 tr = IDL_LIST(curitem).data; 1302 //orbit_cbe_ski_process_piece(&subski); 1303 /* Write list of params */ 1304 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1305 { 1306 fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1307 } 1308 } 1309 tree=op; 1310 1311 fprintf(of, "ev) ? \\\n"); 1312 fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3); 1313 fprintf(of, " (nomSelf,"); 1215 1314 1216 1315 /* add the parms */ … … 1228 1327 } 1229 1328 tree=op; 1329 fprintf(of, "ev)) : %s_retval)\n", id); 1330 fprintf(of, "#else\n"); 1331 1332 /* Normal macro */ 1333 fprintf(of, "#define %s(nomSelf, ", id); 1334 /* add the parms */ 1335 op = tree; 1336 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1337 curitem; curitem = IDL_LIST(curitem).next) { 1338 IDL_tree tr; 1339 tr = IDL_LIST(curitem).data; 1340 /* Write list of params */ 1341 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1342 { 1343 fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1344 } 1345 } 1346 tree=op; 1347 1348 // fprintf(of, "CORBA_Environment *ev) \\\n"); 1349 fprintf(of, "ev) \\\n"); 1350 fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3); 1351 fprintf(of, " (nomSelf,"); 1352 1353 /* add the parms */ 1354 op = tree; 1355 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1356 curitem; curitem = IDL_LIST(curitem).next) { 1357 IDL_tree tr; 1358 tr = IDL_LIST(curitem).data; 1359 //orbit_cbe_ski_process_piece(&subski); 1360 /* Write list of params */ 1361 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1362 { 1363 fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1364 } 1365 } 1366 tree=op; 1230 1367 1231 1368 // fprintf(of, "CORBA_Environment *ev))\n"); 1232 1369 fprintf(of, "ev))\n"); 1370 fprintf(of, "#endif\n"); 1233 1371 /* Method macro */ 1234 1372 fprintf(of, "#define _%s %s", id3 , id); -
trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-skelimpl.c
r249 r253 43 43 FILE *of; 44 44 IDL_tree tree; 45 enum { PASS_VOYAGER_INSTANCE, PASS_VOYAGER_GETDATA, PASS_VOYAGER_CLSDATA, 45 enum { PASS_VOYAGER_INSTANCE, PASS_VOYAGER_GETDATA, PASS_VOYAGER_CLSDATA, PASS_VOYAGER_PARMCHECK, 46 46 PASS_SERVANTS, PASS_PROTOS, PASS_EPVS, PASS_VEPVS, 47 47 PASS_IMPLSTUBS, PASS_VOYAGER_OVERRIDEN_METHODS, PASS_VOYAGER_OVERRIDEN_METHODTAB, … … 67 67 "Voyager GetData macros ", 68 68 "Voyager class data structures", 69 "Voyager parameter check", 69 70 "App-specific servant structures", 70 71 "Implementation stub prototypes", … … 328 329 } 329 330 331 /* 332 The name of our meta class is encoded as a constant. We go over all the constants found during 333 IDL parsing and check for a special marker string in the name. 334 */ 330 335 static void 331 336 VoyagerExtractMetaClass(CBESkelImplInfo *ski) … … 343 348 id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS (ident), "_", 0); 344 349 345 #if 0346 printf(" %d --- > %s %s %s, %s %d\n", __LINE__,347 id, IDL_IDENT(ident).str, IDL_IDENT(IDL_INTERFACE(intf).ident).str,348 passnames[ski->pass], IDL_NODE_TYPE(IDL_CONST_DCL(ski->tree).const_exp));349 #endif350 351 350 if(IDLN_STRING==IDL_NODE_TYPE(IDL_CONST_DCL(ski->tree).const_exp)) 352 351 { 352 // printf(" %d --- > %s\n", __LINE__,IDL_IDENT(ident).str); 353 353 /* Our metaclass info is a string */ 354 354 if(strstr( IDL_IDENT(ident).str, NOM_METACLASS_STRING)) … … 358 358 // printf(" %d --- > %s %s (%x)\n", 359 359 // __LINE__, id, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value, gsMetaClassName[ulCurInterface]); 360 } 361 } 362 g_free(id); 363 }/* PASS_VOYAGER_...*/ 364 } 365 366 /* 367 For methods which should have parameter checks (specified by a special macro in the IDL file) 368 a constant string is specified. The method name is encoded in the constants name while the string 369 holds all the info about the parameters to check. 370 We go over all the constants found during IDL parsing and check for a special marker string in the 371 name. 372 */ 373 static void 374 VoyagerCreateParamCheckFunctions(CBESkelImplInfo *ski) 375 { 376 char *id; 377 IDL_tree ident; 378 IDL_tree intf; 379 380 381 if(PASS_VOYAGER_PARMCHECK==ski->pass) 382 { 383 ident = IDL_CONST_DCL (ski->tree).ident; 384 intf = IDL_get_parent_node(ski->tree, IDLN_INTERFACE, NULL); 385 386 id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS (ident), "_", 0); 387 388 if(IDLN_STRING==IDL_NODE_TYPE(IDL_CONST_DCL(ski->tree).const_exp)) 389 { 390 gchar *ptr; 391 // printf(" %d --- > %s\n", __LINE__,IDL_IDENT(ident).str); 392 /* Our parameter info is a string */ 393 ptr=strstr( id /*IDL_IDENT(ident).str*/, NOM_PARMCHECK_STRING); 394 if(ptr) 395 { 396 *ptr='\0'; 397 //printf(" %d --- > %s %s Params: %s\n", 398 //__LINE__, id, IDL_IDENT(ident).str, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value); 399 fprintf(ski->of, "#ifndef %s_ParmCheck\n", id); 400 fprintf(ski->of, "#define %s_ParmCheck\n", id); 401 fprintf(ski->of, "#endif\n"); 402 *ptr='_'; 360 403 } 361 404 } … … 411 454 break; 412 455 case IDLN_CONST_DCL: 456 /* Find the name of the metaclass for this class if any. */ 413 457 VoyagerExtractMetaClass(ski); 458 /* Create support function for parameter checks. */ 459 VoyagerCreateParamCheckFunctions(ski); 414 460 break; 415 461 default: … … 776 822 gstr=g_string_new(IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str); 777 823 778 /* Check for our spec ailly marked NOM-only methods. Don't output them here, they are handled824 /* Check for our specially marked NOM-only methods. Don't output them here, they are handled 779 825 specially. */ 780 826 if(!strstr(id, NOM_INSTANCEVAR_STRING) /*&& !strstr(id, NOM_OVERRIDE_STRING)*/) … … 954 1000 } 955 1001 956 /* Output the parameter info */1002 /* Output the parameter info for runtime type information */ 957 1003 if(!bOverriden) 958 1004 { … … 988 1034 fprintf(ski->of, "}};\n"); 989 1035 } 1036 1037 /* Output a function for checking the parameters */ 1038 if(!bOverriden) 1039 { 1040 fprintf(ski->of, "#ifdef %s_ParmCheck\n", id); 1041 fprintf(ski->of, "NOMEXTERN "); 1042 fprintf(ski->of, "gboolean NOMLINK parmCheckFunc_%s_%s(%s *nomSelf,\n", 1043 id2, IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str, id2); 1044 op = ski->tree; 1045 for(curitem = IDL_OP_DCL(ski->tree).parameter_dcls; 1046 curitem; curitem = IDL_LIST(curitem).next) { 1047 subski.tree = IDL_LIST(curitem).data; 1048 orbit_cbe_ski_process_piece(&subski); 1049 } 1050 1051 if(IDL_OP_DCL(op).context_expr) 1052 fprintf(ski->of, "CORBA_Context ctx,\n"); 1053 fprintf(ski->of, "CORBA_Environment *ev)"); 1054 1055 fprintf(ski->of, "{\n"); 1056 fprintf(ski->of, " g_message(\"%%s: parameter check for %%s...\", __FUNCTION__, _nomGetClassName(nomSelf, NULLHANDLE));\n"); 1057 fprintf(ski->of, "if(!_nomIsA(nomSelf , %sClassData.classObject, NULLHANDLE))\n", id2); 1058 fprintf(ski->of, " {\n"); 1059 fprintf(ski->of, " g_message(\"Object is not valid\");\n"); 1060 fprintf(ski->of, " return FALSE;\n"); 1061 fprintf(ski->of, " }\n"); 1062 fprintf(ski->of, " return TRUE;\n"); 1063 fprintf(ski->of, "}\n"); 1064 fprintf(ski->of, "#endif\n"); 1065 } 1066 990 1067 991 1068 if(ptr!=NULL) … … 1389 1466 break; 1390 1467 } 1468 case PASS_VOYAGER_PARMCHECK: 1469 { 1470 subski.tree = IDL_INTERFACE(ski->tree).body; 1471 cbe_ski_do_list(&subski); 1472 IDL_tree_traverse_parents(ski->tree, (GFunc)&cbe_ski_do_inherited_methods, ski); 1473 break; 1474 } 1391 1475 case PASS_VOYAGER_CLASSINFO: 1392 1476 { -
trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl2.h
r92 r253 33 33 #define NOM_INSTANCEVAR_STRING "__INSTANCEVAR__" 34 34 #define NOM_METACLASS_STRING "METACLASS_TO_USE" 35 #define NOM_PARMCHECK_STRING "__PARMCHECK__" 35 36 36 37 #endif
Note:
See TracChangeset
for help on using the changeset viewer.