Bug 1652354, part 𝋡: Support categories with generic values in static component registration. r=kmag

Differential Revision: https://phabricator.services.mozilla.com/D85656
This commit is contained in:
Joshua Cranmer 2020-08-10 21:16:31 +00:00
parent 46c84af88a
commit 45bfd75f59
2 changed files with 42 additions and 1 deletions

View File

@ -56,6 +56,16 @@ The files may define any of the following special variables:
# ...
]
# A list of category registrations
Categories = {
'category': {
'name': 'value',
'other-name': ('value', ProcessSelector.MAIN_PROCESS_ONLY),
# ...
},
# ...
}
Class definitions may have the following properties:
``name`` (optional)
@ -270,3 +280,26 @@ This will define each of the following category entries:
* ``"content-policy"`` ``"m-foo",`` ``"@mozilla.org/foo;1"``
* ``"Gecko-Content-Viewers"`` ``"image/jpeg"`` ``"@mozilla.org/foo;1"``
* ``"Gecko-Content-Viewers"`` ``"image/png"`` ``"@mozilla.org/foo;1"``
Some category entries do not have a contract ID as a value. These entries can
be specified by adding to a global ``Categories`` dictionary:
.. code-block:: python
Categories = {
'app-startup': {
'Mapi Support': 'service,@mozilla.org/mapisupport;1',
}
}
It is possible to limit these on a per-process basis by using a tuple as the
value:
.. code-block:: python
Categories = {
'app-startup': {
'MainProcessSingleton': ('service,@mozilla.org/main-process-singleton;1', ProcessSelector.MAIN_PROCESS_ONLY),
}
}

View File

@ -605,6 +605,7 @@ def gen_substs(manifests):
headers = set()
modules = []
categories = defaultdict(list)
for manifest in manifests:
headers |= set(manifest.get('Headers', []))
@ -619,10 +620,17 @@ def gen_substs(manifests):
for clas in manifest['Classes']:
modules.append(ModuleEntry(clas, init_idx))
for category, entries in manifest.get('Categories', {}).items():
for key, entry in entries.items():
if isinstance(entry, tuple):
value, process = entry
else:
value, process = entry, 0
categories[category].append((key, value, process))
cids = set()
contracts = []
contract_map = {}
categories = defaultdict(list)
js_services = {}
jsms = set()