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

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

Issue 2888503002: Mojo bindings generator: introduce Stylizer to specify naming rules. (Closed)
Patch Set: Created 3 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 | « no previous file | mojo/public/tools/bindings/generators/mojom_java_generator.py » ('j') | 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 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 374
375 @UseJinja("module-shared-internal.h.tmpl") 375 @UseJinja("module-shared-internal.h.tmpl")
376 def _GenerateModuleSharedInternalHeader(self): 376 def _GenerateModuleSharedInternalHeader(self):
377 return self._GetJinjaExports() 377 return self._GetJinjaExports()
378 378
379 @UseJinja("module-shared.cc.tmpl") 379 @UseJinja("module-shared.cc.tmpl")
380 def _GenerateModuleSharedSource(self): 380 def _GenerateModuleSharedSource(self):
381 return self._GetJinjaExports() 381 return self._GetJinjaExports()
382 382
383 def GenerateFiles(self, args): 383 def GenerateFiles(self, args):
384 self.module.Stylize(generator.Stylizer())
385
384 if self.generate_non_variant_code: 386 if self.generate_non_variant_code:
385 self.Write(self._GenerateModuleSharedHeader(), 387 self.Write(self._GenerateModuleSharedHeader(),
386 self.MatchMojomFilePath("%s-shared.h" % self.module.name)) 388 "%s-shared.h" % self.module.path)
387 self.Write( 389 self.Write(self._GenerateModuleSharedInternalHeader(),
388 self._GenerateModuleSharedInternalHeader(), 390 "%s-shared-internal.h" % self.module.path)
389 self.MatchMojomFilePath("%s-shared-internal.h" % self.module.name))
390 self.Write(self._GenerateModuleSharedSource(), 391 self.Write(self._GenerateModuleSharedSource(),
391 self.MatchMojomFilePath("%s-shared.cc" % self.module.name)) 392 "%s-shared.cc" % self.module.path)
392 else: 393 else:
393 suffix = "-%s" % self.variant if self.variant else "" 394 suffix = "-%s" % self.variant if self.variant else ""
394 self.Write(self._GenerateModuleHeader(), 395 self.Write(self._GenerateModuleHeader(),
395 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix))) 396 "%s%s.h" % (self.module.path, suffix))
396 self.Write( 397 self.Write(self._GenerateModuleSource(),
397 self._GenerateModuleSource(), 398 "%s%s.cc" % (self.module.path, suffix))
398 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
399 399
400 def _ConstantValue(self, constant): 400 def _ConstantValue(self, constant):
401 return self._ExpressionToText(constant.value, kind=constant.kind) 401 return self._ExpressionToText(constant.value, kind=constant.kind)
402 402
403 # TODO(yzshen): Revisit the default value feature. It was designed prior to 403 # TODO(yzshen): Revisit the default value feature. It was designed prior to
404 # custom type mapping. 404 # custom type mapping.
405 def _DefaultValue(self, field): 405 def _DefaultValue(self, field):
406 if field.default: 406 if field.default:
407 if mojom.IsStructKind(field.kind): 407 if mojom.IsStructKind(field.kind):
408 assert field.default == "default" 408 assert field.default == "default"
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 if mojom.IsDataPipeProducerKind(kind): 795 if mojom.IsDataPipeProducerKind(kind):
796 return "mojo::ScopedDataPipeProducerHandle" 796 return "mojo::ScopedDataPipeProducerHandle"
797 if mojom.IsMessagePipeKind(kind): 797 if mojom.IsMessagePipeKind(kind):
798 return "mojo::ScopedMessagePipeHandle" 798 return "mojo::ScopedMessagePipeHandle"
799 if mojom.IsSharedBufferKind(kind): 799 if mojom.IsSharedBufferKind(kind):
800 return "mojo::ScopedSharedBufferHandle" 800 return "mojo::ScopedSharedBufferHandle"
801 return _kind_to_cpp_type[kind] 801 return _kind_to_cpp_type[kind]
802 802
803 def _GetUnmappedTypeForSerializer(self, kind): 803 def _GetUnmappedTypeForSerializer(self, kind):
804 return self._GetCppDataViewType(kind, qualified=True) 804 return self._GetCppDataViewType(kind, qualified=True)
OLDNEW
« no previous file with comments | « no previous file | mojo/public/tools/bindings/generators/mojom_java_generator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698