Skip to content

Commit

Permalink
Fixes for Unreal Engine, removed TChar
Browse files Browse the repository at this point in the history
  • Loading branch information
muit committed Aug 7, 2024
1 parent c16e8a8 commit 066b806
Show file tree
Hide file tree
Showing 40 changed files with 6,739 additions and 5,535 deletions.
14 changes: 7 additions & 7 deletions Include/Pipe/Core/Backward.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,15 @@ typedef int ssize_t;
// TODO maybe these should be undefined somewhere else?
#undef BACKWARD_HAS_UNWIND
#undef BACKWARD_HAS_BACKTRACE
#if BACKWARD_HAS_PDB_SYMBOL == 1
#if defined(BACKWARD_HAS_PDB_SYMBOL) && BACKWARD_HAS_PDB_SYMBOL == 1
#else
#undef BACKWARD_HAS_PDB_SYMBOL
#define BACKWARD_HAS_PDB_SYMBOL 1
#endif

#endif

#if BACKWARD_HAS_UNWIND == 1
#if defined(BACKWARD_HAS_UNWIND) && BACKWARD_HAS_UNWIND == 1

#include <unwind.h>
// while gcc's unwind.h defines something like that:
Expand All @@ -415,7 +415,7 @@ extern "C" uintptr_t _Unwind_GetIPInfo(_Unwind_Context *, int *);

#endif // BACKWARD_HAS_UNWIND == 1

#if BACKWARD_HAS_LIBUNWIND == 1
#if defined(BACKWARD_HAS_LIBUNWIND) && BACKWARD_HAS_LIBUNWIND == 1
#define UNW_LOCAL_ONLY
#include <libunwind.h>
#endif // BACKWARD_HAS_LIBUNWIND == 1
Expand Down Expand Up @@ -812,7 +812,7 @@ class StackTraceImplHolder : public StackTraceImplBase {
std::vector<void *, p::STLAllocator<void*>> _stacktrace;
};

#if BACKWARD_HAS_UNWIND == 1
#if defined(BACKWARD_HAS_UNWIND) && BACKWARD_HAS_UNWIND == 1

namespace details {

Expand Down Expand Up @@ -914,7 +914,7 @@ class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
};
};

#elif BACKWARD_HAS_LIBUNWIND == 1
#elif defined(BACKWARD_HAS_LIBUNWIND) && BACKWARD_HAS_LIBUNWIND == 1

template <>
class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
Expand Down Expand Up @@ -1223,7 +1223,7 @@ class StackTraceImpl<system_tag::current_tag> : public StackTraceImplHolder {
}
}

Super::_stacktrace.resize(std::min(Super::_stacktrace.size(), Super::skip_n_firsts() + depth));
//Super::_stacktrace.resize(std::min(Super::_stacktrace.size(), Super::skip_n_firsts() + depth));
return Super::size();
}

Expand Down Expand Up @@ -3763,7 +3763,7 @@ class SourceFile {
// but look, I will reuse it two times!
// What a good boy am I.
struct isspace {
bool operator()(char c) { return std::isspace(c); }
bool operator()(char c) { return bool(std::isspace(c)); }
};

bool started = false;
Expand Down
9 changes: 5 additions & 4 deletions Include/Pipe/Core/Char.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@ namespace p
}
};

#define LITERAL(CharType, StringLiteral) TLiteral<CharType>::Select(StringLiteral, L##StringLiteral)
#define P_LITERAL(CharType, StringLiteral) \
TLiteral<CharType>::Select(StringLiteral, L##StringLiteral)

/**
* TChar
* Set of utility functions operating on a single character. The functions
* are specialized for AnsiChar and TChar character types. You can use the
* are specialized for AnsiChar and char character types. You can use the
* typedefs FChar and FCharAnsi for convenience.
*/

Expand Down Expand Up @@ -152,7 +153,7 @@ namespace p
}
static inline bool IsUnderscore(CharType c)
{
return c == LITERAL(CharType, '_');
return c == P_LITERAL(CharType, '_');
}

static inline bool IsLinebreak(CharType c)
Expand All @@ -163,7 +164,7 @@ namespace p
static inline i32 StrtoI32(const CharType* str, CharType** end, i32 radix);
};

using FChar = TCharHelpers<TChar>;
using FChar = TCharHelpers<char>;
using FCharWide = TCharHelpers<WideChar>;
using FCharAnsi = TCharHelpers<AnsiChar>;

Expand Down
8 changes: 4 additions & 4 deletions Include/Pipe/Core/FixedString.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace p

} // namespace Details

