Sorry for resurrecting this post after such a long time, but I'm having the 
same (or very similar) problem as MikeM, in trying to add additional 
javascript objects (which may themselves be the global object of another 
context) to the prototype chain of the global object of a v8 context. It 
seems like this should be possible, but I can't find the one way that makes 
everything work. MikeM, were you able to solve your problem?

Application: my global object has a property interceptor assigned to catch 
all variable accesses (properties) at global scope and delegate those calls 
to the embedding application. However, if a variable name doesn't exist in 
the embedding application, I want to delegate to the prototype chain of the 
Global object, as usual. At the root of my application, I have a javascript 
object defined in a js file that I load and compile into JS; This object 
should be in the prototype chain of every context in the application. I 
have a series of v8::contexts that correspond to a data model hierarchy in 
my application, where the global object of a child node context should have 
the global object of the parent node context as its prototype. I haven't 
found a reason why this shouldn't be possible, but neither have I gotten it 
to work. 

I have tried: 
Create the ObjectTemplate, create the Context (with the template), get the 
global object reference (accounting for the proxy global), and 
SetPrototype(my_parent_object)
Create the ObjectTemplate, create the Context (with the template), get the 
global object reference (accounting for the proxy global), continue to 
traverse using GetPrototype until GetPrototype returns null, then use 
SetPrototype(my_parent_object) on that root prototype object. 
Create a FunctionTemplate to treat as a constructor, write a c++ function 
(js constructor) that assigns the prototype to the newly-created object, 
and create the Context with the InstanceTemplate of the FunctionTemplate.

All of these techniques (after a fair bit of fiddling) will compile and 
execute without segfaults, but none successfully configures the prototype 
chain, since I cannot access the properties of the intended parent class. 

Is what I am trying to accomplish possible? Is there a better approach? 
Thanks - 

Jeremy Turpin

-- 
-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to