Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 class {{export_attribute}} {{struct.name}} { | 1 class {{export_attribute}} {{struct.name}} { |
| 2 public: | 2 public: |
| 3 using DataView = {{struct.name}}DataView; | 3 using DataView = {{struct.name}}DataView; |
| 4 using Data_ = internal::{{struct.name}}_Data; | 4 using Data_ = internal::{{struct.name}}_Data; |
| 5 | 5 |
| 6 {#--- Enums #} | 6 {#--- Enums #} |
| 7 {%- for enum in struct.enums -%} | 7 {%- for enum in struct.enums -%} |
| 8 using {{enum.name}} = {{enum|get_name_for_kind(flatten_nested_kind=True)}}; | 8 using {{enum.name}} = {{enum|get_name_for_kind(flatten_nested_kind=True)}}; |
| 9 {%- endfor %} | 9 {%- endfor %} |
| 10 | 10 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 43 // are available for members. | 43 // are available for members. |
| 44 template <typename T, | 44 template <typename T, |
| 45 typename std::enable_if<std::is_same< | 45 typename std::enable_if<std::is_same< |
| 46 T, {{struct.name}}>::value>::type* = nullptr> | 46 T, {{struct.name}}>::value>::type* = nullptr> |
| 47 bool Equals(const T& other) const; | 47 bool Equals(const T& other) const; |
| 48 | 48 |
| 49 {%- if struct|is_hashable %} | 49 {%- if struct|is_hashable %} |
| 50 size_t Hash(size_t seed) const; | 50 size_t Hash(size_t seed) const; |
| 51 {%- endif %} | 51 {%- endif %} |
| 52 | 52 |
| 53 {%- set serialization_result_type = "mojo::WTFArray<uint8_t>" | 53 {%- set serialization_result_type = "Vector<uint8_t>" |
|
yzshen1
2017/01/03 19:26:26
Please use WTF::Vector here to be more explicit. T
Sam McNally
2017/01/03 23:52:04
Done.
| |
| 54 if for_blink else "mojo::Array<uint8_t>" %} | 54 if for_blink else "std::vector<uint8_t>" %} |
| 55 | 55 |
| 56 template <typename UserType> | 56 template <typename UserType> |
| 57 static {{serialization_result_type}} Serialize(UserType* input) { | 57 static {{serialization_result_type}} Serialize(UserType* input) { |
| 58 return mojo::internal::StructSerializeImpl< | 58 return mojo::internal::StructSerializeImpl< |
| 59 {{struct.name}}::DataView, {{serialization_result_type}}>(input); | 59 {{struct.name}}::DataView, {{serialization_result_type}}>(input); |
| 60 } | 60 } |
| 61 | 61 |
| 62 template <typename UserType> | 62 template <typename UserType> |
| 63 static bool Deserialize(const {{serialization_result_type}}& input, | 63 static bool Deserialize(const {{serialization_result_type}}& input, |
| 64 UserType* output) { | 64 UserType* output) { |
| 65 return mojo::internal::StructDeserializeImpl< | 65 return mojo::internal::StructDeserializeImpl< |
| 66 {{struct.name}}::DataView, {{serialization_result_type}}>( | 66 {{struct.name}}::DataView, {{serialization_result_type}}>( |
| 67 input, output); | 67 input, output); |
| 68 } | 68 } |
| 69 | 69 |
| 70 {#--- Struct members #} | 70 {#--- Struct members #} |
| 71 {% for field in struct.fields %} | 71 {% for field in struct.fields %} |
| 72 {%- set type = field.kind|cpp_wrapper_type %} | 72 {%- set type = field.kind|cpp_wrapper_type %} |
| 73 {%- set name = field.name %} | 73 {%- set name = field.name %} |
| 74 {{type}} {{name}}; | 74 {{type}} {{name}}; |
| 75 {%- endfor %} | 75 {%- endfor %} |
| 76 | 76 |
| 77 {%- if struct|contains_move_only_members %} | 77 {%- if struct|contains_move_only_members %} |
| 78 private: | 78 private: |
| 79 DISALLOW_COPY_AND_ASSIGN({{struct.name}}); | 79 DISALLOW_COPY_AND_ASSIGN({{struct.name}}); |
| 80 {%- endif %} | 80 {%- endif %} |
| 81 }; | 81 }; |
| 82 | 82 |
| OLD | NEW |