Source File
encode.go
Belonging Package
google.golang.org/protobuf/internal/impl
package impl
import (
proto
piface
)
type marshalOptions struct {
flags piface.MarshalInputFlags
}
func ( marshalOptions) () proto.MarshalOptions {
return proto.MarshalOptions{
AllowPartial: true,
Deterministic: .Deterministic(),
UseCachedSize: .UseCachedSize(),
}
}
func ( marshalOptions) () bool { return .flags&piface.MarshalDeterministic != 0 }
func ( marshalOptions) () bool { return .flags&piface.MarshalUseCachedSize != 0 }
func ( *MessageInfo) ( piface.SizeInput) piface.SizeOutput {
var pointer
if , := .Message.(*messageState); {
= .pointer()
} else {
= .Message.(*messageReflectWrapper).pointer()
}
:= .sizePointer(, marshalOptions{
flags: .Flags,
})
return piface.SizeOutput{Size: }
}
func ( *MessageInfo) ( pointer, marshalOptions) ( int) {
.init()
if .IsNil() {
return 0
}
if .UseCachedSize() && .sizecacheOffset.IsValid() {
if := atomic.LoadInt32(.Apply(.sizecacheOffset).Int32()); >= 0 {
return int()
}
}
return .sizePointerSlow(, )
}
func ( *MessageInfo) ( pointer, marshalOptions) ( int) {
if flags.ProtoLegacy && .isMessageSet {
= sizeMessageSet(, , )
if .sizecacheOffset.IsValid() {
atomic.StoreInt32(.Apply(.sizecacheOffset).Int32(), int32())
}
return
}
if .extensionOffset.IsValid() {
:= .Apply(.extensionOffset).Extensions()
+= .sizeExtensions(, )
}
for , := range .orderedCoderFields {
if .funcs.size == nil {
continue
}
:= .Apply(.offset)
if .isPointer && .Elem().IsNil() {
continue
}
+= .funcs.size(, , )
}
if .unknownOffset.IsValid() {
:= *.Apply(.unknownOffset).Bytes()
+= len()
}
if .sizecacheOffset.IsValid() {
atomic.StoreInt32(.Apply(.sizecacheOffset).Int32(), -1)
} else {
atomic.StoreInt32(.Apply(.sizecacheOffset).Int32(), int32())
}
}
return
}
func ( *MessageInfo) ( piface.MarshalInput) ( piface.MarshalOutput, error) {
var pointer
if , := .Message.(*messageState); {
= .pointer()
} else {
= .Message.(*messageReflectWrapper).pointer()
}
, := .marshalAppendPointer(.Buf, , marshalOptions{
flags: .Flags,
})
return piface.MarshalOutput{Buf: },
}
func ( *MessageInfo) ( []byte, pointer, marshalOptions) ([]byte, error) {
.init()
if .IsNil() {
return , nil
}
if flags.ProtoLegacy && .isMessageSet {
return marshalMessageSet(, , , )
}
if .extensionOffset.IsValid() {
, = .appendExtensions(, , )
if != nil {
return ,
}
}
for , := range .orderedCoderFields {
if .funcs.marshal == nil {
continue
}
:= .Apply(.offset)
if .isPointer && .Elem().IsNil() {
continue
}
, = .funcs.marshal(, , , )
if != nil {
return ,
}
}
if .unknownOffset.IsValid() && !.isMessageSet {
:= *.Apply(.unknownOffset).Bytes()
= append(, ...)
}
return , nil
}
func ( *MessageInfo) ( *map[int32]ExtensionField, marshalOptions) ( int) {
if == nil {
return 0
}
for , := range * {
:= getExtensionFieldInfo(.Type())
if .funcs.size == nil {
continue
}
+= .funcs.size(.Value(), .tagsize, )
}
return
}
func ( *MessageInfo) ( []byte, *map[int32]ExtensionField, marshalOptions) ([]byte, error) {
if == nil {
return , nil
}
switch len(*) {
case 0:
return , nil
![]() |
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. |