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

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

Issue 2034273002: Mojo C++ bindings: introduce mojo::WTFMap for blink bindings. (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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 if IsTypemappedKind(kind): 176 if IsTypemappedKind(kind):
177 return GetNativeTypeName(kind) 177 return GetNativeTypeName(kind)
178 if mojom.IsEnumKind(kind): 178 if mojom.IsEnumKind(kind):
179 return GetNameForKind(kind) 179 return GetNameForKind(kind)
180 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): 180 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
181 return "%sPtr" % GetNameForKind(kind) 181 return "%sPtr" % GetNameForKind(kind)
182 if mojom.IsArrayKind(kind): 182 if mojom.IsArrayKind(kind):
183 pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>" 183 pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>"
184 return pattern % GetCppArrayArgWrapperType(kind.kind) 184 return pattern % GetCppArrayArgWrapperType(kind.kind)
185 if mojom.IsMapKind(kind): 185 if mojom.IsMapKind(kind):
186 return "mojo::Map<%s, %s> " % (GetCppArrayArgWrapperType(kind.key_kind), 186 pattern = "mojo::WTFMap<%s, %s>" if _for_blink else "mojo::Map<%s, %s>"
187 GetCppArrayArgWrapperType(kind.value_kind)) 187 return pattern % (GetCppArrayArgWrapperType(kind.key_kind),
188 GetCppArrayArgWrapperType(kind.value_kind))
188 if mojom.IsInterfaceKind(kind): 189 if mojom.IsInterfaceKind(kind):
189 raise Exception("Arrays of interfaces not yet supported!") 190 raise Exception("Arrays of interfaces not yet supported!")
190 if mojom.IsInterfaceRequestKind(kind): 191 if mojom.IsInterfaceRequestKind(kind):
191 raise Exception("Arrays of interface requests not yet supported!") 192 raise Exception("Arrays of interface requests not yet supported!")
192 if mojom.IsAssociatedInterfaceKind(kind): 193 if mojom.IsAssociatedInterfaceKind(kind):
193 raise Exception("Arrays of associated interfaces not yet supported!") 194 raise Exception("Arrays of associated interfaces not yet supported!")
194 if mojom.IsAssociatedInterfaceRequestKind(kind): 195 if mojom.IsAssociatedInterfaceRequestKind(kind):
195 raise Exception("Arrays of associated interface requests not yet " 196 raise Exception("Arrays of associated interface requests not yet "
196 "supported!") 197 "supported!")
197 if mojom.IsStringKind(kind): 198 if mojom.IsStringKind(kind):
(...skipping 14 matching lines...) Expand all
212 if IsTypemappedKind(kind): 213 if IsTypemappedKind(kind):
213 return GetNativeTypeName(kind) 214 return GetNativeTypeName(kind)
214 if mojom.IsEnumKind(kind): 215 if mojom.IsEnumKind(kind):
215 return GetNameForKind(kind) 216 return GetNameForKind(kind)
216 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): 217 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
217 return "%sPtr" % GetNameForKind(kind) 218 return "%sPtr" % GetNameForKind(kind)
218 if mojom.IsArrayKind(kind): 219 if mojom.IsArrayKind(kind):
219 pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>" 220 pattern = "mojo::WTFArray<%s>" if _for_blink else "mojo::Array<%s>"
220 return pattern % GetCppArrayArgWrapperType(kind.kind) 221 return pattern % GetCppArrayArgWrapperType(kind.kind)
221 if mojom.IsMapKind(kind): 222 if mojom.IsMapKind(kind):
222 return "mojo::Map<%s, %s>" % (GetCppArrayArgWrapperType(kind.key_kind), 223 pattern = "mojo::WTFMap<%s, %s>" if _for_blink else "mojo::Map<%s, %s>"
223 GetCppArrayArgWrapperType(kind.value_kind)) 224 return pattern % (GetCppArrayArgWrapperType(kind.key_kind),
225 GetCppArrayArgWrapperType(kind.value_kind))
224 if mojom.IsInterfaceKind(kind): 226 if mojom.IsInterfaceKind(kind):
225 return "%sPtr" % GetNameForKind(kind) 227 return "%sPtr" % GetNameForKind(kind)
226 if mojom.IsInterfaceRequestKind(kind): 228 if mojom.IsInterfaceRequestKind(kind):
227 return "%sRequest" % GetNameForKind(kind.kind) 229 return "%sRequest" % GetNameForKind(kind.kind)
228 if mojom.IsAssociatedInterfaceKind(kind): 230 if mojom.IsAssociatedInterfaceKind(kind):
229 return "%sAssociatedPtrInfo" % GetNameForKind(kind.kind) 231 return "%sAssociatedPtrInfo" % GetNameForKind(kind.kind)
230 if mojom.IsAssociatedInterfaceRequestKind(kind): 232 if mojom.IsAssociatedInterfaceRequestKind(kind):
231 return "%sAssociatedRequest" % GetNameForKind(kind.kind) 233 return "%sAssociatedRequest" % GetNameForKind(kind.kind)
232 if mojom.IsStringKind(kind): 234 if mojom.IsStringKind(kind):
233 return "WTF::String" if _for_blink else "mojo::String" 235 return "WTF::String" if _for_blink else "mojo::String"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 _for_blink = self.for_blink 524 _for_blink = self.for_blink
523 global _variant 525 global _variant
524 _variant = self.variant 526 _variant = self.variant
525 suffix = "-%s" % self.variant if self.variant else "" 527 suffix = "-%s" % self.variant if self.variant else ""
526 self.Write(self.GenerateModuleHeader(), 528 self.Write(self.GenerateModuleHeader(),
527 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 529 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
528 self.Write(self.GenerateModuleInternalHeader(), 530 self.Write(self.GenerateModuleInternalHeader(),
529 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 531 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
530 self.Write(self.GenerateModuleSource(), 532 self.Write(self.GenerateModuleSource(),
531 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 533 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698