[PATCH 1/7] box/console: Add mapping for direct symbols

Cyrill Gorcunov gorcunov at gmail.com
Fri Sep 20 21:45:17 MSK 2019


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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/box/lua/console.lua b/src/box/lua/console.lua
index 64086cf5b..9420bee69 100644
--- a/src/box/lua/console.lua
+++ b/src/box/lua/console.lua
@@ -40,12 +40,24 @@ output_handlers["yaml"] = function(status, opts, ...)
     return internal.format({ error = err })
 end
 
+-- A map for internal symbols in case if they
+-- are not inside tables and serpent won't be
+-- able to handle them properly.
+local lua_map_direct_symbols = {
+    [box.NULL]      = 'box.NULL',
+}
+
 output_handlers["lua"] = function(status, opts, ...)
     --
     -- Don't print nil if there is no data
     if not ... then
         return ""
     end
+    for k,v in pairs(lua_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




More information about the Tarantool-patches mailing list