Rename kym::value::as_* functions to kym::value::to_*
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
cf5ca23f94
commit
02d4d56f35
|
@ -51,7 +51,7 @@ export namespace kym {
|
||||||
this->type = value_type::vector3;
|
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)
|
if (this->type == value_type::integer)
|
||||||
return (*reinterpret_cast<coral::i64 const *>(&this->data));
|
return (*reinterpret_cast<coral::i64 const *>(&this->data));
|
||||||
|
|
||||||
|
|
|
@ -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(vm.compile(script_source.as_slice().as_chars()), [&](kym::bound_object & script) {
|
||||||
vm.with_object(script.call({}), [&](kym::bound_object & config) {
|
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))
|
if ((value >= 0) && (value <= coral::u16_max))
|
||||||
return static_cast<coral::u16>(value);
|
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").
|
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,
|
if (width == 0) return system.log(app::log_level::error,
|
||||||
"failed to decode `width` property of config");
|
"failed to decode `width` property of config");
|
||||||
|
|
||||||
coral::u16 const height{config.get_field("height").
|
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,
|
if (height == 0) return system.log(app::log_level::error,
|
||||||
"failed to decode `height` property of config");
|
"failed to decode `height` property of config");
|
||||||
|
|
Loading…
Reference in New Issue