Interpret topmost entry on Lua stack as a default integer.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer(kind=int_k), | intent(out) | :: | val | Value of the Variable in the script |
||
integer, | intent(out) | :: | ErrCode | Error code to indicate what kind of problem might have occured. |
||
type(flu_State) | :: | L | Handle to the Lua script |
|||
integer(kind=int_k), | intent(in), | optional | :: | default | Some default value, that should be used, if the variable is not set in the Lua script. |
subroutine aot_top_get_integer(val, ErrCode, L, default)
type(flu_State) :: L !! Handle to the Lua script
!> Value of the Variable in the script
integer(kind=int_k), intent(out) :: val
!> Error code to indicate what kind of problem might have occured.
integer, intent(out) :: ErrCode
!> Some default value, that should be used, if the variable is not set in
!! the Lua script.
integer(kind=int_k), optional, intent(in) :: default
logical :: not_retrievable
ErrCode = 0
not_retrievable = .false.
if (flu_isNoneOrNil(L, -1)) then
ErrCode = ibSet(ErrCode, aoterr_NonExistent)
not_retrievable = .true.
else
if (flu_isNumber(L, -1)) then
val = int(flu_toDouble(L, -1))
else
ErrCode = ibSet(ErrCode, aoterr_WrongType)
ErrCode = ibSet(ErrCode, aoterr_Fatal)
not_retrievable = .true.
end if
end if
if (not_retrievable) then
if (present(default)) then
val = default
else
ErrCode = ibSet(ErrCode, aoterr_Fatal)
end if
end if
call flu_pop(L)
end subroutine aot_top_get_integer