encoder

package
v2.28.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2022 License: MIT, MIT Imports: 17 Imported by: 0

Documentation

Overview

Code generated by internal/cmd/generator. DO NOT EDIT!

Index

Constants

View Source
const StartDetectingCyclesAfter = 1000

Variables

View Source
var (
	Marshal   func(interface{}) ([]byte, error)
	Unmarshal func([]byte, interface{}) error
)

Functions

func AppendBool

func AppendBool(_ *RuntimeContext, b []byte, v bool) []byte

func AppendByteSlice

func AppendByteSlice(_ *RuntimeContext, b []byte, src []byte) []byte

func AppendComma

func AppendComma(_ *RuntimeContext, b []byte) []byte

func AppendCommaIndent

func AppendCommaIndent(_ *RuntimeContext, b []byte) []byte

func AppendFloat32

func AppendFloat32(_ *RuntimeContext, b []byte, v float32) []byte

func AppendFloat64

func AppendFloat64(_ *RuntimeContext, b []byte, v float64) []byte

func AppendIndent

func AppendIndent(ctx *RuntimeContext, b []byte, indent uint32) []byte

func AppendInt

func AppendInt(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte

func AppendMarshalJSON

func AppendMarshalJSON(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error)

func AppendMarshalJSONIndent

func AppendMarshalJSONIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error)

func AppendMarshalText

func AppendMarshalText(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error)

func AppendMarshalTextIndent

func AppendMarshalTextIndent(ctx *RuntimeContext, code *Opcode, b []byte, v interface{}) ([]byte, error)

func AppendNull

func AppendNull(_ *RuntimeContext, b []byte) []byte

func AppendNumber

func AppendNumber(_ *RuntimeContext, b []byte, n json.Number) ([]byte, error)

func AppendString

func AppendString(ctx *RuntimeContext, buf []byte, s string) []byte

func AppendStructEnd

func AppendStructEnd(_ *RuntimeContext, b []byte) []byte

func AppendStructEndIndent

func AppendStructEndIndent(ctx *RuntimeContext, code *Opcode, b []byte) []byte

func AppendUint

func AppendUint(_ *RuntimeContext, out []byte, p uintptr, code *Opcode) []byte

func Compact

func Compact(buf *bytes.Buffer, src []byte, escape bool) error

func ErrMarshalerWithCode

func ErrMarshalerWithCode(code *Opcode, err error) *errors.MarshalerError

func ErrUnsupportedFloat

func ErrUnsupportedFloat(v float64) *errors.UnsupportedValueError

func ErrUnsupportedValue

func ErrUnsupportedValue(code *Opcode, ptr uintptr) *errors.UnsupportedValueError

func Indent

func Indent(buf *bytes.Buffer, src []byte, prefix, indentStr string) error

func IsNilForMarshaler

func IsNilForMarshaler(v interface{}) bool

func Load

func Load(base uintptr, idx uintptr) uintptr

func LoadNPtr

func LoadNPtr(base uintptr, idx uintptr, ptrNum int) uintptr

func MapIterInit

func MapIterInit(mapType *runtime.Type, m unsafe.Pointer, it *mapIter)

func MapIterKey

func MapIterKey(it *mapIter) unsafe.Pointer

func MapIterNext

func MapIterNext(it *mapIter)

func MapIterValue

func MapIterValue(it *mapIter) unsafe.Pointer

func MapLen

func MapLen(m unsafe.Pointer) int

func PtrToBool

func PtrToBool(p uintptr) bool

func PtrToBytes

func PtrToBytes(p uintptr) []byte

func PtrToFloat32

func PtrToFloat32(p uintptr) float32

func PtrToFloat64

func PtrToFloat64(p uintptr) float64

func PtrToInterface

func PtrToInterface(code *Opcode, p uintptr) interface{}

func PtrToNPtr

func PtrToNPtr(p uintptr, ptrNum int) uintptr

func PtrToNumber

func PtrToNumber(p uintptr) json.Number

func PtrToPtr

func PtrToPtr(p uintptr) uintptr

func PtrToSlice

func PtrToSlice(p uintptr) *runtime.SliceHeader

func PtrToString

func PtrToString(p uintptr) string

func PtrToUint64

func PtrToUint64(p uintptr) uint64

func PtrToUnsafePtr

func PtrToUnsafePtr(p uintptr) unsafe.Pointer

func ReleaseMapContext

func ReleaseMapContext(c *MapContext)

func ReleaseRuntimeContext

func ReleaseRuntimeContext(ctx *RuntimeContext)

func SetFieldQueryToContext added in v2.25.0

func SetFieldQueryToContext(ctx context.Context, query *FieldQuery) context.Context

func Store

func Store(base uintptr, idx uintptr, p uintptr)

Types

type AnonymousCode added in v2.23.0

type AnonymousCode interface {
	ToAnonymousOpcode(*compileContext) Opcodes
}

type ArrayCode added in v2.23.0

type ArrayCode struct {
	// contains filtered or unexported fields
}

func (*ArrayCode) Filter added in v2.25.0

func (c *ArrayCode) Filter(_ *FieldQuery) Code

func (*ArrayCode) Kind added in v2.23.0

func (c *ArrayCode) Kind() CodeKind

func (*ArrayCode) ToOpcode added in v2.23.0

func (c *ArrayCode) ToOpcode(ctx *compileContext) Opcodes

type BoolCode added in v2.23.0

type BoolCode struct {
	// contains filtered or unexported fields
}

func (*BoolCode) Filter added in v2.25.0

func (c *BoolCode) Filter(_ *FieldQuery) Code

func (*BoolCode) Kind added in v2.23.0

func (c *BoolCode) Kind() CodeKind

