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

Unified Diff: sky/engine/bindings2/scripts/templates/callback_interface_h.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_h.template
diff --git a/sky/engine/bindings2/scripts/templates/callback_interface_h.template b/sky/engine/bindings2/scripts/templates/callback_interface_h.template
new file mode 100644
index 0000000000000000000000000000000000000000..25278dc7772419c0de52ba43884a0c3d5ee8f7a1
--- /dev/null
+++ b/sky/engine/bindings2/scripts/templates/callback_interface_h.template
@@ -0,0 +1,77 @@
+// 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!
+
+#ifndef {{dart_class}}_h
+#define {{dart_class}}_h
+
+{% for filename in header_includes %}
+#include "{{filename}}"
+{% endfor %}
+
+#include "sky/engine/tonic/dart_converter.h"
+#include "sky/engine/tonic/dart_state.h"
+#include "sky/engine/wtf/PassOwnPtr.h"
+
+namespace blink {
+
+class {{dart_class}} : public {{cpp_class}} {
+ public:
+ typedef {{dart_class}} NativeType;
+
+ static PassOwnPtr<NativeType> create(Dart_Handle object,
+ Dart_Handle& exception) {
+ return adoptPtr(new {{dart_class}}(object, exception));
+ }
+
+ static PassOwnPtr<NativeType> createWithNullCheck(Dart_Handle object,
+ Dart_Handle& exception) {
+ if (Dart_IsNull(object))
+ return PassOwnPtr<NativeType>();
+ return create(object, exception);
+ }
+
+ static PassOwnPtr<NativeType> create(Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ Dart_Handle object = Dart_GetNativeArgument(args, index);
+ return create(object, exception);
+ }
+
+ static PassOwnPtr<NativeType> createWithNullCheck(Dart_NativeArguments args,
+ int index,
+ Dart_Handle& exception) {
+ Dart_Handle object = Dart_GetNativeArgument(args, index);
+ if (Dart_IsNull(object))
+ return PassOwnPtr<NativeType>();
+ return create(object, exception);
+ }
+
+{% for method in methods %}
+ virtual {{method.cpp_type}} {{method.name}}({{method.argument_declarations | join(', ')}}) override;
+{% endfor %}
+ private:
+ {{dart_class}}(Dart_Handle object, Dart_Handle& exception)
+ : callback_(DartState::Current(), object, exception) {
+ }
+
+ DartCallback callback_;
+};
+
+template <>
+struct DartConverter<{{ cpp_class }}*> {
+ static PassOwnPtr<{{dart_class}}> FromArguments(
+ Dart_NativeArguments args, int index, Dart_Handle& exception) {
+ return {{dart_class}}::create(args, index, exception);
+ }
+
+ static PassOwnPtr<{{dart_class}}> FromArgumentsWithNullCheck(
+ Dart_NativeArguments args, int index, Dart_Handle& exception) {
+ return {{dart_class}}::createWithNullCheck(args, index, exception);
+ }
+};
+
+} // blink
+#endif // {{dart_class}}_h

Powered by Google App Engine
This is Rietveld 408576698