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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl

Issue 830593003: Update mojo sdk to rev 9fbbc4f0fef1187312316c0ed992342474e139f1 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cherry-pick mojo 9d3b8dd17f12d20035a14737fdc38dd926890ff8 Created 5 years, 11 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: mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
new file mode 100644
index 0000000000000000000000000000000000000000..91ea7cf70f7ccf7fc09de9f85f44693db8f404d2
--- /dev/null
+++ b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_declaration.tmpl
@@ -0,0 +1,50 @@
+class {{union.name}} {
+ public:
+ typedef internal::{{union.name}}_Data Data_;
+ typedef Data_::{{union.name}}_Tag Tag;
+
+ static {{union.name}}Ptr New();
+
+ template <typename U>
+ static {{union.name}}Ptr From(const U& u) {
+ return mojo::TypeConverter<{{union.name}}Ptr, U>::Convert(u);
+ }
+
+ template <typename U>
+ U To() const {
+ return mojo::TypeConverter<U, {{union.name}}>::Convert(*this);
+ }
+
+ {{union.name}}();
+ ~{{union.name}}();
+
+{% if union|is_cloneable_kind %}
+ {{union.name}}Ptr Clone() const;
+{%- endif %}
+ bool Equals(const {{union.name}}& other) const;
+
+ Tag which() const {
+ return tag_;
+ }
+
+{% for field in union.fields %}
+ bool is_{{field.name}}() const;
+ {{field.kind|cpp_result_type}} get_{{field.name}}() const;
+ void set_{{field.name}}({{field.kind|cpp_const_wrapper_type}} {{field.name}});
+{%- endfor %}
+
+ private:
+ friend class mojo::internal::UnionAccessor<{{union.name}}>;
+ union Union_ {
+ Union_() {}
+ ~Union_() {}
+{% for field in union.fields %}
+ {{field.kind|cpp_wrapper_type}} {{field.name}};
+{%- endfor %}
+ };
+ void SwitchActive(Tag new_active);
+ void SetActive(Tag new_active);
+ void DestroyActive();
+ Tag tag_;
+ Union_ data_;
+};

Powered by Google App Engine
This is Rietveld 408576698