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

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

Issue 1517043004: [mojo] Add typemap and variant support to generators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pickle3
Patch Set: set proper upstream 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 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 return { 422 return {
423 "module": self.module, 423 "module": self.module,
424 "namespace": self.module.namespace, 424 "namespace": self.module.namespace,
425 "namespaces_as_array": NamespaceToArray(self.module.namespace), 425 "namespaces_as_array": NamespaceToArray(self.module.namespace),
426 "imports": self.module.imports, 426 "imports": self.module.imports,
427 "kinds": self.module.kinds, 427 "kinds": self.module.kinds,
428 "enums": self.module.enums, 428 "enums": self.module.enums,
429 "structs": self.GetStructs(), 429 "structs": self.GetStructs(),
430 "unions": self.GetUnions(), 430 "unions": self.GetUnions(),
431 "interfaces": self.GetInterfaces(), 431 "interfaces": self.GetInterfaces(),
432 "variant": self.variant,
432 } 433 }
433 434
434 @UseJinja("cpp_templates/module.h.tmpl", filters=cpp_filters) 435 @UseJinja("cpp_templates/module.h.tmpl", filters=cpp_filters)
435 def GenerateModuleHeader(self): 436 def GenerateModuleHeader(self):
436 return self.GetJinjaExports() 437 return self.GetJinjaExports()
437 438
438 @UseJinja("cpp_templates/module-internal.h.tmpl", filters=cpp_filters) 439 @UseJinja("cpp_templates/module-internal.h.tmpl", filters=cpp_filters)
439 def GenerateModuleInternalHeader(self): 440 def GenerateModuleInternalHeader(self):
440 return self.GetJinjaExports() 441 return self.GetJinjaExports()
441 442
442 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters) 443 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters)
443 def GenerateModuleSource(self): 444 def GenerateModuleSource(self):
444 return self.GetJinjaExports() 445 return self.GetJinjaExports()
445 446
446 def GenerateFiles(self, args): 447 def GenerateFiles(self, args):
448 suffix = "-%s" % self.variant if self.variant else ""
447 self.Write(self.GenerateModuleHeader(), 449 self.Write(self.GenerateModuleHeader(),
448 self.MatchMojomFilePath("%s.h" % self.module.name)) 450 self.MatchMojomFilePath("%s%s.h" % (self.module.name, suffix)))
449 self.Write(self.GenerateModuleInternalHeader(), 451 self.Write(self.GenerateModuleInternalHeader(),
450 self.MatchMojomFilePath("%s-internal.h" % self.module.name)) 452 self.MatchMojomFilePath("%s%s-internal.h" % (self.module.name, suffix)))
451 self.Write(self.GenerateModuleSource(), 453 self.Write(self.GenerateModuleSource(),
452 self.MatchMojomFilePath("%s.cc" % self.module.name)) 454 self.MatchMojomFilePath("%s%s.cc" % (self.module.name, suffix)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698