summaryrefslogtreecommitdiff
blob: a3a4118ceb0af2432255bbf05d9047c2b6ea4018 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
Author: Vitaliy Tomin <highwaystar@users.sf.net>
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<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);