| OLD | NEW |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. | 1 # Copyright 2015 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 Go source files from a mojom.Module.''' | 5 '''Generates Go source files from a mojom.Module.''' |
| 6 | 6 |
| 7 from itertools import chain | 7 from itertools import chain |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 | 10 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 'unions': self.GetUnions(), | 324 'unions': self.GetUnions(), |
| 325 } | 325 } |
| 326 | 326 |
| 327 @UseJinja('go_templates/source.tmpl', filters=go_filters) | 327 @UseJinja('go_templates/source.tmpl', filters=go_filters) |
| 328 def GenerateSource(self): | 328 def GenerateSource(self): |
| 329 return self.GetParameters() | 329 return self.GetParameters() |
| 330 | 330 |
| 331 def GenerateFiles(self, args): | 331 def GenerateFiles(self, args): |
| 332 self.should_gen_mojom_types = "--generate_type_info" in args | 332 self.should_gen_mojom_types = "--generate_type_info" in args |
| 333 | 333 |
| 334 self.Write(self.GenerateSource(), os.path.join( | 334 self.Write(self.GenerateSource(), os.path.join("go", "src", |
| 335 GetPackagePath(self.module), "%s.go" % self.module.name)) | 335 GetPackagePath(self.module), "%s.go" % self.module.name)) |
| 336 | 336 |
| 337 def GetJinjaParameters(self): | 337 def GetJinjaParameters(self): |
| 338 return { | 338 return { |
| 339 'lstrip_blocks': True, | 339 'lstrip_blocks': True, |
| 340 'trim_blocks': True, | 340 'trim_blocks': True, |
| 341 } | 341 } |
| 342 | 342 |
| 343 def GetGlobals(self): | 343 def GetGlobals(self): |
| 344 return { | 344 return { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 446 # modify the |name| property. Instead we add a |go_name| property. | 446 # modify the |name| property. Instead we add a |go_name| property. |
| 447 def _GetResponseStructFromMethod(self, method): | 447 def _GetResponseStructFromMethod(self, method): |
| 448 self._AddStructComputedData(False, method.response_param_struct) | 448 self._AddStructComputedData(False, method.response_param_struct) |
| 449 if not hasattr(method.response_param_struct, "go_name"): | 449 if not hasattr(method.response_param_struct, "go_name"): |
| 450 # Only generate the go_names if they have not already been generated. | 450 # Only generate the go_names if they have not already been generated. |
| 451 method.response_param_struct.go_name = "%s_%s_ResponseParams" % ( | 451 method.response_param_struct.go_name = "%s_%s_ResponseParams" % ( |
| 452 GetNameForElement(method.interface), GetNameForElement(method)) | 452 GetNameForElement(method.interface), GetNameForElement(method)) |
| 453 for field in method.response_param_struct.fields: | 453 for field in method.response_param_struct.fields: |
| 454 field.go_name = "out%s" % GetNameForElement(field) | 454 field.go_name = "out%s" % GetNameForElement(field) |
| 455 return method.response_param_struct | 455 return method.response_param_struct |
| OLD | NEW |