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

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

Issue 2339413004: Allow Mojo structs as map keys (Closed)
Patch Set: Remove left-over import Created 4 years, 3 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 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 28 matching lines...) Expand all
39 {{struct.name}}Ptr Clone() const; 39 {{struct.name}}Ptr Clone() const;
40 40
41 // Equals() is a template so it is only instantiated if it is used. Thus, the 41 // Equals() is a template so it is only instantiated if it is used. Thus, the
42 // bindings generator does not need to know whether Equals() or == operator 42 // bindings generator does not need to know whether Equals() or == operator
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 %}
50 size_t Hash(size_t seed) const;
51 {%- endif %}
52
49 {%- set serialization_result_type = "mojo::WTFArray<uint8_t>" 53 {%- set serialization_result_type = "mojo::WTFArray<uint8_t>"
50 if for_blink else "mojo::Array<uint8_t>" %} 54 if for_blink else "mojo::Array<uint8_t>" %}
51 55
52 template <typename UserType> 56 template <typename UserType>
53 static {{serialization_result_type}} Serialize(UserType* input) { 57 static {{serialization_result_type}} Serialize(UserType* input) {
54 return mojo::internal::StructSerializeImpl< 58 return mojo::internal::StructSerializeImpl<
55 {{struct.name}}::DataView, {{serialization_result_type}}>(input); 59 {{struct.name}}::DataView, {{serialization_result_type}}>(input);
56 } 60 }
57 61
58 template <typename UserType> 62 template <typename UserType>
(...skipping 10 matching lines...) Expand all
69 {%- set name = field.name %} 73 {%- set name = field.name %}
70 {{type}} {{name}}; 74 {{type}} {{name}};
71 {%- endfor %} 75 {%- endfor %}
72 76
73 {%- if struct|contains_move_only_members %} 77 {%- if struct|contains_move_only_members %}
74 private: 78 private:
75 DISALLOW_COPY_AND_ASSIGN({{struct.name}}); 79 DISALLOW_COPY_AND_ASSIGN({{struct.name}});
76 {%- endif %} 80 {%- endif %}
77 }; 81 };
78 82
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698