Skip to content

Commit

Permalink
Improvement #7542 : Compiler warnings raise when build cloop generate…
Browse files Browse the repository at this point in the history
…d Firebird.pas in RAD Studio 11.3

Also, fixed AV in FbException.catchException()
  • Loading branch information
hvlad committed Apr 13, 2023
1 parent c7c4990 commit 30b3772
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 17 deletions.
39 changes: 39 additions & 0 deletions extern/cloop/src/cloop/Generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,12 @@ void PascalGenerator::generate()
if (!isProcedure)
fprintf(out, ": %s", convertType(method->returnTypeRef).c_str());

// Methods that present in TObject should be "reintroduce"d.
// So far there is just one case. For more cases better solution required.

if (method->name == "toString")
fprintf(out, "; reintroduce");

fprintf(out, ";\n");
}

Expand Down Expand Up @@ -1279,6 +1285,39 @@ void PascalGenerator::generate()
fprintf(out, "; cdecl;\n");
fprintf(out, "begin\n");

if (!isProcedure)
{
if (method->returnTypeRef.isPointer) {
fprintf(out, "\tResult := nil;\n");
}
else
{
char* sResult;

This comment has been minimized.

Copy link
@asfernandes

asfernandes Apr 13, 2023

Member

const char*, please

This comment has been minimized.

Copy link
@AlexPeshkoff

AlexPeshkoff Apr 13, 2023

Member

already fixed in master

switch (method->returnTypeRef.token.type)
{
case Token::TYPE_STRING:
sResult = "nil";
break;

case Token::TYPE_BOOLEAN:
sResult = "false";
break;

case Token::TYPE_IDENTIFIER:
if (method->returnTypeRef.type == BaseType::TYPE_INTERFACE)
{
sResult = "nil";
break;
}
// fallthru
default:
sResult = "0";
break;
}
fprintf(out, "\tResult := %s;\n", sResult);
}
}

if (!exceptionClass.empty())
fprintf(out, "\ttry\n\t");

Expand Down
Loading

0 comments on commit 30b3772

Please sign in to comment.