The static XPCOM manifest format makes it easy to define a component in a
single place, without separate contract ID and CID macro definitions in
headers, and variable constants in module files. Without any other changes,
however, those macros are still required in order to create instances of or
retrieve services for the component.
This patch solves that problem by allowing component definitions to include an
explicit component name, and adding helpers for each named component to
Components.h:
mozilla::components::<Name>::CID() to retrieve its class ID.
mozilla::components::<Name>::Create() to create a new instance.
mozilla::components::<Name>::Service() to retrieve its service instance.
These getters have the benefit of doing full compile-time sanity checking,
with no possibilty of using a mistyped contract ID string, or a macro constant
which has gotten out of sync with the component entry.
Moreover, when possible, these getters are optimized to operate on module
entries directly, without going through expensive hash lookups or virtual
calls.
Differential Revision: https://phabricator.services.mozilla.com/D15037
--HG--
extra : rebase_source : db7fe00fe80677a6a42d8136fd4505a02e330495
extra : absorb_source : ec11e22825befcd6fa4e96ffa81cd1c1b23e3bef
extra : histedit_source : 650e8e98235df5d757f3fa725bad390e9c094c34
We have tons of code in the component manager which stringifies nsIDs so that
it can print the result. The standard stringification process is pretty
bloated, and makes the code difficult to update. And, frankly, I mostly just
got tired of copying it around.
This patch adds a helper which stringifies a nsID to a nsAutoCString, which
can be used as a temporary value in a single statement, rather than requiring
a separate local variable and function call for each operation.
Differential Revision: https://phabricator.services.mozilla.com/D15036
--HG--
extra : rebase_source : 4a1971289bbf6abb42da30d024b30a81f7a0ca06
extra : absorb_source : 11318729edd01e7fc6bdbcc66346fdbf23e385ba
extra : histedit_source : c9a16f6e23c391813cfc3ce3fc82c835db0c46d6
This patch essentially creates a separate, static component database for
statically-defined CID and contract ID entries, and gives it precedence over
the runtime DB. It combines the two separate databases by updating existing
code to use lookup functions which understand both databases, and then access
all entries through wrappers which defer to the appropriate underlying type.
Static component entries require no runtime relocations, and require no
writable data allocation aside from one pointer-sized BSS entry per CID, and
one bit of BSS per contract ID.
To achieve this, all strings in the static lookup tables are stored as indexes
into a static string table, all constructor functions live in a switch
statement which compiles to a relative jump table, and all writable data for
static entries is accessed by indexed lookups into BSS arrays.
We also avoid creating nsIFactory entries for static components when possible
by adding a CreateInstance method to nsFactoryEntry and the corresponding
entry wrapper to directly call the appropriate constructor method, and only
create a factory object when required by external code.
Differential Revision: https://phabricator.services.mozilla.com/D15035
--HG--
extra : rebase_source : 8d02ff3b67b8078d1ac837d8c12f54786155c6b6
extra : absorb_source : 0fe36ca220c9270e634abf5b1f320a01878e0ce7
extra : histedit_source : 51521ceae2c1b3e4e8bf63d4ed1e2e67e9468780
This aggregates a list of all static component manifests in the tree, and
writes them out to a `manifests-lists.json` file, which is read by the codegen
scripts in the next patch.
It slightly abuses the IDL lists machinery, given that these aren't
technically IDL files. But the semantics are similar enough that it seemed
like the best option.
Differential Revision: https://phabricator.services.mozilla.com/D15034
--HG--
extra : rebase_source : 7e8148f5f6c0d830db92571700289b1eb841e140
extra : histedit_source : cab2c81128d17fa289d4b8ed653cad2599263e35
Currently, when we build the component registry at startup, we exclude any
entry with a process selector which doesn't match the current process. When we
switch to static lookup tables, however, that check is going to have to happen
for every lookup, since we can't alter the table at runtime.
That may not matter much, given how expensive the rest of the component lookup
code is relative to ProcessMatchesSelector, but it's also easy and cheap
enough to generate a lookup table for all possible ProcessSelector values, and
do a quick index check instead.
Differential Revision: https://phabricator.services.mozilla.com/D15033
--HG--
extra : rebase_source : fa6c764c2acd68dbe620e5a0779c6c58724ea209
The current implementations of GetService are slightly different for contract
IDs than they are for CIDs, but I'm pretty sure that's unintentional.
This patch factors out the common parts of the two implementations, which
should prevent them from diverging in the future, and avoids the need to make
the same changes in multiple places in the following patches.
Differential Revision: https://phabricator.services.mozilla.com/D15032
--HG--
extra : rebase_source : 591d854d604dc7597dbfe5438bfbd0af98224c5b
For static components, I don't intend to allow removing or replacing CID
entries, only contract ID entries. And I would generally prefer, when
restoring overrides of those classes, to not create a new dynamic factory
entry for the contract ID.
We already have the ability to mock components without either of those issues,
but registering a new CID entry for the mock (without unregistering the
original), and then restoring the original by calling `registerFactory` with a
null factory object.
This patch updates our existing mocks to behave that way, and paves the way
for the rest of the patches.
Differential Revision: https://phabricator.services.mozilla.com/D15031
--HG--
extra : rebase_source : 61ef2435d764c2d9daee6a16515eb0efd94a6454