| OLD | NEW |
| 1 {% filter format_blink_cpp_source_code %} | 1 {% filter format_blink_cpp_source_code %} |
| 2 | 2 |
| 3 {% include 'copyright_block.txt' %} | 3 {% include 'copyright_block.txt' %} |
| 4 #include "{{v8_class}}.h" | 4 #include "{{v8_class}}.h" |
| 5 | 5 |
| 6 {% for filename in cpp_includes %} | 6 {% for filename in cpp_includes %} |
| 7 #include "{{filename}}" | 7 #include "{{filename}}" |
| 8 {% endfor %} | 8 {% endfor %} |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| 11 | 11 |
| 12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script
State) | 12 {{v8_class}}::{{v8_class}}(v8::Local<v8::Function> callback, ScriptState* script
State) |
| 13 : m_scriptState(scriptState) { | 13 : m_scriptState(scriptState) { |
| 14 m_callback.set(scriptState->isolate(), callback); | 14 m_callback.Set(scriptState->GetIsolate(), callback); |
| 15 } | 15 } |
| 16 | 16 |
| 17 {{v8_class}}::~{{v8_class}}() {} | 17 {{v8_class}}::~{{v8_class}}() {} |
| 18 | 18 |
| 19 DEFINE_TRACE({{v8_class}}) { | 19 DEFINE_TRACE({{v8_class}}) { |
| 20 {{cpp_class}}::trace(visitor); | 20 {{cpp_class}}::Trace(visitor); |
| 21 } | 21 } |
| 22 | 22 |
| 23 {% for method in methods if not method.is_custom %} | 23 {% for method in methods if not method.is_custom %} |
| 24 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations
| join(', ')}}) { | 24 {{method.cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_declarations
| join(', ')}}) { |
| 25 {% set return_default = 'return true' | 25 {% set return_default = 'return true' |
| 26 if method.idl_type == 'boolean' else 'return' %}{# void #} | 26 if method.idl_type == 'boolean' else 'return' %}{# void #} |
| 27 ExecutionContext* executionContext = m_scriptState->getExecutionContext(); | 27 ExecutionContext* executionContext = m_scriptState->GetExecutionContext(); |
| 28 if (!executionContext || executionContext->isContextSuspended() || | 28 if (!executionContext || executionContext->IsContextSuspended() || |
| 29 executionContext->isContextDestroyed()) | 29 executionContext->IsContextDestroyed()) |
| 30 {{return_default}}; | 30 {{return_default}}; |
| 31 if (!m_scriptState->contextIsValid()) | 31 if (!m_scriptState->ContextIsValid()) |
| 32 {{return_default}}; | 32 {{return_default}}; |
| 33 | 33 |
| 34 ScriptState::Scope scope(m_scriptState.get()); | 34 ScriptState::Scope scope(m_scriptState.Get()); |
| 35 {% if method.call_with_this_handle %} | 35 {% if method.call_with_this_handle %} |
| 36 v8::Local<v8::Value> thisHandle = thisValue.v8Value(); | 36 v8::Local<v8::Value> thisHandle = thisValue.V8Value(); |
| 37 {% endif %} | 37 {% endif %} |
| 38 | 38 |
| 39 {% for argument in method.arguments %} | 39 {% for argument in method.arguments %} |
| 40 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}}; | 40 v8::Local<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}}; |
| 41 {% endfor %} | 41 {% endfor %} |
| 42 {% if method.arguments %} | 42 {% if method.arguments %} |
| 43 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} }; | 43 v8::Local<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} }; |
| 44 {% else %} | 44 {% else %} |
| 45 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} | 45 {# Empty array initializers are illegal, and don\'t compile in MSVC. #} |
| 46 v8::Local<v8::Value> *argv = 0; | 46 v8::Local<v8::Value> *argv = 0; |
| 47 {% endif %} | 47 {% endif %} |
| 48 | 48 |
| 49 v8::Isolate* isolate = m_scriptState->isolate(); | 49 v8::Isolate* isolate = m_scriptState->GetIsolate(); |
| 50 {% set this_handle_parameter = 'thisHandle' | 50 {% set this_handle_parameter = 'thisHandle' |
| 51 if method.call_with_this_handle else 'v8::Undefined(isolate)' %} | 51 if method.call_with_this_handle else 'v8::Undefined(isolate)' %} |
| 52 {% if method.idl_type == 'boolean' %} | 52 {% if method.idl_type == 'boolean' %} |
| 53 v8::TryCatch exceptionCatcher(isolate); | 53 v8::TryCatch exceptionCatcher(isolate); |
| 54 exceptionCatcher.SetVerbose(true); | 54 exceptionCatcher.SetVerbose(true); |
| 55 V8ScriptRunner::callFunction(m_callback.newLocal(isolate), | 55 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), |
| 56 executionContext, | 56 executionContext, |
| 57 {{this_handle_parameter}}, | 57 {{this_handle_parameter}}, |
| 58 {{method.arguments | length}}, | 58 {{method.arguments | length}}, |
| 59 argv, | 59 argv, |
| 60 isolate); | 60 isolate); |
| 61 return !exceptionCatcher.HasCaught(); | 61 return !exceptionCatcher.HasCaught(); |
| 62 {% else %}{# void #} | 62 {% else %}{# void #} |
| 63 V8ScriptRunner::callFunction(m_callback.newLocal(isolate), | 63 V8ScriptRunner::CallFunction(m_callback.NewLocal(isolate), |
| 64 m_scriptState->getExecutionContext(), | 64 m_scriptState->GetExecutionContext(), |
| 65 {{this_handle_parameter}}, | 65 {{this_handle_parameter}}, |
| 66 {{method.arguments | length}}, | 66 {{method.arguments | length}}, |
| 67 argv, | 67 argv, |
| 68 isolate); | 68 isolate); |
| 69 {% endif %} | 69 {% endif %} |
| 70 } | 70 } |
| 71 | 71 |
| 72 {% endfor %} | 72 {% endfor %} |
| 73 } // namespace blink | 73 } // namespace blink |
| 74 | 74 |
| 75 {% endfilter %}{# format_blink_cpp_source_code #} | 75 {% endfilter %}{# format_blink_cpp_source_code #} |
| OLD | NEW |