From: Cheng Zhao Date: Wed, 14 Aug 2013 05:14:28 +0000 (+0800) Subject: Use named property handler for createObjectWithName. X-Git-Tag: v0.3.3~9 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0c31494ffa2b76c521be7d197c6f8225aa0d2af5;p=electron.git Use named property handler for createObjectWithName. --- diff --git a/common/api/atom_api_v8_util.cc b/common/api/atom_api_v8_util.cc index 81f42e6c..69b660c6 100644 --- a/common/api/atom_api_v8_util.cc +++ b/common/api/atom_api_v8_util.cc @@ -11,6 +11,18 @@ namespace api { namespace { +v8::Handle PropGetter(v8::Local property, + const v8::AccessorInfo& info) { + return info.This()->GetRealNamedPropertyInPrototypeChain(property); +} + +v8::Handle PropSetter(v8::Local property, + v8::Local value, + const v8::AccessorInfo& info) { + info.This()->ForceSet(property, value); + return value; +} + v8::Handle DummyNew(const v8::Arguments& args) { return args.This(); } @@ -20,6 +32,7 @@ v8::Handle CreateObjectWithName(const v8::Arguments& args) { v8::Local t = v8::FunctionTemplate::New(DummyNew); t->SetClassName(args[0]->ToString()); + t->InstanceTemplate()->SetNamedPropertyHandler(PropGetter, PropSetter); return scope.Close(t->GetFunction()->NewInstance()); }