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 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 104 |
105 // IsHandle returns true if the field is a handle type. | 105 // IsHandle returns true if the field is a handle type. |
106 IsHandle() bool | 106 IsHandle() bool |
107 | 107 |
108 // IsPointer returns true if the field is a pointer: struct, array, map
or string. | 108 // IsPointer returns true if the field is a pointer: struct, array, map
or string. |
109 IsPointer() bool | 109 IsPointer() bool |
110 | 110 |
111 // IsStruct returns true if the field is a struct. | 111 // IsStruct returns true if the field is a struct. |
112 IsStruct() bool | 112 IsStruct() bool |
113 | 113 |
| 114 // IsUnion returns true if the field is a union. |
| 115 IsUnion() bool |
| 116 |
114 // IsArray returns true if the field is an array. | 117 // IsArray returns true if the field is an array. |
115 IsArray() bool | 118 IsArray() bool |
116 | 119 |
117 // IsMap returns true if the field is a map. | 120 // IsMap returns true if the field is a map. |
118 IsMap() bool | 121 IsMap() bool |
119 | 122 |
120 // IsNullable returns true if the field is nullable. | 123 // IsNullable returns true if the field is nullable. |
121 IsNullable() bool | 124 IsNullable() bool |
122 setNullable(nullable bool) | 125 setNullable(nullable bool) |
123 | 126 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } | 179 } |
177 | 180 |
178 func (b *baseEncodingInfo) IsPointer() bool { | 181 func (b *baseEncodingInfo) IsPointer() bool { |
179 return false | 182 return false |
180 } | 183 } |
181 | 184 |
182 func (b *baseEncodingInfo) IsStruct() bool { | 185 func (b *baseEncodingInfo) IsStruct() bool { |
183 return false | 186 return false |
184 } | 187 } |
185 | 188 |
| 189 func (b *baseEncodingInfo) IsUnion() bool { |
| 190 return false |
| 191 } |
| 192 |
186 func (b *baseEncodingInfo) IsArray() bool { | 193 func (b *baseEncodingInfo) IsArray() bool { |
187 return false | 194 return false |
188 } | 195 } |
189 | 196 |
190 func (b *baseEncodingInfo) IsMap() bool { | 197 func (b *baseEncodingInfo) IsMap() bool { |
191 return false | 198 return false |
192 } | 199 } |
193 | 200 |
194 func (b *baseEncodingInfo) ElementEncodingInfo() EncodingInfo { | 201 func (b *baseEncodingInfo) ElementEncodingInfo() EncodingInfo { |
195 panic("Only arrays have elements!") | 202 panic("Only arrays have elements!") |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 return true | 388 return true |
382 } | 389 } |
383 | 390 |
384 func (t *structTypeEncodingInfo) WriteFunction() string { | 391 func (t *structTypeEncodingInfo) WriteFunction() string { |
385 panic("Structs don't have a write function.") | 392 panic("Structs don't have a write function.") |
386 } | 393 } |
387 | 394 |
388 func (t *structTypeEncodingInfo) ReadFunction() string { | 395 func (t *structTypeEncodingInfo) ReadFunction() string { |
389 panic("Structs don't have a read function.") | 396 panic("Structs don't have a read function.") |
390 } | 397 } |
| 398 |
| 399 //////////////////////////////////////////////////////////////////////////////// |
| 400 |
| 401 // unionTypeEncodingInfo is the EncodingInfo for a union. |
| 402 type unionTypeEncodingInfo struct { |
| 403 baseEncodingInfo |
| 404 nestedUnion bool |
| 405 nullable bool |
| 406 } |
| 407 |
| 408 func (t *unionTypeEncodingInfo) BitSize() uint32 { |
| 409 if t.nestedUnion { |
| 410 return uint32(64) |
| 411 } |
| 412 return uint32(128) |
| 413 } |
| 414 |
| 415 func (t *unionTypeEncodingInfo) IsUnion() bool { |
| 416 return true |
| 417 } |
| 418 |
| 419 func (t *unionTypeEncodingInfo) IsPointer() bool { |
| 420 return t.nestedUnion |
| 421 } |
| 422 |
| 423 func (b *unionTypeEncodingInfo) IsNullable() bool { |
| 424 return b.nullable |
| 425 } |
| 426 |
| 427 func (b *unionTypeEncodingInfo) setNullable(nullable bool) { |
| 428 b.nullable = nullable |
| 429 } |
| 430 |
| 431 func (t *unionTypeEncodingInfo) WriteFunction() string { |
| 432 panic("Unions don't have a write function.") |
| 433 } |
| 434 |
| 435 func (t *unionTypeEncodingInfo) ReadFunction() string { |
| 436 panic("Unions don't have a read function.") |
| 437 } |
OLD | NEW |