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

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
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..f7d2874464c8ec58067c7d241195e36897e9491f
--- /dev/null
+++ b/Source/bindings/templates/private_script_interface.cpp
@@ -0,0 +1,59 @@
+// 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);
+ ScriptState::Scope scope(scriptState);
+ LocalDOMWindow* window = scriptState->domWindow();
+ if (!window)
+ return false;
+ v8::Handle<v8::Value> windowWrapper = toV8(window, 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 %}
Nils Barth (inactive) 2014/06/23 03:14:30 Might be worth reminding people that empty array i
+ v8::Handle<v8::Value> argv[] = { {{method.arguments | join(', ', 'handle')}} };
+ {% else %}
+ 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 != '' %}
Nils Barth (inactive) 2014/06/23 03:14:30 Don't need to compare to '', right? (Implicit fals
+ v8::Handle<v8::Value> v8Value = PrivateScriptController::run(scriptState->isolate(), "{{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 %}
Nils Barth (inactive) 2014/06/23 03:14:30 {% else %}{# void return type #} ?
+ PrivateScriptController::run(scriptState->isolate(), "{{cpp_class}}", "{{method.name}}", windowWrapper, {{method.arguments | length}}, argv);
+ if (block.HasCaught())
+ return false;
+ {% endif %}
+ return true;
+}
+
+{% endfor %}
+} // namespace WebCore
+{% endfilter %}

Powered by Google App Engine
This is Rietveld 408576698