Compare commits

...

3 Commits

Author SHA1 Message Date
kayomn 02d4d56f35 Rename kym::value::as_* functions to kym::value::to_*
continuous-integration/drone/push Build is passing Details
2023-02-22 21:03:24 +00:00
kayomn cf5ca23f94 Fix typo in coral::file_writer destructor 2023-02-22 21:02:42 +00:00
kayomn 9b06e7d2e2 Expose virtual destructors on coral::file_reader and coral::file_writer 2023-02-22 21:00:11 +00:00
3 changed files with 9 additions and 5 deletions

View File

@ -107,12 +107,16 @@ export namespace coral {
};
struct file_reader : public reader {
virtual ~file_reader() {}
virtual expected<u64, io_error> seek(u64 offset) = 0;
virtual expected<u64, io_error> tell() = 0;
};
struct file_writer : public writer {};
struct file_writer : public writer {
virtual ~file_writer() {}
};
/**
* Platform-generalized file system interface.

View File

@ -51,7 +51,7 @@ export namespace kym {
this->type = value_type::vector3;
}
coral::optional<coral::i64> as_integer() const {
coral::optional<coral::i64> to_integer() const {
if (this->type == value_type::integer)
return (*reinterpret_cast<coral::i64 const *>(&this->data));

View File

@ -39,7 +39,7 @@ extern "C" int main(int argc, char const * const * argv) {
vm.with_object(vm.compile(script_source.as_slice().as_chars()), [&](kym::bound_object & script) {
vm.with_object(script.call({}), [&](kym::bound_object & config) {
constexpr auto as_u16 = [](coral::i64 value) -> coral::optional<coral::i16> {
constexpr auto to_u16 = [](coral::i64 value) -> coral::optional<coral::i16> {
if ((value >= 0) && (value <= coral::u16_max))
return static_cast<coral::u16>(value);
@ -47,13 +47,13 @@ extern "C" int main(int argc, char const * const * argv) {
};
coral::u16 const width{config.get_field("width").
as_integer().map(as_u16).value_or(0)};
to_integer().map(to_u16).value_or(0)};
if (width == 0) return system.log(app::log_level::error,
"failed to decode `width` property of config");
coral::u16 const height{config.get_field("height").
as_integer().map(as_u16).value_or(0)};
to_integer().map(to_u16).value_or(0)};
if (height == 0) return system.log(app::log_level::error,
"failed to decode `height` property of config");