1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 * Test pararameter passing and argument conversion.
8 * Each test method returns the value in 'b', and copies 'a' into 'b'. This lets
9 * us test return values, in params, and inout params (out params should be
10 * covered by the intersection of return values and inout).
13 #include
"nsISupports.idl"
16 interface nsIXPCTestInterfaceA
;
17 interface nsIXPCTestInterfaceB
;
19 [scriptable
, uuid(812145c7
-9fcc
-425e
-a878
-36ad1b7730b7
)]
20 interface nsIXPCTestParams
: nsISupports
{
22 // These types correspond to the ones in typelib.py
23 boolean testBoolean
(in boolean a
, inout
boolean b
);
24 octet testOctet
(in octet a
, inout octet b
);
25 short testShort
(in short a
, inout
short b
);
26 long testLong
(in long a
, inout
long b
);
27 long long testLongLong
(in long long a
, inout
long long b
);
28 unsigned short testUnsignedShort
(in unsigned short a
, inout
unsigned short b
);
29 unsigned long testUnsignedLong
(in unsigned long a
, inout
unsigned long b
);
30 unsigned long long testUnsignedLongLong
(in unsigned long long a
, inout
unsigned long long b
);
31 float testFloat
(in float a
, inout
float b
);
32 double testDouble
(in double a
, inout
float b
);
33 char testChar
(in char a
, inout
char b
);
34 string testString
(in string a
, inout
string b
);
35 wchar testWchar
(in wchar a
, inout wchar b
);
36 wstring testWstring
(in wstring a
, inout wstring b
);
37 AString testAString
(in AString a
, inout AString b
);
38 AUTF8String testAUTF8String
(in AUTF8String a
, inout AUTF8String b
);
39 ACString testACString
(in ACString a
, inout ACString b
);
40 jsval testJsval
(in jsval a
, inout jsval b
);
42 // Test various forms of the Array<T> type.
43 Array
<short> testShortSequence
(in Array
<short> a
, inout Array
<short> b
);
44 Array
<double> testDoubleSequence
(in Array
<double> a
, inout Array
<double> b
);
45 Array
<nsIXPCTestInterfaceA
> testInterfaceSequence
(in Array
<nsIXPCTestInterfaceA
> a
, inout Array
<nsIXPCTestInterfaceA
> b
);
46 Array
<AString
> testAStringSequence
(in Array
<AString
> a
, inout Array
<AString
> b
);
47 Array
<ACString
> testACStringSequence
(in Array
<ACString
> a
, inout Array
<ACString
> b
);
48 Array
<jsval
> testJsvalSequence
(in Array
<jsval
> a
, inout Array
<jsval
> b
);
49 Array
<Array
<short> > testSequenceSequence
(in Array
<Array
<short> > a
, inout Array
<Array
<short> > b
);
51 void testInterfaceIsSequence
(in nsIIDPtr aIID
, [iid_is(aIID
)] in Array
<nsQIResult
> a
,
52 inout nsIIDPtr bIID
, [iid_is(bIID
)] inout Array
<nsQIResult
> b
,
53 out nsIIDPtr rvIID
, [retval, iid_is(rvIID
)] out Array
<nsQIResult
> rv
);
55 // Returns whatever was passed in.
56 Array
<uint8_t
> testOptionalSequence
([optional] in Array
<uint8_t
> arr
);
59 // Dependent parameters use the same types as above, but are handled much differently.
63 void testShortArray
(in unsigned long aLength
, [array
, size_is(aLength
)] in short a
,
64 inout
unsigned long bLength
, [array
, size_is(bLength
)] inout
short b
,
65 out unsigned long rvLength
, [retval, array
, size_is(rvLength
)] out short rv
);
66 void testDoubleArray
(in unsigned long aLength
, [array
, size_is(aLength
)] in double a
,
67 inout
unsigned long bLength
, [array
, size_is(bLength
)] inout
double b
,
68 out unsigned long rvLength
, [retval, array
, size_is(rvLength
)] out double rv
);
69 void testStringArray
(in unsigned long aLength
, [array
, size_is(aLength
)] in string a
,
70 inout
unsigned long bLength
, [array
, size_is(bLength
)] inout
string b
,
71 out unsigned long rvLength
, [retval, array
, size_is(rvLength
)] out string rv
);
72 void testWstringArray
(in unsigned long aLength
, [array
, size_is(aLength
)] in wstring a
,
73 inout
unsigned long bLength
, [array
, size_is(bLength
)] inout wstring b
,
74 out unsigned long rvLength
, [retval, array
, size_is(rvLength
)] out wstring rv
);
75 void testInterfaceArray
(in unsigned long aLength
, [array
, size_is(aLength
)] in nsIXPCTestInterfaceA a
,
76 inout
unsigned long bLength
, [array
, size_is(bLength
)] inout nsIXPCTestInterfaceA b
,
77 out unsigned long rvLength
, [retval, array
, size_is(rvLength
)] out nsIXPCTestInterfaceA rv
);
79 // uint8 array with optional length. Returns array length.
80 unsigned long testByteArrayOptionalLength
([array
, size_is(aLength
)] in uint8_t a
, [optional] in unsigned long aLength
);
82 // Test sized strings.
83 void testSizedString
(in unsigned long aLength
, [size_is(aLength
)] in string a
,
84 inout
unsigned long bLength
, [size_is(bLength
)] inout
string b
,
85 out unsigned long rvLength
, [retval, size_is(rvLength
)] out string rv
);
86 void testSizedWstring
(in unsigned long aLength
, [size_is(aLength
)] in wstring a
,
87 inout
unsigned long bLength
, [size_is(bLength
)] inout wstring b
,
88 out unsigned long rvLength
, [retval, size_is(rvLength
)] out wstring rv
);
91 void testInterfaceIs
(in nsIIDPtr aIID
, [iid_is(aIID
)] in nsQIResult a
,
92 inout nsIIDPtr bIID
, [iid_is(bIID
)] inout nsQIResult b
,
93 out nsIIDPtr rvIID
, [retval, iid_is(rvIID
)] out nsQIResult rv
);
95 // Test arrays of iid_is. According to khuey we don't use it for anything
96 // in mozilla-central, but calendar stuff depends on it.
97 void testInterfaceIsArray
(in unsigned long aLength
, in nsIIDPtr aIID
,
98 [array
, size_is(aLength
), iid_is(aIID
)] in nsQIResult a
,
99 inout
unsigned long bLength
, inout nsIIDPtr bIID
,
100 [array
, size_is(bLength
), iid_is(bIID
)] inout nsQIResult b
,
101 out unsigned long rvLength
, out nsIIDPtr rvIID
,
102 [retval, array
, size_is(rvLength
), iid_is(rvIID
)] out nsQIResult rv
);
104 // Test arrays of jsvals
105 void testJsvalArray
(in unsigned long aLength
, [array
, size_is(aLength
)] in jsval a
,
106 inout
unsigned long bLength
, [array
, size_is(bLength
)] inout jsval b
,
107 out unsigned long rvLength
, [retval, array
, size_is(rvLength
)] out jsval rv
);
110 // Test for out dipper parameters
111 void testOutAString
(out AString o
);
113 // Test for optional array size_is.
114 ACString testStringArrayOptionalSize
([array
, size_is(aLength
)] in string a
, [optional] in unsigned long aLength
);
116 // Test for omitted optional out parameter.
117 void testOmittedOptionalOut
(in nsIXPCTestParams aJSObj
, [optional] out nsIURI aOut
);
119 readonly attribute
double testNaN
;