From bd5c9d8f10772196b4bb8b1a894dfd15f4b48dba Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov@gmail.com>
Date: Fri, 4 Oct 2019 10:49:20 +0300
Subject: [PATCH] box/console: Add mapping for direct symbols

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

Reviewed-by: Konstantin Osipov <kostja.osipov@gmail.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
(cherry picked from commit 6847367f4ec3155d67f7649b7b3bc4a6f992afa9)
---
 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 64086cf5bf..9420bee691 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.
-- 
GitLab