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 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "strings" | 9 "strings" |
10 ) | 10 ) |
11 | 11 |
12 // TmplFile contains all of the information needed by the templates to generate | 12 // TmplFile contains all of the information needed by the templates to generate |
13 // the go bindings for one mojom file. | 13 // the go bindings for one mojom file. |
14 type TmplFile struct { | 14 type TmplFile struct { |
15 PackageName string | 15 PackageName string |
16 Imports []Import | 16 Imports []Import |
17 Structs []*StructTemplate | 17 Structs []*StructTemplate |
18 Unions []*UnionTemplate | 18 Unions []*UnionTemplate |
19 Enums []*EnumTemplate | 19 Enums []*EnumTemplate |
20 Interfaces []*InterfaceTemplate | 20 Interfaces []*InterfaceTemplate |
21 Constants []*ConstantTemplate | |
vardhan
2016/08/15 22:51:59
tabs
azani
2016/08/15 23:49:39
Done.
| |
21 MojomImports []string | 22 MojomImports []string |
22 SerializedRuntimeTypeInfo string | 23 SerializedRuntimeTypeInfo string |
23 } | 24 } |
24 | 25 |
25 type Import struct { | 26 type Import struct { |
26 PackagePath string | 27 PackagePath string |
27 PackageName string | 28 PackageName string |
28 } | 29 } |
29 | 30 |
30 func (t *TmplFile) TypesPkg() string { | 31 func (t *TmplFile) TypesPkg() string { |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 | 216 |
216 // ResponseParams of the method. | 217 // ResponseParams of the method. |
217 ResponseParams *StructTemplate | 218 ResponseParams *StructTemplate |
218 | 219 |
219 // Interface is the interface that contains this method. | 220 // Interface is the interface that contains this method. |
220 Interface *InterfaceTemplate | 221 Interface *InterfaceTemplate |
221 } | 222 } |
222 | 223 |
223 //////////////////////////////////////////////////////////////////////////////// | 224 //////////////////////////////////////////////////////////////////////////////// |
224 | 225 |
226 type ConstantTemplate struct { | |
227 Name string | |
228 | |
vardhan
2016/08/15 22:51:59
empty spaces not necessary if there are no comment
azani
2016/08/15 23:49:39
Done.
| |
229 Type string | |
230 | |
231 Value string | |
232 } | |
233 | |
234 //////////////////////////////////////////////////////////////////////////////// | |
235 | |
225 // EncodingInfo describes the information necessary to encode a field. | 236 // EncodingInfo describes the information necessary to encode a field. |
226 type EncodingInfo interface { | 237 type EncodingInfo interface { |
227 // IsSimple returns true if the field is a numeric type, boolean or stri ng. | 238 // IsSimple returns true if the field is a numeric type, boolean or stri ng. |
228 IsSimple() bool | 239 IsSimple() bool |
229 | 240 |
230 // IsHandle returns true if the field is a handle type. | 241 // IsHandle returns true if the field is a handle type. |
231 IsHandle() bool | 242 IsHandle() bool |
232 | 243 |
233 // IsPointer returns true if the field is a pointer: struct, array, map or string. | 244 // IsPointer returns true if the field is a pointer: struct, array, map or string. |
234 IsPointer() bool | 245 IsPointer() bool |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
689 } | 700 } |
690 } | 701 } |
691 | 702 |
692 func (t *interfaceTypeEncodingInfo) ReadFunction() string { | 703 func (t *interfaceTypeEncodingInfo) ReadFunction() string { |
693 if t.interfaceRequest { | 704 if t.interfaceRequest { |
694 return "ReadMessagePipeHandle" | 705 return "ReadMessagePipeHandle" |
695 } else { | 706 } else { |
696 return "ReadInterface" | 707 return "ReadInterface" |
697 } | 708 } |
698 } | 709 } |
OLD | NEW |