Compare commits
7 Commits
feat/input
...
v0.1.0
Author | SHA1 | Date | |
---|---|---|---|
71c93f2e73 | |||
fdedd70471 | |||
0fe45a3c9c | |||
3d81336c9b | |||
d0c8ef76fc | |||
5a99160f65 | |||
c2f3756cef |
@ -1,4 +1,4 @@
|
||||
FROM --platform=$BUILDPLATFORM golang:alpine AS builder
|
||||
FROM --platform=$BUILDPLATFORM golang:1.17-alpine AS builder
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
ARG BUILDPLATFORM
|
||||
|
@ -9,7 +9,7 @@ Usage of ./rc-simulator:
|
||||
-debug
|
||||
Debug logs
|
||||
-events-topic-frame string
|
||||
Mqtt topic to events gateway frames, use MQTT_TOPIC_FRAME if args not set
|
||||
Mqtt topic to events gateway frames, use MQTT_TOPIC_CAMERA if args not set
|
||||
-events-topic-steering string
|
||||
Mqtt topic to events gateway steering, use MQTT_TOPIC_STEERING if args not set
|
||||
-events-topic-throttle string
|
||||
|
@ -2,14 +2,18 @@ package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/cyrilix/robocar-base/cli"
|
||||
events2 "github.com/cyrilix/robocar-protobuf/go/events"
|
||||
"github.com/cyrilix/robocar-simulator/pkg/events"
|
||||
"github.com/cyrilix/robocar-simulator/pkg/gateway"
|
||||
"github.com/cyrilix/robocar-simulator/pkg/simulator"
|
||||
mqtt "github.com/eclipse/paho.mqtt.golang"
|
||||
"github.com/golang/protobuf/proto"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const DefaultClientId = "robocar-simulator"
|
||||
@ -25,14 +29,48 @@ func main() {
|
||||
|
||||
cli.InitMqttFlags(DefaultClientId, &mqttBroker, &username, &password, &clientId, &mqttQos, &mqttRetain)
|
||||
|
||||
flag.StringVar(&topicFrame, "events-topic-frame", os.Getenv("MQTT_TOPIC_FRAME"), "Mqtt topic to events gateway frames, use MQTT_TOPIC_FRAME if args not set")
|
||||
flag.StringVar(&topicFrame, "events-topic-steering", os.Getenv("MQTT_TOPIC_STEERING"), "Mqtt topic to events gateway steering, use MQTT_TOPIC_STEERING if args not set")
|
||||
flag.StringVar(&topicFrame, "events-topic-throttle", os.Getenv("MQTT_TOPIC_THROTTLE"), "Mqtt topic to events gateway throttle, use MQTT_TOPIC_THROTTLE if args not set")
|
||||
flag.StringVar(&topicFrame, "topic-steering-ctrl", os.Getenv("MQTT_TOPIC_STEERING_CTRL"), "Mqtt topic to send steering instructions, use MQTT_TOPIC_STEERING_CTRL if args not set")
|
||||
flag.StringVar(&topicFrame, "topic-throttle-ctrl", os.Getenv("MQTT_TOPIC_THROTTLE_CTRL"), "Mqtt topic to send throttle instructions, use MQTT_TOPIC_THROTTLE_CTRL if args not set")
|
||||
flag.StringVar(&topicFrame, "events-topic-camera", os.Getenv("MQTT_TOPIC_CAMERA"), "Mqtt topic to events gateway frames, use MQTT_TOPIC_CAMERA if args not set")
|
||||
flag.StringVar(&topicSteering, "events-topic-steering", os.Getenv("MQTT_TOPIC_STEERING"), "Mqtt topic to events gateway steering, use MQTT_TOPIC_STEERING if args not set")
|
||||
flag.StringVar(&topicThrottle, "events-topic-throttle", os.Getenv("MQTT_TOPIC_THROTTLE"), "Mqtt topic to events gateway throttle, use MQTT_TOPIC_THROTTLE if args not set")
|
||||
flag.StringVar(&topicCtrlSteering, "topic-steering-ctrl", os.Getenv("MQTT_TOPIC_STEERING_CTRL"), "Mqtt topic to send steering instructions, use MQTT_TOPIC_STEERING_CTRL if args not set")
|
||||
flag.StringVar(&topicCtrlThrottle, "topic-throttle-ctrl", os.Getenv("MQTT_TOPIC_THROTTLE_CTRL"), "Mqtt topic to send throttle instructions, use MQTT_TOPIC_THROTTLE_CTRL if args not set")
|
||||
flag.StringVar(&address, "simulator-address", "127.0.0.1:9091", "Simulator address")
|
||||
flag.BoolVar(&debug, "debug", false, "Debug logs")
|
||||
|
||||
var carName, carStyle, carColor string
|
||||
var carFontSize int
|
||||
carStyles := []string{
|
||||
string(simulator.CarConfigBodyStyleDonkey),
|
||||
string(simulator.CarConfigBodyStyleBare),
|
||||
string(simulator.CarConfigBodyStyleCar01),
|
||||
}
|
||||
flag.StringVar(&carName, "car-name", "simulator-gateway", "Car name to display")
|
||||
flag.StringVar(&carStyle, "car-style", string(simulator.CarConfigBodyStyleDonkey), fmt.Sprintf("Car style, only %s", strings.Join(carStyles, ",")))
|
||||
flag.StringVar(&carColor, "car-color", "0,0,0", "Color car as rgb value")
|
||||
flag.IntVar(&carFontSize, "car-font-size", 0, "Car font size")
|
||||
|
||||
var racerName, racerBio, racerCountry, racerGuid string
|
||||
flag.StringVar(&racerName, "racer-name", "", "")
|
||||
flag.StringVar(&racerBio, "racer-bio", "", "")
|
||||
flag.StringVar(&racerCountry, "racer-country", "", "")
|
||||
flag.StringVar(&racerGuid, "racer-guid", "", "")
|
||||
|
||||
var cameraFov, cameraImgW, cameraImgH, cameraImgD int
|
||||
var cameraFishEyeX, cameraFishEyeY float64
|
||||
var cameraOffsetX, cameraOffsetY, cameraOffsetZ, cameraRotX float64
|
||||
var cameraImgEnc string
|
||||
flag.IntVar(&cameraFov, "camera-fov", 90, "")
|
||||
flag.Float64Var(&cameraFishEyeX, "camera-fish-eye-x", 0.4, "")
|
||||
flag.Float64Var(&cameraFishEyeY, "camera-fish-eye-y", 0.7, "")
|
||||
flag.IntVar(&cameraImgW, "camera-img-w", 160, "image width")
|
||||
flag.IntVar(&cameraImgH, "camera-img-h", 128, "image height")
|
||||
flag.IntVar(&cameraImgD, "camera-img-d", 3, "Image depth")
|
||||
flag.StringVar(&cameraImgEnc, "camera-img-enc", string(simulator.CameraImageEncJpeg), "")
|
||||
flag.Float64Var(&cameraOffsetX, "camera-offset-x", 0, "moves camera left/right")
|
||||
flag.Float64Var(&cameraOffsetY, "camera-offset-y", 1.120395, "moves camera up/down")
|
||||
flag.Float64Var(&cameraOffsetZ, "camera-offset-z", 0.5528488, "moves camera forward/back")
|
||||
flag.Float64Var(&cameraRotX, "camera-rot-x", 15.0, "rotate the camera")
|
||||
|
||||
flag.Parse()
|
||||
if len(os.Args) <= 1 {
|
||||
flag.PrintDefaults()
|
||||
@ -48,7 +86,39 @@ func main() {
|
||||
}
|
||||
defer client.Disconnect(10)
|
||||
|
||||
gtw := gateway.New(address)
|
||||
bodyColors := strings.Split(carColor, ",")
|
||||
carConfig := simulator.CarConfigMsg{
|
||||
MsgType: simulator.MsgTypeCarConfig,
|
||||
BodyStyle: simulator.CarStyle(carStyle),
|
||||
BodyR: bodyColors[0],
|
||||
BodyG: bodyColors[1],
|
||||
BodyB: bodyColors[2],
|
||||
CarName: carName,
|
||||
FontSize: strconv.Itoa(carFontSize),
|
||||
}
|
||||
racer := simulator.RacerBioMsg{
|
||||
MsgType: simulator.MsgTypeRacerInfo,
|
||||
RacerName: racerName,
|
||||
CarName: carName,
|
||||
Bio: racerBio,
|
||||
Country: racerCountry,
|
||||
Guid: racerGuid,
|
||||
}
|
||||
camera := simulator.CamConfigMsg{
|
||||
MsgType: simulator.MsgTypeCameraConfig,
|
||||
Fov: strconv.Itoa(cameraFov),
|
||||
FishEyeX: fmt.Sprintf("%.2f", cameraFishEyeX),
|
||||
FishEyeY: fmt.Sprintf("%.2f",cameraFishEyeY),
|
||||
ImgW: strconv.Itoa(cameraImgW),
|
||||
ImgH: strconv.Itoa(cameraImgH),
|
||||
ImgD: strconv.Itoa(cameraImgD),
|
||||
ImgEnc: simulator.CameraImageEnc(cameraImgEnc),
|
||||
OffsetX: fmt.Sprintf("%.2f",cameraOffsetX),
|
||||
OffsetY: fmt.Sprintf("%.2f", cameraOffsetY),
|
||||
OffsetZ: fmt.Sprintf("%.2f", cameraOffsetZ),
|
||||
RotX: fmt.Sprintf("%.2f", cameraRotX),
|
||||
}
|
||||
gtw := gateway.New(address, &carConfig, &racer, &camera)
|
||||
defer gtw.Stop()
|
||||
|
||||
msgPub := events.NewMsgPublisher(
|
||||
@ -59,45 +129,46 @@ func main() {
|
||||
topicThrottle,
|
||||
)
|
||||
defer msgPub.Stop()
|
||||
msgPub.Start()
|
||||
|
||||
cli.HandleExit(gtw)
|
||||
|
||||
err = gtw.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("unable to start service: %v", err)
|
||||
}
|
||||
msgPub.Start()
|
||||
|
||||
if topicCtrlSteering != "" {
|
||||
log.Infof("configure mqtt route on steering command")
|
||||
client.AddRoute(topicCtrlSteering, func(client mqtt.Client, message mqtt.Message) {
|
||||
client.Subscribe(topicCtrlSteering, byte(mqttQos), func(client mqtt.Client, message mqtt.Message) {
|
||||
onSteeringCommand(gtw, message)
|
||||
})
|
||||
}
|
||||
if topicCtrlThrottle != "" {
|
||||
log.Infof("configure mqtt route on throttle command")
|
||||
client.AddRoute(topicCtrlThrottle, func(client mqtt.Client, message mqtt.Message) {
|
||||
client.Subscribe(topicCtrlThrottle, byte(mqttQos), func(client mqtt.Client, message mqtt.Message) {
|
||||
onThrottleCommand(gtw, message)
|
||||
})
|
||||
}
|
||||
|
||||
err = gtw.Start()
|
||||
if err != nil {
|
||||
log.Fatalf("unable to start service: %v", err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func onSteeringCommand(c *gateway.Gateway, message mqtt.Message) {
|
||||
var steeringMsg *events2.SteeringMessage
|
||||
err := proto.Unmarshal(message.Payload(), steeringMsg)
|
||||
var steeringMsg events2.SteeringMessage
|
||||
err := proto.Unmarshal(message.Payload(), &steeringMsg)
|
||||
if err != nil {
|
||||
log.Errorf("unable to unmarshal steering msg: %v", err)
|
||||
return
|
||||
}
|
||||
c.WriteSteering(steeringMsg)
|
||||
c.WriteSteering(&steeringMsg)
|
||||
}
|
||||
|
||||
func onThrottleCommand(c *gateway.Gateway, message mqtt.Message) {
|
||||
var throttleMsg *events2.ThrottleMessage
|
||||
err := proto.Unmarshal(message.Payload(), throttleMsg)
|
||||
var throttleMsg events2.ThrottleMessage
|
||||
err := proto.Unmarshal(message.Payload(), &throttleMsg)
|
||||
if err != nil {
|
||||
log.Errorf("unable to unmarshal throttle msg: %v", err)
|
||||
return
|
||||
}
|
||||
c.WriteThrottle(throttleMsg)
|
||||
c.WriteThrottle(&throttleMsg)
|
||||
}
|
||||
|
21
go.mod
21
go.mod
@ -1,12 +1,19 @@
|
||||
module github.com/cyrilix/robocar-simulator
|
||||
|
||||
go 1.15
|
||||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/avast/retry-go v2.6.0+incompatible
|
||||
github.com/cyrilix/robocar-base v0.1.2
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.2
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.1
|
||||
github.com/golang/protobuf v1.4.3
|
||||
github.com/sirupsen/logrus v1.7.0
|
||||
github.com/avast/retry-go v3.0.0+incompatible
|
||||
github.com/cyrilix/robocar-base v0.1.4
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.3
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.5
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/sirupsen/logrus v1.8.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 // indirect
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd // indirect
|
||||
google.golang.org/protobuf v1.26.0 // indirect
|
||||
)
|
||||
|
18
go.sum
18
go.sum
@ -4,14 +4,20 @@ github.com/Microsoft/go-winio v0.4.11/go.mod h1:VhR8bwka0BXejwEJY73c50VrPtXAaKcy
|
||||
github.com/Microsoft/hcsshim v0.8.6/go.mod h1:Op3hHsoHPAvb6lceZHDtd9OkTew38wNoXnJs8iY7rUg=
|
||||
github.com/avast/retry-go v2.6.0+incompatible h1:FelcMrm7Bxacr1/RM8+/eqkDkmVN7tjlsy51dOzB3LI=
|
||||
github.com/avast/retry-go v2.6.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
|
||||
github.com/avast/retry-go v3.0.0+incompatible h1:4SOWQ7Qs+oroOTQOYnAHqelpCO0biHSxpiH9JdtuBj0=
|
||||
github.com/avast/retry-go v3.0.0+incompatible/go.mod h1:XtSnn+n/sHqQIpZ10K1qAevBhOOCWBLXXy3hyiqqBrY=
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible/go.mod h1:90ReRw6GdpyfrHakVjL/QHaoyV4aDUVVkXQJJJ3NXXM=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/containerd/containerd v1.4.1/go.mod h1:bC6axHOhabU15QhwfG7w5PipXdVtMXFTttgp+kVtyUA=
|
||||
github.com/containerd/continuity v0.0.0-20190426062206-aaeac12a7ffc/go.mod h1:GL3xCUCBDV3CZiTSEKksMWbLE66hEyuu9qyDOOqM47Y=
|
||||
github.com/cyrilix/robocar-base v0.1.2 h1:bhT5ohhviodCOd5usy013ctwu7ko+IfyDXnYHg7lJ8I=
|
||||
github.com/cyrilix/robocar-base v0.1.2/go.mod h1:G2SiYNUDAIv+65XWpiHnCXj7Jz2V6pOBLaIrcasGkww=
|
||||
github.com/cyrilix/robocar-base v0.1.4 h1:nfnjRwAcCfS7xGu6tW9rZhmc/HZIsuDJX5NFhgX5dWE=
|
||||
github.com/cyrilix/robocar-base v0.1.4/go.mod h1:Tt04UmbGBiQtU0Cn3wFD0q7XoyokTwIlWYQxThKI+04=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.2 h1:eWwu7T07uvABh74bWOJa77alUs6VaWNEPd7Zezua2Cs=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.2/go.mod h1:xj7H/a7qpvXgmW1983Fjd143Mz9Yt0C6RCxvB8M6pEM=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.3 h1:iPHw2+7FVXG2C4+Th1m11hQ+2RpAQzlxKhc5M7XOa6Q=
|
||||
github.com/cyrilix/robocar-protobuf/go v1.0.3/go.mod h1:xb95cK07lYXnKcHZKnGafmAgYRrqZWZgV9LMiJAp+gE=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
@ -21,6 +27,8 @@ github.com/docker/go-connections v0.4.0/go.mod h1:Gbd7IOopHjR8Iph03tsViu4nIes5Xh
|
||||
github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk=
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.1 h1:6F5FYb1hxVSZS+p0ji5xBQamc5ltOolTYRy5R15uVmI=
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.1/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
|
||||
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.6.3/go.mod h1:75u5sXoLsGZoRN5Sgbi1eraJ4GU3++wFwWzhwvtwp4M=
|
||||
@ -42,11 +50,15 @@ github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:W
|
||||
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||
github.com/golang/protobuf v1.4.3 h1:JjCZWpVbqXDqFVmTfYWEVTMIYrL/NPdPSCHPJ0T/raM=
|
||||
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
|
||||
@ -79,6 +91,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
|
||||
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
@ -98,6 +112,7 @@ golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTk
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U=
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
|
||||
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
|
||||
@ -130,6 +145,9 @@ google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miE
|
||||
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||
google.golang.org/protobuf v1.23.0 h1:4MY060fB1DLGMB/7MBTLnwQUY6+F09GEiz6SsrNqyzM=
|
||||
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
|
||||
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
@ -111,6 +111,11 @@ func (m *MsgPublisher) listenFrame() {
|
||||
msgChan := m.srcEvents.SubscribeFrame()
|
||||
for {
|
||||
msg := <-msgChan
|
||||
if msg == nil {
|
||||
// channel closed
|
||||
break
|
||||
}
|
||||
logr.Debugf("new frame %v", msg.Id)
|
||||
if m.topicFrame == "" {
|
||||
return
|
||||
}
|
||||
|
@ -4,8 +4,74 @@ import (
|
||||
"github.com/cyrilix/robocar-protobuf/go/events"
|
||||
"github.com/cyrilix/robocar-simulator/pkg/simulator"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
||||
func TestGateway_Start(t *testing.T) {
|
||||
|
||||
simulatorMock := Gw2SimMock{}
|
||||
err := simulatorMock.listen()
|
||||
if err != nil {
|
||||
t.Errorf("unable to start mock gw: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
if err := simulatorMock.Close(); err != nil {
|
||||
t.Errorf("unable to stop simulator mock: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
carConfig := simulator.CarConfigMsg{
|
||||
MsgType: simulator.MsgTypeCarConfig,
|
||||
BodyStyle: simulator.CarConfigBodyStyleCar01,
|
||||
CarName: "car-test",
|
||||
}
|
||||
camConfig :=simulator.CamConfigMsg{
|
||||
MsgType: simulator.MsgTypeCameraConfig,
|
||||
Fov: "0",
|
||||
FishEyeX: "0",
|
||||
FishEyeY: "0",
|
||||
ImgW: "120",
|
||||
ImgH: "50",
|
||||
ImgD: "0",
|
||||
ImgEnc: simulator.CameraImageEncJpeg,
|
||||
OffsetX: "0",
|
||||
OffsetY: "0",
|
||||
OffsetZ: "0",
|
||||
RotX: "0",
|
||||
}
|
||||
gw := New(simulatorMock.Addr(),
|
||||
&carConfig,
|
||||
&simulator.RacerBioMsg{},
|
||||
&camConfig,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to init simulator gateway: %v", err)
|
||||
}
|
||||
go gw.Start()
|
||||
defer gw.Close()
|
||||
|
||||
carNotify := simulatorMock.NotifyCar()
|
||||
select {
|
||||
case <- time.Tick(500 * time.Millisecond):
|
||||
t.Errorf("a car configuration message should be send")
|
||||
case msg := <-carNotify:
|
||||
if *msg != carConfig {
|
||||
t.Errorf("[carConfig] invalid car config: %v, wants %v", &msg, carConfig)
|
||||
}
|
||||
}
|
||||
camNotify := simulatorMock.NotifyCamera()
|
||||
select {
|
||||
case <- time.Tick(500 * time.Millisecond):
|
||||
t.Errorf("a camera configuration message should be send")
|
||||
case msg := <-camNotify:
|
||||
if *msg != camConfig {
|
||||
t.Errorf("[carConfig] invalid camera config: %v, wants %v", &msg, camConfig)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestGateway_WriteSteering(t *testing.T) {
|
||||
|
||||
cases := []struct {
|
||||
@ -18,38 +84,38 @@ func TestGateway_WriteSteering(t *testing.T) {
|
||||
&events.SteeringMessage{Steering: 0.5, Confidence: 1},
|
||||
nil,
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.5,
|
||||
Throttle: 0,
|
||||
Brake: 0,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.50",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.0",
|
||||
}},
|
||||
{"Update steering",
|
||||
&events.SteeringMessage{Steering: -0.5, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0,
|
||||
Brake: 0,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.0",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: -0.5,
|
||||
Throttle: 0,
|
||||
Brake: 0,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "-0.50",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.0",
|
||||
}},
|
||||
{"Update steering shouldn't erase throttle value",
|
||||
&events.SteeringMessage{Steering: -0.3, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.6,
|
||||
Brake: 0.1,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.6",
|
||||
Brake: "0.1",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: -0.3,
|
||||
Throttle: 0.6,
|
||||
Brake: 0.1,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "-0.30",
|
||||
Throttle: "0.6",
|
||||
Brake: "0.1",
|
||||
}},
|
||||
}
|
||||
|
||||
@ -64,19 +130,24 @@ func TestGateway_WriteSteering(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
gw := New(simulatorMock.Addr())
|
||||
gw := New(simulatorMock.Addr(),
|
||||
&simulator.CarConfigMsg{MsgType: simulator.MsgTypeCarConfig},
|
||||
&simulator.RacerBioMsg{},
|
||||
&simulator.CamConfigMsg{})
|
||||
if err != nil {
|
||||
t.Fatalf("unable to init simulator gateway: %v", err)
|
||||
}
|
||||
go gw.Start()
|
||||
defer gw.Close()
|
||||
//go gw.Start()
|
||||
//defer gw.Close()
|
||||
//<- simulatorMock.NotifyCar()
|
||||
//<- simulatorMock.NotifyCamera()
|
||||
|
||||
for _, c := range cases {
|
||||
gw.lastControl = c.previousMsg
|
||||
|
||||
gw.WriteSteering(c.msg)
|
||||
|
||||
ctrlMsg := <-simulatorMock.Notify()
|
||||
ctrlMsg := <-simulatorMock.NotifyCtrl()
|
||||
if *ctrlMsg != c.expectedMsg {
|
||||
t.Errorf("[%v] bad messge received: %#v, wants %#v", c.name, ctrlMsg, c.expectedMsg)
|
||||
}
|
||||
@ -95,80 +166,80 @@ func TestGateway_WriteThrottle(t *testing.T) {
|
||||
&events.ThrottleMessage{Throttle: 0.5, Confidence: 1},
|
||||
nil,
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0,
|
||||
Throttle: 0.5,
|
||||
Brake: 0,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.0",
|
||||
Throttle: "0.50",
|
||||
Brake: "0.0",
|
||||
}},
|
||||
{"Update Throttle",
|
||||
&events.ThrottleMessage{Throttle: 0.6, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0,
|
||||
Throttle: 0.4,
|
||||
Brake: 0,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0",
|
||||
Throttle: "0.4",
|
||||
Brake: "0",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0,
|
||||
Throttle: 0.6,
|
||||
Brake: 0,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0",
|
||||
Throttle: "0.60",
|
||||
Brake: "0.0",
|
||||
}},
|
||||
{"Update steering shouldn't erase throttle value",
|
||||
&events.ThrottleMessage{Throttle: 0.3, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.6,
|
||||
Brake: 0.,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.6",
|
||||
Brake: "0.0",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.3,
|
||||
Brake: 0.,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.30",
|
||||
Brake: "0.0",
|
||||
}},
|
||||
{"Throttle to brake",
|
||||
&events.ThrottleMessage{Throttle: -0.7, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.6,
|
||||
Brake: 0.,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.6",
|
||||
Brake: "0.0",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.,
|
||||
Brake: 0.7,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.70",
|
||||
}},
|
||||
{"Update brake",
|
||||
&events.ThrottleMessage{Throttle: -0.2, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.,
|
||||
Brake: 0.5,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.5",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.,
|
||||
Brake: 0.2,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.20",
|
||||
}},
|
||||
{"Brake to throttle",
|
||||
&events.ThrottleMessage{Throttle: 0.9, Confidence: 1},
|
||||
&simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.,
|
||||
Brake: 0.4,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.4",
|
||||
},
|
||||
simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.2,
|
||||
Throttle: 0.9,
|
||||
Brake: 0.,
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.2",
|
||||
Throttle: "0.90",
|
||||
Brake: "0.0",
|
||||
}},
|
||||
}
|
||||
|
||||
@ -183,17 +254,21 @@ func TestGateway_WriteThrottle(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
gw := New(simulatorMock.Addr())
|
||||
if err != nil {
|
||||
t.Fatalf("unable to init simulator gateway: %v", err)
|
||||
}
|
||||
gw := New(simulatorMock.Addr(), &simulator.CarConfigMsg{MsgType: simulator.MsgTypeCarConfig},
|
||||
&simulator.RacerBioMsg{},
|
||||
&simulator.CamConfigMsg{})
|
||||
|
||||
//go gw.Start()
|
||||
|
||||
//<- simulatorMock.NotifyCar()
|
||||
//<- simulatorMock.NotifyCamera()
|
||||
|
||||
for _, c := range cases {
|
||||
gw.lastControl = c.previousMsg
|
||||
|
||||
gw.WriteThrottle(c.msg)
|
||||
|
||||
ctrlMsg := <-simulatorMock.Notify()
|
||||
ctrlMsg := <-simulatorMock.NotifyCtrl()
|
||||
if *ctrlMsg != c.expectedMsg {
|
||||
t.Errorf("[%v] bad messge received: %#v, wants %#v", c.name, ctrlMsg, c.expectedMsg)
|
||||
}
|
||||
|
@ -31,16 +31,23 @@ type ThrottleSource interface {
|
||||
SubscribeThrottle() <-chan *events.ThrottleMessage
|
||||
}
|
||||
|
||||
func New(addressSimulator string) *Gateway {
|
||||
func New(addressSimulator string, car *simulator.CarConfigMsg, racer *simulator.RacerBioMsg, camera *simulator.CamConfigMsg) *Gateway {
|
||||
l := log.WithField("simulator", addressSimulator)
|
||||
l.Info("run gateway from simulator")
|
||||
|
||||
return &Gateway{
|
||||
address: addressSimulator,
|
||||
log: l,
|
||||
frameSubscribers: make(map[chan<- *events.FrameMessage]interface{}),
|
||||
steeringSubscribers: make(map[chan<- *events.SteeringMessage]interface{}),
|
||||
throttleSubscribers: make(map[chan<- *events.ThrottleMessage]interface{}),
|
||||
address: addressSimulator,
|
||||
log: l,
|
||||
frameSubscribers: make(map[chan<- *events.FrameMessage]interface{}),
|
||||
steeringSubscribers: make(map[chan<- *events.SteeringMessage]interface{}),
|
||||
throttleSubscribers: make(map[chan<- *events.ThrottleMessage]interface{}),
|
||||
telemetrySubscribers: make(map[chan *simulator.TelemetryMsg]interface{}),
|
||||
carSubscribers: make(map[chan *simulator.Msg]interface{}),
|
||||
racerSubscribers: make(map[chan *simulator.Msg]interface{}),
|
||||
cameraSubscribers: make(map[chan *simulator.Msg]interface{}),
|
||||
carConfig: car,
|
||||
racer: racer,
|
||||
cameraConfig: camera,
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,8 +56,10 @@ type Gateway struct {
|
||||
cancel chan interface{}
|
||||
|
||||
address string
|
||||
muConn sync.Mutex
|
||||
conn io.ReadWriteCloser
|
||||
|
||||
muCommand sync.Mutex
|
||||
muConn sync.Mutex
|
||||
conn io.ReadWriteCloser
|
||||
|
||||
muControl sync.Mutex
|
||||
lastControl *simulator.ControlMsg
|
||||
@ -60,88 +69,108 @@ type Gateway struct {
|
||||
frameSubscribers map[chan<- *events.FrameMessage]interface{}
|
||||
steeringSubscribers map[chan<- *events.SteeringMessage]interface{}
|
||||
throttleSubscribers map[chan<- *events.ThrottleMessage]interface{}
|
||||
|
||||
telemetrySubscribers map[chan *simulator.TelemetryMsg]interface{}
|
||||
carSubscribers map[chan *simulator.Msg]interface{}
|
||||
racerSubscribers map[chan *simulator.Msg]interface{}
|
||||
cameraSubscribers map[chan *simulator.Msg]interface{}
|
||||
|
||||
carConfig *simulator.CarConfigMsg
|
||||
racer *simulator.RacerBioMsg
|
||||
cameraConfig *simulator.CamConfigMsg
|
||||
}
|
||||
|
||||
func (p *Gateway) Start() error {
|
||||
p.log.Info("connect to simulator")
|
||||
p.cancel = make(chan interface{})
|
||||
msgChan := make(chan *simulator.TelemetryMsg)
|
||||
func (g *Gateway) Start() error {
|
||||
g.log.Info("connect to simulator")
|
||||
g.cancel = make(chan interface{})
|
||||
msgChan := g.subscribeTelemetryEvents()
|
||||
|
||||
go p.run(msgChan)
|
||||
go g.run()
|
||||
|
||||
err := g.writeRacerConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to configure racer to server: %v", err)
|
||||
}
|
||||
err = g.writeCarConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to configure car to server: %v", err)
|
||||
}
|
||||
err = g.writeCameraConfig()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to configure camera to server: %v", err)
|
||||
}
|
||||
|
||||
for {
|
||||
select {
|
||||
case msg := <-msgChan:
|
||||
fr := p.publishFrame(msg)
|
||||
go p.publishInputSteering(msg, fr)
|
||||
go p.publishInputThrottle(msg, fr)
|
||||
case <-p.cancel:
|
||||
fr := g.publishFrame(msg)
|
||||
go g.publishInputSteering(msg, fr)
|
||||
go g.publishInputThrottle(msg, fr)
|
||||
case <-g.cancel:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Gateway) Stop() {
|
||||
p.log.Info("close simulator gateway")
|
||||
close(p.cancel)
|
||||
func (g *Gateway) Stop() {
|
||||
g.log.Info("close simulator gateway")
|
||||
close(g.cancel)
|
||||
|
||||
if err := p.Close(); err != nil {
|
||||
p.log.Warnf("unexpected error while simulator connection is closed: %v", err)
|
||||
if err := g.Close(); err != nil {
|
||||
g.log.Warnf("unexpected error while simulator connection is closed: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Gateway) Close() error {
|
||||
for c := range p.frameSubscribers {
|
||||
func (g *Gateway) Close() error {
|
||||
for c := range g.frameSubscribers {
|
||||
close(c)
|
||||
}
|
||||
for c := range p.steeringSubscribers {
|
||||
for c := range g.steeringSubscribers {
|
||||
close(c)
|
||||
}
|
||||
for c := range p.throttleSubscribers {
|
||||
for c := range g.throttleSubscribers {
|
||||
close(c)
|
||||
}
|
||||
if p.conn == nil {
|
||||
p.log.Warn("no connection to close")
|
||||
if g.conn == nil {
|
||||
g.log.Warn("no connection to close")
|
||||
return nil
|
||||
}
|
||||
if err := p.conn.Close(); err != nil {
|
||||
if err := g.conn.Close(); err != nil {
|
||||
return fmt.Errorf("unable to close connection to simulator: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Gateway) run(msgChan chan<- *simulator.TelemetryMsg) {
|
||||
err := p.connect()
|
||||
func (g *Gateway) run() {
|
||||
err := g.connect()
|
||||
if err != nil {
|
||||
p.log.Panicf("unable to connect to simulator: %v", err)
|
||||
g.log.Panicf("unable to connect to simulator: %v", err)
|
||||
}
|
||||
|
||||
reader := bufio.NewReader(p.conn)
|
||||
|
||||
err = retry.Do(
|
||||
func() error { return p.listen(msgChan, reader) },
|
||||
func() error { return g.listen() },
|
||||
)
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to connect to server: %v", err)
|
||||
g.log.Errorf("unable to connect to server: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Gateway) connect() error {
|
||||
p.muConn.Lock()
|
||||
defer p.muConn.Unlock()
|
||||
func (g *Gateway) connect() error {
|
||||
g.muConn.Lock()
|
||||
defer g.muConn.Unlock()
|
||||
|
||||
if p.conn != nil {
|
||||
if g.conn != nil {
|
||||
// already connected
|
||||
return nil
|
||||
}
|
||||
err := retry.Do(func() error {
|
||||
p.log.Info("connect to simulator")
|
||||
conn, err := connect(p.address)
|
||||
g.log.Info("connect to simulator")
|
||||
conn, err := connect(g.address)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to connect to simulator at %v", p.address)
|
||||
return fmt.Errorf("unable to connect to simulator at %v", g.address)
|
||||
}
|
||||
p.conn = conn
|
||||
p.log.Info("connection success")
|
||||
g.conn = conn
|
||||
g.log.Info("connection success")
|
||||
return nil
|
||||
},
|
||||
retry.Delay(1*time.Second),
|
||||
@ -149,30 +178,83 @@ func (p *Gateway) connect() error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (p *Gateway) listen(msgChan chan<- *simulator.TelemetryMsg, reader *bufio.Reader) error {
|
||||
func (g *Gateway) listen() error {
|
||||
reader := bufio.NewReader(g.conn)
|
||||
|
||||
for {
|
||||
rawLine, err := reader.ReadBytes('\n')
|
||||
if err == io.EOF {
|
||||
p.log.Info("Connection closed")
|
||||
g.log.Info("Connection closed")
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to read response: %v", err)
|
||||
}
|
||||
|
||||
var msg simulator.TelemetryMsg
|
||||
var msg simulator.Msg
|
||||
err = json.Unmarshal(rawLine, &msg)
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to unmarshal simulator msg '%v': %v", string(rawLine), err)
|
||||
g.log.Errorf("unable to unmarshal simulator msg '%v': %v", string(rawLine), err)
|
||||
}
|
||||
if "telemetry" != msg.MsgType {
|
||||
continue
|
||||
|
||||
switch msg.MsgType {
|
||||
case simulator.MsgTypeTelemetry:
|
||||
g.broadcastTelemetryMsg(rawLine)
|
||||
case simulator.MsgTypeCarLoaded:
|
||||
g.broadcastCarMsg(rawLine)
|
||||
case simulator.MsgTypeRacerInfo:
|
||||
g.broadcastRacerMsg(rawLine)
|
||||
default:
|
||||
log.Warnf("unmanaged simulator message: %v", string(rawLine))
|
||||
}
|
||||
msgChan <- &msg
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Gateway) publishFrame(msgSim *simulator.TelemetryMsg) *events.FrameRef {
|
||||
func (g *Gateway) broadcastTelemetryMsg(rawLine []byte) {
|
||||
for c := range g.telemetrySubscribers {
|
||||
|
||||
var tMsg simulator.TelemetryMsg
|
||||
err := json.Unmarshal(rawLine, &tMsg)
|
||||
if err != nil {
|
||||
g.log.Errorf("unable to unmarshal telemetry simulator msg '%v': %v", string(rawLine), err)
|
||||
}
|
||||
c <- &tMsg
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gateway) broadcastCarMsg(rawLine []byte) {
|
||||
for c := range g.carSubscribers {
|
||||
var tMsg simulator.Msg
|
||||
err := json.Unmarshal(rawLine, &tMsg)
|
||||
if err != nil {
|
||||
g.log.Errorf("unable to unmarshal car simulator msg '%v': %v", string(rawLine), err)
|
||||
}
|
||||
c <- &tMsg
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gateway) broadcastRacerMsg(rawLine []byte) {
|
||||
for c := range g.racerSubscribers {
|
||||
var tMsg simulator.Msg
|
||||
err := json.Unmarshal(rawLine, &tMsg)
|
||||
if err != nil {
|
||||
g.log.Errorf("unable to unmarshal racer simulator msg '%v': %v", string(rawLine), err)
|
||||
}
|
||||
c <- &tMsg
|
||||
}
|
||||
}
|
||||
func (g *Gateway) broadcastCameraMsg(rawLine []byte) {
|
||||
for c := range g.cameraSubscribers {
|
||||
var tMsg simulator.Msg
|
||||
err := json.Unmarshal(rawLine, &tMsg)
|
||||
if err != nil {
|
||||
g.log.Errorf("unable to unmarshal camera simulator msg '%v': %v", string(rawLine), err)
|
||||
}
|
||||
c <- &tMsg
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gateway) publishFrame(msgSim *simulator.TelemetryMsg) *events.FrameRef {
|
||||
now := time.Now()
|
||||
frameRef := &events.FrameRef{
|
||||
Name: "gateway",
|
||||
@ -188,13 +270,14 @@ func (p *Gateway) publishFrame(msgSim *simulator.TelemetryMsg) *events.FrameRef
|
||||
}
|
||||
|
||||
log.Debugf("events frame '%v/%v'", msg.Id.Name, msg.Id.Id)
|
||||
for fs := range p.frameSubscribers {
|
||||
|
||||
for fs := range g.frameSubscribers {
|
||||
fs <- msg
|
||||
}
|
||||
return frameRef
|
||||
}
|
||||
|
||||
func (p *Gateway) publishInputSteering(msgSim *simulator.TelemetryMsg, frameRef *events.FrameRef) {
|
||||
func (g *Gateway) publishInputSteering(msgSim *simulator.TelemetryMsg, frameRef *events.FrameRef) {
|
||||
steering := &events.SteeringMessage{
|
||||
FrameRef: frameRef,
|
||||
Steering: float32(msgSim.SteeringAngle),
|
||||
@ -202,12 +285,12 @@ func (p *Gateway) publishInputSteering(msgSim *simulator.TelemetryMsg, frameRef
|
||||
}
|
||||
|
||||
log.Debugf("events steering '%v'", steering.Steering)
|
||||
for ss := range p.steeringSubscribers {
|
||||
for ss := range g.steeringSubscribers {
|
||||
ss <- steering
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Gateway) publishInputThrottle(msgSim *simulator.TelemetryMsg, frameRef *events.FrameRef) {
|
||||
func (g *Gateway) publishInputThrottle(msgSim *simulator.TelemetryMsg, frameRef *events.FrameRef) {
|
||||
msg := &events.ThrottleMessage{
|
||||
FrameRef: frameRef,
|
||||
Throttle: float32(msgSim.Throttle),
|
||||
@ -215,27 +298,68 @@ func (p *Gateway) publishInputThrottle(msgSim *simulator.TelemetryMsg, frameRef
|
||||
}
|
||||
|
||||
log.Debugf("events throttle '%v'", msg.Throttle)
|
||||
for ts := range p.throttleSubscribers {
|
||||
for ts := range g.throttleSubscribers {
|
||||
ts <- msg
|
||||
}
|
||||
}
|
||||
|
||||
func (p *Gateway) SubscribeFrame() <-chan *events.FrameMessage {
|
||||
func (g *Gateway) SubscribeFrame() <-chan *events.FrameMessage {
|
||||
frameChan := make(chan *events.FrameMessage)
|
||||
p.frameSubscribers[frameChan] = struct{}{}
|
||||
g.frameSubscribers[frameChan] = struct{}{}
|
||||
return frameChan
|
||||
}
|
||||
func (p *Gateway) SubscribeSteering() <-chan *events.SteeringMessage {
|
||||
func (g *Gateway) SubscribeSteering() <-chan *events.SteeringMessage {
|
||||
steeringChan := make(chan *events.SteeringMessage)
|
||||
p.steeringSubscribers[steeringChan] = struct{}{}
|
||||
g.steeringSubscribers[steeringChan] = struct{}{}
|
||||
return steeringChan
|
||||
}
|
||||
func (p *Gateway) SubscribeThrottle() <-chan *events.ThrottleMessage {
|
||||
func (g *Gateway) SubscribeThrottle() <-chan *events.ThrottleMessage {
|
||||
throttleChan := make(chan *events.ThrottleMessage)
|
||||
p.throttleSubscribers[throttleChan] = struct{}{}
|
||||
g.throttleSubscribers[throttleChan] = struct{}{}
|
||||
return throttleChan
|
||||
}
|
||||
|
||||
func (g *Gateway) subscribeTelemetryEvents() chan *simulator.TelemetryMsg {
|
||||
telemetryChan := make(chan *simulator.TelemetryMsg)
|
||||
g.telemetrySubscribers[telemetryChan] = struct{}{}
|
||||
return telemetryChan
|
||||
}
|
||||
func (g *Gateway) unsubscribeTelemetryEvents(telemetryChan chan *simulator.TelemetryMsg) {
|
||||
delete(g.telemetrySubscribers, telemetryChan)
|
||||
close(telemetryChan)
|
||||
}
|
||||
func (g *Gateway) subscribeCarEvents() chan *simulator.Msg {
|
||||
carChan := make(chan *simulator.Msg)
|
||||
g.carSubscribers[carChan] = struct{}{}
|
||||
return carChan
|
||||
}
|
||||
func (g *Gateway) unsubscribeCarEvents(carChan chan *simulator.Msg) {
|
||||
delete(g.carSubscribers, carChan)
|
||||
close(carChan)
|
||||
}
|
||||
|
||||
func (g *Gateway) subscribeRacerEvents() chan *simulator.Msg {
|
||||
racerChan := make(chan *simulator.Msg)
|
||||
g.racerSubscribers[racerChan] = struct{}{}
|
||||
return racerChan
|
||||
}
|
||||
|
||||
func (g *Gateway) unsubscribeRacerEvents(racerChan chan *simulator.Msg) {
|
||||
delete(g.racerSubscribers, racerChan)
|
||||
close(racerChan)
|
||||
}
|
||||
|
||||
func (g *Gateway) subscribeCameraEvents() chan *simulator.Msg {
|
||||
cameraChan := make(chan *simulator.Msg)
|
||||
g.cameraSubscribers[cameraChan] = struct{}{}
|
||||
return cameraChan
|
||||
}
|
||||
|
||||
func (g *Gateway) unsubscribeCameraEvents(cameraChan chan *simulator.Msg) {
|
||||
delete(g.cameraSubscribers, cameraChan)
|
||||
close(cameraChan)
|
||||
}
|
||||
|
||||
var connect = func(address string) (io.ReadWriteCloser, error) {
|
||||
conn, err := net.Dial("tcp", address)
|
||||
if err != nil {
|
||||
@ -244,63 +368,144 @@ var connect = func(address string) (io.ReadWriteCloser, error) {
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (p *Gateway) WriteSteering(message *events.SteeringMessage) {
|
||||
p.muControl.Lock()
|
||||
defer p.muControl.Unlock()
|
||||
p.initLastControlMsg()
|
||||
func (g *Gateway) WriteSteering(message *events.SteeringMessage) {
|
||||
g.muControl.Lock()
|
||||
defer g.muControl.Unlock()
|
||||
g.initLastControlMsg()
|
||||
|
||||
p.lastControl.Steering = message.Steering
|
||||
p.writeControlCommandToSimulator()
|
||||
g.lastControl.Steering = fmt.Sprintf("%.2f", message.Steering)
|
||||
g.writeControlCommandToSimulator()
|
||||
}
|
||||
|
||||
func (p *Gateway) writeControlCommandToSimulator() {
|
||||
if err := p.connect(); err != nil {
|
||||
p.log.Errorf("unable to connect to simulator to send control command: %v", err)
|
||||
return
|
||||
}
|
||||
w := bufio.NewWriter(p.conn)
|
||||
content, err := json.Marshal(p.lastControl)
|
||||
func (g *Gateway) writeControlCommandToSimulator() {
|
||||
content, err := json.Marshal(g.lastControl)
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to marshall control msg \"%#v\": %v", p.lastControl, err)
|
||||
g.log.Errorf("unable to marshall control msg \"%#v\": %v", g.lastControl, err)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = w.Write(append(content, '\n'))
|
||||
err = g.writeCommand(content)
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to write control msg \"%#v\" to simulator: %v", p.lastControl, err)
|
||||
return
|
||||
g.log.Errorf("unable to send control command to simulator: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gateway) writeCommand(content []byte) error {
|
||||
g.muCommand.Lock()
|
||||
defer g.muCommand.Unlock()
|
||||
|
||||
if err := g.connect(); err != nil {
|
||||
g.log.Errorf("unable to connect to simulator to send control command: %v", err)
|
||||
return nil
|
||||
}
|
||||
log.Debugf("write command to simulator: %v", string(content))
|
||||
w := bufio.NewWriter(g.conn)
|
||||
|
||||
_, err := w.Write(append(content, '\n'))
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to write control msg \"%#v\" to simulator: %v", g.lastControl, err)
|
||||
}
|
||||
err = w.Flush()
|
||||
if err != nil {
|
||||
p.log.Errorf("unable to flush control msg \"%#v\" to simulator: %v", p.lastControl, err)
|
||||
return
|
||||
return fmt.Errorf("unable to flush control msg \"%#v\" to simulator: %v", g.lastControl, err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *Gateway) WriteThrottle(message *events.ThrottleMessage) {
|
||||
p.muControl.Lock()
|
||||
defer p.muControl.Unlock()
|
||||
p.initLastControlMsg()
|
||||
func (g *Gateway) WriteThrottle(message *events.ThrottleMessage) {
|
||||
g.muControl.Lock()
|
||||
defer g.muControl.Unlock()
|
||||
g.initLastControlMsg()
|
||||
|
||||
if message.Throttle > 0 {
|
||||
p.lastControl.Throttle = message.Throttle
|
||||
p.lastControl.Brake = 0.
|
||||
g.lastControl.Throttle = fmt.Sprintf("%.2f", message.Throttle)
|
||||
g.lastControl.Brake = "0.0"
|
||||
} else {
|
||||
p.lastControl.Throttle = 0.
|
||||
p.lastControl.Brake = -1 * message.Throttle
|
||||
g.lastControl.Throttle = "0.0"
|
||||
g.lastControl.Brake = fmt.Sprintf("%.2f", -1*message.Throttle)
|
||||
}
|
||||
|
||||
p.writeControlCommandToSimulator()
|
||||
g.writeControlCommandToSimulator()
|
||||
}
|
||||
|
||||
func (p *Gateway) initLastControlMsg() {
|
||||
if p.lastControl != nil {
|
||||
func (g *Gateway) initLastControlMsg() {
|
||||
if g.lastControl != nil {
|
||||
return
|
||||
}
|
||||
p.lastControl = &simulator.ControlMsg{
|
||||
MsgType: "control",
|
||||
Steering: 0.,
|
||||
Throttle: 0.,
|
||||
Brake: 0.,
|
||||
g.lastControl = &simulator.ControlMsg{
|
||||
MsgType: simulator.MsgTypeControl,
|
||||
Steering: "0.0",
|
||||
Throttle: "0.0",
|
||||
Brake: "0.0",
|
||||
}
|
||||
}
|
||||
|
||||
func (g *Gateway) writeCarConfig() error {
|
||||
carChan := g.subscribeCarEvents()
|
||||
defer g.unsubscribeCarEvents(carChan)
|
||||
|
||||
g.log.Info("Send car configuration")
|
||||
|
||||
content, err := json.Marshal(g.carConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to marshall car config msg \"%#v\": %v", g.lastControl, err)
|
||||
}
|
||||
|
||||
err = g.writeCommand(content)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to send car config to simulator: %v", err)
|
||||
}
|
||||
|
||||
msg := <-carChan
|
||||
g.log.Infof("Car loaded: %v", msg)
|
||||
time.Sleep(250 * time.Millisecond)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Gateway) writeRacerConfig() error {
|
||||
racerChan := g.subscribeRacerEvents()
|
||||
defer g.unsubscribeRacerEvents(racerChan)
|
||||
|
||||
g.log.Info("Send racer configuration")
|
||||
|
||||
content, err := json.Marshal(g.racer)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to marshall racer config msg \"%#v\": %v", g.lastControl, err)
|
||||
}
|
||||
|
||||
err = g.writeCommand(content)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to send racer config to simulator: %v", err)
|
||||
}
|
||||
|
||||
select {
|
||||
case msg := <-racerChan:
|
||||
g.log.Infof("Racer loaded: %v", msg)
|
||||
case <-time.Tick(250 * time.Millisecond):
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (g *Gateway) writeCameraConfig() error {
|
||||
cameraChan := g.subscribeCameraEvents()
|
||||
defer g.unsubscribeCameraEvents(cameraChan)
|
||||
|
||||
g.log.Info("Send camera configuration")
|
||||
|
||||
content, err := json.Marshal(g.cameraConfig)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to marshall camera config msg \"%#v\": %v", g.lastControl, err)
|
||||
}
|
||||
|
||||
err = g.writeCommand(content)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to send camera config to simulator: %v", err)
|
||||
}
|
||||
|
||||
select {
|
||||
case msg := <-cameraChan:
|
||||
g.log.Infof("Camera configured: %v", msg)
|
||||
case <-time.Tick(250 * time.Millisecond):
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package gateway
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/cyrilix/robocar-protobuf/go/events"
|
||||
"github.com/cyrilix/robocar-simulator/pkg/simulator"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
@ -23,7 +25,11 @@ func TestGateway_ListenEvents(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
gw := New(simulatorMock.Addr())
|
||||
gw := New(simulatorMock.Addr(),
|
||||
&simulator.CarConfigMsg{MsgType: simulator.MsgTypeCarConfig},
|
||||
&simulator.RacerBioMsg{},
|
||||
&simulator.CamConfigMsg{},
|
||||
)
|
||||
go func() {
|
||||
err := gw.Start()
|
||||
if err != nil {
|
||||
@ -40,6 +46,8 @@ func TestGateway_ListenEvents(t *testing.T) {
|
||||
throttleChannel := gw.SubscribeThrottle()
|
||||
|
||||
simulatorMock.WaitConnection()
|
||||
simulatorMock.EmitMsg(fmt.Sprintf("{\"msg_type\": \"%s\"}", simulator.MsgTypeCarLoaded))
|
||||
|
||||
log.Trace("read test data")
|
||||
testContent, err := ioutil.ReadFile("testdata/msg.json")
|
||||
lines := strings.Split(string(testContent), "\n")
|
||||
|
@ -12,16 +12,31 @@ import (
|
||||
)
|
||||
|
||||
type Gw2SimMock struct {
|
||||
initMsgsOnce sync.Once
|
||||
initOnce sync.Once
|
||||
|
||||
ln net.Listener
|
||||
notifyChan chan *simulator.ControlMsg
|
||||
initNotifyChan sync.Once
|
||||
notifyCtrlChan chan *simulator.ControlMsg
|
||||
notifyCarChan chan *simulator.CarConfigMsg
|
||||
notifyCamChan chan *simulator.CamConfigMsg
|
||||
}
|
||||
|
||||
func (c *Gw2SimMock) Notify() <-chan *simulator.ControlMsg {
|
||||
c.initNotifyChan.Do(func() { c.notifyChan = make(chan *simulator.ControlMsg) })
|
||||
return c.notifyChan
|
||||
func (c *Gw2SimMock) init(){
|
||||
c.notifyCtrlChan = make(chan *simulator.ControlMsg)
|
||||
c.notifyCarChan = make(chan *simulator.CarConfigMsg)
|
||||
c.notifyCamChan = make(chan *simulator.CamConfigMsg)
|
||||
}
|
||||
|
||||
func (c *Gw2SimMock) NotifyCtrl() <-chan *simulator.ControlMsg {
|
||||
c.initOnce.Do(c.init)
|
||||
return c.notifyCtrlChan
|
||||
}
|
||||
func (c *Gw2SimMock) NotifyCar() <-chan *simulator.CarConfigMsg {
|
||||
c.initOnce.Do(c.init)
|
||||
return c.notifyCarChan
|
||||
}
|
||||
func (c *Gw2SimMock) NotifyCamera() <-chan *simulator.CamConfigMsg {
|
||||
c.initOnce.Do(c.init)
|
||||
return c.notifyCamChan
|
||||
}
|
||||
|
||||
func (c *Gw2SimMock) listen() error {
|
||||
@ -50,10 +65,12 @@ func (c *Gw2SimMock) Addr() string {
|
||||
}
|
||||
|
||||
func (c *Gw2SimMock) handleConnection(conn net.Conn) {
|
||||
c.initNotifyChan.Do(func() { c.notifyChan = make(chan *simulator.ControlMsg) })
|
||||
c.initOnce.Do(c.init)
|
||||
reader := bufio.NewReader(conn)
|
||||
writer := bufio.NewWriter(conn)
|
||||
|
||||
for {
|
||||
rawCmd, err := reader.ReadBytes('\n')
|
||||
rawMsg, err := reader.ReadBytes('\n')
|
||||
if err != nil {
|
||||
if err == io.EOF {
|
||||
log.Debug("connection closed")
|
||||
@ -62,15 +79,54 @@ func (c *Gw2SimMock) handleConnection(conn net.Conn) {
|
||||
log.Errorf("unable to read request: %v", err)
|
||||
return
|
||||
}
|
||||
|
||||
var msg simulator.ControlMsg
|
||||
err = json.Unmarshal(rawCmd, &msg)
|
||||
var msg simulator.Msg
|
||||
err = json.Unmarshal(rawMsg, &msg)
|
||||
if err != nil {
|
||||
log.Errorf("unable to unmarchal control msg \"%v\": %v", string(rawCmd), err)
|
||||
log.Errorf("unable to unmarshal msg \"%v\": %v", string(rawMsg), err)
|
||||
continue
|
||||
}
|
||||
|
||||
c.notifyChan <- &msg
|
||||
switch msg.MsgType {
|
||||
case simulator.MsgTypeControl:
|
||||
var msgControl simulator.ControlMsg
|
||||
err = json.Unmarshal(rawMsg, &msgControl)
|
||||
if err != nil {
|
||||
log.Errorf("unable to unmarshal control msg \"%v\": %v", string(rawMsg), err)
|
||||
continue
|
||||
}
|
||||
c.notifyCtrlChan <- &msgControl
|
||||
case simulator.MsgTypeCarConfig:
|
||||
var msgCar simulator.CarConfigMsg
|
||||
err = json.Unmarshal(rawMsg, &msgCar)
|
||||
if err != nil {
|
||||
log.Errorf("unable to unmarshal car msg \"%v\": %v", string(rawMsg), err)
|
||||
continue
|
||||
}
|
||||
c.notifyCarChan <- &msgCar
|
||||
carLoadedMsg := simulator.Msg{MsgType: simulator.MsgTypeCarLoaded}
|
||||
resp, err := json.Marshal(&carLoadedMsg)
|
||||
if err != nil {
|
||||
log.Errorf("unable to generate car loaded response: %v", err)
|
||||
continue
|
||||
}
|
||||
_, err = writer.WriteString(string(resp) + "\n")
|
||||
if err != nil {
|
||||
log.Errorf("unable to write car loaded response: %v", err)
|
||||
continue
|
||||
}
|
||||
err = writer.Flush()
|
||||
if err != nil {
|
||||
log.Errorf("unable to flush car loaded response: %v", err)
|
||||
continue
|
||||
}
|
||||
case simulator.MsgTypeCameraConfig:
|
||||
var msgCam simulator.CamConfigMsg
|
||||
err = json.Unmarshal(rawMsg, &msgCam)
|
||||
if err != nil {
|
||||
log.Errorf("unable to unmarshal camera msg \"%v\": %v", string(rawMsg), err)
|
||||
continue
|
||||
}
|
||||
c.notifyCamChan <- &msgCam
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,8 +136,14 @@ func (c *Gw2SimMock) Close() error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to close mock server: %v", err)
|
||||
}
|
||||
if c.notifyChan != nil {
|
||||
close(c.notifyChan)
|
||||
if c.notifyCtrlChan != nil {
|
||||
close(c.notifyCtrlChan)
|
||||
}
|
||||
if c.notifyCarChan != nil {
|
||||
close(c.notifyCarChan)
|
||||
}
|
||||
if c.notifyCamChan != nil {
|
||||
close(c.notifyCamChan)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -1,7 +1,22 @@
|
||||
package simulator
|
||||
|
||||
type MsgType string
|
||||
|
||||
const (
|
||||
MsgTypeControl = MsgType("control")
|
||||
MsgTypeTelemetry = MsgType("telemetry")
|
||||
MsgTypeCarConfig = MsgType("car_config")
|
||||
MsgTypeCarLoaded = MsgType("car_loaded")
|
||||
MsgTypeRacerInfo = MsgType("racer_info")
|
||||
MsgTypeCameraConfig = MsgType("cam_config")
|
||||
)
|
||||
|
||||
type Msg struct {
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
}
|
||||
|
||||
type TelemetryMsg struct {
|
||||
MsgType string `json:"msg_type"`
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
SteeringAngle float64 `json:"steering_angle"`
|
||||
Throttle float64 `json:"throttle"`
|
||||
Speed float64 `json:"speed"`
|
||||
@ -16,8 +31,86 @@ type TelemetryMsg struct {
|
||||
|
||||
/* Json msg used to control cars. MsgType must be filled with "control" */
|
||||
type ControlMsg struct {
|
||||
MsgType string `json:"msg_type"`
|
||||
Steering float32 `json:"steering"`
|
||||
Throttle float32 `json:"throttle"`
|
||||
Brake float32 `json:"brake"`
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
Steering string `json:"steering"`
|
||||
Throttle string `json:"throttle"`
|
||||
Brake string `json:"brake"`
|
||||
}
|
||||
|
||||
type GetSceneNamesMsg struct {
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
SceneName string `json:"scene_name"`
|
||||
}
|
||||
|
||||
type LoadSceneMsg struct {
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
SceneName string `json:"scene_name"`
|
||||
}
|
||||
|
||||
type CarStyle string
|
||||
|
||||
const (
|
||||
CarConfigBodyStyleDonkey = CarStyle("donkey")
|
||||
CarConfigBodyStyleBare = CarStyle("bare")
|
||||
CarConfigBodyStyleCar01 = CarStyle("car01")
|
||||
)
|
||||
|
||||
/*
|
||||
# body_style = "donkey" | "bare" | "car01" choice of string
|
||||
# body_rgb = (128, 128, 128) tuple of ints
|
||||
# car_name = "string less than 64 char"
|
||||
*/
|
||||
type CarConfigMsg struct {
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
BodyStyle CarStyle `json:"body_style"`
|
||||
BodyR string `json:"body_r"`
|
||||
BodyG string `json:"body_g"`
|
||||
BodyB string `json:"body_b"`
|
||||
CarName string `json:"car_name"`
|
||||
FontSize string `json:"font_size"`
|
||||
}
|
||||
|
||||
/*
|
||||
# car_name = "string less than 64 char"
|
||||
# guid = "some random string"
|
||||
*/
|
||||
type RacerBioMsg struct {
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
RacerName string `json:"racer_name"`
|
||||
CarName string `json:"car_name"`
|
||||
Bio string `json:"bio"`
|
||||
Country string `json:"country"`
|
||||
Guid string `json:"guid"`
|
||||
}
|
||||
|
||||
type CameraImageEnc string
|
||||
|
||||
const (
|
||||
CameraImageEncJpeg = CameraImageEnc("JPG")
|
||||
CameraImageEncPng = CameraImageEnc("PNG")
|
||||
CameraImageEncTga = CameraImageEnc("TGA")
|
||||
)
|
||||
|
||||
/* Camera config
|
||||
set any field to Zero to get the default camera setting.
|
||||
offset_x moves camera left/right
|
||||
offset_y moves camera up/down
|
||||
offset_z moves camera forward/back
|
||||
rot_x will rotate the camera
|
||||
with fish_eye_x/y == 0.0 then you get no distortion
|
||||
img_enc can be one of JPG|PNG|TGA
|
||||
*/
|
||||
type CamConfigMsg struct {
|
||||
MsgType MsgType `json:"msg_type"`
|
||||
Fov string `json:"fov"`
|
||||
FishEyeX string `json:"fish_eye_x"`
|
||||
FishEyeY string `json:"fish_eye_y"`
|
||||
ImgW string `json:"img_w"`
|
||||
ImgH string `json:"img_h"`
|
||||
ImgD string `json:"img_d"`
|
||||
ImgEnc CameraImageEnc `json:"img_enc"`
|
||||
OffsetX string `json:"offset_x"`
|
||||
OffsetY string `json:"offset_y"`
|
||||
OffsetZ string `json:"offset_z"`
|
||||
RotX string `json:"rot_x"`
|
||||
}
|
||||
|
5
vendor/github.com/avast/retry-go/.travis.yml
generated
vendored
5
vendor/github.com/avast/retry-go/.travis.yml
generated
vendored
@ -1,13 +1,14 @@
|
||||
language: go
|
||||
|
||||
go:
|
||||
- 1.6
|
||||
- 1.7
|
||||
- 1.8
|
||||
- 1.9
|
||||
- "1.10"
|
||||
- 1.11
|
||||
- 1.12
|
||||
- 1.13
|
||||
- 1.14
|
||||
- 1.15
|
||||
|
||||
install:
|
||||
- make setup
|
||||
|
37
vendor/github.com/avast/retry-go/README.md
generated
vendored
37
vendor/github.com/avast/retry-go/README.md
generated
vendored
@ -64,6 +64,12 @@ nonintuitive interface (for me)
|
||||
|
||||
### BREAKING CHANGES
|
||||
|
||||
3.0.0
|
||||
|
||||
* `DelayTypeFunc` accepts a new parameter `err` - this breaking change affects
|
||||
only your custom Delay Functions. This change allow [make delay functions based
|
||||
on error](examples/delay_based_on_error_test.go).
|
||||
|
||||
1.0.2 -> 2.0.0
|
||||
|
||||
* argument of `retry.Delay` is final delay (no multiplication by `retry.Units`
|
||||
@ -91,13 +97,14 @@ var (
|
||||
DefaultRetryIf = IsRecoverable
|
||||
DefaultDelayType = CombineDelay(BackOffDelay, RandomDelay)
|
||||
DefaultLastErrorOnly = false
|
||||
DefaultContext = context.Background()
|
||||
)
|
||||
```
|
||||
|
||||
#### func BackOffDelay
|
||||
|
||||
```go
|
||||
func BackOffDelay(n uint, config *Config) time.Duration
|
||||
func BackOffDelay(n uint, _ error, config *Config) time.Duration
|
||||
```
|
||||
BackOffDelay is a DelayType which increases delay between consecutive retries
|
||||
|
||||
@ -110,7 +117,7 @@ func Do(retryableFunc RetryableFunc, opts ...Option) error
|
||||
#### func FixedDelay
|
||||
|
||||
```go
|
||||
func FixedDelay(_ uint, config *Config) time.Duration
|
||||
func FixedDelay(_ uint, _ error, config *Config) time.Duration
|
||||
```
|
||||
FixedDelay is a DelayType which keeps delay the same through all iterations
|
||||
|
||||
@ -124,7 +131,7 @@ IsRecoverable checks if error is an instance of `unrecoverableError`
|
||||
#### func RandomDelay
|
||||
|
||||
```go
|
||||
func RandomDelay(_ uint, config *Config) time.Duration
|
||||
func RandomDelay(_ uint, _ error, config *Config) time.Duration
|
||||
```
|
||||
RandomDelay is a DelayType which picks a random delay up to config.maxJitter
|
||||
|
||||
@ -146,9 +153,11 @@ type Config struct {
|
||||
#### type DelayTypeFunc
|
||||
|
||||
```go
|
||||
type DelayTypeFunc func(n uint, config *Config) time.Duration
|
||||
type DelayTypeFunc func(n uint, err error, config *Config) time.Duration
|
||||
```
|
||||
|
||||
DelayTypeFunc is called to return the next delay to wait after the retriable
|
||||
function fails on `err` after `n` attempts.
|
||||
|
||||
#### func CombineDelay
|
||||
|
||||
@ -207,6 +216,26 @@ func Attempts(attempts uint) Option
|
||||
```
|
||||
Attempts set count of retry default is 10
|
||||
|
||||
#### func Context
|
||||
|
||||
```go
|
||||
func Context(ctx context.Context) Option
|
||||
```
|
||||
Context allow to set context of retry default are Background context
|
||||
|
||||
example of immediately cancellation (maybe it isn't the best example, but it
|
||||
describes behavior enough; I hope)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
cancel()
|
||||
|
||||
retry.Do(
|
||||
func() error {
|
||||
...
|
||||
},
|
||||
retry.Context(ctx),
|
||||
)
|
||||
|
||||
#### func Delay
|
||||
|
||||
```go
|
||||
|
2
vendor/github.com/avast/retry-go/VERSION
generated
vendored
2
vendor/github.com/avast/retry-go/VERSION
generated
vendored
@ -1 +1 @@
|
||||
2.6.0
|
||||
3.0.0
|
||||
|
65
vendor/github.com/avast/retry-go/options.go
generated
vendored
65
vendor/github.com/avast/retry-go/options.go
generated
vendored
@ -1,6 +1,8 @@
|
||||
package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
@ -12,7 +14,8 @@ type RetryIfFunc func(error) bool
|
||||
// n = count of attempts
|
||||
type OnRetryFunc func(n uint, err error)
|
||||
|
||||
type DelayTypeFunc func(n uint, config *Config) time.Duration
|
||||
// DelayTypeFunc is called to return the next delay to wait after the retriable function fails on `err` after `n` attempts.
|
||||
type DelayTypeFunc func(n uint, err error, config *Config) time.Duration
|
||||
|
||||
type Config struct {
|
||||
attempts uint
|
||||
@ -23,6 +26,9 @@ type Config struct {
|
||||
retryIf RetryIfFunc
|
||||
delayType DelayTypeFunc
|
||||
lastErrorOnly bool
|
||||
context context.Context
|
||||
|
||||
maxBackOffN uint
|
||||
}
|
||||
|
||||
// Option represents an option for retry.
|
||||
@ -76,28 +82,49 @@ func DelayType(delayType DelayTypeFunc) Option {
|
||||
}
|
||||
|
||||
// BackOffDelay is a DelayType which increases delay between consecutive retries
|
||||
func BackOffDelay(n uint, config *Config) time.Duration {
|
||||
return config.delay * (1 << n)
|
||||
func BackOffDelay(n uint, _ error, config *Config) time.Duration {
|
||||
// 1 << 63 would overflow signed int64 (time.Duration), thus 62.
|
||||
const max uint = 62
|
||||
|
||||
if config.maxBackOffN == 0 {
|
||||
if config.delay <= 0 {
|
||||
config.delay = 1
|
||||
}
|
||||
|
||||
config.maxBackOffN = max - uint(math.Floor(math.Log2(float64(config.delay))))
|
||||
}
|
||||
|
||||
if n > config.maxBackOffN {
|
||||
n = config.maxBackOffN
|
||||
}
|
||||
|
||||
return config.delay << n
|
||||
}
|
||||
|
||||
// FixedDelay is a DelayType which keeps delay the same through all iterations
|
||||
func FixedDelay(_ uint, config *Config) time.Duration {
|
||||
func FixedDelay(_ uint, _ error, config *Config) time.Duration {
|
||||
return config.delay
|
||||
}
|
||||
|
||||
// RandomDelay is a DelayType which picks a random delay up to config.maxJitter
|
||||
func RandomDelay(_ uint, config *Config) time.Duration {
|
||||
func RandomDelay(_ uint, _ error, config *Config) time.Duration {
|
||||
return time.Duration(rand.Int63n(int64(config.maxJitter)))
|
||||
}
|
||||
|
||||
// CombineDelay is a DelayType the combines all of the specified delays into a new DelayTypeFunc
|
||||
func CombineDelay(delays ...DelayTypeFunc) DelayTypeFunc {
|
||||
return func(n uint, config *Config) time.Duration {
|
||||
var total time.Duration
|
||||
const maxInt64 = uint64(math.MaxInt64)
|
||||
|
||||
return func(n uint, err error, config *Config) time.Duration {
|
||||
var total uint64
|
||||
for _, delay := range delays {
|
||||
total += delay(n, config)
|
||||
total += uint64(delay(n, err, config))
|
||||
if total > maxInt64 {
|
||||
total = maxInt64
|
||||
}
|
||||
}
|
||||
return total
|
||||
|
||||
return time.Duration(total)
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,3 +176,23 @@ func RetryIf(retryIf RetryIfFunc) Option {
|
||||
c.retryIf = retryIf
|
||||
}
|
||||
}
|
||||
|
||||
// Context allow to set context of retry
|
||||
// default are Background context
|
||||
//
|
||||
// example of immediately cancellation (maybe it isn't the best example, but it describes behavior enough; I hope)
|
||||
//
|
||||
// ctx, cancel := context.WithCancel(context.Background())
|
||||
// cancel()
|
||||
//
|
||||
// retry.Do(
|
||||
// func() error {
|
||||
// ...
|
||||
// },
|
||||
// retry.Context(ctx),
|
||||
// )
|
||||
func Context(ctx context.Context) Option {
|
||||
return func(c *Config) {
|
||||
c.context = ctx
|
||||
}
|
||||
}
|
||||
|
23
vendor/github.com/avast/retry-go/retry.go
generated
vendored
23
vendor/github.com/avast/retry-go/retry.go
generated
vendored
@ -43,8 +43,14 @@ SEE ALSO
|
||||
|
||||
* [matryer/try](https://github.com/matryer/try) - very popular package, nonintuitive interface (for me)
|
||||
|
||||
|
||||
BREAKING CHANGES
|
||||
|
||||
3.0.0
|
||||
|
||||
* `DelayTypeFunc` accepts a new parameter `err` - this breaking change affects only your custom Delay Functions. This change allow [make delay functions based on error](examples/delay_based_on_error_test.go).
|
||||
|
||||
|
||||
1.0.2 -> 2.0.0
|
||||
|
||||
* argument of `retry.Delay` is final delay (no multiplication by `retry.Units` anymore)
|
||||
@ -65,6 +71,7 @@ BREAKING CHANGES
|
||||
package retry
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@ -81,6 +88,7 @@ var (
|
||||
DefaultRetryIf = IsRecoverable
|
||||
DefaultDelayType = CombineDelay(BackOffDelay, RandomDelay)
|
||||
DefaultLastErrorOnly = false
|
||||
DefaultContext = context.Background()
|
||||
)
|
||||
|
||||
func Do(retryableFunc RetryableFunc, opts ...Option) error {
|
||||
@ -95,6 +103,7 @@ func Do(retryableFunc RetryableFunc, opts ...Option) error {
|
||||
retryIf: DefaultRetryIf,
|
||||
delayType: DefaultDelayType,
|
||||
lastErrorOnly: DefaultLastErrorOnly,
|
||||
context: DefaultContext,
|
||||
}
|
||||
|
||||
//apply opts
|
||||
@ -102,6 +111,10 @@ func Do(retryableFunc RetryableFunc, opts ...Option) error {
|
||||
opt(config)
|
||||
}
|
||||
|
||||
if err := config.context.Err(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var errorLog Error
|
||||
if !config.lastErrorOnly {
|
||||
errorLog = make(Error, config.attempts)
|
||||
@ -127,11 +140,17 @@ func Do(retryableFunc RetryableFunc, opts ...Option) error {
|
||||
break
|
||||
}
|
||||
|
||||
delayTime := config.delayType(n, config)
|
||||
delayTime := config.delayType(n, err, config)
|
||||
if config.maxDelay > 0 && delayTime > config.maxDelay {
|
||||
delayTime = config.maxDelay
|
||||
}
|
||||
time.Sleep(delayTime)
|
||||
|
||||
select {
|
||||
case <-time.After(delayTime):
|
||||
case <-config.context.Done():
|
||||
return config.context.Err()
|
||||
}
|
||||
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
6
vendor/github.com/cyrilix/robocar-protobuf/go/events/events.pb.go
generated
vendored
6
vendor/github.com/cyrilix/robocar-protobuf/go/events/events.pb.go
generated
vendored
@ -1,6 +1,6 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.25.0-devel
|
||||
// protoc-gen-go v1.26.0
|
||||
// protoc v3.12.4
|
||||
// source: events/events.proto
|
||||
|
||||
@ -966,8 +966,8 @@ var file_events_events_proto_rawDesc = []byte{
|
||||
0x50, 0x49, 0x4c, 0x4f, 0x54, 0x10, 0x02, 0x2a, 0x32, 0x0a, 0x0a, 0x54, 0x79, 0x70, 0x65, 0x4f,
|
||||
0x62, 0x6a, 0x65, 0x63, 0x74, 0x12, 0x07, 0x0a, 0x03, 0x41, 0x4e, 0x59, 0x10, 0x00, 0x12, 0x07,
|
||||
0x0a, 0x03, 0x43, 0x41, 0x52, 0x10, 0x01, 0x12, 0x08, 0x0a, 0x04, 0x42, 0x55, 0x4d, 0x50, 0x10,
|
||||
0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x4f, 0x54, 0x10, 0x03, 0x42, 0x08, 0x5a, 0x06, 0x65,
|
||||
0x76, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
0x02, 0x12, 0x08, 0x0a, 0x04, 0x50, 0x4c, 0x4f, 0x54, 0x10, 0x03, 0x42, 0x0a, 0x5a, 0x08, 0x2e,
|
||||
0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
|
8
vendor/github.com/eclipse/paho.mqtt.golang/README.md
generated
vendored
8
vendor/github.com/eclipse/paho.mqtt.golang/README.md
generated
vendored
@ -104,8 +104,12 @@ func main() {
|
||||
|
||||
* Seemingly random disconnections may be caused by another client connecting to the broker with the same client
|
||||
identifier; this is as per the [spec](https://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html#_Toc384800405).
|
||||
* A `MessageHandler` (called when a new message is received) must not block. If you wish to perform a long-running task,
|
||||
or publish a message, then please use a go routine (blocking in the handler is a common cause of unexpected `pingresp
|
||||
* Unless ordered delivery of messages is essential (and you have configured your broker to support this e.g.
|
||||
`max_inflight_messages=1` in mosquitto) then set `ClientOptions.SetOrderMatters(false)`. Doing so will avoid the
|
||||
below issue (deadlocks due to blocking message handlers).
|
||||
* A `MessageHandler` (called when a new message is received) must not block (unless
|
||||
`ClientOptions.SetOrderMatters(false)` set). If you wish to perform a long-running task, or publish a message, then
|
||||
please use a go routine (blocking in the handler is a common cause of unexpected `pingresp
|
||||
not received, disconnecting` errors).
|
||||
* When QOS1+ subscriptions have been created previously and you connect with `CleanSession` set to false it is possible that the broker will deliver retained
|
||||
messages before `Subscribe` can be called. To process these messages either configure a handler with `AddRoute` or
|
||||
|
112
vendor/github.com/eclipse/paho.mqtt.golang/client.go
generated
vendored
112
vendor/github.com/eclipse/paho.mqtt.golang/client.go
generated
vendored
@ -55,6 +55,8 @@ const (
|
||||
// information can be found in their respective documentation.
|
||||
// Numerous connection options may be specified by configuring a
|
||||
// and then supplying a ClientOptions type.
|
||||
// Implementations of Client must be safe for concurrent use by multiple
|
||||
// goroutines
|
||||
type Client interface {
|
||||
// IsConnected returns a bool signifying whether
|
||||
// the client is connected or not.
|
||||
@ -75,11 +77,21 @@ type Client interface {
|
||||
// Returns a token to track delivery of the message to the broker
|
||||
Publish(topic string, qos byte, retained bool, payload interface{}) Token
|
||||
// Subscribe starts a new subscription. Provide a MessageHandler to be executed when
|
||||
// a message is published on the topic provided, or nil for the default handler
|
||||
// a message is published on the topic provided, or nil for the default handler.
|
||||
//
|
||||
// If options.OrderMatters is true (the default) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// callback must be safe for concurrent use by multiple goroutines.
|
||||
Subscribe(topic string, qos byte, callback MessageHandler) Token
|
||||
// SubscribeMultiple starts a new subscription for multiple topics. Provide a MessageHandler to
|
||||
// be executed when a message is published on one of the topics provided, or nil for the
|
||||
// default handler
|
||||
// default handler.
|
||||
//
|
||||
// If options.OrderMatters is true (the default) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// callback must be safe for concurrent use by multiple goroutines.
|
||||
SubscribeMultiple(filters map[string]byte, callback MessageHandler) Token
|
||||
// Unsubscribe will end the subscription from each of the topics provided.
|
||||
// Messages published to those topics from other clients will no longer be
|
||||
@ -87,7 +99,13 @@ type Client interface {
|
||||
Unsubscribe(topics ...string) Token
|
||||
// AddRoute allows you to add a handler for messages on a specific topic
|
||||
// without making a subscription. For example having a different handler
|
||||
// for parts of a wildcard subscription
|
||||
// for parts of a wildcard subscription or for receiving retained messages
|
||||
// upon connection (before Sub scribe can be processed).
|
||||
//
|
||||
// If options.OrderMatters is true (the default) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// callback must be safe for concurrent use by multiple goroutines.
|
||||
AddRoute(topic string, callback MessageHandler)
|
||||
// OptionsReader returns a ClientOptionsReader which is a copy of the clientoptions
|
||||
// in use by the client.
|
||||
@ -95,6 +113,8 @@ type Client interface {
|
||||
}
|
||||
|
||||
// client implements the Client interface
|
||||
// clients are safe for concurrent use by multiple
|
||||
// goroutines
|
||||
type client struct {
|
||||
lastSent atomic.Value // time.Time - the last time a packet was successfully sent to network
|
||||
lastReceived atomic.Value // time.Time - the last time a packet was successfully received from network
|
||||
@ -153,6 +173,11 @@ func NewClient(o *ClientOptions) Client {
|
||||
// AddRoute allows you to add a handler for messages on a specific topic
|
||||
// without making a subscription. For example having a different handler
|
||||
// for parts of a wildcard subscription
|
||||
//
|
||||
// If options.OrderMatters is true (the default) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// callback must be safe for concurrent use by multiple goroutines.
|
||||
func (c *client) AddRoute(topic string, callback MessageHandler) {
|
||||
if callback != nil {
|
||||
c.msgRouter.addRoute(topic, callback)
|
||||
@ -354,8 +379,13 @@ func (c *client) attemptConnection() (net.Conn, byte, bool, error) {
|
||||
cm := newConnectMsgFromOptions(&c.options, broker)
|
||||
DEBUG.Println(CLI, "about to write new connect msg")
|
||||
CONN:
|
||||
tlsCfg := c.options.TLSConfig
|
||||
if c.options.OnConnectAttempt != nil {
|
||||
DEBUG.Println(CLI, "using custom onConnectAttempt handler...")
|
||||
tlsCfg = c.options.OnConnectAttempt(broker, c.options.TLSConfig)
|
||||
}
|
||||
// Start by opening the network connection (tcp, tls, ws) etc
|
||||
conn, err = openConnection(broker, c.options.TLSConfig, c.options.ConnectTimeout, c.options.HTTPHeaders, c.options.WebsocketOptions)
|
||||
conn, err = openConnection(broker, tlsCfg, c.options.ConnectTimeout, c.options.HTTPHeaders, c.options.WebsocketOptions)
|
||||
if err != nil {
|
||||
ERROR.Println(CLI, err.Error())
|
||||
WARN.Println(CLI, "failed to connect to broker, trying next")
|
||||
@ -372,7 +402,7 @@ func (c *client) attemptConnection() (net.Conn, byte, bool, error) {
|
||||
|
||||
// We may be have to attempt the connection with MQTT 3.1
|
||||
if conn != nil {
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
}
|
||||
if !c.options.protocolVersionExplicit && protocolVersion == 4 { // try falling back to 3.1?
|
||||
DEBUG.Println(CLI, "Trying reconnect using MQTT 3.1 protocol")
|
||||
@ -409,12 +439,22 @@ func (c *client) Disconnect(quiesce uint) {
|
||||
|
||||
dm := packets.NewControlPacket(packets.Disconnect).(*packets.DisconnectPacket)
|
||||
dt := newToken(packets.Disconnect)
|
||||
c.oboundP <- &PacketAndToken{p: dm, t: dt}
|
||||
disconnectSent := false
|
||||
select {
|
||||
case c.oboundP <- &PacketAndToken{p: dm, t: dt}:
|
||||
disconnectSent = true
|
||||
case <-c.commsStopped:
|
||||
WARN.Println("Disconnect packet could not be sent because comms stopped")
|
||||
case <-time.After(time.Duration(quiesce) * time.Millisecond):
|
||||
WARN.Println("Disconnect packet not sent due to timeout")
|
||||
}
|
||||
|
||||
// wait for work to finish, or quiesce time consumed
|
||||
DEBUG.Println(CLI, "calling WaitTimeout")
|
||||
dt.WaitTimeout(time.Duration(quiesce) * time.Millisecond)
|
||||
DEBUG.Println(CLI, "WaitTimeout done")
|
||||
if disconnectSent {
|
||||
DEBUG.Println(CLI, "calling WaitTimeout")
|
||||
dt.WaitTimeout(time.Duration(quiesce) * time.Millisecond)
|
||||
DEBUG.Println(CLI, "WaitTimeout done")
|
||||
}
|
||||
} else {
|
||||
WARN.Println(CLI, "Disconnect() called but not connected (disconnected/reconnecting)")
|
||||
c.setConnected(disconnected)
|
||||
@ -459,10 +499,13 @@ func (c *client) internalConnLost(err error) {
|
||||
DEBUG.Println(CLI, "internalConnLost waiting on workers")
|
||||
<-stopDone
|
||||
DEBUG.Println(CLI, "internalConnLost workers stopped")
|
||||
if c.options.CleanSession && !c.options.AutoReconnect {
|
||||
// It is possible that Disconnect was called which led to this error so reconnection depends upon status
|
||||
reconnect := c.options.AutoReconnect && c.connectionStatus() > connecting
|
||||
|
||||
if c.options.CleanSession && !reconnect {
|
||||
c.messageIds.cleanUp()
|
||||
}
|
||||
if c.options.AutoReconnect {
|
||||
if reconnect {
|
||||
c.setConnected(reconnecting)
|
||||
go c.reconnect()
|
||||
} else {
|
||||
@ -476,8 +519,8 @@ func (c *client) internalConnLost(err error) {
|
||||
}
|
||||
}
|
||||
|
||||
// startCommsWorkers is called when the connection is up. It starts off all of the routines needed to process incoming and
|
||||
// outgoing messages.
|
||||
// startCommsWorkers is called when the connection is up.
|
||||
// It starts off all of the routines needed to process incoming and outgoing messages.
|
||||
// Returns true if the comms workers were started (i.e. they were not already running)
|
||||
func (c *client) startCommsWorkers(conn net.Conn, inboundFromStore <-chan packets.ControlPacket) bool {
|
||||
DEBUG.Println(CLI, "startCommsWorkers called")
|
||||
@ -564,7 +607,22 @@ func (c *client) startCommsWorkers(conn net.Conn, inboundFromStore <-chan packet
|
||||
commsIncomingPub = nil
|
||||
continue
|
||||
}
|
||||
incomingPubChan <- pub
|
||||
// Care is needed here because an error elsewhere could trigger a deadlock
|
||||
sendPubLoop:
|
||||
for {
|
||||
select {
|
||||
case incomingPubChan <- pub:
|
||||
break sendPubLoop
|
||||
case err, ok := <-commsErrors:
|
||||
if !ok { // commsErrors has been closed so we can ignore it
|
||||
commsErrors = nil
|
||||
continue
|
||||
}
|
||||
ERROR.Println(CLI, "Connect comms goroutine - error triggered during send Pub", err)
|
||||
c.internalConnLost(err) // no harm in calling this if the connection is already down (or shutdown is in progress)
|
||||
continue
|
||||
}
|
||||
}
|
||||
case err, ok := <-commsErrors:
|
||||
if !ok {
|
||||
commsErrors = nil
|
||||
@ -686,10 +744,10 @@ func (c *client) Publish(topic string, qos byte, retained bool, payload interfac
|
||||
// Subscribe starts a new subscription. Provide a MessageHandler to be executed when
|
||||
// a message is published on the topic provided.
|
||||
//
|
||||
// Please note: you should try to keep the execution time of the callback to be
|
||||
// as low as possible, especially when SetOrderMatters(true) (the default) is in
|
||||
// place. Blocking calls in message handlers might otherwise delay delivery to
|
||||
// other message handlers.
|
||||
// If options.OrderMatters is true (the default) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// callback must be safe for concurrent use by multiple goroutines.
|
||||
func (c *client) Subscribe(topic string, qos byte, callback MessageHandler) Token {
|
||||
token := newToken(packets.Subscribe).(*SubscribeToken)
|
||||
DEBUG.Println(CLI, "enter Subscribe")
|
||||
@ -766,6 +824,11 @@ func (c *client) Subscribe(topic string, qos byte, callback MessageHandler) Toke
|
||||
|
||||
// SubscribeMultiple starts a new subscription for multiple topics. Provide a MessageHandler to
|
||||
// be executed when a message is published on one of the topics provided.
|
||||
//
|
||||
// If options.OrderMatters is true (the default) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// callback must be safe for concurrent use by multiple goroutines.
|
||||
func (c *client) SubscribeMultiple(filters map[string]byte, callback MessageHandler) Token {
|
||||
var err error
|
||||
token := newToken(packets.Subscribe).(*SubscribeToken)
|
||||
@ -869,7 +932,7 @@ func (c *client) resume(subscription bool, ibound chan packets.ControlPacket) {
|
||||
}
|
||||
details := packet.Details()
|
||||
if isKeyOutbound(key) {
|
||||
switch packet.(type) {
|
||||
switch p := packet.(type) {
|
||||
case *packets.SubscribePacket:
|
||||
if subscription {
|
||||
DEBUG.Println(STR, fmt.Sprintf("loaded pending subscribe (%d)", details.MessageID))
|
||||
@ -909,13 +972,22 @@ func (c *client) resume(subscription bool, ibound chan packets.ControlPacket) {
|
||||
return
|
||||
}
|
||||
case *packets.PublishPacket:
|
||||
// spec: If the DUP flag is set to 0, it indicates that this is the first occasion that the Client or
|
||||
// Server has attempted to send this MQTT PUBLISH Packet. If the DUP flag is set to 1, it indicates that
|
||||
// this might be re-delivery of an earlier attempt to send the Packet.
|
||||
//
|
||||
// If the message is in the store than an attempt at delivery has been made (note that the message may
|
||||
// never have made it onto the wire but tracking that would be complicated!).
|
||||
if p.Qos != 0 { // spec: The DUP flag MUST be set to 0 for all QoS 0 messages
|
||||
p.Dup = true
|
||||
}
|
||||
token := newToken(packets.Publish).(*PublishToken)
|
||||
token.messageID = details.MessageID
|
||||
c.claimID(token, details.MessageID)
|
||||
DEBUG.Println(STR, fmt.Sprintf("loaded pending publish (%d)", details.MessageID))
|
||||
DEBUG.Println(STR, details)
|
||||
select {
|
||||
case c.obound <- &PacketAndToken{p: packet, t: token}:
|
||||
case c.obound <- &PacketAndToken{p: p, t: token}:
|
||||
case <-c.stop:
|
||||
DEBUG.Println(STR, "resume exiting due to stop")
|
||||
return
|
||||
|
8
vendor/github.com/eclipse/paho.mqtt.golang/go.mod
generated
vendored
8
vendor/github.com/eclipse/paho.mqtt.golang/go.mod
generated
vendored
@ -1,8 +0,0 @@
|
||||
module github.com/eclipse/paho.mqtt.golang
|
||||
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0
|
||||
)
|
8
vendor/github.com/eclipse/paho.mqtt.golang/go.sum
generated
vendored
8
vendor/github.com/eclipse/paho.mqtt.golang/go.sum
generated
vendored
@ -1,8 +0,0 @@
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0 h1:Jcxah/M+oLZ/R4/z5RzfPzGbPXnVDPkEDtf2JnuxN+U=
|
||||
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
5
vendor/github.com/eclipse/paho.mqtt.golang/netconn.go
generated
vendored
5
vendor/github.com/eclipse/paho.mqtt.golang/netconn.go
generated
vendored
@ -30,7 +30,8 @@ import (
|
||||
// This just establishes the network connection; once established the type of connection should be irrelevant
|
||||
//
|
||||
|
||||
// openConnection opens a network connection using the protocol indicated in the URL. Does not carry out any MQTT specific handshakes
|
||||
// openConnection opens a network connection using the protocol indicated in the URL.
|
||||
// Does not carry out any MQTT specific handshakes.
|
||||
func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, headers http.Header, websocketOptions *WebsocketOptions) (net.Conn, error) {
|
||||
switch uri.Scheme {
|
||||
case "ws":
|
||||
@ -81,7 +82,7 @@ func openConnection(uri *url.URL, tlsc *tls.Config, timeout time.Duration, heade
|
||||
|
||||
err = tlsConn.Handshake()
|
||||
if err != nil {
|
||||
conn.Close()
|
||||
_ = conn.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
32
vendor/github.com/eclipse/paho.mqtt.golang/options.go
generated
vendored
32
vendor/github.com/eclipse/paho.mqtt.golang/options.go
generated
vendored
@ -21,7 +21,6 @@ import (
|
||||
"crypto/tls"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -50,7 +49,11 @@ type OnConnectHandler func(Client)
|
||||
// the initial connection is lost
|
||||
type ReconnectHandler func(Client, *ClientOptions)
|
||||
|
||||
// ClientOptions contains configurable options for an Client.
|
||||
// ConnectionAttemptHandler is invoked prior to making the initial connection.
|
||||
type ConnectionAttemptHandler func(broker *url.URL, tlsCfg *tls.Config) *tls.Config
|
||||
|
||||
// ClientOptions contains configurable options for an Client. Note that these should be set using the
|
||||
// relevant methods (e.g. AddBroker) rather than directly. See those functions for information on usage.
|
||||
type ClientOptions struct {
|
||||
Servers []*url.URL
|
||||
ClientID string
|
||||
@ -79,6 +82,7 @@ type ClientOptions struct {
|
||||
OnConnect OnConnectHandler
|
||||
OnConnectionLost ConnectionLostHandler
|
||||
OnReconnecting ReconnectHandler
|
||||
OnConnectAttempt ConnectionAttemptHandler
|
||||
WriteTimeout time.Duration
|
||||
MessageChannelDepth uint
|
||||
ResumeSubs bool
|
||||
@ -90,7 +94,7 @@ type ClientOptions struct {
|
||||
// default values.
|
||||
// Port: 1883
|
||||
// CleanSession: True
|
||||
// Order: True
|
||||
// Order: True (note: it is recommended that this be set to FALSE unless order is important)
|
||||
// KeepAlive: 30 (seconds)
|
||||
// ConnectTimeout: 30 (seconds)
|
||||
// MaxReconnectInterval 10 (minutes)
|
||||
@ -120,6 +124,7 @@ func NewClientOptions() *ClientOptions {
|
||||
Store: nil,
|
||||
OnConnect: nil,
|
||||
OnConnectionLost: DefaultConnectionLostHandler,
|
||||
OnConnectAttempt: nil,
|
||||
WriteTimeout: 0, // 0 represents timeout disabled
|
||||
ResumeSubs: false,
|
||||
HTTPHeaders: make(map[string][]string),
|
||||
@ -137,14 +142,12 @@ func NewClientOptions() *ClientOptions {
|
||||
//
|
||||
// An example broker URI would look like: tcp://foobar.com:1883
|
||||
func (o *ClientOptions) AddBroker(server string) *ClientOptions {
|
||||
re := regexp.MustCompile(`%(25)?`)
|
||||
if len(server) > 0 && server[0] == ':' {
|
||||
server = "127.0.0.1" + server
|
||||
}
|
||||
if !strings.Contains(server, "://") {
|
||||
server = "tcp://" + server
|
||||
}
|
||||
server = re.ReplaceAllLiteralString(server, "%25")
|
||||
brokerURI, err := url.Parse(server)
|
||||
if err != nil {
|
||||
ERROR.Println(CLI, "Failed to parse %q broker address: %s", server, err)
|
||||
@ -206,10 +209,13 @@ func (o *ClientOptions) SetCleanSession(clean bool) *ClientOptions {
|
||||
}
|
||||
|
||||
// SetOrderMatters will set the message routing to guarantee order within
|
||||
// each QoS level. By default, this value is true. If set to false,
|
||||
// each QoS level. By default, this value is true. If set to false (recommended),
|
||||
// this flag indicates that messages can be delivered asynchronously
|
||||
// from the client to the application and possibly arrive out of order.
|
||||
// Specifically, the message handler is called in its own go routine.
|
||||
// Note that setting this to true does not guarantee in-order delivery
|
||||
// (this is subject to broker settings like "max_inflight_messages=1" in mosquitto)
|
||||
// and if true then handlers must not block.
|
||||
func (o *ClientOptions) SetOrderMatters(order bool) *ClientOptions {
|
||||
o.Order = order
|
||||
return o
|
||||
@ -289,6 +295,11 @@ func (o *ClientOptions) SetBinaryWill(topic string, payload []byte, qos byte, re
|
||||
|
||||
// SetDefaultPublishHandler sets the MessageHandler that will be called when a message
|
||||
// is received that does not match any known subscriptions.
|
||||
//
|
||||
// If OrderMatters is true (the defaultHandler) then callback must not block or
|
||||
// call functions within this package that may block (e.g. Publish) other than in
|
||||
// a new go routine.
|
||||
// defaultHandler must be safe for concurrent use by multiple goroutines.
|
||||
func (o *ClientOptions) SetDefaultPublishHandler(defaultHandler MessageHandler) *ClientOptions {
|
||||
o.DefaultPublishHandler = defaultHandler
|
||||
return o
|
||||
@ -315,6 +326,15 @@ func (o *ClientOptions) SetReconnectingHandler(cb ReconnectHandler) *ClientOptio
|
||||
return o
|
||||
}
|
||||
|
||||
// SetConnectionAttemptHandler sets the ConnectionAttemptHandler callback to be executed prior
|
||||
// to each attempt to connect to an MQTT broker. Returns the *tls.Config that will be used when establishing
|
||||
// the connection (a copy of the tls.Config from ClientOptions will be passed in along with the broker URL).
|
||||
// This allows connection specific changes to be made to the *tls.Config.
|
||||
func (o *ClientOptions) SetConnectionAttemptHandler(onConnectAttempt ConnectionAttemptHandler) *ClientOptions {
|
||||
o.OnConnectAttempt = onConnectAttempt
|
||||
return o
|
||||
}
|
||||
|
||||
// SetWriteTimeout puts a limit on how long a mqtt publish should block until it unblocks with a
|
||||
// timeout error. A duration of 0 never times out. Default never times out
|
||||
func (o *ClientOptions) SetWriteTimeout(t time.Duration) *ClientOptions {
|
||||
|
6
vendor/github.com/eclipse/paho.mqtt.golang/packets/connect.go
generated
vendored
6
vendor/github.com/eclipse/paho.mqtt.golang/packets/connect.go
generated
vendored
@ -29,7 +29,11 @@ type ConnectPacket struct {
|
||||
}
|
||||
|
||||
func (c *ConnectPacket) String() string {
|
||||
return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, c.Password)
|
||||
var password string
|
||||
if len(c.Password) > 0 {
|
||||
password = "<redacted>"
|
||||
}
|
||||
return fmt.Sprintf("%s protocolversion: %d protocolname: %s cleansession: %t willflag: %t WillQos: %d WillRetain: %t Usernameflag: %t Passwordflag: %t keepalive: %d clientId: %s willtopic: %s willmessage: %s Username: %s Password: %s", c.FixedHeader, c.ProtocolVersion, c.ProtocolName, c.CleanSession, c.WillFlag, c.WillQos, c.WillRetain, c.UsernameFlag, c.PasswordFlag, c.Keepalive, c.ClientIdentifier, c.WillTopic, c.WillMessage, c.Username, password)
|
||||
}
|
||||
|
||||
func (c *ConnectPacket) Write(w io.Writer) error {
|
||||
|
24
vendor/github.com/eclipse/paho.mqtt.golang/packets/packets.go
generated
vendored
24
vendor/github.com/eclipse/paho.mqtt.golang/packets/packets.go
generated
vendored
@ -81,17 +81,27 @@ var ConnackReturnCodes = map[uint8]string{
|
||||
255: "Connection Refused: Protocol Violation",
|
||||
}
|
||||
|
||||
var (
|
||||
ErrorRefusedBadProtocolVersion = errors.New("unacceptable protocol version")
|
||||
ErrorRefusedIDRejected = errors.New("identifier rejected")
|
||||
ErrorRefusedServerUnavailable = errors.New("server Unavailable")
|
||||
ErrorRefusedBadUsernameOrPassword = errors.New("bad user name or password")
|
||||
ErrorRefusedNotAuthorised = errors.New("not Authorized")
|
||||
ErrorNetworkError = errors.New("network Error")
|
||||
ErrorProtocolViolation = errors.New("protocol Violation")
|
||||
)
|
||||
|
||||
// ConnErrors is a map of the errors codes constants for Connect()
|
||||
// to a Go error
|
||||
var ConnErrors = map[byte]error{
|
||||
Accepted: nil,
|
||||
ErrRefusedBadProtocolVersion: errors.New("unacceptable protocol version"),
|
||||
ErrRefusedIDRejected: errors.New("identifier rejected"),
|
||||
ErrRefusedServerUnavailable: errors.New("server Unavailable"),
|
||||
ErrRefusedBadUsernameOrPassword: errors.New("bad user name or password"),
|
||||
ErrRefusedNotAuthorised: errors.New("not Authorized"),
|
||||
ErrNetworkError: errors.New("network Error"),
|
||||
ErrProtocolViolation: errors.New("protocol Violation"),
|
||||
ErrRefusedBadProtocolVersion: ErrorRefusedBadProtocolVersion,
|
||||
ErrRefusedIDRejected: ErrorRefusedIDRejected,
|
||||
ErrRefusedServerUnavailable: ErrorRefusedServerUnavailable,
|
||||
ErrRefusedBadUsernameOrPassword: ErrorRefusedBadUsernameOrPassword,
|
||||
ErrRefusedNotAuthorised: ErrorRefusedNotAuthorised,
|
||||
ErrNetworkError: ErrorNetworkError,
|
||||
ErrProtocolViolation: ErrorProtocolViolation,
|
||||
}
|
||||
|
||||
// ReadPacket takes an instance of an io.Reader (such as net.Conn) and attempts
|
||||
|
57
vendor/github.com/eclipse/paho.mqtt.golang/router.go
generated
vendored
57
vendor/github.com/eclipse/paho.mqtt.golang/router.go
generated
vendored
@ -132,13 +132,46 @@ func (r *router) setDefaultHandler(handler MessageHandler) {
|
||||
// associated callback (or the defaultHandler, if one exists and no other route matched). If
|
||||
// anything is sent down the stop channel the function will end.
|
||||
func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order bool, client *client) <-chan *PacketAndToken {
|
||||
ackChan := make(chan *PacketAndToken)
|
||||
go func() {
|
||||
var wg sync.WaitGroup
|
||||
ackOutChan := make(chan *PacketAndToken) // Channel returned to caller; closed when messages channel closed
|
||||
var ackInChan chan *PacketAndToken // ACKs generated by ackFunc get put onto this channel
|
||||
|
||||
stopAckCopy := make(chan struct{}) // Closure requests stop of go routine copying ackInChan to ackOutChan
|
||||
ackCopyStopped := make(chan struct{}) // Closure indicates that it is safe to close ackOutChan
|
||||
goRoutinesDone := make(chan struct{}) // closed on wg.Done()
|
||||
if order {
|
||||
ackInChan = ackOutChan // When order = true no go routines are used so safe to use one channel and close when done
|
||||
} else {
|
||||
// When order = false ACK messages are sent in go routines so ackInChan cannot be closed until all goroutines done
|
||||
ackInChan = make(chan *PacketAndToken)
|
||||
go func() { // go routine to copy from ackInChan to ackOutChan until stopped
|
||||
for {
|
||||
select {
|
||||
case a := <-ackInChan:
|
||||
ackOutChan <- a
|
||||
case <-stopAckCopy:
|
||||
close(ackCopyStopped) // Signal main go routine that it is safe to close ackOutChan
|
||||
for {
|
||||
select {
|
||||
case <-ackInChan: // drain ackInChan to ensure all goRoutines can complete cleanly (ACK dropped)
|
||||
DEBUG.Println(ROU, "matchAndDispatch received acknowledgment after processing stopped (ACK dropped).")
|
||||
case <-goRoutinesDone:
|
||||
close(ackInChan) // Nothing further should be sent (a panic is probably better than silent failure)
|
||||
DEBUG.Println(ROU, "matchAndDispatch order=false copy goroutine exiting.")
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
go func() { // Main go routine handling inbound messages
|
||||
for message := range messages {
|
||||
// DEBUG.Println(ROU, "matchAndDispatch received message")
|
||||
sent := false
|
||||
r.RLock()
|
||||
m := messageFromPublish(message, ackFunc(ackChan, client.persist, message))
|
||||
m := messageFromPublish(message, ackFunc(ackInChan, client.persist, message))
|
||||
var handlers []MessageHandler
|
||||
for e := r.routes.Front(); e != nil; e = e.Next() {
|
||||
if e.Value.(*route).match(message.TopicName) {
|
||||
@ -146,9 +179,11 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
|
||||
handlers = append(handlers, e.Value.(*route).callback)
|
||||
} else {
|
||||
hd := e.Value.(*route).callback
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
hd(client, m)
|
||||
m.Ack()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
sent = true
|
||||
@ -159,9 +194,11 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
|
||||
if order {
|
||||
handlers = append(handlers, r.defaultHandler)
|
||||
} else {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
r.defaultHandler(client, m)
|
||||
m.Ack()
|
||||
wg.Done()
|
||||
}()
|
||||
}
|
||||
} else {
|
||||
@ -175,8 +212,18 @@ func (r *router) matchAndDispatch(messages <-chan *packets.PublishPacket, order
|
||||
}
|
||||
// DEBUG.Println(ROU, "matchAndDispatch handled message")
|
||||
}
|
||||
close(ackChan)
|
||||
if order {
|
||||
close(ackOutChan)
|
||||
} else { // Ensure that nothing further will be written to ackOutChan before closing it
|
||||
close(stopAckCopy)
|
||||
<-ackCopyStopped
|
||||
close(ackOutChan)
|
||||
go func() {
|
||||
wg.Wait() // Note: If this remains running then the user has handlers that are not returning
|
||||
close(goRoutinesDone)
|
||||
}()
|
||||
}
|
||||
DEBUG.Println(ROU, "matchAndDispatch exiting")
|
||||
}()
|
||||
return ackChan
|
||||
return ackOutChan
|
||||
}
|
||||
|
16
vendor/github.com/eclipse/paho.mqtt.golang/websocket.go
generated
vendored
16
vendor/github.com/eclipse/paho.mqtt.golang/websocket.go
generated
vendored
@ -2,9 +2,11 @@ package mqtt
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@ -15,8 +17,11 @@ import (
|
||||
type WebsocketOptions struct {
|
||||
ReadBufferSize int
|
||||
WriteBufferSize int
|
||||
Proxy ProxyFunction
|
||||
}
|
||||
|
||||
type ProxyFunction func(req *http.Request) (*url.URL, error)
|
||||
|
||||
// NewWebsocket returns a new websocket and returns a net.Conn compatible interface using the gorilla/websocket package
|
||||
func NewWebsocket(host string, tlsc *tls.Config, timeout time.Duration, requestHeader http.Header, options *WebsocketOptions) (net.Conn, error) {
|
||||
if timeout == 0 {
|
||||
@ -27,9 +32,11 @@ func NewWebsocket(host string, tlsc *tls.Config, timeout time.Duration, requestH
|
||||
// Apply default options
|
||||
options = &WebsocketOptions{}
|
||||
}
|
||||
|
||||
if options.Proxy == nil {
|
||||
options.Proxy = http.ProxyFromEnvironment
|
||||
}
|
||||
dialer := &websocket.Dialer{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
Proxy: options.Proxy,
|
||||
HandshakeTimeout: timeout,
|
||||
EnableCompression: false,
|
||||
TLSClientConfig: tlsc,
|
||||
@ -38,9 +45,12 @@ func NewWebsocket(host string, tlsc *tls.Config, timeout time.Duration, requestH
|
||||
WriteBufferSize: options.WriteBufferSize,
|
||||
}
|
||||
|
||||
ws, _, err := dialer.Dial(host, requestHeader)
|
||||
ws, resp, err := dialer.Dial(host, requestHeader)
|
||||
|
||||
if err != nil {
|
||||
if resp != nil {
|
||||
WARN.Println(CLI, fmt.Sprintf("Websocket handshake failure. StatusCode: %d. Body: %s", resp.StatusCode, resp.Body))
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
10
vendor/github.com/golang/protobuf/proto/registry.go
generated
vendored
10
vendor/github.com/golang/protobuf/proto/registry.go
generated
vendored
@ -13,6 +13,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/reflect/protodesc"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
"google.golang.org/protobuf/runtime/protoimpl"
|
||||
@ -62,14 +63,7 @@ func FileDescriptor(s filePath) fileDescGZIP {
|
||||
// Find the descriptor in the v2 registry.
|
||||
var b []byte
|
||||
if fd, _ := protoregistry.GlobalFiles.FindFileByPath(s); fd != nil {
|
||||
if fd, ok := fd.(interface{ ProtoLegacyRawDesc() []byte }); ok {
|
||||
b = fd.ProtoLegacyRawDesc()
|
||||
} else {
|
||||
// TODO: Use protodesc.ToFileDescriptorProto to construct
|
||||
// a descriptorpb.FileDescriptorProto and marshal it.
|
||||
// However, doing so causes the proto package to have a dependency
|
||||
// on descriptorpb, leading to cyclic dependency issues.
|
||||
}
|
||||
b, _ = Marshal(protodesc.ToFileDescriptorProto(fd))
|
||||
}
|
||||
|
||||
// Locally cache the raw descriptor form for the file.
|
||||
|
3
vendor/github.com/gorilla/websocket/go.mod
generated
vendored
3
vendor/github.com/gorilla/websocket/go.mod
generated
vendored
@ -1,3 +0,0 @@
|
||||
module github.com/gorilla/websocket
|
||||
|
||||
go 1.12
|
0
vendor/github.com/gorilla/websocket/go.sum
generated
vendored
0
vendor/github.com/gorilla/websocket/go.sum
generated
vendored
14
vendor/github.com/sirupsen/logrus/.travis.yml
generated
vendored
14
vendor/github.com/sirupsen/logrus/.travis.yml
generated
vendored
@ -4,14 +4,12 @@ git:
|
||||
depth: 1
|
||||
env:
|
||||
- GO111MODULE=on
|
||||
go: [1.13.x, 1.14.x]
|
||||
os: [linux, osx]
|
||||
go: 1.15.x
|
||||
os: linux
|
||||
install:
|
||||
- ./travis/install.sh
|
||||
script:
|
||||
- ./travis/cross_build.sh
|
||||
- ./travis/lint.sh
|
||||
- export GOMAXPROCS=4
|
||||
- export GORACE=halt_on_error=1
|
||||
- go test -race -v ./...
|
||||
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then go test -race -v -tags appengine ./... ; fi
|
||||
- cd ci
|
||||
- go run mage.go -v -w ../ crossBuild
|
||||
- go run mage.go -v -w ../ lint
|
||||
- go run mage.go -v -w ../ test
|
||||
|
36
vendor/github.com/sirupsen/logrus/CHANGELOG.md
generated
vendored
36
vendor/github.com/sirupsen/logrus/CHANGELOG.md
generated
vendored
@ -1,3 +1,39 @@
|
||||
# 1.8.1
|
||||
Code quality:
|
||||
* move magefile in its own subdir/submodule to remove magefile dependency on logrus consumer
|
||||
* improve timestamp format documentation
|
||||
|
||||
Fixes:
|
||||
* fix race condition on logger hooks
|
||||
|
||||
|
||||
# 1.8.0
|
||||
|
||||
Correct versioning number replacing v1.7.1.
|
||||
|
||||
# 1.7.1
|
||||
|
||||
Beware this release has introduced a new public API and its semver is therefore incorrect.
|
||||
|
||||
Code quality:
|
||||
* use go 1.15 in travis
|
||||
* use magefile as task runner
|
||||
|
||||
Fixes:
|
||||
* small fixes about new go 1.13 error formatting system
|
||||
* Fix for long time race condiction with mutating data hooks
|
||||
|
||||
Features:
|
||||
* build support for zos
|
||||
|
||||
# 1.7.0
|
||||
Fixes:
|
||||
* the dependency toward a windows terminal library has been removed
|
||||
|
||||
Features:
|
||||
* a new buffer pool management API has been added
|
||||
* a set of `<LogLevel>Fn()` functions have been added
|
||||
|
||||
# 1.6.0
|
||||
Fixes:
|
||||
* end of line cleanup
|
||||
|
2
vendor/github.com/sirupsen/logrus/README.md
generated
vendored
2
vendor/github.com/sirupsen/logrus/README.md
generated
vendored
@ -402,7 +402,7 @@ func (f *MyJSONFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
// source of the official loggers.
|
||||
serialized, err := json.Marshal(entry.Data)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %v", err)
|
||||
return nil, fmt.Errorf("Failed to marshal fields to JSON, %w", err)
|
||||
}
|
||||
return append(serialized, '\n'), nil
|
||||
}
|
||||
|
75
vendor/github.com/sirupsen/logrus/entry.go
generated
vendored
75
vendor/github.com/sirupsen/logrus/entry.go
generated
vendored
@ -78,6 +78,14 @@ func NewEntry(logger *Logger) *Entry {
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) Dup() *Entry {
|
||||
data := make(Fields, len(entry.Data))
|
||||
for k, v := range entry.Data {
|
||||
data[k] = v
|
||||
}
|
||||
return &Entry{Logger: entry.Logger, Data: data, Time: entry.Time, Context: entry.Context, err: entry.err}
|
||||
}
|
||||
|
||||
// Returns the bytes representation of this entry from the formatter.
|
||||
func (entry *Entry) Bytes() ([]byte, error) {
|
||||
return entry.Logger.Formatter.Format(entry)
|
||||
@ -123,11 +131,9 @@ func (entry *Entry) WithFields(fields Fields) *Entry {
|
||||
for k, v := range fields {
|
||||
isErrField := false
|
||||
if t := reflect.TypeOf(v); t != nil {
|
||||
switch t.Kind() {
|
||||
case reflect.Func:
|
||||
switch {
|
||||
case t.Kind() == reflect.Func, t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Func:
|
||||
isErrField = true
|
||||
case reflect.Ptr:
|
||||
isErrField = t.Elem().Kind() == reflect.Func
|
||||
}
|
||||
}
|
||||
if isErrField {
|
||||
@ -212,68 +218,72 @@ func (entry Entry) HasCaller() (has bool) {
|
||||
entry.Caller != nil
|
||||
}
|
||||
|
||||
// This function is not declared with a pointer value because otherwise
|
||||
// race conditions will occur when using multiple goroutines
|
||||
func (entry Entry) log(level Level, msg string) {
|
||||
func (entry *Entry) log(level Level, msg string) {
|
||||
var buffer *bytes.Buffer
|
||||
|
||||
// Default to now, but allow users to override if they want.
|
||||
//
|
||||
// We don't have to worry about polluting future calls to Entry#log()
|
||||
// with this assignment because this function is declared with a
|
||||
// non-pointer receiver.
|
||||
if entry.Time.IsZero() {
|
||||
entry.Time = time.Now()
|
||||
newEntry := entry.Dup()
|
||||
|
||||
if newEntry.Time.IsZero() {
|
||||
newEntry.Time = time.Now()
|
||||
}
|
||||
|
||||
entry.Level = level
|
||||
entry.Message = msg
|
||||
entry.Logger.mu.Lock()
|
||||
if entry.Logger.ReportCaller {
|
||||
entry.Caller = getCaller()
|
||||
}
|
||||
entry.Logger.mu.Unlock()
|
||||
newEntry.Level = level
|
||||
newEntry.Message = msg
|
||||
|
||||
entry.fireHooks()
|
||||
newEntry.Logger.mu.Lock()
|
||||
reportCaller := newEntry.Logger.ReportCaller
|
||||
newEntry.Logger.mu.Unlock()
|
||||
|
||||
if reportCaller {
|
||||
newEntry.Caller = getCaller()
|
||||
}
|
||||
|
||||
newEntry.fireHooks()
|
||||
|
||||
buffer = getBuffer()
|
||||
defer func() {
|
||||
entry.Buffer = nil
|
||||
newEntry.Buffer = nil
|
||||
putBuffer(buffer)
|
||||
}()
|
||||
buffer.Reset()
|
||||
entry.Buffer = buffer
|
||||
newEntry.Buffer = buffer
|
||||
|
||||
entry.write()
|
||||
newEntry.write()
|
||||
|
||||
entry.Buffer = nil
|
||||
newEntry.Buffer = nil
|
||||
|
||||
// To avoid Entry#log() returning a value that only would make sense for
|
||||
// panic() to use in Entry#Panic(), we avoid the allocation by checking
|
||||
// directly here.
|
||||
if level <= PanicLevel {
|
||||
panic(&entry)
|
||||
panic(newEntry)
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) fireHooks() {
|
||||
var tmpHooks LevelHooks
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
err := entry.Logger.Hooks.Fire(entry.Level, entry)
|
||||
tmpHooks = make(LevelHooks, len(entry.Logger.Hooks))
|
||||
for k, v := range entry.Logger.Hooks {
|
||||
tmpHooks[k] = v
|
||||
}
|
||||
entry.Logger.mu.Unlock()
|
||||
|
||||
err := tmpHooks.Fire(entry.Level, entry)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to fire hook: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (entry *Entry) write() {
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
serialized, err := entry.Logger.Formatter.Format(entry)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to obtain reader, %v\n", err)
|
||||
return
|
||||
}
|
||||
if _, err = entry.Logger.Out.Write(serialized); err != nil {
|
||||
entry.Logger.mu.Lock()
|
||||
defer entry.Logger.mu.Unlock()
|
||||
if _, err := entry.Logger.Out.Write(serialized); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Failed to write to log, %v\n", err)
|
||||
}
|
||||
}
|
||||
@ -319,7 +329,6 @@ func (entry *Entry) Fatal(args ...interface{}) {
|
||||
|
||||
func (entry *Entry) Panic(args ...interface{}) {
|
||||
entry.Log(PanicLevel, args...)
|
||||
panic(fmt.Sprint(args...))
|
||||
}
|
||||
|
||||
// Entry Printf family functions
|
||||
|
10
vendor/github.com/sirupsen/logrus/go.mod
generated
vendored
10
vendor/github.com/sirupsen/logrus/go.mod
generated
vendored
@ -1,10 +0,0 @@
|
||||
module github.com/sirupsen/logrus
|
||||
|
||||
require (
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/stretchr/testify v1.2.2
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037
|
||||
)
|
||||
|
||||
go 1.13
|
10
vendor/github.com/sirupsen/logrus/go.sum
generated
vendored
10
vendor/github.com/sirupsen/logrus/go.sum
generated
vendored
@ -1,10 +0,0 @@
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
5
vendor/github.com/sirupsen/logrus/json_formatter.go
generated
vendored
5
vendor/github.com/sirupsen/logrus/json_formatter.go
generated
vendored
@ -23,6 +23,9 @@ func (f FieldMap) resolve(key fieldKey) string {
|
||||
// JSONFormatter formats logs into parsable json
|
||||
type JSONFormatter struct {
|
||||
// TimestampFormat sets the format used for marshaling timestamps.
|
||||
// The format to use is the same than for time.Format or time.Parse from the standard
|
||||
// library.
|
||||
// The standard Library already provides a set of predefined format.
|
||||
TimestampFormat string
|
||||
|
||||
// DisableTimestamp allows disabling automatic timestamps in output
|
||||
@ -118,7 +121,7 @@ func (f *JSONFormatter) Format(entry *Entry) ([]byte, error) {
|
||||
encoder.SetIndent("", " ")
|
||||
}
|
||||
if err := encoder.Encode(data); err != nil {
|
||||
return nil, fmt.Errorf("failed to marshal fields to JSON, %v", err)
|
||||
return nil, fmt.Errorf("failed to marshal fields to JSON, %w", err)
|
||||
}
|
||||
|
||||
return b.Bytes(), nil
|
||||
|
2
vendor/github.com/sirupsen/logrus/logger.go
generated
vendored
2
vendor/github.com/sirupsen/logrus/logger.go
generated
vendored
@ -12,7 +12,7 @@ import (
|
||||
// LogFunction For big messages, it can be more efficient to pass a function
|
||||
// and only call it if the log level is actually enables rather than
|
||||
// generating the log message and then checking if the level is enabled
|
||||
type LogFunction func()[]interface{}
|
||||
type LogFunction func() []interface{}
|
||||
|
||||
type Logger struct {
|
||||
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
|
||||
|
2
vendor/github.com/sirupsen/logrus/terminal_check_unix.go
generated
vendored
2
vendor/github.com/sirupsen/logrus/terminal_check_unix.go
generated
vendored
@ -1,4 +1,4 @@
|
||||
// +build linux aix
|
||||
// +build linux aix zos
|
||||
// +build !js
|
||||
|
||||
package logrus
|
||||
|
7
vendor/github.com/sirupsen/logrus/text_formatter.go
generated
vendored
7
vendor/github.com/sirupsen/logrus/text_formatter.go
generated
vendored
@ -53,7 +53,10 @@ type TextFormatter struct {
|
||||
// the time passed since beginning of execution.
|
||||
FullTimestamp bool
|
||||
|
||||
// TimestampFormat to use for display when a full timestamp is printed
|
||||
// TimestampFormat to use for display when a full timestamp is printed.
|
||||
// The format to use is the same than for time.Format or time.Parse from the standard
|
||||
// library.
|
||||
// The standard Library already provides a set of predefined format.
|
||||
TimestampFormat string
|
||||
|
||||
// The fields are sorted by default for a consistent output. For applications
|
||||
@ -235,6 +238,8 @@ func (f *TextFormatter) printColored(b *bytes.Buffer, entry *Entry, keys []strin
|
||||
levelColor = yellow
|
||||
case ErrorLevel, FatalLevel, PanicLevel:
|
||||
levelColor = red
|
||||
case InfoLevel:
|
||||
levelColor = blue
|
||||
default:
|
||||
levelColor = blue
|
||||
}
|
||||
|
102
vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
102
vendor/google.golang.org/protobuf/encoding/prototext/decode.go
generated
vendored
@ -6,14 +6,13 @@ package prototext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/encoding/text"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/set"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
@ -23,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
// Unmarshal reads the given []byte into the given proto.Message.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func Unmarshal(b []byte, m proto.Message) error {
|
||||
return UnmarshalOptions{}.Unmarshal(b, m)
|
||||
}
|
||||
@ -51,9 +51,17 @@ type UnmarshalOptions struct {
|
||||
}
|
||||
}
|
||||
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message using options in
|
||||
// UnmarshalOptions object.
|
||||
// Unmarshal reads the given []byte and populates the given proto.Message
|
||||
// using options in the UnmarshalOptions object.
|
||||
// The provided message must be mutable (e.g., a non-nil pointer to a message).
|
||||
func (o UnmarshalOptions) Unmarshal(b []byte, m proto.Message) error {
|
||||
return o.unmarshal(b, m)
|
||||
}
|
||||
|
||||
// unmarshal is a centralized function that all unmarshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for unmarshal that do not go through this.
|
||||
func (o UnmarshalOptions) unmarshal(b []byte, m proto.Message) error {
|
||||
proto.Reset(m)
|
||||
|
||||
if o.Resolver == nil {
|
||||
@ -101,7 +109,7 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
return errors.New("no support for proto1 MessageSets")
|
||||
}
|
||||
|
||||
if messageDesc.FullName() == "google.protobuf.Any" {
|
||||
if messageDesc.FullName() == genid.Any_message_fullname {
|
||||
return d.unmarshalAny(m, checkDelims)
|
||||
}
|
||||
|
||||
@ -151,21 +159,11 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
switch tok.NameKind() {
|
||||
case text.IdentName:
|
||||
name = pref.Name(tok.IdentName())
|
||||
fd = fieldDescs.ByName(name)
|
||||
if fd == nil {
|
||||
// The proto name of a group field is in all lowercase,
|
||||
// while the textproto field name is the group message name.
|
||||
gd := fieldDescs.ByName(pref.Name(strings.ToLower(string(name))))
|
||||
if gd != nil && gd.Kind() == pref.GroupKind && gd.Message().Name() == name {
|
||||
fd = gd
|
||||
}
|
||||
} else if fd.Kind() == pref.GroupKind && fd.Message().Name() != name {
|
||||
fd = nil // reset since field name is actually the message name
|
||||
}
|
||||
fd = fieldDescs.ByTextName(string(name))
|
||||
|
||||
case text.TypeName:
|
||||
// Handle extensions only. This code path is not for Any.
|
||||
xt, xtErr = d.findExtension(pref.FullName(tok.TypeName()))
|
||||
xt, xtErr = d.opts.Resolver.FindExtensionByName(pref.FullName(tok.TypeName()))
|
||||
|
||||
case text.FieldNumber:
|
||||
isFieldNumberName = true
|
||||
@ -262,15 +260,6 @@ func (d decoder) unmarshalMessage(m pref.Message, checkDelims bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// findExtension returns protoreflect.ExtensionType from the Resolver if found.
|
||||
func (d decoder) findExtension(xtName pref.FullName) (pref.ExtensionType, error) {
|
||||
xt, err := d.opts.Resolver.FindExtensionByName(xtName)
|
||||
if err == nil {
|
||||
return xt, nil
|
||||
}
|
||||
return messageset.FindMessageSetExtension(d.opts.Resolver, xtName)
|
||||
}
|
||||
|
||||
// unmarshalSingular unmarshals a non-repeated field value specified by the
|
||||
// given FieldDescriptor.
|
||||
func (d decoder) unmarshalSingular(fd pref.FieldDescriptor, m pref.Message) error {
|
||||
@ -531,14 +520,13 @@ Loop:
|
||||
return d.unexpectedTokenError(tok)
|
||||
}
|
||||
|
||||
name := tok.IdentName()
|
||||
switch name {
|
||||
case "key":
|
||||
switch name := pref.Name(tok.IdentName()); name {
|
||||
case genid.MapEntry_Key_field_name:
|
||||
if !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
if key.IsValid() {
|
||||
return d.newError(tok.Pos(), `map entry "key" cannot be repeated`)
|
||||
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
|
||||
}
|
||||
val, err := d.unmarshalScalar(fd.MapKey())
|
||||
if err != nil {
|
||||
@ -546,14 +534,14 @@ Loop:
|
||||
}
|
||||
key = val.MapKey()
|
||||
|
||||
case "value":
|
||||
case genid.MapEntry_Value_field_name:
|
||||
if kind := fd.MapValue().Kind(); (kind != pref.MessageKind) && (kind != pref.GroupKind) {
|
||||
if !tok.HasSeparator() {
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
}
|
||||
if pval.IsValid() {
|
||||
return d.newError(tok.Pos(), `map entry "value" cannot be repeated`)
|
||||
return d.newError(tok.Pos(), "map entry %q cannot be repeated", name)
|
||||
}
|
||||
pval, err = unmarshalMapValue()
|
||||
if err != nil {
|
||||
@ -590,13 +578,9 @@ Loop:
|
||||
func (d decoder) unmarshalAny(m pref.Message, checkDelims bool) error {
|
||||
var typeURL string
|
||||
var bValue []byte
|
||||
|
||||
// hasFields tracks which valid fields have been seen in the loop below in
|
||||
// order to flag an error if there are duplicates or conflicts. It may
|
||||
// contain the strings "type_url", "value" and "expanded". The literal
|
||||
// "expanded" is used to indicate that the expanded form has been
|
||||
// encountered already.
|
||||
hasFields := map[string]bool{}
|
||||
var seenTypeUrl bool
|
||||
var seenValue bool
|
||||
var isExpanded bool
|
||||
|
||||
if checkDelims {
|
||||
tok, err := d.Read()
|
||||
@ -635,12 +619,12 @@ Loop:
|
||||
return d.syntaxError(tok.Pos(), "missing field separator :")
|
||||
}
|
||||
|
||||
switch tok.IdentName() {
|
||||
case "type_url":
|
||||
if hasFields["type_url"] {
|
||||
return d.newError(tok.Pos(), "duplicate Any type_url field")
|
||||
switch name := pref.Name(tok.IdentName()); name {
|
||||
case genid.Any_TypeUrl_field_name:
|
||||
if seenTypeUrl {
|
||||
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_TypeUrl_field_fullname)
|
||||
}
|
||||
if hasFields["expanded"] {
|
||||
if isExpanded {
|
||||
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
|
||||
}
|
||||
tok, err := d.Read()
|
||||
@ -650,15 +634,15 @@ Loop:
|
||||
var ok bool
|
||||
typeURL, ok = tok.String()
|
||||
if !ok {
|
||||
return d.newError(tok.Pos(), "invalid Any type_url: %v", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_TypeUrl_field_fullname, tok.RawString())
|
||||
}
|
||||
hasFields["type_url"] = true
|
||||
seenTypeUrl = true
|
||||
|
||||
case "value":
|
||||
if hasFields["value"] {
|
||||
return d.newError(tok.Pos(), "duplicate Any value field")
|
||||
case genid.Any_Value_field_name:
|
||||
if seenValue {
|
||||
return d.newError(tok.Pos(), "duplicate %v field", genid.Any_Value_field_fullname)
|
||||
}
|
||||
if hasFields["expanded"] {
|
||||
if isExpanded {
|
||||
return d.newError(tok.Pos(), "conflict with [%s] field", typeURL)
|
||||
}
|
||||
tok, err := d.Read()
|
||||
@ -667,22 +651,22 @@ Loop:
|
||||
}
|
||||
s, ok := tok.String()
|
||||
if !ok {
|
||||
return d.newError(tok.Pos(), "invalid Any value: %v", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid %v field value: %v", genid.Any_Value_field_fullname, tok.RawString())
|
||||
}
|
||||
bValue = []byte(s)
|
||||
hasFields["value"] = true
|
||||
seenValue = true
|
||||
|
||||
default:
|
||||
if !d.opts.DiscardUnknown {
|
||||
return d.newError(tok.Pos(), "invalid field name %q in google.protobuf.Any message", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
|
||||
}
|
||||
}
|
||||
|
||||
case text.TypeName:
|
||||
if hasFields["expanded"] {
|
||||
if isExpanded {
|
||||
return d.newError(tok.Pos(), "cannot have more than one type")
|
||||
}
|
||||
if hasFields["type_url"] {
|
||||
if seenTypeUrl {
|
||||
return d.newError(tok.Pos(), "conflict with type_url field")
|
||||
}
|
||||
typeURL = tok.TypeName()
|
||||
@ -691,21 +675,21 @@ Loop:
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hasFields["expanded"] = true
|
||||
isExpanded = true
|
||||
|
||||
default:
|
||||
if !d.opts.DiscardUnknown {
|
||||
return d.newError(tok.Pos(), "invalid field name %q in google.protobuf.Any message", tok.RawString())
|
||||
return d.newError(tok.Pos(), "invalid field name %q in %v message", tok.RawString(), genid.Any_message_fullname)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fds := m.Descriptor().Fields()
|
||||
if len(typeURL) > 0 {
|
||||
m.Set(fds.ByNumber(fieldnum.Any_TypeUrl), pref.ValueOfString(typeURL))
|
||||
m.Set(fds.ByNumber(genid.Any_TypeUrl_field_number), pref.ValueOfString(typeURL))
|
||||
}
|
||||
if len(bValue) > 0 {
|
||||
m.Set(fds.ByNumber(fieldnum.Any_Value), pref.ValueOfBytes(bValue))
|
||||
m.Set(fds.ByNumber(genid.Any_Value_field_number), pref.ValueOfBytes(bValue))
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
103
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
103
vendor/google.golang.org/protobuf/encoding/prototext/encode.go
generated
vendored
@ -6,7 +6,6 @@ package prototext
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strconv"
|
||||
"unicode/utf8"
|
||||
|
||||
@ -14,12 +13,13 @@ import (
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/encoding/text"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/flags"
|
||||
"google.golang.org/protobuf/internal/mapsort"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
"google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
@ -102,6 +102,13 @@ func (o MarshalOptions) Format(m proto.Message) string {
|
||||
// MarshalOptions object. Do not depend on the output being stable. It may
|
||||
// change over time across different versions of the program.
|
||||
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
|
||||
return o.marshal(m)
|
||||
}
|
||||
|
||||
// marshal is a centralized function that all marshal operations go through.
|
||||
// For profiling purposes, avoid changing the name of this function or
|
||||
// introducing other code paths for marshal that do not go through this.
|
||||
func (o MarshalOptions) marshal(m proto.Message) ([]byte, error) {
|
||||
var delims = [2]byte{'{', '}'}
|
||||
|
||||
if o.Multiline && o.Indent == "" {
|
||||
@ -155,42 +162,22 @@ func (e encoder) marshalMessage(m pref.Message, inclDelims bool) error {
|
||||
}
|
||||
|
||||
// Handle Any expansion.
|
||||
if messageDesc.FullName() == "google.protobuf.Any" {
|
||||
if messageDesc.FullName() == genid.Any_message_fullname {
|
||||
if e.marshalAny(m) {
|
||||
return nil
|
||||
}
|
||||
// If unable to expand, continue on to marshal Any as a regular message.
|
||||
}
|
||||
|
||||
// Marshal known fields.
|
||||
fieldDescs := messageDesc.Fields()
|
||||
size := fieldDescs.Len()
|
||||
for i := 0; i < size; {
|
||||
fd := fieldDescs.Get(i)
|
||||
if od := fd.ContainingOneof(); od != nil {
|
||||
fd = m.WhichOneof(od)
|
||||
i += od.Fields().Len()
|
||||
} else {
|
||||
i++
|
||||
// Marshal fields.
|
||||
var err error
|
||||
order.RangeFields(m, order.IndexNameFieldOrder, func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
|
||||
if err = e.marshalField(fd.TextName(), v, fd); err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
if fd == nil || !m.Has(fd) {
|
||||
continue
|
||||
}
|
||||
|
||||
name := fd.Name()
|
||||
// Use type name for group field name.
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
name = fd.Message().Name()
|
||||
}
|
||||
val := m.Get(fd)
|
||||
if err := e.marshalField(string(name), val, fd); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// Marshal extensions.
|
||||
if err := e.marshalExtensions(m); err != nil {
|
||||
return true
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@ -283,18 +270,18 @@ func (e encoder) marshalList(name string, list pref.List, fd pref.FieldDescripto
|
||||
// marshalMap marshals the given protoreflect.Map as multiple name-value fields.
|
||||
func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor) error {
|
||||
var err error
|
||||
mapsort.Range(mmap, fd.MapKey().Kind(), func(key pref.MapKey, val pref.Value) bool {
|
||||
order.RangeEntries(mmap, order.GenericKeyOrder, func(key pref.MapKey, val pref.Value) bool {
|
||||
e.WriteName(name)
|
||||
e.StartMessage()
|
||||
defer e.EndMessage()
|
||||
|
||||
e.WriteName("key")
|
||||
e.WriteName(string(genid.MapEntry_Key_field_name))
|
||||
err = e.marshalSingular(key.Value(), fd.MapKey())
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
e.WriteName("value")
|
||||
e.WriteName(string(genid.MapEntry_Value_field_name))
|
||||
err = e.marshalSingular(val, fd.MapValue())
|
||||
if err != nil {
|
||||
return false
|
||||
@ -304,48 +291,6 @@ func (e encoder) marshalMap(name string, mmap pref.Map, fd pref.FieldDescriptor)
|
||||
return err
|
||||
}
|
||||
|
||||
// marshalExtensions marshals extension fields.
|
||||
func (e encoder) marshalExtensions(m pref.Message) error {
|
||||
type entry struct {
|
||||
key string
|
||||
value pref.Value
|
||||
desc pref.FieldDescriptor
|
||||
}
|
||||
|
||||
// Get a sorted list based on field key first.
|
||||
var entries []entry
|
||||
m.Range(func(fd pref.FieldDescriptor, v pref.Value) bool {
|
||||
if !fd.IsExtension() {
|
||||
return true
|
||||
}
|
||||
// For MessageSet extensions, the name used is the parent message.
|
||||
name := fd.FullName()
|
||||
if messageset.IsMessageSetExtension(fd) {
|
||||
name = name.Parent()
|
||||
}
|
||||
entries = append(entries, entry{
|
||||
key: string(name),
|
||||
value: v,
|
||||
desc: fd,
|
||||
})
|
||||
return true
|
||||
})
|
||||
// Sort extensions lexicographically.
|
||||
sort.Slice(entries, func(i, j int) bool {
|
||||
return entries[i].key < entries[j].key
|
||||
})
|
||||
|
||||
// Write out sorted list.
|
||||
for _, entry := range entries {
|
||||
// Extension field name is the proto field name enclosed in [].
|
||||
name := "[" + entry.key + "]"
|
||||
if err := e.marshalField(name, entry.value, entry.desc); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// marshalUnknown parses the given []byte and marshals fields out.
|
||||
// This function assumes proper encoding in the given []byte.
|
||||
func (e encoder) marshalUnknown(b []byte) {
|
||||
@ -392,7 +337,7 @@ func (e encoder) marshalUnknown(b []byte) {
|
||||
func (e encoder) marshalAny(any pref.Message) bool {
|
||||
// Construct the embedded message.
|
||||
fds := any.Descriptor().Fields()
|
||||
fdType := fds.ByNumber(fieldnum.Any_TypeUrl)
|
||||
fdType := fds.ByNumber(genid.Any_TypeUrl_field_number)
|
||||
typeURL := any.Get(fdType).String()
|
||||
mt, err := e.opts.Resolver.FindMessageByURL(typeURL)
|
||||
if err != nil {
|
||||
@ -401,7 +346,7 @@ func (e encoder) marshalAny(any pref.Message) bool {
|
||||
m := mt.New().Interface()
|
||||
|
||||
// Unmarshal bytes into embedded message.
|
||||
fdValue := fds.ByNumber(fieldnum.Any_Value)
|
||||
fdValue := fds.ByNumber(genid.Any_Value_field_number)
|
||||
value := any.Get(fdValue)
|
||||
err = proto.UnmarshalOptions{
|
||||
AllowPartial: true,
|
||||
|
2
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/descfmt/stringer.go
generated
vendored
@ -42,6 +42,8 @@ func formatListOpt(vs list, isRoot, allowMulti bool) string {
|
||||
name = "FileImports"
|
||||
case pref.Descriptor:
|
||||
name = reflect.ValueOf(vs).MethodByName("Get").Type().Out(0).Name() + "s"
|
||||
default:
|
||||
name = reflect.ValueOf(vs).Elem().Type().Name()
|
||||
}
|
||||
start, end = name+"{", "}"
|
||||
}
|
||||
|
8
vendor/google.golang.org/protobuf/internal/detrand/rand.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/detrand/rand.go
generated
vendored
@ -26,6 +26,14 @@ func Bool() bool {
|
||||
return randSeed%2 == 1
|
||||
}
|
||||
|
||||
// Intn returns a deterministically random integer between 0 and n-1, inclusive.
|
||||
func Intn(n int) int {
|
||||
if n <= 0 {
|
||||
panic("must be positive")
|
||||
}
|
||||
return int(randSeed % uint64(n))
|
||||
}
|
||||
|
||||
// randSeed is a best-effort at an approximate hash of the Go binary.
|
||||
var randSeed = binaryHash()
|
||||
|
||||
|
35
vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
generated
vendored
35
vendor/google.golang.org/protobuf/internal/encoding/messageset/messageset.go
generated
vendored
@ -11,10 +11,9 @@ import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// The MessageSet wire format is equivalent to a message defiend as follows,
|
||||
// The MessageSet wire format is equivalent to a message defined as follows,
|
||||
// where each Item defines an extension field with a field number of 'type_id'
|
||||
// and content of 'message'. MessageSet extensions must be non-repeated message
|
||||
// fields.
|
||||
@ -48,33 +47,17 @@ func IsMessageSet(md pref.MessageDescriptor) bool {
|
||||
return ok && xmd.IsMessageSet()
|
||||
}
|
||||
|
||||
// IsMessageSetExtension reports this field extends a MessageSet.
|
||||
// IsMessageSetExtension reports this field properly extends a MessageSet.
|
||||
func IsMessageSetExtension(fd pref.FieldDescriptor) bool {
|
||||
if fd.Name() != ExtensionName {
|
||||
switch {
|
||||
case fd.Name() != ExtensionName:
|
||||
return false
|
||||
case !IsMessageSet(fd.ContainingMessage()):
|
||||
return false
|
||||
case fd.FullName().Parent() != fd.Message().FullName():
|
||||
return false
|
||||
}
|
||||
if fd.FullName().Parent() != fd.Message().FullName() {
|
||||
return false
|
||||
}
|
||||
return IsMessageSet(fd.ContainingMessage())
|
||||
}
|
||||
|
||||
// FindMessageSetExtension locates a MessageSet extension field by name.
|
||||
// In text and JSON formats, the extension name used is the message itself.
|
||||
// The extension field name is derived by appending ExtensionName.
|
||||
func FindMessageSetExtension(r preg.ExtensionTypeResolver, s pref.FullName) (pref.ExtensionType, error) {
|
||||
name := s.Append(ExtensionName)
|
||||
xt, err := r.FindExtensionByName(name)
|
||||
if err != nil {
|
||||
if err == preg.NotFound {
|
||||
return nil, err
|
||||
}
|
||||
return nil, errors.Wrap(err, "%q", name)
|
||||
}
|
||||
if !IsMessageSetExtension(xt.TypeDescriptor()) {
|
||||
return nil, preg.NotFound
|
||||
}
|
||||
return xt, nil
|
||||
return true
|
||||
}
|
||||
|
||||
// SizeField returns the size of a MessageSet item field containing an extension
|
||||
|
2
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/encoding/tag/tag.go
generated
vendored
@ -104,7 +104,7 @@ func Unmarshal(tag string, goType reflect.Type, evs pref.EnumValueDescriptors) p
|
||||
case strings.HasPrefix(s, "json="):
|
||||
jsonName := s[len("json="):]
|
||||
if jsonName != strs.JSONCamelCase(string(f.L0.FullName.Name())) {
|
||||
f.L1.JSONName.Init(jsonName)
|
||||
f.L1.StringName.InitJSON(jsonName)
|
||||
}
|
||||
case s == "packed":
|
||||
f.L1.HasPacked = true
|
||||
|
8
vendor/google.golang.org/protobuf/internal/encoding/text/encode.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/encoding/text/encode.go
generated
vendored
@ -32,7 +32,6 @@ type Encoder struct {
|
||||
encoderState
|
||||
|
||||
indent string
|
||||
newline string // set to "\n" if len(indent) > 0
|
||||
delims [2]byte
|
||||
outputASCII bool
|
||||
}
|
||||
@ -61,7 +60,6 @@ func NewEncoder(indent string, delims [2]byte, outputASCII bool) (*Encoder, erro
|
||||
return nil, errors.New("indent may only be composed of space and tab characters")
|
||||
}
|
||||
e.indent = indent
|
||||
e.newline = "\n"
|
||||
}
|
||||
switch delims {
|
||||
case [2]byte{0, 0}:
|
||||
@ -126,7 +124,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||
// are used to represent both the proto string and bytes type.
|
||||
r = rune(in[0])
|
||||
fallthrough
|
||||
case r < ' ' || r == '"' || r == '\\':
|
||||
case r < ' ' || r == '"' || r == '\\' || r == 0x7f:
|
||||
out = append(out, '\\')
|
||||
switch r {
|
||||
case '"', '\\':
|
||||
@ -143,7 +141,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||
out = strconv.AppendUint(out, uint64(r), 16)
|
||||
}
|
||||
in = in[n:]
|
||||
case outputASCII && r >= utf8.RuneSelf:
|
||||
case r >= utf8.RuneSelf && (outputASCII || r <= 0x009f):
|
||||
out = append(out, '\\')
|
||||
if r <= math.MaxUint16 {
|
||||
out = append(out, 'u')
|
||||
@ -168,7 +166,7 @@ func appendString(out []byte, in string, outputASCII bool) []byte {
|
||||
// escaping. If no characters need escaping, this returns the input length.
|
||||
func indexNeedEscapeInString(s string) int {
|
||||
for i := 0; i < len(s); i++ {
|
||||
if c := s[i]; c < ' ' || c == '"' || c == '\'' || c == '\\' || c >= utf8.RuneSelf {
|
||||
if c := s[i]; c < ' ' || c == '"' || c == '\'' || c == '\\' || c >= 0x7f {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
13
vendor/google.golang.org/protobuf/internal/fieldnum/any_gen.go
generated
vendored
13
vendor/google.golang.org/protobuf/internal/fieldnum/any_gen.go
generated
vendored
@ -1,13 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Any.
|
||||
const (
|
||||
Any_TypeUrl = 1 // optional string
|
||||
Any_Value = 2 // optional bytes
|
||||
)
|
35
vendor/google.golang.org/protobuf/internal/fieldnum/api_gen.go
generated
vendored
35
vendor/google.golang.org/protobuf/internal/fieldnum/api_gen.go
generated
vendored
@ -1,35 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Api.
|
||||
const (
|
||||
Api_Name = 1 // optional string
|
||||
Api_Methods = 2 // repeated google.protobuf.Method
|
||||
Api_Options = 3 // repeated google.protobuf.Option
|
||||
Api_Version = 4 // optional string
|
||||
Api_SourceContext = 5 // optional google.protobuf.SourceContext
|
||||
Api_Mixins = 6 // repeated google.protobuf.Mixin
|
||||
Api_Syntax = 7 // optional google.protobuf.Syntax
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Method.
|
||||
const (
|
||||
Method_Name = 1 // optional string
|
||||
Method_RequestTypeUrl = 2 // optional string
|
||||
Method_RequestStreaming = 3 // optional bool
|
||||
Method_ResponseTypeUrl = 4 // optional string
|
||||
Method_ResponseStreaming = 5 // optional bool
|
||||
Method_Options = 6 // repeated google.protobuf.Option
|
||||
Method_Syntax = 7 // optional google.protobuf.Syntax
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Mixin.
|
||||
const (
|
||||
Mixin_Name = 1 // optional string
|
||||
Mixin_Root = 2 // optional string
|
||||
)
|
240
vendor/google.golang.org/protobuf/internal/fieldnum/descriptor_gen.go
generated
vendored
240
vendor/google.golang.org/protobuf/internal/fieldnum/descriptor_gen.go
generated
vendored
@ -1,240 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_File = 1 // repeated google.protobuf.FileDescriptorProto
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FileDescriptorProto.
|
||||
const (
|
||||
FileDescriptorProto_Name = 1 // optional string
|
||||
FileDescriptorProto_Package = 2 // optional string
|
||||
FileDescriptorProto_Dependency = 3 // repeated string
|
||||
FileDescriptorProto_PublicDependency = 10 // repeated int32
|
||||
FileDescriptorProto_WeakDependency = 11 // repeated int32
|
||||
FileDescriptorProto_MessageType = 4 // repeated google.protobuf.DescriptorProto
|
||||
FileDescriptorProto_EnumType = 5 // repeated google.protobuf.EnumDescriptorProto
|
||||
FileDescriptorProto_Service = 6 // repeated google.protobuf.ServiceDescriptorProto
|
||||
FileDescriptorProto_Extension = 7 // repeated google.protobuf.FieldDescriptorProto
|
||||
FileDescriptorProto_Options = 8 // optional google.protobuf.FileOptions
|
||||
FileDescriptorProto_SourceCodeInfo = 9 // optional google.protobuf.SourceCodeInfo
|
||||
FileDescriptorProto_Syntax = 12 // optional string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.
|
||||
const (
|
||||
DescriptorProto_Name = 1 // optional string
|
||||
DescriptorProto_Field = 2 // repeated google.protobuf.FieldDescriptorProto
|
||||
DescriptorProto_Extension = 6 // repeated google.protobuf.FieldDescriptorProto
|
||||
DescriptorProto_NestedType = 3 // repeated google.protobuf.DescriptorProto
|
||||
DescriptorProto_EnumType = 4 // repeated google.protobuf.EnumDescriptorProto
|
||||
DescriptorProto_ExtensionRange = 5 // repeated google.protobuf.DescriptorProto.ExtensionRange
|
||||
DescriptorProto_OneofDecl = 8 // repeated google.protobuf.OneofDescriptorProto
|
||||
DescriptorProto_Options = 7 // optional google.protobuf.MessageOptions
|
||||
DescriptorProto_ReservedRange = 9 // repeated google.protobuf.DescriptorProto.ReservedRange
|
||||
DescriptorProto_ReservedName = 10 // repeated string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.ExtensionRange.
|
||||
const (
|
||||
DescriptorProto_ExtensionRange_Start = 1 // optional int32
|
||||
DescriptorProto_ExtensionRange_End = 2 // optional int32
|
||||
DescriptorProto_ExtensionRange_Options = 3 // optional google.protobuf.ExtensionRangeOptions
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.ReservedRange.
|
||||
const (
|
||||
DescriptorProto_ReservedRange_Start = 1 // optional int32
|
||||
DescriptorProto_ReservedRange_End = 2 // optional int32
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FieldDescriptorProto.
|
||||
const (
|
||||
FieldDescriptorProto_Name = 1 // optional string
|
||||
FieldDescriptorProto_Number = 3 // optional int32
|
||||
FieldDescriptorProto_Label = 4 // optional google.protobuf.FieldDescriptorProto.Label
|
||||
FieldDescriptorProto_Type = 5 // optional google.protobuf.FieldDescriptorProto.Type
|
||||
FieldDescriptorProto_TypeName = 6 // optional string
|
||||
FieldDescriptorProto_Extendee = 2 // optional string
|
||||
FieldDescriptorProto_DefaultValue = 7 // optional string
|
||||
FieldDescriptorProto_OneofIndex = 9 // optional int32
|
||||
FieldDescriptorProto_JsonName = 10 // optional string
|
||||
FieldDescriptorProto_Options = 8 // optional google.protobuf.FieldOptions
|
||||
FieldDescriptorProto_Proto3Optional = 17 // optional bool
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.OneofDescriptorProto.
|
||||
const (
|
||||
OneofDescriptorProto_Name = 1 // optional string
|
||||
OneofDescriptorProto_Options = 2 // optional google.protobuf.OneofOptions
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumDescriptorProto.
|
||||
const (
|
||||
EnumDescriptorProto_Name = 1 // optional string
|
||||
EnumDescriptorProto_Value = 2 // repeated google.protobuf.EnumValueDescriptorProto
|
||||
EnumDescriptorProto_Options = 3 // optional google.protobuf.EnumOptions
|
||||
EnumDescriptorProto_ReservedRange = 4 // repeated google.protobuf.EnumDescriptorProto.EnumReservedRange
|
||||
EnumDescriptorProto_ReservedName = 5 // repeated string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumDescriptorProto.EnumReservedRange.
|
||||
const (
|
||||
EnumDescriptorProto_EnumReservedRange_Start = 1 // optional int32
|
||||
EnumDescriptorProto_EnumReservedRange_End = 2 // optional int32
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValueDescriptorProto.
|
||||
const (
|
||||
EnumValueDescriptorProto_Name = 1 // optional string
|
||||
EnumValueDescriptorProto_Number = 2 // optional int32
|
||||
EnumValueDescriptorProto_Options = 3 // optional google.protobuf.EnumValueOptions
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ServiceDescriptorProto.
|
||||
const (
|
||||
ServiceDescriptorProto_Name = 1 // optional string
|
||||
ServiceDescriptorProto_Method = 2 // repeated google.protobuf.MethodDescriptorProto
|
||||
ServiceDescriptorProto_Options = 3 // optional google.protobuf.ServiceOptions
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MethodDescriptorProto.
|
||||
const (
|
||||
MethodDescriptorProto_Name = 1 // optional string
|
||||
MethodDescriptorProto_InputType = 2 // optional string
|
||||
MethodDescriptorProto_OutputType = 3 // optional string
|
||||
MethodDescriptorProto_Options = 4 // optional google.protobuf.MethodOptions
|
||||
MethodDescriptorProto_ClientStreaming = 5 // optional bool
|
||||
MethodDescriptorProto_ServerStreaming = 6 // optional bool
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FileOptions.
|
||||
const (
|
||||
FileOptions_JavaPackage = 1 // optional string
|
||||
FileOptions_JavaOuterClassname = 8 // optional string
|
||||
FileOptions_JavaMultipleFiles = 10 // optional bool
|
||||
FileOptions_JavaGenerateEqualsAndHash = 20 // optional bool
|
||||
FileOptions_JavaStringCheckUtf8 = 27 // optional bool
|
||||
FileOptions_OptimizeFor = 9 // optional google.protobuf.FileOptions.OptimizeMode
|
||||
FileOptions_GoPackage = 11 // optional string
|
||||
FileOptions_CcGenericServices = 16 // optional bool
|
||||
FileOptions_JavaGenericServices = 17 // optional bool
|
||||
FileOptions_PyGenericServices = 18 // optional bool
|
||||
FileOptions_PhpGenericServices = 42 // optional bool
|
||||
FileOptions_Deprecated = 23 // optional bool
|
||||
FileOptions_CcEnableArenas = 31 // optional bool
|
||||
FileOptions_ObjcClassPrefix = 36 // optional string
|
||||
FileOptions_CsharpNamespace = 37 // optional string
|
||||
FileOptions_SwiftPrefix = 39 // optional string
|
||||
FileOptions_PhpClassPrefix = 40 // optional string
|
||||
FileOptions_PhpNamespace = 41 // optional string
|
||||
FileOptions_PhpMetadataNamespace = 44 // optional string
|
||||
FileOptions_RubyPackage = 45 // optional string
|
||||
FileOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_MessageSetWireFormat = 1 // optional bool
|
||||
MessageOptions_NoStandardDescriptorAccessor = 2 // optional bool
|
||||
MessageOptions_Deprecated = 3 // optional bool
|
||||
MessageOptions_MapEntry = 7 // optional bool
|
||||
MessageOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FieldOptions.
|
||||
const (
|
||||
FieldOptions_Ctype = 1 // optional google.protobuf.FieldOptions.CType
|
||||
FieldOptions_Packed = 2 // optional bool
|
||||
FieldOptions_Jstype = 6 // optional google.protobuf.FieldOptions.JSType
|
||||
FieldOptions_Lazy = 5 // optional bool
|
||||
FieldOptions_Deprecated = 3 // optional bool
|
||||
FieldOptions_Weak = 10 // optional bool
|
||||
FieldOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumOptions.
|
||||
const (
|
||||
EnumOptions_AllowAlias = 2 // optional bool
|
||||
EnumOptions_Deprecated = 3 // optional bool
|
||||
EnumOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValueOptions.
|
||||
const (
|
||||
EnumValueOptions_Deprecated = 1 // optional bool
|
||||
EnumValueOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ServiceOptions.
|
||||
const (
|
||||
ServiceOptions_Deprecated = 33 // optional bool
|
||||
ServiceOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MethodOptions.
|
||||
const (
|
||||
MethodOptions_Deprecated = 33 // optional bool
|
||||
MethodOptions_IdempotencyLevel = 34 // optional google.protobuf.MethodOptions.IdempotencyLevel
|
||||
MethodOptions_UninterpretedOption = 999 // repeated google.protobuf.UninterpretedOption
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UninterpretedOption.
|
||||
const (
|
||||
UninterpretedOption_Name = 2 // repeated google.protobuf.UninterpretedOption.NamePart
|
||||
UninterpretedOption_IdentifierValue = 3 // optional string
|
||||
UninterpretedOption_PositiveIntValue = 4 // optional uint64
|
||||
UninterpretedOption_NegativeIntValue = 5 // optional int64
|
||||
UninterpretedOption_DoubleValue = 6 // optional double
|
||||
UninterpretedOption_StringValue = 7 // optional bytes
|
||||
UninterpretedOption_AggregateValue = 8 // optional string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UninterpretedOption.NamePart.
|
||||
const (
|
||||
UninterpretedOption_NamePart_NamePart = 1 // required string
|
||||
UninterpretedOption_NamePart_IsExtension = 2 // required bool
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.SourceCodeInfo.
|
||||
const (
|
||||
SourceCodeInfo_Location = 1 // repeated google.protobuf.SourceCodeInfo.Location
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.SourceCodeInfo.Location.
|
||||
const (
|
||||
SourceCodeInfo_Location_Path = 1 // repeated int32
|
||||
SourceCodeInfo_Location_Span = 2 // repeated int32
|
||||
SourceCodeInfo_Location_LeadingComments = 3 // optional string
|
||||
SourceCodeInfo_Location_TrailingComments = 4 // optional string
|
||||
SourceCodeInfo_Location_LeadingDetachedComments = 6 // repeated string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GeneratedCodeInfo.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation = 1 // repeated google.protobuf.GeneratedCodeInfo.Annotation
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GeneratedCodeInfo.Annotation.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_Path = 1 // repeated int32
|
||||
GeneratedCodeInfo_Annotation_SourceFile = 2 // optional string
|
||||
GeneratedCodeInfo_Annotation_Begin = 3 // optional int32
|
||||
GeneratedCodeInfo_Annotation_End = 4 // optional int32
|
||||
)
|
7
vendor/google.golang.org/protobuf/internal/fieldnum/doc.go
generated
vendored
7
vendor/google.golang.org/protobuf/internal/fieldnum/doc.go
generated
vendored
@ -1,7 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package fieldnum contains constants for field numbers of fields in messages
|
||||
// declared in descriptor.proto and any of the well-known types.
|
||||
package fieldnum
|
13
vendor/google.golang.org/protobuf/internal/fieldnum/duration_gen.go
generated
vendored
13
vendor/google.golang.org/protobuf/internal/fieldnum/duration_gen.go
generated
vendored
@ -1,13 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Duration.
|
||||
const (
|
||||
Duration_Seconds = 1 // optional int64
|
||||
Duration_Nanos = 2 // optional int32
|
||||
)
|
10
vendor/google.golang.org/protobuf/internal/fieldnum/empty_gen.go
generated
vendored
10
vendor/google.golang.org/protobuf/internal/fieldnum/empty_gen.go
generated
vendored
@ -1,10 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Empty.
|
||||
const ()
|
12
vendor/google.golang.org/protobuf/internal/fieldnum/field_mask_gen.go
generated
vendored
12
vendor/google.golang.org/protobuf/internal/fieldnum/field_mask_gen.go
generated
vendored
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.FieldMask.
|
||||
const (
|
||||
FieldMask_Paths = 1 // repeated string
|
||||
)
|
12
vendor/google.golang.org/protobuf/internal/fieldnum/source_context_gen.go
generated
vendored
12
vendor/google.golang.org/protobuf/internal/fieldnum/source_context_gen.go
generated
vendored
@ -1,12 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.SourceContext.
|
||||
const (
|
||||
SourceContext_FileName = 1 // optional string
|
||||
)
|
33
vendor/google.golang.org/protobuf/internal/fieldnum/struct_gen.go
generated
vendored
33
vendor/google.golang.org/protobuf/internal/fieldnum/struct_gen.go
generated
vendored
@ -1,33 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Struct.
|
||||
const (
|
||||
Struct_Fields = 1 // repeated google.protobuf.Struct.FieldsEntry
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Struct.FieldsEntry.
|
||||
const (
|
||||
Struct_FieldsEntry_Key = 1 // optional string
|
||||
Struct_FieldsEntry_Value = 2 // optional google.protobuf.Value
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Value.
|
||||
const (
|
||||
Value_NullValue = 1 // optional google.protobuf.NullValue
|
||||
Value_NumberValue = 2 // optional double
|
||||
Value_StringValue = 3 // optional string
|
||||
Value_BoolValue = 4 // optional bool
|
||||
Value_StructValue = 5 // optional google.protobuf.Struct
|
||||
Value_ListValue = 6 // optional google.protobuf.ListValue
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ListValue.
|
||||
const (
|
||||
ListValue_Values = 1 // repeated google.protobuf.Value
|
||||
)
|
13
vendor/google.golang.org/protobuf/internal/fieldnum/timestamp_gen.go
generated
vendored
13
vendor/google.golang.org/protobuf/internal/fieldnum/timestamp_gen.go
generated
vendored
@ -1,13 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Timestamp.
|
||||
const (
|
||||
Timestamp_Seconds = 1 // optional int64
|
||||
Timestamp_Nanos = 2 // optional int32
|
||||
)
|
53
vendor/google.golang.org/protobuf/internal/fieldnum/type_gen.go
generated
vendored
53
vendor/google.golang.org/protobuf/internal/fieldnum/type_gen.go
generated
vendored
@ -1,53 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.Type.
|
||||
const (
|
||||
Type_Name = 1 // optional string
|
||||
Type_Fields = 2 // repeated google.protobuf.Field
|
||||
Type_Oneofs = 3 // repeated string
|
||||
Type_Options = 4 // repeated google.protobuf.Option
|
||||
Type_SourceContext = 5 // optional google.protobuf.SourceContext
|
||||
Type_Syntax = 6 // optional google.protobuf.Syntax
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Field.
|
||||
const (
|
||||
Field_Kind = 1 // optional google.protobuf.Field.Kind
|
||||
Field_Cardinality = 2 // optional google.protobuf.Field.Cardinality
|
||||
Field_Number = 3 // optional int32
|
||||
Field_Name = 4 // optional string
|
||||
Field_TypeUrl = 6 // optional string
|
||||
Field_OneofIndex = 7 // optional int32
|
||||
Field_Packed = 8 // optional bool
|
||||
Field_Options = 9 // repeated google.protobuf.Option
|
||||
Field_JsonName = 10 // optional string
|
||||
Field_DefaultValue = 11 // optional string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Enum.
|
||||
const (
|
||||
Enum_Name = 1 // optional string
|
||||
Enum_Enumvalue = 2 // repeated google.protobuf.EnumValue
|
||||
Enum_Options = 3 // repeated google.protobuf.Option
|
||||
Enum_SourceContext = 4 // optional google.protobuf.SourceContext
|
||||
Enum_Syntax = 5 // optional google.protobuf.Syntax
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValue.
|
||||
const (
|
||||
EnumValue_Name = 1 // optional string
|
||||
EnumValue_Number = 2 // optional int32
|
||||
EnumValue_Options = 3 // repeated google.protobuf.Option
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Option.
|
||||
const (
|
||||
Option_Name = 1 // optional string
|
||||
Option_Value = 2 // optional google.protobuf.Any
|
||||
)
|
52
vendor/google.golang.org/protobuf/internal/fieldnum/wrappers_gen.go
generated
vendored
52
vendor/google.golang.org/protobuf/internal/fieldnum/wrappers_gen.go
generated
vendored
@ -1,52 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package fieldnum
|
||||
|
||||
// Field numbers for google.protobuf.DoubleValue.
|
||||
const (
|
||||
DoubleValue_Value = 1 // optional double
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FloatValue.
|
||||
const (
|
||||
FloatValue_Value = 1 // optional float
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Int64Value.
|
||||
const (
|
||||
Int64Value_Value = 1 // optional int64
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UInt64Value.
|
||||
const (
|
||||
UInt64Value_Value = 1 // optional uint64
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Int32Value.
|
||||
const (
|
||||
Int32Value_Value = 1 // optional int32
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UInt32Value.
|
||||
const (
|
||||
UInt32Value_Value = 1 // optional uint32
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.BoolValue.
|
||||
const (
|
||||
BoolValue_Value = 1 // optional bool
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.StringValue.
|
||||
const (
|
||||
StringValue_Value = 1 // optional string
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.BytesValue.
|
||||
const (
|
||||
BytesValue_Value = 1 // optional bytes
|
||||
)
|
40
vendor/google.golang.org/protobuf/internal/fieldsort/fieldsort.go
generated
vendored
40
vendor/google.golang.org/protobuf/internal/fieldsort/fieldsort.go
generated
vendored
@ -1,40 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package fieldsort defines an ordering of fields.
|
||||
//
|
||||
// The ordering defined by this package matches the historic behavior of the proto
|
||||
// package, placing extensions first and oneofs last.
|
||||
//
|
||||
// There is no guarantee about stability of the wire encoding, and users should not
|
||||
// depend on the order defined in this package as it is subject to change without
|
||||
// notice.
|
||||
package fieldsort
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
// Less returns true if field a comes before field j in ordered wire marshal output.
|
||||
func Less(a, b protoreflect.FieldDescriptor) bool {
|
||||
ea := a.IsExtension()
|
||||
eb := b.IsExtension()
|
||||
oa := a.ContainingOneof()
|
||||
ob := b.ContainingOneof()
|
||||
switch {
|
||||
case ea != eb:
|
||||
return ea
|
||||
case oa != nil && ob != nil:
|
||||
if oa == ob {
|
||||
return a.Number() < b.Number()
|
||||
}
|
||||
return oa.Index() < ob.Index()
|
||||
case oa != nil && !oa.IsSynthetic():
|
||||
return false
|
||||
case ob != nil && !ob.IsSynthetic():
|
||||
return true
|
||||
default:
|
||||
return a.Number() < b.Number()
|
||||
}
|
||||
}
|
19
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
19
vendor/google.golang.org/protobuf/internal/filedesc/build.go
generated
vendored
@ -3,11 +3,14 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package filedesc provides functionality for constructing descriptors.
|
||||
//
|
||||
// The types in this package implement interfaces in the protoreflect package
|
||||
// related to protobuf descripriptors.
|
||||
package filedesc
|
||||
|
||||
import (
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
@ -126,24 +129,24 @@ func (db *Builder) unmarshalCounts(b []byte, isFile bool) {
|
||||
b = b[m:]
|
||||
if isFile {
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_EnumType:
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
db.NumEnums++
|
||||
case fieldnum.FileDescriptorProto_MessageType:
|
||||
case genid.FileDescriptorProto_MessageType_field_number:
|
||||
db.unmarshalCounts(v, false)
|
||||
db.NumMessages++
|
||||
case fieldnum.FileDescriptorProto_Extension:
|
||||
case genid.FileDescriptorProto_Extension_field_number:
|
||||
db.NumExtensions++
|
||||
case fieldnum.FileDescriptorProto_Service:
|
||||
case genid.FileDescriptorProto_Service_field_number:
|
||||
db.NumServices++
|
||||
}
|
||||
} else {
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_EnumType:
|
||||
case genid.DescriptorProto_EnumType_field_number:
|
||||
db.NumEnums++
|
||||
case fieldnum.DescriptorProto_NestedType:
|
||||
case genid.DescriptorProto_NestedType_field_number:
|
||||
db.unmarshalCounts(v, false)
|
||||
db.NumMessages++
|
||||
case fieldnum.DescriptorProto_Extension:
|
||||
case genid.DescriptorProto_Extension_field_number:
|
||||
db.NumExtensions++
|
||||
}
|
||||
}
|
||||
|
82
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
82
vendor/google.golang.org/protobuf/internal/filedesc/desc.go
generated
vendored
@ -13,6 +13,8 @@ import (
|
||||
"google.golang.org/protobuf/internal/descfmt"
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/encoding/defval"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@ -98,15 +100,6 @@ func (fd *File) lazyInitOnce() {
|
||||
fd.mu.Unlock()
|
||||
}
|
||||
|
||||
// ProtoLegacyRawDesc is a pseudo-internal API for allowing the v1 code
|
||||
// to be able to retrieve the raw descriptor.
|
||||
//
|
||||
// WARNING: This method is exempt from the compatibility promise and may be
|
||||
// removed in the future without warning.
|
||||
func (fd *File) ProtoLegacyRawDesc() []byte {
|
||||
return fd.builder.RawDescriptor
|
||||
}
|
||||
|
||||
// GoPackagePath is a pseudo-internal API for determining the Go package path
|
||||
// that this file descriptor is declared in.
|
||||
//
|
||||
@ -206,7 +199,7 @@ type (
|
||||
Number pref.FieldNumber
|
||||
Cardinality pref.Cardinality // must be consistent with Message.RequiredNumbers
|
||||
Kind pref.Kind
|
||||
JSONName jsonName
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsWeak bool // promoted from google.protobuf.FieldOptions
|
||||
HasPacked bool // promoted from google.protobuf.FieldOptions
|
||||
@ -276,8 +269,9 @@ func (fd *Field) Options() pref.ProtoMessage {
|
||||
func (fd *Field) Number() pref.FieldNumber { return fd.L1.Number }
|
||||
func (fd *Field) Cardinality() pref.Cardinality { return fd.L1.Cardinality }
|
||||
func (fd *Field) Kind() pref.Kind { return fd.L1.Kind }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.JSONName.has }
|
||||
func (fd *Field) JSONName() string { return fd.L1.JSONName.get(fd) }
|
||||
func (fd *Field) HasJSONName() bool { return fd.L1.StringName.hasJSON }
|
||||
func (fd *Field) JSONName() string { return fd.L1.StringName.getJSON(fd) }
|
||||
func (fd *Field) TextName() string { return fd.L1.StringName.getText(fd) }
|
||||
func (fd *Field) HasPresence() bool {
|
||||
return fd.L1.Cardinality != pref.Repeated && (fd.L0.ParentFile.L1.Syntax == pref.Proto2 || fd.L1.Message != nil || fd.L1.ContainingOneof != nil)
|
||||
}
|
||||
@ -302,13 +296,13 @@ func (fd *Field) MapKey() pref.FieldDescriptor {
|
||||
if !fd.IsMap() {
|
||||
return nil
|
||||
}
|
||||
return fd.Message().Fields().ByNumber(1)
|
||||
return fd.Message().Fields().ByNumber(genid.MapEntry_Key_field_number)
|
||||
}
|
||||
func (fd *Field) MapValue() pref.FieldDescriptor {
|
||||
if !fd.IsMap() {
|
||||
return nil
|
||||
}
|
||||
return fd.Message().Fields().ByNumber(2)
|
||||
return fd.Message().Fields().ByNumber(genid.MapEntry_Value_field_number)
|
||||
}
|
||||
func (fd *Field) HasDefault() bool { return fd.L1.Default.has }
|
||||
func (fd *Field) Default() pref.Value { return fd.L1.Default.get(fd) }
|
||||
@ -372,7 +366,7 @@ type (
|
||||
}
|
||||
ExtensionL2 struct {
|
||||
Options func() pref.ProtoMessage
|
||||
JSONName jsonName
|
||||
StringName stringName
|
||||
IsProto3Optional bool // promoted from google.protobuf.FieldDescriptorProto
|
||||
IsPacked bool // promoted from google.protobuf.FieldOptions
|
||||
Default defaultValue
|
||||
@ -390,8 +384,9 @@ func (xd *Extension) Options() pref.ProtoMessage {
|
||||
func (xd *Extension) Number() pref.FieldNumber { return xd.L1.Number }
|
||||
func (xd *Extension) Cardinality() pref.Cardinality { return xd.L1.Cardinality }
|
||||
func (xd *Extension) Kind() pref.Kind { return xd.L1.Kind }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().JSONName.has }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().JSONName.get(xd) }
|
||||
func (xd *Extension) HasJSONName() bool { return xd.lazyInit().StringName.hasJSON }
|
||||
func (xd *Extension) JSONName() string { return xd.lazyInit().StringName.getJSON(xd) }
|
||||
func (xd *Extension) TextName() string { return xd.lazyInit().StringName.getText(xd) }
|
||||
func (xd *Extension) HasPresence() bool { return xd.L1.Cardinality != pref.Repeated }
|
||||
func (xd *Extension) HasOptionalKeyword() bool {
|
||||
return (xd.L0.ParentFile.L1.Syntax == pref.Proto2 && xd.L1.Cardinality == pref.Optional) || xd.lazyInit().IsProto3Optional
|
||||
@ -505,27 +500,50 @@ func (d *Base) Syntax() pref.Syntax { return d.L0.ParentFile.Syn
|
||||
func (d *Base) IsPlaceholder() bool { return false }
|
||||
func (d *Base) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
type jsonName struct {
|
||||
has bool
|
||||
once sync.Once
|
||||
name string
|
||||
type stringName struct {
|
||||
hasJSON bool
|
||||
once sync.Once
|
||||
nameJSON string
|
||||
nameText string
|
||||
}
|
||||
|
||||
// Init initializes the name. It is exported for use by other internal packages.
|
||||
func (js *jsonName) Init(s string) {
|
||||
js.has = true
|
||||
js.name = s
|
||||
// InitJSON initializes the name. It is exported for use by other internal packages.
|
||||
func (s *stringName) InitJSON(name string) {
|
||||
s.hasJSON = true
|
||||
s.nameJSON = name
|
||||
}
|
||||
|
||||
func (js *jsonName) get(fd pref.FieldDescriptor) string {
|
||||
if !js.has {
|
||||
js.once.Do(func() {
|
||||
js.name = strs.JSONCamelCase(string(fd.Name()))
|
||||
})
|
||||
}
|
||||
return js.name
|
||||
func (s *stringName) lazyInit(fd pref.FieldDescriptor) *stringName {
|
||||
s.once.Do(func() {
|
||||
if fd.IsExtension() {
|
||||
// For extensions, JSON and text are formatted the same way.
|
||||
var name string
|
||||
if messageset.IsMessageSetExtension(fd) {
|
||||
name = string("[" + fd.FullName().Parent() + "]")
|
||||
} else {
|
||||
name = string("[" + fd.FullName() + "]")
|
||||
}
|
||||
s.nameJSON = name
|
||||
s.nameText = name
|
||||
} else {
|
||||
// Format the JSON name.
|
||||
if !s.hasJSON {
|
||||
s.nameJSON = strs.JSONCamelCase(string(fd.Name()))
|
||||
}
|
||||
|
||||
// Format the text name.
|
||||
s.nameText = string(fd.Name())
|
||||
if fd.Kind() == pref.GroupKind {
|
||||
s.nameText = string(fd.Message().Name())
|
||||
}
|
||||
}
|
||||
})
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *stringName) getJSON(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameJSON }
|
||||
func (s *stringName) getText(fd pref.FieldDescriptor) string { return s.lazyInit(fd).nameText }
|
||||
|
||||
func DefaultValue(v pref.Value, ev pref.EnumValueDescriptor) defaultValue {
|
||||
dv := defaultValue{has: v.IsValid(), val: v, enum: ev}
|
||||
if b, ok := v.Interface().([]byte); ok {
|
||||
|
62
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
62
vendor/google.golang.org/protobuf/internal/filedesc/desc_init.go
generated
vendored
@ -8,7 +8,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
@ -107,7 +107,7 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_Syntax:
|
||||
case genid.FileDescriptorProto_Syntax_field_number:
|
||||
switch string(v) {
|
||||
case "proto2":
|
||||
fd.L1.Syntax = pref.Proto2
|
||||
@ -116,36 +116,36 @@ func (fd *File) unmarshalSeed(b []byte) {
|
||||
default:
|
||||
panic("invalid syntax")
|
||||
}
|
||||
case fieldnum.FileDescriptorProto_Name:
|
||||
case genid.FileDescriptorProto_Name_field_number:
|
||||
fd.L1.Path = sb.MakeString(v)
|
||||
case fieldnum.FileDescriptorProto_Package:
|
||||
case genid.FileDescriptorProto_Package_field_number:
|
||||
fd.L1.Package = pref.FullName(sb.MakeString(v))
|
||||
case fieldnum.FileDescriptorProto_EnumType:
|
||||
if prevField != fieldnum.FileDescriptorProto_EnumType {
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
if prevField != genid.FileDescriptorProto_EnumType_field_number {
|
||||
if numEnums > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posEnums = len(b0) - len(b) - n - m
|
||||
}
|
||||
numEnums++
|
||||
case fieldnum.FileDescriptorProto_MessageType:
|
||||
if prevField != fieldnum.FileDescriptorProto_MessageType {
|
||||
case genid.FileDescriptorProto_MessageType_field_number:
|
||||
if prevField != genid.FileDescriptorProto_MessageType_field_number {
|
||||
if numMessages > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posMessages = len(b0) - len(b) - n - m
|
||||
}
|
||||
numMessages++
|
||||
case fieldnum.FileDescriptorProto_Extension:
|
||||
if prevField != fieldnum.FileDescriptorProto_Extension {
|
||||
case genid.FileDescriptorProto_Extension_field_number:
|
||||
if prevField != genid.FileDescriptorProto_Extension_field_number {
|
||||
if numExtensions > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posExtensions = len(b0) - len(b) - n - m
|
||||
}
|
||||
numExtensions++
|
||||
case fieldnum.FileDescriptorProto_Service:
|
||||
if prevField != fieldnum.FileDescriptorProto_Service {
|
||||
case genid.FileDescriptorProto_Service_field_number:
|
||||
if prevField != genid.FileDescriptorProto_Service_field_number {
|
||||
if numServices > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
@ -233,9 +233,9 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Desc
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_Name:
|
||||
case genid.EnumDescriptorProto_Name_field_number:
|
||||
ed.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.EnumDescriptorProto_Value:
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
numValues++
|
||||
}
|
||||
default:
|
||||
@ -260,7 +260,7 @@ func (ed *Enum) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.Desc
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_Value:
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
ed.L2.Values.List[i].unmarshalFull(v, sb, pf, ed, i)
|
||||
i++
|
||||
}
|
||||
@ -288,33 +288,33 @@ func (md *Message) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.D
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_Name:
|
||||
case genid.DescriptorProto_Name_field_number:
|
||||
md.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.DescriptorProto_EnumType:
|
||||
if prevField != fieldnum.DescriptorProto_EnumType {
|
||||
case genid.DescriptorProto_EnumType_field_number:
|
||||
if prevField != genid.DescriptorProto_EnumType_field_number {
|
||||
if numEnums > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posEnums = len(b0) - len(b) - n - m
|
||||
}
|
||||
numEnums++
|
||||
case fieldnum.DescriptorProto_NestedType:
|
||||
if prevField != fieldnum.DescriptorProto_NestedType {
|
||||
case genid.DescriptorProto_NestedType_field_number:
|
||||
if prevField != genid.DescriptorProto_NestedType_field_number {
|
||||
if numMessages > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posMessages = len(b0) - len(b) - n - m
|
||||
}
|
||||
numMessages++
|
||||
case fieldnum.DescriptorProto_Extension:
|
||||
if prevField != fieldnum.DescriptorProto_Extension {
|
||||
case genid.DescriptorProto_Extension_field_number:
|
||||
if prevField != genid.DescriptorProto_Extension_field_number {
|
||||
if numExtensions > 0 {
|
||||
panic("non-contiguous repeated field")
|
||||
}
|
||||
posExtensions = len(b0) - len(b) - n - m
|
||||
}
|
||||
numExtensions++
|
||||
case fieldnum.DescriptorProto_Options:
|
||||
case genid.DescriptorProto_Options_field_number:
|
||||
md.unmarshalSeedOptions(v)
|
||||
}
|
||||
prevField = num
|
||||
@ -375,9 +375,9 @@ func (md *Message) unmarshalSeedOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MessageOptions_MapEntry:
|
||||
case genid.MessageOptions_MapEntry_field_number:
|
||||
md.L1.IsMapEntry = protowire.DecodeBool(v)
|
||||
case fieldnum.MessageOptions_MessageSetWireFormat:
|
||||
case genid.MessageOptions_MessageSetWireFormat_field_number:
|
||||
md.L1.IsMessageSet = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
@ -400,20 +400,20 @@ func (xd *Extension) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Number:
|
||||
case genid.FieldDescriptorProto_Number_field_number:
|
||||
xd.L1.Number = pref.FieldNumber(v)
|
||||
case fieldnum.FieldDescriptorProto_Label:
|
||||
case genid.FieldDescriptorProto_Label_field_number:
|
||||
xd.L1.Cardinality = pref.Cardinality(v)
|
||||
case fieldnum.FieldDescriptorProto_Type:
|
||||
case genid.FieldDescriptorProto_Type_field_number:
|
||||
xd.L1.Kind = pref.Kind(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Name:
|
||||
case genid.FieldDescriptorProto_Name_field_number:
|
||||
xd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.FieldDescriptorProto_Extendee:
|
||||
case genid.FieldDescriptorProto_Extendee_field_number:
|
||||
xd.L1.Extendee = PlaceholderMessage(makeFullName(sb, v))
|
||||
}
|
||||
default:
|
||||
@ -436,7 +436,7 @@ func (sd *Service) unmarshalSeed(b []byte, sb *strs.Builder, pf *File, pd pref.D
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.ServiceDescriptorProto_Name:
|
||||
case genid.ServiceDescriptorProto_Name_field_number:
|
||||
sd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
}
|
||||
default:
|
||||
|
128
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
128
vendor/google.golang.org/protobuf/internal/filedesc/desc_lazy.go
generated
vendored
@ -10,7 +10,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/descopts"
|
||||
"google.golang.org/protobuf/internal/fieldnum"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/internal/strs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
@ -143,35 +143,35 @@ func (fd *File) unmarshalFull(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_PublicDependency:
|
||||
case genid.FileDescriptorProto_PublicDependency_field_number:
|
||||
fd.L2.Imports[v].IsPublic = true
|
||||
case fieldnum.FileDescriptorProto_WeakDependency:
|
||||
case genid.FileDescriptorProto_WeakDependency_field_number:
|
||||
fd.L2.Imports[v].IsWeak = true
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FileDescriptorProto_Dependency:
|
||||
case genid.FileDescriptorProto_Dependency_field_number:
|
||||
path := sb.MakeString(v)
|
||||
imp, _ := fd.builder.FileRegistry.FindFileByPath(path)
|
||||
if imp == nil {
|
||||
imp = PlaceholderFile(path)
|
||||
}
|
||||
fd.L2.Imports = append(fd.L2.Imports, pref.FileImport{FileDescriptor: imp})
|
||||
case fieldnum.FileDescriptorProto_EnumType:
|
||||
case genid.FileDescriptorProto_EnumType_field_number:
|
||||
fd.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
|
||||
enumIdx++
|
||||
case fieldnum.FileDescriptorProto_MessageType:
|
||||
case genid.FileDescriptorProto_MessageType_field_number:
|
||||
fd.L1.Messages.List[messageIdx].unmarshalFull(v, sb)
|
||||
messageIdx++
|
||||
case fieldnum.FileDescriptorProto_Extension:
|
||||
case genid.FileDescriptorProto_Extension_field_number:
|
||||
fd.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
|
||||
extensionIdx++
|
||||
case fieldnum.FileDescriptorProto_Service:
|
||||
case genid.FileDescriptorProto_Service_field_number:
|
||||
fd.L1.Services.List[serviceIdx].unmarshalFull(v, sb)
|
||||
serviceIdx++
|
||||
case fieldnum.FileDescriptorProto_Options:
|
||||
case genid.FileDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@ -196,13 +196,13 @@ func (ed *Enum) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_Value:
|
||||
case genid.EnumDescriptorProto_Value_field_number:
|
||||
rawValues = append(rawValues, v)
|
||||
case fieldnum.EnumDescriptorProto_ReservedName:
|
||||
case genid.EnumDescriptorProto_ReservedName_field_number:
|
||||
ed.L2.ReservedNames.List = append(ed.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
|
||||
case fieldnum.EnumDescriptorProto_ReservedRange:
|
||||
case genid.EnumDescriptorProto_ReservedRange_field_number:
|
||||
ed.L2.ReservedRanges.List = append(ed.L2.ReservedRanges.List, unmarshalEnumReservedRange(v))
|
||||
case fieldnum.EnumDescriptorProto_Options:
|
||||
case genid.EnumDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@ -228,9 +228,9 @@ func unmarshalEnumReservedRange(b []byte) (r [2]pref.EnumNumber) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumDescriptorProto_EnumReservedRange_Start:
|
||||
case genid.EnumDescriptorProto_EnumReservedRange_Start_field_number:
|
||||
r[0] = pref.EnumNumber(v)
|
||||
case fieldnum.EnumDescriptorProto_EnumReservedRange_End:
|
||||
case genid.EnumDescriptorProto_EnumReservedRange_End_field_number:
|
||||
r[1] = pref.EnumNumber(v)
|
||||
}
|
||||
default:
|
||||
@ -255,17 +255,17 @@ func (vd *EnumValue) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumValueDescriptorProto_Number:
|
||||
case genid.EnumValueDescriptorProto_Number_field_number:
|
||||
vd.L1.Number = pref.EnumNumber(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.EnumValueDescriptorProto_Name:
|
||||
case genid.EnumValueDescriptorProto_Name_field_number:
|
||||
// NOTE: Enum values are in the same scope as the enum parent.
|
||||
vd.L0.FullName = appendFullName(sb, pd.Parent().FullName(), v)
|
||||
case fieldnum.EnumValueDescriptorProto_Options:
|
||||
case genid.EnumValueDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@ -289,29 +289,29 @@ func (md *Message) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_Field:
|
||||
case genid.DescriptorProto_Field_field_number:
|
||||
rawFields = append(rawFields, v)
|
||||
case fieldnum.DescriptorProto_OneofDecl:
|
||||
case genid.DescriptorProto_OneofDecl_field_number:
|
||||
rawOneofs = append(rawOneofs, v)
|
||||
case fieldnum.DescriptorProto_ReservedName:
|
||||
case genid.DescriptorProto_ReservedName_field_number:
|
||||
md.L2.ReservedNames.List = append(md.L2.ReservedNames.List, pref.Name(sb.MakeString(v)))
|
||||
case fieldnum.DescriptorProto_ReservedRange:
|
||||
case genid.DescriptorProto_ReservedRange_field_number:
|
||||
md.L2.ReservedRanges.List = append(md.L2.ReservedRanges.List, unmarshalMessageReservedRange(v))
|
||||
case fieldnum.DescriptorProto_ExtensionRange:
|
||||
case genid.DescriptorProto_ExtensionRange_field_number:
|
||||
r, rawOptions := unmarshalMessageExtensionRange(v)
|
||||
opts := md.L0.ParentFile.builder.optionsUnmarshaler(&descopts.ExtensionRange, rawOptions)
|
||||
md.L2.ExtensionRanges.List = append(md.L2.ExtensionRanges.List, r)
|
||||
md.L2.ExtensionRangeOptions = append(md.L2.ExtensionRangeOptions, opts)
|
||||
case fieldnum.DescriptorProto_EnumType:
|
||||
case genid.DescriptorProto_EnumType_field_number:
|
||||
md.L1.Enums.List[enumIdx].unmarshalFull(v, sb)
|
||||
enumIdx++
|
||||
case fieldnum.DescriptorProto_NestedType:
|
||||
case genid.DescriptorProto_NestedType_field_number:
|
||||
md.L1.Messages.List[messageIdx].unmarshalFull(v, sb)
|
||||
messageIdx++
|
||||
case fieldnum.DescriptorProto_Extension:
|
||||
case genid.DescriptorProto_Extension_field_number:
|
||||
md.L1.Extensions.List[extensionIdx].unmarshalFull(v, sb)
|
||||
extensionIdx++
|
||||
case fieldnum.DescriptorProto_Options:
|
||||
case genid.DescriptorProto_Options_field_number:
|
||||
md.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
@ -347,9 +347,9 @@ func (md *Message) unmarshalOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MessageOptions_MapEntry:
|
||||
case genid.MessageOptions_MapEntry_field_number:
|
||||
md.L1.IsMapEntry = protowire.DecodeBool(v)
|
||||
case fieldnum.MessageOptions_MessageSetWireFormat:
|
||||
case genid.MessageOptions_MessageSetWireFormat_field_number:
|
||||
md.L1.IsMessageSet = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
@ -368,9 +368,9 @@ func unmarshalMessageReservedRange(b []byte) (r [2]pref.FieldNumber) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_ReservedRange_Start:
|
||||
case genid.DescriptorProto_ReservedRange_Start_field_number:
|
||||
r[0] = pref.FieldNumber(v)
|
||||
case fieldnum.DescriptorProto_ReservedRange_End:
|
||||
case genid.DescriptorProto_ReservedRange_End_field_number:
|
||||
r[1] = pref.FieldNumber(v)
|
||||
}
|
||||
default:
|
||||
@ -390,16 +390,16 @@ func unmarshalMessageExtensionRange(b []byte) (r [2]pref.FieldNumber, rawOptions
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_ExtensionRange_Start:
|
||||
case genid.DescriptorProto_ExtensionRange_Start_field_number:
|
||||
r[0] = pref.FieldNumber(v)
|
||||
case fieldnum.DescriptorProto_ExtensionRange_End:
|
||||
case genid.DescriptorProto_ExtensionRange_End_field_number:
|
||||
r[1] = pref.FieldNumber(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.DescriptorProto_ExtensionRange_Options:
|
||||
case genid.DescriptorProto_ExtensionRange_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@ -425,13 +425,13 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Number:
|
||||
case genid.FieldDescriptorProto_Number_field_number:
|
||||
fd.L1.Number = pref.FieldNumber(v)
|
||||
case fieldnum.FieldDescriptorProto_Label:
|
||||
case genid.FieldDescriptorProto_Label_field_number:
|
||||
fd.L1.Cardinality = pref.Cardinality(v)
|
||||
case fieldnum.FieldDescriptorProto_Type:
|
||||
case genid.FieldDescriptorProto_Type_field_number:
|
||||
fd.L1.Kind = pref.Kind(v)
|
||||
case fieldnum.FieldDescriptorProto_OneofIndex:
|
||||
case genid.FieldDescriptorProto_OneofIndex_field_number:
|
||||
// In Message.unmarshalFull, we allocate slices for both
|
||||
// the field and oneof descriptors before unmarshaling either
|
||||
// of them. This ensures pointers to slice elements are stable.
|
||||
@ -441,22 +441,22 @@ func (fd *Field) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
panic("oneof type already set")
|
||||
}
|
||||
fd.L1.ContainingOneof = od
|
||||
case fieldnum.FieldDescriptorProto_Proto3Optional:
|
||||
case genid.FieldDescriptorProto_Proto3Optional_field_number:
|
||||
fd.L1.IsProto3Optional = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Name:
|
||||
case genid.FieldDescriptorProto_Name_field_number:
|
||||
fd.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.FieldDescriptorProto_JsonName:
|
||||
fd.L1.JSONName.Init(sb.MakeString(v))
|
||||
case fieldnum.FieldDescriptorProto_DefaultValue:
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
fd.L1.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
fd.L1.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveMessages
|
||||
case fieldnum.FieldDescriptorProto_TypeName:
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case fieldnum.FieldDescriptorProto_Options:
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
fd.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
@ -488,10 +488,10 @@ func (fd *Field) unmarshalOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldOptions_Packed:
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
fd.L1.HasPacked = true
|
||||
fd.L1.IsPacked = protowire.DecodeBool(v)
|
||||
case fieldnum.FieldOptions_Weak:
|
||||
case genid.FieldOptions_Weak_field_number:
|
||||
fd.L1.IsWeak = protowire.DecodeBool(v)
|
||||
case FieldOptions_EnforceUTF8:
|
||||
fd.L1.HasEnforceUTF8 = true
|
||||
@ -518,9 +518,9 @@ func (od *Oneof) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.Des
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.OneofDescriptorProto_Name:
|
||||
case genid.OneofDescriptorProto_Name_field_number:
|
||||
od.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.OneofDescriptorProto_Options:
|
||||
case genid.OneofDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@ -543,20 +543,20 @@ func (xd *Extension) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_Proto3Optional:
|
||||
case genid.FieldDescriptorProto_Proto3Optional_field_number:
|
||||
xd.L2.IsProto3Optional = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldDescriptorProto_JsonName:
|
||||
xd.L2.JSONName.Init(sb.MakeString(v))
|
||||
case fieldnum.FieldDescriptorProto_DefaultValue:
|
||||
case genid.FieldDescriptorProto_JsonName_field_number:
|
||||
xd.L2.StringName.InitJSON(sb.MakeString(v))
|
||||
case genid.FieldDescriptorProto_DefaultValue_field_number:
|
||||
xd.L2.Default.val = pref.ValueOfBytes(v) // temporarily store as bytes; later resolved in resolveExtensions
|
||||
case fieldnum.FieldDescriptorProto_TypeName:
|
||||
case genid.FieldDescriptorProto_TypeName_field_number:
|
||||
rawTypeName = v
|
||||
case fieldnum.FieldDescriptorProto_Options:
|
||||
case genid.FieldDescriptorProto_Options_field_number:
|
||||
xd.unmarshalOptions(v)
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
@ -586,7 +586,7 @@ func (xd *Extension) unmarshalOptions(b []byte) {
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.FieldOptions_Packed:
|
||||
case genid.FieldOptions_Packed_field_number:
|
||||
xd.L2.IsPacked = protowire.DecodeBool(v)
|
||||
}
|
||||
default:
|
||||
@ -608,9 +608,9 @@ func (sd *Service) unmarshalFull(b []byte, sb *strs.Builder) {
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.ServiceDescriptorProto_Method:
|
||||
case genid.ServiceDescriptorProto_Method_field_number:
|
||||
rawMethods = append(rawMethods, v)
|
||||
case fieldnum.ServiceDescriptorProto_Options:
|
||||
case genid.ServiceDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
@ -641,22 +641,22 @@ func (md *Method) unmarshalFull(b []byte, sb *strs.Builder, pf *File, pd pref.De
|
||||
v, m := protowire.ConsumeVarint(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MethodDescriptorProto_ClientStreaming:
|
||||
case genid.MethodDescriptorProto_ClientStreaming_field_number:
|
||||
md.L1.IsStreamingClient = protowire.DecodeBool(v)
|
||||
case fieldnum.MethodDescriptorProto_ServerStreaming:
|
||||
case genid.MethodDescriptorProto_ServerStreaming_field_number:
|
||||
md.L1.IsStreamingServer = protowire.DecodeBool(v)
|
||||
}
|
||||
case protowire.BytesType:
|
||||
v, m := protowire.ConsumeBytes(b)
|
||||
b = b[m:]
|
||||
switch num {
|
||||
case fieldnum.MethodDescriptorProto_Name:
|
||||
case genid.MethodDescriptorProto_Name_field_number:
|
||||
md.L0.FullName = appendFullName(sb, pd.FullName(), v)
|
||||
case fieldnum.MethodDescriptorProto_InputType:
|
||||
case genid.MethodDescriptorProto_InputType_field_number:
|
||||
md.L1.Input = PlaceholderMessage(makeFullName(sb, v))
|
||||
case fieldnum.MethodDescriptorProto_OutputType:
|
||||
case genid.MethodDescriptorProto_OutputType_field_number:
|
||||
md.L1.Output = PlaceholderMessage(makeFullName(sb, v))
|
||||
case fieldnum.MethodDescriptorProto_Options:
|
||||
case genid.MethodDescriptorProto_Options_field_number:
|
||||
rawOptions = appendOptions(rawOptions, v)
|
||||
}
|
||||
default:
|
||||
|
176
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
176
vendor/google.golang.org/protobuf/internal/filedesc/desc_list.go
generated
vendored
@ -10,6 +10,8 @@ import (
|
||||
"sort"
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/descfmt"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
@ -185,10 +187,7 @@ func (p *FieldRanges) CheckValid(isMessageSet bool) error {
|
||||
// Unlike the FieldNumber.IsValid method, it allows ranges that cover the
|
||||
// reserved number range.
|
||||
func isValidFieldNumber(n protoreflect.FieldNumber, isMessageSet bool) bool {
|
||||
if isMessageSet {
|
||||
return protowire.MinValidNumber <= n && n <= math.MaxInt32
|
||||
}
|
||||
return protowire.MinValidNumber <= n && n <= protowire.MaxValidNumber
|
||||
return protowire.MinValidNumber <= n && (n <= protowire.MaxValidNumber || isMessageSet)
|
||||
}
|
||||
|
||||
// CheckOverlap reports an error if p and q overlap.
|
||||
@ -249,6 +248,7 @@ type OneofFields struct {
|
||||
once sync.Once
|
||||
byName map[pref.Name]pref.FieldDescriptor // protected by once
|
||||
byJSON map[string]pref.FieldDescriptor // protected by once
|
||||
byText map[string]pref.FieldDescriptor // protected by once
|
||||
byNum map[pref.FieldNumber]pref.FieldDescriptor // protected by once
|
||||
}
|
||||
|
||||
@ -256,6 +256,7 @@ func (p *OneofFields) Len() int { return
|
||||
func (p *OneofFields) Get(i int) pref.FieldDescriptor { return p.List[i] }
|
||||
func (p *OneofFields) ByName(s pref.Name) pref.FieldDescriptor { return p.lazyInit().byName[s] }
|
||||
func (p *OneofFields) ByJSONName(s string) pref.FieldDescriptor { return p.lazyInit().byJSON[s] }
|
||||
func (p *OneofFields) ByTextName(s string) pref.FieldDescriptor { return p.lazyInit().byText[s] }
|
||||
func (p *OneofFields) ByNumber(n pref.FieldNumber) pref.FieldDescriptor { return p.lazyInit().byNum[n] }
|
||||
func (p *OneofFields) Format(s fmt.State, r rune) { descfmt.FormatList(s, r, p) }
|
||||
func (p *OneofFields) ProtoInternal(pragma.DoNotImplement) {}
|
||||
@ -265,11 +266,13 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[pref.Name]pref.FieldDescriptor, len(p.List))
|
||||
p.byJSON = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byText = make(map[string]pref.FieldDescriptor, len(p.List))
|
||||
p.byNum = make(map[pref.FieldNumber]pref.FieldDescriptor, len(p.List))
|
||||
for _, f := range p.List {
|
||||
// Field names and numbers are guaranteed to be unique.
|
||||
p.byName[f.Name()] = f
|
||||
p.byJSON[f.JSONName()] = f
|
||||
p.byText[f.TextName()] = f
|
||||
p.byNum[f.Number()] = f
|
||||
}
|
||||
}
|
||||
@ -278,9 +281,170 @@ func (p *OneofFields) lazyInit() *OneofFields {
|
||||
}
|
||||
|
||||
type SourceLocations struct {
|
||||
// List is a list of SourceLocations.
|
||||
// The SourceLocation.Next field does not need to be populated
|
||||
// as it will be lazily populated upon first need.
|
||||
List []pref.SourceLocation
|
||||
|
||||
// File is the parent file descriptor that these locations are relative to.
|
||||
// If non-nil, ByDescriptor verifies that the provided descriptor
|
||||
// is a child of this file descriptor.
|
||||
File pref.FileDescriptor
|
||||
|
||||
once sync.Once
|
||||
byPath map[pathKey]int
|
||||
}
|
||||
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.List[i] }
|
||||
func (p *SourceLocations) Len() int { return len(p.List) }
|
||||
func (p *SourceLocations) Get(i int) pref.SourceLocation { return p.lazyInit().List[i] }
|
||||
func (p *SourceLocations) byKey(k pathKey) pref.SourceLocation {
|
||||
if i, ok := p.lazyInit().byPath[k]; ok {
|
||||
return p.List[i]
|
||||
}
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
func (p *SourceLocations) ByPath(path pref.SourcePath) pref.SourceLocation {
|
||||
return p.byKey(newPathKey(path))
|
||||
}
|
||||
func (p *SourceLocations) ByDescriptor(desc pref.Descriptor) pref.SourceLocation {
|
||||
if p.File != nil && desc != nil && p.File != desc.ParentFile() {
|
||||
return pref.SourceLocation{} // mismatching parent files
|
||||
}
|
||||
var pathArr [16]int32
|
||||
path := pathArr[:0]
|
||||
for {
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
// Reverse the path since it was constructed in reverse.
|
||||
for i, j := 0, len(path)-1; i < j; i, j = i+1, j-1 {
|
||||
path[i], path[j] = path[j], path[i]
|
||||
}
|
||||
return p.byKey(newPathKey(path))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_MessageType_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_NestedType_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.FieldDescriptor:
|
||||
isExtension := desc.(pref.FieldDescriptor).IsExtension()
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
if isExtension {
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Extension_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Extension_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
} else {
|
||||
switch desc.(type) {
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_Field_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
case pref.OneofDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_OneofDecl_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_EnumType_field_number))
|
||||
case pref.MessageDescriptor:
|
||||
path = append(path, int32(genid.DescriptorProto_EnumType_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.EnumValueDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.EnumDescriptor:
|
||||
path = append(path, int32(genid.EnumDescriptorProto_Value_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.FileDescriptor:
|
||||
path = append(path, int32(genid.FileDescriptorProto_Service_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
case pref.MethodDescriptor:
|
||||
path = append(path, int32(desc.Index()))
|
||||
desc = desc.Parent()
|
||||
switch desc.(type) {
|
||||
case pref.ServiceDescriptor:
|
||||
path = append(path, int32(genid.ServiceDescriptorProto_Method_field_number))
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
default:
|
||||
return pref.SourceLocation{}
|
||||
}
|
||||
}
|
||||
}
|
||||
func (p *SourceLocations) lazyInit() *SourceLocations {
|
||||
p.once.Do(func() {
|
||||
if len(p.List) > 0 {
|
||||
// Collect all the indexes for a given path.
|
||||
pathIdxs := make(map[pathKey][]int, len(p.List))
|
||||
for i, l := range p.List {
|
||||
k := newPathKey(l.Path)
|
||||
pathIdxs[k] = append(pathIdxs[k], i)
|
||||
}
|
||||
|
||||
// Update the next index for all locations.
|
||||
p.byPath = make(map[pathKey]int, len(p.List))
|
||||
for k, idxs := range pathIdxs {
|
||||
for i := 0; i < len(idxs)-1; i++ {
|
||||
p.List[idxs[i]].Next = idxs[i+1]
|
||||
}
|
||||
p.List[idxs[len(idxs)-1]].Next = 0
|
||||
p.byPath[k] = idxs[0] // record the first location for this path
|
||||
}
|
||||
}
|
||||
})
|
||||
return p
|
||||
}
|
||||
func (p *SourceLocations) ProtoInternal(pragma.DoNotImplement) {}
|
||||
|
||||
// pathKey is a comparable representation of protoreflect.SourcePath.
|
||||
type pathKey struct {
|
||||
arr [16]uint8 // first n-1 path segments; last element is the length
|
||||
str string // used if the path does not fit in arr
|
||||
}
|
||||
|
||||
func newPathKey(p pref.SourcePath) (k pathKey) {
|
||||
if len(p) < len(k.arr) {
|
||||
for i, ps := range p {
|
||||
if ps < 0 || math.MaxUint8 <= ps {
|
||||
return pathKey{str: p.String()}
|
||||
}
|
||||
k.arr[i] = uint8(ps)
|
||||
}
|
||||
k.arr[len(k.arr)-1] = uint8(len(p))
|
||||
return k
|
||||
}
|
||||
return pathKey{str: p.String()}
|
||||
}
|
||||
|
11
vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go
generated
vendored
11
vendor/google.golang.org/protobuf/internal/filedesc/desc_list_gen.go
generated
vendored
@ -142,6 +142,7 @@ type Fields struct {
|
||||
once sync.Once
|
||||
byName map[protoreflect.Name]*Field // protected by once
|
||||
byJSON map[string]*Field // protected by once
|
||||
byText map[string]*Field // protected by once
|
||||
byNum map[protoreflect.FieldNumber]*Field // protected by once
|
||||
}
|
||||
|
||||
@ -163,6 +164,12 @@ func (p *Fields) ByJSONName(s string) protoreflect.FieldDescriptor {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *Fields) ByTextName(s string) protoreflect.FieldDescriptor {
|
||||
if d := p.lazyInit().byText[s]; d != nil {
|
||||
return d
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *Fields) ByNumber(n protoreflect.FieldNumber) protoreflect.FieldDescriptor {
|
||||
if d := p.lazyInit().byNum[n]; d != nil {
|
||||
return d
|
||||
@ -178,6 +185,7 @@ func (p *Fields) lazyInit() *Fields {
|
||||
if len(p.List) > 0 {
|
||||
p.byName = make(map[protoreflect.Name]*Field, len(p.List))
|
||||
p.byJSON = make(map[string]*Field, len(p.List))
|
||||
p.byText = make(map[string]*Field, len(p.List))
|
||||
p.byNum = make(map[protoreflect.FieldNumber]*Field, len(p.List))
|
||||
for i := range p.List {
|
||||
d := &p.List[i]
|
||||
@ -187,6 +195,9 @@ func (p *Fields) lazyInit() *Fields {
|
||||
if _, ok := p.byJSON[d.JSONName()]; !ok {
|
||||
p.byJSON[d.JSONName()] = d
|
||||
}
|
||||
if _, ok := p.byText[d.TextName()]; !ok {
|
||||
p.byText[d.TextName()] = d
|
||||
}
|
||||
if _, ok := p.byNum[d.Number()]; !ok {
|
||||
p.byNum[d.Number()] = d
|
||||
}
|
||||
|
34
vendor/google.golang.org/protobuf/internal/genid/any_gen.go
generated
vendored
Normal file
34
vendor/google.golang.org/protobuf/internal/genid/any_gen.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_any_proto = "google/protobuf/any.proto"
|
||||
|
||||
// Names for google.protobuf.Any.
|
||||
const (
|
||||
Any_message_name protoreflect.Name = "Any"
|
||||
Any_message_fullname protoreflect.FullName = "google.protobuf.Any"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Any.
|
||||
const (
|
||||
Any_TypeUrl_field_name protoreflect.Name = "type_url"
|
||||
Any_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
Any_TypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Any.type_url"
|
||||
Any_Value_field_fullname protoreflect.FullName = "google.protobuf.Any.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Any.
|
||||
const (
|
||||
Any_TypeUrl_field_number protoreflect.FieldNumber = 1
|
||||
Any_Value_field_number protoreflect.FieldNumber = 2
|
||||
)
|
106
vendor/google.golang.org/protobuf/internal/genid/api_gen.go
generated
vendored
Normal file
106
vendor/google.golang.org/protobuf/internal/genid/api_gen.go
generated
vendored
Normal file
@ -0,0 +1,106 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_api_proto = "google/protobuf/api.proto"
|
||||
|
||||
// Names for google.protobuf.Api.
|
||||
const (
|
||||
Api_message_name protoreflect.Name = "Api"
|
||||
Api_message_fullname protoreflect.FullName = "google.protobuf.Api"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Api.
|
||||
const (
|
||||
Api_Name_field_name protoreflect.Name = "name"
|
||||
Api_Methods_field_name protoreflect.Name = "methods"
|
||||
Api_Options_field_name protoreflect.Name = "options"
|
||||
Api_Version_field_name protoreflect.Name = "version"
|
||||
Api_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Api_Mixins_field_name protoreflect.Name = "mixins"
|
||||
Api_Syntax_field_name protoreflect.Name = "syntax"
|
||||
|
||||
Api_Name_field_fullname protoreflect.FullName = "google.protobuf.Api.name"
|
||||
Api_Methods_field_fullname protoreflect.FullName = "google.protobuf.Api.methods"
|
||||
Api_Options_field_fullname protoreflect.FullName = "google.protobuf.Api.options"
|
||||
Api_Version_field_fullname protoreflect.FullName = "google.protobuf.Api.version"
|
||||
Api_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Api.source_context"
|
||||
Api_Mixins_field_fullname protoreflect.FullName = "google.protobuf.Api.mixins"
|
||||
Api_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Api.syntax"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Api.
|
||||
const (
|
||||
Api_Name_field_number protoreflect.FieldNumber = 1
|
||||
Api_Methods_field_number protoreflect.FieldNumber = 2
|
||||
Api_Options_field_number protoreflect.FieldNumber = 3
|
||||
Api_Version_field_number protoreflect.FieldNumber = 4
|
||||
Api_SourceContext_field_number protoreflect.FieldNumber = 5
|
||||
Api_Mixins_field_number protoreflect.FieldNumber = 6
|
||||
Api_Syntax_field_number protoreflect.FieldNumber = 7
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Method.
|
||||
const (
|
||||
Method_message_name protoreflect.Name = "Method"
|
||||
Method_message_fullname protoreflect.FullName = "google.protobuf.Method"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Method.
|
||||
const (
|
||||
Method_Name_field_name protoreflect.Name = "name"
|
||||
Method_RequestTypeUrl_field_name protoreflect.Name = "request_type_url"
|
||||
Method_RequestStreaming_field_name protoreflect.Name = "request_streaming"
|
||||
Method_ResponseTypeUrl_field_name protoreflect.Name = "response_type_url"
|
||||
Method_ResponseStreaming_field_name protoreflect.Name = "response_streaming"
|
||||
Method_Options_field_name protoreflect.Name = "options"
|
||||
Method_Syntax_field_name protoreflect.Name = "syntax"
|
||||
|
||||
Method_Name_field_fullname protoreflect.FullName = "google.protobuf.Method.name"
|
||||
Method_RequestTypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Method.request_type_url"
|
||||
Method_RequestStreaming_field_fullname protoreflect.FullName = "google.protobuf.Method.request_streaming"
|
||||
Method_ResponseTypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Method.response_type_url"
|
||||
Method_ResponseStreaming_field_fullname protoreflect.FullName = "google.protobuf.Method.response_streaming"
|
||||
Method_Options_field_fullname protoreflect.FullName = "google.protobuf.Method.options"
|
||||
Method_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Method.syntax"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Method.
|
||||
const (
|
||||
Method_Name_field_number protoreflect.FieldNumber = 1
|
||||
Method_RequestTypeUrl_field_number protoreflect.FieldNumber = 2
|
||||
Method_RequestStreaming_field_number protoreflect.FieldNumber = 3
|
||||
Method_ResponseTypeUrl_field_number protoreflect.FieldNumber = 4
|
||||
Method_ResponseStreaming_field_number protoreflect.FieldNumber = 5
|
||||
Method_Options_field_number protoreflect.FieldNumber = 6
|
||||
Method_Syntax_field_number protoreflect.FieldNumber = 7
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Mixin.
|
||||
const (
|
||||
Mixin_message_name protoreflect.Name = "Mixin"
|
||||
Mixin_message_fullname protoreflect.FullName = "google.protobuf.Mixin"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Mixin.
|
||||
const (
|
||||
Mixin_Name_field_name protoreflect.Name = "name"
|
||||
Mixin_Root_field_name protoreflect.Name = "root"
|
||||
|
||||
Mixin_Name_field_fullname protoreflect.FullName = "google.protobuf.Mixin.name"
|
||||
Mixin_Root_field_fullname protoreflect.FullName = "google.protobuf.Mixin.root"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Mixin.
|
||||
const (
|
||||
Mixin_Name_field_number protoreflect.FieldNumber = 1
|
||||
Mixin_Root_field_number protoreflect.FieldNumber = 2
|
||||
)
|
829
vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go
generated
vendored
Normal file
829
vendor/google.golang.org/protobuf/internal/genid/descriptor_gen.go
generated
vendored
Normal file
@ -0,0 +1,829 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_descriptor_proto = "google/protobuf/descriptor.proto"
|
||||
|
||||
// Names for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_message_name protoreflect.Name = "FileDescriptorSet"
|
||||
FileDescriptorSet_message_fullname protoreflect.FullName = "google.protobuf.FileDescriptorSet"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_File_field_name protoreflect.Name = "file"
|
||||
|
||||
FileDescriptorSet_File_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorSet.file"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FileDescriptorSet.
|
||||
const (
|
||||
FileDescriptorSet_File_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FileDescriptorProto.
|
||||
const (
|
||||
FileDescriptorProto_message_name protoreflect.Name = "FileDescriptorProto"
|
||||
FileDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FileDescriptorProto.
|
||||
const (
|
||||
FileDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
FileDescriptorProto_Package_field_name protoreflect.Name = "package"
|
||||
FileDescriptorProto_Dependency_field_name protoreflect.Name = "dependency"
|
||||
FileDescriptorProto_PublicDependency_field_name protoreflect.Name = "public_dependency"
|
||||
FileDescriptorProto_WeakDependency_field_name protoreflect.Name = "weak_dependency"
|
||||
FileDescriptorProto_MessageType_field_name protoreflect.Name = "message_type"
|
||||
FileDescriptorProto_EnumType_field_name protoreflect.Name = "enum_type"
|
||||
FileDescriptorProto_Service_field_name protoreflect.Name = "service"
|
||||
FileDescriptorProto_Extension_field_name protoreflect.Name = "extension"
|
||||
FileDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
FileDescriptorProto_SourceCodeInfo_field_name protoreflect.Name = "source_code_info"
|
||||
FileDescriptorProto_Syntax_field_name protoreflect.Name = "syntax"
|
||||
|
||||
FileDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.name"
|
||||
FileDescriptorProto_Package_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.package"
|
||||
FileDescriptorProto_Dependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.dependency"
|
||||
FileDescriptorProto_PublicDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.public_dependency"
|
||||
FileDescriptorProto_WeakDependency_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.weak_dependency"
|
||||
FileDescriptorProto_MessageType_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.message_type"
|
||||
FileDescriptorProto_EnumType_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.enum_type"
|
||||
FileDescriptorProto_Service_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.service"
|
||||
FileDescriptorProto_Extension_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.extension"
|
||||
FileDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.options"
|
||||
FileDescriptorProto_SourceCodeInfo_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.source_code_info"
|
||||
FileDescriptorProto_Syntax_field_fullname protoreflect.FullName = "google.protobuf.FileDescriptorProto.syntax"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FileDescriptorProto.
|
||||
const (
|
||||
FileDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
FileDescriptorProto_Package_field_number protoreflect.FieldNumber = 2
|
||||
FileDescriptorProto_Dependency_field_number protoreflect.FieldNumber = 3
|
||||
FileDescriptorProto_PublicDependency_field_number protoreflect.FieldNumber = 10
|
||||
FileDescriptorProto_WeakDependency_field_number protoreflect.FieldNumber = 11
|
||||
FileDescriptorProto_MessageType_field_number protoreflect.FieldNumber = 4
|
||||
FileDescriptorProto_EnumType_field_number protoreflect.FieldNumber = 5
|
||||
FileDescriptorProto_Service_field_number protoreflect.FieldNumber = 6
|
||||
FileDescriptorProto_Extension_field_number protoreflect.FieldNumber = 7
|
||||
FileDescriptorProto_Options_field_number protoreflect.FieldNumber = 8
|
||||
FileDescriptorProto_SourceCodeInfo_field_number protoreflect.FieldNumber = 9
|
||||
FileDescriptorProto_Syntax_field_number protoreflect.FieldNumber = 12
|
||||
)
|
||||
|
||||
// Names for google.protobuf.DescriptorProto.
|
||||
const (
|
||||
DescriptorProto_message_name protoreflect.Name = "DescriptorProto"
|
||||
DescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.DescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.DescriptorProto.
|
||||
const (
|
||||
DescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
DescriptorProto_Field_field_name protoreflect.Name = "field"
|
||||
DescriptorProto_Extension_field_name protoreflect.Name = "extension"
|
||||
DescriptorProto_NestedType_field_name protoreflect.Name = "nested_type"
|
||||
DescriptorProto_EnumType_field_name protoreflect.Name = "enum_type"
|
||||
DescriptorProto_ExtensionRange_field_name protoreflect.Name = "extension_range"
|
||||
DescriptorProto_OneofDecl_field_name protoreflect.Name = "oneof_decl"
|
||||
DescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
DescriptorProto_ReservedRange_field_name protoreflect.Name = "reserved_range"
|
||||
DescriptorProto_ReservedName_field_name protoreflect.Name = "reserved_name"
|
||||
|
||||
DescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.name"
|
||||
DescriptorProto_Field_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.field"
|
||||
DescriptorProto_Extension_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.extension"
|
||||
DescriptorProto_NestedType_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.nested_type"
|
||||
DescriptorProto_EnumType_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.enum_type"
|
||||
DescriptorProto_ExtensionRange_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.extension_range"
|
||||
DescriptorProto_OneofDecl_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.oneof_decl"
|
||||
DescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.options"
|
||||
DescriptorProto_ReservedRange_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.reserved_range"
|
||||
DescriptorProto_ReservedName_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.reserved_name"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.
|
||||
const (
|
||||
DescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
DescriptorProto_Field_field_number protoreflect.FieldNumber = 2
|
||||
DescriptorProto_Extension_field_number protoreflect.FieldNumber = 6
|
||||
DescriptorProto_NestedType_field_number protoreflect.FieldNumber = 3
|
||||
DescriptorProto_EnumType_field_number protoreflect.FieldNumber = 4
|
||||
DescriptorProto_ExtensionRange_field_number protoreflect.FieldNumber = 5
|
||||
DescriptorProto_OneofDecl_field_number protoreflect.FieldNumber = 8
|
||||
DescriptorProto_Options_field_number protoreflect.FieldNumber = 7
|
||||
DescriptorProto_ReservedRange_field_number protoreflect.FieldNumber = 9
|
||||
DescriptorProto_ReservedName_field_number protoreflect.FieldNumber = 10
|
||||
)
|
||||
|
||||
// Names for google.protobuf.DescriptorProto.ExtensionRange.
|
||||
const (
|
||||
DescriptorProto_ExtensionRange_message_name protoreflect.Name = "ExtensionRange"
|
||||
DescriptorProto_ExtensionRange_message_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.DescriptorProto.ExtensionRange.
|
||||
const (
|
||||
DescriptorProto_ExtensionRange_Start_field_name protoreflect.Name = "start"
|
||||
DescriptorProto_ExtensionRange_End_field_name protoreflect.Name = "end"
|
||||
DescriptorProto_ExtensionRange_Options_field_name protoreflect.Name = "options"
|
||||
|
||||
DescriptorProto_ExtensionRange_Start_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange.start"
|
||||
DescriptorProto_ExtensionRange_End_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange.end"
|
||||
DescriptorProto_ExtensionRange_Options_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ExtensionRange.options"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.ExtensionRange.
|
||||
const (
|
||||
DescriptorProto_ExtensionRange_Start_field_number protoreflect.FieldNumber = 1
|
||||
DescriptorProto_ExtensionRange_End_field_number protoreflect.FieldNumber = 2
|
||||
DescriptorProto_ExtensionRange_Options_field_number protoreflect.FieldNumber = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.DescriptorProto.ReservedRange.
|
||||
const (
|
||||
DescriptorProto_ReservedRange_message_name protoreflect.Name = "ReservedRange"
|
||||
DescriptorProto_ReservedRange_message_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ReservedRange"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.DescriptorProto.ReservedRange.
|
||||
const (
|
||||
DescriptorProto_ReservedRange_Start_field_name protoreflect.Name = "start"
|
||||
DescriptorProto_ReservedRange_End_field_name protoreflect.Name = "end"
|
||||
|
||||
DescriptorProto_ReservedRange_Start_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ReservedRange.start"
|
||||
DescriptorProto_ReservedRange_End_field_fullname protoreflect.FullName = "google.protobuf.DescriptorProto.ReservedRange.end"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DescriptorProto.ReservedRange.
|
||||
const (
|
||||
DescriptorProto_ReservedRange_Start_field_number protoreflect.FieldNumber = 1
|
||||
DescriptorProto_ReservedRange_End_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_message_name protoreflect.Name = "ExtensionRangeOptions"
|
||||
ExtensionRangeOptions_message_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
ExtensionRangeOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ExtensionRangeOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ExtensionRangeOptions.
|
||||
const (
|
||||
ExtensionRangeOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldDescriptorProto.
|
||||
const (
|
||||
FieldDescriptorProto_message_name protoreflect.Name = "FieldDescriptorProto"
|
||||
FieldDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FieldDescriptorProto.
|
||||
const (
|
||||
FieldDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
FieldDescriptorProto_Number_field_name protoreflect.Name = "number"
|
||||
FieldDescriptorProto_Label_field_name protoreflect.Name = "label"
|
||||
FieldDescriptorProto_Type_field_name protoreflect.Name = "type"
|
||||
FieldDescriptorProto_TypeName_field_name protoreflect.Name = "type_name"
|
||||
FieldDescriptorProto_Extendee_field_name protoreflect.Name = "extendee"
|
||||
FieldDescriptorProto_DefaultValue_field_name protoreflect.Name = "default_value"
|
||||
FieldDescriptorProto_OneofIndex_field_name protoreflect.Name = "oneof_index"
|
||||
FieldDescriptorProto_JsonName_field_name protoreflect.Name = "json_name"
|
||||
FieldDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
FieldDescriptorProto_Proto3Optional_field_name protoreflect.Name = "proto3_optional"
|
||||
|
||||
FieldDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.name"
|
||||
FieldDescriptorProto_Number_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.number"
|
||||
FieldDescriptorProto_Label_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.label"
|
||||
FieldDescriptorProto_Type_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.type"
|
||||
FieldDescriptorProto_TypeName_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.type_name"
|
||||
FieldDescriptorProto_Extendee_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.extendee"
|
||||
FieldDescriptorProto_DefaultValue_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.default_value"
|
||||
FieldDescriptorProto_OneofIndex_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.oneof_index"
|
||||
FieldDescriptorProto_JsonName_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.json_name"
|
||||
FieldDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.options"
|
||||
FieldDescriptorProto_Proto3Optional_field_fullname protoreflect.FullName = "google.protobuf.FieldDescriptorProto.proto3_optional"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FieldDescriptorProto.
|
||||
const (
|
||||
FieldDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
FieldDescriptorProto_Number_field_number protoreflect.FieldNumber = 3
|
||||
FieldDescriptorProto_Label_field_number protoreflect.FieldNumber = 4
|
||||
FieldDescriptorProto_Type_field_number protoreflect.FieldNumber = 5
|
||||
FieldDescriptorProto_TypeName_field_number protoreflect.FieldNumber = 6
|
||||
FieldDescriptorProto_Extendee_field_number protoreflect.FieldNumber = 2
|
||||
FieldDescriptorProto_DefaultValue_field_number protoreflect.FieldNumber = 7
|
||||
FieldDescriptorProto_OneofIndex_field_number protoreflect.FieldNumber = 9
|
||||
FieldDescriptorProto_JsonName_field_number protoreflect.FieldNumber = 10
|
||||
FieldDescriptorProto_Options_field_number protoreflect.FieldNumber = 8
|
||||
FieldDescriptorProto_Proto3Optional_field_number protoreflect.FieldNumber = 17
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldDescriptorProto.Type.
|
||||
const (
|
||||
FieldDescriptorProto_Type_enum_fullname = "google.protobuf.FieldDescriptorProto.Type"
|
||||
FieldDescriptorProto_Type_enum_name = "Type"
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldDescriptorProto.Label.
|
||||
const (
|
||||
FieldDescriptorProto_Label_enum_fullname = "google.protobuf.FieldDescriptorProto.Label"
|
||||
FieldDescriptorProto_Label_enum_name = "Label"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.OneofDescriptorProto.
|
||||
const (
|
||||
OneofDescriptorProto_message_name protoreflect.Name = "OneofDescriptorProto"
|
||||
OneofDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.OneofDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.OneofDescriptorProto.
|
||||
const (
|
||||
OneofDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
OneofDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
|
||||
OneofDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.OneofDescriptorProto.name"
|
||||
OneofDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.OneofDescriptorProto.options"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.OneofDescriptorProto.
|
||||
const (
|
||||
OneofDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
OneofDescriptorProto_Options_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumDescriptorProto.
|
||||
const (
|
||||
EnumDescriptorProto_message_name protoreflect.Name = "EnumDescriptorProto"
|
||||
EnumDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.EnumDescriptorProto.
|
||||
const (
|
||||
EnumDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
EnumDescriptorProto_Value_field_name protoreflect.Name = "value"
|
||||
EnumDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
EnumDescriptorProto_ReservedRange_field_name protoreflect.Name = "reserved_range"
|
||||
EnumDescriptorProto_ReservedName_field_name protoreflect.Name = "reserved_name"
|
||||
|
||||
EnumDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.name"
|
||||
EnumDescriptorProto_Value_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.value"
|
||||
EnumDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.options"
|
||||
EnumDescriptorProto_ReservedRange_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.reserved_range"
|
||||
EnumDescriptorProto_ReservedName_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.reserved_name"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumDescriptorProto.
|
||||
const (
|
||||
EnumDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
EnumDescriptorProto_Value_field_number protoreflect.FieldNumber = 2
|
||||
EnumDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
|
||||
EnumDescriptorProto_ReservedRange_field_number protoreflect.FieldNumber = 4
|
||||
EnumDescriptorProto_ReservedName_field_number protoreflect.FieldNumber = 5
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumDescriptorProto.EnumReservedRange.
|
||||
const (
|
||||
EnumDescriptorProto_EnumReservedRange_message_name protoreflect.Name = "EnumReservedRange"
|
||||
EnumDescriptorProto_EnumReservedRange_message_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.EnumReservedRange"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.EnumDescriptorProto.EnumReservedRange.
|
||||
const (
|
||||
EnumDescriptorProto_EnumReservedRange_Start_field_name protoreflect.Name = "start"
|
||||
EnumDescriptorProto_EnumReservedRange_End_field_name protoreflect.Name = "end"
|
||||
|
||||
EnumDescriptorProto_EnumReservedRange_Start_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.EnumReservedRange.start"
|
||||
EnumDescriptorProto_EnumReservedRange_End_field_fullname protoreflect.FullName = "google.protobuf.EnumDescriptorProto.EnumReservedRange.end"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumDescriptorProto.EnumReservedRange.
|
||||
const (
|
||||
EnumDescriptorProto_EnumReservedRange_Start_field_number protoreflect.FieldNumber = 1
|
||||
EnumDescriptorProto_EnumReservedRange_End_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumValueDescriptorProto.
|
||||
const (
|
||||
EnumValueDescriptorProto_message_name protoreflect.Name = "EnumValueDescriptorProto"
|
||||
EnumValueDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.EnumValueDescriptorProto.
|
||||
const (
|
||||
EnumValueDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
EnumValueDescriptorProto_Number_field_name protoreflect.Name = "number"
|
||||
EnumValueDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
|
||||
EnumValueDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto.name"
|
||||
EnumValueDescriptorProto_Number_field_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto.number"
|
||||
EnumValueDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumValueDescriptorProto.options"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValueDescriptorProto.
|
||||
const (
|
||||
EnumValueDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
EnumValueDescriptorProto_Number_field_number protoreflect.FieldNumber = 2
|
||||
EnumValueDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ServiceDescriptorProto.
|
||||
const (
|
||||
ServiceDescriptorProto_message_name protoreflect.Name = "ServiceDescriptorProto"
|
||||
ServiceDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.ServiceDescriptorProto.
|
||||
const (
|
||||
ServiceDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
ServiceDescriptorProto_Method_field_name protoreflect.Name = "method"
|
||||
ServiceDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
|
||||
ServiceDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto.name"
|
||||
ServiceDescriptorProto_Method_field_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto.method"
|
||||
ServiceDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.ServiceDescriptorProto.options"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ServiceDescriptorProto.
|
||||
const (
|
||||
ServiceDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
ServiceDescriptorProto_Method_field_number protoreflect.FieldNumber = 2
|
||||
ServiceDescriptorProto_Options_field_number protoreflect.FieldNumber = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.MethodDescriptorProto.
|
||||
const (
|
||||
MethodDescriptorProto_message_name protoreflect.Name = "MethodDescriptorProto"
|
||||
MethodDescriptorProto_message_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.MethodDescriptorProto.
|
||||
const (
|
||||
MethodDescriptorProto_Name_field_name protoreflect.Name = "name"
|
||||
MethodDescriptorProto_InputType_field_name protoreflect.Name = "input_type"
|
||||
MethodDescriptorProto_OutputType_field_name protoreflect.Name = "output_type"
|
||||
MethodDescriptorProto_Options_field_name protoreflect.Name = "options"
|
||||
MethodDescriptorProto_ClientStreaming_field_name protoreflect.Name = "client_streaming"
|
||||
MethodDescriptorProto_ServerStreaming_field_name protoreflect.Name = "server_streaming"
|
||||
|
||||
MethodDescriptorProto_Name_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.name"
|
||||
MethodDescriptorProto_InputType_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.input_type"
|
||||
MethodDescriptorProto_OutputType_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.output_type"
|
||||
MethodDescriptorProto_Options_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.options"
|
||||
MethodDescriptorProto_ClientStreaming_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.client_streaming"
|
||||
MethodDescriptorProto_ServerStreaming_field_fullname protoreflect.FullName = "google.protobuf.MethodDescriptorProto.server_streaming"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MethodDescriptorProto.
|
||||
const (
|
||||
MethodDescriptorProto_Name_field_number protoreflect.FieldNumber = 1
|
||||
MethodDescriptorProto_InputType_field_number protoreflect.FieldNumber = 2
|
||||
MethodDescriptorProto_OutputType_field_number protoreflect.FieldNumber = 3
|
||||
MethodDescriptorProto_Options_field_number protoreflect.FieldNumber = 4
|
||||
MethodDescriptorProto_ClientStreaming_field_number protoreflect.FieldNumber = 5
|
||||
MethodDescriptorProto_ServerStreaming_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FileOptions.
|
||||
const (
|
||||
FileOptions_message_name protoreflect.Name = "FileOptions"
|
||||
FileOptions_message_fullname protoreflect.FullName = "google.protobuf.FileOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FileOptions.
|
||||
const (
|
||||
FileOptions_JavaPackage_field_name protoreflect.Name = "java_package"
|
||||
FileOptions_JavaOuterClassname_field_name protoreflect.Name = "java_outer_classname"
|
||||
FileOptions_JavaMultipleFiles_field_name protoreflect.Name = "java_multiple_files"
|
||||
FileOptions_JavaGenerateEqualsAndHash_field_name protoreflect.Name = "java_generate_equals_and_hash"
|
||||
FileOptions_JavaStringCheckUtf8_field_name protoreflect.Name = "java_string_check_utf8"
|
||||
FileOptions_OptimizeFor_field_name protoreflect.Name = "optimize_for"
|
||||
FileOptions_GoPackage_field_name protoreflect.Name = "go_package"
|
||||
FileOptions_CcGenericServices_field_name protoreflect.Name = "cc_generic_services"
|
||||
FileOptions_JavaGenericServices_field_name protoreflect.Name = "java_generic_services"
|
||||
FileOptions_PyGenericServices_field_name protoreflect.Name = "py_generic_services"
|
||||
FileOptions_PhpGenericServices_field_name protoreflect.Name = "php_generic_services"
|
||||
FileOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
FileOptions_CcEnableArenas_field_name protoreflect.Name = "cc_enable_arenas"
|
||||
FileOptions_ObjcClassPrefix_field_name protoreflect.Name = "objc_class_prefix"
|
||||
FileOptions_CsharpNamespace_field_name protoreflect.Name = "csharp_namespace"
|
||||
FileOptions_SwiftPrefix_field_name protoreflect.Name = "swift_prefix"
|
||||
FileOptions_PhpClassPrefix_field_name protoreflect.Name = "php_class_prefix"
|
||||
FileOptions_PhpNamespace_field_name protoreflect.Name = "php_namespace"
|
||||
FileOptions_PhpMetadataNamespace_field_name protoreflect.Name = "php_metadata_namespace"
|
||||
FileOptions_RubyPackage_field_name protoreflect.Name = "ruby_package"
|
||||
FileOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
FileOptions_JavaPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_package"
|
||||
FileOptions_JavaOuterClassname_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_outer_classname"
|
||||
FileOptions_JavaMultipleFiles_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_multiple_files"
|
||||
FileOptions_JavaGenerateEqualsAndHash_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_generate_equals_and_hash"
|
||||
FileOptions_JavaStringCheckUtf8_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_string_check_utf8"
|
||||
FileOptions_OptimizeFor_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.optimize_for"
|
||||
FileOptions_GoPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.go_package"
|
||||
FileOptions_CcGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_generic_services"
|
||||
FileOptions_JavaGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.java_generic_services"
|
||||
FileOptions_PyGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.py_generic_services"
|
||||
FileOptions_PhpGenericServices_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_generic_services"
|
||||
FileOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.deprecated"
|
||||
FileOptions_CcEnableArenas_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.cc_enable_arenas"
|
||||
FileOptions_ObjcClassPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.objc_class_prefix"
|
||||
FileOptions_CsharpNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.csharp_namespace"
|
||||
FileOptions_SwiftPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.swift_prefix"
|
||||
FileOptions_PhpClassPrefix_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_class_prefix"
|
||||
FileOptions_PhpNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_namespace"
|
||||
FileOptions_PhpMetadataNamespace_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.php_metadata_namespace"
|
||||
FileOptions_RubyPackage_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.ruby_package"
|
||||
FileOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FileOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FileOptions.
|
||||
const (
|
||||
FileOptions_JavaPackage_field_number protoreflect.FieldNumber = 1
|
||||
FileOptions_JavaOuterClassname_field_number protoreflect.FieldNumber = 8
|
||||
FileOptions_JavaMultipleFiles_field_number protoreflect.FieldNumber = 10
|
||||
FileOptions_JavaGenerateEqualsAndHash_field_number protoreflect.FieldNumber = 20
|
||||
FileOptions_JavaStringCheckUtf8_field_number protoreflect.FieldNumber = 27
|
||||
FileOptions_OptimizeFor_field_number protoreflect.FieldNumber = 9
|
||||
FileOptions_GoPackage_field_number protoreflect.FieldNumber = 11
|
||||
FileOptions_CcGenericServices_field_number protoreflect.FieldNumber = 16
|
||||
FileOptions_JavaGenericServices_field_number protoreflect.FieldNumber = 17
|
||||
FileOptions_PyGenericServices_field_number protoreflect.FieldNumber = 18
|
||||
FileOptions_PhpGenericServices_field_number protoreflect.FieldNumber = 42
|
||||
FileOptions_Deprecated_field_number protoreflect.FieldNumber = 23
|
||||
FileOptions_CcEnableArenas_field_number protoreflect.FieldNumber = 31
|
||||
FileOptions_ObjcClassPrefix_field_number protoreflect.FieldNumber = 36
|
||||
FileOptions_CsharpNamespace_field_number protoreflect.FieldNumber = 37
|
||||
FileOptions_SwiftPrefix_field_number protoreflect.FieldNumber = 39
|
||||
FileOptions_PhpClassPrefix_field_number protoreflect.FieldNumber = 40
|
||||
FileOptions_PhpNamespace_field_number protoreflect.FieldNumber = 41
|
||||
FileOptions_PhpMetadataNamespace_field_number protoreflect.FieldNumber = 44
|
||||
FileOptions_RubyPackage_field_number protoreflect.FieldNumber = 45
|
||||
FileOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FileOptions.OptimizeMode.
|
||||
const (
|
||||
FileOptions_OptimizeMode_enum_fullname = "google.protobuf.FileOptions.OptimizeMode"
|
||||
FileOptions_OptimizeMode_enum_name = "OptimizeMode"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_message_name protoreflect.Name = "MessageOptions"
|
||||
MessageOptions_message_fullname protoreflect.FullName = "google.protobuf.MessageOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_MessageSetWireFormat_field_name protoreflect.Name = "message_set_wire_format"
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_name protoreflect.Name = "no_standard_descriptor_accessor"
|
||||
MessageOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
MessageOptions_MapEntry_field_name protoreflect.Name = "map_entry"
|
||||
MessageOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
MessageOptions_MessageSetWireFormat_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.message_set_wire_format"
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.no_standard_descriptor_accessor"
|
||||
MessageOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.deprecated"
|
||||
MessageOptions_MapEntry_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.map_entry"
|
||||
MessageOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MessageOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MessageOptions.
|
||||
const (
|
||||
MessageOptions_MessageSetWireFormat_field_number protoreflect.FieldNumber = 1
|
||||
MessageOptions_NoStandardDescriptorAccessor_field_number protoreflect.FieldNumber = 2
|
||||
MessageOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
MessageOptions_MapEntry_field_number protoreflect.FieldNumber = 7
|
||||
MessageOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FieldOptions.
|
||||
const (
|
||||
FieldOptions_message_name protoreflect.Name = "FieldOptions"
|
||||
FieldOptions_message_fullname protoreflect.FullName = "google.protobuf.FieldOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FieldOptions.
|
||||
const (
|
||||
FieldOptions_Ctype_field_name protoreflect.Name = "ctype"
|
||||
FieldOptions_Packed_field_name protoreflect.Name = "packed"
|
||||
FieldOptions_Jstype_field_name protoreflect.Name = "jstype"
|
||||
FieldOptions_Lazy_field_name protoreflect.Name = "lazy"
|
||||
FieldOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
FieldOptions_Weak_field_name protoreflect.Name = "weak"
|
||||
FieldOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
FieldOptions_Ctype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.ctype"
|
||||
FieldOptions_Packed_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.packed"
|
||||
FieldOptions_Jstype_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.jstype"
|
||||
FieldOptions_Lazy_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.lazy"
|
||||
FieldOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.deprecated"
|
||||
FieldOptions_Weak_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.weak"
|
||||
FieldOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.FieldOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FieldOptions.
|
||||
const (
|
||||
FieldOptions_Ctype_field_number protoreflect.FieldNumber = 1
|
||||
FieldOptions_Packed_field_number protoreflect.FieldNumber = 2
|
||||
FieldOptions_Jstype_field_number protoreflect.FieldNumber = 6
|
||||
FieldOptions_Lazy_field_number protoreflect.FieldNumber = 5
|
||||
FieldOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
FieldOptions_Weak_field_number protoreflect.FieldNumber = 10
|
||||
FieldOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.CType.
|
||||
const (
|
||||
FieldOptions_CType_enum_fullname = "google.protobuf.FieldOptions.CType"
|
||||
FieldOptions_CType_enum_name = "CType"
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.FieldOptions.JSType.
|
||||
const (
|
||||
FieldOptions_JSType_enum_fullname = "google.protobuf.FieldOptions.JSType"
|
||||
FieldOptions_JSType_enum_name = "JSType"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_message_name protoreflect.Name = "OneofOptions"
|
||||
OneofOptions_message_fullname protoreflect.FullName = "google.protobuf.OneofOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
OneofOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.OneofOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.OneofOptions.
|
||||
const (
|
||||
OneofOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumOptions.
|
||||
const (
|
||||
EnumOptions_message_name protoreflect.Name = "EnumOptions"
|
||||
EnumOptions_message_fullname protoreflect.FullName = "google.protobuf.EnumOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.EnumOptions.
|
||||
const (
|
||||
EnumOptions_AllowAlias_field_name protoreflect.Name = "allow_alias"
|
||||
EnumOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
EnumOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
EnumOptions_AllowAlias_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.allow_alias"
|
||||
EnumOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.deprecated"
|
||||
EnumOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumOptions.
|
||||
const (
|
||||
EnumOptions_AllowAlias_field_number protoreflect.FieldNumber = 2
|
||||
EnumOptions_Deprecated_field_number protoreflect.FieldNumber = 3
|
||||
EnumOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumValueOptions.
|
||||
const (
|
||||
EnumValueOptions_message_name protoreflect.Name = "EnumValueOptions"
|
||||
EnumValueOptions_message_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.EnumValueOptions.
|
||||
const (
|
||||
EnumValueOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
EnumValueOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
EnumValueOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.deprecated"
|
||||
EnumValueOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.EnumValueOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValueOptions.
|
||||
const (
|
||||
EnumValueOptions_Deprecated_field_number protoreflect.FieldNumber = 1
|
||||
EnumValueOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ServiceOptions.
|
||||
const (
|
||||
ServiceOptions_message_name protoreflect.Name = "ServiceOptions"
|
||||
ServiceOptions_message_fullname protoreflect.FullName = "google.protobuf.ServiceOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.ServiceOptions.
|
||||
const (
|
||||
ServiceOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
ServiceOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
ServiceOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.deprecated"
|
||||
ServiceOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.ServiceOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ServiceOptions.
|
||||
const (
|
||||
ServiceOptions_Deprecated_field_number protoreflect.FieldNumber = 33
|
||||
ServiceOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Names for google.protobuf.MethodOptions.
|
||||
const (
|
||||
MethodOptions_message_name protoreflect.Name = "MethodOptions"
|
||||
MethodOptions_message_fullname protoreflect.FullName = "google.protobuf.MethodOptions"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.MethodOptions.
|
||||
const (
|
||||
MethodOptions_Deprecated_field_name protoreflect.Name = "deprecated"
|
||||
MethodOptions_IdempotencyLevel_field_name protoreflect.Name = "idempotency_level"
|
||||
MethodOptions_UninterpretedOption_field_name protoreflect.Name = "uninterpreted_option"
|
||||
|
||||
MethodOptions_Deprecated_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.deprecated"
|
||||
MethodOptions_IdempotencyLevel_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.idempotency_level"
|
||||
MethodOptions_UninterpretedOption_field_fullname protoreflect.FullName = "google.protobuf.MethodOptions.uninterpreted_option"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.MethodOptions.
|
||||
const (
|
||||
MethodOptions_Deprecated_field_number protoreflect.FieldNumber = 33
|
||||
MethodOptions_IdempotencyLevel_field_number protoreflect.FieldNumber = 34
|
||||
MethodOptions_UninterpretedOption_field_number protoreflect.FieldNumber = 999
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.MethodOptions.IdempotencyLevel.
|
||||
const (
|
||||
MethodOptions_IdempotencyLevel_enum_fullname = "google.protobuf.MethodOptions.IdempotencyLevel"
|
||||
MethodOptions_IdempotencyLevel_enum_name = "IdempotencyLevel"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.UninterpretedOption.
|
||||
const (
|
||||
UninterpretedOption_message_name protoreflect.Name = "UninterpretedOption"
|
||||
UninterpretedOption_message_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.UninterpretedOption.
|
||||
const (
|
||||
UninterpretedOption_Name_field_name protoreflect.Name = "name"
|
||||
UninterpretedOption_IdentifierValue_field_name protoreflect.Name = "identifier_value"
|
||||
UninterpretedOption_PositiveIntValue_field_name protoreflect.Name = "positive_int_value"
|
||||
UninterpretedOption_NegativeIntValue_field_name protoreflect.Name = "negative_int_value"
|
||||
UninterpretedOption_DoubleValue_field_name protoreflect.Name = "double_value"
|
||||
UninterpretedOption_StringValue_field_name protoreflect.Name = "string_value"
|
||||
UninterpretedOption_AggregateValue_field_name protoreflect.Name = "aggregate_value"
|
||||
|
||||
UninterpretedOption_Name_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.name"
|
||||
UninterpretedOption_IdentifierValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.identifier_value"
|
||||
UninterpretedOption_PositiveIntValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.positive_int_value"
|
||||
UninterpretedOption_NegativeIntValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.negative_int_value"
|
||||
UninterpretedOption_DoubleValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.double_value"
|
||||
UninterpretedOption_StringValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.string_value"
|
||||
UninterpretedOption_AggregateValue_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.aggregate_value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UninterpretedOption.
|
||||
const (
|
||||
UninterpretedOption_Name_field_number protoreflect.FieldNumber = 2
|
||||
UninterpretedOption_IdentifierValue_field_number protoreflect.FieldNumber = 3
|
||||
UninterpretedOption_PositiveIntValue_field_number protoreflect.FieldNumber = 4
|
||||
UninterpretedOption_NegativeIntValue_field_number protoreflect.FieldNumber = 5
|
||||
UninterpretedOption_DoubleValue_field_number protoreflect.FieldNumber = 6
|
||||
UninterpretedOption_StringValue_field_number protoreflect.FieldNumber = 7
|
||||
UninterpretedOption_AggregateValue_field_number protoreflect.FieldNumber = 8
|
||||
)
|
||||
|
||||
// Names for google.protobuf.UninterpretedOption.NamePart.
|
||||
const (
|
||||
UninterpretedOption_NamePart_message_name protoreflect.Name = "NamePart"
|
||||
UninterpretedOption_NamePart_message_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.NamePart"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.UninterpretedOption.NamePart.
|
||||
const (
|
||||
UninterpretedOption_NamePart_NamePart_field_name protoreflect.Name = "name_part"
|
||||
UninterpretedOption_NamePart_IsExtension_field_name protoreflect.Name = "is_extension"
|
||||
|
||||
UninterpretedOption_NamePart_NamePart_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.NamePart.name_part"
|
||||
UninterpretedOption_NamePart_IsExtension_field_fullname protoreflect.FullName = "google.protobuf.UninterpretedOption.NamePart.is_extension"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UninterpretedOption.NamePart.
|
||||
const (
|
||||
UninterpretedOption_NamePart_NamePart_field_number protoreflect.FieldNumber = 1
|
||||
UninterpretedOption_NamePart_IsExtension_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.SourceCodeInfo.
|
||||
const (
|
||||
SourceCodeInfo_message_name protoreflect.Name = "SourceCodeInfo"
|
||||
SourceCodeInfo_message_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.SourceCodeInfo.
|
||||
const (
|
||||
SourceCodeInfo_Location_field_name protoreflect.Name = "location"
|
||||
|
||||
SourceCodeInfo_Location_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.location"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.SourceCodeInfo.
|
||||
const (
|
||||
SourceCodeInfo_Location_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.SourceCodeInfo.Location.
|
||||
const (
|
||||
SourceCodeInfo_Location_message_name protoreflect.Name = "Location"
|
||||
SourceCodeInfo_Location_message_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.SourceCodeInfo.Location.
|
||||
const (
|
||||
SourceCodeInfo_Location_Path_field_name protoreflect.Name = "path"
|
||||
SourceCodeInfo_Location_Span_field_name protoreflect.Name = "span"
|
||||
SourceCodeInfo_Location_LeadingComments_field_name protoreflect.Name = "leading_comments"
|
||||
SourceCodeInfo_Location_TrailingComments_field_name protoreflect.Name = "trailing_comments"
|
||||
SourceCodeInfo_Location_LeadingDetachedComments_field_name protoreflect.Name = "leading_detached_comments"
|
||||
|
||||
SourceCodeInfo_Location_Path_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.path"
|
||||
SourceCodeInfo_Location_Span_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.span"
|
||||
SourceCodeInfo_Location_LeadingComments_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.leading_comments"
|
||||
SourceCodeInfo_Location_TrailingComments_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.trailing_comments"
|
||||
SourceCodeInfo_Location_LeadingDetachedComments_field_fullname protoreflect.FullName = "google.protobuf.SourceCodeInfo.Location.leading_detached_comments"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.SourceCodeInfo.Location.
|
||||
const (
|
||||
SourceCodeInfo_Location_Path_field_number protoreflect.FieldNumber = 1
|
||||
SourceCodeInfo_Location_Span_field_number protoreflect.FieldNumber = 2
|
||||
SourceCodeInfo_Location_LeadingComments_field_number protoreflect.FieldNumber = 3
|
||||
SourceCodeInfo_Location_TrailingComments_field_number protoreflect.FieldNumber = 4
|
||||
SourceCodeInfo_Location_LeadingDetachedComments_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.GeneratedCodeInfo.
|
||||
const (
|
||||
GeneratedCodeInfo_message_name protoreflect.Name = "GeneratedCodeInfo"
|
||||
GeneratedCodeInfo_message_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.GeneratedCodeInfo.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_field_name protoreflect.Name = "annotation"
|
||||
|
||||
GeneratedCodeInfo_Annotation_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.annotation"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GeneratedCodeInfo.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.GeneratedCodeInfo.Annotation.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_message_name protoreflect.Name = "Annotation"
|
||||
GeneratedCodeInfo_Annotation_message_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.GeneratedCodeInfo.Annotation.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_Path_field_name protoreflect.Name = "path"
|
||||
GeneratedCodeInfo_Annotation_SourceFile_field_name protoreflect.Name = "source_file"
|
||||
GeneratedCodeInfo_Annotation_Begin_field_name protoreflect.Name = "begin"
|
||||
GeneratedCodeInfo_Annotation_End_field_name protoreflect.Name = "end"
|
||||
|
||||
GeneratedCodeInfo_Annotation_Path_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.path"
|
||||
GeneratedCodeInfo_Annotation_SourceFile_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.source_file"
|
||||
GeneratedCodeInfo_Annotation_Begin_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.begin"
|
||||
GeneratedCodeInfo_Annotation_End_field_fullname protoreflect.FullName = "google.protobuf.GeneratedCodeInfo.Annotation.end"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.GeneratedCodeInfo.Annotation.
|
||||
const (
|
||||
GeneratedCodeInfo_Annotation_Path_field_number protoreflect.FieldNumber = 1
|
||||
GeneratedCodeInfo_Annotation_SourceFile_field_number protoreflect.FieldNumber = 2
|
||||
GeneratedCodeInfo_Annotation_Begin_field_number protoreflect.FieldNumber = 3
|
||||
GeneratedCodeInfo_Annotation_End_field_number protoreflect.FieldNumber = 4
|
||||
)
|
11
vendor/google.golang.org/protobuf/internal/genid/doc.go
generated
vendored
Normal file
11
vendor/google.golang.org/protobuf/internal/genid/doc.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package genid contains constants for declarations in descriptor.proto
|
||||
// and the well-known types.
|
||||
package genid
|
||||
|
||||
import protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
const GoogleProtobuf_package protoreflect.FullName = "google.protobuf"
|
34
vendor/google.golang.org/protobuf/internal/genid/duration_gen.go
generated
vendored
Normal file
34
vendor/google.golang.org/protobuf/internal/genid/duration_gen.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_duration_proto = "google/protobuf/duration.proto"
|
||||
|
||||
// Names for google.protobuf.Duration.
|
||||
const (
|
||||
Duration_message_name protoreflect.Name = "Duration"
|
||||
Duration_message_fullname protoreflect.FullName = "google.protobuf.Duration"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Duration.
|
||||
const (
|
||||
Duration_Seconds_field_name protoreflect.Name = "seconds"
|
||||
Duration_Nanos_field_name protoreflect.Name = "nanos"
|
||||
|
||||
Duration_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Duration.seconds"
|
||||
Duration_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Duration.nanos"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Duration.
|
||||
const (
|
||||
Duration_Seconds_field_number protoreflect.FieldNumber = 1
|
||||
Duration_Nanos_field_number protoreflect.FieldNumber = 2
|
||||
)
|
19
vendor/google.golang.org/protobuf/internal/genid/empty_gen.go
generated
vendored
Normal file
19
vendor/google.golang.org/protobuf/internal/genid/empty_gen.go
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_empty_proto = "google/protobuf/empty.proto"
|
||||
|
||||
// Names for google.protobuf.Empty.
|
||||
const (
|
||||
Empty_message_name protoreflect.Name = "Empty"
|
||||
Empty_message_fullname protoreflect.FullName = "google.protobuf.Empty"
|
||||
)
|
31
vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go
generated
vendored
Normal file
31
vendor/google.golang.org/protobuf/internal/genid/field_mask_gen.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_field_mask_proto = "google/protobuf/field_mask.proto"
|
||||
|
||||
// Names for google.protobuf.FieldMask.
|
||||
const (
|
||||
FieldMask_message_name protoreflect.Name = "FieldMask"
|
||||
FieldMask_message_fullname protoreflect.FullName = "google.protobuf.FieldMask"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FieldMask.
|
||||
const (
|
||||
FieldMask_Paths_field_name protoreflect.Name = "paths"
|
||||
|
||||
FieldMask_Paths_field_fullname protoreflect.FullName = "google.protobuf.FieldMask.paths"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FieldMask.
|
||||
const (
|
||||
FieldMask_Paths_field_number protoreflect.FieldNumber = 1
|
||||
)
|
25
vendor/google.golang.org/protobuf/internal/genid/goname.go
generated
vendored
Normal file
25
vendor/google.golang.org/protobuf/internal/genid/goname.go
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package genid
|
||||
|
||||
// Go names of implementation-specific struct fields in generated messages.
|
||||
const (
|
||||
State_goname = "state"
|
||||
|
||||
SizeCache_goname = "sizeCache"
|
||||
SizeCacheA_goname = "XXX_sizecache"
|
||||
|
||||
WeakFields_goname = "weakFields"
|
||||
WeakFieldsA_goname = "XXX_weak"
|
||||
|
||||
UnknownFields_goname = "unknownFields"
|
||||
UnknownFieldsA_goname = "XXX_unrecognized"
|
||||
|
||||
ExtensionFields_goname = "extensionFields"
|
||||
ExtensionFieldsA_goname = "XXX_InternalExtensions"
|
||||
ExtensionFieldsB_goname = "XXX_extensions"
|
||||
|
||||
WeakFieldPrefix_goname = "XXX_weak_"
|
||||
)
|
16
vendor/google.golang.org/protobuf/internal/genid/map_entry.go
generated
vendored
Normal file
16
vendor/google.golang.org/protobuf/internal/genid/map_entry.go
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package genid
|
||||
|
||||
import protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
// Generic field names and numbers for synthetic map entry messages.
|
||||
const (
|
||||
MapEntry_Key_field_name protoreflect.Name = "key"
|
||||
MapEntry_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
MapEntry_Key_field_number protoreflect.FieldNumber = 1
|
||||
MapEntry_Value_field_number protoreflect.FieldNumber = 2
|
||||
)
|
31
vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go
generated
vendored
Normal file
31
vendor/google.golang.org/protobuf/internal/genid/source_context_gen.go
generated
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_source_context_proto = "google/protobuf/source_context.proto"
|
||||
|
||||
// Names for google.protobuf.SourceContext.
|
||||
const (
|
||||
SourceContext_message_name protoreflect.Name = "SourceContext"
|
||||
SourceContext_message_fullname protoreflect.FullName = "google.protobuf.SourceContext"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.SourceContext.
|
||||
const (
|
||||
SourceContext_FileName_field_name protoreflect.Name = "file_name"
|
||||
|
||||
SourceContext_FileName_field_fullname protoreflect.FullName = "google.protobuf.SourceContext.file_name"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.SourceContext.
|
||||
const (
|
||||
SourceContext_FileName_field_number protoreflect.FieldNumber = 1
|
||||
)
|
116
vendor/google.golang.org/protobuf/internal/genid/struct_gen.go
generated
vendored
Normal file
116
vendor/google.golang.org/protobuf/internal/genid/struct_gen.go
generated
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_struct_proto = "google/protobuf/struct.proto"
|
||||
|
||||
// Full and short names for google.protobuf.NullValue.
|
||||
const (
|
||||
NullValue_enum_fullname = "google.protobuf.NullValue"
|
||||
NullValue_enum_name = "NullValue"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Struct.
|
||||
const (
|
||||
Struct_message_name protoreflect.Name = "Struct"
|
||||
Struct_message_fullname protoreflect.FullName = "google.protobuf.Struct"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Struct.
|
||||
const (
|
||||
Struct_Fields_field_name protoreflect.Name = "fields"
|
||||
|
||||
Struct_Fields_field_fullname protoreflect.FullName = "google.protobuf.Struct.fields"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Struct.
|
||||
const (
|
||||
Struct_Fields_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Struct.FieldsEntry.
|
||||
const (
|
||||
Struct_FieldsEntry_message_name protoreflect.Name = "FieldsEntry"
|
||||
Struct_FieldsEntry_message_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Struct.FieldsEntry.
|
||||
const (
|
||||
Struct_FieldsEntry_Key_field_name protoreflect.Name = "key"
|
||||
Struct_FieldsEntry_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
Struct_FieldsEntry_Key_field_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry.key"
|
||||
Struct_FieldsEntry_Value_field_fullname protoreflect.FullName = "google.protobuf.Struct.FieldsEntry.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Struct.FieldsEntry.
|
||||
const (
|
||||
Struct_FieldsEntry_Key_field_number protoreflect.FieldNumber = 1
|
||||
Struct_FieldsEntry_Value_field_number protoreflect.FieldNumber = 2
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Value.
|
||||
const (
|
||||
Value_message_name protoreflect.Name = "Value"
|
||||
Value_message_fullname protoreflect.FullName = "google.protobuf.Value"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Value.
|
||||
const (
|
||||
Value_NullValue_field_name protoreflect.Name = "null_value"
|
||||
Value_NumberValue_field_name protoreflect.Name = "number_value"
|
||||
Value_StringValue_field_name protoreflect.Name = "string_value"
|
||||
Value_BoolValue_field_name protoreflect.Name = "bool_value"
|
||||
Value_StructValue_field_name protoreflect.Name = "struct_value"
|
||||
Value_ListValue_field_name protoreflect.Name = "list_value"
|
||||
|
||||
Value_NullValue_field_fullname protoreflect.FullName = "google.protobuf.Value.null_value"
|
||||
Value_NumberValue_field_fullname protoreflect.FullName = "google.protobuf.Value.number_value"
|
||||
Value_StringValue_field_fullname protoreflect.FullName = "google.protobuf.Value.string_value"
|
||||
Value_BoolValue_field_fullname protoreflect.FullName = "google.protobuf.Value.bool_value"
|
||||
Value_StructValue_field_fullname protoreflect.FullName = "google.protobuf.Value.struct_value"
|
||||
Value_ListValue_field_fullname protoreflect.FullName = "google.protobuf.Value.list_value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Value.
|
||||
const (
|
||||
Value_NullValue_field_number protoreflect.FieldNumber = 1
|
||||
Value_NumberValue_field_number protoreflect.FieldNumber = 2
|
||||
Value_StringValue_field_number protoreflect.FieldNumber = 3
|
||||
Value_BoolValue_field_number protoreflect.FieldNumber = 4
|
||||
Value_StructValue_field_number protoreflect.FieldNumber = 5
|
||||
Value_ListValue_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Oneof names for google.protobuf.Value.
|
||||
const (
|
||||
Value_Kind_oneof_name protoreflect.Name = "kind"
|
||||
|
||||
Value_Kind_oneof_fullname protoreflect.FullName = "google.protobuf.Value.kind"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.ListValue.
|
||||
const (
|
||||
ListValue_message_name protoreflect.Name = "ListValue"
|
||||
ListValue_message_fullname protoreflect.FullName = "google.protobuf.ListValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.ListValue.
|
||||
const (
|
||||
ListValue_Values_field_name protoreflect.Name = "values"
|
||||
|
||||
ListValue_Values_field_fullname protoreflect.FullName = "google.protobuf.ListValue.values"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.ListValue.
|
||||
const (
|
||||
ListValue_Values_field_number protoreflect.FieldNumber = 1
|
||||
)
|
34
vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go
generated
vendored
Normal file
34
vendor/google.golang.org/protobuf/internal/genid/timestamp_gen.go
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_timestamp_proto = "google/protobuf/timestamp.proto"
|
||||
|
||||
// Names for google.protobuf.Timestamp.
|
||||
const (
|
||||
Timestamp_message_name protoreflect.Name = "Timestamp"
|
||||
Timestamp_message_fullname protoreflect.FullName = "google.protobuf.Timestamp"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Timestamp.
|
||||
const (
|
||||
Timestamp_Seconds_field_name protoreflect.Name = "seconds"
|
||||
Timestamp_Nanos_field_name protoreflect.Name = "nanos"
|
||||
|
||||
Timestamp_Seconds_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.seconds"
|
||||
Timestamp_Nanos_field_fullname protoreflect.FullName = "google.protobuf.Timestamp.nanos"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Timestamp.
|
||||
const (
|
||||
Timestamp_Seconds_field_number protoreflect.FieldNumber = 1
|
||||
Timestamp_Nanos_field_number protoreflect.FieldNumber = 2
|
||||
)
|
184
vendor/google.golang.org/protobuf/internal/genid/type_gen.go
generated
vendored
Normal file
184
vendor/google.golang.org/protobuf/internal/genid/type_gen.go
generated
vendored
Normal file
@ -0,0 +1,184 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_type_proto = "google/protobuf/type.proto"
|
||||
|
||||
// Full and short names for google.protobuf.Syntax.
|
||||
const (
|
||||
Syntax_enum_fullname = "google.protobuf.Syntax"
|
||||
Syntax_enum_name = "Syntax"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Type.
|
||||
const (
|
||||
Type_message_name protoreflect.Name = "Type"
|
||||
Type_message_fullname protoreflect.FullName = "google.protobuf.Type"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Type.
|
||||
const (
|
||||
Type_Name_field_name protoreflect.Name = "name"
|
||||
Type_Fields_field_name protoreflect.Name = "fields"
|
||||
Type_Oneofs_field_name protoreflect.Name = "oneofs"
|
||||
Type_Options_field_name protoreflect.Name = "options"
|
||||
Type_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Type_Syntax_field_name protoreflect.Name = "syntax"
|
||||
|
||||
Type_Name_field_fullname protoreflect.FullName = "google.protobuf.Type.name"
|
||||
Type_Fields_field_fullname protoreflect.FullName = "google.protobuf.Type.fields"
|
||||
Type_Oneofs_field_fullname protoreflect.FullName = "google.protobuf.Type.oneofs"
|
||||
Type_Options_field_fullname protoreflect.FullName = "google.protobuf.Type.options"
|
||||
Type_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Type.source_context"
|
||||
Type_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Type.syntax"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Type.
|
||||
const (
|
||||
Type_Name_field_number protoreflect.FieldNumber = 1
|
||||
Type_Fields_field_number protoreflect.FieldNumber = 2
|
||||
Type_Oneofs_field_number protoreflect.FieldNumber = 3
|
||||
Type_Options_field_number protoreflect.FieldNumber = 4
|
||||
Type_SourceContext_field_number protoreflect.FieldNumber = 5
|
||||
Type_Syntax_field_number protoreflect.FieldNumber = 6
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Field.
|
||||
const (
|
||||
Field_message_name protoreflect.Name = "Field"
|
||||
Field_message_fullname protoreflect.FullName = "google.protobuf.Field"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Field.
|
||||
const (
|
||||
Field_Kind_field_name protoreflect.Name = "kind"
|
||||
Field_Cardinality_field_name protoreflect.Name = "cardinality"
|
||||
Field_Number_field_name protoreflect.Name = "number"
|
||||
Field_Name_field_name protoreflect.Name = "name"
|
||||
Field_TypeUrl_field_name protoreflect.Name = "type_url"
|
||||
Field_OneofIndex_field_name protoreflect.Name = "oneof_index"
|
||||
Field_Packed_field_name protoreflect.Name = "packed"
|
||||
Field_Options_field_name protoreflect.Name = "options"
|
||||
Field_JsonName_field_name protoreflect.Name = "json_name"
|
||||
Field_DefaultValue_field_name protoreflect.Name = "default_value"
|
||||
|
||||
Field_Kind_field_fullname protoreflect.FullName = "google.protobuf.Field.kind"
|
||||
Field_Cardinality_field_fullname protoreflect.FullName = "google.protobuf.Field.cardinality"
|
||||
Field_Number_field_fullname protoreflect.FullName = "google.protobuf.Field.number"
|
||||
Field_Name_field_fullname protoreflect.FullName = "google.protobuf.Field.name"
|
||||
Field_TypeUrl_field_fullname protoreflect.FullName = "google.protobuf.Field.type_url"
|
||||
Field_OneofIndex_field_fullname protoreflect.FullName = "google.protobuf.Field.oneof_index"
|
||||
Field_Packed_field_fullname protoreflect.FullName = "google.protobuf.Field.packed"
|
||||
Field_Options_field_fullname protoreflect.FullName = "google.protobuf.Field.options"
|
||||
Field_JsonName_field_fullname protoreflect.FullName = "google.protobuf.Field.json_name"
|
||||
Field_DefaultValue_field_fullname protoreflect.FullName = "google.protobuf.Field.default_value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Field.
|
||||
const (
|
||||
Field_Kind_field_number protoreflect.FieldNumber = 1
|
||||
Field_Cardinality_field_number protoreflect.FieldNumber = 2
|
||||
Field_Number_field_number protoreflect.FieldNumber = 3
|
||||
Field_Name_field_number protoreflect.FieldNumber = 4
|
||||
Field_TypeUrl_field_number protoreflect.FieldNumber = 6
|
||||
Field_OneofIndex_field_number protoreflect.FieldNumber = 7
|
||||
Field_Packed_field_number protoreflect.FieldNumber = 8
|
||||
Field_Options_field_number protoreflect.FieldNumber = 9
|
||||
Field_JsonName_field_number protoreflect.FieldNumber = 10
|
||||
Field_DefaultValue_field_number protoreflect.FieldNumber = 11
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.Field.Kind.
|
||||
const (
|
||||
Field_Kind_enum_fullname = "google.protobuf.Field.Kind"
|
||||
Field_Kind_enum_name = "Kind"
|
||||
)
|
||||
|
||||
// Full and short names for google.protobuf.Field.Cardinality.
|
||||
const (
|
||||
Field_Cardinality_enum_fullname = "google.protobuf.Field.Cardinality"
|
||||
Field_Cardinality_enum_name = "Cardinality"
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Enum.
|
||||
const (
|
||||
Enum_message_name protoreflect.Name = "Enum"
|
||||
Enum_message_fullname protoreflect.FullName = "google.protobuf.Enum"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Enum.
|
||||
const (
|
||||
Enum_Name_field_name protoreflect.Name = "name"
|
||||
Enum_Enumvalue_field_name protoreflect.Name = "enumvalue"
|
||||
Enum_Options_field_name protoreflect.Name = "options"
|
||||
Enum_SourceContext_field_name protoreflect.Name = "source_context"
|
||||
Enum_Syntax_field_name protoreflect.Name = "syntax"
|
||||
|
||||
Enum_Name_field_fullname protoreflect.FullName = "google.protobuf.Enum.name"
|
||||
Enum_Enumvalue_field_fullname protoreflect.FullName = "google.protobuf.Enum.enumvalue"
|
||||
Enum_Options_field_fullname protoreflect.FullName = "google.protobuf.Enum.options"
|
||||
Enum_SourceContext_field_fullname protoreflect.FullName = "google.protobuf.Enum.source_context"
|
||||
Enum_Syntax_field_fullname protoreflect.FullName = "google.protobuf.Enum.syntax"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Enum.
|
||||
const (
|
||||
Enum_Name_field_number protoreflect.FieldNumber = 1
|
||||
Enum_Enumvalue_field_number protoreflect.FieldNumber = 2
|
||||
Enum_Options_field_number protoreflect.FieldNumber = 3
|
||||
Enum_SourceContext_field_number protoreflect.FieldNumber = 4
|
||||
Enum_Syntax_field_number protoreflect.FieldNumber = 5
|
||||
)
|
||||
|
||||
// Names for google.protobuf.EnumValue.
|
||||
const (
|
||||
EnumValue_message_name protoreflect.Name = "EnumValue"
|
||||
EnumValue_message_fullname protoreflect.FullName = "google.protobuf.EnumValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.EnumValue.
|
||||
const (
|
||||
EnumValue_Name_field_name protoreflect.Name = "name"
|
||||
EnumValue_Number_field_name protoreflect.Name = "number"
|
||||
EnumValue_Options_field_name protoreflect.Name = "options"
|
||||
|
||||
EnumValue_Name_field_fullname protoreflect.FullName = "google.protobuf.EnumValue.name"
|
||||
EnumValue_Number_field_fullname protoreflect.FullName = "google.protobuf.EnumValue.number"
|
||||
EnumValue_Options_field_fullname protoreflect.FullName = "google.protobuf.EnumValue.options"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.EnumValue.
|
||||
const (
|
||||
EnumValue_Name_field_number protoreflect.FieldNumber = 1
|
||||
EnumValue_Number_field_number protoreflect.FieldNumber = 2
|
||||
EnumValue_Options_field_number protoreflect.FieldNumber = 3
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Option.
|
||||
const (
|
||||
Option_message_name protoreflect.Name = "Option"
|
||||
Option_message_fullname protoreflect.FullName = "google.protobuf.Option"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Option.
|
||||
const (
|
||||
Option_Name_field_name protoreflect.Name = "name"
|
||||
Option_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
Option_Name_field_fullname protoreflect.FullName = "google.protobuf.Option.name"
|
||||
Option_Value_field_fullname protoreflect.FullName = "google.protobuf.Option.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Option.
|
||||
const (
|
||||
Option_Name_field_number protoreflect.FieldNumber = 1
|
||||
Option_Value_field_number protoreflect.FieldNumber = 2
|
||||
)
|
13
vendor/google.golang.org/protobuf/internal/genid/wrappers.go
generated
vendored
Normal file
13
vendor/google.golang.org/protobuf/internal/genid/wrappers.go
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package genid
|
||||
|
||||
import protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
|
||||
// Generic field name and number for messages in wrappers.proto.
|
||||
const (
|
||||
WrapperValue_Value_field_name protoreflect.Name = "value"
|
||||
WrapperValue_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
175
vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go
generated
vendored
Normal file
175
vendor/google.golang.org/protobuf/internal/genid/wrappers_gen.go
generated
vendored
Normal file
@ -0,0 +1,175 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Code generated by generate-protos. DO NOT EDIT.
|
||||
|
||||
package genid
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
const File_google_protobuf_wrappers_proto = "google/protobuf/wrappers.proto"
|
||||
|
||||
// Names for google.protobuf.DoubleValue.
|
||||
const (
|
||||
DoubleValue_message_name protoreflect.Name = "DoubleValue"
|
||||
DoubleValue_message_fullname protoreflect.FullName = "google.protobuf.DoubleValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.DoubleValue.
|
||||
const (
|
||||
DoubleValue_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
DoubleValue_Value_field_fullname protoreflect.FullName = "google.protobuf.DoubleValue.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.DoubleValue.
|
||||
const (
|
||||
DoubleValue_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.FloatValue.
|
||||
const (
|
||||
FloatValue_message_name protoreflect.Name = "FloatValue"
|
||||
FloatValue_message_fullname protoreflect.FullName = "google.protobuf.FloatValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.FloatValue.
|
||||
const (
|
||||
FloatValue_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
FloatValue_Value_field_fullname protoreflect.FullName = "google.protobuf.FloatValue.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.FloatValue.
|
||||
const (
|
||||
FloatValue_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Int64Value.
|
||||
const (
|
||||
Int64Value_message_name protoreflect.Name = "Int64Value"
|
||||
Int64Value_message_fullname protoreflect.FullName = "google.protobuf.Int64Value"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Int64Value.
|
||||
const (
|
||||
Int64Value_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
Int64Value_Value_field_fullname protoreflect.FullName = "google.protobuf.Int64Value.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Int64Value.
|
||||
const (
|
||||
Int64Value_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.UInt64Value.
|
||||
const (
|
||||
UInt64Value_message_name protoreflect.Name = "UInt64Value"
|
||||
UInt64Value_message_fullname protoreflect.FullName = "google.protobuf.UInt64Value"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.UInt64Value.
|
||||
const (
|
||||
UInt64Value_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
UInt64Value_Value_field_fullname protoreflect.FullName = "google.protobuf.UInt64Value.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UInt64Value.
|
||||
const (
|
||||
UInt64Value_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.Int32Value.
|
||||
const (
|
||||
Int32Value_message_name protoreflect.Name = "Int32Value"
|
||||
Int32Value_message_fullname protoreflect.FullName = "google.protobuf.Int32Value"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.Int32Value.
|
||||
const (
|
||||
Int32Value_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
Int32Value_Value_field_fullname protoreflect.FullName = "google.protobuf.Int32Value.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.Int32Value.
|
||||
const (
|
||||
Int32Value_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.UInt32Value.
|
||||
const (
|
||||
UInt32Value_message_name protoreflect.Name = "UInt32Value"
|
||||
UInt32Value_message_fullname protoreflect.FullName = "google.protobuf.UInt32Value"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.UInt32Value.
|
||||
const (
|
||||
UInt32Value_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
UInt32Value_Value_field_fullname protoreflect.FullName = "google.protobuf.UInt32Value.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.UInt32Value.
|
||||
const (
|
||||
UInt32Value_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.BoolValue.
|
||||
const (
|
||||
BoolValue_message_name protoreflect.Name = "BoolValue"
|
||||
BoolValue_message_fullname protoreflect.FullName = "google.protobuf.BoolValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.BoolValue.
|
||||
const (
|
||||
BoolValue_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
BoolValue_Value_field_fullname protoreflect.FullName = "google.protobuf.BoolValue.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.BoolValue.
|
||||
const (
|
||||
BoolValue_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.StringValue.
|
||||
const (
|
||||
StringValue_message_name protoreflect.Name = "StringValue"
|
||||
StringValue_message_fullname protoreflect.FullName = "google.protobuf.StringValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.StringValue.
|
||||
const (
|
||||
StringValue_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
StringValue_Value_field_fullname protoreflect.FullName = "google.protobuf.StringValue.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.StringValue.
|
||||
const (
|
||||
StringValue_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
||||
|
||||
// Names for google.protobuf.BytesValue.
|
||||
const (
|
||||
BytesValue_message_name protoreflect.Name = "BytesValue"
|
||||
BytesValue_message_fullname protoreflect.FullName = "google.protobuf.BytesValue"
|
||||
)
|
||||
|
||||
// Field names for google.protobuf.BytesValue.
|
||||
const (
|
||||
BytesValue_Value_field_name protoreflect.Name = "value"
|
||||
|
||||
BytesValue_Value_field_fullname protoreflect.FullName = "google.protobuf.BytesValue.value"
|
||||
)
|
||||
|
||||
// Field numbers for google.protobuf.BytesValue.
|
||||
const (
|
||||
BytesValue_Value_field_number protoreflect.FieldNumber = 1
|
||||
)
|
25
vendor/google.golang.org/protobuf/internal/genname/name.go
generated
vendored
25
vendor/google.golang.org/protobuf/internal/genname/name.go
generated
vendored
@ -1,25 +0,0 @@
|
||||
// Copyright 2019 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package genname contains constants for generated names.
|
||||
package genname
|
||||
|
||||
const (
|
||||
State = "state"
|
||||
|
||||
SizeCache = "sizeCache"
|
||||
SizeCacheA = "XXX_sizecache"
|
||||
|
||||
WeakFields = "weakFields"
|
||||
WeakFieldsA = "XXX_weak"
|
||||
|
||||
UnknownFields = "unknownFields"
|
||||
UnknownFieldsA = "XXX_unrecognized"
|
||||
|
||||
ExtensionFields = "extensionFields"
|
||||
ExtensionFieldsA = "XXX_InternalExtensions"
|
||||
ExtensionFieldsB = "XXX_extensions"
|
||||
|
||||
WeakFieldPrefix = "XXX_weak_"
|
||||
)
|
9
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
9
vendor/google.golang.org/protobuf/internal/impl/api_export.go
generated
vendored
@ -10,6 +10,7 @@ import (
|
||||
"strconv"
|
||||
|
||||
"google.golang.org/protobuf/encoding/prototext"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
@ -19,6 +20,12 @@ import (
|
||||
// functions that we do not want to appear in godoc.
|
||||
type Export struct{}
|
||||
|
||||
// NewError formats a string according to the format specifier and arguments and
|
||||
// returns an error that has a "proto" prefix.
|
||||
func (Export) NewError(f string, x ...interface{}) error {
|
||||
return errors.New(f, x...)
|
||||
}
|
||||
|
||||
// enum is any enum type generated by protoc-gen-go
|
||||
// and must be a named int32 type.
|
||||
type enum = interface{}
|
||||
@ -160,7 +167,7 @@ func (Export) MessageTypeOf(m message) pref.MessageType {
|
||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||
return mv.ProtoReflect().Type()
|
||||
}
|
||||
return legacyLoadMessageInfo(reflect.TypeOf(m), "")
|
||||
return legacyLoadMessageType(reflect.TypeOf(m), "")
|
||||
}
|
||||
|
||||
// MessageStringOf returns the message value as a string,
|
||||
|
18
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
18
vendor/google.golang.org/protobuf/internal/impl/codec_field.go
generated
vendored
@ -10,6 +10,7 @@ import (
|
||||
"sync"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/errors"
|
||||
"google.golang.org/protobuf/proto"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
@ -20,6 +21,7 @@ type errInvalidUTF8 struct{}
|
||||
|
||||
func (errInvalidUTF8) Error() string { return "string field contains invalid UTF-8" }
|
||||
func (errInvalidUTF8) InvalidUTF8() bool { return true }
|
||||
func (errInvalidUTF8) Unwrap() error { return errors.Error }
|
||||
|
||||
// initOneofFieldCoders initializes the fast-path functions for the fields in a oneof.
|
||||
//
|
||||
@ -242,7 +244,7 @@ func consumeMessageInfo(b []byte, p pointer, wtyp protowire.Type, f *coderFieldI
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if p.Elem().IsNil() {
|
||||
p.SetPointer(pointerOfValue(reflect.New(f.mi.GoReflectType.Elem())))
|
||||
@ -276,7 +278,7 @@ func consumeMessage(b []byte, m proto.Message, wtyp protowire.Type, opts unmarsh
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: v,
|
||||
@ -420,7 +422,7 @@ func consumeGroup(b []byte, m proto.Message, num protowire.Number, wtyp protowir
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
Buf: b,
|
||||
@ -494,7 +496,7 @@ func consumeMessageSliceInfo(b []byte, p pointer, wtyp protowire.Type, f *coderF
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
m := reflect.New(f.mi.GoReflectType.Elem()).Interface()
|
||||
mp := pointerOfIface(m)
|
||||
@ -550,7 +552,7 @@ func consumeMessageSlice(b []byte, p pointer, goType reflect.Type, wtyp protowir
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
mp := reflect.New(goType.Elem())
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
@ -613,7 +615,7 @@ func consumeMessageSliceValue(b []byte, listv pref.Value, _ protowire.Number, wt
|
||||
}
|
||||
v, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return pref.Value{}, out, protowire.ParseError(n)
|
||||
return pref.Value{}, out, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
@ -681,7 +683,7 @@ func consumeGroupSliceValue(b []byte, listv pref.Value, num protowire.Number, wt
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return pref.Value{}, out, protowire.ParseError(n)
|
||||
return pref.Value{}, out, errDecode
|
||||
}
|
||||
m := list.NewElement()
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
@ -767,7 +769,7 @@ func consumeGroupSlice(b []byte, p pointer, num protowire.Number, wtyp protowire
|
||||
}
|
||||
b, n := protowire.ConsumeGroup(num, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
mp := reflect.New(goType.Elem())
|
||||
o, err := opts.Options().UnmarshalState(piface.UnmarshalInput{
|
||||
|
974
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
974
vendor/google.golang.org/protobuf/internal/impl/codec_gen.go
generated
vendored
File diff suppressed because it is too large
Load Diff
24
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
24
vendor/google.golang.org/protobuf/internal/impl/codec_map.go
generated
vendored
@ -5,11 +5,11 @@
|
||||
package impl
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"reflect"
|
||||
"sort"
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
|
||||
@ -117,7 +117,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
}
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
var (
|
||||
key = mapi.keyZero
|
||||
@ -126,15 +126,15 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
for len(b) > 0 {
|
||||
num, wtyp, n := protowire.ConsumeTag(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if num > protowire.MaxValidNumber {
|
||||
return out, errors.New("invalid field number")
|
||||
return out, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
err := errUnknown
|
||||
switch num {
|
||||
case 1:
|
||||
case genid.MapEntry_Key_field_number:
|
||||
var v pref.Value
|
||||
var o unmarshalOutput
|
||||
v, o, err = mapi.keyFuncs.unmarshal(b, key, num, wtyp, opts)
|
||||
@ -143,7 +143,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
}
|
||||
key = v
|
||||
n = o.n
|
||||
case 2:
|
||||
case genid.MapEntry_Value_field_number:
|
||||
var v pref.Value
|
||||
var o unmarshalOutput
|
||||
v, o, err = mapi.valFuncs.unmarshal(b, val, num, wtyp, opts)
|
||||
@ -156,7 +156,7 @@ func consumeMap(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi *mapInfo
|
||||
if err == errUnknown {
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
} else if err != nil {
|
||||
return out, err
|
||||
@ -174,7 +174,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
}
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
var (
|
||||
key = mapi.keyZero
|
||||
@ -183,10 +183,10 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
for len(b) > 0 {
|
||||
num, wtyp, n := protowire.ConsumeTag(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if num > protowire.MaxValidNumber {
|
||||
return out, errors.New("invalid field number")
|
||||
return out, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
err := errUnknown
|
||||
@ -207,7 +207,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
var v []byte
|
||||
v, n = protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
var o unmarshalOutput
|
||||
o, err = f.mi.unmarshalPointer(v, pointerOfValue(val), 0, opts)
|
||||
@ -220,7 +220,7 @@ func consumeMapOfMessage(b []byte, mapv reflect.Value, wtyp protowire.Type, mapi
|
||||
if err == errUnknown {
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
} else if err != nil {
|
||||
return out, err
|
||||
|
68
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
68
vendor/google.golang.org/protobuf/internal/impl/codec_message.go
generated
vendored
@ -11,7 +11,7 @@ import (
|
||||
|
||||
"google.golang.org/protobuf/encoding/protowire"
|
||||
"google.golang.org/protobuf/internal/encoding/messageset"
|
||||
"google.golang.org/protobuf/internal/fieldsort"
|
||||
"google.golang.org/protobuf/internal/order"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
@ -27,6 +27,7 @@ type coderMessageInfo struct {
|
||||
coderFields map[protowire.Number]*coderFieldInfo
|
||||
sizecacheOffset offset
|
||||
unknownOffset offset
|
||||
unknownPtrKind bool
|
||||
extensionOffset offset
|
||||
needsInitCheck bool
|
||||
isMessageSet bool
|
||||
@ -47,9 +48,20 @@ type coderFieldInfo struct {
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
mi.sizecacheOffset = si.sizecacheOffset
|
||||
mi.unknownOffset = si.unknownOffset
|
||||
mi.extensionOffset = si.extensionOffset
|
||||
mi.sizecacheOffset = invalidOffset
|
||||
mi.unknownOffset = invalidOffset
|
||||
mi.extensionOffset = invalidOffset
|
||||
|
||||
if si.sizecacheOffset.IsValid() && si.sizecacheType == sizecacheType {
|
||||
mi.sizecacheOffset = si.sizecacheOffset
|
||||
}
|
||||
if si.unknownOffset.IsValid() && (si.unknownType == unknownFieldsAType || si.unknownType == unknownFieldsBType) {
|
||||
mi.unknownOffset = si.unknownOffset
|
||||
mi.unknownPtrKind = si.unknownType.Kind() == reflect.Ptr
|
||||
}
|
||||
if si.extensionOffset.IsValid() && si.extensionType == extensionFieldsType {
|
||||
mi.extensionOffset = si.extensionOffset
|
||||
}
|
||||
|
||||
mi.coderFields = make(map[protowire.Number]*coderFieldInfo)
|
||||
fields := mi.Desc.Fields()
|
||||
@ -73,6 +85,27 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
var funcs pointerCoderFuncs
|
||||
var childMessage *MessageInfo
|
||||
switch {
|
||||
case ft == nil:
|
||||
// This never occurs for generated message types.
|
||||
// It implies that a hand-crafted type has missing Go fields
|
||||
// for specific protobuf message fields.
|
||||
funcs = pointerCoderFuncs{
|
||||
size: func(p pointer, f *coderFieldInfo, opts marshalOptions) int {
|
||||
return 0
|
||||
},
|
||||
marshal: func(b []byte, p pointer, f *coderFieldInfo, opts marshalOptions) ([]byte, error) {
|
||||
return nil, nil
|
||||
},
|
||||
unmarshal: func(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, opts unmarshalOptions) (unmarshalOutput, error) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
isInit: func(p pointer, f *coderFieldInfo) error {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
merge: func(dst, src pointer, f *coderFieldInfo, opts mergeOptions) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
}
|
||||
case isOneof:
|
||||
fieldOffset = offsetOf(fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
@ -136,7 +169,7 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
sort.Slice(mi.orderedCoderFields, func(i, j int) bool {
|
||||
fi := fields.ByNumber(mi.orderedCoderFields[i].num)
|
||||
fj := fields.ByNumber(mi.orderedCoderFields[j].num)
|
||||
return fieldsort.Less(fi, fj)
|
||||
return order.LegacyFieldOrder(fi, fj)
|
||||
})
|
||||
}
|
||||
|
||||
@ -157,3 +190,28 @@ func (mi *MessageInfo) makeCoderMethods(t reflect.Type, si structInfo) {
|
||||
mi.methods.Merge = mi.merge
|
||||
}
|
||||
}
|
||||
|
||||
// getUnknownBytes returns a *[]byte for the unknown fields.
|
||||
// It is the caller's responsibility to check whether the pointer is nil.
|
||||
// This function is specially designed to be inlineable.
|
||||
func (mi *MessageInfo) getUnknownBytes(p pointer) *[]byte {
|
||||
if mi.unknownPtrKind {
|
||||
return *p.Apply(mi.unknownOffset).BytesPtr()
|
||||
} else {
|
||||
return p.Apply(mi.unknownOffset).Bytes()
|
||||
}
|
||||
}
|
||||
|
||||
// mutableUnknownBytes returns a *[]byte for the unknown fields.
|
||||
// The returned pointer is guaranteed to not be nil.
|
||||
func (mi *MessageInfo) mutableUnknownBytes(p pointer) *[]byte {
|
||||
if mi.unknownPtrKind {
|
||||
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||
if *bp == nil {
|
||||
*bp = new([]byte)
|
||||
}
|
||||
return *bp
|
||||
} else {
|
||||
return p.Apply(mi.unknownOffset).Bytes()
|
||||
}
|
||||
}
|
||||
|
21
vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
generated
vendored
21
vendor/google.golang.org/protobuf/internal/impl/codec_messageset.go
generated
vendored
@ -29,8 +29,9 @@ func sizeMessageSet(mi *MessageInfo, p pointer, opts marshalOptions) (size int)
|
||||
size += xi.funcs.size(x.Value(), protowire.SizeTag(messageset.FieldMessage), opts)
|
||||
}
|
||||
|
||||
unknown := *p.Apply(mi.unknownOffset).Bytes()
|
||||
size += messageset.SizeUnknown(unknown)
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
size += messageset.SizeUnknown(*u)
|
||||
}
|
||||
|
||||
return size
|
||||
}
|
||||
@ -69,10 +70,12 @@ func marshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts marshalOptions
|
||||
}
|
||||
}
|
||||
|
||||
unknown := *p.Apply(mi.unknownOffset).Bytes()
|
||||
b, err := messageset.AppendUnknown(b, unknown)
|
||||
if err != nil {
|
||||
return b, err
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
var err error
|
||||
b, err = messageset.AppendUnknown(b, *u)
|
||||
if err != nil {
|
||||
return b, err
|
||||
}
|
||||
}
|
||||
|
||||
return b, nil
|
||||
@ -100,13 +103,13 @@ func unmarshalMessageSet(mi *MessageInfo, b []byte, p pointer, opts unmarshalOpt
|
||||
*ep = make(map[int32]ExtensionField)
|
||||
}
|
||||
ext := *ep
|
||||
unknown := p.Apply(mi.unknownOffset).Bytes()
|
||||
initialized := true
|
||||
err = messageset.Unmarshal(b, true, func(num protowire.Number, v []byte) error {
|
||||
o, err := mi.unmarshalExtension(v, num, protowire.BytesType, ext, opts)
|
||||
if err == errUnknown {
|
||||
*unknown = protowire.AppendTag(*unknown, num, protowire.BytesType)
|
||||
*unknown = append(*unknown, v...)
|
||||
u := mi.mutableUnknownBytes(p)
|
||||
*u = protowire.AppendTag(*u, num, protowire.BytesType)
|
||||
*u = append(*u, v...)
|
||||
return nil
|
||||
}
|
||||
if !o.initialized {
|
||||
|
8
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
8
vendor/google.golang.org/protobuf/internal/impl/codec_reflect.go
generated
vendored
@ -30,7 +30,7 @@ func consumeEnum(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInfo, _
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
p.v.Elem().SetInt(int64(v))
|
||||
out.n = n
|
||||
@ -130,12 +130,12 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||
if wtyp == protowire.BytesType {
|
||||
b, n := protowire.ConsumeBytes(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
for len(b) > 0 {
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
rv := reflect.New(s.Type().Elem()).Elem()
|
||||
rv.SetInt(int64(v))
|
||||
@ -150,7 +150,7 @@ func consumeEnumSlice(b []byte, p pointer, wtyp protowire.Type, f *coderFieldInf
|
||||
}
|
||||
v, n := protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
rv := reflect.New(s.Type().Elem()).Elem()
|
||||
rv.SetInt(int64(v))
|
||||
|
29
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
29
vendor/google.golang.org/protobuf/internal/impl/convert.go
generated
vendored
@ -423,6 +423,13 @@ func (c *messageConverter) PBValueOf(v reflect.Value) pref.Value {
|
||||
if v.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", v.Type(), c.goType))
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
if v.CanAddr() {
|
||||
v = v.Addr() // T => *T
|
||||
} else {
|
||||
v = reflect.Zero(reflect.PtrTo(v.Type()))
|
||||
}
|
||||
}
|
||||
if m, ok := v.Interface().(pref.ProtoMessage); ok {
|
||||
return pref.ValueOfMessage(m.ProtoReflect())
|
||||
}
|
||||
@ -437,6 +444,16 @@ func (c *messageConverter) GoValueOf(v pref.Value) reflect.Value {
|
||||
} else {
|
||||
rv = reflect.ValueOf(m.Interface())
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
if rv.Type() != reflect.PtrTo(c.goType) {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), reflect.PtrTo(c.goType)))
|
||||
}
|
||||
if !rv.IsNil() {
|
||||
rv = rv.Elem() // *T => T
|
||||
} else {
|
||||
rv = reflect.Zero(rv.Type().Elem())
|
||||
}
|
||||
}
|
||||
if rv.Type() != c.goType {
|
||||
panic(fmt.Sprintf("invalid type: got %v, want %v", rv.Type(), c.goType))
|
||||
}
|
||||
@ -451,6 +468,9 @@ func (c *messageConverter) IsValidPB(v pref.Value) bool {
|
||||
} else {
|
||||
rv = reflect.ValueOf(m.Interface())
|
||||
}
|
||||
if c.isNonPointer() {
|
||||
return rv.Type() == reflect.PtrTo(c.goType)
|
||||
}
|
||||
return rv.Type() == c.goType
|
||||
}
|
||||
|
||||
@ -459,9 +479,18 @@ func (c *messageConverter) IsValidGo(v reflect.Value) bool {
|
||||
}
|
||||
|
||||
func (c *messageConverter) New() pref.Value {
|
||||
if c.isNonPointer() {
|
||||
return c.PBValueOf(reflect.New(c.goType).Elem())
|
||||
}
|
||||
return c.PBValueOf(reflect.New(c.goType.Elem()))
|
||||
}
|
||||
|
||||
func (c *messageConverter) Zero() pref.Value {
|
||||
return c.PBValueOf(reflect.Zero(c.goType))
|
||||
}
|
||||
|
||||
// isNonPointer reports whether the type is a non-pointer type.
|
||||
// This never occurs for generated message types.
|
||||
func (c *messageConverter) isNonPointer() bool {
|
||||
return c.goType.Kind() != reflect.Ptr
|
||||
}
|
||||
|
16
vendor/google.golang.org/protobuf/internal/impl/decode.go
generated
vendored
16
vendor/google.golang.org/protobuf/internal/impl/decode.go
generated
vendored
@ -17,6 +17,8 @@ import (
|
||||
piface "google.golang.org/protobuf/runtime/protoiface"
|
||||
)
|
||||
|
||||
var errDecode = errors.New("cannot parse invalid wire-format data")
|
||||
|
||||
type unmarshalOptions struct {
|
||||
flags protoiface.UnmarshalInputFlags
|
||||
resolver interface {
|
||||
@ -100,13 +102,13 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
var n int
|
||||
tag, n = protowire.ConsumeVarint(b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
b = b[n:]
|
||||
}
|
||||
var num protowire.Number
|
||||
if n := tag >> 3; n < uint64(protowire.MinValidNumber) || n > uint64(protowire.MaxValidNumber) {
|
||||
return out, errors.New("invalid field number")
|
||||
return out, errDecode
|
||||
} else {
|
||||
num = protowire.Number(n)
|
||||
}
|
||||
@ -114,7 +116,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
|
||||
if wtyp == protowire.EndGroupType {
|
||||
if num != groupTag {
|
||||
return out, errors.New("mismatching end group marker")
|
||||
return out, errDecode
|
||||
}
|
||||
groupTag = 0
|
||||
break
|
||||
@ -170,10 +172,10 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
}
|
||||
n = protowire.ConsumeFieldValue(num, wtyp, b)
|
||||
if n < 0 {
|
||||
return out, protowire.ParseError(n)
|
||||
return out, errDecode
|
||||
}
|
||||
if !opts.DiscardUnknown() && mi.unknownOffset.IsValid() {
|
||||
u := p.Apply(mi.unknownOffset).Bytes()
|
||||
u := mi.mutableUnknownBytes(p)
|
||||
*u = protowire.AppendTag(*u, num, wtyp)
|
||||
*u = append(*u, b[:n]...)
|
||||
}
|
||||
@ -181,7 +183,7 @@ func (mi *MessageInfo) unmarshalPointer(b []byte, p pointer, groupTag protowire.
|
||||
b = b[n:]
|
||||
}
|
||||
if groupTag != 0 {
|
||||
return out, errors.New("missing end group marker")
|
||||
return out, errDecode
|
||||
}
|
||||
if mi.numRequiredFields > 0 && bits.OnesCount64(requiredMask) != int(mi.numRequiredFields) {
|
||||
initialized = false
|
||||
@ -221,7 +223,7 @@ func (mi *MessageInfo) unmarshalExtension(b []byte, num protowire.Number, wtyp p
|
||||
return out, nil
|
||||
}
|
||||
case ValidationInvalid:
|
||||
return out, errors.New("invalid wire format")
|
||||
return out, errDecode
|
||||
case ValidationUnknown:
|
||||
}
|
||||
}
|
||||
|
10
vendor/google.golang.org/protobuf/internal/impl/encode.go
generated
vendored
10
vendor/google.golang.org/protobuf/internal/impl/encode.go
generated
vendored
@ -79,8 +79,9 @@ func (mi *MessageInfo) sizePointerSlow(p pointer, opts marshalOptions) (size int
|
||||
size += f.funcs.size(fptr, f, opts)
|
||||
}
|
||||
if mi.unknownOffset.IsValid() {
|
||||
u := *p.Apply(mi.unknownOffset).Bytes()
|
||||
size += len(u)
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
size += len(*u)
|
||||
}
|
||||
}
|
||||
if mi.sizecacheOffset.IsValid() {
|
||||
if size > math.MaxInt32 {
|
||||
@ -141,8 +142,9 @@ func (mi *MessageInfo) marshalAppendPointer(b []byte, p pointer, opts marshalOpt
|
||||
}
|
||||
}
|
||||
if mi.unknownOffset.IsValid() && !mi.isMessageSet {
|
||||
u := *p.Apply(mi.unknownOffset).Bytes()
|
||||
b = append(b, u...)
|
||||
if u := mi.getUnknownBytes(p); u != nil {
|
||||
b = append(b, (*u)...)
|
||||
}
|
||||
}
|
||||
return b, nil
|
||||
}
|
||||
|
2
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
2
vendor/google.golang.org/protobuf/internal/impl/legacy_export.go
generated
vendored
@ -30,7 +30,7 @@ func (Export) LegacyMessageTypeOf(m piface.MessageV1, name pref.FullName) pref.M
|
||||
if mv := (Export{}).protoMessageV2Of(m); mv != nil {
|
||||
return mv.ProtoReflect().Type()
|
||||
}
|
||||
return legacyLoadMessageInfo(reflect.TypeOf(m), name)
|
||||
return legacyLoadMessageType(reflect.TypeOf(m), name)
|
||||
}
|
||||
|
||||
// UnmarshalJSONEnum unmarshals an enum from a JSON-encoded input.
|
||||
|
3
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
3
vendor/google.golang.org/protobuf/internal/impl/legacy_extension.go
generated
vendored
@ -154,7 +154,8 @@ func (x placeholderExtension) Number() pref.FieldNumber { retu
|
||||
func (x placeholderExtension) Cardinality() pref.Cardinality { return 0 }
|
||||
func (x placeholderExtension) Kind() pref.Kind { return 0 }
|
||||
func (x placeholderExtension) HasJSONName() bool { return false }
|
||||
func (x placeholderExtension) JSONName() string { return "" }
|
||||
func (x placeholderExtension) JSONName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) TextName() string { return "[" + string(x.name) + "]" }
|
||||
func (x placeholderExtension) HasPresence() bool { return false }
|
||||
func (x placeholderExtension) HasOptionalKeyword() bool { return false }
|
||||
func (x placeholderExtension) IsExtension() bool { return true }
|
||||
|
122
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
122
vendor/google.golang.org/protobuf/internal/impl/legacy_message.go
generated
vendored
@ -24,14 +24,24 @@ import (
|
||||
// legacyWrapMessage wraps v as a protoreflect.Message,
|
||||
// where v must be a *struct kind and not implement the v2 API already.
|
||||
func legacyWrapMessage(v reflect.Value) pref.Message {
|
||||
typ := v.Type()
|
||||
if typ.Kind() != reflect.Ptr || typ.Elem().Kind() != reflect.Struct {
|
||||
t := v.Type()
|
||||
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
|
||||
return aberrantMessage{v: v}
|
||||
}
|
||||
mt := legacyLoadMessageInfo(typ, "")
|
||||
mt := legacyLoadMessageInfo(t, "")
|
||||
return mt.MessageOf(v.Interface())
|
||||
}
|
||||
|
||||
// legacyLoadMessageType dynamically loads a protoreflect.Type for t,
|
||||
// where t must be not implement the v2 API already.
|
||||
// The provided name is used if it cannot be determined from the message.
|
||||
func legacyLoadMessageType(t reflect.Type, name pref.FullName) protoreflect.MessageType {
|
||||
if t.Kind() != reflect.Ptr || t.Elem().Kind() != reflect.Struct {
|
||||
return aberrantMessageType{t}
|
||||
}
|
||||
return legacyLoadMessageInfo(t, name)
|
||||
}
|
||||
|
||||
var legacyMessageTypeCache sync.Map // map[reflect.Type]*MessageInfo
|
||||
|
||||
// legacyLoadMessageInfo dynamically loads a *MessageInfo for t,
|
||||
@ -49,8 +59,9 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||
GoReflectType: t,
|
||||
}
|
||||
|
||||
var hasMarshal, hasUnmarshal bool
|
||||
v := reflect.Zero(t).Interface()
|
||||
if _, ok := v.(legacyMarshaler); ok {
|
||||
if _, hasMarshal = v.(legacyMarshaler); hasMarshal {
|
||||
mi.methods.Marshal = legacyMarshal
|
||||
|
||||
// We have no way to tell whether the type's Marshal method
|
||||
@ -59,10 +70,10 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||
// calling Marshal methods when present.
|
||||
mi.methods.Flags |= piface.SupportMarshalDeterministic
|
||||
}
|
||||
if _, ok := v.(legacyUnmarshaler); ok {
|
||||
if _, hasUnmarshal = v.(legacyUnmarshaler); hasUnmarshal {
|
||||
mi.methods.Unmarshal = legacyUnmarshal
|
||||
}
|
||||
if _, ok := v.(legacyMerger); ok {
|
||||
if _, hasMerge := v.(legacyMerger); hasMerge || (hasMarshal && hasUnmarshal) {
|
||||
mi.methods.Merge = legacyMerge
|
||||
}
|
||||
|
||||
@ -75,7 +86,7 @@ func legacyLoadMessageInfo(t reflect.Type, name pref.FullName) *MessageInfo {
|
||||
var legacyMessageDescCache sync.Map // map[reflect.Type]protoreflect.MessageDescriptor
|
||||
|
||||
// LegacyLoadMessageDesc returns an MessageDescriptor derived from the Go type,
|
||||
// which must be a *struct kind and not implement the v2 API already.
|
||||
// which should be a *struct kind and must not implement the v2 API already.
|
||||
//
|
||||
// This is exported for testing purposes.
|
||||
func LegacyLoadMessageDesc(t reflect.Type) pref.MessageDescriptor {
|
||||
@ -114,17 +125,19 @@ func legacyLoadMessageDesc(t reflect.Type, name pref.FullName) pref.MessageDescr
|
||||
// If the Go type has no fields, then this might be a proto3 empty message
|
||||
// from before the size cache was added. If there are any fields, check to
|
||||
// see that at least one of them looks like something we generated.
|
||||
if nfield := t.Elem().NumField(); nfield > 0 {
|
||||
hasProtoField := false
|
||||
for i := 0; i < nfield; i++ {
|
||||
f := t.Elem().Field(i)
|
||||
if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") {
|
||||
hasProtoField = true
|
||||
break
|
||||
if t.Elem().Kind() == reflect.Struct {
|
||||
if nfield := t.Elem().NumField(); nfield > 0 {
|
||||
hasProtoField := false
|
||||
for i := 0; i < nfield; i++ {
|
||||
f := t.Elem().Field(i)
|
||||
if f.Tag.Get("protobuf") != "" || f.Tag.Get("protobuf_oneof") != "" || strings.HasPrefix(f.Name, "XXX_") {
|
||||
hasProtoField = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !hasProtoField {
|
||||
return aberrantLoadMessageDesc(t, name)
|
||||
}
|
||||
}
|
||||
if !hasProtoField {
|
||||
return aberrantLoadMessageDesc(t, name)
|
||||
}
|
||||
}
|
||||
|
||||
@ -370,7 +383,7 @@ type legacyMerger interface {
|
||||
Merge(protoiface.MessageV1)
|
||||
}
|
||||
|
||||
var legacyProtoMethods = &piface.Methods{
|
||||
var aberrantProtoMethods = &piface.Methods{
|
||||
Marshal: legacyMarshal,
|
||||
Unmarshal: legacyUnmarshal,
|
||||
Merge: legacyMerge,
|
||||
@ -401,18 +414,40 @@ func legacyUnmarshal(in piface.UnmarshalInput) (piface.UnmarshalOutput, error) {
|
||||
v := in.Message.(unwrapper).protoUnwrap()
|
||||
unmarshaler, ok := v.(legacyUnmarshaler)
|
||||
if !ok {
|
||||
return piface.UnmarshalOutput{}, errors.New("%T does not implement Marshal", v)
|
||||
return piface.UnmarshalOutput{}, errors.New("%T does not implement Unmarshal", v)
|
||||
}
|
||||
return piface.UnmarshalOutput{}, unmarshaler.Unmarshal(in.Buf)
|
||||
}
|
||||
|
||||
func legacyMerge(in piface.MergeInput) piface.MergeOutput {
|
||||
// Check whether this supports the legacy merger.
|
||||
dstv := in.Destination.(unwrapper).protoUnwrap()
|
||||
merger, ok := dstv.(legacyMerger)
|
||||
if ok {
|
||||
merger.Merge(Export{}.ProtoMessageV1Of(in.Source))
|
||||
return piface.MergeOutput{Flags: piface.MergeComplete}
|
||||
}
|
||||
|
||||
// If legacy merger is unavailable, implement merge in terms of
|
||||
// a marshal and unmarshal operation.
|
||||
srcv := in.Source.(unwrapper).protoUnwrap()
|
||||
marshaler, ok := srcv.(legacyMarshaler)
|
||||
if !ok {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
merger.Merge(Export{}.ProtoMessageV1Of(in.Source))
|
||||
dstv = in.Destination.(unwrapper).protoUnwrap()
|
||||
unmarshaler, ok := dstv.(legacyUnmarshaler)
|
||||
if !ok {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
b, err := marshaler.Marshal()
|
||||
if err != nil {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
err = unmarshaler.Unmarshal(b)
|
||||
if err != nil {
|
||||
return piface.MergeOutput{}
|
||||
}
|
||||
return piface.MergeOutput{Flags: piface.MergeComplete}
|
||||
}
|
||||
|
||||
@ -422,6 +457,9 @@ type aberrantMessageType struct {
|
||||
}
|
||||
|
||||
func (mt aberrantMessageType) New() pref.Message {
|
||||
if mt.t.Kind() == reflect.Ptr {
|
||||
return aberrantMessage{reflect.New(mt.t.Elem())}
|
||||
}
|
||||
return aberrantMessage{reflect.Zero(mt.t)}
|
||||
}
|
||||
func (mt aberrantMessageType) Zero() pref.Message {
|
||||
@ -443,6 +481,17 @@ type aberrantMessage struct {
|
||||
v reflect.Value
|
||||
}
|
||||
|
||||
// Reset implements the v1 proto.Message.Reset method.
|
||||
func (m aberrantMessage) Reset() {
|
||||
if mr, ok := m.v.Interface().(interface{ Reset() }); ok {
|
||||
mr.Reset()
|
||||
return
|
||||
}
|
||||
if m.v.Kind() == reflect.Ptr && !m.v.IsNil() {
|
||||
m.v.Elem().Set(reflect.Zero(m.v.Type().Elem()))
|
||||
}
|
||||
}
|
||||
|
||||
func (m aberrantMessage) ProtoReflect() pref.Message {
|
||||
return m
|
||||
}
|
||||
@ -454,33 +503,40 @@ func (m aberrantMessage) Type() pref.MessageType {
|
||||
return aberrantMessageType{m.v.Type()}
|
||||
}
|
||||
func (m aberrantMessage) New() pref.Message {
|
||||
if m.v.Type().Kind() == reflect.Ptr {
|
||||
return aberrantMessage{reflect.New(m.v.Type().Elem())}
|
||||
}
|
||||
return aberrantMessage{reflect.Zero(m.v.Type())}
|
||||
}
|
||||
func (m aberrantMessage) Interface() pref.ProtoMessage {
|
||||
return m
|
||||
}
|
||||
func (m aberrantMessage) Range(f func(pref.FieldDescriptor, pref.Value) bool) {
|
||||
return
|
||||
}
|
||||
func (m aberrantMessage) Has(pref.FieldDescriptor) bool {
|
||||
panic("invalid field descriptor")
|
||||
return false
|
||||
}
|
||||
func (m aberrantMessage) Clear(pref.FieldDescriptor) {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.Clear on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) Get(pref.FieldDescriptor) pref.Value {
|
||||
panic("invalid field descriptor")
|
||||
func (m aberrantMessage) Get(fd pref.FieldDescriptor) pref.Value {
|
||||
if fd.Default().IsValid() {
|
||||
return fd.Default()
|
||||
}
|
||||
panic("invalid Message.Get on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) Set(pref.FieldDescriptor, pref.Value) {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.Set on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) Mutable(pref.FieldDescriptor) pref.Value {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.Mutable on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) NewField(pref.FieldDescriptor) pref.Value {
|
||||
panic("invalid field descriptor")
|
||||
panic("invalid Message.NewField on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) WhichOneof(pref.OneofDescriptor) pref.FieldDescriptor {
|
||||
panic("invalid oneof descriptor")
|
||||
panic("invalid Message.WhichOneof descriptor on " + string(m.Descriptor().FullName()))
|
||||
}
|
||||
func (m aberrantMessage) GetUnknown() pref.RawFields {
|
||||
return nil
|
||||
@ -489,13 +545,13 @@ func (m aberrantMessage) SetUnknown(pref.RawFields) {
|
||||
// SetUnknown discards its input on messages which don't support unknown field storage.
|
||||
}
|
||||
func (m aberrantMessage) IsValid() bool {
|
||||
// An invalid message is a read-only, empty message. Since we don't know anything
|
||||
// about the alleged contents of this message, we can't say with confidence that
|
||||
// it is invalid in this sense. Therefore, report it as valid.
|
||||
return true
|
||||
if m.v.Kind() == reflect.Ptr {
|
||||
return !m.v.IsNil()
|
||||
}
|
||||
return false
|
||||
}
|
||||
func (m aberrantMessage) ProtoMethods() *piface.Methods {
|
||||
return legacyProtoMethods
|
||||
return aberrantProtoMethods
|
||||
}
|
||||
func (m aberrantMessage) protoUnwrap() interface{} {
|
||||
return m.v.Interface()
|
||||
|
6
vendor/google.golang.org/protobuf/internal/impl/merge.go
generated
vendored
6
vendor/google.golang.org/protobuf/internal/impl/merge.go
generated
vendored
@ -77,9 +77,9 @@ func (mi *MessageInfo) mergePointer(dst, src pointer, opts mergeOptions) {
|
||||
}
|
||||
}
|
||||
if mi.unknownOffset.IsValid() {
|
||||
du := dst.Apply(mi.unknownOffset).Bytes()
|
||||
su := src.Apply(mi.unknownOffset).Bytes()
|
||||
if len(*su) > 0 {
|
||||
su := mi.getUnknownBytes(src)
|
||||
if su != nil && len(*su) > 0 {
|
||||
du := mi.mutableUnknownBytes(dst)
|
||||
*du = append(*du, *su...)
|
||||
}
|
||||
}
|
||||
|
79
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
79
vendor/google.golang.org/protobuf/internal/impl/message.go
generated
vendored
@ -12,9 +12,10 @@ import (
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"google.golang.org/protobuf/internal/genname"
|
||||
"google.golang.org/protobuf/internal/genid"
|
||||
"google.golang.org/protobuf/reflect/protoreflect"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
preg "google.golang.org/protobuf/reflect/protoregistry"
|
||||
)
|
||||
|
||||
// MessageInfo provides protobuf related functionality for a given Go type
|
||||
@ -109,22 +110,29 @@ func (mi *MessageInfo) getPointer(m pref.Message) (p pointer, ok bool) {
|
||||
type (
|
||||
SizeCache = int32
|
||||
WeakFields = map[int32]protoreflect.ProtoMessage
|
||||
UnknownFields = []byte
|
||||
UnknownFields = unknownFieldsA // TODO: switch to unknownFieldsB
|
||||
unknownFieldsA = []byte
|
||||
unknownFieldsB = *[]byte
|
||||
ExtensionFields = map[int32]ExtensionField
|
||||
)
|
||||
|
||||
var (
|
||||
sizecacheType = reflect.TypeOf(SizeCache(0))
|
||||
weakFieldsType = reflect.TypeOf(WeakFields(nil))
|
||||
unknownFieldsType = reflect.TypeOf(UnknownFields(nil))
|
||||
unknownFieldsAType = reflect.TypeOf(unknownFieldsA(nil))
|
||||
unknownFieldsBType = reflect.TypeOf(unknownFieldsB(nil))
|
||||
extensionFieldsType = reflect.TypeOf(ExtensionFields(nil))
|
||||
)
|
||||
|
||||
type structInfo struct {
|
||||
sizecacheOffset offset
|
||||
sizecacheType reflect.Type
|
||||
weakOffset offset
|
||||
weakType reflect.Type
|
||||
unknownOffset offset
|
||||
unknownType reflect.Type
|
||||
extensionOffset offset
|
||||
extensionType reflect.Type
|
||||
|
||||
fieldsByNumber map[pref.FieldNumber]reflect.StructField
|
||||
oneofsByName map[pref.Name]reflect.StructField
|
||||
@ -148,21 +156,25 @@ func (mi *MessageInfo) makeStructInfo(t reflect.Type) structInfo {
|
||||
fieldLoop:
|
||||
for i := 0; i < t.NumField(); i++ {
|
||||
switch f := t.Field(i); f.Name {
|
||||
case genname.SizeCache, genname.SizeCacheA:
|
||||
case genid.SizeCache_goname, genid.SizeCacheA_goname:
|
||||
if f.Type == sizecacheType {
|
||||
si.sizecacheOffset = offsetOf(f, mi.Exporter)
|
||||
si.sizecacheType = f.Type
|
||||
}
|
||||
case genname.WeakFields, genname.WeakFieldsA:
|
||||
case genid.WeakFields_goname, genid.WeakFieldsA_goname:
|
||||
if f.Type == weakFieldsType {
|
||||
si.weakOffset = offsetOf(f, mi.Exporter)
|
||||
si.weakType = f.Type
|
||||
}
|
||||
case genname.UnknownFields, genname.UnknownFieldsA:
|
||||
if f.Type == unknownFieldsType {
|
||||
case genid.UnknownFields_goname, genid.UnknownFieldsA_goname:
|
||||
if f.Type == unknownFieldsAType || f.Type == unknownFieldsBType {
|
||||
si.unknownOffset = offsetOf(f, mi.Exporter)
|
||||
si.unknownType = f.Type
|
||||
}
|
||||
case genname.ExtensionFields, genname.ExtensionFieldsA, genname.ExtensionFieldsB:
|
||||
case genid.ExtensionFields_goname, genid.ExtensionFieldsA_goname, genid.ExtensionFieldsB_goname:
|
||||
if f.Type == extensionFieldsType {
|
||||
si.extensionOffset = offsetOf(f, mi.Exporter)
|
||||
si.extensionType = f.Type
|
||||
}
|
||||
default:
|
||||
for _, s := range strings.Split(f.Tag.Get("protobuf"), ",") {
|
||||
@ -212,4 +224,53 @@ func (mi *MessageInfo) New() protoreflect.Message {
|
||||
func (mi *MessageInfo) Zero() protoreflect.Message {
|
||||
return mi.MessageOf(reflect.Zero(mi.GoReflectType).Interface())
|
||||
}
|
||||
func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor { return mi.Desc }
|
||||
func (mi *MessageInfo) Descriptor() protoreflect.MessageDescriptor {
|
||||
return mi.Desc
|
||||
}
|
||||
func (mi *MessageInfo) Enum(i int) protoreflect.EnumType {
|
||||
mi.init()
|
||||
fd := mi.Desc.Fields().Get(i)
|
||||
return Export{}.EnumTypeOf(mi.fieldTypes[fd.Number()])
|
||||
}
|
||||
func (mi *MessageInfo) Message(i int) protoreflect.MessageType {
|
||||
mi.init()
|
||||
fd := mi.Desc.Fields().Get(i)
|
||||
switch {
|
||||
case fd.IsWeak():
|
||||
mt, _ := preg.GlobalTypes.FindMessageByName(fd.Message().FullName())
|
||||
return mt
|
||||
case fd.IsMap():
|
||||
return mapEntryType{fd.Message(), mi.fieldTypes[fd.Number()]}
|
||||
default:
|
||||
return Export{}.MessageTypeOf(mi.fieldTypes[fd.Number()])
|
||||
}
|
||||
}
|
||||
|
||||
type mapEntryType struct {
|
||||
desc protoreflect.MessageDescriptor
|
||||
valType interface{} // zero value of enum or message type
|
||||
}
|
||||
|
||||
func (mt mapEntryType) New() protoreflect.Message {
|
||||
return nil
|
||||
}
|
||||
func (mt mapEntryType) Zero() protoreflect.Message {
|
||||
return nil
|
||||
}
|
||||
func (mt mapEntryType) Descriptor() protoreflect.MessageDescriptor {
|
||||
return mt.desc
|
||||
}
|
||||
func (mt mapEntryType) Enum(i int) protoreflect.EnumType {
|
||||
fd := mt.desc.Fields().Get(i)
|
||||
if fd.Enum() == nil {
|
||||
return nil
|
||||
}
|
||||
return Export{}.EnumTypeOf(mt.valType)
|
||||
}
|
||||
func (mt mapEntryType) Message(i int) protoreflect.MessageType {
|
||||
fd := mt.desc.Fields().Get(i)
|
||||
if fd.Message() == nil {
|
||||
return nil
|
||||
}
|
||||
return Export{}.MessageTypeOf(mt.valType)
|
||||
}
|
||||
|
125
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
125
vendor/google.golang.org/protobuf/internal/impl/message_reflect.go
generated
vendored
@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
|
||||
"google.golang.org/protobuf/internal/detrand"
|
||||
"google.golang.org/protobuf/internal/pragma"
|
||||
pref "google.golang.org/protobuf/reflect/protoreflect"
|
||||
)
|
||||
@ -16,6 +17,11 @@ type reflectMessageInfo struct {
|
||||
fields map[pref.FieldNumber]*fieldInfo
|
||||
oneofs map[pref.Name]*oneofInfo
|
||||
|
||||
// fieldTypes contains the zero value of an enum or message field.
|
||||
// For lists, it contains the element type.
|
||||
// For maps, it contains the entry value type.
|
||||
fieldTypes map[pref.FieldNumber]interface{}
|
||||
|
||||
// denseFields is a subset of fields where:
|
||||
// 0 < fieldDesc.Number() < len(denseFields)
|
||||
// It provides faster access to the fieldInfo, but may be incomplete.
|
||||
@ -36,6 +42,7 @@ func (mi *MessageInfo) makeReflectFuncs(t reflect.Type, si structInfo) {
|
||||
mi.makeKnownFieldsFunc(si)
|
||||
mi.makeUnknownFieldsFunc(t, si)
|
||||
mi.makeExtensionFieldsFunc(t, si)
|
||||
mi.makeFieldTypes(si)
|
||||
}
|
||||
|
||||
// makeKnownFieldsFunc generates functions for operations that can be performed
|
||||
@ -51,17 +58,23 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
for i := 0; i < fds.Len(); i++ {
|
||||
fd := fds.Get(i)
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||
if isOneof {
|
||||
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||
}
|
||||
var fi fieldInfo
|
||||
switch {
|
||||
case fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic():
|
||||
fi = fieldInfoForOneof(fd, si.oneofsByName[fd.ContainingOneof().Name()], mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
case fs.Type == nil:
|
||||
fi = fieldInfoForMissing(fd) // never occurs for officially generated message types
|
||||
case isOneof:
|
||||
fi = fieldInfoForOneof(fd, fs, mi.Exporter, si.oneofWrappersByNumber[fd.Number()])
|
||||
case fd.IsMap():
|
||||
fi = fieldInfoForMap(fd, fs, mi.Exporter)
|
||||
case fd.IsList():
|
||||
fi = fieldInfoForList(fd, fs, mi.Exporter)
|
||||
case fd.IsWeak():
|
||||
fi = fieldInfoForWeakMessage(fd, si.weakOffset)
|
||||
case fd.Kind() == pref.MessageKind || fd.Kind() == pref.GroupKind:
|
||||
case fd.Message() != nil:
|
||||
fi = fieldInfoForMessage(fd, fs, mi.Exporter)
|
||||
default:
|
||||
fi = fieldInfoForScalar(fd, fs, mi.Exporter)
|
||||
@ -92,27 +105,53 @@ func (mi *MessageInfo) makeKnownFieldsFunc(si structInfo) {
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// Introduce instability to iteration order, but keep it deterministic.
|
||||
if len(mi.rangeInfos) > 1 && detrand.Bool() {
|
||||
i := detrand.Intn(len(mi.rangeInfos) - 1)
|
||||
mi.rangeInfos[i], mi.rangeInfos[i+1] = mi.rangeInfos[i+1], mi.rangeInfos[i]
|
||||
}
|
||||
}
|
||||
|
||||
func (mi *MessageInfo) makeUnknownFieldsFunc(t reflect.Type, si structInfo) {
|
||||
mi.getUnknown = func(pointer) pref.RawFields { return nil }
|
||||
mi.setUnknown = func(pointer, pref.RawFields) { return }
|
||||
if si.unknownOffset.IsValid() {
|
||||
switch {
|
||||
case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsAType:
|
||||
// Handle as []byte.
|
||||
mi.getUnknown = func(p pointer) pref.RawFields {
|
||||
if p.IsNil() {
|
||||
return nil
|
||||
}
|
||||
rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType)
|
||||
return pref.RawFields(*rv.Interface().(*[]byte))
|
||||
return *p.Apply(mi.unknownOffset).Bytes()
|
||||
}
|
||||
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
||||
if p.IsNil() {
|
||||
panic("invalid SetUnknown on nil Message")
|
||||
}
|
||||
rv := p.Apply(si.unknownOffset).AsValueOf(unknownFieldsType)
|
||||
*rv.Interface().(*[]byte) = []byte(b)
|
||||
*p.Apply(mi.unknownOffset).Bytes() = b
|
||||
}
|
||||
} else {
|
||||
case si.unknownOffset.IsValid() && si.unknownType == unknownFieldsBType:
|
||||
// Handle as *[]byte.
|
||||
mi.getUnknown = func(p pointer) pref.RawFields {
|
||||
if p.IsNil() {
|
||||
return nil
|
||||
}
|
||||
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||
if *bp == nil {
|
||||
return nil
|
||||
}
|
||||
return **bp
|
||||
}
|
||||
mi.setUnknown = func(p pointer, b pref.RawFields) {
|
||||
if p.IsNil() {
|
||||
panic("invalid SetUnknown on nil Message")
|
||||
}
|
||||
bp := p.Apply(mi.unknownOffset).BytesPtr()
|
||||
if *bp == nil {
|
||||
*bp = new([]byte)
|
||||
}
|
||||
**bp = b
|
||||
}
|
||||
default:
|
||||
mi.getUnknown = func(pointer) pref.RawFields {
|
||||
return nil
|
||||
}
|
||||
@ -139,6 +178,58 @@ func (mi *MessageInfo) makeExtensionFieldsFunc(t reflect.Type, si structInfo) {
|
||||
}
|
||||
}
|
||||
}
|
||||
func (mi *MessageInfo) makeFieldTypes(si structInfo) {
|
||||
md := mi.Desc
|
||||
fds := md.Fields()
|
||||
for i := 0; i < fds.Len(); i++ {
|
||||
var ft reflect.Type
|
||||
fd := fds.Get(i)
|
||||
fs := si.fieldsByNumber[fd.Number()]
|
||||
isOneof := fd.ContainingOneof() != nil && !fd.ContainingOneof().IsSynthetic()
|
||||
if isOneof {
|
||||
fs = si.oneofsByName[fd.ContainingOneof().Name()]
|
||||
}
|
||||
var isMessage bool
|
||||
switch {
|
||||
case fs.Type == nil:
|
||||
continue // never occurs for officially generated message types
|
||||
case isOneof:
|
||||
if fd.Enum() != nil || fd.Message() != nil {
|
||||
ft = si.oneofWrappersByNumber[fd.Number()].Field(0).Type
|
||||
}
|
||||
case fd.IsMap():
|
||||
if fd.MapValue().Enum() != nil || fd.MapValue().Message() != nil {
|
||||
ft = fs.Type.Elem()
|
||||
}
|
||||
isMessage = fd.MapValue().Message() != nil
|
||||
case fd.IsList():
|
||||
if fd.Enum() != nil || fd.Message() != nil {
|
||||
ft = fs.Type.Elem()
|
||||
}
|
||||
isMessage = fd.Message() != nil
|
||||
case fd.Enum() != nil:
|
||||
ft = fs.Type
|
||||
if fd.HasPresence() && ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
}
|
||||
case fd.Message() != nil:
|
||||
ft = fs.Type
|
||||
if fd.IsWeak() {
|
||||
ft = nil
|
||||
}
|
||||
isMessage = true
|
||||
}
|
||||
if isMessage && ft != nil && ft.Kind() != reflect.Ptr {
|
||||
ft = reflect.PtrTo(ft) // never occurs for officially generated message types
|
||||
}
|
||||
if ft != nil {
|
||||
if mi.fieldTypes == nil {
|
||||
mi.fieldTypes = make(map[pref.FieldNumber]interface{})
|
||||
}
|
||||
mi.fieldTypes[fd.Number()] = reflect.Zero(ft).Interface()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type extensionMap map[int32]ExtensionField
|
||||
|
||||
@ -306,7 +397,6 @@ var (
|
||||
// pointer to a named Go struct. If the provided type has a ProtoReflect method,
|
||||
// it must be implemented by calling this method.
|
||||
func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
||||
// TODO: Switch the input to be an opaque Pointer.
|
||||
if reflect.TypeOf(m) != mi.GoReflectType {
|
||||
panic(fmt.Sprintf("type mismatch: got %T, want %v", m, mi.GoReflectType))
|
||||
}
|
||||
@ -320,6 +410,17 @@ func (mi *MessageInfo) MessageOf(m interface{}) pref.Message {
|
||||
func (m *messageReflectWrapper) pointer() pointer { return m.p }
|
||||
func (m *messageReflectWrapper) messageInfo() *MessageInfo { return m.mi }
|
||||
|
||||
// Reset implements the v1 proto.Message.Reset method.
|
||||
func (m *messageIfaceWrapper) Reset() {
|
||||
if mr, ok := m.protoUnwrap().(interface{ Reset() }); ok {
|
||||
mr.Reset()
|
||||
return
|
||||
}
|
||||
rv := reflect.ValueOf(m.protoUnwrap())
|
||||
if rv.Kind() == reflect.Ptr && !rv.IsNil() {
|
||||
rv.Elem().Set(reflect.Zero(rv.Type().Elem()))
|
||||
}
|
||||
}
|
||||
func (m *messageIfaceWrapper) ProtoReflect() pref.Message {
|
||||
return (*messageReflectWrapper)(m)
|
||||
}
|
||||
|
85
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
85
vendor/google.golang.org/protobuf/internal/impl/message_reflect_field.go
generated
vendored
@ -28,6 +28,39 @@ type fieldInfo struct {
|
||||
newField func() pref.Value
|
||||
}
|
||||
|
||||
func fieldInfoForMissing(fd pref.FieldDescriptor) fieldInfo {
|
||||
// This never occurs for generated message types.
|
||||
// It implies that a hand-crafted type has missing Go fields
|
||||
// for specific protobuf message fields.
|
||||
return fieldInfo{
|
||||
fieldDesc: fd,
|
||||
has: func(p pointer) bool {
|
||||
return false
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
get: func(p pointer) pref.Value {
|
||||
return fd.Default()
|
||||
},
|
||||
set: func(p pointer, v pref.Value) {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
mutable: func(p pointer) pref.Value {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
newMessage: func() pref.Message {
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
newField: func() pref.Value {
|
||||
if v := fd.Default(); v.IsValid() {
|
||||
return v
|
||||
}
|
||||
panic("missing Go struct field for " + string(fd.FullName()))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x exporter, ot reflect.Type) fieldInfo {
|
||||
ft := fs.Type
|
||||
if ft.Kind() != reflect.Interface {
|
||||
@ -97,7 +130,7 @@ func fieldInfoForOneof(fd pref.FieldDescriptor, fs reflect.StructField, x export
|
||||
rv.Set(reflect.New(ot))
|
||||
}
|
||||
rv = rv.Elem().Elem().Field(0)
|
||||
if rv.IsNil() {
|
||||
if rv.Kind() == reflect.Ptr && rv.IsNil() {
|
||||
rv.Set(conv.GoValueOf(pref.ValueOfMessage(conv.New().Message())))
|
||||
}
|
||||
return conv.PBValueOf(rv)
|
||||
@ -225,7 +258,10 @@ func fieldInfoForScalar(fd pref.FieldDescriptor, fs reflect.StructField, x expor
|
||||
isBytes := ft.Kind() == reflect.Slice && ft.Elem().Kind() == reflect.Uint8
|
||||
if nullable {
|
||||
if ft.Kind() != reflect.Ptr && ft.Kind() != reflect.Slice {
|
||||
panic(fmt.Sprintf("field %v has invalid type: got %v, want pointer", fd.FullName(), ft))
|
||||
// This never occurs for generated message types.
|
||||
// Despite the protobuf type system specifying presence,
|
||||
// the Go field type cannot represent it.
|
||||
nullable = false
|
||||
}
|
||||
if ft.Kind() == reflect.Ptr {
|
||||
ft = ft.Elem()
|
||||
@ -388,6 +424,9 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||
return false
|
||||
}
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if fs.Type.Kind() != reflect.Ptr {
|
||||
return !isZero(rv)
|
||||
}
|
||||
return !rv.IsNil()
|
||||
},
|
||||
clear: func(p pointer) {
|
||||
@ -404,13 +443,13 @@ func fieldInfoForMessage(fd pref.FieldDescriptor, fs reflect.StructField, x expo
|
||||
set: func(p pointer, v pref.Value) {
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
rv.Set(conv.GoValueOf(v))
|
||||
if rv.IsNil() {
|
||||
if fs.Type.Kind() == reflect.Ptr && rv.IsNil() {
|
||||
panic(fmt.Sprintf("field %v has invalid nil pointer", fd.FullName()))
|
||||
}
|
||||
},
|
||||
mutable: func(p pointer) pref.Value {
|
||||
rv := p.Apply(fieldOffset).AsValueOf(fs.Type).Elem()
|
||||
if rv.IsNil() {
|
||||
if fs.Type.Kind() == reflect.Ptr && rv.IsNil() {
|
||||
rv.Set(conv.GoValueOf(conv.New()))
|
||||
}
|
||||
return conv.PBValueOf(rv)
|
||||
@ -464,3 +503,41 @@ func makeOneofInfo(od pref.OneofDescriptor, si structInfo, x exporter) *oneofInf
|
||||
}
|
||||
return oi
|
||||
}
|
||||
|
||||
// isZero is identical to reflect.Value.IsZero.
|
||||
// TODO: Remove this when Go1.13 is the minimally supported Go version.
|
||||
func isZero(v reflect.Value) bool {
|
||||
switch v.Kind() {
|
||||
case reflect.Bool:
|
||||
return !v.Bool()
|
||||
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||
return v.Int() == 0
|
||||
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||
return v.Uint() == 0
|
||||
case reflect.Float32, reflect.Float64:
|
||||
return math.Float64bits(v.Float()) == 0
|
||||
case reflect.Complex64, reflect.Complex128:
|
||||
c := v.Complex()
|
||||
return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
|
||||
case reflect.Array:
|
||||
for i := 0; i < v.Len(); i++ {
|
||||
if !isZero(v.Index(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
||||
return v.IsNil()
|
||||
case reflect.String:
|
||||
return v.Len() == 0
|
||||
case reflect.Struct:
|
||||
for i := 0; i < v.NumField(); i++ {
|
||||
if !isZero(v.Field(i)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
default:
|
||||
panic(&reflect.ValueError{"reflect.Value.IsZero", v.Kind()})
|
||||
}
|
||||
}
|
||||
|
1
vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
generated
vendored
1
vendor/google.golang.org/protobuf/internal/impl/pointer_reflect.go
generated
vendored
@ -121,6 +121,7 @@ func (p pointer) String() *string { return p.v.Interface().(*string) }
|
||||
func (p pointer) StringPtr() **string { return p.v.Interface().(**string) }
|
||||
func (p pointer) StringSlice() *[]string { return p.v.Interface().(*[]string) }
|
||||
func (p pointer) Bytes() *[]byte { return p.v.Interface().(*[]byte) }
|
||||
func (p pointer) BytesPtr() **[]byte { return p.v.Interface().(**[]byte) }
|
||||
func (p pointer) BytesSlice() *[][]byte { return p.v.Interface().(*[][]byte) }
|
||||
func (p pointer) WeakFields() *weakFields { return (*weakFields)(p.v.Interface().(*WeakFields)) }
|
||||
func (p pointer) Extensions() *map[int32]ExtensionField {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user