Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the appropriate base conversion in decode generation #204

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions _generated/def.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package _generated

import (
"math/big"
"os"
"time"

Expand Down Expand Up @@ -263,3 +264,19 @@ type NonMsgStructTags struct {
}
}
}

//msgp:shim big.Int as:[]byte using:i2b/b2i

func b2i(b []byte) big.Int {
var i big.Int
i.SetBytes(b)
return i
}

func i2b(i big.Int) []byte {
return i.Bytes()
}

type Issue203 struct {
Value big.Int `msg:"value"`
}
2 changes: 1 addition & 1 deletion gen/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func (d *decodeGen) gBase(b *BaseElem) {
switch b.Value {
case Bytes:
if b.Convert {
d.p.printf("\n%s, err = dc.ReadBytes([]byte(%s))", tmp, vname)
d.p.printf("\n%s, err = dc.ReadBytes(%s)", tmp, tobaseConvert(b))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For convert mode, the functions being called return two values ([]byte, error), so I think this will throw an error.

} else {
d.p.printf("\n%s, err = dc.ReadBytes(%s)", vname, vname)
}
Expand Down