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

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

Issue 814543006: Move //mojo/{public, edk} underneath //third_party (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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_definition.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
deleted file mode 100644
index bab528c65ff8b39f0addae2d7396857d964a6b45..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/cpp_templates/wrapper_union_class_definition.tmpl
+++ /dev/null
@@ -1,96 +0,0 @@
-// static
-{{union.name}}Ptr {{union.name}}::New() {
- {{union.name}}Ptr rv;
- mojo::internal::StructHelper<{{union.name}}>::Initialize(&rv);
- return rv.Pass();
-}
-
-{{union.name}}::{{union.name}}() {
- // TODO(azani): Implement default values here when/if we support them.
- // TODO(azani): Set to UNKNOWN when unknown is implemented.
- SetActive(static_cast<Tag>(0));
-}
-
-{{union.name}}::~{{union.name}}() {
- DestroyActive();
-}
-
-{% if union|is_cloneable_kind %}
-{{union.name}}Ptr {{union.name}}::Clone() const {
- {{union.name}}Ptr rv(New());
- switch (tag_) {
-{% for field in union.fields %}
- case Tag::{{field.name|upper}}:
- rv->set_{{field.name}}(data_.{{field.name}});
- break;
-{%- endfor %}
- };
- return rv.Pass();
-}
-{%- endif %}
-
-bool {{union.name}}::Equals(const {{union.name}}& other) const {
- if (tag_ != other.which()) {
- return false;
- }
-
- switch (tag_) {
-{% for field in union.fields %}
- case Tag::{{field.name|upper}}:
- return mojo::internal::ValueTraits<{{field.kind|cpp_wrapper_type}}>::Equals(data_.{{field.name}}, other.get_{{field.name}}());
-{%- endfor %}
- };
-
- return false;
-}
-
-{% for field in union.fields %}
-bool {{union.name}}::is_{{field.name}}() const {
- return tag_ == Tag::{{field.name|upper}};
-}
-
-{{field.kind|cpp_result_type}} {{union.name}}::get_{{field.name}}() const {
- MOJO_DCHECK(tag_ == Tag::{{field.name|upper}});
- return data_.{{field.name}};
-}
-
-void {{union.name}}::set_{{field.name}}({{field.kind|cpp_const_wrapper_type}} {{field.name}}) {
- SwitchActive(Tag::{{field.name|upper}});
- data_.{{field.name}} = {{field.name}};
-}
-{%- endfor %}
-
-void {{union.name}}::SwitchActive(Tag new_active) {
- if (new_active == tag_) {
- return;
- }
-
- DestroyActive();
- SetActive(new_active);
-}
-
-void {{union.name}}::SetActive(Tag new_active) {
- switch (new_active) {
-{% for field in union.fields %}
- case Tag::{{field.name|upper}}:
-{% if field.kind|is_string_kind %}
- new (&data_.{{field.name}}) String();
-{%- endif %}
- break;
-{%- endfor %}
- }
-
- tag_ = new_active;
-}
-
-void {{union.name}}::DestroyActive() {
- switch (tag_) {
-{% for field in union.fields %}
- case Tag::{{field.name|upper}}:
-{% if field.kind|is_string_kind %}
- data_.{{field.name}}.~String();
-{%- endif %}
- break;
-{%- endfor %}
- }
-}

Powered by Google App Engine
This is Rietveld 408576698