Commits

Harald Klimach committed 02b767a

Added a wrapper for lua_settable to LuaFortran

  • Participants
  • Parent commits 5acaf00

Comments (0)

Files changed (3)

File LuaFortran/flu_binding.f90

+!> This module provides the Fortran Lua interface.
+!!
+!! It defines a flu_state which encapsulates the
+!! Lua state and is used to reference a Lua script.
+!! The main content are then the wrapper implementations
+!! which ease the usage of the Lua functions declared
+!! in the lua_fif module.
 module flu_binding
   use, intrinsic :: iso_c_binding
   use lua_fif
   public :: flu_State
 
   public :: flu_close, flu_isopen
+  public :: flu_createTable
   public :: flu_getField, flu_getGlobal, flu_getTable, flu_getTop
   public :: flu_setGlobal
   public :: flu_isFunction, flu_isNumber, flu_isTable
   public :: flu_pcall
   public :: flu_next
   public :: flu_setTop
+  public :: flu_setTable
   public :: flu_todouble
   public :: flu_tolstring, flu_tonumber, flu_toboolean
   public :: flu_pop
   end subroutine flu_pushvalue
 
 
+  subroutine flu_settable(L, n)
+    type(flu_State) :: L
+    integer, intent(in) :: n
+
+    integer(kind=c_int) :: n_c
+
+    n_c = n
+    call lua_settable(L%state, n_c)
+  end subroutine flu_settable
+
+
   subroutine flu_settop(L, n)
     type(flu_State) :: L
     integer, intent(in) :: n

File LuaFortran/lua_fif.f90

+!> This module provides a direct translation of some
+!! Lua 5.2.1
+!! C-Interfaces to Fortran 2003 interfaces using the
+!! ISO_C_BINDING facilities.
 module lua_fif
   use, intrinsic :: iso_c_binding
   use lua_parameters
-  ! This module provides a direct translation of the
-  ! lua 5.1.4
-  ! C-Interfaces to Fortran 2003 interfaces using the
-  ! ISO_C_BINDING facilities.
 
   implicit none
 
       integer(kind=c_int), value :: index
     end subroutine lua_pushvalue
 
+    subroutine lua_setglobal(L, k) bind(c, name="lua_setglobal")
+      use, intrinsic :: iso_c_binding
+      type(c_ptr), value :: L
+      character(kind=c_char), dimension(*) :: k
+    end subroutine lua_setglobal
+
+    subroutine lua_settable(L, index) bind(c, name="lua_settable")
+      use, intrinsic :: iso_c_binding
+      type(c_ptr), value :: L
+      integer(kind=c_int), value :: index
+    end subroutine lua_settable
+
     subroutine lua_settop(L, index) bind(c, name="lua_settop")
       use, intrinsic :: iso_c_binding
       type(c_ptr), value :: L
       integer(kind=c_int), value :: index
     end subroutine lua_settop
 
-    subroutine lua_setglobal(L, k) bind(c, name="lua_setglobal")
-      use, intrinsic :: iso_c_binding
-      type(c_ptr), value :: L
-      character(kind=c_char), dimension(*) :: k
-    end subroutine lua_setglobal
-
     function lua_tolstring(L, index, len) bind(c, name="lua_tolstring")
       use, intrinsic :: iso_c_binding
       type(c_ptr), value :: L

File LuaFortran/lua_parameters.f90

+!> This module provides some parameters defined in the
+!! Lua header file that are needed in the wrapper
+!! functions for the Fortran interface.
+!!
+!! Lua_int and Lua_num are system dependent, and you
+!! might need to adapt them on your system.
+!! The type constants have to be consistent with the
+!! Lua header definition, and thus should be checked
+!! after version upgrades of the Lua library.
 module lua_parameters
   use, intrinsic :: iso_c_binding
 
   integer, parameter :: lua_int = c_long
   integer, parameter :: lua_num = c_double
 
-  ! lua constants
+  ! Lua constants
   integer(kind=c_int), parameter :: LUA_TNONE = -1
   integer(kind=c_int), parameter :: LUA_TNIL = 0
   integer(kind=c_int), parameter :: LUA_TBOOLEAN = 1