diff --git a/headers/meta.hpp/meta_infos/_infos_fwd.hpp b/headers/meta.hpp/meta_infos/_infos_fwd.hpp new file mode 100644 index 0000000..62999e5 --- /dev/null +++ b/headers/meta.hpp/meta_infos/_infos_fwd.hpp @@ -0,0 +1,11 @@ +/******************************************************************************* + * This file is part of the "https://github.com/blackmatov/meta.hpp" + * For conditions of distribution and use, see copyright notice in LICENSE.md + * Copyright (C) 2021, by Matvey Cherevko (blackmatov@gmail.com) + ******************************************************************************/ + +#pragma once + +#include "../meta_fwd.hpp" +#include "../meta_types.hpp" +#include "../meta_utilities.hpp" diff --git a/headers/meta.hpp/meta_infos/class_info.hpp b/headers/meta.hpp/meta_infos/class_info.hpp index 3b8e2c5..2095cf7 100644 --- a/headers/meta.hpp/meta_infos/class_info.hpp +++ b/headers/meta.hpp/meta_infos/class_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "ctor_info.hpp" #include "data_info.hpp" @@ -26,6 +25,7 @@ namespace meta_hpp explicit operator bool() const noexcept; const std::string& name() const noexcept; + const class_type& type() const noexcept; public: template < typename F > void visit(F&& f) const; @@ -53,7 +53,8 @@ namespace meta_hpp private: template < typename Class > friend class class_; - explicit class_info(std::string name); + template < typename Class > + explicit class_info(typename_arg_t, std::string name); private: struct state; std::shared_ptr state_; @@ -64,6 +65,7 @@ namespace meta_hpp { struct class_info::state final { std::string name; + class_type type; class_info_map classes; ctor_info_map ctors; data_info_map datas; @@ -88,6 +90,10 @@ namespace meta_hpp inline const std::string& class_info::name() const noexcept { return state_->name; } + + inline const class_type& class_info::type() const noexcept { + return state_->type; + } } namespace meta_hpp @@ -155,9 +161,11 @@ namespace meta_hpp namespace meta_hpp { - inline class_info::class_info(std::string name) + template < typename Class > + inline class_info::class_info(typename_arg_t, std::string name) : state_{std::make_shared(state{ std::move(name), + class_type{typename_arg}, {}, {}, {}, {}, {}, {}, {} })} {} } diff --git a/headers/meta.hpp/meta_infos/ctor_info.hpp b/headers/meta.hpp/meta_infos/ctor_info.hpp index e2bbdc1..464d28c 100644 --- a/headers/meta.hpp/meta_infos/ctor_info.hpp +++ b/headers/meta.hpp/meta_infos/ctor_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "data_info.hpp" @@ -19,6 +18,8 @@ namespace meta_hpp void merge(const ctor_info& other); explicit operator bool() const noexcept; + + const ctor_type& type() const noexcept; public: template < typename F > void visit(F&& f) const; @@ -39,6 +40,7 @@ namespace meta_hpp namespace meta_hpp { struct ctor_info::state final { + ctor_type type; data_info_map datas; }; } @@ -53,6 +55,10 @@ namespace meta_hpp inline ctor_info::operator bool() const noexcept { return !!state_; } + + inline const ctor_type& ctor_info::type() const noexcept { + return state_->type; + } } namespace meta_hpp @@ -75,6 +81,7 @@ namespace meta_hpp template < typename Class, typename... Args > inline ctor_info::ctor_info(typename_arg_t, typename_arg_t) : state_{std::make_shared(state{ + ctor_type{typename_arg, typename_arg}, {} })} {} } diff --git a/headers/meta.hpp/meta_infos/data_info.hpp b/headers/meta.hpp/meta_infos/data_info.hpp index 810f46d..560d31c 100644 --- a/headers/meta.hpp/meta_infos/data_info.hpp +++ b/headers/meta.hpp/meta_infos/data_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" namespace meta_hpp { diff --git a/headers/meta.hpp/meta_infos/enum_info.hpp b/headers/meta.hpp/meta_infos/enum_info.hpp index 96cc666..9b13e68 100644 --- a/headers/meta.hpp/meta_infos/enum_info.hpp +++ b/headers/meta.hpp/meta_infos/enum_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "data_info.hpp" #include "evalue_info.hpp" @@ -22,6 +21,7 @@ namespace meta_hpp explicit operator bool() const noexcept; const std::string& name() const noexcept; + const enum_type& type() const noexcept; public: template < typename F > void visit(F&& f) const; @@ -34,7 +34,8 @@ namespace meta_hpp private: template < typename Enum > friend class enum_; - explicit enum_info(std::string name); + template < typename Enum > + explicit enum_info(typename_arg_t, std::string name); private: struct state; std::shared_ptr state_; @@ -45,6 +46,7 @@ namespace meta_hpp { struct enum_info::state final { std::string name; + enum_type type; data_info_map datas; evalue_info_map evalues; }; @@ -64,6 +66,10 @@ namespace meta_hpp inline const std::string& enum_info::name() const noexcept { return state_->name; } + + inline const enum_type& enum_info::type() const noexcept { + return state_->type; + } } namespace meta_hpp @@ -91,9 +97,11 @@ namespace meta_hpp namespace meta_hpp { - inline enum_info::enum_info(std::string name) + template < typename Enum > + inline enum_info::enum_info(typename_arg_t, std::string name) : state_{std::make_shared(state{ std::move(name), + enum_type{typename_arg}, {}, {} })} {} } diff --git a/headers/meta.hpp/meta_infos/evalue_info.hpp b/headers/meta.hpp/meta_infos/evalue_info.hpp index 9d0adee..a1c988b 100644 --- a/headers/meta.hpp/meta_infos/evalue_info.hpp +++ b/headers/meta.hpp/meta_infos/evalue_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "data_info.hpp" diff --git a/headers/meta.hpp/meta_infos/function_info.hpp b/headers/meta.hpp/meta_infos/function_info.hpp index e979464..d4efcb7 100644 --- a/headers/meta.hpp/meta_infos/function_info.hpp +++ b/headers/meta.hpp/meta_infos/function_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "data_info.hpp" @@ -21,6 +20,7 @@ namespace meta_hpp explicit operator bool() const noexcept; const std::string& name() const noexcept; + const function_type& type() const noexcept; public: template < typename F > void visit(F&& f) const; @@ -42,6 +42,7 @@ namespace meta_hpp { struct function_info::state final { std::string name; + function_type type; data_info_map datas; }; } @@ -60,6 +61,10 @@ namespace meta_hpp inline const std::string& function_info::name() const noexcept { return state_->name; } + + inline const function_type& function_info::type() const noexcept { + return state_->type; + } } namespace meta_hpp @@ -83,6 +88,7 @@ namespace meta_hpp inline function_info::function_info(std::string name, Function instance) : state_{std::make_shared(state{ std::move(name), + function_type{typename_arg}, {} })} { (void)instance; diff --git a/headers/meta.hpp/meta_infos/member_info.hpp b/headers/meta.hpp/meta_infos/member_info.hpp index 443705f..ab5b147 100644 --- a/headers/meta.hpp/meta_infos/member_info.hpp +++ b/headers/meta.hpp/meta_infos/member_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "data_info.hpp" @@ -21,6 +20,7 @@ namespace meta_hpp explicit operator bool() const noexcept; const std::string& name() const noexcept; + const member_type& type() const noexcept; public: template < typename F > void visit(F&& f) const; @@ -42,6 +42,7 @@ namespace meta_hpp { struct member_info::state final { std::string name; + member_type type; data_info_map datas; }; } @@ -60,6 +61,10 @@ namespace meta_hpp inline const std::string& member_info::name() const noexcept { return state_->name; } + + inline const member_type& member_info::type() const noexcept { + return state_->type; + } } namespace meta_hpp @@ -83,6 +88,7 @@ namespace meta_hpp inline member_info::member_info(std::string name, Member instance) : state_{std::make_shared(state{ std::move(name), + member_type{typename_arg}, {} })} { (void)instance; diff --git a/headers/meta.hpp/meta_infos/method_info.hpp b/headers/meta.hpp/meta_infos/method_info.hpp index 335643d..0d99b9d 100644 --- a/headers/meta.hpp/meta_infos/method_info.hpp +++ b/headers/meta.hpp/meta_infos/method_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "data_info.hpp" @@ -21,6 +20,7 @@ namespace meta_hpp explicit operator bool() const noexcept; const std::string& name() const noexcept; + const method_type& type() const noexcept; public: template < typename F > void visit(F&& f) const; @@ -42,6 +42,7 @@ namespace meta_hpp { struct method_info::state final { std::string name; + method_type type; data_info_map datas; }; } @@ -60,6 +61,10 @@ namespace meta_hpp inline const std::string& method_info::name() const noexcept { return state_->name; } + + inline const method_type& method_info::type() const noexcept { + return state_->type; + } } namespace meta_hpp @@ -83,6 +88,7 @@ namespace meta_hpp inline method_info::method_info(std::string name, Method instance) : state_{std::make_shared(state{ std::move(name), + method_type{typename_arg}, {} })} { (void)instance; diff --git a/headers/meta.hpp/meta_infos/namespace_info.hpp b/headers/meta.hpp/meta_infos/namespace_info.hpp index 73e8d33..6f7638f 100644 --- a/headers/meta.hpp/meta_infos/namespace_info.hpp +++ b/headers/meta.hpp/meta_infos/namespace_info.hpp @@ -6,8 +6,7 @@ #pragma once -#include "../meta_fwd.hpp" -#include "../meta_utilities.hpp" +#include "_infos_fwd.hpp" #include "class_info.hpp" #include "data_info.hpp"