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

Side by Side Diff: src/api.cc

Issue 460333002: Expose Value::IsArgumentsObject in V8 API. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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') | test/cctest/test-api.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 2365 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 bool Value::IsObject() const { 2376 bool Value::IsObject() const {
2377 return Utils::OpenHandle(this)->IsJSObject(); 2377 return Utils::OpenHandle(this)->IsJSObject();
2378 } 2378 }
2379 2379
2380 2380
2381 bool Value::IsNumber() const { 2381 bool Value::IsNumber() const {
2382 return Utils::OpenHandle(this)->IsNumber(); 2382 return Utils::OpenHandle(this)->IsNumber();
2383 } 2383 }
2384 2384
2385 2385
2386 bool Value::IsArgumentsObject() const {
2387 i::Handle<i::Object> obj = Utils::OpenHandle(this);
2388 if (!obj->IsHeapObject()) return false;
2389 i::Isolate* isolate = i::HeapObject::cast(*obj)->GetIsolate();
2390 return obj->HasSpecificClassOf(isolate->heap()->Arguments_string());
Yang 2014/08/12 10:53:46 I don't think this is fool-proof. You could always
2391 }
2392
2393
2386 bool Value::IsBoolean() const { 2394 bool Value::IsBoolean() const {
2387 return Utils::OpenHandle(this)->IsBoolean(); 2395 return Utils::OpenHandle(this)->IsBoolean();
2388 } 2396 }
2389 2397
2390 2398
2391 bool Value::IsExternal() const { 2399 bool Value::IsExternal() const {
2392 return Utils::OpenHandle(this)->IsExternal(); 2400 return Utils::OpenHandle(this)->IsExternal();
2393 } 2401 }
2394 2402
2395 2403
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
3289 3297
3290 // Native implementation of Object.prototype.toString (v8natives.js): 3298 // Native implementation of Object.prototype.toString (v8natives.js):
3291 // var c = %_ClassOf(this); 3299 // var c = %_ClassOf(this);
3292 // if (c === 'Arguments') c = 'Object'; 3300 // if (c === 'Arguments') c = 'Object';
3293 // return "[object " + c + "]"; 3301 // return "[object " + c + "]";
3294 3302
3295 if (!name->IsString()) { 3303 if (!name->IsString()) {
3296 return v8::String::NewFromUtf8(isolate, "[object ]"); 3304 return v8::String::NewFromUtf8(isolate, "[object ]");
3297 } else { 3305 } else {
3298 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); 3306 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name);
3299 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) { 3307 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) {
aandrey 2014/08/12 11:17:16 I think Arguments_string() should also be used her
3300 return v8::String::NewFromUtf8(isolate, "[object Object]"); 3308 return v8::String::NewFromUtf8(isolate, "[object Object]");
3301 } else { 3309 } else {
3302 const char* prefix = "[object "; 3310 const char* prefix = "[object ";
3303 Local<String> str = Utils::ToLocal(class_name); 3311 Local<String> str = Utils::ToLocal(class_name);
3304 const char* postfix = "]"; 3312 const char* postfix = "]";
3305 3313
3306 int prefix_len = i::StrLength(prefix); 3314 int prefix_len = i::StrLength(prefix);
3307 int str_len = str->Utf8Length(); 3315 int str_len = str->Utf8Length();
3308 int postfix_len = i::StrLength(postfix); 3316 int postfix_len = i::StrLength(postfix);
3309 3317
(...skipping 4323 matching lines...) Expand 10 before | Expand all | Expand 10 after
7633 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7641 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7634 Address callback_address = 7642 Address callback_address =
7635 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7643 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7636 VMState<EXTERNAL> state(isolate); 7644 VMState<EXTERNAL> state(isolate);
7637 ExternalCallbackScope call_scope(isolate, callback_address); 7645 ExternalCallbackScope call_scope(isolate, callback_address);
7638 callback(info); 7646 callback(info);
7639 } 7647 }
7640 7648
7641 7649
7642 } } // namespace v8::internal 7650 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « include/v8.h ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698