Skip to content

Commit

Permalink
preprocessor + CI cleanup
Browse files Browse the repository at this point in the history
also:
- minor refactors in path
- updated conformance tests
  • Loading branch information
marzer committed Jul 31, 2022
1 parent e2edd69 commit 501a80e
Show file tree
Hide file tree
Showing 28 changed files with 2,020 additions and 1,714 deletions.
20 changes: 16 additions & 4 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros:
- TOML_ABSTRACT_BASE
- TOML_ABSTRACT_INTERFACE
- TOML_CALLCONV
- TOML_CLOSED_ENUM
- TOML_CLOSED_FLAGS_ENUM
- TOML_EMPTY_BASES
- TOML_EXPORTED_CLASS
- TOML_FLAGS_ENUM
- TOML_LIKELY_CASE
- TOML_OPEN_ENUM
Expand Down Expand Up @@ -132,7 +133,6 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 1000000
PenaltyIndentedWhitespace: 0
PointerAlignment: Left
ReferenceAlignment: Left
ReflowComments: true
SortIncludes: false
SortJavaStaticImport: Before
Expand Down Expand Up @@ -161,6 +161,8 @@ SpaceBeforeSquareBrackets: false
BitFieldColonSpacing: Both
Standard: Latest
StatementMacros:
- __pragma
- _Pragma
- TOML_ALWAYS_INLINE
- TOML_API
- TOML_ATTR
Expand All @@ -177,6 +179,13 @@ StatementMacros:
- TOML_NEVER_INLINE
- TOML_NODISCARD
- TOML_NODISCARD_CTOR
- TOML_PRAGMA_CLANG
- TOML_PRAGMA_CLANG_GE_9
- TOML_PRAGMA_CLANG_GE_10
- TOML_PRAGMA_CLANG_GE_11
- TOML_PRAGMA_GCC
- TOML_PRAGMA_MSVC
- TOML_PRAGMA_ICC
- TOML_PURE_GETTER
- TOML_PURE_INLINE_GETTER
- TOML_RETURNS_BY_THROWING
Expand All @@ -190,13 +199,16 @@ WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- TOML_ATTR
- TOML_CONCAT
- TOML_HAS_INCLUDE
- TOML_LIKELY
- TOML_MAKE_RAW_STRING
- TOML_MAKE_STRING
- TOML_MAKE_STRING_VIEW
- TOML_PRAGMA_CLANG
- TOML_PRAGMA_CLANG_GE_9
- TOML_PRAGMA_CLANG_GE_10
- TOML_PRAGMA_CLANG_GE_11
- TOML_PRAGMA_GCC
- TOML_PRAGMA_MSVC
- TOML_PRAGMA_ICC
- TOML_UNLIKELY
...

53 changes: 46 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
clang_version: '14'
gcc_version: '11'

jobs:
linux:
strategy:
Expand All @@ -48,22 +52,56 @@ jobs:

runs-on: ubuntu-latest

defaults:
run:
shell: bash

steps:
- name: Install dependencies
- name: Install base dependencies
run: |
sudo apt -y update
if [ ${{ matrix.compiler }} = clang++ ]; then compiler=clang; else compiler=${{ matrix.compiler }}; fi
sudo apt -y install --no-install-recommends $compiler ${{ matrix.linker }} pkgconf git ca-certificates locales-all python3 python3-pip python3-setuptools python3-wheel ninja-build
sudo pip3 install --upgrade meson
sudo apt -y install --no-install-recommends ${{ matrix.linker }} git python3 python3-pip ninja-build locales-all
sudo -H pip3 install --no-cache-dir --upgrade meson
- uses: actions/checkout@v3

