Chromium Code Reviews| Index: Source/bindings/templates/callback.cpp |
| diff --git a/Source/bindings/templates/callback.cpp b/Source/bindings/templates/callback.cpp |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0018629935a07500e80274df7532c0cf6bed0229 |
| --- /dev/null |
| +++ b/Source/bindings/templates/callback.cpp |
| @@ -0,0 +1,89 @@ |
| +/* |
| + This file is part of the Blink open source project. |
|
haraken
2013/07/26 02:03:30
Ditto. Please use a proper copyright.
|
| + This file has been auto-generated by CodeGeneratorV8.pm. DO NOT MODIFY! |
| + |
| + This library is free software; you can redistribute it and/or |
| + modify it under the terms of the GNU Library General Public |
| + License as published by the Free Software Foundation; either |
| + version 2 of the License, or (at your option) any later version. |
| + |
| + This library is distributed in the hope that it will be useful, |
| + but WITHOUT ANY WARRANTY; without even the implied warranty of |
| + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| + Library General Public License for more details. |
| + |
| + You should have received a copy of the GNU Library General Public License |
| + along with this library; see the file COPYING.LIB. If not, write to |
| + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| + Boston, MA 02111-1307, USA. |
| +*/ |
| + |
| +#include "config.h" |
| +{% if conditional_string %} |
| +#if {{conditional_string}} |
| +{% endif %} |
| +#include "{{v8_class_name}}.h" |
| + |
| +{% for filename in implementation_includes %} |
| +#include "{{filename}}" |
| +{% endfor %} |
|
haraken
2013/07/26 02:03:30
Nit: One empty line please below this line.
|
| +namespace WebCore { |
| + |
| +{{v8_class_name}}::{{v8_class_name}}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context) |
| + : ActiveDOMCallback(context) |
| + , m_callback(callback) |
| + , m_world(DOMWrapperWorld::current()) |
| +{ |
| +} |
| + |
| +{{v8_class_name}}::~{{v8_class_name}}() |
| +{ |
| +} |
| + |
| +// Functions |
|
haraken
2013/07/26 02:03:30
Nit: I'd remove this comment.
|
| + |
| +{% for function in functions %} |
| +{% if not function.custom %} |
| +{{function["return_type"]}} {{v8_class_name}}::{{function["name"]}}({{function["parameter_declaration"]}}) |
| +{ |
| + if (!canInvokeCallback()) |
| + return true; |
| + |
| + v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| + v8::HandleScope handleScope(isolate); |
| + |
| + v8::Handle<v8::Context> v8Context = toV8Context(scriptExecutionContext(), m_world.get()); |
| + if (v8Context.IsEmpty()) |
| + return true; |
| + |
| + v8::Context::Scope scope(v8Context); |
| + |
| +{% for parameter in function["parameters"] %} |
| + {{parameter["native_to_js_value_statement"] | indent(4)}} |
|
haraken
2013/07/26 02:03:30
Looks like "native_to_js_value_statement" is not d
kojih
2013/07/26 07:18:38
Removed this block since parameters are not suppor
|
| + if ({{parameter["name"]}}Handle.IsEmpty()) { |
| + if (!isScriptControllerTerminating()) |
| + CRASH(); |
| + return true; |
| + } |
| + {% endfor %} |
|
haraken
2013/07/26 02:03:30
Nit: Wrong indentation.
|
| + |
| +{% if function["parameters"] | length > 0 %} |
| + v8::Handle<v8::Value> argv[] = { |
| + {{function["handles"] | indent(8)}} |
| + }; |
| +{% else %} |
| + v8::Handle<v8::Value> *argv = 0; |
| +{% endif %} |
| + |
| + bool callbackReturnValue = false; |
| + return !invokeCallback(m_callback.newLocal(isolate), {{function["parameters"]|length}}, argv, callbackReturnValue, scriptExecutionContext()); |
|
haraken
2013/07/26 02:03:30
Nit: Spaces are needed around '|'.
|
| +} |
| + |
| +{% endif %} |
| +{% endfor %} |
|
haraken
2013/07/26 02:03:30
Nit: You might want to add a jinja comment about w
|
| +} // namespace WebCore |
| + |
| +{% if conditional_string %} |
| +#endif // {{conditional_string}} |
| +{% endif %} |
| + |