[Tarantool-patches] [PATCH 2.X 7/7] module api: luaL_cdata_iscallable
Timur Safin
tsafin at tarantool.org
Fri Oct 2 19:14:01 MSK 2020
: From: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
: Subject: Re: [Tarantool-patches] [PATCH 2.X 7/7] module api:
: luaL_cdata_iscallable
:
: 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()?
Good question - indeed. I needed luaL_cdata_iscallable only while
luaL_iscallable was part of compat layer inside of merger module. Now
having luaL_iscallable as part of module api both in 1.10 and 2.*
the luaL_cdata_iscallable could be local, as it used to be before.
Let me check whether I miss some details I needed in both versions we
attack?
:
: > 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.
I hear, hear. Don't need to repeat it twice. Don't need to repeat it twice.
:
: > + *
:
: 4. Extra empty line.
:
: > + */
: > +LUA_API int
: > +luaL_cdata_iscallable(lua_State *L, int idx);
Regards,
Timur
More information about the Tarantool-patches
mailing list