Harry Zhang wrote:
Thanks for the hint, I know that XPCOM component can be used as script
object in webpage, but actually what i mean is somehow as:
Object* object = new CustomizedObject(); /* customizedobject class has a
slot named "test" */
webframe::addToJavascriptWindowObject("foo", object);
then in webpage, we can use "foo.test()" to invoke the method of a runtime C
object.
You'd need to have the object implement some scriptable interface (it
doesn't have to be an XPCOM component in the sense of being registered
with the component manager or anything).
That is, sounds like webkit has an auto-reflection layer from QT objects
to JS. We have an auto-reflection layer from XPCOM objects to JS.
XPCOM objects don't have quite the same reflection setup that QT objects
seem to, so you have to explicitly declare your methods/properties.
Of course you could always use JSAPI directly and just create a JSObject
with various properties stuck on it; that's what XPConnect ends up doing
for you with an XPCOM object that implements a scriptable interface.
-Boris
_______________________________________________
dev-embedding mailing list
dev-embedding@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-embedding