Changeset 254
- Timestamp:
- Mar 12, 2007, 10:37:06 PM (18 years ago)
- Location:
- trunk/ORBit2-2.14.0/src/idl-compiler
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-headers.c
r253 r254 166 166 break; 167 167 } 168 169 168 } 170 169 … … 671 670 return ptr2; 672 671 }; 672 673 673 /* 674 674 This functions puts constants into the header file. For Voyager we … … 688 688 id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS (ident), "_", 0); 689 689 690 /* Enable parameter check for a method. This is done by putting a #define xxx 691 at the top of the file. Checking code is sourrounded by #ifdef/#endif. */ 690 692 ptr=strstr( id , NOM_PARMCHECK_STRING); 691 /* Enable parameter check for a method */692 693 if(ptr) 693 694 { … … 696 697 //printf(" %d --- > %s %s Params: %s\n", 697 698 //__LINE__, id, IDL_IDENT(ident).str, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value); 699 /* Print out the line for easy finding in this source file */ 698 700 fprintf(ci->fh, "/* %s: %s line %d */\n", __FILE__, __FUNCTION__, __LINE__); 699 701 fprintf(ci->fh, "/* Value: %s */\n", IDL_STRING(IDL_CONST_DCL(tree).const_exp).value); 702 /* Protect by #ifdef...*/ 700 703 fprintf(ci->fh, "#ifndef %s_ParmCheck_h\n", id); 701 704 fprintf(ci->fh, "#define %s_ParmCheck_h\n", id); 705 /* Default return code (provided by the macro) */ 702 706 retVal=VoyagerExtractRetValFromParmCheck(IDL_STRING(IDL_CONST_DCL(tree).const_exp).value); 703 707 fprintf(ci->fh, "#define %s_retval %s\n", id, retVal); … … 723 727 } 724 728 729 /* Get the name of our explicit metaclass if any. */ 725 730 if(IDLN_STRING==IDL_NODE_TYPE(IDL_CONST_DCL(tree).const_exp)) 726 731 { 727 /* Get the name of our explicit metaclass if any */728 732 /* Our metaclass info is a string */ 729 733 if(strstr( IDL_IDENT(ident).str, NOM_METACLASS_STRING)) … … 731 735 gsMetaClassName=g_string_new(NULL); 732 736 g_string_printf(gsMetaClassName, "%s", IDL_STRING(IDL_CONST_DCL(tree).const_exp).value); 733 // 734 // 737 //printf(" %d --- > %s %s (%x)\n", 738 //__LINE__, id, IDL_STRING(IDL_CONST_DCL(ski->tree).const_exp).value, gsMetaClassName[ulCurInterface]); 735 739 } 736 740 } … … 1156 1160 IDL_tree sub; 1157 1161 1158 //fprintf(ioi->of, "#define %s_%s() \\\n %s_%s()\n",1159 // realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str,1160 // id, IDL_IDENT(IDL_OP_DCL(curop).ident).str);1161 1162 fprintf(ioi->of, "#define %s_%s(nomSelf, ", 1162 1163 realid, IDL_IDENT(IDL_OP_DCL(curop).ident).str); … … 1185 1186 } 1186 1187 1188 /* 1189 Output the typespecs and parameters of a new method. 1190 Note that tree must be correctly chosen. 1191 */ 1192 static void 1193 doWriteTypespecAndParameters(FILE *of, IDL_tree tree) 1194 { 1195 IDL_tree curitem; 1196 1197 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1198 curitem; curitem = IDL_LIST(curitem).next) { 1199 IDL_tree tr; 1200 tr = IDL_LIST(curitem).data; 1201 /* Write list of params */ 1202 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1203 { 1204 fprintf(of, " "); 1205 orbit_cbe_write_param_typespec(of, tr); 1206 fprintf(of, " %s,\n", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1207 } 1208 } 1209 } 1210 1211 /* 1212 Output the parameters only of a new method. 1213 Note that tree must be correctly chosen. 1214 */ 1215 static void 1216 doWriteParametersOnly(FILE *of, IDL_tree tree) 1217 { 1218 IDL_tree curitem; 1219 1220 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1221 curitem; curitem = IDL_LIST(curitem).next) { 1222 IDL_tree tr; 1223 tr = IDL_LIST(curitem).data; 1224 /* Write list of params */ 1225 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1226 { 1227 fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1228 } 1229 } 1230 } 1231 1232 /* 1233 This function does quite some real work. It puts all the info about an introduced method 1234 into the *.h file. This includes convenience macros, strings specifying the method name 1235 and macros for automatic checking of parameters. 1236 */ 1187 1237 static void 1188 1238 VoyagerOutputNewMethod(FILE *of, IDL_tree tree, const char *nom_prefix) … … 1195 1245 IDL_tree curitem, op; 1196 1246 int level; 1197 // CBESkelImplInfo subski = *ski;1198 1247 1199 1248 g_assert (IDL_NODE_TYPE(tree) == IDLN_OP_DCL); … … 1224 1273 IDL_tree tr; 1225 1274 tr = IDL_LIST(curitem).data; 1226 //orbit_cbe_ski_process_piece(&subski); 1275 1227 1276 /* Write list of params */ 1228 1277 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) … … 1254 1303 fprintf(of, "#define nomMNDef_%s \"%s\"\n", id, id3); 1255 1304 fprintf(of, "#define nomMNFullDef_%s \"%s:%s\"\n", id, id2, id3); 1305 1256 1306 /* define method call as a macro */ 1257 1307 fprintf(of, "/* define method call as a macro */\n"); 1258 fprintf(of, "#ifdef %s_ParmCheck_h /* Parameter check */\n", id); 1259 /* Forward declaration */ 1308 fprintf(of, "#ifndef NOM_NO_PARAM_CHECK /* Parameter chack at all? */\n"); 1309 fprintf(of, "#ifdef %s_ParmCheck_h /* Extended parameter check enabled */\n", id); 1310 1311 /* Forward declaration of parameter test function */ 1260 1312 fprintf(of, "NOMEXTERN "); 1261 1313 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 */ 1314 /* Write parameter list including the type spec */ 1315 doWriteTypespecAndParameters(of, tree); 1316 fprintf(of, "CORBA_Environment *ev);\n"); 1317 1318 /* Macro to be used when several parameters are checked */ 1280 1319 fprintf(of, "#define %s(nomSelf, ", id); 1281 1320 /* add the parms */ 1282 op = tree; 1283 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1284 curitem; curitem = IDL_LIST(curitem).next) { 1285 IDL_tree tr; 1286 tr = IDL_LIST(curitem).data; 1287 /* Write list of params */ 1288 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1289 { 1290 fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1291 } 1292 } 1293 tree=op; 1321 doWriteParametersOnly(of, tree); 1294 1322 fprintf(of, "ev) \\\n"); 1295 1323 fprintf(of, " (parmCheckFunc_%s(nomSelf, ", id); 1296 1324 /* 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; 1325 doWriteParametersOnly(of, tree); 1310 1326 1311 1327 fprintf(of, "ev) ? \\\n"); 1312 1328 fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3); 1313 1329 fprintf(of, " (nomSelf,"); 1314 1315 1330 /* add the parms */ 1316 op = tree; 1317 for(curitem = IDL_OP_DCL(tree).parameter_dcls; 1318 curitem; curitem = IDL_LIST(curitem).next) { 1319 IDL_tree tr; 1320 tr = IDL_LIST(curitem).data; 1321 //orbit_cbe_ski_process_piece(&subski); 1322 /* Write list of params */ 1323 if(IDL_NODE_TYPE(tr) == IDLN_PARAM_DCL) 1324 { 1325 fprintf(of, " %s,", IDL_IDENT(IDL_PARAM_DCL(tr).simple_declarator).str); 1326 } 1327 } 1328 tree=op; 1331 doWriteParametersOnly(of, tree); 1329 1332 fprintf(of, "ev)) : %s_retval)\n", id); 1330 fprintf(of, "#else\n"); 1333 1334 /* else NOM_NO_PARAM_CHECK */ 1335 fprintf(of, "#else /* Extended parameter check */\n"); 1336 1337 /* Check object only */ 1338 fprintf(of, "#define %s(nomSelf, ", id); 1339 /* add the parms */ 1340 doWriteParametersOnly(of, tree); 1341 fprintf(of, "ev) \\\n"); 1342 fprintf(of, " (objectCheckFunc_%s(nomSelf, ", id2); 1343 fprintf(of, " \"%s\") ? \\\n", id); 1344 fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3); 1345 fprintf(of, " (nomSelf,"); 1346 /* add the parms */ 1347 doWriteParametersOnly(of, tree); 1348 fprintf(of, "ev)) : ("); 1349 orbit_cbe_write_param_typespec(of, tree); 1350 fprintf(of, ") NULL)\n"); 1351 fprintf(of, "#endif\n"); 1352 1353 /* No parameter check at all */ 1354 fprintf(of, "#else /* NOM_NO_PARAM_CHECK */\n"); 1331 1355 1332 1356 /* Normal macro */ 1333 1357 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"); 1358 doWriteParametersOnly(of, tree); 1349 1359 fprintf(of, "ev) \\\n"); 1350 1360 fprintf(of, " (NOM_Resolve(nomSelf, %s, %s) \\\n", id2, id3); 1351 1361 fprintf(of, " (nomSelf,"); 1352 1353 1362 /* 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; 1367 1368 // fprintf(of, "CORBA_Environment *ev))\n"); 1363 doWriteParametersOnly(of, tree); 1369 1364 fprintf(of, "ev))\n"); 1370 fprintf(of, "#endif\n"); 1365 fprintf(of, "#endif\n"); /* Parameter check*/ 1366 1371 1367 /* Method macro */ 1372 1368 fprintf(of, "#define _%s %s", id3 , id); … … 1378 1374 } 1379 1375 1376 /* CW: probably some cleanup isn't too bad here... */ 1380 1377 static void 1381 1378 ch_output_stub_protos(IDL_tree tree, OIDL_Run_Info *rinfo, OIDL_C_Info *ci) … … 1431 1428 case IDLN_OP_DCL: 1432 1429 orbit_idl_check_oneway_op (cur); 1433 /* orbit_cbe_op_write_proto(ci->fh, cur, "", FALSE); */1434 1430 1435 1431 /* NOM allows method overriding. This is done using a macro which builds a method … … 1459 1455 } 1460 1456 #else 1457 #if 0 1458 /* 11.03.2007: We don't use attributes for now! */ 1461 1459 /* We put the attribute methods automatically into the *ClassStruct. 1462 1460 That's different to SOM where you have to put them in the releaseorder list … … 1468 1466 fprintf(ci->fh, ";\n"); 1469 1467 } 1468 #endif 1470 1469 #endif 1471 1470 }/* for() */ … … 1479 1478 fprintf(ci->fh, "} %sClassData;\n\n", id); 1480 1479 1481 1482 /******* Print introduced method for possible postprocessing *******/ 1480 /******* Print generic object check function *******/ 1481 1482 fprintf(ci->fh, "NOMEXTERN gboolean NOMLINK objectCheckFunc_%s(%s *nomSelf, gchar* chrMethodName);\n\n", id, id); 1483 1484 1485 /******* Print introduced methods *******/ 1483 1486 for(sub = IDL_INTERFACE(tree).body; sub; sub = IDL_LIST(sub).next) { 1484 1487 IDL_tree cur; … … 1495 1498 fprintf(ci->fh, "/*\n * NEW_METHOD: "); 1496 1499 fprintf(ci->fh, "%s %s\n */\n", IDL_IDENT (IDL_OP_DCL (cur).ident).str, id ); 1497 1500 /* Do print... */ 1498 1501 VoyagerOutputNewMethod(ci->fh, cur, ""); 1499 1500 1502 } 1501 1503 break; -
trunk/ORBit2-2.14.0/src/idl-compiler/orbit-idl-c-skelimpl.c
r253 r254 127 127 } 128 128 129 /* 130 Worker function for outputting the name of a class introducing some method. 131 Called by VoyagerOutputIntroducingClass(); 132 */ 129 133 static 130 void Voyager OutputIntroducingClass(IDL_tree curif, InheritedOutputInfo *ioi)134 void VoyagerDoOutputIntroducingClass(IDL_tree curif, InheritedOutputInfo *ioi) 131 135 { 132 136 char *id; … … 160 164 g_free(id); 161 165 } 166 167 /* 168 Output the name of a class introducing an overriden method. 169 */ 170 static 171 void VoyagerOutputIntroducingClass(IDL_tree tmptree, CBESkelImplInfo *ski, GString *gstr) 172 { 173 if(IDL_INTERFACE(tmptree).inheritance_spec) { 174 InheritedOutputInfo ioi; 175 176 ioi.of = ski->of; 177 ioi.realif = tmptree; 178 ioi.chrOverridenMethodName=gstr->str; 179 IDL_tree_traverse_parents(IDL_INTERFACE(tmptree).inheritance_spec, 180 (GFunc)VoyagerDoOutputIntroducingClass, &ioi); 181 } 182 } 183 162 184 163 185 static … … 365 387 366 388 /* 389 This function creates a define for methods with parameter check at the top of the *.ih file 390 to enable the check function whichis sourrounded by '#ifdef/#endif. 391 Note that this function does not create any checking code. 392 367 393 For methods which should have parameter checks (specified by a special macro in the IDL file) 368 394 a constant string is specified. The method name is encoded in the constants name while the string … … 372 398 */ 373 399 static void 374 VoyagerCreateParamCheck Functions(CBESkelImplInfo *ski)400 VoyagerCreateParamCheckDefines(CBESkelImplInfo *ski) 375 401 { 376 402 char *id; … … 408 434 409 435 /* 436 Output a generic function for checking the object pointer. 437 */ 438 static void 439 VoyagerCreateObjectCheckFunction(char *id2, CBESkelImplInfo *ski) 440 { 441 #if 0 442 if(PASS_VOYAGER_PARMCHECK==ski->pass) 443 { 444 445 char *id, *id2; 446 IDL_tree curitem; 447 int level; 448 GString *gstr; 449 450 curitem = IDL_get_parent_node(ski->tree, IDLN_INTERFACE, &level); 451 g_assert(curitem); 452 453 id = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_OP_DCL(ski->tree).ident), "_", 0); 454 id2 = IDL_ns_ident_to_qstring(IDL_IDENT_TO_NS(IDL_INTERFACE(curitem).ident), "_", 0); 455 456 gstr=g_string_new(IDL_IDENT(IDL_OP_DCL(ski->tree).ident).str); 457 #endif 458 459 /* Output a function for checking the parameters. Note that we only 460 check the object pointer. */ 461 fprintf(ski->of, "\n/* Function to check if an object is valid before calling a method on it */\n"); 462 fprintf(ski->of, "#ifndef NOM_NO_PARAM_CHECK\n"); 463 fprintf(ski->of, "NOMEXTERN "); 464 fprintf(ski->of, "gboolean NOMLINK objectCheckFunc_%s(%s *nomSelf, gchar* chrMethodName)\n", 465 id2, id2); 466 fprintf(ski->of, "{\n"); 467 468 fprintf(ski->of, "if(!nomIsObj(nomSelf) || !_nomIsA(nomSelf , %sClassData.classObject, NULLHANDLE))\n", id2); 469 fprintf(ski->of, " {\n"); 470 fprintf(ski->of, " nomPrintObjectPointerError(nomSelf, \"%s\", chrMethodName);\n", id2); 471 fprintf(ski->of, " g_message(\"Note that NULL is returned for the call (if the method returns a value). This may not be correct. Use the NOMPARMCHECK() macro to specify default return values for methods.\");\n"); 472 fprintf(ski->of, " return FALSE;\n"); 473 fprintf(ski->of, " }\n"); 474 fprintf(ski->of, " return TRUE;\n"); 475 fprintf(ski->of, "}\n"); 476 fprintf(ski->of, "#endif\n"); 477 // g_free(id); g_free(id2); 478 // } 479 } 480 481 482 /* 410 483 This function outputs the parameter type of methods without the 'const' 411 484 qualifier. … … 416 489 return; 417 490 418 orbit_cbe_voyager_write_param_typespec(ski->of, ski->tree); 419 491 orbit_cbe_voyager_write_param_typespec(ski->of, ski->tree); 420 492 } 421 493 … … 456 528 /* Find the name of the metaclass for this class if any. */ 457 529 VoyagerExtractMetaClass(ski); 458 /* Create support functionfor parameter checks. */459 VoyagerCreateParamCheck Functions(ski);530 /* Create enable defines for parameter checks. */ 531 VoyagerCreateParamCheckDefines(ski); 460 532 break; 461 533 default: … … 924 996 id2, gstr->str); 925 997 /* Output name of introducing class */ 998 #if 0 926 999 if(IDL_INTERFACE(tmptree).inheritance_spec) { 927 1000 InheritedOutputInfo ioi; … … 933 1006 (GFunc)VoyagerOutputIntroducingClass, &ioi); 934 1007 } 1008 #endif 1009 VoyagerOutputIntroducingClass(tmptree, ski, gstr); 935 1010 fprintf(ski->of, ":%s\";\n",gstr->str); /* Output the method name */ 936 1011 … … 968 1043 fprintf(ski->of, "(("); 969 1044 /* Output name of introducing class */ 1045 #if 0 970 1046 if(IDL_INTERFACE(tmptree).inheritance_spec) { 971 1047 InheritedOutputInfo ioi; … … 977 1053 (GFunc)VoyagerOutputIntroducingClass, &ioi); 978 1054 } 1055 #endif 1056 VoyagerOutputIntroducingClass(tmptree, ski, gstr); 979 1057 fprintf(ski->of, "*)nomSelf, "); 980 //fprintf(ski->of, "(nomSelf, "); 1058 981 1059 if(IDL_INTERFACE(tmptree).inheritance_spec) { 982 1060 InheritedOutputInfo ioi; … … 1035 1113 } 1036 1114 1037 /* Output a function for checking the parameters */ 1115 /* Output a function for checking the parameters. Note that we only 1116 check the object pointer for now. */ 1038 1117 if(!bOverriden) 1039 1118 { … … 1054 1133 1055 1134 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);1135 1136 fprintf(ski->of, "if(!nomIsObj(nomSelf) || !_nomIsA(nomSelf , %sClassData.classObject, NULLHANDLE))\n", id2); 1058 1137 fprintf(ski->of, " {\n"); 1059 fprintf(ski->of, " g_message(\"Object is not valid\");\n");1138 fprintf(ski->of, " nomPrintObjectPointerError(nomSelf, \"%s\", \"%s\");\n", id2, id); 1060 1139 fprintf(ski->of, " return FALSE;\n"); 1061 1140 fprintf(ski->of, " }\n"); 1141 fprintf(ski->of, " g_message(\"%%s: parameter check for %%s...\", __FUNCTION__, _nomGetClassName(nomSelf, NULLHANDLE));\n"); 1062 1142 fprintf(ski->of, " return TRUE;\n"); 1063 1143 fprintf(ski->of, "}\n"); … … 1470 1550 subski.tree = IDL_INTERFACE(ski->tree).body; 1471 1551 cbe_ski_do_list(&subski); 1552 /* Output parameter check defines */ 1472 1553 IDL_tree_traverse_parents(ski->tree, (GFunc)&cbe_ski_do_inherited_methods, ski); 1554 /* Output generic object check function */ 1555 VoyagerCreateObjectCheckFunction(id, ski); 1473 1556 break; 1474 1557 }
Note:
See TracChangeset
for help on using the changeset viewer.