Skip to content

Commit

Permalink
formatting/updates/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipDeegan committed Nov 19, 2023
1 parent 51662eb commit f95f3e9
Show file tree
Hide file tree
Showing 80 changed files with 861 additions and 1,858 deletions.
3 changes: 3 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ IndentWidth: 2
BasedOnStyle: 'google'
ColumnLimit: 100
SortIncludes: false
UseTab: Never
DerivePointerAlignment: false
PointerAlignment: Left
6 changes: 3 additions & 3 deletions .github/workflows/build_nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:

- name: "Build/Test" # contains slash so use quotes otherwise UB
run: |
wget https://github.com/mkn/mkn/releases/download/latest/mkn_nix
chmod +x mkn_nix
KLOG=3 ./mkn_nix clean build run -dtOp test -a "-std=c++17 -fPIC"
curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_nix
chmod +x mkn
KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC"
6 changes: 3 additions & 3 deletions .github/workflows/build_osx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ jobs:

- name: "Build/Test" # contains slash so use quotes otherwise UB
run: |
wget https://github.com/mkn/mkn/releases/download/latest/mkn_osx
chmod +x mkn_osx
KLOG=3 ./mkn_osx clean build run -dtOp test -a "-std=c++17 -fPIC"
curl -Lo mkn https://github.com/mkn/mkn/releases/download/latest/mkn_osx
chmod +x mkn
KLOG=3 ./mkn clean build run -dtOp test -a "-std=c++17 -fPIC"
38 changes: 0 additions & 38 deletions .travis.yml

This file was deleted.

19 changes: 0 additions & 19 deletions appveyor.yml

This file was deleted.

45 changes: 15 additions & 30 deletions inc/mkn/kul/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,46 +36,31 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <numeric>
#include <algorithm>

#include "mkn/kul/span.hpp"

