forked from mhammond/pywin32
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPyCOMTest.idl
More file actions
413 lines (372 loc) · 14.6 KB
/
PyCOMTest.idl
File metadata and controls
413 lines (372 loc) · 14.6 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
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
// PyCOMTest.idl : IDL source for PyCOMTest.dll
//
// This is a test harness for Python
// Most things are contrived purely to testing purposes!
//
// This started out life as an ATL sample, and still has
// a "Random Event" interface, that is free threaded, and may
// provide a reasonable test harness for Python free threading later.
//
typedef enum EnumTestAttributes1
{
TestAttr1,
TestAttr1_1,
} TestAttributes1;
typedef enum // Missing EnumTestAttributes2
{
TestAttr2,
} TestAttributes2;
/////////////////////////////////////////////////////////////////////////////
// Library
/////////////////////////////////////////////////////////////////////////////
[
uuid(6bcdcb60-5605-11d0-ae5f-cadd4c000000),
version(1.1),
// an extended character in the help string should stress things...
helpstring("Python COM Test Harness 1.0 Type Library, © pywin32 contributors")
]
library PyCOMTestLib
{
importlib("stdole32.tlb");
// Do a simple typedef to create a simple alias.
typedef [public] VARIANT_BOOL QsBoolean;
cpp_quote("const QsBoolean True = VARIANT_TRUE;")
cpp_quote("const QsBoolean False = VARIANT_FALSE;")
// Create nested alias objects.
typedef [public] long HCON;
typedef [public] HCON CONNECTID;
typedef [uuid(14894ca0-554a-11d0-ae5f-cadd4c000000)]
enum tagQsAttribute {
Attr1, // Comments for Attr1
Attr2, // Comments for Attr2
Attr3 = 0x80000000, // Special case test.
// Insert new attrib enums before here. This must always be the last
// enum value.
// Only used to dimension arrays, etc.
NumberOfAttribs
} QsAttribute;
// v1_enum specifies a 32 bit enum value
typedef [public, v1_enum] enum tagQsAttributeWide {
WideAttr1 = 0,
WideAttr2 = -1,
WideAttr3 = 1,
WideAttr4 = -70000,
WideAttr5 = 70000
} QsAttributeWide;
// constant test values
module Constants {
const unsigned long ULongTest1 = 0xFFFFFFFFUL;
const unsigned long ULongTest2 = 0x7FFFFFFFUL;
const long LongTest1 = -0x7FFFFFFFL;
const long LongTest2 = 0x7FFFFFFFL;
const unsigned char UCharTest = 255;
const char CharTest = -1;
const LPWSTR StringTest = L"Hello Wo®ld";
};
enum TestAttributes3{ // Note missing the enum name.
TestAttr3,
None, // Few keywords etc here
print,
};
// Some test structures
typedef [uuid(7a4ce6a7-7959-4e85-a3c0-b41442ff0f67), version(1.0)]
struct TestStruct1 {
int int_value;
BSTR str_value;
} TestStruct1;
typedef [version(1.0)]
struct tagStructWithoutUUID {
int int_value;
BSTR str_value;
} StructWithoutUUID;
typedef [uuid(78F0EA07-B7CF-42EA-A251-A4C6269F76AF), version(1.0)]
struct TestStruct2 {
SAFEARRAY(TestStruct1) array_of_records;
int rec_count;
} TestStruct2;
// Test enumerators.
[
object, // Removed for the purposes of testing what happens without it!
public,
uuid(528d6940-5a31-11d0-ae5f-cadd4c000000),
dual,
helpstring("ISimpleCounter Interface"),
pointer_default(unique)
]
interface ISimpleCounter : IDispatch
{
import "oaidl.idl";
[propget, helpstring("Returns what we count up to.")]
HRESULT Count([out, retval] long* retval);
[propget, id(DISPID_VALUE),
helpstring("Given an index, returns an item in the collection.")]
HRESULT Item([in] long Index, [out, retval] VARIANT* retval);
[propget, restricted, id(DISPID_NEWENUM),
helpstring("returns an enumerator over the steps in the program.")]
HRESULT _NewEnum([out, retval] IUnknown** retval);
[propput, helpstring("Sets the lower bound of our collection.")]
HRESULT LBound([in] long lbound);
[propget, helpstring("Gets the lower bound of our collection.")]
HRESULT LBound([out, retval] long *lbound);
[propput, helpstring("Sets the upper bound of our collection.")]
HRESULT UBound([in] long lbound);
[propget, helpstring("Gets the upper bound of our collection.")]
HRESULT UBound([out, retval] long *lbound);
// Purpose of this test was a "propput" with multiple args. If I make
// this propput, the second arg is not present in the TLB??
[helpstring("Sets the lower and upper bounds of our collection.")]
HRESULT SetBounds([in] long lowerbound, [in] long upperbound);
[helpstring("Gets the lower and upper bound of our collection.")]
HRESULT GetBounds([out] long *lbound, [out] long *ubound);
[propput, helpstring("Tests setting a property with a default arg.")]
HRESULT TestProperty([in] long propval1, [in,defaultvalue(0)] long propval2 );
[propget, helpstring("Tests getting a property with a default arg.")]
HRESULT TestPropertyWithDef([in, defaultvalue(0)] long arg1, [out, retval] long *result );
[propget, helpstring("Tests getting a property without a default arg.")]
HRESULT TestPropertyNoDef([in] long arg1, [out, retval] long *result );
[propput, helpstring("Tests setting a property with 3 args, and 1 default.")]
HRESULT TestProperty2([in] long propval1, [in] long propval2, [in,defaultvalue(0)] long propval3 );
};
[uuid(e29d77a0-04ca-11d2-a69a-00aa00125a98)]
dispinterface ISimpleCounterPro {
interface ISimpleCounter;
};
[uuid(b88dd310-bae8-11d0-ae86-76f2c1000000),helpstring("The CoClass for the ISimpleCounter")]
coclass CoSimpleCounter
{
dispinterface ISimpleCounterPro;
[default] interface ISimpleCounter;
};
[
uuid(8ee0c520-5605-11d0-ae5f-cadd4c000000),
helpstring("PyCOMTest Class")
]
coclass CoPyCOMTest
{
[default] interface IPyCOMTest;
[default, source] dispinterface IPyCOMTestEvent;
// [source] dispinterface PyCOMTestEvent;
};
// This file will be processed by the MIDL tool to
// produce the type library (PyCOMTest.tlb) and marshalling code.
[
object,
uuid(a0d9ceb0-5605-11d0-ae5f-cadd4c000000),
dual,
helpstring("PyCOMTest Interface - with some fancy \tbackslash\chars\\"),
pointer_default(unique)
]
interface IPyCOMTest : IDispatch
{
import "oaidl.idl";
// Test simple alias. HCON is long.
[
helpstring("docstring for Start - with some fancy \tslash chars\\")
]
HRESULT Start([out, retval] HCON * pnID);
// Nested alaas - CONNECTID is HCON.
HRESULT Stop([in] CONNECTID nID);
HRESULT StopAll();
// Test alias in and byref params.
HRESULT Test([in] VARIANT key, [in] QsBoolean inval, [out, retval] QsBoolean* retval);
// Test enum in and byref params.
HRESULT Test2([in] QsAttribute inval, [out, retval] QsAttribute* retval);
HRESULT Test3([in] TestAttributes1 inval, [out, retval] TestAttributes1* retval);
HRESULT Test4([in] TestAttributes2 inval, [out, retval] TestAttributes2* retval);
HRESULT Test5([in, out] TestAttributes1 *inout);
HRESULT Test6([in] QsAttributeWide inval, [out, retval] QsAttributeWide* retval);
HRESULT TestInOut([in, out] float *fval, [in, out] QsBoolean *bval, [in, out] long *lval);
// Test IDispatch in and byref.
HRESULT GetSetInterface([in] IPyCOMTest *ininterface, [out, retval] IPyCOMTest **outinterface);
HRESULT GetSetInterfaceArray([in] SAFEARRAY(IPyCOMTest) ininterface, [out, retval] SAFEARRAY(IPyCOMTest) *outinterface);
HRESULT GetMultipleInterfaces([out] IPyCOMTest **outinterface1, [out] IPyCOMTest **outinterface2);
HRESULT GetSetDispatch([in] IDispatch *indisp, [out, retval] IDispatch **outdisp);
HRESULT GetSetUnknown([in] IUnknown *inunk, [out, retval] IUnknown **outunk);
HRESULT GetSetVariant([in] VARIANT vin, [out, retval] VARIANT *vout);
HRESULT GetSetInt([in] int invar, [out, retval] int *outunk);
HRESULT GetSetUnsignedInt([in] unsigned int invar, [out, retval] unsigned int *outunk);
HRESULT GetSetLong([in] long invar, [out, retval] long *outunk);
HRESULT GetSetUnsignedLong([in] unsigned long invar, [out, retval] unsigned long *outunk);
HRESULT GetVariantAndType([in] VARIANT vin, [out] unsigned short *vt, [out] VARIANT *vout);
HRESULT TestByRefVariant([in, out] VARIANT *v);
HRESULT TestByRefString([in, out] BSTR *v);
HRESULT TakeByRefTypedDispatch([in, out] IPyCOMTest **inout);
HRESULT TakeByRefDispatch([in, out] IDispatch **inout);
// Test Safe arrays - simple, then alias, enum
HRESULT SetBinSafeArray([in] SAFEARRAY(unsigned char) buf, [out, retval]int *resultSize);
HRESULT SetIntSafeArray([in] SAFEARRAY(int) ints, [out, retval]int *resultSize);
HRESULT SetLongLongSafeArray([in] SAFEARRAY(long long) ints, [out, retval]int *resultSize);
HRESULT SetULongLongSafeArray([in] SAFEARRAY(unsigned long long) ints, [out, retval]int *resultSize);
HRESULT SetVariantSafeArray([in] SAFEARRAY(VARIANT) vars, [out, retval]int *resultSize);
HRESULT SetDoubleSafeArray([in] SAFEARRAY(double) vals, [out, retval]int *resultSize);
HRESULT SetFloatSafeArray([in] SAFEARRAY(float) vals, [out, retval]int *resultSize);
HRESULT GetSimpleSafeArray([out] SAFEARRAY(int)* ints);
HRESULT GetSafeArrays([out] SAFEARRAY(QsAttribute)* attrs,
[out] SAFEARRAY(enum tagQsAttribute)*attrs2,
[out] SAFEARRAY(int)*ints);
HRESULT ChangeDoubleSafeArray([in, out]SAFEARRAY(double)*vals);
HRESULT GetSimpleCounter([out, retval] ISimpleCounter** counter);
HRESULT CheckVariantSafeArray([in] SAFEARRAY(VARIANT)* data, [out, retval]int *sum);
[vararg] HRESULT SetVarArgs([in]SAFEARRAY(VARIANT) vars);
HRESULT GetLastVarArgs([out, retval]SAFEARRAY(VARIANT) *result);
HRESULT Fire([in]long nId);
HRESULT TestOptionals( [in,optional,defaultvalue("def")] BSTR strArg,
[in,optional,defaultvalue(0)] short sval,
[in,optional,defaultvalue(1)] long lval,
[in,optional,defaultvalue(3.14)] double dval,
[out,retval] SAFEARRAY(VARIANT) *pret );
HRESULT TestOptionals2(
double dval,
[optional, defaultvalue("")] BSTR strval,
[optional, defaultvalue(1)] short sval,
[out,retval] SAFEARRAY(VARIANT) *pret );
// Trying (but failing) to find a bug related to SourceSafe's VSSItem's IDL defn. Note
// the lack of 'optional' even though a default is specified (which doesn't seem to
// have any effect, but seeing we are here...)
HRESULT TestOptionals3(
[in]double dval,
[in, defaultvalue(1)] short sval,
[out, retval] IPyCOMTest **ppout );
HRESULT GetStruct([out, retval]TestStruct1 *ret);
HRESULT GetOutStruct([ out ] TestStruct1 * ret);
HRESULT DoubleString([in] BSTR inStr, [ out, retval ] BSTR * outStr);
HRESULT DoubleInOutString([in,out] BSTR *str);
[restricted] HRESULT NotScriptable([in,out] int *val);
HRESULT TestMyInterface([in] IUnknown *tester);
// Test date objects.
HRESULT EarliestDate(
[in] DATE First,
[in, optional, defaultvalue(0)] DATE Second,
[out, retval] Date* pResult);
HRESULT MakeDate(
[in] double val,
[out, retval] DATE* pResult);
HRESULT TestQueryInterface();
HRESULT AddCurrencies(
[in] CY v1,
[in] CY v2,
[out, retval] CY* pResult);
HRESULT DoubleCurrency([in] CY v,
[out, retval] CY *ret );
HRESULT DoubleCurrencyByVal([in, out] CY *v);
// Some test properties
[propget] HRESULT LongProp([out, retval] long* retval);
[propput] HRESULT LongProp([in] long val);
[propget] HRESULT ULongProp([out, retval] unsigned long* retval);
[propput] HRESULT ULongProp([in] unsigned long val);
[propget] HRESULT IntProp([out, retval] int* retval);
[propput] HRESULT IntProp([in] int val);
[propget] HRESULT CurrencyProp([out, retval] CY* retval);
[propput] HRESULT CurrencyProp([in] CY val);
[propget] HRESULT ParamProp([in] int which, [out, retval] int *retval);
[propput] HRESULT ParamProp([in] int which, [in]int val);
// reserved words etc
HRESULT None();
HRESULT def();
// Test struct byref as [ in, out ] parameter.
HRESULT ModifyStruct([ in, out ] TestStruct1 * prec);
HRESULT VerifyArrayOfStructs([in] TestStruct2 * prec, [ out, retval ] VARIANT_BOOL * is_ok);
};
// Define a new class to test how Python handles derived interfaces!
[
uuid(4E58A400-1117-11d1-9C4B-00AA00125A98),
helpstring("PyCOMTest2 Class")
]
coclass CoPyCOMTest2
{
[default] interface IPyCOMTest2;
[default, source] dispinterface IPyCOMTestEvent; // use same events for now.
// [source] dispinterface PyCOMTestEvent;
};
[
object,
uuid(4E58A401-1117-11d1-9C4B-00AA00125A98),
dual,
helpstring("PyCOMTest2 Interface (derived from PyCOMTest)"),
pointer_default(unique)
]
interface IPyCOMTest2 : IPyCOMTest
{
import "oaidl.idl";
// Test enum in and byref params.
HRESULT TestDerived([in] QsAttribute inval, [out, retval] QsAttribute* retval);
};
// The event interface.
//
[
object,
uuid(af643370-5605-11d0-ae5f-cadd4c000000),
dual,
helpstring("IPyCOMTestEvent Interface"),
pointer_default(unique)
]
interface IPyCOMTestEvent : IDispatch
{
import "oaidl.idl";
HRESULT Fire([in]long nID);
HRESULT FireWithNamedParams([in]long nID, [in]QsBoolean b, [in, out]int *outVal, [in, out]int *outVal2);
};
[
uuid(b636cac0-5605-11d0-ae5f-cadd4c000000),
helpstring("PyCOMTestEvent IDispatch Interface"),
]
dispinterface PyCOMTestEvent
{
interface IPyCOMTestEvent;
};
// Some non-IDispatch based interfaces for univgw testing.
[
object,
uuid(36f7a0f7-10c9-43b7-9bd8-47a932b11d84),
helpstring("IPyCOMTestNoDispatch Interface"),
pointer_default(unique)
]
interface IPyCOMTestNoDispatch : IUnknown
{
HRESULT PlayWithSomeArgs([in,out]VARIANT *var, [in,out]long *l);
HRESULT ChangeStruct([in]TestStruct1 *inval, [out, retval]TestStruct1 *ret);
HRESULT InPtr([in]int *inval, [out]int *outval);
};
[
object,
uuid(b21b658a-19a8-488a-8d3a-b63b3cf98501),
dual,
helpstring("IPyCOMTestNoDispatchEvent Interface"),
pointer_default(unique)
]
interface IPyCOMTestNoDispatchEvent : IUnknown
{
HRESULT Fire([in]long nID);
};
[
uuid(638630ac-a734-45a2-8080-fda5c1e47f66),
helpstring("PyCOMTest Class that doesn't derive from IDispatch")
]
coclass CoPyCOMTestNoDispatch
{
[default] interface IPyCOMTestNoDispatch;
[default, source] dispinterface IPyCOMTestNoDispatchEvent; // use same events for now.
};
// Some array tests, from Stefan Schukat
[
object,
uuid(974f29b3-4e58-4654-9f85-4491d7a2418c),
dual,
helpstring("PyCOMTest IArrayTest Interface"),
pointer_default(unique)
]
interface IArrayTest : IDispatch
{
[propget, id(1), helpstring("property Array")] HRESULT Array([out, retval] VARIANT *pVal);
[propput, id(1), helpstring("property Array")] HRESULT Array([in] VARIANT newVal);
[id(2), helpstring("method ReturnSampleArray")] HRESULT ReturnSampleArray([out, retval] VARIANT *pVal);
};
[
uuid(f1a51873-24e9-47ed-ae71-925462c5fe3b),
helpstring("PyCOMTest ArrayTest Class")
]
coclass ArrayTest
{
[default] interface IArrayTest;
};
};