OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 {%- if variant -%} | 5 {%- if variant -%} |
6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%} | 6 {%- set variant_path = "%s-%s"|format(module.path, variant) -%} |
7 {%- else -%} | 7 {%- else -%} |
8 {%- set variant_path = module.path -%} | 8 {%- set variant_path = module.path -%} |
9 {%- endif -%} | 9 {%- endif -%} |
10 | 10 |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 {%- macro namespace_end() %} | 29 {%- macro namespace_end() %} |
30 {%- if variant %} | 30 {%- if variant %} |
31 } // namespace {{variant}} | 31 } // namespace {{variant}} |
32 {%- endif %} | 32 {%- endif %} |
33 {%- for namespace in namespaces_as_array|reverse %} | 33 {%- for namespace in namespaces_as_array|reverse %} |
34 } // namespace {{namespace}} | 34 } // namespace {{namespace}} |
35 {%- endfor %} | 35 {%- endfor %} |
36 {%- endmacro %} | 36 {%- endmacro %} |
37 | 37 |
| 38 {%- macro data_view_traits(kind) %} |
| 39 namespace mojo { |
| 40 namespace internal { |
| 41 template <> |
| 42 struct DataViewTraits<{{kind|get_qualified_name_for_kind}}DataView> { |
| 43 using MojomType = {{kind|get_qualified_name_for_kind}}Ptr; |
| 44 }; |
| 45 } // namespace internal |
| 46 } // namespace mojo |
| 47 {%- endmacro %} |
| 48 |
38 #ifndef {{header_guard}} | 49 #ifndef {{header_guard}} |
39 #define {{header_guard}} | 50 #define {{header_guard}} |
40 | 51 |
41 #include <stdint.h> | 52 #include <stdint.h> |
42 | 53 |
43 #include <functional> | 54 #include <functional> |
44 #include <ostream> | 55 #include <ostream> |
45 #include <type_traits> | 56 #include <type_traits> |
46 #include <utility> | 57 #include <utility> |
47 | 58 |
48 #include "base/callback.h" | 59 #include "base/callback.h" |
49 #include "base/optional.h" | 60 #include "base/optional.h" |
50 #include "base/strings/string_piece.h" | 61 #include "mojo/public/cpp/bindings/array_data_view.h" |
51 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | 62 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" |
52 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" | 63 #include "mojo/public/cpp/bindings/associated_interface_ptr_info.h" |
53 #include "mojo/public/cpp/bindings/associated_interface_request.h" | 64 #include "mojo/public/cpp/bindings/associated_interface_request.h" |
54 #include "mojo/public/cpp/bindings/interface_ptr.h" | 65 #include "mojo/public/cpp/bindings/interface_ptr.h" |
55 #include "mojo/public/cpp/bindings/interface_request.h" | 66 #include "mojo/public/cpp/bindings/interface_request.h" |
56 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" | 67 #include "mojo/public/cpp/bindings/lib/control_message_handler.h" |
57 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" | 68 #include "mojo/public/cpp/bindings/lib/control_message_proxy.h" |
58 #include "mojo/public/cpp/bindings/lib/serialization.h" | 69 #include "mojo/public/cpp/bindings/lib/serialization.h" |
59 #include "mojo/public/cpp/bindings/map.h" | 70 #include "mojo/public/cpp/bindings/map.h" |
| 71 #include "mojo/public/cpp/bindings/map_data_view.h" |
60 #include "mojo/public/cpp/bindings/message_filter.h" | 72 #include "mojo/public/cpp/bindings/message_filter.h" |
61 #include "mojo/public/cpp/bindings/native_enum.h" | 73 #include "mojo/public/cpp/bindings/native_enum.h" |
62 #include "mojo/public/cpp/bindings/native_struct.h" | 74 #include "mojo/public/cpp/bindings/native_struct.h" |
| 75 #include "mojo/public/cpp/bindings/native_struct_data_view.h" |
63 #include "mojo/public/cpp/bindings/no_interface.h" | 76 #include "mojo/public/cpp/bindings/no_interface.h" |
| 77 #include "mojo/public/cpp/bindings/string_data_view.h" |
64 #include "mojo/public/cpp/bindings/struct_ptr.h" | 78 #include "mojo/public/cpp/bindings/struct_ptr.h" |
65 #include "mojo/public/cpp/bindings/struct_traits.h" | 79 #include "mojo/public/cpp/bindings/struct_traits.h" |
66 #include "{{variant_path}}-internal.h" | 80 #include "{{variant_path}}-internal.h" |
67 {%- for import in imports %} | 81 {%- for import in imports %} |
68 {%- if variant %} | 82 {%- if variant %} |
69 #include "{{"%s-%s.h"|format(import.module.path, variant)}}" | 83 #include "{{"%s-%s.h"|format(import.module.path, variant)}}" |
70 {%- else %} | 84 {%- else %} |
71 #include "{{import.module.path}}.h" | 85 #include "{{import.module.path}}.h" |
72 {%- endif %} | 86 {%- endif %} |
73 {%- endfor %} | 87 {%- endfor %} |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 using {{interface.name}}AssociatedPtrInfo = | 148 using {{interface.name}}AssociatedPtrInfo = |
135 mojo::AssociatedInterfacePtrInfo<{{interface.name}}>; | 149 mojo::AssociatedInterfacePtrInfo<{{interface.name}}>; |
136 using {{interface.name}}AssociatedRequest = | 150 using {{interface.name}}AssociatedRequest = |
137 mojo::AssociatedInterfaceRequest<{{interface.name}}>; | 151 mojo::AssociatedInterfaceRequest<{{interface.name}}>; |
138 {% endfor %} | 152 {% endfor %} |
139 | 153 |
140 {#--- Struct Forward Declarations -#} | 154 {#--- Struct Forward Declarations -#} |
141 {% for struct in structs %} | 155 {% for struct in structs %} |
142 {%- if struct|is_native_only_kind %} | 156 {%- if struct|is_native_only_kind %} |
143 using {{struct.name}} = mojo::NativeStruct; | 157 using {{struct.name}} = mojo::NativeStruct; |
| 158 using {{struct.name}}DataView = mojo::NativeStructDataView; |
144 using {{struct.name}}Ptr = mojo::NativeStructPtr; | 159 using {{struct.name}}Ptr = mojo::NativeStructPtr; |
145 {%- else %} | 160 {%- else %} |
146 class {{struct.name}}; | 161 class {{struct.name}}; |
147 class {{struct.name}}DataView; | 162 class {{struct.name}}DataView; |
148 {%- if struct|should_inline %} | 163 {%- if struct|should_inline %} |
149 using {{struct.name}}Ptr = mojo::InlinedStructPtr<{{struct.name}}>; | 164 using {{struct.name}}Ptr = mojo::InlinedStructPtr<{{struct.name}}>; |
150 {%- else %} | 165 {%- else %} |
151 using {{struct.name}}Ptr = mojo::StructPtr<{{struct.name}}>; | 166 using {{struct.name}}Ptr = mojo::StructPtr<{{struct.name}}>; |
152 {%- endif %} | 167 {%- endif %} |
153 {%- endif %} | 168 {%- endif %} |
154 {% endfor %} | 169 {% endfor %} |
155 | 170 |
156 {#--- Union Forward Declarations -#} | 171 {#--- Union Forward Declarations -#} |
157 {% for union in unions %} | 172 {% for union in unions %} |
158 class {{union.name}}; | 173 class {{union.name}}; |
| 174 class {{union.name}}DataView; |
159 {% if union|should_inline_union %} | 175 {% if union|should_inline_union %} |
160 typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr; | 176 typedef mojo::InlinedStructPtr<{{union.name}}> {{union.name}}Ptr; |
161 {% else %} | 177 {% else %} |
162 typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; | 178 typedef mojo::StructPtr<{{union.name}}> {{union.name}}Ptr; |
163 {% endif %} | 179 {% endif %} |
164 {%- endfor %} | 180 {%- endfor %} |
165 | 181 |
166 {#--- Interfaces -#} | 182 {#--- Interfaces -#} |
167 {% for interface in interfaces %} | 183 {% for interface in interfaces %} |
168 {% include "interface_declaration.tmpl" %} | 184 {% include "interface_declaration.tmpl" %} |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 {%- endfor %} | 226 {%- endfor %} |
211 | 227 |
212 {#--- NOTE: Unions and non-inlined structs may have pointers to inlined structs, | 228 {#--- NOTE: Unions and non-inlined structs may have pointers to inlined structs, |
213 so we need to fully define inlined structs ahead of the others. #} | 229 so we need to fully define inlined structs ahead of the others. #} |
214 | 230 |
215 {#--- Inlined structs #} | 231 {#--- Inlined structs #} |
216 {% for struct in structs %} | 232 {% for struct in structs %} |
217 {% if struct|should_inline and not struct|is_native_only_kind %} | 233 {% if struct|should_inline and not struct|is_native_only_kind %} |
218 {% include "wrapper_class_declaration.tmpl" %} | 234 {% include "wrapper_class_declaration.tmpl" %} |
219 {% include "struct_data_view_declaration.tmpl" %} | 235 {% include "struct_data_view_declaration.tmpl" %} |
| 236 |
| 237 {{namespace_end()}} |
| 238 {{data_view_traits(struct)}} |
| 239 {{namespace_begin()}} |
| 240 |
220 {% endif %} | 241 {% endif %} |
221 {%- endfor %} | 242 {%- endfor %} |
222 | 243 |
223 {#--- Unions must be declared before non-inlined structs because they can be | 244 {#--- Unions must be declared before non-inlined structs because they can be |
224 members of structs. #} | 245 members of structs. #} |
225 {#--- Unions #} | 246 {#--- Unions #} |
226 {% for union in unions %} | 247 {% for union in unions %} |
227 {% include "wrapper_union_class_declaration.tmpl" %} | 248 {% include "wrapper_union_class_declaration.tmpl" %} |
| 249 {% include "union_data_view_declaration.tmpl" %} |
| 250 |
| 251 {{namespace_end()}} |
| 252 {{data_view_traits(union)}} |
| 253 {{namespace_begin()}} |
| 254 |
228 {%- endfor %} | 255 {%- endfor %} |
229 | 256 |
230 {#--- Non-inlined structs #} | 257 {#--- Non-inlined structs #} |
231 {% for struct in structs %} | 258 {% for struct in structs %} |
232 {% if not struct|should_inline and not struct|is_native_only_kind %} | 259 {% if not struct|should_inline and not struct|is_native_only_kind %} |
233 {% include "wrapper_class_declaration.tmpl" %} | 260 {% include "wrapper_class_declaration.tmpl" %} |
234 {% include "struct_data_view_declaration.tmpl" %} | 261 {% include "struct_data_view_declaration.tmpl" %} |
| 262 |
| 263 {{namespace_end()}} |
| 264 {{data_view_traits(struct)}} |
| 265 {{namespace_begin()}} |
| 266 |
235 {% endif %} | 267 {% endif %} |
236 {%- endfor %} | 268 {%- endfor %} |
237 | 269 |
238 {%- for union in unions %} | 270 {%- for union in unions %} |
239 {% include "wrapper_union_class_template_definition.tmpl" %} | 271 {% include "wrapper_union_class_template_definition.tmpl" %} |
240 {%- endfor %} | 272 {%- endfor %} |
241 | 273 |
242 {%- for struct in structs %} | 274 {%- for struct in structs %} |
243 {%- if not struct|is_native_only_kind %} | 275 {%- if not struct|is_native_only_kind %} |
244 {% include "wrapper_class_template_definition.tmpl" %} | 276 {% include "wrapper_class_template_definition.tmpl" %} |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 {#--- Union Serialization Helpers -#} | 335 {#--- Union Serialization Helpers -#} |
304 {% if unions %} | 336 {% if unions %} |
305 {%- for union in unions %} | 337 {%- for union in unions %} |
306 {% include "union_serialization_declaration.tmpl" %} | 338 {% include "union_serialization_declaration.tmpl" %} |
307 {%- endfor %} | 339 {%- endfor %} |
308 {%- endif %} | 340 {%- endif %} |
309 | 341 |
310 } // namespace mojo | 342 } // namespace mojo |
311 | 343 |
312 #endif // {{header_guard}} | 344 #endif // {{header_guard}} |
OLD | NEW |