xo-reflect: + FunctionTdx::make_function()
This commit is contained in:
parent
ef41f9b280
commit
b06c55b98b
2 changed files with 17 additions and 11 deletions
|
|
@ -24,6 +24,10 @@ namespace xo {
|
|||
static std::unique_ptr<FunctionTdx> make_function(TypeDescr retval_td,
|
||||
std::vector<TypeDescr> arg_td_v,
|
||||
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 -----
|
||||
|
||||
|
|
@ -39,9 +43,7 @@ namespace xo {
|
|||
virtual bool fn_is_noexcept() const override { return info_.is_noexcept_; }
|
||||
|
||||
private:
|
||||
FunctionTdx(TypeDescr retval_td,
|
||||
bool is_noexcept,
|
||||
std::vector<TypeDescr> arg_td_v);
|
||||
FunctionTdx(const FunctionTdxInfo & fn_info);
|
||||
|
||||
private:
|
||||
/** ingredients in complete function type description **/
|
||||
|
|
|
|||
|
|
@ -11,17 +11,21 @@ namespace xo {
|
|||
std::vector<TypeDescr> arg_td_v,
|
||||
bool is_noexcept)
|
||||
{
|
||||
return std::unique_ptr<FunctionTdx>(new FunctionTdx(retval_td,
|
||||
is_noexcept,
|
||||
std::move(arg_td_v)));
|
||||
return make_function(FunctionTdxInfo(retval_td,
|
||||
std::move(arg_td_v),
|
||||
is_noexcept));
|
||||
}
|
||||
|
||||
FunctionTdx::FunctionTdx(TypeDescr retval_td,
|
||||
bool is_noexcept,
|
||||
std::vector<TypeDescr> arg_td_v)
|
||||
: info_{retval_td, std::move(arg_td_v), is_noexcept}
|
||||
std::unique_ptr<FunctionTdx>
|
||||
FunctionTdx::make_function(const FunctionTdxInfo & fn_info)
|
||||
{
|
||||
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?");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue