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 |
11 from mojom.generate.template_expander import UseJinja | 11 from mojom.generate.template_expander import UseJinja |
12 | 12 |
13 import mojom.generate.generator as generator | 13 import mojom.generate.generator as generator |
14 import mojom.generate.module as mojom | 14 import mojom.generate.module as mojom |
15 import mojom.generate.pack as pack | 15 import mojom.generate.pack as pack |
16 | 16 |
| 17 GENERATOR_PREFIX = 'go' |
| 18 |
17 class KindInfo(object): | 19 class KindInfo(object): |
18 def __init__(self, go_type, encode_suffix, decode_suffix, bit_size): | 20 def __init__(self, go_type, encode_suffix, decode_suffix, bit_size): |
19 self.go_type = go_type | 21 self.go_type = go_type |
20 self.encode_suffix = encode_suffix | 22 self.encode_suffix = encode_suffix |
21 self.decode_suffix = decode_suffix | 23 self.decode_suffix = decode_suffix |
22 self.bit_size = bit_size | 24 self.bit_size = bit_size |
23 | 25 |
24 _kind_infos = { | 26 _kind_infos = { |
25 mojom.BOOL: KindInfo('bool', 'Bool', 'Bool', 1), | 27 mojom.BOOL: KindInfo('bool', 'Bool', 'Bool', 1), |
26 mojom.INT8: KindInfo('int8', 'Int8', 'Int8', 8), | 28 mojom.INT8: KindInfo('int8', 'Int8', 'Int8', 8), |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 # Overrides the implementation from the base class in order to customize the | 489 # Overrides the implementation from the base class in order to customize the |
488 # struct and field names. | 490 # struct and field names. |
489 def _GetResponseStructFromMethod(self, method): | 491 def _GetResponseStructFromMethod(self, method): |
490 params_class = "%s_%s_ResponseParams" % ( | 492 params_class = "%s_%s_ResponseParams" % ( |
491 GetNameForElement(method.interface), GetNameForElement(method)) | 493 GetNameForElement(method.interface), GetNameForElement(method)) |
492 struct = mojom.Struct(params_class, module=method.interface.module) | 494 struct = mojom.Struct(params_class, module=method.interface.module) |
493 for param in method.response_parameters: | 495 for param in method.response_parameters: |
494 struct.AddField("out%s" % GetNameForElement(param), | 496 struct.AddField("out%s" % GetNameForElement(param), |
495 param.kind, param.ordinal, attributes=param.attributes) | 497 param.kind, param.ordinal, attributes=param.attributes) |
496 return self._AddStructComputedData(False, struct) | 498 return self._AddStructComputedData(False, struct) |
OLD | NEW |