OLD | NEW |
---|---|
1 {# TODO(yzshen): Make these templates more readable. #} | 1 {# TODO(yzshen): Make these templates more readable. #} |
2 | 2 |
3 {# Computes the serialized size for the specified struct. | 3 {# Computes the serialized size for the specified struct. |
4 |struct| is the struct definition. | 4 |struct| is the struct definition. |
5 |input_field_pattern| should be a pattern that contains one string | 5 |input_field_pattern| should be a pattern that contains one string |
6 placeholder, for example, "input->%s", "p_%s". The placeholder will be | 6 placeholder, for example, "input->%s", "p_%s". The placeholder will be |
7 substituted with struct field names to refer to the input fields. | 7 substituted with struct field names to refer to the input fields. |
8 This macro is expanded to compute seriailized size for both: | 8 This macro is expanded to compute seriailized size for both: |
9 - user-defined structs: the input is an instance of the corresponding struct | 9 - user-defined structs: the input is an instance of the corresponding struct |
10 wrapper class. | 10 wrapper class. |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
88 {%- if not kind|is_nullable_kind %} | 88 {%- if not kind|is_nullable_kind %} |
89 MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( | 89 MOJO_INTERNAL_DLOG_SERIALIZATION_WARNING( |
90 {%- if kind|is_interface_kind %} | 90 {%- if kind|is_interface_kind %} |
91 !{{output}}->{{name}}.handle.is_valid(), | 91 !{{output}}->{{name}}.handle.is_valid(), |
92 {%- else %} | 92 {%- else %} |
93 !{{output}}->{{name}}.is_valid(), | 93 !{{output}}->{{name}}.is_valid(), |
94 {%- endif %} | 94 {%- endif %} |
95 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, | 95 mojo::internal::VALIDATION_ERROR_UNEXPECTED_INVALID_HANDLE, |
96 "invalid {{name}} in {{struct_display_name}}"); | 96 "invalid {{name}} in {{struct_display_name}}"); |
97 {%- endif %} | 97 {%- endif %} |
98 {%- elif kind|is_enum_kind %} | |
99 {{output}}->{{name}} = | |
100 static_cast<typename std::underlying_type< | |
viettrungluu
2015/10/01 17:49:55
Ditto -- no need for underlying_type.
johngro
2015/10/02 00:49:04
Done.
| |
101 {{kind|cpp_wrapper_type}}>::type>({{input_field}}); | |
98 {%- else %} | 102 {%- else %} |
99 {{output}}->{{name}} = {{input_field}}; | 103 {{output}}->{{name}} = {{input_field}}; |
100 {%- endif %} | 104 {%- endif %} |
101 {%- endfor %} | 105 {%- endfor %} |
102 {%- endmacro -%} | 106 {%- endmacro -%} |
103 | 107 |
104 {# Deserializes the specified struct. | 108 {# Deserializes the specified struct. |
105 |struct| is the struct definition. | 109 |struct| is the struct definition. |
106 |input| is the name of the input struct instance. | 110 |input| is the name of the input struct instance. |
107 |output_field_pattern| should be a pattern that contains one string | 111 |output_field_pattern| should be a pattern that contains one string |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 {%- elif kind|is_any_handle_kind %} | 154 {%- elif kind|is_any_handle_kind %} |
151 {{output_field}}.reset(mojo::internal::FetchAndReset(&{{input}}->{{name}})); | 155 {{output_field}}.reset(mojo::internal::FetchAndReset(&{{input}}->{{name}})); |
152 {%- elif kind|is_enum_kind %} | 156 {%- elif kind|is_enum_kind %} |
153 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name} }); | 157 {{output_field}} = static_cast<{{kind|cpp_wrapper_type}}>({{input}}->{{name} }); |
154 {%- else %} | 158 {%- else %} |
155 {{output_field}} = {{input}}->{{name}}; | 159 {{output_field}} = {{input}}->{{name}}; |
156 {%- endif %} | 160 {%- endif %} |
157 {%- endfor %} | 161 {%- endfor %} |
158 } while (false); | 162 } while (false); |
159 {%- endmacro %} | 163 {%- endmacro %} |
OLD | NEW |