Hi,

Synopsis: I'm wondering how I can have a v8::Object point to a v8::Template.

Here's what I'm doing: I'm hacking away at a protocol buffer wrapper.

In my design, every protocol message type (represented by a
proto2::Descriptor*) is mapped to an ObjectTemplate.
Each property of the message type becomes an Accessor that calls back into
C++. The Accessor's "data" contains the proto2::FieldDescriptor and -in the
case of a sub-message- the object template used to wrap that submessage's
type.

So for a message Outer { Inner inner; }, the layout I'd like to have is as
such:
ObjectTemplate"Outer" {
  Accessor"inner" : {
    Callback"read and wrap submessage",
    Data: Handle->Object{
      External<FieldDescriptor"inner" *>,
      Handle->ObjectTemplate"Inner" -> ...     <= *******
    }
  }
}

I would like the whole structure to be managed by the V8 GC (the proto
descriptors are static data), i.e. I'd like the inner ObjectTemplates to be
GC'ed once I drop the outer one.

However, and here's my actual problem, I cannot get the callback data to
refer to the inner v8::ObjectTemplate (*****), because the latter does not
extend v8::Value but only v8::Data. The only way I can imagine is using an
External wrapping a Persistent* but that would defeat the GC.

So, is there a fundamental reason why "Data" cannot be used even as an
internal field of an Object?
I see that internally, in objects.h, an AccessorInfo's "Data" is not
required to be a JSObject but just an Object.

Would horrible things happen if I coerced a Handle<ObjectTemplate> to be a
Handle<Value> and store it as internal fields of the callback Data? Could we
change Object::Set/GetInternalField to use Handle<Data>?

Thx
Matthias

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

Reply via email to