From 6be9037f100b7646dc359003600a4ef6faae04ae Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 6 Oct 2023 16:53:47 -0400 Subject: [PATCH] reflect: insert xo/ subdir into include path --- include/{ => xo}/reflect/CMakeLists.txt | 0 .../{ => xo}/reflect/EstablishTypeDescr.hpp | 38 ++++---- include/{ => xo}/reflect/Metatype.hpp | 0 include/{ => xo}/reflect/Reflect.hpp | 62 ++++++------- include/{ => xo}/reflect/SelfTagging.hpp | 6 +- include/{ => xo}/reflect/StructReflector.hpp | 90 +++++++++---------- include/{ => xo}/reflect/TaggedPtr.hpp | 3 +- include/{ => xo}/reflect/TaggedRcptr.hpp | 50 +++++------ include/{ => xo}/reflect/TypeDescr.hpp | 2 +- include/{ => xo}/reflect/TypeDescrExtra.hpp | 2 +- include/{ => xo}/reflect/TypeDrivenMap.hpp | 0 include/{ => xo}/reflect/atomic/AtomicTdx.hpp | 2 +- include/{ => xo}/reflect/init_reflect.hpp | 0 .../{ => xo}/reflect/pointer/PointerTdx.hpp | 4 +- .../{ => xo}/reflect/struct/StructMember.hpp | 29 +++--- include/{ => xo}/reflect/struct/StructTdx.hpp | 7 +- include/{ => xo}/reflect/vector/VectorTdx.hpp | 34 ++++--- utest/StructReflector.test.cpp | 8 +- utest/StructTdx.test.cpp | 2 +- utest/VectorTdx.test.cpp | 10 +-- 20 files changed, 172 insertions(+), 177 deletions(-) rename include/{ => xo}/reflect/CMakeLists.txt (100%) rename include/{ => xo}/reflect/EstablishTypeDescr.hpp (60%) rename include/{ => xo}/reflect/Metatype.hpp (100%) rename include/{ => xo}/reflect/Reflect.hpp (84%) rename include/{ => xo}/reflect/SelfTagging.hpp (88%) rename include/{ => xo}/reflect/StructReflector.hpp (64%) rename include/{ => xo}/reflect/TaggedPtr.hpp (98%) rename include/{ => xo}/reflect/TaggedRcptr.hpp (67%) rename include/{ => xo}/reflect/TypeDescr.hpp (99%) rename include/{ => xo}/reflect/TypeDescrExtra.hpp (98%) rename include/{ => xo}/reflect/TypeDrivenMap.hpp (100%) rename include/{ => xo}/reflect/atomic/AtomicTdx.hpp (96%) rename include/{ => xo}/reflect/init_reflect.hpp (100%) rename include/{ => xo}/reflect/pointer/PointerTdx.hpp (96%) rename include/{ => xo}/reflect/struct/StructMember.hpp (92%) rename include/{ => xo}/reflect/struct/StructTdx.hpp (95%) rename include/{ => xo}/reflect/vector/VectorTdx.hpp (75%) diff --git a/include/reflect/CMakeLists.txt b/include/xo/reflect/CMakeLists.txt similarity index 100% rename from include/reflect/CMakeLists.txt rename to include/xo/reflect/CMakeLists.txt diff --git a/include/reflect/EstablishTypeDescr.hpp b/include/xo/reflect/EstablishTypeDescr.hpp similarity index 60% rename from include/reflect/EstablishTypeDescr.hpp rename to include/xo/reflect/EstablishTypeDescr.hpp index 2b0e25a..32e546d 100644 --- a/include/reflect/EstablishTypeDescr.hpp +++ b/include/xo/reflect/EstablishTypeDescr.hpp @@ -5,8 +5,8 @@ #pragma once -#include "reflect/TypeDescr.hpp" -#include "reflect/TaggedPtr.hpp" +#include "TypeDescr.hpp" +#include "TaggedPtr.hpp" namespace xo { namespace reflect { @@ -26,28 +26,28 @@ namespace xo { template static TypeDescrW establish() { - TypeDescrW td = TypeDescrBase::require(&typeid(T), - type_name(), - nullptr); + TypeDescrW td = TypeDescrBase::require(&typeid(T), + type_name(), + nullptr); #ifdef NOT_USING - std::function to_self_tp; + std::function to_self_tp; - if (std::is_base_of_v) { - /* T is a descendant of SelfTagging (or T = SelfTagging); - * use SelfTagging.self_tp() - */ - to_self_tp = [](void * x) { return reinterpret_cast(x)->self_tp(); }; - } else { - /* T is not a descendant of SelfTagging. - * want to return - */ - to_self_tp = [td](void * x) { return TaggedPtr(td, x); }; - } + if (std::is_base_of_v) { + /* T is a descendant of SelfTagging (or T = SelfTagging); + * use SelfTagging.self_tp() + */ + to_self_tp = [](void * x) { return reinterpret_cast(x)->self_tp(); }; + } else { + /* T is not a descendant of SelfTagging. + * want to return + */ + to_self_tp = [td](void * x) { return TaggedPtr(td, x); }; + } - td->assign_to_self_tp(to_self_tp); + td->assign_to_self_tp(to_self_tp); #endif - return td; + return td; } }; /*EstablishTypeDescr*/ diff --git a/include/reflect/Metatype.hpp b/include/xo/reflect/Metatype.hpp similarity index 100% rename from include/reflect/Metatype.hpp rename to include/xo/reflect/Metatype.hpp diff --git a/include/reflect/Reflect.hpp b/include/xo/reflect/Reflect.hpp similarity index 84% rename from include/reflect/Reflect.hpp rename to include/xo/reflect/Reflect.hpp index 73ef68f..a6e6fe5 100644 --- a/include/reflect/Reflect.hpp +++ b/include/xo/reflect/Reflect.hpp @@ -5,12 +5,12 @@ #pragma once -#include "reflect/SelfTagging.hpp" -#include "reflect/EstablishTypeDescr.hpp" -#include "reflect/atomic/AtomicTdx.hpp" -#include "reflect/pointer/PointerTdx.hpp" -#include "reflect/vector/VectorTdx.hpp" -#include "reflect/struct/StructTdx.hpp" +#include "SelfTagging.hpp" +#include "EstablishTypeDescr.hpp" +#include "atomic/AtomicTdx.hpp" +#include "pointer/PointerTdx.hpp" +#include "vector/VectorTdx.hpp" +#include "struct/StructTdx.hpp" #include "refcnt/Refcounted.hpp" #include #include @@ -22,7 +22,7 @@ namespace xo { class EstablishTdx { public: static std::unique_ptr make() { return AtomicTdx::make(); } - }; /*EstablishTdx*/ + }; /*EstablishTdx*/ // ----- xo::ref::rp ----- @@ -34,7 +34,7 @@ namespace xo { }; /*EstablishTdx*/ // ----- std::array ----- - + /* definition provide after decl for Reflect {} below */ template class EstablishTdx> { @@ -73,11 +73,11 @@ namespace xo { class TaggedPtrMaker { public: static TaggedPtr make_tp(SelfTagging * x) { - return x->self_tp(); + return x->self_tp(); } /*make_tp*/ static TaggedRcptr make_rctp(SelfTagging * x) { - return x->self_tp(); + return x->self_tp(); } /*make_rctp*/ }; /*TaggedPtrMaker*/ @@ -113,35 +113,35 @@ namespace xo { * implemented in specialized header (like [reflect/struct/VectorTdx.hpp]) to * refer to reflection info for T without having to pull in all the * headers needed to properly reflect T (like this [reflect/Reflect.hpp]) - * + * */ template static TypeDescrW require() { - TypeDescrW retval_td = EstablishTypeDescr::establish(); + TypeDescrW retval_td = EstablishTypeDescr::establish(); - /* mark TypeDescr for T as complete (even though it isn't quite yet), - * so that when we encounter recursive types, reflection terminates. - * For example consider type resulting from code like - * - * typename T; - * using T = std::vector; - * - */ - if (retval_td->mark_complete()) { - /* control here on 2nd+later calls to require(). - * in principle can immediately short-circuit. - */ - } else { - /* control comes here the first time require() runs */ + /* mark TypeDescr for T as complete (even though it isn't quite yet), + * so that when we encounter recursive types, reflection terminates. + * For example consider type resulting from code like + * + * typename T; + * using T = std::vector; + * + */ + if (retval_td->mark_complete()) { + /* control here on 2nd+later calls to require(). + * in principle can immediately short-circuit. + */ + } else { + /* control comes here the first time require() runs */ - auto final_tdx = EstablishTdx::make(); + auto final_tdx = EstablishTdx::make(); - retval_td->assign_tdextra(std::move(final_tdx)); + retval_td->assign_tdextra(std::move(final_tdx)); - /* also need to require for each child */ - } + /* also need to require for each child */ + } - return retval_td; + return retval_td; } /*require*/ /* Use: diff --git a/include/reflect/SelfTagging.hpp b/include/xo/reflect/SelfTagging.hpp similarity index 88% rename from include/reflect/SelfTagging.hpp rename to include/xo/reflect/SelfTagging.hpp index 29517e3..e188b5c 100644 --- a/include/reflect/SelfTagging.hpp +++ b/include/xo/reflect/SelfTagging.hpp @@ -5,9 +5,9 @@ #pragma once -#include "refcnt/Refcounted.hpp" -#include "reflect/TypeDescr.hpp" -#include "reflect/TaggedRcptr.hpp" +#include "Refcounted.hpp" +#include "TypeDescr.hpp" +#include "TaggedRcptr.hpp" namespace xo { namespace reflect { diff --git a/include/reflect/StructReflector.hpp b/include/xo/reflect/StructReflector.hpp similarity index 64% rename from include/reflect/StructReflector.hpp rename to include/xo/reflect/StructReflector.hpp index f223757..750b866 100644 --- a/include/reflect/StructReflector.hpp +++ b/include/xo/reflect/StructReflector.hpp @@ -2,10 +2,10 @@ #pragma once -#include "reflect/Reflect.hpp" -#include "reflect/TypeDescr.hpp" -#include "reflect/struct/StructMember.hpp" -#include "reflect/struct/StructTdx.hpp" +#include "Reflect.hpp" +#include "TypeDescr.hpp" +#include "struct/StructMember.hpp" +#include "struct/StructTdx.hpp" #include namespace xo { @@ -16,7 +16,7 @@ namespace xo { template struct SelfTagger { static TaggedPtr self_tp(void * object) { - return (reinterpret_cast(object))->self_tp(); + return (reinterpret_cast(object))->self_tp(); } }; @@ -35,7 +35,7 @@ namespace xo { * REFLECT_LITERAL_MEMBER(sr, y_); * * // optional: regardless, reflection will be completed when sr goes out of scope - * sr.require_complete(); + * sr.require_complete(); */ template class StructReflector { @@ -45,68 +45,68 @@ namespace xo { public: StructReflector() : td_{EstablishTypeDescr::establish()} {} ~StructReflector() { - this->require_complete(); + this->require_complete(); } - + bool is_complete() const { return s_reflected_flag; } bool is_incomplete() const { return !s_reflected_flag; } template void reflect_member(std::string const & member_name, - MemberT OwnerT::* member_addr) { + MemberT OwnerT::* member_addr) { - auto accessor - (GeneralStructMemberAccessor::make(member_addr)); + auto accessor + (GeneralStructMemberAccessor::make(member_addr)); - /* used to do this in GeneralStructMemberAccessor<> ctor, - * but that introduces #include cycle - */ - Reflect::require(); + /* used to do this in GeneralStructMemberAccessor<> ctor, + * but that introduces #include cycle + */ + Reflect::require(); - this->member_v_.emplace_back(member_name, std::move(accessor)); + this->member_v_.emplace_back(member_name, std::move(accessor)); } /*reflect_member*/ void require_complete() { - if(!s_reflected_flag) { - s_reflected_flag = true; + if(!s_reflected_flag) { + s_reflected_flag = true; - constexpr bool have_to_self_tp = std::is_base_of_v; + constexpr bool have_to_self_tp = std::is_base_of_v; - /* if self-tagging, can use .self_tp() to get most-derived tagged pointer */ - auto to_self_tp_fn - = ([](void * object) - { - return SelfTagger::self_tp(object); - }); + /* if self-tagging, can use .self_tp() to get most-derived tagged pointer */ + auto to_self_tp_fn + = ([](void * object) + { + return SelfTagger::self_tp(object); + }); - auto tdx = StructTdx::make(std::move(this->member_v_), - have_to_self_tp, - to_self_tp_fn); + auto tdx = StructTdx::make(std::move(this->member_v_), + have_to_self_tp, + to_self_tp_fn); - this->td_->assign_tdextra(std::move(tdx)); - } + this->td_->assign_tdextra(std::move(tdx)); + } } /*complete*/ - + template void adopt_ancestors() { - assert(Reflect::is_reflected()); + assert(Reflect::is_reflected()); - TypeDescr ancestor_td = Reflect::require(); + TypeDescr ancestor_td = Reflect::require(); - /* requires that reflection of AncestorT has completed */ - { - assert(ancestor_td->is_struct()); - assert(ancestor_td->complete_flag()); - } + /* requires that reflection of AncestorT has completed */ + { + assert(ancestor_td->is_struct()); + assert(ancestor_td->complete_flag()); + } - /* for structs, - * we know that object argument to TypeDescr::n_child() is unused - */ - for (uint32_t i = 0, n = ancestor_td->n_child(nullptr); i < n; ++i) { - StructMember const & member = ancestor_td->struct_member(i); + /* for structs, + * we know that object argument to TypeDescr::n_child() is unused + */ + for (uint32_t i = 0, n = ancestor_td->n_child(nullptr); i < n; ++i) { + StructMember const & member = ancestor_td->struct_member(i); - this->member_v_.push_back(member.for_descendant()); - } + this->member_v_.push_back(member.for_descendant()); + } } /*adopt_ancestors*/ private: diff --git a/include/reflect/TaggedPtr.hpp b/include/xo/reflect/TaggedPtr.hpp similarity index 98% rename from include/reflect/TaggedPtr.hpp rename to include/xo/reflect/TaggedPtr.hpp index 610cb00..7bb520a 100644 --- a/include/reflect/TaggedPtr.hpp +++ b/include/xo/reflect/TaggedPtr.hpp @@ -2,8 +2,7 @@ #pragma once -#include "reflect/TypeDescr.hpp" -//#include "reflect/EstablishTypeDescr.hpp" +#include "TypeDescr.hpp" #include namespace xo { diff --git a/include/reflect/TaggedRcptr.hpp b/include/xo/reflect/TaggedRcptr.hpp similarity index 67% rename from include/reflect/TaggedRcptr.hpp rename to include/xo/reflect/TaggedRcptr.hpp index 9ca8b15..e31cffb 100644 --- a/include/reflect/TaggedRcptr.hpp +++ b/include/xo/reflect/TaggedRcptr.hpp @@ -5,7 +5,7 @@ #pragma once -#include "reflect/TaggedPtr.hpp" +#include "TaggedPtr.hpp" // causes #include cycle, reflect/Reflect.hpp includes this header //#include "reflect/Reflect.hpp" #include "refcnt/Refcounted.hpp" @@ -20,22 +20,22 @@ namespace xo { class TaggedRcptr : public TaggedPtr { public: using Refcount = ref::Refcount; - + public: TaggedRcptr(TypeDescr td, Refcount * x) : TaggedPtr(td, x) { - ref::intrusive_ptr_add_ref(x); + ref::intrusive_ptr_add_ref(x); } TaggedRcptr(TaggedRcptr const & x) : TaggedPtr(x) { - ref::intrusive_ptr_add_ref(x.rc_address()); + ref::intrusive_ptr_add_ref(x.rc_address()); } TaggedRcptr(TaggedRcptr && x) : TaggedPtr(std::move(x)) { - /* since we're moving from x, need to make sure x.dtor - * doesn't decrement refcount - */ - x.assign_address(nullptr); + /* since we're moving from x, need to make sure x.dtor + * doesn't decrement refcount + */ + x.assign_address(nullptr); } ~TaggedRcptr() { - ref::intrusive_ptr_release(this->rc_address()); + ref::intrusive_ptr_release(this->rc_address()); } /* causes #include cycle, see [reflect/Reflect.hpp] */ @@ -46,37 +46,37 @@ namespace xo { #endif Refcount * rc_address() const { - return reinterpret_cast(this->address()); + return reinterpret_cast(this->address()); } /*rc_address*/ TaggedRcptr & operator=(TaggedRcptr const & rhs) { - Refcount * x = rhs.rc_address(); - Refcount * old = this->rc_address(); + Refcount * x = rhs.rc_address(); + Refcount * old = this->rc_address(); - TaggedPtr::operator=(rhs); + TaggedPtr::operator=(rhs); - if (x != old) { - intrusive_ptr_release(old); - intrusive_ptr_add_ref(x); - } + if (x != old) { + intrusive_ptr_release(old); + intrusive_ptr_add_ref(x); + } - return *this; + return *this; } /*operator=*/ TaggedRcptr & operator=(TaggedRcptr && rhs) { - /* swap pointers + type descriptions; - * then don't need to touch refcounts - */ - std::swap(this->td_, rhs.td_); - std::swap(this->address_, rhs.address_); + /* swap pointers + type descriptions; + * then don't need to touch refcounts + */ + std::swap(this->td_, rhs.td_); + std::swap(this->address_, rhs.address_); - return *this; + return *this; } /*operator=*/ void display(std::ostream & os) const; std::string display_string() const; }; /*TaggedRcptr*/ - + inline std::ostream & operator<<(std::ostream & os, TaggedRcptr const & x) { x.display(os); return os; diff --git a/include/reflect/TypeDescr.hpp b/include/xo/reflect/TypeDescr.hpp similarity index 99% rename from include/reflect/TypeDescr.hpp rename to include/xo/reflect/TypeDescr.hpp index 0861407..da59c00 100644 --- a/include/reflect/TypeDescr.hpp +++ b/include/xo/reflect/TypeDescr.hpp @@ -3,7 +3,7 @@ #pragma once //#include "reflect/atomic/AtomicTdx.hpp" -#include "reflect/TypeDescrExtra.hpp" +#include "TypeDescrExtra.hpp" #include "cxxutil/demangle.hpp" #include #include diff --git a/include/reflect/TypeDescrExtra.hpp b/include/xo/reflect/TypeDescrExtra.hpp similarity index 98% rename from include/reflect/TypeDescrExtra.hpp rename to include/xo/reflect/TypeDescrExtra.hpp index 2d2be7f..824cd5d 100644 --- a/include/reflect/TypeDescrExtra.hpp +++ b/include/xo/reflect/TypeDescrExtra.hpp @@ -2,7 +2,7 @@ #pragma once -#include "reflect/Metatype.hpp" +#include "Metatype.hpp" #include /* note: this file #include'd into TypeDescr.hpp */ #include diff --git a/include/reflect/TypeDrivenMap.hpp b/include/xo/reflect/TypeDrivenMap.hpp similarity index 100% rename from include/reflect/TypeDrivenMap.hpp rename to include/xo/reflect/TypeDrivenMap.hpp diff --git a/include/reflect/atomic/AtomicTdx.hpp b/include/xo/reflect/atomic/AtomicTdx.hpp similarity index 96% rename from include/reflect/atomic/AtomicTdx.hpp rename to include/xo/reflect/atomic/AtomicTdx.hpp index 7b2e042..98e10cf 100644 --- a/include/reflect/atomic/AtomicTdx.hpp +++ b/include/xo/reflect/atomic/AtomicTdx.hpp @@ -2,7 +2,7 @@ #pragma once -#include "reflect/TypeDescrExtra.hpp" +#include "xo/reflect/TypeDescrExtra.hpp" //#include "reflect/TaggedPtr.hpp" #include diff --git a/include/reflect/init_reflect.hpp b/include/xo/reflect/init_reflect.hpp similarity index 100% rename from include/reflect/init_reflect.hpp rename to include/xo/reflect/init_reflect.hpp diff --git a/include/reflect/pointer/PointerTdx.hpp b/include/xo/reflect/pointer/PointerTdx.hpp similarity index 96% rename from include/reflect/pointer/PointerTdx.hpp rename to include/xo/reflect/pointer/PointerTdx.hpp index d2d3b86..327456c 100644 --- a/include/reflect/pointer/PointerTdx.hpp +++ b/include/xo/reflect/pointer/PointerTdx.hpp @@ -5,8 +5,8 @@ #pragma once -#include "reflect/TypeDescrExtra.hpp" -#include "reflect/EstablishTypeDescr.hpp" +#include "xo/reflect/TypeDescrExtra.hpp" +#include "xo/reflect/EstablishTypeDescr.hpp" #include "indentlog/scope.hpp" namespace xo { diff --git a/include/reflect/struct/StructMember.hpp b/include/xo/reflect/struct/StructMember.hpp similarity index 92% rename from include/reflect/struct/StructMember.hpp rename to include/xo/reflect/struct/StructMember.hpp index eaddf3b..3c7bab6 100644 --- a/include/reflect/struct/StructMember.hpp +++ b/include/xo/reflect/struct/StructMember.hpp @@ -2,10 +2,9 @@ #pragma once -#include "reflect/TypeDescr.hpp" -#include "reflect/EstablishTypeDescr.hpp" -//#include "reflect/Reflect.hpp" -#include "reflect/TaggedPtr.hpp" +#include "xo/reflect/TypeDescr.hpp" +#include "xo/reflect/EstablishTypeDescr.hpp" +#include "xo/reflect/TaggedPtr.hpp" #include #include @@ -14,7 +13,7 @@ namespace reflect { class AbstractStructMemberAccessor { public: virtual ~AbstractStructMemberAccessor() = default; - + /* get tagged pointer referring to this member of the object at *struct_addr */ TaggedPtr member_tp(void * struct_addr) const; @@ -30,7 +29,7 @@ namespace reflect { * .member_td() => Reflect::require(); */ virtual TypeDescr member_td() const = 0; - + /* get address of a particular member, given parent address */ virtual void * address(void * struct_addr) const = 0; @@ -63,7 +62,7 @@ namespace reflect { public: GeneralStructMemberAccessor(Memptr memptr) : member_td_{EstablishTypeDescr::establish()}, - memptr_{memptr} {} + memptr_{memptr} {} GeneralStructMemberAccessor(GeneralStructMemberAccessor const & x) = default; virtual ~GeneralStructMemberAccessor() = default; @@ -78,7 +77,7 @@ namespace reflect { return &(owner_addr->*memptr_); } /*address_impl*/ - + // ----- Inherited from AbstractStructMemberAccessor ----- #ifdef OBSOLETE @@ -102,7 +101,7 @@ namespace reflect { virtual std::unique_ptr clone() const override { return std::unique_ptr - (new GeneralStructMemberAccessor(*this)); + (new GeneralStructMemberAccessor(*this)); } /*clone*/ private: @@ -142,7 +141,7 @@ namespace reflect { static std::unique_ptr adopt(std::unique_ptr ancestor_accessor) { return std::unique_ptr - (new AncestorStructMemberAccessor(std::move(ancestor_accessor))); + (new AncestorStructMemberAccessor(std::move(ancestor_accessor))); } /*adopt*/ void * address_impl(StructT * self_addr) const { @@ -171,7 +170,7 @@ namespace reflect { virtual std::unique_ptr clone() const override { return std::unique_ptr - (new AncestorStructMemberAccessor(std::move(this->ancestor_accessor_->clone()))); + (new AncestorStructMemberAccessor(std::move(this->ancestor_accessor_->clone()))); } /*clone*/ private: @@ -186,11 +185,11 @@ namespace reflect { public: StructMember() = default; StructMember(std::string const & name, - std::unique_ptr accessor) + std::unique_ptr accessor) : member_name_{name}, accessor_{std::move(accessor)} {} StructMember(StructMember && x) : member_name_{std::move(x.member_name_)}, - accessor_{std::move(x.accessor_)} {} + accessor_{std::move(x.accessor_)} {} static StructMember null(); @@ -210,8 +209,8 @@ namespace reflect { assert(EstablishTypeDescr::establish() == this->get_struct_td()); return StructMember(this->member_name(), - std::move(AncestorStructMemberAccessor::adopt - (std::move(this->accessor_->clone())))); + std::move(AncestorStructMemberAccessor::adopt + (std::move(this->accessor_->clone())))); } /*for_descendant*/ StructMember & operator=(StructMember && x) { diff --git a/include/reflect/struct/StructTdx.hpp b/include/xo/reflect/struct/StructTdx.hpp similarity index 95% rename from include/reflect/struct/StructTdx.hpp rename to include/xo/reflect/struct/StructTdx.hpp index 5e170ef..594de2d 100644 --- a/include/reflect/struct/StructTdx.hpp +++ b/include/xo/reflect/struct/StructTdx.hpp @@ -2,9 +2,10 @@ #pragma once -#include "reflect/TypeDescrExtra.hpp" -#include "reflect/TaggedPtr.hpp" -#include "reflect/struct/StructMember.hpp" +#include "xo/reflect/TypeDescrExtra.hpp" +#include "xo/reflect/TaggedPtr.hpp" +#include "StructMember.hpp" +//#include "xo/reflect/struct/StructMember.hpp" #include #include #include diff --git a/include/reflect/vector/VectorTdx.hpp b/include/xo/reflect/vector/VectorTdx.hpp similarity index 75% rename from include/reflect/vector/VectorTdx.hpp rename to include/xo/reflect/vector/VectorTdx.hpp index 4f3309c..944c451 100644 --- a/include/reflect/vector/VectorTdx.hpp +++ b/include/xo/reflect/vector/VectorTdx.hpp @@ -5,12 +5,8 @@ #pragma once -#include "reflect/TypeDescrExtra.hpp" -//#include "reflect/TaggedPtr.hpp" -#include "reflect/EstablishTypeDescr.hpp" -//#include "reflect/TaggedPtr.hpp" -//#include -//#include +#include "xo/reflect/TypeDescrExtra.hpp" +#include "xo/reflect/EstablishTypeDescr.hpp" namespace xo { namespace reflect { @@ -42,19 +38,19 @@ namespace xo { using target_t = VectorT; static std::unique_ptr make() { - return std::unique_ptr(new StlVectorTdx()); + return std::unique_ptr(new StlVectorTdx()); } /*make*/ virtual uint32_t n_child(void * object) const override { - target_t * vec = reinterpret_cast(object); + target_t * vec = reinterpret_cast(object); - return vec->size(); + return vec->size(); } /*n_child*/ virtual TaggedPtr child_tp(uint32_t i, void * object) const override { - target_t * vec = reinterpret_cast(object); + target_t * vec = reinterpret_cast(object); - return establish_most_derived_tp(&((*vec)[i])); + return establish_most_derived_tp(&((*vec)[i])); } /*child_tp*/ }; /*StlVectorTdx*/ @@ -66,9 +62,9 @@ namespace xo { template using StdArrayTdx = StlVectorTdx>; - + // ----- std::vector ----- - + /* coordinates with EstablishTdx>::make() * see [reflect/Reflect.hpp] */ @@ -76,21 +72,21 @@ namespace xo { class StdVectorTdx : public VectorTdx { public: using target_t = std::vector; - + static std::unique_ptr make() { - return std::unique_ptr(new StdVectorTdx()); + return std::unique_ptr(new StdVectorTdx()); } /*make*/ virtual uint32_t n_child(void * object) const override { - target_t * vec = reinterpret_cast(object); + target_t * vec = reinterpret_cast(object); - return vec->size(); + return vec->size(); } /*n_child*/ virtual TaggedPtr child_tp(uint32_t i, void * object) const override { - target_t * vec = reinterpret_cast(object); + target_t * vec = reinterpret_cast(object); - return establish_most_derived_tp(&((*vec)[i])); + return establish_most_derived_tp(&((*vec)[i])); } }; /*StdVectorTdx*/ } /*namespace reflect*/ diff --git a/utest/StructReflector.test.cpp b/utest/StructReflector.test.cpp index 5bf87ad..4ab0772 100644 --- a/utest/StructReflector.test.cpp +++ b/utest/StructReflector.test.cpp @@ -3,12 +3,12 @@ * author: Roland Conybeare, Aug 2022 */ -#include "reflect/Reflect.hpp" -#include "reflect/StructReflector.hpp" +#include "xo/reflect/Reflect.hpp" +#include "xo/reflect/StructReflector.hpp" #include #define STRINGIFY(x) #x - + namespace xo { using xo::reflect::Reflect; using xo::reflect::TaggedPtr; @@ -129,7 +129,7 @@ namespace xo { REQUIRE(tp.get_child(2).td() == Reflect::require()); REQUIRE(tp.get_child(2).address() == &(recd1.z_)); - + REQUIRE(tp.get_child(3).is_universal_null()); REQUIRE(tp.get_child(3).td() == nullptr); REQUIRE(tp.get_child(3).address() == nullptr); diff --git a/utest/StructTdx.test.cpp b/utest/StructTdx.test.cpp index c20e213..cb845e1 100644 --- a/utest/StructTdx.test.cpp +++ b/utest/StructTdx.test.cpp @@ -3,7 +3,7 @@ * author: Roland Conybeare, Aug 2022 */ -#include "reflect/Reflect.hpp" +#include "xo/reflect/Reflect.hpp" #include namespace xo { diff --git a/utest/VectorTdx.test.cpp b/utest/VectorTdx.test.cpp index 3836b4f..00f30a4 100644 --- a/utest/VectorTdx.test.cpp +++ b/utest/VectorTdx.test.cpp @@ -3,7 +3,7 @@ * author: Roland Conybeare, Aug 2022 */ -#include "reflect/Reflect.hpp" +#include "xo/reflect/Reflect.hpp" #include namespace xo { @@ -81,7 +81,7 @@ namespace xo { REQUIRE(tp0.td()->metatype() == Metatype::mt_atomic); REQUIRE(tp0.recover_native() == &(v[0])); REQUIRE(tp0.n_child() == 0); - + TaggedPtr tp1 = tp.get_child(1); REQUIRE(tp1.td()->complete_flag()); @@ -91,7 +91,7 @@ namespace xo { REQUIRE(tp1.td()->metatype() == Metatype::mt_atomic); REQUIRE(tp1.recover_native() == &(v[1])); REQUIRE(tp1.n_child() == 0); - } /*TEST(std-vector-reflect-two)*/ + } /*TEST(std-vector-reflect-two)*/ // ----- std::array ----- @@ -163,7 +163,7 @@ namespace xo { REQUIRE(tp0.td()->metatype() == Metatype::mt_atomic); REQUIRE(tp0.recover_native() == &(v[0])); REQUIRE(tp0.n_child() == 0); - + TaggedPtr tp1 = tp.get_child(1); REQUIRE(tp1.td()->complete_flag()); @@ -173,7 +173,7 @@ namespace xo { REQUIRE(tp1.td()->metatype() == Metatype::mt_atomic); REQUIRE(tp1.recover_native() == &(v[1])); REQUIRE(tp1.n_child() == 0); - } /*TEST(std-array-reflect-two)*/ + } /*TEST(std-array-reflect-two)*/ } /*namespace ut*/ } /*namespace xo*/