Search completed in 1.13 seconds.
nsIClassInfo
Inherits from: nsISupports Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) Method overview nsISupports getHelperForLanguage(in PRUint32 language); void getInterfaces(out PRUint32 count, [array, size_is(count), retval] out nsIIDPtr array); Attributes Attribute Type Description classDescription string A human readable string naming the class, or null. Read only. classID nsCIDPtr A classID through which an instance of this class can be created, or null. ...
...y the Mozilla codebase only. RESERVED 1 << 31 The high order bit is RESERVED for consumers of these flags. No implementor of this interface should ever return flags with this bit set. EAGER_CLASSINFO 1 << 5 This flag is designed for use with nsGenericFactory and can be set in nsModuleComponentInfo::mFlags. It has no meaning when returned from the flags attribute of a
nsIClassInfo implementation. Obsolete since Gecko 2.0 Methods getHelperForLanguage() Get a language mapping specific helper object that may assist in using objects of this class in a specific lanaguage. For example, if asked for the helper for nsIProgrammingLanguage::JAVASCRIPT this might return an object that can be nsISupports.QueryInterface()'d into the nsIXPCScriptable interface to assist XPConn...
...rn 0 for count and null for array. ...
Using nsIClassInfo
What is
nsIClassInfo good for? If you use a C++ class which implements
nsIClassInfo from JavaScript, then you don't have to explicitly call QueryInterface on the JavaScript object to access the object's interfaces.
nsIClassInfo is good for other things too, but they're dark XPCOM magic. How do I use it? If you're writing JavaScript code which uses a C++ class implementing
nsIClassInfo, you don't need to do anything to activate the auto-interface magic which makes calling QueryInterface unnecessary. It just happens. How do I make my C++ class implement
nsIClassInfo? See
nsIClassInfoImpl.h for instructions. How does
nsIClassInfo work? That's also detailed in
nsIClassInfoImpl.h. Original Document Information Authors: Mike Shaver, Justin Lebar Last Updated Date: July 25, 2011 Copyr...
Mozilla DOM Hacking Guide
description of the structure: const char *mName: C-style string that is passed as second argument to the macro. It is the name of the JavaScript object that will be available in the browser through the DOM. union { nsDOMClassInfoConstructorFnc mConstructorFptr; nsDOMClassInfoExternalConstructorFnc mExternalConstructorFptr; } u; This union is a pointer to a function typedef'ed: typedef
nsIClassInfo* (*nsDOMClassInfoConstructorFnc)(nsDOMClassInfoID aID); or typedef
nsIClassInfo* (*nsDOMClassInfoExternalConstructorFnc) (const char* aName); It is initialized with the doCreate member function of the helper class passed as third argument to the macro.
nsIClassInfo *mCachedClassInfo: mCachedClassInfo holds an
nsIClassInfo pointer to an instance of the relevant helper class. const nsIID *m...
... it was defined on." For example, when we have the document object in JavaScript, we can call indistinctly document.getElementById(), or document.addEventListener(), although they are defined on two different interfaces (DOMDocument and DOMEventTarget. Needless to say this is critical for the use of the DOM in real-world content. In Mozilla interface flattening is obtained through the use of the
nsIClassInfo interface.
nsIClassInfo stores the interfaces available for an object and later on XPConnect uses those interfaces to lookup the right method to call. The great thing is that one can easily see the interfaces available from JS through interface flattening by looking at the code. The interesting part is in nsDOMClassInfo::Init(). There we have a long list of macros. There is one set of macros per...
... attribute that was not defined in IDL, and NewResolve() is used when resolving for the first time an attribute or method that was not previously resolved. Please see the nsIXPCScriptable interface for more information. The nsDOMClassInfo class The heart of Class Info is the nsDOMClassInfo class, defined in nsDOMClassInfo.h. It implements two interfaces besides nsISupports: nsIXPCScriptable and
nsIClassInfo. We already know what nsIXPCScriptable is used for (see the previous Section).
nsIClassInfo is an XPCOM interface, very well described by Mike Shaver in this overview of
nsIClassInfo. Basically it contains convenient methods to find out about the interfaces an object promises to support. In our case, this list of interfaces will be populated by "Class Info". See also Section 1.5 on the Init() f...
...And 10 more matches
Obsolete: XPCOM-based scripting for NPAPI plugins - Archive of obsolete content
the plugin code? A unique interface id should be obtained. Windows command uuidgen should be sufficient. An Interface Definition (.idl) file describing the plugin scriptable interface should be added to the project (see example 1). A Scriptable instance object should be implemented in the plugin. This class will contain native methods callable from JavaScript. This class should also inherit from
nsIClassInfo and implement its methods to be able to request all necessary privileges from the Mozilla security manager (see example 2). Two new cases for the above mentioned new variables should be added to the plugin implementation of NPP_GetValue (see example 3). How to call plugin native methods The following HTML code will do the job:</p> This should be changed, we shouldn't advocate EMBED <embed type="...
...d in the Mozilla source tree under modules/plugin/samples/4x-scriptable/ IBM Developer Works has published a good article on XPCOM. Examples Example 1. Sample .idl file #include "nsISupports.idl" [scriptable, uuid(bedb0778-2ee0-11d5-9cf8-0060b0fbd8ac)] interface nsITestPlugin : nsISupports { void nativeMethod(); }; Example 2. ...
...ules/plugin/samples/4x-scriptable/ IBM Developer Works has published a good article on XPCOM. Examples Example 1. Sample .idl file #include "nsISupports.idl" [scriptable, uuid(bedb0778-2ee0-11d5-9cf8-0060b0fbd8ac)] interface nsITestPlugin : nsISupports { void nativeMethod(); }; Example 2. Scriptable instance class #include "nsITestPlugin.h" #include "
nsIClassInfo.h" // We must implement
nsIClassInfo because it signals the // Mozilla Security Manager to allow calls from JavaScript. // helper class to implement all necessary
nsIClassInfo method stubs // and to set flags used by the security system class nsClassInfoMixin : public
nsIClassInfo { // These flags are used by the DOM and security systems to signal that // JavaScript callers are allowed to call this object's scritable methods. ...
...And 2 more matches
nsIXPConnect
Obsolete since Gecko 2.0 JSVal getXOWForObject(in JSContextPtr aJSContext, in JSObjectPtr aParent, in JSObjectPtr aWrappedObj); Native code only! Obsolete since Gecko 2.0 void ...
... void setDefaultSecurityManager(in nsIXPCSecurityManager aManager, in PRUint16 flags); nsIXPCFunctionThisTranslator setFunctionThisTranslator(in nsIIDRef aIID, in nsIXPCFunctionThisTranslator aTranslator); void setReportAllJSExceptions(in boo...
... cx A context. Requires request. proto The (newly created) prototype object for a DOM class. The JS half of an XPCWrappedNativeProto. flags Property flags for the quick stub properties--should be either JSPROP_ENUMERATE or 0. interfaceCount The number of interfaces the class implements. interfaceArray The interfaces the class implements; interfaceArray and interfaceCount are like what
nsIClassInfo.getInterfaces returns. Return value Missing Description Exceptions thrown Missing Exception Missing Description Native code only!evalInSandboxObject Evaluate script in a sandbox, completely isolated from all other running scripts. jsval evalInSandboxObject( in AString source, in JSContextPtr cx, in nsIXPConnectJSObjectHolder sandbox, in PRBool returnStringOnly ); Parameter...
...And 2 more matches
XPCOMUtils.jsm
the generateQI helper. classInfo: XPCOMUtils.generateCI( {classID: Components.ID("{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}"), contractID: "@example.com/xxx;1", classDescription: "unique text description", interfaces: [Components.interfaces.nsIObserver, Components.interfaces.nsIMyInterface, "nsIFoo", "nsIBar"], flags: Ci.
nsIClassInfo.SINGLETON}), // ...component implementation... }; Note: The ability to register the component in a category only on specific applications by adding the apps field to a category entry was added in Gecko 2. Notice that the QueryInterface() method implemented by the component simply calls the generateQI() method provided by the XPCOMUtils code module. Create an array of component constructo...
...uery the service to. generateNSGetFactory() Generates the NSGetFactory() function along with the factory definition. Function generateNSGetFactory( componentsArray ); Parameters componentsArray An array of component constructors. Return value A function that will return the factory for the components and can be assigned to NSGetFactory global variable. generateCI() Generates an
nsIClassInfo implementation for a component. The returned object should be assigned to the classInfo property of a JS object, the QueryInterface() function generated by generateQI will return it automatically then. function generateCI( classInfo ); Parameters classInfo An object containing the optional properties interfaces, contractID, classDescription, classID, flags. This parameter should not be t...
...classInfo property of a JS object, the QueryInterface() function generated by generateQI will return it automatically then. function generateCI( classInfo ); Parameters classInfo An object containing the optional properties interfaces, contractID, classDescription, classID, flags. This parameter should not be the component itself because that would cause a memory leak. Return value An
nsIClassInfo implementation returning the values of the properties from the classInfo parameter in its various properties. Exceptions thrown This method throws an exception with the message "In generateCI, don't use a component for generating classInfo" if classInfo parameter is an XPCOM component. generateQI() Generates a QueryInterface() function implementation. You need to assign the returned function ...
Index
rence Manual XPCOM This section will help you if you're already familiar with nsCOMPtr but you need details. If you've never use nsCOMPtrs before, you might want to read the Getting Started Guide first. If you're trying to fix a broken build, the FAQ might lead you to the answer more quickly. 83 Status, Recent Changes, and Plans XPCOM No summary! 84 Using
nsIClassInfo XPCOM If you use a C++ class which implements
nsIClassInfo from JavaScript, then you don't have to explicitly call QueryInterface on the JavaScript object to access the object's interfaces. 85 Using nsIDirectoryService Extensions, Guide, XPCOM nsDirectoryService implements the nsIProperties interface. This implementation will allow you to Get(), Set(), Define(), and...
...charset is actually detected. 390 nsIChromeFrameMessageManager Interfaces, Interfaces:Scriptable, XPCOM, XPCOM Interface Reference Loads a script into the remote frame. 391 nsIChromeRegistry Interfaces, NeedsContent, Reference, Reference(2), XPCOM, XPCOM Interface Reference Implemented by: @mozilla.org/chrome/chrome-registry;1 as a service: 392
nsIClassInfo Interfaces, Interfaces:Scriptable, XPCOM, XPCOM API Reference, XPCOM Interface Reference Bitflags for 'flags' attribute. 393 classDescription No summary! 394 classID No summary! 395 classIDNoAlloc No summary! 396 flags No summary! 397 getHelperForLanguage No summary! 398 ...
...ence, XPCOM Interface Reference Bitflags for 'flags' attribute. 393 classDescription No summary! 394 classID No summary! 395 classIDNoAlloc No summary! 396 flags No summary! 397 getHelperForLanguage No summary! 398 getInterfaces This content is now available at
nsIClassInfo.getInterfaces(). 399 implementationLanguage No summary! 400 nsIClipboard Clipboard, Interfaces, Interfaces:Scriptable, XPCOM, XPCOM API Reference, XPCOM Interface Reference Most clipboard operations in Firefox use kGlobalClipboard, which is the one also used by the typical control-C/control-V keyboard shortcuts. 401 nsIClipboardCommands Cl...
JavaScript-DOM Prototypes in Mozilla
totype setup on an XPConnect wrapped DOM node in Mozilla When a DOM node is accessed from JavaScript in Mozilla, the native C++ DOM node is wrapped using XPConnect and the wrapper is exposed to JavaScript as the JavaScript representation of the DOM node. When XPConnect wraps a C++ object it will create a JSObject that is unique to this C++ object. In the case where the C++ object has class info (
nsIClassInfo), the JSObject is a more or less empty JSObject which is not really that special. All the methods that are supposed to show up on this JSObject are actually not properties of the object itself, but rather properties of the prototype of the JSObject for the wrapper (unless the C++ object's class info has the flag nsIXPCScriptable::DONT_SHARE_PROTOTYPE set, but lets assume that's not the case here)...
How to build an XPCOM component in JavaScript
// define the function we want to expose in our interface hello: function() { return "Hello World!"; }, }; XPCOMUtils does the work of creating the module and factory for you after this. Finally, you create an array of your components to be created: var components = [HelloWorld]; and replace NSGetFactory/NSGetModule to use this ...
An Overview of XPCOM
y of a factory, for example, you derive from the nsISupports interface, which allows you to manage the lifetime of the factory objects themselves. This is important when you want to group sets of factories together and determine if they can be unloaded. Another benefit of using the nsISupports interface is that you can support other interfaces as they are introduced. As we'll show when we discuss
nsIClassInfo, some factories support querying information about the underlying implementation, such as what language the object is written in, interfaces that the object supports, etc. This kind of "future-proofing" is a key advantage that comes along with deriving from nsISupports. XPIDL and Type Libraries An easy and powerful way to define an interface - indeed, a requirement for defining interfaces in a ...
Creating the Component Code
o this interface is that the return type of getClassObject does not have to be an nsIFactory. Instead, the nsIModule can ask for implementation details about the XPCOM object. This is very useful if the caller is required to know information about the component like its threading module, whether or not it's a singleton, its implementation language, and so forth. The interface used in this case is
nsIClassInfo. Starting from the outside in, Onion Peel View of XPCOM Component Creation represents the sequence for constructing an XPCOM object. Onion Peel View of XPCOM Component Creation Before we begin looking at the various parts of the component and how they'll be implemented in the source, let's look at the module in weblock.cpp to see where we're going. The source we're referring to is listed in i...
Components.interfaces
gnated 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 interf...
classID
This content is now available at
nsIClassInfo.Attributes. ...
classIDNoAlloc
This content is now available at
nsIClassInfo.Attributes. ...
flags
This content is now available at
nsIClassInfo.Attributes. ...
nsIModule
nloaded. If the component module is native (that is, as part of a DLL), then this method may be called to determine whether or not the DLL may be unloaded from memory. Note: As of Gecko 1.7, native component modules are never unloaded. getClassObject() Obtains a Class Object from a nsIModule for a given CID and IID pair. This class object can either be query to a nsIFactory or a may be query to a
nsIClassInfo. void getClassObject( in nsIComponentManager aCompMgr, in nsCIDRef aClass, in nsIIDRef aIID, [retval, iid_is(aIID)] out nsQIResult aResult ); Parameters aCompMgr The global component manager. aClass The ClassID of object instance requested. aIID The IID of interface requested. aResult The resulting interface pointer. Exceptions thrown NS_ERROR_FACTO...
XPCOM Interface Reference
nsIBoxObjectnsIBrowserBoxObjectnsIBrowserHistorynsIBrowserSearchServicensICRLInfonsICRLManagernsICachensICacheDeviceInfonsICacheEntryDescriptornsICacheEntryInfonsICacheListenernsICacheMetaDataVisitornsICacheServicensICacheSessionnsICacheVisitornsICachingChannelnsICancelablensICategoryManagernsIChannelnsIChannelEventSinknsIChannelPolicynsICharsetResolvernsIChromeFrameMessageManagernsIChromeRegistry
nsIClassInfonsIClipboardnsIClipboardCommandsnsIClipboardDragDropHookListnsIClipboardDragDropHooksnsIClipboardHelpernsIClipboardOwnernsICollectionnsICommandControllernsICommandLinensICommandLineHandlernsICommandLineRunnernsIComponentManagernsIComponentRegistrarnsICompositionStringSynthesizernsIConsoleListenernsIConsoleMessagensIConsoleServicensIContainerBoxObjectnsIContentFrameMessageManagernsIContentPrefnsICo...
XPCOM
create an XPCOM component, it may fail to register correctly.Using nsCOMPtrThis document is the sum total of everything written down about nsCOMPtr. If you have a question about nsCOMPtr, and this document doesn't answer it, there probably isn't a document that answers it. You'll have to turn to the XPCOM newsgroup or another experienced nsCOMPtr user, or find the answer by experimentation.Using
nsIClassInfoIf you use a C++ class which implements
nsIClassInfo from JavaScript, then you don't have to explicitly call QueryInterface on the JavaScript object to access the object's interfaces.Using nsIDirectoryServicensDirectoryService implements the nsIProperties interface. This implementation will allow you to Get(), Set(), Define(), and Undefine() nsIFile.Using nsIPasswordManagerTechnical review complet...
Mozilla
es in Mozilla When a DOM node is accessed from JavaScript in Mozilla, the native C++ DOM node is wrapped using XPConnect and the wrapper is exposed to JavaScript as the JavaScript representation of the DOM node. When XPConnect wraps a C++ object it will create a JSObject that is unique to this C++ object. In the case where the C++ object has class info (
nsIClassInfo), the JSObject is a more or less empty JSObject which is not really that special. All the methods that are supposed to show up on this JSObject are actually not properties of the object itself, but rather properties of the prototype of the JSObject for the wrapper (unless the C++ object's class info has the flag nsIXPCScriptable::DONT_SHARE_PROTOTYPE set, but lets assume tha...