- name: Check toml.hpp
run: |
sudo pip3 install --upgrade --requirement tools/requirements.txt
cd tools
sudo -H pip3 install --upgrade --requirement ./requirements.txt
python3 ci_single_header_check.py
- name: Update LLVM package repository
if: ${{ startsWith(matrix.compiler, 'clang') || startsWith(matrix.linker, 'lld') }}
run: |
sudo apt -y install --no-install-recommends software-properties-common wget
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
codename=$(lsb_release -sc)
sudo add-apt-repository --yes --no-update "deb http://apt.llvm.org/${codename}/ llvm-toolchain-${codename}-${{ env.clang_version }} main"
sudo apt -y update
- name: Install clang
if: ${{ startsWith(matrix.compiler, 'clang') }}
run: |
sudo apt -y install --no-install-recommends clang-${{ env.clang_version }}
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${{ env.clang_version }} 1000
- name: Install g++
if: ${{ startsWith(matrix.compiler, 'g++') }}
run: |
sudo apt -y install --no-install-recommends g++-${{ env.gcc_version }}
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-${{ env.gcc_version }} 1000
- name: Install lld
if: ${{ startsWith(matrix.linker, 'lld') }}
run: |
sudo apt -y install --no-install-recommends lld-${{ env.clang_version }}
sudo update-alternatives --install /usr/bin/ld.lld ld.lld /usr/bin/ld.lld-${{ env.clang_version }} 1000
- name: Configure locales
run: |
sudo locale-gen 'en_US.utf8' 'ja_JP.utf8' 'de_DE.utf8' 'it_IT.utf8' 'tr_TR.utf8' 'fi_FI.utf8' 'fr_FR.utf8' 'zh_CN.utf8'
- name: Configure Meson
run: |
CXX=${{ matrix.compiler }} CXX_LD=${{ matrix.linker }} meson setup build --buildtype=${{ matrix.type }} -Dcompile_library=${{ matrix.compile_library }} -Dpedantic=true -Dbuild_tests=true -Dbuild_examples=true -Dgenerate_cmake_config=false -Db_lto=false -Dubsan_examples=true -Dasan_examples=true
Expand Down Expand Up @@ -97,7 +135,7 @@ jobs:
python3 -m pip install -U pip==21.3.1
pip3 install meson ninja
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: ilammy/msvc-dev-cmd@v1

Expand All @@ -114,13 +152,14 @@ jobs:
tipi-build-linux:
name: tipi.build project build and dependency resolution
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
container: tipibuild/tipi-ubuntu

env:
HOME: /root

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- run: mkdir -p ~/.tipi

# checking if the tomlplusplus project builds and passes tests
Expand Down
2 changes: 1 addition & 1 deletion cpp.hint
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#define TOML_ABI_NAMESPACE_BOOL(...) static_assert(true)
#define TOML_ABI_NAMESPACE_END static_assert(true)
#define TOML_ABSTRACT_BASE
#define TOML_ABSTRACT_INTERFACE
#define TOML_ALWAYS_INLINE inline
#define TOML_ANON_NAMESPACE_END static_assert(true)
#define TOML_ANON_NAMESPACE_START namespace
Expand Down
1 change: 1 addition & 0 deletions docs/poxy.toml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ string_literals = [ '_toml' ]
'(?:toml::)?node[_ ]views?' = 'classtoml_1_1node__view.html'
'(?:toml::)?parse[_ ]errors?' = 'classtoml_1_1parse__error.html'
'(?:toml::)?parse[_ ]results?' = 'classtoml_1_1parse__result.html'
'(?:toml::)?path[_ ]components?' = 'classtoml_1_1path__component.html'
'(?:toml::)?source[_ ]positions?' = 'structtoml_1_1source__position.html'
'(?:toml::)?source[_ ]regions?' = 'structtoml_1_1source__region.html'
'(?:toml::)?time[_ ]offsets?' = 'structtoml_1_1time__offset.html'
Expand Down
5 changes: 4 additions & 1 deletion include/toml++/impl/array.inl
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ TOML_NAMESPACE_START
return elems_.insert(pos, std::move(elem));
}

TOML_PURE_GETTER
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype) const noexcept
{
Expand All @@ -155,6 +156,7 @@ TOML_NAMESPACE_START
return true;
}

