Commit 497d6970
497d69700e72Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 5 files · +4 added · ~1 modified
Description
Merge pull request #323 from ryanseys/fix/divmod-tuple-inspect
fix(codegen): inspect tuple:int,int / tuple:int,float for p
Details
- Commit
- 497d69700e72
- Parent
- 760bc936cd54
- Merge parent
- bfe58c281865
spinel_codegen.rbmodifiedView file
@@ -31811,6 +31811,20 @@
3181131811
@needs_int_array = 13181231812
return "sp_SymArrayPtrArray_inspect(" + val + ")"3181331813
end31814+
# Tuples produced by methods that return Ruby Arrays of fixed31815+
# arity (Integer#divmod, Array#minmax, etc.). Without an inspect31816+
# path here, `p arr.minmax` would fall through to printf("%lld",...)31817+
# and emit the struct pointer. Format as Ruby's "[a, b]" so the31818+
# output round-trips with CRuby.31819+
if at == "tuple:int,int"31820+
return "sp_sprintf(\"[%lld, %lld]\", (long long)" + val + "->_0, (long long)" + val + "->_1)"31821+
end31822+
if at == "tuple:int,float"31823+
return "sp_sprintf(\"[%lld, %s]\", (long long)" + val + "->_0, sp_float_inspect(" + val + "->_1))"31824+
end31825+
if at == "tuple:float,float"31826+
return "sp_sprintf(\"[%s, %s]\", sp_float_inspect(" + val + "->_0), sp_float_inspect(" + val + "->_1))"31827+
end3181431828
""3181531829
end3181631830
test/array_minmax.rbaddedView file
Loading diff…
test/array_minmax.rb.expectedaddedView file
Loading diff…
test/integer_divmod.rbaddedView file
Loading diff…
test/integer_divmod.rb.expectedaddedView file
Loading diff…