XPCOM primitive

An XPCOM primitive is an XPCOM object that "boxes" a value of a primitive type. All XPCOM primitives are scriptable, and they all implement an XPCOM interface from the table below.

Primitives are rarely useful. The main use case is to store primitive values in a data structure that can only store XPCOM objects, such as nsIArray. Also, certain APIs, such as nsITransferable.setTransferData(), require primitives. (However, if you are designing that kind of API today, you should probably use nsIVariant instead.)

IDL data type Interface Component IDL
nsIDPtr nsISupportsID @mozilla.org/supports-id;1
[scriptable, uuid(d18290a0-4a1c-11d3-9890-006008962422)]
interface nsISupportsID : nsISupportsPrimitive
{
    attribute nsIDPtr data;
    string toString();
};
AString nsISupportsString @mozilla.org/supports-string;1
[scriptable, uuid(d79dc970-4a1c-11d3-9890-006008962422)]
interface nsISupportsString : nsISupportsPrimitive
{
    attribute AString data;
    wstring toString();
};
PRBool nsISupportsPRBool @mozilla.org/supports-PRBool;1
[scriptable, uuid(ddc3b490-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRBool : nsISupportsPrimitive
{
    attribute PRBool data;
    string toString();
};
PRUint8 nsISupportsPRUint8 @mozilla.org/supports-PRUint8;1
[scriptable, uuid(dec2e4e0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint8 : nsISupportsPrimitive
{
    attribute PRUint8 data;
    string toString();
};
PRUint16 nsISupportsPRUint16 @mozilla.org/supports-PRUint16;1
[scriptable, uuid(dfacb090-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint16 : nsISupportsPrimitive
{
    attribute PRUint16 data;
    string toString();
};
PRUint32 nsISupportsPRUint32 @mozilla.org/supports-PRUint32;1
[scriptable, uuid(e01dc470-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint32 : nsISupportsPrimitive
{
    attribute PRUint32 data;
    string toString();
};
PRUint64 nsISupportsPRUint64 @mozilla.org/supports-PRUint64;1
[scriptable, uuid(e13567c0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint64 : nsISupportsPrimitive
{
    attribute PRUint64 data;
    string toString();
};
PRTime nsISupportsPRTime @mozilla.org/supports-PRTime;1
[scriptable, uuid(e2563630-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRTime : nsISupportsPrimitive
{
    attribute PRTime data;
    string toString();
};
char nsISupportsChar @mozilla.org/supports-char;1
[scriptable, uuid(e2b05e40-4a1c-11d3-9890-006008962422)]
interface nsISupportsChar : nsISupportsPrimitive
{
    attribute char data;
    string toString();
};
PRInt16 nsISupportsPRInt16 @mozilla.org/supports-PRInt16;1
[scriptable, uuid(e30d94b0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt16 : nsISupportsPrimitive
{
    attribute PRInt16 data;
    string toString();
};
PRInt32 nsISupportsPRInt32 @mozilla.org/supports-PRInt32;1
[scriptable, uuid(e36c5250-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt32 : nsISupportsPrimitive
{
    attribute PRInt32 data;
    string toString();
};
PRInt64 nsISupportsPRInt64 @mozilla.org/supports-PRInt64;1
[scriptable, uuid(e3cb0ff0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt64 : nsISupportsPrimitive
{
    attribute PRInt64 data;
    string toString();
};
float nsISupportsFloat @mozilla.org/supports-float;1
[scriptable, uuid(abeaa390-4ac0-11d3-baea-00805f8a5dd7)]
interface nsISupportsFloat : nsISupportsPrimitive
{
    attribute float data;
    string toString();
};
double nsISupportsDouble @mozilla.org/supports-double;1
[scriptable, uuid(b32523a0-4ac0-11d3-baea-00805f8a5dd7)]
interface nsISupportsDouble : nsISupportsPrimitive
{
    attribute double data;
    string toString();
};
voidPtr nsISupportsVoid @mozilla.org/supports-void;1
[scriptable, uuid(464484f0-568d-11d3-baf8-00805f8a5dd7)]
interface nsISupportsVoid : nsISupportsPrimitive
{
    [noscript] attribute voidPtr data;
    string toString();
};
nsISupports nsISupportsInterfacePointer @mozilla.org/supports-interface-pointer;1
[scriptable, uuid(995ea724-1dd1-11b2-9211-c21bdd3e7ed0)]
interface nsISupportsInterfacePointer : nsISupportsPrimitive
{
    attribute nsISupports data;
    attribute nsIDPtr dataIID;
    string toString();
};

Document Tags and Contributors

 Contributors to this page: teoli, Smi, Jorend
 Last updated by: Smi,