encoding/protobuf: don't encode default values for enums

As the fields are now optional, setting a default
does not make a whole ton of sense.

Change-Id: I10f78a41a17f027505a4b338059c00b04c4dc758
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3661
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: Jason Wang <jasonwzm@google.com>
diff --git a/encoding/protobuf/parse.go b/encoding/protobuf/parse.go
index bfde74c..e70601c 100644
--- a/encoding/protobuf/parse.go
+++ b/encoding/protobuf/parse.go
@@ -636,12 +636,7 @@
 
 			var e ast.Expr = value
 			// Make the first value the default value.
-			if i == 0 {
-				e = value
-				if numEnums > 1 {
-					e = &ast.UnaryExpr{OpPos: newline, Op: token.MUL, X: value}
-				}
-			} else {
+			if i > 0 {
 				value.ValuePos = newline
 			}
 			addComments(e, i, y.Comment, nil)
diff --git a/encoding/protobuf/testdata/gateway.proto.out.cue b/encoding/protobuf/testdata/gateway.proto.out.cue
index 86bae1e..f3503d2 100644
--- a/encoding/protobuf/testdata/gateway.proto.out.cue
+++ b/encoding/protobuf/testdata/gateway.proto.out.cue
@@ -393,7 +393,7 @@
 	// The SNI string presented by the client will be used as the match
 	// criterion in a VirtualService TLS route to determine the
 	// destination service from the service registry.
-	*"PASSTHROUGH" |
+	"PASSTHROUGH" |
 
 	// Secure connections with standard TLS semantics.
 	"SIMPLE" |
@@ -422,8 +422,7 @@
 }
 
 // TLS protocol versions.
-Server_TLSOptions_TLSProtocol:
-	*"TLS_AUTO" | // Automatically choose the optimal TLS version.
+Server_TLSOptions_TLSProtocol: "TLS_AUTO" | // Automatically choose the optimal TLS version.
 	"TLSV1_0" | // TLS version 1.0
 	"TLSV1_1" | // TLS version 1.1
 	"TLSV1_2" | // TLS version 1.2
diff --git a/encoding/protobuf/testdata/istio.io/api/mixer/v1/mixer_proto_gen.cue b/encoding/protobuf/testdata/istio.io/api/mixer/v1/mixer_proto_gen.cue
index 1a75599..b69bf68 100644
--- a/encoding/protobuf/testdata/istio.io/api/mixer/v1/mixer_proto_gen.cue
+++ b/encoding/protobuf/testdata/istio.io/api/mixer/v1/mixer_proto_gen.cue
@@ -112,8 +112,7 @@
 }
 
 // How an attribute's value was matched
-ReferencedAttributes_Condition:
-	*"CONDITION_UNSPECIFIED" | // should not occur
+ReferencedAttributes_Condition: "CONDITION_UNSPECIFIED" | // should not occur
 	"ABSENCE" | // match when attribute doesn't exist
 	"EXACT" | // match when attribute value is an exact byte-for-byte match
 	"REGEX" // match when attribute value matches the included regex
@@ -167,8 +166,7 @@
 }
 
 // Operation type.
-HeaderOperation_Operation:
-	*"REPLACE" | // replaces the header with the given name
+HeaderOperation_Operation: "REPLACE" | // replaces the header with the given name
 	"REMOVE" | // removes the header with the given name (the value is ignored)
 	"APPEND" // appends the value to the header value, or sets it if not present
 
@@ -230,7 +228,7 @@
 	// request size. Each individual set of attributes is used to modify the previous set.
 	// NOTE: There is no way with this encoding to specify attribute value deletion. This
 	// option should be used with extreme caution.
-	*"DELTA_ENCODING" |
+	"DELTA_ENCODING" |
 
 	// Treat each set of compressed attributes as complete - independent from other sets
 	// in this request. This will result in on-wire duplication of attributes and values, but
