From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: Alexander Turenko <alexander.turenko@tarantool.org>
Cc: tarantool-patches@freelists.org
Subject: Re: [PATCH 1/3] Add luaT_iscallable with support of cdata metatype
Date: Wed, 26 Dec 2018 21:35:56 +0300 [thread overview]
Message-ID: <20181226183556.gilqpkhj4gmliby4@esperanza> (raw)
In-Reply-To: <b248c4b0921ba5bc653f7771fc7311047dfc73c8.1544989900.git.alexander.turenko@tarantool.org>
On Sun, Dec 16, 2018 at 11:17:24PM +0300, Alexander Turenko wrote:
> Needed for #3276.
> ---
> extra/exports | 1 +
> src/lua/utils.c | 43 ++++++++++++++++
> src/lua/utils.h | 10 ++++
> test/app-tap/module_api.c | 10 ++++
> test/app-tap/module_api.test.lua | 85 +++++++++++++++++++++++++++++++-
> 5 files changed, 147 insertions(+), 2 deletions(-)
>
> diff --git a/extra/exports b/extra/exports
> index 5f69e0730..52f0b2378 100644
> --- a/extra/exports
> +++ b/extra/exports
> @@ -134,6 +134,7 @@ luaT_call
> luaT_cpcall
> luaT_state
> luaT_tolstring
> +luaT_iscallable
Do we really need to export it?
> box_txn
> box_txn_begin
> box_txn_commit
> diff --git a/src/lua/utils.c b/src/lua/utils.c
> index 978fe61f1..7a6069fbb 100644
> --- a/src/lua/utils.c
> +++ b/src/lua/utils.c
> @@ -920,6 +920,49 @@ luaT_tolstring(lua_State *L, int idx, size_t *len)
> return lua_tolstring(L, -1, len);
> }
>
> +/* Based on ffi_meta___call() from luajit/src/lib_ffi.c. */
> +static int
> +luaT_cdata_iscallable(lua_State *L, int idx)
I think this function should have prefix luaL_ rather than luaT_.
Other than that, this particular patch looks OK to me.
> +{
> + /* Calculate absolute value in the stack. */
> + if (idx < 0)
> + idx = lua_gettop(L) + idx + 1;
> +
> + /* Get cdata from the stack. */
> + assert(lua_type(L, idx) == LUA_TCDATA);
> + GCcdata *cd = cdataV(L->base + idx - 1);
> +
> + CTState *cts = ctype_cts(L);
> + CTypeID id = cd->ctypeid;
> + CType *ct = ctype_raw(cts, id);
> + if (ctype_isptr(ct->info))
> + id = ctype_cid(ct->info);
> +
> + /* Get ctype metamethod. */
> + cTValue *tv = lj_ctype_meta(cts, id, MM_call);
> +
> + return tv != NULL;
> +}
next prev parent reply other threads:[~2018-12-26 18:35 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 20:17 [PATCH 0/3] Merger Alexander Turenko
2018-12-16 20:17 ` [PATCH 1/3] Add luaT_iscallable with support of cdata metatype Alexander Turenko
2018-12-26 18:35 ` Vladimir Davydov [this message]
2018-12-28 1:46 ` Alexander Turenko
2018-12-28 8:00 ` Vladimir Davydov
2018-12-16 20:17 ` [PATCH 2/3] Add module to ease using Lua iterators from C Alexander Turenko
2018-12-26 18:45 ` Vladimir Davydov
2018-12-31 6:43 ` Alexander Turenko
2018-12-16 20:17 ` [PATCH 3/3] Add merger for tuple streams Alexander Turenko
2018-12-26 20:11 ` Vladimir Davydov
2019-01-09 21:36 ` Alexander Turenko
2018-12-18 12:16 ` [PATCH 0/3] Merger Alexander Turenko
2019-03-22 14:24 ` [tarantool-patches] [PATCH 0/3] lua: add key_def lua module Kirill Shcherbatov
2019-03-22 16:20 ` Alexander Turenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181226183556.gilqpkhj4gmliby4@esperanza \
--to=vdavydov.dev@gmail.com \
--cc=alexander.turenko@tarantool.org \
--cc=tarantool-patches@freelists.org \
--subject='Re: [PATCH 1/3] Add luaT_iscallable with support of cdata metatype' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox