mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
accounts/abi/bind: Improve code readability
This commit is contained in:
parent
a31bc94a55
commit
0e147cce0f
1 changed files with 15 additions and 10 deletions
|
|
@ -296,21 +296,26 @@ func bindUnnestedTypeJava(stringKind string) (int, string) {
|
|||
return len(parts[0]), "byte[]"
|
||||
|
||||
case strings.HasPrefix(stringKind, "int") || strings.HasPrefix(stringKind, "uint"):
|
||||
//Note that uint and int (without digits) are also matched,
|
||||
// these are size 256, and will translate to BigInt (the default).
|
||||
parts := regexp.MustCompile(`(u)?int([0-9]*)`).FindStringSubmatch(stringKind)
|
||||
if len(parts) != 3 {
|
||||
return len(stringKind), stringKind
|
||||
}
|
||||
switch parts[2] {
|
||||
case "8":
|
||||
return len(parts[0]), "byte"
|
||||
case "16":
|
||||
return len(parts[0]), "short"
|
||||
case "32":
|
||||
return len(parts[0]), "int"
|
||||
case "64":
|
||||
return len(parts[0]), "long"
|
||||
|
||||
namedSize := map[string]string{
|
||||
"8": "byte",
|
||||
"16": "short",
|
||||
"32": "int",
|
||||
"64": "long",
|
||||
}[parts[2]]
|
||||
|
||||
//default to BigInt
|
||||
if namedSize == "" {
|
||||
namedSize = "BigInt"
|
||||
}
|
||||
return len(parts[0]), "BigInt"
|
||||
return len(parts[0]), namedSize
|
||||
|
||||
case strings.HasPrefix(stringKind, "bool"):
|
||||
return len("bool"), "boolean"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue