michael@0: /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* The long avoided variant support for xpcom. */ michael@0: michael@0: #include "nsISupports.idl" michael@0: michael@0: [scriptable,uuid(4d12e540-83d7-11d5-90ed-0010a4e73d9a)] michael@0: interface nsIDataType : nsISupports michael@0: { michael@0: // These MUST match the declarations in xpt_struct.h. michael@0: // Otherwise the world is likely to explode. michael@0: // From xpt_struct.h ... michael@0: const uint16_t VTYPE_INT8 = 0; // TD_INT8 = 0, michael@0: const uint16_t VTYPE_INT16 = 1; // TD_INT16 = 1, michael@0: const uint16_t VTYPE_INT32 = 2; // TD_INT32 = 2, michael@0: const uint16_t VTYPE_INT64 = 3; // TD_INT64 = 3, michael@0: const uint16_t VTYPE_UINT8 = 4; // TD_UINT8 = 4, michael@0: const uint16_t VTYPE_UINT16 = 5; // TD_UINT16 = 5, michael@0: const uint16_t VTYPE_UINT32 = 6; // TD_UINT32 = 6, michael@0: const uint16_t VTYPE_UINT64 = 7; // TD_UINT64 = 7, michael@0: const uint16_t VTYPE_FLOAT = 8; // TD_FLOAT = 8, michael@0: const uint16_t VTYPE_DOUBLE = 9; // TD_DOUBLE = 9, michael@0: const uint16_t VTYPE_BOOL = 10; // TD_BOOL = 10, michael@0: const uint16_t VTYPE_CHAR = 11; // TD_CHAR = 11, michael@0: const uint16_t VTYPE_WCHAR = 12; // TD_WCHAR = 12, michael@0: const uint16_t VTYPE_VOID = 13; // TD_VOID = 13, michael@0: const uint16_t VTYPE_ID = 14; // TD_PNSIID = 14, michael@0: const uint16_t VTYPE_DOMSTRING = 15; // TD_DOMSTRING = 15, michael@0: const uint16_t VTYPE_CHAR_STR = 16; // TD_PSTRING = 16, michael@0: const uint16_t VTYPE_WCHAR_STR = 17; // TD_PWSTRING = 17, michael@0: const uint16_t VTYPE_INTERFACE = 18; // TD_INTERFACE_TYPE = 18, michael@0: const uint16_t VTYPE_INTERFACE_IS = 19; // TD_INTERFACE_IS_TYPE = 19, michael@0: const uint16_t VTYPE_ARRAY = 20; // TD_ARRAY = 20, michael@0: const uint16_t VTYPE_STRING_SIZE_IS = 21; // TD_PSTRING_SIZE_IS = 21, michael@0: const uint16_t VTYPE_WSTRING_SIZE_IS = 22; // TD_PWSTRING_SIZE_IS = 22, michael@0: const uint16_t VTYPE_UTF8STRING = 23; // TD_UTF8STRING = 23, michael@0: const uint16_t VTYPE_CSTRING = 24; // TD_CSTRING = 24, michael@0: const uint16_t VTYPE_ASTRING = 25; // TD_ASTRING = 25, michael@0: const uint16_t VTYPE_EMPTY_ARRAY = 254; michael@0: const uint16_t VTYPE_EMPTY = 255; michael@0: }; michael@0: michael@0: /** michael@0: * XPConnect has magic to transparently convert between nsIVariant and JS types. michael@0: * We mark the interface [scriptable] so that JS can use methods michael@0: * that refer to this interface. But we mark all the methods and attributes michael@0: * [noscript] since any nsIVariant object will be automatically converted to a michael@0: * JS type anyway. michael@0: */ michael@0: michael@0: [scriptable, uuid(81e4c2de-acac-4ad6-901a-b5fb1b851a0d)] michael@0: interface nsIVariant : nsISupports michael@0: { michael@0: [noscript] readonly attribute uint16_t dataType; michael@0: michael@0: [noscript] uint8_t getAsInt8(); michael@0: [noscript] int16_t getAsInt16(); michael@0: [noscript] int32_t getAsInt32(); michael@0: [noscript] int64_t getAsInt64(); michael@0: [noscript] uint8_t getAsUint8(); michael@0: [noscript] uint16_t getAsUint16(); michael@0: [noscript] uint32_t getAsUint32(); michael@0: [noscript] uint64_t getAsUint64(); michael@0: [noscript] float getAsFloat(); michael@0: [noscript] double getAsDouble(); michael@0: [noscript] boolean getAsBool(); michael@0: [noscript] char getAsChar(); michael@0: [noscript] wchar getAsWChar(); michael@0: [notxpcom] nsresult getAsID(out nsID retval); michael@0: [noscript] AString getAsAString(); michael@0: [noscript] DOMString getAsDOMString(); michael@0: [noscript] ACString getAsACString(); michael@0: [noscript] AUTF8String getAsAUTF8String(); michael@0: [noscript] string getAsString(); michael@0: [noscript] wstring getAsWString(); michael@0: [noscript] nsISupports getAsISupports(); michael@0: [noscript] jsval getAsJSVal(); michael@0: michael@0: [noscript] void getAsInterface(out nsIIDPtr iid, michael@0: [iid_is(iid), retval] out nsQIResult iface); michael@0: michael@0: [notxpcom] nsresult getAsArray(out uint16_t type, out nsIID iid, michael@0: out uint32_t count, out voidPtr ptr); michael@0: michael@0: [noscript] void getAsStringWithSize(out uint32_t size, michael@0: [size_is(size), retval] out string str); michael@0: michael@0: [noscript] void getAsWStringWithSize(out uint32_t size, michael@0: [size_is(size), retval] out wstring str); michael@0: }; michael@0: michael@0: /** michael@0: * An object that implements nsIVariant may or may NOT also implement this michael@0: * nsIWritableVariant. michael@0: * michael@0: * If the 'writable' attribute is false then attempts to call any of the 'set' michael@0: * methods can be expected to fail. Setting the 'writable' attribute may or michael@0: * may not succeed. michael@0: * michael@0: */ michael@0: michael@0: [scriptable, uuid(5586a590-8c82-11d5-90f3-0010a4e73d9a)] michael@0: interface nsIWritableVariant : nsIVariant michael@0: { michael@0: attribute boolean writable; michael@0: michael@0: void setAsInt8(in uint8_t aValue); michael@0: void setAsInt16(in int16_t aValue); michael@0: void setAsInt32(in int32_t aValue); michael@0: void setAsInt64(in int64_t aValue); michael@0: void setAsUint8(in uint8_t aValue); michael@0: void setAsUint16(in uint16_t aValue); michael@0: void setAsUint32(in uint32_t aValue); michael@0: void setAsUint64(in uint64_t aValue); michael@0: void setAsFloat(in float aValue); michael@0: void setAsDouble(in double aValue); michael@0: void setAsBool(in boolean aValue); michael@0: void setAsChar(in char aValue); michael@0: void setAsWChar(in wchar aValue); michael@0: void setAsID(in nsIDRef aValue); michael@0: void setAsAString(in AString aValue); michael@0: void setAsDOMString(in DOMString aValue); michael@0: void setAsACString(in ACString aValue); michael@0: void setAsAUTF8String(in AUTF8String aValue); michael@0: void setAsString(in string aValue); michael@0: void setAsWString(in wstring aValue); michael@0: void setAsISupports(in nsISupports aValue); michael@0: michael@0: void setAsInterface(in nsIIDRef iid, michael@0: [iid_is(iid)] in nsQIResult iface); michael@0: michael@0: [noscript] void setAsArray(in uint16_t type, in nsIIDPtr iid, michael@0: in uint32_t count, in voidPtr ptr); michael@0: michael@0: void setAsStringWithSize(in uint32_t size, michael@0: [size_is(size)] in string str); michael@0: michael@0: void setAsWStringWithSize(in uint32_t size, michael@0: [size_is(size)] in wstring str); michael@0: michael@0: void setAsVoid(); michael@0: void setAsEmpty(); michael@0: void setAsEmptyArray(); michael@0: michael@0: void setFromVariant(in nsIVariant aValue); michael@0: }; michael@0: michael@0: %{C++ michael@0: // The contractID for the generic implementation built in to xpcom. michael@0: #define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1" michael@0: %}