Purge WCHAR typedef

This commit is contained in:
Chuck Walbourn 2016-05-11 11:50:00 -07:00
parent 50b9628682
commit ee3334ff0b
2 changed files with 25 additions and 25 deletions

View File

@ -41,7 +41,7 @@ namespace
return S_OK; return S_OK;
} }
inline HRESULT write_file_string(HANDLE hFile, const WCHAR* value) inline HRESULT write_file_string(HANDLE hFile, const wchar_t* value)
{ {
UINT length = (value) ? static_cast<UINT>( wcslen(value)+1 ) : 1; UINT length = (value) ? static_cast<UINT>( wcslen(value)+1 ) : 1;
@ -54,7 +54,7 @@ namespace
if (length > 0) if (length > 0)
{ {
DWORD bytes = static_cast<DWORD>(sizeof(WCHAR) * length); DWORD bytes = static_cast<DWORD>(sizeof(wchar_t) * length);
if (!WriteFile(hFile, value, bytes, &bytesWritten, nullptr)) if (!WriteFile(hFile, value, bytes, &bytesWritten, nullptr))
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
@ -64,11 +64,11 @@ namespace
} }
else else
{ {
WCHAR nul = 0; wchar_t nul = 0;
if (!WriteFile(hFile, &nul, sizeof(WCHAR), &bytesWritten, nullptr)) if (!WriteFile(hFile, &nul, sizeof(wchar_t), &bytesWritten, nullptr))
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
if (bytesWritten != sizeof(WCHAR)) if (bytesWritten != sizeof(wchar_t))
return E_FAIL; return E_FAIL;
} }
@ -1578,7 +1578,7 @@ HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Ma
return hr; return hr;
{ {
WCHAR fname[_MAX_FNAME]; wchar_t fname[_MAX_FNAME];
_wsplitpath_s(szFileName, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, nullptr, 0); _wsplitpath_s(szFileName, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, nullptr, 0);
hr = write_file_string(hFile.get(), fname); hr = write_file_string(hFile.get(), fname);
@ -1616,7 +1616,7 @@ HRESULT Mesh::ExportToCMO(const wchar_t* szFileName, size_t nMaterials, const Ma
} }
else else
{ {
WCHAR name[64]; wchar_t name[64];
swprintf_s(name, L"material%03u\n", j); swprintf_s(name, L"material%03u\n", j);
hr = write_file_string(hFile.get(), name); hr = write_file_string(hFile.get(), name);
} }

View File

@ -74,7 +74,7 @@ enum CHANNELS
struct SConversion struct SConversion
{ {
WCHAR szSrc [MAX_PATH]; wchar_t szSrc [MAX_PATH];
}; };
struct SValue struct SValue
@ -138,7 +138,7 @@ SValue g_pOptions[] =
#pragma prefast(disable : 26018, "Only used with static internal arrays") #pragma prefast(disable : 26018, "Only used with static internal arrays")
DWORD LookupByName(const WCHAR *pName, const SValue *pArray) DWORD LookupByName(const wchar_t *pName, const SValue *pArray)
{ {
while(pArray->pName) while(pArray->pName)
{ {
@ -151,7 +151,7 @@ DWORD LookupByName(const WCHAR *pName, const SValue *pArray)
return 0; return 0;
} }
const WCHAR* LookupByValue(DWORD pValue, const SValue *pArray) const wchar_t* LookupByValue(DWORD pValue, const SValue *pArray)
{ {
while(pArray->pName) while(pArray->pName)
{ {
@ -234,7 +234,7 @@ HRESULT __cdecl UVAtlasCallback( float fPercentDone )
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
HRESULT LoadFromOBJ(const WCHAR* szFilename, std::unique_ptr<Mesh>& inMesh, std::vector<Mesh::Material>& inMaterial, DWORD options ) HRESULT LoadFromOBJ(const wchar_t* szFilename, std::unique_ptr<Mesh>& inMesh, std::vector<Mesh::Material>& inMaterial, DWORD options )
{ {
WaveFrontReader<uint32_t> wfReader; WaveFrontReader<uint32_t> wfReader;
HRESULT hr = wfReader.Load(szFilename, (options & (1 << OPT_CLOCKWISE)) ? false : true ); HRESULT hr = wfReader.Load(szFilename, (options & (1 << OPT_CLOCKWISE)) ? false : true );
@ -313,11 +313,11 @@ HRESULT LoadFromOBJ(const WCHAR* szFilename, std::unique_ptr<Mesh>& inMesh, std:
mtl.diffuseColor = it->vDiffuse; mtl.diffuseColor = it->vDiffuse;
mtl.specularColor = (it->bSpecular) ? it->vSpecular : XMFLOAT3(0.f, 0.f, 0.f); mtl.specularColor = (it->bSpecular) ? it->vSpecular : XMFLOAT3(0.f, 0.f, 0.f);
WCHAR texture[_MAX_PATH] = { 0 }; wchar_t texture[_MAX_PATH] = { 0 };
if (*it->strTexture) if (*it->strTexture)
{ {
WCHAR txext[_MAX_EXT]; wchar_t txext[_MAX_EXT];
WCHAR txfname[_MAX_FNAME]; wchar_t txfname[_MAX_FNAME];
_wsplitpath_s(it->strTexture, nullptr, 0, nullptr, 0, txfname, _MAX_FNAME, txext, _MAX_EXT); _wsplitpath_s(it->strTexture, nullptr, 0, nullptr, 0, txfname, _MAX_FNAME, txext, _MAX_EXT);
if (!(options & (1 << OPT_NODDS))) if (!(options & (1 << OPT_NODDS)))
@ -354,8 +354,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
CHANNELS perVertex = CHANNEL_NONE; CHANNELS perVertex = CHANNEL_NONE;
DWORD uvOptions = UVATLAS_DEFAULT; DWORD uvOptions = UVATLAS_DEFAULT;
WCHAR szTexFile[MAX_PATH] = { 0 }; wchar_t szTexFile[MAX_PATH] = { 0 };
WCHAR szOutputFile[MAX_PATH] = { 0 }; wchar_t szOutputFile[MAX_PATH] = { 0 };
// Initialize COM (needed for WIC) // Initialize COM (needed for WIC)
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED); HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
@ -608,8 +608,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
// Process files // Process files
for( auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv ) for( auto pConv = conversion.begin(); pConv != conversion.end(); ++pConv )
{ {
WCHAR ext[_MAX_EXT]; wchar_t ext[_MAX_EXT];
WCHAR fname[_MAX_FNAME]; wchar_t fname[_MAX_FNAME];
_wsplitpath_s( pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT ); _wsplitpath_s( pConv->szSrc, nullptr, 0, nullptr, 0, fname, _MAX_FNAME, ext, _MAX_EXT );
if ( pConv != conversion.begin() ) if ( pConv != conversion.begin() )
@ -790,7 +790,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1; return 1;
} }
WCHAR txext[_MAX_EXT]; wchar_t txext[_MAX_EXT];
_wsplitpath_s(szTexFile, nullptr, 0, nullptr, 0, nullptr, 0, txext, _MAX_EXT); _wsplitpath_s(szTexFile, nullptr, 0, nullptr, 0, nullptr, 0, txext, _MAX_EXT);
ScratchImage iimage; ScratchImage iimage;
@ -854,7 +854,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
} }
else else
{ {
const WCHAR* szChannel = L"*unknown*"; const wchar_t* szChannel = L"*unknown*";
const float* pSignal = nullptr; const float* pSignal = nullptr;
size_t signalDim = 0; size_t signalDim = 0;
size_t signalStride = 0; size_t signalStride = 0;
@ -1022,7 +1022,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
Mesh::Material mtl; Mesh::Material mtl;
memset( &mtl, 0, sizeof(mtl) ); memset( &mtl, 0, sizeof(mtl) );
WCHAR matname[32]; wchar_t matname[32];
wsprintf( matname, L"Chart%02Iu", j+1 ); wsprintf( matname, L"Chart%02Iu", j+1 );
mtl.name = matname; mtl.name = matname;
mtl.specularPower = 1.f; mtl.specularPower = 1.f;
@ -1071,8 +1071,8 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
// Write results // Write results
wprintf(L"\n\t->\n"); wprintf(L"\n\t->\n");
WCHAR outputPath[ MAX_PATH ] = { 0 }; wchar_t outputPath[ MAX_PATH ] = { 0 };
WCHAR outputExt[ _MAX_EXT] = { 0 }; wchar_t outputExt[ _MAX_EXT] = { 0 };
if ( *szOutputFile ) if ( *szOutputFile )
{ {
@ -1095,7 +1095,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
wcscpy_s(outputExt, L".sdkmesh"); wcscpy_s(outputExt, L".sdkmesh");
} }
WCHAR outFilename[ _MAX_FNAME ] = { 0 }; wchar_t outFilename[ _MAX_FNAME ] = { 0 };
wcscpy_s( outFilename, fname ); wcscpy_s( outFilename, fname );
_wmakepath_s( outputPath, nullptr, nullptr, outFilename, outputExt ); _wmakepath_s( outputPath, nullptr, nullptr, outFilename, outputExt );
@ -1175,7 +1175,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
return 1; return 1;
} }
WCHAR uvFilename[_MAX_FNAME] = { 0 }; wchar_t uvFilename[_MAX_FNAME] = { 0 };
wcscpy_s(uvFilename, fname); wcscpy_s(uvFilename, fname);
wcscat_s(uvFilename, L"_texture"); wcscat_s(uvFilename, L"_texture");