| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 Python source files from a mojom.Module.""" | 5 """Generates Python source files from a mojom.Module.""" |
| 6 | 6 |
| 7 import re | 7 import re |
| 8 from itertools import ifilter | 8 from itertools import ifilter |
| 9 | 9 |
| 10 import mojom.generate.generator as generator | 10 import mojom.generate.generator as generator |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 'struct_from_method': GetStructFromMethod, | 291 'struct_from_method': GetStructFromMethod, |
| 292 } | 292 } |
| 293 | 293 |
| 294 @UseJinja('python_templates/module.py.tmpl', filters=python_filters) | 294 @UseJinja('python_templates/module.py.tmpl', filters=python_filters) |
| 295 def GeneratePythonModule(self): | 295 def GeneratePythonModule(self): |
| 296 return { | 296 return { |
| 297 'enums': self.module.enums, | 297 'enums': self.module.enums, |
| 298 'imports': self.GetImports(), | 298 'imports': self.GetImports(), |
| 299 'interfaces': self.GetQualifiedInterfaces(), | 299 'interfaces': self.GetQualifiedInterfaces(), |
| 300 'module': ComputeStaticValues(self.module), | 300 'module': ComputeStaticValues(self.module), |
| 301 'namespace': self.module.namespace, |
| 301 'structs': self.GetStructs(), | 302 'structs': self.GetStructs(), |
| 302 } | 303 } |
| 303 | 304 |
| 304 def GenerateFiles(self, args): | 305 def GenerateFiles(self, args): |
| 305 import_path = MojomToPythonImport(self.module.name) | 306 import_path = MojomToPythonImport(self.module.name) |
| 306 self.Write(self.GeneratePythonModule(), | 307 self.Write(self.GeneratePythonModule(), |
| 307 self.MatchMojomFilePath('%s.py' % import_path)) | 308 self.MatchMojomFilePath('%s.py' % import_path)) |
| 308 | 309 |
| 309 def GetImports(self): | 310 def GetImports(self): |
| 310 for each in self.module.imports: | 311 for each in self.module.imports: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 329 'Unable to find interface %s declared as client of %s.' % | 330 'Unable to find interface %s declared as client of %s.' % |
| 330 (interface.client, interface.name)) | 331 (interface.client, interface.name)) |
| 331 interface.qualified_client = interfaces_by_name[interface.client] | 332 interface.qualified_client = interfaces_by_name[interface.client] |
| 332 return sorted(interfaces, key=lambda i: (bool(i.client), i.name)) | 333 return sorted(interfaces, key=lambda i: (bool(i.client), i.name)) |
| 333 | 334 |
| 334 def GetJinjaParameters(self): | 335 def GetJinjaParameters(self): |
| 335 return { | 336 return { |
| 336 'lstrip_blocks': True, | 337 'lstrip_blocks': True, |
| 337 'trim_blocks': True, | 338 'trim_blocks': True, |
| 338 } | 339 } |
| OLD | NEW |