| // Copyright 2020 The Go Authors. All rights reserved. | |
| // Use of this source code is governed by a BSD-style | |
| // license that can be found in the LICENSE file. | |
| // Code generated by the codec package. DO NOT EDIT. | |
| //lint:file-ignore SA1019 go/doc uses *ast.Object, so we must preserve it. | |
| package somepkg | |
| import ( | |
| "go/token" | |
| "golang.org/x/pkgsite/internal/godoc/codec" | |
| ) | |
| // Fields of codec_BasicLit: ValuePos Kind Value | |
| func encode_codec_BasicLit(e *codec.Encoder, x *codec.BasicLit) { | |
| if !e.StartStruct(x == nil, x) { | |
| return | |
| } | |
| if x.ValuePos != 0 { | |
| e.EncodeUint(0) | |
| e.EncodeInt(int64(x.ValuePos)) | |
| } | |
| if x.Kind != 0 { | |
| e.EncodeUint(1) | |
| e.EncodeInt(int64(x.Kind)) | |
| } | |
| if x.Value != "" { | |
| e.EncodeUint(2) | |
| e.EncodeString(x.Value) | |
| } | |
| e.EndStruct() | |
| } | |
| func decode_codec_BasicLit(d *codec.Decoder, p **codec.BasicLit) { | |
| proceed, ref := d.StartStruct() | |
| if !proceed { | |
| return | |
| } | |
| if ref != nil { | |
| *p = ref.(*codec.BasicLit) | |
| return | |
| } | |
| var x codec.BasicLit | |
| d.StoreRef(&x) | |
| for { | |
| n := d.NextStructField() | |
| if n < 0 { | |
| break | |
| } | |
| switch n { | |
| case 0: | |
| x.ValuePos = token.Pos(d.DecodeInt()) | |
| case 1: | |
| x.Kind = token.Token(d.DecodeInt()) | |
| case 2: | |
| x.Value = d.DecodeString() | |
| default: | |
| d.UnknownField("codec.BasicLit", n) | |
| } | |
| *p = &x | |
| } | |
| } | |
| func init() { | |
| codec.Register(&codec.BasicLit{}, | |
| func(e *codec.Encoder, x any) { encode_codec_BasicLit(e, x.(*codec.BasicLit)) }, | |
| func(d *codec.Decoder) any { | |
| var x *codec.BasicLit | |
| decode_codec_BasicLit(d, &x) | |
| return x | |
| }) | |
| } |