From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp54.i.mail.ru (smtp54.i.mail.ru [217.69.128.34]) (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 2DDC844643E for ; Thu, 24 Sep 2020 20:01:03 +0300 (MSK) From: Timur Safin Date: Thu, 24 Sep 2020 20:00:19 +0300 Message-Id: <51700ea1fd13c5cbea49e3426551d1c16c1bda02.1600955781.git.tsafin@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH 2.X 6/7] module api: luaL_checkibuf & luaL_checkconstchar List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org Cc: tarantool-patches@dev.tarantool.org Moved `luaL_checkibuf` & `luaL_checkconstchar` to the public part of module api. Part of #5273 --- src/exports.h | 2 ++ src/lua/utils.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/exports.h b/src/exports.h index ef4f3b741..08c7ac53f 100644 --- a/src/exports.h +++ b/src/exports.h @@ -348,6 +348,8 @@ EXPORT(luaL_callmeta) EXPORT(luaL_cdef) EXPORT(luaL_checkany) EXPORT(luaL_checkcdata) +EXPORT(luaL_checkconstchar) +EXPORT(luaL_checkibuf) EXPORT(luaL_checkint64) EXPORT(luaL_checkinteger) EXPORT(luaL_checklstring) diff --git a/src/lua/utils.h b/src/lua/utils.h index da0140076..6b10d2755 100644 --- a/src/lua/utils.h +++ b/src/lua/utils.h @@ -589,6 +589,23 @@ luaT_temp_luastate(int *coro_ref, int *top); void luaT_release_temp_luastate(struct lua_State *L, int coro_ref, int top); +/** + * Check if a value on @a L stack by index @a idx is an ibuf + * object. Both 'struct ibuf' and 'struct ibuf *' are accepted. + * Returns NULL, if can't convert - not an ibuf object. + */ +struct ibuf * +luaL_checkibuf(struct lua_State *L, int idx); + +/** + * Check if a value on @a L stack by index @a idx is pointer at + * char or const char. '(char *)NULL' is also considered a valid + * char pointer. + */ +int +luaL_checkconstchar(struct lua_State *L, int idx, const char **res, + uint32_t *cdata_type_p); + /** \endcond public */ /** @@ -666,6 +683,8 @@ luaL_checkfinite(struct lua_State *L, struct luaL_serializer *cfg, luaL_error(L, "number must not be NaN or Inf"); } +/** \cond public */ + /** * Check if a value on @a L stack by index @a idx is an ibuf * object. Both 'struct ibuf' and 'struct ibuf *' are accepted. -- 2.20.1