home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activepython / ActivePython-2.1.1.msi / Python21_win32comext_axdebug_gateways.py < prev    next >
Encoding:
Python Source  |  2001-07-26  |  15.5 KB  |  454 lines

  1. # Classes which describe interfaces.
  2.  
  3. from win32com.server.exception import Exception
  4. from win32com.server.util import ListEnumeratorGateway
  5. from win32com.axdebug import axdebug
  6. from win32com.axdebug.util import RaiseNotImpl, _wrap
  7. import pythoncom
  8. import win32com.server.connect
  9. import winerror
  10. import string
  11.  
  12. class EnumDebugCodeContexts(ListEnumeratorGateway):
  13.     """A class to expose a Python sequence as an EnumDebugCodeContexts
  14.  
  15.     Create an instance of this class passing a sequence (list, tuple, or
  16.     any sequence protocol supporting object) and it will automatically
  17.     support the EnumDebugCodeContexts interface for the object.
  18.  
  19.     """
  20.     _com_interfaces_ = [ axdebug.IID_IEnumDebugCodeContexts ]
  21.  
  22. class EnumDebugStackFrames(ListEnumeratorGateway):
  23.     """A class to expose a Python sequence as an EnumDebugStackFrames
  24.  
  25.     Create an instance of this class passing a sequence (list, tuple, or
  26.     any sequence protocol supporting object) and it will automatically
  27.     support the EnumDebugStackFrames interface for the object.
  28.  
  29.     """
  30.     _com_interfaces_ = [ axdebug.IID_IEnumDebugStackFrames ]
  31.  
  32. class EnumDebugApplicationNodes(ListEnumeratorGateway):
  33.     """A class to expose a Python sequence as an EnumDebugStackFrames
  34.  
  35.     Create an instance of this class passing a sequence (list, tuple, or
  36.     any sequence protocol supporting object) and it will automatically
  37.     support the EnumDebugApplicationNodes interface for the object.
  38.  
  39.     """
  40.     _com_interfaces_ = [ axdebug.IID_IEnumDebugApplicationNodes ]
  41.  
  42. class EnumRemoteDebugApplications(ListEnumeratorGateway):
  43.     _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplications ]
  44.  
  45. class EnumRemoteDebugApplicationThreads(ListEnumeratorGateway):
  46.     _com_interfaces_ = [ axdebug.IID_IEnumRemoteDebugApplicationThreads ]
  47.  
  48. class DebugDocumentInfo:
  49.     _public_methods_ = ["GetName", "GetDocumentClassId"]
  50.     _com_interfaces_ = [axdebug.IID_IDebugDocumentInfo]
  51.     def __init__(self):
  52.         pass
  53.     def GetName(self, dnt):
  54.         """ Get the one of the name of the document
  55.             dnt -- int DOCUMENTNAMETYPE
  56.         """
  57.         RaiseNotImpl("GetName")
  58.     def GetDocumentClassId(self):
  59.         """
  60.             Result must be an IID object (or string representing one).
  61.         """
  62.         RaiseNotImpl("GetDocumentClassId")
  63.         
  64. class DebugDocumentProvider(DebugDocumentInfo):
  65.     _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"]
  66.     _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [axdebug.IID_IDebugDocumentProvider]
  67.     def GetDocument(self):
  68.         RaiseNotImpl("GetDocument")
  69.  
  70. class DebugApplicationNode(DebugDocumentProvider):
  71.     """Provides the functionality of IDebugDocumentProvider, plus a context within a project tree.
  72.     """
  73.     _public_methods_ = string.split("""EnumChildren GetParent SetDocumentProvider 
  74.             Close Attach Detach""") + \
  75.         DebugDocumentProvider._public_methods_
  76.     _com_interfaces_ = [axdebug.IID_IDebugDocumentProvider] + \
  77.         DebugDocumentProvider._com_interfaces_
  78.     def __init__(self):
  79.         DebugDocumentProvider.__init__(self)
  80.     def EnumChildren(self):
  81.         # Result is type PyIEnumDebugApplicationNodes
  82.         RaiseNotImpl("EnumChildren")
  83.     def GetParent(self):
  84.         # result is type PyIDebugApplicationNode
  85.         RaiseNotImpl("GetParent")
  86.     def SetDocumentProvider(self, pddp): # PyIDebugDocumentProvider pddp
  87.         # void result.
  88.         RaiseNotImpl("SetDocumentProvider")
  89.     def Close(self):
  90.         # void result.
  91.         RaiseNotImpl("Close")
  92.     def Attach(self, parent): # PyIDebugApplicationNode
  93.              # void result.
  94.         RaiseNotImpl("Attach")
  95.     def Detach(self):
  96.         # void result.
  97.         RaiseNotImpl("Detach")
  98.  
  99. class DebugApplicationNodeEvents:
  100.     """Event interface for DebugApplicationNode object.
  101.     """
  102.     _public_methods_ = string.split("onAddChild onRemoveChild onDetach")
  103.     _com_interfaces_ = [axdebug.IID_IDebugApplicationNodeEvents]
  104.     def __init__(self):
  105.         pass
  106.     def onAddChild(self, child): # PyIDebugApplicationNode
  107.              # void result.
  108.         RaiseNotImpl("onAddChild")
  109.     def onRemoveChild(self, child): # PyIDebugApplicationNode
  110.         # void result.
  111.         RaiseNotImpl("onRemoveChild")
  112.     def onDetach(self):
  113.         # void result.
  114.         RaiseNotImpl("onDetach")
  115.     def onAttach(self, parent): # PyIDebugApplicationNode
  116.         # void result.
  117.         RaiseNotImpl("onAttach")
  118.  
  119. class DebugDocument(DebugDocumentInfo):
  120.     """The base interface to all debug documents.  
  121.     """
  122.     _public_methods_ = DebugDocumentInfo._public_methods_
  123.     _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_
  124.  
  125. class DebugDocumentText(DebugDocument):
  126.     """The interface to a text only debug document.
  127.     """
  128.     _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + \
  129.                      DebugDocument._com_interfaces_
  130.     _public_methods_ = ["GetDocumentAttributes", "GetSize",
  131.                         "GetPositionOfLine", "GetLineOfPosition", "GetText",
  132.                         "GetPositionOfContext", "GetContextOfPosition"] + \
  133.                      DebugDocument._public_methods_ 
  134.     def __init__(self):
  135.         pass
  136.     # IDebugDocumentText
  137.     def GetDocumentAttributes(self):
  138.         # Result is int (TEXT_DOC_ATTR)
  139.         RaiseNotImpl("GetDocumentAttributes")
  140.     def GetSize(self):
  141.         # Result is (numLines, numChars)
  142.         RaiseNotImpl("GetSize")
  143.     def GetPositionOfLine(self, cLineNumber):
  144.         # Result is int char position
  145.         RaiseNotImpl("GetPositionOfLine")
  146.     def GetLineOfPosition(self, charPos):
  147.         # Result is int, int (lineNo, offset)
  148.         RaiseNotImpl("GetLineOfPosition")
  149.     def GetText(self, charPos, maxChars, wantAttr):
  150.         """Params
  151.         charPos -- integer
  152.         maxChars -- integer
  153.         wantAttr -- Should the function compute attributes.
  154.  
  155.         Return value must be (string, attribtues).  attributes may be
  156.         None if(not wantAttr)
  157.         """
  158.         RaiseNotImpl("GetText")
  159.     def GetPositionOfContext(self, debugDocumentContext):
  160.         """Params
  161.         debugDocumentContext -- a PyIDebugDocumentContext object.
  162.     
  163.         Return value must be (charPos, numChars)
  164.         """
  165.         RaiseNotImpl("GetPositionOfContext")
  166.     def GetContextOfPosition(self, charPos, maxChars):
  167.         """Params are integers.
  168.         Return value must be PyIDebugDocumentContext object
  169.         """
  170.         print self
  171.         RaiseNotImpl("GetContextOfPosition")
  172.  
  173. class DebugDocumentTextExternalAuthor:
  174.     """Allow external editors to edit file-based debugger documents, and to notify the document when the source file has been changed.
  175.     """
  176.     _public_methods_ = ["GetPathName", "GetFileName", "NotifyChanged"]
  177.     _com_interfaces_ = [axdebug.IID_IDebugDocumentTextExternalAuthor]
  178.     def __init__(self):
  179.         pass
  180.     def GetPathName(self):
  181.         """Return the full path (including file name) to the document's source file.
  182.         
  183.         Result must be (filename, fIsOriginal), where
  184.         - if fIsOriginalPath is TRUE if the path refers to the original file for the document.
  185.         - if fIsOriginalPath is FALSE if the path refers to a newly created temporary file.
  186.  
  187.         raise Exception(winerror.E_FAIL) if no source file can be created/determined.  
  188.         """
  189.         RaiseNotImpl("GetPathName")
  190.   
  191.     def GetFileName(self):
  192.         """Return just the name of the document, with no path information.  (Used for "Save As...")
  193.  
  194.         Result is a string
  195.         """
  196.         RaiseNotImpl("GetFileName")
  197.   
  198.     def NotifyChanged(self):
  199.         """ Notify the host that the document's source file has been saved and  
  200.         that its contents should be refreshed.
  201.         """
  202.         RaiseNotImpl("NotifyChanged")
  203.  
  204.  
  205. class DebugDocumentTextEvents:
  206.     _public_methods_ = string.split("""onDestroy onInsertText onRemoveText 
  207.               onReplaceText onUpdateTextAttributes onUpdateDocumentAttributes""")
  208.     _com_interfaces_ = [ axdebug.IID_IDebugDocumentTextEvents ]
  209.     def __init__(self):
  210.         pass
  211.     def onDestroy(self):
  212.         # Result is void.
  213.         RaiseNotImpl("onDestroy")
  214.     def onInsertText(self, cCharacterPosition, cNumToInsert):
  215.         # Result is void.
  216.         RaiseNotImpl("onInsertText")
  217.     def onRemoveText(self, cCharacterPosition, cNumToRemove):
  218.         # Result is void.
  219.         RaiseNotImpl("onRemoveText")
  220.     def onReplaceText(self, cCharacterPosition, cNumToReplace):
  221.         # Result is void.
  222.         RaiseNotImpl("onReplaceText")
  223.     def onUpdateTextAttributes(self, cCharacterPosition, cNumToUpdate):
  224.         # Result is void.
  225.         RaiseNotImpl("onUpdateTextAttributes")
  226.     def onUpdateDocumentAttributes(self,textdocattr): # TEXT_DOC_ATTR
  227.         # Result is void.
  228.         RaiseNotImpl("onUpdateDocumentAttributes")
  229.  
  230. class DebugDocumentContext:
  231.     _public_methods_ = [ 'GetDocument', 'EnumCodeContexts']
  232.     _com_interfaces_ = [ axdebug.IID_IDebugDocumentContext ]
  233.     def __init__(self):
  234.         pass
  235.     def GetDocument(self):
  236.         """Return value must be a PyIDebugDocument object
  237.         """
  238.         RaiseNotImpl("GetDocument")
  239.  
  240.     def EnumCodeContexts(self):
  241.         """Return value must be a PyIEnumDebugCodeContexts object
  242.         """
  243.         RaiseNotImpl("EnumCodeContexts")
  244.  
  245.  
  246. class DebugCodeContext:
  247.     _public_methods_ = [ 'GetDocumentContext', 'SetBreakPoint']
  248.     _com_interfaces_ = [ axdebug.IID_IDebugCodeContext ]
  249.     def __init__(self):
  250.         pass
  251.     def GetDocumentContext(self):
  252.         """Return value must be a PyIDebugDocumentContext object
  253.         """
  254.         RaiseNotImpl("GetDocumentContext")
  255.     def SetBreakPoint(self, bps):
  256.         """bps -- an integer with flags.
  257.         """
  258.         RaiseNotImpl("SetBreakPoint")
  259.  
  260.  
  261. class DebugStackFrame:
  262.     """Abstraction representing a logical stack frame on the stack of a thread."""
  263.     _public_methods_ = [ 'GetCodeContext', 'GetDescriptionString', 'GetLanguageString', 'GetThread', 'GetDebugProperty']
  264.     _com_interfaces_ = [ axdebug.IID_IDebugStackFrame ]
  265.     def __init__(self):
  266.         pass
  267.     def GetCodeContext(self):
  268.         """Returns the current code context associated with the stack frame.
  269.  
  270.         Return value must be a IDebugCodeContext object
  271.         """
  272.         RaiseNotImpl("GetCodeContext")
  273.     def GetDescriptionString(self, fLong):
  274.         """Returns a textual description of the stack frame.
  275.         
  276.         fLong -- A flag indicating if the long name is requested.
  277.         """
  278.         RaiseNotImpl("GetDescriptionString")
  279.     def GetLanguageString(self):
  280.         """Returns a short or long textual description of the language.
  281.         
  282.         fLong -- A flag indicating if the long name is requested.
  283.         """
  284.         RaiseNotImpl("GetLanguageString")
  285.     def GetThread(self):
  286.         """ Returns the thread associated with this stack frame.
  287.  
  288.         Result must be a IDebugApplicationThread
  289.         """
  290.         RaiseNotImpl("GetThread")
  291.     def GetDebugProperty(self):
  292.         RaiseNotImpl("GetDebugProperty")
  293.  
  294.  
  295. class DebugDocumentHost:
  296.     """The interface from the IDebugDocumentHelper back to  
  297.     the smart host or language engine.  This interface  
  298.     exposes host specific functionality such as syntax coloring.
  299.     """
  300.     _public_methods_ = [ 'GetDeferredText', 'GetScriptTextAttributes', 'OnCreateDocumentContext', 'GetPathName', 'GetFileName', 'NotifyChanged']
  301.     _com_interfaces_ = [ axdebug.IID_IDebugDocumentHost ]
  302.     def __init__(self):
  303.         pass
  304.     def GetDeferredText(self, dwTextStartCookie,  maxChars, bWantAttr):
  305.         RaiseNotImpl("GetDeferredText")
  306.   
  307.     def GetScriptTextAttributes(self, codeText, delimterText, flags):
  308.         # Result must be an attribute sequence of same "length" as the code.    
  309.         RaiseNotImpl("GetScriptTextAttributes")
  310.   
  311.     def OnCreateDocumentContext(self): 
  312.         # Result must be a PyIUnknown
  313.         RaiseNotImpl("OnCreateDocumentContext")
  314.   
  315.     def GetPathName(self):
  316.         # Result must be (string, int) where the int is a BOOL
  317.         # - TRUE if the path refers to the original file for the document.
  318.         # - FALSE if the path refers to a newly created temporary file.
  319.         # - raise Exception(scode=E_FAIL) if no source file can be created/determined.  
  320.         RaiseNotImpl("GetPathName")
  321.   
  322.     def GetFileName(self):
  323.         # Result is a string with just the name of the document, no path information.  
  324.         RaiseNotImpl("GetFileName")
  325.   
  326.     def NotifyChanged(self):
  327.         RaiseNotImpl("NotifyChanged")
  328.  
  329. # Additional gateway related functions.
  330.  
  331. class DebugDocumentTextConnectServer:
  332.     _public_methods_ = win32com.server.connect.IConnectionPointContainer_methods + win32com.server.connect.IConnectionPoint_methods
  333.     _com_interfaces_ = [pythoncom.IID_IConnectionPoint, pythoncom.IID_IConnectionPointContainer]
  334.     # IConnectionPoint interfaces
  335.     def __init__(self):
  336.         self.cookieNo = -1
  337.         self.connections = {}
  338.     def EnumConnections(self):
  339.         RaiseNotImpl("EnumConnections")
  340.     def GetConnectionInterface(self):
  341.         RaiseNotImpl("GetConnectionInterface")
  342.     def GetConnectionPointContainer(self):
  343.         return _wrap(self)
  344.     def Advise(self, pUnk):
  345.         # Creates a connection to the client.  Simply allocate a new cookie,
  346.         # find the clients interface, and store it in a dictionary.
  347.         interface = pUnk.QueryInterface(axdebug.IID_IDebugDocumentTextEvents,1)
  348.         self.cookieNo = self.cookieNo + 1
  349.         self.connections[self.cookieNo] = interface
  350.         return self.cookieNo
  351.     def Unadvise(self, cookie):
  352.         # Destroy a connection - simply delete interface from the map.
  353.         try:
  354.             del self.connections[cookie]
  355.         except KeyError:
  356.             return Exception(scode=winerror.E_UNEXPECTED)
  357.     # IConnectionPointContainer interfaces
  358.     def EnumConnectionPoints(self):
  359.         RaiseNotImpl("EnumConnectionPoints")
  360.     def FindConnectionPoint(self, iid):
  361.         # Find a connection we support.  Only support the single event interface.
  362.         if iid==axdebug.IID_IDebugDocumentTextEvents:
  363.             return _wrap(self)
  364.         raise Exception(scode=winerror.E_NOINTERFACE) # ??
  365.  
  366. class RemoteDebugApplicationEvents:
  367.     _public_methods_ = ["OnConnectDebugger","OnDisconnectDebugger","OnSetName","OnDebugOutput","OnClose","OnEnterBreakPoint","OnLeaveBreakPoint","OnCreateThread","OnDestroyThread","OnBreakFlagChange"]
  368.     _com_interfaces_ = [axdebug.IID_IRemoteDebugApplicationEvents]
  369.     def OnConnectDebugger(self, appDebugger):
  370.         """appDebugger -- a PyIApplicationDebugger
  371.         """
  372.         RaiseNotImpl("OnConnectDebugger")
  373.     def OnDisconnectDebugger(self):
  374.         RaiseNotImpl("OnDisconnectDebugger")
  375.     def OnSetName(self, name):
  376.         RaiseNotImpl("OnSetName")
  377.     def OnDebugOutput(self, string):
  378.         RaiseNotImpl("OnDebugOutput")
  379.     def OnClose(self):
  380.         RaiseNotImpl("OnClose")
  381.     def OnEnterBreakPoint(self, rdat):
  382.         """rdat -- PyIRemoteDebugApplicationThread
  383.         """
  384.         RaiseNotImpl("OnEnterBreakPoint")
  385.     def OnLeaveBreakPoint(self, rdat):
  386.         """rdat -- PyIRemoteDebugApplicationThread
  387.         """
  388.         RaiseNotImpl("OnLeaveBreakPoint")
  389.     def OnCreateThread(self, rdat):
  390.         """rdat -- PyIRemoteDebugApplicationThread
  391.         """
  392.         RaiseNotImpl("OnCreateThread")
  393.     def OnDestroyThread(self, rdat):
  394.         """rdat -- PyIRemoteDebugApplicationThread
  395.         """
  396.         RaiseNotImpl("OnDestroyThread")
  397.     def OnBreakFlagChange(self, abf, rdat):
  398.         """abf -- int - one of the axdebug.APPBREAKFLAGS constants
  399.         rdat -- PyIRemoteDebugApplicationThread
  400.         RaiseNotImpl("OnBreakFlagChange")
  401.         """
  402. class DebugExpressionContext:
  403.     _public_methods_ = ["ParseLanguageText", "GetLanguageInfo"]
  404.     _com_interfaces_ = [axdebug.IID_IDebugExpressionContext]
  405.     def __init__(self):
  406.         pass
  407.     def ParseLanguageText(self, code, radix, delim, flags):
  408.         """
  409.         result is IDebugExpression
  410.         """
  411.         RaiseNotImpl("ParseLanguageText")
  412.     def GetLanguageInfo(self):
  413.         """
  414.         result is (string langName, iid langId)
  415.         """
  416.         RaiseNotImpl("GetLanguageInfo")
  417.  
  418. class DebugExpression:
  419.     _public_methods_ = ["Start", "Abort", "QueryIsComplete", "GetResultAsString", "GetResultAsDebugProperty"]
  420.     _com_interfaces_ = [axdebug.IID_IDebugExpression]
  421.     def Start(self, callback):
  422.         """
  423.         callback -- an IDebugExpressionCallback
  424.         
  425.         result - void
  426.         """
  427.         RaiseNotImpl("Start")
  428.     def Abort(self):
  429.         """
  430.         no params
  431.         result -- void
  432.         """
  433.         RaiseNotImpl("Abort")
  434.  
  435.     def QueryIsComplete(self):
  436.         """
  437.         no params
  438.         result -- void
  439.         """
  440.         RaiseNotImpl("QueryIsComplete")
  441.  
  442.     def GetResultAsString(self):
  443.         RaiseNotImpl("GetResultAsString")
  444.  
  445.     def GetResultAsDebugProperty(self):
  446.         RaiseNotImpl("GetResultAsDebugProperty")
  447.  
  448. class ProvideExpressionContexts:
  449.     _public_methods_ = ["EnumExpressionContexts"]
  450.     _com_interfaces_ = [axdebug.IID_IProvideExpressionContexts]
  451.     def EnumExpressionContexts(self):
  452.         RaiseNotImpl("EnumExpressionContexts")
  453.         
  454.