namespace mkn {
namespace kul {

#define PRINT_LINE() std::cout << __LINE__ << std::endl

namespace func {
template <typename...>
using check = void;
}

template <typename T, typename data_fn = void, typename size_fn = void>
struct is_span_like : std::false_type {};

template <typename T>
struct is_span_like<T, func::check<decltype(std::declval<T>().data())>,
func::check<decltype(std::declval<T>().size())>> : std::true_type {};

template <typename T>
auto constexpr is_span_like_v = is_span_like<T>::value;

template <typename Container, typename Function>
void for_each(Container& container, Function && function) {
void for_each(Container& container, Function&& function) {
std::for_each(std::begin(container), std::end(container), function);
}

template <typename Container, typename Function>
bool any_of(Container const& container, Function && function) {
bool any_of(Container const& container, Function&& function) {
return std::any_of(std::begin(container), std::end(container), function);
}
template <typename Container, typename Function>
bool any_of(Container && container, Function && function) {
bool any_of(Container&& container, Function&& function) {
return std::any_of(std::begin(container), std::end(container), function);
}

template <typename Container, typename Function>
bool all_of(Container const& container, Function && function) {
bool all_of(Container const& container, Function&& function) {
return std::all_of(std::begin(container), std::end(container), function);
}
template <typename Container, typename Function>
bool all_of(Container && container, Function && function) {
bool all_of(Container&& container, Function&& function) {
return all_of(container, function);
}

Expand All @@ -90,7 +75,7 @@ bool compare_to(T const& t, OP const& op, Args const&... args) {
return ((op(args, t)) && ...);
}
template <typename T, typename OP, typename... Args>
bool compare_to(T && t, OP && op, Args &&... args) {
bool compare_to(T&& t, OP&& op, Args&&... args) {
return compare_to(t, op, args...);
}

Expand All @@ -100,7 +85,7 @@ bool compare_to(T const& t, OP const& op, std::tuple<TupleElements...> const& tu
return std::apply([&](auto const&... args) { return compare_to(t, op, args...); }, tuple);
}
template <typename T, typename OP, typename... TupleElements>
bool compare_to(T && t, OP && op, std::tuple<TupleElements...> && tuple) {
bool compare_to(T&& t, OP&& op, std::tuple<TupleElements...>&& tuple) {
return compare_to(t, op, tuple);
}

Expand All @@ -114,7 +99,7 @@ class All {
return are(t, std::equal_to<T>{});
}
template <typename T>
bool operator==(T && t) {
bool operator==(T&& t) {
return are(t, std::equal_to<T>{});
}

Expand All @@ -123,7 +108,7 @@ class All {
return are(t, std::not_equal_to<T>{});
}
template <typename T>
bool operator!=(T && t) {
bool operator!=(T&& t) {
return are(t, std::not_equal_to<T>{});
}

Expand All @@ -132,7 +117,7 @@ class All {
return are(t, std::greater<T>{});
}
template <typename T>
bool operator>(T && t) {
bool operator>(T&& t) {
return are(t, std::greater<T>{});
}

Expand All @@ -141,7 +126,7 @@ class All {
return are(t, std::less<T>{});
}
template <typename T>
bool operator<(T && t) {
bool operator<(T&& t) {
return are(t, std::less<T>{});
}

Expand All @@ -150,7 +135,7 @@ class All {
return are(t, std::greater_equal<T>{});
}
template <typename T>
bool operator>=(T && t) {
bool operator>=(T&& t) {
return are(t, std::greater_equal<T>{});
}

Expand All @@ -159,7 +144,7 @@ class All {
return are(t, std::less_equal<T>{});
}
template <typename T>
bool operator<=(T && t) {
bool operator<=(T&& t) {
return are(t, std::less_equal<T>{});
}

Expand Down
8 changes: 3 additions & 5 deletions inc/mkn/kul/alloc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace mkn::kul {
template <typename T, std::int32_t alignment = 32>
class AlignedAllocator {
using This = AlignedAllocator<T, alignment>;

public:
using pointer = T*;
using reference = T&;
Expand Down Expand Up @@ -71,13 +72,10 @@ class AlignedAllocator {
deallocate(p);
}


bool operator!=(This const& that) const {
return !(*this == that);
}
bool operator!=(This const& that) const { return !(*this == that); }

bool operator==(This const& /*that*/) const {
return true; // stateless
return true; // stateless
}
};

Expand Down
39 changes: 22 additions & 17 deletions inc/mkn/kul/asio/log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ namespace log {

class Exception : public mkn::kul::Exception {
public:
Exception(char const *f, uint16_t const &l, std::string const &s) : mkn::kul::Exception(f, l, s) {}
Exception(char const* f, uint16_t const& l, std::string const& s)
: mkn::kul::Exception(f, l, s) {}
};
} // namespace log

Expand All @@ -51,20 +52,20 @@ class Logger : public mkn::kul::Logger {

private:
mkn::kul::ChroncurrentThreadPool<> ctp;
std::function<void(std::string const &)> defE, defO;
std::function<void(std::string const&)> defE, defO;

public:
Logger()
: ctp(1, 1),
defE([&](std::string const &s) { mkn::kul::Logger::err(s); }),
defO([&](std::string const &s) { mkn::kul::Logger::out(s); }) {}
void err(std::string const &s) override {
defE([&](std::string const& s) { mkn::kul::Logger::err(s); }),
defO([&](std::string const& s) { mkn::kul::Logger::out(s); }) {}
void err(std::string const& s) override {
if (e)
ctp.async(std::bind(e, s));
else
ctp.async(std::bind(defE, s));
}
void out(std::string const &s) override {
void out(std::string const& s) override {
if (o)
ctp.async(std::bind(o, s));
else
Expand All @@ -77,7 +78,7 @@ class LogMan : public mkn::kul::ALogMan {
LogMan() : ALogMan(new mkn::kul::asio::Logger()) {}

public:
static LogMan &INSTANCE() {
static LogMan& INSTANCE() {
static LogMan instance;
return instance;
};
Expand All @@ -86,40 +87,44 @@ class LogMan : public mkn::kul::ALogMan {
class Message {
protected:
std::stringstream ss;
const mkn::kul::log::mode &m;
const mkn::kul::log::mode& m;

Message(const mkn::kul::log::mode &_m) : m(_m) {}
Message(const mkn::kul::log::mode& _m) : m(_m) {}

public:
template <class T>
Message &operator<<(const T &s) {
Message& operator<<(const T& s) {
ss << s;
return *this;
}
};
class LogMessage : public Message {
public:
~LogMessage() { LogMan::INSTANCE().log(f, fn, l, m, ss.str()); }
LogMessage(char const *_f, char const *_fn, uint16_t const &_l, const mkn::kul::log::mode &_m)
LogMessage(char const* _f, char const* _fn, uint16_t const& _l, const mkn::kul::log::mode& _m)
: Message(_m), f(_f), fn(_fn), l(_l) {}

private:
char const *f, *fn;
uint16_t const &l;
uint16_t const& l;
};
struct OutMessage : public Message {
OutMessage(const mkn::kul::log::mode &_m = mkn::kul::log::mode::NON) : Message(_m) {}
OutMessage(const mkn::kul::log::mode& _m = mkn::kul::log::mode::NON) : Message(_m) {}
~OutMessage() { LogMan::INSTANCE().out(m, ss.str()); }
};
struct ErrMessage : public Message {
ErrMessage() : Message(mkn::kul::log::mode::ERR) {}
~ErrMessage() { LogMan::INSTANCE().err(ss.str()); }
};

#define KASIO_LOG_INF mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::INF)
#define KASIO_LOG_ERR mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::ERR)
#define KASIO_LOG_DBG mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::DBG)
#define KASIO_LOG_TRC mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::TRC)
#define KASIO_LOG_INF \
mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::INF)
#define KASIO_LOG_ERR \
mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::ERR)
#define KASIO_LOG_DBG \
mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::DBG)
#define KASIO_LOG_TRC \
mkn::kul::asio::LogMessage(__FILE__, __func__, __LINE__, mkn::kul::log::mode::TRC)
#define KASIO_LOG(sev) KLOG_##sev

#define KASIO_OUT_NON mkn::kul::asio::OutMessage()
Expand Down
2 changes: 1 addition & 1 deletion inc/mkn/kul/assert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace kul {
struct Assert {
template <typename T>
Assert(T t) {
(void) t;
(void)t;
#if !defined(NDEBUG)
if (!(t)) {
auto tid = mkn::kul::this_thread::id();
Expand Down
Loading

0 comments on commit f95f3e9

Please sign in to comment.