ona/source/turtle/io.cpp

52 lines
1.0 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 {
bool poll() {
return false;
}
2023-03-02 20:46:25 +00:00
static int run(coral::slice<char const> const & title, coral::closure<int(event_loop &)> execute) {
event_loop loop{title};
return execute(loop);
}
private:
2023-03-02 20:46:25 +00:00
static constexpr coral::usize title_max = 256;
coral::u8 title_buffer[256];
2023-03-02 20:46:25 +00:00
event_loop(coral::slice<char const> const & title) {
coral::copy(this->title_buffer, title.sliced(0, coral::min(title.length, title_max)).as_bytes());
}
};
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();
}
};
};