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

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

Issue 2259283003: Mojo C++ bindings: share DataView class between chromium and blink variants. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@92_change_traits_param
Patch Set: . Created 4 years, 4 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 {%- set serialization_result_type = "mojo::WTFArray<uint8_t>" 49 {%- set serialization_result_type = "mojo::WTFArray<uint8_t>"
50 if for_blink else "mojo::Array<uint8_t>" %} 50 if for_blink else "mojo::Array<uint8_t>" %}
51 51
52 template <typename UserType> 52 template <typename UserType>
53 static {{serialization_result_type}} Serialize(UserType* input) { 53 static {{serialization_result_type}} Serialize(UserType* input) {
54 return mojo::internal::StructSerializeImpl< 54 return mojo::internal::StructSerializeImpl<
55 {{struct.name}}Ptr, {{serialization_result_type}}>(input); 55 {{struct.name}}::DataView, {{serialization_result_type}}>(input);
56 } 56 }
57 57
58 template <typename UserType> 58 template <typename UserType>
59 static bool Deserialize(const {{serialization_result_type}}& input, 59 static bool Deserialize(const {{serialization_result_type}}& input,
60 UserType* output) { 60 UserType* output) {
61 return mojo::internal::StructDeserializeImpl< 61 return mojo::internal::StructDeserializeImpl<
62 {{struct.name}}Ptr, {{serialization_result_type}}>( 62 {{struct.name}}::DataView, {{serialization_result_type}}>(
63 input, output); 63 input, output);
64 } 64 }
65 65
66 {#--- Struct members #} 66 {#--- Struct members #}
67 {% for field in struct.fields %} 67 {% for field in struct.fields %}
68 {%- set type = field.kind|cpp_wrapper_type %} 68 {%- set type = field.kind|cpp_wrapper_type %}
69 {%- set name = field.name %} 69 {%- set name = field.name %}
70 {{type}} {{name}}; 70 {{type}} {{name}};
71 {%- endfor %} 71 {%- endfor %}
72 72
73 {%- if struct|contains_move_only_members %} 73 {%- if struct|contains_move_only_members %}
74 private: 74 private:
75 DISALLOW_COPY_AND_ASSIGN({{struct.name}}); 75 DISALLOW_COPY_AND_ASSIGN({{struct.name}});
76 {%- endif %} 76 {%- endif %}
77 }; 77 };
78 78
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698