this time the correct clang-format has been used

This commit is contained in:
keldu.magnus 2020-08-09 02:09:49 +02:00
parent 389c21b435
commit 9c87f9d9c8
8 changed files with 192 additions and 190 deletions

View File

@ -71,7 +71,7 @@ IncludeCategories:
IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: false
IndentPPDirectives: None
IndentWidth: 2
IndentWidth: 4
IndentWrappedFunctionNames: false
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
@ -116,6 +116,6 @@ StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: ForIndentation
UseTab: ForContinuationAndIndentation
...

View File

@ -12,95 +12,95 @@ Event::Event(EventLoop &loop) : loop{loop} {}
Event::~Event() { disarm(); }
void Event::armNext() {
assert(&loop == local_loop);
if (prev == nullptr) {
// Push the next_insert_point back by one
// and inserts itself before that
next = *loop.next_insert_point;
prev = loop.next_insert_point;
*prev = this;
if (next) {
next->prev = &next;
assert(&loop == local_loop);
if (prev == nullptr) {
// Push the next_insert_point back by one
// and inserts itself before that
next = *loop.next_insert_point;
prev = loop.next_insert_point;
*prev = this;
if (next) {
next->prev = &next;
}
// Set the new insertion ptr location to next
loop.next_insert_point = &next;
// Pushes back the later insert point if it was pointing at the
// previous event
if (loop.later_insert_point == prev) {
loop.later_insert_point = &next;
}
// If tail points at the same location then
// we are at the end and have to update tail then.
// Technically should be possible by checking if
// next is a `nullptr`
if (loop.tail == prev) {
loop.tail = &next;
}
loop.setRunnable(true);
}
// Set the new insertion ptr location to next
loop.next_insert_point = &next;
// Pushes back the later insert point if it was pointing at the
// previous event
if (loop.later_insert_point == prev) {
loop.later_insert_point = &next;
}
// If tail points at the same location then
// we are at the end and have to update tail then.
// Technically should be possible by checking if
// next is a `nullptr`
if (loop.tail == prev) {
loop.tail = &next;
}
loop.setRunnable(true);
}
}
void Event::armLater() {
assert(&loop == local_loop);
assert(&loop == local_loop);
if (prev == nullptr) {
next = *loop.later_insert_point;
prev = loop.later_insert_point;
*prev = this;
if (next) {
next->prev = &next;
if (prev == nullptr) {
next = *loop.later_insert_point;
prev = loop.later_insert_point;
*prev = this;
if (next) {
next->prev = &next;
}
loop.later_insert_point = &next;
if (loop.tail == prev) {
loop.tail = &next;
}
loop.setRunnable(true);
}
loop.later_insert_point = &next;
if (loop.tail == prev) {
loop.tail = &next;
}
loop.setRunnable(true);
}
}
void Event::armLast() {
assert(&loop == local_loop);
assert(&loop == local_loop);
if (prev == nullptr) {
next = *loop.later_insert_point;
prev = loop.later_insert_point;
*prev = this;
if (next) {
next->prev = &next;
if (prev == nullptr) {
next = *loop.later_insert_point;
prev = loop.later_insert_point;
*prev = this;
if (next) {
next->prev = &next;
}
if (loop.tail == prev) {
loop.tail = &next;
}
loop.setRunnable(true);
}
if (loop.tail == prev) {
loop.tail = &next;
}
loop.setRunnable(true);
}
}
void Event::disarm() {
if (!prev) {
if (loop.tail == &next) {
loop.tail = prev;
}
if (!prev) {
if (loop.tail == &next) {
loop.tail = prev;
}
if (loop.next_insert_point == &next) {
loop.next_insert_point = prev;
}
if (loop.next_insert_point == &next) {
loop.next_insert_point = prev;
}
*prev = next;
if (next) {
next->prev = prev;
}
*prev = next;
if (next) {
next->prev = prev;
}
prev = nullptr;
next = nullptr;
}
prev = nullptr;
next = nullptr;
}
}
void EventLoop::setRunnable(bool runnable) { is_runnable = runnable; }
@ -110,21 +110,21 @@ EventLoop::EventLoop() {}
EventLoop::~EventLoop() { assert(local_loop != this); }
void EventLoop::enterScope() {
assert(!local_loop);
local_loop = this;
assert(!local_loop);
local_loop = this;
}
void EventLoop::leaveScope() {
assert(local_loop == this);
local_loop = nullptr;
assert(local_loop == this);
local_loop = nullptr;
}
bool EventLoop::wait(const std::chrono::steady_clock::duration &duration) {
return false;
return false;
}
bool EventLoop::wait(const std::chrono::steady_clock::time_point &time_point) {
return false;
return false;
}
bool EventLoop::wait() { return false; }
@ -138,11 +138,11 @@ WaitScope::~WaitScope() { loop.leaveScope(); }
void WaitScope::wait() { loop.wait(); }
void WaitScope::wait(const std::chrono::steady_clock::duration &duration) {
loop.wait(duration);
loop.wait(duration);
}
void WaitScope::wait(const std::chrono::steady_clock::time_point &time_point) {
loop.wait(time_point);
loop.wait(time_point);
}
void WaitScope::poll() { loop.poll(); }

View File

@ -7,23 +7,23 @@
namespace gin {
class ConveyorNode {
public:
virtual ~ConveyorNode() = default;
public:
virtual ~ConveyorNode() = default;
};
class ConveyorBase {
private:
Own<ConveyorNode> node;
private:
Own<ConveyorNode> node;
public:
virtual ~ConveyorBase() = default;
public:
virtual ~ConveyorBase() = default;
};
template <typename Func, typename T> struct ReturnTypeHelper {
typedef decltype(instance<Func>()(instance<T>())) Type;
typedef decltype(instance<Func>()(instance<T>())) Type;
};
template <typename Func> struct ReturnTypeHelper<Func, void> {
typedef decltype(instance<Func>()()) Type;
typedef decltype(instance<Func>()()) Type;
};
template <typename Func, typename T>
@ -42,84 +42,84 @@ template <typename Func, typename T>
using ConveyorResult = ChainedConveyors<ReturnType<Func, T>>;
template <typename T> class Conveyor : public ConveyorBase {
private:
public:
template <typename Func, typename ErrorFunc>
ConveyorResult<Func, T> then(Func &&func, ErrorFunc &&error_func);
private:
public:
template <typename Func, typename ErrorFunc>
ConveyorResult<Func, T> then(Func &&func, ErrorFunc &&error_func);
};
class EventLoop;
class Event {
private:
EventLoop &loop;
Event **prev = nullptr;
Event *next = nullptr;
private:
EventLoop &loop;
Event **prev = nullptr;
Event *next = nullptr;
public:
Event(EventLoop &loop);
virtual ~Event();
public:
Event(EventLoop &loop);
virtual ~Event();
virtual void fire() = 0;
virtual void fire() = 0;
void armNext();
void armLater();
void armLast();
void disarm();
void armNext();
void armLater();
void armLast();
void disarm();
};
class EventLoop {
private:
friend class Event;
Event *head = nullptr;
Event **tail = &head;
Event **next_insert_point = &head;
Event **later_insert_point = &head;
private:
friend class Event;
Event *head = nullptr;
Event **tail = &head;
Event **next_insert_point = &head;
Event **later_insert_point = &head;
bool is_runnable = false;
bool is_runnable = false;
// functions
void setRunnable(bool runnable);
// functions
void setRunnable(bool runnable);
friend class WaitScope;
void enterScope();
void leaveScope();
friend class WaitScope;
void enterScope();
void leaveScope();
public:
EventLoop();
~EventLoop();
public:
EventLoop();
~EventLoop();
bool wait();
bool wait(const std::chrono::steady_clock::duration &);
bool wait(const std::chrono::steady_clock::time_point &);
bool poll();
bool wait();
bool wait(const std::chrono::steady_clock::duration &);
bool wait(const std::chrono::steady_clock::time_point &);
bool poll();
};
class WaitScope {
private:
EventLoop &loop;
private:
EventLoop &loop;
public:
WaitScope(EventLoop &loop);
~WaitScope();
public:
WaitScope(EventLoop &loop);
~WaitScope();
void wait();
void wait(const std::chrono::steady_clock::duration &);
void wait(const std::chrono::steady_clock::time_point &);
void poll();
void wait();
void wait(const std::chrono::steady_clock::duration &);
void wait(const std::chrono::steady_clock::time_point &);
void poll();
};
class InputConveyorNode : public ConveyorNode {
public:
public:
};
template <typename T> class ConvertConveyorNode : public ConveyorNode {};
template <typename T, size_t S>
class ArrayBufferConveyorNode : public ConveyorNode, public Event {
private:
std::array<T, S> storage;
private:
std::array<T, S> storage;
public:
public:
};
} // namespace gin
// Template inlining

Binary file not shown.

View File

@ -12,8 +12,8 @@ namespace gin {
#define GIN_UNIQUE_NAME(prefix) GIN_CONCAT(prefix, __LINE__)
#define GIN_FORBID_COPY(classname) \
classname(const classname &) = delete; \
classname &operator=(const classname &) = delete
classname(const classname &) = delete; \
classname &operator=(const classname &) = delete
template <typename T> using Maybe = std::optional<T>;
@ -24,11 +24,11 @@ template <typename T> using Our = std::shared_ptr<T>;
template <typename T> using Lent = std::weak_ptr<T>;
template <typename T, class... Args> Own<T> heap(Args &&... args) {
return std::make_unique<T>(std::forward<Args>(args)...);
return std::make_unique<T>(std::forward<Args>(args)...);
}
template <typename T, class... Args> Our<T> share(Args &&... args) {
return std::make_shared<T>(std::forward<Args>(args)...);
return std::make_shared<T>(std::forward<Args>(args)...);
}
struct Void {};

View File

@ -6,10 +6,10 @@ Error::Error() : error_{0} {}
Error::Error(const std::string &msg) : error_message{msg}, error_{1} {}
Error::Error(const std::string &msg, int8_t code)
: error_message{msg}, error_{code} {}
: error_message{msg}, error_{code} {}
Error::Error(const Error &error)
: error_message{error.error_message}, error_{error.error_} {}
: error_message{error.error_message}, error_{error.error_} {}
const std::string &Error::message() const { return error_message; }

View File

@ -5,21 +5,21 @@
namespace gin {
class Error {
private:
std::string error_message;
int8_t error_;
private:
std::string error_message;
int8_t error_;
public:
Error();
Error(const std::string &msg);
Error(const std::string &msg, int8_t code);
Error(const Error &error);
public:
Error();
Error(const std::string &msg);
Error(const std::string &msg, int8_t code);
Error(const Error &error);
const std::string &message() const;
bool failed() const;
const std::string &message() const;
bool failed() const;
bool isCritical() const;
bool isRecoverable() const;
bool isCritical() const;
bool isRecoverable() const;
};
Error criticalError(const std::string &msg);
@ -27,30 +27,32 @@ Error recoverableError(const std::string &msg);
Error noError();
class ErrorOrValue {
public:
virtual ~ErrorOrValue() = default;
public:
virtual ~ErrorOrValue() = default;
};
template <typename T> class ErrorOr : public ErrorOrValue {
private:
std::variant<T, Error> value_or_error;
private:
std::variant<T, Error> value_or_error;
public:
ErrorOr(const T &value) : value_or_error{value} {}
public:
ErrorOr(const T &value) : value_or_error{value} {}
ErrorOr(T &&value) : value_or_error{std::move(value)} {}
ErrorOr(T &&value) : value_or_error{std::move(value)} {}
ErrorOr(const Error &error) : value_or_error{error} {}
ErrorOr(Error &&error) : value_or_error{std::move(error)} {}
ErrorOr(const Error &error) : value_or_error{error} {}
ErrorOr(Error &&error) : value_or_error{std::move(error)} {}
bool isValue() const { return std::holds_alternative<T>(value_or_error); }
bool isValue() const { return std::holds_alternative<T>(value_or_error); }
bool isError() const { return std::holds_alternative<Error>(value_or_error); }
bool isError() const {
return std::holds_alternative<Error>(value_or_error);
}
const Error &error() const { return std::get<Error>(value_or_error); }
const Error &error() const { return std::get<Error>(value_or_error); }
T &value() { return std::get<T>(value_or_error); }
T &value() { return std::get<T>(value_or_error); }
const T &value() const { return std::get<T>(value_or_error); }
const T &value() const { return std::get<T>(value_or_error); }
};
} // namespace gin

View File

@ -5,32 +5,32 @@
namespace gin {
template <typename T, size_t M, size_t N> class Matrix {
private:
std::array<T, M * N> data;
private:
std::array<T, M * N> data;
public:
Matrix();
public:
Matrix();
T &operator()(size_t i, size_t j);
const T &operator()(size_t i, size_t j) const;
T &operator()(size_t i, size_t j);
const T &operator()(size_t i, size_t j) const;
template <size_t K>
Matrix<T, M, K> operator*(const Matrix<T, N, K> &rhs) const;
template <size_t K>
Matrix<T, M, K> operator*(const Matrix<T, N, K> &rhs) const;
Vector<T, M> operator*(const Vector<T, N> &rhs) const;
Vector<T, M> operator*(const Vector<T, N> &rhs) const;
};
template <typename T, size_t N> class Vector {
private:
std::array<T, N> data;
private:
std::array<T, N> data;
public:
Vector();
public:
Vector();
T operator*(const Vector<T, N> &rhs) const;
T operator*(const Vector<T, N> &rhs) const;
T &operator()(size_t i);
const T &operator()(size_t i) const;
T &operator()(size_t i);
const T &operator()(size_t i) const;
};
} // namespace gin
@ -38,12 +38,12 @@ namespace gin {
// column major is "i + j * M";
template <typename T, size_t M, size_t N>
T &Matrix<T, M, N>::operator()(size_t i, size_t j) {
assert(i < M && j < N);
return data[i * N + j];
assert(i < M && j < N);
return data[i * N + j];
}
template <typename T, size_t M, size_t N>
const T &Matrix<T, M, N>::operator()(size_t i, size_t j) const {
assert(i < M && j < N);
return data[i * N + j];
assert(i < M && j < N);
return data[i * N + j];
}
} // namespace gin