Components.interfaces 编辑

Components.interfaces is a read-only object whose properties are interfaces indexed by their names.

Introduction

Components.interfaces is a read-only object whose properties implement the nsIJSIID interface. Each object represents one of the XPCOM interfaces -- that some component or another might or might not implement. It reflects only those interfaces which have been designated in their .idl description as scriptable, that is the interfaces which XPConnect is capable of reflecting into JavaScript.

Properties of the Components.interfaces object are used where XPCOM methods expect a parameter of type nsID. This includes nsISupports.QueryInterface(), the optional parameter accepted by nsIJSCID.getService(), nsIJSCID.createInstance() when called from JavaScript, and nsIClassInfo.getInterfaces().

The properties of the Components.interfaces object can be enumerated using a for...in loop.

Usage

Accessing an interface object

Properties of the Components.interfaces object are indexed by interface name. You can retrieve an interface object using:

var iface = Components.interfaces.nsISupportsArray;

This will return you the interface object for the nsISupportsArray interface.

Accessing constants defined in an interface

Interface descriptions (cf. XPIDL) may not only contain method declarations, but also constants. For example, assume we have the following interface declaration:

interface nsIFoo : nsISupports {
  const PRUint32 MYFLAG = 5;
};

The constant MYFLAG can then be accessed using

var myFlag = Components.interfaces.nsIFoo.MYFLAG;

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

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

发布评论

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

词条统计

浏览:91 次

字数:3012

最后编辑:8年前

编辑次数:0 次

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