Commits

Harald Klimach committed 6c1fa11

Added the wrapper for lua_setfield to LuaFortran

  • Participants
  • Parent commits d81f2ac

Comments (0)

Files changed (2)

File LuaFortran/flu_binding.f90

   public :: flu_pcall
   public :: flu_next
   public :: flu_setTop
-  public :: flu_setTable
+  public :: flu_setTable, flu_setField
   public :: flu_todouble
   public :: flu_tolstring, flu_tonumber, flu_toboolean
   public :: flu_pop
   end subroutine flu_settop
 
 
+  subroutine flu_setfield(L, index, k)
+    type(flu_State)  :: L
+    integer          :: index
+    character(len=*) :: k
+
+    integer(kind=c_int) :: c_index
+    character(len=len_trim(k)+1) :: c_k
+
+    c_k = trim(k) // c_null_char
+    c_index = index
+    call lua_setfield(L%state, c_index, c_k)
+  end subroutine flu_setfield
+
+
   subroutine flu_setglobal(L, k)
       type(flu_State) :: L
       character(len=*), intent(in) :: k

File LuaFortran/lua_fif.f90

       integer(kind=c_int), value :: index
     end subroutine lua_pushvalue
 
+    subroutine lua_setfield(L, index, k) bind(c, name="lua_setfield")
+      use, intrinsic :: iso_c_binding
+      type(c_ptr), value :: L
+      integer(kind=c_int), value :: index
+      character(kind=c_char), dimension(*) :: k
+    end subroutine lua_setfield
+
     subroutine lua_setglobal(L, k) bind(c, name="lua_setglobal")
       use, intrinsic :: iso_c_binding
       type(c_ptr), value :: L