aot_top_get_userdata Subroutine

private subroutine aot_top_get_userdata(val, ErrCode, L, default)

Uses

  • proc~~aot_top_get_userdata~~UsesGraph proc~aot_top_get_userdata aot_top_get_userdata iso_c_binding iso_c_binding proc~aot_top_get_userdata->iso_c_binding

Interpret topmost entry on Lua stack as userdata.

Arguments

Type IntentOptional Attributes Name
type(c_ptr), 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

type(c_ptr), intent(in), optional :: default

Some default value, that should be used, if the variable is not set in the Lua script.


Calls

proc~~aot_top_get_userdata~~CallsGraph proc~aot_top_get_userdata aot_top_get_userdata proc~flu_islightuserdata flu_islightuserdata proc~aot_top_get_userdata->proc~flu_islightuserdata proc~flu_isnoneornil flu_isNoneOrNil proc~aot_top_get_userdata->proc~flu_isnoneornil proc~flu_pop flu_pop proc~aot_top_get_userdata->proc~flu_pop proc~flu_touserdata flu_touserdata proc~aot_top_get_userdata->proc~flu_touserdata interface~lua_type lua_type proc~flu_islightuserdata->interface~lua_type proc~flu_isnoneornil->interface~lua_type interface~lua_settop lua_settop proc~flu_pop->interface~lua_settop interface~lua_touserdata lua_touserdata proc~flu_touserdata->interface~lua_touserdata

Called by

proc~~aot_top_get_userdata~~CalledByGraph proc~aot_top_get_userdata aot_top_get_userdata interface~aot_top_get_val aot_top_get_val interface~aot_top_get_val->proc~aot_top_get_userdata

Source Code

  subroutine aot_top_get_userdata(val, ErrCode, L, default)
    use, intrinsic :: iso_c_binding
    type(flu_State) :: L !! Handle to the Lua script

    !> Value of the Variable in the script
    type(c_ptr), 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.
    type(c_ptr), 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_islightuserdata(L, -1)) then
        val = flu_touserdata(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_userdata