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();
};