Skip to content

Commit

Permalink
gendecoder: handle int type
Browse files Browse the repository at this point in the history
  • Loading branch information
safchain committed Oct 1, 2019
1 parent 53b47ea commit 24ced98
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions scripts/gendecoder/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func resolveSymbol(pkg, symbol string) (types.Object, error) {

func handleBasic(getter *getter, name, kind string) {
switch kind {
case "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64":
case "int", "int8", "int16", "int32", "int64", "uint", "uint8", "uint16", "uint32", "uint64":
getter.Fields = append(getter.Fields, field{Name: name, Type: "int64"})
default:
public := false
Expand All @@ -115,13 +115,16 @@ func handleBasic(getter *getter, name, kind string) {

func handleField(astFile *ast.File, getter *getter, fieldName, pkgName, fieldType string) error {
switch fieldType {
case "string", "bool", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64":
case "string", "bool", "int", "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64":
handleBasic(getter, fieldName, fieldType)
default:
symbol, err := resolveSymbol(pkgName, fieldType)
if err != nil || symbol == nil {
if err != nil {
return fmt.Errorf("Failed to resolve symbol for %+v: %s", fieldType, err)
}
if symbol == nil {
return fmt.Errorf("Failed to resolve symbol for %+v", fieldType)
}

if named, ok := symbol.Type().(*types.Named); ok {
for i := 0; i < named.NumMethods(); i++ {
Expand Down

0 comments on commit 24ced98

Please sign in to comment.