template<sizet N, typename CharType = TChar, typename TTraits = std::char_traits<CharType>>
template<sizet N, typename CharType = char, typename TTraits = std::char_traits<CharType>>
struct TFixedString
{
// exposition only
Expand Down Expand Up @@ -696,14 +696,14 @@ namespace p

#endif // CPP20_SPACESHIP_OPERATOR_PRESENT

template<sizet N, typename CharType = TChar>
template<sizet N, typename CharType = char>
TFixedString(const CharType (&)[N]) -> TFixedString<N - 1, CharType>;

template<sizet N>
using FixedString = TFixedString<N, TChar>;
using FixedString = TFixedString<N, char>;

// template <sizet N>
// FixedString(const TChar (&)[N]) -> FixedString<N - 1>;
// FixedString(const char (&)[N]) -> FixedString<N - 1>;


template<sizet N, sizet M, typename CharType, typename TTraits>
Expand Down
4 changes: 0 additions & 4 deletions Include/Pipe/Core/GenericPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,6 @@ namespace p
// compilers which don't fully support C++11 yet (i.e. MSVC).
using Char32 = unsigned int;

// A switchable character - In-memory only.
// Either AnsiChar or WideChar
using TChar = AnsiChar;

// unsigned int the same size as a pointer
using uPtr = SelectIntPointerType<std::uint32_t, std::uint64_t, sizeof(void*)>::TIntPointer;

Expand Down
2 changes: 1 addition & 1 deletion Include/Pipe/Core/Guid.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace p
return Value.ToString();
}

friend void LexFromString(Guid& Result, const TChar* String)
friend void LexFromString(Guid& Result, const char* String)
{
Guid::Parse(String, Result);
}
Expand Down
4 changes: 2 additions & 2 deletions Include/Pipe/Core/Hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace p
// FNV String hash
// Use offset and prime based on the architecture (64bit or 32bit)
// http://www.isthe.com/chongo/tech/comp/fnv/index.html
template<typename CharType = TChar>
template<typename CharType = char>
inline PIPE_API constexpr sizet GetStringHash(const CharType* str)
{
// 32/64 bit architecture switch
Expand All @@ -41,7 +41,7 @@ namespace p
}
}

template<typename CharType = TChar>
template<typename CharType = char>
inline PIPE_API constexpr sizet GetStringHash(const CharType* str, sizet size)
{
// 32/64 bit architecture switch
Expand Down
1 change: 0 additions & 1 deletion Include/Pipe/Core/LinuxPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ namespace p
using TYPE_OF_NULL = decltype(__null);
#if P_PLATFORM_LINUX_USE_CHAR16
using WideChar = char16_t;
using TChar = WideChar;
#endif
};

Expand Down
1 change: 0 additions & 1 deletion Include/Pipe/Core/MacPlatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace p
using TYPE_OF_NULL = decltype(nullptr);
#if P_PLATFORM_MACOS_USE_CHAR16
using WideChar = char16_t;
using TChar = WideChar;
#else
using Char16 = char16_t;
#endif
Expand Down
2 changes: 0 additions & 2 deletions Include/Pipe/Core/Platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ namespace p
using AnsiChar = PlatformTypes::AnsiChar;
// A wide character. Normally a signed type.
using WideChar = PlatformTypes::WideChar;
// Either AnsiChar or WideChar, depending on whether the platform supports wide characters
using TChar = PlatformTypes::TChar;
// An 8-bit character containing a UTF8 (Unicode, 8-bit, variable-width) code unit.
using Char8 = PlatformTypes::Char8;
// A 16-bit character containing a UTF16 (Unicode, 16-bit, variable-width) code unit.
Expand Down
14 changes: 7 additions & 7 deletions Include/Pipe/Core/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ namespace p
template<typename CharType>
using TString =
std::basic_string<CharType, std::char_traits<CharType>, std::allocator<CharType>>;
using String = TString<TChar>;
using String = TString<char>;
using WString = TString<WideChar>;

template<typename... Args>
using FormatString = std::basic_format_string<TChar, Args...>;
using FormatString = std::basic_format_string<char, Args...>;

namespace Strings
{
Expand Down Expand Up @@ -88,20 +88,20 @@ namespace p
* @return The number of elements in InArray
*/
PIPE_API i32 ParseIntoArray(const String& str, TArray<String>& OutArray,
const TChar* pchDelim, bool InCullEmpty = true);
const char* pchDelim, bool InCullEmpty = true);

PIPE_API void RemoveFromStart(String& str, sizet size);
PIPE_API void RemoveFromEnd(String& str, sizet size);
PIPE_API void RemoveFromEnd(String& str, StringView subStr);

PIPE_API bool RemoveCharFromEnd(String& str, TChar c);
PIPE_API bool RemoveCharFromEnd(String& str, char c);

PIPE_API i32 Split(const String& str, TArray<String>& tokens, const TChar delim);
PIPE_API i32 Split(const String& str, TArray<String>& tokens, const char delim);

PIPE_API bool Split(const String& str, String& a, String& b, const TChar* delim);
PIPE_API bool Split(const String& str, String& a, String& b, const char* delim);

PIPE_API bool IsNumeric(const String& str);
PIPE_API bool IsNumeric(const TChar* Str);
PIPE_API bool IsNumeric(const char* Str);

PIPE_API String ParseMemorySize(sizet size);

