From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id E0C1544643E for ; Tue, 29 Sep 2020 01:21:26 +0300 (MSK) References: <7eaf13e0ac86f3c9afe521d82d2dc907479b3ffe.1600955781.git.tsafin@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Tue, 29 Sep 2020 00:21:25 +0200 MIME-Version: 1.0 In-Reply-To: <7eaf13e0ac86f3c9afe521d82d2dc907479b3ffe.1600955781.git.tsafin@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 2.X 7/7] module api: luaL_cdata_iscallable List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Timur Safin , alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org 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);