aot_reference_for Function

public function aot_reference_for(L, thandle, key, pos) result(ref)

Get a reference for the entry defined by thandle, key and pos, or the current top entry in the stack.

The reference can be used to refer to a given object in the Lua table by storing a reference to it in the LUA_REGISTRYINDEX table.

The object can then be put onto the stack again by using this reference.

Arguments

Type IntentOptional Attributes Name
type(flu_State) :: L

Handle to the Lua script

integer, intent(in), optional :: thandle

Handle to the table containing the object to get a reference for.

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

Name of the object to look up, if thandle is not present, this is a global definition.

If neither thandle nor key is provided, a reference to the top of the stack is returned.

integer, intent(in), optional :: pos

Positional index of the object inside thandle to get the reference for. If thandle is not provided, this argument is ignored.

If a key is provided, that takes precedent over pos.

Return Value integer


Calls

proc~~aot_reference_for~~CallsGraph proc~aot_reference_for aot_reference_for proc~aot_table_push aot_table_push proc~aot_reference_for->proc~aot_table_push proc~flu_getglobal flu_getglobal proc~aot_reference_for->proc~flu_getglobal proc~flul_ref fluL_ref proc~aot_reference_for->proc~flul_ref proc~aot_table_push->proc~flu_getglobal interface~flu_pushinteger flu_pushinteger proc~aot_table_push->interface~flu_pushinteger proc~flu_getfield flu_getfield proc~aot_table_push->proc~flu_getfield proc~flu_gettable flu_gettable proc~aot_table_push->proc~flu_gettable proc~flu_pop flu_pop proc~aot_table_push->proc~flu_pop proc~flu_pushnil flu_pushnil proc~aot_table_push->proc~flu_pushnil proc~flu_type flu_type proc~aot_table_push->proc~flu_type interface~lua_getglobal lua_getglobal proc~flu_getglobal->interface~lua_getglobal interface~lual_ref luaL_ref proc~flul_ref->interface~lual_ref proc~flu_pushint flu_pushint interface~flu_pushinteger->proc~flu_pushint proc~flu_pushlong flu_pushlong interface~flu_pushinteger->proc~flu_pushlong interface~lua_getfield lua_getfield proc~flu_getfield->interface~lua_getfield interface~lua_gettable lua_gettable proc~flu_gettable->interface~lua_gettable interface~lua_settop lua_settop proc~flu_pop->interface~lua_settop interface~lua_pushnil lua_pushnil proc~flu_pushnil->interface~lua_pushnil interface~lua_type lua_type proc~flu_type->interface~lua_type interface~lua_pushinteger lua_pushinteger proc~flu_pushint->interface~lua_pushinteger proc~flu_pushlong->interface~lua_pushinteger

Source Code

  function aot_reference_for(L, thandle, key, pos) result(ref)
    type(flu_State) :: L !! Handle to the Lua script

    !> Handle to the table containing the object to get a reference for.
    integer, intent(in), optional :: thandle

    !> Name of the object to look up, if thandle is not present, this is
    !! a global definition.
    !!
    !! If neither thandle nor key is provided, a reference to the top of
    !! the stack is returned.
    character(len=*), intent(in), optional :: key

    !> Positional index of the object inside thandle to get the reference
    !! for. If thandle is not provided, this argument is ignored.
    !!
    !! If a key is provided, that takes precedent over pos.
    integer, intent(in), optional :: pos

    integer :: toptype
    integer :: ref

    if (present(thandle)) then
      call aot_table_push(L=L, thandle=thandle, &
        &                 key=key, pos=pos      )
    else if (present(key)) then
      toptype = flu_getglobal(L, key)
    end if

    ref = fluL_ref(L, LUA_REGISTRYINDEX)
  end function aot_reference_for