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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论