More work on code generator; Services.jsm; | Anny G's blog

More work on code generator; Services.jsm;

Written on Jul 30, 2018

Hiding old Services object and exposing the one generated via template

So I have added all services from Services.jsm to Services.py and firefox has compiled successfully, but one of the errors I get upon starting Firefox is that Services.search is undefined. I define Services.search if MOZ_TOOLKIT_SEARCH is defined. But it seems as though MOZ_TOOLKIT_SEARCH is not defined, even though it’s needed. Let’s try to figure out how to define it.

I found this code bit.

for var in ('MOZ_TOOLKIT_SEARCH',
            'MOZ_SYSTEM_NSS',
            'MOZ_UPDATER',
            'MOZ_ANDROID_MOZILLA_ONLINE',
            'MOZ_SWITCHBOARD'):
    if CONFIG[var]:
        DEFINES[var] = True

So I added the following to xpcom/build/moz.build

for var in ('MOZ_TOOLKIT_SEARCH',
            'MOZ_CRASHREPORTER',
            'MOZ_GECKO_PROFILER',
            'ANDROID'):
    if CONFIG[var]:
        DEFINES[var] = True

because all of the above are mentioned in Services.jsm.

Services.blocklist.pluginQueries

I am running firefox, and while most of the things are working, I am getting the following error in the console:

... TypeError: Services.blocklist.pluginQueries is undefined (resource://gre/modules/Blocklist.jsm:310:1) JS Stack trace: _init@Blocklist.jsm:310:1

So turns out Blocklist service, similar to CrashManageris also defined in JavaScript. I need to figure out how to expose it to C++.

Next steps and observations

Update to my code generator

Useful links