github.com/klaytn/klaytn@v1.12.1/rlp/rlpgen/testdata/optional.out.txt (about) 1 package test 2 3 import "github.com/klaytn/klaytn/rlp" 4 import "io" 5 6 func (obj *Test) EncodeRLP(_w io.Writer) error { 7 w := rlp.NewEncoderBuffer(_w) 8 _tmp0 := w.List() 9 _tmp1 := obj.Uint64 != 0 10 _tmp2 := obj.Pointer != nil 11 _tmp3 := obj.String != "" 12 _tmp4 := len(obj.Slice) > 0 13 _tmp5 := obj.Array != ([3]byte{}) 14 _tmp6 := obj.NamedStruct != (Aux{}) 15 _tmp7 := obj.AnonStruct != (struct{ A string }{}) 16 if _tmp1 || _tmp2 || _tmp3 || _tmp4 || _tmp5 || _tmp6 || _tmp7 { 17 w.WriteUint64(obj.Uint64) 18 } 19 if _tmp2 || _tmp3 || _tmp4 || _tmp5 || _tmp6 || _tmp7 { 20 if obj.Pointer == nil { 21 w.Write([]byte{0x80}) 22 } else { 23 w.WriteUint64((*obj.Pointer)) 24 } 25 } 26 if _tmp3 || _tmp4 || _tmp5 || _tmp6 || _tmp7 { 27 w.WriteString(obj.String) 28 } 29 if _tmp4 || _tmp5 || _tmp6 || _tmp7 { 30 _tmp8 := w.List() 31 for _, _tmp9 := range obj.Slice { 32 w.WriteUint64(_tmp9) 33 } 34 w.ListEnd(_tmp8) 35 } 36 if _tmp5 || _tmp6 || _tmp7 { 37 w.WriteBytes(obj.Array[:]) 38 } 39 if _tmp6 || _tmp7 { 40 _tmp10 := w.List() 41 w.WriteUint64(obj.NamedStruct.A) 42 w.ListEnd(_tmp10) 43 } 44 if _tmp7 { 45 _tmp11 := w.List() 46 w.WriteString(obj.AnonStruct.A) 47 w.ListEnd(_tmp11) 48 } 49 w.ListEnd(_tmp0) 50 return w.Flush() 51 } 52 53 func (obj *Test) DecodeRLP(dec *rlp.Stream) error { 54 var _tmp0 Test 55 { 56 if _, err := dec.List(); err != nil { 57 return err 58 } 59 // Uint64: 60 if dec.MoreDataInList() { 61 _tmp1, err := dec.Uint64() 62 if err != nil { 63 return err 64 } 65 _tmp0.Uint64 = _tmp1 66 // Pointer: 67 if dec.MoreDataInList() { 68 _tmp2, err := dec.Uint64() 69 if err != nil { 70 return err 71 } 72 _tmp0.Pointer = &_tmp2 73 // String: 74 if dec.MoreDataInList() { 75 _tmp3, err := dec.String() 76 if err != nil { 77 return err 78 } 79 _tmp0.String = _tmp3 80 // Slice: 81 if dec.MoreDataInList() { 82 var _tmp4 []uint64 83 if _, err := dec.List(); err != nil { 84 return err 85 } 86 for dec.MoreDataInList() { 87 _tmp5, err := dec.Uint64() 88 if err != nil { 89 return err 90 } 91 _tmp4 = append(_tmp4, _tmp5) 92 } 93 if err := dec.ListEnd(); err != nil { 94 return err 95 } 96 _tmp0.Slice = _tmp4 97 // Array: 98 if dec.MoreDataInList() { 99 var _tmp6 [3]byte 100 if err := dec.ReadBytes(_tmp6[:]); err != nil { 101 return err 102 } 103 _tmp0.Array = _tmp6 104 // NamedStruct: 105 if dec.MoreDataInList() { 106 var _tmp7 Aux 107 { 108 if _, err := dec.List(); err != nil { 109 return err 110 } 111 // A: 112 _tmp8, err := dec.Uint64() 113 if err != nil { 114 return err 115 } 116 _tmp7.A = _tmp8 117 if err := dec.ListEnd(); err != nil { 118 return err 119 } 120 } 121 _tmp0.NamedStruct = _tmp7 122 // AnonStruct: 123 if dec.MoreDataInList() { 124 var _tmp9 struct{ A string } 125 { 126 if _, err := dec.List(); err != nil { 127 return err 128 } 129 // A: 130 _tmp10, err := dec.String() 131 if err != nil { 132 return err 133 } 134 _tmp9.A = _tmp10 135 if err := dec.ListEnd(); err != nil { 136 return err 137 } 138 } 139 _tmp0.AnonStruct = _tmp9 140 } 141 } 142 } 143 } 144 } 145 } 146 } 147 if err := dec.ListEnd(); err != nil { 148 return err 149 } 150 } 151 *obj = _tmp0 152 return nil 153 }