質問

In node-addon-example, line 11 of 3_callbacks/addon.cc reads:

cb->Call(Context::GetCurrent()->Global(), argc, argv);

V8's documentation shows that:

V8EXPORT Local<Value> v8::Function::Call(Handle<Object> recv,
    int argc,
    Handle<Value> argv[]
);

So Context::GetCurrent()->Global() is used as Handle<Object> recv.

But what does recv stand for? What does it mean? And why is it appropriate to use Context::GetCurrent()->Global() in this case?

役に立ちましたか?

解決

It is the same as apply in JS. In JS, you do

var context = ...;
cb.apply(context, [ ...args...]);

The object passed as the first argument becomes this within the function scope. More documentation on MDN. If you don't know JS well, you can read more about JS's this here: http://unschooled.org/2012/03/understanding-javascript-this/

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top