From 276e1e545115334b6d9283cb99c3687a00f41082 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 18 Jun 2024 17:16:28 -0400 Subject: [PATCH] xo-reflect: + TypeDescrBase::require_by_fn_info() --- include/xo/reflect/TypeDescr.hpp | 4 +++- src/reflect/TypeDescr.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/xo/reflect/TypeDescr.hpp b/include/xo/reflect/TypeDescr.hpp index 77303a83..4452f094 100644 --- a/include/xo/reflect/TypeDescr.hpp +++ b/include/xo/reflect/TypeDescr.hpp @@ -192,7 +192,9 @@ namespace xo { const std::string & canonical_name, std::unique_ptr tdextra); - /* print table of reflected types to os */ + /** Create type-description for function from input ingredients. **/ + static TypeDescrW require_by_fn_info(const FunctionTdxInfo & fn_info); + /** lookup type by canonical name **/ static TypeDescr lookup_by_name(const std::string & canonical_name); static void print_reflected_types(std::ostream & os); diff --git a/src/reflect/TypeDescr.cpp b/src/reflect/TypeDescr.cpp index 84579d5b..c9812240 100644 --- a/src/reflect/TypeDescr.cpp +++ b/src/reflect/TypeDescr.cpp @@ -165,6 +165,20 @@ namespace xo { return new_slot.get(); } /*require*/ + TypeDescrW + TypeDescrBase::require_by_fn_info(const FunctionTdxInfo & fn_info) { + auto ix = s_function_type_map.find(fn_info); + + if (ix != s_function_type_map.end()) + return ix->second; + + auto fn_tdextra = FunctionTdx::make_function(fn_info); + + return require(nullptr /*native_tinfo - n/avail on this path*/, + fn_info.make_canonical_name(), + std::move(fn_tdextra)); + } /*require_by_fn_info*/ + TypeDescr TypeDescrBase::lookup_by_name(const std::string & name) { auto ix = s_canonical_type_table_map.find(name);