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 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
301 return '\n'.join(struct_decls) | 301 return '\n'.join(struct_decls) |
302 | 302 |
303 def GetInterfaceClassDeclaration(self, interface, template, method_postfix): | 303 def GetInterfaceClassDeclaration(self, interface, template, method_postfix): |
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)) |
DaveMoore
2013/11/11 18:49:05
Since this ends up being a statically defined thin
| |
312 peer = interface.attributes['Peer'] | |
312 return template.substitute( | 313 return template.substitute( |
313 CLASS=interface.name, | 314 CLASS=interface.name, |
314 METHODS='.\n'.join(methods)) | 315 PEER=peer, |
316 METHODS='\n'.join(methods)) | |
315 | 317 |
316 def GetInterfaceClassDeclarations(self): | 318 def GetInterfaceClassDeclarations(self): |
317 template = self.GetTemplate("interface_declaration") | 319 template = self.GetTemplate("interface_declaration") |
318 interface_decls = \ | 320 interface_decls = \ |
319 map(lambda i: | 321 map(lambda i: |
320 self.GetInterfaceClassDeclaration(i, template, " = 0"), | 322 self.GetInterfaceClassDeclaration(i, template, " = 0"), |
321 self.module.interfaces) | 323 self.module.interfaces) |
322 return '\n'.join(interface_decls) | 324 return '\n'.join(interface_decls) |
323 | 325 |
324 def GetInterfaceProxyDeclarations(self): | 326 def GetInterfaceProxyDeclarations(self): |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
474 self.module.structs); | 476 self.module.structs); |
475 self.WriteTemplateToFile("module_internal.h", | 477 self.WriteTemplateToFile("module_internal.h", |
476 HEADER_GUARD = self.GetHeaderGuard(self.module.name + "_INTERNAL"), | 478 HEADER_GUARD = self.GetHeaderGuard(self.module.name + "_INTERNAL"), |
477 HEADER = self.GetHeaderFile(self.module.name), | 479 HEADER = self.GetHeaderFile(self.module.name), |
478 TRAITS = '\n'.join(traits)) | 480 TRAITS = '\n'.join(traits)) |
479 | 481 |
480 def GenerateFiles(self): | 482 def GenerateFiles(self): |
481 self.GenerateModuleHeader() | 483 self.GenerateModuleHeader() |
482 self.GenerateModuleInternalHeader() | 484 self.GenerateModuleInternalHeader() |
483 self.GenerateModuleSource() | 485 self.GenerateModuleSource() |
OLD | NEW |