Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++ XPCOM component in Firefox 12

39 views
Skip to first unread message

flexo

unread,
Jun 4, 2012, 3:35:58 PM6/4/12
to
Hi,

I want to make a C++ XPCOM component for Firefox 12. In this component, I want a function that will be passed a (native) function from javascript.In the function from the C++ component, the passed function will be changed (the pointer to the actual function code, reserved slots,...).

In my solution, I'm trying to pass a javascript object to the C++ component as jsval parameter. Now if I make an IDL file with a function that has an input parameter jsval, the generated header file makes the input parameter a const jsval. Does this mean I can't change a passed object from javascript to the C++ component from within the C++ component?

Also I include the jsapi.h file for the function JS_ValueToObject, but when building the component it says unresolved external symbol _imp_JS_ValueToObject. Do I need to include some specific dll file or something that contains the implementation of the functions in jsapi.h to build the component?

Neil

unread,
Jun 6, 2012, 4:48:17 AM6/6/12
to
flexo wrote:

>In my solution, I'm trying to pass a javascript object to the C++ component as jsval parameter. Now if I make an IDL file with a function that has an input parameter jsval, the generated header file makes the input parameter a const jsval. Does this mean I can't change a passed object from javascript to the C++ component from within the C++ component?
>
>
I'm no JSAPI hacker but doesn't jsval behave as a union type that can
contain a (const) pointer to a non-const object?

>Also I include the jsapi.h file for the function JS_ValueToObject, but when building the component it says unresolved external symbol _imp_JS_ValueToObject. Do I need to include some specific dll file or something that contains the implementation of the functions in jsapi.h to build the component?
>
>
mozjs.lib/dll probably.

--
Warning: May contain traces of nuts.

bertwi...@hotmail.com

unread,
Jun 13, 2012, 10:35:42 AM6/13/12
to
Thanks, I will try this and check if I can change the jsvals.

flexo

unread,
Jul 2, 2012, 5:52:51 AM7/2/12
to
Ok thanks, it was the mozjs.lib that I needed to let the jsapi work :)

But now I would like to change the native method pointer of the JSFunction object (JSFunction_obj.u.n.native) of the passed function. Is this even possible doing this in a XPCOM component? I can't find any way to get a reference to this native pointer of a JSFunction so I can change it. Any idea?
0 new messages