mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-14 19:41:29 +07:00
new way to bind metadata and arguments
This commit is contained in:
@@ -36,29 +36,25 @@ TEST_CASE("meta/meta_manuals/metadata") {
|
||||
meta::class_<ivec3>(meta::metadata_() // for class type
|
||||
("tooltip", "3D Vector"s)
|
||||
)
|
||||
.member_("x", &ivec3::x, {
|
||||
.metadata = meta::metadata_() // for class members
|
||||
.member_("x", &ivec3::x, meta::metadata_() // for class members
|
||||
("tooltip", "X-Coordinate"s)
|
||||
})
|
||||
.member_("y", &ivec3::y, {
|
||||
.metadata = meta::metadata_()
|
||||
)
|
||||
.member_("y", &ivec3::y, meta::metadata_()
|
||||
("tooltip", "Y-Coordinate"s)
|
||||
})
|
||||
.member_("z", &ivec3::z, {
|
||||
.metadata = meta::metadata_()
|
||||
)
|
||||
.member_("z", &ivec3::z, meta::metadata_()
|
||||
("tooltip", "Z-Coordinate"s)
|
||||
});
|
||||
);
|
||||
|
||||
const meta::scope math_scope = meta::local_scope_("math")
|
||||
.typedef_<ivec3>("ivec3")
|
||||
.function_("cross", &cross, {
|
||||
.arguments = meta::arguments_()
|
||||
.function_("cross", &cross,
|
||||
meta::arguments_()
|
||||
("first vector")
|
||||
("second vector", meta::metadata_() // even function arguments can have metadata
|
||||
("tooltip", "The second cross product argument"s)),
|
||||
.metadata = meta::metadata_() // for functions in a scope
|
||||
("tooltip", "Cross product of vectors"s),
|
||||
});
|
||||
meta::metadata_() // for functions in a scope
|
||||
("tooltip", "Cross product of vectors"s));
|
||||
|
||||
// after binding, you can use it as you wish
|
||||
// in this example, I'm just going to print all of them to stdout
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
49
develop/untests/meta_base/type_list_tests.cpp
Normal file
49
develop/untests/meta_base/type_list_tests.cpp
Normal file
@@ -0,0 +1,49 @@
|
||||
/*******************************************************************************
|
||||
* 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-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#include <meta.hpp/meta_all.hpp>
|
||||
#include <doctest/doctest.h>
|
||||
|
||||
TEST_CASE("meta/meta_base/type_list") {
|
||||
namespace meta = meta_hpp;
|
||||
using meta::detail::type_list;
|
||||
|
||||
SUBCASE("type_list_at_t") {
|
||||
using meta::detail::type_list_at_t;
|
||||
|
||||
static_assert(std::is_same_v<type_list_at_t<0, type_list<int, float>>, int>);
|
||||
static_assert(std::is_same_v<type_list_at_t<1, type_list<int, float>>, float>);
|
||||
}
|
||||
|
||||
SUBCASE("type_list_arity_v") {
|
||||
using meta::detail::type_list_arity_v;
|
||||
|
||||
static_assert(type_list_arity_v<type_list<>> == 0);
|
||||
static_assert(type_list_arity_v<type_list<int>> == 1);
|
||||
static_assert(type_list_arity_v<type_list<int, float>> == 2);
|
||||
}
|
||||
|
||||
SUBCASE("type_list_count_of_v") {
|
||||
using meta::detail::type_list_count_of_v;
|
||||
|
||||
static_assert(type_list_count_of_v<std::is_integral, type_list<>> == 0);
|
||||
static_assert(type_list_count_of_v<std::is_integral, type_list<float>> == 0);
|
||||
static_assert(type_list_count_of_v<std::is_integral, type_list<int, float>> == 1);
|
||||
static_assert(type_list_count_of_v<std::is_integral, type_list<int, float, int>> == 2);
|
||||
static_assert(type_list_count_of_v<std::is_integral, type_list<int, float, int, double, long>> == 3);
|
||||
}
|
||||
|
||||
SUBCASE("type_list_first_of_t") {
|
||||
using meta::detail::type_list_first_of_t;
|
||||
|
||||
static_assert(std::is_same_v<type_list_first_of_t<std::is_integral, double, type_list<int, float>>, int>);
|
||||
static_assert(std::is_same_v<type_list_first_of_t<std::is_integral, double, type_list<float, int>>, int>);
|
||||
static_assert(std::is_same_v<type_list_first_of_t<std::is_integral, double, type_list<int, float, long>>, int>);
|
||||
static_assert(std::is_same_v<type_list_first_of_t<std::is_integral, double, type_list<float, long, int>>, long>);
|
||||
|
||||
static_assert(std::is_same_v<type_list_first_of_t<std::is_integral, long, type_list<float, double>>, long>);
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,8 @@ TEST_CASE("meta/meta_states/dtor") {
|
||||
meta::class_<clazz_virtual_dtor>();
|
||||
|
||||
meta::class_<clazz_dtor_metadata>()
|
||||
.destructor_({
|
||||
.metadata = meta::metadata_()
|
||||
("desc", "virtual dtor"s)
|
||||
});
|
||||
.destructor_(meta::metadata_()
|
||||
("desc", "virtual dtor"s));
|
||||
|
||||
SUBCASE("closed_dtor") {
|
||||
const meta::class_type clazz_type = meta::resolve_type<clazz_closed_dtor>();
|
||||
|
||||
@@ -27,8 +27,8 @@ TEST_CASE("meta/meta_states/function2") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
meta::class_<ivec2>()
|
||||
.function_("iadd", &ivec2::iadd, { "l" })
|
||||
.function_("isub", &ivec2::isub, { "l", "r" });
|
||||
.function_("iadd", &ivec2::iadd, meta::arguments_()("l"))
|
||||
.function_("isub", &ivec2::isub, meta::arguments_()("l")("r"));
|
||||
|
||||
const meta::class_type ivec2_type = meta::resolve_type<ivec2>();
|
||||
REQUIRE(ivec2_type);
|
||||
|
||||
@@ -31,7 +31,13 @@ namespace
|
||||
static ivec2 iadd(const ivec2& l, const ivec2& r) noexcept {
|
||||
return {l.x + r.x, l.y + r.y};
|
||||
}
|
||||
|
||||
static const ivec2 zero;
|
||||
static const ivec2 unit;
|
||||
};
|
||||
|
||||
const ivec2 ivec2::zero{0, 0};
|
||||
const ivec2 ivec2::unit{1, 1};
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_states/metadata/enum") {
|
||||
@@ -41,15 +47,12 @@ TEST_CASE("meta/meta_states/metadata/enum") {
|
||||
meta::enum_<color>(meta::metadata_()
|
||||
("desc1", "enum-desc1"s)
|
||||
("desc2", "enum-desc2"s))
|
||||
.evalue_("red", color::red, {
|
||||
.metadata{meta::metadata_()("desc1", "red-color"s)}
|
||||
})
|
||||
.evalue_("green", color::green, {
|
||||
.metadata{meta::metadata_()("desc1", "green-color"s)}
|
||||
})
|
||||
.evalue_("blue", color::blue, {
|
||||
.metadata{meta::metadata_()("desc1", "blue-color"s)}
|
||||
});
|
||||
.evalue_("red", color::red,
|
||||
meta::metadata_()("desc1", "red-color"s))
|
||||
.evalue_("green", color::green,
|
||||
meta::metadata_()("desc1", "green-color"s))
|
||||
.evalue_("blue", color::blue,
|
||||
meta::metadata_()("desc1", "blue-color"s));
|
||||
|
||||
// metadata override
|
||||
|
||||
@@ -58,10 +61,9 @@ TEST_CASE("meta/meta_states/metadata/enum") {
|
||||
("desc3", "new-enum-desc3"s));
|
||||
|
||||
meta::enum_<color>()
|
||||
.evalue_("red", color::red, {
|
||||
.metadata = meta::metadata_()
|
||||
("desc2", "new-red-color"s)
|
||||
});
|
||||
.evalue_("red", color::red,
|
||||
meta::metadata_()
|
||||
("desc2", "new-red-color"s));
|
||||
|
||||
//
|
||||
|
||||
@@ -89,36 +91,28 @@ TEST_CASE("meta/meta_states/metadata/class") {
|
||||
meta::class_<ivec2>(meta::metadata_()
|
||||
("desc1", "class-desc1"s)
|
||||
("desc2", "class-desc2"s))
|
||||
.constructor_<int>({
|
||||
.arguments{meta::arguments_()
|
||||
("v", meta::metadata_()("desc", "the ctor arg"s))},
|
||||
.metadata{meta::metadata_()("desc", "one arg 2d vector ctor"s)},
|
||||
})
|
||||
.constructor_<int, int>({
|
||||
.arguments{meta::arguments_()
|
||||
("x", meta::metadata_()("desc", "the 1st ctor arg"s))
|
||||
("y", meta::metadata_()("desc", "the 2nd ctor arg"s))
|
||||
},
|
||||
.metadata{meta::metadata_()("desc", "two args 2d vector ctor"s)}
|
||||
})
|
||||
.member_("x", &ivec2::x, {
|
||||
.metadata{meta::metadata_()("desc", "x-member"s)}
|
||||
})
|
||||
.member_("y", &ivec2::y, {
|
||||
.metadata{meta::metadata_()("desc", "y-member"s)}
|
||||
})
|
||||
.method_("add", &ivec2::add, {
|
||||
.arguments{meta::arguments_()
|
||||
("other", meta::metadata_()("desc", "other-arg"s))},
|
||||
.metadata{meta::metadata_()("desc", "add-method"s)}
|
||||
})
|
||||
.function_("iadd", &ivec2::iadd, {
|
||||
.arguments{meta::arguments_()
|
||||
("l", meta::metadata_()("desc", "l-arg"s))
|
||||
("r", meta::metadata_()("desc", "r-arg"s))
|
||||
},
|
||||
.metadata{meta::metadata_()("desc", "iadd-function"s)}
|
||||
});
|
||||
.constructor_<int>(
|
||||
meta::arguments_()
|
||||
("v", meta::metadata_()("desc", "the ctor arg"s)),
|
||||
meta::metadata_()("desc", "one arg 2d vector ctor"s))
|
||||
.constructor_<int, int>(
|
||||
meta::argument_("x", meta::metadata_("desc", "the 1st ctor arg"s)),
|
||||
meta::argument_("y", meta::metadata_("desc", "the 2nd ctor arg"s)),
|
||||
meta::metadata_()("desc", "two args 2d vector ctor"s))
|
||||
.member_("x", &ivec2::x, meta::metadata_()("desc", "x-member"s))
|
||||
.member_("y", &ivec2::y, meta::metadata_()("desc", "y-member"s))
|
||||
.method_("add", &ivec2::add,
|
||||
meta::arguments_()
|
||||
("other", meta::metadata_()("desc", "other-arg"s)),
|
||||
meta::metadata_()("desc", "add-method"s))
|
||||
.function_("iadd", &ivec2::iadd,
|
||||
meta::arguments_()
|
||||
("l", meta::metadata_()("desc", "l-arg"s)),
|
||||
meta::arguments_()
|
||||
("r", meta::metadata_()("desc", "r-arg"s)),
|
||||
meta::metadata_()("desc", "iadd-function"s))
|
||||
.variable_("zero", &ivec2::zero, meta::metadata_("desc", "{0,0} vector"s))
|
||||
.variable_("unit", &ivec2::unit, meta::metadata_("desc", "{1,1} vector"s));
|
||||
|
||||
// metadata override
|
||||
|
||||
@@ -221,6 +215,22 @@ TEST_CASE("meta/meta_states/metadata/class") {
|
||||
REQUIRE(ivec2_iadd.get_argument(1).get_metadata().contains("desc"));
|
||||
CHECK(ivec2_iadd.get_argument(1).get_metadata().at("desc").as<std::string>() == "r-arg"s);
|
||||
}
|
||||
|
||||
SUBCASE("ivec2::zero") {
|
||||
const meta::variable ivec2_zero = ivec2_type.get_variable("zero");
|
||||
REQUIRE(ivec2_zero);
|
||||
|
||||
REQUIRE(ivec2_zero.get_metadata().contains("desc"));
|
||||
CHECK(ivec2_zero.get_metadata().at("desc").as<std::string>() == "{0,0} vector"s);
|
||||
}
|
||||
|
||||
SUBCASE("ivec2::unit") {
|
||||
const meta::variable ivec2_unit = ivec2_type.get_variable("unit");
|
||||
REQUIRE(ivec2_unit);
|
||||
|
||||
REQUIRE(ivec2_unit.get_metadata().contains("desc"));
|
||||
CHECK(ivec2_unit.get_metadata().at("desc").as<std::string>() == "{1,1} vector"s);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("meta/meta_states/metadata/scope") {
|
||||
|
||||
@@ -25,7 +25,7 @@ TEST_CASE("meta/meta_states/method2") {
|
||||
namespace meta = meta_hpp;
|
||||
|
||||
meta::class_<ivec2>()
|
||||
.method_("add", &ivec2::add, {"other"});
|
||||
.method_("add", &ivec2::add, meta::argument_("other"));
|
||||
|
||||
const meta::class_type ivec2_type = meta::resolve_type<ivec2>();
|
||||
REQUIRE(ivec2_type);
|
||||
|
||||
@@ -43,17 +43,18 @@ namespace
|
||||
|
||||
TEST_CASE("meta/meta_states/scope") {
|
||||
namespace meta = meta_hpp;
|
||||
using namespace std::string_literals;
|
||||
|
||||
meta::static_scope_("meta/meta_states/scope/math")
|
||||
.typedef_<color>("color")
|
||||
.typedef_<ivec2>("ivec2")
|
||||
.typedef_<ivec3>("ivec3")
|
||||
.function_("iadd2", &iadd2, {"l", "r"})
|
||||
.function_("iadd3", &iadd3, {"l"})
|
||||
.function_("iadd2", &iadd2, meta::arguments_()("l")("r"), meta::metadata_()("desc", "iadd2"s))
|
||||
.function_("iadd3", &iadd3, meta::arguments_()("l"), meta::metadata_()("desc", "iadd3"s))
|
||||
.function_("function_overloaded", meta::select_overload<int(int)>(&function_overloaded))
|
||||
.function_("function_overloaded", meta::select_overload<int(int,int)>(&function_overloaded))
|
||||
.variable_("static_ivec2", &static_ivec2)
|
||||
.variable_("static_const_ivec3", &static_const_ivec3);
|
||||
.variable_("static_ivec2", &static_ivec2, meta::metadata_()("desc", "static_ivec2"s))
|
||||
.variable_("static_const_ivec3", &static_const_ivec3, meta::metadata_()("desc", "static_const_ivec3"s));
|
||||
|
||||
const meta::scope math_scope = meta::resolve_scope("meta/meta_states/scope/math");
|
||||
REQUIRE(math_scope);
|
||||
@@ -114,6 +115,9 @@ TEST_CASE("meta/meta_states/scope") {
|
||||
CHECK(iadd2_func.get_argument(1).get_name() == "r");
|
||||
|
||||
CHECK_FALSE(iadd2_func.get_argument(2));
|
||||
|
||||
REQUIRE(iadd2_func.get_metadata().contains("desc"));
|
||||
CHECK(iadd2_func.get_metadata().at("desc").as<std::string>() == "iadd2"s);
|
||||
}
|
||||
|
||||
const meta::function iadd3_func = math_scope.get_function("iadd3");
|
||||
@@ -133,6 +137,9 @@ TEST_CASE("meta/meta_states/scope") {
|
||||
CHECK(iadd3_func.get_argument(1).get_name() == "");
|
||||
|
||||
CHECK_FALSE(iadd3_func.get_argument(2));
|
||||
|
||||
REQUIRE(iadd3_func.get_metadata().contains("desc"));
|
||||
CHECK(iadd3_func.get_metadata().at("desc").as<std::string>() == "iadd3"s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,10 +206,14 @@ TEST_CASE("meta/meta_states/scope") {
|
||||
const meta::variable static_ivec2_var = math_scope.get_variable("static_ivec2");
|
||||
REQUIRE(static_ivec2_var);
|
||||
CHECK(static_ivec2_var.get_type().get_data_type() == meta::resolve_type<ivec2>());
|
||||
REQUIRE(static_ivec2_var.get_metadata().contains("desc"));
|
||||
CHECK(static_ivec2_var.get_metadata().at("desc").as<std::string>() == "static_ivec2"s);
|
||||
|
||||
const meta::variable static_const_ivec3_var = math_scope.get_variable("static_const_ivec3");
|
||||
REQUIRE(static_const_ivec3_var);
|
||||
CHECK(static_const_ivec3_var.get_type().get_data_type() == meta::resolve_type<ivec3>());
|
||||
REQUIRE(static_const_ivec3_var.get_metadata().contains("desc"));
|
||||
CHECK(static_const_ivec3_var.get_metadata().at("desc").as<std::string>() == "static_const_ivec3"s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "meta_base/memory_buffer.hpp"
|
||||
#include "meta_base/noncopyable.hpp"
|
||||
#include "meta_base/nonesuch.hpp"
|
||||
#include "meta_base/overloaded.hpp"
|
||||
#include "meta_base/select_overload.hpp"
|
||||
#include "meta_base/to_underlying.hpp"
|
||||
#include "meta_base/type_kinds.hpp"
|
||||
|
||||
20
headers/meta.hpp/meta_base/overloaded.hpp
Normal file
20
headers/meta.hpp/meta_base/overloaded.hpp
Normal file
@@ -0,0 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* 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-2023, by Matvey Cherevko (blackmatov@gmail.com)
|
||||
******************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "base.hpp"
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < typename... Ts >
|
||||
struct overloaded : Ts... {
|
||||
using Ts::operator()...;
|
||||
};
|
||||
|
||||
template < typename... Ts >
|
||||
overloaded(Ts...) -> overloaded<Ts...>;
|
||||
}
|
||||
@@ -45,3 +45,37 @@ namespace meta_hpp::detail
|
||||
template < typename TypeList >
|
||||
inline constexpr std::size_t type_list_arity_v = type_list_arity<TypeList>::value;
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < template < typename > class Pred, typename TypeList >
|
||||
struct type_list_count_of;
|
||||
|
||||
template < template < typename > class Pred, typename... Types >
|
||||
struct type_list_count_of<Pred, type_list<Types...>> : size_constant<(0 + ... + Pred<Types>::value)> {};
|
||||
|
||||
template < template < typename > class Pred, typename TypeList >
|
||||
inline constexpr std::size_t type_list_count_of_v = type_list_count_of<Pred, TypeList>::value;
|
||||
}
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < template < typename > class Pred, typename Default, typename TypeList >
|
||||
struct type_list_first_of;
|
||||
|
||||
template < template < typename > class Pred, typename Default >
|
||||
struct type_list_first_of<Pred, Default, type_list<>> {
|
||||
using type = Default;
|
||||
};
|
||||
|
||||
template < template < typename > class Pred, typename Default, typename Type, typename... Types >
|
||||
struct type_list_first_of<Pred, Default, type_list<Type, Types...>> {
|
||||
using type = std::conditional_t< //
|
||||
Pred<Type>::value,
|
||||
Type,
|
||||
typename type_list_first_of<Pred, Default, type_list<Types...>>::type>;
|
||||
};
|
||||
|
||||
template < template < typename > class Pred, typename Default, typename TypeList >
|
||||
using type_list_first_of_t = typename type_list_first_of<Pred, Default, TypeList>::type;
|
||||
}
|
||||
|
||||
@@ -82,40 +82,6 @@ namespace meta_hpp
|
||||
using argument_info_list = std::vector<argument_info>;
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
struct constructor_opts final {
|
||||
argument_info_list arguments;
|
||||
metadata_map metadata;
|
||||
};
|
||||
|
||||
struct destructor_opts final {
|
||||
metadata_map metadata;
|
||||
};
|
||||
|
||||
struct evalue_opts final {
|
||||
metadata_map metadata;
|
||||
};
|
||||
|
||||
struct function_opts final {
|
||||
argument_info_list arguments;
|
||||
metadata_map metadata;
|
||||
};
|
||||
|
||||
struct member_opts final {
|
||||
metadata_map metadata;
|
||||
};
|
||||
|
||||
struct method_opts final {
|
||||
argument_info_list arguments;
|
||||
metadata_map metadata;
|
||||
};
|
||||
|
||||
struct variable_opts final {
|
||||
metadata_map metadata;
|
||||
};
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
{
|
||||
template < type_family Type >
|
||||
@@ -185,77 +151,33 @@ namespace meta_hpp
|
||||
public:
|
||||
explicit class_bind(metadata_map metadata);
|
||||
|
||||
// base_
|
||||
|
||||
template < detail::class_kind... Bases >
|
||||
requires(... && detail::class_bind_base_kind<Class, Bases>)
|
||||
class_bind& base_();
|
||||
|
||||
// constructor_
|
||||
|
||||
template < typename... Args, constructor_policy_family Policy = constructor_policy::as_object_t >
|
||||
class_bind& constructor_(Policy = {})
|
||||
template < typename... Args, typename... Opts >
|
||||
class_bind& constructor_(Opts&&... opts)
|
||||
requires detail::class_bind_constructor_kind<Class, Args...>;
|
||||
|
||||
template < typename... Args, constructor_policy_family Policy = constructor_policy::as_object_t >
|
||||
class_bind& constructor_(constructor_opts opts, Policy = {})
|
||||
requires detail::class_bind_constructor_kind<Class, Args...>;
|
||||
|
||||
// destructor_
|
||||
|
||||
class_bind& destructor_()
|
||||
template < typename... Opts >
|
||||
class_bind& destructor_(Opts&&... opts)
|
||||
requires detail::class_bind_destructor_kind<Class>;
|
||||
|
||||
class_bind& destructor_(destructor_opts opts)
|
||||
requires detail::class_bind_destructor_kind<Class>;
|
||||
template < detail::function_pointer_kind Function, typename... Opts >
|
||||
class_bind& function_(std::string name, Function function_ptr, Opts&&... opts);
|
||||
|
||||
// function_
|
||||
template < detail::member_pointer_kind Member, typename... Opts >
|
||||
class_bind& member_(std::string name, Member member_ptr, Opts&&... opts);
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t >
|
||||
class_bind& function_(std::string name, Function function_ptr, Policy = {});
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t >
|
||||
class_bind& function_(std::string name, Function function_ptr, function_opts opts, Policy = {});
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t >
|
||||
class_bind& function_(std::string name, Function function_ptr, string_ilist arguments, Policy = {});
|
||||
|
||||
// member_
|
||||
|
||||
template < detail::member_pointer_kind Member, member_policy_family Policy = member_policy::as_copy_t >
|
||||
requires detail::class_bind_member_kind<Class, Member>
|
||||
class_bind& member_(std::string name, Member member_ptr, Policy = {});
|
||||
|
||||
template < detail::member_pointer_kind Member, member_policy_family Policy = member_policy::as_copy_t >
|
||||
requires detail::class_bind_member_kind<Class, Member>
|
||||
class_bind& member_(std::string name, Member member_ptr, member_opts opts, Policy = {});
|
||||
|
||||
// method_
|
||||
|
||||
template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t >
|
||||
template < detail::method_pointer_kind Method, typename... Opts >
|
||||
requires detail::class_bind_method_kind<Class, Method>
|
||||
class_bind& method_(std::string name, Method method_ptr, Policy = {});
|
||||
|
||||
template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t >
|
||||
requires detail::class_bind_method_kind<Class, Method>
|
||||
class_bind& method_(std::string name, Method method_ptr, method_opts opts, Policy = {});
|
||||
|
||||
template < detail::method_pointer_kind Method, method_policy_family Policy = method_policy::as_copy_t >
|
||||
requires detail::class_bind_method_kind<Class, Method>
|
||||
class_bind& method_(std::string name, Method method_ptr, string_ilist arguments, Policy = {});
|
||||
|
||||
// typdef_
|
||||
class_bind& method_(std::string name, Method method_ptr, Opts&&... opts);
|
||||
|
||||
template < typename Type >
|
||||
class_bind& typedef_(std::string name);
|
||||
|
||||
// variable_
|
||||
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t >
|
||||
class_bind& variable_(std::string name, Pointer variable_ptr, Policy = {});
|
||||
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t >
|
||||
class_bind& variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy = {});
|
||||
template < detail::pointer_kind Pointer, typename... Opts >
|
||||
class_bind& variable_(std::string name, Pointer variable_ptr, Opts&&... opts);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -266,8 +188,8 @@ namespace meta_hpp
|
||||
public:
|
||||
explicit enum_bind(metadata_map metadata);
|
||||
|
||||
enum_bind& evalue_(std::string name, Enum value);
|
||||
enum_bind& evalue_(std::string name, Enum value, evalue_opts opts);
|
||||
template < typename... Opts >
|
||||
enum_bind& evalue_(std::string name, Enum value, Opts&&... opts);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -349,29 +271,14 @@ namespace meta_hpp
|
||||
public:
|
||||
explicit scope_bind(const scope& scope, metadata_map metadata);
|
||||
|
||||
// function_
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t >
|
||||
scope_bind& function_(std::string name, Function function_ptr, Policy = {});
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t >
|
||||
scope_bind& function_(std::string name, Function function_ptr, function_opts opts, Policy = {});
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy = function_policy::as_copy_t >
|
||||
scope_bind& function_(std::string name, Function function_ptr, string_ilist arguments, Policy = {});
|
||||
|
||||
// typedef_
|
||||
template < detail::function_pointer_kind Function, typename... Opts >
|
||||
scope_bind& function_(std::string name, Function function_ptr, Opts&&... opts);
|
||||
|
||||
template < typename Type >
|
||||
scope_bind& typedef_(std::string name);
|
||||
|
||||
// variable_
|
||||
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t >
|
||||
scope_bind& variable_(std::string name, Pointer variable_ptr, Policy = {});
|
||||
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy = variable_policy::as_copy_t >
|
||||
scope_bind& variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy = {});
|
||||
template < detail::pointer_kind Pointer, typename... Opts >
|
||||
scope_bind& variable_(std::string name, Pointer variable_ptr, Opts&&... opts);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -494,6 +401,14 @@ namespace meta_hpp
|
||||
inline arguments_bind arguments_() {
|
||||
return arguments_bind{};
|
||||
}
|
||||
|
||||
inline arguments_bind argument_(std::string name) {
|
||||
return arguments_()(std::move(name));
|
||||
}
|
||||
|
||||
inline arguments_bind argument_(std::string name, metadata_map metadata) {
|
||||
return arguments_()(std::move(name), std::move(metadata));
|
||||
}
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
@@ -530,4 +445,8 @@ namespace meta_hpp
|
||||
inline metadata_bind metadata_() {
|
||||
return metadata_bind{};
|
||||
}
|
||||
|
||||
inline metadata_bind metadata_(std::string name, uvalue value) {
|
||||
return metadata_()(std::move(name), std::move(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,10 +97,6 @@ namespace meta_hpp
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// base_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::class_kind... Bases >
|
||||
requires(... && detail::class_bind_base_kind<Class, Bases>)
|
||||
@@ -145,167 +141,227 @@ namespace meta_hpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// constructor_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < typename... Args, constructor_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::constructor_(Policy policy)
|
||||
template < typename... Args, typename... Opts >
|
||||
class_bind<Class>& class_bind<Class>::constructor_(Opts&&... opts)
|
||||
requires detail::class_bind_constructor_kind<Class, Args...>
|
||||
{
|
||||
return constructor_<Args...>({}, policy);
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<constructor_policy::is_family, constructor_policy::as_object_t, opts_t>;
|
||||
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<constructor_policy::is_family, opts_t> <= 1,
|
||||
"constructor policy may be specified only once"
|
||||
);
|
||||
|
||||
metadata_map metadata;
|
||||
argument_info_list arguments;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, constructor_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
[&arguments](auto&&, argument_info_list l) {
|
||||
arguments.insert(arguments.end(),
|
||||
std::make_move_iterator(l.begin()),
|
||||
std::make_move_iterator(l.end()));
|
||||
},
|
||||
[](auto&& self, arguments_bind b) {
|
||||
self(self, argument_info_list{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < typename... Args, constructor_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::constructor_(constructor_opts opts, Policy)
|
||||
requires detail::class_bind_constructor_kind<Class, Args...>
|
||||
{
|
||||
auto state = detail::constructor_state::make<Policy, Class, Args...>(std::move(opts.metadata));
|
||||
auto state = detail::constructor_state::make<policy_t, Class, Args...>(std::move(metadata));
|
||||
|
||||
META_HPP_ASSERT( //
|
||||
opts.arguments.size() <= state->arguments.size() //
|
||||
arguments.size() <= state->arguments.size() //
|
||||
&& "provided argument names don't match constructor argument count"
|
||||
);
|
||||
|
||||
for ( std::size_t i{}, e{std::min(opts.arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
for ( std::size_t i{}, e{std::min(arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
detail::state_access(arg)->name = std::move(opts.arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(opts.arguments[i].get_metadata());
|
||||
detail::state_access(arg)->name = std::move(arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(arguments[i].get_metadata());
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_data().constructors, constructor{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// destructor_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
class_bind<Class>& class_bind<Class>::destructor_()
|
||||
template < typename... Opts >
|
||||
class_bind<Class>& class_bind<Class>::destructor_(Opts&&... opts)
|
||||
requires detail::class_bind_destructor_kind<Class>
|
||||
{
|
||||
return destructor_({});
|
||||
metadata_map metadata;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
template < detail::class_kind Class >
|
||||
class_bind<Class>& class_bind<Class>::destructor_(destructor_opts opts)
|
||||
requires detail::class_bind_destructor_kind<Class>
|
||||
{
|
||||
auto state = detail::destructor_state::make<Class>(std::move(opts.metadata));
|
||||
auto state = detail::destructor_state::make<Class>(std::move(metadata));
|
||||
detail::insert_or_assign(get_data().destructors, destructor{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// function_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::function_(std::string name, Function function_ptr, Policy policy) {
|
||||
return function_(std::move(name), function_ptr, {}, policy);
|
||||
}
|
||||
template < detail::function_pointer_kind Function, typename... Opts >
|
||||
class_bind<Class>& class_bind<Class>::function_(std::string name, Function function_ptr, Opts&&... opts) {
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<function_policy::is_family, function_policy::as_copy_t, opts_t>;
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::function_(std::string name, Function function_ptr, function_opts opts, Policy) {
|
||||
auto state = detail::function_state::make<Policy>(std::move(name), function_ptr, std::move(opts.metadata));
|
||||
|
||||
META_HPP_ASSERT( //
|
||||
opts.arguments.size() <= state->arguments.size() //
|
||||
&& "provided arguments don't match function argument count"
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<function_policy::is_family, opts_t> <= 1,
|
||||
"function policy may be specified only once"
|
||||
);
|
||||
|
||||
for ( std::size_t i{}, e{std::min(opts.arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
detail::state_access(arg)->name = std::move(opts.arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(opts.arguments[i].get_metadata());
|
||||
metadata_map metadata;
|
||||
argument_info_list arguments;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, function_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
[&arguments](auto&&, argument_info_list l) {
|
||||
arguments.insert(arguments.end(),
|
||||
std::make_move_iterator(l.begin()),
|
||||
std::make_move_iterator(l.end()));
|
||||
},
|
||||
[](auto&& self, arguments_bind b) {
|
||||
self(self, argument_info_list{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_data().functions, function{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
auto state = detail::function_state::make<policy_t>(std::move(name), function_ptr, std::move(metadata));
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::function_(std::string name, Function function_ptr, string_ilist arguments, Policy) {
|
||||
auto state = detail::function_state::make<Policy>(std::move(name), function_ptr, {});
|
||||
|
||||
META_HPP_ASSERT(
|
||||
META_HPP_ASSERT( //
|
||||
arguments.size() <= state->arguments.size() //
|
||||
&& "provided argument names don't match function argument count"
|
||||
);
|
||||
|
||||
for ( std::size_t i{}, e{std::min(arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
detail::state_access(arg)->name = std::data(arguments)[i];
|
||||
detail::state_access(arg)->name = std::move(arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(arguments[i].get_metadata());
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_data().functions, function{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// member_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::member_pointer_kind Member, member_policy_family Policy >
|
||||
requires detail::class_bind_member_kind<Class, Member>
|
||||
class_bind<Class>& class_bind<Class>::member_(std::string name, Member member_ptr, Policy policy) {
|
||||
return member_(std::move(name), member_ptr, {}, policy);
|
||||
template < detail::member_pointer_kind Member, typename... Opts >
|
||||
class_bind<Class>& class_bind<Class>::member_(std::string name, Member member_ptr, [[maybe_unused]] Opts&&... opts) {
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<member_policy::is_family, member_policy::as_copy_t, opts_t>;
|
||||
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<member_policy::is_family, opts_t> <= 1,
|
||||
"member policy may be specified only once"
|
||||
);
|
||||
|
||||
metadata_map metadata;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, member_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::member_pointer_kind Member, member_policy_family Policy >
|
||||
requires detail::class_bind_member_kind<Class, Member>
|
||||
class_bind<Class>& class_bind<Class>::member_(std::string name, Member member_ptr, member_opts opts, Policy) {
|
||||
auto state = detail::member_state::make<Policy>(std::move(name), member_ptr, std::move(opts.metadata));
|
||||
auto state = detail::member_state::make<policy_t>(std::move(name), member_ptr, std::move(metadata));
|
||||
detail::insert_or_assign(get_data().members, member{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// method_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::method_pointer_kind Method, method_policy_family Policy >
|
||||
template < detail::method_pointer_kind Method, typename... Opts >
|
||||
requires detail::class_bind_method_kind<Class, Method>
|
||||
class_bind<Class>& class_bind<Class>::method_(std::string name, Method method_ptr, Policy policy) {
|
||||
return method_(std::move(name), method_ptr, {}, policy);
|
||||
}
|
||||
class_bind<Class>& class_bind<Class>::method_(std::string name, Method method_ptr, Opts&&... opts) {
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<method_policy::is_family, method_policy::as_copy_t, opts_t>;
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::method_pointer_kind Method, method_policy_family Policy >
|
||||
requires detail::class_bind_method_kind<Class, Method>
|
||||
class_bind<Class>& class_bind<Class>::method_(std::string name, Method method_ptr, method_opts opts, Policy) {
|
||||
auto state = detail::method_state::make<Policy>(std::move(name), method_ptr, std::move(opts.metadata));
|
||||
|
||||
META_HPP_ASSERT( //
|
||||
opts.arguments.size() <= state->arguments.size() //
|
||||
&& "provided arguments don't match method argument count"
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<method_policy::is_family, opts_t> <= 1,
|
||||
"method policy may be specified only once"
|
||||
);
|
||||
|
||||
for ( std::size_t i{}, e{std::min(opts.arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
detail::state_access(arg)->name = std::move(opts.arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(opts.arguments[i].get_metadata());
|
||||
metadata_map metadata;
|
||||
argument_info_list arguments;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, method_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
[&arguments](auto&&, argument_info_list l) {
|
||||
arguments.insert(arguments.end(),
|
||||
std::make_move_iterator(l.begin()),
|
||||
std::make_move_iterator(l.end()));
|
||||
},
|
||||
[](auto&& self, arguments_bind b) {
|
||||
self(self, argument_info_list{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_data().methods, method{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::method_pointer_kind Method, method_policy_family Policy >
|
||||
requires detail::class_bind_method_kind<Class, Method>
|
||||
class_bind<Class>& class_bind<Class>::method_(std::string name, Method method_ptr, string_ilist arguments, Policy) {
|
||||
auto state = detail::method_state::make<Policy>(std::move(name), method_ptr, {});
|
||||
auto state = detail::method_state::make<policy_t>(std::move(name), method_ptr, std::move(metadata));
|
||||
|
||||
META_HPP_ASSERT( //
|
||||
arguments.size() <= state->arguments.size() //
|
||||
@@ -314,18 +370,14 @@ namespace meta_hpp
|
||||
|
||||
for ( std::size_t i{}, e{std::min(arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
detail::state_access(arg)->name = std::data(arguments)[i];
|
||||
detail::state_access(arg)->name = std::move(arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(arguments[i].get_metadata());
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_data().methods, method{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// typedef_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < typename Type >
|
||||
class_bind<Class>& class_bind<Class>::typedef_(std::string name) {
|
||||
@@ -333,20 +385,38 @@ namespace meta_hpp
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// variable_
|
||||
//
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::variable_(std::string name, Pointer variable_ptr, Policy policy) {
|
||||
return variable_(std::move(name), variable_ptr, {}, policy);
|
||||
template < detail::pointer_kind Pointer, typename... Opts >
|
||||
class_bind<Class>& class_bind<Class>::variable_(std::string name, Pointer variable_ptr, Opts&&... opts) {
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<variable_policy::is_family, variable_policy::as_copy_t, opts_t>;
|
||||
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<variable_policy::is_family, opts_t> <= 1,
|
||||
"variable policy may be specified only once"
|
||||
);
|
||||
|
||||
metadata_map metadata;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, variable_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
template < detail::class_kind Class >
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy >
|
||||
class_bind<Class>& class_bind<Class>::variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy) {
|
||||
auto state = detail::variable_state::make<Policy>(std::move(name), variable_ptr, std::move(opts.metadata));
|
||||
auto state = detail::variable_state::make<policy_t>(std::move(name), variable_ptr, std::move(metadata));
|
||||
detail::insert_or_assign(get_data().variables, variable{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -17,13 +17,26 @@ namespace meta_hpp
|
||||
: type_bind_base{resolve_type<Enum>(), std::move(metadata)} {}
|
||||
|
||||
template < detail::enum_kind Enum >
|
||||
enum_bind<Enum>& enum_bind<Enum>::evalue_(std::string name, Enum value) {
|
||||
return evalue_(std::move(name), std::move(value), {});
|
||||
template < typename... Opts >
|
||||
enum_bind<Enum>& enum_bind<Enum>::evalue_(std::string name, Enum value, Opts&&... opts) {
|
||||
metadata_map metadata;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
template < detail::enum_kind Enum >
|
||||
enum_bind<Enum>& enum_bind<Enum>::evalue_(std::string name, Enum value, evalue_opts opts) {
|
||||
auto state = detail::evalue_state::make(std::move(name), std::move(value), std::move(opts.metadata));
|
||||
auto state = detail::evalue_state::make(std::move(name), std::move(value), std::move(metadata));
|
||||
detail::insert_or_assign(get_data().evalues, evalue{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -15,75 +15,99 @@ namespace meta_hpp
|
||||
inline scope_bind::scope_bind(const scope& scope, metadata_map metadata)
|
||||
: state_bind_base{scope, std::move(metadata)} {}
|
||||
|
||||
//
|
||||
// function_
|
||||
//
|
||||
template < detail::function_pointer_kind Function, typename... Opts >
|
||||
scope_bind& scope_bind::function_(std::string name, Function function_ptr, Opts&&... opts) {
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<function_policy::is_family, function_policy::as_copy_t, opts_t>;
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy >
|
||||
scope_bind& scope_bind::function_(std::string name, Function function_ptr, Policy policy) {
|
||||
return function_(std::move(name), function_ptr, {}, policy);
|
||||
}
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy >
|
||||
scope_bind& scope_bind::function_(std::string name, Function function_ptr, function_opts opts, Policy) {
|
||||
auto state = detail::function_state::make<Policy>(std::move(name), function_ptr, std::move(opts.metadata));
|
||||
|
||||
META_HPP_ASSERT( //
|
||||
opts.arguments.size() <= state->arguments.size() //
|
||||
&& "provided arguments don't match function argument count"
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<function_policy::is_family, opts_t> <= 1,
|
||||
"function policy may be specified only once"
|
||||
);
|
||||
|
||||
for ( std::size_t i{}, e{std::min(opts.arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
detail::state_access(arg)->name = std::move(opts.arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(opts.arguments[i].get_metadata());
|
||||
metadata_map metadata;
|
||||
argument_info_list arguments;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, function_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
[&arguments](auto&&, argument_info_list l) {
|
||||
arguments.insert(arguments.end(),
|
||||
std::make_move_iterator(l.begin()),
|
||||
std::make_move_iterator(l.end()));
|
||||
},
|
||||
[](auto&& self, arguments_bind b) {
|
||||
self(self, argument_info_list{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_state().functions, function{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
template < detail::function_pointer_kind Function, function_policy_family Policy >
|
||||
scope_bind& scope_bind::function_(std::string name, Function function_ptr, string_ilist arguments, Policy) {
|
||||
auto state = detail::function_state::make<Policy>(std::move(name), function_ptr, {});
|
||||
auto state = detail::function_state::make<policy_t>(std::move(name), function_ptr, std::move(metadata));
|
||||
|
||||
META_HPP_ASSERT( //
|
||||
arguments.size() <= state->arguments.size() //
|
||||
&& "provided argument names don't match function argument count"
|
||||
&& "provided arguments don't match function argument count"
|
||||
);
|
||||
|
||||
for ( std::size_t i{}, e{std::min(arguments.size(), state->arguments.size())}; i < e; ++i ) {
|
||||
argument& arg = state->arguments[i];
|
||||
// NOLINTNEXTLINE(*-pointer-arithmetic)
|
||||
detail::state_access(arg)->name = std::data(arguments)[i];
|
||||
detail::state_access(arg)->name = std::move(arguments[i].get_name());
|
||||
detail::state_access(arg)->metadata = std::move(arguments[i].get_metadata());
|
||||
}
|
||||
|
||||
detail::insert_or_assign(get_state().functions, function{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// typedef_
|
||||
//
|
||||
|
||||
template < typename Type >
|
||||
scope_bind& scope_bind::typedef_(std::string name) {
|
||||
get_state().typedefs.insert_or_assign(std::move(name), resolve_type<Type>());
|
||||
return *this;
|
||||
}
|
||||
|
||||
//
|
||||
// variable_
|
||||
//
|
||||
template < detail::pointer_kind Pointer, typename... Opts >
|
||||
scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, Opts&&... opts) {
|
||||
using opts_t = detail::type_list<std::remove_cvref_t<Opts>...>;
|
||||
using policy_t = detail::type_list_first_of_t<variable_policy::is_family, variable_policy::as_copy_t, opts_t>;
|
||||
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy >
|
||||
scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, Policy policy) {
|
||||
return variable_(std::move(name), variable_ptr, {}, policy);
|
||||
static_assert( //
|
||||
detail::type_list_count_of_v<variable_policy::is_family, opts_t> <= 1,
|
||||
"variable policy may be specified only once"
|
||||
);
|
||||
|
||||
metadata_map metadata;
|
||||
|
||||
{
|
||||
// clang-format off
|
||||
const auto process_opt = detail::overloaded{
|
||||
[](auto&&, variable_policy::family auto) {
|
||||
// nothing
|
||||
},
|
||||
[&metadata](auto&&, metadata_map m) {
|
||||
detail::insert_or_assign(metadata, std::move(m));
|
||||
},
|
||||
[](auto&& self, metadata_bind b) {
|
||||
self(self, metadata_map{std::move(b)});
|
||||
},
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
(process_opt(process_opt, std::forward<Opts>(opts)), ...);
|
||||
}
|
||||
|
||||
template < detail::pointer_kind Pointer, variable_policy_family Policy >
|
||||
scope_bind& scope_bind::variable_(std::string name, Pointer variable_ptr, variable_opts opts, Policy) {
|
||||
auto state = detail::variable_state::make<Policy>(std::move(name), variable_ptr, std::move(opts.metadata));
|
||||
auto state = detail::variable_state::make<policy_t>(std::move(name), variable_ptr, std::move(metadata));
|
||||
detail::insert_or_assign(get_state().variables, variable{std::move(state)});
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -18,102 +18,128 @@ namespace meta_hpp
|
||||
{
|
||||
namespace constructor_policy
|
||||
{
|
||||
struct as_object_t final {};
|
||||
inline constexpr struct as_object_t final {
|
||||
} as_object{};
|
||||
|
||||
struct as_raw_pointer_t final {};
|
||||
inline constexpr struct as_raw_pointer_t final {
|
||||
} as_raw_pointer{};
|
||||
|
||||
struct as_shared_pointer_t final {};
|
||||
inline constexpr struct as_shared_pointer_t final {
|
||||
} as_shared_pointer{};
|
||||
|
||||
struct as_unique_pointer_t final {};
|
||||
inline constexpr struct as_unique_pointer_t final {
|
||||
} as_unique_pointer{};
|
||||
|
||||
inline constexpr as_object_t as_object{};
|
||||
inline constexpr as_raw_pointer_t as_raw_pointer{};
|
||||
inline constexpr as_shared_pointer_t as_shared_pointer{};
|
||||
inline constexpr as_unique_pointer_t as_unique_pointer{};
|
||||
template < typename Policy >
|
||||
concept family //
|
||||
= std::is_same_v<Policy, as_object_t> //
|
||||
|| std::is_same_v<Policy, as_raw_pointer_t> //
|
||||
|| std::is_same_v<Policy, as_shared_pointer_t> //
|
||||
|| std::is_same_v<Policy, as_unique_pointer_t>; //
|
||||
|
||||
template < typename T >
|
||||
using is_family = std::bool_constant<family<T>>;
|
||||
|
||||
template < typename T >
|
||||
inline constexpr bool is_family_v = is_family<T>::value;
|
||||
}
|
||||
|
||||
namespace function_policy
|
||||
{
|
||||
struct as_copy_t final {};
|
||||
inline constexpr struct as_copy_t final {
|
||||
} as_copy{};
|
||||
|
||||
struct discard_return_t final {};
|
||||
inline constexpr struct discard_return_t final {
|
||||
} discard_return{};
|
||||
|
||||
struct return_reference_as_pointer_t final {};
|
||||
inline constexpr struct return_reference_as_pointer_t final {
|
||||
} return_reference_as_pointer{};
|
||||
|
||||
inline constexpr as_copy_t as_copy{};
|
||||
inline constexpr discard_return_t discard_return{};
|
||||
inline constexpr return_reference_as_pointer_t return_reference_as_pointer{};
|
||||
template < typename Policy >
|
||||
concept family //
|
||||
= std::is_same_v<Policy, as_copy_t> //
|
||||
|| std::is_same_v<Policy, discard_return_t> //
|
||||
|| std::is_same_v<Policy, return_reference_as_pointer_t>; //
|
||||
|
||||
template < typename T >
|
||||
using is_family = std::bool_constant<family<T>>;
|
||||
|
||||
template < typename T >
|
||||
inline constexpr bool is_family_v = is_family<T>::value;
|
||||
}
|
||||
|
||||
namespace member_policy
|
||||
{
|
||||
struct as_copy_t final {};
|
||||
inline constexpr struct as_copy_t final {
|
||||
} as_copy{};
|
||||
|
||||
struct as_pointer_t final {};
|
||||
inline constexpr struct as_pointer_t final {
|
||||
} as_pointer{};
|
||||
|
||||
struct as_reference_wrapper_t final {};
|
||||
inline constexpr struct as_reference_wrapper_t final {
|
||||
} as_reference_wrapper{};
|
||||
|
||||
template < typename Policy >
|
||||
concept family //
|
||||
= std::is_same_v<Policy, as_copy_t> //
|
||||
|| std::is_same_v<Policy, as_pointer_t> //
|
||||
|| std::is_same_v<Policy, as_reference_wrapper_t>; //
|
||||
|
||||
template < typename T >
|
||||
using is_family = std::bool_constant<family<T>>;
|
||||
|
||||
template < typename T >
|
||||
inline constexpr bool is_family_v = is_family<T>::value;
|
||||
|
||||
inline constexpr as_copy_t as_copy{};
|
||||
inline constexpr as_pointer_t as_pointer{};
|
||||
inline constexpr as_reference_wrapper_t as_reference_wrapper{};
|
||||
}
|
||||
|
||||
namespace method_policy
|
||||
{
|
||||
struct as_copy_t final {};
|
||||
inline constexpr struct as_copy_t final {
|
||||
} as_copy{};
|
||||
|
||||
struct discard_return_t final {};
|
||||
inline constexpr struct discard_return_t final {
|
||||
} discard_return{};
|
||||
|
||||
struct return_reference_as_pointer_t final {};
|
||||
inline constexpr struct return_reference_as_pointer_t final {
|
||||
} return_reference_as_pointer{};
|
||||
|
||||
inline constexpr as_copy_t as_copy{};
|
||||
inline constexpr discard_return_t discard_return{};
|
||||
inline constexpr return_reference_as_pointer_t return_reference_as_pointer{};
|
||||
template < typename Policy >
|
||||
concept family //
|
||||
= std::is_same_v<Policy, as_copy_t> //
|
||||
|| std::is_same_v<Policy, discard_return_t> //
|
||||
|| std::is_same_v<Policy, return_reference_as_pointer_t>; //
|
||||
|
||||
template < typename T >
|
||||
using is_family = std::bool_constant<family<T>>;
|
||||
|
||||
template < typename T >
|
||||
inline constexpr bool is_family_v = is_family<T>::value;
|
||||
}
|
||||
|
||||
namespace variable_policy
|
||||
{
|
||||
struct as_copy_t final {};
|
||||
inline constexpr struct as_copy_t final {
|
||||
} as_copy{};
|
||||
|
||||
struct as_pointer_t final {};
|
||||
inline constexpr struct as_pointer_t final {
|
||||
} as_pointer{};
|
||||
|
||||
struct as_reference_wrapper_t final {};
|
||||
inline constexpr struct as_reference_wrapper_t final {
|
||||
} as_reference_wrapper{};
|
||||
|
||||
inline constexpr as_copy_t as_copy{};
|
||||
inline constexpr as_pointer_t as_pointer{};
|
||||
inline constexpr as_reference_wrapper_t as_reference_wrapper{};
|
||||
template < typename Policy >
|
||||
concept family //
|
||||
= std::is_same_v<Policy, as_copy_t> //
|
||||
|| std::is_same_v<Policy, as_pointer_t> //
|
||||
|| std::is_same_v<Policy, as_reference_wrapper_t>; //
|
||||
|
||||
template < typename T >
|
||||
using is_family = std::bool_constant<family<T>>;
|
||||
|
||||
template < typename T >
|
||||
inline constexpr bool is_family_v = is_family<T>::value;
|
||||
}
|
||||
|
||||
template < typename Policy >
|
||||
concept constructor_policy_family //
|
||||
= std::is_same_v<Policy, constructor_policy::as_object_t> //
|
||||
|| std::is_same_v<Policy, constructor_policy::as_raw_pointer_t> //
|
||||
|| std::is_same_v<Policy, constructor_policy::as_shared_pointer_t> //
|
||||
|| std::is_same_v<Policy, constructor_policy::as_unique_pointer_t>; //
|
||||
|
||||
template < typename Policy >
|
||||
concept function_policy_family //
|
||||
= std::is_same_v<Policy, function_policy::as_copy_t> //
|
||||
|| std::is_same_v<Policy, function_policy::discard_return_t> //
|
||||
|| std::is_same_v<Policy, function_policy::return_reference_as_pointer_t>; //
|
||||
|
||||
template < typename Policy >
|
||||
concept member_policy_family //
|
||||
= std::is_same_v<Policy, member_policy::as_copy_t> //
|
||||
|| std::is_same_v<Policy, member_policy::as_pointer_t> //
|
||||
|| std::is_same_v<Policy, member_policy::as_reference_wrapper_t>; //
|
||||
|
||||
template < typename Policy >
|
||||
concept method_policy_family //
|
||||
= std::is_same_v<Policy, method_policy::as_copy_t> //
|
||||
|| std::is_same_v<Policy, method_policy::discard_return_t> //
|
||||
|| std::is_same_v<Policy, method_policy::return_reference_as_pointer_t>; //
|
||||
|
||||
template < typename Policy >
|
||||
concept variable_policy_family //
|
||||
= std::is_same_v<Policy, variable_policy::as_copy_t> //
|
||||
|| std::is_same_v<Policy, variable_policy::as_pointer_t> //
|
||||
|| std::is_same_v<Policy, variable_policy::as_reference_wrapper_t>; //
|
||||
}
|
||||
|
||||
namespace meta_hpp
|
||||
@@ -497,7 +523,7 @@ namespace meta_hpp::detail
|
||||
create_error_impl create_error{};
|
||||
argument_list arguments{};
|
||||
|
||||
template < constructor_policy_family Policy, class_kind Class, typename... Args >
|
||||
template < constructor_policy::family Policy, class_kind Class, typename... Args >
|
||||
[[nodiscard]] static constructor_state_ptr make(metadata_map metadata);
|
||||
explicit constructor_state(constructor_index index, metadata_map metadata);
|
||||
};
|
||||
@@ -542,7 +568,7 @@ namespace meta_hpp::detail
|
||||
invoke_error_impl invoke_error{};
|
||||
argument_list arguments{};
|
||||
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
template < function_policy::family Policy, function_pointer_kind Function >
|
||||
[[nodiscard]] static function_state_ptr make(std::string name, Function function_ptr, metadata_map metadata);
|
||||
explicit function_state(function_index index, metadata_map metadata);
|
||||
};
|
||||
@@ -562,7 +588,7 @@ namespace meta_hpp::detail
|
||||
getter_error_impl getter_error{};
|
||||
setter_error_impl setter_error{};
|
||||
|
||||
template < member_policy_family Policy, member_pointer_kind Member >
|
||||
template < member_policy::family Policy, member_pointer_kind Member >
|
||||
[[nodiscard]] static member_state_ptr make(std::string name, Member member_ptr, metadata_map metadata);
|
||||
explicit member_state(member_index index, metadata_map metadata);
|
||||
};
|
||||
@@ -578,7 +604,7 @@ namespace meta_hpp::detail
|
||||
invoke_error_impl invoke_error{};
|
||||
argument_list arguments{};
|
||||
|
||||
template < method_policy_family Policy, method_pointer_kind Method >
|
||||
template < method_policy::family Policy, method_pointer_kind Method >
|
||||
[[nodiscard]] static method_state_ptr make(std::string name, Method method_ptr, metadata_map metadata);
|
||||
explicit method_state(method_index index, metadata_map metadata);
|
||||
};
|
||||
@@ -607,7 +633,7 @@ namespace meta_hpp::detail
|
||||
setter_impl setter{};
|
||||
setter_error_impl setter_error{};
|
||||
|
||||
template < variable_policy_family Policy, pointer_kind Pointer >
|
||||
template < variable_policy::family Policy, pointer_kind Pointer >
|
||||
[[nodiscard]] static variable_state_ptr make(std::string name, Pointer variable_ptr, metadata_map metadata);
|
||||
explicit variable_state(variable_index index, metadata_map metadata);
|
||||
};
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < constructor_policy_family Policy, class_kind Class, typename... Args >
|
||||
template < constructor_policy::family Policy, class_kind Class, typename... Args >
|
||||
uvalue raw_constructor_create(type_registry& registry, std::span<const uarg> args) {
|
||||
using ct = constructor_traits<Class, Args...>;
|
||||
using class_type = typename ct::class_type;
|
||||
@@ -104,7 +104,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < constructor_policy_family Policy, class_kind Class, typename... Args >
|
||||
template < constructor_policy::family Policy, class_kind Class, typename... Args >
|
||||
constructor_state::create_impl make_constructor_create(type_registry& registry) {
|
||||
return [®istry](std::span<const uarg> args) { //
|
||||
return raw_constructor_create<Policy, Class, Args...>(registry, args);
|
||||
@@ -146,7 +146,7 @@ namespace meta_hpp::detail
|
||||
: index{nindex}
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
template < constructor_policy_family Policy, class_kind Class, typename... Args >
|
||||
template < constructor_policy::family Policy, class_kind Class, typename... Args >
|
||||
constructor_state_ptr constructor_state::make(metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
template < function_policy::family Policy, function_pointer_kind Function >
|
||||
uvalue raw_function_invoke(type_registry& registry, Function function_ptr, std::span<const uarg> args) {
|
||||
using ft = function_traits<std::remove_pointer_t<Function>>;
|
||||
using return_type = typename ft::return_type;
|
||||
@@ -82,7 +82,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
template < function_policy::family Policy, function_pointer_kind Function >
|
||||
function_state::invoke_impl make_function_invoke(type_registry& registry, Function function_ptr) {
|
||||
return [®istry, function_ptr](std::span<const uarg> args) { //
|
||||
return raw_function_invoke<Policy>(registry, function_ptr, args);
|
||||
@@ -117,7 +117,7 @@ namespace meta_hpp::detail
|
||||
: index{std::move(nindex)}
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
template < function_policy_family Policy, function_pointer_kind Function >
|
||||
template < function_policy::family Policy, function_pointer_kind Function >
|
||||
function_state_ptr function_state::make(std::string name, Function function_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < member_policy_family Policy, member_pointer_kind Member >
|
||||
template < member_policy::family Policy, member_pointer_kind Member >
|
||||
uvalue raw_member_getter(type_registry& registry, Member member_ptr, const uinst& inst) {
|
||||
using mt = member_traits<Member>;
|
||||
using class_type = typename mt::class_type;
|
||||
@@ -159,7 +159,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < member_policy_family Policy, member_pointer_kind Member >
|
||||
template < member_policy::family Policy, member_pointer_kind Member >
|
||||
member_state::getter_impl make_member_getter(type_registry& registry, Member member_ptr) {
|
||||
return [®istry, member_ptr](const uinst& inst) { //
|
||||
return raw_member_getter<Policy>(registry, member_ptr, inst);
|
||||
@@ -194,7 +194,7 @@ namespace meta_hpp::detail
|
||||
: index{std::move(nindex)}
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
template < member_policy_family Policy, member_pointer_kind Member >
|
||||
template < member_policy::family Policy, member_pointer_kind Member >
|
||||
member_state_ptr member_state::make(std::string name, Member member_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < method_policy_family Policy, method_pointer_kind Method >
|
||||
template < method_policy::family Policy, method_pointer_kind Method >
|
||||
uvalue raw_method_invoke(type_registry& registry, Method method_ptr, const uinst& inst, std::span<const uarg> args) {
|
||||
using mt = method_traits<Method>;
|
||||
using return_type = typename mt::return_type;
|
||||
@@ -94,7 +94,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < method_policy_family Policy, method_pointer_kind Method >
|
||||
template < method_policy::family Policy, method_pointer_kind Method >
|
||||
method_state::invoke_impl make_method_invoke(type_registry& registry, Method method_ptr) {
|
||||
return [®istry, method_ptr](const uinst& inst, std::span<const uarg> args) {
|
||||
return raw_method_invoke<Policy>(registry, method_ptr, inst, args);
|
||||
@@ -129,7 +129,7 @@ namespace meta_hpp::detail
|
||||
: index{std::move(nindex)}
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
template < method_policy_family Policy, method_pointer_kind Method >
|
||||
template < method_policy::family Policy, method_pointer_kind Method >
|
||||
method_state_ptr method_state::make(std::string name, Method method_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < variable_policy_family Policy, pointer_kind Pointer >
|
||||
template < variable_policy::family Policy, pointer_kind Pointer >
|
||||
uvalue raw_variable_getter(type_registry&, Pointer variable_ptr) {
|
||||
using pt = pointer_traits<Pointer>;
|
||||
using data_type = typename pt::data_type;
|
||||
@@ -87,7 +87,7 @@ namespace meta_hpp::detail
|
||||
|
||||
namespace meta_hpp::detail
|
||||
{
|
||||
template < variable_policy_family Policy, pointer_kind Pointer >
|
||||
template < variable_policy::family Policy, pointer_kind Pointer >
|
||||
variable_state::getter_impl make_variable_getter(type_registry& registry, Pointer variable_ptr) {
|
||||
return [®istry, variable_ptr]() { //
|
||||
return raw_variable_getter<Policy>(registry, variable_ptr);
|
||||
@@ -115,7 +115,7 @@ namespace meta_hpp::detail
|
||||
: index{std::move(nindex)}
|
||||
, metadata{std::move(nmetadata)} {}
|
||||
|
||||
template < variable_policy_family Policy, pointer_kind Pointer >
|
||||
template < variable_policy::family Policy, pointer_kind Pointer >
|
||||
variable_state_ptr variable_state::make(std::string name, Pointer variable_ptr, metadata_map metadata) {
|
||||
type_registry& registry{type_registry::instance()};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user