-
Notifications
You must be signed in to change notification settings - Fork 63
Open
Description
gopher-luar is able to automatically convert lua-types into go - an example for that is given in the documentation.
However, this mechanism is not exposed in the API. While there is a luar.New(), the counterpart is missing.
This becomes necessary when calling lua-functions from go, and trying to get the function's return value:
// Convert from go-to-LUA
var args []interface{} = ...
lArgs := make([]lua.LValue, len(args))
for i, a := range args {
lArgs[i] = luar.New(L, a)
}
var numberOfReturnArgs = 4
vm.state.CallByParam(lua.P{
Fn: L.GetGlobal("functionName"),
NRet: numberOfReturnArgs,
}, lArgs...)
// Collect return values:
retValues := make([]interface{}, returnArgs)
for i := returnArgs; i > 0; i-- {
ret := vm.state.Get(-1)
vm.state.Pop(1)
retValues[i-1] = ret // <--- how to convert to go-type?
}
How can I convert these return-values to go-types?
Metadata
Metadata
Assignees
Labels
No labels