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

Javascript callback function with C++ embedding

38 views
Skip to first unread message

Stefan Klinger

unread,
Oct 2, 2006, 6:16:54 PM10/2/06
to
Hello,

i found some hints how to create javascript functions mapped to C++
function which are callable from within the browser, but none provieded
me with a solution how to actually do it.

What i want is something like a Javascript Function for this C/C++
"Callback" inside the embedding code.

void JavascriptCallback(<some string type> argument) {
}

Some Newsgroup Posts said you should use JS_DefineFunction, but i found
no way to create a header from IDL for it nor does any header in the
gecko SDK define it.

Can someone give me a bit of code how to actually do such a thing?

Thanks in regards,
Stefan

Rémy Deslignes

unread,
Oct 3, 2006, 9:03:14 AM10/3/06
to Stefan Klinger, dev-em...@lists.mozilla.org
Hi,

Using gecko, you should define an XPCOM class defining a function that
you will implement within your javascrpipt code :
var callback =
{
call : function(argument)
{
...
}
}

then pass this object to your XPCOM coded object :
callbackemitter.setCallback(callback);

and call it from C++ :

void
nsCallbackEmitter::callback()
{
_callback->Call(argument);
}

Stefan Klinger a écrit :

> _______________________________________________
> dev-embedding mailing list
> dev-em...@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-embedding
> ---------------------------------------------------------------------------------------
>
> Orange vous informe que cet e-mail a ete controle par l'anti-virus
> mail. Aucun virus connu a ce jour par nos services n'a ete detecte.
>
>
>
>
>


--
Remy Deslignes

Ingenieur Developement / Software Engineer

Tel: +33 (0)1.53.90.11.19

===========================================
Silicon Worlds S.A.
12, rue de Chatillon
75014 Paris France
Tel: +33 (0)1.53.90.11.11
Fax: +33 (0)1.53.90.11.12
http://www.silicon-worlds.fr
===========================================

0 new messages