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

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

Issue 2064903002: Mojo: Report bindings validation errors via MojoNotifyBadMessage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 6 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
1 {%- set class_name = union.name ~ "_Data" -%} 1 {%- set class_name = union.name ~ "_Data" -%}
2 {%- set enum_name = union.name ~ "_Tag" -%} 2 {%- set enum_name = union.name ~ "_Tag" -%}
3 {%- import "struct_macros.tmpl" as struct_macros %} 3 {%- import "struct_macros.tmpl" as struct_macros %}
4 4
5 class {{class_name}} { 5 class {{class_name}} {
6 public: 6 public:
7 // Used to identify Mojom Union Data Classes. 7 // Used to identify Mojom Union Data Classes.
8 typedef void MojomUnionDataType; 8 typedef void MojomUnionDataType;
9 static {{class_name}}* New(mojo::internal::Buffer* buf); 9 static {{class_name}}* New(mojo::internal::Buffer* buf);
10 {{class_name}}(); 10 {{class_name}}();
11 // Do nothing in the destructor since it won't be called. 11 // Do nothing in the destructor since it won't be called.
12 ~{{class_name}}() {} 12 ~{{class_name}}() {}
13 13
14 static bool Validate(const void* data, 14 static bool Validate(const void* data,
15 mojo::internal::BoundsChecker* bounds_checker, 15 mojo::internal::ValidationContext* validation_context,
16 bool inlined); 16 bool inlined);
17 17
18 bool is_null() const { 18 bool is_null() const {
19 return size == 0; 19 return size == 0;
20 } 20 }
21 21
22 void set_null(); 22 void set_null();
23 23
24 enum class {{enum_name}} : uint32_t { 24 enum class {{enum_name}} : uint32_t {
25 {% for field in union.fields %} 25 {% for field in union.fields %}
(...skipping 17 matching lines...) Expand all
43 43
44 uint32_t size; 44 uint32_t size;
45 {{enum_name}} tag; 45 {{enum_name}} tag;
46 Union_ data; 46 Union_ data;
47 47
48 void EncodePointers(); 48 void EncodePointers();
49 void DecodePointers(); 49 void DecodePointers();
50 }; 50 };
51 static_assert(sizeof({{class_name}}) == mojo::internal::kUnionDataSize, 51 static_assert(sizeof({{class_name}}) == mojo::internal::kUnionDataSize,
52 "Bad sizeof({{class_name}})"); 52 "Bad sizeof({{class_name}})");
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698