5
我正在使用Node模塊,並試圖傳遞將ObjectWrap
作爲參數的子類的實例傳遞給JavaScript回調。如何在V8中將對象傳遞給JavaScript回調
在其他地方,我已經能夠成功地展開JavaScript對象同一類,使用:
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args[0]->ToObject());
我怎麼可能做相反?我想的GitCommit
一個實例傳遞到JavaScript回調,如:
Local<Value> argv[] = {
// Error code
Local<Value>::New(Integer::New(0)),
// The commit
commit // Instance of GitCommit : ObjectWrap
};
// Both error code and the commit are passed, JS equiv: callback(error, commit)
ar->callback->Call(Context::GetCurrent()->Global(), 1, argv);
這可能嗎?如果有的話,請給我一個例子,或鏈接到相關文件?
謝謝*非常*這個! – 2013-03-04 09:28:52