Commit Graph

70 Commits

Author SHA1 Message Date
k0zmo 0336d06114 Disallow deserialization of object variants with multiple object branches 2019-07-06 11:14:34 +02:00
k0zmo fd4a718586 Adhere to new rules of object variants (re)initialization 2019-07-06 11:14:34 +02:00
Marcus Eriksson 90f47e1043 Only include the type name in the error message 2019-07-06 11:14:34 +02:00
Marcus Eriksson ef2b2e9ae7 Fixes for Nim v0.20.0
The breaking changes affecting this library are:

* Macro arguments of type typedesc are now passed to the macro as
  NimNode like every other type except static. Use typed for a behavior
  that is identical in new and old Nim. See the RFC Pass typedesc as
  NimNode to macros for more details.
  (https://github.com/nim-lang/RFCs/issues/148)

* case object branch transitions via system.reset are deprecated.
  Compile your code with -d:nimOldCaseObjects for a transition period.

  The solution here is to compile with '-d:nimOldCaseObjects' for the
  time being. I didn't understand how to modify the code to adhere to
  the new way of initializing/changing variant objects.

* The compiler now enforces range checking which exposed a bug in the
  fieldCount proc. For variant objects where one of the branches is
  given on one line, e.g.

    ...
    of akDog: barkometer: int
    ...

  the field wasn't counted and the total field count was not accurate.
2019-07-06 11:14:34 +02:00
Vindaar 407b10be66 do not construct empty seq for `yamlScalar` 2018-10-12 16:00:39 +02:00
Vindaar 446493ded8 replace `newException` by `constructionError` call if int too large
If an integer doesn't fit into the target type an exception is thrown.
2018-10-12 16:00:39 +02:00
Vindaar 53c476ce38 remove unnecessary if branch related too seq construction
Not needed anymore, since seqs can never be nil nowadays.
2018-10-12 16:00:39 +02:00
Vindaar 81e50d73d9 remove commented out old code 2018-10-12 16:00:39 +02:00
Vindaar 253a4623e4 circumvent RangeError, which will be wrongly caught
Converting an integer via `T(number)` to some integer will cause a
range error, if it doesn't fit. Maybe it didn't in the past, which is
why the code worked before? Some other error was thrown?
With this code anyway it crashed, because it threw an internal error.
2018-10-12 16:00:39 +02:00
Vindaar 4821ef95fb [soft] take out yTagNimNilString/Seq and related (?) nil tests 2018-10-12 16:00:39 +02:00
Vindaar 7ad13d98d9 force vals in `quote do` to bool due to compile time when changes 2018-10-12 16:00:39 +02:00
Vindaar 011c99270f fix regression in times.parse syntax due to changes in times module
Probably due to the changes in the times module, the old syntax throws
an error now.
2018-10-12 16:00:39 +02:00
Vindaar 890bbed5ed further `nil` fixes in `tojson` and `serialization` 2018-10-12 16:00:39 +02:00
Alexander Ivanov 566e28dcc5 Make it work with new not nil 2018-10-12 16:00:39 +02:00
Alexander Ivanov ba53fc0494 Load 0 fix #60 2018-08-30 09:21:30 +02:00
Marcus Eriksson 2328289dba Fixes #54 2018-05-29 19:12:03 +02:00
Jacob MacDonald 4933194dd6 Fix for newer versions of compiler.
61720e0df9475af647de171f6b2964c36234961a in the Nim compiler introduced the bug
in this project. In brief, the upstream change flattens `nnkStmtList`s of one
item. Thus, `quote do:` followed by one statement is no longer a nnkStmtList
but whatever that one statement is. This breaks several macro implementations
where a `quote do:` form is initialized and then appended to. Based on Araq's
feedback (https://irclogs.nim-lang.org/02-10-2017.html#21:01:26), these
single-statement quotes are now converted into one-element statement lists as
necessary (behavior on old versions of the compiler is maintained).
2017-10-03 15:59:45 +02:00
Felix Krause 8d8464da71 Fixes #43 2017-09-20 18:58:09 +02:00
Felix Krause 37031c4c80 make tests green again 2017-08-30 18:11:18 +02:00
Felix Krause ff86083461 Fixes #44 2017-08-30 18:04:52 +02:00
Felix Krause f07cf173dc Fixed to previous JS adjustments 2017-03-30 17:58:53 +02:00
Felix Krause 7ba95845e0 JS improvements; also added constructObjectDefault 2017-03-29 21:42:07 +02:00
Felix Krause 71b075abf6 Allow backticked field names in macros 2017-03-29 18:38:31 +02:00
Felix Krause 5ebde01ca5 Made tjson and tserialization compile for JS 2017-02-13 17:10:56 +01:00
Felix Krause 0ef9cbf535 Moved private sources to yaml/private 2017-02-06 20:39:04 +01:00
Felix Krause 40e303049f Documented serialization macros 2016-11-30 18:31:09 +01:00
Felix Krause 5e00d714eb Do not assume RecLists everywhere. Fixes #31 2016-11-30 18:01:03 +01:00
Felix Krause a51befe30d Improved float parsing
* Fixed #30
 * Accept underscores in float literals
 * Added test
2016-11-10 10:12:32 +01:00
Felix Krause 64f68ae1af Implemented !!timestamp 2016-11-08 21:13:01 +01:00
Felix Krause dcfa8fd27c Implemented ignoreInputKey 2016-10-27 17:58:14 +02:00
Felix Krause 6402433d2a Implemented setDefaultValue. 2016-10-26 18:32:54 +02:00
Felix Krause 9290ca0d91 Load objects with transient fields 2016-10-19 22:04:46 +02:00
Felix Krause ab8bfe4192 Removed garbage code 2016-10-15 18:30:52 +02:00
Felix Krause 3ab3dc7ad0 Dump variant objects with transient fields
* tuples not working yet
 * loading not woring yet
 * added tests
2016-10-15 17:58:29 +02:00
Felix Krause b3d83025f7 Started transient implementation
* represent of simple object works
 * TODO: variant objects
 * TODO: construct
2016-10-12 22:39:59 +02:00
Felix Krause 29352fa4fe Use global tag handle for NimYAML
* NimYAML now uses the tag prefix tag:nimyaml.org,2016:
 * That tag handle is shortened to !n! when presenting
 * Also fixed some minor bugs dealing with tag handles
2016-10-10 20:16:54 +02:00
Felix Krause 0f2e077b87 Added automatic test for quickstart snippets
* There are errors which indicate real bugs!
2016-10-08 23:35:33 +02:00
Felix Krause 9f7e87e935 Ordered snippets with file system hierarchy 2016-10-08 20:57:53 +02:00
Felix Krause 3942e80d9b Improved error messages and test them. 2016-09-24 16:45:49 +02:00
Felix Krause 2ad41d349e Improved and fixed issues with error reporting 2016-09-23 15:42:24 +02:00
Felix Krause a8d68d1696 Addressed some compiler warnings 2016-09-22 14:25:10 +02:00
Felix Krause 680e419d12 Simplified field checking 2016-09-22 14:16:10 +02:00
Felix Krause 1dc8ddc6ea got rid of yaml.common 2016-09-22 13:28:24 +02:00
Felix Krause 5dfc984913 Updated documentation for new structure 2016-09-21 21:20:57 +02:00
Felix Krause d987b607e5 Check for custom object errors when loading
* Ensure no duplicate fields
 * Ensure no missing fields
 * Ensure no unknown fields
 * Implemented for both tuples and objects,
   including variant objects
2016-09-21 15:40:03 +02:00
Felix Krause 12960b2e31 Restructuring: no more includes 2016-09-20 21:53:38 +02:00
Felix Krause 325e3ec18f Made serialization part of yaml. Improved doc. 2016-02-12 20:44:38 +01:00
Felix Krause c6c13eb044 Better doc index. YamlStream now an object.
* Also various fixes to serialization and presentation
2016-02-12 19:53:25 +01:00
Felix Krause 32c42054f7 Renamed serialize() to represent() to better conform to YAML spec 2016-02-02 18:19:40 +01:00
Felix Krause e89a9a5b14 Serialization: Support enum types 2016-02-01 20:16:35 +01:00