test_pycomtest.py
4.43 KB
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
# This is part of the Python test suite.
# The object is registered when you first run the test suite.
# (and hopefully unregistered once done ;-)
# Ensure the vtables in the tlb are known.
from win32com import universal
from win32com.server.exception import COMException
from win32com.client import gencache
import winerror
from win32com.client import constants
from win32com.server.util import wrap
import pythoncom
pythoncom.__future_currency__ = True
# We use the constants from the module, so must insist on a gencache.
# Otherwise, use of gencache is not necessary (tho still advised)
gencache.EnsureModule('{6BCDCB60-5605-11D0-AE5F-CADD4C000000}', 0, 1, 1)
class PyCOMTest:
_typelib_guid_ = "{6BCDCB60-5605-11D0-AE5F-CADD4C000000}"
_typelib_version = 1,0
_com_interfaces_ = ['IPyCOMTest']
_reg_clsid_ = "{e743d9cd-cb03-4b04-b516-11d3a81c1597}"
_reg_progid_ = "Python.Test.PyCOMTest"
def DoubleString(self, str):
return str*2
def DoubleInOutString(self, str):
return str*2
def Fire(self, nID):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetLastVarArgs(self):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetMultipleInterfaces(self, outinterface1, outinterface2):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetSafeArrays(self, attrs, attrs2, ints):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetSetDispatch(self, indisp):
raise COMException(hresult=winerror.E_NOTIMPL)
# Result is of type IPyCOMTest
def GetSetInterface(self, ininterface):
return wrap(self)
def GetSetVariant(self, indisp):
return indisp
def TestByRefVariant(self, v):
return v * 2
def TestByRefString(self, v):
return v * 2
# Result is of type IPyCOMTest
def GetSetInterfaceArray(self, ininterface):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetSetUnknown(self, inunk):
raise COMException(hresult=winerror.E_NOTIMPL)
# Result is of type ISimpleCounter
def GetSimpleCounter(self):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetSimpleSafeArray(self, ints):
raise COMException(hresult=winerror.E_NOTIMPL)
def GetStruct(self):
raise COMException(hresult=winerror.E_NOTIMPL)
def SetIntSafeArray(self, ints):
return len(ints)
def SetLongLongSafeArray(self, ints):
return len(ints)
def SetULongLongSafeArray(self, ints):
return len(ints)
def SetBinSafeArray(self, buf):
return len(buf)
def SetVarArgs(self, *args):
raise COMException(hresult=winerror.E_NOTIMPL)
def SetVariantSafeArray(self, vars):
raise COMException(hresult=winerror.E_NOTIMPL)
def Start(self):
raise COMException(hresult=winerror.E_NOTIMPL)
def Stop(self, nID):
raise COMException(hresult=winerror.E_NOTIMPL)
def StopAll(self):
raise COMException(hresult=winerror.E_NOTIMPL)
def TakeByRefDispatch(self, inout):
raise COMException(hresult=winerror.E_NOTIMPL)
def TakeByRefTypedDispatch(self, inout):
raise COMException(hresult=winerror.E_NOTIMPL)
def Test(self, key, inval):
return not inval
def Test2(self, inval):
return inval
def Test3(self, inval):
raise COMException(hresult=winerror.E_NOTIMPL)
def Test4(self, inval):
raise COMException(hresult=winerror.E_NOTIMPL)
def Test5(self, inout):
if inout == constants.TestAttr1:
return constants.TestAttr1_1
elif inout == constants.TestAttr1_1:
return constants.TestAttr1
else:
return -1
def Test6(self, inval):
return inval
def TestOptionals(self, strArg='def', sval=0, lval=1, dval=3.1400001049041748):
raise COMException(hresult=winerror.E_NOTIMPL)
def TestOptionals2(self, dval, strval='', sval=1):
raise COMException(hresult=winerror.E_NOTIMPL)
def CheckVariantSafeArray(self, data):
return 1
def LongProp(self):
return self.longval
def SetLongProp(self, val):
self.longval = val
def ULongProp(self):
return self.ulongval
def SetULongProp(self, val):
self.ulongval = val
def IntProp(self):
return self.intval
def SetIntProp(self, val):
self.intval = val
class PyCOMTestMI(PyCOMTest):
_typelib_guid_ = "{6BCDCB60-5605-11D0-AE5F-CADD4C000000}"
_typelib_version = 1,0
# Interfaces with a interface name, a real IID, and an IID as a string
_com_interfaces_ = ['IPyCOMTest',
pythoncom.IID_IStream,
str(pythoncom.IID_IStorage),
]
_reg_clsid_ = "{F506E9A1-FB46-4238-A597-FA4EB69787CA}"
_reg_progid_ = "Python.Test.PyCOMTestMI"
if __name__ == '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(PyCOMTest)
win32com.server.register.UseCommandLine(PyCOMTestMI)