Skip to content

Commit 77feffb

Browse files
committed
update c4core post-rebase
1 parent ca742e3 commit 77feffb

30 files changed

+1001
-243
lines changed

.github/workflows/infra.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ jobs:
4343
echo "ERROR: generated workflows are out of date"
4444
fi
4545
exit $status
46+
make -C proj workflows-check || \
47+
( echo "ERROR: generated workflows are out of date" ; exit 1 )
4648
- name: check cmake presets
4749
run: |
4850
make -C proj presets-check || \

ext/c4core.dev/c4/enum.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
#define _C4_ENUM_HPP_
33

44
#include "c4/error.hpp"
5-
#include <cstddef>
5+
6+
#include <stddef.h>
67
#include <string.h>
8+
#include <type_traits>
79

810
/** @file enum.hpp utilities for enums: convert to/from string
911
*/
@@ -22,7 +24,7 @@ using is_scoped_enum = std::integral_constant<bool, std::is_enum<Enum>::value &&
2224
//-----------------------------------------------------------------------------
2325
//-----------------------------------------------------------------------------
2426

25-
typedef enum {
27+
typedef enum { // NOLINT(cert-int09-c,readability-enum-initial-value)
2628
EOFFS_NONE = 0, ///< no offset
2729
EOFFS_CLS = 1, ///< get the enum offset for the class name. @see eoffs_cls()
2830
EOFFS_PFX = 2, ///< get the enum offset for the enum prefix. @see eoffs_pfx()

ext/c4core.dev/c4/memory_resource.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ arealloc_pfn s_arealloc = nullptr;
2626
#else
2727

2828

29-
void afree_impl(void *ptr)
29+
void afree_impl(void *ptr) // NOLINT(misc-use-internal-linkage)
3030
{
3131
#if defined(C4_WIN) || defined(C4_XBOX)
3232
::_aligned_free(ptr);
@@ -36,7 +36,7 @@ void afree_impl(void *ptr)
3636
}
3737

3838

39-
void* aalloc_impl(size_t size, size_t alignment)
39+
void* aalloc_impl(size_t size, size_t alignment) // NOLINT(misc-use-internal-linkage)
4040
{
4141
// alignment must be nonzero and a power of 2
4242
C4_CHECK(alignment > 0 && (alignment & (alignment - 1u)) == 0);
@@ -77,7 +77,7 @@ void* aalloc_impl(size_t size, size_t alignment)
7777
}
7878

7979

80-
void* arealloc_impl(void* ptr, size_t oldsz, size_t newsz, size_t alignment)
80+
void* arealloc_impl(void* ptr, size_t oldsz, size_t newsz, size_t alignment) // NOLINT(misc-use-internal-linkage)
8181
{
8282
/** @todo make this more efficient
8383
* @see https://stackoverflow.com/questions/9078259/does-realloc-keep-the-memory-alignment-of-posix-memalign
@@ -97,9 +97,9 @@ void* arealloc_impl(void* ptr, size_t oldsz, size_t newsz, size_t alignment)
9797
return tmp;
9898
}
9999

100-
aalloc_pfn s_aalloc = aalloc_impl;
101-
afree_pfn s_afree = afree_impl;
102-
arealloc_pfn s_arealloc = arealloc_impl;
100+
aalloc_pfn s_aalloc = aalloc_impl; // NOLINT(misc-use-internal-linkage)
101+
afree_pfn s_afree = afree_impl; // NOLINT(misc-use-internal-linkage)
102+
arealloc_pfn s_arealloc = arealloc_impl; // NOLINT(misc-use-internal-linkage)
103103

104104
#endif // C4_NO_ALLOC_DEFAULTS
105105

ext/c4core.dev/c4/span.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH("-Wold-style-cast")
4343
* @see cspanrsl
4444
*/
4545
template<class T, class I, class SpanImpl>
46-
class span_crtp
46+
class span_crtp // NOLINT(*crtp-constructor-accessibility)
4747
{
4848
// some utility defines, undefined at the end of this class
4949
#define _c4this ((SpanImpl *)this)

ext/c4core.dev/c4/szconv.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "c4/error.hpp"
88

99
#include <limits>
10+
#include <type_traits>
1011

1112
namespace c4 {
1213

ext/c4core.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
C4CORE_REPO := https://github.com/biojppm/c4core
44
# must be tag or a FULL commit hash; cannot be a branch name.
5-
C4CORE_TAG := 1f2c1a87ba28344909ff4249d461d190c2dd5de1
5+
C4CORE_TAG := v0.2.10

ext/c4core.src.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ c4/memory_util.cpp
2222
c4/memory_util.hpp
2323
c4/platform.hpp
2424
c4/preprocessor.hpp
25+
c4/std/span_fwd.hpp
26+
c4/std/span.hpp
2527
c4/std/std.hpp
2628
c4/std/std_fwd.hpp
2729
c4/std/string.hpp

ext/c4core.src/c4/base64.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ constexpr static const char base64_char_to_sextet_[128] = {
7676
};
7777

7878
#ifndef NDEBUG
79-
void base64_test_tables()
79+
void base64_test_tables() // NOLINT(*use-internal-linkage*)
8080
{
8181
for(size_t i = 0; i < C4_COUNTOF(detail::base64_sextet_to_char_); ++i)
8282
{

ext/c4core.src/c4/charconv.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ C4_ALWAYS_INLINE bool read_dec(csubstr s, I *C4_RESTRICT v) noexcept
867867
{
868868
if(C4_UNLIKELY(c < '0' || c > '9'))
869869
return false;
870-
*v = (*v) * I(10) + (I(c) - I('0'));
870+
*v = ((*v) * I(10)) + (I(c) - I('0'));
871871
}
872872
return true;
873873
}
@@ -902,7 +902,7 @@ C4_ALWAYS_INLINE bool read_hex(csubstr s, I *C4_RESTRICT v) noexcept
902902
cv = I(10) + (I(c) - I('A'));
903903
else
904904
return false;
905-
*v = (*v) * I(16) + cv;
905+
*v = ((*v) * I(16)) + cv;
906906
}
907907
return true;
908908
}
@@ -960,7 +960,7 @@ C4_ALWAYS_INLINE bool read_oct(csubstr s, I *C4_RESTRICT v) noexcept
960960
{
961961
if(C4_UNLIKELY(c < '0' || c > '7'))
962962
return false;
963-
*v = (*v) * I(8) + (I(c) - I('0'));
963+
*v = ((*v) * I(8)) + (I(c) - I('0'));
964964
}
965965
return true;
966966
}
@@ -1974,11 +1974,11 @@ C4_ALWAYS_INLINE bool scan_rhex(csubstr s, T *C4_RESTRICT val) noexcept
19741974
{
19751975
const char c = s.str[pos];
19761976
if(c >= '0' && c <= '9')
1977-
*val = *val * T(16) + T(c - '0');
1977+
*val = (*val * T(16)) + T(c - '0');
19781978
else if(c >= 'a' && c <= 'f')
1979-
*val = *val * T(16) + T(c - 'a');
1979+
*val = (*val * T(16)) + T(c - 'a');
19801980
else if(c >= 'A' && c <= 'F')
1981-
*val = *val * T(16) + T(c - 'A');
1981+
*val = (*val * T(16)) + T(c - 'A');
19821982
else if(c == '.')
19831983
{
19841984
++pos;
@@ -2179,7 +2179,11 @@ C4_ALWAYS_INLINE bool atod(csubstr str, double * C4_RESTRICT v) noexcept
21792179
if(!(rem.len >= 2 && (rem.str[0] == '0' && (rem.str[1] == 'x' || rem.str[1] == 'X'))))
21802180
{
21812181
fast_float::from_chars_result result;
2182+
#ifndef CLANG_TIDY // suppress a false-positive error (cannot be done with NOLINT: https://stackoverflow.com/questions/62838193/ )
21822183
result = fast_float::from_chars(str.str, str.str + str.len, *v);
2184+
#else
2185+
result = {};
2186+
#endif
21832187
return result.ec == std::errc();
21842188
}
21852189
else if(detail::scan_rhex(rem.sub(2), v))

ext/c4core.src/c4/dump.hpp

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#define C4_DUMP_HPP_
33

44
#include <c4/substr.hpp>
5+
#include <utility> // for std::forward
6+
57

68
/** @file dump.hpp This file provides functions to dump several
79
* arguments as strings to a user-provided function sink, for example
@@ -52,29 +54,24 @@ C4_SUPPRESS_WARNING_GCC_CLANG_WITH_PUSH("-Wold-style-cast")
5254
using SinkPfn = void (*)(csubstr str);
5355

5456

55-
/** a traits class to use in SFINAE with @ref c4::dump() to select if
56-
* a type is treated as string type (which is dumped directly to the
57-
* sink, using to_csubstr()), or if the type is treated as a value,
58-
* which is first serialized to a buffer using to_chars(), and then
59-
* the serialization serialized as */
60-
template<class T> struct dump_directly : public std::false_type {};
61-
template<> struct dump_directly<csubstr> : public std::true_type {};
62-
template<> struct dump_directly< substr> : public std::true_type {};
63-
template<> struct dump_directly<const char*> : public std::true_type {};
64-
template<> struct dump_directly< char*> : public std::true_type {};
65-
template<size_t N> struct dump_directly<const char (&)[N]> : public std::true_type {};
66-
template<size_t N> struct dump_directly< char (&)[N]> : public std::true_type {};
67-
template<size_t N> struct dump_directly<const char[N]> : public std::true_type {};
68-
template<size_t N> struct dump_directly< char[N]> : public std::true_type {};
57+
template<class T> struct is_string; // fwd-decl
58+
59+
/** a traits class used by @ref c4::dump() to decide whether a type is
60+
* treated as a string type (which is dumped directly to the sink via
61+
* to_csubstr()), or if the type is treated as a value, which is first
62+
* serialized to the dump buffer using to_chars() prior to dumping it
63+
* to the sink. This type defaults to @ref c4::is_string, but can be
64+
* overriden independently. */
65+
template<class T> struct dump_directly : public is_string<T> {};
6966

7067

7168
#if (C4_CPP >= 17) || defined(__DOXYGEN__)
7269
/** Dump a serializable object to the (statically dispatched)
7370
* sink. Before dumping, the object may be serialized to a string if
7471
* @ref c4::dump_directly<Arg> is a false type (the default if
7572
* dump_directly does not have a specialization). Otherwise the object
76-
* is considered a string object is dumped directly, without any
77-
* intermediate serialization.
73+
* is considered a string object and is therefore dumped directly,
74+
* without any intermediate serialization.
7875
*
7976
* @return the number of bytes needed to serialize the string-type
8077
* object, which may be 0 when there is no serialization
@@ -97,10 +94,11 @@ size_t dump(substr buf, Arg const& a)
9794
{
9895
if constexpr (dump_directly<Arg>::value)
9996
{
100-
C4_ASSERT(!buf.overlaps(a));
10197
C4_UNUSED(buf);
98+
csubstr sa = to_csubstr(a);
99+
C4_ASSERT(!buf.overlaps(sa));
102100
// dump directly, no need to serialize to the buffer
103-
sinkfn(to_csubstr(a));
101+
sinkfn(sa);
104102
return 0; // no space was used in the buffer
105103
}
106104
else
@@ -151,9 +149,10 @@ size_t dump(SinkFn &&sinkfn, substr buf, Arg const& a)
151149
if constexpr (dump_directly<Arg>::value)
152150
{
153151
C4_UNUSED(buf);
154-
C4_ASSERT(!buf.overlaps(a));
152+
csubstr sa = to_csubstr(a);
153+
C4_ASSERT(!buf.overlaps(sa));
155154
// dump directly, no need to serialize to the buffer
156-
std::forward<SinkFn>(sinkfn)(to_csubstr(a));
155+
std::forward<SinkFn>(sinkfn)(sa);
157156
return 0; // no space was used in the buffer
158157
}
159158
else
@@ -181,20 +180,22 @@ template<SinkPfn sinkfn, class Arg>
181180
inline auto dump(substr buf, Arg const& a)
182181
-> typename std::enable_if<dump_directly<Arg>::value, size_t>::type
183182
{
184-
C4_ASSERT(!buf.overlaps(a));
185183
C4_UNUSED(buf);
184+
csubstr sa = to_csubstr(a);
185+
C4_ASSERT(!buf.overlaps(sa));
186186
// dump directly, no need to serialize to the buffer
187-
sinkfn(to_csubstr(a));
187+
sinkfn(sa);
188188
return 0; // no space was used in the buffer
189189
}
190190
template<class SinkFn, class Arg>
191191
inline auto dump(SinkFn &&sinkfn, substr buf, Arg const& a)
192192
-> typename std::enable_if<dump_directly<Arg>::value, size_t>::type
193193
{
194194
C4_UNUSED(buf);
195-
C4_ASSERT(!buf.overlaps(a));
195+
csubstr sa = to_csubstr(a);
196+
C4_ASSERT(!buf.overlaps(sa));
196197
// dump directly, no need to serialize to the buffer
197-
std::forward<SinkFn>(sinkfn)(to_csubstr(a));
198+
std::forward<SinkFn>(sinkfn)(sa);
198199
return 0; // no space was used in the buffer
199200
}
200201

0 commit comments

Comments
 (0)