| OLD | NEW |
| 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 Loading... |
| 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 // EncodingInfo contains the information necessary to encode and decode
the field. |
| 95 EncodingInfo EncodingInfo |
| 96 } |
| 97 |
| 72 //////////////////////////////////////////////////////////////////////////////// | 98 //////////////////////////////////////////////////////////////////////////////// |
| 73 | 99 |
| 74 // EncodingInfo describes the information necessary to encode a field. | 100 // EncodingInfo describes the information necessary to encode a field. |
| 75 type EncodingInfo interface { | 101 type EncodingInfo interface { |
| 76 // IsSimple returns true if the field is a numeric type, boolean or stri
ng. | 102 // IsSimple returns true if the field is a numeric type, boolean or stri
ng. |
| 77 IsSimple() bool | 103 IsSimple() bool |
| 78 | 104 |
| 79 // IsHandle returns true if the field is a handle type. | 105 // IsHandle returns true if the field is a handle type. |
| 80 IsHandle() bool | 106 IsHandle() bool |
| 81 | 107 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return true | 381 return true |
| 356 } | 382 } |
| 357 | 383 |
| 358 func (t *structTypeEncodingInfo) WriteFunction() string { | 384 func (t *structTypeEncodingInfo) WriteFunction() string { |
| 359 panic("Structs don't have a write function.") | 385 panic("Structs don't have a write function.") |
| 360 } | 386 } |
| 361 | 387 |
| 362 func (t *structTypeEncodingInfo) ReadFunction() string { | 388 func (t *structTypeEncodingInfo) ReadFunction() string { |
| 363 panic("Structs don't have a read function.") | 389 panic("Structs don't have a read function.") |
| 364 } | 390 } |
| OLD | NEW |