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_contexts.py < prev    next >
Encoding:
Python Source  |  2001-07-26  |  1.9 KB  |  57 lines

  1. """ A module for managing the AXDebug I*Contexts
  2.  
  3. """
  4. import gateways, axdebug
  5. import pythoncom, win32com.server.util
  6.  
  7. # Utility function for wrapping object created by this module.
  8. from util import _wrap, _wrap_remove, trace
  9. import adb
  10.  
  11. class DebugCodeContext(gateways.DebugCodeContext, gateways.DebugDocumentContext):
  12.     # NOTE: We also implement the IDebugDocumentContext interface for Simple Hosts.
  13.     # Thus, debugDocument may be NULL when we have smart hosts - but in that case, we
  14.     # wont be called upon to provide it.
  15.     _public_methods_ = gateways.DebugCodeContext._public_methods_ + \
  16.                        gateways.DebugDocumentContext._public_methods_
  17.     _com_interfaces_ = gateways.DebugCodeContext._com_interfaces_ + \
  18.                        gateways.DebugDocumentContext._com_interfaces_
  19.  
  20.     def __init__(self, lineNo, charPos, len, codeContainer, debugSite):
  21.         self.debugSite = debugSite
  22.         self.offset = charPos
  23.         self.length = len
  24.         self.breakPointState = 0
  25.         self.lineno = lineNo
  26.         gateways.DebugCodeContext.__init__(self)
  27.         self.codeContainer = codeContainer
  28.  
  29.     def _Close(self):
  30.         self.debugSite = None
  31.  
  32.     def GetDocumentContext(self):
  33.         if self.debugSite is not None:
  34.             # We have a smart host - let him give it to us.
  35.             return self.debugSite.GetDocumentContextFromPosition(
  36.                 self.codeContainer.sourceContext,
  37.                 self.offset, 
  38.                 self.length)
  39.         else:
  40.             # Simple host - Fine - Ill do it myself!
  41.             return _wrap(self, axdebug.IID_IDebugDocumentContext)
  42.  
  43.     def SetBreakPoint(self, bps):
  44.         self.breakPointState = bps
  45.         adb.OnSetBreakPoint(self, bps, self.lineno)
  46.         
  47.     # The DebugDocumentContext methods for simple hosts.
  48.     def GetDocument(self):
  49.         return self.codeContainer.debugDocument
  50.  
  51.     def EnumCodeContexts(self):
  52.         return _wrap(EnumDebugCodeContexts([self]), axdebug.IID_IEnumDebugCodeContexts)
  53.  
  54. class EnumDebugCodeContexts(gateways.EnumDebugCodeContexts):
  55.     def _wrap(self, obj):
  56.         return _wrap(obj, axdebug.IID_IDebugCodeContext)
  57.