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

Unified Diff: mojo/public/tools/bindings/generators/cpp_templates/union_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 side-by-side diff with in-line comments
Download patch
Index: mojo/public/tools/bindings/generators/cpp_templates/union_declaration.tmpl
diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_declaration.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_declaration.tmpl
deleted file mode 100644
index eb7081cd572edf2765deb53748393ea595b51100..0000000000000000000000000000000000000000
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_declaration.tmpl
+++ /dev/null
@@ -1,57 +0,0 @@
-{%- set class_name = union.name ~ "_Data" -%}
-{%- set enum_name = union.name ~ "_Tag" -%}
-{%- import "struct_macros.tmpl" as struct_macros %}
-
-class {{class_name}} {
- public:
- // Used to identify Mojom Union Data Classes.
- typedef void MojomUnionDataType;
- static {{class_name}}* New(mojo::internal::Buffer* buf);
- {{class_name}}();
- // Do nothing in the destructor since it won't be called.
- ~{{class_name}}() {}
-
- static mojo::internal::ValidationError Validate(
- const void* data,
- mojo::internal::BoundsChecker* bounds_checker,
- bool inlined,
- std::string* err);
-
- bool is_null() const {
- return size == 0;
- }
-
- void set_null();
-
- enum class {{enum_name}} : uint32_t {
-{% for field in union.fields %}
- {{field.name|upper}},
-{%- endfor %}
- __UNKNOWN__ = 0xFFFFFFFF,
- };
-
- // A note on layout:
- // "Each non-static data member is allocated as if it were the sole member of
- // a struct." - Section 9.5.2 ISO/IEC 14882:2011 (The C++ Spec)
- union MOJO_ALIGNAS(8) Union_ {
-{%- for field in union.fields %}
-{%- if field.kind.spec == 'b' %}
- uint8_t f_{{field.name}} : 1;
-{%- else %}
- {{field.kind|cpp_union_field_type}} f_{{field.name}};
-{%- endif %}
-{%- endfor %}
- uint64_t unknown;
- };
-
- uint32_t size;
- {{enum_name}} tag;
- Union_ data;
-
- void EncodePointersAndHandles(std::vector<mojo::Handle>* handles);
- void DecodePointersAndHandles(std::vector<mojo::Handle>* handles);
-};
-static_assert(sizeof({{class_name}}) == 16,
- "Bad sizeof({{class_name}})");
-static_assert(sizeof({{class_name}}::Union_) == 8,
- "Bad sizeof({{class_name}}::Union_)");

Powered by Google App Engine
This is Rietveld 408576698