Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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, |
|
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
| |
| 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 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
| |
| 971 array.add(isolate->factory()->undefined_value()); | |
| 972 continue; | |
| 973 } | |
| 974 array.add(Utils::OpenHandle(*data[i])); | |
| 975 } | |
| 976 } | |
| 977 | |
| 978 | |
| 979 void Template::Set(v8::Handle<String> name, | |
| 980 v8::Handle<Data> value, | |
| 959 v8::PropertyAttribute attribute) { | 981 v8::PropertyAttribute attribute) { |
| 960 i::Isolate* isolate = i::Isolate::Current(); | 982 i::Isolate* isolate = i::Isolate::Current(); |
| 961 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; | 983 if (IsDeadCheck(isolate, "v8::Template::Set()")) return; |
| 962 ENTER_V8(isolate); | 984 ENTER_V8(isolate); |
| 963 i::HandleScope scope(isolate); | 985 i::HandleScope scope(isolate); |
| 964 i::Handle<i::Object> list(Utils::OpenHandle(this)->property_list(), isolate); | 986 const int kSize = 3; |
| 965 if (list->IsUndefined()) { | 987 v8::Handle<v8::Data> data[kSize] = { |
| 966 list = NeanderArray().value(); | 988 name, |
| 967 Utils::OpenHandle(this)->set_property_list(*list); | 989 value, |
| 968 } | 990 v8::Integer::New(attribute)}; |
| 969 NeanderArray array(list); | 991 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 } | 992 } |
| 974 | 993 |
| 975 | 994 |
| 995 void Template::SetJsAccessor(v8::Isolate* v8_isolate, | |
| 996 v8::Local<v8::String> name, | |
| 997 v8::Local<FunctionTemplate> getter, | |
| 998 v8::Local<FunctionTemplate> setter, | |
| 999 v8::AccessControl access_control, | |
| 1000 v8::PropertyAttribute attribute) { | |
| 1001 i::Isolate* isolate = reinterpret_cast<i::Isolate*>(v8_isolate); | |
| 1002 if (IsDeadCheck(isolate, "v8::Template::SetAccessor()")) return; | |
| 1003 ENTER_V8(isolate); | |
| 1004 ASSERT(!name.IsEmpty()); | |
| 1005 ASSERT(!getter.IsEmpty() || !setter.IsEmpty()); | |
| 1006 i::HandleScope scope(isolate); | |
| 1007 const int kSize = 5; | |
| 1008 v8::Handle<v8::Data> data[kSize] = { | |
| 1009 name, | |
| 1010 getter, | |
| 1011 setter, | |
| 1012 v8::Integer::New(access_control), | |
| 1013 v8::Integer::New(attribute)}; | |
| 1014 TemplateSet(isolate, this, kSize, data); | |
| 1015 } | |
| 1016 | |
| 1017 | |
| 976 // --- F u n c t i o n T e m p l a t e --- | 1018 // --- F u n c t i o n T e m p l a t e --- |
| 977 static void InitializeFunctionTemplate( | 1019 static void InitializeFunctionTemplate( |
| 978 i::Handle<i::FunctionTemplateInfo> info) { | 1020 i::Handle<i::FunctionTemplateInfo> info) { |
| 979 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); | 1021 info->set_tag(i::Smi::FromInt(Consts::FUNCTION_TEMPLATE)); |
| 980 info->set_flag(0); | 1022 info->set_flag(0); |
| 981 } | 1023 } |
| 982 | 1024 |
| 983 | 1025 |
| 984 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { | 1026 Local<ObjectTemplate> FunctionTemplate::PrototypeTemplate() { |
| 985 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 1027 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| (...skipping 7187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8173 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 8215 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 8174 Address callback_address = | 8216 Address callback_address = |
| 8175 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8217 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 8176 VMState<EXTERNAL> state(isolate); | 8218 VMState<EXTERNAL> state(isolate); |
| 8177 ExternalCallbackScope call_scope(isolate, callback_address); | 8219 ExternalCallbackScope call_scope(isolate, callback_address); |
| 8178 return callback(info); | 8220 return callback(info); |
| 8179 } | 8221 } |
| 8180 | 8222 |
| 8181 | 8223 |
| 8182 } } // namespace v8::internal | 8224 } } // namespace v8::internal |
| OLD | NEW |