MCPcopy Create free account
hub / github.com/apache/fory / WriteData

Method WriteData

go/fory/enum.go:31–44  ·  view source on GitHub ↗
(ctx *WriteContext, value reflect.Value)

Source from the content-addressed store, hash-verified

29}
30
31func (s *enumSerializer) WriteData(ctx *WriteContext, value reflect.Value) {
32 // Convert the enum value to its integer ordinal
33 var ordinal uint32
34 switch value.Kind() {
35 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
36 ordinal = uint32(value.Int())
37 case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64:
38 ordinal = uint32(value.Uint())
39 default:
40 ctx.SetError(SerializationErrorf("enum serializer: unsupported kind %v", value.Kind()))
41 return
42 }
43 ctx.buffer.WriteVarUint32Small7(ordinal)
44}
45
46func (s *enumSerializer) Write(ctx *WriteContext, refMode RefMode, writeType bool, hasGenerics bool, value reflect.Value) {
47 if refMode != RefModeNone {

Callers 1

WriteMethod · 0.95

Calls 5

SerializationErrorfFunction · 0.85
KindMethod · 0.80
WriteVarUint32Small7Method · 0.80
uint32Function · 0.50
SetErrorMethod · 0.45

Tested by

no test coverage detected