OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "gin/runner.h" | 5 #include "gin/runner.h" |
6 | 6 |
7 #include "gin/converter.h" | 7 #include "gin/converter.h" |
8 | 8 |
9 using v8::Context; | 9 using v8::Context; |
10 using v8::Function; | 10 using v8::Function; |
(...skipping 26 matching lines...) Expand all Loading... |
37 void Runner::Run(Handle<Script> script) { | 37 void Runner::Run(Handle<Script> script) { |
38 script->Run(); | 38 script->Run(); |
39 Handle<Function> main = GetMain(); | 39 Handle<Function> main = GetMain(); |
40 if (main.IsEmpty()) | 40 if (main.IsEmpty()) |
41 return; | 41 return; |
42 Handle<Value> argv[] = { delegate_->CreateRootObject(this) }; | 42 Handle<Value> argv[] = { delegate_->CreateRootObject(this) }; |
43 main->Call(global(), 1, argv); | 43 main->Call(global(), 1, argv); |
44 } | 44 } |
45 | 45 |
46 v8::Handle<v8::Function> Runner::GetMain() { | 46 v8::Handle<v8::Function> Runner::GetMain() { |
47 Handle<Value> property = global()->Get(StringToV8(isolate_, "main")); | 47 Handle<Value> property = global()->Get(StringToSymbol(isolate_, "main")); |
48 if (property.IsEmpty()) | 48 if (property.IsEmpty()) |
49 return v8::Handle<v8::Function>(); | 49 return v8::Handle<v8::Function>(); |
50 Handle<Function> main; | 50 Handle<Function> main; |
51 if (!ConvertFromV8(property, &main)) | 51 if (!ConvertFromV8(property, &main)) |
52 return v8::Handle<v8::Function>(); | 52 return v8::Handle<v8::Function>(); |
53 return main; | 53 return main; |
54 } | 54 } |
55 | 55 |
56 Runner::Scope::Scope(Runner* runner) | 56 Runner::Scope::Scope(Runner* runner) |
57 : handle_scope_(runner->isolate_), | 57 : handle_scope_(runner->isolate_), |
58 scope_(Local<Context>::New(runner->isolate_, runner->context_)) { | 58 scope_(Local<Context>::New(runner->isolate_, runner->context_)) { |
59 } | 59 } |
60 | 60 |
61 Runner::Scope::~Scope() { | 61 Runner::Scope::~Scope() { |
62 } | 62 } |
63 | 63 |
64 } // namespace gin | 64 } // namespace gin |
OLD | NEW |