metadata member for every type

This commit is contained in:
BlackMATov
2022-02-12 05:04:27 +07:00
parent 380aacc4f5
commit ccef5eae5d
16 changed files with 74 additions and 0 deletions

View File

@@ -204,6 +204,7 @@ namespace meta_hpp
namespace meta_hpp namespace meta_hpp
{ {
using argument_list = std::vector<argument>; using argument_list = std::vector<argument>;
using metadata_map = std::map<std::string, uvalue, std::less<>>;
using class_set = std::set<class_type, std::less<>>; using class_set = std::set<class_type, std::less<>>;
using class_map = std::map<std::string, class_type, std::less<>>; using class_map = std::map<std::string, class_type, std::less<>>;

View File

@@ -70,6 +70,8 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] type_kind get_kind() const noexcept; [[nodiscard]] type_kind get_kind() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
any_type(const array_type& other) noexcept; any_type(const array_type& other) noexcept;
any_type(const class_type& other) noexcept; any_type(const class_type& other) noexcept;
any_type(const constructor_type& other) noexcept; any_type(const constructor_type& other) noexcept;
@@ -126,6 +128,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] array_bitflags get_flags() const noexcept; [[nodiscard]] array_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] std::size_t get_extent() const noexcept; [[nodiscard]] std::size_t get_extent() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept; [[nodiscard]] any_type get_data_type() const noexcept;
@@ -144,6 +147,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] class_bitflags get_flags() const noexcept; [[nodiscard]] class_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] std::size_t get_size() const noexcept; [[nodiscard]] std::size_t get_size() const noexcept;
@@ -216,6 +220,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] constructor_bitflags get_flags() const noexcept; [[nodiscard]] constructor_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] any_type get_class_type() const noexcept; [[nodiscard]] any_type get_class_type() const noexcept;
@@ -236,6 +241,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] destructor_bitflags get_flags() const noexcept; [[nodiscard]] destructor_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] any_type get_class_type() const noexcept; [[nodiscard]] any_type get_class_type() const noexcept;
private: private:
@@ -253,6 +259,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] enum_bitflags get_flags() const noexcept; [[nodiscard]] enum_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] number_type get_underlying_type() const noexcept; [[nodiscard]] number_type get_underlying_type() const noexcept;
@@ -278,6 +285,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] function_bitflags get_flags() const noexcept; [[nodiscard]] function_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] any_type get_return_type() const noexcept; [[nodiscard]] any_type get_return_type() const noexcept;
@@ -298,6 +306,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] member_bitflags get_flags() const noexcept; [[nodiscard]] member_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] class_type get_owner_type() const noexcept; [[nodiscard]] class_type get_owner_type() const noexcept;
[[nodiscard]] any_type get_value_type() const noexcept; [[nodiscard]] any_type get_value_type() const noexcept;
@@ -316,6 +325,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] method_bitflags get_flags() const noexcept; [[nodiscard]] method_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] std::size_t get_arity() const noexcept; [[nodiscard]] std::size_t get_arity() const noexcept;
[[nodiscard]] class_type get_owner_type() const noexcept; [[nodiscard]] class_type get_owner_type() const noexcept;
@@ -336,6 +346,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept; [[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
private: private:
detail::nullptr_type_data_ptr data_; detail::nullptr_type_data_ptr data_;
friend auto detail::type_access<nullptr_type>(const nullptr_type&); friend auto detail::type_access<nullptr_type>(const nullptr_type&);
@@ -351,6 +362,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] number_bitflags get_flags() const noexcept; [[nodiscard]] number_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] std::size_t get_size() const noexcept; [[nodiscard]] std::size_t get_size() const noexcept;
private: private:
@@ -368,6 +380,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] pointer_bitflags get_flags() const noexcept; [[nodiscard]] pointer_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept; [[nodiscard]] any_type get_data_type() const noexcept;
private: private:
@@ -385,6 +398,7 @@ namespace meta_hpp
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] reference_bitflags get_flags() const noexcept; [[nodiscard]] reference_bitflags get_flags() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
[[nodiscard]] any_type get_data_type() const noexcept; [[nodiscard]] any_type get_data_type() const noexcept;
private: private:
@@ -401,6 +415,7 @@ namespace meta_hpp
[[nodiscard]] explicit operator bool() const noexcept; [[nodiscard]] explicit operator bool() const noexcept;
[[nodiscard]] type_id get_id() const noexcept; [[nodiscard]] type_id get_id() const noexcept;
[[nodiscard]] const metadata_map& get_metadata() const noexcept;
private: private:
detail::void_type_data_ptr data_; detail::void_type_data_ptr data_;
friend auto detail::type_access<void_type>(const void_type&); friend auto detail::type_access<void_type>(const void_type&);
@@ -447,6 +462,8 @@ namespace meta_hpp::detail
const type_id id; const type_id id;
const type_kind kind; const type_kind kind;
metadata_map metadata;
explicit type_data_base(type_id id, type_kind kind) explicit type_data_base(type_id id, type_kind kind)
: id{id} : id{id}
, kind{kind} {} , kind{kind} {}

