TestWinRT/TestComponent/TestComponent.idl

203 строки
12 KiB
Plaintext
Исходник Обычный вид История

2019-10-17 16:57:31 +03:00
namespace TestComponent
{
2020-02-10 18:29:04 +03:00
// All language projections must deal with blittable vs. non-blittable structs somehow. In C++/WinRT, only structs
// containing String or IReference<T> are non-blittable since they result in structs that are not trivially destructible.
// In C#/WinRT, structs containing Boolean and Char are also non-blittable according to the following doc:
// https://docs.microsoft.com/en-us/dotnet/framework/interop/blittable-and-non-blittable-types
2020-02-03 20:15:10 +03:00
struct Blittable
2020-01-30 17:20:30 +03:00
{
2020-02-05 18:27:40 +03:00
UInt8 A;
UInt16 B;
UInt32 C;
UInt64 D;
Int16 E;
Int32 F;
Int64 G;
Single H;
Double I;
2020-02-10 18:29:04 +03:00
Guid J;
2020-01-30 17:20:30 +03:00
};
2020-02-03 20:15:10 +03:00
struct NonBlittable
2020-01-30 17:20:30 +03:00
{
2020-02-05 18:27:40 +03:00
Boolean A;
2020-02-10 18:29:04 +03:00
Char B;
String C;
Windows.Foundation.IReference<Int64> D;
2020-01-30 17:20:30 +03:00
};
2020-02-03 20:15:10 +03:00
struct Nested
2020-01-30 17:20:30 +03:00
{
2020-02-03 20:15:10 +03:00
Blittable Blittable;
NonBlittable NonBlittable;
2020-01-30 17:20:30 +03:00
};
2020-02-03 20:15:10 +03:00
delegate Boolean Param1Handler(Boolean a, out Boolean b);
delegate UInt8 Param2Handler(UInt8 a, out UInt8 b);
delegate UInt16 Param3Handler(UInt16 a, out UInt16 b);
delegate UInt32 Param4Handler(UInt32 a, out UInt32 b);
delegate UInt64 Param5Handler(UInt64 a, out UInt64 b);
delegate Int16 Param6Handler(Int16 a, out Int16 b);
delegate Int32 Param7Handler(Int32 a, out Int32 b);
delegate Int64 Param8Handler(Int64 a, out Int64 b);
delegate Single Param9Handler(Single a, out Single b);
delegate Double Param10Handler(Double a, out Double b);
delegate Char Param11Handler(Char a, out Char b);
delegate String Param12Handler(String a, out String b);
2020-02-04 18:23:36 +03:00
delegate Blittable Param13Handler(Blittable a, ref const Blittable b, out Blittable c);
delegate NonBlittable Param14Handler(NonBlittable a, ref const NonBlittable b, out NonBlittable c);
delegate Nested Param15Handler(Nested a, ref const Nested b, out Nested c);
2020-02-03 20:15:10 +03:00
delegate Boolean[] Array1Handler(Boolean[] a, ref Boolean[] b, out Boolean[] c);
delegate UInt8[] Array2Handler(UInt8[] a, ref UInt8[] b, out UInt8[] c);
delegate UInt16[] Array3Handler(UInt16[] a, ref UInt16[] b, out UInt16[] c);
delegate UInt32[] Array4Handler(UInt32[] a, ref UInt32[] b, out UInt32[] c);
delegate UInt64[] Array5Handler(UInt64[] a, ref UInt64[] b, out UInt64[] c);
delegate Int16[] Array6Handler(Int16[] a, ref Int16[] b, out Int16[] c);
delegate Int32[] Array7Handler(Int32[] a, ref Int32[] b, out Int32[] c);
delegate Int64[] Array8Handler(Int64[] a, ref Int64[] b, out Int64[] c);
delegate Single[] Array9Handler(Single[] a, ref Single[] b, out Single[] c);
delegate Double[] Array10Handler(Double[] a, ref Double[] b, out Double[] c);
delegate Char[] Array11Handler(Char[] a, ref Char[] b, out Char[] c);
delegate String[] Array12Handler(String[] a, ref String[] b, out String[] c);
delegate Blittable[] Array13Handler(Blittable[] a, ref Blittable[] b, out Blittable[] c);
delegate NonBlittable[] Array14Handler(NonBlittable[] a, ref NonBlittable[] b, out NonBlittable[] c);
delegate Nested[] Array15Handler(Nested[] a, ref Nested[] b, out Nested[] c);
2020-02-03 21:28:50 +03:00
delegate Windows.Foundation.Collections.IIterable<String> Collection1Handler(Windows.Foundation.Collections.IIterable<String> a, out Windows.Foundation.Collections.IIterable<String> b);
delegate Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > Collection2Handler(Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > a, out Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > b);
delegate Windows.Foundation.Collections.IMap<String, String> Collection3Handler(Windows.Foundation.Collections.IMap<String, String> a, out Windows.Foundation.Collections.IMap<String, String> b);
delegate Windows.Foundation.Collections.IMapView<String, String> Collection4Handler(Windows.Foundation.Collections.IMapView<String, String> a, out Windows.Foundation.Collections.IMapView<String, String> b);
delegate Windows.Foundation.Collections.IVector<String> Collection5Handler(Windows.Foundation.Collections.IVector<String> a, out Windows.Foundation.Collections.IVector<String> b);
delegate Windows.Foundation.Collections.IVectorView<String> Collection6Handler(Windows.Foundation.Collections.IVectorView<String> a, out Windows.Foundation.Collections.IVectorView<String> b);
delegate Windows.Foundation.IAsyncAction Async1Handler(Windows.Foundation.IAsyncAction suspend, Boolean fail);
delegate Windows.Foundation.IAsyncActionWithProgress<Int32> Async2Handler(Windows.Foundation.IAsyncAction suspend, Boolean fail, Int32 progress);
delegate Windows.Foundation.IAsyncOperation<Int32> Async3Handler(Windows.Foundation.IAsyncAction suspend, Boolean fail, Int32 result);
delegate Windows.Foundation.IAsyncOperationWithProgress<Int32, Int32> Async4Handler(Windows.Foundation.IAsyncAction suspend, Boolean fail, Int32 result, Int32 progress);
2019-10-17 16:57:31 +03:00
interface ITests
{
2020-02-03 22:28:38 +03:00
UInt32 Percentage{ get; };
2019-10-18 01:35:59 +03:00
void Simple();
2019-10-17 16:57:31 +03:00
2020-02-03 20:15:10 +03:00
Boolean Param1(Boolean a, out Boolean b);
UInt8 Param2(UInt8 a, out UInt8 b);
UInt16 Param3(UInt16 a, out UInt16 b);
UInt32 Param4(UInt32 a, out UInt32 b);
UInt64 Param5(UInt64 a, out UInt64 b);
Int16 Param6(Int16 a, out Int16 b);
Int32 Param7(Int32 a, out Int32 b);
Int64 Param8(Int64 a, out Int64 b);
Single Param9(Single a, out Single b);
Double Param10(Double a, out Double b);
Char Param11(Char a, out Char b);
String Param12(String a, out String b);
2020-02-04 18:23:36 +03:00
Blittable Param13(Blittable a, ref const Blittable b, out Blittable c);
NonBlittable Param14(NonBlittable a, ref const NonBlittable b, out NonBlittable c);
Nested Param15(Nested a, ref const Nested b, out Nested c);
2020-02-03 20:15:10 +03:00
void Param1Call(Param1Handler handler);
void Param2Call(Param2Handler handler);
void Param3Call(Param3Handler handler);
void Param4Call(Param4Handler handler);
void Param5Call(Param5Handler handler);
void Param6Call(Param6Handler handler);
void Param7Call(Param7Handler handler);
void Param8Call(Param8Handler handler);
void Param9Call(Param9Handler handler);
void Param10Call(Param10Handler handler);
void Param11Call(Param11Handler handler);
void Param12Call(Param12Handler handler);
void Param13Call(Param13Handler handler);
void Param14Call(Param14Handler handler);
void Param15Call(Param15Handler handler);
Boolean[] Array1(Boolean[] a, ref Boolean[] b, out Boolean[] c);
UInt8[] Array2(UInt8[] a, ref UInt8[] b, out UInt8[] c);
UInt16[] Array3(UInt16[] a, ref UInt16[] b, out UInt16[] c);
UInt32[] Array4(UInt32[] a, ref UInt32[] b, out UInt32[] c);
UInt64[] Array5(UInt64[] a, ref UInt64[] b, out UInt64[] c);
Int16[] Array6(Int16[] a, ref Int16[] b, out Int16[] c);
Int32[] Array7(Int32[] a, ref Int32[] b, out Int32[] c);
Int64[] Array8(Int64[] a, ref Int64[] b, out Int64[] c);
Single[] Array9(Single[] a, ref Single[] b, out Single[] c);
Double[] Array10(Double[] a, ref Double[] b, out Double[] c);
Char[] Array11(Char[] a, ref Char[] b, out Char[] c);
String[] Array12(String[] a, ref String[] b, out String[] c);
Blittable[] Array13(Blittable[] a, ref Blittable[] b, out Blittable[] c);
NonBlittable[] Array14(NonBlittable[] a, ref NonBlittable[] b, out NonBlittable[] c);
Nested[] Array15(Nested[] a, ref Nested[] b, out Nested[] c);
void Array1Call(Array1Handler handler);
void Array2Call(Array2Handler handler);
void Array3Call(Array3Handler handler);
void Array4Call(Array4Handler handler);
void Array5Call(Array5Handler handler);
void Array6Call(Array6Handler handler);
void Array7Call(Array7Handler handler);
void Array8Call(Array8Handler handler);
void Array9Call(Array9Handler handler);
void Array10Call(Array10Handler handler);
void Array11Call(Array11Handler handler);
void Array12Call(Array12Handler handler);
void Array13Call(Array13Handler handler);
void Array14Call(Array14Handler handler);
void Array15Call(Array15Handler handler);
Windows.Foundation.Collections.IIterable<String> Collection1(Windows.Foundation.Collections.IIterable<String> a, out Windows.Foundation.Collections.IIterable<String> b);
Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > Collection2(Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > a, out Windows.Foundation.Collections.IIterable<Windows.Foundation.Collections.IKeyValuePair<String, String> > b);
Windows.Foundation.Collections.IMap<String, String> Collection3(Windows.Foundation.Collections.IMap<String, String> a, out Windows.Foundation.Collections.IMap<String, String> b);
Windows.Foundation.Collections.IMapView<String, String> Collection4(Windows.Foundation.Collections.IMapView<String, String> a, out Windows.Foundation.Collections.IMapView<String, String> b);
Windows.Foundation.Collections.IVector<String> Collection5(Windows.Foundation.Collections.IVector<String> a, out Windows.Foundation.Collections.IVector<String> b);
Windows.Foundation.Collections.IVectorView<String> Collection6(Windows.Foundation.Collections.IVectorView<String> a, out Windows.Foundation.Collections.IVectorView<String> b);
2020-02-03 21:28:50 +03:00
void Collection1Call(Collection1Handler handler);
void Collection2Call(Collection2Handler handler);
void Collection3Call(Collection3Handler handler);
void Collection4Call(Collection4Handler handler);
void Collection5Call(Collection5Handler handler);
void Collection6Call(Collection6Handler handler);
2020-02-03 20:15:10 +03:00
Windows.Foundation.IAsyncAction Async1(Windows.Foundation.IAsyncAction suspend, Boolean fail);
Windows.Foundation.IAsyncActionWithProgress<Int32> Async2(Windows.Foundation.IAsyncAction suspend, Boolean fail, Int32 progress);
Windows.Foundation.IAsyncOperation<Int32> Async3(Windows.Foundation.IAsyncAction suspend, Boolean fail, Int32 result);
Windows.Foundation.IAsyncOperationWithProgress<Int32, Int32> Async4(Windows.Foundation.IAsyncAction suspend, Boolean fail, Int32 result, Int32 progress);
2020-02-03 21:28:50 +03:00
void Async1Call(Async1Handler handler);
void Async2Call(Async2Handler handler);
void Async3Call(Async3Handler handler);
void Async4Call(Async4Handler handler);
2020-02-05 18:27:40 +03:00
event Windows.Foundation.EventHandler<Int32> Event1;
event Windows.Foundation.TypedEventHandler<ITests, Int32> Event2;
void Event1Call(Int32 value);
void Event2Call(Int32 value);
2019-10-22 16:16:12 +03:00
}
2019-10-17 16:57:31 +03:00
delegate void TestHandler(ITests tests);
runtimeclass TestRunner
{
2020-02-03 20:15:10 +03:00
// Throws an exception if ITests is not implemented correctly.
static void TestProducer(ITests callee);
2019-10-22 16:16:12 +03:00
// Returns 100 (percent) if the calling language projection faithfully covered all tests.
2020-02-03 20:15:10 +03:00
static UInt32 TestConsumer(TestHandler caller);
2019-10-22 16:16:12 +03:00
// Test C++/WinRT as both caller and callee.
2019-10-17 17:43:09 +03:00
static void TestSelf();
2020-02-03 22:28:38 +03:00
// Returns an implementation of ITests for independently driven testing.
static ITests MakeTests();
// Creates empty collections to support Rust/WinRT testing.
static Windows.Foundation.Collections.IVector<Int32> CreateInt32Vector();
static Windows.Foundation.Collections.IVector<String> CreateStringVector();
static Windows.Foundation.Collections.IVector<Windows.Foundation.IStringable> CreateStringableVector();
2019-10-17 16:57:31 +03:00
}
}