Commits

Kannan Masilamani committed 3a33565

added isNone and isNil function in flu_binding

  • Participants
  • Parent commits 067beb5

Comments (0)

Files changed (2)

File LuaFortran/flu_binding.f90

 
   public :: flu_close
   public :: flu_getField, flu_getGlobal, flu_getTable, flu_getTop
-  public :: flu_isFunction, flu_isNumber, flu_isNoneOrNil, flu_isTable
+  public :: flu_isFunction, flu_isNumber, flu_isTable
+  public :: flu_isNone, flu_isNoneOrNil, flu_isNil
   public :: flu_isBoolean
   public :: flu_pcall
   public :: flu_next
   end function flu_isNoneOrNil
 
 
+  function flu_isNil(L, index) result(is_Nil)
+    type(flu_State) :: L
+    integer         :: index
+    logical         :: is_Nil
+
+    integer(kind=c_int) :: c_index
+
+    c_index = int(index, kind = c_int)
+    !! Only defined as a Macro, using lua_type:
+    is_Nil = (lua_Type(L%state, c_index) .eq. LUA_TNIL)
+  end function flu_isNil
+
+
+  function flu_isNone(L, index) result(is_None)
+    type(flu_State) :: L
+    integer         :: index
+    logical         :: is_None
+
+    integer(kind=c_int) :: c_index
+
+    c_index = int(index, kind = c_int)
+    !! Only defined as a Macro, using lua_type:
+    is_None = (lua_Type(L%state, c_index) .eq. LUA_TNONE)
+  end function flu_isNone
+
+
   function flu_next(L, index) result(exists)
     type(flu_State) :: L
     integer, intent(in) :: index

File LuaFortran/lua_parameters.f90

   integer, parameter :: lua_num = c_double
 
   ! 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
   integer(kind=c_int), parameter :: LUA_TTABLE = 5
   integer(kind=c_int), parameter :: LUA_TFUNCTION = 6