func (*BoolCode) ToOpcode added in v2.23.0

func (c *BoolCode) ToOpcode(ctx *compileContext) Opcodes

type BytesCode added in v2.23.0

type BytesCode struct {
	// contains filtered or unexported fields
}

func (*BytesCode) Filter added in v2.25.0

func (c *BytesCode) Filter(_ *FieldQuery) Code

func (*BytesCode) Kind added in v2.23.0

func (c *BytesCode) Kind() CodeKind

func (*BytesCode) ToOpcode added in v2.23.0

func (c *BytesCode) ToOpcode(ctx *compileContext) Opcodes

type Code added in v2.23.0

type Code interface {
	Kind() CodeKind
	ToOpcode(*compileContext) Opcodes
	Filter(*FieldQuery) Code
}

type CodeKind added in v2.23.0

type CodeKind int
const (
	CodeKindInterface CodeKind = iota
	CodeKindPtr
	CodeKindInt
	CodeKindUint
	CodeKindFloat
	CodeKindString
	CodeKindBool
	CodeKindStruct
	CodeKindMap
	CodeKindSlice
	CodeKindArray
	CodeKindBytes
	CodeKindMarshalJSON
	CodeKindMarshalText
	CodeKindRecursive
)

type CodeType

type CodeType int
const (
	CodeOp          CodeType = 0
	CodeArrayHead   CodeType = 1
	CodeArrayElem   CodeType = 2
	CodeSliceHead   CodeType = 3
	CodeSliceElem   CodeType = 4
	CodeMapHead     CodeType = 5
	CodeMapKey      CodeType = 6
	CodeMapValue    CodeType = 7
	CodeMapEnd      CodeType = 8
	CodeRecursive   CodeType = 9
	CodeStructField CodeType = 10
	CodeStructEnd   CodeType = 11
)

type ColorFormat

type ColorFormat = EncodeFormat

type ColorScheme

type ColorScheme = EncodeFormatScheme

type CompiledCode

type CompiledCode struct {
	Code    *Opcode
	Linked  bool // whether recursive code already have linked
	CurLen  uintptr
	NextLen uintptr
}

type Compiler added in v2.23.0

type Compiler struct {
	// contains filtered or unexported fields
}

type EncodeFormat

type EncodeFormat struct {
	Header string
	Footer string
}

type EncodeFormatScheme

type EncodeFormatScheme struct {
	Int       EncodeFormat
	Uint      EncodeFormat
	Float     EncodeFormat
	Bool      EncodeFormat
	String    EncodeFormat
	Binary    EncodeFormat
	ObjectKey EncodeFormat
	Null      EncodeFormat
}

type FieldQuery added in v2.25.0

type FieldQuery struct {
	Name   string
	Fields []*FieldQuery
	// contains filtered or unexported fields
}

func FieldQueryFromContext added in v2.25.0

func FieldQueryFromContext(ctx context.Context) *FieldQuery

func (*FieldQuery) Hash added in v2.25.0

func (q *FieldQuery) Hash() string

func (*FieldQuery) MarshalJSON added in v2.25.0

func (q *FieldQuery) MarshalJSON() ([]byte, error)

func (*FieldQuery) QueryString added in v2.25.0

func (q *FieldQuery) QueryString() (FieldQueryString, error)

type FieldQueryString added in v2.25.0

type FieldQueryString string

func (FieldQueryString) Build added in v2.25.0

func (s FieldQueryString) Build() (*FieldQuery, error)

type FloatCode added in v2.23.0

type FloatCode struct {
	// contains filtered or unexported fields
}

func (*FloatCode) Filter added in v2.25.0

func (c *FloatCode) Filter(_ *FieldQuery) Code

func (*FloatCode) Kind added in v2.23.0

func (c *FloatCode) Kind() CodeKind

func (*FloatCode) ToOpcode added in v2.23.0

func (c *FloatCode) ToOpcode(ctx *compileContext) Opcodes

type IntCode added in v2.23.0

type IntCode struct {
	// contains filtered or unexported fields
}

func (*IntCode) Filter added in v2.25.0

func (c *IntCode) Filter(_ *FieldQuery) Code

func (*IntCode) Kind added in v2.23.0

func (c *IntCode) Kind() CodeKind

func (*IntCode) ToOpcode added in v2.23.0

func (c *IntCode) ToOpcode(ctx *compileContext) Opcodes

type InterfaceCode added in v2.23.0

type InterfaceCode struct {
	// contains filtered or unexported fields
}

func (*InterfaceCode) Filter added in v2.25.0

func (c *InterfaceCode) Filter(query *FieldQuery) Code

func (*InterfaceCode) Kind added in v2.23.0

func (c *InterfaceCode) Kind() CodeKind

func (*InterfaceCode) ToOpcode added in v2.23.0

func (c *InterfaceCode) ToOpcode(ctx *compileContext) Opcodes

type MapCode added in v2.23.0

type MapCode struct {
	// contains filtered or unexported fields
}

func (*MapCode) Filter added in v2.25.0

func (c *MapCode) Filter(_ *FieldQuery) Code

func (*MapCode) Kind added in v2.23.0

func (c *MapCode) Kind() CodeKind

func (*MapCode) ToOpcode added in v2.23.0

func (c *MapCode) ToOpcode(ctx *compileContext) Opcodes

type MapContext

type MapContext struct {
	Start int
	First int
	Idx   int
	Slice *Mapslice
	Buf   []byte
	Len   int
	Iter  mapIter
}

func NewMapContext

func NewMapContext(mapLen int, unorderedMap bool) *MapContext

type MapItem

type MapItem struct {
	Key   []byte
	Value []byte
}

