From 6ba04457018da7e35ad6b774d660b48cb25e042f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 16 Nov 2025 20:10:23 -0500 Subject: [PATCH] xo-interpreter adds + explict mm arg to ctors (retiring Object::mm) --- include/xo/reflect/EstablishTypeDescr.hpp | 8 ++++---- src/reflect/CMakeLists.txt | 2 +- src/reflect/TypeDescr.cpp | 21 +++++++++++++++++++-- src/reflect/init_reflect.cpp | 20 ++++++++++---------- 4 files changed, 34 insertions(+), 17 deletions(-) diff --git a/include/xo/reflect/EstablishTypeDescr.hpp b/include/xo/reflect/EstablishTypeDescr.hpp index 0f18d84..e461a91 100644 --- a/include/xo/reflect/EstablishTypeDescr.hpp +++ b/include/xo/reflect/EstablishTypeDescr.hpp @@ -39,10 +39,10 @@ namespace xo { template static TypeDescrW establish() { - TypeDescrW td = TypeDescrBase::require(&typeid(T), - std::string(type_name()), - nullptr /*tdextra*/, - nullptr /*invoker*/); + static TypeDescrW td = TypeDescrBase::require(&typeid(T), + std::string(type_name()), + nullptr /*tdextra*/, + nullptr /*invoker*/); #ifdef NOT_USING std::function to_self_tp; diff --git a/src/reflect/CMakeLists.txt b/src/reflect/CMakeLists.txt index 8741706..c9a95d6 100644 --- a/src/reflect/CMakeLists.txt +++ b/src/reflect/CMakeLists.txt @@ -13,7 +13,7 @@ set(SELF_SRCS xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) xo_dependency(${SELF_LIB} refcnt) xo_dependency(${SELF_LIB} indentlog) -xo_dependency(${SELF_LIB} subsys) +xo_headeronly_dependency(${SELF_LIB} subsys) #xo_boost_dependency(${SELF_LIB}) # end CMakeLists.txt diff --git a/src/reflect/TypeDescr.cpp b/src/reflect/TypeDescr.cpp index 676225f..de5f4ad 100644 --- a/src/reflect/TypeDescr.cpp +++ b/src/reflect/TypeDescr.cpp @@ -57,6 +57,10 @@ namespace xo { detail::Invoker * invoker, std::unique_ptr tdextra) { + scope log(XO_DEBUG(false)); + + log && log(xtag("canonical_name", canonical_name)); + if (native_tinfo) { /* 1. lookup by tinfo hash_code in s_type_table_map * Not available for manually-constructed type descriptions. @@ -64,19 +68,29 @@ namespace xo { { auto ix = s_native_type_table_map.find(TypeInfoRef(native_tinfo)); - if ((ix != s_native_type_table_map.end()) && ix->second) + if ((ix != s_native_type_table_map.end()) && ix->second) { + log && log("TypeDescrBase::require" + ": using s_native_type_table_map[TypeInfoRef(native_tinfo)]"); + return ix->second; + } } /* 2. lookup by tinfo hash_code in s_coalesced_type_table_map */ { auto ix = s_coalesced_type_table_map.find(TypeInfoRef(native_tinfo)); - if ((ix != s_coalesced_type_table_map.end()) && ix->second) + if ((ix != s_coalesced_type_table_map.end()) && ix->second) { + log && log("TypeDescrBase::require" + ": using s_coalesced_type_table_map[TypeInfoRef(native_tinfo)]"); + return ix->second; + } } } + log && log("TypeDescrBase::require: try lookup by canonical name"); + /* 3. lookup by canonical_name, before we create a new slot. * * Have to accept that on clang type_info objects aren't always unique (!$@#!!) @@ -85,6 +99,7 @@ namespace xo { auto ix = s_canonical_type_table_map.find(canonical_name); if (ix != s_canonical_type_table_map.end()) { + /** assume existing slot, with same canonical name, * represents the same type as native_tinfo **/ @@ -145,6 +160,8 @@ namespace xo { TypeId new_td_id = TypeId::allocate(); + log && log("TypeDescrBase::require", xtag("new_td_id", new_td_id)); + if (s_type_table_v.size() <= new_td_id.id()) s_type_table_v.resize(new_td_id.id() + 1); diff --git a/src/reflect/init_reflect.cpp b/src/reflect/init_reflect.cpp index d95bf2e..bcfa34b 100644 --- a/src/reflect/init_reflect.cpp +++ b/src/reflect/init_reflect.cpp @@ -7,17 +7,17 @@ #include "xo/subsys/Subsystem.hpp" namespace xo { - void - InitSubsys::init() - { - /* placeholder -- expecting there to be non-trivial content soon */ - } /*init*/ + void + InitSubsys::init() + { + /* placeholder -- expecting there to be non-trivial content soon */ + } /*init*/ - InitEvidence - InitSubsys::require() - { - return Subsystem::provide("reflect", &init); - } /*require*/ + InitEvidence + InitSubsys::require() + { + return Subsystem::provide("reflect", &init); + } /*require*/ } /*namespace xo*/ /* end init_reflect.cpp */