blob: 4b0b6f9b69d3562733b319439e2904915198bc1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "gin/runner.h"
#include "gin/converter.h"
using v8::Context;
using v8::Handle;
using v8::HandleScope;
using v8::Isolate;
using v8::Object;
using v8::ObjectTemplate;
using v8::Script;
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)
: 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() {
}
void Runner::Run(const std::string& script) {
Run(Script::New(StringToV8(isolate(), script)));
}
void Runner::Run(Handle<Script> script) {
script->Run();
}
Runner::Scope::Scope(Runner* runner)
: handle_scope_(runner->isolate()),
scope_(runner->context()) {
}
Runner::Scope::~Scope() {
}
} // namespace gin
|