type Mapslice

type Mapslice struct {
	Items []MapItem
}

func (*Mapslice) Len

func (m *Mapslice) Len() int

func (*Mapslice) Less

func (m *Mapslice) Less(i, j int) bool

func (*Mapslice) Swap

func (m *Mapslice) Swap(i, j int)

type MarshalJSONCode added in v2.23.0

type MarshalJSONCode struct {
	// contains filtered or unexported fields
}

func (*MarshalJSONCode) Filter added in v2.25.0

func (c *MarshalJSONCode) Filter(query *FieldQuery) Code

func (*MarshalJSONCode) Kind added in v2.23.0

func (c *MarshalJSONCode) Kind() CodeKind

func (*MarshalJSONCode) ToOpcode added in v2.23.0

func (c *MarshalJSONCode) ToOpcode(ctx *compileContext) Opcodes

type MarshalTextCode added in v2.23.0

type MarshalTextCode struct {
	// contains filtered or unexported fields
}

func (*MarshalTextCode) Filter added in v2.25.0

func (c *MarshalTextCode) Filter(query *FieldQuery) Code

func (*MarshalTextCode) Kind added in v2.23.0

func (c *MarshalTextCode) Kind() CodeKind

func (*MarshalTextCode) ToOpcode added in v2.23.0

func (c *MarshalTextCode) ToOpcode(ctx *compileContext) Opcodes

type OpFlags

type OpFlags uint16
const (
	AnonymousHeadFlags     OpFlags = 1 << 0
	AnonymousKeyFlags      OpFlags = 1 << 1
	IndirectFlags          OpFlags = 1 << 2
	IsTaggedKeyFlags       OpFlags = 1 << 3
	NilCheckFlags          OpFlags = 1 << 4
	AddrForMarshalerFlags  OpFlags = 1 << 5
	IsNextOpPtrTypeFlags   OpFlags = 1 << 6
	IsNilableTypeFlags     OpFlags = 1 << 7
	MarshalerContextFlags  OpFlags = 1 << 8
	NonEmptyInterfaceFlags OpFlags = 1 << 9
)

type OpType

