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

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Sep 29 01:21:25 MSK 2020


Thanks for the patch!

See 4 comments below.

On 24.09.2020 19:00, Timur Safin wrote:
> In addition to `luaL_iscallable` we need `luaL_cdata_iscallable`
> because code which was calling it directly had to be copied to
> merger side

1. Please, put '.' in the end of sentences. Here and in other
commits.

2. luaL_iscallable() already checks luaL_cdata_iscallable(). Why
do you need it separated from luaL_iscallable()?

> 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/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.

3. The function will crash in debug build, if it is not cdata. And will
do UB in release build. This is because it is not supposed to be called
out of luaL_iscallable(). And I don't see why would you need it.

> + *

4. Extra empty line.

> + */
> +LUA_API int
> +luaL_cdata_iscallable(lua_State *L, int idx);


More information about the Tarantool-patches mailing list