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

Unified Diff: sky/engine/bindings2/scripts/templates/callback_interface_cpp.template

Issue 914413004: Add a new bindings2/scripts directory for Dart bindings (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Remove idlrenderer.py it's not used Created 5 years, 10 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: sky/engine/bindings2/scripts/templates/callback_interface_cpp.template
diff --git a/sky/engine/bindings2/scripts/templates/callback_interface_cpp.template b/sky/engine/bindings2/scripts/templates/callback_interface_cpp.template
new file mode 100644
index 0000000000000000000000000000000000000000..979ec6f5877b0c42f7cd0112338dd467baa222f5
--- /dev/null
+++ b/sky/engine/bindings2/scripts/templates/callback_interface_cpp.template
@@ -0,0 +1,49 @@
+// Copyright 2014 The Dartium 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_dart}}. DO NOT MODIFY!
+
+#include "sky/engine/config.h"
+#include "{{dart_class}}.h"
+
+{% for filename in cpp_includes %}
+#include "{{filename}}"
+{% endfor %}
+
+#include "sky/engine/tonic/dart_api_scope.h"
+#include "sky/engine/tonic/dart_converter.h"
+#include "sky/engine/tonic/dart_isolate_scope.h"
+
+namespace blink {
+
+{% for method in methods if not method.custom %}
+{{method.cpp_type}} {{dart_class}}::{{method.name}}({{method.argument_declarations | join(', ')}})
+{
+ {% set return_default = 'return true'
+ if method.idl_type == 'boolean' else 'return' %}{# void #}
+ if (!callback_.IsIsolateAlive())
+ {{return_default}};
+ DartIsolateScope scope(callback_.GetIsolate());
+ DartApiScope apiScope;
+ {% if method.call_with_this_handle %}
+ // FIXME: we ignore thisValue which may or may not be correct for Dart.
+ {% endif %}
+ {% for argument in method.arguments %}
+ Dart_Handle {{argument.handle}} = {{argument.cpp_value_to_dart_value}};
+ if (Dart_IsError({{argument.handle}}))
+ {{return_default}};
+ {% endfor %}
+ {% if method.arguments %}
+ Dart_Handle arguments[] = { {{method.arguments | join(', ', attribute='handle')}} };
+ {% else %}
+ Dart_Handle *arguments = 0;
+ {% endif %}
+
+ {% set return_with = 'return'
+ if method.idl_type == 'boolean' else '' %}{# void #}
+ {{return_with}} callback_.handleEvent({{method.arguments | length}}, arguments);
+}
+
+{% endfor %}
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698