[Tarantool-patches] [PATCH 2.X 7/7] module api: luaL_cdata_iscallable

Timur Safin tsafin at tarantool.org
Thu Sep 24 20:00:20 MSK 2020


In addition to `luaL_iscallable` we need `luaL_cdata_iscallable`
because code which was calling it directly had to be copied to
merger side

Part of #5273
---
 src/exports.h   | 1 +
 src/lua/utils.c | 2 +-
 src/lua/utils.h | 6 ++++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/exports.h b/src/exports.h
index 08c7ac53f..943ad69fa 100644
--- a/src/exports.h
+++ b/src/exports.h
@@ -345,6 +345,7 @@ EXPORT(luaL_addvalue)
 EXPORT(luaL_argerror)
 EXPORT(luaL_buffinit)
 EXPORT(luaL_callmeta)
+EXPORT(luaL_cdata_iscallable)
 EXPORT(luaL_cdef)
 EXPORT(luaL_checkany)
 EXPORT(luaL_checkcdata)
diff --git a/src/lua/utils.c b/src/lua/utils.c
index 40078b5df..bf9f46cb7 100644
--- a/src/lua/utils.c
+++ b/src/lua/utils.c
@@ -1063,7 +1063,7 @@ luaT_tolstring(lua_State *L, int idx, size_t *len)
 }
 
 /* Based on ffi_meta___call() from luajit/src/lib_ffi.c. */
-static int
+int
 luaL_cdata_iscallable(lua_State *L, int idx)
 {
 	/* Calculate absolute value in the stack. */
diff --git a/src/lua/utils.h b/src/lua/utils.h
index 6b10d2755..69ff4de86 100644
--- a/src/lua/utils.h
+++ b/src/lua/utils.h
@@ -541,6 +541,12 @@ luaT_tolstring(lua_State *L, int idx, size_t *ssize);
 LUA_API int
 luaL_iscallable(lua_State *L, int idx);
 
+/**
+ * Check whether a Lua object is a cdata metatype with a __call field.
+ *
+ */
+LUA_API int
+luaL_cdata_iscallable(lua_State *L, int idx);
 
 /**
  * @brief Creates a new Lua coroutine in a protected frame. If
-- 
2.20.1



More information about the Tarantool-patches mailing list