lang: funcs: funcgen: Refactor slightly for list input

This code had some design issues. We'll rewrite this eventually, but for
now, let's allow list inputs. Refactor this to make it possible.
This commit is contained in:
James Shubin
2023-11-25 20:54:10 -05:00
parent 0e2c73a36d
commit 4650ed01eb
2 changed files with 6 additions and 3 deletions

View File

@@ -68,8 +68,9 @@ func (obj *arg) ToMcl() (string, error) {
}
}
// ToGo prints the arg signature as expected by golang.
func (obj *arg) ToGolang() (string, error) {
// OldToGolang prints the arg signature as expected by golang. This is only used
// for returns.
func (obj *arg) OldToGolang() (string, error) {
switch obj.Type {
case "bool":
return "Bool", nil
@@ -79,6 +80,8 @@ func (obj *arg) ToGolang() (string, error) {
return "Int", nil
case "float64":
return "Float", nil
//case "[]string":
// XXX: Lists don't fit well with this code design. Refactor!
default:
return "", fmt.Errorf("cannot convert %v to golang", obj)
}

View File

@@ -143,7 +143,7 @@ func (obj *function) Signature() (string, error) {
// MakeGoReturn returns the golang signature of the return.
func (obj *function) MakeGoReturn() (string, error) {
return obj.Return[0].ToGolang()
return obj.Return[0].OldToGolang()
}
// ConvertStart returns the start of a casting function required to convert from