MCPcopy
hub / github.com/ugorji/go / CodecEncodeSelf

Method CodecEncodeSelf

codec/values_codecgen_generated_test.go:7365–7426  ·  view source on GitHub ↗
(e *Encoder)

Source from the content-addressed store, hash-verified

7363
7364func (codecgenL) codecSelferViaCodecgen() {}
7365func (x *codecgenL) CodecEncodeSelf(e *Encoder) {
7366 var h codecSelfer19780
7367 z, r := GenHelper().Encoder(e)
7368 _, _, _ = h, z, r
7369 if z.EncBasicHandle().CheckCircularRef {
7370 z.EncEncode(x)
7371 return
7372 }
7373 if x == nil {
7374 r.EncodeNil()
7375 } else {
7376 yy2arr2 := z.EncBasicHandle().StructToArray
7377 _ = yy2arr2
7378 const yyr2 bool = false // struct tag has 'toArray'
7379 if yyr2 || yy2arr2 {
7380 z.EncWriteArrayStart(2)
7381 z.EncWriteArrayElem()
7382 r.EncodeInt(int64(x.X))
7383 z.EncWriteArrayElem()
7384 r.EncodeUint(uint64(x.Y))
7385 z.EncWriteArrayEnd()
7386 } else {
7387 z.EncWriteMapStart(2)
7388 if z.EncBasicHandle().Canonical {
7389 z.EncWriteMapElemKey()
7390 if z.IsJSONHandle() {
7391 z.EncWr().WriteStr("\"X\"")
7392 } else {
7393 r.EncodeString(`X`)
7394 }
7395 z.EncWriteMapElemValue()
7396 r.EncodeInt(int64(x.X))
7397 z.EncWriteMapElemKey()
7398 if z.IsJSONHandle() {
7399 z.EncWr().WriteStr("\"Y\"")
7400 } else {
7401 r.EncodeString(`Y`)
7402 }
7403 z.EncWriteMapElemValue()
7404 r.EncodeUint(uint64(x.Y))
7405 } else {
7406 z.EncWriteMapElemKey()
7407 if z.IsJSONHandle() {
7408 z.EncWr().WriteStr("\"X\"")
7409 } else {
7410 r.EncodeString(`X`)
7411 }
7412 z.EncWriteMapElemValue()
7413 r.EncodeInt(int64(x.X))
7414 z.EncWriteMapElemKey()
7415 if z.IsJSONHandle() {
7416 z.EncWr().WriteStr("\"Y\"")
7417 } else {
7418 r.EncodeString(`Y`)
7419 }
7420 z.EncWriteMapElemValue()
7421 r.EncodeUint(uint64(x.Y))
7422 }

Callers

nothing calls this directly

Calls 15

GenHelperFunction · 0.85
EncoderMethod · 0.80
EncBasicHandleMethod · 0.80
EncEncodeMethod · 0.80
EncWriteArrayStartMethod · 0.80
EncWriteArrayElemMethod · 0.80
EncWriteArrayEndMethod · 0.80
EncWriteMapStartMethod · 0.80
EncWriteMapElemKeyMethod · 0.80
WriteStrMethod · 0.80
EncWrMethod · 0.80
EncWriteMapElemValueMethod · 0.80

Tested by

no test coverage detected