Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(286)

Unified Diff: src/api.cc

Issue 22903012: js accessor creation on Template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: grokdump Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « include/v8.h ('k') | src/apinatives.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
« no previous file with comments | « include/v8.h ('k') | src/apinatives.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698