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

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

Issue 2147563004: Mojo C++ bindings: rename "pass_by_value" typemap attribute to "move_only". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@68_native_types
Patch Set: Created 4 years, 5 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
« no previous file with comments | « mojo/public/tools/bindings/generate_type_mappings.py ('k') | ui/events/mojo/event.typemap » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if mojom.IsSharedBufferKind(kind): 209 if mojom.IsSharedBufferKind(kind):
210 return "mojo::ScopedSharedBufferHandle" 210 return "mojo::ScopedSharedBufferHandle"
211 if not kind in _kind_to_cpp_type: 211 if not kind in _kind_to_cpp_type:
212 raise Exception("Unrecognized kind %s" % kind.spec) 212 raise Exception("Unrecognized kind %s" % kind.spec)
213 return _kind_to_cpp_type[kind] 213 return _kind_to_cpp_type[kind]
214 214
215 def IsMoveOnlyKind(kind): 215 def IsMoveOnlyKind(kind):
216 if IsTypemappedKind(kind): 216 if IsTypemappedKind(kind):
217 if mojom.IsEnumKind(kind): 217 if mojom.IsEnumKind(kind):
218 return False 218 return False
219 # TODO(yzshen): Change the attribute to "move_only". 219 return _current_typemap[GetFullMojomNameForKind(kind)]["move_only"]
220 return _current_typemap[GetFullMojomNameForKind(kind)]["pass_by_value"]
221 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): 220 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
222 return True 221 return True
223 if mojom.IsArrayKind(kind): 222 if mojom.IsArrayKind(kind):
224 return IsMoveOnlyKind(kind.kind) if _use_new_wrapper_types else True 223 return IsMoveOnlyKind(kind.kind) if _use_new_wrapper_types else True
225 if mojom.IsMapKind(kind): 224 if mojom.IsMapKind(kind):
226 return IsMoveOnlyKind(kind.value_kind) if _use_new_wrapper_types else True 225 return IsMoveOnlyKind(kind.value_kind) if _use_new_wrapper_types else True
227 if mojom.IsAnyHandleOrInterfaceKind(kind): 226 if mojom.IsAnyHandleOrInterfaceKind(kind):
228 return True 227 return True
229 return False 228 return False
230 229
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 _use_new_wrapper_types = self.use_new_wrapper_types 500 _use_new_wrapper_types = self.use_new_wrapper_types
502 global _variant 501 global _variant
503 _variant = self.variant 502 _variant = self.variant
504 suffix = "-%s" % self.variant if self.variant else "" 503 suffix = "-%s" % self.variant if self.variant else ""
505 self.Write(self.GenerateModuleHeader(), 504 self.Write(self.GenerateModuleHeader(),
506 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 505 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
507 self.Write(self.GenerateModuleInternalHeader(), 506 self.Write(self.GenerateModuleInternalHeader(),
508 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 507 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
509 self.Write(self.GenerateModuleSource(), 508 self.Write(self.GenerateModuleSource(),
510 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 509 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW
« no previous file with comments | « mojo/public/tools/bindings/generate_type_mappings.py ('k') | ui/events/mojo/event.typemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698