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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
# Classes which describe interfaces.

import pythoncom
import win32com.server.connect
import winerror
from win32com.axdebug import axdebug
from win32com.axdebug.util import RaiseNotImpl, _wrap
from win32com.server.exception import Exception
from win32com.server.util import ListEnumeratorGateway


class EnumDebugCodeContexts(ListEnumeratorGateway):
    """A class to expose a Python sequence as an EnumDebugCodeContexts

    Create an instance of this class passing a sequence (list, tuple, or
    any sequence protocol supporting object) and it will automatically
    support the EnumDebugCodeContexts interface for the object.

    """

    _com_interfaces_ = [axdebug.IID_IEnumDebugCodeContexts]


class EnumDebugStackFrames(ListEnumeratorGateway):
    """A class to expose a Python sequence as an EnumDebugStackFrames

    Create an instance of this class passing a sequence (list, tuple, or
    any sequence protocol supporting object) and it will automatically
    support the EnumDebugStackFrames interface for the object.

    """

    _com_interfaces_ = [axdebug.IID_IEnumDebugStackFrames]


class EnumDebugApplicationNodes(ListEnumeratorGateway):
    """A class to expose a Python sequence as an EnumDebugStackFrames

    Create an instance of this class passing a sequence (list, tuple, or
    any sequence protocol supporting object) and it will automatically
    support the EnumDebugApplicationNodes interface for the object.

    """

    _com_interfaces_ = [axdebug.IID_IEnumDebugApplicationNodes]


class EnumRemoteDebugApplications(ListEnumeratorGateway):
    _com_interfaces_ = [axdebug.IID_IEnumRemoteDebugApplications]


class EnumRemoteDebugApplicationThreads(ListEnumeratorGateway):
    _com_interfaces_ = [axdebug.IID_IEnumRemoteDebugApplicationThreads]


class DebugDocumentInfo:
    _public_methods_ = ["GetName", "GetDocumentClassId"]
    _com_interfaces_ = [axdebug.IID_IDebugDocumentInfo]

    def __init__(self):
        pass

    def GetName(self, dnt):
        """Get the one of the name of the document
        dnt -- int DOCUMENTNAMETYPE
        """
        RaiseNotImpl("GetName")

    def GetDocumentClassId(self):
        """
        Result must be an IID object (or string representing one).
        """
        RaiseNotImpl("GetDocumentClassId")


class DebugDocumentProvider(DebugDocumentInfo):
    _public_methods_ = DebugDocumentInfo._public_methods_ + ["GetDocument"]
    _com_interfaces_ = DebugDocumentInfo._com_interfaces_ + [
        axdebug.IID_IDebugDocumentProvider
    ]

    def GetDocument(self):
        RaiseNotImpl("GetDocument")


class DebugApplicationNode(DebugDocumentProvider):
    """Provides the functionality of IDebugDocumentProvider, plus a context within a project tree."""

    _public_methods_ = (
        """EnumChildren GetParent SetDocumentProvider
                    Close Attach Detach""".split()
        + DebugDocumentProvider._public_methods_
    )
    _com_interfaces_ = [
        axdebug.IID_IDebugDocumentProvider
    ] + DebugDocumentProvider._com_interfaces_

    def __init__(self):
        DebugDocumentProvider.__init__(self)

    def EnumChildren(self):
        # Result is type PyIEnumDebugApplicationNodes
        RaiseNotImpl("EnumChildren")

    def GetParent(self):
        # result is type PyIDebugApplicationNode
        RaiseNotImpl("GetParent")

    def SetDocumentProvider(self, pddp):  # PyIDebugDocumentProvider pddp
        # void result.
        RaiseNotImpl("SetDocumentProvider")

    def Close(self):
        # void result.
        RaiseNotImpl("Close")

    def Attach(self, parent):  # PyIDebugApplicationNode
        # void result.
        RaiseNotImpl("Attach")

    def Detach(self):
        # void result.
        RaiseNotImpl("Detach")


class DebugApplicationNodeEvents:
    """Event interface for DebugApplicationNode object."""

    _public_methods_ = "onAddChild onRemoveChild onDetach".split()
    _com_interfaces_ = [axdebug.IID_IDebugApplicationNodeEvents]

    def __init__(self):
        pass

    def onAddChild(self, child):  # PyIDebugApplicationNode
        # void result.
        RaiseNotImpl("onAddChild")

    def onRemoveChild(self, child):  # PyIDebugApplicationNode
        # void result.
        RaiseNotImpl("onRemoveChild")

    def onDetach(self):
        # void result.
        RaiseNotImpl("onDetach")

    def onAttach(self, parent):  # PyIDebugApplicationNode
        # void result.
        RaiseNotImpl("onAttach")


