compileable state with some struct renaming missing

fb-mini-snake
Claudius Holeksa 2023-01-03 18:45:30 +01:00
parent 59451d3a4c
commit a83826552e
8 changed files with 65 additions and 65 deletions

View File

@ -3,4 +3,4 @@ CheckOptions:
- { key: readability-identifier-naming.PrivateMemberSuffix, value: "_" }
- { key: readability-identifier-naming.ProtectedMemberSuffix, value: "_" }
- { key: readability-identifier-naming.ClassCase, value: "lower_case" }
- { key: readability-identifier-naming.StructCase, value: "CamelCase" }
- { key: readability-identifier-naming.StructCase, value: "lower_case" }

View File

@ -73,17 +73,17 @@ env.Alias('test', env.test_program)
# Clang format part
env.Append(BUILDERS={'ClangFormat' : Builder(action = 'clang-format --style=file -i $SOURCE')})
env.format_actions = []
env.format_actions = [];
def format_iter(env,files):
for f in files:
env.format_actions.append(env.AlwaysBuild(env.ClangFormat(target=f+"-clang-format",source=f)))
pass
env.Append(BUILDERS={'ClangTidy' : Builder(action = 'clang-tidy -extra-arg-before=-xc++ $SOURCE')})
env.tidy_actions = []
env.tidy_actions = [];
def tidy_iter(env,files):
string_of_files = "";
for f in files:
if(f != "/home/keldu/workspace/forstio/source/forstio/async.tmpl.h" and f != "/home/keldu/workspace/forstio/forstio/source/forstio/io_peer.tmpl.h" ):
if(f != "/home/keldu/workspace/forstio/forstio/source/forstio/async.tmpl.h" and f != "/home/keldu/workspace/forstio/forstio/source/forstio/io_peer.tmpl.h" ):
env.tidy_actions.append(env.AlwaysBuild(env.ClangTidy(target=f+"-clang-tidy",source=f)));
pass

View File

