On Thu, Mar 25, 2010 at 1:31 PM, Matthias Ernst <[email protected]> wrote:
> There is no direct C++ representative for the Array prototype. Just as in
> JS, you would attach a function to the Array prototype, like so:
>
> Handle<Value> TheFunction(const Arguments& args) {
> HandleScope locals;
> // use args.This(), args[0..args.Length()-1], or args.Data()
> return locals.Close(result);
> }
>
> ... setup:
>
> Handle<Object> array_prototype =
> Handle<Object>::Cast(
> Handle<Object>::Cast(
> context->Global()->Get(String::New("Array")))->GetPrototype());
>
> array_prototype->Set(
> String::New("theFunction"),
> FunctionTemplate::New(
> TheFunction
> [,optionalCallbackData]
> )
->GetFunction()
> );
>
>
> Now you should be all set.
>
>
> On Thu, Mar 25, 2010 at 12:45 PM, Tim Smart <[email protected]> wrote:
>
>> Also, while I am here, what is the correct way to access `this` within
>> the embedded API? (sorry for all the questions, I'm on a C++ learning
>> curve here)
>>
>> On Mar 26, 12:39 am, Tim Smart <[email protected]> wrote:
>> > Hey!
>> >
>> > What is the equivalent to attaching things to `Object.prototype` or
>> > `Array.prototype` (in Javascript), except in the C++ embeddable API?
>> >
>> > Just curious, as I am working on some Node.js addons that make use of
>> > the V8 embeddable API, and I would like to modify the Object and Array
>> > etc. objects.
>> >
>> > Thanks!
>>
>> --
>> v8-users mailing list
>> [email protected]
>> http://groups.google.com/group/v8-users
>>
>> To unsubscribe from this group, send email to v8-users+
>> unsubscribegooglegroups.com or reply to this email with the words "REMOVE
>> ME" as the subject.
>>
>
>
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
To unsubscribe from this group, send email to
v8-users+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.