[tarantool-patches] Re: [tarantool-patches] [PATCH 1/6] box/console: Add mapping for direct symbols

Sergey Ostanevich sergos at tarantool.org
Mon Sep 9 18:11:44 MSK 2019


Cyrill,

Why not to move the map_direct_symbols to the module level, so that creation and 
fill of the table will happens only once and not at every call to the output handler?


>Пятница,  6 сентября 2019, 0:28 +03:00 от Cyrill Gorcunov <gorcunov at gmail.com>:
>
>Sole symbols (such as box.NULL) are not processed
>by serpent "custom" symbols feature, since they
>are not in table.
>
>Thus we should process them separately. Without it
>we have
>
> > require('console').set_default_output("lua,block")
> > ;
> > box.NULL
> > "cdata<void %*>: NULL";
>
>instead of
>
> > box.NULL
> > box.NULL;
>
>as it should be.
>
>Part-of #3834
>---
> src/box/lua/console.lua | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
>diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
>index 64086cf5b..22bafab3a 100644
>--- a/src/box/lua/console.lua
>+++ b/src/box/lua/console.lua
>@@ -46,6 +46,17 @@ output_handlers["lua"] = function(status, opts, ...)
>     if not ... then
>         return ""
>     end
>+    -- Map internal symbols in case if they are
>+    -- not inside tables and serpent won't handle
>+    -- them properly.
>+    local map_direct_symbols = {
>+        [box.NULL]      = 'box.NULL',
>+    }
>+    for k,v in pairs(map_direct_symbols) do
>+        if k == ... then
>+            return v
>+        end
>+    end
>     --
>     -- Map internal symbols which serpent doesn't know
>     -- about to a known representation.
>-- 
>2.20.1
>
>


-- 
Sergey Ostanevich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.tarantool.org/pipermail/tarantool-patches/attachments/20190909/09e29642/attachment.html>


More information about the Tarantool-patches mailing list