| Index: gin/runner.cc
|
| diff --git a/gin/runner.cc b/gin/runner.cc
|
| index ec701b7e5a320ced9cf577a8d2bfaf867ebb7629..4b0b6f9b69d3562733b319439e2904915198bc1b 100644
|
| --- a/gin/runner.cc
|
| +++ b/gin/runner.cc
|
| @@ -7,55 +7,52 @@
|
| #include "gin/converter.h"
|
|
|
| using v8::Context;
|
| -using v8::Function;
|
| using v8::Handle;
|
| using v8::HandleScope;
|
| using v8::Isolate;
|
| -using v8::Local;
|
| using v8::Object;
|
| +using v8::ObjectTemplate;
|
| using v8::Script;
|
| -using v8::String;
|
| -using v8::Value;
|
|
|
| namespace gin {
|
|
|
| +RunnerDelegate::RunnerDelegate() {
|
| +}
|
| +
|
| RunnerDelegate::~RunnerDelegate() {
|
| }
|
|
|
| +Handle<ObjectTemplate> RunnerDelegate::GetGlobalTemplate(Runner* runner) {
|
| + return Handle<ObjectTemplate>();
|
| +}
|
| +
|
| +void RunnerDelegate::DidCreateContext(Runner* runner) {
|
| +}
|
| +
|
| Runner::Runner(RunnerDelegate* delegate, Isolate* isolate)
|
| - : delegate_(delegate),
|
| - isolate_(isolate) {
|
| - HandleScope handle_scope(isolate_);
|
| - context_.Reset(isolate_, Context::New(isolate_));
|
| + : ContextHolder(isolate),
|
| + delegate_(delegate) {
|
| + HandleScope handle_scope(isolate);
|
| + SetContext(Context::New(isolate, NULL, delegate_->GetGlobalTemplate(this)));
|
| +
|
| + v8::Context::Scope scope(context());
|
| + delegate_->DidCreateContext(this);
|
| }
|
|
|
| Runner::~Runner() {
|
| - // TODO(abarth): Figure out how to set kResetInDestructor to true.
|
| - context_.Reset();
|
| }
|
|
|
| -void Runner::Run(Handle<Script> script) {
|
| - script->Run();
|
| - Handle<Function> main = GetMain();
|
| - if (main.IsEmpty())
|
| - return;
|
| - Handle<Value> argv[] = { delegate_->CreateRootObject(this) };
|
| - main->Call(global(), 1, argv);
|
| +void Runner::Run(const std::string& script) {
|
| + Run(Script::New(StringToV8(isolate(), script)));
|
| }
|
|
|
| -v8::Handle<v8::Function> Runner::GetMain() {
|
| - Handle<Value> property = global()->Get(StringToSymbol(isolate_, "main"));
|
| - if (property.IsEmpty())
|
| - return v8::Handle<v8::Function>();
|
| - Handle<Function> main;
|
| - if (!ConvertFromV8(property, &main))
|
| - return v8::Handle<v8::Function>();
|
| - return main;
|
| +void Runner::Run(Handle<Script> script) {
|
| + script->Run();
|
| }
|
|
|
| Runner::Scope::Scope(Runner* runner)
|
| - : handle_scope_(runner->isolate_),
|
| - scope_(Local<Context>::New(runner->isolate_, runner->context_)) {
|
| + : handle_scope_(runner->isolate()),
|
| + scope_(runner->context()) {
|
| }
|
|
|
| Runner::Scope::~Scope() {
|
|
|