forked from TrueCloudLab/neoneo-go
binding: avoid name conflicts with Go keywords
And clashing one name on another after rename.
This commit is contained in:
parent
3b635164b7
commit
02ce59cfd5
3 changed files with 28 additions and 5 deletions
|
@ -45,6 +45,15 @@ func TestGenerate(t *testing.T) {
|
||||||
ReturnType: smartcontract.IntegerType,
|
ReturnType: smartcontract.IntegerType,
|
||||||
Safe: true,
|
Safe: true,
|
||||||
},
|
},
|
||||||
|
manifest.Method{
|
||||||
|
Name: "zum",
|
||||||
|
Parameters: []manifest.Parameter{
|
||||||
|
manifest.NewParameter("type", smartcontract.IntegerType),
|
||||||
|
manifest.NewParameter("typev", smartcontract.IntegerType),
|
||||||
|
manifest.NewParameter("func", smartcontract.IntegerType),
|
||||||
|
},
|
||||||
|
ReturnType: smartcontract.IntegerType,
|
||||||
|
},
|
||||||
manifest.Method{
|
manifest.Method{
|
||||||
Name: "justExecute",
|
Name: "justExecute",
|
||||||
Parameters: []manifest.Parameter{
|
Parameters: []manifest.Parameter{
|
||||||
|
@ -172,6 +181,11 @@ func Sum3() int {
|
||||||
return neogointernal.CallWithToken(Hash, "sum3", int(contract.ReadOnly)).(int)
|
return neogointernal.CallWithToken(Hash, "sum3", int(contract.ReadOnly)).(int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Zum invokes ` + "`zum`" + ` method of contract.
|
||||||
|
func Zum(typev int, typev_ int, funcv int) int {
|
||||||
|
return neogointernal.CallWithToken(Hash, "zum", int(contract.All), typev, typev_, funcv).(int)
|
||||||
|
}
|
||||||
|
|
||||||
// JustExecute invokes ` + "`justExecute`" + ` method of contract.
|
// JustExecute invokes ` + "`justExecute`" + ` method of contract.
|
||||||
func JustExecute(arr []interface{}) {
|
func JustExecute(arr []interface{}) {
|
||||||
neogointernal.CallWithTokenNoRet(Hash, "justExecute", int(contract.All), arr)
|
neogointernal.CallWithTokenNoRet(Hash, "justExecute", int(contract.All), arr)
|
||||||
|
|
|
@ -47,8 +47,8 @@ func (c *ContractReader) IsAvailable(name string) (bool, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRecord invokes `getRecord` method of contract.
|
// GetRecord invokes `getRecord` method of contract.
|
||||||
func (c *ContractReader) GetRecord(name string, type *big.Int) (string, error) {
|
func (c *ContractReader) GetRecord(name string, typev *big.Int) (string, error) {
|
||||||
return unwrap.UTF8String(c.invoker.Call(Hash, "getRecord", name, type))
|
return unwrap.UTF8String(c.invoker.Call(Hash, "getRecord", name, typev))
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetAllRecords invokes `getAllRecords` method of contract.
|
// GetAllRecords invokes `getAllRecords` method of contract.
|
||||||
|
@ -57,6 +57,6 @@ func (c *ContractReader) GetAllRecords(name string) (stackitem.Item, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve invokes `resolve` method of contract.
|
// Resolve invokes `resolve` method of contract.
|
||||||
func (c *ContractReader) Resolve(name string, type *big.Int) (string, error) {
|
func (c *ContractReader) Resolve(name string, typev *big.Int) (string, error) {
|
||||||
return unwrap.UTF8String(c.invoker.Call(Hash, "resolve", name, type))
|
return unwrap.UTF8String(c.invoker.Call(Hash, "resolve", name, typev))
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package binding
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"go/token"
|
||||||
"io"
|
"io"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -201,6 +202,8 @@ func TemplateFromManifest(cfg Config, scTypeConverter func(string, smartcontract
|
||||||
} else if m.Safe {
|
} else if m.Safe {
|
||||||
mtd.CallFlag = callflag.ReadOnly.String()
|
mtd.CallFlag = callflag.ReadOnly.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var varnames = make(map[string]bool)
|
||||||
for i := range m.Parameters {
|
for i := range m.Parameters {
|
||||||
name := m.Parameters[i].Name
|
name := m.Parameters[i].Name
|
||||||
if name == "" {
|
if name == "" {
|
||||||
|
@ -211,7 +214,13 @@ func TemplateFromManifest(cfg Config, scTypeConverter func(string, smartcontract
|
||||||
if pkg != "" {
|
if pkg != "" {
|
||||||
imports[pkg] = struct{}{}
|
imports[pkg] = struct{}{}
|
||||||
}
|
}
|
||||||
|
if token.IsKeyword(name) {
|
||||||
|
name = name + "v"
|
||||||
|
}
|
||||||
|
for varnames[name] {
|
||||||
|
name = name + "_"
|
||||||
|
}
|
||||||
|
varnames[name] = true
|
||||||
mtd.Arguments = append(mtd.Arguments, ParamTmpl{
|
mtd.Arguments = append(mtd.Arguments, ParamTmpl{
|
||||||
Name: name,
|
Name: name,
|
||||||
Type: typeStr,
|
Type: typeStr,
|
||||||
|
|
Loading…
Reference in a new issue