Update dependencies
This commit is contained in:
68
vendor/github.com/go-json-experiment/json/internal/jsonopts/options.go
generated
vendored
68
vendor/github.com/go-json-experiment/json/internal/jsonopts/options.go
generated
vendored
@@ -46,30 +46,17 @@ type ArshalValues struct {
|
||||
// DefaultOptionsV2 is the set of all options that define default v2 behavior.
|
||||
var DefaultOptionsV2 = Struct{
|
||||
Flags: jsonflags.Flags{
|
||||
Presence: uint64(jsonflags.AllFlags),
|
||||
Presence: uint64(jsonflags.AllFlags & ^jsonflags.WhitespaceFlags),
|
||||
Values: uint64(0),
|
||||
},
|
||||
CoderValues: CoderValues{Indent: "\t"}, // Indent is set, but Expand is set to false
|
||||
}
|
||||
|
||||
// DefaultOptionsV1 is the set of all options that define default v1 behavior.
|
||||
var DefaultOptionsV1 = Struct{
|
||||
Flags: jsonflags.Flags{
|
||||
Presence: uint64(jsonflags.AllFlags),
|
||||
Presence: uint64(jsonflags.AllFlags & ^jsonflags.WhitespaceFlags),
|
||||
Values: uint64(jsonflags.DefaultV1Flags),
|
||||
},
|
||||
CoderValues: CoderValues{Indent: "\t"}, // Indent is set, but Expand is set to false
|
||||
}
|
||||
|
||||
// CopyCoderOptions copies coder-specific options from src to dst.
|
||||
// This is used by json.MarshalEncode and json.UnmarshalDecode since those
|
||||
// functions ignore any coder-specific options and uses the options from the
|
||||
// Encoder or Decoder that is passed in.
|
||||
func (dst *Struct) CopyCoderOptions(src *Struct) {
|
||||
srcFlags := src.Flags
|
||||
srcFlags.Clear(^jsonflags.AllCoderFlags)
|
||||
dst.Flags.Join(srcFlags)
|
||||
dst.CoderValues = src.CoderValues
|
||||
}
|
||||
|
||||
func (*Struct) JSONOptions(internal.NotForPublicUse) {}
|
||||
@@ -125,50 +112,73 @@ func GetOption[T any](opts Options, setter func(T) Options) (T, bool) {
|
||||
var JoinUnknownOption = func(*Struct, Options) { panic("unknown option") }
|
||||
|
||||
func (dst *Struct) Join(srcs ...Options) {
|
||||
dst.join(false, srcs...)
|
||||
}
|
||||
|
||||
func (dst *Struct) JoinWithoutCoderOptions(srcs ...Options) {
|
||||
dst.join(true, srcs...)
|
||||
}
|
||||
|
||||
func (dst *Struct) join(excludeCoderOptions bool, srcs ...Options) {
|
||||
for _, src := range srcs {
|
||||
switch src := src.(type) {
|
||||
case nil:
|
||||
continue
|
||||
case jsonflags.Bools:
|
||||
if excludeCoderOptions {
|
||||
src &= ^jsonflags.AllCoderFlags
|
||||
}
|
||||
dst.Flags.Set(src)
|
||||
case Indent:
|
||||
dst.Flags.Set(jsonflags.Expand | jsonflags.Indent | 1)
|
||||
if excludeCoderOptions {
|
||||
continue
|
||||
}
|
||||
dst.Flags.Set(jsonflags.Multiline | jsonflags.Indent | 1)
|
||||
dst.Indent = string(src)
|
||||
case IndentPrefix:
|
||||
dst.Flags.Set(jsonflags.Expand | jsonflags.IndentPrefix | 1)
|
||||
if excludeCoderOptions {
|
||||
continue
|
||||
}
|
||||
dst.Flags.Set(jsonflags.Multiline | jsonflags.IndentPrefix | 1)
|
||||
dst.IndentPrefix = string(src)
|
||||
case ByteLimit:
|
||||
if excludeCoderOptions {
|
||||
continue
|
||||
}
|
||||
dst.Flags.Set(jsonflags.ByteLimit | 1)
|
||||
dst.ByteLimit = int64(src)
|
||||
case DepthLimit:
|
||||
if excludeCoderOptions {
|
||||
continue
|
||||
}
|
||||
dst.Flags.Set(jsonflags.DepthLimit | 1)
|
||||
dst.DepthLimit = int(src)
|
||||
case *Struct:
|
||||
dst.Flags.Join(src.Flags)
|
||||
if src.Flags.Has(jsonflags.NonBooleanFlags) {
|
||||
if src.Flags.Has(jsonflags.Indent) {
|
||||
srcFlags := src.Flags // shallow copy the flags
|
||||
if excludeCoderOptions {
|
||||
srcFlags.Clear(jsonflags.AllCoderFlags)
|
||||
}
|
||||
dst.Flags.Join(srcFlags)
|
||||
if srcFlags.Has(jsonflags.NonBooleanFlags) {
|
||||
if srcFlags.Has(jsonflags.Indent) {
|
||||
dst.Indent = src.Indent
|
||||
}
|
||||
if src.Flags.Has(jsonflags.IndentPrefix) {
|
||||
if srcFlags.Has(jsonflags.IndentPrefix) {
|
||||
dst.IndentPrefix = src.IndentPrefix
|
||||
}
|
||||
if src.Flags.Has(jsonflags.ByteLimit) {
|
||||
if srcFlags.Has(jsonflags.ByteLimit) {
|
||||
dst.ByteLimit = src.ByteLimit
|
||||
}
|
||||
if src.Flags.Has(jsonflags.DepthLimit) {
|
||||
if srcFlags.Has(jsonflags.DepthLimit) {
|
||||
dst.DepthLimit = src.DepthLimit
|
||||
}
|
||||
if src.Flags.Has(jsonflags.Marshalers) {
|
||||
if srcFlags.Has(jsonflags.Marshalers) {
|
||||
dst.Marshalers = src.Marshalers
|
||||
}
|
||||
if src.Flags.Has(jsonflags.Unmarshalers) {
|
||||
if srcFlags.Has(jsonflags.Unmarshalers) {
|
||||
dst.Unmarshalers = src.Unmarshalers
|
||||
}
|
||||
}
|
||||
if src.Format != "" {
|
||||
dst.Format = src.Format
|
||||
dst.FormatDepth = src.FormatDepth
|
||||
}
|
||||
default:
|
||||
JoinUnknownOption(dst, src)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user