I'm using the v8 in the program of VC++.
I used a shell.cc of sample files v8_shell of v8 source, modify the source code.
I try to output the value of the result of executing the javascript read the js file.
Function, use the Function Template, and outputs the value of the results. However variable are not output the value of the results.
I to receiving the value of the variable, knows that it is necessary to use the Accessor.
Homepage
I was referring to the home page of the link, but the description is not the attitude.
An example of how it is used is insufficient.
Portion to be a problem is the location.href of javascript.
Using the Accessor, but will try to output the url value, an error occurs.
The following is a source code that I have created.
Complete source ->
Test V8shell · GitHub
Compilation is not a problem, but not in the normal run.
Operation of the program is output to have been stopped.
v8::Local<v8::Context> CreateShellContext(v8::Isolate* isolate) {
v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
global->Set(
v8::String::NewFromUtf8(isolate, "print", v8::NewStringType::kNormal)
.ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Print));
global->Set(v8::String::NewFromUtf8(
isolate, "read", v8::NewStringType::kNormal).ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Read));
global->Set(v8::String::NewFromUtf8(
isolate, "load", v8::NewStringType::kNormal).ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Load));
global->Set(v8::String::NewFromUtf8(
isolate, "quit", v8::NewStringType::kNormal).ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Quit));
global->Set(
v8::String::NewFromUtf8(isolate, "version", v8::NewStringType::kNormal)
.ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Version));
global->Set(
v8::String::NewFromUtf8(isolate, "alert", v8::NewStringType::kNormal)
.ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Alert));
global->Set(
v8::String::NewFromUtf8(isolate, "prompt", v8::NewStringType::kNormal)
.ToLocalChecked(),
v8::FunctionTemplate::New(isolate, Prompt));
v8::Local<v8::ObjectTemplate> MLTempl = MakeLocationObjectTemplate(isolate);
v8::Local<v8::Object> MLObject = MLTempl->NewInstance();
global->Set(
v8::String::NewFromUtf8(isolate, "location", v8::NewStringType::kInternalized)
.ToLocalChecked(), MLObject);
return v8::Context::New(isolate, NULL, global);
}
Problem is, in the above code
v8 :: Local MLObject = MLTempl-> NewInstance (); occur in the part of .
And try to keep track of the error, in the end, an error occurs in the next part.
110 line
NATIVE_CONTEXT_FIELDS (NATIVE_CONTEXT_FIELD_ACCESSOR)
access error of isolate-inl.h is output.
how do i do this?
What I have tried:
google refer to the website, I tried to fix a look at the source of the previous version.