refactor
This commit is contained in:
parent
6e7565284e
commit
57e4b16afc
@ -124,10 +124,10 @@ func (p *TypescriptApiParser) fieldToVal(typ *ast.TypeNode) (types.ValType, erro
|
|||||||
case "Buffer":
|
case "Buffer":
|
||||||
return types.TBlob, nil
|
return types.TBlob, nil
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("reference type %s is not supported yet", ident.Text)
|
return types.TNoType, fmt.Errorf("reference type %s is not supported yet", ident.Text)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return 0, fmt.Errorf("type %s is not supported yet", typ.Kind)
|
return types.TNoType, fmt.Errorf("type %s is not supported yet", typ.Kind)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,28 +1,12 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
type ValType int
|
type ValType string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TInt ValType = 1
|
TNoType ValType = "" // zero value constant for ValType (please don't use just "" as zero value!)
|
||||||
TString ValType = 2
|
TInt ValType = "int"
|
||||||
TBool ValType = 3
|
TString ValType = "string"
|
||||||
TBlob ValType = 4
|
TBool ValType = "bool"
|
||||||
TArray ValType = 5
|
TBlob ValType = "blob"
|
||||||
|
TArray ValType = "array"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (v ValType) String() string {
|
|
||||||
switch v {
|
|
||||||
case TInt:
|
|
||||||
return "int"
|
|
||||||
case TString:
|
|
||||||
return "string"
|
|
||||||
case TBool:
|
|
||||||
return "bool"
|
|
||||||
case TBlob:
|
|
||||||
return "blob"
|
|
||||||
case TArray:
|
|
||||||
return "array"
|
|
||||||
default:
|
|
||||||
panic("unreachable code")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user