Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(324)

Side by Side Diff: mojo/public/tools/bindings/generators/go_templates/struct.tmpl

Issue 1719873003: Mojom runtime type info: New implementation for Go. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebasing Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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(struct, typepkg, package, exported=True) %} 7 {% macro define(struct, typepkg, package, exported=True) %}
9 type {{struct|name(exported)}} struct { 8 type {{struct|name(exported)}} struct {
10 {% for field in struct.fields %} 9 {% for field in struct.fields %}
11 {{field|name(exported)}} {{field.kind|go_type}} 10 {{field|name(exported)}} {{field.kind|go_type}}
12 {% endfor %} 11 {% endfor %}
13 } 12 }
14 13
15 func (s *{{struct|name(exported)}}) Encode(encoder *bindings.Encoder) error { 14 func (s *{{struct|name(exported)}}) Encode(encoder *bindings.Encoder) error {
16 {% set HEADER_SIZE = 8 %} 15 {% set HEADER_SIZE = 8 %}
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 {{encoding_macros.decode('s.'~packed_field.field|name(exported), packed_field.field.kind)|tab_indent(2)}} 56 {{encoding_macros.decode('s.'~packed_field.field|name(exported), packed_field.field.kind)|tab_indent(2)}}
58 } 57 }
59 {% endfor %} 58 {% endfor %}
60 {% endfor %} 59 {% endfor %}
61 if err := decoder.Finish(); err != nil { 60 if err := decoder.Finish(); err != nil {
62 return err 61 return err
63 } 62 }
64 return nil 63 return nil
65 } 64 }
66 65
67 {{ mojom_type_macros.writeMojomTypeDef(typepkg, struct, package, exported) }}
68
69 {% endmacro %} 66 {% endmacro %}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698