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

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

Issue 2031823002: Mojo C++ bindings: more consistent Clone() and Equals(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 return _NameFormatter(kind, _variant).FormatForCpp( 128 return _NameFormatter(kind, _variant).FormatForCpp(
129 internal=internal, add_same_module_namespaces=True) 129 internal=internal, add_same_module_namespaces=True)
130 130
131 def GetFullMojomNameForKind(kind): 131 def GetFullMojomNameForKind(kind):
132 return _NameFormatter(kind, _variant).FormatForMojom() 132 return _NameFormatter(kind, _variant).FormatForMojom()
133 133
134 def IsTypemappedKind(kind): 134 def IsTypemappedKind(kind):
135 return hasattr(kind, "name") and \ 135 return hasattr(kind, "name") and \
136 GetFullMojomNameForKind(kind) in _current_typemap 136 GetFullMojomNameForKind(kind) in _current_typemap
137 137
138 def IsCloneableKind(kind):
139 return mojom.IsCloneableKind(kind, IsTypemappedKind)
140
141 def IsNativeOnlyKind(kind): 138 def IsNativeOnlyKind(kind):
142 return mojom.IsStructKind(kind) and kind.native_only 139 return mojom.IsStructKind(kind) and kind.native_only
143 140
144 def GetNativeTypeName(typemapped_kind): 141 def GetNativeTypeName(typemapped_kind):
145 return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"] 142 return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"]
146 143
147 def GetCppType(kind): 144 def GetCppType(kind):
148 if mojom.IsArrayKind(kind): 145 if mojom.IsArrayKind(kind):
149 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind) 146 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind)
150 if mojom.IsMapKind(kind): 147 if mojom.IsMapKind(kind):
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs, 434 "get_array_validate_params_ctor_args": GetArrayValidateParamsCtorArgs,
438 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs, 435 "get_map_validate_params_ctor_args": GetMapValidateParamsCtorArgs,
439 "get_name_for_kind": GetNameForKind, 436 "get_name_for_kind": GetNameForKind,
440 "get_pad": pack.GetPad, 437 "get_pad": pack.GetPad,
441 "get_qualified_name_for_kind": GetQualifiedNameForKind, 438 "get_qualified_name_for_kind": GetQualifiedNameForKind,
442 "has_callbacks": mojom.HasCallbacks, 439 "has_callbacks": mojom.HasCallbacks,
443 "has_sync_methods": mojom.HasSyncMethods, 440 "has_sync_methods": mojom.HasSyncMethods,
444 "should_inline": ShouldInlineStruct, 441 "should_inline": ShouldInlineStruct,
445 "should_inline_union": ShouldInlineUnion, 442 "should_inline_union": ShouldInlineUnion,
446 "is_array_kind": mojom.IsArrayKind, 443 "is_array_kind": mojom.IsArrayKind,
447 "is_cloneable_kind": IsCloneableKind,
448 "is_enum_kind": mojom.IsEnumKind, 444 "is_enum_kind": mojom.IsEnumKind,
449 "is_integral_kind": mojom.IsIntegralKind, 445 "is_integral_kind": mojom.IsIntegralKind,
450 "is_move_only_kind": mojom.IsMoveOnlyKind, 446 "is_move_only_kind": mojom.IsMoveOnlyKind,
451 "is_native_only_kind": IsNativeOnlyKind, 447 "is_native_only_kind": IsNativeOnlyKind,
452 "is_any_handle_kind": mojom.IsAnyHandleKind, 448 "is_any_handle_kind": mojom.IsAnyHandleKind,
453 "is_interface_kind": mojom.IsInterfaceKind, 449 "is_interface_kind": mojom.IsInterfaceKind,
454 "is_interface_request_kind": mojom.IsInterfaceRequestKind, 450 "is_interface_request_kind": mojom.IsInterfaceRequestKind,
455 "is_associated_interface_kind": mojom.IsAssociatedInterfaceKind, 451 "is_associated_interface_kind": mojom.IsAssociatedInterfaceKind,
456 "is_associated_interface_request_kind": 452 "is_associated_interface_request_kind":
457 mojom.IsAssociatedInterfaceRequestKind, 453 mojom.IsAssociatedInterfaceRequestKind,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 _for_blink = self.for_blink 522 _for_blink = self.for_blink
527 global _variant 523 global _variant
528 _variant = self.variant 524 _variant = self.variant
529 suffix = "-%s" % self.variant if self.variant else "" 525 suffix = "-%s" % self.variant if self.variant else ""
530 self.Write(self.GenerateModuleHeader(), 526 self.Write(self.GenerateModuleHeader(),
531 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 527 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
532 self.Write(self.GenerateModuleInternalHeader(), 528 self.Write(self.GenerateModuleInternalHeader(),
533 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 529 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
534 self.Write(self.GenerateModuleSource(), 530 self.Write(self.GenerateModuleSource(),
535 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 531 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698