Software / code / prosody
Diff
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 |
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