Source File
value_unsafe.go
Belonging Package
google.golang.org/protobuf/reflect/protoreflect
package protoreflect
import (
)
type (
stringHeader struct {
Data unsafe.Pointer
Len int
}
sliceHeader struct {
Data unsafe.Pointer
Len int
Cap int
}
ifaceHeader struct {
Type unsafe.Pointer
Data unsafe.Pointer
}
)
var (
nilType = typeOf(nil)
boolType = typeOf(*new(bool))
int32Type = typeOf(*new(int32))
int64Type = typeOf(*new(int64))
uint32Type = typeOf(*new(uint32))
uint64Type = typeOf(*new(uint64))
float32Type = typeOf(*new(float32))
float64Type = typeOf(*new(float64))
stringType = typeOf(*new(string))
bytesType = typeOf(*new([]byte))
enumType = typeOf(*new(EnumNumber))
)
type value struct {
pragma.DoNotCompare // 0B
num uint64 // 8B
}
func ( string) Value {
:= (*stringHeader)(unsafe.Pointer(&))
return Value{typ: stringType, ptr: .Data, num: uint64(len())}
}
func ( []byte) Value {
:= (*sliceHeader)(unsafe.Pointer(&))
return Value{typ: bytesType, ptr: .Data, num: uint64(len())}
}
func ( interface{}) Value {
:= (*ifaceHeader)(unsafe.Pointer(&))
return Value{typ: .Type, ptr: .Data}
}
func ( Value) () ( string) {
*(*stringHeader)(unsafe.Pointer(&)) = stringHeader{Data: .ptr, Len: int(.num)}
return
}
func ( Value) () ( []byte) {
*(*sliceHeader)(unsafe.Pointer(&)) = sliceHeader{Data: .ptr, Len: int(.num), Cap: int(.num)}
return
}
func ( Value) () ( interface{}) {
*(*ifaceHeader)(unsafe.Pointer(&)) = ifaceHeader{Type: .typ, Data: .ptr}
return
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |