我正在将一些使用void *作为上下文对象(在本例中为v8函数)的代码集成到一个函数中,但这会导致编译错误。你会如何处理这个问题?从void *投射到本地<Function>
void callback(void* context) {
Local<Function> func = static_cast<Local<Function> *>(context);
func->Call(Context::GetCurrent()->Global(), 1, 0);
}
这里是注册回调的代码。请注意,fn会作为void *传递给“回调”。
Persistent<Function> fn = Persistent<Function>::New(Handle<Function>::Cast(args[0]));
registerEvent(&callback, /* context*/ &fn);
'本地 * func'应该做的伎俩。 –