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

Side by Side Diff: src/api.cc

Issue 179983002: initialize v8::Private with v8::String (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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 // 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 5966 matching lines...) Expand 10 before | Expand all | Expand 10 after
5977 if (length == -1) length = i::StrLength(data); 5977 if (length == -1) length = i::StrLength(data);
5978 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8( 5978 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
5979 i::Vector<const char>(data, length)); 5979 i::Vector<const char>(data, length));
5980 result->set_name(*name); 5980 result->set_name(*name);
5981 } 5981 }
5982 return Utils::ToLocal(result); 5982 return Utils::ToLocal(result);
5983 } 5983 }
5984 5984
5985 5985
5986 Local<Private> v8::Private::New( 5986 Local<Private> v8::Private::New(
5987 Isolate* isolate, const char* data, int length) { 5987 Isolate* isolate, Local<String> name) {
rossberg 2014/02/25 15:43:47 Nit: remove line break
5988 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); 5988 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate);
5989 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()"); 5989 EnsureInitializedForIsolate(i_isolate, "v8::Private::New()");
5990 LOG_API(i_isolate, "Private::New()"); 5990 LOG_API(i_isolate, "Private::New()");
5991 ENTER_V8(i_isolate); 5991 ENTER_V8(i_isolate);
5992 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol(); 5992 i::Handle<i::Symbol> symbol = i_isolate->factory()->NewPrivateSymbol();
5993 if (data != NULL) { 5993 if (!name.IsEmpty()) symbol->set_name(*Utils::OpenHandle(*name));
5994 if (length == -1) length = i::StrLength(data);
5995 i::Handle<i::String> name = i_isolate->factory()->NewStringFromUtf8(
5996 i::Vector<const char>(data, length));
5997 symbol->set_name(*name);
5998 }
5999 Local<Symbol> result = Utils::ToLocal(symbol); 5994 Local<Symbol> result = Utils::ToLocal(symbol);
6000 return v8::Handle<Private>(reinterpret_cast<Private*>(*result)); 5995 return v8::Handle<Private>(reinterpret_cast<Private*>(*result));
6001 } 5996 }
6002 5997
6003 5998
6004 Local<Number> v8::Number::New(Isolate* isolate, double value) { 5999 Local<Number> v8::Number::New(Isolate* isolate, double value) {
6005 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate); 6000 i::Isolate* internal_isolate = reinterpret_cast<i::Isolate*>(isolate);
6006 ASSERT(internal_isolate->IsInitialized()); 6001 ASSERT(internal_isolate->IsInitialized());
6007 if (std::isnan(value)) { 6002 if (std::isnan(value)) {
6008 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs. 6003 // Introduce only canonical NaN value into the VM, to avoid signaling NaNs.
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after
7377 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); 7372 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate());
7378 Address callback_address = 7373 Address callback_address =
7379 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); 7374 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback));
7380 VMState<EXTERNAL> state(isolate); 7375 VMState<EXTERNAL> state(isolate);
7381 ExternalCallbackScope call_scope(isolate, callback_address); 7376 ExternalCallbackScope call_scope(isolate, callback_address);
7382 callback(info); 7377 callback(info);
7383 } 7378 }
7384 7379
7385 7380
7386 } } // namespace v8::internal 7381 } } // 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