Chromium Code Reviews| Index: src/api.cc |
| diff --git a/src/api.cc b/src/api.cc |
| index eb2ffcff18094e3e3b2fe37c4a1dbe7276ea9e97..b8afe6652ade5362a7c806590fb973df1f23fecb 100644 |
| --- a/src/api.cc |
| +++ b/src/api.cc |
| @@ -955,21 +955,63 @@ 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, |
|
Sven Panne
2013/08/21 10:46:25
I don't understand what this function is for... o_
dcarney
2013/08/21 10:59:33
I'm stashing multiple kinds of properties in a sin
|
| + 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++) { |
| + if (data[i].IsEmpty()) { |
|
Sven Panne
2013/08/21 10:46:25
Nit: Using a ternary ?: to calculate the value and
dcarney
2013/08/21 10:59:33
okay
|
| + array.add(isolate->factory()->undefined_value()); |
| + continue; |
| + } |
| + array.add(Utils::OpenHandle(*data[i])); |
| + } |
| +} |
| + |
| + |
| +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::SetJsAccessor(v8::Isolate* v8_isolate, |
| + v8::Local<v8::String> name, |
| + v8::Local<FunctionTemplate> getter, |
| + v8::Local<FunctionTemplate> setter, |
| + v8::AccessControl access_control, |
| + v8::PropertyAttribute attribute) { |
| + i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); |
| + 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(access_control), |
| + v8::Integer::New(attribute)}; |
| + TemplateSet(isolate, this, kSize, data); |
| } |