1
0
mirror of https://github.com/ceph/ceph-csi.git synced 2025-06-14 18:53:35 +00:00

vendor update for CSI 0.3.0

This commit is contained in:
gman
2018-07-18 16:47:22 +02:00
parent 6f484f92fc
commit 8ea659f0d5
6810 changed files with 438061 additions and 193861 deletions
Gopkg.lockGopkg.toml
vendor
github.com
container-storage-interface
golang
protobuf
.gitignore.travis.ymlMake.protobufMakefileREADME.md
conformance
descriptor
jsonpb
proto
protoc-gen-go
ptypes
regenerate.sh
kubernetes-csi
golang.org
x
net
CONTRIBUTING.md
dns
html
http
http2
icmp
internal
ipv4
ipv6
netutil
proxy
publicsuffix
route
trace
webdav
websocket
sys
CONTRIBUTING.md
cpu
plan9
unix
asm_dragonfly_amd64.scap_freebsd.gocreds_test.godev_darwin_test.godev_dragonfly_test.godev_linux_test.godev_netbsd_test.godev_openbsd_test.godev_solaris_test.goexample_test.gofcntl.gofcntl_linux_32bit.gogccgo_c.cioctl.go
linux
mkerrors.shmkpost.gomksysctl_openbsd.plopenbsd_pledge.gosyscall.gosyscall_bsd.gosyscall_darwin.gosyscall_darwin_test.gosyscall_dragonfly.gosyscall_freebsd.gosyscall_freebsd_test.gosyscall_linux.gosyscall_linux_386.gosyscall_linux_amd64.gosyscall_linux_arm.gosyscall_linux_arm64.gosyscall_linux_gc_386.gosyscall_linux_gccgo_386.gosyscall_linux_gccgo_arm.gosyscall_linux_mips64x.gosyscall_linux_mipsx.gosyscall_linux_ppc64x.gosyscall_linux_s390x.gosyscall_linux_sparc64.gosyscall_linux_test.gosyscall_netbsd.gosyscall_openbsd.gosyscall_openbsd_amd64.gosyscall_solaris.gosyscall_solaris_amd64.gosyscall_unix.gosyscall_unix_test.gotypes_netbsd.goxattr_test.gozerrors_darwin_386.gozerrors_darwin_amd64.gozerrors_darwin_arm.gozerrors_darwin_arm64.gozerrors_dragonfly_amd64.gozerrors_freebsd_386.gozerrors_freebsd_amd64.gozerrors_freebsd_arm.gozerrors_linux_386.gozerrors_linux_amd64.gozerrors_linux_arm.gozerrors_linux_arm64.gozerrors_linux_mips.gozerrors_linux_mips64.gozerrors_linux_mips64le.gozerrors_linux_mipsle.gozerrors_linux_ppc64.gozerrors_linux_ppc64le.gozerrors_linux_s390x.gozerrors_linux_sparc64.gozerrors_netbsd_386.gozerrors_netbsd_amd64.gozerrors_netbsd_arm.gozerrors_openbsd_386.gozerrors_openbsd_amd64.gozerrors_openbsd_arm.gozerrors_solaris_amd64.gozsyscall_darwin_386.gozsyscall_darwin_amd64.gozsyscall_darwin_arm.gozsyscall_darwin_arm64.gozsyscall_dragonfly_amd64.gozsyscall_freebsd_386.gozsyscall_freebsd_amd64.gozsyscall_freebsd_arm.gozsyscall_linux_386.gozsyscall_linux_amd64.gozsyscall_linux_arm.gozsyscall_linux_arm64.gozsyscall_linux_mips.gozsyscall_linux_mips64.gozsyscall_linux_mips64le.gozsyscall_linux_mipsle.gozsyscall_linux_ppc64.gozsyscall_linux_ppc64le.gozsyscall_linux_s390x.gozsyscall_linux_sparc64.gozsyscall_netbsd_386.gozsyscall_netbsd_amd64.gozsyscall_netbsd_arm.gozsyscall_openbsd_386.gozsyscall_openbsd_amd64.gozsyscall_openbsd_arm.gozsyscall_solaris_amd64.gozsysctl_openbsd_386.gozsysctl_openbsd_amd64.gozsysctl_openbsd_arm.gozsysnum_linux_ppc64.gozsysnum_linux_ppc64le.gozsysnum_linux_s390x.gozsysnum_linux_sparc64.gozsysnum_netbsd_386.gozsysnum_netbsd_amd64.gozsysnum_netbsd_arm.gozsysnum_openbsd_386.gozsysnum_openbsd_amd64.gozsysnum_openbsd_arm.goztypes_darwin_386.goztypes_darwin_amd64.goztypes_darwin_arm.goztypes_darwin_arm64.goztypes_dragonfly_amd64.goztypes_linux_386.goztypes_linux_amd64.goztypes_linux_arm.goztypes_linux_arm64.goztypes_linux_mips.goztypes_linux_mips64.goztypes_linux_mips64le.goztypes_linux_mipsle.goztypes_linux_ppc64.goztypes_linux_ppc64le.goztypes_linux_s390x.goztypes_linux_sparc64.goztypes_netbsd_386.goztypes_netbsd_amd64.goztypes_netbsd_arm.goztypes_openbsd_amd64.goztypes_solaris_amd64.go
windows
google.golang.org
genproto
.travis.yml
googleapis
api
appengine
assistant
bigtable
bytestream
cloud
audit
automl
bigquery
billing
dataproc
dialogflow
functions
iot
kms
language
location
ml
oslogin
redis
resourcemanager
runtimeconfig
speech
support
tasks
texttospeech
videointelligence
vision
websecurityscanner
container
datastore
devtools
example
library
firestore
genomics
home
iam
logging
longrunning
monitoring
privacy
pubsub
rpc
spanner
storagetransfer
streetview
type
watcher
protobuf
regen.goregen.sh
grpc
.travis.ymlCONTRIBUTING.md
Documentation
MakefileREADME.mdbackoff.gobalancer.go
balancer
balancer_conn_wrappers.gobalancer_switching_test.gobalancer_test.gobalancer_v1_wrapper.go
benchmark
call.gocall_test.go
channelz
clientconn.goclientconn_test.go
codes
credentials
encoding
envconfig.go
examples
gotutorial.md
helloworld
greeter_client
helloworld
mock_helloworld
oauth
client
server
route_guide
client
mock_routeguide
routeguide
server
rpc_errors
client
server
go16.gogo17.go
grpclb
grpclog
health
interceptor.go
internal
interop
metadata
naming
picker_wrapper.gopicker_wrapper_test.gopickfirst_test.goproxy_test.go
reflection
resolver
resolver_conn_wrapper.goresolver_conn_wrapper_test.gorpc_util.gorpc_util_test.goserver.goserver_test.goservice_config.go
stats
status
stickiness_linkedmap.gostickiness_linkedmap_test.gostickiness_test.gostream.go
stress
client
grpc_testing
metrics_client
test
transport
version.govet.sh
k8s.io
kubernetes
.github
.gitignoreCHANGELOG-1.10.mdCHANGELOG-1.11.mdCHANGELOG.md
Godeps
OWNERSOWNERS_ALIASESSECURITY_CONTACTS
api
build
cluster
BUILD
addons
addon-manager
calico-policy-controller
cluster-loadbalancing
cluster-monitoring
dashboard
device-plugins
nvidia-gpu
dns-horizontal-autoscaler
dns
etcd-empty-dir-cleanup
fluentd-elasticsearch
fluentd-gcp
istio
kube-proxy
metadata-agent
metadata-proxy
metrics-server
node-problem-detector
prometheus
rbac
centos
clientbin.shcommon.sh
gce
get-kube-local.sh
images
juju
kube-down.shkube-up.shkube-util.shkubeadm.shkubectl.sh
kubemark
kubernetes-anywhere
local
log-dump
pre-existing
restore-from-backup.sh
skeleton
test-e2e.shtest-network.shtest-smoke.shupdate-storage-objects.shvalidate-cluster.sh
cmd
clicheck
cloud-controller-manager
controller-manager
gendocs
genkubedocs
genman
genyaml
hyperkube
importverifier
kube-apiserver
kube-controller-manager
kube-proxy
kube-scheduler
kubeadm
.import-restrictionsOWNERS
app
BUILD
apis
cmd
constants
discovery
features
images
kubeadm.go
phases
preflight
util
test
kubectl
kubelet
docs
.generated_docs
admin
api-reference
admissionregistration.k8s.io
apps
batch
certificates.k8s.io
extensions
networking.k8s.io
policy
rbac.authorization.k8s.io
scheduling.k8s.io
settings.k8s.io
storage.k8s.io
v1
man
user-guide
yaml
examples
BUILDOWNERSREADME.md
cloud-controller-manager
cluster-dns
cockroachdb
cpu-manager
elasticsearch
examples_test.go
explorer
guestbook-go
guestbook
guidelines.md
https-nginx
javaee
javaweb-tomcat-sidecar
job
expansions
work-queue-1
work-queue-2
kubectl-container
meteor
mysql-cinder-pd
mysql-wordpress-pd
newrelic-infrastructure
newrelic
nodesjs-mongodb
oms
openshift-origin
persistent-volume-provisioning
phabricator
podsecuritypolicy
runtime-constraints
scheduler-policy-config-with-extender.jsonscheduler-policy-config.json
selenium
sharing-clusters
simple-nginx.md
spark
storage
storm
sysdig-cloud
volumes
aws_ebs
azure_disk
azure_file
cephfs
cinder
fibre_channel
flexvolume
flocker
glusterfs
iscsi
nfs
portworx
quobyte
rbd
scaleio
storageos
vsphere
hack
.golint_failuresBUILDOWNERSbenchmark-go.sh
boilerplate
build-cross.shbuild-go.shbuild-ui.shcherry_pick_pull.sh
cmd
dev-build-and-push.shdev-build-and-up.sh
e2e-internal
e2e-node-test.she2e.goe2e_test.go
gen-swagger-doc
generate-bindata.shgenerate-docs.shget-build.shginkgo-e2e.shgodep-restore.shgodep-save.shgrab-profiles.shimport-restrictions.yamlinstall-etcd.sh
jenkins
lib
list-feature-tests.shlocal-up-cluster.shlookup_pull.py
make-rules
run-in-gopath.shtest-go.shtest-integration.shtest-update-storage-objects.sh
testdata
update-all.shupdate-api-reference-docs.shupdate-bazel.shupdate-cloudprovider-gce.shupdate-codegen.shupdate-generated-device-plugin-dockerized.shupdate-generated-device-plugin.shupdate-generated-docs.shupdate-generated-kms-dockerized.shupdate-generated-kms.shupdate-generated-kubelet-plugin-registration-dockerized.shupdate-generated-kubelet-plugin-registration.shupdate-generated-protobuf-dockerized.shupdate-generated-protobuf.shupdate-generated-runtime-dockerized.shupdate-generated-runtime.shupdate-generated-swagger-docs.shupdate-godep-licenses.shupdate-gofmt.shupdate-openapi-spec.shupdate-staging-godeps-dockerized.shupdate-staging-godeps.shupdate-swagger-spec.shupdate-translations.shupdate-workspace-mirror.shupdate_owners.pyverify-all.shverify-api-groups.shverify-api-reference-docs.shverify-bazel.shverify-boilerplate.shverify-cli-conventions.shverify-cloudprovider-gce.shverify-codegen.shverify-description.shverify-flags-underscore.pyverify-generated-device-plugin.shverify-generated-docs.shverify-generated-files-remake.shverify-generated-files.shverify-generated-kms.shverify-generated-kubelet-plugin-registration.shverify-generated-protobuf.shverify-generated-runtime.shverify-generated-swagger-docs.shverify-godeps.shverify-gofmt.shverify-golint.shverify-govet.shverify-import-boss.shverify-imports.shverify-linkcheck.shverify-no-vendor-cycles.shverify-openapi-spec.shverify-pkg-names.shverify-readonly-packages.shverify-spelling.shverify-staging-godeps.shverify-swagger-spec.shverify-symbols.shverify-test-images.shverify-typecheck.sh
pkg
BUILD
api
apis
abac
admission
admissionregistration
apps
authentication
authorization
autoscaling
batch
certificates
componentconfig
core
events
extensions
imagepolicy
networking
policy
rbac
scheduling
settings
storage
auth
OWNERS
authorizer
client
clientset_generated
internalclientset
BUILDclientset.godoc.go
fake
scheme
typed
admissionregistration
apps
authentication
authorization
autoscaling
batch
certificates
core
events
extensions
networking
policy
rbac
scheduling
settings
storage
informers
leaderelectionconfig
listers
admissionregistration
apps
authentication
authorization
autoscaling
batch
certificates
core
extensions
imagepolicy
networking
policy
rbac
scheduling
settings
storage
tests
cloudprovider
OWNERScloud.goplugins.go
providers
aws
azure
cloudstack
fake
gce
openstack
ovirt
photon
vsphere
controller
BUILD
bootstrap
certificates
cloud
controller_ref_manager.gocontroller_ref_manager_test.gocontroller_utils.gocontroller_utils_test.go
cronjob
daemon
deployment
disruption
endpoint
garbagecollector
history
job
namespace
nodeipam
nodelifecycle
podautoscaler
replicaset
replication
resourcequota
route
service
serviceaccount
statefulset
testutil
util
volume
credentialprovider
features
generated
kubeapiserver
kubectl
.import-restrictionsBUILDapply.go
apply
autoscale_test.gobash_comp_utils.go
cmd
BUILDalpha.goannotate.goannotate_test.goapiresources.goapiversions.goapply.goapply_edit_last_applied.goapply_set_last_applied.goapply_test.goapply_view_last_applied.goattach.goattach_test.go
auth
autoscale.gocertificates.goclusterinfo.goclusterinfo_dump.goclusterinfo_dump_test.gocmd.gocmd_printing_test.gocmd_test.gocompletion.go
config
convert.goconvert_test.gocp.gocp_test.gocreate.go
create
create_job.godelete.godelete_flags.godelete_test.godescribe.godescribe_test.godiff.godiff_test.godrain.godrain_test.goedit.goedit_test.goexec.goexec_test.goexplain.goexpose.goexpose_test.go
get
label.golabel_test.gologs.gologs_test.gopatch.gopatch_test.goplugin.goplugin_test.goportforward.goportforward_test.goproxy.goreplace.goreplace_test.gorollingupdate.gorollingupdate_test.go
rollout
run.gorun_test.goscale.go
scalejob
set
taint.gotaint_test.go
templates
testdata
edit
record_editor.shrecord_testcase.shtest_editor.sh
testcase-apply-edit-last-applied-list-fail
testcase-apply-edit-last-applied-list
testcase-apply-edit-last-applied-syntax-error
testcase-apply-edit-last-applied
testcase-create-list-error
testcase-create-list
testcase-edit-error-reedit
testcase-edit-output-patch
testcase-list-errors
testcase-list-record
testcase-list
testcase-not-update-annotation
testcase-schemaless-list
testcase-single-service
testcase-syntax-error
testcase-unknown-field-known-group-kind
testcase-unknown-version-known-group-kind
testcase-update-annotation
testing
top.gotop_node.gotop_node_test.gotop_pod.gotop_pod_test.gotop_test.go
util
version.go
wait
conditions.godelete.godelete_test.godeployment.godeployment_test.go
explain
genericclioptions
history.gokubectl.go
plugins
polymorphichelpers
resource
resource_filter.goresource_filter_test.gorollback.gorolling_updater.gorolling_updater_test.gorollout_status.gorollout_status_test.gorun.goscale.goscale_test.go
scheme
secret.gosecret_for_docker_registry.gosecret_test.goservice_basic_test.gosorter.gosorter_test.go
util
kubelet
BUILD
apis
cadvisor
certificate
checkpoint
checkpointmanager
client
cm
config
configmap
container
dockershim
eviction
gpu
images
kubelet.gokubelet_getters.gokubelet_network.gokubelet_network_test.gokubelet_node_status.gokubelet_node_status_test.gokubelet_pods.gokubelet_pods_test.gokubelet_pods_windows_test.gokubelet_test.gokubelet_volumes.gokubelet_volumes_test.go
kubeletconfig
kuberuntime
lifecycle
logs
metrics
mountpod
network
pod
pod_container_deletor.gopod_workers.go
preemption
prober
remote
rkt
runonce.gorunonce_test.go
secret
server
stats
status
sysctl
token
types
util
volume_host.go
volumemanager
master
printers
proxy
quota
registry
BUILD
admissionregistration
initializerconfiguration
mutatingwebhookconfiguration
rest
validatingwebhookconfiguration
apps
authentication
authorization
localsubjectaccessreview
rest
selfsubjectaccessreview
selfsubjectrulesreview
subjectaccessreview
autoscaling
batch
certificates
core
events
extensions
networking
policy
rbac
registrytest
scheduling
settings
storage
scheduler
BUILDOWNERS
algorithm
algorithmprovider
api
cache
core
factory
metrics
scheduler.goscheduler_test.go
testing
util
volumebinder
security
securitycontext
serviceaccount
ssh
util
volume
BUILD
aws_ebs
azure_dd
azure_file
cephfs
cinder
configmap
csi
downwardapi
fc
flexvolume
flocker
gce_pd
git_repo
glusterfs
host_path
iscsi
local
metrics_du.go
nfs
photon_pd
plugins.go
portworx
projected
quobyte
rbd
scaleio
secret
storageos
testing
util
volume.govolume_linux.govolume_unsupported.go
vsphere_volume
windows
plugin
BUILD
pkg
admission
auth
staging
BUILD
src
k8s.io
api
BUILD
Godeps
SECURITY_CONTACTS
admission
admissionregistration
apps
authentication
authorization
autoscaling
batch
certificates
core
events
extensions
imagepolicy
networking
policy
rbac
roundtrip_test.go
scheduling
settings
storage
apiextensions-apiserver
BUILD
Godeps
OWNERSSECURITY_CONTACTS
artifacts
example
examples
hack
main.go
pkg
apis
apiserver
client
cmd
server
controller
features
registry
test
apimachinery
Godeps
SECURITY_CONTACTS
pkg
api
apimachinery
apis
conversion
fields
labels
runtime
test
types
util
version
watch
third_party
forked
golang
apiserver
CONTRIBUTING.md
Godeps
OWNERSSECURITY_CONTACTS
pkg
admission
apis
audit
endpoints
features
registry
server
storage
util
plugin
client-go
.github
Godeps
OWNERSSECURITY_CONTACTS
deprecated-dynamic
discovery
dynamic
examples
create-update-delete-deployment
informers
BUILD
admissionregistration
apps
autoscaling
batch
certificates
core
events
extensions
factory.gogeneric.go
internalinterfaces
networking
policy
rbac
scheduling
settings
storage
kubernetes
BUILDclientset.godoc.go
fake
scheme
typed
admissionregistration
apps
authentication
authorization
autoscaling
batch
certificates
core
events
extensions
networking
policy
rbac
scheduling
settings
storage
listers
admissionregistration
apps
authentication
authorization
autoscaling
batch
certificates
core
events
extensions
imagepolicy
networking
policy
rbac
scheduling
settings
storage
pkg
plugin
rest
restmapper
scale
testing
tools
transport
util
code-generator
Godeps
SECURITY_CONTACTS
_examples
apiserver
apis
clientset
informers
listers
crd
cmd
generate-groups.sh
hack
kube-aggregator
Godeps
SECURITY_CONTACTS
artifacts
hack
main.go
pkg
apis
apiserver
client
cmd
server
controllers
registry
metrics
sample-apiserver
BUILD
Godeps
README.mdSECURITY_CONTACTS
artifacts
example
hack
main.go
pkg
admission
plugin
banflunder
apis
apiserver
client
cmd
server
registry
sample-controller
test
BUILDOWNERS
conformance
e2e
BUILD
apimachinery
apps
auth
autoscaling
common
e2e.goexamples.go
framework
generated
gke_local_ssd.go
instrumentation
kubectl
lifecycle
manifest
network
node
scalability
scheduling
storage
testing-manifests
ui
upgrades
e2e_kubeadm
e2e_node
fixtures
pkg
kubectl
cmd
apply
plugins
plugins2
images
integration
kubemark
test_owners.csv
typecheck
utils
third_party
BUILD
forked
golang
shell2junit
htpasswd
translations
BUILD
kubectl
it_IT
LC_MESSAGES
ko_KR
LC_MESSAGES
zh_CN
LC_MESSAGES
utils

