| Index: src/d8.cc
|
| diff --git a/src/d8.cc b/src/d8.cc
|
| index 4ab7af6d2c7fedd22e61b098b0d2038285d0f3d2..183a6e70eeea5d2a30c6d989e1fc328b8bed6281 100644
|
| --- a/src/d8.cc
|
| +++ b/src/d8.cc
|
| @@ -1437,6 +1437,33 @@ Local<String> Shell::Stringify(Isolate* isolate, Local<Value> value) {
|
| return result.ToLocalChecked().As<String>();
|
| }
|
|
|
| +void NamedGetter(Local<String> property,
|
| + const PropertyCallbackInfo<Value>& info) {
|
| + Isolate* isolate = Isolate::GetCurrent();
|
| + EscapableHandleScope scope(isolate);
|
| + Local<Object> selfObj = info.Holder();
|
| + info.GetReturnValue().Set(
|
| + scope.Escape(String::NewFromUtf8(isolate, "value")));
|
| +}
|
| +
|
| +void NamedSetter(Local<String> property, Local<Value> value,
|
| + const PropertyCallbackInfo<Value>& info) {
|
| + Isolate* isolate = Isolate::GetCurrent();
|
| + EscapableHandleScope scope(isolate);
|
| + Local<Object> selfObj = info.Holder();
|
| +}
|
| +
|
| +void NamedEnumerator(const PropertyCallbackInfo<Array>& info) {
|
| + Isolate* isolate = Isolate::GetCurrent();
|
| + EscapableHandleScope scope(isolate);
|
| + Local<Object> selfObj = info.Holder();
|
| + Handle<Array> array = Array::New(isolate);
|
| + array->Set(0, String::NewFromUtf8(isolate, "one"));
|
| + array->Set(1, String::NewFromUtf8(isolate, "two"));
|
| + array->Set(2, String::NewFromUtf8(isolate, "three"));
|
| + array->Set(3, String::NewFromUtf8(isolate, "four"));
|
| + info.GetReturnValue().Set(scope.Escape(array));
|
| +}
|
|
|
| Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
|
| Local<ObjectTemplate> global_template = ObjectTemplate::New(isolate);
|
| @@ -1580,6 +1607,14 @@ Local<ObjectTemplate> Shell::CreateGlobalTemplate(Isolate* isolate) {
|
| .ToLocalChecked(),
|
| os_templ);
|
|
|
| + Local<FunctionTemplate> funTem = FunctionTemplate::New(isolate);
|
| + Local<ObjectTemplate> inst = funTem->InstanceTemplate();
|
| + inst->SetNamedPropertyHandler(NamedGetter, NamedSetter, 0, 0,
|
| + NamedEnumerator);
|
| +
|
| + global_template->Set(String::NewFromUtf8(isolate, "NamedObject"), funTem,
|
| + v8::PropertyAttribute(v8::DontDelete | v8::ReadOnly));
|
| +
|
| return global_template;
|
| }
|
|
|
|
|