Skip to content

Commit 4415fd3

Browse files
committed
Expanded the type database
1 parent fb75a69 commit 4415fd3

5 files changed

Lines changed: 432 additions & 298 deletions

File tree

psl/inc/psl/reflection.hpp

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "psl/details/fixed_astring.hpp"
1010
#include "psl/string_utils.hpp"
1111

12-
namespace psl::ser {
12+
namespace psl::refl {
1313

1414
enum class mode_t { opt_in, opt_out };
1515

@@ -45,7 +45,7 @@ struct accessor;
4545
namespace impl {
4646
static consteval auto get_annotations_of(std::meta::info dm) {
4747
auto notes = annotations_of(dm);
48-
std::erase_if(notes, [](std::meta::info ann) { return parent_of(type_of(ann)) != ^^psl::ser; });
48+
std::erase_if(notes, [](std::meta::info ann) { return parent_of(type_of(ann)) != ^^psl::refl; });
4949
return notes;
5050
}
5151

@@ -125,7 +125,7 @@ namespace impl {
125125
struct serialize_instance_t {
126126
private:
127127
struct internal_type {
128-
friend psl::ser::accessor;
128+
friend psl::refl::accessor;
129129
};
130130

131131
static consteval void make_aggregate();
@@ -136,7 +136,7 @@ namespace impl {
136136
public:
137137
struct type : private internal_type {
138138
friend T;
139-
friend psl::ser::accessor;
139+
friend psl::refl::accessor;
140140
};
141141
type value;
142142
};
@@ -238,7 +238,7 @@ namespace impl {
238238
template <std::meta::info Member>
239239
consteval auto field_info_t::get() -> field_info_t {
240240
constexpr auto get_serialization_name = []() constexpr {
241-
constexpr auto alt_name = get_annotation_helper<Member, psl::ser::name_t<"">>();
241+
constexpr auto alt_name = get_annotation_helper<Member, psl::refl::name_t<"">>();
242242
if constexpr(alt_name.name.size() != 0) {
243243
return std::string_view {alt_name.name};
244244
}
@@ -269,7 +269,7 @@ struct accessor {
269269
template for(constexpr auto member : define_static_array(
270270
::std::meta::nonstatic_data_members_of(^^std::remove_cvref_t<Type>, ctx))) {
271271
constexpr auto has_annotations = impl::has_annotations_of(member);
272-
if constexpr(!(impl::get_annotation_helper<^^Type, container_t>().mode != psl::ser::mode_t::opt_out) ||
272+
if constexpr(!(impl::get_annotation_helper<^^Type, container_t>().mode != psl::refl::mode_t::opt_out) ||
273273
has_annotations) {
274274
result.push_back(member);
275275
}
@@ -334,7 +334,7 @@ struct accessor {
334334
constexpr auto ctx = std::meta::access_context::current();
335335
template for(constexpr auto member : define_static_array(
336336
::std::meta::nonstatic_data_members_of(^^std::remove_cvref_t<Type>, ctx))) {
337-
if constexpr(!psl::ser::impl::has_annotations_of(member)) {
337+
if constexpr(!psl::refl::impl::has_annotations_of(member)) {
338338
continue;
339339
}
340340
return true;
@@ -381,7 +381,7 @@ namespace impl {
381381

382382

383383
template <typename T>
384-
using serialize_type_t = psl::ser::impl::serialize_instance_t<T>::type;
384+
using serialize_type_t = psl::refl::impl::serialize_instance_t<T>::type;
385385

386386
namespace impl {
387387
template <typename Spec, typename Result = Spec>
@@ -415,8 +415,8 @@ namespace impl {
415415
if constexpr(std::is_default_constructible_v<type_t>) {
416416
parse<type_t, type_t>(result.[:member:], sub_args);
417417
} else {
418-
auto result = psl::ser::serialize_type_t<type_t> {};
419-
parse<type_t, psl::ser::serialize_type_t<type_t>>(result, sub_args);
418+
auto result = psl::refl::serialize_type_t<type_t> {};
419+
parse<type_t, psl::refl::serialize_type_t<type_t>>(result, sub_args);
420420
result.[:member:] = std::move(result);
421421
}
422422
continue;
@@ -471,20 +471,9 @@ template <impl::IsSerializableObject Spec>
471471
requires(!std::is_default_constructible_v<Spec>)
472472
constexpr auto parse(std::vector<std::pair<std::string_view, std::string_view>> const& args) {
473473
auto args_copy = args;
474-
using type = psl::ser::serialize_type_t<Spec>;
474+
using type = psl::refl::serialize_type_t<Spec>;
475475
auto result = type {};
476476
impl::parse<Spec>(result, args_copy);
477477
return Spec {std::move(result)};
478478
}
479-
480-
template <impl::IsSerializableObject Spec>
481-
constexpr auto to_spec() -> impl::type_spec_t {
482-
return impl::object_info_t<Spec> {}.to_spec();
483-
}
484-
485-
template <typename Spec>
486-
requires(!impl::IsSerializableObject<Spec>)
487-
constexpr auto to_spec() -> impl::type_spec_t {
488-
return impl::object_info_t<Spec> {}.to_spec();
489-
}
490-
} // namespace psl::ser
479+
} // namespace psl::refl

0 commit comments

Comments
 (0)