gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/iter.lua
diff options
context:
space:
mode:
Diffstat (limited to 'iter.lua')
-rw-r--r--iter.lua 14
1 files changed, 11 insertions, 3 deletions
diff --git a/iter.lua b/iter.lua
index 06d4618a..4d2b6ffa 100644
--- a/iter.lua
+++ b/iter.lua
@@ -20,6 +20,7 @@
local cat = table.concat
local fmt = string.format
+local tostring = tostring
do
local ffi = require('ffi')
@@ -61,6 +62,13 @@ end
local max_depth = 3
+local function cdata_tos(t, deep)
+ local tp = gsl_type and gsl_type(t) or 'cdata'
+ if tp ~= 'cdata' and t.show then
+ return (deep and t:show() or fmt("<%s: %p>", tp, t))
+ end
+end
+
tos = function (t, depth)
local tp = type(t)
if tp == 'table' then
@@ -92,9 +100,9 @@ tos = function (t, depth)
end
end
elseif tp == 'cdata' then
- local tpext = gsl_type and gsl_type(t) or tp
- if tpext ~= 'cdata' and t.show then
- return (depth == 0 and t:show() or fmt("<%s: %p>", tpext, t))
+ local ok, s = pcall(cdata_tos, t, depth == 0)
+ if ok and type(s) == 'string' then
+ return s
end
end
return tostring(t)
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月26日 08:40:35 +0000

AltStyle によって変換されたページ (->オリジナル) /