Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gateways.py 17KB

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