first version of shared types

This commit is contained in:
BlackMATov
2024-02-05 02:09:55 +07:00
parent e2f287420a
commit 9c3a8b5f6c
20 changed files with 1576 additions and 147 deletions

View File

@@ -14,6 +14,7 @@ namespace
int x;
int y;
ivec2() = default;
explicit ivec2(int nv) : x{nv}, y{nv} {}
ivec2(int nx, int ny) : x{nx}, y{ny} {}
@@ -22,35 +23,110 @@ namespace
}
};
struct another_ivec2 {
int x;
int y;
};
enum class color {
red, green, blue,
};
void bind_ivec2() {
meta::class_<ivec2>()
.constructor_<>()
.constructor_<int>()
.constructor_<int, int>()
.constructor_<const ivec2&>()
.member_("x", &ivec2::x)
.member_("y", &ivec2::y)
.method_("length2", &ivec2::length2);
meta::class_<another_ivec2>();
}
void bind_color() {
meta::enum_<color>()
.evalue_("red", color::red)
.evalue_("green", color::green)
.evalue_("blue", color::blue);
}
const auto library_scope = []() -> meta::scope {
bind_ivec2();
bind_color();
return meta::local_scope_("library_scope")
.typedef_<int>("int")
.typedef_<ivec2>("ivec2");
.typedef_<int*>("int*")
.typedef_<int const*>("int const*")
.typedef_<int volatile*>("int volatile*")
.typedef_<int const volatile*>("int const volatile*")
.typedef_<int&>("int&")
.typedef_<int const&>("int const&")
.typedef_<int volatile&>("int volatile&")
.typedef_<int const volatile&>("int const volatile&")
.typedef_<int**>("int**")
.typedef_<int* const*>("int* const*")
.typedef_<int const**>("int const**")
.typedef_<void**>("void**")
.typedef_<void* const*>("void* const*")
.typedef_<void const**>("void const**")
.typedef_<void()>("void()")
.typedef_<int*()>("int*()")
.typedef_<color(int*)>("color(int*)")
.typedef_<color(float*)>("color(float*)")
.typedef_<color(float*) noexcept>("color(float*) noexcept")
.typedef_<void>("void")
.typedef_<void*>("void*")
.typedef_<void const*>("void const*")
.typedef_<decltype(nullptr)>("nullptr_t")
.typedef_<decltype(nullptr)*>("nullptr_t*")
.typedef_<decltype(nullptr) const*>("nullptr_t const*")
.typedef_<ivec2>("ivec2")
.typedef_<another_ivec2>("another_ivec2")
.typedef_<ivec2 const&>("ivec2 const&")
.typedef_<ivec2 const&&>("ivec2 const&&")
.typedef_<ivec2[]>("ivec2[]")
.typedef_<ivec2(&)[]>("ivec2(&)[]")
.typedef_<ivec2 const(&)[]>("ivec2 const(&)[]")
.typedef_<ivec2 const*[42]>("ivec2 const*[42]")
.typedef_<ivec2 const*[21]>("ivec2 const*[21]")
.typedef_<color>("color")
.typedef_<color const*>("color const*")
.typedef_<int ivec2::*>("int ivec2::*")
.typedef_<int const ivec2::*>("int const ivec2::*")
.typedef_<int volatile ivec2::*>("int volatile ivec2::*")
.typedef_<int const volatile ivec2::*>("int const volatile ivec2::*")
.typedef_<int ivec2::*const*>("int ivec2::*const*")
.typedef_<int (ivec2::*)()>("int (ivec2::*)()")
.typedef_<float (ivec2::*)()>("float (ivec2::*)()")
.typedef_<int (ivec2::*)(float)>("int (ivec2::*)(float)")
.typedef_<int (ivec2::*)(double)>("int (ivec2::*)(double)")
.typedef_<int (ivec2::*)(double) noexcept>("int (ivec2::*)(double) noexcept")
.typedef_<int (ivec2::*const*)()>("int (ivec2::*const*)()")
;
}();
}
META_HPP_DEFINE_SHARED_TYPE(ivec2, "ivec2")
META_HPP_DEFINE_SHARED_TYPE(another_ivec2, "another_ivec2")
META_HPP_DEFINE_SHARED_TYPE(color, "color")
namespace meta_shared_lib
{
meta::scope get_library_scope() {
return library_scope;
}
meta::uvalue wrap_int(int value) {
return value;
}
int unwrap_int(const meta::uvalue& value) {
return value.as<int>();
}
}

View File

@@ -15,7 +15,4 @@ namespace meta_shared_lib
namespace meta = meta_hpp;
META_HPP_SHARED_LIB_EXPORT meta::scope get_library_scope();
META_HPP_SHARED_LIB_EXPORT meta::uvalue wrap_int(int value);
META_HPP_SHARED_LIB_EXPORT int unwrap_int(const meta::uvalue& value);
}