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