summaryrefslogtreecommitdiff
path: root/deps/v8/samples
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-10-18 15:03:02 -0700
committerMichaël Zasso <targos@protonmail.com>2017-10-18 17:01:41 -0700
commit3d1b3df9486c0e7708065257f7311902f6b7b366 (patch)
treecb051bdeaead11e06dcd97725783e0f113afb1bf /deps/v8/samples
parente2cddbb8ccdb7b3c4a40c8acc630f68703bc77b5 (diff)
downloadandroid-node-v8-3d1b3df9486c0e7708065257f7311902f6b7b366.tar.gz
android-node-v8-3d1b3df9486c0e7708065257f7311902f6b7b366.tar.bz2
android-node-v8-3d1b3df9486c0e7708065257f7311902f6b7b366.zip
deps: update V8 to 6.2.414.32
PR-URL: https://github.com/nodejs/node/pull/15362 Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'deps/v8/samples')
-rw-r--r--deps/v8/samples/hello-world.cc2
-rw-r--r--deps/v8/samples/process.cc27
-rw-r--r--deps/v8/samples/shell.cc19
3 files changed, 25 insertions, 23 deletions
diff --git a/deps/v8/samples/hello-world.cc b/deps/v8/samples/hello-world.cc
index 9e5188f479..8a2122c96b 100644
--- a/deps/v8/samples/hello-world.cc
+++ b/deps/v8/samples/hello-world.cc
@@ -48,7 +48,7 @@ int main(int argc, char* argv[]) {
Local<Value> result = script->Run(context).ToLocalChecked();
// Convert the result to an UTF8 string and print it.
- String::Utf8Value utf8(result);
+ String::Utf8Value utf8(isolate, result);
printf("%s\n", *utf8);
}
diff --git a/deps/v8/samples/process.cc b/deps/v8/samples/process.cc
index 29ddb5cf2f..5ebe1dbfc4 100644
--- a/deps/v8/samples/process.cc
+++ b/deps/v8/samples/process.cc
@@ -144,9 +144,10 @@ class JsHttpRequestProcessor : public HttpRequestProcessor {
static void LogCallback(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() < 1) return;
- HandleScope scope(args.GetIsolate());
+ Isolate* isolate = args.GetIsolate();
+ HandleScope scope(isolate);
Local<Value> arg = args[0];
- String::Utf8Value value(arg);
+ String::Utf8Value value(isolate, arg);
HttpRequestProcessor::Log(*value);
}
@@ -221,7 +222,7 @@ bool JsHttpRequestProcessor::ExecuteScript(Local<String> script) {
// Compile the script and check for errors.
Local<Script> compiled_script;
if (!Script::Compile(context, script).ToLocal(&compiled_script)) {
- String::Utf8Value error(try_catch.Exception());
+ String::Utf8Value error(GetIsolate(), try_catch.Exception());
Log(*error);
// The script failed to compile; bail out.
return false;
@@ -231,11 +232,12 @@ bool JsHttpRequestProcessor::ExecuteScript(Local<String> script) {
Local<Value> result;
if (!compiled_script->Run(context).ToLocal(&result)) {
// The TryCatch above is still in effect and will have caught the error.
- String::Utf8Value error(try_catch.Exception());
+ String::Utf8Value error(GetIsolate(), try_catch.Exception());
Log(*error);
// Running the script failed; bail out.
return false;
}
+
return true;
}
@@ -295,17 +297,16 @@ bool JsHttpRequestProcessor::Process(HttpRequest* request) {
v8::Local<v8::Function>::New(GetIsolate(), process_);
Local<Value> result;
if (!process->Call(context, context->Global(), argc, argv).ToLocal(&result)) {
- String::Utf8Value error(try_catch.Exception());
+ String::Utf8Value error(GetIsolate(), try_catch.Exception());
Log(*error);
return false;
- } else {
- return true;
}
+ return true;
}
JsHttpRequestProcessor::~JsHttpRequestProcessor() {
- // Dispose the persistent handles. When noone else has any
+ // Dispose the persistent handles. When no one else has any
// references to the objects stored in the handles they will be
// automatically reclaimed.
context_.Reset();
@@ -366,8 +367,8 @@ map<string, string>* JsHttpRequestProcessor::UnwrapMap(Local<Object> obj) {
// Convert a JavaScript string to a std::string. To not bother too
// much with string encodings we just use ascii.
-string ObjectToString(Local<Value> value) {
- String::Utf8Value utf8_value(value);
+string ObjectToString(v8::Isolate* isolate, Local<Value> value) {
+ String::Utf8Value utf8_value(isolate, value);
return string(*utf8_value);
}
@@ -380,7 +381,7 @@ void JsHttpRequestProcessor::MapGet(Local<Name> name,
map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the JavaScript string to a std::string.
- string key = ObjectToString(Local<String>::Cast(name));
+ string key = ObjectToString(info.GetIsolate(), Local<String>::Cast(name));
// Look up the value if it exists using the standard STL ideom.
map<string, string>::iterator iter = obj->find(key);
@@ -405,8 +406,8 @@ void JsHttpRequestProcessor::MapSet(Local<Name> name, Local<Value> value_obj,
map<string, string>* obj = UnwrapMap(info.Holder());
// Convert the key and value to std::strings.
- string key = ObjectToString(Local<String>::Cast(name));
- string value = ObjectToString(value_obj);
+ string key = ObjectToString(info.GetIsolate(), Local<String>::Cast(name));
+ string value = ObjectToString(info.GetIsolate(), value_obj);
// Update the map.
(*obj)[key] = value;
diff --git a/deps/v8/samples/shell.cc b/deps/v8/samples/shell.cc
index e042815e7a..0f8e2a4fdc 100644
--- a/deps/v8/samples/shell.cc
+++ b/deps/v8/samples/shell.cc
@@ -147,7 +147,7 @@ void Print(const v8::FunctionCallbackInfo<v8::Value>& args) {
} else {
printf(" ");
}
- v8::String::Utf8Value str(args[i]);
+ v8::String::Utf8Value str(args.GetIsolate(), args[i]);
const char* cstr = ToCString(str);
printf("%s", cstr);
}
@@ -166,7 +166,7 @@ void Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::NewStringType::kNormal).ToLocalChecked());
return;
}
- v8::String::Utf8Value file(args[0]);
+ v8::String::Utf8Value file(args.GetIsolate(), args[0]);
if (*file == NULL) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file",
@@ -180,17 +180,17 @@ void Read(const v8::FunctionCallbackInfo<v8::Value>& args) {
v8::NewStringType::kNormal).ToLocalChecked());
return;
}
+
args.GetReturnValue().Set(source);
}
-
// The callback that is invoked by v8 whenever the JavaScript 'load'
// function is called. Loads, compiles and executes its argument
// JavaScript file.
void Load(const v8::FunctionCallbackInfo<v8::Value>& args) {
for (int i = 0; i < args.Length(); i++) {
v8::HandleScope handle_scope(args.GetIsolate());
- v8::String::Utf8Value file(args[i]);
+ v8::String::Utf8Value file(args.GetIsolate(), args[i]);
if (*file == NULL) {
args.GetIsolate()->ThrowException(
v8::String::NewFromUtf8(args.GetIsolate(), "Error loading file",
@@ -361,7 +361,7 @@ bool ExecuteString(v8::Isolate* isolate, v8::Local<v8::String> source,
if (print_result && !result->IsUndefined()) {
// If all went well and the result wasn't undefined then print
// the returned value.
- v8::String::Utf8Value str(result);
+ v8::String::Utf8Value str(isolate, result);
const char* cstr = ToCString(str);
printf("%s\n", cstr);
}
@@ -373,7 +373,7 @@ bool ExecuteString(v8::Isolate* isolate, v8::Local<v8::String> source,
void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) {
v8::HandleScope handle_scope(isolate);
- v8::String::Utf8Value exception(try_catch->Exception());
+ v8::String::Utf8Value exception(isolate, try_catch->Exception());
const char* exception_string = ToCString(exception);
v8::Local<v8::Message> message = try_catch->Message();
if (message.IsEmpty()) {
@@ -382,14 +382,15 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) {
fprintf(stderr, "%s\n", exception_string);
} else {
// Print (filename):(line number): (message).
- v8::String::Utf8Value filename(message->GetScriptOrigin().ResourceName());
+ v8::String::Utf8Value filename(isolate,
+ message->GetScriptOrigin().ResourceName());
v8::Local<v8::Context> context(isolate->GetCurrentContext());
const char* filename_string = ToCString(filename);
int linenum = message->GetLineNumber(context).FromJust();
fprintf(stderr, "%s:%i: %s\n", filename_string, linenum, exception_string);
// Print line of source code.
v8::String::Utf8Value sourceline(
- message->GetSourceLine(context).ToLocalChecked());
+ isolate, message->GetSourceLine(context).ToLocalChecked());
const char* sourceline_string = ToCString(sourceline);
fprintf(stderr, "%s\n", sourceline_string);
// Print wavy underline (GetUnderline is deprecated).
@@ -406,7 +407,7 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* try_catch) {
if (try_catch->StackTrace(context).ToLocal(&stack_trace_string) &&
stack_trace_string->IsString() &&
v8::Local<v8::String>::Cast(stack_trace_string)->Length() > 0) {
- v8::String::Utf8Value stack_trace(stack_trace_string);
+ v8::String::Utf8Value stack_trace(isolate, stack_trace_string);
const char* stack_trace_string = ToCString(stack_trace);
fprintf(stderr, "%s\n", stack_trace_string);
}