OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "bindings/core/v8/ScriptFunction.h" | 5 #include "bindings/core/v8/ScriptFunction.h" |
6 | 6 |
7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 v8::Local<v8::Function> ScriptFunction::bindToV8Function() | 11 v8::Local<v8::Function> ScriptFunction::bindToV8Function() |
12 { | 12 { |
13 v8::Isolate* isolate = m_scriptState->isolate(); | 13 v8::Isolate* isolate = m_scriptState->isolate(); |
14 v8::Local<v8::External> wrapper = v8::External::New(isolate, this); | 14 v8::Local<v8::External> wrapper = v8::External::New(isolate, this); |
15 m_scriptState->world().registerDOMObjectHolder(isolate, this, wrapper); | 15 m_scriptState->world().registerDOMObjectHolder(isolate, this, wrapper); |
16 return createClosure(&ScriptFunction::callCallback, wrapper, isolate); | 16 return createClosure(&ScriptFunction::callCallback, wrapper, isolate); |
17 } | 17 } |
18 | 18 |
19 void ScriptFunction::callCallback(const v8::FunctionCallbackInfo<v8::Value>& arg
s) | 19 void ScriptFunction::callCallback(const v8::FunctionCallbackInfo<v8::Value>& arg
s) |
20 { | 20 { |
21 ASSERT(args.Data()->IsExternal()); | 21 ASSERT(args.Data()->IsExternal()); |
22 ScriptFunction* scriptFunction = static_cast<ScriptFunction*>(v8::Local<v8::
External>::Cast(args.Data())->Value()); | 22 ScriptFunction* scriptFunction = static_cast<ScriptFunction*>(v8::Local<v8::
External>::Cast(args.Data())->Value()); |
23 ScriptValue result = scriptFunction->call(ScriptValue(scriptFunction->script
State(), args[0])); | 23 ScriptValue result = scriptFunction->call(ScriptValue(scriptFunction->getScr
iptState(), args[0])); |
24 v8SetReturnValue(args, result.v8Value()); | 24 v8SetReturnValue(args, result.v8Value()); |
25 } | 25 } |
26 | 26 |
27 } // namespace blink | 27 } // namespace blink |
OLD | NEW |