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

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

Issue 909903003: Remove unnecessary/unreachable |return| from generated union code. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 {%- import "validation_macros.tmpl" as validation_macros %} 1 {%- import "validation_macros.tmpl" as validation_macros %}
2 {%- set class_name = union.name ~ "_Data" %} 2 {%- set class_name = union.name ~ "_Data" %}
3 {%- set enum_name = union.name ~ "_Tag" -%} 3 {%- set enum_name = union.name ~ "_Tag" -%}
4 4
5 // static 5 // static
6 {{class_name}}* {{class_name}}::New(mojo::internal::Buffer* buf) { 6 {{class_name}}* {{class_name}}::New(mojo::internal::Buffer* buf) {
7 return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}(); 7 return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}();
8 } 8 }
9 9
10 // static 10 // static
(...skipping 13 matching lines...) Expand all
24 mojo::internal::VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE); 24 mojo::internal::VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE);
25 return false; 25 return false;
26 } 26 }
27 const {{class_name}}* object = static_cast<const {{class_name}}*>(data); 27 const {{class_name}}* object = static_cast<const {{class_name}}*>(data);
28 MOJO_ALLOW_UNUSED_LOCAL(object); 28 MOJO_ALLOW_UNUSED_LOCAL(object);
29 29
30 switch (object->tag) { 30 switch (object->tag) {
31 {% for field in union.fields %} 31 {% for field in union.fields %}
32 case {{enum_name}}::{{field.name|upper}}: 32 case {{enum_name}}::{{field.name|upper}}:
33 {{ validation_macros.validate_union_field(field, union)|indent(6) }} 33 {{ validation_macros.validate_union_field(field, union)|indent(6) }}
34 break;
35 {%- endfor %} 34 {%- endfor %}
36 default: 35 default:
37 ReportValidationError( 36 ReportValidationError(
38 mojo::internal::VALIDATION_ERROR_UNKOWN_UNION_TAG, 37 mojo::internal::VALIDATION_ERROR_UNKOWN_UNION_TAG,
39 "unknown tag in {{union.name}}"); 38 "unknown tag in {{union.name}}");
40 return false; 39 return false;
41 }; 40 }
42
43 return true;
44 } 41 }
45 42
46 {{class_name}}::{{class_name}}() { 43 {{class_name}}::{{class_name}}() {
47 } 44 }
48 45
49 void {{class_name}}::EncodePointersAndHandles( 46 void {{class_name}}::EncodePointersAndHandles(
50 std::vector<mojo::Handle>* handles) { 47 std::vector<mojo::Handle>* handles) {
51 // TODO(azani): Implement pointers and handles. 48 // TODO(azani): Implement pointers and handles.
52 } 49 }
53 50
54 void {{class_name}}::DecodePointersAndHandles( 51 void {{class_name}}::DecodePointersAndHandles(
55 std::vector<mojo::Handle>* handles) { 52 std::vector<mojo::Handle>* handles) {
56 // TODO(azani): Implement pointers and handles. 53 // TODO(azani): Implement pointers and handles.
57 } 54 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698