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 3174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3185 key_obj, | 3185 key_obj, |
3186 value_obj, | 3186 value_obj, |
3187 static_cast<PropertyAttributes>(attribs)); | 3187 static_cast<PropertyAttributes>(attribs)); |
3188 has_pending_exception = obj.is_null(); | 3188 has_pending_exception = obj.is_null(); |
3189 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3189 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3190 return true; | 3190 return true; |
3191 } | 3191 } |
3192 | 3192 |
3193 | 3193 |
3194 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { | 3194 bool v8::Object::SetPrivate(v8::Handle<Private> key, v8::Handle<Value> value) { |
3195 v8::Handle<Value>* key_as_value = reinterpret_cast<v8::Handle<Value>*>(&key); | 3195 return Set(v8::Handle<Value>(reinterpret_cast<Value*>(*key)), |
3196 return Set(*key_as_value, value, DontEnum); | 3196 value, DontEnum); |
3197 } | 3197 } |
3198 | 3198 |
3199 | 3199 |
3200 bool v8::Object::ForceDelete(v8::Handle<Value> key) { | 3200 bool v8::Object::ForceDelete(v8::Handle<Value> key) { |
3201 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3201 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3202 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); | 3202 ON_BAILOUT(isolate, "v8::Object::ForceDelete()", return false); |
3203 ENTER_V8(isolate); | 3203 ENTER_V8(isolate); |
3204 i::HandleScope scope(isolate); | 3204 i::HandleScope scope(isolate); |
3205 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3205 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3206 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3206 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3242 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3242 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
3243 EXCEPTION_PREAMBLE(isolate); | 3243 EXCEPTION_PREAMBLE(isolate); |
3244 i::Handle<i::Object> result = i::Object::GetElement(isolate, self, index); | 3244 i::Handle<i::Object> result = i::Object::GetElement(isolate, self, index); |
3245 has_pending_exception = result.is_null(); | 3245 has_pending_exception = result.is_null(); |
3246 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); | 3246 EXCEPTION_BAILOUT_CHECK(isolate, Local<Value>()); |
3247 return Utils::ToLocal(result); | 3247 return Utils::ToLocal(result); |
3248 } | 3248 } |
3249 | 3249 |
3250 | 3250 |
3251 Local<Value> v8::Object::GetPrivate(v8::Handle<Private> key) { | 3251 Local<Value> v8::Object::GetPrivate(v8::Handle<Private> key) { |
3252 v8::Handle<Value>* key_as_value = reinterpret_cast<v8::Handle<Value>*>(&key); | 3252 return Get(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); |
3253 return Get(*key_as_value); | |
3254 } | 3253 } |
3255 | 3254 |
3256 | 3255 |
3257 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { | 3256 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { |
3258 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3257 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3259 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", | 3258 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", |
3260 return static_cast<PropertyAttribute>(NONE)); | 3259 return static_cast<PropertyAttribute>(NONE)); |
3261 ENTER_V8(isolate); | 3260 ENTER_V8(isolate); |
3262 i::HandleScope scope(isolate); | 3261 i::HandleScope scope(isolate); |
3263 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3262 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3447 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3446 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3448 EXCEPTION_PREAMBLE(isolate); | 3447 EXCEPTION_PREAMBLE(isolate); |
3449 i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj); | 3448 i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj); |
3450 has_pending_exception = obj.is_null(); | 3449 has_pending_exception = obj.is_null(); |
3451 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3450 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3452 return obj->IsTrue(); | 3451 return obj->IsTrue(); |
3453 } | 3452 } |
3454 | 3453 |
3455 | 3454 |
3456 bool v8::Object::DeletePrivate(v8::Handle<Private> key) { | 3455 bool v8::Object::DeletePrivate(v8::Handle<Private> key) { |
3457 v8::Handle<Value>* key_as_value = reinterpret_cast<v8::Handle<Value>*>(&key); | 3456 return Delete(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); |
3458 return Delete(*key_as_value); | |
3459 } | 3457 } |
3460 | 3458 |
3461 | 3459 |
3462 bool v8::Object::Has(v8::Handle<Value> key) { | 3460 bool v8::Object::Has(v8::Handle<Value> key) { |
3463 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3461 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3464 ON_BAILOUT(isolate, "v8::Object::Has()", return false); | 3462 ON_BAILOUT(isolate, "v8::Object::Has()", return false); |
3465 ENTER_V8(isolate); | 3463 ENTER_V8(isolate); |
3466 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); | 3464 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this); |
3467 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); | 3465 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); |
3468 EXCEPTION_PREAMBLE(isolate); | 3466 EXCEPTION_PREAMBLE(isolate); |
3469 i::Handle<i::Object> obj = i::HasProperty(self, key_obj); | 3467 i::Handle<i::Object> obj = i::HasProperty(self, key_obj); |
3470 has_pending_exception = obj.is_null(); | 3468 has_pending_exception = obj.is_null(); |
3471 EXCEPTION_BAILOUT_CHECK(isolate, false); | 3469 EXCEPTION_BAILOUT_CHECK(isolate, false); |
3472 return obj->IsTrue(); | 3470 return obj->IsTrue(); |
3473 } | 3471 } |
3474 | 3472 |
3475 | 3473 |
3476 bool v8::Object::HasPrivate(v8::Handle<Private> key) { | 3474 bool v8::Object::HasPrivate(v8::Handle<Private> key) { |
3477 v8::Handle<Value>* key_as_value = reinterpret_cast<v8::Handle<Value>*>(&key); | 3475 return Has(v8::Handle<Value>(reinterpret_cast<Value*>(*key))); |
3478 return Has(*key_as_value); | |
3479 } | 3476 } |
3480 | 3477 |
3481 | 3478 |
3482 bool v8::Object::Delete(uint32_t index) { | 3479 bool v8::Object::Delete(uint32_t index) { |
3483 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3480 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
3484 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()", | 3481 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()", |
3485 return false); | 3482 return false); |
3486 ENTER_V8(isolate); | 3483 ENTER_V8(isolate); |
3487 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); | 3484 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); |
3488 i::Handle<i::JSObject> self = Utils::OpenHandle(this); | 3485 i::Handle<i::JSObject> self = Utils::OpenHandle(this); |
(...skipping 2701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6190 LOG_API(i_isolate, "Private::New()"); | 6187 LOG_API(i_isolate, "Private::New()"); |
6191 ENTER_V8(i_isolate); | 6188 ENTER_V8(i_isolate); |
6192 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); | 6189 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); |
6193 if (data != NULL) { | 6190 if (data != NULL) { |
6194 if (length == -1) length = i::StrLength(data); | 6191 if (length == -1) length = i::StrLength(data); |
6195 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( | 6192 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( |
6196 i::Vector<const char>(data, length)); | 6193 i::Vector<const char>(data, length)); |
6197 symbol->set_name(*name); | 6194 symbol->set_name(*name); |
6198 } | 6195 } |
6199 Local<Symbol> result = Utils::ToLocal(symbol); | 6196 Local<Symbol> result = Utils::ToLocal(symbol); |
6200 v8::Handle<Private>* result_as_private = | 6197 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); |
6201 reinterpret_cast<v8::Handle<Private>*>(&result); | |
6202 return *result_as_private; | |
6203 } | 6198 } |
6204 | 6199 |
6205 | 6200 |
6206 Local<Number> v8::Number::New(double value) { | 6201 Local<Number> v8::Number::New(double value) { |
6207 i::Isolate* isolate = i::Isolate::Current(); | 6202 i::Isolate* isolate = i::Isolate::Current(); |
6208 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); | 6203 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); |
6209 return Number::New(reinterpret_cast<Isolate*>(isolate), value); | 6204 return Number::New(reinterpret_cast<Isolate*>(isolate), value); |
6210 } | 6205 } |
6211 | 6206 |
6212 | 6207 |
(...skipping 1411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7624 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7619 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7625 Address callback_address = | 7620 Address callback_address = |
7626 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7621 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7627 VMState<EXTERNAL> state(isolate); | 7622 VMState<EXTERNAL> state(isolate); |
7628 ExternalCallbackScope call_scope(isolate, callback_address); | 7623 ExternalCallbackScope call_scope(isolate, callback_address); |
7629 callback(info); | 7624 callback(info); |
7630 } | 7625 } |
7631 | 7626 |
7632 | 7627 |
7633 } } // namespace v8::internal | 7628 } } // namespace v8::internal |
OLD | NEW |