I'm trying to deduce the rules for cross-context use of javascript
objects.

I have two questions. Please tell me if I understand these matters, or
if I've got it all wrong.

First, the only way I see to directly access an object created by
javascript code in another context is if that object is made
accessible somehow through C++ via a template-constructed object in
the current context. I see various interfaces for controlling inter-
context access such as the
AccessControl settings for property accessors, but these are only
features of template-constructed objects. Similarly, one might reject
property writes and property deletes using interceptors, but these too
are only features of template-constructed objects. Am I correct that
access to other contexts is only possible indirectly, through template-
constructed functions and objects? Or is it possible to take a handle
for a javascript object created in one context, and store it as a
property value in an object in some other context, and then access it
there directly?

Second, regarding function objects in particular, defined by
javascript code (not function template instances defined by C++ code):
I see that scripts are bound to specific contexts, either at Compile()
time or if compiled by Script::New() then later, at Run() time. Does
this mean that functions defined by the script are similarly bound to
the context in which the script was run? Am I right that if I Call()
such a function object (within the C++ code of some template-
constructed object that mediates my access to it), the function will
be called in the context in which its defining script was run -- not
the caller's context? (Do I need to enter that context scope before I
call it?) If I'm right about this, does it imply that if I want such a
function to actually run in several different contexts, I must first
define it in each such context by running the script in which it is
defined?

I hope my questions are clear, even if my understanding isn't. Thanks!


--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to