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

Side by Side Diff: mojo/public/tools/bindings/generators/mojom_cpp_generator.py

Issue 2863353002: Mojo code generator: change where to add computed data to mojom definitions (Closed)
Patch Set: . Created 3 years, 7 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 # 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 """Generates C++ source files from a mojom.Module.""" 5 """Generates C++ source files from a mojom.Module."""
6 6
7 import mojom.generate.generator as generator 7 import mojom.generate.generator as generator
8 import mojom.generate.module as mojom 8 import mojom.generate.module as mojom
9 import mojom.generate.pack as pack 9 import mojom.generate.pack as pack
10 from mojom.generate.template_expander import UseJinja 10 from mojom.generate.template_expander import UseJinja
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 for struct in self.module.structs + self.module.unions: 271 for struct in self.module.structs + self.module.unions:
272 for field in struct.fields: 272 for field in struct.fields:
273 yield field.kind 273 yield field.kind
274 274
275 for interface in self.module.interfaces: 275 for interface in self.module.interfaces:
276 for method in interface.methods: 276 for method in interface.methods:
277 for param in method.parameters + (method.response_parameters or []): 277 for param in method.parameters + (method.response_parameters or []):
278 yield param.kind 278 yield param.kind
279 279
280 def _GetJinjaExports(self): 280 def _GetJinjaExports(self):
281 structs = self.GetStructs()
282 interfaces = self.GetInterfaces()
283 all_enums = list(self.module.enums) 281 all_enums = list(self.module.enums)
284 for struct in structs: 282 for struct in self.module.structs:
285 all_enums.extend(struct.enums) 283 all_enums.extend(struct.enums)
286 for interface in interfaces: 284 for interface in self.module.interfaces:
287 all_enums.extend(interface.enums) 285 all_enums.extend(interface.enums)
288 286
289 return { 287 return {
290 "module": self.module, 288 "module": self.module,
291 "namespace": self.module.namespace, 289 "namespace": self.module.namespace,
292 "namespaces_as_array": NamespaceToArray(self.module.namespace), 290 "namespaces_as_array": NamespaceToArray(self.module.namespace),
293 "imports": self.module.imports, 291 "imports": self.module.imports,
294 "kinds": self.module.kinds, 292 "kinds": self.module.kinds,
295 "enums": self.module.enums, 293 "enums": self.module.enums,
296 "all_enums": all_enums, 294 "all_enums": all_enums,
297 "structs": structs, 295 "structs": self.module.structs,
298 "unions": self.GetUnions(), 296 "unions": self.module.unions,
299 "interfaces": interfaces, 297 "interfaces": self.module.interfaces,
300 "variant": self.variant, 298 "variant": self.variant,
301 "extra_traits_headers": self._GetExtraTraitsHeaders(), 299 "extra_traits_headers": self._GetExtraTraitsHeaders(),
302 "extra_public_headers": self._GetExtraPublicHeaders(), 300 "extra_public_headers": self._GetExtraPublicHeaders(),
303 "for_blink": self.for_blink, 301 "for_blink": self.for_blink,
304 "use_once_callback": self.use_once_callback, 302 "use_once_callback": self.use_once_callback,
305 "export_attribute": self.export_attribute, 303 "export_attribute": self.export_attribute,
306 "export_header": self.export_header, 304 "export_header": self.export_header,
307 } 305 }
308 306
309 @staticmethod 307 @staticmethod
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 "is_map_kind": mojom.IsMapKind, 347 "is_map_kind": mojom.IsMapKind,
350 "is_nullable_kind": mojom.IsNullableKind, 348 "is_nullable_kind": mojom.IsNullableKind,
351 "is_object_kind": mojom.IsObjectKind, 349 "is_object_kind": mojom.IsObjectKind,
352 "is_reference_kind": mojom.IsReferenceKind, 350 "is_reference_kind": mojom.IsReferenceKind,
353 "is_string_kind": mojom.IsStringKind, 351 "is_string_kind": mojom.IsStringKind,
354 "is_struct_kind": mojom.IsStructKind, 352 "is_struct_kind": mojom.IsStructKind,
355 "is_typemapped_kind": self._IsTypemappedKind, 353 "is_typemapped_kind": self._IsTypemappedKind,
356 "is_union_kind": mojom.IsUnionKind, 354 "is_union_kind": mojom.IsUnionKind,
357 "passes_associated_kinds": mojom.PassesAssociatedKinds, 355 "passes_associated_kinds": mojom.PassesAssociatedKinds,
358 "struct_constructors": self._GetStructConstructors, 356 "struct_constructors": self._GetStructConstructors,
359 "under_to_camel": generator.UnderToCamel, 357 "under_to_camel": generator.ToCamel,
360 "unmapped_type_for_serializer": self._GetUnmappedTypeForSerializer, 358 "unmapped_type_for_serializer": self._GetUnmappedTypeForSerializer,
361 "wtf_hash_fn_name_for_enum": GetWtfHashFnNameForEnum, 359 "wtf_hash_fn_name_for_enum": GetWtfHashFnNameForEnum,
362 } 360 }
363 return cpp_filters 361 return cpp_filters
364 362
365 @UseJinja("module.h.tmpl") 363 @UseJinja("module.h.tmpl")
366 def _GenerateModuleHeader(self): 364 def _GenerateModuleHeader(self):
367 return self._GetJinjaExports() 365 return self._GetJinjaExports()
368 366
369 @UseJinja("module.cc.tmpl") 367 @UseJinja("module.cc.tmpl")
(...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 if mojom.IsDataPipeProducerKind(kind): 795 if mojom.IsDataPipeProducerKind(kind):
798 return "mojo::ScopedDataPipeProducerHandle" 796 return "mojo::ScopedDataPipeProducerHandle"
799 if mojom.IsMessagePipeKind(kind): 797 if mojom.IsMessagePipeKind(kind):
800 return "mojo::ScopedMessagePipeHandle" 798 return "mojo::ScopedMessagePipeHandle"
801 if mojom.IsSharedBufferKind(kind): 799 if mojom.IsSharedBufferKind(kind):
802 return "mojo::ScopedSharedBufferHandle" 800 return "mojo::ScopedSharedBufferHandle"
803 return _kind_to_cpp_type[kind] 801 return _kind_to_cpp_type[kind]
804 802
805 def _GetUnmappedTypeForSerializer(self, kind): 803 def _GetUnmappedTypeForSerializer(self, kind):
806 return self._GetCppDataViewType(kind, qualified=True) 804 return self._GetCppDataViewType(kind, qualified=True)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698