Skip to content

Commit

Permalink
Merge db4c891 into 3280cdc
Browse files Browse the repository at this point in the history
  • Loading branch information
biojppm committed Sep 23, 2020
2 parents 3280cdc + db4c891 commit f614500
Show file tree
Hide file tree
Showing 23 changed files with 483 additions and 136 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ c4_declare_project(ryml
#-------------------------------------------------------

option(RYML_DEFAULT_CALLBACKS "Enable ryml's default implementation of callbacks: allocate(), free(), error()" ON)
option(RYML_DBG "Enable (very verbose) ryml debug prints." OFF)
option(RYML_BUILD_API "Enable API generation (python, etc)" OFF)
option(RYML_DBG "Enable (very verbose) ryml debug prints." OFF)


#-------------------------------------------------------
Expand All @@ -26,8 +26,9 @@ c4_add_library(ryml
SOURCES
ryml.hpp
ryml_std.hpp
c4/yml/detail/stack.hpp
c4/yml/detail/checks.hpp
c4/yml/detail/parser_dbg.hpp
c4/yml/detail/stack.hpp
c4/yml/common.hpp
c4/yml/common.cpp
c4/yml/emit.def.hpp
Expand Down
8 changes: 4 additions & 4 deletions src/c4/yml/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@


#ifndef RYML_DBG
# define RYML_CHECK(cond) if(!(cond)) { ::c4::yml::error("ERROR: expected true: " #cond); }
# define RYML_CHECK_MSG(cond, msg) if(!(cond)) { ::c4::yml::error(msg ": ERROR: expected true: " #cond); }
# define RYML_CHECK(cond) if(!(cond)) { ::c4::yml::error("expected true: " #cond); }
# define RYML_CHECK_MSG(cond, msg) if(!(cond)) { ::c4::yml::error(msg ": expected true: " #cond); }
#else
# define RYML_CHECK(cond) \
if(!(cond)) \
Expand All @@ -45,7 +45,7 @@
{ \
C4_DEBUG_BREAK(); \
} \
::c4::yml::error(__FILE__ ":" C4_XQUOTE(__LINE__) ": ERROR: expected true: " #cond); \
::c4::yml::error(__FILE__ ":" C4_XQUOTE(__LINE__) ": expected true: " #cond); \
}
# define RYML_CHECK_MSG(cond, msg) \
if(!(cond)) \
Expand All @@ -54,7 +54,7 @@
{ \
C4_DEBUG_BREAK(); \
} \
::c4::yml::error(__FILE__ ":" C4_XQUOTE(__LINE__) ": ERROR: expected true: " #cond "\n" msg); \
::c4::yml::error(__FILE__ ":" C4_XQUOTE(__LINE__) ": expected true: " #cond "\n" msg); \
}
#endif

Expand Down
15 changes: 10 additions & 5 deletions src/c4/yml/detail/checks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
#include "c4/yml/tree.hpp"

#ifdef __clang__
# pragma clang diagnostic push
# pragma clang diagnostic push
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits" // error: comparison of unsigned expression >= 0 is always true
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits" // error: comparison of unsigned expression >= 0 is always true
#elif defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4296/*expression is always 'boolean_value'*/)
#endif

namespace c4 {
Expand Down Expand Up @@ -187,9 +190,11 @@ inline void check_arena(Tree const& t)
} /* namespace c4 */

#ifdef __clang__
# pragma clang diagnostic pop
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
# pragma GCC diagnostic pop
#elif defined(_MSC_VER)
# pragma warning(pop)
#endif

#endif /* C4_YML_DETAIL_CHECKS_HPP_ */
19 changes: 19 additions & 0 deletions src/c4/yml/detail/stack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ class stack
return m_stack[m_size];
}

#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4296/*expression is always 'boolean_value'*/)
#elif defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wtype-limits"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wtype-limits"
#endif

C4_ALWAYS_INLINE T const& C4_RESTRICT top() const { RYML_ASSERT(m_size > 0); return m_stack[m_size - 1]; }
C4_ALWAYS_INLINE T & C4_RESTRICT top() { RYML_ASSERT(m_size > 0); return m_stack[m_size - 1]; }

Expand All @@ -120,6 +131,14 @@ class stack
C4_ALWAYS_INLINE T const& C4_RESTRICT operator[](size_t i) const { RYML_ASSERT(i >= 0 && i < m_size); return m_stack[i]; }
C4_ALWAYS_INLINE T & C4_RESTRICT operator[](size_t i) { RYML_ASSERT(i >= 0 && i < m_size); return m_stack[i]; }

#if defined(_MSC_VER)
# pragma warning(pop)
#elif defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

public:

using iterator = T *;
Expand Down
22 changes: 22 additions & 0 deletions src/c4/yml/node.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef _C4_YML_NODE_HPP_
#define _C4_YML_NODE_HPP_

/** @file node.hpp
* @see NodeRef */

#include <cstddef>

#include "c4/yml/tree.hpp"
Expand All @@ -14,6 +17,7 @@
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4251/*needs to have dll-interface to be used by clients of struct*/)
# pragma warning(disable: 4296/*expression is always 'boolean_value'*/)
#endif

namespace c4 {
Expand All @@ -40,6 +44,8 @@ inline Key<K> key(K & k)
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------

/** a reference to a node in an existing yaml tree, offering a more
* convenient API than the index-based API used in the tree. */
class RYML_EXPORT NodeRef
{
private:
Expand Down Expand Up @@ -742,9 +748,25 @@ class RYML_EXPORT NodeRef
children_view children() { return children_view(begin(), end()); }
const_children_view children() const { return const_children_view(begin(), end()); }

#if defined(__clang__)
# pragma clang diagnostic push
# pragma clang diagnostic ignored "-Wnull-dereference"
#elif defined(__GNUC__)
# pragma GCC diagnostic push
# if __GNUC__ >= 6
# pragma GCC diagnostic ignored "-Wnull-dereference"
# endif
#endif

children_view siblings() { if(is_root()) { return children_view(end(), end()); } else { size_t p = get()->m_parent; return children_view(iterator(m_tree, m_tree->get(p)->m_first_child), iterator(m_tree, NONE)); } }
const_children_view siblings() const { if(is_root()) { return const_children_view(end(), end()); } else { size_t p = get()->m_parent; return const_children_view(const_iterator(m_tree, m_tree->get(p)->m_first_child), const_iterator(m_tree, NONE)); } }

#if defined(__clang__)
# pragma clang diagnostic pop
#elif defined(__GNUC__)
# pragma GCC diagnostic pop
#endif

public:

/** visit every child node calling fn(node) */
Expand Down

0 comments on commit f614500

Please sign in to comment.