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

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

Issue 1967703004: Mojo C++ bindings: add StringTraits and ArrayTraits for STL types. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@27_update_users
Patch Set: Created 4 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
« no previous file with comments | « mojo/public/interfaces/bindings/tests/struct_with_traits.mojom ('k') | no next file » | 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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return "mojo::internal::Handle_Data" 170 return "mojo::internal::Handle_Data"
171 return _kind_to_cpp_type[kind] 171 return _kind_to_cpp_type[kind]
172 172
173 def GetCppPodType(kind): 173 def GetCppPodType(kind):
174 if mojom.IsStringKind(kind): 174 if mojom.IsStringKind(kind):
175 return "char*" 175 return "char*"
176 return _kind_to_cpp_type[kind] 176 return _kind_to_cpp_type[kind]
177 177
178 def GetCppArrayArgWrapperType(kind): 178 def GetCppArrayArgWrapperType(kind):
179 if IsTypemappedKind(kind): 179 if IsTypemappedKind(kind):
180 if mojom.IsStructKind(kind) and kind.native_only: 180 return GetNativeTypeName(kind)
181 return GetNativeTypeName(kind)
182 else:
183 raise Exception(
184 "Cannot serialize containers of non-native typemapped structs yet!")
185 if mojom.IsEnumKind(kind): 181 if mojom.IsEnumKind(kind):
186 return GetNameForKind(kind) 182 return GetNameForKind(kind)
187 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): 183 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
188 return "%sPtr" % GetNameForKind(kind) 184 return "%sPtr" % GetNameForKind(kind)
189 if mojom.IsArrayKind(kind): 185 if mojom.IsArrayKind(kind):
190 pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>" 186 pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>"
191 return pattern % GetCppArrayArgWrapperType(kind.kind) 187 return pattern % GetCppArrayArgWrapperType(kind.kind)
192 if mojom.IsMapKind(kind): 188 if mojom.IsMapKind(kind):
193 return "mojo::Map<%s, %s> " % (GetCppArrayArgWrapperType(kind.key_kind), 189 return "mojo::Map<%s, %s> " % (GetCppArrayArgWrapperType(kind.key_kind),
194 GetCppArrayArgWrapperType(kind.value_kind)) 190 GetCppArrayArgWrapperType(kind.value_kind))
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 _for_blink = self.for_blink 596 _for_blink = self.for_blink
601 global _variant 597 global _variant
602 _variant = self.variant 598 _variant = self.variant
603 suffix = "-%s" % self.variant if self.variant else "" 599 suffix = "-%s" % self.variant if self.variant else ""
604 self.Write(self.GenerateModuleHeader(), 600 self.Write(self.GenerateModuleHeader(),
605 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 601 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
606 self.Write(self.GenerateModuleInternalHeader(), 602 self.Write(self.GenerateModuleInternalHeader(),
607 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 603 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
608 self.Write(self.GenerateModuleSource(), 604 self.Write(self.GenerateModuleSource(),
609 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 605 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW
« no previous file with comments | « mojo/public/interfaces/bindings/tests/struct_with_traits.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698