1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
16 * The Original Code is mozilla.org code.
18 * The Initial Developer of the Original Code is
19 * Netscape Communications Corporation.
20 * Portions created by the Initial Developer are Copyright (C) 1998
21 * the Initial Developer. All Rights Reserved.
24 * John Bandhauer <jband@netscape.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 /* The long avoided variant support for xpcom. */
42 #include
"nsISupports.idl"
44 [scriptable
,uuid(4d12e540
-83d7
-11d5
-90ed
-0010a4e73d9a
)]
45 interface nsIDataType
: nsISupports
47 // These MUST match the declarations in xpt_struct.h.
48 // Otherwise the world is likely to explode.
49 // From xpt_struct.h ...
50 const PRUint16 VTYPE_INT8
= 0; // TD_INT8 = 0,
51 const PRUint16 VTYPE_INT16
= 1; // TD_INT16 = 1,
52 const PRUint16 VTYPE_INT32
= 2; // TD_INT32 = 2,
53 const PRUint16 VTYPE_INT64
= 3; // TD_INT64 = 3,
54 const PRUint16 VTYPE_UINT8
= 4; // TD_UINT8 = 4,
55 const PRUint16 VTYPE_UINT16
= 5; // TD_UINT16 = 5,
56 const PRUint16 VTYPE_UINT32
= 6; // TD_UINT32 = 6,
57 const PRUint16 VTYPE_UINT64
= 7; // TD_UINT64 = 7,
58 const PRUint16 VTYPE_FLOAT
= 8; // TD_FLOAT = 8,
59 const PRUint16 VTYPE_DOUBLE
= 9; // TD_DOUBLE = 9,
60 const PRUint16 VTYPE_BOOL
= 10; // TD_BOOL = 10,
61 const PRUint16 VTYPE_CHAR
= 11; // TD_CHAR = 11,
62 const PRUint16 VTYPE_WCHAR
= 12; // TD_WCHAR = 12,
63 const PRUint16 VTYPE_VOID
= 13; // TD_VOID = 13,
64 const PRUint16 VTYPE_ID
= 14; // TD_PNSIID = 14,
65 const PRUint16 VTYPE_DOMSTRING
= 15; // TD_DOMSTRING = 15,
66 const PRUint16 VTYPE_CHAR_STR
= 16; // TD_PSTRING = 16,
67 const PRUint16 VTYPE_WCHAR_STR
= 17; // TD_PWSTRING = 17,
68 const PRUint16 VTYPE_INTERFACE
= 18; // TD_INTERFACE_TYPE = 18,
69 const PRUint16 VTYPE_INTERFACE_IS
= 19; // TD_INTERFACE_IS_TYPE = 19,
70 const PRUint16 VTYPE_ARRAY
= 20; // TD_ARRAY = 20,
71 const PRUint16 VTYPE_STRING_SIZE_IS
= 21; // TD_PSTRING_SIZE_IS = 21,
72 const PRUint16 VTYPE_WSTRING_SIZE_IS
= 22; // TD_PWSTRING_SIZE_IS = 22,
73 const PRUint16 VTYPE_UTF8STRING
= 23; // TD_UTF8STRING = 23,
74 const PRUint16 VTYPE_CSTRING
= 24; // TD_CSTRING = 24,
75 const PRUint16 VTYPE_ASTRING
= 25; // TD_ASTRING = 25,
76 const PRUint16 VTYPE_EMPTY_ARRAY
= 254;
77 const PRUint16 VTYPE_EMPTY
= 255;
85 * XPConnect has magic to transparently convert between nsIVariant and JS types.
86 * We mark the interface [scriptable] so that JS can use methods
87 * that refer to this interface. But we mark all the methods and attributes
88 * [noscript] since any nsIVariant object will be automatically converted to a
92 [scriptable
, uuid(81e4c2de
-acac
-4ad6
-901a
-b5fb1b851a0d
)]
93 interface nsIVariant
: nsISupports
95 [noscript
] readonly attribute PRUint16 dataType
;
97 [noscript
] PRUint8 getAsInt8
();
98 [noscript
] PRInt16 getAsInt16
();
99 [noscript
] PRInt32 getAsInt32
();
100 [noscript
] PRInt64 getAsInt64
();
101 [noscript
] PRUint8 getAsUint8
();
102 [noscript
] PRUint16 getAsUint16
();
103 [noscript
] PRUint32 getAsUint32
();
104 [noscript
] PRUint64 getAsUint64
();
105 [noscript
] float getAsFloat
();
106 [noscript
] double getAsDouble
();
107 [noscript
] PRBool getAsBool
();
108 [noscript
] char getAsChar
();
109 [noscript
] wchar getAsWChar
();
110 [notxpcom
] nsresult getAsID
(out nsID
retval);
111 [noscript
] AString getAsAString
();
112 [noscript
] DOMString getAsDOMString
();
113 [noscript
] ACString getAsACString
();
114 [noscript
] AUTF8String getAsAUTF8String
();
115 [noscript
] string getAsString
();
116 [noscript
] wstring getAsWString
();
117 [noscript
] nsISupports getAsISupports
();
118 [noscript
] jsval getAsJSVal
();
120 [noscript
] void getAsInterface
(out nsIIDPtr iid
,
121 [iid_is(iid
), retval] out nsQIResult iface
);
123 [notxpcom
] nsresult getAsArray
(out PRUint16 type
, out nsIID iid
,
124 out PRUint32 count
, out voidPtr
ptr);
126 [noscript
] void getAsStringWithSize
(out PRUint32 size
,
127 [size_is(size
), retval] out string str
);
129 [noscript
] void getAsWStringWithSize
(out PRUint32 size
,
130 [size_is(size
), retval] out wstring str
);
134 * An object that implements nsIVariant may or may NOT also implement this
135 * nsIWritableVariant.
137 * If the 'writable' attribute is false then attempts to call any of the 'set'
138 * methods can be expected to fail. Setting the 'writable' attribute may or
143 [scriptable
, uuid(5586a590
-8c82
-11d5
-90f3
-0010a4e73d9a
)]
144 interface nsIWritableVariant
: nsIVariant
146 attribute PRBool writable
;
148 void setAsInt8
(in PRUint8 aValue
);
149 void setAsInt16
(in PRInt16 aValue
);
150 void setAsInt32
(in PRInt32 aValue
);
151 void setAsInt64
(in PRInt64 aValue
);
152 void setAsUint8
(in PRUint8 aValue
);
153 void setAsUint16
(in PRUint16 aValue
);
154 void setAsUint32
(in PRUint32 aValue
);
155 void setAsUint64
(in PRUint64 aValue
);
156 void setAsFloat
(in float aValue
);
157 void setAsDouble
(in double aValue
);
158 void setAsBool
(in PRBool aValue
);
159 void setAsChar
(in char aValue
);
160 void setAsWChar
(in wchar aValue
);
161 void setAsID
(in nsIDRef aValue
);
162 void setAsAString
(in AString aValue
);
163 void setAsDOMString
(in DOMString aValue
);
164 void setAsACString
(in ACString aValue
);
165 void setAsAUTF8String
(in AUTF8String aValue
);
166 void setAsString
(in string aValue
);
167 void setAsWString
(in wstring aValue
);
168 void setAsISupports
(in nsISupports aValue
);
170 void setAsInterface
(in nsIIDRef iid
,
171 [iid_is(iid
)] in nsQIResult iface
);
173 [noscript
] void setAsArray
(in PRUint16 type
, in nsIIDPtr iid
,
174 in PRUint32 count
, in voidPtr
ptr);
176 void setAsStringWithSize
(in PRUint32 size
,
177 [size_is(size
)] in string str
);
179 void setAsWStringWithSize
(in PRUint32 size
,
180 [size_is(size
)] in wstring str
);
184 void setAsEmptyArray
();
186 void setFromVariant
(in nsIVariant aValue
);
190 // The contractID for the generic implementation built in to xpcom.
191 #define NS_VARIANT_CONTRACTID
"@mozilla.org/variant;1"