cue: observe JSON mappings for google.protobuf.Struct

Change-Id: I234767c9bcdb67dee3492827cf598f5a45258959
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2681
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/encoding/protobuf/types.go b/encoding/protobuf/types.go
index c6c8548..f54708e 100644
--- a/encoding/protobuf/types.go
+++ b/encoding/protobuf/types.go
@@ -48,24 +48,40 @@
 	"bytes":  "bytes",
 }
 
-var timePkg = &protoConverter{
-	id:        "time",
-	goPkg:     "time",
-	goPkgPath: "time",
-}
-
 func (p *protoConverter) setBuiltin(from, to string, pkg *protoConverter) {
 	p.scope[0][from] = mapping{to, "", pkg}
 }
 
-func (p *protoConverter) mapBuiltinPackage(pos scanner.Position, file string, required bool) {
+func (p *protoConverter) mapBuiltinPackage(pos scanner.Position, file string, required bool) (generate bool) {
 	// Map some builtin types to their JSON/CUE mappings.
 	switch file {
 	case "gogoproto/gogo.proto":
 
+	case "google/protobuf/struct.proto":
+		p.setBuiltin("google.protobuf.Struct", "{}", nil)
+		p.setBuiltin("google.protobuf.Value", "_", nil)
+		p.setBuiltin("google.protobuf.NullValue", "null", nil)
+		p.setBuiltin("google.protobuf.ListValue", "[...]", nil)
+		p.setBuiltin("google.protobuf.StringValue", "string", nil)
+		p.setBuiltin("google.protobuf.BoolValue", "bool", nil)
+		p.setBuiltin("google.protobuf.NumberValue", "number", nil)
+		return false
+
+	// TODO: consider mapping the following:
+
+	// case "google/protobuf/duration.proto":
+	// 	p.setBuiltin("google.protobuf.Duration", "time.Duration", "time")
+
+	// case "google/protobuf/timestamp.proto":
+	// 	p.setBuiltin("google.protobuf.Timestamp", "time.Time", "time")
+
+	// case "google/protobuf/empty.proto":
+	// 	p.setBuiltin("google.protobuf.Empty", "struct.MaxFields(0)", nil)
+
 	default:
 		if required {
 			failf(pos, "import %q not found", file)
 		}
 	}
+	return true
 }