type for infos

This commit is contained in:
BlackMATov
2021-08-03 10:57:55 +07:00
parent adb8141d14
commit 0601285e9c
10 changed files with 71 additions and 22 deletions

View File

@@ -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"

View File

@@ -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<Class>, std::string name);
private:
struct state;
std::shared_ptr<state> 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<Class>, std::string name)
: state_{std::make_shared<state>(state{
std::move(name),
class_type{typename_arg<Class>},
{}, {}, {}, {}, {}, {}, {}
})} {}
}

View File

@@ -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<Class>, typename_arg_t<Args...>)
: state_{std::make_shared<state>(state{
ctor_type{typename_arg<Class>, typename_arg<Args...>},
{}
})} {}
}

View File

@@ -6,8 +6,7 @@
#pragma once
#include "../meta_fwd.hpp"
#include "../meta_utilities.hpp"
#include "_infos_fwd.hpp"
namespace meta_hpp
{

View File

@@ -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<Enum>, std::string name);
private:
struct state;
std::shared_ptr<state> 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<Enum>, std::string name)
: state_{std::make_shared<state>(state{
std::move(name),
enum_type{typename_arg<Enum>},
{}, {}
})} {}
}

View File

@@ -6,8 +6,7 @@
#pragma once
#include "../meta_fwd.hpp"
#include "../meta_utilities.hpp"
#include "_infos_fwd.hpp"
#include "data_info.hpp"

View File

@@ -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>(state{
std::move(name),
function_type{typename_arg<Function>},
{}
})} {
(void)instance;

View File

@@ -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>(state{
std::move(name),
member_type{typename_arg<Member>},
{}
})} {
(void)instance;

View File

@@ -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>(state{
std::move(name),
method_type{typename_arg<Method>},
{}
})} {
(void)instance;

View File

@@ -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"