encoding/protobuf: don't use disallowed "__" prefix
Change-Id: If143743b952f993cb97c3493361610c7f10a5d2f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3580
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/protobuf/parse.go b/encoding/protobuf/parse.go
index 76183c7..bfde74c 100644
--- a/encoding/protobuf/parse.go
+++ b/encoding/protobuf/parse.go
@@ -273,7 +273,7 @@
alias, ok := p.aliases[first]
if !ok {
// TODO: this is likely to be okay, but find something better.
- alias = "__" + first
+ alias = "_" + first + "_"
p.file.Decls = append(p.file.Decls, &ast.Alias{
Ident: ast.NewIdent(alias),
Expr: ast.NewIdent(first),
diff --git a/encoding/protobuf/protobuf_test.go b/encoding/protobuf/protobuf_test.go
index bd5a905..b824e05 100644
--- a/encoding/protobuf/protobuf_test.go
+++ b/encoding/protobuf/protobuf_test.go
@@ -25,6 +25,7 @@
"testing"
"cuelang.org/go/cue/ast"
+ "cuelang.org/go/cue/errors"
"cuelang.org/go/cue/format"
"github.com/kr/pretty"
)
@@ -92,7 +93,7 @@
files, err := b.Files()
if err != nil {
- t.Fatal(err)
+ t.Fatal(errors.Details(err, nil))
}
if *update {
diff --git a/encoding/protobuf/testdata/attributes.proto.out.cue b/encoding/protobuf/testdata/attributes.proto.out.cue
index 4ac3479..936a6db 100644
--- a/encoding/protobuf/testdata/attributes.proto.out.cue
+++ b/encoding/protobuf/testdata/attributes.proto.out.cue
@@ -128,17 +128,17 @@
// Holds attributes of type TIMESTAMP
time?: {
- <_>: __time.Time
+ <_>: _time_.Time
} @protobuf(6,type=map<sint32,google.protobuf.Timestamp>,"(gogoproto.nullable)=false","(gogoproto.stdtime)")
// Holds attributes of type DURATION
durations?: {
- <_>: __time.Duration
+ <_>: _time_.Duration
} @protobuf(7,type=map<sint32,google.protobuf.Duration>,"(gogoproto.nullable)=false","(gogoproto.stdduration)")
// Holds attributes of type BYTES
bytes?: {
- <_>: __bytes
+ <_>: _bytes_
} @protobuf(8,type=map<sint32,bytes>)
// Holds attributes of type STRING_MAP
@@ -146,8 +146,8 @@
<_>: StringMap
} @protobuf(9,type=map<sint32,StringMap>,string_maps,"(gogoproto.nullable)=false")
}
-__time = time
-__bytes = bytes
+_time_ = time
+_bytes_ = bytes
// A map of string to string. The keys and values in this map are dictionary
// indices (see the [Attributes][istio.mixer.v1.CompressedAttributes] message for an explanation)
diff --git a/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue b/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue
index 97fa441..27260d7 100644
--- a/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue
+++ b/encoding/protobuf/testdata/istio.io/api/mixer/v1/attributes_proto_gen.cue
@@ -128,17 +128,17 @@
// Holds attributes of type TIMESTAMP
time?: {
- <_>: __time.Time
+ <_>: _time_.Time
} @protobuf(6,type=map<sint32,google.protobuf.Timestamp>,"(gogoproto.nullable)=false","(gogoproto.stdtime)")
// Holds attributes of type DURATION
durations?: {
- <_>: __time.Duration
+ <_>: _time_.Duration
} @protobuf(7,type=map<sint32,google.protobuf.Duration>,"(gogoproto.nullable)=false","(gogoproto.stdduration)")
// Holds attributes of type BYTES
bytes?: {
- <_>: __bytes
+ <_>: _bytes_
} @protobuf(8,type=map<sint32,bytes>)
// Holds attributes of type STRING_MAP
@@ -146,8 +146,8 @@
<_>: StringMap
} @protobuf(9,type=map<sint32,StringMap>,string_maps,"(gogoproto.nullable)=false")
}
-__time = time
-__bytes = bytes
+_time_ = time
+_bytes_ = bytes
// A map of string to string. The keys and values in this map are dictionary
// indices (see the [Attributes][istio.mixer.v1.CompressedAttributes] message for an explanation)
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 4d07c39..1a75599 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
@@ -68,7 +68,7 @@
CheckResponse_PreconditionResult: {
// A status code of OK indicates all preconditions were satisfied. Any other code indicates not
// all preconditions were satisfied and details describe why.
- status?: __status.Status @protobuf(1,type=google.rpc.Status,"(gogoproto.nullable)=false")
+ status?: _status_.Status @protobuf(1,type=google.rpc.Status,"(gogoproto.nullable)=false")
// The amount of time for which this result can be considered valid.
validDuration?: time.Duration @protobuf(2,type=google.protobuf.Duration,name=valid_duration,"(gogoproto.nullable)=false","(gogoproto.stdduration)")
@@ -84,7 +84,7 @@
// whenever all preconditions are satisfied.
routeDirective?: RouteDirective @protobuf(6,name=route_directive)
}
-__status = status
+_status_ = status
// Expresses the result of a quota allocation.
CheckResponse_QuotaResult: {