Skip to content

Commit

Permalink
We can now not set one or the other of the getter/setter pair of Prop…
Browse files Browse the repository at this point in the history
…erties.
  • Loading branch information
playmer committed Feb 28, 2017
1 parent f75da07 commit 8e2f5c3
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Reflection/Attribute.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "Attribute.hpp"

8 changes: 8 additions & 0 deletions Reflection/Attribute.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#pragma once
#include "Type.hpp"


class Attribute : public Base
{
DeclareType(Attribute)
};
12 changes: 12 additions & 0 deletions Reflection/Function.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,18 @@ struct Binding<Return(ObjectType::*)(Arguments...), typename std::enable_if<std:
}
};



template <>
struct Binding<nullptr_t>
{
template <nullptr_t BoundFunc>
static std::unique_ptr<Function> BindFunction(const char *name)
{
return std::unique_ptr<Function>();
}
};

template <typename FunctionSignature, FunctionSignature BoundFunc>
static std::unique_ptr<Function> BindFunction(const char *name)
{
Expand Down
1 change: 1 addition & 0 deletions Reflection/Property.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "Types.hpp"
#include "Function.hpp"

// TODO: Have some requirements on the types of setters and getters.
Expand Down
2 changes: 2 additions & 0 deletions Reflection/Reflection.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<ItemGroup>
<ClInclude Include="Algorithm.hpp" />
<ClInclude Include="Any.hpp" />
<ClInclude Include="Attribute.hpp" />
<ClInclude Include="CacheOrderedSet.hpp" />
<ClInclude Include="ConstexprString.hpp" />
<ClInclude Include="Field.hpp" />
Expand All @@ -125,6 +126,7 @@
<ClInclude Include="Types.hpp" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="Attribute.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="Type.cpp" />
</ItemGroup>
Expand Down
6 changes: 6 additions & 0 deletions Reflection/Reflection.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClInclude Include="Field.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Attribute.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
Expand All @@ -59,5 +62,8 @@
<ClCompile Include="Type.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Attribute.cpp">
<Filter>Header Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
22 changes: 22 additions & 0 deletions Reflection/Types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,28 @@ inline void GenericDoNothing(byte *aMemory)
{
}




template <typename Return, typename Arg = Return>
struct DecomposeFunctionType {};

template <typename Return, typename Event>
struct DecomposeFunctionType<Return(*)(Event*)>
{
using ReturnType = Return;
using EventType = Event;
};

template <typename Return, typename Object, typename Event>
struct DecomposeFunctionType<Return(Object::*)(Event*)>
{
using ReturnType = Return;
using ObjectType = Object;
using EventType = Event;
};


inline void runtime_assert(bool aValue, const char *aMessage = "")
{
if (false == aValue)
Expand Down
2 changes: 2 additions & 0 deletions Reflection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ int main()
auto func = BindFunction<decltype(&Test::Test2::UrMum::Print),&Test::Test2::UrMum::Print>("Print");
auto prop = BindProperty<decltype(&Test::Test2::UrMum::GetX), &Test::Test2::UrMum::GetX,
decltype(&Test::Test2::UrMum::SetX), &Test::Test2::UrMum::SetX>("X");
auto prop2 = BindProperty<nullptr_t, nullptr,
decltype(&Test::Test2::UrMum::SetX), &Test::Test2::UrMum::SetX>("X");

urMum->AddFunction(std::move(func));
urMum->AddProperty(std::move(prop));
Expand Down

0 comments on commit 8e2f5c3

Please sign in to comment.