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

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: grokdump Created 7 years, 3 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') | no next file with comments »
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 917 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 928
929 929
930 // --- T e m p l a t e --- 930 // --- T e m p l a t e ---
931 931
932 932
933 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) { 933 static void InitializeTemplate(i::Handle<i::TemplateInfo> that, int type) {
934 that->set_tag(i::Smi::FromInt(type)); 934 that->set_tag(i::Smi::FromInt(type));
935 } 935 }
936 936
937 937
938 void Template::Set(v8::Handle<String> name, v8::Handle<Data> value, 938 static void TemplateSet(i::Isolate* isolate,
939 v8::Template* templ,
940 int length,
941 v8::Handle<v8::Data>* data) {
942 i::Handle<i::Object> list(Utils::OpenHandle(templ)->property_list(), isolate);
943 if (list->IsUndefined()) {
944 list = NeanderArray().value();
945 Utils::OpenHandle(templ)->set_property_list(*list);
946 }
947 NeanderArray array(list);
948 array.add(Utils::OpenHandle(*v8::Integer::New(length)));
949 for (int i = 0; i < length; i++) {
950 i::Handle<i::Object> value = data[i].IsEmpty() ?
951 i::Handle<i::Object>(isolate->factory()->undefined_value()) :
952 Utils::OpenHandle(*data[i]);
953 array.add(value);
954 }
955 }
956
957
958 void Template::Set(v8::Handle<String> name,
959 v8::Handle<Data> value,
939 v8::PropertyAttribute attribute) { 960 v8::PropertyAttribute attribute) {
940 i::Isolate* isolate = i::Isolate::Current(); 961 i::Isolate* isolate = i::Isolate::Current();
941 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; 962 if (IsDeadCheck(isolate, "v8::Template::Set()")) return;
942 ENTER_V8(isolate); 963 ENTER_V8(isolate);
943 i::HandleScope scope(isolate); 964 i::HandleScope scope(isolate);
944 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list(), isolate); 965 const int kSize = 3;
945 if (list->IsUndefined()) { 966 v8::Handle<v8::Data> data[kSize] = {
946 list = NeanderArray().value(); 967 name,
947 Utils::OpenHandle(this)->set_property_list(*list); 968 value,
948 } 969 v8::Integer::New(attribute)};
949 NeanderArray array(list); 970 TemplateSet(isolate, this, kSize, data);
950 array.add(Utils::OpenHandle(*name));
951 array.add(Utils::OpenHandle(*value));
952 array.add(Utils::OpenHandle(*v8::Integer::New(attribute)));
953 } 971 }
954 972
955 973
974 void Template::SetAccessorProperty(
975 v8::Local<v8::String> name,
976 v8::Local<FunctionTemplate> getter,
977 v8::Local<FunctionTemplate> setter,
978 v8::PropertyAttribute attribute,
979 v8::AccessControl access_control) {
980 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
981 if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return;
982 ENTER_V8(isolate);
983 ASSERT(!name.IsEmpty());
984 ASSERT(!getter.IsEmpty() || !setter.IsEmpty());
985 i::HandleScope scope(isolate);
986 const int kSize = 5;
987 v8::Handle<v8::Data> data[kSize] = {
988 name,
989 getter,
990 setter,
991 v8::Integer::New(attribute),
992 v8::Integer::New(access_control)};
993 TemplateSet(isolate, this, kSize, data);
994 }
995
996
956 // --- F u n c t i o n T e m p l a t e --- 997 // --- F u n c t i o n T e m p l a t e ---
957 static void InitializeFunctionTemplate( 998 static void InitializeFunctionTemplate(
958 i::Handle<i::FunctionTemplateInfo> info) { 999 i::Handle<i::FunctionTemplateInfo> info) {
959 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); 1000 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE));
960 info->set_flag(0); 1001 info->set_flag(0);
961 } 1002 }
962 1003
963 1004
964 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { 1005 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() {
965 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 1006 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
(...skipping 7187 matching lines...) Expand 10 before | Expand all | Expand 10 after
8153 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 8194 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
8154 Address callback_address = 8195 Address callback_address =
8155 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 8196 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
8156 VMState<EXTERNAL> state(isolate); 8197 VMState<EXTERNAL> state(isolate);
8157 ExternalCallbackScope call_scope(isolate, callback_address); 8198 ExternalCallbackScope call_scope(isolate, callback_address);
8158 return callback(info); 8199 return callback(info);
8159 } 8200 }
8160 8201
8161 8202
8162 } } // namespace v8::internal 8203 } } // namespace v8::internal
OLDNEW
« 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