Using nsIClassInfo

  • Revision slug: Using_nsIClassInfo
  • Revision title: Using nsIClassInfo
  • Revision id: 76981
  • Created:
  • Creator: jlebar
  • Is current revision? No
  • Comment 8 words added, 5 words removed

Revision Content

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
  • Copyright Information: Portions of this content are © 1998–2011 by individual mozilla.org contributors; content available under a Creative Commons license | Details.

Revision Source

<h5 name="What_is_nsIClassInfo.3F">What is <code>nsIClassInfo</code> good for?</h5>
<p>If you use a C++ class which implements <code>nsIClassInfo</code> from JavaScript, then you don't have to explicitly call <code>QueryInterface</code> on the JavaScript object to access the object's interfaces.</p>
<p><code>nsIClassInfo</code> is good for other things too, but they're dark XPCOM magic.</p>
<h5 name="How_do_I_use_it.3F">How do I use it?</h5>
<p>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.</p>
<h5>How do I make my C++ class implement nsIClassInfo?</h5>
<p>See <a class=" external" href="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsIClassInfoImpl.h" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsIClassInfoImpl.h"><code>nsIClassInfoImpl.h</code></a> for instructions.</p>
<h5>How does nsIClassInfo work?</h5>
<p>That's also detailed in <a class=" external" href="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsIClassInfoImpl.h" title="http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsIClassInfoImpl.h"><code>nsIClassInfoImpl.h</code></a>.</p>
<div class="originaldocinfo">
<h2 name="Original_Document_Information">Original Document Information</h2>
<ul> <li>Authors: <a class="link-mailto" href="mailto:shaver@mozilla.org">Mike Shaver</a>, <a href="/Justin_Lebar" title="Justin Lebar">Justin Lebar</a></li> <li>Last Updated Date: July 25, 2011</li> <li>Copyright Information: Portions of this content are © 1998–2011 by individual mozilla.org contributors; content available under a Creative Commons license | <a class="external" href="http://www.mozilla.org/foundation/licensing/website-content.html">Details</a>.</li>
</ul></div>
Revert to this revision