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

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

Powered by Google App Engine
This is Rietveld 408576698