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