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

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

Issue 2012693002: Generate a templated Clone method for all mojo structs. (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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
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): 138 def IsCloneableKind(kind):
139 return mojom.IsCloneableKind(kind, IsTypemappedKind) 139 return mojom.IsCloneableKind(
140 kind,
141 lambda kind : IsTypemappedKind(kind) and ShouldPassParamByValue(kind))
yzshen1 2016/05/26 16:24:14 I feel that the cloneable check should probably be
Sam McNally 2016/05/27 02:57:40 Done for structs.
140 142
141 def IsNativeOnlyKind(kind): 143 def IsNativeOnlyKind(kind):
142 return mojom.IsStructKind(kind) and kind.native_only 144 return mojom.IsStructKind(kind) and kind.native_only
143 145
144 def GetNativeTypeName(typemapped_kind): 146 def GetNativeTypeName(typemapped_kind):
145 return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"] 147 return _current_typemap[GetFullMojomNameForKind(typemapped_kind)]["typename"]
146 148
147 def GetCppType(kind): 149 def GetCppType(kind):
148 if mojom.IsArrayKind(kind): 150 if mojom.IsArrayKind(kind):
149 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind) 151 return "mojo::internal::Array_Data<%s>*" % GetCppType(kind.kind)
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 _for_blink = self.for_blink 528 _for_blink = self.for_blink
527 global _variant 529 global _variant
528 _variant = self.variant 530 _variant = self.variant
529 suffix = "-%s" % self.variant if self.variant else "" 531 suffix = "-%s" % self.variant if self.variant else ""
530 self.Write(self.GenerateModuleHeader(), 532 self.Write(self.GenerateModuleHeader(),
531 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 533 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
532 self.Write(self.GenerateModuleInternalHeader(), 534 self.Write(self.GenerateModuleInternalHeader(),
533 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 535 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
534 self.Write(self.GenerateModuleSource(), 536 self.Write(self.GenerateModuleSource(),
535 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 537 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698