OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 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 datetime | 7 import datetime |
8 import mojom | 8 import mojom |
9 import mojom_pack | 9 import mojom_pack |
10 import os | 10 import os |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 methods = [] | 304 methods = [] |
305 for method in interface.methods: | 305 for method in interface.methods: |
306 params = [] | 306 params = [] |
307 for param in method.parameters: | 307 for param in method.parameters: |
308 params.append("%s %s" % (self.GetConstType(param.kind), param.name)) | 308 params.append("%s %s" % (self.GetConstType(param.kind), param.name)) |
309 methods.append( | 309 methods.append( |
310 " virtual void %s(%s) %s;" % | 310 " virtual void %s(%s) %s;" % |
311 (method.name, ", ".join(params), method_postfix)) | 311 (method.name, ", ".join(params), method_postfix)) |
312 return template.substitute( | 312 return template.substitute( |
313 CLASS=interface.name, | 313 CLASS=interface.name, |
314 METHODS='.\n'.join(methods)) | 314 PEER=interface.peer, |
| 315 METHODS='\n'.join(methods)) |
315 | 316 |
316 def GetInterfaceClassDeclarations(self): | 317 def GetInterfaceClassDeclarations(self): |
317 template = self.GetTemplate("interface_declaration") | 318 template = self.GetTemplate("interface_declaration") |
318 interface_decls = \ | 319 interface_decls = \ |
319 map(lambda i: | 320 map(lambda i: |
320 self.GetInterfaceClassDeclaration(i, template, " = 0"), | 321 self.GetInterfaceClassDeclaration(i, template, " = 0"), |
321 self.module.interfaces) | 322 self.module.interfaces) |
322 return '\n'.join(interface_decls) | 323 return '\n'.join(interface_decls) |
323 | 324 |
324 def GetInterfaceProxyDeclarations(self): | 325 def GetInterfaceProxyDeclarations(self): |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 self.module.structs); | 475 self.module.structs); |
475 self.WriteTemplateToFile("module_internal.h", | 476 self.WriteTemplateToFile("module_internal.h", |
476 HEADER_GUARD = self.GetHeaderGuard(self.module.name + "_INTERNAL"), | 477 HEADER_GUARD = self.GetHeaderGuard(self.module.name + "_INTERNAL"), |
477 HEADER = self.GetHeaderFile(self.module.name), | 478 HEADER = self.GetHeaderFile(self.module.name), |
478 TRAITS = '\n'.join(traits)) | 479 TRAITS = '\n'.join(traits)) |
479 | 480 |
480 def GenerateFiles(self): | 481 def GenerateFiles(self): |
481 self.GenerateModuleHeader() | 482 self.GenerateModuleHeader() |
482 self.GenerateModuleInternalHeader() | 483 self.GenerateModuleInternalHeader() |
483 self.GenerateModuleSource() | 484 self.GenerateModuleSource() |
OLD | NEW |