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

Side by Side Diff: mojom/generators/go/translator/mojom_file.go

Issue 2045063002: [New go generator] Implement declaring unions. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 6 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 package translator 5 package translator
6 6
7 // TmplFile contains all of the information needed by the templates to generate 7 // TmplFile contains all of the information needed by the templates to generate
8 // the go bindings for one mojom file. 8 // the go bindings for one mojom file.
9 type TmplFile struct { 9 type TmplFile struct {
10 PackageName string 10 PackageName string
11 Imports []Import 11 Imports []Import
12 Structs []*StructTemplate 12 Structs []*StructTemplate
13 Unions []*UnionTemplate
13 } 14 }
14 15
15 type Import struct { 16 type Import struct {
16 PackagePath string 17 PackagePath string
17 PackageName string 18 PackageName string
18 } 19 }
19 20
20 //////////////////////////////////////////////////////////////////////////////// 21 ////////////////////////////////////////////////////////////////////////////////
21 22
22 // StructTemplate contains all of the information needed by the templates to 23 // StructTemplate contains all of the information needed by the templates to
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 63
63 // structVersion contains the description of a struct's version. 64 // structVersion contains the description of a struct's version.
64 type structVersion struct { 65 type structVersion struct {
65 // NumBytes is the size of the struct in bytes at that version. 66 // NumBytes is the size of the struct in bytes at that version.
66 NumBytes uint32 67 NumBytes uint32
67 68
68 // Version is the version number. 69 // Version is the version number.
69 Version uint32 70 Version uint32
70 } 71 }
71 72
73 type UnionTemplate struct {
74 // Name is the name of the union in go code.
75 Name string
76
77 // Fields contains the list of fields of the union.
78 Fields []UnionFieldTemplate
79 }
80
81 type UnionFieldTemplate struct {
82 // Name is the name of the field in go.
83 Name string
84
85 // Type is the go type of the field value.
86 Type string
87
88 // Tag of the field.
89 Tag uint32
90
91 // Union is the union containing this field.
92 Union *UnionTemplate
93 }
94
72 //////////////////////////////////////////////////////////////////////////////// 95 ////////////////////////////////////////////////////////////////////////////////
73 96
74 // EncodingInfo describes the information necessary to encode a field. 97 // EncodingInfo describes the information necessary to encode a field.
75 type EncodingInfo interface { 98 type EncodingInfo interface {
76 // IsSimple returns true if the field is a numeric type, boolean or stri ng. 99 // IsSimple returns true if the field is a numeric type, boolean or stri ng.
77 IsSimple() bool 100 IsSimple() bool
78 101
79 // IsHandle returns true if the field is a handle type. 102 // IsHandle returns true if the field is a handle type.
80 IsHandle() bool 103 IsHandle() bool
81 104
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return true 378 return true
356 } 379 }
357 380
358 func (t *structTypeEncodingInfo) WriteFunction() string { 381 func (t *structTypeEncodingInfo) WriteFunction() string {
359 panic("Structs don't have a write function.") 382 panic("Structs don't have a write function.")
360 } 383 }
361 384
362 func (t *structTypeEncodingInfo) ReadFunction() string { 385 func (t *structTypeEncodingInfo) ReadFunction() string {
363 panic("Structs don't have a read function.") 386 panic("Structs don't have a read function.")
364 } 387 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698