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

Side by Side Diff: src/api.cc

Issue 390833003: Remove PropertyAttributes from SetProperty (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 5 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/debug.cc » ('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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/api.h" 5 #include "src/api.h"
6 6
7 #include <string.h> // For memcpy, strlen. 7 #include <string.h> // For memcpy, strlen.
8 #ifdef V8_USE_ADDRESS_SANITIZER 8 #ifdef V8_USE_ADDRESS_SANITIZER
9 #include <sanitizer/asan_interface.h> 9 #include <sanitizer/asan_interface.h>
10 #endif // V8_USE_ADDRESS_SANITIZER 10 #endif // V8_USE_ADDRESS_SANITIZER
(...skipping 3005 matching lines...) Expand 10 before | Expand all | Expand 10 after
3016 EXCEPTION_BAILOUT_CHECK(isolate, 0); 3016 EXCEPTION_BAILOUT_CHECK(isolate, 0);
3017 if (num->IsSmi()) { 3017 if (num->IsSmi()) {
3018 return i::Smi::cast(*num)->value(); 3018 return i::Smi::cast(*num)->value();
3019 } else { 3019 } else {
3020 return static_cast<uint32_t>(num->Number()); 3020 return static_cast<uint32_t>(num->Number());
3021 } 3021 }
3022 } 3022 }
3023 } 3023 }
3024 3024
3025 3025
3026 // TODO(verwaest): Remove the attribs argument, since it doesn't make sense for 3026 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value) {
3027 // existing properties. Use ForceSet instead to define or redefine properties
3028 // with specific attributes.
3029 bool v8::Object::Set(v8::Handle<Value> key, v8::Handle<Value> value,
3030 v8::PropertyAttribute attribs) {
3031 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3027 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3032 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 3028 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3033 ENTER_V8(isolate); 3029 ENTER_V8(isolate);
3034 i::HandleScope scope(isolate); 3030 i::HandleScope scope(isolate);
3035 i::Handle<i::Object> self = Utils::OpenHandle(this); 3031 i::Handle<i::Object> self = Utils::OpenHandle(this);
3036 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3032 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3037 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value); 3033 i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
3038 EXCEPTION_PREAMBLE(isolate); 3034 EXCEPTION_PREAMBLE(isolate);
3039 has_pending_exception = i::Runtime::SetObjectProperty( 3035 has_pending_exception =
3040 isolate, self, key_obj, value_obj, i::SLOPPY, 3036 i::Runtime::SetObjectProperty(isolate, self, key_obj, value_obj,
3041 static_cast<PropertyAttributes>(attribs)).is_null(); 3037 i::SLOPPY).is_null();
3042 EXCEPTION_BAILOUT_CHECK(isolate, false); 3038 EXCEPTION_BAILOUT_CHECK(isolate, false);
3043 return true; 3039 return true;
3044 } 3040 }
3045 3041
3046 3042
3047 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) { 3043 bool v8::Object::Set(uint32_t index, v8::Handle<Value> value) {
3048 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3044 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3049 ON_BAILOUT(isolate, "v8::Object::Set()", return false); 3045 ON_BAILOUT(isolate, "v8::Object::Set()", return false);
3050 ENTER_V8(isolate); 3046 ENTER_V8(isolate);
3051 i::HandleScope scope(isolate); 3047 i::HandleScope scope(isolate);
(...skipping 3114 matching lines...) Expand 10 before | Expand all | Expand 10 after
6166 i::Handle<i::String> part = i_isolate->factory()->for_string(); 6162 i::Handle<i::String> part = i_isolate->factory()->for_string();
6167 i::Handle<i::JSObject> symbols = 6163 i::Handle<i::JSObject> symbols =
6168 i::Handle<i::JSObject>::cast( 6164 i::Handle<i::JSObject>::cast(
6169 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); 6165 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
6170 i::Handle<i::Object> symbol = 6166 i::Handle<i::Object> symbol =
6171 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked(); 6167 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked();
6172 if (!symbol->IsSymbol()) { 6168 if (!symbol->IsSymbol()) {
6173 ASSERT(symbol->IsUndefined()); 6169 ASSERT(symbol->IsUndefined());
6174 symbol = i_isolate->factory()->NewSymbol(); 6170 symbol = i_isolate->factory()->NewSymbol();
6175 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6171 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6176 i::JSObject::SetProperty( 6172 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert();
6177 symbols, i_name, symbol, NONE, i::STRICT).Assert();
6178 } 6173 }
6179 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6174 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6180 } 6175 }
6181 6176
6182 6177
6183 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) { 6178 Local<Symbol> v8::Symbol::ForApi(Isolate* isolate, Local<String> name) {
6184 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6179 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6185 i::Handle<i::String> i_name = Utils::OpenHandle(*name); 6180 i::Handle<i::String> i_name = Utils::OpenHandle(*name);
6186 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry(); 6181 i::Handle<i::JSObject> registry = i_isolate->GetSymbolRegistry();
6187 i::Handle<i::String> part = i_isolate->factory()->for_api_string(); 6182 i::Handle<i::String> part = i_isolate->factory()->for_api_string();
6188 i::Handle<i::JSObject> symbols = 6183 i::Handle<i::JSObject> symbols =
6189 i::Handle<i::JSObject>::cast( 6184 i::Handle<i::JSObject>::cast(
6190 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); 6185 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
6191 i::Handle<i::Object> symbol = 6186 i::Handle<i::Object> symbol =
6192 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked(); 6187 i::Object::GetPropertyOrElement(symbols, i_name).ToHandleChecked();
6193 if (!symbol->IsSymbol()) { 6188 if (!symbol->IsSymbol()) {
6194 ASSERT(symbol->IsUndefined()); 6189 ASSERT(symbol->IsUndefined());
6195 symbol = i_isolate->factory()->NewSymbol(); 6190 symbol = i_isolate->factory()->NewSymbol();
6196 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6191 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6197 i::JSObject::SetProperty( 6192 i::JSObject::SetProperty(symbols, i_name, symbol, i::STRICT).Assert();
6198 symbols, i_name, symbol, NONE, i::STRICT).Assert();
6199 } 6193 }
6200 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6194 return Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6201 } 6195 }
6202 6196
6203 6197
6204 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) { 6198 Local<Private> v8::Private::New(Isolate* isolate, Local<String> name) {
6205 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 6199 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
6206 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); 6200 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
6207 LOG_API(i_isolate, "Private::New()"); 6201 LOG_API(i_isolate, "Private::New()");
6208 ENTER_V8(i_isolate); 6202 ENTER_V8(i_isolate);
(...skipping 11 matching lines...) Expand all
6220 i::Handle<i::String> part = i_isolate->factory()->private_api_string(); 6214 i::Handle<i::String> part = i_isolate->factory()->private_api_string();
6221 i::Handle<i::JSObject> privates = 6215 i::Handle<i::JSObject> privates =
6222 i::Handle<i::JSObject>::cast( 6216 i::Handle<i::JSObject>::cast(
6223 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked()); 6217 i::Object::GetPropertyOrElement(registry, part).ToHandleChecked());
6224 i::Handle<i::Object> symbol = 6218 i::Handle<i::Object> symbol =
6225 i::Object::GetPropertyOrElement(privates, i_name).ToHandleChecked(); 6219 i::Object::GetPropertyOrElement(privates, i_name).ToHandleChecked();
6226 if (!symbol->IsSymbol()) { 6220 if (!symbol->IsSymbol()) {
6227 ASSERT(symbol->IsUndefined()); 6221 ASSERT(symbol->IsUndefined());
6228 symbol = i_isolate->factory()->NewPrivateSymbol(); 6222 symbol = i_isolate->factory()->NewPrivateSymbol();
6229 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name); 6223 i::Handle<i::Symbol>::cast(symbol)->set_name(*i_name);
6230 i::JSObject::SetProperty( 6224 i::JSObject::SetProperty(privates, i_name, symbol, i::STRICT).Assert();
6231 privates, i_name, symbol, NONE, i::STRICT).Assert();
6232 } 6225 }
6233 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol)); 6226 Local<Symbol> result = Utils::ToLocal(i::Handle<i::Symbol>::cast(symbol));
6234 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 6227 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6235 } 6228 }
6236 6229
6237 6230
6238 Local<Number> v8::Number::New(Isolate* isolate, double value) { 6231 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6239 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6232 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6240 ASSERT(internal_isolate->IsInitialized()); 6233 ASSERT(internal_isolate->IsInitialized());
6241 if (std::isnan(value)) { 6234 if (std::isnan(value)) {
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
7630 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7623 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7631 Address callback_address = 7624 Address callback_address =
7632 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7625 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7633 VMState<EXTERNAL> state(isolate); 7626 VMState<EXTERNAL> state(isolate);
7634 ExternalCallbackScope call_scope(isolate, callback_address); 7627 ExternalCallbackScope call_scope(isolate, callback_address);
7635 callback(info); 7628 callback(info);
7636 } 7629 }
7637 7630
7638 7631
7639 } } // namespace v8::internal 7632 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698