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

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

Issue 177183002: Mojo: Include "path/to/foo.mojom.h" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove unnecessary abspath Created 6 years, 9 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 | Annotate | Revision Log
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 from generate import mojom 7 from generate import mojom
8 from generate import mojom_pack 8 from generate import mojom_pack
9 from generate import mojom_generator 9 from generate import mojom_generator
10 10
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 "struct_size": lambda ps: ps.GetTotalSize() + _HEADER_SIZE, 134 "struct_size": lambda ps: ps.GetTotalSize() + _HEADER_SIZE,
135 "struct_from_method": mojom_generator.GetStructFromMethod, 135 "struct_from_method": mojom_generator.GetStructFromMethod,
136 "stylize_method": mojom_generator.StudlyCapsToCamel, 136 "stylize_method": mojom_generator.StudlyCapsToCamel,
137 "verify_token_type": mojom_generator.VerifyTokenType, 137 "verify_token_type": mojom_generator.VerifyTokenType,
138 } 138 }
139 139
140 def GetJinjaExports(self): 140 def GetJinjaExports(self):
141 return { 141 return {
142 "module": self.module, 142 "module": self.module,
143 "module_name": self.module.name, 143 "module_name": self.module.name,
144 "module_path": self.module.path,
144 "namespace": self.module.namespace, 145 "namespace": self.module.namespace,
145 "imports": self.module.imports, 146 "imports": self.module.imports,
146 "kinds": self.module.kinds, 147 "kinds": self.module.kinds,
147 "enums": self.module.enums, 148 "enums": self.module.enums,
148 "structs": self.GetStructs(), 149 "structs": self.GetStructs(),
149 "interfaces": self.module.interfaces, 150 "interfaces": self.module.interfaces,
150 "include_prefix": self.GetIncludePrefix(), 151 "include_prefix": self.GetIncludePrefix(),
151 } 152 }
152 153
153 @UseJinja("cpp_templates/module.h.tmpl", filters=cpp_filters) 154 @UseJinja("cpp_templates/module.h.tmpl", filters=cpp_filters)
154 def GenerateModuleHeader(self): 155 def GenerateModuleHeader(self):
155 return self.GetJinjaExports() 156 return self.GetJinjaExports()
156 157
157 @UseJinja("cpp_templates/module_internal.h.tmpl", filters=cpp_filters) 158 @UseJinja("cpp_templates/module-internal.h.tmpl", filters=cpp_filters)
158 def GenerateModuleInternalHeader(self): 159 def GenerateModuleInternalHeader(self):
159 return self.GetJinjaExports() 160 return self.GetJinjaExports()
160 161
161 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters) 162 @UseJinja("cpp_templates/module.cc.tmpl", filters=cpp_filters)
162 def GenerateModuleSource(self): 163 def GenerateModuleSource(self):
163 return self.GetJinjaExports() 164 return self.GetJinjaExports()
164 165
165 def GenerateFiles(self): 166 def GenerateFiles(self):
166 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name) 167 self.Write(self.GenerateModuleHeader(), "%s.h" % self.module.name)
167 self.Write(self.GenerateModuleInternalHeader(), 168 self.Write(self.GenerateModuleInternalHeader(),
168 "%s_internal.h" % self.module.name) 169 "%s-internal.h" % self.module.name)
169 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name) 170 self.Write(self.GenerateModuleSource(), "%s.cc" % self.module.name)
170 171
171 def GetIncludePrefix(self): 172 def GetIncludePrefix(self):
172 if not self.header_dir: 173 if not self.header_dir:
173 return "" 174 return ""
174 if self.header_dir[-1] == "/": 175 if self.header_dir[-1] == "/":
175 return self.header_dir 176 return self.header_dir
176 return self.header_dir + "/" 177 return self.header_dir + "/"
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698