Skip to content

Commit

Permalink
ICE fixed, simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
playmer committed Aug 7, 2018
1 parent 8bcf7a4 commit 65951c6
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 9 deletions.
15 changes: 13 additions & 2 deletions Reflection/Meta.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@

namespace YTE
{
namespace Detail
{
// This is needed to workaround a bug in MSVC relating to using
// decltype on auto template parameters. It will sometimes not
// deduce the correct type and thus fail some template matching
// attempts that should succeed.
// Bug reported here: https://developercommunity.visualstudio.com/content/problem/248892/failed-template-matching-with-auto-parameter.html
// Can be removed when bug is fixed.
template<typename T> T GetTypeMSVCWorkaround(T);
}

inline constexpr std::nullptr_t NoGetter = nullptr;
inline constexpr std::nullptr_t NoSetter = nullptr;

Expand Down Expand Up @@ -84,9 +95,9 @@ namespace YTE
};

template <auto tBoundFunction>
FunctionBuilder<decltype(tBoundFunction)> Function(char const* aName)
auto Function(char const* aName)
{
using FunctionSignature = decltype(tBoundFunction);
using FunctionSignature = decltype(Detail::GetTypeMSVCWorkaround(tBoundFunction));

auto function = Detail::Meta::FunctionBinding<FunctionSignature>:: template BindFunction<tBoundFunction>(aName);
function->SetOwningType(TypeId<tType>());
Expand Down
12 changes: 8 additions & 4 deletions Reflection/Reflection.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
<SDLCheck>true</SDLCheck>
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
Expand All @@ -87,7 +88,8 @@
<SDLCheck>true</SDLCheck>
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -99,7 +101,8 @@
<SDLCheck>true</SDLCheck>
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -115,7 +118,8 @@
<SDLCheck>true</SDLCheck>
<DisableLanguageExtensions>true</DisableLanguageExtensions>
<EnforceTypeConversionRules>true</EnforceTypeConversionRules>
<LanguageStandard>stdcpplatest</LanguageStandard>
<LanguageStandard>stdcpp17</LanguageStandard>
<AdditionalOptions>-permissive- %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand Down
162 changes: 159 additions & 3 deletions Reflection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ namespace YTE
YTEDefineType(GamepadSystem)
{
RegisterType<GamepadSystem>();

//YTEBindProperty(&GamepadSystem::Get, &GamepadSystem::Set, "asd");
TypeBuilder<GamepadSystem> builder;
builder.Property<&GamepadSystem::Get, &GamepadSystem::Set>("Id");
}
}

Expand All @@ -64,10 +64,166 @@ YTEDefineExternalType(YTE::ControllerId)

TypeBuilder<YTE::ControllerId> builder;

//builder.Enum<YTE::ControllerId::Xbox_P1>("Xbox_P1");
builder.Enum<YTE::ControllerId::Xbox_P1>("Xbox_P1");
}


int main()
{
}







































//#include <string>
//
//
//
//
//template <typename Return>
//struct CountFunctionArguments
//{
//
//};
//
//template <typename Return, typename ...Arguments>
//struct CountFunctionArguments<Return(Arguments...)>
//{
// constexpr static size_t Size()
// {
// return sizeof...(Arguments);
// }
//};
//
//template <typename Return, typename ...Arguments>
//struct CountFunctionArguments<Return(Arguments...) noexcept>
// : public CountFunctionArguments<Return(Arguments...)>
//{
//};
//
//template <typename Return, typename ...Arguments>
//struct CountFunctionArguments<Return(*)(Arguments...)>
// : public CountFunctionArguments<Return(Arguments...)>
//{
//};
//
//template <typename Return, typename ...Arguments>
//struct CountFunctionArguments<Return(*)(Arguments...) noexcept>
// : public CountFunctionArguments<Return(Arguments...)>
//{
//};
//
//template <typename Return, typename Object, typename ...Arguments>
//struct CountFunctionArguments<Return(Object::*)(Arguments...)>
// : public CountFunctionArguments<Return(Arguments...)>
//{
//};
//
//template <typename Return, typename Object, typename ...Arguments>
//struct CountFunctionArguments<Return(Object::*)(Arguments...) const>
// : public CountFunctionArguments<Return(Arguments...)>
//{
//};
//
//
//
//namespace Detail
//{
// // This is needed to workaround a bug in MSVC relating to using
// // decltype on auto template parameters. It will sometimes not
// // deduce the correct type and thus fail some template matching
// // attempts that should succeed.
// // Bug reported here: https://developercommunity.visualstudio.com/content/problem/248892/failed-template-matching-with-auto-parameter.html
// // Can be removed when bug is fixed.
// template<typename T> T GetTypeMSVCWorkaround(T);
//}
//
//
//template <typename tType>
//class TypeBuilder
//{
// public:
// template <typename tFunctionSignature>
// class FunctionBuilder
// {
// public:
// FunctionBuilder()
// {
//
// }
//
// template <typename... tArguments>
// void SetParameterNames(tArguments&& ...aNames)
// {
// constexpr size_t passedNames = sizeof...(aNames);
// constexpr size_t funcNames = CountFunctionArguments<tFunctionSignature>::Size();
// static_assert(0 != funcNames, "You needn't set the parameter names for this function, as there are no parameters.");
//
// static_assert(passedNames == funcNames,
// "If passing names of function parameters you must pass either exactly as many names as there are arguments, or 0.");
// }
// };
//
//
// template <auto tBoundFunction>
// auto Function(char const* aName)
// {
// using FunctionSignature = decltype(Detail::GetTypeMSVCWorkaround(tBoundFunction));
//
// return FunctionBuilder<FunctionSignature>{ };
// }
//};
//
//
//struct Type
//{
// public:
// static Type* GetGlobalType(const std::string &aName);
//
// static void InitializeTypeInfo()
// {
// TypeBuilder<Type> builder;
// builder.Function<&Type::GetGlobalType>("GetGlobalType")
// .SetParameterNames("aName");
// }
//};





0 comments on commit 65951c6

Please sign in to comment.