reflect: insert xo/ subdir into include path
This commit is contained in:
parent
ba95d0a40c
commit
6be9037f10
20 changed files with 179 additions and 184 deletions
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescr.hpp"
|
#include "TypeDescr.hpp"
|
||||||
#include "reflect/TaggedPtr.hpp"
|
#include "TaggedPtr.hpp"
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace reflect {
|
namespace reflect {
|
||||||
|
|
@ -26,28 +26,28 @@ namespace xo {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static TypeDescrW establish() {
|
static TypeDescrW establish() {
|
||||||
TypeDescrW td = TypeDescrBase::require(&typeid(T),
|
TypeDescrW td = TypeDescrBase::require(&typeid(T),
|
||||||
type_name<T>(),
|
type_name<T>(),
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
#ifdef NOT_USING
|
#ifdef NOT_USING
|
||||||
std::function<TaggedPtr (void *)> to_self_tp;
|
std::function<TaggedPtr (void *)> to_self_tp;
|
||||||
|
|
||||||
if (std::is_base_of_v<SelfTagging, T>) {
|
if (std::is_base_of_v<SelfTagging, T>) {
|
||||||
/* T is a descendant of SelfTagging (or T = SelfTagging);
|
/* T is a descendant of SelfTagging (or T = SelfTagging);
|
||||||
* use SelfTagging.self_tp()
|
* use SelfTagging.self_tp()
|
||||||
*/
|
*/
|
||||||
to_self_tp = [](void * x) { return reinterpret_cast<T *>(x)->self_tp(); };
|
to_self_tp = [](void * x) { return reinterpret_cast<T *>(x)->self_tp(); };
|
||||||
} else {
|
} else {
|
||||||
/* T is not a descendant of SelfTagging.
|
/* T is not a descendant of SelfTagging.
|
||||||
* want to return
|
* want to return
|
||||||
*/
|
*/
|
||||||
to_self_tp = [td](void * x) { return TaggedPtr(td, x); };
|
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
|
#endif
|
||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
}; /*EstablishTypeDescr*/
|
}; /*EstablishTypeDescr*/
|
||||||
|
|
||||||
|
|
@ -5,12 +5,12 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/SelfTagging.hpp"
|
#include "SelfTagging.hpp"
|
||||||
#include "reflect/EstablishTypeDescr.hpp"
|
#include "EstablishTypeDescr.hpp"
|
||||||
#include "reflect/atomic/AtomicTdx.hpp"
|
#include "atomic/AtomicTdx.hpp"
|
||||||
#include "reflect/pointer/PointerTdx.hpp"
|
#include "pointer/PointerTdx.hpp"
|
||||||
#include "reflect/vector/VectorTdx.hpp"
|
#include "vector/VectorTdx.hpp"
|
||||||
#include "reflect/struct/StructTdx.hpp"
|
#include "struct/StructTdx.hpp"
|
||||||
#include "refcnt/Refcounted.hpp"
|
#include "refcnt/Refcounted.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
@ -73,11 +73,11 @@ namespace xo {
|
||||||
class TaggedPtrMaker<SelfTagging> {
|
class TaggedPtrMaker<SelfTagging> {
|
||||||
public:
|
public:
|
||||||
static TaggedPtr make_tp(SelfTagging * x) {
|
static TaggedPtr make_tp(SelfTagging * x) {
|
||||||
return x->self_tp();
|
return x->self_tp();
|
||||||
} /*make_tp*/
|
} /*make_tp*/
|
||||||
|
|
||||||
static TaggedRcptr make_rctp(SelfTagging * x) {
|
static TaggedRcptr make_rctp(SelfTagging * x) {
|
||||||
return x->self_tp();
|
return x->self_tp();
|
||||||
} /*make_rctp*/
|
} /*make_rctp*/
|
||||||
}; /*TaggedPtrMaker*/
|
}; /*TaggedPtrMaker*/
|
||||||
|
|
||||||
|
|
@ -117,31 +117,31 @@ namespace xo {
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static TypeDescrW require() {
|
static TypeDescrW require() {
|
||||||
TypeDescrW retval_td = EstablishTypeDescr::establish<T>();
|
TypeDescrW retval_td = EstablishTypeDescr::establish<T>();
|
||||||
|
|
||||||
/* mark TypeDescr for T as complete (even though it isn't quite yet),
|
/* mark TypeDescr for T as complete (even though it isn't quite yet),
|
||||||
* so that when we encounter recursive types, reflection terminates.
|
* so that when we encounter recursive types, reflection terminates.
|
||||||
* For example consider type resulting from code like
|
* For example consider type resulting from code like
|
||||||
*
|
*
|
||||||
* typename T;
|
* typename T;
|
||||||
* using T = std::vector<T *>;
|
* using T = std::vector<T *>;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
if (retval_td->mark_complete()) {
|
if (retval_td->mark_complete()) {
|
||||||
/* control here on 2nd+later calls to require<T>().
|
/* control here on 2nd+later calls to require<T>().
|
||||||
* in principle can immediately short-circuit.
|
* in principle can immediately short-circuit.
|
||||||
*/
|
*/
|
||||||
} else {
|
} else {
|
||||||
/* control comes here the first time require<T>() runs */
|
/* control comes here the first time require<T>() runs */
|
||||||
|
|
||||||
auto final_tdx = EstablishTdx<T>::make();
|
auto final_tdx = EstablishTdx<T>::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*/
|
} /*require*/
|
||||||
|
|
||||||
/* Use:
|
/* Use:
|
||||||
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "refcnt/Refcounted.hpp"
|
#include "Refcounted.hpp"
|
||||||
#include "reflect/TypeDescr.hpp"
|
#include "TypeDescr.hpp"
|
||||||
#include "reflect/TaggedRcptr.hpp"
|
#include "TaggedRcptr.hpp"
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace reflect {
|
namespace reflect {
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/Reflect.hpp"
|
#include "Reflect.hpp"
|
||||||
#include "reflect/TypeDescr.hpp"
|
#include "TypeDescr.hpp"
|
||||||
#include "reflect/struct/StructMember.hpp"
|
#include "struct/StructMember.hpp"
|
||||||
#include "reflect/struct/StructTdx.hpp"
|
#include "struct/StructTdx.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -16,7 +16,7 @@ namespace xo {
|
||||||
template<typename StructT>
|
template<typename StructT>
|
||||||
struct SelfTagger<StructT, true> {
|
struct SelfTagger<StructT, true> {
|
||||||
static TaggedPtr self_tp(void * object) {
|
static TaggedPtr self_tp(void * object) {
|
||||||
return (reinterpret_cast<StructT *>(object))->self_tp();
|
return (reinterpret_cast<StructT *>(object))->self_tp();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ namespace xo {
|
||||||
public:
|
public:
|
||||||
StructReflector() : td_{EstablishTypeDescr::establish<StructT>()} {}
|
StructReflector() : td_{EstablishTypeDescr::establish<StructT>()} {}
|
||||||
~StructReflector() {
|
~StructReflector() {
|
||||||
this->require_complete();
|
this->require_complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_complete() const { return s_reflected_flag; }
|
bool is_complete() const { return s_reflected_flag; }
|
||||||
|
|
@ -53,60 +53,60 @@ namespace xo {
|
||||||
|
|
||||||
template<typename OwnerT, typename MemberT>
|
template<typename OwnerT, typename MemberT>
|
||||||
void reflect_member(std::string const & member_name,
|
void reflect_member(std::string const & member_name,
|
||||||
MemberT OwnerT::* member_addr) {
|
MemberT OwnerT::* member_addr) {
|
||||||
|
|
||||||
auto accessor
|
auto accessor
|
||||||
(GeneralStructMemberAccessor<StructT, OwnerT, MemberT>::make(member_addr));
|
(GeneralStructMemberAccessor<StructT, OwnerT, MemberT>::make(member_addr));
|
||||||
|
|
||||||
/* used to do this in GeneralStructMemberAccessor<> ctor,
|
/* used to do this in GeneralStructMemberAccessor<> ctor,
|
||||||
* but that introduces #include cycle
|
* but that introduces #include cycle
|
||||||
*/
|
*/
|
||||||
Reflect::require<MemberT>();
|
Reflect::require<MemberT>();
|
||||||
|
|
||||||
this->member_v_.emplace_back(member_name, std::move(accessor));
|
this->member_v_.emplace_back(member_name, std::move(accessor));
|
||||||
} /*reflect_member*/
|
} /*reflect_member*/
|
||||||
|
|
||||||
void require_complete() {
|
void require_complete() {
|
||||||
if(!s_reflected_flag) {
|
if(!s_reflected_flag) {
|
||||||
s_reflected_flag = true;
|
s_reflected_flag = true;
|
||||||
|
|
||||||
constexpr bool have_to_self_tp = std::is_base_of_v<SelfTagging, StructT>;
|
constexpr bool have_to_self_tp = std::is_base_of_v<SelfTagging, StructT>;
|
||||||
|
|
||||||
/* if self-tagging, can use .self_tp() to get most-derived tagged pointer */
|
/* if self-tagging, can use .self_tp() to get most-derived tagged pointer */
|
||||||
auto to_self_tp_fn
|
auto to_self_tp_fn
|
||||||
= ([](void * object)
|
= ([](void * object)
|
||||||
{
|
{
|
||||||
return SelfTagger<StructT, have_to_self_tp>::self_tp(object);
|
return SelfTagger<StructT, have_to_self_tp>::self_tp(object);
|
||||||
});
|
});
|
||||||
|
|
||||||
auto tdx = StructTdx::make(std::move(this->member_v_),
|
auto tdx = StructTdx::make(std::move(this->member_v_),
|
||||||
have_to_self_tp,
|
have_to_self_tp,
|
||||||
to_self_tp_fn);
|
to_self_tp_fn);
|
||||||
|
|
||||||
this->td_->assign_tdextra(std::move(tdx));
|
this->td_->assign_tdextra(std::move(tdx));
|
||||||
}
|
}
|
||||||
} /*complete*/
|
} /*complete*/
|
||||||
|
|
||||||
template<typename AncestorT>
|
template<typename AncestorT>
|
||||||
void adopt_ancestors() {
|
void adopt_ancestors() {
|
||||||
assert(Reflect::is_reflected<AncestorT>());
|
assert(Reflect::is_reflected<AncestorT>());
|
||||||
|
|
||||||
TypeDescr ancestor_td = Reflect::require<AncestorT>();
|
TypeDescr ancestor_td = Reflect::require<AncestorT>();
|
||||||
|
|
||||||
/* requires that reflection of AncestorT has completed */
|
/* requires that reflection of AncestorT has completed */
|
||||||
{
|
{
|
||||||
assert(ancestor_td->is_struct());
|
assert(ancestor_td->is_struct());
|
||||||
assert(ancestor_td->complete_flag());
|
assert(ancestor_td->complete_flag());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* for structs,
|
/* for structs,
|
||||||
* we know that object argument to TypeDescr::n_child() is unused
|
* 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) {
|
for (uint32_t i = 0, n = ancestor_td->n_child(nullptr); i < n; ++i) {
|
||||||
StructMember const & member = ancestor_td->struct_member(i);
|
StructMember const & member = ancestor_td->struct_member(i);
|
||||||
|
|
||||||
this->member_v_.push_back(member.for_descendant<StructT, AncestorT>());
|
this->member_v_.push_back(member.for_descendant<StructT, AncestorT>());
|
||||||
}
|
}
|
||||||
} /*adopt_ancestors*/
|
} /*adopt_ancestors*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescr.hpp"
|
#include "TypeDescr.hpp"
|
||||||
//#include "reflect/EstablishTypeDescr.hpp"
|
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TaggedPtr.hpp"
|
#include "TaggedPtr.hpp"
|
||||||
// causes #include cycle, reflect/Reflect.hpp includes this header
|
// causes #include cycle, reflect/Reflect.hpp includes this header
|
||||||
//#include "reflect/Reflect.hpp"
|
//#include "reflect/Reflect.hpp"
|
||||||
#include "refcnt/Refcounted.hpp"
|
#include "refcnt/Refcounted.hpp"
|
||||||
|
|
@ -23,19 +23,19 @@ namespace xo {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TaggedRcptr(TypeDescr td, Refcount * x) : TaggedPtr(td, x) {
|
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) {
|
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)) {
|
TaggedRcptr(TaggedRcptr && x) : TaggedPtr(std::move(x)) {
|
||||||
/* since we're moving from x, need to make sure x.dtor
|
/* since we're moving from x, need to make sure x.dtor
|
||||||
* doesn't decrement refcount
|
* doesn't decrement refcount
|
||||||
*/
|
*/
|
||||||
x.assign_address(nullptr);
|
x.assign_address(nullptr);
|
||||||
}
|
}
|
||||||
~TaggedRcptr() {
|
~TaggedRcptr() {
|
||||||
ref::intrusive_ptr_release(this->rc_address());
|
ref::intrusive_ptr_release(this->rc_address());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* causes #include cycle, see [reflect/Reflect.hpp] */
|
/* causes #include cycle, see [reflect/Reflect.hpp] */
|
||||||
|
|
@ -46,31 +46,31 @@ namespace xo {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Refcount * rc_address() const {
|
Refcount * rc_address() const {
|
||||||
return reinterpret_cast<Refcount *>(this->address());
|
return reinterpret_cast<Refcount *>(this->address());
|
||||||
} /*rc_address*/
|
} /*rc_address*/
|
||||||
|
|
||||||
TaggedRcptr & operator=(TaggedRcptr const & rhs) {
|
TaggedRcptr & operator=(TaggedRcptr const & rhs) {
|
||||||
Refcount * x = rhs.rc_address();
|
Refcount * x = rhs.rc_address();
|
||||||
Refcount * old = this->rc_address();
|
Refcount * old = this->rc_address();
|
||||||
|
|
||||||
TaggedPtr::operator=(rhs);
|
TaggedPtr::operator=(rhs);
|
||||||
|
|
||||||
if (x != old) {
|
if (x != old) {
|
||||||
intrusive_ptr_release(old);
|
intrusive_ptr_release(old);
|
||||||
intrusive_ptr_add_ref(x);
|
intrusive_ptr_add_ref(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
} /*operator=*/
|
} /*operator=*/
|
||||||
|
|
||||||
TaggedRcptr & operator=(TaggedRcptr && rhs) {
|
TaggedRcptr & operator=(TaggedRcptr && rhs) {
|
||||||
/* swap pointers + type descriptions;
|
/* swap pointers + type descriptions;
|
||||||
* then don't need to touch refcounts
|
* then don't need to touch refcounts
|
||||||
*/
|
*/
|
||||||
std::swap(this->td_, rhs.td_);
|
std::swap(this->td_, rhs.td_);
|
||||||
std::swap(this->address_, rhs.address_);
|
std::swap(this->address_, rhs.address_);
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
} /*operator=*/
|
} /*operator=*/
|
||||||
|
|
||||||
void display(std::ostream & os) const;
|
void display(std::ostream & os) const;
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
//#include "reflect/atomic/AtomicTdx.hpp"
|
//#include "reflect/atomic/AtomicTdx.hpp"
|
||||||
#include "reflect/TypeDescrExtra.hpp"
|
#include "TypeDescrExtra.hpp"
|
||||||
#include "cxxutil/demangle.hpp"
|
#include "cxxutil/demangle.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/Metatype.hpp"
|
#include "Metatype.hpp"
|
||||||
#include <string>
|
#include <string>
|
||||||
/* note: this file #include'd into TypeDescr.hpp */
|
/* note: this file #include'd into TypeDescr.hpp */
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescrExtra.hpp"
|
#include "xo/reflect/TypeDescrExtra.hpp"
|
||||||
//#include "reflect/TaggedPtr.hpp"
|
//#include "reflect/TaggedPtr.hpp"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -5,8 +5,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescrExtra.hpp"
|
#include "xo/reflect/TypeDescrExtra.hpp"
|
||||||
#include "reflect/EstablishTypeDescr.hpp"
|
#include "xo/reflect/EstablishTypeDescr.hpp"
|
||||||
#include "indentlog/scope.hpp"
|
#include "indentlog/scope.hpp"
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescr.hpp"
|
#include "xo/reflect/TypeDescr.hpp"
|
||||||
#include "reflect/EstablishTypeDescr.hpp"
|
#include "xo/reflect/EstablishTypeDescr.hpp"
|
||||||
//#include "reflect/Reflect.hpp"
|
#include "xo/reflect/TaggedPtr.hpp"
|
||||||
#include "reflect/TaggedPtr.hpp"
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
@ -63,7 +62,7 @@ namespace reflect {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GeneralStructMemberAccessor(Memptr memptr) : member_td_{EstablishTypeDescr::establish<MemberT>()},
|
GeneralStructMemberAccessor(Memptr memptr) : member_td_{EstablishTypeDescr::establish<MemberT>()},
|
||||||
memptr_{memptr} {}
|
memptr_{memptr} {}
|
||||||
GeneralStructMemberAccessor(GeneralStructMemberAccessor const & x) = default;
|
GeneralStructMemberAccessor(GeneralStructMemberAccessor const & x) = default;
|
||||||
virtual ~GeneralStructMemberAccessor() = default;
|
virtual ~GeneralStructMemberAccessor() = default;
|
||||||
|
|
||||||
|
|
@ -102,7 +101,7 @@ namespace reflect {
|
||||||
|
|
||||||
virtual std::unique_ptr<AbstractStructMemberAccessor> clone() const override {
|
virtual std::unique_ptr<AbstractStructMemberAccessor> clone() const override {
|
||||||
return std::unique_ptr<AbstractStructMemberAccessor>
|
return std::unique_ptr<AbstractStructMemberAccessor>
|
||||||
(new GeneralStructMemberAccessor(*this));
|
(new GeneralStructMemberAccessor(*this));
|
||||||
} /*clone*/
|
} /*clone*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -142,7 +141,7 @@ namespace reflect {
|
||||||
static std::unique_ptr<AncestorStructMemberAccessor>
|
static std::unique_ptr<AncestorStructMemberAccessor>
|
||||||
adopt(std::unique_ptr<AbstractStructMemberAccessor> ancestor_accessor) {
|
adopt(std::unique_ptr<AbstractStructMemberAccessor> ancestor_accessor) {
|
||||||
return std::unique_ptr<AncestorStructMemberAccessor>
|
return std::unique_ptr<AncestorStructMemberAccessor>
|
||||||
(new AncestorStructMemberAccessor(std::move(ancestor_accessor)));
|
(new AncestorStructMemberAccessor(std::move(ancestor_accessor)));
|
||||||
} /*adopt*/
|
} /*adopt*/
|
||||||
|
|
||||||
void * address_impl(StructT * self_addr) const {
|
void * address_impl(StructT * self_addr) const {
|
||||||
|
|
@ -171,7 +170,7 @@ namespace reflect {
|
||||||
|
|
||||||
virtual std::unique_ptr<AbstractStructMemberAccessor> clone() const override {
|
virtual std::unique_ptr<AbstractStructMemberAccessor> clone() const override {
|
||||||
return std::unique_ptr<AbstractStructMemberAccessor>
|
return std::unique_ptr<AbstractStructMemberAccessor>
|
||||||
(new AncestorStructMemberAccessor(std::move(this->ancestor_accessor_->clone())));
|
(new AncestorStructMemberAccessor(std::move(this->ancestor_accessor_->clone())));
|
||||||
} /*clone*/
|
} /*clone*/
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
@ -186,11 +185,11 @@ namespace reflect {
|
||||||
public:
|
public:
|
||||||
StructMember() = default;
|
StructMember() = default;
|
||||||
StructMember(std::string const & name,
|
StructMember(std::string const & name,
|
||||||
std::unique_ptr<AbstractStructMemberAccessor> accessor)
|
std::unique_ptr<AbstractStructMemberAccessor> accessor)
|
||||||
: member_name_{name}, accessor_{std::move(accessor)} {}
|
: member_name_{name}, accessor_{std::move(accessor)} {}
|
||||||
StructMember(StructMember && x)
|
StructMember(StructMember && x)
|
||||||
: member_name_{std::move(x.member_name_)},
|
: member_name_{std::move(x.member_name_)},
|
||||||
accessor_{std::move(x.accessor_)} {}
|
accessor_{std::move(x.accessor_)} {}
|
||||||
|
|
||||||
static StructMember null();
|
static StructMember null();
|
||||||
|
|
||||||
|
|
@ -210,8 +209,8 @@ namespace reflect {
|
||||||
assert(EstablishTypeDescr::establish<StructT>() == this->get_struct_td());
|
assert(EstablishTypeDescr::establish<StructT>() == this->get_struct_td());
|
||||||
|
|
||||||
return StructMember(this->member_name(),
|
return StructMember(this->member_name(),
|
||||||
std::move(AncestorStructMemberAccessor<DescendantT, StructT>::adopt
|
std::move(AncestorStructMemberAccessor<DescendantT, StructT>::adopt
|
||||||
(std::move(this->accessor_->clone()))));
|
(std::move(this->accessor_->clone()))));
|
||||||
} /*for_descendant*/
|
} /*for_descendant*/
|
||||||
|
|
||||||
StructMember & operator=(StructMember && x) {
|
StructMember & operator=(StructMember && x) {
|
||||||
|
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescrExtra.hpp"
|
#include "xo/reflect/TypeDescrExtra.hpp"
|
||||||
#include "reflect/TaggedPtr.hpp"
|
#include "xo/reflect/TaggedPtr.hpp"
|
||||||
#include "reflect/struct/StructMember.hpp"
|
#include "StructMember.hpp"
|
||||||
|
//#include "xo/reflect/struct/StructMember.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
@ -5,12 +5,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "reflect/TypeDescrExtra.hpp"
|
#include "xo/reflect/TypeDescrExtra.hpp"
|
||||||
//#include "reflect/TaggedPtr.hpp"
|
#include "xo/reflect/EstablishTypeDescr.hpp"
|
||||||
#include "reflect/EstablishTypeDescr.hpp"
|
|
||||||
//#include "reflect/TaggedPtr.hpp"
|
|
||||||
//#include <vector>
|
|
||||||
//#include <memory>
|
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace reflect {
|
namespace reflect {
|
||||||
|
|
@ -42,19 +38,19 @@ namespace xo {
|
||||||
using target_t = VectorT;
|
using target_t = VectorT;
|
||||||
|
|
||||||
static std::unique_ptr<StlVectorTdx> make() {
|
static std::unique_ptr<StlVectorTdx> make() {
|
||||||
return std::unique_ptr<StlVectorTdx>(new StlVectorTdx());
|
return std::unique_ptr<StlVectorTdx>(new StlVectorTdx());
|
||||||
} /*make*/
|
} /*make*/
|
||||||
|
|
||||||
virtual uint32_t n_child(void * object) const override {
|
virtual uint32_t n_child(void * object) const override {
|
||||||
target_t * vec = reinterpret_cast<target_t *>(object);
|
target_t * vec = reinterpret_cast<target_t *>(object);
|
||||||
|
|
||||||
return vec->size();
|
return vec->size();
|
||||||
} /*n_child*/
|
} /*n_child*/
|
||||||
|
|
||||||
virtual TaggedPtr child_tp(uint32_t i, void * object) const override {
|
virtual TaggedPtr child_tp(uint32_t i, void * object) const override {
|
||||||
target_t * vec = reinterpret_cast<target_t *>(object);
|
target_t * vec = reinterpret_cast<target_t *>(object);
|
||||||
|
|
||||||
return establish_most_derived_tp(&((*vec)[i]));
|
return establish_most_derived_tp(&((*vec)[i]));
|
||||||
} /*child_tp*/
|
} /*child_tp*/
|
||||||
}; /*StlVectorTdx*/
|
}; /*StlVectorTdx*/
|
||||||
|
|
||||||
|
|
@ -78,19 +74,19 @@ namespace xo {
|
||||||
using target_t = std::vector<Element>;
|
using target_t = std::vector<Element>;
|
||||||
|
|
||||||
static std::unique_ptr<StdVectorTdx> make() {
|
static std::unique_ptr<StdVectorTdx> make() {
|
||||||
return std::unique_ptr<StdVectorTdx>(new StdVectorTdx());
|
return std::unique_ptr<StdVectorTdx>(new StdVectorTdx());
|
||||||
} /*make*/
|
} /*make*/
|
||||||
|
|
||||||
virtual uint32_t n_child(void * object) const override {
|
virtual uint32_t n_child(void * object) const override {
|
||||||
target_t * vec = reinterpret_cast<target_t *>(object);
|
target_t * vec = reinterpret_cast<target_t *>(object);
|
||||||
|
|
||||||
return vec->size();
|
return vec->size();
|
||||||
} /*n_child*/
|
} /*n_child*/
|
||||||
|
|
||||||
virtual TaggedPtr child_tp(uint32_t i, void * object) const override {
|
virtual TaggedPtr child_tp(uint32_t i, void * object) const override {
|
||||||
target_t * vec = reinterpret_cast<target_t *>(object);
|
target_t * vec = reinterpret_cast<target_t *>(object);
|
||||||
|
|
||||||
return establish_most_derived_tp(&((*vec)[i]));
|
return establish_most_derived_tp(&((*vec)[i]));
|
||||||
}
|
}
|
||||||
}; /*StdVectorTdx*/
|
}; /*StdVectorTdx*/
|
||||||
} /*namespace reflect*/
|
} /*namespace reflect*/
|
||||||
|
|
@ -3,8 +3,8 @@
|
||||||
* author: Roland Conybeare, Aug 2022
|
* author: Roland Conybeare, Aug 2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "reflect/Reflect.hpp"
|
#include "xo/reflect/Reflect.hpp"
|
||||||
#include "reflect/StructReflector.hpp"
|
#include "xo/reflect/StructReflector.hpp"
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
#define STRINGIFY(x) #x
|
#define STRINGIFY(x) #x
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* author: Roland Conybeare, Aug 2022
|
* author: Roland Conybeare, Aug 2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "reflect/Reflect.hpp"
|
#include "xo/reflect/Reflect.hpp"
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* author: Roland Conybeare, Aug 2022
|
* author: Roland Conybeare, Aug 2022
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "reflect/Reflect.hpp"
|
#include "xo/reflect/Reflect.hpp"
|
||||||
#include <catch2/catch.hpp>
|
#include <catch2/catch.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue