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 E310944643C for ; Fri, 25 Sep 2020 01:32:04 +0300 (MSK) References: <98551e8b90ebd2839dee57fee13f446aee515e42.1600817803.git.alexander.turenko@tarantool.org> From: Vladislav Shpilevoy Message-ID: <53bcd1f3-7a8d-dc4e-93de-11445a64e815@tarantool.org> Date: Fri, 25 Sep 2020 00:32:03 +0200 MIME-Version: 1.0 In-Reply-To: <98551e8b90ebd2839dee57fee13f446aee515e42.1600817803.git.alexander.turenko@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Tarantool-patches] [PATCH 03/14] WIP: module api/lua: add luaL_iscdata() function List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Alexander Turenko Cc: tarantool-patches@dev.tarantool.org Thanks for the patch! See 2 comments below. > diff --git a/src/exports.h b/src/exports.h > index 7861bb529..08ca03507 100644 > --- a/src/exports.h > +++ b/src/exports.h > @@ -355,6 +355,7 @@ EXPORT(luaL_fileresult) > EXPORT(luaL_findtable) > EXPORT(luaL_getmetafield) > EXPORT(luaL_gsub) > +EXPORT(luaL_iscdata) > EXPORT(luaL_iscallable) 1. 'd' > 'a', so luaL_isc*d*ata should come after luaL_isc*a*llable. > EXPORT(luaL_loadbuffer) > EXPORT(luaL_loadbufferx) > diff --git a/src/lua/utils.h b/src/lua/utils.h > index 7e02a05f2..e9dd27d08 100644 > --- a/src/lua/utils.h > +++ b/src/lua/utils.h > @@ -78,6 +78,26 @@ luaL_pushuuid(struct lua_State *L); > > /** \cond public */ > > +/** > + * @brief Checks whether a value on the Lua stack is a cdata. > + * > + * Unlike () this function does not raise an > + * error. It is useful to raise a domain specific error. > + * > + * Lua API and module API don't expose LUA_TCDATA constant. > + * We have no guarantee that this constant will remain the same in > + * future LuaJIT versions. So this function should be used in > + * modules instead of `lua_type(L, idx) == LUA_TCDATA`. > + * > + * @param L Lua State > + * @param idx stack index 2. I am going to go OCD here, but lets start sentences from a capital letter and end with a dot. Here and in all the other commits in their places. > + * > + * @return 1 if the value at the given acceptable index is a cdata > + * and 0 otherwise. > + */ > +LUA_API int > +luaL_iscdata(struct lua_State *L, int idx); > + > /** > * @brief Push cdata of given \a ctypeid onto the stack. > * CTypeID must be used from FFI at least once. Allocated memory returned >