type OpType uint16
const (
	OpEnd                                    OpType = 0
	OpInterface                              OpType = 1
	OpPtr                                    OpType = 2
	OpSliceElem                              OpType = 3
	OpSliceEnd                               OpType = 4
	OpArrayElem                              OpType = 5
	OpArrayEnd                               OpType = 6
	OpMapKey                                 OpType = 7
	OpMapValue                               OpType = 8
	OpMapEnd                                 OpType = 9
	OpRecursive                              OpType = 10
	OpRecursivePtr                           OpType = 11
	OpRecursiveEnd                           OpType = 12
	OpInterfaceEnd                           OpType = 13
	OpInt                                    OpType = 14
	OpUint                                   OpType = 15
	OpFloat32                                OpType = 16
	OpFloat64                                OpType = 17
	OpBool                                   OpType = 18
	OpString                                 OpType = 19
	OpBytes                                  OpType = 20
	OpNumber                                 OpType = 21
	OpArray                                  OpType = 22
	OpMap                                    OpType = 23
	OpSlice                                  OpType = 24
	OpStruct                                 OpType = 25
	OpMarshalJSON                            OpType = 26
	OpMarshalText                            OpType = 27
	OpIntString                              OpType = 28
	OpUintString                             OpType = 29
	OpFloat32String                          OpType = 30
	OpFloat64String                          OpType = 31
	OpBoolString                             OpType = 32
	OpStringString                           OpType = 33
	OpNumberString                           OpType = 34
	OpIntPtr                                 OpType = 35
	OpUintPtr                                OpType = 36
	OpFloat32Ptr                             OpType = 37
	OpFloat64Ptr                             OpType = 38
	OpBoolPtr                                OpType = 39
	OpStringPtr                              OpType = 40
	OpBytesPtr                               OpType = 41
	OpNumberPtr                              OpType = 42
	OpArrayPtr                               OpType = 43
	OpMapPtr                                 OpType = 44
	OpSlicePtr                               OpType = 45
	OpMarshalJSONPtr                         OpType = 46
	OpMarshalTextPtr                         OpType = 47
	OpInterfacePtr                           OpType = 48
	OpIntPtrString                           OpType = 49
	OpUintPtrString                          OpType = 50
	OpFloat32PtrString                       OpType = 51
	OpFloat64PtrString                       OpType = 52
	OpBoolPtrString                          OpType = 53
	OpStringPtrString                        OpType = 54
	OpNumberPtrString                        OpType = 55
	OpStructHeadInt                          OpType = 56
	OpStructHeadOmitEmptyInt                 OpType = 57
	OpStructPtrHeadInt                       OpType = 58
	OpStructPtrHeadOmitEmptyInt              OpType = 59
	OpStructHeadUint                         OpType = 60
	OpStructHeadOmitEmptyUint                OpType = 61
	OpStructPtrHeadUint                      OpType = 62
	OpStructPtrHeadOmitEmptyUint             OpType = 63
	OpStructHeadFloat32                      OpType = 64
	OpStructHeadOmitEmptyFloat32             OpType = 65
	OpStructPtrHeadFloat32                   OpType = 66
	OpStructPtrHeadOmitEmptyFloat32          OpType = 67
	OpStructHeadFloat64                      OpType = 68
	OpStructHeadOmitEmptyFloat64             OpType = 69
	OpStructPtrHeadFloat64                   OpType = 70
	OpStructPtrHeadOmitEmptyFloat64          OpType = 71
	OpStructHeadBool                         OpType = 72
	OpStructHeadOmitEmptyBool                OpType = 73
	OpStructPtrHeadBool                      OpType = 74
	OpStructPtrHeadOmitEmptyBool             OpType = 75
	OpStructHeadString                       OpType = 76
	OpStructHeadOmitEmptyString              OpType = 77
	OpStructPtrHeadString                    OpType = 78
	OpStructPtrHeadOmitEmptyString           OpType = 79
	OpStructHeadBytes                        OpType = 80
	OpStructHeadOmitEmptyBytes               OpType = 81
	OpStructPtrHeadBytes                     OpType = 82
	OpStructPtrHeadOmitEmptyBytes            OpType = 83
	OpStructHeadNumber                       OpType = 84
	OpStructHeadOmitEmptyNumber              OpType = 85
	OpStructPtrHeadNumber                    OpType = 86
	OpStructPtrHeadOmitEmptyNumber           OpType = 87
	OpStructHeadArray                        OpType = 88
	OpStructHeadOmitEmptyArray               OpType = 89
	OpStructPtrHeadArray                     OpType = 90
	OpStructPtrHeadOmitEmptyArray            OpType = 91
	OpStructHeadMap                          OpType = 92
	OpStructHeadOmitEmptyMap                 OpType = 93
	OpStructPtrHeadMap                       OpType = 94
	OpStructPtrHeadOmitEmptyMap              OpType = 95
	OpStructHeadSlice                        OpType = 96
	OpStructHeadOmitEmptySlice               OpType = 97
	OpStructPtrHeadSlice                     OpType = 98
	OpStructPtrHeadOmitEmptySlice            OpType = 99
	OpStructHeadStruct                       OpType = 100
	OpStructHeadOmitEmptyStruct              OpType = 101
	OpStructPtrHeadStruct                    OpType = 102
	OpStructPtrHeadOmitEmptyStruct           OpType = 103
	OpStructHeadMarshalJSON                  OpType = 104
	OpStructHeadOmitEmptyMarshalJSON         OpType = 105
	OpStructPtrHeadMarshalJSON               OpType = 106
	OpStructPtrHeadOmitEmptyMarshalJSON      OpType = 107
	OpStructHeadMarshalText                  OpType = 108
	OpStructHeadOmitEmptyMarshalText         OpType = 109
	OpStructPtrHeadMarshalText               OpType = 110
	OpStructPtrHeadOmitEmptyMarshalText      OpType = 111
	OpStructHeadIntString                    OpType = 112
	OpStructHeadOmitEmptyIntString           OpType = 113
	OpStructPtrHeadIntString                 OpType = 114
	OpStructPtrHeadOmitEmptyIntString        OpType = 115
	OpStructHeadUintString                   OpType = 116
	OpStructHeadOmitEmptyUintString          OpType = 117
	OpStructPtrHeadUintString                OpType = 118
	OpStructPtrHeadOmitEmptyUintString       OpType = 119
	OpStructHeadFloat32String                OpType = 120
	OpStructHeadOmitEmptyFloat32String       OpType = 121
	OpStructPtrHeadFloat32String             OpType = 122
	OpStructPtrHeadOmitEmptyFloat32String    OpType = 123
	OpStructHeadFloat64String                OpType = 124
	OpStructHeadOmitEmptyFloat64String       OpType = 125
	OpStructPtrHeadFloat64String             OpType = 126
	OpStructPtrHeadOmitEmptyFloat64String    OpType = 127
	OpStructHeadBoolString                   OpType = 128
	OpStructHeadOmitEmptyBoolString          OpType = 129
	OpStructPtrHeadBoolString                OpType = 130
	OpStructPtrHeadOmitEmptyBoolString       OpType = 131
	OpStructHeadStringString                 OpType = 132
	OpStructHeadOmitEmptyStringString        OpType = 133
	OpStructPtrHeadStringString              OpType = 134
	OpStructPtrHeadOmitEmptyStringString     OpType = 135
	OpStructHeadNumberString                 OpType = 136
	OpStructHeadOmitEmptyNumberString        OpType = 137
	OpStructPtrHeadNumberString              OpType = 138
	OpStructPtrHeadOmitEmptyNumberString     OpType = 139
	OpStructHeadIntPtr                       OpType = 140
	OpStructHeadOmitEmptyIntPtr              OpType = 141
	OpStructPtrHeadIntPtr                    OpType = 142
	OpStructPtrHeadOmitEmptyIntPtr           OpType = 143
	OpStructHeadUintPtr                      OpType = 144
	OpStructHeadOmitEmptyUintPtr             OpType = 145
	OpStructPtrHeadUintPtr                   OpType = 146
	OpStructPtrHeadOmitEmptyUintPtr          OpType = 147
	OpStructHeadFloat32Ptr                   OpType = 148
	OpStructHeadOmitEmptyFloat32Ptr          OpType = 149
	OpStructPtrHeadFloat32Ptr                OpType = 150
	OpStructPtrHeadOmitEmptyFloat32Ptr       OpType = 151
	OpStructHeadFloat64Ptr                   OpType = 152
	OpStructHeadOmitEmptyFloat64Ptr          OpType = 153
	OpStructPtrHeadFloat64Ptr                OpType = 154
	OpStructPtrHeadOmitEmptyFloat64Ptr       OpType = 155
	OpStructHeadBoolPtr                      OpType = 156
	OpStructHeadOmitEmptyBoolPtr             OpType = 157
	OpStructPtrHeadBoolPtr                   OpType = 158
	OpStructPtrHeadOmitEmptyBoolPtr          OpType = 159
	OpStructHeadStringPtr                    OpType = 160
	OpStructHeadOmitEmptyStringPtr           OpType = 161
	OpStructPtrHeadStringPtr                 OpType = 162
	OpStructPtrHeadOmitEmptyStringPtr        OpType = 163
	OpStructHeadBytesPtr                     OpType = 164
	OpStructHeadOmitEmptyBytesPtr            OpType = 165
	OpStructPtrHeadBytesPtr                  OpType = 166
	OpStructPtrHeadOmitEmptyBytesPtr         OpType = 167
	OpStructHeadNumberPtr                    OpType = 168
	OpStructHeadOmitEmptyNumberPtr           OpType = 169
	OpStructPtrHeadNumberPtr                 OpType = 170
	OpStructPtrHeadOmitEmptyNumberPtr        OpType = 171
	OpStructHeadArrayPtr                     OpType = 172
	OpStructHeadOmitEmptyArrayPtr            OpType = 173
	OpStructPtrHeadArrayPtr                  OpType = 174
	OpStructPtrHeadOmitEmptyArrayPtr         OpType = 175
	OpStructHeadMapPtr                       OpType = 176
	OpStructHeadOmitEmptyMapPtr              OpType = 177
	OpStructPtrHeadMapPtr                    OpType = 178
	OpStructPtrHeadOmitEmptyMapPtr           OpType = 179
	OpStructHeadSlicePtr                     OpType = 180
	OpStructHeadOmitEmptySlicePtr            OpType = 181
	OpStructPtrHeadSlicePtr                  OpType = 182
	OpStructPtrHeadOmitEmptySlicePtr         OpType = 183
	OpStructHeadMarshalJSONPtr               OpType = 184
	OpStructHeadOmitEmptyMarshalJSONPtr      OpType = 185
	OpStructPtrHeadMarshalJSONPtr            OpType = 186
	OpStructPtrHeadOmitEmptyMarshalJSONPtr   OpType = 187
	OpStructHeadMarshalTextPtr               OpType = 188
	OpStructHeadOmitEmptyMarshalTextPtr      OpType = 189
	OpStructPtrHeadMarshalTextPtr            OpType = 190
	OpStructPtrHeadOmitEmptyMarshalTextPtr   OpType = 191
	OpStructHeadInterfacePtr                 OpType = 192
	OpStructHeadOmitEmptyInterfacePtr        OpType = 193
	OpStructPtrHeadInterfacePtr              OpType = 194
	OpStructPtrHeadOmitEmptyInterfacePtr     OpType = 195
	OpStructHeadIntPtrString                 OpType = 196
	OpStructHeadOmitEmptyIntPtrString        OpType = 197
	OpStructPtrHeadIntPtrString              OpType = 198
	OpStructPtrHeadOmitEmptyIntPtrString     OpType = 199
	OpStructHeadUintPtrString                OpType = 200
	OpStructHeadOmitEmptyUintPtrString       OpType = 201
	OpStructPtrHeadUintPtrString             OpType = 202
	OpStructPtrHeadOmitEmptyUintPtrString    OpType = 203
	OpStructHeadFloat32PtrString             OpType = 204
	OpStructHeadOmitEmptyFloat32PtrString    OpType = 205
	OpStructPtrHeadFloat32PtrString          OpType = 206
	OpStructPtrHeadOmitEmptyFloat32PtrString OpType = 207
	OpStructHeadFloat64PtrString             OpType = 208
	OpStructHeadOmitEmptyFloat64PtrString    OpType = 209
	OpStructPtrHeadFloat64PtrString          OpType = 210
	OpStructPtrHeadOmitEmptyFloat64PtrString OpType = 211
	OpStructHeadBoolPtrString                OpType = 212
	OpStructHeadOmitEmptyBoolPtrString       OpType = 213
	OpStructPtrHeadBoolPtrString             OpType = 214
	OpStructPtrHeadOmitEmptyBoolPtrString    OpType = 215
	OpStructHeadStringPtrString              OpType = 216
	OpStructHeadOmitEmptyStringPtrString     OpType = 217
	OpStructPtrHeadStringPtrString           OpType = 218
	OpStructPtrHeadOmitEmptyStringPtrString  OpType = 219
	OpStructHeadNumberPtrString              OpType = 220
	OpStructHeadOmitEmptyNumberPtrString     OpType = 221
	OpStructPtrHeadNumberPtrString           OpType = 222
	OpStructPtrHeadOmitEmptyNumberPtrString  OpType = 223
	OpStructHead                             OpType = 224
	OpStructHeadOmitEmpty                    OpType = 225
	OpStructPtrHead                          OpType = 226
	OpStructPtrHeadOmitEmpty                 OpType = 227
	OpStructFieldInt                         OpType = 228
	OpStructFieldOmitEmptyInt                OpType = 229
	OpStructEndInt                           OpType = 230
	OpStructEndOmitEmptyInt                  OpType = 231
	OpStructFieldUint                        OpType = 232
	OpStructFieldOmitEmptyUint               OpType = 233
	OpStructEndUint                          OpType = 234
	OpStructEndOmitEmptyUint                 OpType = 235
	OpStructFieldFloat32                     OpType = 236
	OpStructFieldOmitEmptyFloat32            OpType = 237
	OpStructEndFloat32                       OpType = 238
	OpStructEndOmitEmptyFloat32              OpType = 239
	OpStructFieldFloat64                     OpType = 240
	OpStructFieldOmitEmptyFloat64            OpType = 241
	OpStructEndFloat64                       OpType = 242
	OpStructEndOmitEmptyFloat64              OpType = 243
	OpStructFieldBool                        OpType = 244
	OpStructFieldOmitEmptyBool               OpType = 245
	OpStructEndBool                          OpType = 246
	OpStructEndOmitEmptyBool                 OpType = 247
	OpStructFieldString                      OpType = 248
	OpStructFieldOmitEmptyString             OpType = 249
	OpStructEndString                        OpType = 250
	OpStructEndOmitEmptyString               OpType = 251
	OpStructFieldBytes                       OpType = 252
	OpStructFieldOmitEmptyBytes              OpType = 253
	OpStructEndBytes                         OpType = 254
	OpStructEndOmitEmptyBytes                OpType = 255
	OpStructFieldNumber                      OpType = 256
	OpStructFieldOmitEmptyNumber             OpType = 257
	OpStructEndNumber                        OpType = 258
	OpStructEndOmitEmptyNumber               OpType = 259
	OpStructFieldArray                       OpType = 260
	OpStructFieldOmitEmptyArray              OpType = 261
	OpStructEndArray                         OpType = 262
	OpStructEndOmitEmptyArray                OpType = 263
	OpStructFieldMap                         OpType = 264
	OpStructFieldOmitEmptyMap                OpType = 265
	OpStructEndMap                           OpType = 266
	OpStructEndOmitEmptyMap                  OpType = 267
	OpStructFieldSlice                       OpType = 268
	OpStructFieldOmitEmptySlice              OpType = 269
	OpStructEndSlice                         OpType = 270
	OpStructEndOmitEmptySlice                OpType = 271
	OpStructFieldStruct                      OpType = 272
	OpStructFieldOmitEmptyStruct             OpType = 273
	OpStructEndStruct                        OpType = 274
	OpStructEndOmitEmptyStruct               OpType = 275
	OpStructFieldMarshalJSON                 OpType = 276
	OpStructFieldOmitEmptyMarshalJSON        OpType = 277
	OpStructEndMarshalJSON                   OpType = 278
	OpStructEndOmitEmptyMarshalJSON          OpType = 279
	OpStructFieldMarshalText                 OpType = 280
	OpStructFieldOmitEmptyMarshalText        OpType = 281
	OpStructEndMarshalText                   OpType = 282
	OpStructEndOmitEmptyMarshalText          OpType = 283
	OpStructFieldIntString                   OpType = 284
	OpStructFieldOmitEmptyIntString          OpType = 285
	OpStructEndIntString                     OpType = 286
	OpStructEndOmitEmptyIntString            OpType = 287
	OpStructFieldUintString                  OpType = 288
	OpStructFieldOmitEmptyUintString         OpType = 289
	OpStructEndUintString                    OpType = 290
	OpStructEndOmitEmptyUintString           OpType = 291
	OpStructFieldFloat32String               OpType = 292
	OpStructFieldOmitEmptyFloat32String      OpType = 293
	OpStructEndFloat32String                 OpType = 294
	OpStructEndOmitEmptyFloat32String        OpType = 295
	OpStructFieldFloat64String               OpType = 296
	OpStructFieldOmitEmptyFloat64String      OpType = 297
	OpStructEndFloat64String                 OpType = 298
	OpStructEndOmitEmptyFloat64String        OpType = 299
	OpStructFieldBoolString                  OpType = 300
	OpStructFieldOmitEmptyBoolString         OpType = 301
	OpStructEndBoolString                    OpType = 302
	OpStructEndOmitEmptyBoolString           OpType = 303
	OpStructFieldStringString                OpType = 304
	OpStructFieldOmitEmptyStringString       OpType = 305
	OpStructEndStringString                  OpType = 306
	OpStructEndOmitEmptyStringString         OpType = 307
	OpStructFieldNumberString                OpType = 308
	OpStructFieldOmitEmptyNumberString       OpType = 309
	OpStructEndNumberString                  OpType = 310
	OpStructEndOmitEmptyNumberString         OpType = 311
	OpStructFieldIntPtr                      OpType = 312
	OpStructFieldOmitEmptyIntPtr             OpType = 313
	OpStructEndIntPtr                        OpType = 314
	OpStructEndOmitEmptyIntPtr               OpType = 315
	OpStructFieldUintPtr                     OpType = 316
	OpStructFieldOmitEmptyUintPtr            OpType = 317
	OpStructEndUintPtr                       OpType = 318
	OpStructEndOmitEmptyUintPtr              OpType = 319
	OpStructFieldFloat32Ptr                  OpType = 320
	OpStructFieldOmitEmptyFloat32Ptr         OpType = 321
	OpStructEndFloat32Ptr                    OpType = 322
	OpStructEndOmitEmptyFloat32Ptr           OpType = 323
	OpStructFieldFloat64Ptr                  OpType = 324
	OpStructFieldOmitEmptyFloat64Ptr         OpType = 325
	OpStructEndFloat64Ptr                    OpType = 326
	OpStructEndOmitEmptyFloat64Ptr           OpType = 327
	OpStructFieldBoolPtr                     OpType = 328
	OpStructFieldOmitEmptyBoolPtr            OpType = 329
	OpStructEndBoolPtr                       OpType = 330
	OpStructEndOmitEmptyBoolPtr              OpType = 331
	OpStructFieldStringPtr                   OpType = 332
	OpStructFieldOmitEmptyStringPtr          OpType = 333
	OpStructEndStringPtr                     OpType = 334
	OpStructEndOmitEmptyStringPtr            OpType = 335
	OpStructFieldBytesPtr                    OpType = 336
	OpStructFieldOmitEmptyBytesPtr           OpType = 337
	OpStructEndBytesPtr                      OpType = 338
	OpStructEndOmitEmptyBytesPtr             OpType = 339
	OpStructFieldNumberPtr                   OpType = 340
	OpStructFieldOmitEmptyNumberPtr          OpType = 341
	OpStructEndNumberPtr                     OpType = 342
	OpStructEndOmitEmptyNumberPtr            OpType = 343
	OpStructFieldArrayPtr                    OpType = 344
	OpStructFieldOmitEmptyArrayPtr           OpType = 345
	OpStructEndArrayPtr                      OpType = 346
	OpStructEndOmitEmptyArrayPtr             OpType = 347
	OpStructFieldMapPtr                      OpType = 348
	OpStructFieldOmitEmptyMapPtr             OpType = 349
	OpStructEndMapPtr                        OpType = 350
	OpStructEndOmitEmptyMapPtr               OpType = 351
	OpStructFieldSlicePtr                    OpType = 352
	OpStructFieldOmitEmptySlicePtr           OpType = 353
	OpStructEndSlicePtr                      OpType = 354
	OpStructEndOmitEmptySlicePtr             OpType = 355
	OpStructFieldMarshalJSONPtr              OpType = 356
	OpStructFieldOmitEmptyMarshalJSONPtr     OpType = 357
	OpStructEndMarshalJSONPtr                OpType = 358
	OpStructEndOmitEmptyMarshalJSONPtr       OpType = 359
	OpStructFieldMarshalTextPtr              OpType = 360
	OpStructFieldOmitEmptyMarshalTextPtr     OpType = 361
	OpStructEndMarshalTextPtr                OpType = 362
	OpStructEndOmitEmptyMarshalTextPtr       OpType = 363
	OpStructFieldInterfacePtr                OpType = 364
	OpStructFieldOmitEmptyInterfacePtr       OpType = 365
	OpStructEndInterfacePtr                  OpType = 366
	OpStructEndOmitEmptyInterfacePtr         OpType = 367
	OpStructFieldIntPtrString                OpType = 368
	OpStructFieldOmitEmptyIntPtrString       OpType = 369
	OpStructEndIntPtrString                  OpType = 370
	OpStructEndOmitEmptyIntPtrString         OpType = 371
	OpStructFieldUintPtrString               OpType = 372
	OpStructFieldOmitEmptyUintPtrString      OpType = 373
	OpStructEndUintPtrString                 OpType = 374
	OpStructEndOmitEmptyUintPtrString        OpType = 375
	OpStructFieldFloat32PtrString            OpType = 376
	OpStructFieldOmitEmptyFloat32PtrString   OpType = 377
	OpStructEndFloat32PtrString              OpType = 378
	OpStructEndOmitEmptyFloat32PtrString     OpType = 379
	OpStructFieldFloat64PtrString            OpType = 380
	OpStructFieldOmitEmptyFloat64PtrString   OpType = 381
	OpStructEndFloat64PtrString              OpType = 382
	OpStructEndOmitEmptyFloat64PtrString     OpType = 383
	OpStructFieldBoolPtrString               OpType = 384
	OpStructFieldOmitEmptyBoolPtrString      OpType = 385
	OpStructEndBoolPtrString                 OpType = 386
	OpStructEndOmitEmptyBoolPtrString        OpType = 387
	OpStructFieldStringPtrString             OpType = 388
	OpStructFieldOmitEmptyStringPtrString    OpType = 389
	OpStructEndStringPtrString               OpType = 390
	OpStructEndOmitEmptyStringPtrString      OpType = 391
	OpStructFieldNumberPtrString             OpType = 392
	OpStructFieldOmitEmptyNumberPtrString    OpType = 393
	OpStructEndNumberPtrString               OpType = 394
	OpStructEndOmitEmptyNumberPtrString      OpType = 395
	OpStructField                            OpType = 396
	OpStructFieldOmitEmpty                   OpType = 397
	OpStructEnd                              OpType = 398
	OpStructEndOmitEmpty                     OpType = 399
)

