diff options
Diffstat (limited to 'nihil.ucl/boolean.ccm')
| -rw-r--r-- | nihil.ucl/boolean.ccm | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/nihil.ucl/boolean.ccm b/nihil.ucl/boolean.ccm index db6c864..e9c161b 100644 --- a/nihil.ucl/boolean.ccm +++ b/nihil.ucl/boolean.ccm @@ -22,18 +22,30 @@ export struct boolean final : object { inline static constexpr object_type ucl_type = object_type::boolean; - boolean(value_type value) - : object(::ucl_object_frombool(value)) + // Create a new boolean from a UCL object. + boolean(ref_t, ::ucl_object_t const *uobj) + : object(nihil::ucl::ref, uobj) { - if (_object == nullptr) - throw error("failed to create UCL object"); + if (type() != ucl_type) + throw type_mismatch(ucl_type, type()); } - explicit boolean(::ucl_object_t *uobj) : object(uobj) + boolean(noref_t, ::ucl_object_t *uobj) + : object(noref, uobj) { - assert(type() == object_type::boolean); + if (type() != ucl_type) + throw type_mismatch(ucl_type, type()); + } + + // Create a new boolean from a value. + explicit boolean(value_type value) + : object(noref, ::ucl_object_frombool(value)) + { + if (_object == nullptr) + throw error("failed to create UCL object"); } + // Return this object's value. auto value(this boolean const &self) -> value_type { auto v = value_type{}; |
