home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
c't freeware shareware 1997
/
CT_SW_97.ISO
/
mac
/
Software
/
entwickl
/
win95
/
pythowin.exe
/
DATA.4
/
AXScript
/
pyaxsu.py
< prev
Wrap
Text File
|
1996-11-21
|
3KB
|
108 lines
import axscript # Built in to the script engine.
import sys
sys.stdout = sys.stderr = axscript # axscript has a "write" method.
# Error message will now go _somewhere_ - even if only the debugger!
import pyaximpl # Core code.
import traceback # for debugging.
debugging=0
reload_impl = 0
def debug_print(*args):
if debugging:
for arg in args:
print arg,
print
class AXScriptEngine:
def __init__(self, CScript):
self.cscript = CScript # The C++ script engine.
self.mgr = None
def Init(self):
debug_print("AXScriptEngine.Init called")
try:
if reload_impl: reload(pyaximpl) # for debugging
self.mgr = pyaximpl.AXScriptManager()
except:
raise pyaximpl.AXScriptException()
def Reset(self):
debug_print( "AXScriptEngine.Reset called" )
try:
if self.mgr: self.mgr.Reset()
if reload_impl: reload(pyaximpl) # For debugging purposes
self.mgr = pyaximpl.AXScriptManager() # Create a new manager.
except:
traceback.print_exc()
raise pyaximpl.AXScriptException()
def Release(self):
debug_print( "AXScriptEngine.Release called" )
try:
if self.mgr: self.mgr.Release()
self.mgr = None
except:
traceback.print_exc()
raise pyaximpl.AXScriptException()
def AddObject(self, name, IDispatch, modId, flags):
debug_print("AXScriptEngine.AddObject called with ",name, IDispatch, modId, flags)
try:
module = self.mgr.GetModule(modId)
module.AddObject(name, IDispatch, flags)
except:
traceback.print_exc()
raise pyaximpl.AXScriptException()
def AddToScript(self, sourceCode, modId, useEntry, flags, linebase, args):
debug_print("AXScriptEngine.AddToScript called with ", sourceCode, modId, useEntry, flags, linebase, args)
try:
self.mgr.AddToScript(modId, sourceCode, useEntry, flags, linebase, args)
except:
raise pyaximpl.AXScriptException()
def GetEntryPoint(self, name, modId):
debug_print("GetEntryPoint called with ", name, modId)
try:
mod = self.mgr.GetModule(modId)
rc = mod.GetEntryPoint(name)
if rc is None and mod <> 0: # Not in local - check global
rc = self.mgr.GetModule(0).GetEntryPoint(name)
return rc
except:
raise pyaximpl.AXScriptException()
def ReleaseEntryPoint(self, entryPoint):
debug_print("ReleaseEntryPoint called with ", entryPoint)
def Call(self, variantArgs, addnlArgs):
# debug_print("Call called with ", variantArgs, addnlArgs)
(modId, instmethod), flags, defiDisp = addnlArgs
try:
return self.mgr.Call(modId, instmethod, flags, defiDisp, variantArgs)
except:
raise pyaximpl.AXScriptException()
def Execute(self):
debug_print("AXScriptEngine.Execute called, but ignored!")
def SetDefaultThis(self, this):
debug_print("AXScriptEngine.SetDefaultThis called, but ignored!")
def SetDefaultDispatch(self, modId, dispatch):
try:
self.mgr.SetDefaultDispatch(modId, dispatch)
except:
raise pyaximpl.AXScriptException()
def GetDispatchForModule(self, modId):
try:
return self.mgr.GetDispatchForModule(modId)
except:
raise pyaximpl.AXScriptException()
def GetInterfaceSafetyOptions(self):
return self.mgr.GetInterfaceSafetyOptions()
def SetInterfaceSafetyOptions(self, optionsMask, enabledOptions):
return self.mgr.SetInterfaceSafetyOptions(optionsMask, enabledOptions)
def CreateScriptEngine(CScript):
debug_print("Creating script engine")
return AXScriptEngine(CScript)