Software /
code /
prosody
Comparison
util/serialization.lua @ 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 |
parent | 10061:5c71693c8345 |
child | 12781:22066b02887f |
comparison
equal
deleted
inserted
replaced
11092:bd13aa89262d | 11093:ec14d4fce855 |
---|---|
148 local tag = mt.__name; | 148 local tag = mt.__name; |
149 local fr = mt.__freeze; | 149 local fr = mt.__freeze; |
150 | 150 |
151 if type(fr) == "function" then | 151 if type(fr) == "function" then |
152 t = fr(t); | 152 t = fr(t); |
153 if type(t) == "string" then | |
154 o[l], l = t, l + 1; | |
155 return l; | |
156 end | |
153 if type(tag) == "string" then | 157 if type(tag) == "string" then |
154 o[l], l = tag, l + 1; | 158 o[l], l = tag, l + 1; |
155 end | 159 end |
156 end | 160 end |
157 end | 161 end |