如何绕过AccessorGetter拦截器?
Handle<FunctionTemplate> mars_obj_templ = FunctionTemplate::New(createMars);
Handle<ObjectTemplate> mars_obj_proto = mars_obj_templ->PrototypeTemplate();
Handle<ObjectTemplate> mars_obj_inst = mars_obj_templ->InstanceTemplate();
mars_obj_inst->SetInternalFieldCount(1);
mars_obj_inst->SetAccessor(String::New("name"),GetName,SetName);
Handle<Value> GetName(Local<String> property,const AccessorInfo &info){
Local<Object> self = info.Holder();
//return what, if self->Get(property) will Recursive call
}发布于 2012-10-22 05:03:27
根据我的经验,你不能,但是如果你在ObjectTemplate上使用SetNamedPropertyHandler注册一个通用的拦截器,你可以安全地调用self->Get,而不会导致递归。将请求的属性与您感兴趣的属性进行比较,您可以处理它们并转发其他调用。
https://stackoverflow.com/questions/12907395
复制相似问题