func (OpType) CodeType

func (t OpType) CodeType() CodeType

func (OpType) FieldToEnd

func (t OpType) FieldToEnd() OpType

func (OpType) FieldToOmitEmptyField

func (t OpType) FieldToOmitEmptyField() OpType

func (OpType) HeadToOmitEmptyHead

func (t OpType) HeadToOmitEmptyHead() OpType

func (OpType) HeadToPtrHead

func (t OpType) HeadToPtrHead() OpType

func (OpType) IsMultipleOpField

func (t OpType) IsMultipleOpField() bool

func (OpType) IsMultipleOpHead

func (t OpType) IsMultipleOpHead() bool

func (OpType) PtrHeadToHead

func (t OpType) PtrHeadToHead() OpType

func (OpType) String

func (t OpType) String() string

type Opcode

type Opcode struct {
	Op         OpType  // operation type
	Idx        uint32  // offset to access ptr
	Next       *Opcode // next opcode
	End        *Opcode // array/slice/struct/map end
	NextField  *Opcode // next struct field
	Key        string  // struct field key
	Offset     uint32  // offset size from struct header
	PtrNum     uint8   // pointer number: e.g. double pointer is 2.
	NumBitSize uint8
	Flags      OpFlags

	Type       *runtime.Type // go type
	Jmp        *CompiledCode // for recursive call
	FieldQuery *FieldQuery   // field query for Interface / MarshalJSON / MarshalText
	ElemIdx    uint32        // offset to access array/slice elem
	Length     uint32        // offset to access slice length or array length
	Indent     uint32        // indent number
	Size       uint32        // array/slice elem size
	DisplayIdx uint32        // opcode index
	DisplayKey string        // key text to display
}