class DebugDocument(DebugDocumentInfo):
    """The base interface to all debug documents."""

    _public_methods_ = DebugDocumentInfo._public_methods_
    _com_interfaces_ = [axdebug.IID_IDebugDocument] + DebugDocumentInfo._com_interfaces_


class DebugDocumentText(DebugDocument):
    """The interface to a text only debug document."""

    _com_interfaces_ = [axdebug.IID_IDebugDocumentText] + DebugDocument._com_interfaces_
    _public_methods_ = [
        "GetDocumentAttributes",
        "GetSize",
        "GetPositionOfLine",
        "GetLineOfPosition",
        "GetText",
        "GetPositionOfContext",
        "GetContextOfPosition",
    ] + DebugDocument._public_methods_

    def __init__(self):
        pass

    # IDebugDocumentText
    def GetDocumentAttributes(self):
        # Result is int (TEXT_DOC_ATTR)
        RaiseNotImpl("GetDocumentAttributes")

    def GetSize(self):
        # Result is (numLines, numChars)
        RaiseNotImpl("GetSize")

    def GetPositionOfLine(self, cLineNumber):
        # Result is int char position
        RaiseNotImpl("GetPositionOfLine")

    def GetLineOfPosition(self, charPos):
        # Result is int, int (lineNo, offset)
        RaiseNotImpl("GetLineOfPosition")

    def GetText(self, charPos, maxChars, wantAttr):
        """Params
        charPos -- integer
        maxChars -- integer
        wantAttr -- Should the function compute attributes.

        Return value must be (string, attribtues).  attributes may be
        None if(not wantAttr)
        """
        RaiseNotImpl("GetText")

    def GetPositionOfContext(self, debugDocumentContext):
        """Params
        debugDocumentContext -- a PyIDebugDocumentContext object.

        Return value must be (charPos, numChars)
        """
        RaiseNotImpl("GetPositionOfContext")

    def GetContextOfPosition(self, charPos, maxChars):
        """Params are integers.
        Return value must be PyIDebugDocumentContext object
        """
        print(self)
        RaiseNotImpl("GetContextOfPosition")


class DebugDocumentTextExternalAuthor:
    """Allow external editors to edit file-based debugger documents, and to notify the document when the source file has been changed."""

    _public_methods_ = ["GetPathName", "GetFileName", "NotifyChanged"]
    _com_interfaces_ = [axdebug.IID_IDebugDocumentTextExternalAuthor]

    def __init__(self):
        pass

    def GetPathName(self):
        """Return the full path (including file name) to the document's source file.

        Result must be (filename, fIsOriginal), where
        - if fIsOriginalPath is TRUE if the path refers to the original file for the document.
        - if fIsOriginalPath is FALSE if the path refers to a newly created temporary file.

        raise Exception(winerror.E_FAIL) if no source file can be created/determined.
        """
        RaiseNotImpl("GetPathName")

    def GetFileName(self):
        """Return just the name of the document, with no path information.  (Used for "Save As...")

        Result is a string
        """
        RaiseNotImpl("GetFileName")

    def NotifyChanged(self):
        """Notify the host that the document's source file has been saved and
        that its contents should be refreshed.
        """
        RaiseNotImpl("NotifyChanged")


class DebugDocumentTextEvents:
    _public_methods_ = """onDestroy onInsertText onRemoveText
              onReplaceText onUpdateTextAttributes
              onUpdateDocumentAttributes""".split()
    _com_interfaces_ = [axdebug.IID_IDebugDocumentTextEvents]

    def __init__(self):
        pass

    def onDestroy(self):
        # Result is void.
        RaiseNotImpl("onDestroy")

    def onInsertText(self, cCharacterPosition, cNumToInsert):
        # Result is void.
        RaiseNotImpl("onInsertText")

    def onRemoveText(self, cCharacterPosition, cNumToRemove):
        # Result is void.
        RaiseNotImpl("onRemoveText")

    def onReplaceText(self, cCharacterPosition, cNumToReplace):
        # Result is void.
        RaiseNotImpl("onReplaceText")

    def onUpdateTextAttributes(self, cCharacterPosition, cNumToUpdate):
        # Result is void.
        RaiseNotImpl("onUpdateTextAttributes")

    def onUpdateDocumentAttributes(self, textdocattr):  # TEXT_DOC_ATTR
        # Result is void.
        RaiseNotImpl("onUpdateDocumentAttributes")


