Skip to content

Commit

Permalink
cull WCHAR_T pp blocks, tidy up printing and scanning
Browse files Browse the repository at this point in the history
  • Loading branch information
gorlak committed Jun 8, 2013
1 parent 6526b11 commit 3c546a8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 67 deletions.
15 changes: 4 additions & 11 deletions Encoding.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,9 @@ namespace Helium
Helium::ConvertString( chars, convertedChars, convertedChars##Count ); \
}

#if HELIUM_WCHAR_T
# define HELIUM_TCHAR_TO_CHAR( chars, convertedChars ) HELIUM_CONVERT_TO_CHAR( chars, convertedChars )
# define HELIUM_CHAR_TO_TCHAR( chars, convertedChars ) HELIUM_CONVERT_TO_WIDE( chars, convertedChars )
# define HELIUM_TCHAR_TO_WIDE( chars, convertedChars ) const wchar_t* convertedChars = chars;
# define HELIUM_WIDE_TO_TCHAR( chars, convertedChars ) const wchar_t* convertedChars = chars;
#else
# define HELIUM_TCHAR_TO_CHAR( chars, convertedChars ) const wchar_t* convertedChars = chars;
# define HELIUM_CHAR_TO_TCHAR( chars, convertedChars ) const wchar_t* convertedChars = chars;
# define HELIUM_TCHAR_TO_WIDE( chars, convertedChars ) HELIUM_CONVERT_TO_WIDE( chars, convertedChars )
# define HELIUM_WIDE_TO_TCHAR( chars, convertedChars ) HELIUM_CONVERT_TO_CHAR( chars, convertedChars )
#endif
#define HELIUM_TCHAR_TO_CHAR( chars, convertedChars ) const wchar_t* convertedChars = chars;
#define HELIUM_CHAR_TO_TCHAR( chars, convertedChars ) const wchar_t* convertedChars = chars;
#define HELIUM_TCHAR_TO_WIDE( chars, convertedChars ) HELIUM_CONVERT_TO_WIDE( chars, convertedChars )
#define HELIUM_WIDE_TO_TCHAR( chars, convertedChars ) HELIUM_CONVERT_TO_CHAR( chars, convertedChars )

#include "Platform/Encoding.inl"
36 changes: 0 additions & 36 deletions MemoryHeapImpl.inl
Original file line number Diff line number Diff line change
Expand Up @@ -51,46 +51,10 @@ static int VirtualMemoryFree( void* pMemory, size_t size )
/// @param[in] ... Format arguments.
static void PrintfWrapper( const char* pFormat, ... )
{
#if HELIUM_WCHAR_T
char message[ Helium::Trace::DEFAULT_MESSAGE_BUFFER_SIZE ];

va_list argList;
va_start( argList, pFormat );
#if HELIUM_OS_WIN
_snprintf( message, HELIUM_ARRAY_COUNT( message ), pFormat, argList );
#else
snprintf( message, HELIUM_ARRAY_COUNT( message ), pFormat, argList );
#endif
va_end( argList );

message[ HELIUM_ARRAY_COUNT( message ) - 1 ] = '\0';

// Do a direct conversion, assuming memory allocator logging is only using 7-bit ASCII text.
wchar_t messageWide[ Helium::Trace::DEFAULT_MESSAGE_BUFFER_SIZE ];

const char* pSourceCharacter = &message[ 0 ];
wchar_t* pDestCharacter = &messageWide[ 0 ];
for( ; ; )
{
uint8_t character = *pSourceCharacter;
*pDestCharacter = static_cast< wchar_t >( character );

if( character == '\0' )
{
break;
}

++pSourceCharacter;
++pDestCharacter;
}

HELIUM_TRACE( Helium::TraceLevels::Debug, TXT( "%s" ), messageWide );
#else
va_list argList;
va_start( argList, pFormat );
HELIUM_TRACE_VA( Helium::TraceLevels::Debug, pFormat, argList );
va_end( argList );
#endif
}
#endif // HELIUM_ENABLE_TRACE

Expand Down
7 changes: 0 additions & 7 deletions ThreadWin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,7 @@ bool Thread::Start( const tchar_t* pName, ThreadPriority priority )
nameInfo.dwType = 0x1000;
nameInfo.dwThreadId = threadId;
nameInfo.dwFlags = 0;

#if HELIUM_WCHAR_T
char name[ 128 ];
wcstombs_s( NULL, name, m_Name, _TRUNCATE );
nameInfo.szName = name;
#else
nameInfo.szName = m_Name;
#endif

__try
{
Expand Down
13 changes: 0 additions & 13 deletions Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -170,25 +170,12 @@ typedef double float64_t;
# endif
#endif

#ifdef HELIUM_WCHAR_T

/// Default character type.
typedef wchar_t tchar_t;

/// Prefix for declaring string and character literals of the default character type.
#define TXT2(X) L ## X
#define TXT(X) TXT2(X)

#else // HELIUM_WCHAR_T

/// Default character type.
typedef char tchar_t;

/// Prefix for declaring string and character literals of the default character type.
#define TXT( X ) X

#endif // HELIUM_WCHAR_T

typedef std::basic_string< tchar_t > tstring;

typedef std::basic_istream< tchar_t, std::char_traits< tchar_t > > tistream;
Expand Down

0 comments on commit 3c546a8

Please sign in to comment.