Execute a given function and put its results on the stack, where it is retrievable with aot_top_get_val.
The optional arguments ErrCode and ErrString provide some feedback on the success of the function execution. If none of them are in the argument list, the execution of the application will be stopped, and the error will be printed to the standard output. You have to provide the number of results to obtain in nresults. Keep in mind, that multiple results have to obtained in reverse order from the stack.
Note
You might want to return multiple values as a single argument in a table instead of several single values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(flu_State) | :: | L |
Handle for the Lua script. |
|||
type(aot_fun_type) | :: | fun |
Handle to the function to execute. |
|||
integer, | intent(in) | :: | nresults |
Number of resulting values the caller wants to obtain from the Lua function. |
||
integer, | intent(out), | optional | :: | ErrCode |
Error code returned by Lua during execution of the function. |
|
character(len=*), | intent(out), | optional | :: | ErrString |
Obtained error string from the Lua stack if an error occured. |
subroutine aot_fun_do(L, fun, nresults, ErrCode, ErrString) type(flu_state) :: L !! Handle for the Lua script. !> Handle to the function to execute. type(aot_fun_type) :: fun !> Number of resulting values the caller wants to obtain from the Lua !! function. integer, intent(in) :: nresults !> Error code returned by Lua during execution of the function. integer, intent(out), optional :: ErrCode !> Obtained error string from the Lua stack if an error occured. character(len=*), intent(out), optional :: ErrString integer :: err if (fun%handle /= 0) then err = flu_pcall(L, fun%arg_count, nresults, 0) call aot_err_handler(L=L, err=err, msg="Failed aot_fun_do! ", & & ErrCode = ErrCode, ErrString = ErrString) fun%arg_count = -1 end if end subroutine aot_fun_do