xo-reflect: + FunctionTdx::make_function()

This commit is contained in:
Roland Conybeare 2024-06-18 17:17:26 -04:00
commit b06c55b98b
2 changed files with 17 additions and 11 deletions

View file

@ -24,6 +24,10 @@ namespace xo {
static std::unique_ptr<FunctionTdx> make_function(TypeDescr retval_td, static std::unique_ptr<FunctionTdx> make_function(TypeDescr retval_td,
std::vector<TypeDescr> arg_td_v, std::vector<TypeDescr> arg_td_v,
bool is_noexcept); bool is_noexcept);
/** create instance from FunctionTdxInfo
* @param fn_info. function ingredients -- return type, arg types, noexcept
**/
static std::unique_ptr<FunctionTdx> make_function(const FunctionTdxInfo & fn_info);
// ----- Inherited from TypeDescrExtra ----- // ----- Inherited from TypeDescrExtra -----
@ -39,9 +43,7 @@ namespace xo {
virtual bool fn_is_noexcept() const override { return info_.is_noexcept_; } virtual bool fn_is_noexcept() const override { return info_.is_noexcept_; }
private: private:
FunctionTdx(TypeDescr retval_td, FunctionTdx(const FunctionTdxInfo & fn_info);
bool is_noexcept,
std::vector<TypeDescr> arg_td_v);
private: private:
/** ingredients in complete function type description **/ /** ingredients in complete function type description **/

View file

@ -11,17 +11,21 @@ namespace xo {
std::vector<TypeDescr> arg_td_v, std::vector<TypeDescr> arg_td_v,
bool is_noexcept) bool is_noexcept)
{ {
return std::unique_ptr<FunctionTdx>(new FunctionTdx(retval_td, return make_function(FunctionTdxInfo(retval_td,
is_noexcept, std::move(arg_td_v),
std::move(arg_td_v))); is_noexcept));
} }
FunctionTdx::FunctionTdx(TypeDescr retval_td, std::unique_ptr<FunctionTdx>
bool is_noexcept, FunctionTdx::make_function(const FunctionTdxInfo & fn_info)
std::vector<TypeDescr> arg_td_v)
: info_{retval_td, std::move(arg_td_v), is_noexcept}
{ {
if (!retval_td) { return std::unique_ptr<FunctionTdx>(new FunctionTdx(fn_info));
}
FunctionTdx::FunctionTdx(const FunctionTdxInfo & fn_info)
: info_{fn_info}
{
if (!info_.retval_td_) {
throw std::runtime_error("FunctionTdx::ctor: null return type?"); throw std::runtime_error("FunctionTdx::ctor: null return type?");
} }
} }