Hello together,

I want to call a function which is a member of a class instance.

Consider the following Javascript code.
function MyClass(name)
{
    this.name = name;
    this.callback = function () { console.log("My name is " +
this.name"); }
}

var a = new MyClass("MyCallbackClass");

myextension.add(a.callback);

In my C++ part:
Handle<Value> MyExtension::Add(const Arguments& args)
{
    HandleScope scope;
    Local<Function> func =
Local<Function>::New(args[0].As<Function>());
    func->Call(args.This(), 0, NULL);
    return scope.Close(Undefined());
}

When executing the code, the output is: "My name is Undefined" instead
of "My name is MyCallbackClass. I guess this happens because I'm
passing the wrong first argument (recv) to func->Call(), but how do I
get the correct "this" to pass it to function call?

Thanks in advance.

Cheers,
 Sebastian

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

Reply via email to