[Tarantool-patches] [PATCH 03/14] WIP: module api/lua: add luaL_iscdata() function
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Fri Sep 25 01:32:03 MSK 2020
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 <luaL_checkcdata>() 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
>
More information about the Tarantool-patches
mailing list