| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 parser | 5 package parser |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "mojom/mojom_parser/mojom" | 9 "mojom/mojom_parser/mojom" |
| 10 "strings" | 10 "strings" |
| (...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 | 1038 |
| 1039 struct MyStruct { | 1039 struct MyStruct { |
| 1040 const Color RED = BLUE; | 1040 const Color RED = BLUE; |
| 1041 | 1041 |
| 1042 Color a_color = RED; // This should resolve to the local constant RED, | 1042 Color a_color = RED; // This should resolve to the local constant RED, |
| 1043 // and therefore the concrete value should be BLUE. | 1043 // and therefore the concrete value should be BLUE. |
| 1044 };` | 1044 };` |
| 1045 | 1045 |
| 1046 testFunc := func(descriptor *mojom.MojomDescriptor) error { | 1046 testFunc := func(descriptor *mojom.MojomDescriptor) error { |
| 1047 myStructType := descriptor.TypesByKey["TYPE_KEY:MyStruct
"].(*mojom.MojomStruct) | 1047 myStructType := descriptor.TypesByKey["TYPE_KEY:MyStruct
"].(*mojom.MojomStruct) |
| 1048 » » » aColorField := myStructType.Fields[0] | 1048 » » » aColorField := myStructType.FieldsInLexicalOrder[0] |
| 1049 concreteValue := aColorField.DefaultValue.ResolvedConcre
teValue().(*mojom.EnumValue) | 1049 concreteValue := aColorField.DefaultValue.ResolvedConcre
teValue().(*mojom.EnumValue) |
| 1050 key := concreteValue.ValueKey() | 1050 key := concreteValue.ValueKey() |
| 1051 if key != "TYPE_KEY:Color.BLUE" { | 1051 if key != "TYPE_KEY:Color.BLUE" { |
| 1052 return fmt.Errorf("%s != TYPE_KEY:Color.BLUE", k
ey) | 1052 return fmt.Errorf("%s != TYPE_KEY:Color.BLUE", k
ey) |
| 1053 } | 1053 } |
| 1054 return nil | 1054 return nil |
| 1055 } | 1055 } |
| 1056 test.addTestCase("", contents, testFunc) | 1056 test.addTestCase("", contents, testFunc) |
| 1057 } | 1057 } |
| 1058 | 1058 |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 typeKey = mojom.ComputeTypeKey(t) | 1386 typeKey = mojom.ComputeTypeKey(t) |
| 1387 } | 1387 } |
| 1388 userDefinedType := descriptor.TypesByKey[typeKey] | 1388 userDefinedType := descriptor.TypesByKey[typeKey] |
| 1389 if userDefinedType == nil { | 1389 if userDefinedType == nil { |
| 1390 panic(fmt.Sprintf("No type found for: %s", t)) | 1390 panic(fmt.Sprintf("No type found for: %s", t)) |
| 1391 } | 1391 } |
| 1392 typeSet.Add(userDefinedType) | 1392 typeSet.Add(userDefinedType) |
| 1393 } | 1393 } |
| 1394 return typeSet | 1394 return typeSet |
| 1395 } | 1395 } |
| OLD | NEW |