diff --git a/encoding/protobuf/testdata/istio.io/api/networking/v1alpha3/gateway_proto_gen.cue b/encoding/protobuf/testdata/istio.io/api/networking/v1alpha3/gateway_proto_gen.cue
index 1a2a293..dd88b3e 100644
--- a/encoding/protobuf/testdata/istio.io/api/networking/v1alpha3/gateway_proto_gen.cue
+++ b/encoding/protobuf/testdata/istio.io/api/networking/v1alpha3/gateway_proto_gen.cue
@@ -392,7 +392,7 @@
 	// The SNI string presented by the client will be used as the match
 	// criterion in a VirtualService TLS route to determine the
 	// destination service from the service registry.
-	*"PASSTHROUGH" |
+	"PASSTHROUGH" |
 
 	// Secure connections with standard TLS semantics.
 	"SIMPLE" |
@@ -421,8 +421,7 @@
 }
 
 // TLS protocol versions.
-Server_TLSOptions_TLSProtocol:
-	*"TLS_AUTO" | // Automatically choose the optimal TLS version.
+Server_TLSOptions_TLSProtocol: "TLS_AUTO" | // Automatically choose the optimal TLS version.
 	"TLSV1_0" | // TLS version 1.0
 	"TLSV1_1" | // TLS version 1.1
 	"TLSV1_2" | // TLS version 1.2
diff --git a/encoding/protobuf/testdata/istio.io/api/pkg/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor_proto_gen.cue b/encoding/protobuf/testdata/istio.io/api/pkg/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor_proto_gen.cue
index a897906..073dfde 100644
--- a/encoding/protobuf/testdata/istio.io/api/pkg/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor_proto_gen.cue
+++ b/encoding/protobuf/testdata/istio.io/api/pkg/github.com/golang/protobuf/protoc-gen-go/descriptor/descriptor_proto_gen.cue
@@ -189,7 +189,7 @@
 FieldDescriptorProto_Type:
 	// 0 is reserved for errors.
 	// Order is weird for historical reasons.
-	*"TYPE_DOUBLE" |
+	"TYPE_DOUBLE" |
 	"TYPE_FLOAT" |
 
 	// Not ZigZag encoded.  Negative numbers take 10 bytes.  Use TYPE_SINT64 if
@@ -243,7 +243,7 @@
 }
 FieldDescriptorProto_Label:
 	// 0 is reserved for errors
-	*"LABEL_OPTIONAL" |
+	"LABEL_OPTIONAL" |
 	"LABEL_REQUIRED" |
 	"LABEL_REPEATED"
 
@@ -421,8 +421,7 @@
 }
 
 // Generated classes can be optimized for speed or code size.
-FileOptions_OptimizeMode:
-	*"SPEED" | // Generate complete code for parsing, serialization,
+FileOptions_OptimizeMode: "SPEED" | // Generate complete code for parsing, serialization,
 
 	// etc.
 	"CODE_SIZE" |
@@ -564,7 +563,7 @@
 }
 FieldOptions_CType:
 	// Default mode.
-	*"STRING" |
+	"STRING" |
 	"CORD" |
 	"STRING_PIECE"
 
@@ -575,7 +574,7 @@
 }
 FieldOptions_JSType:
 	// Use the default type.
-	*"JS_NORMAL" |
+	"JS_NORMAL" |
 
 	// Use JavaScript strings.
 	"JS_STRING" |
@@ -658,8 +657,7 @@
 // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
 // or neither? HTTP based RPC implementation may choose GET verb for safe
 // methods, and PUT verb for idempotent methods instead of the default POST.
-MethodOptions_IdempotencyLevel:
-	*"IDEMPOTENCY_UNKNOWN" |
+MethodOptions_IdempotencyLevel: "IDEMPOTENCY_UNKNOWN" |
 	"NO_SIDE_EFFECTS" | // implies idempotent
 	"IDEMPOTENT" // idempotent, but may have side effects