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 |
index 6e6fe95a74c1dc207af7f5d252494a1936fd7e14..224a268711fde7591b7a0f5298f7eed2943e008f 100644 |
--- a/mojo/public/tools/bindings/generators/cpp_templates/union_declaration.tmpl |
+++ b/mojo/public/tools/bindings/generators/cpp_templates/union_declaration.tmpl |
@@ -5,9 +5,22 @@ |
class {{class_name}} { |
public: |
static {{class_name}}* New(mojo::internal::Buffer* buf); |
+ {{class_name}}(); |
+ // Do nothing in the destructor since it won't be called. |
+ ~{{class_name}}() {} |
+ |
+ static bool Validate(const void* data, |
+ mojo::internal::BoundsChecker* bounds_checker, |
+ bool claim_memory); |
yzshen1
2015/02/17 19:34:35
I think it seems nicer to name it |inlined| becaus
azani
2015/02/18 00:27:57
Done.
|
static bool Validate(const void* data, |
- mojo::internal::BoundsChecker* bounds_checker); |
+ mojo::internal::BoundsChecker* bounds_checker) { |
yzshen1
2015/02/17 19:34:35
Maybe we should remove this, so that if we don't h
azani
2015/02/18 00:27:57
Done.
|
+ return Validate(data, bounds_checker, true); |
+ } |
+ |
+ bool is_null() const { |
yzshen1
2015/02/17 19:34:35
This is not correct: when the union is non-inlined
azani
2015/02/18 00:27:57
I think I had a different understanding of the out
|
+ return (flags & 0x1) == 0; |
+ } |
enum class {{enum_name}} : uint32_t { |
{% for field in union.fields %} |
@@ -33,16 +46,12 @@ class {{class_name}} { |
uint64_t unknown; |
}; |
- uint32_t reserved; |
+ uint32_t flags; |
yzshen1
2015/02/17 19:34:35
The name |flags| seems confusing. It is the size o
azani
2015/02/18 00:27:57
See above. I thought we were just reserving the sp
|
{{enum_name}} tag; |
Union_ data; |
void EncodePointersAndHandles(std::vector<mojo::Handle>* handles); |
void DecodePointersAndHandles(std::vector<mojo::Handle>* handles); |
- |
- private: |
- {{class_name}}(); |
- ~{{class_name}}() = delete; |
}; |
static_assert(sizeof({{class_name}}) == 16, |
"Bad sizeof({{class_name}})"); |