This reference describes the interfaces and functions provided by the XPCOM library. In addition, it details the various helper classes and functions, as well as the components, provided by the XPCOM glue library. The contents herein are oriented primarily toward extension developers and people embedding XPCOM in other projects.
Note: If you're working on a module in the Mozilla codebase that's compiled with the
MOZILLA_INTERNAL_API flag set, some of these APIs -- the string functions and classes in particular -- are not the ones you should be using. See the XPCOM internal string guide for documentation of the internal string API used within the Mozilla codebase.
- Core XPCOM functions
- XPCOM provides a number of global functions which are used to initialize and shut down the XPCOM library, as well as to allocate memory, get access to services, and to instantiate interfaces.
- Standard XPCOM components
- There are a number of components provided in the standard implementation of XPCOM; these are as follows.
- XPCOM Interface Reference
- This is a reference to the XPCOM interfaces provided by the Mozilla platform.
- XPCOM glue classes
- These "glue" classes are provided to make it easier to use XPCOM from C++ code.
- XPCOM string functions
- XPCOM provides these low-level string functions to let you work with strings; however, it's often better to use one of the string classes rather than directly using these functions.
Many XPCOM pages return an
nsresult. Prior to Gecko 19 (Firefox 19 / Thunderbird 19 / SeaMonkey 2.16), this was an integer that simply returned an error code. It is now a strongly typed
enum when XPCOM is built using a C++11 compiler. This causes compile-time errors to occur when improper values are returned as nsresult values, thereby making it easier to catch many bugs.