From dc26b9780225fed5029e097b5a11537a05fcb0fa Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 27 Jul 2025 13:35:20 -0400 Subject: [PATCH] xo-reader: integer arithmetic + parser + pretty-printing adds --- include/xo/reflect/TypeDescr.hpp | 16 ++++++++++------ src/reflect/TypeDescr.cpp | 21 +++++++++++++++++++++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/include/xo/reflect/TypeDescr.hpp b/include/xo/reflect/TypeDescr.hpp index 57deb81..8896ed3 100644 --- a/include/xo/reflect/TypeDescr.hpp +++ b/include/xo/reflect/TypeDescr.hpp @@ -240,13 +240,13 @@ namespace xo { TypeDescrExtra * tdextra() const { return tdextra_.get(); } Metatype metatype() const { return tdextra_->metatype(); } - /* true iff the type represented by *this is the same as the type - * represented by T. + /** true iff the type represented by _c *this is the same as the type + * represented by @tparam T * - * Warning: comparing typeinfo address can give false negatives. - * suspect this is caused by problems coalescing linker symbols - * in the clang toolchain. - */ + * Warning: comparing typeinfo address can give false negatives. + * suspect this is caused by problems coalescing linker symbols + * in the clang toolchain. + **/ template [[deprecated]] bool is_native() const { @@ -317,6 +317,10 @@ namespace xo { } } /*recover_native2*/ + bool is_i128() const; + bool is_i64() const; + bool is_f64() const; + bool is_pointer() const { return this->tdextra_->is_pointer(); } bool is_vector() const { return this->tdextra_->is_vector(); } bool is_struct() const { return this->tdextra_->is_struct(); } diff --git a/src/reflect/TypeDescr.cpp b/src/reflect/TypeDescr.cpp index 4d04801..8b40678 100644 --- a/src/reflect/TypeDescr.cpp +++ b/src/reflect/TypeDescr.cpp @@ -254,6 +254,22 @@ namespace xo { { } + bool + TypeDescrBase::is_i64() const + { + static_assert(sizeof(long long) == 8); + + return Reflect::is_native(this); + } + + bool + TypeDescrBase::is_f64() const + { + static_assert(sizeof(double) == 8); + + return Reflect::is_native(this); + } + TaggedPtr TypeDescrBase::most_derived_self_tp(void * object) const { @@ -311,6 +327,11 @@ namespace xo { #endif TypeDescrTable::TypeDescrTable() { + /* want long == i64 */ + static_assert(sizeof(long) == 8); + /* want double == f64 */ + static_assert(sizeof(double) == 8); + Reflect::require(); Reflect::require(); Reflect::require();