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

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

Issue 1294043002: Mojom compiler: Improves error message by giving misspelled identifier. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Add comment as requested in code review. Created 5 years, 4 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 | « no previous file | 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if mojom.IsGenericHandleKind(kind): 139 if mojom.IsGenericHandleKind(kind):
140 return "mojo::ScopedHandle" 140 return "mojo::ScopedHandle"
141 if mojom.IsDataPipeConsumerKind(kind): 141 if mojom.IsDataPipeConsumerKind(kind):
142 return "mojo::ScopedDataPipeConsumerHandle" 142 return "mojo::ScopedDataPipeConsumerHandle"
143 if mojom.IsDataPipeProducerKind(kind): 143 if mojom.IsDataPipeProducerKind(kind):
144 return "mojo::ScopedDataPipeProducerHandle" 144 return "mojo::ScopedDataPipeProducerHandle"
145 if mojom.IsMessagePipeKind(kind): 145 if mojom.IsMessagePipeKind(kind):
146 return "mojo::ScopedMessagePipeHandle" 146 return "mojo::ScopedMessagePipeHandle"
147 if mojom.IsSharedBufferKind(kind): 147 if mojom.IsSharedBufferKind(kind):
148 return "mojo::ScopedSharedBufferHandle" 148 return "mojo::ScopedSharedBufferHandle"
149 return _kind_to_cpp_type[kind] 149 # TODO(rudominer) After improvements to compiler front end have landed,
150 # revisit strategy used below for emitting a useful error message when an
151 # undefined identifier is referenced.
152 val = _kind_to_cpp_type.get(kind)
153 if (val is not None):
154 return val
155 raise Exception("Unrecognized kind %s" % kind.spec)
150 156
151 def GetCppWrapperType(kind): 157 def GetCppWrapperType(kind):
152 if mojom.IsEnumKind(kind): 158 if mojom.IsEnumKind(kind):
153 return GetNameForKind(kind) 159 return GetNameForKind(kind)
154 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind): 160 if mojom.IsStructKind(kind) or mojom.IsUnionKind(kind):
155 return "%sPtr" % GetNameForKind(kind) 161 return "%sPtr" % GetNameForKind(kind)
156 if mojom.IsArrayKind(kind): 162 if mojom.IsArrayKind(kind):
157 return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind) 163 return "mojo::Array<%s>" % GetCppArrayArgWrapperType(kind.kind)
158 if mojom.IsMapKind(kind): 164 if mojom.IsMapKind(kind):
159 return "mojo::Map<%s, %s>" % (GetCppArrayArgWrapperType(kind.key_kind), 165 return "mojo::Map<%s, %s>" % (GetCppArrayArgWrapperType(kind.key_kind),
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 def GenerateModuleSource(self): 412 def GenerateModuleSource(self):
407 return self.GetJinjaExports() 413 return self.GetJinjaExports()
408 414
409 def GenerateFiles(self, args): 415 def GenerateFiles(self, args):
410 self.Write(self.GenerateModuleHeader(), 416 self.Write(self.GenerateModuleHeader(),
411 self.MatchMojomFilePath("%s.h" % self.module.name)) 417 self.MatchMojomFilePath("%s.h" % self.module.name))
412 self.Write(self.GenerateModuleInternalHeader(), 418 self.Write(self.GenerateModuleInternalHeader(),
413 self.MatchMojomFilePath("%s-internal.h" % self.module.name)) 419 self.MatchMojomFilePath("%s-internal.h" % self.module.name))
414 self.Write(self.GenerateModuleSource(), 420 self.Write(self.GenerateModuleSource(),
415 self.MatchMojomFilePath("%s.cc" % self.module.name)) 421 self.MatchMojomFilePath("%s.cc" % self.module.name))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698