class DebugDocumentContext:
    _public_methods_ = ["GetDocument", "EnumCodeContexts"]
    _com_interfaces_ = [axdebug.IID_IDebugDocumentContext]

    def __init__(self):
        pass

    def GetDocument(self):
        """Return value must be a PyIDebugDocument object"""
        RaiseNotImpl("GetDocument")

    def EnumCodeContexts(self):
        """Return value must be a PyIEnumDebugCodeContexts object"""
        RaiseNotImpl("EnumCodeContexts")


class DebugCodeContext:
    _public_methods_ = ["GetDocumentContext", "SetBreakPoint"]
    _com_interfaces_ = [axdebug.IID_IDebugCodeContext]

    def __init__(self):
        pass

    def GetDocumentContext(self):
        """Return value must be a PyIDebugDocumentContext object"""
        RaiseNotImpl("GetDocumentContext")

    def SetBreakPoint(self, bps):
        """bps -- an integer with flags."""
        RaiseNotImpl("SetBreakPoint")


class DebugStackFrame:
    """Abstraction representing a logical stack frame on the stack of a thread."""

    _public_methods_ = [
        "GetCodeContext",
        "GetDescriptionString",
        "GetLanguageString",
        "GetThread",
        "GetDebugProperty",
    ]
    _com_interfaces_ = [axdebug.IID_IDebugStackFrame]

    def __init__(self):
        pass

    def GetCodeContext(self):
        """Returns the current code context associated with the stack frame.

        Return value must be a IDebugCodeContext object
        """
        RaiseNotImpl("GetCodeContext")

    def GetDescriptionString(self, fLong):
        """Returns a textual description of the stack frame.

        fLong -- A flag indicating if the long name is requested.
        """
        RaiseNotImpl("GetDescriptionString")

    def GetLanguageString(self):
        """Returns a short or long textual description of the language.

        fLong -- A flag indicating if the long name is requested.
        """
        RaiseNotImpl("GetLanguageString")

    def GetThread(self):
        """Returns the thread associated with this stack frame.

        Result must be a IDebugApplicationThread
        """
        RaiseNotImpl("GetThread")

    def GetDebugProperty(self):
        RaiseNotImpl("GetDebugProperty")


class DebugDocumentHost:
    """The interface from the IDebugDocumentHelper back to
    the smart host or language engine.  This interface
    exposes host specific functionality such as syntax coloring.
    """

    _public_methods_ = [
        "GetDeferredText",
        "GetScriptTextAttributes",
        "OnCreateDocumentContext",
        "GetPathName",
        "GetFileName",
        "NotifyChanged",
    ]
    _com_interfaces_ = [axdebug.IID_IDebugDocumentHost]

    def __init__(self):
        pass

    def GetDeferredText(self, dwTextStartCookie, maxChars, bWantAttr):
        RaiseNotImpl("GetDeferredText")

    def GetScriptTextAttributes(self, codeText, delimterText, flags):
        # Result must be an attribute sequence of same "length" as the code.
        RaiseNotImpl("GetScriptTextAttributes")

    def OnCreateDocumentContext(self):
        # Result must be a PyIUnknown
        RaiseNotImpl("OnCreateDocumentContext")

    def GetPathName(self):
        # Result must be (string, int) where the int is a BOOL
        # - TRUE if the path refers to the original file for the document.
        # - FALSE if the path refers to a newly created temporary file.
        # - raise Exception(scode=E_FAIL) if no source file can be created/determined.
        RaiseNotImpl("GetPathName")

    def GetFileName(self):
        # Result is a string with just the name of the document, no path information.
        RaiseNotImpl("GetFileName")

    def NotifyChanged(self):
        RaiseNotImpl("NotifyChanged")


# Additional gateway related functions.


