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

Side by Side Diff: src/api.cc

Issue 22903012: js accessor creation on Template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: forgot something 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « include/v8.h ('k') | src/apinatives.js » ('j') | src/runtime.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
948 948
949 949
950 // --- T e m p l a t e --- 950 // --- T e m p l a t e ---
951 951
952 952
953 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { 953 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
954 that->set_tag(i::Smi::FromInt(type)); 954 that->set_tag(i::Smi::FromInt(type));
955 } 955 }
956 956
957 957
958 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, 958 static void TemplateSet(i::Isolate* isolate,
959 v8::Template* templ,
960 int length,
961 v8::Handle<v8::Data>* data) {
962 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate);
963 if (list->IsUndefined()) {
964 list = NeanderArray().value();
965 Utils::OpenHandle(templ)->set_property_list(*list);
966 }
967 NeanderArray array(list);
968 array.add(Utils::OpenHandle(*v8::Integer::New(length)));
969 for (int i = 0; i < length; i++) {
970 i::Handle<i::Object> value = data[i].IsEmpty() ?
971 i::Handle<i::Object>(isolate->factory()->undefined_value()) :
972 Utils::OpenHandle(*data[i]);
973 array.add(value);
974 }
975 }
976
977
978 void Template::Set(v8::Handle<String> name,
979 v8::Handle<Data> value,
959 v8::PropertyAttribute attribute) { 980 v8::PropertyAttribute attribute) {
960 i::Isolate* isolate = i::Isolate::Current(); 981 i::Isolate* isolate = i::Isolate::Current();
961 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; 982 if (IsDeadCheck(isolate, "v8::Template::Set()")) return;
962 ENTER_V8(isolate); 983 ENTER_V8(isolate);
963 i::HandleScope scope(isolate); 984 i::HandleScope scope(isolate);
964 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list(), isolate); 985 const int kSize = 3;
965 if (list->IsUndefined()) { 986 v8::Handle<v8::Data> data[kSize] = {
966 list = NeanderArray().value(); 987 name,
967 Utils::OpenHandle(this)->set_property_list(*list); 988 value,
968 } 989 v8::Integer::New(attribute)};
969 NeanderArray array(list); 990 TemplateSet(isolate, this, kSize, data);
970 array.add(Utils::OpenHandle(*name));
971 array.add(Utils::OpenHandle(*value));
972 array.add(Utils::OpenHandle(*v8::Integer::New(attribute)));
973 } 991 }
974 992
975 993
994 void Template::SetAccessorProperty(
995 v8::Local<v8::String> name,
996 v8::Local<FunctionTemplate> getter,
997 v8::Local<FunctionTemplate> setter,
998 v8::PropertyAttribute attribute,
999 v8::AccessControl access_control) {
1000 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
1001 if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return;
1002 ENTER_V8(isolate);
1003 ASSERT(!name.IsEmpty());
1004 ASSERT(!getter.IsEmpty() || !setter.IsEmpty());
1005 i::HandleScope scope(isolate);
1006 const int kSize = 5;
1007 v8::Handle<v8::Data> data[kSize] = {
1008 name,
1009 getter,
1010 setter,
1011 v8::Integer::New(attribute),
1012 v8::Integer::New(access_control)};
1013 TemplateSet(isolate, this, kSize, data);
1014 }
1015
1016
976 // --- F u n c t i o n T e m p l a t e --- 1017 // --- F u n c t i o n T e m p l a t e ---
977 static void InitializeFunctionTemplate( 1018 static void InitializeFunctionTemplate(
978 i::Handle<i::FunctionTemplateInfo> info) { 1019 i::Handle<i::FunctionTemplateInfo> info) {
979 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); 1020 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE));
980 info->set_flag(0); 1021 info->set_flag(0);
981 } 1022 }
982 1023
983 1024
984 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 1025 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
985 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1026 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
(...skipping 7187 matching lines...) Expand 10 before | Expand all | Expand 10 after
8173 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8214 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8174 Address callback_address = 8215 Address callback_address =
8175 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8216 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8176 VMState<EXTERNAL> state(isolate); 8217 VMState<EXTERNAL> state(isolate);
8177 ExternalCallbackScope call_scope(isolate, callback_address); 8218 ExternalCallbackScope call_scope(isolate, callback_address);
8178 return callback(info); 8219 return callback(info);
8179 } 8220 }
8180 8221
8181 8222
8182 } } // namespace v8::internal 8223 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/apinatives.js » ('j') | src/runtime.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698