From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 11.2 \(3445.5.20\)) Subject: Re: [PATCH 2/5] lua: port console yaml formatting to C From: "v.shpilevoy@tarantool.org" In-Reply-To: <20180321091455.3td6h42oe3l2omlg@esperanza> Date: Wed, 21 Mar 2018 12:30:51 +0300 Content-Transfer-Encoding: 7bit Message-Id: <4C6FE419-35BE-4323-803A-624CAFC80522@tarantool.org> References: <881a3705ddfd6c3885171fe3a748b0e2baaded92.1521466428.git.v.shpilevoy@tarantool.org> <20180320175113.bnocgitvdf5eh2dn@esperanza> <20180321091455.3td6h42oe3l2omlg@esperanza> To: Vladimir Davydov Cc: tarantool-patches@freelists.org List-ID: >>> >>>> diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua >>>> @@ -395,4 +375,6 @@ package.loaded['console'] = { >>>> on_start = on_start; >>>> on_client_disconnect = on_client_disconnect; >>>> completion_handler = internal.completion_handler; >>>> + formatter = internal.formatter; >>> >>> I don't like that we export the serializer to Lua, but never use it in >>> Lua code, only in C. Can't we create a serializer in C and pass it to >>> the encoder function explicitly? >> >> The problem of Lua formatter is that it is Lua table, not cdata. And >> to fully port it on C it is necessary to rewrite luaL_serializer and >> l_dump in lyaml.cc , that seems to be too >> complicated for a single propose - format push message. But if you >> insist, I can do full port. > > I'm not sure... Obviously, I don't want you to rewrite the yaml encode. > I just want to understand if there are alternatives to exporting the > yaml encoder to the Lua console module, just to use it in C. Please take > a look at how src/lua/msgpack.c is implemented - may be, we could borrow > some ideas from it. Ok, I will investigate.