class DebugDocumentTextConnectServer:
    _public_methods_ = (
        win32com.server.connect.IConnectionPointContainer_methods
        + win32com.server.connect.IConnectionPoint_methods
    )
    _com_interfaces_ = [
        pythoncom.IID_IConnectionPoint,
        pythoncom.IID_IConnectionPointContainer,
    ]

    # IConnectionPoint interfaces
    def __init__(self):
        self.cookieNo = -1
        self.connections = {}

    def EnumConnections(self):
        RaiseNotImpl("EnumConnections")

    def GetConnectionInterface(self):
        RaiseNotImpl("GetConnectionInterface")

    def GetConnectionPointContainer(self):
        return _wrap(self)

    def Advise(self, pUnk):
        # Creates a connection to the client.  Simply allocate a new cookie,
        # find the clients interface, and store it in a dictionary.
        interface = pUnk.QueryInterface(axdebug.IID_IDebugDocumentTextEvents, 1)
        self.cookieNo = self.cookieNo + 1
        self.connections[self.cookieNo] = interface
        return self.cookieNo

    def Unadvise(self, cookie):
        # Destroy a connection - simply delete interface from the map.
        try:
            del self.connections[cookie]
        except KeyError:
            return Exception(scode=winerror.E_UNEXPECTED)

    # IConnectionPointContainer interfaces
    def EnumConnectionPoints(self):
        RaiseNotImpl("EnumConnectionPoints")

    def FindConnectionPoint(self, iid):
        # Find a connection we support.  Only support the single event interface.
        if iid == axdebug.IID_IDebugDocumentTextEvents:
            return _wrap(self)
        raise Exception(scode=winerror.E_NOINTERFACE)  # ??


class RemoteDebugApplicationEvents:
    _public_methods_ = [
        "OnConnectDebugger",
        "OnDisconnectDebugger",
        "OnSetName",
        "OnDebugOutput",
        "OnClose",
        "OnEnterBreakPoint",
        "OnLeaveBreakPoint",
        "OnCreateThread",
        "OnDestroyThread",
        "OnBreakFlagChange",
    ]
    _com_interfaces_ = [axdebug.IID_IRemoteDebugApplicationEvents]

    def OnConnectDebugger(self, appDebugger):
        """appDebugger -- a PyIApplicationDebugger"""
        RaiseNotImpl("OnConnectDebugger")

    def OnDisconnectDebugger(self):
        RaiseNotImpl("OnDisconnectDebugger")

    def OnSetName(self, name):
        RaiseNotImpl("OnSetName")

    def OnDebugOutput(self, string):
        RaiseNotImpl("OnDebugOutput")

    def OnClose(self):
        RaiseNotImpl("OnClose")

    def OnEnterBreakPoint(self, rdat):
        """rdat -- PyIRemoteDebugApplicationThread"""
        RaiseNotImpl("OnEnterBreakPoint")

    def OnLeaveBreakPoint(self, rdat):
        """rdat -- PyIRemoteDebugApplicationThread"""
        RaiseNotImpl("OnLeaveBreakPoint")

    def OnCreateThread(self, rdat):
        """rdat -- PyIRemoteDebugApplicationThread"""
        RaiseNotImpl("OnCreateThread")

    def OnDestroyThread(self, rdat):
        """rdat -- PyIRemoteDebugApplicationThread"""
        RaiseNotImpl("OnDestroyThread")

    def OnBreakFlagChange(self, abf, rdat):
        """abf -- int - one of the axdebug.APPBREAKFLAGS constants
        rdat -- PyIRemoteDebugApplicationThread
        RaiseNotImpl("OnBreakFlagChange")
        """


class DebugExpressionContext:
    _public_methods_ = ["ParseLanguageText", "GetLanguageInfo"]
    _com_interfaces_ = [axdebug.IID_IDebugExpressionContext]

    def __init__(self):
        pass

    def ParseLanguageText(self, code, radix, delim, flags):
        """
        result is IDebugExpression
        """
        RaiseNotImpl("ParseLanguageText")

    def GetLanguageInfo(self):
        """
        result is (string langName, iid langId)
        """
        RaiseNotImpl("GetLanguageInfo")


class DebugExpression:
    _public_methods_ = [
        "Start",
        "Abort",
        "QueryIsComplete",
        "GetResultAsString",
        "GetResultAsDebugProperty",
    ]
    _com_interfaces_ = [axdebug.IID_IDebugExpression]

    def Start(self, callback):
        """
        callback -- an IDebugExpressionCallback

        result - void
        """
        RaiseNotImpl("Start")

    def Abort(self):
        """
        no params
        result -- void
        """
        RaiseNotImpl("Abort")

    def QueryIsComplete(self):
        """
        no params
        result -- void
        """
        RaiseNotImpl("QueryIsComplete")

    def GetResultAsString(self):
        RaiseNotImpl("GetResultAsString")

    def GetResultAsDebugProperty(self):
        RaiseNotImpl("GetResultAsDebugProperty")


class ProvideExpressionContexts:
    _public_methods_ = ["EnumExpressionContexts"]
    _com_interfaces_ = [axdebug.IID_IProvideExpressionContexts]

    def EnumExpressionContexts(self):
        RaiseNotImpl("EnumExpressionContexts")