You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/dev-lang/gdl/files/0.9.6-fun-fix.patch

57 lines
2.0 KiB

Author: Vitaliy Tomin <highwaystar@users.sf.net>
Description: Fix direct calling of direct function calls from Python
Bug: http://sourceforge.net/p/gnudatalanguage/bugs/678
--- a/src/pythongdl.cpp
+++ b/src/pythongdl.cpp
@@ -392,25 +392,31 @@
BaseGDL* retValGDL = NULL;
Guard<BaseGDL> retValGDL_guard;
- if( functionCall)
- {
- if( libCall)
- retValGDL = static_cast<DLibFun*>(static_cast<EnvT*>(e)->
- GetPro())->Fun()( static_cast<EnvT*>(e));
- else
- retValGDL = interpreter->call_fun(static_cast<DSubUD*>
- (static_cast<EnvUDT*>(e)
- ->GetPro())->GetTree());
- retValGDL_guard.Reset( retValGDL);
- }
- else
- {
- if( libCall)
- static_cast<DLibPro*>(e->GetPro())->Pro()(static_cast<EnvT*>(e)); // throws
- else
- interpreter->call_pro(static_cast<DSubUD*>
- (e->GetPro())->GetTree()); //throws
- }
+
+ if (functionCall) {
+ DLibFun* sub_fun_chk = dynamic_cast<DLibFun *>(static_cast<EnvT *>(e)->GetPro());
+ if (sub_fun_chk) {
+ //handle direct call function first
+ if (sub_fun_chk->DirectCall()) {
+ BaseGDL* directCallParameter = e->GetParDefined(0);
+ retValGDL = static_cast<DLibFunDirect*>(sub_fun_chk)->FunDirect()(directCallParameter, true /*isReference*/);
+ }
+ } else if (libCall)
+ retValGDL = static_cast<DLibFun *>(static_cast<EnvT *>(e)->GetPro())
+ ->Fun()(static_cast<EnvT *>(e));
+ else
+ retValGDL = interpreter->call_fun(
+ static_cast<DSubUD *>(static_cast<EnvUDT *>(e)->GetPro())
+ ->GetTree());
+ retValGDL_guard.Reset(retValGDL);
+ } else {
+ if (libCall)
+ static_cast<DLibPro *>(e->GetPro())
+ ->Pro()(static_cast<EnvT *>(e)); // throws
+ else
+ interpreter->call_pro(
+ static_cast<DSubUD *>(e->GetPro())->GetTree()); // throws
+ }
// copy back args and keywords
success = CopyArgToPython( parRef, kwRef, *e, argTuple, kwDict);