def _wrap(self, obj): # This enum returns a tuple, with 2 com objects in it. obFrame, min, lim, fFinal, obFinal = obj obFrame = _wrap(obFrame, axdebug.IID_IDebugStackFrame) if obFinal: obFinal = _wrap(obFinal, pythoncom.IID_IUnknown) return obFrame, min, lim, fFinal, obFinal
def GetPropertyInfo(obname, obvalue, dwFieldSpec, nRadix, hresult=0, dictionary = None, stackFrame = None): # returns a tuple name = typ = value = fullname = attrib = dbgprop = None if dwFieldSpec & axdebug.DBGPROP_INFO_VALUE: value = MakeNiceString(obvalue) if dwFieldSpec & axdebug.DBGPROP_INFO_NAME: name = obname if dwFieldSpec & axdebug.DBGPROP_INFO_TYPE: if hresult: typ = "Error" else: try: typ = type(obvalue).__name__ except AttributeError: typ = str(type(obvalue)) if dwFieldSpec & axdebug.DBGPROP_INFO_FULLNAME: fullname = obname if dwFieldSpec & axdebug.DBGPROP_INFO_ATTRIBUTES: if hasattr(obvalue, "has_key") or hasattr(obvalue, "__dict__"): # If it is a dict or object attrib = axdebug.DBGPROP_ATTRIB_VALUE_IS_EXPANDABLE else: attrib = 0 if dwFieldSpec & axdebug.DBGPROP_INFO_DEBUGPROP: dbgprop = _wrap(DebugProperty(name, obvalue, None, hresult, dictionary, stackFrame), axdebug.IID_IDebugProperty) return name, typ, value, fullname, attrib, dbgprop
def GetDocumentContext(self): if self.debugSite is not None: # We have a smart host - let him give it to us. return self.debugSite.GetDocumentContextFromPosition( self.codeContainer.sourceContext, self.offset, self.length) else: # Simple host - Fine - Ill do it myself! return _wrap(self, axdebug.IID_IDebugDocumentContext)
def _query_interface_(self, iid): if iid==axdebug.IID_IDebugExpressionContext: if self.expressionContext is None: self.expressionContext = _wrap(expressions.ExpressionContext(self.frame), axdebug.IID_IDebugExpressionContext) return self.expressionContext # from win32com.util import IIDToInterfaceName # print "DebugStackFrame QI with %s (%s)" % (IIDToInterfaceName(iid), str(iid)) return 0
def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid, stackFrame = None): name_vals = [] if hasattr(object, "has_key"): # If it is a dict. name_vals = object.items() dictionary = object elif hasattr(object, "__dict__"): #object with dictionary, module name_vals = object.__dict__.items() dictionary = object.__dict__ infos = [] for name, val in name_vals: infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0, dictionary, stackFrame)) return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo)
def MakeEnumDebugProperty(object, dwFieldSpec, nRadix, iid, stackFrame = None): name_vals = [] if hasattr(object, "items") and hasattr(object, "keys"): # If it is a dict. name_vals = object.iteritems() dictionary = object elif hasattr(object, "__dict__"): #object with dictionary, module name_vals = object.__dict__.iteritems() dictionary = object.__dict__ infos = [] for name, val in name_vals: infos.append(GetPropertyInfo(name, val, dwFieldSpec, nRadix, 0, dictionary, stackFrame)) return _wrap(EnumDebugPropertyInfo(infos), axdebug.IID_IEnumDebugPropertyInfo)
def _MakeDebugCodeContext(self, lineNo, charPos, len): return _wrap( contexts.DebugCodeContext(lineNo, charPos, len, self, self.site), axdebug.IID_IDebugCodeContext)
def EnumStackFrames(self): trace("DebugStackFrameSniffer.EnumStackFrames called") return _wrap(EnumDebugStackFrames(self.debugger), axdebug.IID_IEnumDebugStackFrames)
def GetDebugProperty(self): return _wrap(StackFrameDebugProperty(self.frame), axdebug.IID_IDebugProperty)
def _MakeDebugCodeContext(self, lineNo, charPos, len): return _wrap(contexts.DebugCodeContext(lineNo, charPos, len, self, self.site), axdebug.IID_IDebugCodeContext)
def GetContextOfPosition(self, charPos, maxChars): # Make one doc = _wrap(self, axdebug.IID_IDebugDocument) rc = self.codeContainer.GetCodeContextAtPosition(charPos) return rc.QueryInterface(axdebug.IID_IDebugDocumentContext)
def ParseLanguageText(self, code, radix, delim, flags): return _wrap(Expression(self.frame, code, radix, delim, flags), axdebug.IID_IDebugExpression)
def _wrap(self, obj): return _wrap(obj, axdebug.IID_IDebugCodeContext)
def EnumCodeContexts(self): return _wrap(EnumDebugCodeContexts([self]), axdebug.IID_IEnumDebugCodeContexts)
def GetResultAsDebugProperty(self): result = _wrap(DebugProperty(self.code, self.result, None, self.hresult), axdebug.IID_IDebugProperty) return self.hresult, result