Skip to content

Commit

Permalink
Fixed pointer names on MSVC
Browse files Browse the repository at this point in the history
  • Loading branch information
playmer committed Mar 23, 2017
1 parent 609e4ba commit e105e3e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
15 changes: 14 additions & 1 deletion Reflection/ConstexprString.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

#pragma once

constexpr size_t StringLength(const char *aString)
Expand Down Expand Up @@ -73,7 +74,7 @@ struct StringRange

constexpr StringRange(const char *aBegin)
: mBegin(aBegin),
mEnd(aBegin + StringLength(aBegin))
mEnd(aBegin + StringLength(aBegin))
{

}
Expand Down Expand Up @@ -113,6 +114,12 @@ struct ConstexprTokenWriter : public ConstexprToken<tConstSize>
constexpr ConstexprTokenWriter()
: mWritingPosition(this->mData)
{
for (size_t i = 0; i < tConstSize; i++)
{
this->mData[i] = 0;
}

this->mData[tConstSize] = { '\0' };
}


Expand Down Expand Up @@ -166,3 +173,9 @@ constexpr size_t GetFirstInstanceOfCharacter(const char *aString, size_t aSize,
return toReturn;
}







24 changes: 12 additions & 12 deletions Reflection/Reflection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ constexpr bool IsWhiteSpace(char aCharacter)
constexpr bool IsIdentifier(char aCharacter)
{
if ((('a' <= aCharacter) && (aCharacter <= 'z')) ||
(('A' <= aCharacter) && (aCharacter <= 'Z')) ||
(('0' <= aCharacter) && (aCharacter <= '9')) ||
'_' == aCharacter)
(('A' <= aCharacter) && (aCharacter <= 'Z')) ||
(('0' <= aCharacter) && (aCharacter <= '9')) ||
'_' == aCharacter)
{
return true;
}
Expand Down Expand Up @@ -111,18 +111,18 @@ constexpr auto GetTypeName()
constexpr const char* functionName = CONSTEXPR_FUNCTION_SIGNATURE;

// TODO: Should also work for GCC.
//#if defined(__clang__)
// size_t lastSpace = GetLastInstanceOfCharacter(typeName, StringLength(typeName), '=');
// size_t typeNameLength = totalLength - lastSpace - GetTypeEnd() - 2;
//
// ConstexprToken<typeNameLength> token{ typeName + lastSpace + 2 };
//#elif defined(_MSC_VER)
//#if defined(__clang__)
// size_t lastSpace = GetLastInstanceOfCharacter(typeName, StringLength(typeName), '=');
// size_t typeNameLength = totalLength - lastSpace - GetTypeEnd() - 2;
//
// ConstexprToken<typeNameLength> token{ typeName + lastSpace + 2 };
//#elif defined(_MSC_VER)
constexpr size_t firstArrow = GetFirstInstanceOfCharacter(functionName, StringLength(functionName), '<') + 1;
constexpr size_t lastArrow = GetLastInstanceOfCharacter(functionName, StringLength(functionName), '>');

constexpr size_t typenameTotalRangeSize = lastArrow - firstArrow;

ConstexprTokenWriter<typenameTotalRangeSize> finalName;
ConstexprTokenWriter<typenameTotalRangeSize + 1> finalName;

StringRange totalType{ functionName + firstArrow, functionName + lastArrow };

Expand All @@ -141,7 +141,7 @@ constexpr auto GetTypeName()

totalType.mBegin = token.mEnd;
}
//#endif
//#endif

return finalName;
}
}
18 changes: 9 additions & 9 deletions Reflection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@ namespace Test

auto x = BindField<decltype(&Test::Test2::Animal::x),
&Test::Test2::Animal::x>("X");
//auto y = BindField<decltype(&Test::Test2::Animal::y),
// &Test::Test2::Animal::y>("Y");
//auto z = BindField<decltype(&Test::Test2::Animal::z),
// &Test::Test2::Animal::z>("Z");
//auto w = BindField<decltype(&Test::Test2::Animal::w),
// &Test::Test2::Animal::w>("W");
auto y = BindField<decltype(&Test::Test2::Animal::y),
&Test::Test2::Animal::y>("Y");
auto z = BindField<decltype(&Test::Test2::Animal::z),
&Test::Test2::Animal::z>("Z");
auto w = BindField<decltype(&Test::Test2::Animal::w),
&Test::Test2::Animal::w>("W");

GetStaticType()->AddField(std::move(x));
//GetStaticType()->AddField(std::move(y));
//GetStaticType()->AddField(std::move(z));
//GetStaticType()->AddField(std::move(w));
GetStaticType()->AddField(std::move(y));
GetStaticType()->AddField(std::move(z));
GetStaticType()->AddField(std::move(w));
}
}
}
Expand Down

0 comments on commit e105e3e

Please sign in to comment.