func ToEndCode

func ToEndCode(code *Opcode) *Opcode

func (*Opcode) Dump

func (c *Opcode) Dump() string

func (*Opcode) IsEnd added in v2.23.0

func (c *Opcode) IsEnd() bool

func (*Opcode) IterNext added in v2.23.0

func (c *Opcode) IterNext() *Opcode

func (*Opcode) MaxIdx

func (c *Opcode) MaxIdx() uint32

func (*Opcode) ToFieldType

func (c *Opcode) ToFieldType(isString bool) OpType

func (*Opcode) ToHeaderType

func (c *Opcode) ToHeaderType(isString bool) OpType

func (*Opcode) TotalLength

func (c *Opcode) TotalLength() int

func (*Opcode) Validate added in v2.23.0

func (c *Opcode) Validate() error

type OpcodeSet

type OpcodeSet struct {
	Type                     *runtime.Type
	NoescapeKeyCode          *Opcode
	EscapeKeyCode            *Opcode
	InterfaceNoescapeKeyCode *Opcode
	InterfaceEscapeKeyCode   *Opcode
	CodeLength               int
	EndCode                  *Opcode
	Code                     Code
	QueryCache               map[string]*OpcodeSet
	// contains filtered or unexported fields
}

func CompileToGetCodeSet

