Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(333)

Unified Diff: Source/bindings/templates/private_script_interface.cpp

Issue 345893002: Implement an infrastructure of Blink-in-JS Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/templates/private_script_interface.h ('k') | Source/bindings/templates/templates.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/private_script_interface.cpp
diff --git a/Source/bindings/templates/private_script_interface.cpp b/Source/bindings/templates/private_script_interface.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..af5b25a0db813f70d0f26166c0c2ce4a324153f3
--- /dev/null
+++ b/Source/bindings/templates/private_script_interface.cpp
@@ -0,0 +1,60 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file has been auto-generated by {{code_generator}}. DO NOT MODIFY!
+
+#include "config.h"
+{% filter conditional(conditional_string) %}
+#include "{{v8_class}}.h"
+
+{% for filename in cpp_includes %}
+#include "{{filename}}"
+{% endfor %}
+
+namespace WebCore {
+
+{% for method in methods %}
+bool {{v8_class}}::{{method.name}}({{method.argument_declarations | join(', ')}})
+{
+ v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::privateScriptWorld());
+ if (context.IsEmpty())
+ return false;
+ ScriptState* scriptState = ScriptState::from(context);
+ if (!scriptState->executionContext() || !scriptState->domWindow())
+ return false;
+
+ ScriptState::Scope scope(scriptState);
+ v8::Handle<v8::Value> windowWrapper = toV8(scriptState->domWindow(), scriptState->context()->Global(), scriptState->isolate());
+
+ {% for argument in method.arguments %}
+ v8::Handle<v8::Value> {{argument.handle}} = {{argument.cpp_value_to_v8_value}};
+ {% endfor %}
+ {% if method.arguments %}
+ v8::Handle<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
+ {% else %}
+ {# Empty array initializers are illegal in MSVC. #}
+ v8::Handle<v8::Value> *argv = 0;
+ {% endif %}
+ // FIXME: Support exceptions thrown from Blink-in-JS.
+ v8::TryCatch block;
+ {% if method.v8_value_to_cpp_value %}
+ v8::Handle<v8::Value> v8Value = PrivateScriptController::run(scriptState, "{{cpp_class}}", "{{method.name}}", windowWrapper, {{method.arguments | length}}, argv);
+ if (block.HasCaught())
+ return false;
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "{{method.name}}", "{{cpp_class}}", scriptState->context()->Global(), scriptState->isolate());
+ {{method.cpp_type}} cppValue = {{method.v8_value_to_cpp_value}};
+ if (block.HasCaught())
+ return false;
+ *output = cppValue;
+ {% else %}{# void return type #}
+ PrivateScriptController::run(scriptState, "{{cpp_class}}", "{{method.name}}", windowWrapper, {{method.arguments | length}}, argv);
+ if (block.HasCaught())
+ return false;
+ {% endif %}
+ return true;
+}
+
+{% endfor %}
+} // namespace WebCore
+{% endfilter %}
« no previous file with comments | « Source/bindings/templates/private_script_interface.h ('k') | Source/bindings/templates/templates.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698