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

Side by Side Diff: src/api.cc

Issue 13626002: ES6 symbols: extend V8 API to support symbols (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added TODO Created 7 years, 8 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 | « src/api.h ('k') | src/handles.h » ('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 2349 matching lines...) Expand 10 before | Expand all | Expand 10 after
2360 2360
2361 2361
2362 bool Value::FullIsString() const { 2362 bool Value::FullIsString() const {
2363 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsString()")) return false; 2363 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsString()")) return false;
2364 bool result = Utils::OpenHandle(this)->IsString(); 2364 bool result = Utils::OpenHandle(this)->IsString();
2365 ASSERT_EQ(result, QuickIsString()); 2365 ASSERT_EQ(result, QuickIsString());
2366 return result; 2366 return result;
2367 } 2367 }
2368 2368
2369 2369
2370 bool Value::IsSymbol() const {
2371 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsSymbol()")) return false;
2372 return Utils::OpenHandle(this)->IsSymbol();
2373 }
2374
2375
2370 bool Value::IsArray() const { 2376 bool Value::IsArray() const {
2371 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArray()")) return false; 2377 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsArray()")) return false;
2372 return Utils::OpenHandle(this)->IsJSArray(); 2378 return Utils::OpenHandle(this)->IsJSArray();
2373 } 2379 }
2374 2380
2375 2381
2376 bool Value::IsObject() const { 2382 bool Value::IsObject() const {
2377 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false; 2383 if (IsDeadCheck(i::Isolate::Current(), "v8::Value::IsObject()")) return false;
2378 return Utils::OpenHandle(this)->IsJSObject(); 2384 return Utils::OpenHandle(this)->IsJSObject();
2379 } 2385 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
2444 2450
2445 2451
2446 bool Value::IsStringObject() const { 2452 bool Value::IsStringObject() const {
2447 i::Isolate* isolate = i::Isolate::Current(); 2453 i::Isolate* isolate = i::Isolate::Current();
2448 if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false; 2454 if (IsDeadCheck(isolate, "v8::Value::IsStringObject()")) return false;
2449 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2455 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2450 return obj->HasSpecificClassOf(isolate->heap()->String_string()); 2456 return obj->HasSpecificClassOf(isolate->heap()->String_string());
2451 } 2457 }
2452 2458
2453 2459
2460 bool Value::IsSymbolObject() const {
2461 // TODO(svenpanne): these and other test functions should be written such
2462 // that they do not use Isolate::Current().
2463 i::Isolate* isolate = i::Isolate::Current();
2464 if (IsDeadCheck(isolate, "v8::Value::IsSymbolObject()")) return false;
2465 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2466 return obj->HasSpecificClassOf(isolate->heap()->Symbol_string());
2467 }
2468
2469
2454 bool Value::IsNumberObject() const { 2470 bool Value::IsNumberObject() const {
2455 i::Isolate* isolate = i::Isolate::Current(); 2471 i::Isolate* isolate = i::Isolate::Current();
2456 if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false; 2472 if (IsDeadCheck(isolate, "v8::Value::IsNumberObject()")) return false;
2457 i::Handle<i::Object> obj = Utils::OpenHandle(this); 2473 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2458 return obj->HasSpecificClassOf(isolate->heap()->Number_string()); 2474 return obj->HasSpecificClassOf(isolate->heap()->Number_string());
2459 } 2475 }
2460 2476
2461 2477
2462 static i::Object* LookupBuiltin(i::Isolate* isolate, 2478 static i::Object* LookupBuiltin(i::Isolate* isolate,
2463 const char* builtin_name) { 2479 const char* builtin_name) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
2657 2673
2658 void v8::String::CheckCast(v8::Value* that) { 2674 void v8::String::CheckCast(v8::Value* that) {
2659 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Cast()")) return; 2675 if (IsDeadCheck(i::Isolate::Current(), "v8::String::Cast()")) return;
2660 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2676 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2661 ApiCheck(obj->IsString(), 2677 ApiCheck(obj->IsString(),
2662 "v8::String::Cast()", 2678 "v8::String::Cast()",
2663 "Could not convert to string"); 2679 "Could not convert to string");
2664 } 2680 }
2665 2681
2666 2682
2683 void v8::Symbol::CheckCast(v8::Value* that) {
2684 if (IsDeadCheck(i::Isolate::Current(), "v8::Symbol::Cast()")) return;
2685 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2686 ApiCheck(obj->IsSymbol(),
2687 "v8::Symbol::Cast()",
2688 "Could not convert to symbol");
2689 }
2690
2691
2667 void v8::Number::CheckCast(v8::Value* that) { 2692 void v8::Number::CheckCast(v8::Value* that) {
2668 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Cast()")) return; 2693 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Cast()")) return;
2669 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2694 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2670 ApiCheck(obj->IsNumber(), 2695 ApiCheck(obj->IsNumber(),
2671 "v8::Number::Cast()", 2696 "v8::Number::Cast()",
2672 "Could not convert to number"); 2697 "Could not convert to number");
2673 } 2698 }
2674 2699
2675 2700
2676 void v8::Integer::CheckCast(v8::Value* that) { 2701 void v8::Integer::CheckCast(v8::Value* that) {
(...skipping 27 matching lines...) Expand all
2704 void v8::StringObject::CheckCast(v8::Value* that) { 2729 void v8::StringObject::CheckCast(v8::Value* that) {
2705 i::Isolate* isolate = i::Isolate::Current(); 2730 i::Isolate* isolate = i::Isolate::Current();
2706 if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return; 2731 if (IsDeadCheck(isolate, "v8::StringObject::Cast()")) return;
2707 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2732 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2708 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()), 2733 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->String_string()),
2709 "v8::StringObject::Cast()", 2734 "v8::StringObject::Cast()",
2710 "Could not convert to StringObject"); 2735 "Could not convert to StringObject");
2711 } 2736 }
2712 2737
2713 2738
2739 void v8::SymbolObject::CheckCast(v8::Value* that) {
2740 i::Isolate* isolate = i::Isolate::Current();
2741 if (IsDeadCheck(isolate, "v8::SymbolObject::Cast()")) return;
2742 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2743 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Symbol_string()),
2744 "v8::SymbolObject::Cast()",
2745 "Could not convert to SymbolObject");
2746 }
2747
2748
2714 void v8::NumberObject::CheckCast(v8::Value* that) { 2749 void v8::NumberObject::CheckCast(v8::Value* that) {
2715 i::Isolate* isolate = i::Isolate::Current(); 2750 i::Isolate* isolate = i::Isolate::Current();
2716 if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return; 2751 if (IsDeadCheck(isolate, "v8::NumberObject::Cast()")) return;
2717 i::Handle<i::Object> obj = Utils::OpenHandle(that); 2752 i::Handle<i::Object> obj = Utils::OpenHandle(that);
2718 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()), 2753 ApiCheck(obj->HasSpecificClassOf(isolate->heap()->Number_string()),
2719 "v8::NumberObject::Cast()", 2754 "v8::NumberObject::Cast()",
2720 "Could not convert to NumberObject"); 2755 "Could not convert to NumberObject");
2721 } 2756 }
2722 2757
2723 2758
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
3072 3107
3073 3108
3074 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) { 3109 PropertyAttribute v8::Object::GetPropertyAttributes(v8::Handle<Value> key) {
3075 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3110 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3076 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()", 3111 ON_BAILOUT(isolate, "v8::Object::GetPropertyAttribute()",
3077 return static_cast<PropertyAttribute>(NONE)); 3112 return static_cast<PropertyAttribute>(NONE));
3078 ENTER_V8(isolate); 3113 ENTER_V8(isolate);
3079 i::HandleScope scope(isolate); 3114 i::HandleScope scope(isolate);
3080 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3115 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3081 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key); 3116 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3082 if (!key_obj->IsString()) { 3117 if (!key_obj->IsName()) {
3083 EXCEPTION_PREAMBLE(isolate); 3118 EXCEPTION_PREAMBLE(isolate);
3084 key_obj = i::Execution::ToString(key_obj, &has_pending_exception); 3119 key_obj = i::Execution::ToString(key_obj, &has_pending_exception);
3085 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE)); 3120 EXCEPTION_BAILOUT_CHECK(isolate, static_cast<PropertyAttribute>(NONE));
3086 } 3121 }
3087 i::Handle<i::String> key_string = i::Handle<i::String>::cast(key_obj); 3122 i::Handle<i::Name> key_name = i::Handle<i::Name>::cast(key_obj);
3088 PropertyAttributes result = self->GetPropertyAttribute(*key_string); 3123 PropertyAttributes result = self->GetPropertyAttribute(*key_name);
3089 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE); 3124 if (result == ABSENT) return static_cast<PropertyAttribute>(NONE);
3090 return static_cast<PropertyAttribute>(result); 3125 return static_cast<PropertyAttribute>(result);
3091 } 3126 }
3092 3127
3093 3128
3094 Local<Value> v8::Object::GetPrototype() { 3129 Local<Value> v8::Object::GetPrototype() {
3095 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3130 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3096 ON_BAILOUT(isolate, "v8::Object::GetPrototype()", 3131 ON_BAILOUT(isolate, "v8::Object::GetPrototype()",
3097 return Local<v8::Value>()); 3132 return Local<v8::Value>());
3098 ENTER_V8(isolate); 3133 ENTER_V8(isolate);
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3248 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3283 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3249 ON_BAILOUT(isolate, "v8::Object::GetConstructorName()", 3284 ON_BAILOUT(isolate, "v8::Object::GetConstructorName()",
3250 return Local<v8::String>()); 3285 return Local<v8::String>());
3251 ENTER_V8(isolate); 3286 ENTER_V8(isolate);
3252 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3287 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3253 i::Handle<i::String> name(self->constructor_name()); 3288 i::Handle<i::String> name(self->constructor_name());
3254 return Utils::ToLocal(name); 3289 return Utils::ToLocal(name);
3255 } 3290 }
3256 3291
3257 3292
3258 bool v8::Object::Delete(v8::Handle<String> key) { 3293 bool v8::Object::Delete(v8::Handle<Value> key) {
3259 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3294 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3260 ON_BAILOUT(isolate, "v8::Object::Delete()", return false); 3295 ON_BAILOUT(isolate, "v8::Object::Delete()", return false);
3261 ENTER_V8(isolate); 3296 ENTER_V8(isolate);
3262 i::HandleScope scope(isolate); 3297 i::HandleScope scope(isolate);
3263 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3298 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3264 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3299 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3265 return i::JSObject::DeleteProperty(self, key_obj)->IsTrue(); 3300 EXCEPTION_PREAMBLE(isolate);
3301 i::Handle<i::Object> obj = i::DeleteProperty(self, key_obj);
3302 has_pending_exception = obj.is_null();
3303 EXCEPTION_BAILOUT_CHECK(isolate, false);
3304 return obj->IsTrue();
3266 } 3305 }
3267 3306
3268 3307
3269 bool v8::Object::Has(v8::Handle<String> key) { 3308 bool v8::Object::Has(v8::Handle<Value> key) {
3270 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3309 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3271 ON_BAILOUT(isolate, "v8::Object::Has()", return false); 3310 ON_BAILOUT(isolate, "v8::Object::Has()", return false);
3272 ENTER_V8(isolate); 3311 ENTER_V8(isolate);
3273 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3312 i::Handle<i::JSReceiver> self = Utils::OpenHandle(this);
3274 i::Handle<i::String> key_obj = Utils::OpenHandle(*key); 3313 i::Handle<i::Object> key_obj = Utils::OpenHandle(*key);
3275 return self->HasProperty(*key_obj); 3314 EXCEPTION_PREAMBLE(isolate);
3315 i::Handle<i::Object> obj = i::HasProperty(self, key_obj);
3316 has_pending_exception = obj.is_null();
3317 EXCEPTION_BAILOUT_CHECK(isolate, false);
3318 return obj->IsTrue();
3276 } 3319 }
3277 3320
3278 3321
3279 bool v8::Object::Delete(uint32_t index) { 3322 bool v8::Object::Delete(uint32_t index) {
3280 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3323 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3281 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()", 3324 ON_BAILOUT(isolate, "v8::Object::DeleteProperty()",
3282 return false); 3325 return false);
3283 ENTER_V8(isolate); 3326 ENTER_V8(isolate);
3284 HandleScope scope(reinterpret_cast<Isolate*>(isolate)); 3327 HandleScope scope(reinterpret_cast<Isolate*>(isolate));
3285 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3328 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
(...skipping 1298 matching lines...) Expand 10 before | Expand all | Expand 10 after
4584 if (i::StringShape(*str).IsExternalAscii()) { 4627 if (i::StringShape(*str).IsExternalAscii()) {
4585 const void* resource = 4628 const void* resource =
4586 i::Handle<i::ExternalAsciiString>::cast(str)->resource(); 4629 i::Handle<i::ExternalAsciiString>::cast(str)->resource();
4587 return reinterpret_cast<const ExternalAsciiStringResource*>(resource); 4630 return reinterpret_cast<const ExternalAsciiStringResource*>(resource);
4588 } else { 4631 } else {
4589 return NULL; 4632 return NULL;
4590 } 4633 }
4591 } 4634 }
4592 4635
4593 4636
4637 Local<Value> Symbol::Name() const {
4638 if (IsDeadCheck(i::Isolate::Current(), "v8::Symbol::Name()"))
4639 return Local<Value>();
4640 i::Handle<i::Symbol> sym = Utils::OpenHandle(this);
4641 i::Handle<i::Object> name(sym->name(), sym->GetIsolate());
4642 return Utils::ToLocal(name);
4643 }
4644
4645
4594 double Number::Value() const { 4646 double Number::Value() const {
4595 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0; 4647 if (IsDeadCheck(i::Isolate::Current(), "v8::Number::Value()")) return 0;
4596 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4648 i::Handle<i::Object> obj = Utils::OpenHandle(this);
4597 return obj->Number(); 4649 return obj->Number();
4598 } 4650 }
4599 4651
4600 4652
4601 bool Boolean::Value() const { 4653 bool Boolean::Value() const {
4602 if (IsDeadCheck(i::Isolate::Current(), "v8::Boolean::Value()")) return false; 4654 if (IsDeadCheck(i::Isolate::Current(), "v8::Boolean::Value()")) return false;
4603 i::Handle<i::Object> obj = Utils::OpenHandle(this); 4655 i::Handle<i::Object> obj = Utils::OpenHandle(this);
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after
5422 return Local<v8::String>(); 5474 return Local<v8::String>();
5423 } 5475 }
5424 LOG_API(isolate, "StringObject::StringValue"); 5476 LOG_API(isolate, "StringObject::StringValue");
5425 i::Handle<i::Object> obj = Utils::OpenHandle(this); 5477 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5426 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj); 5478 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5427 return Utils::ToLocal( 5479 return Utils::ToLocal(
5428 i::Handle<i::String>(i::String::cast(jsvalue->value()))); 5480 i::Handle<i::String>(i::String::cast(jsvalue->value())));
5429 } 5481 }
5430 5482
5431 5483
5484 Local<v8::Value> v8::SymbolObject::New(Isolate* isolate, Handle<Symbol> value) {
5485 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5486 EnsureInitializedForIsolate(i_isolate, "v8::SymbolObject::New()");
5487 LOG_API(i_isolate, "SymbolObject::New");
5488 ENTER_V8(i_isolate);
5489 i::Handle<i::Object> obj =
5490 i_isolate->factory()->ToObject(Utils::OpenHandle(*value));
5491 return Utils::ToLocal(obj);
5492 }
5493
5494
5495 Local<v8::Symbol> v8::SymbolObject::SymbolValue() const {
5496 i::Isolate* isolate = i::Isolate::Current();
5497 if (IsDeadCheck(isolate, "v8::SymbolObject::SymbolValue()"))
5498 return Local<v8::Symbol>();
5499 LOG_API(isolate, "SymbolObject::SymbolValue");
5500 i::Handle<i::Object> obj = Utils::OpenHandle(this);
5501 i::Handle<i::JSValue> jsvalue = i::Handle<i::JSValue>::cast(obj);
5502 return Utils::ToLocal(
5503 i::Handle<i::Symbol>(i::Symbol::cast(jsvalue->value())));
5504 }
5505
5506
5432 Local<v8::Value> v8::Date::New(double time) { 5507 Local<v8::Value> v8::Date::New(double time) {
5433 i::Isolate* isolate = i::Isolate::Current(); 5508 i::Isolate* isolate = i::Isolate::Current();
5434 EnsureInitializedForIsolate(isolate, "v8::Date::New()"); 5509 EnsureInitializedForIsolate(isolate, "v8::Date::New()");
5435 LOG_API(isolate, "Date::New"); 5510 LOG_API(isolate, "Date::New");
5436 if (isnan(time)) { 5511 if (isnan(time)) {
5437 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 5512 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
5438 time = i::OS::nan_value(); 5513 time = i::OS::nan_value();
5439 } 5514 }
5440 ENTER_V8(isolate); 5515 ENTER_V8(isolate);
5441 EXCEPTION_PREAMBLE(isolate); 5516 EXCEPTION_PREAMBLE(isolate);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
5603 EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()"); 5678 EnsureInitializedForIsolate(isolate, "v8::String::NewSymbol()");
5604 LOG_API(isolate, "String::NewSymbol(char)"); 5679 LOG_API(isolate, "String::NewSymbol(char)");
5605 ENTER_V8(isolate); 5680 ENTER_V8(isolate);
5606 if (length == -1) length = i::StrLength(data); 5681 if (length == -1) length = i::StrLength(data);
5607 i::Handle<i::String> result = isolate->factory()->InternalizeUtf8String( 5682 i::Handle<i::String> result = isolate->factory()->InternalizeUtf8String(
5608 i::Vector<const char>(data, length)); 5683 i::Vector<const char>(data, length));
5609 return Utils::ToLocal(result); 5684 return Utils::ToLocal(result);
5610 } 5685 }
5611 5686
5612 5687
5688 Local<Symbol> v8::Symbol::New(Isolate* isolate) {
5689 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5690 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
5691 LOG_API(i_isolate, "Symbol::New()");
5692 ENTER_V8(i_isolate);
5693 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
5694 return Utils::ToLocal(result);
5695 }
5696
5697
5698 Local<Symbol> v8::Symbol::New(Isolate* isolate, const char* data, int length) {
5699 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5700 EnsureInitializedForIsolate(i_isolate, "v8::Symbol::New()");
5701 LOG_API(i_isolate, "Symbol::New(char)");
5702 ENTER_V8(i_isolate);
5703 if (length == -1) length = i::StrLength(data);
5704 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
5705 i::Vector<const char>(data, length));
5706 i::Handle<i::Symbol> result = i_isolate->factory()->NewSymbol();
5707 result->set_name(*name);
5708 return Utils::ToLocal(result);
5709 }
5710
5711
5613 Local<Number> v8::Number::New(double value) { 5712 Local<Number> v8::Number::New(double value) {
5614 i::Isolate* isolate = i::Isolate::Current(); 5713 i::Isolate* isolate = i::Isolate::Current();
5615 EnsureInitializedForIsolate(isolate, "v8::Number::New()"); 5714 EnsureInitializedForIsolate(isolate, "v8::Number::New()");
5616 if (isnan(value)) { 5715 if (isnan(value)) {
5617 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 5716 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
5618 value = i::OS::nan_value(); 5717 value = i::OS::nan_value();
5619 } 5718 }
5620 ENTER_V8(isolate); 5719 ENTER_V8(isolate);
5621 i::Handle<i::Object> result = isolate->factory()->NewNumber(value); 5720 i::Handle<i::Object> result = isolate->factory()->NewNumber(value);
5622 return Utils::NumberToLocal(result); 5721 return Utils::NumberToLocal(result);
(...skipping 1590 matching lines...) Expand 10 before | Expand all | Expand 10 after
7213 7312
7214 v->VisitPointers(blocks_.first(), first_block_limit_); 7313 v->VisitPointers(blocks_.first(), first_block_limit_);
7215 7314
7216 for (int i = 1; i < blocks_.length(); i++) { 7315 for (int i = 1; i < blocks_.length(); i++) {
7217 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 7316 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
7218 } 7317 }
7219 } 7318 }
7220 7319
7221 7320
7222 } } // namespace v8::internal 7321 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/api.h ('k') | src/handles.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698