Good day, ajg,

I don't think you can (and should be able to) create v8::Array with
ObjectTemplate.

However, it's easy to install Array functions to any kind of
object---ECMAScript array functions were intentionally designed to
work with generic objects---all you need is to add a length property.
Simple test would be to do something like [].forEach.call(yourobject,
args).  To use convenient syntax yourobject.forEach just add
Array.prototype.forEach and other functions to prototype of your
object (see PrototypTemplate) or an object directly (1st option is
preferable).

hth and yours,
anton.

On Thu, Apr 7, 2011 at 9:59 PM, ajg <[email protected]> wrote:
> I already have a working ObjectTemplate that enables js code to access
> C++ objects in a lazy fashion, using the NamedPropertyHandler.
> Now I also need to create v8:Array that is backed by a C++ object
> using the IndexedPropertyHandler.
> But it seems that ObjectTemplate can only create a v8::Object, not a
> v8::Array.
> Doing an indexed access on v8::Object works fine but then the built-in
> functions like "forEach" are not available.
> Basically I need to either:
> - create a v8::Array with IndexedPropertyHandlers
> - create a v8::Object with IndexedPropertyHandlers and transfer the
> builtin methods to it, or somehow convert it to a v8::Array.
> Note that on C++ side it is not a native type array, so I cannot use
> the v8::Object::SetIndexedPropertiesToExternalArrayData
> Any suggestion?
> thanks
>
> --
> v8-users mailing list
> [email protected]
> http://groups.google.com/group/v8-users
>

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

Reply via email to