diff options
Diffstat (limited to 'wizards/source/scriptforge/SF_PythonHelper.xba')
-rw-r--r-- | wizards/source/scriptforge/SF_PythonHelper.xba | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/wizards/source/scriptforge/SF_PythonHelper.xba b/wizards/source/scriptforge/SF_PythonHelper.xba index b90454dcd88d..c54d799ae282 100644 --- a/wizards/source/scriptforge/SF_PythonHelper.xba +++ b/wizards/source/scriptforge/SF_PythonHelper.xba @@ -557,6 +557,7 @@ Const cstNoArgs = "+++NOARGS+++", cstSymEmpty = "+++EMPTY+++" ' Determines the CallType Const vbGet = 2, vbLet = 4, vbMethod = 1, vbSet = 8 ' Protocol flags +Const cstDateRet = 128 ' Return value can be a date Const cstArgArray = 512 ' 1st argument can be a 2D array Const cstRetArray = 1024 ' Return value can be an array Const cstUno = 256 ' Return value can be a UNO object @@ -580,7 +581,8 @@ Check: If vArg = cstNoArgs Then Exit For End If If VarType(vArg) = V_STRING Then - If vArg = cstSymEmpty Then + If Len(vArg) = 0 Then + ElseIf vArg = cstSymEmpty Then vArg = Empty ElseIf vArg = cstSymNull Then vArg = Null @@ -613,6 +615,11 @@ Try: ' may be considered as properties when no argument ' Requires Python and Basic update in the concerned library but is transparent for this dispatcher + ' Initialize Python persistent storage at 1st call + If IsEmpty(_SF_.PythonStorage) Then _SF_._InitPythonStorage() + ' Reset any error + _SF_._Stackreset() + Select case VarType(BasicObject) Case V_STRING ' Special entry for CreateScriptService() @@ -644,9 +651,18 @@ Try: bBasicClass = ( Left(sObjectType, 3) <> "SF_" ) sLibrary = Split(vBasicObject.ServiceName, ".")(0) + ' Methods in standard modules returning a date are hardcoded as exceptions + If Not bBasicClass And ((CallType And vbMethod) = vbMethod) And ((CallType And cstDateRet) = cstDateRet) Then + Select Case sLibrary + Case "ScriptForge" + If sObjectType = "SF_FileSystem" And Script = "GetFileModified" Then vReturn = SF_FileSystem.GetFileModified(vArgs(0)) + End Select + ' Methods in usual modules are called by ExecuteBasicScript() except if they use a ParamArray - If Not bBasicClass And (CallType And vbMethod) = vbMethod Then + ElseIf Not bBasicClass And (CallType And vbMethod) = vbMethod Then sScript = sLibrary & "." & sObjectType & "." & Script + ' Force validation in targeted function, not in ExecuteBasicScript() + _SF_.StackLevel = -1 Select Case UBound(vArgs) Case -1 : vReturn = sess.ExecuteBasicScript(, sScript) Case 0 : vReturn = sess.ExecuteBasicScript(, sScript, vArgs(0)) @@ -658,6 +674,7 @@ Try: Case 6 : vReturn = sess.ExecuteBasicScript(, sScript, vArgs(0), vArgs(1), vArgs(2), vArgs(3), vArgs(4), vArgs(5), vArgs(6)) Case 7 : vReturn = sess.ExecuteBasicScript(, sScript, vArgs(0), vArgs(1), vArgs(2), vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7)) End Select + _SF_.StackLevel = 0 ' Properties in any service are got and set with obj.GetProperty/SetProperty(...) ElseIf (CallType And vbGet) = vbGet Then @@ -677,8 +694,6 @@ Try: ElseIf bBasicClass And ((CallType And vbMethod) = vbMethod) Then Select Case UBound(vArgs) Case -1 : vReturn = CallByName(vBasicObject, Script, vbMethod) - ' Special case: Dispose() must update the cache for class objects created in Python scripts - If Script = "Dispose" Then Set _SF_.PythonStorage(BasicObject) = Nothing Case 0 : vReturn = CallByName(vBasicObject, Script, vbMethod, vArgs(0)) Case 1 : vReturn = CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1)) Case 2 : vReturn = CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2)) @@ -689,6 +704,12 @@ Try: Case 7 : vReturn = CallByName(vBasicObject, Script, vbMethod, vArgs(0), vArgs(1), vArgs(2), vArgs(3), vArgs(4), vArgs(5), vArgs(6), vArgs(7)) End Select End If + + ' Post processing + If Script = "Dispose" Then + ' Special case: Dispose() must update the cache for class objects created in Python scripts + Set _SF_.PythonStorage(BasicObject) = Nothing + End If Case Else End Select @@ -725,7 +746,7 @@ Try: End If Else ' Scalar or Nothing ReDim vReturnArray(0 To 1) - vReturnArray(0) = vReturn + If VarType(vReturn) = V_DATE Then vReturnArray(0) = SF_Utils._CDateToIso(vReturn) Else vReturnArray(0) = vReturn vReturnArray(1) = VarType(vReturn) End If @@ -749,4 +770,4 @@ Private Function _Repr() As String End Function ' ScriptForge.SF_PythonHelper._Repr REM ================================================= END OF SCRIPTFORGE.SF_PythonHelper -</script:module> +</script:module>
\ No newline at end of file |