| OLD | NEW |
| 1 {# http://www.chromium.org/blink/coding-style#TOC-License #} | 1 {# http://www.chromium.org/blink/coding-style#TOC-License #} |
| 2 /* | 2 /* |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 | 34 |
| 35 #include "config.h" | 35 #include "config.h" |
| 36 {% filter conditional(conditional_string) %} | 36 {% filter conditional(conditional_string) %} |
| 37 #include "{{v8_class}}.h" | 37 #include "{{v8_class}}.h" |
| 38 | 38 |
| 39 {% for filename in cpp_includes %} | 39 {% for filename in cpp_includes %} |
| 40 #include "{{filename}}" | 40 #include "{{filename}}" |
| 41 {% endfor %} | 41 {% endfor %} |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 {{v8_class}}::{{v8_class}}(v8::Handle<v8::Object> callback, ExecutionContext* co
ntext) | 44 {{v8_class}}::{{v8_class}}(v8::Handle<v8::Function> callback, ExecutionContext*
context) |
| 45 : ActiveDOMCallback(context) | 45 : ActiveDOMCallback(context) |
| 46 , m_callback(toIsolate(context), callback) | 46 , m_callback(toIsolate(context), callback) |
| 47 , m_world(DOMWrapperWorld::current()) | 47 , m_world(DOMWrapperWorld::current()) |
| 48 { | 48 { |
| 49 } | 49 } |
| 50 | 50 |
| 51 {{v8_class}}::~{{v8_class}}() | 51 {{v8_class}}::~{{v8_class}}() |
| 52 { | 52 { |
| 53 } | 53 } |
| 54 | 54 |
| 55 {% for method in methods if not method.custom %} | 55 {% for method in methods if not method.custom %} |
| 56 {{method.return_cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_decla
rations | join(', ')}}) | 56 {{method.return_cpp_type}} {{v8_class}}::{{method.name}}({{method.argument_decla
rations | join(', ')}}) |
| 57 { | 57 { |
| 58 {% set return_default = 'return true' |
| 59 if method.return_idl_type == 'boolean' else 'return' %}{# void #} |
| 58 if (!canInvokeCallback()) | 60 if (!canInvokeCallback()) |
| 59 return true; | 61 {{return_default}}; |
| 60 | 62 |
| 61 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 63 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 62 v8::HandleScope handleScope(isolate); | 64 v8::HandleScope handleScope(isolate); |
| 63 | 65 |
| 64 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); | 66 v8::Handle<v8::Context> v8Context = toV8Context(executionContext(), m_world.
get()); |
| 65 if (v8Context.IsEmpty()) | 67 if (v8Context.IsEmpty()) |
| 66 return true; | 68 {{return_default}}; |
| 67 | 69 |
| 68 v8::Context::Scope scope(v8Context); | 70 v8::Context::Scope scope(v8Context); |
| 69 {% if method.call_with_this_handle %} | 71 {% if method.call_with_this_handle %} |
| 70 v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); | 72 v8::Handle<v8::Value> thisHandle = thisValue.v8Value(); |
| 71 if (thisHandle.IsEmpty()) { | 73 if (thisHandle.IsEmpty()) { |
| 72 if (!isScriptControllerTerminating()) | 74 if (!isScriptControllerTerminating()) |
| 73 CRASH(); | 75 CRASH(); |
| 74 return true; | 76 {{return_default}}; |
| 75 } | 77 } |
| 76 ASSERT(thisHandle->IsObject()); | 78 ASSERT(thisHandle->IsObject()); |
| 77 {% endif %} | 79 {% endif %} |
| 78 {% for argument in method.arguments %} | 80 {% for argument in method.arguments %} |
| 79 {{argument.cpp_to_v8_conversion | indent}} | 81 {{argument.cpp_to_v8_conversion | indent}} |
| 80 if ({{argument.name}}Handle.IsEmpty()) { | 82 if ({{argument.name}}Handle.IsEmpty()) { |
| 81 if (!isScriptControllerTerminating()) | 83 if (!isScriptControllerTerminating()) |
| 82 CRASH(); | 84 CRASH(); |
| 83 return true; | 85 {{return_default}}; |
| 84 } | 86 } |
| 85 {% endfor %} | 87 {% endfor %} |
| 86 {% if method.arguments %} | 88 {% if method.arguments %} |
| 87 v8::Handle<v8::Value> argv[] = { {{method.handles | join(', ')}} }; | 89 v8::Handle<v8::Value> argv[] = { {{method.handles | join(', ')}} }; |
| 88 {% else %} | 90 {% else %} |
| 89 v8::Handle<v8::Value> *argv = 0; | 91 v8::Handle<v8::Value> *argv = 0; |
| 90 {% endif %} | 92 {% endif %} |
| 91 | 93 |
| 92 bool callbackReturnValue = false; | |
| 93 {% set this_handle_parameter = 'v8::Handle<v8::Object>::Cast(thisHandle), '
if method.call_with_this_handle else '' %} | 94 {% set this_handle_parameter = 'v8::Handle<v8::Object>::Cast(thisHandle), '
if method.call_with_this_handle else '' %} |
| 94 return !invokeCallback(m_callback.newLocal(isolate), {{this_handle_parameter
}}{{method.arguments | length}}, argv, callbackReturnValue, executionContext(),
isolate); | 95 {% if method.return_idl_type == 'boolean' %} |
| 96 return invokeCallback(m_callback.newLocal(isolate), {{this_handle_parameter}
}{{method.arguments | length}}, argv, executionContext(), isolate); |
| 97 {% else %}{# void #} |
| 98 invokeCallback(m_callback.newLocal(isolate), {{this_handle_parameter}}{{meth
od.arguments | length}}, argv, executionContext(), isolate); |
| 99 {% endif %} |
| 95 } | 100 } |
| 96 | 101 |
| 97 {% endfor %} | 102 {% endfor %} |
| 98 } // namespace WebCore | 103 } // namespace WebCore |
| 99 {% endfilter %} | 104 {% endfilter %} |
| OLD | NEW |