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

Side by Side Diff: src/api.cc

Issue 83323003: Remove usage of deprecated APIs from v8 itself (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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/allocation-tracker.cc ('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 // 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 3383 matching lines...) Expand 10 before | Expand all | Expand 10 after
3394 // to never change the result of the basic enumeration function so 3394 // to never change the result of the basic enumeration function so
3395 // we clone the result. 3395 // we clone the result.
3396 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value); 3396 i::Handle<i::FixedArray> elms = isolate->factory()->CopyFixedArray(value);
3397 i::Handle<i::JSArray> result = 3397 i::Handle<i::JSArray> result =
3398 isolate->factory()->NewJSArrayWithElements(elms); 3398 isolate->factory()->NewJSArrayWithElements(elms);
3399 return Utils::ToLocal(scope.CloseAndEscape(result)); 3399 return Utils::ToLocal(scope.CloseAndEscape(result));
3400 } 3400 }
3401 3401
3402 3402
3403 Local<String> v8::Object::ObjectProtoToString() { 3403 Local<String> v8::Object::ObjectProtoToString() {
3404 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3404 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate();
3405 ON_BAILOUT(isolate, "v8::Object::ObjectProtoToString()", 3405 Isolate* isolate = reinterpret_cast<Isolate*>(i_isolate);
3406 ON_BAILOUT(i_isolate, "v8::Object::ObjectProtoToString()",
3406 return Local<v8::String>()); 3407 return Local<v8::String>());
3407 ENTER_V8(isolate); 3408 ENTER_V8(i_isolate);
3408 i::Handle<i::JSObject> self = Utils::OpenHandle(this); 3409 i::Handle<i::JSObject> self = Utils::OpenHandle(this);
3409 3410
3410 i::Handle<i::Object> name(self->class_name(), isolate); 3411 i::Handle<i::Object> name(self->class_name(), i_isolate);
3411 3412
3412 // Native implementation of Object.prototype.toString (v8natives.js): 3413 // Native implementation of Object.prototype.toString (v8natives.js):
3413 // var c = %_ClassOf(this); 3414 // var c = %_ClassOf(this);
3414 // if (c === 'Arguments') c = 'Object'; 3415 // if (c === 'Arguments') c = 'Object';
3415 // return "[object " + c + "]"; 3416 // return "[object " + c + "]";
3416 3417
3417 if (!name->IsString()) { 3418 if (!name->IsString()) {
3418 return v8::String::New("[object ]"); 3419 return v8::String::NewFromUtf8(isolate, "[object ]");
3419
3420 } else { 3420 } else {
3421 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name); 3421 i::Handle<i::String> class_name = i::Handle<i::String>::cast(name);
3422 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) { 3422 if (class_name->IsOneByteEqualTo(STATIC_ASCII_VECTOR("Arguments"))) {
3423 return v8::String::New("[object Object]"); 3423 return v8::String::NewFromUtf8(isolate, "[object Object]");
3424
3425 } else { 3424 } else {
3426 const char* prefix = "[object "; 3425 const char* prefix = "[object ";
3427 Local<String> str = Utils::ToLocal(class_name); 3426 Local<String> str = Utils::ToLocal(class_name);
3428 const char* postfix = "]"; 3427 const char* postfix = "]";
3429 3428
3430 int prefix_len = i::StrLength(prefix); 3429 int prefix_len = i::StrLength(prefix);
3431 int str_len = str->Utf8Length(); 3430 int str_len = str->Utf8Length();
3432 int postfix_len = i::StrLength(postfix); 3431 int postfix_len = i::StrLength(postfix);
3433 3432
3434 int buf_len = prefix_len + str_len + postfix_len; 3433 int buf_len = prefix_len + str_len + postfix_len;
3435 i::ScopedVector<char> buf(buf_len); 3434 i::ScopedVector<char> buf(buf_len);
3436 3435
3437 // Write prefix. 3436 // Write prefix.
3438 char* ptr = buf.start(); 3437 char* ptr = buf.start();
3439 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize); 3438 i::OS::MemCopy(ptr, prefix, prefix_len * v8::internal::kCharSize);
3440 ptr += prefix_len; 3439 ptr += prefix_len;
3441 3440
3442 // Write real content. 3441 // Write real content.
3443 str->WriteUtf8(ptr, str_len); 3442 str->WriteUtf8(ptr, str_len);
3444 ptr += str_len; 3443 ptr += str_len;
3445 3444
3446 // Write postfix. 3445 // Write postfix.
3447 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize); 3446 i::OS::MemCopy(ptr, postfix, postfix_len * v8::internal::kCharSize);
3448 3447
3449 // Copy the buffer into a heap-allocated string and return it. 3448 // Copy the buffer into a heap-allocated string and return it.
3450 Local<String> result = v8::String::New(buf.start(), buf_len); 3449 Local<String> result = v8::String::NewFromUtf8(
3450 isolate, buf.start(), String::kNormalString, buf_len);
3451 return result; 3451 return result;
3452 } 3452 }
3453 } 3453 }
3454 } 3454 }
3455 3455
3456 3456
3457 Local<Value> v8::Object::GetConstructor() { 3457 Local<Value> v8::Object::GetConstructor() {
3458 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); 3458 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();
3459 ON_BAILOUT(isolate, "v8::Object::GetConstructor()", 3459 ON_BAILOUT(isolate, "v8::Object::GetConstructor()",
3460 return Local<v8::Function>()); 3460 return Local<v8::Function>());
(...skipping 4217 matching lines...) Expand 10 before | Expand all | Expand 10 after
7678 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7678 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7679 Address callback_address = 7679 Address callback_address =
7680 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7680 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7681 VMState<EXTERNAL> state(isolate); 7681 VMState<EXTERNAL> state(isolate);
7682 ExternalCallbackScope call_scope(isolate, callback_address); 7682 ExternalCallbackScope call_scope(isolate, callback_address);
7683 callback(info); 7683 callback(info);
7684 } 7684 }
7685 7685
7686 7686
7687 } } // namespace v8::internal 7687 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/allocation-tracker.cc ('k') | src/debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698