654
vendor/github.com/golang/protobuf/proto/table_merge.go generated vendored Normal file

@ -0,0 +1,654 @@
// Go support for Protocol Buffers - Google's data interchange format
//
// Copyright 2016 The Go Authors. All rights reserved.
// https://github.com/golang/protobuf
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package proto
import (
"fmt"
"reflect"
"strings"
"sync"
"sync/atomic"
)
// Merge merges the src message into dst.
// This assumes that dst and src of the same type and are non-nil.
func (a *InternalMessageInfo) Merge(dst, src Message) {
mi := atomicLoadMergeInfo(&a.merge)
if mi == nil {
mi = getMergeInfo(reflect.TypeOf(dst).Elem())
atomicStoreMergeInfo(&a.merge, mi)
}
mi.merge(toPointer(&dst), toPointer(&src))
}
type mergeInfo struct {
typ reflect.Type
initialized int32 // 0: only typ is valid, 1: everything is valid
lock sync.Mutex
fields []mergeFieldInfo
unrecognized field // Offset of XXX_unrecognized
}
type mergeFieldInfo struct {
field field // Offset of field, guaranteed to be valid
// isPointer reports whether the value in the field is a pointer.
// This is true for the following situations:
// * Pointer to struct
// * Pointer to basic type (proto2 only)
// * Slice (first value in slice header is a pointer)
// * String (first value in string header is a pointer)
isPointer bool
// basicWidth reports the width of the field assuming that it is directly
// embedded in the struct (as is the case for basic types in proto3).
// The possible values are:
// 0: invalid
// 1: bool
// 4: int32, uint32, float32
// 8: int64, uint64, float64
basicWidth int
// Where dst and src are pointers to the types being merged.
merge func(dst, src pointer)
}
var (
mergeInfoMap = map[reflect.Type]*mergeInfo{}
mergeInfoLock sync.Mutex
)
func getMergeInfo(t reflect.Type) *mergeInfo {
mergeInfoLock.Lock()
defer mergeInfoLock.Unlock()
mi := mergeInfoMap[t]
if mi == nil {
mi = &mergeInfo{typ: t}
mergeInfoMap[t] = mi
}
return mi
}
// merge merges src into dst assuming they are both of type *mi.typ.
func (mi *mergeInfo) merge(dst, src pointer) {
if dst.isNil() {
panic("proto: nil destination")
}
if src.isNil() {
return // Nothing to do.
}
if atomic.LoadInt32(&mi.initialized) == 0 {
mi.computeMergeInfo()
}
for _, fi := range mi.fields {
sfp := src.offset(fi.field)
// As an optimization, we can avoid the merge function call cost
// if we know for sure that the source will have no effect
// by checking if it is the zero value.
if unsafeAllowed {
if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
continue
}
if fi.basicWidth > 0 {
switch {
case fi.basicWidth == 1 && !*sfp.toBool():
continue
case fi.basicWidth == 4 && *sfp.toUint32() == 0:
continue
case fi.basicWidth == 8 && *sfp.toUint64() == 0:
continue
}
}
}
dfp := dst.offset(fi.field)
fi.merge(dfp, sfp)
}
// TODO: Make this faster?
out := dst.asPointerTo(mi.typ).Elem()
in := src.asPointerTo(mi.typ).Elem()
if emIn, err := extendable(in.Addr().Interface()); err == nil {
emOut, _ := extendable(out.Addr().Interface())
mIn, muIn := emIn.extensionsRead()
if mIn != nil {
mOut := emOut.extensionsWrite()
muIn.Lock()
mergeExtension(mOut, mIn)
muIn.Unlock()
}
}
if mi.unrecognized.IsValid() {
if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
*dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
}
}
}
func (mi *mergeInfo) computeMergeInfo() {
mi.lock.Lock()
defer mi.lock.Unlock()
if mi.initialized != 0 {
return
}
t := mi.typ
n := t.NumField()
props := GetProperties(t)
for i := 0; i < n; i++ {
f := t.Field(i)
if strings.HasPrefix(f.Name, "XXX_") {
continue
}
mfi := mergeFieldInfo{field: toField(&f)}
tf := f.Type
// As an optimization, we can avoid the merge function call cost
// if we know for sure that the source will have no effect
// by checking if it is the zero value.
if unsafeAllowed {
switch tf.Kind() {
case reflect.Ptr, reflect.Slice, reflect.String:
// As a special case, we assume slices and strings are pointers
// since we know that the first field in the SliceSlice or
// StringHeader is a data pointer.
mfi.isPointer = true
case reflect.Bool:
mfi.basicWidth = 1
case reflect.Int32, reflect.Uint32, reflect.Float32:
mfi.basicWidth = 4
case reflect.Int64, reflect.Uint64, reflect.Float64:
mfi.basicWidth = 8
}
}
// Unwrap tf to get at its most basic type.
var isPointer, isSlice bool
if tf.Kind() == reflect.Slice && tf.Elem().Kind() != reflect.Uint8 {
isSlice = true
tf = tf.Elem()
}
if tf.Kind() == reflect.Ptr {
isPointer = true
tf = tf.Elem()
}
if isPointer && isSlice && tf.Kind() != reflect.Struct {
panic("both pointer and slice for basic type in " + tf.Name())
}
switch tf.Kind() {
case reflect.Int32:
switch {
case isSlice: // E.g., []int32
mfi.merge = func(dst, src pointer) {
// NOTE: toInt32Slice is not defined (see pointer_reflect.go).
/*
sfsp := src.toInt32Slice()
if *sfsp != nil {
dfsp := dst.toInt32Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []int64{}
}
}
*/
sfs := src.getInt32Slice()
if sfs != nil {
dfs := dst.getInt32Slice()
dfs = append(dfs, sfs...)
if dfs == nil {
dfs = []int32{}
}
dst.setInt32Slice(dfs)
}
}
case isPointer: // E.g., *int32
mfi.merge = func(dst, src pointer) {
// NOTE: toInt32Ptr is not defined (see pointer_reflect.go).
/*
sfpp := src.toInt32Ptr()
if *sfpp != nil {
dfpp := dst.toInt32Ptr()
if *dfpp == nil {
*dfpp = Int32(**sfpp)
} else {
**dfpp = **sfpp
}
}
*/
sfp := src.getInt32Ptr()
if sfp != nil {
dfp := dst.getInt32Ptr()
if dfp == nil {
dst.setInt32Ptr(*sfp)
} else {
*dfp = *sfp
}
}
}
default: // E.g., int32
mfi.merge = func(dst, src pointer) {
if v := *src.toInt32(); v != 0 {
*dst.toInt32() = v
}
}
}
case reflect.Int64:
switch {
case isSlice: // E.g., []int64
mfi.merge = func(dst, src pointer) {
sfsp := src.toInt64Slice()
if *sfsp != nil {
dfsp := dst.toInt64Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []int64{}
}
}
}
case isPointer: // E.g., *int64
mfi.merge = func(dst, src pointer) {
sfpp := src.toInt64Ptr()
if *sfpp != nil {
dfpp := dst.toInt64Ptr()
if *dfpp == nil {
*dfpp = Int64(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., int64
mfi.merge = func(dst, src pointer) {
if v := *src.toInt64(); v != 0 {
*dst.toInt64() = v
}
}
}
case reflect.Uint32:
switch {
case isSlice: // E.g., []uint32
mfi.merge = func(dst, src pointer) {
sfsp := src.toUint32Slice()
if *sfsp != nil {
dfsp := dst.toUint32Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []uint32{}
}
}
}
case isPointer: // E.g., *uint32
mfi.merge = func(dst, src pointer) {
sfpp := src.toUint32Ptr()
if *sfpp != nil {
dfpp := dst.toUint32Ptr()
if *dfpp == nil {
*dfpp = Uint32(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., uint32
mfi.merge = func(dst, src pointer) {
if v := *src.toUint32(); v != 0 {
*dst.toUint32() = v
}
}
}
case reflect.Uint64:
switch {
case isSlice: // E.g., []uint64
mfi.merge = func(dst, src pointer) {
sfsp := src.toUint64Slice()
if *sfsp != nil {
dfsp := dst.toUint64Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []uint64{}
}
}
}
case isPointer: // E.g., *uint64
mfi.merge = func(dst, src pointer) {
sfpp := src.toUint64Ptr()
if *sfpp != nil {
dfpp := dst.toUint64Ptr()
if *dfpp == nil {
*dfpp = Uint64(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., uint64
mfi.merge = func(dst, src pointer) {
if v := *src.toUint64(); v != 0 {
*dst.toUint64() = v
}
}
}
case reflect.Float32:
switch {
case isSlice: // E.g., []float32
mfi.merge = func(dst, src pointer) {
sfsp := src.toFloat32Slice()
if *sfsp != nil {
dfsp := dst.toFloat32Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []float32{}
}
}
}
case isPointer: // E.g., *float32
mfi.merge = func(dst, src pointer) {
sfpp := src.toFloat32Ptr()
if *sfpp != nil {
dfpp := dst.toFloat32Ptr()
if *dfpp == nil {
*dfpp = Float32(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., float32
mfi.merge = func(dst, src pointer) {
if v := *src.toFloat32(); v != 0 {
*dst.toFloat32() = v
}
}
}
case reflect.Float64:
switch {
case isSlice: // E.g., []float64
mfi.merge = func(dst, src pointer) {
sfsp := src.toFloat64Slice()
if *sfsp != nil {
dfsp := dst.toFloat64Slice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []float64{}
}
}
}
case isPointer: // E.g., *float64
mfi.merge = func(dst, src pointer) {
sfpp := src.toFloat64Ptr()
if *sfpp != nil {
dfpp := dst.toFloat64Ptr()
if *dfpp == nil {
*dfpp = Float64(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., float64
mfi.merge = func(dst, src pointer) {
if v := *src.toFloat64(); v != 0 {
*dst.toFloat64() = v
}
}
}
case reflect.Bool:
switch {
case isSlice: // E.g., []bool
mfi.merge = func(dst, src pointer) {
sfsp := src.toBoolSlice()
if *sfsp != nil {
dfsp := dst.toBoolSlice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []bool{}
}
}
}
case isPointer: // E.g., *bool
mfi.merge = func(dst, src pointer) {
sfpp := src.toBoolPtr()
if *sfpp != nil {
dfpp := dst.toBoolPtr()
if *dfpp == nil {
*dfpp = Bool(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., bool
mfi.merge = func(dst, src pointer) {
if v := *src.toBool(); v {
*dst.toBool() = v
}
}
}
case reflect.String:
switch {
case isSlice: // E.g., []string
mfi.merge = func(dst, src pointer) {
sfsp := src.toStringSlice()
if *sfsp != nil {
dfsp := dst.toStringSlice()
*dfsp = append(*dfsp, *sfsp...)
if *dfsp == nil {
*dfsp = []string{}
}
}
}
case isPointer: // E.g., *string
mfi.merge = func(dst, src pointer) {
sfpp := src.toStringPtr()
if *sfpp != nil {
dfpp := dst.toStringPtr()
if *dfpp == nil {
*dfpp = String(**sfpp)
} else {
**dfpp = **sfpp
}
}
}
default: // E.g., string
mfi.merge = func(dst, src pointer) {
if v := *src.toString(); v != "" {
*dst.toString() = v
}
}
}
case reflect.Slice:
isProto3 := props.Prop[i].proto3
switch {
case isPointer:
panic("bad pointer in byte slice case in " + tf.Name())
case tf.Elem().Kind() != reflect.Uint8:
panic("bad element kind in byte slice case in " + tf.Name())
case isSlice: // E.g., [][]byte
mfi.merge = func(dst, src pointer) {
sbsp := src.toBytesSlice()
if *sbsp != nil {
dbsp := dst.toBytesSlice()
for _, sb := range *sbsp {
if sb == nil {
*dbsp = append(*dbsp, nil)
} else {
*dbsp = append(*dbsp, append([]byte{}, sb...))
}
}
if *dbsp == nil {
*dbsp = [][]byte{}
}
}
}
default: // E.g., []byte
mfi.merge = func(dst, src pointer) {
sbp := src.toBytes()
if *sbp != nil {
dbp := dst.toBytes()
if !isProto3 || len(*sbp) > 0 {
*dbp = append([]byte{}, *sbp...)
}
}
}
}
case reflect.Struct:
switch {
case !isPointer:
panic(fmt.Sprintf("message field %s without pointer", tf))
case isSlice: // E.g., []*pb.T
mi := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) {
sps := src.getPointerSlice()
if sps != nil {
dps := dst.getPointerSlice()
for _, sp := range sps {
var dp pointer
if !sp.isNil() {
dp = valToPointer(reflect.New(tf))
mi.merge(dp, sp)
}
dps = append(dps, dp)
}
if dps == nil {
dps = []pointer{}
}
dst.setPointerSlice(dps)
}
}
default: // E.g., *pb.T
mi := getMergeInfo(tf)
mfi.merge = func(dst, src pointer) {
sp := src.getPointer()
if !sp.isNil() {
dp := dst.getPointer()
if dp.isNil() {
dp = valToPointer(reflect.New(tf))
dst.setPointer(dp)
}
mi.merge(dp, sp)
}
}
}
case reflect.Map:
switch {
case isPointer || isSlice:
panic("bad pointer or slice in map case in " + tf.Name())
default: // E.g., map[K]V
mfi.merge = func(dst, src pointer) {
sm := src.asPointerTo(tf).Elem()
if sm.Len() == 0 {
return
}
dm := dst.asPointerTo(tf).Elem()
if dm.IsNil() {
dm.Set(reflect.MakeMap(tf))
}
switch tf.Elem().Kind() {
case reflect.Ptr: // Proto struct (e.g., *T)
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
val = reflect.ValueOf(Clone(val.Interface().(Message)))
dm.SetMapIndex(key, val)
}
case reflect.Slice: // E.g. Bytes type (e.g., []byte)
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
val = reflect.ValueOf(append([]byte{}, val.Bytes()...))
dm.SetMapIndex(key, val)
}
default: // Basic type (e.g., string)
for _, key := range sm.MapKeys() {
val := sm.MapIndex(key)
dm.SetMapIndex(key, val)
}
}
}
}
case reflect.Interface:
// Must be oneof field.
switch {
case isPointer || isSlice:
panic("bad pointer or slice in interface case in " + tf.Name())
default: // E.g., interface{}
// TODO: Make this faster?
mfi.merge = func(dst, src pointer) {
su := src.asPointerTo(tf).Elem()
if !su.IsNil() {
du := dst.asPointerTo(tf).Elem()
typ := su.Elem().Type()
if du.IsNil() || du.Elem().Type() != typ {
du.Set(reflect.New(typ.Elem())) // Initialize interface if empty
}
sv := su.Elem().Elem().Field(0)
if sv.Kind() == reflect.Ptr && sv.IsNil() {
return
}
dv := du.Elem().Elem().Field(0)
if dv.Kind() == reflect.Ptr && dv.IsNil() {
dv.Set(reflect.New(sv.Type().Elem())) // Initialize proto message if empty
}
switch sv.Type().Kind() {
case reflect.Ptr: // Proto struct (e.g., *T)
Merge(dv.Interface().(Message), sv.Interface().(Message))
case reflect.Slice: // E.g. Bytes type (e.g., []byte)
dv.Set(reflect.ValueOf(append([]byte{}, sv.Bytes()...)))
default: // Basic type (e.g., string)
dv.Set(sv)
}
}
}
}
default:
panic(fmt.Sprintf("merger not found for type:%s", tf))
}
mi.fields = append(mi.fields, mfi)
}
mi.unrecognized = invalidField
if f, ok := t.FieldByName("XXX_unrecognized"); ok {
if f.Type != reflect.TypeOf([]byte{}) {
panic("expected XXX_unrecognized to be of type []byte")
}
mi.unrecognized = toField(&f)
}
atomic.StoreInt32(&mi.initialized, 1)
}