ona/source/turtle/io.cpp

55 lines
1.1 KiB
C++
Raw Normal View History

export module turtle.io;
import coral;
import coral.files;
import turtle;
export namespace turtle {
enum class log_level {
notice,
warning,
error,
};
struct event_loop {
void log(log_level level, coral::slice<char const> const & message) {
static_cast<void>(output().write(message.as_chars().as_bytes()));
static_cast<void>(output().write(coral::slice{"\n"}.as_bytes()));
}
bool poll() {
return false;
}
static int run(coral::path const & title, coral::closure<int(event_loop &)> execute) {
event_loop loop{title};
return execute(loop);
}
private:
coral::path title;
event_loop(coral::path const & title) {
this->title = title;
}
};
struct system_allocator : public coral::allocator {
system_allocator() = default;
// TODO: implement thread-safety.
coral::u8 * reallocate(coral::u8 * maybe_allocation, coral::usize requested_size) override {
if (maybe_allocation != nullptr) coral::unreachable();
return nullptr;
}
void deallocate(void * allocation) override {
if (allocation != nullptr) coral::unreachable();
}
};
};