[Tarantool-patches] [PATCH 4/7] box/console: rename luaL_yaml_default to serializer_yaml

Oleg Babin olegrok at tarantool.org
Mon May 18 15:11:04 MSK 2020


Hi! I'm not sure that we really should do that. Functions with LuaL 
prefix is a part of Lua code convention AFAIK.
(https://www.lua.org/manual/5.1/manual.html#4)

But LGTM if nobody doesn't have objections.

On 12/05/2020 16:50, Cyrill Gorcunov wrote:
> As we gonna implement lua output serializer lets
> rename luaL_yaml_default to serializer_yaml which
> will be more general name, for other serializers
> we will use same serializer_ prefix.
> 
> Part-of #4682
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at gmail.com>
> ---
>   src/box/lua/console.c | 16 ++++++++--------
>   1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/src/box/lua/console.c b/src/box/lua/console.c
> index 734c0ee47..c8e0dea58 100644
> --- a/src/box/lua/console.c
> +++ b/src/box/lua/console.c
> @@ -49,7 +49,7 @@
>   
>   extern char serpent_lua[];
>   
> -static struct luaL_serializer *luaL_yaml_default = NULL;
> +static struct luaL_serializer *serializer_yaml;
>   
>   /*
>    * Completion engine (Mike Paul's).
> @@ -369,7 +369,7 @@ lbox_console_format_yaml(struct lua_State *L)
>   	}
>   	lua_replace(L, 1);
>   	lua_settop(L, 1);
> -	return lua_yaml_encode(L, luaL_yaml_default, NULL, NULL);
> +	return lua_yaml_encode(L, serializer_yaml, NULL, NULL);
>   }
>   
>   int
> @@ -404,7 +404,7 @@ console_dump_plain(struct lua_State *L, uint32_t *size)
>   {
>   	enum output_format fmt = console_get_output_format();
>   	if (fmt == OUTPUT_FORMAT_YAML) {
> -		int rc = lua_yaml_encode(L, luaL_yaml_default, "!push!",
> +		int rc = lua_yaml_encode(L, serializer_yaml, "!push!",
>   					 "tag:tarantool.io/push,2018");
>   		if (rc == 2) {
>   			/*
> @@ -566,11 +566,11 @@ tarantool_lua_console_init(struct lua_State *L)
>   	lua_pushcclosure(L, lbox_console_readline, 1);
>   	lua_setfield(L, -2, "readline");
>   
> -	luaL_yaml_default = lua_yaml_new_serializer(L);
> -	luaL_yaml_default->encode_invalid_numbers = 1;
> -	luaL_yaml_default->encode_load_metatables = 1;
> -	luaL_yaml_default->encode_use_tostring = 1;
> -	luaL_yaml_default->encode_invalid_as_nil = 1;
> +	serializer_yaml = lua_yaml_new_serializer(L);
> +	serializer_yaml->encode_invalid_numbers = 1;
> +	serializer_yaml->encode_load_metatables = 1;
> +	serializer_yaml->encode_use_tostring = 1;
> +	serializer_yaml->encode_invalid_as_nil = 1;
>   	/*
>   	 * Hold reference to the formatter in module local
>   	 * variable.
> 


More information about the Tarantool-patches mailing list