View File

@@ -27,6 +27,10 @@ namespace meta_hpp
return data_->kind; return data_->kind;
} }
inline const metadata_map& any_type::get_metadata() const noexcept {
return data_->metadata;
}
inline any_type::any_type(const array_type& other) noexcept inline any_type::any_type(const array_type& other) noexcept
: data_{detail::type_access(other)} {} : data_{detail::type_access(other)} {}

View File

@@ -47,6 +47,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& array_type::get_metadata() const noexcept {
return data_->metadata;
}
inline std::size_t array_type::get_extent() const noexcept { inline std::size_t array_type::get_extent() const noexcept {
return data_->extent; return data_->extent;
} }

View File

@@ -53,6 +53,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& class_type::get_metadata() const noexcept {
return data_->metadata;
}
inline std::size_t class_type::get_size() const noexcept { inline std::size_t class_type::get_size() const noexcept {
return data_->size; return data_->size;
} }

View File

@@ -47,6 +47,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& constructor_type::get_metadata() const noexcept {
return data_->metadata;
}
inline std::size_t constructor_type::get_arity() const noexcept { inline std::size_t constructor_type::get_arity() const noexcept {
return data_->argument_types.size(); return data_->argument_types.size();
} }

View File

@@ -46,6 +46,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& destructor_type::get_metadata() const noexcept {
return data_->metadata;
}
inline any_type destructor_type::get_class_type() const noexcept { inline any_type destructor_type::get_class_type() const noexcept {
return data_->class_type; return data_->class_type;
} }

View File

@@ -49,6 +49,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& enum_type::get_metadata() const noexcept {
return data_->metadata;
}
inline number_type enum_type::get_underlying_type() const noexcept { inline number_type enum_type::get_underlying_type() const noexcept {
return data_->underlying_type; return data_->underlying_type;
} }

View File

@@ -47,6 +47,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& function_type::get_metadata() const noexcept {
return data_->metadata;
}
inline std::size_t function_type::get_arity() const noexcept { inline std::size_t function_type::get_arity() const noexcept {
return data_->argument_types.size(); return data_->argument_types.size();
} }

View File

@@ -47,6 +47,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& member_type::get_metadata() const noexcept {
return data_->metadata;
}
inline class_type member_type::get_owner_type() const noexcept { inline class_type member_type::get_owner_type() const noexcept {
return data_->owner_type; return data_->owner_type;
} }

View File

@@ -48,6 +48,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& method_type::get_metadata() const noexcept {
return data_->metadata;
}
inline std::size_t method_type::get_arity() const noexcept { inline std::size_t method_type::get_arity() const noexcept {
return data_->argument_types.size(); return data_->argument_types.size();
} }

View File

@@ -36,4 +36,8 @@ namespace meta_hpp
inline type_id nullptr_type::get_id() const noexcept { inline type_id nullptr_type::get_id() const noexcept {
return data_->id; return data_->id;
} }
inline const metadata_map& nullptr_type::get_metadata() const noexcept {
return data_->metadata;
}
} }

View File

@@ -45,6 +45,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& number_type::get_metadata() const noexcept {
return data_->metadata;
}
inline std::size_t number_type::get_size() const noexcept { inline std::size_t number_type::get_size() const noexcept {
return data_->size; return data_->size;
} }

View File

@@ -46,6 +46,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& pointer_type::get_metadata() const noexcept {
return data_->metadata;
}
inline any_type pointer_type::get_data_type() const noexcept { inline any_type pointer_type::get_data_type() const noexcept {
return data_->data_type; return data_->data_type;
} }

View File

@@ -46,6 +46,10 @@ namespace meta_hpp
return data_->flags; return data_->flags;
} }
inline const metadata_map& reference_type::get_metadata() const noexcept {
return data_->metadata;
}
inline any_type reference_type::get_data_type() const noexcept { inline any_type reference_type::get_data_type() const noexcept {
return data_->data_type; return data_->data_type;
} }

View File

@@ -36,4 +36,8 @@ namespace meta_hpp
inline type_id void_type::get_id() const noexcept { inline type_id void_type::get_id() const noexcept {
return data_->id; return data_->id;
} }
inline const metadata_map& void_type::get_metadata() const noexcept {
return data_->metadata;
}
} }