Documentation ¶
Index ¶
- Variables
- func ContainType()
- func CopyFieldValueByType(src any, sub any) bool
- func CopyStruct(src any, dest any) error
- func DereferenceInterfaceValue(v reflect.Value) reflect.Value
- func DereferencePtrValue(v reflect.Value) reflect.Value
- func DereferenceType(t reflect.Type) reflect.Type
- func DereferenceValue(v reflect.Value) reflect.Value
- func Hash(v interface{}) uint32
- func OriginalType(typ reflect.Type) reflect.Type
- func RuntimeTypeID(t reflect.Type) uintptr
- func SetField(structValue reflect.Value, name string, value any) error
- func SetField2(o interface{}, field string, v interface{})
- func SetSubField(src any, sub any) bool
- func SetSubFieldValue(srcValue reflect.Value, subValue reflect.Value) bool
- func Stream(array any) stream
- func TypeInfo(v interface{})
- type ChanType
- type Eface
- type EmptyInterface
- type Flag
- type Func
- type FuncID
- type Iface
- type Imethod
- type InterfaceType
- type Itab
- type MapType
- type Name
- type NameOff
- type NonEmptyInterface
- type PtrType
- type Rtype
- type SliceType
- type StructField
- type StructType
- type TextOff
- type Tflag
- type Type
- type TypeOff
- type Value
Constants ¶
This section is empty.
Variables ¶
var ( PtrOffset = func() uintptr { return unsafe.Offsetof(e.Word) }() KindOffset = func() uintptr { return unsafe.Offsetof(e.Typ.Kind) }() ElemOffset = func() uintptr { return unsafe.Offsetof(new(PtrType).Elem) }() SliceDataOffset = func() uintptr { return unsafe.Offsetof(new(reflect.SliceHeader).Data) }() )
Functions ¶
func CopyFieldValueByType ¶
CopyFieldValueByType 根据类型复制字段 参数均为指针,sub类型为src field的类型
func DereferenceInterfaceValue ¶
DereferenceInterfaceValue returns the value of the underlying type that implements the interface v.
func DereferencePtrValue ¶
DereferencePtrValue returns the underlying non-pointer type value.
func DereferenceValue ¶
DereferenceValue dereference and unpack interface, get the underlying non-pointer and non-interface value.
func RuntimeTypeID ¶
func SetSubField ¶
SetSubField 设置字段值 参数均为指针,dst类型为src field的类型
func SetSubFieldValue ¶
SetSubFieldValue 设置字段值 subValue为srcValue field的类型
Types ¶
type ChanType ¶
type ChanType struct { Rtype Elem *Rtype // channel element type Dir uintptr // channel direction (ChanDir) }
ChanType represents a channel type.
type EmptyInterface ¶
type Flag ¶
type Flag uintptr
const ( FlagKindWidth = 5 // there are 27 kinds FlagKindMask Flag = 1<<FlagKindWidth - 1 FlagStickyRO Flag = 1 << 5 FlagEmbedRO Flag = 1 << 6 FlagIndir Flag = 1 << 7 FlagAddr Flag = 1 << 8 FlagMethod Flag = 1 << 9 FlagMethodShift = 10 FlagRO Flag = FlagStickyRO | FlagEmbedRO )
type Func ¶
type Func struct { Entry uintptr // start pc Nameoff int32 // function name Args int32 // in/out args size Deferreturn uint32 // offset of start of a deferreturn call instruction from entry, if any. Pcsp uint32 Pcfile uint32 Pcln uint32 Npcdata uint32 CuOffset uint32 // runtime.cutab offset of this function's CU FuncID FuncID // set for certain special runtime functions Nfuncdata uint8 // must be last // contains filtered or unexported fields }
type InterfaceType ¶
interfaceType represents an interface type.
type MapType ¶
type MapType struct { Rtype Key *Rtype // map key type Elem *Rtype // map element (value) type Bucket *Rtype // internal bucket structure // function for hashing keys (ptr to key, seed) -> hash Hasher func(unsafe.Pointer, uintptr) uintptr Keysize uint8 // size of key slot Valuesize uint8 // size of value slot Bucketsize uint16 // size of bucket Flags uint32 }
MapType represents a map type.
type NonEmptyInterface ¶
type NonEmptyInterface struct { // see ../runtime/iface.go:/Itab Itab *struct { Ityp *Rtype // static interface type Typ *Rtype // dynamic concrete type Hash uint32 // copy of typ.hash Fun [100000]unsafe.Pointer // method table // contains filtered or unexported fields } Word unsafe.Pointer }
NonEmptyInterface is the header for an interface value with methods.
type Rtype ¶
type Rtype struct { Size uintptr Ptrdata uintptr // number of bytes in the type that can contain pointers Hash uint32 // hash of type; avoids computation in hash tables Align uint8 // alignment of variable with this type FieldAlign uint8 // alignment of struct field with this type Kind uint8 // enumeration for C // function for comparing objects of this type // (ptr to object A, ptr to object B) -> ==? Equal func(unsafe.Pointer, unsafe.Pointer) bool Gcdata *byte // garbage collection data Str NameOff // string form PtrToThis TypeOff // type for pointer to this type, may be zero // contains filtered or unexported fields }
Rtype must be kept in sync with ../runtime/type.go:/^type._type.
type StructField ¶
type StructField struct { Name Name // name is always non-empty Typ *Rtype // type of field OffsetEmbed uintptr // byte offset of field<<1 | isEmbedded }
Struct field
type StructType ¶
type StructType struct { Rtype PkgPath Name Fields []StructField // sorted by offset }
StructType represents a struct type.
type Type ¶
type Type struct { Size uintptr Ptrdata uintptr // size of memory prefix holding all pointers Hash uint32 Tflag Tflag Align uint8 FieldAlign uint8 Kind uint8 // function for comparing objects of this type // (ptr to object A, ptr to object B) -> ==? Equal func(unsafe.Pointer, unsafe.Pointer) bool // gcdata stores the GC type data for the garbage collector. // If the KindGCProg bit is set in kind, gcdata is a GC program. // Otherwise it is a ptrmask bitmap. See mbitmap.go for details. Gcdata *byte Str NameOff PtrToThis TypeOff }