Commit Graph

37 Commits

Author SHA1 Message Date
Paul Kulchenko
6e41f2ca07 Added option to change radix for floating numbers (closes #36, closes #37).
This is needed to produce a valid Lua code when a local locale setting
makes `format` to produce floating point numbers with a comma.

Limitation: only commas are being fixed in floating point numbers.
2020-11-05 21:04:43 -08:00
Peter Melnichenko
ecf3b48c83 Fixed incorrect sref name used for tables within table keys
`insref` argument of `val2str` explicitly sets name to use for a value
within the self reference section when it is seen again.

It's necessary to provide it for table keys, as they can only be
referenced through the `iname` storage table. For values sref name
can be calculated based on sref of the parent table and the key.

When serializing normal values (key is not a table or another special type),
`insref` was passed as is to the recursive `val2str` call. This is incorrect
when `insref` is actually present (i.e. parent table is a table key
or a value for a table key), the values should get their own sref names
instead of the parent name. Passing `nil` instead is enough to fix this.

Fixes #28, closes #30.
2018-04-23 20:57:22 -07:00
Paul Kulchenko
679a5a3bca Added metatostring option to disable __tostring processing during serialization.
Ref pkulchenko/MobDebug#27, pkulchenko/MobDebug#29.
2017-09-01 21:35:04 -07:00
Paul Kulchenko
06a575ed69 Added numeric format to preserve floating point precision (closes #17). 2015-05-07 22:55:21 -07:00
Paul Kulchenko
664b6eebea Improved handling of failures in __tostring (pkulchenko/ZeroBraneStudio#446). 2015-05-07 09:03:58 -07:00
Paul Kulchenko
d78f212b71 Switched to a method proposed by @SoniEx2 to disallow function calls (#15). 2015-01-24 13:56:33 -08:00
Paul Kulchenko
3fcbb72531 Added setting env to protect against assigning global functions (closes #15). 2015-01-20 20:54:33 -08:00
Paul Kulchenko
ce5281c1f5 Updated tests to work with Lua 5.3. 2015-01-20 20:30:36 -08:00
Paul Kulchenko
f2fc9e7517 Improved Lua 5.2 support for serialized functions. 2014-01-19 21:40:03 -08:00
Paul Kulchenko
ca4140a2d1 Fixed (properly this time) order of elements in the array part (fixes #13). 2014-01-10 16:05:19 -08:00
Paul Kulchenko
7d56d50a9c Fixed order of elements in the array part with sortkeys=true (fixes #13). 2014-01-10 10:27:26 -08:00
Paul Kulchenko
4e4a19df1d Added load function to deserialize; updated documentation (closes #9). 2013-11-05 11:52:05 -08:00
Paul Kulchenko
a4e258cb77 Fixed an issue with mixed tables that may be missing keys.
Earlier optimization depended on incorrect assumption that `next` can be
started by using #t, which is not the case.
2013-10-01 20:52:34 -07:00
Paul Kulchenko
29d2e11920 Optimized processing of tables with numeric indexes. 2013-09-30 21:17:59 -07:00
Paul Kulchenko
115b30ea77 Added maxnum option to limit the number of elements in tables. 2013-09-29 14:33:15 -07:00
Paul Kulchenko
f7b2a819c0 Fixed an issue missing numerical keys (fixes #8). 2013-06-12 11:04:56 -07:00
Paul Kulchenko
a36b3fec71 Added support for metatables with __serialize method. 2013-03-05 10:38:06 -08:00
Paul Kulchenko
7f58e5899c Added handling of metatables with __tostring method. 2013-03-05 10:28:26 -08:00
Paul Kulchenko
4883768d13 Fixed an issue with having too many locals in self-reference section. 2013-03-04 11:18:29 -08:00
Paul Kulchenko
9db92970d3 Fixed emitting premature circular reference in self-reference section, which caused invalid serialization. 2013-02-27 23:19:53 -08:00
Paul Kulchenko
16c5599903 Added ability to process __tostring results that may be non-string values. 2013-01-15 11:53:07 -08:00
Paul Kulchenko
bb73826310 Renamed ignore option to valignore for consistency. 2013-01-08 10:09:12 -08:00
Jess Telford
fb1f135674 Added valtypeignore option 2013-01-04 19:24:30 +11:00
Jess Telford
6892d907ec rename keywhitelist to keyallow for consistency with ignore 2013-01-04 13:37:49 +11:00
Jess Telford
832af701d3 Allow serialization of only whitelisted keys
Example:

    local a = {
    	foo = 'bar',
    	[1] = 2,
    	[true] = 'only me'
    }

    local options = {
    	keywhitelist = {
    		['foo'] = true,
    		[true] = true
    	},
    	ignore = {
    		['bar'] = true
    	}
    }

    print(serpent.block(a, options))

    -- output:

    {
    	[true] = "only me"
    }
2013-01-04 00:19:20 +11:00
Paul Kulchenko
07e85484df Added serialization of metatables using __tostring (when present). 2012-11-16 21:21:42 -08:00
Paul Kulchenko
d8e92a3388 Fixed an issue with serializing functions as keys when the keys are created as part of the delayed shared reference processing. 2012-11-16 15:07:04 -08:00
Paul Kulchenko
6f0b9e75e0 Fixed an issue with serializing data structures with circular references.
Fixed an issue with serializing keys that point to shared references.
Optimized overall serialization to inline values when possible.
2012-09-14 14:31:37 -07:00
Paul Kulchenko
e72ca380f9 Removed confusing comment from serialized results 2012-08-28 21:42:28 -07:00
Paul Kulchenko
3471396adb Added 'comment=num' option to limit comments up to particular depth level 2012-06-19 12:29:42 -07:00
Paul Kulchenko
ad84a79966 Added 'ignore' parameter to allow ignoring table values 2012-06-16 19:43:15 -07:00
Paul Kulchenko
d9e1055bd0 Fixed an issue with negative and real value numeric keys being misplaced 2012-06-13 21:06:23 -07:00
Paul Kulchenko
82a4aee176 Fixed an issue with string keys with numeric values ['3'] getting mixed with real numeric keys 2012-06-13 11:07:59 -07:00
Paul Kulchenko
428061f498 Fixed key sorting and removed addresses from names of temp variables for a more stable output. 2012-06-13 10:21:44 -07:00
Paul Kulchenko
e89d8b8a9b Added options to configure serialization process 2012-06-12 23:17:44 -07:00
Paul Kulchenko
7be5ecd21a Fixed comments in the test 2012-06-06 08:24:14 -07:00
Paul Kulchenko
9bc76dc20c Initial commit 2012-06-03 22:34:39 -07:00