def EnumCodeContextsOfPosition(self, context, charOffset, numChars): trace("EnumCodeContextsOfPosition", context, charOffset, numChars) try: context = self.codeContainers[context].GetCodeContextAtPosition(charOffset) except KeyError: raise COMException(scode=winerror.E_UNEXPECTED) enum = EnumDebugCodeContexts([context]) return _wrap(enum, axdebug.IID_IEnumDebugCodeContexts)
def OnEnterScript(self): trace("OnEnterScript") try: 1/0 except: # Bit of a hack - reach into engine. baseFrame = sys.exc_info()[2].tb_frame.f_back self.adb.SetupAXDebugging(baseFrame)
def HandleRuntimeError( self ): """Called by the engine when a runtime error occurs. If we have a debugger, we let it know. The result is a boolean which indicates if the error handler should call IActiveScriptSite::OnScriptError() """ # if self.IsAnyHost: # site = _wrap(self, axdebug.IID_IActiveScriptSite) # breakResume, errorResume, fCallOnError = self.debugApplication(activeScriptErrorDebug, site) # Do something with these! # else: trace("HandleRuntimeError") fCallOnError = 1 return fCallOnError
def __init__(self, scriptEngine): self.scriptEngine = scriptEngine self.adb = adb.Debugger() self.rootNode = None self.debugApplication = None self.ccProvider = documents.CodeContainerProvider() try: self.scriptSiteDebug = scriptEngine.GetScriptSite( axdebug.IID_IActiveScriptSiteDebug) except pythoncom.com_error: # No debugger interface (ie, dumb host). Do the extra work. trace("Scripting site has no debugger interface") self.scriptSiteDebug = None # Get the debug application object. self.debugApplication = None if self.scriptSiteDebug is not None: # Spec says that we should test for this, and if it fails revert to # PDM application. try: self.debugApplication = self.scriptSiteDebug.GetApplication() self.rootNode = self.scriptSiteDebug.GetRootApplicationNode() except pythoncom.com_error: self.debugApplication = None if self.debugApplication is None: # Try to get/create the default one # NOTE - Dont catch exceptions here - let the parent do it, # so it knows debug support is available. pdm = pythoncom.CoCreateInstance(axdebug.CLSID_ProcessDebugManager, None, pythoncom.CLSCTX_ALL, axdebug.IID_IProcessDebugManager) self.debugApplication = pdm.GetDefaultApplication() self.rootNode = self.debugApplication.GetRootNode() assert self.debugApplication is not None, "Need to have a DebugApplication object by now!" self.activeScriptDebug = None if self.debugApplication is not None: self.adb.AttachApp(self.debugApplication, self.ccProvider) self.codeContainers = {} self.activeScriptDebug = _wrap( ActiveScriptDebug(self, self.codeContainers), axdebug.IID_IActiveScriptDebug)
def __init__(self, scriptEngine): self.scriptEngine = scriptEngine self.adb = adb.Debugger() self.rootNode = None self.debugApplication = None self.ccProvider = documents.CodeContainerProvider() try: self.scriptSiteDebug = scriptEngine.GetScriptSite(axdebug.IID_IActiveScriptSiteDebug) except pythoncom.com_error: # No debugger interface (ie, dumb host). Do the extra work. trace("Scripting site has no debugger interface") self.scriptSiteDebug = None # Get the debug application object. self.debugApplication = None if self.scriptSiteDebug is not None: # Spec says that we should test for this, and if it fails revert to # PDM application. try: self.debugApplication = self.scriptSiteDebug.GetApplication() self.rootNode = self.scriptSiteDebug.GetRootApplicationNode() except pythoncom.com_error: self.debugApplication = None if self.debugApplication is None: # Try to get/create the default one # NOTE - Dont catch exceptions here - let the parent do it, # so it knows debug support is available. pdm=pythoncom.CoCreateInstance(axdebug.CLSID_ProcessDebugManager,None,pythoncom.CLSCTX_ALL, axdebug.IID_IProcessDebugManager) self.debugApplication = pdm.GetDefaultApplication() self.rootNode = self.debugApplication.GetRootNode() assert self.debugApplication is not None, "Need to have a DebugApplication object by now!" self.activeScriptDebug = None if self.debugApplication is not None: self.adb.AttachApp(self.debugApplication, self.ccProvider) self.codeContainers = {} self.activeScriptDebug = _wrap(ActiveScriptDebug(self, self.codeContainers), axdebug.IID_IActiveScriptDebug)
def GetScriptletTextAttributes(self, code, delim, flags): trace("GetScriptletTextAttributes", code, delim, flags) container = SourceCodeContainer(code, "<Temp Code Block>") return container.GetSyntaxColorAttributes()
def _query_interface_(self, iid): trace("DebuggerQI with", iid) return _wrap(self.debugMgr.scriptEngine, iid)
def OnLeaveScript(self): trace("OnLeaveScript") self.adb.ResetAXDebugging()
def _query_interface_for_debugger_(self, iid): if iid in self._debugger_interfaces_: return self.activeScriptDebug trace("DebugManager QI - unknown IID", iid) return 0
def GetScriptletTextAttributes(self, code, delim, flags): trace ("GetScriptletTextAttributes", code, delim, flags) container = SourceCodeContainer(code, "<Temp Code Block>") return container.GetSyntaxColorAttributes()