Expand Down
60 changes: 30 additions & 30 deletions Include/Pipe/Core/StringView.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace p
template<typename CharType>
using TStringView = std::basic_string_view<CharType, std::char_traits<CharType>>;

using StringView = TStringView<TChar>;
using StringView = TStringView<char>;
using WStringView = TStringView<WideChar>;


Expand Down Expand Up @@ -187,103 +187,103 @@ namespace p
// END Any Char API


// BEGIN TChar API
// Specializations to avoid requiring <TChar> on function calls
// BEGIN char API
// Specializations to avoid requiring <char> on function calls

PIPE_API constexpr sizet Find(
const StringView str, const TChar c, FindDirection direction = FindDirection::Front)
const StringView str, const char c, FindDirection direction = FindDirection::Front)
{
return Find<TChar>(str, c, direction);
return Find<char>(str, c, direction);
}

PIPE_API constexpr sizet Find(const StringView str, const StringView subStr,
FindDirection direction = FindDirection::Front)
{
return Find<TChar>(str, subStr, direction);
return Find<char>(str, subStr, direction);
}

PIPE_API constexpr bool Contains(
const StringView str, const TChar c, FindDirection direction = FindDirection::Front)
const StringView str, const char c, FindDirection direction = FindDirection::Front)
{
return Contains<TChar>(str, c, direction);
return Contains<char>(str, c, direction);
}

PIPE_API constexpr bool Contains(const StringView str, const StringView subStr,
FindDirection direction = FindDirection::Front)
{
return Contains<TChar>(str, subStr, direction);
return Contains<char>(str, subStr, direction);
}

PIPE_API constexpr bool Equals(const StringView str, const StringView other)
{
return Equals<TChar>(str, other);
return Equals<char>(str, other);
}

PIPE_API constexpr bool Equals(const StringView str, const TChar c)
PIPE_API constexpr bool Equals(const StringView str, const char c)
{
return Equals<TChar>(str, c);
return Equals<char>(str, c);
}

PIPE_API constexpr bool StartsWith(const StringView str, const StringView subStr)
{
return StartsWith<TChar>(str, subStr);
return StartsWith<char>(str, subStr);
}

PIPE_API constexpr bool EndsWith(const StringView str, const StringView subStr)
{
return EndsWith<TChar>(str, subStr);
return EndsWith<char>(str, subStr);
}

PIPE_API constexpr bool EndsWith(const StringView str, const TChar c)
PIPE_API constexpr bool EndsWith(const StringView str, const char c)
{
return EndsWith<TChar>(str, c);
return EndsWith<char>(str, c);
}

PIPE_API constexpr StringView RemoveFromStart(const StringView str, sizet size)
{
return RemoveFromStart<TChar>(str, size);
return RemoveFromStart<char>(str, size);
}

PIPE_API constexpr StringView RemoveFromStart(const StringView str, const StringView subStr)
{
return RemoveFromStart<TChar>(str, subStr);
return RemoveFromStart<char>(str, subStr);
}


PIPE_API constexpr StringView RemoveFromEnd(const StringView str, sizet size)
{
return RemoveFromEnd<TChar>(str, size);
return RemoveFromEnd<char>(str, size);
}

PIPE_API constexpr StringView RemoveFromEnd(const StringView str, const StringView subStr)
{
return RemoveFromEnd<TChar>(str, subStr);
return RemoveFromEnd<char>(str, subStr);
}

PIPE_API constexpr StringView RemoveCharFromEnd(const StringView str, const TChar c)
PIPE_API constexpr StringView RemoveCharFromEnd(const StringView str, const char c)
{
return RemoveCharFromEnd<TChar>(str, c);
return RemoveCharFromEnd<char>(str, c);
}

PIPE_API constexpr StringView FrontSubstr(StringView str, sizet size)
{
return FrontSubstr<TChar>(str, size);
return FrontSubstr<char>(str, size);
}

PIPE_API constexpr StringView BackSubstr(StringView str, sizet size)
{
return BackSubstr<TChar>(str, size);
return BackSubstr<char>(str, size);
}

PIPE_API constexpr void Replace(
StringView str, const TChar searchChar, const TChar replacementChar)
StringView str, const char searchChar, const char replacementChar)
{
Replace<TChar>(str, searchChar, replacementChar);
Replace<char>(str, searchChar, replacementChar);
}

PIPE_API constexpr sizet Length(const TChar* str)
PIPE_API constexpr sizet Length(const char* str)
{
return Length<TChar>(str);
return Length<char>(str);
}

template<Number T>
Expand Down Expand Up @@ -319,7 +319,7 @@ namespace p
PIPE_API TOptional<i64> ToNumber<i64>(StringView str);
/** End ToNumber spetializations */

// END TChar API
// END char API
} // namespace Strings


Expand All @@ -328,7 +328,7 @@ namespace p
return GetStringHash(str.data(), str.size());
};

inline sizet GetHash(const TChar* str)
inline sizet GetHash(const char* str)
{
return GetStringHash(str);
};
Expand Down
Loading

0 comments on commit 066b806

Please sign in to comment.