Hey all,

I have a question about accessing C++ code from Javascript.  Currently we
are embedding Mozilla in an application and to do any communication to our
C++ modules, we use regular XPCom components via XPConnect.  However, for
each page load that we do, we have to do another CreateInstance on each of
our components which as you can see is not the most efficient way to do it.

So, is there any other way we should be tackling this problem.  In other
words, is there a way to set up a communication channel between a C++
component (or code) and Javascript at the beginning of application
initilization and keep that channel open throughout the lifetime of the app
so that these components are always available via Javascript?

Some of the things I've been looking at include:

1) Getting to the global JSRuntime and JSContext and adding
functions/objects during app initialization (which is why I posted to this
group).  But, this seems like I need to get an interface pointer to an
nsIDOMDocument which would be needed for each page load.  Is this correct or
is this in fact what I need to do?

2) Just read a little on services exposed through the ServiceManager.  Does
this somehow provide the singleton access that I'm looking for?  Would I do
a RegisterService in my embedded app and then a GetService in the JavaScript
to get to it?

Thanks for any info you can provide.
-Mark



Reply via email to