// // forward.h // reflection // // Created by Sam Jaffe on 7/3/22. // Copyright © 2022 Sam Jaffe. All rights reserved. // #pragma once #include #include #include #include #include #include namespace reflection { class Context; class ContextScope; class Object; class Scope; template class Reflection; template class Proxy; template class TypeCast; template using Cache = std::map; template using TypeMap = std::unordered_map; template using Accessor = std::function; template using Getter = std::function; template constexpr std::string_view Name = ""; } #define reflect(object) reflection::Object(object, #object) #define INSTANTIATE_REFLECTION_IMPL(T, name, ...) \ template <> constexpr std::string_view Name = name; \ template Cache> Reflection::members_; \ template Cache> Reflection::const_members_ #define INSTANTIATE_REFLECTION(T, ...) \ INSTANTIATE_REFLECTION_IMPL(T, ##__VA_ARGS__, #T) #define INSTANTIATE_REFLECTION_TYPECAST_IMPL(T, name, ...) \ template <> constexpr std::string_view Name = name; \ template TypeMap> TypeCast::get_; \ template TypeMap> TypeCast::set_ #define INSTANTIATE_REFLECTION_TYPECAST(T, ...) \ INSTANTIATE_REFLECTION_TYPECAST_IMPL(T, ##__VA_ARGS__, #T) #if !defined(CONCAT) #define CONCAT_IMPL(A, B) A##B #define CONCAT(A, B) CONCAT_IMPL(A, B) #endif #define REFLECTION(T) \ bool const CONCAT(reflection_, __LINE__) = ::reflection::Reflection() #define REFLECTION_TYPE_CAST(T) \ bool const CONCAT(type_cast_, __LINE__) = ::reflection::TypeCast() #define IS_SCOPE_CONTAINER(C) \ std::is_constructible_v()))>