mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-15 11:52:08 +07:00
metadata binds for all types
This commit is contained in:
@@ -9,9 +9,19 @@
|
|||||||
#include "meta_base.hpp"
|
#include "meta_base.hpp"
|
||||||
|
|
||||||
#include "meta_binds.hpp"
|
#include "meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "meta_binds/array_bind.hpp"
|
||||||
#include "meta_binds/class_bind.hpp"
|
#include "meta_binds/class_bind.hpp"
|
||||||
#include "meta_binds/enum_bind.hpp"
|
#include "meta_binds/enum_bind.hpp"
|
||||||
|
#include "meta_binds/function_bind.hpp"
|
||||||
|
#include "meta_binds/member_bind.hpp"
|
||||||
|
#include "meta_binds/method_bind.hpp"
|
||||||
|
#include "meta_binds/nullptr_bind.hpp"
|
||||||
|
#include "meta_binds/number_bind.hpp"
|
||||||
|
#include "meta_binds/pointer_bind.hpp"
|
||||||
|
#include "meta_binds/reference_bind.hpp"
|
||||||
#include "meta_binds/scope_bind.hpp"
|
#include "meta_binds/scope_bind.hpp"
|
||||||
|
#include "meta_binds/void_bind.hpp"
|
||||||
|
|
||||||
#include "meta_indices.hpp"
|
#include "meta_indices.hpp"
|
||||||
#include "meta_indices/argument_index.hpp"
|
#include "meta_indices/argument_index.hpp"
|
||||||
|
|||||||
@@ -39,21 +39,10 @@ namespace meta_hpp::detail
|
|||||||
|
|
||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
struct class_opts final {
|
struct type_opts final {
|
||||||
metadata_map metadata{};
|
metadata_map metadata{};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct enum_opts final {
|
|
||||||
metadata_map metadata{};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct scope_opts final {
|
|
||||||
metadata_map metadata{};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace meta_hpp
|
|
||||||
{
|
|
||||||
struct argument_opts final {
|
struct argument_opts final {
|
||||||
std::string name{};
|
std::string name{};
|
||||||
metadata_map metadata{};
|
metadata_map metadata{};
|
||||||
@@ -86,17 +75,33 @@ namespace meta_hpp
|
|||||||
metadata_map metadata{};
|
metadata_map metadata{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct scope_opts final {
|
||||||
|
metadata_map metadata{};
|
||||||
|
};
|
||||||
|
|
||||||
struct variable_opts final {
|
struct variable_opts final {
|
||||||
metadata_map metadata{};
|
metadata_map metadata{};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::array_kind Array >
|
||||||
|
class array_bind final {
|
||||||
|
public:
|
||||||
|
explicit array_bind(type_opts opts);
|
||||||
|
operator array_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::array_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
template < detail::class_kind Class >
|
template < detail::class_kind Class >
|
||||||
class class_bind final {
|
class class_bind final {
|
||||||
public:
|
public:
|
||||||
explicit class_bind(class_opts opts);
|
explicit class_bind(type_opts opts);
|
||||||
operator class_type() const noexcept;
|
operator class_type() const noexcept;
|
||||||
|
|
||||||
// constructor_
|
// constructor_
|
||||||
@@ -223,7 +228,7 @@ namespace meta_hpp
|
|||||||
template < detail::enum_kind Enum >
|
template < detail::enum_kind Enum >
|
||||||
class enum_bind final {
|
class enum_bind final {
|
||||||
public:
|
public:
|
||||||
explicit enum_bind(enum_opts opts);
|
explicit enum_bind(type_opts opts);
|
||||||
operator enum_type() const noexcept;
|
operator enum_type() const noexcept;
|
||||||
|
|
||||||
enum_bind& evalue_(std::string name, Enum value);
|
enum_bind& evalue_(std::string name, Enum value);
|
||||||
@@ -233,6 +238,102 @@ namespace meta_hpp
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::function_kind Function >
|
||||||
|
class function_bind final {
|
||||||
|
public:
|
||||||
|
explicit function_bind(type_opts opts);
|
||||||
|
operator function_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::function_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::member_kind Member >
|
||||||
|
class member_bind final {
|
||||||
|
public:
|
||||||
|
explicit member_bind(type_opts opts);
|
||||||
|
operator member_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::member_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::method_kind Method >
|
||||||
|
class method_bind final {
|
||||||
|
public:
|
||||||
|
explicit method_bind(type_opts opts);
|
||||||
|
operator method_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::method_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::nullptr_kind Nullptr >
|
||||||
|
class nullptr_bind final {
|
||||||
|
public:
|
||||||
|
explicit nullptr_bind(type_opts opts);
|
||||||
|
operator nullptr_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::nullptr_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::number_kind Number >
|
||||||
|
class number_bind final {
|
||||||
|
public:
|
||||||
|
explicit number_bind(type_opts opts);
|
||||||
|
operator number_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::number_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::pointer_kind Pointer >
|
||||||
|
class pointer_bind final {
|
||||||
|
public:
|
||||||
|
explicit pointer_bind(type_opts opts);
|
||||||
|
operator pointer_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::pointer_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::reference_kind Reference >
|
||||||
|
class reference_bind final {
|
||||||
|
public:
|
||||||
|
explicit reference_bind(type_opts opts);
|
||||||
|
operator reference_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::reference_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::void_kind Void >
|
||||||
|
class void_bind final {
|
||||||
|
public:
|
||||||
|
explicit void_bind(type_opts opts);
|
||||||
|
operator void_type() const noexcept;
|
||||||
|
private:
|
||||||
|
detail::void_type_data_ptr data_;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
class scope_bind final {
|
class scope_bind final {
|
||||||
@@ -298,16 +399,64 @@ namespace meta_hpp
|
|||||||
|
|
||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
|
template < detail::array_kind Array >
|
||||||
|
array_bind<Array> array_(type_opts opts = {}) {
|
||||||
|
return array_bind<Array>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
template < detail::class_kind Class >
|
template < detail::class_kind Class >
|
||||||
class_bind<Class> class_(class_opts opts = {}) {
|
class_bind<Class> class_(type_opts opts = {}) {
|
||||||
return class_bind<Class>{std::move(opts)};
|
return class_bind<Class>{std::move(opts)};
|
||||||
}
|
}
|
||||||
|
|
||||||
template < detail::enum_kind Enum >
|
template < detail::enum_kind Enum >
|
||||||
enum_bind<Enum> enum_(enum_opts opts = {}) {
|
enum_bind<Enum> enum_(type_opts opts = {}) {
|
||||||
return enum_bind<Enum>{std::move(opts)};
|
return enum_bind<Enum>{std::move(opts)};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < detail::function_kind Function >
|
||||||
|
function_bind<Function> function_(type_opts opts = {}) {
|
||||||
|
return function_bind<Function>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::member_kind Member >
|
||||||
|
member_bind<Member> member_(type_opts opts = {}) {
|
||||||
|
return member_bind<Member>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::method_kind Method >
|
||||||
|
method_bind<Method> method_(type_opts opts = {}) {
|
||||||
|
return method_bind<Method>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::nullptr_kind Nullptr >
|
||||||
|
nullptr_bind<Nullptr> nullptr_(type_opts opts = {}) {
|
||||||
|
return nullptr_bind<Nullptr>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::number_kind Number >
|
||||||
|
number_bind<Number> number_(type_opts opts = {}) {
|
||||||
|
return number_bind<Number>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::pointer_kind Pointer >
|
||||||
|
pointer_bind<Pointer> pointer_(type_opts opts = {}) {
|
||||||
|
return pointer_bind<Pointer>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::reference_kind Reference >
|
||||||
|
reference_bind<Reference> reference_(type_opts opts = {}) {
|
||||||
|
return reference_bind<Reference>{std::move(opts)};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::void_kind Void >
|
||||||
|
void_bind<Void> void_(type_opts opts = {}) {
|
||||||
|
return void_bind<Void>{std::move(opts)};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
inline scope_bind local_scope_(std::string name, scope_opts opts = {}) {
|
inline scope_bind local_scope_(std::string name, scope_opts opts = {}) {
|
||||||
return scope_bind{std::move(name), std::move(opts), scope_bind::local_tag()};
|
return scope_bind{std::move(name), std::move(opts), scope_bind::local_tag()};
|
||||||
}
|
}
|
||||||
|
|||||||
27
headers/meta.hpp/meta_binds/array_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/array_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::array_kind Array >
|
||||||
|
array_bind<Array>::array_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Array>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::array_kind Array >
|
||||||
|
array_bind<Array>::operator array_type() const noexcept {
|
||||||
|
return array_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
template < detail::class_kind Class >
|
template < detail::class_kind Class >
|
||||||
class_bind<Class>::class_bind(class_opts opts)
|
class_bind<Class>::class_bind(type_opts opts)
|
||||||
: data_{detail::type_access(detail::resolve_type<Class>())} {
|
: data_{detail::type_access(detail::resolve_type<Class>())} {
|
||||||
data_->metadata.swap(opts.metadata);
|
data_->metadata.swap(opts.metadata);
|
||||||
data_->metadata.merge(opts.metadata);
|
data_->metadata.merge(opts.metadata);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
namespace meta_hpp
|
namespace meta_hpp
|
||||||
{
|
{
|
||||||
template < detail::enum_kind Enum >
|
template < detail::enum_kind Enum >
|
||||||
enum_bind<Enum>::enum_bind(enum_opts opts)
|
enum_bind<Enum>::enum_bind(type_opts opts)
|
||||||
: data_{detail::type_access(detail::resolve_type<Enum>())} {
|
: data_{detail::type_access(detail::resolve_type<Enum>())} {
|
||||||
data_->metadata.swap(opts.metadata);
|
data_->metadata.swap(opts.metadata);
|
||||||
data_->metadata.merge(opts.metadata);
|
data_->metadata.merge(opts.metadata);
|
||||||
|
|||||||
27
headers/meta.hpp/meta_binds/function_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/function_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::function_kind Function >
|
||||||
|
function_bind<Function>::function_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Function>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::function_kind Function >
|
||||||
|
function_bind<Function>::operator function_type() const noexcept {
|
||||||
|
return function_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/member_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/member_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::member_kind Member >
|
||||||
|
member_bind<Member>::member_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Member>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::member_kind Member >
|
||||||
|
member_bind<Member>::operator member_type() const noexcept {
|
||||||
|
return member_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/method_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/method_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::method_kind Method >
|
||||||
|
method_bind<Method>::method_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Method>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::method_kind Method >
|
||||||
|
method_bind<Method>::operator method_type() const noexcept {
|
||||||
|
return method_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/nullptr_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/nullptr_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::nullptr_kind Nullptr >
|
||||||
|
nullptr_bind<Nullptr>::nullptr_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Nullptr>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::nullptr_kind Nullptr >
|
||||||
|
nullptr_bind<Nullptr>::operator nullptr_type() const noexcept {
|
||||||
|
return nullptr_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/number_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/number_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::number_kind Number >
|
||||||
|
number_bind<Number>::number_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Number>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::number_kind Number >
|
||||||
|
number_bind<Number>::operator number_type() const noexcept {
|
||||||
|
return number_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/pointer_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/pointer_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::pointer_kind Pointer >
|
||||||
|
pointer_bind<Pointer>::pointer_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Pointer>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::pointer_kind Pointer >
|
||||||
|
pointer_bind<Pointer>::operator pointer_type() const noexcept {
|
||||||
|
return pointer_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/reference_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/reference_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::reference_kind Reference >
|
||||||
|
reference_bind<Reference>::reference_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<Reference>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::reference_kind Reference >
|
||||||
|
reference_bind<Reference>::operator reference_type() const noexcept {
|
||||||
|
return reference_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
27
headers/meta.hpp/meta_binds/void_bind.hpp
Normal file
27
headers/meta.hpp/meta_binds/void_bind.hpp
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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-2022, by Matvey Cherevko (blackmatov@gmail.com)
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "../meta_base.hpp"
|
||||||
|
#include "../meta_binds.hpp"
|
||||||
|
|
||||||
|
#include "../meta_detail/type_registry.hpp"
|
||||||
|
|
||||||
|
namespace meta_hpp
|
||||||
|
{
|
||||||
|
template < detail::void_kind Void >
|
||||||
|
void_bind<Void>::void_bind(type_opts opts)
|
||||||
|
: data_{detail::type_access(detail::resolve_type<void>())} {
|
||||||
|
data_->metadata.swap(opts.metadata);
|
||||||
|
data_->metadata.merge(opts.metadata);
|
||||||
|
}
|
||||||
|
|
||||||
|
template < detail::void_kind Void >
|
||||||
|
void_bind<Void>::operator void_type() const noexcept {
|
||||||
|
return void_type{data_};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -244,3 +244,89 @@ TEST_CASE("meta/meta_states/metadata/class") {
|
|||||||
CHECK(ivec2_iadd.get_argument(1).get_metadata().at("desc") == "r-arg"s);
|
CHECK(ivec2_iadd.get_argument(1).get_metadata().at("desc") == "r-arg"s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("meta/meta_states/metadata/other") {
|
||||||
|
namespace meta = meta_hpp;
|
||||||
|
using namespace std::string_literals;
|
||||||
|
|
||||||
|
SUBCASE("array") {
|
||||||
|
meta::array_<int[]>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"int[]-type"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int[]>().get_metadata().at("desc") == "int[]-type"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("function") {
|
||||||
|
meta::function_<int(*)(int)>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"int->int"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int(*)(int)>().get_metadata().at("desc") == "int->int"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("member") {
|
||||||
|
meta::member_<int ivec2::*>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"ivec2::int"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int ivec2::*>().get_metadata().at("desc") == "ivec2::int"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("method") {
|
||||||
|
meta::method_<int (ivec2::*)(int)>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"ivec2(int -> int)"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int (ivec2::*)(int)>().get_metadata().at("desc") == "ivec2(int -> int)"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("nullptr") {
|
||||||
|
meta::nullptr_<nullptr_t>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"nullptr_t"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<nullptr_t>().get_metadata().at("desc") == "nullptr_t"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("number") {
|
||||||
|
meta::number_<int>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"int-type"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int>().get_metadata().at("desc") == "int-type"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("pointer") {
|
||||||
|
meta::pointer_<int*>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"int*-type"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int*>().get_metadata().at("desc") == "int*-type"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("reference") {
|
||||||
|
meta::reference_<int&>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"int&-type"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<int&>().get_metadata().at("desc") == "int&-type"s);
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBCASE("void") {
|
||||||
|
meta::void_<void>({
|
||||||
|
.metadata{
|
||||||
|
{"desc", meta::uvalue{"void-type"s}}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CHECK(meta::resolve_type<void>().get_metadata().at("desc") == "void-type"s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user