xpcom/ds/nsIVariant.idl

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/xpcom/ds/nsIVariant.idl	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,155 @@
     1.4 +/* -*- Mode: IDL; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
     1.5 + *
     1.6 + * This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +/* The long avoided variant support for xpcom. */
    1.11 +
    1.12 +#include "nsISupports.idl"
    1.13 +
    1.14 +[scriptable,uuid(4d12e540-83d7-11d5-90ed-0010a4e73d9a)]
    1.15 +interface nsIDataType : nsISupports
    1.16 +{
    1.17 +    // These MUST match the declarations in xpt_struct.h. 
    1.18 +    // Otherwise the world is likely to explode.   
    1.19 +                                                   // From xpt_struct.h ...
    1.20 +    const uint16_t VTYPE_INT8                =  0; // TD_INT8              = 0,
    1.21 +    const uint16_t VTYPE_INT16               =  1; // TD_INT16             = 1,
    1.22 +    const uint16_t VTYPE_INT32               =  2; // TD_INT32             = 2,
    1.23 +    const uint16_t VTYPE_INT64               =  3; // TD_INT64             = 3,
    1.24 +    const uint16_t VTYPE_UINT8               =  4; // TD_UINT8             = 4,
    1.25 +    const uint16_t VTYPE_UINT16              =  5; // TD_UINT16            = 5,
    1.26 +    const uint16_t VTYPE_UINT32              =  6; // TD_UINT32            = 6,
    1.27 +    const uint16_t VTYPE_UINT64              =  7; // TD_UINT64            = 7,
    1.28 +    const uint16_t VTYPE_FLOAT               =  8; // TD_FLOAT             = 8, 
    1.29 +    const uint16_t VTYPE_DOUBLE              =  9; // TD_DOUBLE            = 9,
    1.30 +    const uint16_t VTYPE_BOOL                = 10; // TD_BOOL              = 10,
    1.31 +    const uint16_t VTYPE_CHAR                = 11; // TD_CHAR              = 11,
    1.32 +    const uint16_t VTYPE_WCHAR               = 12; // TD_WCHAR             = 12,
    1.33 +    const uint16_t VTYPE_VOID                = 13; // TD_VOID              = 13,
    1.34 +    const uint16_t VTYPE_ID                  = 14; // TD_PNSIID            = 14,
    1.35 +    const uint16_t VTYPE_DOMSTRING           = 15; // TD_DOMSTRING         = 15,
    1.36 +    const uint16_t VTYPE_CHAR_STR            = 16; // TD_PSTRING           = 16,
    1.37 +    const uint16_t VTYPE_WCHAR_STR           = 17; // TD_PWSTRING          = 17,
    1.38 +    const uint16_t VTYPE_INTERFACE           = 18; // TD_INTERFACE_TYPE    = 18,
    1.39 +    const uint16_t VTYPE_INTERFACE_IS        = 19; // TD_INTERFACE_IS_TYPE = 19,
    1.40 +    const uint16_t VTYPE_ARRAY               = 20; // TD_ARRAY             = 20,
    1.41 +    const uint16_t VTYPE_STRING_SIZE_IS      = 21; // TD_PSTRING_SIZE_IS   = 21,
    1.42 +    const uint16_t VTYPE_WSTRING_SIZE_IS     = 22; // TD_PWSTRING_SIZE_IS  = 22,
    1.43 +    const uint16_t VTYPE_UTF8STRING          = 23; // TD_UTF8STRING        = 23,
    1.44 +    const uint16_t VTYPE_CSTRING             = 24; // TD_CSTRING           = 24,
    1.45 +    const uint16_t VTYPE_ASTRING             = 25; // TD_ASTRING           = 25,
    1.46 +    const uint16_t VTYPE_EMPTY_ARRAY         = 254;
    1.47 +    const uint16_t VTYPE_EMPTY               = 255;
    1.48 +};
    1.49 +
    1.50 +/**
    1.51 + * XPConnect has magic to transparently convert between nsIVariant and JS types.
    1.52 + * We mark the interface [scriptable] so that JS can use methods
    1.53 + * that refer to this interface. But we mark all the methods and attributes
    1.54 + * [noscript] since any nsIVariant object will be automatically converted to a
    1.55 + * JS type anyway.
    1.56 + */
    1.57 +
    1.58 +[scriptable, uuid(81e4c2de-acac-4ad6-901a-b5fb1b851a0d)]
    1.59 +interface nsIVariant : nsISupports
    1.60 +{
    1.61 +    [noscript] readonly attribute uint16_t     dataType;
    1.62 +
    1.63 +    [noscript] uint8_t      getAsInt8();
    1.64 +    [noscript] int16_t      getAsInt16();
    1.65 +    [noscript] int32_t      getAsInt32();
    1.66 +    [noscript] int64_t      getAsInt64();
    1.67 +    [noscript] uint8_t      getAsUint8();
    1.68 +    [noscript] uint16_t     getAsUint16();
    1.69 +    [noscript] uint32_t     getAsUint32();
    1.70 +    [noscript] uint64_t     getAsUint64();
    1.71 +    [noscript] float        getAsFloat();
    1.72 +    [noscript] double       getAsDouble();
    1.73 +    [noscript] boolean      getAsBool();
    1.74 +    [noscript] char         getAsChar();
    1.75 +    [noscript] wchar        getAsWChar();
    1.76 +    [notxpcom] nsresult     getAsID(out nsID retval);
    1.77 +    [noscript] AString      getAsAString();
    1.78 +    [noscript] DOMString    getAsDOMString();
    1.79 +    [noscript] ACString     getAsACString();
    1.80 +    [noscript] AUTF8String  getAsAUTF8String();
    1.81 +    [noscript] string       getAsString();
    1.82 +    [noscript] wstring      getAsWString();
    1.83 +    [noscript] nsISupports  getAsISupports();
    1.84 +    [noscript] jsval        getAsJSVal();
    1.85 +
    1.86 +    [noscript] void getAsInterface(out nsIIDPtr iid, 
    1.87 +                                   [iid_is(iid), retval] out nsQIResult iface);
    1.88 +
    1.89 +    [notxpcom] nsresult getAsArray(out uint16_t type, out nsIID iid,
    1.90 +                                   out uint32_t count, out voidPtr ptr);
    1.91 +
    1.92 +    [noscript] void getAsStringWithSize(out uint32_t size, 
    1.93 +                                        [size_is(size), retval] out string str);
    1.94 +    
    1.95 +    [noscript] void getAsWStringWithSize(out uint32_t size, 
    1.96 +                                         [size_is(size), retval] out wstring str);
    1.97 +};
    1.98 +
    1.99 +/**
   1.100 + * An object that implements nsIVariant may or may NOT also implement this
   1.101 + * nsIWritableVariant.
   1.102 + * 
   1.103 + * If the 'writable' attribute is false then attempts to call any of the 'set'
   1.104 + * methods can be expected to fail. Setting the 'writable' attribute may or
   1.105 + * may not succeed.
   1.106 + *
   1.107 + */
   1.108 +
   1.109 +[scriptable, uuid(5586a590-8c82-11d5-90f3-0010a4e73d9a)]
   1.110 +interface nsIWritableVariant : nsIVariant
   1.111 +{
   1.112 +    attribute boolean writable;
   1.113 +
   1.114 +    void setAsInt8(in uint8_t aValue);
   1.115 +    void setAsInt16(in int16_t aValue);
   1.116 +    void setAsInt32(in int32_t aValue);
   1.117 +    void setAsInt64(in int64_t aValue);
   1.118 +    void setAsUint8(in uint8_t aValue);
   1.119 +    void setAsUint16(in uint16_t aValue);
   1.120 +    void setAsUint32(in uint32_t aValue);
   1.121 +    void setAsUint64(in uint64_t aValue);
   1.122 +    void setAsFloat(in float aValue);
   1.123 +    void setAsDouble(in double aValue);
   1.124 +    void setAsBool(in boolean aValue);
   1.125 +    void setAsChar(in char aValue);
   1.126 +    void setAsWChar(in wchar aValue);
   1.127 +    void setAsID(in nsIDRef aValue);
   1.128 +    void setAsAString(in AString aValue);
   1.129 +    void setAsDOMString(in DOMString aValue);
   1.130 +    void setAsACString(in ACString aValue);
   1.131 +    void setAsAUTF8String(in AUTF8String aValue);
   1.132 +    void setAsString(in string aValue);
   1.133 +    void setAsWString(in wstring aValue);
   1.134 +    void setAsISupports(in nsISupports aValue);
   1.135 +
   1.136 +    void setAsInterface(in nsIIDRef iid, 
   1.137 +                        [iid_is(iid)] in nsQIResult iface);
   1.138 +
   1.139 +    [noscript] void setAsArray(in uint16_t type, in nsIIDPtr iid,
   1.140 +                               in uint32_t count, in voidPtr ptr);
   1.141 +
   1.142 +    void setAsStringWithSize(in uint32_t size, 
   1.143 +                             [size_is(size)] in string str);
   1.144 +    
   1.145 +    void setAsWStringWithSize(in uint32_t size, 
   1.146 +                              [size_is(size)] in wstring str);
   1.147 +
   1.148 +    void setAsVoid();
   1.149 +    void setAsEmpty();
   1.150 +    void setAsEmptyArray();
   1.151 +
   1.152 +    void setFromVariant(in nsIVariant aValue);
   1.153 +};
   1.154 +
   1.155 +%{C++
   1.156 +// The contractID for the generic implementation built in to xpcom.
   1.157 +#define NS_VARIANT_CONTRACTID "@mozilla.org/variant;1"
   1.158 +%}

mercurial