зеркало из https://github.com/mozilla/pjs.git
162 строки
5.4 KiB
HTML
162 строки
5.4 KiB
HTML
|
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
||
|
<html>
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
||
|
<meta name="Author" content="pnunn">
|
||
|
<meta name="GENERATOR" content="Mozilla/4.5 [en]C-NSCP (WinNT; U) [Netscape]">
|
||
|
<title>xpCom FAQ</title>
|
||
|
</head>
|
||
|
<body>
|
||
|
<b><font size=+3>XPCOM FAQ</font></b>
|
||
|
<p>Get out your decoder rings kids!
|
||
|
<p>Having a basic understanding of COM is only the first
|
||
|
<br>step. To get CMonkey code to build and run,
|
||
|
<br>you need to translate your COM ideas into Netscape
|
||
|
<br>speak.
|
||
|
<p>Feel free to add to this document or change incorrect info.
|
||
|
<br>Hopefully more info and more examples will help new
|
||
|
<br>people reach XPCOM nirvana more quickly.
|
||
|
<p><b>To mentally translate XPCOM to COM.</b>
|
||
|
<br>
|
||
|
<table BORDER COLS=2 WIDTH="100%" >
|
||
|
<tr>
|
||
|
<td BGCOLOR="#CCCCCC"><b>vanilla COM</b></td>
|
||
|
|
||
|
<td BGCOLOR="#FFCCCC"><b>XPCOM</b></td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#CCCCCC"> IUnknown</td>
|
||
|
|
||
|
<td BGCOLOR="#FFCCCC">nsISupports</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#CCCCCC">IClassFactory</td>
|
||
|
|
||
|
<td BGCOLOR="#FFCCCC">nsIFactory</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#CCCCCC">virtual void _stdcall</td>
|
||
|
|
||
|
<td BGCOLOR="#FFCCCC">NS_IMETHOD</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#CCCCCC">interface ID = IID</td>
|
||
|
|
||
|
<td BGCOLOR="#FFCCCC">nsID = nsIID = IID</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#CCCCCC">class ID = CLSID </td>
|
||
|
|
||
|
<td BGCOLOR="#FFCCCC">nsCID = CID</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p>Not too difficult.
|
||
|
<br>But wait. There's more.
|
||
|
<br><b>-------------------------------------------</b>
|
||
|
<p><b><font size=+1>Why don't those classes have AddRef?</font></b>
|
||
|
<p>Actually, those classes do have AddRef. It is hidden
|
||
|
<br>in a macro. There are alot of macros that are alot of help
|
||
|
<br>once you know :
|
||
|
<br> 1) They exist.
|
||
|
<p> 2) Where they are defined. (They aren't always mnemonic
|
||
|
or onomatipeic.
|
||
|
<br>
|
||
|
You might want to print them out.)
|
||
|
<p> mozilla/xpcom/public/nsCom.h
|
||
|
<br>
|
||
|
mozilla/xpcom/public/nsISupports.h
|
||
|
<p> 3)What they are
|
||
|
<br>
|
||
|
Here's a short list to give you an idea of what you've been missing.
|
||
|
<br>
|
||
|
The include files listed above are the real reference.
|
||
|
<p> 4) A quick way to expand pesky macros:
|
||
|
<br>
|
||
|
For macros in foo.cpp, 'make foo.i'
|
||
|
<p> This
|
||
|
will pump the foo.cpp file through C preprocessing
|
||
|
<br>
|
||
|
and expand all the macros for you. The output can be
|
||
|
<br>
|
||
|
hard to read, but if you search for unique strings
|
||
|
<br>
|
||
|
in the area you aredebugging, you can navigate
|
||
|
<br>
|
||
|
the file pretty easily.
|
||
|
<br>
|
||
|
(thanks to hshaw@netscape.com)
|
||
|
<br>
|
||
|
<br>
|
||
|
<br>
|
||
|
<table BORDER COLS=2 WIDTH="100%" BGCOLOR="#CCCCCC" >
|
||
|
<tr>
|
||
|
<td BGCOLOR="#FFCCCC"><b><font size=+1>Netscape MACRO</font></b></td>
|
||
|
|
||
|
<td><b><font size=+1>Expansion of macro</font></b></td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#FFCCCC">NSADDREF(factoryinstname)</td>
|
||
|
|
||
|
<td>Factory->AddRef();</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#FFCCCC">NS_IMETHOD</td>
|
||
|
|
||
|
<td>virtual nsresult __stdcall</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#FFCCCC">NS_INIT_REFCNT()</td>
|
||
|
|
||
|
<td>mRefCnt = 0</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#FFCCCC">NS_INIT_ISUPPORTS()</td>
|
||
|
|
||
|
<td>NS_INIT_REFCNT()</td>
|
||
|
</tr>
|
||
|
|
||
|
<tr>
|
||
|
<td BGCOLOR="#FFCCCC">NS_DECL_ISUPPORTS</td>
|
||
|
|
||
|
<td>public:
|
||
|
<br> NS_IMETHOD QueryInterface(REFNSIID
|
||
|
aIID,
|
||
|
<br>
|
||
|
void** aInstancePtr);
|
||
|
<br> NS_IMETHOD_(nsrefcnt)
|
||
|
AddRef(void);
|
||
|
<br> NS_IMETHOD_(nsrefcnt)
|
||
|
Release(void);
|
||
|
<br> protected:
|
||
|
<br> nsrefcnt mRefCnt;</td>
|
||
|
</tr>
|
||
|
</table>
|
||
|
|
||
|
<p> <font size=+1>Useful Links to COM Documents:</font>
|
||
|
<p><a href="http://www.mozilla.org/projects/xpcom/">XPCOM Page</a>
|
||
|
<br><a href="http://www.mozilla.org/projects/xpcom/nsCOMPtr.html">nsCOMPtr</a>
|
||
|
<br><a href="http://warp.netscape.com/client/raptor/codingconventions.html">Coding
|
||
|
Conventions</a>
|
||
|
<br><a href="http://warp/client/bam/eng/howto.html">Getting BAMmed</a>
|
||
|
<br><a href="http://warp/client/bam/eng/comdoc.html">How to COM</a>
|
||
|
<br><a href="http://www.mozilla.org/docs/tplist/catFlow/modunote.htm">Modularization
|
||
|
Techniques</a>
|
||
|
<br><a href="http://www.mozilla.org/docs/tplist/catBuild/portable-cpp.html">C++
|
||
|
Portability Guide</a>
|
||
|
<br><a href="http://www.mozilla.org/newlayout/">NGLayout</a>
|
||
|
<br>
|
||
|
<br>
|
||
|
<br>
|
||
|
</body>
|
||
|
</html>
|