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 typeInterfaceComponentIDL
nsIDPtrnsISupportsID@mozilla.org/supports-id;1
[scriptable, uuid(d18290a0-4a1c-11d3-9890-006008962422)]
interface nsISupportsID : nsISupportsPrimitive
{
    attribute nsIDPtr data;
    string toString();
};
AStringnsISupportsString@mozilla.org/supports-string;1
[scriptable, uuid(d79dc970-4a1c-11d3-9890-006008962422)]
interface nsISupportsString : nsISupportsPrimitive
{
    attribute AString data;
    wstring toString();
};
PRBoolnsISupportsPRBool@mozilla.org/supports-PRBool;1
[scriptable, uuid(ddc3b490-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRBool : nsISupportsPrimitive
{
    attribute PRBool data;
    string toString();
};
PRUint8nsISupportsPRUint8@mozilla.org/supports-PRUint8;1
[scriptable, uuid(dec2e4e0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint8 : nsISupportsPrimitive
{
    attribute PRUint8 data;
    string toString();
};
PRUint16nsISupportsPRUint16@mozilla.org/supports-PRUint16;1
[scriptable, uuid(dfacb090-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint16 : nsISupportsPrimitive
{
    attribute PRUint16 data;
    string toString();
};
PRUint32nsISupportsPRUint32@mozilla.org/supports-PRUint32;1
[scriptable, uuid(e01dc470-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint32 : nsISupportsPrimitive
{
    attribute PRUint32 data;
    string toString();
};
PRUint64nsISupportsPRUint64@mozilla.org/supports-PRUint64;1
[scriptable, uuid(e13567c0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRUint64 : nsISupportsPrimitive
{
    attribute PRUint64 data;
    string toString();
};
PRTimensISupportsPRTime@mozilla.org/supports-PRTime;1
[scriptable, uuid(e2563630-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRTime : nsISupportsPrimitive
{
    attribute PRTime data;
    string toString();
};
charnsISupportsChar@mozilla.org/supports-char;1
[scriptable, uuid(e2b05e40-4a1c-11d3-9890-006008962422)]
interface nsISupportsChar : nsISupportsPrimitive
{
    attribute char data;
    string toString();
};
PRInt16nsISupportsPRInt16@mozilla.org/supports-PRInt16;1
[scriptable, uuid(e30d94b0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt16 : nsISupportsPrimitive
{
    attribute PRInt16 data;
    string toString();
};
PRInt32nsISupportsPRInt32@mozilla.org/supports-PRInt32;1
[scriptable, uuid(e36c5250-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt32 : nsISupportsPrimitive
{
    attribute PRInt32 data;
    string toString();
};
PRInt64nsISupportsPRInt64@mozilla.org/supports-PRInt64;1
[scriptable, uuid(e3cb0ff0-4a1c-11d3-9890-006008962422)]
interface nsISupportsPRInt64 : nsISupportsPrimitive
{
    attribute PRInt64 data;
    string toString();
};
floatnsISupportsFloat@mozilla.org/supports-float;1
[scriptable, uuid(abeaa390-4ac0-11d3-baea-00805f8a5dd7)]
interface nsISupportsFloat : nsISupportsPrimitive
{
    attribute float data;
    string toString();
};
doublensISupportsDouble@mozilla.org/supports-double;1
[scriptable, uuid(b32523a0-4ac0-11d3-baea-00805f8a5dd7)]
interface nsISupportsDouble : nsISupportsPrimitive
{
    attribute double data;
    string toString();
};
voidPtrnsISupportsVoid@mozilla.org/supports-void;1
[scriptable, uuid(464484f0-568d-11d3-baf8-00805f8a5dd7)]
interface nsISupportsVoid : nsISupportsPrimitive
{
    [noscript] attribute voidPtr data;
    string toString();
};
nsISupportsnsISupportsInterfacePointer@mozilla.org/supports-interface-pointer;1
[scriptable, uuid(995ea724-1dd1-11b2-9211-c21bdd3e7ed0)]
interface nsISupportsInterfacePointer : nsISupportsPrimitive
{
    attribute nsISupports data;
    attribute nsIDPtr dataIID;

    string toString();
};

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:106 次

字数:9199

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文