Written on Jul 23, 2018
https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components.classes
Last night I was thinking about how to retrieve a service and return it to the js consumer, and then I remembered getService(...)
method. It is a method defined on Components.classes
and it retrieves a service as a singleton. Here you can learn more about Components.classes
.
Upon doing a search in searchfox.org, one can see that there are at least two definitions of getService
, one in xpcjsid.id
and one in nsIServiceManager.idl
. The implementation of the one in nsIServiceManager.idl
did not seem useful because it did not deal with any JS runtime objects. So I looked at the implementation of the one in xpcjsid.id
and it did deal with JS objects. Furthermore, since Components.classes
is an object that implements nsIJSCID
interface, we can rest assured knowing that that’s the right place to look at.
11:48 AM I am in the middle of writing codegen logic, but it own’t compile because I am getting the following error
0:06.12 ~/src/mozilla-central/obj-opt/dist/include/mozilla/Services.h:493:1: error: unused function 'JSScriptloaderServiceGetter' [-Werror,-Wunused-function]
0:06.12 JSScriptloaderServiceGetter(JSContext* aCx, unsigned aArgc, JS::Value* aVp);
0:06.12 ^
I run full tests, and here are the tests that are failing