@@ -357,15 +357,8 @@ void CppGenerator::generate()
357357
358358 fprintf (out, " \n\t\t " );
359359
360- string statusName;
361-
362- if (!method->parameters .empty () &&
363- parser->exceptionInterface &&
364- method->parameters .front ()->typeRef .token .text == parser->exceptionInterface ->name )
365- {
366- statusName = method->parameters .front ()->name ;
360+ if (!method->statusName .empty ())
367361 fprintf (out, " template <typename StatusType> " );
368- }
369362
370363 fprintf (out, " %s %s(" ,
371364 convertType (method->returnTypeRef ).c_str (), method->name .c_str ());
@@ -379,7 +372,7 @@ void CppGenerator::generate()
379372 if (k != method->parameters .begin ())
380373 fprintf (out, " , " );
381374
382- if (k == method->parameters .begin () && !statusName.empty ())
375+ if (k == method->parameters .begin () && !method-> statusName .empty ())
383376 fprintf (out, " StatusType* %s" , parameter->name .c_str ());
384377 else
385378 {
@@ -397,7 +390,7 @@ void CppGenerator::generate()
397390 fprintf (out, " \t\t\t {\n " );
398391
399392 const string exceptionClass (" StatusType" );
400- ActionParametersBlock apb = {out, LANGUAGE_CPP, prefix, exceptionClass, statusName, interface, method};
393+ ActionParametersBlock apb = {out, LANGUAGE_CPP, prefix, exceptionClass, interface, method};
401394
402395 if (method->notImplementedAction )
403396 method->notImplementedAction ->generate (apb, 4 );
@@ -419,11 +412,11 @@ void CppGenerator::generate()
419412 fprintf (out, " \t\t\t }\n " );
420413 }
421414
422- if (!statusName.empty ())
415+ if (!method-> statusName .empty ())
423416 {
424417 fprintf (out, " \t\t\t " );
425418
426- fprintf (out, " StatusType::clearException(%s)" , statusName.c_str ());
419+ fprintf (out, " StatusType::clearException(%s)" , method-> statusName .c_str ());
427420
428421 fprintf (out, " ;\n " );
429422 }
@@ -694,7 +687,19 @@ void CppGenerator::generate()
694687 }
695688 }
696689
697- fprintf (out, " )%s = 0;\n " , (method->isConst ? " const" : " " ));
690+ fprintf (out, " )%s" , (method->isConst ? " const" : " " ));
691+
692+ if (method->stubAction )
693+ {
694+ const string exceptionClass (" StatusType" );
695+ ActionParametersBlock apb = {out, LANGUAGE_CPP, prefix, exceptionClass, interface, method};
696+
697+ fprintf (out, " \n\t\t {\n " );
698+ method->stubAction ->generate (apb, 3 );
699+ fprintf (out, " \t\t }\n " );
700+ }
701+ else
702+ fprintf (out, " = 0;\n " );
698703 }
699704
700705 fprintf (out, " \t };\n " );
@@ -1227,7 +1232,10 @@ void PascalGenerator::generate()
12271232 if (!isProcedure)
12281233 fprintf (out, " : %s" , convertType (method->returnTypeRef ).c_str ());
12291234
1230- fprintf (out, " ; virtual; abstract;\n " );
1235+ fprintf (out, " ; virtual;" );
1236+ if (!method->stubAction )
1237+ fprintf (out, " abstract;" );
1238+ fprintf (out, " \n " );
12311239 }
12321240
12331241 fprintf (out, " \t end;\n\n " );
@@ -1252,15 +1260,6 @@ void PascalGenerator::generate()
12521260 bool isProcedure = method->returnTypeRef .token .type == Token::TYPE_VOID &&
12531261 !method->returnTypeRef .isPointer ;
12541262
1255- string statusName;
1256-
1257- if (!method->parameters .empty () &&
1258- parser->exceptionInterface &&
1259- method->parameters .front ()->typeRef .token .text == parser->exceptionInterface ->name )
1260- {
1261- statusName = method->parameters .front ()->name ;
1262- }
1263-
12641263 fprintf (out, " %s %s.%s(" ,
12651264 (isProcedure ? " procedure" : " function" ),
12661265 escapeName (interface->name , true ).c_str (),
@@ -1291,8 +1290,7 @@ void PascalGenerator::generate()
12911290 {
12921291 fprintf (out, " \t if (vTable.version < %d) then begin\n " , method->version );
12931292
1294- ActionParametersBlock apb = {out, LANGUAGE_PASCAL, prefix, exceptionClass,
1295- statusName, interface, method};
1293+ ActionParametersBlock apb = {out, LANGUAGE_PASCAL, prefix, exceptionClass, interface, method};
12961294
12971295 if (method->notImplementedAction )
12981296 method->notImplementedAction ->generate (apb, 2 );
@@ -1333,8 +1331,8 @@ void PascalGenerator::generate()
13331331 if (ident > 1 )
13341332 fprintf (out, " \t end;\n " );
13351333
1336- if (!statusName.empty () && !exceptionClass.empty ())
1337- fprintf (out, " \t %s.checkException(%s);\n " , exceptionClass.c_str (), escapeName (statusName).c_str ());
1334+ if (!method-> statusName .empty () && !exceptionClass.empty ())
1335+ fprintf (out, " \t %s.checkException(%s);\n " , exceptionClass.c_str (), escapeName (method-> statusName ).c_str ());
13381336
13391337 fprintf (out, " end;\n\n " );
13401338 }
@@ -1358,6 +1356,8 @@ void PascalGenerator::generate()
13581356 bool isProcedure = method->returnTypeRef .token .type == Token::TYPE_VOID &&
13591357 !method->returnTypeRef .isPointer ;
13601358
1359+ ActionParametersBlock apb = {out, LANGUAGE_PASCAL, prefix, exceptionClass, interface, method};
1360+
13611361 fprintf (out, " %s %sImpl_%sDispatcher(this: %s" ,
13621362 (isProcedure ? " procedure" : " function" ),
13631363 escapeName (interface->name , true ).c_str (),
@@ -1380,39 +1380,7 @@ void PascalGenerator::generate()
13801380
13811381 fprintf (out, " ; cdecl;\n " );
13821382 fprintf (out, " begin\n " );
1383-
1384- if (!isProcedure)
1385- {
1386- if (method->returnTypeRef .isPointer ) {
1387- fprintf (out, " \t Result := nil;\n " );
1388- }
1389- else
1390- {
1391- const char * sResult ;
1392- switch (method->returnTypeRef .token .type )
1393- {
1394- case Token::TYPE_STRING:
1395- sResult = " nil" ;
1396- break ;
1397-
1398- case Token::TYPE_BOOLEAN:
1399- sResult = " false" ;
1400- break ;
1401-
1402- case Token::TYPE_IDENTIFIER:
1403- if (method->returnTypeRef .type == BaseType::TYPE_INTERFACE)
1404- {
1405- sResult = " nil" ;
1406- break ;
1407- }
1408- // fallthru
1409- default :
1410- sResult = " 0" ;
1411- break ;
1412- }
1413- fprintf (out, " \t Result := %s;\n " , sResult );
1414- }
1415- }
1383+ DefAction (DefAction::DEF_IGNORE).generate (apb, 1 );
14161384
14171385 if (!exceptionClass.empty ())
14181386 fprintf (out, " \t try\n\t " );
@@ -1454,8 +1422,35 @@ void PascalGenerator::generate()
14541422
14551423 fprintf (out, " \t end\n " );
14561424 }
1457-
14581425 fprintf (out, " end;\n\n " );
1426+
1427+ if (method->stubAction )
1428+ {
1429+ fprintf (out, " %s %sImpl.%s(" ,
1430+ (isProcedure ? " procedure" : " function" ),
1431+ escapeName (interface->name , true ).c_str (),
1432+ escapeName (method->name ).c_str ());
1433+
1434+ for (vector<Parameter*>::iterator k = method->parameters .begin ();
1435+ k != method->parameters .end ();
1436+ ++k)
1437+ {
1438+ Parameter* parameter = *k;
1439+
1440+ fprintf (out, " %s%s" ,
1441+ k == method->parameters .begin () ? " " : " ; " ,
1442+ convertParameter (*parameter).c_str ());
1443+ }
1444+
1445+ fprintf (out, " )" );
1446+ if (!isProcedure)
1447+ fprintf (out, " : %s" , convertType (method->returnTypeRef ).c_str ());
1448+ fprintf (out, " ;\n " );
1449+
1450+ fprintf (out, " begin\n " );
1451+ method->stubAction ->generate (apb, 1 );
1452+ fprintf (out, " end;\n\n " );
1453+ }
14591454 }
14601455
14611456 fprintf (out, " var\n " );
0 commit comments