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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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))) |
OLD | NEW |