diff --git a/include/xo/reflect/TypeDescr.hpp b/include/xo/reflect/TypeDescr.hpp index 77303a8..4452f09 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 84579d5..c981224 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);