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

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

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 class {{union.name}} {
2 public:
3 using Data_ = internal::{{union.name}}_Data;
4 using Tag = Data_::{{union.name}}_Tag;
5
6 static {{union.name}}Ptr New();
7
8 template <typename U>
9 static {{union.name}}Ptr From(const U& u) {
10 return mojo::TypeConverter<{{union.name}}Ptr, U>::Convert(u);
11 }
12
13 template <typename U>
14 U To() const {
15 return mojo::TypeConverter<U, {{union.name}}>::Convert(*this);
16 }
17
18 {{union.name}}();
19 ~{{union.name}}();
20
21 {% if union|is_cloneable_kind %}
22 {{union.name}}Ptr Clone() const;
23 {%- endif %}
24 bool Equals(const {{union.name}}& other) const;
25
26 Tag which() const {
27 return tag_;
28 }
29
30 {% for field in union.fields %}
31 bool is_{{field.name}}() const;
32 {{field.kind|cpp_union_getter_return_type}} get_{{field.name}}() const;
33 void set_{{field.name}}({{field.kind|cpp_const_wrapper_type}} {{field.name}});
34 {%- endfor %}
35 bool has_unknown_tag() const;
36
37 private:
38 friend class mojo::internal::UnionAccessor<{{union.name}}>;
39 union Union_ {
40 Union_() {}
41 ~Union_() {}
42 {% for field in union.fields %}
43 {% if field.kind|is_object_kind or field.kind|is_any_handle_kind
44 or field.kind|is_interface_kind -%}
45 {{field.kind|cpp_wrapper_type}}* {{field.name}};
46 {% else -%}
47 {{field.kind|cpp_wrapper_type}} {{field.name}};
48 {% endif -%}
49 {%- endfor %}
50 };
51 void SwitchActive(Tag new_active);
52 void SetActive(Tag new_active);
53 void DestroyActive();
54 Tag tag_;
55 Union_ data_;
56 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698