TOML_PURE_GETTER
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype, node * &first_nonmatch) noexcept
{
Expand All @@ -176,6 +178,7 @@ TOML_NAMESPACE_START
return true;
}

TOML_PURE_GETTER
TOML_EXTERNAL_LINKAGE
bool array::is_homogeneous(node_type ntype, const node*& first_nonmatch) const noexcept
{
Expand All @@ -188,7 +191,7 @@ TOML_NAMESPACE_START
TOML_EXTERNAL_LINKAGE
node& array::at(size_t index)
{
#if TOML_COMPILER_EXCEPTIONS
#if TOML_COMPILER_HAS_EXCEPTIONS

return *elems_.at(index);

Expand Down
2 changes: 1 addition & 1 deletion include/toml++/impl/json_formatter.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ TOML_NAMESPACE_START
: base{ &source, nullptr, constants, { flags, " "sv } }
{}

#if defined(DOXYGEN) || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
#if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)

/// \brief Constructs a JSON formatter and binds it to a toml::parse_result.
///
Expand Down
4 changes: 2 additions & 2 deletions include/toml++/impl/key.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,10 @@ TOML_NAMESPACE_START
/// \name Iteration
/// @{

/// A const iterator for iterating over the characters in the key.
/// \brief A const iterator for iterating over the characters in the key.
using const_iterator = const char*;

/// A const iterator for iterating over the characters in the key.
/// \brief A const iterator for iterating over the characters in the key.
using iterator = const_iterator;

/// \brief Returns an iterator to the first character in the key's backing string.
Expand Down
2 changes: 1 addition & 1 deletion include/toml++/impl/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ TOML_NAMESPACE_START
///
/// \detail A parsed TOML document forms a tree made up of tables, arrays and values.
/// This type is the base of each of those, providing a lot of the polymorphic plumbing.
class TOML_ABSTRACT_BASE TOML_EXPORTED_CLASS node
class TOML_ABSTRACT_INTERFACE TOML_EXPORTED_CLASS node
{
private:
/// \cond
Expand Down
1 change: 1 addition & 0 deletions include/toml++/impl/node.inl
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ TOML_NAMESPACE_END;

TOML_IMPL_NAMESPACE_START
{
TOML_PURE_GETTER
TOML_EXTERNAL_LINKAGE
bool TOML_CALLCONV node_deep_equality(const node* lhs, const node* rhs) noexcept
{
Expand Down
2 changes: 1 addition & 1 deletion include/toml++/impl/parse_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "print_to_stream.h"
#include "header_start.h"

#if defined(DOXYGEN) || !TOML_EXCEPTIONS
#if TOML_DOXYGEN || !TOML_EXCEPTIONS
#define TOML_PARSE_ERROR_BASE
#else
#define TOML_PARSE_ERROR_BASE : public std::runtime_error
Expand Down
6 changes: 5 additions & 1 deletion include/toml++/impl/parse_result.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once

#include "preprocessor.h"
#if defined(DOXYGEN) || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)
#if TOML_DOXYGEN || (TOML_ENABLE_PARSER && !TOML_EXCEPTIONS)

#include "table.h"
#include "parse_error.h"
Expand Down Expand Up @@ -170,6 +170,8 @@ TOML_NAMESPACE_START
/// @}

/// \name Successful parses
/// \warning It is undefined behaviour to call these functions when the result respresents a failed parse.
/// Check #failed(), #succeeded or #operator bool() to determine the result's state.
/// @{

/// \brief Returns the internal toml::table.
Expand Down Expand Up @@ -220,6 +222,8 @@ TOML_NAMESPACE_START
/// @}

/// \name Failed parses
/// \warning It is undefined behaviour to call these functions when the result respresents a successful parse.
/// Check #failed(), #succeeded or #operator bool() to determine the result's state.
/// @{

/// \brief Returns the internal toml::parse_error.
Expand Down
24 changes: 12 additions & 12 deletions include/toml++/impl/parser.inl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ TOML_ANON_NAMESPACE_START

public:
TOML_NODISCARD_CTOR
explicit utf8_byte_stream(std::istream& stream) noexcept(!TOML_COMPILER_EXCEPTIONS) //
explicit utf8_byte_stream(std::istream& stream) noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) //
: source_{ &stream }
{
if (!*this) // eof, bad
Expand Down Expand Up @@ -147,14 +147,14 @@ TOML_ANON_NAMESPACE_START
}

TOML_NODISCARD
bool peek_eof() const noexcept(!TOML_COMPILER_EXCEPTIONS)
bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
{
return eof() || source_->peek() == std::istream::traits_type::eof();
}

TOML_NODISCARD
TOML_ATTR(nonnull)
size_t operator()(void* dest, size_t num) noexcept(!TOML_COMPILER_EXCEPTIONS)
size_t operator()(void* dest, size_t num) noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
{
TOML_ASSERT(*this);

Expand Down Expand Up @@ -185,16 +185,16 @@ TOML_ANON_NAMESPACE_START
static_assert(std::is_trivial_v<utf8_codepoint>);
static_assert(std::is_standard_layout_v<utf8_codepoint>);

struct TOML_ABSTRACT_BASE utf8_reader_interface
struct TOML_ABSTRACT_INTERFACE utf8_reader_interface
{
TOML_NODISCARD
virtual const source_path_ptr& source_path() const noexcept = 0;

TOML_NODISCARD
virtual const utf8_codepoint* read_next() noexcept(!TOML_COMPILER_EXCEPTIONS) = 0;
virtual const utf8_codepoint* read_next() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) = 0;

TOML_NODISCARD
virtual bool peek_eof() const noexcept(!TOML_COMPILER_EXCEPTIONS) = 0;
virtual bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) = 0;

#if !TOML_EXCEPTIONS

Expand Down Expand Up @@ -257,7 +257,7 @@ TOML_ANON_NAMESPACE_START
optional<parse_error> err_;
#endif

bool read_next_block() noexcept(!TOML_COMPILER_EXCEPTIONS)
bool read_next_block() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
{
TOML_ASSERT(stream_);

Expand Down Expand Up @@ -435,7 +435,7 @@ TOML_ANON_NAMESPACE_START
}

TOML_NODISCARD
const utf8_codepoint* read_next() noexcept(!TOML_COMPILER_EXCEPTIONS) final
const utf8_codepoint* read_next() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) final
{
utf8_reader_error_check({});

Expand All @@ -454,7 +454,7 @@ TOML_ANON_NAMESPACE_START
}

TOML_NODISCARD
bool peek_eof() const noexcept(!TOML_COMPILER_EXCEPTIONS) final
bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS) final
{
return stream_.peek_eof();
}
Expand Down Expand Up @@ -521,7 +521,7 @@ TOML_ANON_NAMESPACE_START
}

TOML_NODISCARD
const utf8_codepoint* read_next() noexcept(!TOML_COMPILER_EXCEPTIONS)
const utf8_codepoint* read_next() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
{
utf8_buffered_reader_error_check({});

Expand Down Expand Up @@ -575,7 +575,7 @@ TOML_ANON_NAMESPACE_START
}

TOML_NODISCARD
bool peek_eof() const noexcept(!TOML_COMPILER_EXCEPTIONS)
bool peek_eof() const noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
{
return reader_.peek_eof();
}
Expand Down Expand Up @@ -2622,7 +2622,7 @@ TOML_IMPL_NAMESPACE_START
char32_t chars[utf8_buffered_reader::max_history_length];
size_t char_count = {}, advance_count = {};
bool eof_while_scanning = false;
const auto scan = [&]() noexcept(!TOML_COMPILER_EXCEPTIONS)
const auto scan = [&]() noexcept(!TOML_COMPILER_HAS_EXCEPTIONS)
{
if (is_eof())
return;
Expand Down
Loading

0 comments on commit 501a80e

Please sign in to comment.