4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-07-04 10:07:44 +00:00

Update vendor (#1228)

This commit is contained in:
Wim
2020-09-04 23:29:13 +02:00
committed by GitHub
parent 17747a5c88
commit 2f59abdda7
1436 changed files with 21840 additions and 3466 deletions

View File

@ -128,7 +128,6 @@ package protoreflect
import (
"fmt"
"regexp"
"strings"
"google.golang.org/protobuf/encoding/protowire"
@ -408,19 +407,14 @@ type EnumRanges interface {
doNotImplement
}
var (
regexName = regexp.MustCompile(`^[_a-zA-Z][_a-zA-Z0-9]*$`)
regexFullName = regexp.MustCompile(`^[_a-zA-Z][_a-zA-Z0-9]*(\.[_a-zA-Z][_a-zA-Z0-9]*)*$`)
)
// Name is the short name for a proto declaration. This is not the name
// as used in Go source code, which might not be identical to the proto name.
type Name string // e.g., "Kind"
// IsValid reports whether n is a syntactically valid name.
// IsValid reports whether s is a syntactically valid name.
// An empty name is invalid.
func (n Name) IsValid() bool {
return regexName.MatchString(string(n))
func (s Name) IsValid() bool {
return consumeIdent(string(s)) == len(s)
}
// Names represent a list of names.
@ -443,10 +437,42 @@ type Names interface {
// This should not have any leading or trailing dots.
type FullName string // e.g., "google.protobuf.Field.Kind"
// IsValid reports whether n is a syntactically valid full name.
// IsValid reports whether s is a syntactically valid full name.
// An empty full name is invalid.
func (n FullName) IsValid() bool {
return regexFullName.MatchString(string(n))
func (s FullName) IsValid() bool {
i := consumeIdent(string(s))
if i < 0 {
return false
}
for len(s) > i {
if s[i] != '.' {
return false
}
i++
n := consumeIdent(string(s[i:]))
if n < 0 {
return false
}
i += n
}
return true
}
func consumeIdent(s string) (i int) {
if len(s) == 0 || !isLetter(s[i]) {
return -1
}
i++
for len(s) > i && isLetterDigit(s[i]) {
i++
}
return i
}
func isLetter(c byte) bool {
return c == '_' || ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z')
}
func isLetterDigit(c byte) bool {
return isLetter(c) || ('0' <= c && c <= '9')
}
// Name returns the short name, which is the last identifier segment.

View File

@ -85,6 +85,8 @@ func ValueOf(v interface{}) Value {
return ValueOfEnum(v)
case Message, List, Map:
return valueOfIface(v)
case ProtoMessage:
panic(fmt.Sprintf("invalid proto.Message(%T) type, expected a protoreflect.Message type", v))
default:
panic(fmt.Sprintf("invalid type: %T", v))
}