open_config_buffer Subroutine

public subroutine open_config_buffer(L, buffer, bufName, ErrCode, ErrString)

Subroutine to load and execute a script given in a buffer (bytecode).

Arguments

Type IntentOptional Attributes Name
type(flu_State) :: L

Handle to the Lua script

character(len=1), intent(in) :: buffer(:)

String with Lua code to load.

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

Name for the buffer to use in debug messages.

integer, intent(out), optional :: ErrCode

Error code returned by Lua during loading or executing the file.

This optional parameter might be used to react on errors in the calling side. If neither ErrCode nor ErrString are given, this subroutine will stop the program execution and print the error message from Lua to the stdout.

character(len=*), intent(out), optional :: ErrString

Obtained error description from the Lua stack.

This optional argument holds the Lua error message in case somehting went wrong. It can be used to provide some feedback to the user in the calling routine. If neither ErrCode nor ErrString are provided, open_config() will print the error message and stop program execution.


Calls

proc~~open_config_buffer~~CallsGraph proc~open_config_buffer open_config_buffer proc~aot_err_handler aot_err_handler proc~open_config_buffer->proc~aot_err_handler proc~flu_isopen flu_isopen proc~open_config_buffer->proc~flu_isopen proc~flu_pcall flu_pcall proc~open_config_buffer->proc~flu_pcall proc~flul_loadbuffer fluL_loadbuffer proc~open_config_buffer->proc~flul_loadbuffer proc~flul_newstate fluL_newstate proc~open_config_buffer->proc~flul_newstate proc~flul_openlibs fluL_openlibs proc~open_config_buffer->proc~flul_openlibs proc~flu_tolstring flu_tolstring proc~aot_err_handler->proc~flu_tolstring interface~lua_pcallk lua_pcallk proc~flu_pcall->interface~lua_pcallk interface~lual_loadbufferx luaL_loadbufferx proc~flul_loadbuffer->interface~lual_loadbufferx interface~lual_newstate luaL_newstate proc~flul_newstate->interface~lual_newstate interface~lual_openlibs luaL_openlibs proc~flul_openlibs->interface~lual_openlibs interface~lua_tolstring lua_tolstring proc~flu_tolstring->interface~lua_tolstring

Called by

proc~~open_config_buffer~~CalledByGraph proc~open_config_buffer open_config_buffer proc~aot_require_buffer aot_require_buffer proc~aot_require_buffer->proc~open_config_buffer

Source Code

  subroutine open_config_buffer(L, buffer, bufName, ErrCode, ErrString)
    type(flu_State) :: L !! Handle to the Lua script

    !> String with Lua code to load.
    character, intent(in) :: buffer(:)

    !> Name for the buffer to use in debug messages.
    character(len=*), intent(in), optional :: bufName

    !> Error code returned by Lua during loading or executing the file.
    !!
    !! This optional parameter might be used to react on errors in the calling
    !! side. If neither ErrCode nor ErrString are given, this subroutine will
    !! stop the program execution and print the error message from Lua to the
    !! stdout.
    integer, intent(out), optional :: ErrCode

    !> Obtained error description from the Lua stack.
    !!
    !! This optional argument holds the Lua error message in case somehting
    !! went wrong. It can be used to provide some feedback to the user in the
    !! calling routine. If neither ErrCode nor ErrString are provided,
    !! open_config() will print the error message and stop program execution.
    character(len=*), intent(out), optional :: ErrString

    integer :: err

    if (.not.flu_isopen(L)) L = fluL_newstate()

    err = fluL_loadbuffer(L, buffer, bufName)

    call aot_err_handler(L, err, 'Cannot load buffer:', ErrString, ErrCode)

    if (err == 0) then
      call fluL_openlibs(L)

      err = flu_pcall(L, 0, 0, 0)

      call aot_err_handler(L, err, 'Cannot run buffer:', ErrString, ErrCode)
    end if

  end subroutine open_config_buffer