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 | 9 |
10 "mojom/generated/mojom_types" | 10 "mojom/generated/mojom_types" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 valueEncodingInfo.elementEncodingInfo = t.encodingInfoNested(mojomType.V
alueType, level+1) | 133 valueEncodingInfo.elementEncodingInfo = t.encodingInfoNested(mojomType.V
alueType, level+1) |
134 valueEncodingInfo.setIdentifier(fmt.Sprintf("values%v", level)) | 134 valueEncodingInfo.setIdentifier(fmt.Sprintf("values%v", level)) |
135 valueEncodingInfo.setGoType(fmt.Sprintf("[]%v", valueEncodingInfo.elemen
tEncodingInfo.GoType())) | 135 valueEncodingInfo.setGoType(fmt.Sprintf("[]%v", valueEncodingInfo.elemen
tEncodingInfo.GoType())) |
136 valueEncodingInfo.elementEncodingInfo.setIdentifier(fmt.Sprintf("value%v
", level)) | 136 valueEncodingInfo.elementEncodingInfo.setIdentifier(fmt.Sprintf("value%v
", level)) |
137 | 137 |
138 return info | 138 return info |
139 } | 139 } |
140 | 140 |
141 func (t *translator) typeRefEncodingInfo(typeRef mojom_types.TypeReference) (inf
o EncodingInfo) { | 141 func (t *translator) typeRefEncodingInfo(typeRef mojom_types.TypeReference) (inf
o EncodingInfo) { |
142 mojomType := t.GetUserDefinedType(*typeRef.TypeKey) | 142 mojomType := t.GetUserDefinedType(*typeRef.TypeKey) |
143 » switch m := mojomType.(type) { | 143 » switch mojomType.(type) { |
144 default: | 144 default: |
145 panic("Unsupported type. This should never happen.") | 145 panic("Unsupported type. This should never happen.") |
146 case *mojom_types.UserDefinedTypeStructType: | 146 case *mojom_types.UserDefinedTypeStructType: |
147 » » info = t.structTypeEncodingInfo(m.Value) | 147 » » info = new(structTypeEncodingInfo) |
148 case *mojom_types.UserDefinedTypeUnionType: | 148 case *mojom_types.UserDefinedTypeUnionType: |
149 » » info = t.unionTypeEncodingInfo(m.Value) | 149 » » info = new(unionTypeEncodingInfo) |
150 case *mojom_types.UserDefinedTypeEnumType: | 150 case *mojom_types.UserDefinedTypeEnumType: |
151 » » info = t.enumTypeEncodingInfo(m.Value) | 151 » » info = new(enumTypeEncodingInfo) |
| 152 » case *mojom_types.UserDefinedTypeInterfaceType: |
| 153 » » info = new(interfaceTypeEncodingInfo) |
| 154 » » info.(*interfaceTypeEncodingInfo).interfaceRequest = typeRef.IsI
nterfaceRequest |
152 } | 155 } |
153 if typeRef.Nullable { | 156 if typeRef.Nullable { |
154 info.setNullable(true) | 157 info.setNullable(true) |
155 } | 158 } |
156 return info | 159 return info |
157 } | 160 } |
158 | |
159 func (t *translator) structTypeEncodingInfo(mojomType mojom_types.MojomStruct) (
info *structTypeEncodingInfo) { | |
160 info = new(structTypeEncodingInfo) | |
161 return info | |
162 } | |
163 | |
164 func (t *translator) unionTypeEncodingInfo(mojomType mojom_types.MojomUnion) (in
fo *unionTypeEncodingInfo) { | |
165 info = new(unionTypeEncodingInfo) | |
166 return info | |
167 } | |
168 | |
169 func (t *translator) enumTypeEncodingInfo(mojomType mojom_types.MojomEnum) (info
*enumTypeEncodingInfo) { | |
170 info = new(enumTypeEncodingInfo) | |
171 return info | |
172 } | |
OLD | NEW |