| 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 {% import "encoding_macros.tmpl" as encoding_macros %} | 5 {% import "encoding_macros.tmpl" as encoding_macros %} |
| 6 {% import "mojom_type_macros.tmpl" as mojom_type_macros %} | |
| 7 | 6 |
| 8 {% macro define(union, typepkg, package, exported=True) %} | 7 {% macro define(union, typepkg, package, exported=True) %} |
| 9 type {{union|name(exported)}} interface { | 8 type {{union|name(exported)}} interface { |
| 10 Tag() uint32 | 9 Tag() uint32 |
| 11 Interface() interface{} | 10 Interface() interface{} |
| 12 __Reflect(__{{union|name(exported)}}Reflect) | 11 __Reflect(__{{union|name(exported)}}Reflect) |
| 13 Encode(encoder *bindings.Encoder) error | 12 Encode(encoder *bindings.Encoder) error |
| 14 } | 13 } |
| 15 | 14 |
| 16 type __{{union|name(exported)}}Reflect struct { | 15 type __{{union|name(exported)}}Reflect struct { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 return nil | 69 return nil |
| 71 } | 70 } |
| 72 | 71 |
| 73 func (u *{{struct_name}}) decodeInternal(decoder *bindings.Decoder) error { | 72 func (u *{{struct_name}}) decodeInternal(decoder *bindings.Decoder) error { |
| 74 {{decode_union_field('u.Value', field.kind)|tab_indent()}} | 73 {{decode_union_field('u.Value', field.kind)|tab_indent()}} |
| 75 return nil | 74 return nil |
| 76 } | 75 } |
| 77 | 76 |
| 78 {% endfor %} | 77 {% endfor %} |
| 79 | 78 |
| 80 {{ mojom_type_macros.writeMojomTypeDef(typepkg, union, package, exported) }} | |
| 81 | |
| 82 {% endmacro %} | 79 {% endmacro %} |
| 83 | 80 |
| 84 {% macro encode_union_field(value, kind) %} | 81 {% macro encode_union_field(value, kind) %} |
| 85 {% if kind|is_union %} | 82 {% if kind|is_union %} |
| 86 if err := encoder.WritePointer(); err != nil { | 83 if err := encoder.WritePointer(); err != nil { |
| 87 return err | 84 return err |
| 88 } | 85 } |
| 89 | 86 |
| 90 encoder.StartNestedUnion() | 87 encoder.StartNestedUnion() |
| 91 {{encoding_macros.encode(value, kind)}} | 88 {{encoding_macros.encode(value, kind)}} |
| (...skipping 21 matching lines...) Expand all Loading... |
| 113 return err | 110 return err |
| 114 } | 111 } |
| 115 | 112 |
| 116 {{encoding_macros.decode(value, kind)}} | 113 {{encoding_macros.decode(value, kind)}} |
| 117 | 114 |
| 118 decoder.Finish() | 115 decoder.Finish() |
| 119 {% else %} | 116 {% else %} |
| 120 {{encoding_macros.decode(value, kind)}} | 117 {{encoding_macros.decode(value, kind)}} |
| 121 {% endif %} | 118 {% endif %} |
| 122 {% endmacro %} | 119 {% endmacro %} |
| OLD | NEW |