Permalink
Browse files

isnil is needed to check if a symbol queried via getglobal was found.

  • Loading branch information...
1 parent 748c0ef commit 66a37bd61c4770cd7463aca6a36d4ea97f61a7ce @MaikBeckmann committed May 3, 2011
Showing with 29 additions and 5 deletions.
  1. +6 −0 src/clua.c
  2. +11 −1 src/flua.f90
  3. +12 −4 src/lua_c_interfaces.f90
View
@@ -82,6 +82,12 @@ int f2k3lua_lua_istable(lua_State *L, int n)
return lua_istable(L, n);
}
+int f2k3lua_lua_isnil(lua_State *L, int n)
+{
+ return lua_isnil(L, n);
+}
+
+
void f2k3lua_lua_pop(lua_State *L, int n)
{
View
@@ -130,10 +130,20 @@ FUNCTION lua_istable(L, n)
TYPE(C_PTR), INTENT(IN) :: L
INTEGER, INTENT(IN) :: n
LOGICAL :: lua_istable
- !
+
lua_istable = lua_istable_c(L, n) /= 0
END FUNCTION lua_istable
+FUNCTION lua_isnil(L, n)
+ USE ISO_C_BINDING, ONLY: C_PTR
+ USE lua_c_interfaces_simple, ONLY: lua_isnil_c
+ IMPLICIT NONE
+ TYPE(C_PTR), INTENT(IN) :: L
+ INTEGER, INTENT(IN) :: n
+ LOGICAL :: lua_isnil
+
+ lua_isnil = lua_isnil_c(L, n) /= 0
+END FUNCTION lua_isnil
FUNCTION lua_isstring(L, n)
USE ISO_C_BINDING, ONLY: C_PTR
View
@@ -44,8 +44,8 @@ SUBROUTINE lua_setglobal_c(L, k) BIND(C, name="f2k3lua_lua_setglobal")
TYPE(C_PTR), VALUE :: L
CHARACTER(KIND=C_CHAR, LEN=1), DIMENSION(*) :: k
END SUBROUTINE lua_setglobal_c
- !
- !
+
+
!> int f2k3lua_lua_istable(lua_State *L, int n);
FUNCTION lua_istable_c(L, n) BIND(C, name="f2k3lua_lua_istable")
USE ISO_C_BINDING
@@ -54,8 +54,16 @@ FUNCTION lua_istable_c(L, n) BIND(C, name="f2k3lua_lua_istable")
INTEGER(KIND=C_INT), VALUE :: n
INTEGER(KIND=C_INT) :: lua_istable_c
END FUNCTION lua_istable_c
- !
- !
+
+ !> int f2k3lua_lua_isnil(lua_State *L, int n);
+ FUNCTION lua_isnil_c(L, n) BIND(C, name="f2k3lua_lua_isnil")
+ USE ISO_C_BINDING
+ IMPLICIT NONE
+ TYPE(C_PTR), VALUE :: L
+ INTEGER(KIND=C_INT), VALUE :: n
+ INTEGER(KIND=C_INT) :: lua_isnil_c
+ END FUNCTION lua_isnil_c
+
! LUA_API int (lua_isstring) (lua_State *L, int idx);
FUNCTION lua_isstring_c(L, n) BIND(C, name="lua_isstring")
USE ISO_C_BINDING

0 comments on commit 66a37bd

Please sign in to comment.