aot_table_set_top Subroutine

public subroutine aot_table_set_top(L, thandle, key, pos)

Put the top of the stack into a table.

Arguments

Type IntentOptional Attributes Name
type(flu_State) :: L

Handle to the Lua script.

integer, intent(in) :: thandle

Handle to the table to look the value up in.

character(len=*), intent(in), optional :: key

Name of the entry to look for.

Key and pos are both optional, however at least one of them has to be supplied. The key takes precedence over the pos if both are given.

integer, intent(in), optional :: pos

Position of the entry to look for in the table.

It allows the access to unnamed arrays in the Lua tables.


Calls

proc~~aot_table_set_top~~CallsGraph proc~aot_table_set_top aot_table_set_top interface~flu_pushinteger flu_pushinteger proc~aot_table_set_top->interface~flu_pushinteger proc~flu_gettop flu_gettop proc~aot_table_set_top->proc~flu_gettop proc~flu_insert flu_insert proc~aot_table_set_top->proc~flu_insert proc~flu_setfield flu_setfield proc~aot_table_set_top->proc~flu_setfield proc~flu_settable flu_settable proc~aot_table_set_top->proc~flu_settable proc~flu_pushint flu_pushint interface~flu_pushinteger->proc~flu_pushint proc~flu_pushlong flu_pushlong interface~flu_pushinteger->proc~flu_pushlong interface~lua_gettop lua_gettop proc~flu_gettop->interface~lua_gettop interface~lua_rotate lua_rotate proc~flu_insert->interface~lua_rotate interface~lua_setfield lua_setfield proc~flu_setfield->interface~lua_setfield interface~lua_settable lua_settable proc~flu_settable->interface~lua_settable interface~lua_pushinteger lua_pushinteger proc~flu_pushint->interface~lua_pushinteger proc~flu_pushlong->interface~lua_pushinteger

Source Code

  subroutine aot_table_set_top(L, thandle, key, pos)
    type(flu_State) :: L !! Handle to the Lua script.

    !> Handle to the table to look the value up in.
    integer, intent(in) :: thandle

    !> Name of the entry to look for.
    !!
    !! Key and pos are both optional, however at least one of them has to be
    !! supplied.
    !! The key takes precedence over the pos if both are given.
    character(len=*), intent(in), optional :: key

    !> Position of the entry to look for in the table.
    !!
    !! It allows the access to unnamed arrays in the Lua tables.
    integer, intent(in), optional :: pos

    integer :: indpos

    ! First store the current top of the stack for later reference, to
    ! move the desired position infront of it.
    indpos = flu_gettop(L)

    ! Only put the top into the given table, if it is a valid reference,
    ! and the top is not the table itself.
    if ( (thandle > 0) .and. (thandle < indpos) ) then

      if (present(key)) then
        ! There is a key, given, use it to put the value into the table.
        call flu_setField(L, thandle, trim(key))
      else
        ! No key given, try to put the value by position
        if (present(pos)) then
          ! First put the index, where to write the value into the table, on the
          ! stack.
          call flu_pushInteger(L, pos)
          ! Now move this position infront of the actual argument, which was
          ! at the top previously.
          call flu_insert(L, indpos)
          ! Use the two entries from the stack to put the value at the given
          ! position into the table.
          call flu_setTable(L, thandle)
        end if
      end if

    end if

  end subroutine aot_table_set_top