-
Notifications
You must be signed in to change notification settings - Fork 16
/
test_component.idl
424 lines (349 loc) · 15.4 KB
/
test_component.idl
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
#include "Types.idl"
#include "AsyncMethods.idl"
#include "BufferTests.idl"
#include "CollectionTester.idl"
#include "EventTester.idl"
#include "Keywords.idl"
#include "NullValues.idl"
#include "WeakReferencer.idl"
#include "ArrayTester.idl"
import "Windows.Foundation.idl";
// import "Windows.Foundation.Numerics.idl";
namespace Windows.Foundation.Metadata
{
[attributeusage(target_method, target_property)]
[attributename("noexcept2")]
attribute NoExceptionAttribute
{
}
}
namespace test_component
{
// Just defined to validate we properly generate this name
enum SwiftifiableNames
{
camelCase, // Should be preserved
PascalCase, // Should become pascalCase
ESingleLetterPrefixed, // Should become esingleLetterPrefixed
LEADINGCaps, // Should become leadingCaps
R8G8B8A8Typeless, // Should become r8g8b8a8Typeless (from D3D)
UUID, // Should become uuid
};
struct StructWithEnum
{
SwiftifiableNames Names;
};
struct StructWithIReference
{
Windows.Foundation.IReference<Int32> Value1;
Windows.Foundation.IReference<Int32> Value2;
};
namespace Delegates
{
delegate void SignalDelegate();
delegate void InDelegate(String value);
delegate String ReturnStringDelegate();
delegate Int32 ReturnInt32Delegate();
delegate void OutStringDelegate(out String value);
delegate void OutInt32Delegate(out Int32 value);
delegate void InObjectDelegate(Object value);
// delegate String[] ReturnStringArrayDelegate();
// delegate void OutStringArrayDelegate(out String[] value);
// delegate void RefStringArrayDelegate(ref String[] value);
// delegate test_component.Struct[] StructDelegate();
}
struct SimpleEventArgs
{
Int32 Value;
};
// Just ensure that IObservableVector compiles
interface IInterfaceWithObservableVector
{
void TakeObservable(Windows.Foundation.Collections.IObservableVector<IBasic> basics);
}
runtimeclass Simple
{
Simple();
void Method();
//Windows.Foundation.IReference<Int32> Reference(Windows.Foundation.DateTime value);
Windows.Foundation.IAsyncOperation<Int32> Operation(Windows.Foundation.DateTime value);
Windows.Foundation.IAsyncAction Action(Windows.Foundation.DateTime value);
Object Object(Windows.Foundation.DateTime value);
static event Windows.Foundation.EventHandler<Object> StaticEvent;
static void FireStaticEvent();
//Windows.Foundation.Numerics.Vector2 ReturnVector2();
BlittableStruct ReturnBlittableStruct();
void TakeBlittableStruct(BlittableStruct value);
BlittableStruct BlittableStructProperty;
StructWithIReference ReturnStructWithReference();
void TakeStructWithReference(StructWithIReference value);
StructWithIReference StructWithReferenceProperty;
NonBlittableStruct ReturnNonBlittableStruct();
void TakeNonBlittableStruct(NonBlittableStruct value);
NonBlittableStruct NonBlittableStructProperty;
String StringProperty;
event test_component.Delegates.SignalDelegate SignalEvent;
event test_component.Delegates.InDelegate InEvent;
event Windows.Foundation.TypedEventHandler<Simple, SimpleEventArgs> SimpleEvent;
void FireEvent();
overridable void CantActuallyOverrideBecauseNotComposable();
}
runtimeclass DeferrableEventArgs
{
Windows.Foundation.Deferral GetDeferral();
void IncrementCounter();
}
//runtimeclass Optional
//{
// Optional();
// Windows.Foundation.IReference<Int32> Property;
//}
interface IIAmImplementable
{
String InInt32(Int32 value);
String InString(String value);
String InObject(Object value);
// String InStringable(Windows.Foundation.IStringable value);
// String InStruct(Struct value);
// String InStructRef(ref const Struct value);
String InEnum(Signed value);
void OutInt32(out Int32 value);
void OutString(out String value);
void OutObject(out Object value);
// void OutStringable(out Windows.Foundation.IStringable value);
void OutBlittableStruct(out BlittableStruct value);
void OutNonBlittableStruct(out NonBlittableStruct value);
void OutEnum(out Signed value);
// Int32 ReturnInt32();
// String ReturnString();
Object ReturnObject();
// Windows.Foundation.IStringable ReturnStringable();
// Struct ReturnStruct();
Signed ReturnEnum();
Fruit EnumProperty;
Windows.Foundation.IReference<Guid> Id;
event test_component.Delegates.InDelegate ImplementableEvent;
void FireEvent(String data);
}
interface ISimpleDelegate
{
void DoThis();
void DoThat(Int32 val);
}
interface IBasic
{
[noexcept2]
void Method();
}
runtimeclass Class : IBasic
{
Class();
Class(String name);
Class(String name, Fruit fruit);
static void StaticTest();
static Int32 StaticTestReturn();
static Int32 StaticProperty{ get; };
IBasic Implementation;
// This is used to mimic API contract behavior, such that this will enforce separate types be generated
[
constructor_name("test_component.IClassFactory2"),
static_name("test_component.IClassStatics2")
]
{
Class(String name, Fruit fruit, IIAmImplementable implementation);
static Single StaticTestReturnFloat();
static Single StaticPropertyFloat;
}
void SetDelegate(ISimpleDelegate value);
ISimpleDelegate GetDelegate();
// Class(Windows.Foundation.Collections.IIterable<String> arg, Int32 dummy1);
// Class(Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > arg, Int32 dummy1, Int32 dummy2);
Class(Windows.Foundation.Collections.IMap<String, String> arg, Int32 dummy1, Int32 dummy2, Int32 dummy3);
Class(Windows.Foundation.Collections.IMapView<String, String> arg, Int32 dummy1, Int32 dummy2, Int32 dummy3, Int32 dummy4);
Class(Windows.Foundation.Collections.IVector<String> arg, Int32 dummy1, Int32 dummy2, Int32 dummy3, Int32 dummy4, Int32 dummy5);
Class(Windows.Foundation.Collections.IVectorView<String> arg, Int32 dummy1, Int32 dummy2, Int32 dummy3, Int32 dummy4, Int32 dummy5, Int32 dummy6);
void Fail(String message);
String InInt32(Int32 value);
String InString(String value);
String InObject(Object value);
// String InStringable(Windows.Foundation.IStringable value);
// String InStruct(Struct value);
// String InStructRef(ref const Struct value);
String InEnum(Signed value);
void OutInt32(out Int32 value);
void OutString(out String value);
void OutObject(out Object value);
void OutStringable(out Windows.Foundation.IStringable value);
void OutBlittableStruct(out BlittableStruct value);
void OutNonBlittableStruct(out NonBlittableStruct value);
void OutEnum(out Signed value);
// Int32 ReturnInt32();
// String ReturnString();
Object ReturnObject();
// Windows.Foundation.IStringable ReturnStringable();
// Struct ReturnStruct();
Signed ReturnEnum();
Windows.Foundation.IReference<Signed> ReturnReferenceEnum();
Fruit EnumProperty;
// void OutInt32Array(out Int32[] value);
// void OutStringArray(out String[] value);
// void OutObjectArray(out Object[] value);
// void OutStringableArray(out Windows.Foundation.IStringable[] value);
// void OutStructArray(out Struct[] value);
// void OutEnumArray(out Signed[] value);
// void RefInt32Array(ref Int32[] value);
// void RefStringArray(ref String[] value);
// void RefObjectArray(ref Object[] value);
// void RefStringableArray(ref Windows.Foundation.IStringable[] value);
// void RefStructArray(ref Struct[] value);
// void RefEnumArray(ref Signed[] value);
// Int32[] ReturnInt32Array();
// String[] ReturnStringArray();
// Object[] ReturnObjectArray();
// Windows.Foundation.IStringable[] ReturnStringableArray();
// Struct[] ReturnStructArray();
// Signed[] ReturnEnumArray();
[noexcept2] void NoexceptVoid();
[noexcept2] Int32 NoexceptInt32();
[noexcept2] String NoexceptString();
event Windows.Foundation.TypedEventHandler<Class, DeferrableEventArgs> DeferrableEvent;
Windows.Foundation.IAsyncOperation<Int32> RaiseDeferrableEventAsync();
// static Boolean TestNoMakeDetection();
// static Int32 StaticPropertyWithAsyncSetter;
// static void StaticMethodWithAsyncReturn();
Char ReturnChar();
String InChar(Char value);
void OutChar(out Char value);
Windows.Foundation.IReference<Int32> StartValue;
Windows.Foundation.IReference<Guid> Id;
Base BaseProperty;
BaseNoOverrides BaseNoOverridesProperty;
static void TakeBaseAndGiveToCallbackAsObject(Base base, test_component.Delegates.InObjectDelegate callback);
}
static runtimeclass StaticClass
{
static Fruit EnumProperty;
static String InEnum(Signed value);
static String InNonBlittableStruct(NonBlittableStruct value);
static void TakeBase(Base base);
}
//namespace Structs
//
// struct All
// {
// Windows.Foundation.Numerics.Matrix3x2 A;
// Windows.Foundation.Numerics.Matrix4x4 B;
// Windows.Foundation.Numerics.Plane C;
// Windows.Foundation.Numerics.Quaternion D;
// Windows.Foundation.Numerics.Vector2 E;
// Windows.Foundation.Numerics.Vector3 F;
// Windows.Foundation.Numerics.Vector4 G;
// Guid H;
// // TODO: uncomment when build server has newer version of midlrt.
// //HRESULT I;
// //EventRegistrationToken J;
// };
// struct Inner
// {
// Int32 InnerValue;
// };
// namespace Nested
// {
// struct Outer
// {
// test_component.Structs.Inner Depends;
// Int32 OuterValue;
// };
// }
// // structs can contain nullable types (IReference<>) as well as strings. These are the only non-POD types
// // Alphabetical sorting of names below is important to validate sort order in generated code. Metadata will
// // sort to alphabetical order. cppwinrt needs to re-establish dependencies in the IReference types to produce
// // correct output.
// struct NullableC
// {
// Single a1;
// Windows.Foundation.IReference<Single> a2;
// };
// struct NullableB
// {
// Windows.Foundation.IReference<NullableC> a1;
// };
// struct NullableA
// {
// Windows.Foundation.IReference<NullableB> a1;
// };
// }
// namespace Parent
// {
// // This validates namespace inclusion rules. The "...Three.h" header must include the
// // "...Parent.h" header but skip over the intermediate namespaces as they are empty
// // and won't be generated and those won't exist.
// struct ParentStruct
// {
// Int32 Value;
// };
// namespace One.Two.Three
// {
// struct ThreeStruct
// {
// Int32 Value;
// };
// }
// }
//}
unsealed runtimeclass Base {
protected Base();
overridable void OnDoTheThing();
void DoTheThing();
static Base CreateFromString(String value);
};
unsealed runtimeclass BaseNoOverrides {
protected BaseNoOverrides();
static BaseNoOverrides CreateFromString(String value);
}
unsealed runtimeclass UnsealedDerivedNoOverrides : BaseNoOverrides {
protected UnsealedDerivedNoOverrides();
}
runtimeclass Derived : Base {
Derived();
Int32 Prop;
static Derived CreateFromString(String value);
};
unsealed runtimeclass UnsealedDerivedNoConstructor: Base {
}
runtimeclass DerivedFromNoConstructor: UnsealedDerivedNoConstructor {
void Method();
}
unsealed runtimeclass UnsealedDerivedFromNoConstructor: UnsealedDerivedNoConstructor {
UnsealedDerivedFromNoConstructor();
}
unsealed runtimeclass UnsealedDerived : Base {
UnsealedDerived();
UnsealedDerived(Int32 prop);
UnsealedDerived(String prop1, Base prop2);
Int32 Prop;
overridable void OnBeforeDoTheThing();
[
overridable_name("test_component.IUnsealedDerivedOverloads2")
]
{
overridable void OnAfterDoTheThing();
}
};
unsealed runtimeclass UnsealedDerived2 : UnsealedDerived {
protected UnsealedDerived2();
UnsealedDerived2(Int32 prop);
void Method();
}
// unsealed to verify composable type names for generic default interfaces
unsealed runtimeclass BaseCollection : [default] IVector<Base>
{
protected BaseCollection();
}
runtimeclass BaseMapCollection : [default] IMap<String, Base>
{
}
runtimeclass BaseObservableCollection: [default] IObservableVector<Base>
{
}
}