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

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

Issue 1524703002: [mojo] Support native types with mojom wire format (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bindings-5-pickles
Patch Set: doc Created 5 years 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return _kind_to_cpp_type[kind] 125 return _kind_to_cpp_type[kind]
126 126
127 def GetCppPodType(kind): 127 def GetCppPodType(kind):
128 if mojom.IsStringKind(kind): 128 if mojom.IsStringKind(kind):
129 return "char*" 129 return "char*"
130 return _kind_to_cpp_type[kind] 130 return _kind_to_cpp_type[kind]
131 131
132 def GetCppArrayArgWrapperType(kind): 132 def GetCppArrayArgWrapperType(kind):
133 if mojom.IsStructKind(kind) and kind.native_only: 133 if mojom.IsStructKind(kind) and kind.native_only:
134 raise Exception("Cannot serialize containers of native-only types yet!") 134 raise Exception("Cannot serialize containers of native-only types yet!")
135 if IsTypemappedKind(kind):
136 raise Exception("Cannot serialize containers of typemapped structs yet!")
135 if mojom.IsEnumKind(kind): 137 if mojom.IsEnumKind(kind):
136 return GetNameForKind(kind) 138 return GetNameForKind(kind)
137 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): 139 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
138 return "%sPtr" % GetNameForKind(kind) 140 return "%sPtr" % GetNameForKind(kind)
139 if mojom.IsArrayKind(kind): 141 if mojom.IsArrayKind(kind):
140 return "mojo::Array<%s> " % GetCppArrayArgWrapperType(kind.kind) 142 return "mojo::Array<%s> " % GetCppArrayArgWrapperType(kind.kind)
141 if mojom.IsMapKind(kind): 143 if mojom.IsMapKind(kind):
142 return "mojo::Map<%s, %s> " % (GetCppArrayArgWrapperType(kind.key_kind), 144 return "mojo::Map<%s, %s> " % (GetCppArrayArgWrapperType(kind.key_kind),
143 GetCppArrayArgWrapperType(kind.value_kind)) 145 GetCppArrayArgWrapperType(kind.value_kind))
144 if mojom.IsInterfaceKind(kind): 146 if mojom.IsInterfaceKind(kind):
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 def GenerateFiles(self, args): 503 def GenerateFiles(self, args):
502 global _current_typemap 504 global _current_typemap
503 _current_typemap = self.typemap 505 _current_typemap = self.typemap
504 suffix = "-%s" % self.variant if self.variant else "" 506 suffix = "-%s" % self.variant if self.variant else ""
505 self.Write(self.GenerateModuleHeader(), 507 self.Write(self.GenerateModuleHeader(),
506 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 508 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
507 self.Write(self.GenerateModuleInternalHeader(), 509 self.Write(self.GenerateModuleInternalHeader(),
508 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix))) 510 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
509 self.Write(self.GenerateModuleSource(), 511 self.Write(self.GenerateModuleSource(),
510 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix))) 512 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698