Skip to content

Commit e039e01

Browse files
committed
Fixed CORE-6446: CLOOP envelopes is wrong in IStatus
1 parent 7e1e9b3 commit e039e01

8 files changed

Lines changed: 64 additions & 18 deletions

File tree

extern/cloop/src/cloop/Generator.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,8 +542,17 @@ void CppGenerator::generate()
542542
if (method->returnTypeRef.token.type != Token::TYPE_VOID ||
543543
method->returnTypeRef.isPointer)
544544
{
545-
fprintf(out, "\t\t\t\treturn static_cast<%s>(0);\n",
546-
convertType(method->returnTypeRef).c_str());
545+
const char* ret = "\t\t\t\treturn";
546+
if (method->onErrorFunction.length())
547+
{
548+
fprintf(out, "%s %s();\n",
549+
ret, method->onErrorFunction.c_str());
550+
}
551+
else
552+
{
553+
fprintf(out, "%s static_cast<%s>(0);\n",
554+
ret, convertType(method->returnTypeRef).c_str());
555+
}
547556
}
548557

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

extern/cloop/src/cloop/Lexer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ Token& Lexer::getToken(Token& token)
9696
token.type = Token::TYPE_TYPEDEF;
9797
else if (token.text == "version")
9898
token.type = Token::TYPE_VERSION;
99+
else if (token.text == "onError")
100+
token.type = Token::TYPE_ON_ERROR;
99101
// types
100102
else if (token.text == "void")
101103
token.type = Token::TYPE_VOID;

extern/cloop/src/cloop/Lexer.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ struct Token
4949
TYPE_STRUCT,
5050
TYPE_TYPEDEF,
5151
TYPE_VERSION,
52+
TYPE_ON_ERROR,
5253
// types
5354
TYPE_VOID,
5455
TYPE_BOOLEAN,

extern/cloop/src/cloop/Parser.cpp

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -177,24 +177,43 @@ void Parser::parseTypedef()
177177
void Parser::parseItem()
178178
{
179179
Expr* notImplementedExpr = NULL;
180+
std::string onError;
180181

181-
lexer->getToken(token);
182-
183-
if (token.type == TOKEN('['))
182+
while (lexer->getToken(token).type == TOKEN('['))
184183
{
185-
getToken(token, Token::TYPE_NOT_IMPLEMENTED); // This is the only attribute we allow now.
186-
getToken(token, TOKEN('('));
187-
notImplementedExpr = parseExpr();
188-
getToken(token, TOKEN(')'));
189-
getToken(token, TOKEN(']'));
184+
lexer->getToken(token);
185+
switch (token.type)
186+
{
187+
case Token::TYPE_NOT_IMPLEMENTED:
188+
if (notImplementedExpr)
189+
syntaxError(token);
190+
getToken(token, TOKEN('('));
191+
notImplementedExpr = parseExpr();
192+
getToken(token, TOKEN(')'));
193+
getToken(token, TOKEN(']'));
194+
break;
195+
196+
case Token::TYPE_ON_ERROR:
197+
if (onError.length())
198+
syntaxError(token);
199+
lexer->getToken(token);
200+
if (token.type != Token::TYPE_IDENTIFIER)
201+
syntaxError(token);
202+
onError = token.text;
203+
getToken(token, TOKEN(']'));
204+
break;
205+
206+
default:
207+
syntaxError(token);
208+
break;
209+
}
190210
}
191-
else
192-
lexer->pushToken(token);
211+
lexer->pushToken(token);
193212

194213
TypeRef typeRef(parseTypeRef());
195214
string name(getToken(token, Token::TYPE_IDENTIFIER).text);
196215

197-
if (!notImplementedExpr && typeRef.isConst)
216+
if ((!(notImplementedExpr || onError.length())) && typeRef.isConst)
198217
{
199218
if (lexer->getToken(token).type == TOKEN('='))
200219
{
@@ -207,7 +226,7 @@ void Parser::parseItem()
207226
}
208227

209228
getToken(token, TOKEN('('));
210-
parseMethod(typeRef, name, notImplementedExpr);
229+
parseMethod(typeRef, name, notImplementedExpr, onError);
211230
}
212231

213232
void Parser::parseConstant(const TypeRef& typeRef, const string& name)
@@ -222,7 +241,7 @@ void Parser::parseConstant(const TypeRef& typeRef, const string& name)
222241
getToken(token, TOKEN(';'));
223242
}
224243

225-
void Parser::parseMethod(const TypeRef& returnTypeRef, const string& name, Expr* notImplementedExpr)
244+
void Parser::parseMethod(const TypeRef& returnTypeRef, const string& name, Expr* notImplementedExpr, const string& onError)
226245
{
227246
Method* method = new Method();
228247
interface->methods.push_back(method);
@@ -231,6 +250,7 @@ void Parser::parseMethod(const TypeRef& returnTypeRef, const string& name, Expr*
231250
method->name = name;
232251
method->version = interface->version;
233252
method->notImplementedExpr = notImplementedExpr;
253+
method->onErrorFunction = onError;
234254

235255
if (lexer->getToken(token).type != TOKEN(')'))
236256
{

extern/cloop/src/cloop/Parser.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class Method
107107
Expr* notImplementedExpr;
108108
unsigned version;
109109
bool isConst;
110+
std::string onErrorFunction;
110111
};
111112

112113

@@ -159,7 +160,7 @@ class Parser
159160
void parseTypedef();
160161
void parseItem();
161162
void parseConstant(const TypeRef& typeRef, const std::string& name);
162-
void parseMethod(const TypeRef& returnTypeRef, const std::string& name, Expr* notImplementedExpr);
163+
void parseMethod(const TypeRef& returnTypeRef, const std::string& name, Expr* notImplementedExpr, const std::string& onErrorFunction);
163164

164165
Expr* parseExpr();
165166
Expr* parseLogicalExpr();

src/include/firebird/FirebirdInterface.idl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ interface Status : Disposable
8080
void setErrors(const intptr* value);
8181
void setWarnings(const intptr* value);
8282

83+
[onError stubError]
8384
const intptr* getErrors() const;
85+
[onError stubError]
8486
const intptr* getWarnings() const;
8587

8688
Status clone() const;

src/include/firebird/IdlFbInterfaces.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6603,7 +6603,7 @@ namespace Firebird
66036603
catch (...)
66046604
{
66056605
StatusType::catchException(0);
6606-
return static_cast<const intptr_t*>(0);
6606+
return stubError();
66076607
}
66086608
}
66096609

@@ -6616,7 +6616,7 @@ namespace Firebird
66166616
catch (...)
66176617
{
66186618
StatusType::catchException(0);
6619-
return static_cast<const intptr_t*>(0);
6619+
return stubError();
66206620
}
66216621
}
66226622

src/include/firebird/Interface.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,17 @@ struct PerformanceInfo
9393
ISC_INT64 pin_records_fetched; // records fetched from statement/procedure
9494
};
9595

96+
inline const intptr_t* stubError()
97+
{
98+
static const intptr_t codes[] = {
99+
isc_arg_gds, isc_random,
100+
isc_arg_string, (intptr_t) "Unrecognized exception in Status interface",
101+
isc_arg_end
102+
};
103+
104+
return codes;
105+
}
106+
96107
} // namespace Firebird
97108

98109

0 commit comments

Comments
 (0)