@ -310,13 +310,13 @@ template <> class conveyor_feeder<void> {
public:
virtual ~conveyor_feeder() = default;
virtual void feed(Void &&value = Void{}) = 0;
virtual void feed(void_t &&value = void_t{}) = 0;
virtual void fail(error &&error) = 0;
virtual size_t space() const = 0;
virtual size_t queued() const = 0;
virtual error swap(conveyor<Void> &&conveyor) noexcept = 0;
virtual error swap(conveyor<void_t> &&conveyor) noexcept = 0;
};
template <typename T> struct conveyor_and_feeder {
@ -477,25 +477,25 @@ template <typename Out, typename In> struct fix_void_caller {
}
};
template <typename Out> struct fix_void_caller<Out, Void> {
template <typename Func> static Out apply(Func &func, Void &&in) {
template <typename Out> struct fix_void_caller<Out, void_t> {
template <typename Func> static Out apply(Func &func, void_t &&in) {
(void)in;
return func();
}
};
template <typename In> struct fix_void_caller<Void, In> {
template <typename Func> static Void apply(Func &func, In &&in) {
template <typename In> struct fix_void_caller<void_t, In> {
template <typename Func> static void_t apply(Func &func, In &&in) {
func(std::move(in));
return Void{};
return void_t{};
}
};
template <> struct fix_void_caller<Void, Void> {
template <typename Func> static Void apply(Func &func, Void &&in) {
template <> struct fix_void_caller<void_t, void_t> {
template <typename Func> static void_t apply(Func &func, void_t &&in) {
(void)in;
func();
return Void{};
return void_t{};
}
};
@ -789,7 +789,7 @@ public:
// ConveyorNode
void get_result(error_or_value &err_or_val) noexcept override {
err_or_val.as<Void>() =
err_or_val.as<void_t>() =
critical_error("In a sink node no result can be returned");
}

View File

@ -60,14 +60,14 @@ template <typename Func> struct return_type_helper<Func, void> {
template <typename Func, typename T>
using return_type = typename return_type_helper<Func, T>::Type;
struct Void {};
struct void_t {};
template <typename T> struct void_fix { typedef T Type; };
template <> struct void_fix<void> { typedef Void Type; };
template <> struct void_fix<void> { typedef void_t Type; };
template <typename T> using fix_void = typename void_fix<T>::Type;
template <typename T> struct void_unfix { typedef T Type; };
template <> struct void_unfix<Void> { typedef void Type; };
template <> struct void_unfix<void_t> { typedef void Type; };
template <typename T> using unfix_void = typename void_unfix<T>::Type;
template <typename... T> constexpr bool always_false = false;

View File

@ -106,7 +106,7 @@ template <typename T> class error_or final : public error_or_value {
private:
std::variant<error, fix_void<T>> value_or_error_;
static_assert(!std::is_same_v<T, Void>, "Don't use internal private types");
static_assert(!std::is_same_v<T, void_t>, "Don't use internal private types");
public:
error_or() = default;

View File

@ -42,7 +42,7 @@ public:
*/
conveyor_feeder<HeapMessageRoot<Outgoing, OutContainer>> &feeder();
conveyor<void> onReadDisconnected();
conveyor<void> on_read_disconnected();
private:
/// @unimplemented

View File

@ -2,109 +2,109 @@ namespace saw {
template <typename Codec, typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
StreamingIoPeer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
StreamingIoPeer(
Own<ConveyorFeeder<HeapMessageRoot<Incoming, InContainer>>> feed,
Own<AsyncIoStream> str)
: StreamingIoPeer{std::move(feed), std::move(str), {}, {}, {}} {}
streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
streaming_io_peer(
own<conveyor_feeder<HeapMessageRoot<Incoming, InContainer>>> feed,
own<async_io_stream> str)
: streaming_io_peer{std::move(feed), std::move(str), {}, {}, {}} {}
template <typename Codec, typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
StreamingIoPeer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
StreamingIoPeer(
Own<ConveyorFeeder<HeapMessageRoot<Incoming, InContainer>>> feed,
Own<AsyncIoStream> stream, Codec codec, BufferT in, BufferT out)
streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer, BufferT>::
streaming_io_peer(
own<conveyor_feeder<HeapMessageRoot<Incoming, InContainer>>> feed,
own<async_io_stream> stream, Codec codec, BufferT in, BufferT out)
: incoming_feeder_{std::move(feed)},
io_stream_{std::move(stream)}, codec_{std::move(codec)},
in_buffer_{std::move(in)}, out_buffer_{std::move(out)},
sink_read_{io_stream_->readDone()
.then([this](size_t bytes) -> ErrorOr<void> {
in_buffer_.writeAdvance(bytes);
sink_read_{io_stream_->read_done()
.then([this](size_t bytes) -> error_or<void> {
in_buffer_.write_advance(bytes);
if (in_buffer_.writeSegmentLength() == 0) {
return criticalError("Message too long");
if (in_buffer_.write_segment_length() == 0) {
return critical_error("Message too long");
}
io_stream_->read(&in_buffer_.write(), 1,
in_buffer_.writeSegmentLength());
in_buffer_.write_segment_length());
while (true) {
auto root =
heapMessageRoot<Incoming, InContainer>();
auto builder = root.build();
Error error =
error err =
codec_.template decode<Incoming, InContainer>(
builder, in_buffer_);
if (error.isCritical()) {
return error;
if (err.is_critical()) {
return err;
}
if (!error.failed()) {
if (!err.failed()) {
incoming_feeder_->feed(std::move(root));
} else {
break;
}
}
return Void{};
return void_t{};
})
.sink([this](Error error) {
incoming_feeder_->fail(error.copyError());
.sink([this](error err) {
incoming_feeder_->fail(err.copy_error());
return error;
return err;
})},
sink_write_{io_stream_->writeDone()
.then([this](size_t bytes) -> ErrorOr<void> {
out_buffer_.readAdvance(bytes);
sink_write_{io_stream_->write_done()
.then([this](size_t bytes) -> error_or<void> {
out_buffer_.read_advance(bytes);
if (out_buffer_.readCompositeLength() > 0) {
io_stream_->write(
&out_buffer_.read(),
out_buffer_.readSegmentLength());
out_buffer_.read_segment_length());
}
return Void{};
return void_t{};
})
.sink()} {
io_stream_->read(&in_buffer_.write(), 1, in_buffer_.writeSegmentLength());
io_stream_->read(&in_buffer_.write(), 1, in_buffer_.write_segment_length());
}
template <typename Codec, typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
Error StreamingIoPeer<Codec, Incoming, Outgoing, InContainer, OutContainer,
error streaming_io_peer<Codec, Incoming, Outgoing, InContainer, OutContainer,
BufferT>::send(HeapMessageRoot<Outgoing, OutContainer>
msg) {
bool restart_write = out_buffer_.readSegmentLength() == 0;
bool restart_write = out_buffer_.read_segment_length() == 0;
Error error =
error err =
codec_.template encode<Outgoing, OutContainer>(msg.read(), out_buffer_);
if (error.failed()) {
return error;
if (err.failed()) {
return err;
}
if (restart_write) {
io_stream_->write(&out_buffer_.read(), out_buffer_.readSegmentLength());
io_stream_->write(&out_buffer_.read(), out_buffer_.read_segment_length());
}
return noError();
return no_error();
}
template <typename Codec, typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
Conveyor<void> StreamingIoPeer<Codec, Incoming, Outgoing, InContainer,
OutContainer, BufferT>::onReadDisconnected() {
return io_stream_->onReadDisconnected();
conveyor<void> streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
OutContainer, BufferT>::on_read_disconnected() {
return io_stream_->on_read_disconnected();
}
template <typename Codec, typename Incoming, typename Outgoing,
typename InContainer, typename OutContainer, typename BufferT>
std::pair<Own<StreamingIoPeer<Codec, Incoming, Outgoing, InContainer,
std::pair<own<streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
OutContainer, BufferT>>,
Conveyor<HeapMessageRoot<Incoming, InContainer>>>
newStreamingIoPeer(Own<AsyncIoStream> stream) {
auto caf = newConveyorAndFeeder<HeapMessageRoot<Incoming, InContainer>>();
conveyor<HeapMessageRoot<Incoming, InContainer>>>
newstreaming_io_peer(own<async_io_stream> stream) {
auto caf = newconveyorAndFeeder<HeapMessageRoot<Incoming, InContainer>>();
return {heap<StreamingIoPeer<Codec, Incoming, Outgoing, InContainer,
return {heap<streaming_io_peer<Codec, Incoming, Outgoing, InContainer,
OutContainer, BufferT>>(std::move(caf.feeder),
std::move(stream)),
std::move(caf.conveyor)};

View File

@ -193,7 +193,7 @@ conveyor<own<io_stream>> TlsNetwork::connect(network_address& address) {
hlp_ptr->setupTurn();
hlp_ptr->turn();
return Void{};
return void_t{};
});
helper->connection_sink = prim_conv.sink();