func CompileToGetCodeSet(ctx *RuntimeContext, typeptr uintptr) (*OpcodeSet, error)

type Opcodes added in v2.23.0

type Opcodes []*Opcode

func (Opcodes) Add added in v2.23.0

func (o Opcodes) Add(codes ...*Opcode) Opcodes

func (Opcodes) First added in v2.23.0

func (o Opcodes) First() *Opcode

func (Opcodes) Last added in v2.23.0

func (o Opcodes) Last() *Opcode

type Option

type Option struct {
	Flag        OptionFlag
	ColorScheme *ColorScheme
	Context     context.Context
}

type OptionFlag

type OptionFlag uint8
const (
	HTMLEscapeOption OptionFlag = 1 << iota
	IndentOption
	UnorderedMapOption
	DebugOption
	ColorizeOption
	ContextOption
	NormalizeUTF8Option
	FieldQueryOption
)

type PtrCode added in v2.23.0

type PtrCode struct {
	// contains filtered or unexported fields
}

func (*PtrCode) Filter added in v2.25.0

func (c *PtrCode) Filter(query *FieldQuery) Code

func (*PtrCode) Kind added in v2.23.0

func (c *PtrCode) Kind() CodeKind

func (*PtrCode) ToAnonymousOpcode added in v2.23.0

