Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Unified Diff: mojom/mojom_tool/mojom/user_defined_types.go

Issue 1958463003: Mojom compiler: Eliminate duplicate representation of enum values in mojom_files.mojom. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Responded to code reveiw comments. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojom/generated/mojom_types/mojom_types.mojom.go ('k') | mojom/mojom_tool/serialization/serialization.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_tool/mojom/user_defined_types.go
diff --git a/mojom/mojom_tool/mojom/user_defined_types.go b/mojom/mojom_tool/mojom/user_defined_types.go
index a3019ad29cf131ed708fd7f6aa86c872a61d0c6e..9cd5513d5623b281d25846e8f4f952fd712271d3 100644
--- a/mojom/mojom_tool/mojom/user_defined_types.go
+++ b/mojom/mojom_tool/mojom/user_defined_types.go
@@ -1123,6 +1123,7 @@ func (e *MojomEnum) InitAsScope(parentScope *Scope) *Scope {
func (e *MojomEnum) AddEnumValue(declData DeclarationData, valueRef ValueRef) DuplicateNameError {
enumValue := new(EnumValue)
enumValue.Init(declData, UserDefinedValueKindEnumValue, enumValue, valueRef)
+ enumValue.valueIndex = uint32(len(e.Values))
e.Values = append(e.Values, enumValue)
e.DeclaredObjects = append(e.DeclaredObjects, enumValue)
enumValue.enumType = e
@@ -1154,6 +1155,8 @@ type EnumValue struct {
UserDefinedValueBase
enumType *MojomEnum
+ // The 0-based index of this EnumValue in the |values| slice of |enumType|.
+ valueIndex uint32
// After all values in the MojomDescriptor have been resolved,
// MojomDescriptor.ComputeEnumValueIntegers() should be invoked. This
@@ -1168,6 +1171,10 @@ func (ev *EnumValue) EnumType() *MojomEnum {
return ev.enumType
}
+func (ev *EnumValue) ValueIndex() uint32 {
+ return ev.valueIndex
+}
+
// EnumValue implements ConcreteValue
func (ev *EnumValue) ValueType() ConcreteType {
return ev.enumType
« no previous file with comments | « mojom/generated/mojom_types/mojom_types.mojom.go ('k') | mojom/mojom_tool/serialization/serialization.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698