xo-reflect: + TypeDescrBase::require_by_fn_info()

This commit is contained in:
Roland Conybeare 2024-06-18 17:16:28 -04:00
commit 276e1e5451
2 changed files with 17 additions and 1 deletions

View file

@ -192,7 +192,9 @@ namespace xo {
const std::string & canonical_name, const std::string & canonical_name,
std::unique_ptr<TypeDescrExtra> tdextra); std::unique_ptr<TypeDescrExtra> 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 **/ /** lookup type by canonical name **/
static TypeDescr lookup_by_name(const std::string & canonical_name); static TypeDescr lookup_by_name(const std::string & canonical_name);
static void print_reflected_types(std::ostream & os); static void print_reflected_types(std::ostream & os);

View file

@ -165,6 +165,20 @@ namespace xo {
return new_slot.get(); return new_slot.get();
} /*require*/ } /*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 TypeDescr
TypeDescrBase::lookup_by_name(const std::string & name) { TypeDescrBase::lookup_by_name(const std::string & name) {
auto ix = s_canonical_type_table_map.find(name); auto ix = s_canonical_type_table_map.find(name);