xpcom/ds/nsIVariant.idl

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 /* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 *
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 /* The long avoided variant support for xpcom. */
michael@0 8
michael@0 9 #include "nsISupports.idl"
michael@0 10
michael@0 11 [scriptable,uuid(4d12e540-83d7-11d5-90ed-0010a4e73d9a)]
michael@0 12 interface nsIDataType : nsISupports
michael@0 13 {
michael@0 14 // These MUST match the declarations in xpt_struct.h.
michael@0 15 // Otherwise the world is likely to explode.
michael@0 16 // From xpt_struct.h ...
michael@0 17 const uint16_t VTYPE_INT8 = 0; // TD_INT8 = 0,
michael@0 18 const uint16_t VTYPE_INT16 = 1; // TD_INT16 = 1,
michael@0 19 const uint16_t VTYPE_INT32 = 2; // TD_INT32 = 2,
michael@0 20 const uint16_t VTYPE_INT64 = 3; // TD_INT64 = 3,
michael@0 21 const uint16_t VTYPE_UINT8 = 4; // TD_UINT8 = 4,
michael@0 22 const uint16_t VTYPE_UINT16 = 5; // TD_UINT16 = 5,
michael@0 23 const uint16_t VTYPE_UINT32 = 6; // TD_UINT32 = 6,
michael@0 24 const uint16_t VTYPE_UINT64 = 7; // TD_UINT64 = 7,
michael@0 25 const uint16_t VTYPE_FLOAT = 8; // TD_FLOAT = 8,
michael@0 26 const uint16_t VTYPE_DOUBLE = 9; // TD_DOUBLE = 9,
michael@0 27 const uint16_t VTYPE_BOOL = 10; // TD_BOOL = 10,
michael@0 28 const uint16_t VTYPE_CHAR = 11; // TD_CHAR = 11,
michael@0 29 const uint16_t VTYPE_WCHAR = 12; // TD_WCHAR = 12,
michael@0 30 const uint16_t VTYPE_VOID = 13; // TD_VOID = 13,
michael@0 31 const uint16_t VTYPE_ID = 14; // TD_PNSIID = 14,
michael@0 32 const uint16_t VTYPE_DOMSTRING = 15; // TD_DOMSTRING = 15,
michael@0 33 const uint16_t VTYPE_CHAR_STR = 16; // TD_PSTRING = 16,
michael@0 34 const uint16_t VTYPE_WCHAR_STR = 17; // TD_PWSTRING = 17,
michael@0 35 const uint16_t VTYPE_INTERFACE = 18; // TD_INTERFACE_TYPE = 18,
michael@0 36 const uint16_t VTYPE_INTERFACE_IS = 19; // TD_INTERFACE_IS_TYPE = 19,
michael@0 37 const uint16_t VTYPE_ARRAY = 20; // TD_ARRAY = 20,
michael@0 38 const uint16_t VTYPE_STRING_SIZE_IS = 21; // TD_PSTRING_SIZE_IS = 21,
michael@0 39 const uint16_t VTYPE_WSTRING_SIZE_IS = 22; // TD_PWSTRING_SIZE_IS = 22,
michael@0 40 const uint16_t VTYPE_UTF8STRING = 23; // TD_UTF8STRING = 23,
michael@0 41 const uint16_t VTYPE_CSTRING = 24; // TD_CSTRING = 24,
michael@0 42 const uint16_t VTYPE_ASTRING = 25; // TD_ASTRING = 25,
michael@0 43 const uint16_t VTYPE_EMPTY_ARRAY = 254;
michael@0 44 const uint16_t VTYPE_EMPTY = 255;
michael@0 45 };
michael@0 46
michael@0 47 /**
michael@0 48 * XPConnect has magic to transparently convert between nsIVariant and JS types.
michael@0 49 * We mark the interface [scriptable] so that JS can use methods
michael@0 50 * that refer to this interface. But we mark all the methods and attributes
michael@0 51 * [noscript] since any nsIVariant object will be automatically converted to a
michael@0 52 * JS type anyway.
michael@0 53 */
michael@0 54
michael@0 55 [scriptable, uuid(81e4c2de-acac-4ad6-901a-b5fb1b851a0d)]
michael@0 56 interface nsIVariant : nsISupports
michael@0 57 {
michael@0 58 [noscript] readonly attribute uint16_t dataType;
michael@0 59
michael@0 60 [noscript] uint8_t getAsInt8();
michael@0 61 [noscript] int16_t getAsInt16();
michael@0 62 [noscript] int32_t getAsInt32();
michael@0 63 [noscript] int64_t getAsInt64();
michael@0 64 [noscript] uint8_t getAsUint8();
michael@0 65 [noscript] uint16_t getAsUint16();
michael@0 66 [noscript] uint32_t getAsUint32();
michael@0 67 [noscript] uint64_t getAsUint64();
michael@0 68 [noscript] float getAsFloat();
michael@0 69 [noscript] double getAsDouble();
michael@0 70 [noscript] boolean getAsBool();
michael@0 71 [noscript] char getAsChar();
michael@0 72 [noscript] wchar getAsWChar();
michael@0 73 [notxpcom] nsresult getAsID(out nsID retval);
michael@0 74 [noscript] AString getAsAString();
michael@0 75 [noscript] DOMString getAsDOMString();
michael@0 76 [noscript] ACString getAsACString();
michael@0 77 [noscript] AUTF8String getAsAUTF8String();
michael@0 78 [noscript] string getAsString();
michael@0 79 [noscript] wstring getAsWString();
michael@0 80 [noscript] nsISupports getAsISupports();
michael@0 81 [noscript] jsval getAsJSVal();
michael@0 82
michael@0 83 [noscript] void getAsInterface(out nsIIDPtr iid,
michael@0 84 [iid_is(iid), retval] out nsQIResult iface);
michael@0 85
michael@0 86 [notxpcom] nsresult getAsArray(out uint16_t type, out nsIID iid,
michael@0 87 out uint32_t count, out voidPtr ptr);
michael@0 88
michael@0 89 [noscript] void getAsStringWithSize(out uint32_t size,
michael@0 90 [size_is(size), retval] out string str);
michael@0 91
michael@0 92 [noscript] void getAsWStringWithSize(out uint32_t size,
michael@0 93 [size_is(size), retval] out wstring str);
michael@0 94 };
michael@0 95
michael@0 96 /**
michael@0 97 * An object that implements nsIVariant may or may NOT also implement this
michael@0 98 * nsIWritableVariant.
michael@0 99 *
michael@0 100 * If the 'writable' attribute is false then attempts to call any of the 'set'
michael@0 101 * methods can be expected to fail. Setting the 'writable' attribute may or
michael@0 102 * may not succeed.
michael@0 103 *
michael@0 104 */
michael@0 105
michael@0 106 [scriptable, uuid(5586a590-8c82-11d5-90f3-0010a4e73d9a)]
michael@0 107 interface nsIWritableVariant : nsIVariant
michael@0 108 {
michael@0 109 attribute boolean writable;
michael@0 110
michael@0 111 void setAsInt8(in uint8_t aValue);
michael@0 112 void setAsInt16(in int16_t aValue);
michael@0 113 void setAsInt32(in int32_t aValue);
michael@0 114 void setAsInt64(in int64_t aValue);
michael@0 115 void setAsUint8(in uint8_t aValue);
michael@0 116 void setAsUint16(in uint16_t aValue);
michael@0 117 void setAsUint32(in uint32_t aValue);
michael@0 118 void setAsUint64(in uint64_t aValue);
michael@0 119 void setAsFloat(in float aValue);
michael@0 120 void setAsDouble(in double aValue);
michael@0 121 void setAsBool(in boolean aValue);
michael@0 122 void setAsChar(in char aValue);
michael@0 123 void setAsWChar(in wchar aValue);
michael@0 124 void setAsID(in nsIDRef aValue);
michael@0 125 void setAsAString(in AString aValue);
michael@0 126 void setAsDOMString(in DOMString aValue);
michael@0 127 void setAsACString(in ACString aValue);
michael@0 128 void setAsAUTF8String(in AUTF8String aValue);
michael@0 129 void setAsString(in string aValue);
michael@0 130 void setAsWString(in wstring aValue);
michael@0 131 void setAsISupports(in nsISupports aValue);
michael@0 132
michael@0 133 void setAsInterface(in nsIIDRef iid,
michael@0 134 [iid_is(iid)] in nsQIResult iface);
michael@0 135
michael@0 136 [noscript] void setAsArray(in uint16_t type, in nsIIDPtr iid,
michael@0 137 in uint32_t count, in voidPtr ptr);
michael@0 138
michael@0 139 void setAsStringWithSize(in uint32_t size,
michael@0 140 [size_is(size)] in string str);
michael@0 141
michael@0 142 void setAsWStringWithSize(in uint32_t size,
michael@0 143 [size_is(size)] in wstring str);
michael@0 144
michael@0 145 void setAsVoid();
michael@0 146 void setAsEmpty();
michael@0 147 void setAsEmptyArray();
michael@0 148
michael@0 149 void setFromVariant(in nsIVariant aValue);
michael@0 150 };
michael@0 151
michael@0 152 %{C++
michael@0 153 // The contractID for the generic implementation built in to xpcom.
michael@0 154 #define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1"
michael@0 155 %}

mercurial