Changeset

11093:ec14d4fce855

util.serialization: Let freeze metamethod return a literal string Enables custom serialization, such as creating a datatype that serializes into a variable reference.
author Kim Alvefur <zash@zash.se>
date Sat, 26 Sep 2020 23:17:53 +0200
parents 11092:bd13aa89262d
children 11094:03fdf41fd948
files util/serialization.lua
diffstat 1 files changed, 4 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/util/serialization.lua	Sat Sep 26 18:15:49 2020 +0200
+++ b/util/serialization.lua	Sat Sep 26 23:17:53 2020 +0200
@@ -150,6 +150,10 @@
 
 				if type(fr) == "function" then
 					t = fr(t);
+					if type(t) == "string" then
+						o[l], l = t, l + 1;
+						return l;
+					end
 					if type(tag) == "string" then
 						o[l], l = tag, l + 1;
 					end