Skip to content

Commit

Permalink
v0.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Apr 28, 2024
1 parent a06d9f8 commit 620615f
Show file tree
Hide file tree
Showing 15 changed files with 135 additions and 135 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ project(ryml
LANGUAGES CXX)
include(./compat.cmake)

c4_project(VERSION 0.5.0 STANDALONE
c4_project(VERSION 0.6.0 STANDALONE
AUTHOR "Joao Paulo Magalhaes <[email protected]>")


Expand Down
104 changes: 104 additions & 0 deletions changelog/0.6.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
### Add API documentation

- [PR#423](https://github.com/biojppm/rapidyaml/pull/423): **add Doxygen-based API documentation, now hosted in [https://rapidyaml.readthedocs.io/](https://rapidyaml.readthedocs.io/)!**.
- It uses the base doxygen docs, as I couldn't get doxyrest or breathe or exhale to produce anything meaningful using the groups already defined in the source code.


### Error handling

Fix major error handling problem reported in [#389](https://github.com/biojppm/rapidyaml/issues/389) ([PR#411](https://github.com/biojppm/rapidyaml/pull/411)):

- The `NodeRef` and `ConstNodeRef` classes are now conditional noexcept using `RYML_NOEXCEPT`, which evaluates either to nothing when assertions are enabled, and to `noexcept` otherwise. The problem was that these classes had many methods explicitly marked `noexcept`, but were doing assertions which could throw exceptions, causing an abort instead of a throw whenever the assertion called an exception-throwing error callback.
- Also, this problem was compounded by exceptions being enabled in every build type -- despite the intention to have them only in debug builds. There was a problem in the preprocessor code to enable assertions which led to assertions being enabled in release builds even when `RYML_USE_ASSERT` was defined to 0. Thanks to @jdrouhard for reporting this.
- Although the code is and was extensively tested, the testing was addressing mostly the happy path. Tests were added to ensure that the error behavior is as intended.
- Together with this changeset, a major revision was carried out of the asserting/checking status of each function in the node classes. In most cases, assertions were added to functions cases that were missing them. So **beware** - user code that was invalid will now assert or error out. Also, assertions and checks are now directed as much as possible to the callbacks of the closest scope, ie if a tree has custom callbacks, errors within the tree class should go through those callbacks.
- Also, the intended assertion behavior is now in place: *no assertions in release builds*. **Beware** as well - user code which was relying on this will now silently succeed and return garbage in release builds. See the next points, which may help:
- Added new methods to the `NodeRef`/`ConstNodeRef` classes:
```c++
/** Distinguish between a valid seed vs a valid non-seed ref. */
bool readable() const { return valid() && !is_seed(); }

/** Get a child by name, with error checking; complexity is
* O(num_children).
*
* Behaves as operator[](csubstr) const, but always raises an
* error (even when RYML_USE_ASSERT is set to false) when the
* returned node does not exist, or when this node is not
* readable, or when it is not a map. This behaviour is similar to
* std::vector::at(), but the error consists in calling the error
* callback instead of directly raising an exception. */
ConstNodeRef at(csubstr key) const;
/** Likewise, but return a seed node when the key is not found */
NodeRef at(csubstr key);

/** Get a child by position, with error checking; complexity is
* O(pos).
*
* Behaves as operator[](size_t) const, but always raises an error
* (even when RYML_USE_ASSERT is set to false) when the returned
* node does not exist, or when this node is not readable, or when
* it is not a container. This behaviour is similar to
* std::vector::at(), but the error consists in calling the error
* callback instead of directly raising an exception. */
ConstNodeRef at(size_t pos) const;
/** Likewise, but return a seed node when pos is not found */
NodeRef at(csubstr key);
```
- The state for `NodeRef` was refined, and now there are three mutually exclusive states (and class predicates) for an object of this class:
- `.invalid()` when the object was not initialized to any node
- `.readable()` when the object points at an existing tree+node
- `.is_seed()` when the object points at an hypotethic tree+node
- The previous state `.valid()` was deprecated: its semantics were confusing as it actually could be any of `.readable()` or `.is_seed()`
- Deprecated also the following methods for `NodeRef`/`ConstNodeRef`:
```c++
RYML_DEPRECATED() bool operator== (std::nullptr_t) const;
RYML_DEPRECATED() bool operator!= (std::nullptr_t) const;
RYML_DEPRECATED() bool operator== (csubstr val) const;
RYML_DEPRECATED() bool operator!= (csubstr val) const;
```
- Added macros and respective cmake options to control error handling:
- `RYML_USE_ASSERT` - enable assertions regardless of build type. This is disabled by default. This macro was already defined; the current PR adds the cmake option.
- `RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS` - make the default error handler provided by ryml throw exceptions instead of calling `std::abort()`. This is disabled by default.
- Also, `RYML_DEBUG_BREAK()` is now enabled only if `RYML_DBG` is defined, as reported in [#362](https://github.com/biojppm/rapidyaml/issues/362).
- As part of [PR#423](https://github.com/biojppm/rapidyaml/pull/423), to improve linters and codegen:
- annotate the error handlers with `[[noreturn]]`/`C4_NORETURN`
- annotate some error sites with `C4_UNREACHABLE_AFTER_ERR()`


### More fixes

- `Tree::arena() const` was returning a `substr`; this was an error. This function was changed to:
```
csubstr Tree::arena() const;
substr Tree::arena();
```
- Fix [#390](https://github.com/biojppm/rapidyaml/pull/390) - `csubstr::first_real_span()` failed on scientific numbers with one digit in the exponent.
- Fix [#361](https://github.com/biojppm/rapidyaml/pull/361) - parse error on map scalars containing `:` and starting on the next line:
```yaml
---
# failed to parse:
description:
foo:bar
---
# but this was ok:
description: foo:bar
```
- [PR#368](https://github.com/biojppm/rapidyaml/pull/368) - fix pedantic compiler warnings.
- Fix [#373](https://github.com/biojppm/rapidyaml/issues/373) - false parse error with empty quoted keys in block-style map ([PR#374](https://github.com/biojppm/rapidyaml/pull/374)).
- Fix [#356](https://github.com/biojppm/rapidyaml/issues/356) - fix overzealous check in `emit_as()`. An id may be larger than the tree's size, eg when nodes were removed. ([PR#357](https://github.com/biojppm/rapidyaml/pull/357)).
- Fix [#417](https://github.com/biojppm/rapidyaml/issues/417)) - add quickstart example explaining how to avoid precision loss while serializing floats ([PR#420](https://github.com/biojppm/rapidyaml/pull/420)).
- Fix [#380](https://github.com/biojppm/rapidyaml/issues/380) - Debug visualizer .natvis file for Visual Studio was missing `ConstNodeRef` ([PR#383](https://github.com/biojppm/rapidyaml/issues/383)).
- FR [#403](https://github.com/biojppm/rapidyaml/issues/403) - install is now optional when using cmake. The relevant option is `RYML_INSTALL`.


### Python

- Fix [#428](https://github.com/biojppm/rapidyaml/issues/428)/[#412](https://github.com/biojppm/rapidyaml/discussions/412) - Parse errors now throw `RuntimeError` instead of aborting.



### Thanks

- @Neko-Box-Coder
- @jdrouhard
- @dmachaj
104 changes: 0 additions & 104 deletions changelog/current.md
Original file line number Diff line number Diff line change
@@ -1,104 +0,0 @@
### Add API documentation

- [PR#423](https://github.com/biojppm/rapidyaml/pull/423): **add Doxygen-based API documentation, now hosted in [https://rapidyaml.readthedocs.io/](https://rapidyaml.readthedocs.io/)!**.
- It uses the base doxygen docs, as I couldn't get doxyrest or breathe or exhale to produce anything meaningful using the groups already defined in the source code.


### Error handling

Fix major error handling problem reported in [#389](https://github.com/biojppm/rapidyaml/issues/389) ([PR#411](https://github.com/biojppm/rapidyaml/pull/411)):

- The `NodeRef` and `ConstNodeRef` classes are now conditional noexcept using `RYML_NOEXCEPT`, which evaluates either to nothing when assertions are enabled, and to `noexcept` otherwise. The problem was that these classes had many methods explicitly marked `noexcept`, but were doing assertions which could throw exceptions, causing an abort instead of a throw whenever the assertion called an exception-throwing error callback.
- Also, this problem was compounded by exceptions being enabled in every build type -- despite the intention to have them only in debug builds. There was a problem in the preprocessor code to enable assertions which led to assertions being enabled in release builds even when `RYML_USE_ASSERT` was defined to 0. Thanks to @jdrouhard for reporting this.
- Although the code is and was extensively tested, the testing was addressing mostly the happy path. Tests were added to ensure that the error behavior is as intended.
- Together with this changeset, a major revision was carried out of the asserting/checking status of each function in the node classes. In most cases, assertions were added to functions cases that were missing them. So **beware** - user code that was invalid will now assert or error out. Also, assertions and checks are now directed as much as possible to the callbacks of the closest scope, ie if a tree has custom callbacks, errors within the tree class should go through those callbacks.
- Also, the intended assertion behavior is now in place: *no assertions in release builds*. **Beware** as well - user code which was relying on this will now silently succeed and return garbage in release builds. See the next points, which may help:
- Added new methods to the `NodeRef`/`ConstNodeRef` classes:
```c++
/** Distinguish between a valid seed vs a valid non-seed ref. */
bool readable() const { return valid() && !is_seed(); }

/** Get a child by name, with error checking; complexity is
* O(num_children).
*
* Behaves as operator[](csubstr) const, but always raises an
* error (even when RYML_USE_ASSERT is set to false) when the
* returned node does not exist, or when this node is not
* readable, or when it is not a map. This behaviour is similar to
* std::vector::at(), but the error consists in calling the error
* callback instead of directly raising an exception. */
ConstNodeRef at(csubstr key) const;
/** Likewise, but return a seed node when the key is not found */
NodeRef at(csubstr key);

/** Get a child by position, with error checking; complexity is
* O(pos).
*
* Behaves as operator[](size_t) const, but always raises an error
* (even when RYML_USE_ASSERT is set to false) when the returned
* node does not exist, or when this node is not readable, or when
* it is not a container. This behaviour is similar to
* std::vector::at(), but the error consists in calling the error
* callback instead of directly raising an exception. */
ConstNodeRef at(size_t pos) const;
/** Likewise, but return a seed node when pos is not found */
NodeRef at(csubstr key);
```
- The state for `NodeRef` was refined, and now there are three mutually exclusive states (and class predicates) for an object of this class:
- `.invalid()` when the object was not initialized to any node
- `.readable()` when the object points at an existing tree+node
- `.is_seed()` when the object points at an hypotethic tree+node
- The previous state `.valid()` was deprecated: its semantics were confusing as it actually could be any of `.readable()` or `.is_seed()`
- Deprecated also the following methods for `NodeRef`/`ConstNodeRef`:
```c++
RYML_DEPRECATED() bool operator== (std::nullptr_t) const;
RYML_DEPRECATED() bool operator!= (std::nullptr_t) const;
RYML_DEPRECATED() bool operator== (csubstr val) const;
RYML_DEPRECATED() bool operator!= (csubstr val) const;
```
- Added macros and respective cmake options to control error handling:
- `RYML_USE_ASSERT` - enable assertions regardless of build type. This is disabled by default. This macro was already defined; the current PR adds the cmake option.
- `RYML_DEFAULT_CALLBACK_USES_EXCEPTIONS` - make the default error handler provided by ryml throw exceptions instead of calling `std::abort()`. This is disabled by default.
- Also, `RYML_DEBUG_BREAK()` is now enabled only if `RYML_DBG` is defined, as reported in [#362](https://github.com/biojppm/rapidyaml/issues/362).
- As part of [PR#423](https://github.com/biojppm/rapidyaml/pull/423), to improve linters and codegen:
- annotate the error handlers with `[[noreturn]]`/`C4_NORETURN`
- annotate some error sites with `C4_UNREACHABLE_AFTER_ERR()`


### More fixes

- `Tree::arena() const` was returning a `substr`; this was an error. This function was changed to:
```
csubstr Tree::arena() const;
substr Tree::arena();
```
- Fix [#390](https://github.com/biojppm/rapidyaml/pull/390) - `csubstr::first_real_span()` failed on scientific numbers with one digit in the exponent.
- Fix [#361](https://github.com/biojppm/rapidyaml/pull/361) - parse error on map scalars containing `:` and starting on the next line:
```yaml
---
# failed to parse:
description:
foo:bar
---
# but this was ok:
description: foo:bar
```
- [PR#368](https://github.com/biojppm/rapidyaml/pull/368) - fix pedantic compiler warnings.
- Fix [#373](https://github.com/biojppm/rapidyaml/issues/373) - false parse error with empty quoted keys in block-style map ([PR#374](https://github.com/biojppm/rapidyaml/pull/374)).
- Fix [#356](https://github.com/biojppm/rapidyaml/issues/356) - fix overzealous check in `emit_as()`. An id may be larger than the tree's size, eg when nodes were removed. ([PR#357](https://github.com/biojppm/rapidyaml/pull/357)).
- Fix [#417](https://github.com/biojppm/rapidyaml/issues/417)) - add quickstart example explaining how to avoid precision loss while serializing floats ([PR#420](https://github.com/biojppm/rapidyaml/pull/420)).
- Fix [#380](https://github.com/biojppm/rapidyaml/issues/380) - Debug visualizer .natvis file for Visual Studio was missing `ConstNodeRef` ([PR#383](https://github.com/biojppm/rapidyaml/issues/383)).
- FR [#403](https://github.com/biojppm/rapidyaml/issues/403) - install is now optional when using cmake. The relevant option is `RYML_INSTALL`.


### Python

- Fix [#428](https://github.com/biojppm/rapidyaml/issues/428)/[#412](https://github.com/biojppm/rapidyaml/discussions/412) - Parse errors now throw `RuntimeError` instead of aborting.



### Thanks

- @Neko-Box-Coder
- @jdrouhard
- @dmachaj
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ PROJECT_NAME = rapidyaml
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 0.5.0
PROJECT_NUMBER = 0.6.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
project = 'rapidyaml'
copyright = '2018-2024 Joao Paulo Magalhaes <[email protected]>'
author = 'Joao Paulo Magalhaes <[email protected]>'
release = '0.5.0'
release = '0.6.0'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
2 changes: 1 addition & 1 deletion doc/doxy_main.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# rapidyaml

* Begin by looking at the [project's README](https://github.com/biojppm/rapidyaml/blob/v0.5.0/README.md)
* Begin by looking at the [project's README](https://github.com/biojppm/rapidyaml/blob/v0.6.0/README.md)
* [Documentation page](https://rapidyaml.readthedocs.org)
* Next, skim the docs for the @ref doc_quickstart sample.
* Good! Now the main ryml topics:
Expand Down
18 changes: 9 additions & 9 deletions doc/sphinx_is_it_rapid.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ faster.
nicely as claimed here, we would definitely like to see it! Please
open an issue, or submit a pull request adding the file to
`bm/cases
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases>`__, or
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/cases>`__, or
just send us the files.

`Here’s a parsing benchmark
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_parse.cpp>`__. Using
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/bm_parse.cpp>`__. Using
different approaches within ryml (in-situ/read-only vs. with/without
reuse), a YAML / JSON buffer is repeatedly parsed, and compared
against other libraries.
Expand All @@ -40,7 +40,7 @@ Comparison with yaml-cpp

The first result set is for Windows, and is using a `appveyor.yml
config file
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/appveyor.yml>`__. A
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/cases/appveyor.yml>`__. A
comparison of these results is summarized on the table below:

=========================== ===== ======= ==========
Expand All @@ -52,11 +52,11 @@ appveyor / vs2017 / Debug 6.4 0.0844 76x / 1.3%

The next set of results is taken in Linux, comparing g++ 8.2 and
clang++ 7.0.1 in parsing a YAML buffer from a `travis.yml config file
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/travis.yml>`__
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/cases/travis.yml>`__
or a JSON buffer from a `compile_commands.json file
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/compile_commands.json>`__. You
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/cases/compile_commands.json>`__. You
can `see the full results here
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/results/parse.linux.i7_6800K.md>`__. Summarizing:
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/results/parse.linux.i7_6800K.md>`__. Summarizing:

========================== ===== ======= ========
Read rates (MB/s) ryml yamlcpp compared
Expand Down Expand Up @@ -89,9 +89,9 @@ So how does ryml compare against other JSON readers? Well, it may not
be the fastest, but it's definitely ahead of the pack!

The benchmark is the `same as above
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_parse.cpp>`__,
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/bm_parse.cpp>`__,
and it is reading the `compile_commands.json
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/cases/compile_commands.json>`__,
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/cases/compile_commands.json>`__,
The ``_arena`` suffix notes parsing a read-only buffer (so buffer
copies are performed), while the ``_inplace`` suffix means that the
source buffer can be parsed in place. The ``_reuse`` means the data
Expand Down Expand Up @@ -131,7 +131,7 @@ Performance emitting
--------------------

`Emitting benchmarks
<https://github.com/biojppm/rapidyaml/blob/v0.5.0/bm/bm_emit.cpp>`__
<https://github.com/biojppm/rapidyaml/blob/v0.6.0/bm/bm_emit.cpp>`__
also show similar speedups from the existing libraries, also
anecdotally reported by some users `(eg, here’s a user reporting 25x
speedup from yaml-cpp)
Expand Down
6 changes: 3 additions & 3 deletions doc/sphinx_quicklinks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Quick links

* `Kanban board <https://github.com/biojppm/rapidyaml/projects/1>`_

* Latest release: `0.5.0 <https://github.com/biojppm/rapidyaml/releases/tag/v0.5.0>`_
* Latest release: `0.6.0 <https://github.com/biojppm/rapidyaml/releases/tag/v0.6.0>`_

* `Release page [0.5.0] <https://github.com/biojppm/rapidyaml/releases/tag/v0.5.0>`_
* `Release page [0.6.0] <https://github.com/biojppm/rapidyaml/releases/tag/v0.6.0>`_

* `README [0.5.0] <https://github.com/biojppm/rapidyaml/blob/v0.5.0/README.md>`_
* `README [0.6.0] <https://github.com/biojppm/rapidyaml/blob/v0.6.0/README.md>`_


* Since latest release (master branch):
Expand Down
2 changes: 1 addition & 1 deletion doc/sphinx_try_quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
include(FetchContent)
FetchContent_Declare(ryml
GIT_REPOSITORY https://github.com/biojppm/rapidyaml.git
GIT_TAG v0.5.0
GIT_TAG v0.6.0
GIT_SHALLOW FALSE # ensure submodules are checked out
)
FetchContent_MakeAvailable(ryml)
Expand Down
Loading

0 comments on commit 620615f

Please sign in to comment.