Friday, July 18, 2018 | Anny G's blog

Friday, July 18, 2018

Written on Jul 20, 2018

Things I could explain

Things relevant to this new bug

Guide to understanding XPCOM

Trying to figure out what to do

I need to figure out how the newly created Service object will be used by the js consumers. I found some classes where they also create a new object in js and now I need to look for classes where the new component is created using JS_NewPlainObject and returned.

Update

Actually, I realized it’s okay that ChromeUtils is not exactly like Services.jsm because I just need an example of how C++ interfaces get exposed to JS code. Perhaps, it is through webidl.

Actually

It won’t work because ChromeUtils as an object is already exposed through webidl, and it uses low level JS APIs to create a copy of it. But the method that created a copy of itself is defined on an alerady existing object. So it won’t work 100% for me.

3:28 pm

Perhaps, I will look instead at functions that have the following function declaration myFunc(JSContext* aCx, JS::MutableHandleValue aResult) and see they are exposed. I found this https://searchfox.org/mozilla-central/source/widget/GfxInfoBase.cpp#1205.

4:01 pm

I don’t think I should be creating new webidl file because that means I will be creating Services object in C++. Furthermore, if I can’t really generate a webidl file.

4:54 pm

I discovered a Components object. Per https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Language_Bindings/Components_object

The Components object is the object through which XPConnect functionality is reflected into JavaScript.

5:49 pm

Success!!! I have managed to create an API in C++ in the Components class and expose it to js. TODO This is how I did it.

Things to do

To draw