Index: src/api.cc |
diff --git a/src/api.cc b/src/api.cc |
index d027d7a1a3e9e71033460eadb28b001c8711a25f..9aed956a4214e0238b3235a4635c4d6e04179f52 100644 |
--- a/src/api.cc |
+++ b/src/api.cc |
@@ -935,21 +935,62 @@ static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { |
} |
-void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, |
+static void TemplateSet(i::Isolate* isolate, |
+ v8::Template* templ, |
+ int length, |
+ v8::Handle<v8::Data>* data) { |
+ i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate); |
+ if (list->IsUndefined()) { |
+ list = NeanderArray().value(); |
+ Utils::OpenHandle(templ)->set_property_list(*list); |
+ } |
+ NeanderArray array(list); |
+ array.add(Utils::OpenHandle(*v8::Integer::New(length))); |
+ for (int i = 0; i < length; i++) { |
+ i::Handle<i::Object> value = data[i].IsEmpty() ? |
+ i::Handle<i::Object>(isolate->factory()->undefined_value()) : |
+ Utils::OpenHandle(*data[i]); |
+ array.add(value); |
+ } |
+} |
+ |
+ |
+void Template::Set(v8::Handle<String> name, |
+ v8::Handle<Data> value, |
v8::PropertyAttribute attribute) { |
i::Isolate* isolate = i::Isolate::Current(); |
if (IsDeadCheck(isolate, "v8::Template::Set()")) return; |
ENTER_V8(isolate); |
i::HandleScope scope(isolate); |
- i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list(), isolate); |
- if (list->IsUndefined()) { |
- list = NeanderArray().value(); |
- Utils::OpenHandle(this)->set_property_list(*list); |
- } |
- NeanderArray array(list); |
- array.add(Utils::OpenHandle(*name)); |
- array.add(Utils::OpenHandle(*value)); |
- array.add(Utils::OpenHandle(*v8::Integer::New(attribute))); |
+ const int kSize = 3; |
+ v8::Handle<v8::Data> data[kSize] = { |
+ name, |
+ value, |
+ v8::Integer::New(attribute)}; |
+ TemplateSet(isolate, this, kSize, data); |
+} |
+ |
+ |
+void Template::SetAccessorProperty( |
+ v8::Local<v8::String> name, |
+ v8::Local<FunctionTemplate> getter, |
+ v8::Local<FunctionTemplate> setter, |
+ v8::PropertyAttribute attribute, |
+ v8::AccessControl access_control) { |
+ i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
+ if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return; |
+ ENTER_V8(isolate); |
+ ASSERT(!name.IsEmpty()); |
+ ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); |
+ i::HandleScope scope(isolate); |
+ const int kSize = 5; |
+ v8::Handle<v8::Data> data[kSize] = { |
+ name, |
+ getter, |
+ setter, |
+ v8::Integer::New(attribute), |
+ v8::Integer::New(access_control)}; |
+ TemplateSet(isolate, this, kSize, data); |
} |