Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main(int argc, char* argv[])
- {
- string file = removeExe(argv[0]);
- file.append("init.js");
- cout << file << endl;
- Isolate* isolate = Isolate::GetCurrent();
- HandleScope handle_scope(isolate);
- // ----------------------------------------------------------
- // Global object
- Handle<ObjectTemplate> global = ObjectTemplate::New(isolate);
- global->Set(String::NewFromUtf8(isolate, "print"), FunctionTemplate::New(isolate, Print));
- global->Set(String::NewFromUtf8(isolate, "exit"), FunctionTemplate::New(isolate, Exit));
- global->Set(String::NewFromUtf8(isolate, "waitpress"), FunctionTemplate::New(isolate, Getch));
- global->Set(String::NewFromUtf8(isolate, "myname"), FunctionTemplate::New(isolate, MyName));
- global->Set(String::NewFromUtf8(isolate, "clearscreen"), FunctionTemplate::New(isolate, ClearScreen));
- global->Set(String::NewFromUtf8(isolate, "tochar"), FunctionTemplate::New(isolate, ToChar));
- // ----------------------------------------------------------
- Handle<Context> context = Context::New(isolate, NULL, global);
- Persistent<Context> persistent_context(isolate, context);
- Context::Scope context_scope(context);
- Handle<String> source_obj = ReadFile(isolate, file);
- Handle<Script> script_obj = Script::Compile(source_obj);
- Handle<Value> local_result = script_obj->Run();
- String::Utf8Value utf8(local_result);
- printf("Result: %s\n", utf8);
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement