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

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

Issue 2637393002: Make mojom-generated C++ string constants really constant. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
OLDNEW
1 {%- import "interface_macros.tmpl" as interface_macros %} 1 {%- import "interface_macros.tmpl" as interface_macros %}
2 {%- import "struct_macros.tmpl" as struct_macros %} 2 {%- import "struct_macros.tmpl" as struct_macros %}
3 3
4 {%- set class_name = interface.name %} 4 {%- set class_name = interface.name %}
5 {%- set proxy_name = interface.name ~ "Proxy" %} 5 {%- set proxy_name = interface.name ~ "Proxy" %}
6 {%- set namespace_as_string = "%s"|format(namespace|replace(".","::")) %} 6 {%- set namespace_as_string = "%s"|format(namespace|replace(".","::")) %}
7 7
8 {%- macro alloc_params(struct, params, message, serialization_context, 8 {%- macro alloc_params(struct, params, message, serialization_context,
9 description) %} 9 description) %}
10 ({{serialization_context}})->handles.Swap(({{message}})->mutable_handles()); 10 ({{serialization_context}})->handles.Swap(({{message}})->mutable_handles());
(...skipping 24 matching lines...) Expand all
35 serialization_context) -%} 35 serialization_context) -%}
36 {{struct_macros.serialize(struct, struct_display_name, input_pattern, 36 {{struct_macros.serialize(struct, struct_display_name, input_pattern,
37 "params", "builder.buffer()", 37 "params", "builder.buffer()",
38 serialization_context)}} 38 serialization_context)}}
39 ({{serialization_context}})->handles.Swap( 39 ({{serialization_context}})->handles.Swap(
40 builder.message()->mutable_handles()); 40 builder.message()->mutable_handles());
41 {%- endmacro %} 41 {%- endmacro %}
42 42
43 {#--- Begin #} 43 {#--- Begin #}
44 const char {{class_name}}::Name_[] = "{{namespace_as_string}}::{{class_name}}"; 44 const char {{class_name}}::Name_[] = "{{namespace_as_string}}::{{class_name}}";
45 const uint32_t {{class_name}}::Version_;
46 45
47 {#--- Constants #} 46 {#--- Constants #}
48 {%- for constant in interface.constants %} 47 {%- for constant in interface.constants %}
49 {%- if constant.kind|is_integral_kind %} 48 {%- if constant.kind|is_string_kind %}
50 const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}}; 49 const char {{interface.name}}::{{constant.name}}[] = {{constant|constant_value}} ;
51 {%- else %}
52 const {{constant.kind|cpp_pod_type}} {{interface.name}}::{{constant.name}} = {{c onstant|constant_value}};
53 {%- endif %} 50 {%- endif %}
54 {%- endfor %} 51 {%- endfor %}
55 52
56 53
57 {%- for method in interface.methods %} 54 {%- for method in interface.methods %}
58 {%- if method.sync %} 55 {%- if method.sync %}
59 bool {{class_name}}::{{method.name}}({{interface_macros.declare_sync_method_para ms("", method)}}) { 56 bool {{class_name}}::{{method.name}}({{interface_macros.declare_sync_method_para ms("", method)}}) {
60 NOTREACHED(); 57 NOTREACHED();
61 return false; 58 return false;
62 } 59 }
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 break; 443 break;
447 } 444 }
448 445
449 // Unrecognized message. 446 // Unrecognized message.
450 ReportValidationError( 447 ReportValidationError(
451 &validation_context, 448 &validation_context,
452 mojo::internal::VALIDATION_ERROR_MESSAGE_HEADER_UNKNOWN_METHOD); 449 mojo::internal::VALIDATION_ERROR_MESSAGE_HEADER_UNKNOWN_METHOD);
453 return false; 450 return false;
454 } 451 }
455 {%- endif -%} 452 {%- endif -%}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698