I have an XPCOM interface implemented in C++. Inside my code I need to
create new JSContext objects for private use, but I would also like to
access global variables or local variables declared by the caller
function:

--- test.js --
var answer = 42; // this variable I want to have visible in my C++!

var myxpcom =
Components.classes["@mozilla.org/myxpcom;1"].createInstance();
var myobj = myxpcom.QueryInterface(Components.interfaces.nsIMyObj);

myobj.print();

--- C++ --
void nsMyObj::Print() {
/* I would like to be able to write something like:
printf("anser=%s\n", answer);

how do I get caller's JSContext and scope, so I may use variables
defined at the caller's scope? */
}

--
-- Regards,
   Tal.
--------------------------------------------------
            Home: +972-(0)3-642-3906
          Mobile: +972-(0)52-3366-364
--------------------------------------------------

_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to