Mon, July 23, 2018 | Anny G's blog

Mon, July 23, 2018

Written on Jul 23, 2018

Working on python generator

How to retrieve a service as a singleton and return it to js consumers

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, one can see that there are at least two definitions of getService, one in 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 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 ^

Back to Clipboard

I run full tests, and here are the tests that are failing