> v8 provide the global object with Context::Global method, you should
> wrap the document object first, and add it to the global object in the
> entered context.
That's right. I added the root scope in my hierarchy (which is
session) to this object. So I have this:
[global object] =
{
session :
{
application :
{
document :
{
dialog : {}
}
}
}
};
The problem is, I can't find any methods in the context to make
another object global (such as document in my example).
> to wrap the document object, you must implement the named, indexed
> property and call as function handler, and create the object with
> ObjectTemplate
>
> v8::HandleScope handle_scope;
>
> v8::Handle<v8::ObjectTemplate> clazz = v8::ObjectTemplate::New();
>
> clazz->SetNamedPropertyHandler(NamedGetter, NamedSetter, NamedQuery,
> NamedDeleter, NamedEnumerator);
> clazz->SetIndexedPropertyHandler(IndexedGetter, IndexedSetter,
> IndexedQuery, IndexedDeleter, IndexedEnumerator);
> clazz->SetCallAsFunctionHandler(Caller);
>
> return v8::Persistent<v8::ObjectTemplate>::New(clazz);
I don't understand. All scope objects are pure JS objects, they are
not native. Why do I need an ObjectTemplate? Or do you mean that I
have to create an artifical native object that would reroute all its
property access calls to the appropriate scope object of my hierarchy?
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users