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

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

Issue 1819223002: Mojom frontend: Allow non-reference types in non-zero versions of a struct. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 9 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/mojom_parser/mojom/types.go ('k') | mojom/mojom_parser/parser/computed_data_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojom/mojom_parser/mojom/user_defined_types.go
diff --git a/mojom/mojom_parser/mojom/user_defined_types.go b/mojom/mojom_parser/mojom/user_defined_types.go
index 6f6b877d2cf6d30cfa234b3720a0934cf195c13f..6d1833b951c4f6eae9208bd1b086024d8648294b 100644
--- a/mojom/mojom_parser/mojom/user_defined_types.go
+++ b/mojom/mojom_parser/mojom/user_defined_types.go
@@ -534,69 +534,6 @@ func (s *MojomStruct) ComputeFieldOrdinals() error {
return nil
}
-var ErrMinVersionIllformed = errors.New("MinVersion attribute value illformed")
-var ErrMinVersionOutOfOrder = errors.New("MinVersion attribute value out of order")
-var ErrMinVersionNotNullable = errors.New("Non-Zero MinVersion attribute value on non-nullable field")
-
-type StructFieldMinVersionError struct {
- // The field whose MinVersion is being set.
- field *StructField
-
- // The MinValue of the previous field. Only used for ErrMinVersionOutOfOrder
- previousValue uint32
-
- // The LiteralValue of the attribute assignment.
- // NOTE: We use the following convention: literalValue.token == nil indicates that
- // there was no MinVersion attribute on the given field. This can only happen with
- // ErrMinVersionOutOfOrder
- literalValue LiteralValue
-
- // The type of error (ErrMinVersionIllfromed, ErrMinVersionOutOfOrder, ErrMinVersionNotNullable)
- err error
-}
-
-// StructFieldMinVersionError implements error.
-func (e *StructFieldMinVersionError) Error() string {
- var message string
- var token lexer.Token
- switch e.err {
- case ErrMinVersionIllformed:
- message = fmt.Sprintf("Invalid MinVersion attribute for field %s: %s. "+
- "The value must be a non-negative 32-bit integer value.",
- e.field.SimpleName(), e.literalValue)
- token = *e.literalValue.token
- case ErrMinVersionOutOfOrder:
- if e.literalValue.token == nil {
- message = fmt.Sprintf("Invalid missing MinVersion for field %s. "+
- "The MinVersion must be non-decreasing as a function of the ordinal. "+
- "This field must have a MinVersion attribute with a value at least %d.",
- e.field.SimpleName(), e.previousValue)
- token = e.field.NameToken()
- } else {
- message = fmt.Sprintf("Invalid MinVersion attribute for field %s: %s. "+
- "The MinVersion must be non-decreasing as a function of the ordinal. "+
- "This field's MinVersion must be at least %d.",
- e.field.SimpleName(), e.literalValue.token.Text, e.previousValue)
- token = *e.literalValue.token
- }
- case ErrMinVersionNotNullable:
- message = fmt.Sprintf("Invalid type for field %s: %s. "+
- "Non-nullable fields are only allowed in version 0 of of a struct. "+
- "This field's MinVersion is %s.",
- e.field.SimpleName(), e.field.FieldType.TypeName(), e.literalValue.token.Text)
- switch fieldType := e.field.FieldType.(type) {
- case *UserTypeRef:
- token = fieldType.token
- default:
- // It would be nice for the green carets in the snippit in the error message to point at
- // the type name, but other than for user type refs we don't store that token so
- // instead we use the field's name.
- token = e.field.NameToken()
- }
- }
- return UserErrorMessage(e.field.OwningFile(), token, message)
-}
-
func (m MojomStruct) String() string {
s := fmt.Sprintf("\n---------struct--------------\n")
s += fmt.Sprintf("%s\n", m.UserDefinedTypeBase)
« no previous file with comments | « mojom/mojom_parser/mojom/types.go ('k') | mojom/mojom_parser/parser/computed_data_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698