如何将对象传递给V8中的JavaScriptcallback
我正在做一个Node模块,并试图传递一个将ObjectWrap
作为参数的子类的实例传递给JavaScriptcallback。
在其他地方,我已经能够成功地展开JavaScript对象到同一个类,使用:
GitCommit *commit = ObjectWrap::Unwrap<GitCommit>(args[0]->ToObject());
我该怎么做呢? 我想将一个GitCommit
实例GitCommit
给一个JavaScriptcallback,如:
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);
这可能吗? 如果有的话,请给我一个例子,或链接到相关文件?
所以你正在编写一个节点插件。 尝试:
Handle<Value> argv[] = { // Error code Integer::New(0), // The commit commit->handle_ // 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);
- 将.NET与nodejs(crypto)进行比较时,哈希值不同
- 我可以将Node.js C ++扩展与Node的内部OpenSSL实现链接起来吗?
- 将轻量级Web服务器embedded到.net应用程序(node.js)中?
- 一个node.js如何检查参数types
- 节点configuration文件中的___mac_get_pid符号是什么?
- 另一个pthread中的V8代码会导致段错误
- 用C ++创build与Node.js的TCP连接
- 有没有办法以编程方式覆盖模板图像上的文本,并创build一个输出图像文件(PNG或JPEG)?
- npm install上的node-gyp错误:bson和kerberos编译中的致命错误C1083