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 """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 Loading... |
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 Loading... |
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))) |
OLD | NEW |