func (c *PtrCode) ToAnonymousOpcode(ctx *compileContext) Opcodes

func (*PtrCode) ToOpcode added in v2.23.0

func (c *PtrCode) ToOpcode(ctx *compileContext) Opcodes

type RuntimeContext

type RuntimeContext struct {
	Context    context.Context
	Buf        []byte
	MarshalBuf []byte
	Ptrs       []uintptr
	KeepRefs   []unsafe.Pointer
	SeenPtr    []uintptr
	BaseIndent uint32
	Prefix     []byte
	IndentStr  []byte
	Option     *Option
}

func TakeRuntimeContext

func TakeRuntimeContext() *RuntimeContext

func (*RuntimeContext) Init

func (c *RuntimeContext) Init(p uintptr, codelen int)

func (*RuntimeContext) Ptr

func (c *RuntimeContext) Ptr() uintptr

type SliceCode added in v2.23.0

type SliceCode struct {
	// contains filtered or unexported fields
}

func (*SliceCode) Filter added in v2.25.0

func (c *SliceCode) Filter(_ *FieldQuery) Code

func (*SliceCode) Kind added in v2.23.0

func (c *SliceCode) Kind() CodeKind

func (*SliceCode) ToOpcode added in v2.23.0

func (c *SliceCode) ToOpcode(ctx *compileContext) Opcodes

type StringCode added in v2.23.0

type StringCode struct {
	// contains filtered or unexported fields
}

func (*StringCode) Filter added in v2.25.0

func (c *StringCode) Filter(_ *FieldQuery) Code

func (*StringCode) Kind added in v2.23.0

func (c *StringCode) Kind() CodeKind

func (*StringCode) ToOpcode added in v2.23.0

func (c *StringCode) ToOpcode(ctx *compileContext) Opcodes

type StructCode added in v2.23.0

type StructCode struct {
	// contains filtered or unexported fields
}

func (*StructCode) Filter added in v2.25.0

func (c *StructCode) Filter(query *FieldQuery) Code

func (*StructCode) Kind added in v2.23.0

func (c *StructCode) Kind() CodeKind

func (*StructCode) ToAnonymousOpcode added in v2.23.0

func (c *StructCode) ToAnonymousOpcode(ctx *compileContext) Opcodes

func (*StructCode) ToOpcode added in v2.23.0

func (c *StructCode) ToOpcode(ctx *compileContext) Opcodes

type StructFieldCode added in v2.23.0

type StructFieldCode struct {
	// contains filtered or unexported fields
}

func (*StructFieldCode) ToAnonymousOpcode added in v2.23.0

func (c *StructFieldCode) ToAnonymousOpcode(ctx *compileContext, isFirstField, isEndField bool) Opcodes

func (*StructFieldCode) ToOpcode added in v2.23.0

func (c *StructFieldCode) ToOpcode(ctx *compileContext, isFirstField, isEndField bool) Opcodes

type UintCode added in v2.23.0

type UintCode struct {
	// contains filtered or unexported fields
}

func (*UintCode) Filter added in v2.25.0

func (c *UintCode) Filter(_ *FieldQuery) Code

func (*UintCode) Kind added in v2.23.0

func (c *UintCode) Kind() CodeKind

func (*UintCode) ToOpcode added in v2.23.0

func (c *UintCode) ToOpcode(ctx *compileContext) Opcodes

Directories

Path Synopsis
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.
Code generated by internal/cmd/generator.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL