More Linux work. Convert all casts to new style, away from legacy.

This commit is contained in:
mfeemster
2014-12-06 23:51:44 -08:00
parent 47dd9fe35c
commit 623d417f0f
52 changed files with 946 additions and 880 deletions

View File

@ -161,7 +161,7 @@ static uint CalcStrips(double memRequired, double memAvailable, double useMem)
if (memAvailable >= memRequired)
return 1;
strips = (uint)ceil(memRequired / memAvailable);
strips = uint(ceil(memRequired / memAvailable));
return strips;
}
@ -290,7 +290,7 @@ static bool StripsRender(RendererBase* renderer, Ember<T>& ember, vector<byte>&
vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>> randVec;
ember.m_Quality *= strips;
ember.m_FinalRasH = (size_t)ceil(floatStripH);
ember.m_FinalRasH = size_t(ceil(floatStripH));
if (strips > 1)
randVec = renderer->RandVec();
@ -298,7 +298,7 @@ static bool StripsRender(RendererBase* renderer, Ember<T>& ember, vector<byte>&
for (size_t strip = 0; strip < strips; strip++)
{
size_t stripOffset;
if (yAxisUp)
stripOffset = ember.m_FinalRasH * ((strips - strip) - 1) * renderer->FinalRowSize();
else
@ -346,7 +346,7 @@ static bool StripsRender(RendererBase* renderer, Ember<T>& ember, vector<byte>&
allStripsFinished(ember);
}
}
Memset(finalImage);
return success;
@ -370,7 +370,7 @@ static size_t VerifyStrips(size_t height, size_t strips,
{
os << "A strips value of " << strips << " does not divide evenly into a height of " << height << ".";
stripError2(os.str()); os.str("");
strips = NextHighestEvenDiv(height, strips);
if (strips == 1)//No higher divisor, check for a lower one.

View File

@ -159,12 +159,12 @@ public:
EmberOptionEntry(eOptionUse optUsage, eOptionIDs optId, const CharT* arg, T defaultVal, ESOArgType argType, string docString)
{
m_OptionUse = optUsage;
m_Option.nId = (int)optId;
m_Option.nId = int(optId);
m_Option.pszArg = arg;
m_Option.nArgType = argType;
m_DocString = docString;
m_NameWithoutDashes = Trim(string(arg), '-');
m_Val = Arg<T>((char*)m_NameWithoutDashes.c_str(), defaultVal);
m_Val = Arg<T>(const_cast<char*>(m_NameWithoutDashes.c_str()), defaultVal);
}
/// <summary>

View File

@ -70,8 +70,8 @@ static bool WriteJpeg(const char* filename, byte* image, size_t width, size_t he
jpeg_stdio_dest(&info, file);
info.in_color_space = JCS_RGB;
info.input_components = 3;
info.image_width = (JDIMENSION)width;
info.image_height = (JDIMENSION)height;
info.image_width = JDIMENSION(width);
info.image_height = JDIMENSION(height);
jpeg_set_defaults(&info);
jpeg_set_quality(&info, quality, TRUE);
jpeg_start_compress(&info, TRUE);
@ -79,36 +79,36 @@ static bool WriteJpeg(const char* filename, byte* image, size_t width, size_t he
//Write comments to jpeg.
if (enableComments)
{
jpeg_write_marker(&info, JPEG_COM, (byte*)verString, (int)strlen(verString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(verString), strlen(verString));
if (nick != "")
{
snprintf_s(nickString, 64, "flam3_nickname: %s", nick.c_str());
jpeg_write_marker(&info, JPEG_COM, (byte*)nickString, (int)strlen(nickString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(nickString), strlen(nickString));
}
if (url != "")
{
snprintf_s(urlString, 128, "flam3_url: %s", url.c_str());
jpeg_write_marker(&info, JPEG_COM, (byte*)urlString, (int)strlen(urlString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(urlString), strlen(urlString));
}
if (id != "")
{
snprintf_s(idString, 128, "flam3_id: %s", id.c_str());
jpeg_write_marker(&info, JPEG_COM, (byte*)idString, (int)strlen(idString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(idString), strlen(idString));
}
jpeg_write_marker(&info, JPEG_COM, (byte*)bvString, (int)strlen(bvString));
jpeg_write_marker(&info, JPEG_COM, (byte*)niString, (int)strlen(niString));
jpeg_write_marker(&info, JPEG_COM, (byte*)rtString, (int)strlen(rtString));
jpeg_write_marker(&info, JPEG_COM, (byte*)genomeString, (int)strlen(genomeString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(bvString), strlen(bvString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(niString), strlen(niString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(rtString), strlen(rtString));
jpeg_write_marker(&info, JPEG_COM, reinterpret_cast<byte*>(genomeString), strlen(genomeString));
}
for (i = 0; i < height; i++)
{
JSAMPROW row_pointer[1];
row_pointer[0] = (byte*)image + (3 * width * i);
row_pointer[0] = reinterpret_cast<byte*>(image) + (3 * width * i);
jpeg_write_scanlines(&info, row_pointer, 1);
}
@ -150,39 +150,39 @@ static bool WritePng(const char* filename, byte* image, size_t width, size_t hei
vector<byte*> rows(height);
text[0].compression = PNG_TEXT_COMPRESSION_NONE;
text[0].key = (png_charp)"flam3_version";
text[0].text = (png_charp)EmberVersion();
text[0].key = const_cast<png_charp>("flam3_version");
text[0].text = const_cast<png_charp>(EmberVersion());
text[1].compression = PNG_TEXT_COMPRESSION_NONE;
text[1].key = (png_charp)"flam3_nickname";
text[1].text = (png_charp)nick.c_str();
text[1].key = const_cast<png_charp>("flam3_nickname");
text[1].text = const_cast<png_charp>(nick.c_str());
text[2].compression = PNG_TEXT_COMPRESSION_NONE;
text[2].key = (png_charp)"flam3_url";
text[2].text = (png_charp)url.c_str();
text[2].key = const_cast<png_charp>("flam3_url");
text[2].text = const_cast<png_charp>(url.c_str());
text[3].compression = PNG_TEXT_COMPRESSION_NONE;
text[3].key = (png_charp)"flam3_id";
text[3].text = (png_charp)id.c_str();
text[3].key = const_cast<png_charp>("flam3_id");
text[3].text = const_cast<png_charp>(id.c_str());
text[4].compression = PNG_TEXT_COMPRESSION_NONE;
text[4].key = (png_charp)"flam3_error_rate";
text[4].text = (png_charp)comments.m_Badvals.c_str();
text[4].key = const_cast<png_charp>("flam3_error_rate");
text[4].text = const_cast<png_charp>(comments.m_Badvals.c_str());
text[5].compression = PNG_TEXT_COMPRESSION_NONE;
text[5].key = (png_charp)"flam3_samples";
text[5].text = (png_charp)comments.m_NumIters.c_str();
text[5].key = const_cast<png_charp>("flam3_samples");
text[5].text = const_cast<png_charp>(comments.m_NumIters.c_str());
text[6].compression = PNG_TEXT_COMPRESSION_NONE;
text[6].key = (png_charp)"flam3_time";
text[6].text = (png_charp)comments.m_Runtime.c_str();
text[6].key = const_cast<png_charp>("flam3_time");
text[6].text = const_cast<png_charp>(comments.m_Runtime.c_str());
text[7].compression = PNG_TEXT_COMPRESSION_zTXt;
text[7].key = (png_charp)"flam3_genome";
text[7].text = (png_charp)comments.m_Genome.c_str();
text[7].key = const_cast<png_charp>("flam3_genome");
text[7].text = const_cast<png_charp>(comments.m_Genome.c_str());
for (i = 0; i < height; i++)
rows[i] = (byte*)image + i * width * 4 * bytesPerChannel;
rows[i] = image + i * width * 4 * bytesPerChannel;
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
info_ptr = png_create_info_struct(png_ptr);
@ -197,7 +197,7 @@ static bool WritePng(const char* filename, byte* image, size_t width, size_t hei
png_init_io(png_ptr, file);
png_set_IHDR(png_ptr, info_ptr, (png_uint_32)width, (png_uint_32)height, 8 * (png_uint_32)bytesPerChannel,
png_set_IHDR(png_ptr, info_ptr, png_uint_32(width), png_uint_32(height), 8 * png_uint_32(bytesPerChannel),
PNG_COLOR_TYPE_RGBA,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_BASE,
@ -214,7 +214,7 @@ static bool WritePng(const char* filename, byte* image, size_t width, size_t hei
png_set_swap(png_ptr);
}
png_write_image(png_ptr, (png_bytepp) rows.data());
png_write_image(png_ptr, const_cast<png_bytepp>(rows.data()));
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(file);

View File

@ -214,7 +214,7 @@ class SimpleGlobUtil
{
public:
static const char * strchr(const char *s, char c) {
return (char *) sg_strchr((const SOCHAR_T *)s, c);
return sg_strchr(reinterpret_cast<const SOCHAR_T *>(s), c);
}
static const wchar_t * strchr(const wchar_t *s, wchar_t c) {
return ::wcschr(s, c);
@ -226,7 +226,7 @@ public:
#endif
static const char * strrchr(const char *s, char c) {
return (char *) sg_strrchr((const SOCHAR_T *)s, c);
return sg_strrchr(reinterpret_cast<const SOCHAR_T *>(s), c);
}
static const wchar_t * strrchr(const wchar_t *s, wchar_t c) {
return ::wcsrchr(s, c);
@ -246,7 +246,7 @@ public:
static void strcpy_s(char *dst, size_t n, const char *src) {
(void) n;
sg_strcpy_s((SOCHAR_T *)dst, n, (const SOCHAR_T *)src);
sg_strcpy_s(reinterpret_cast<SOCHAR_T *>(dst), n, reinterpret_cast<const SOCHAR_T *>(src));
}
static void strcpy_s(wchar_t *dst, size_t n, const wchar_t *src) {
# if __STDC_WANT_SECURE_LIB__
@ -263,7 +263,7 @@ public:
#endif
static int strcmp(const char *s1, const char *s2) {
return sg_strcmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2);
return sg_strcmp(reinterpret_cast<const SOCHAR_T *>(s1), reinterpret_cast<const SOCHAR_T *>(s2));
}
static int strcmp(const wchar_t *s1, const wchar_t *s2) {
return ::wcscmp(s1, s2);
@ -275,7 +275,7 @@ public:
#endif
static int strcasecmp(const char *s1, const char *s2) {
return sg_strcasecmp((const SOCHAR_T *)s1, (const SOCHAR_T *)s2);
return sg_strcasecmp(reinterpret_cast<const SOCHAR_T *>(s1), reinterpret_cast<const SOCHAR_T *>(s2));
}
#if _WIN32
static int strcasecmp(const wchar_t *s1, const wchar_t *s2) {
@ -389,7 +389,7 @@ struct SimpleGlobBase
{
SimpleGlobBase() {
memset(&m_glob, 0, sizeof(m_glob));
m_uiCurr = (size_t)-1;
m_uiCurr = size_t(-1);
}
~SimpleGlobBase() {
@ -446,11 +446,11 @@ struct SimpleGlobBase
void FindDone() {
globfree(&m_glob);
memset(&m_glob, 0, sizeof(m_glob));
m_uiCurr = (size_t)-1;
m_uiCurr = size_t(-1);
}
const char * GetFileNameS(char) const {
SG_ASSERT(m_uiCurr != (size_t)-1);
SG_ASSERT(m_uiCurr != size_t(-1));
return m_glob.gl_pathv[m_uiCurr];
}
@ -467,7 +467,7 @@ struct SimpleGlobBase
#endif
bool IsDirS(char) const {
SG_ASSERT(m_uiCurr != (size_t)-1);
SG_ASSERT(m_uiCurr != size_t(-1));
return m_bIsDir;
}
@ -747,8 +747,8 @@ CSimpleGlobTempl<SOCHAR>::Add(
int nError, nStartLen = m_nArgsLen;
bool bSuccess;
do {
nError = AppendName(this->GetFileNameS((SOCHAR)0), this->IsDirS((SOCHAR)0));
bSuccess = this->FindNextFileS((SOCHAR)0);
nError = AppendName(this->GetFileNameS(SOCHAR(0)), this->IsDirS(SOCHAR(0)));
bSuccess = this->FindNextFileS(SOCHAR(0));
}
while (nError == SG_SUCCESS && bSuccess);
SimpleGlobBase<SOCHAR>::FindDone();
@ -829,7 +829,7 @@ CSimpleGlobTempl<SOCHAR>::AppendName(
}
// add this entry. m_uiBufferLen is offset from beginning of buffer.
m_rgpArgs[m_nArgsLen++] = (SOCHAR*)m_uiBufferLen;
m_rgpArgs[m_nArgsLen++] = reinterpret_cast<SOCHAR*>(m_uiBufferLen);
SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen,
m_uiBufferSize - m_uiBufferLen, m_szPathPrefix);
SimpleGlobUtil::strcpy_s(m_pBuffer + m_uiBufferLen + uiPrefixLen,
@ -856,8 +856,8 @@ CSimpleGlobTempl<SOCHAR>::SetArgvArrayType(
if (a_nNewType == POINTERS) {
SG_ASSERT(m_nArgArrayType == OFFSETS);
for (int n = 0; n < m_nArgsLen; ++n) {
m_rgpArgs[n] = (m_rgpArgs[n] == (SOCHAR*)-1) ?
nullptr : m_pBuffer + (size_t) m_rgpArgs[n];
m_rgpArgs[n] = (m_rgpArgs[n] == reinterpret_cast<SOCHAR*>(-1)) ?
nullptr : m_pBuffer + size_t(m_rgpArgs[n]);
}
}
else {
@ -865,7 +865,7 @@ CSimpleGlobTempl<SOCHAR>::SetArgvArrayType(
SG_ASSERT(m_nArgArrayType == POINTERS);
for (int n = 0; n < m_nArgsLen; ++n) {
m_rgpArgs[n] = (m_rgpArgs[n] == nullptr) ?
(SOCHAR*) -1 : (SOCHAR*) (m_rgpArgs[n] - m_pBuffer);
reinterpret_cast<SOCHAR*>(-1) : reinterpret_cast<SOCHAR*>(m_rgpArgs[n] - m_pBuffer);
}
}
m_nArgArrayType = a_nNewType;
@ -887,7 +887,7 @@ CSimpleGlobTempl<SOCHAR>::GrowArgvArray(
void * pNewBuffer = realloc(m_rgpArgs, nNewSize * sizeof(SOCHAR*));
if (!pNewBuffer) return false;
m_nArgsSize = nNewSize;
m_rgpArgs = (SOCHAR**) pNewBuffer;
m_rgpArgs = reinterpret_cast<SOCHAR**>(pNewBuffer);
}
return true;
}
@ -908,7 +908,7 @@ CSimpleGlobTempl<SOCHAR>::GrowStringBuffer(
void * pNewBuffer = realloc(m_pBuffer, uiNewSize * sizeof(SOCHAR));
if (!pNewBuffer) return false;
m_uiBufferSize = uiNewSize;
m_pBuffer = (SOCHAR*) pNewBuffer;
m_pBuffer = reinterpret_cast<SOCHAR*>(pNewBuffer);
}
return true;
}
@ -920,8 +920,8 @@ CSimpleGlobTempl<SOCHAR>::fileSortCompare(
const void *a2
)
{
const SOCHAR * s1 = *(const SOCHAR **)a1;
const SOCHAR * s2 = *(const SOCHAR **)a2;
const SOCHAR * s1 = *(reinterpret_cast<const SOCHAR **>(a1));
const SOCHAR * s2 = *(reinterpret_cast<const SOCHAR **>(a2));
if (s1 && s2) {
return SimpleGlobUtil::strcasecmp(s1, s2);
}

View File

@ -522,7 +522,7 @@ private:
// Find the '=' character within a string.
inline SOCHAR * FindEquals(SOCHAR *s) const {
while (*s && *s != (SOCHAR)'=') ++s;
while (*s && *s != SOCHAR('=')) ++s;
return *s ? s : nullptr;
}
bool IsEqual(SOCHAR a_cLeft, SOCHAR a_cRight, int a_nArgType) const;
@ -576,8 +576,8 @@ CSimpleOptTempl<SOCHAR>::Init(
m_pszOptionText = nullptr;
m_pszOptionArg = nullptr;
m_nNextOption = (a_nFlags & SO_O_USEALL) ? 0 : 1;
m_szShort[0] = (SOCHAR)'-';
m_szShort[2] = (SOCHAR)'\0';
m_szShort[0] = SOCHAR('-');
m_szShort[2] = SOCHAR('\0');
m_nFlags = a_nFlags;
m_pszClump = nullptr;
@ -592,7 +592,7 @@ CSimpleOptTempl<SOCHAR>::Init(
free(m_rgShuffleBuf);
}
if (m_argc > SO_STATICBUF) {
m_rgShuffleBuf = (SOCHAR**) malloc(sizeof(SOCHAR*) * m_argc);
m_rgShuffleBuf = reinterpret_cast<SOCHAR**>(malloc(sizeof(SOCHAR*) * m_argc));
if (!m_rgShuffleBuf) {
return false;
}
@ -646,11 +646,11 @@ CSimpleOptTempl<SOCHAR>::Next()
// find this option in the options table
cFirst = PrepareArg(pszArg);
if (pszArg[0] == (SOCHAR)'-') {
if (pszArg[0] == SOCHAR('-')) {
// find any combined argument string and remove equals sign
m_pszOptionArg = FindEquals(pszArg);
if (m_pszOptionArg) {
*m_pszOptionArg++ = (SOCHAR)'\0';
*m_pszOptionArg++ = SOCHAR('\0');
}
}
nTableIdx = LookupOption(pszArg);
@ -659,9 +659,9 @@ CSimpleOptTempl<SOCHAR>::Next()
// option then we try the alternative forms
if (nTableIdx < 0
&& !m_pszOptionArg
&& pszArg[0] == (SOCHAR)'-'
&& pszArg[0] == SOCHAR('-')
&& pszArg[1]
&& pszArg[1] != (SOCHAR)'-'
&& pszArg[1] != SOCHAR('-')
&& pszArg[2])
{
// test for a short-form with argument if appropriate
@ -694,7 +694,7 @@ CSimpleOptTempl<SOCHAR>::Next()
// and we are not suppressing errors for invalid options then it
// is reported as an error, otherwise it is data.
if (nTableIdx < 0) {
if (!HasFlag(SO_O_NOERR) && pszArg[0] == (SOCHAR)'-') {
if (!HasFlag(SO_O_NOERR) && pszArg[0] == SOCHAR('-')) {
m_pszOptionText = pszArg;
break;
}
@ -702,7 +702,7 @@ CSimpleOptTempl<SOCHAR>::Next()
pszArg[0] = cFirst;
++nOptIdx;
if (m_pszOptionArg) {
*(--m_pszOptionArg) = (SOCHAR)'=';
*(--m_pszOptionArg) = SOCHAR('=');
}
}
}
@ -719,7 +719,7 @@ CSimpleOptTempl<SOCHAR>::Next()
// get the option id
ESOArgType nArgType = SO_NONE;
if (nTableIdx < 0) {
m_nLastError = (ESOError) nTableIdx; // error code
m_nLastError = ESOError(nTableIdx); // error code
}
else {
m_nOptionId = m_rgOptions[nTableIdx].nId;
@ -836,7 +836,7 @@ CSimpleOptTempl<SOCHAR>::NextClumped()
// unknown option
if (nTableIdx < 0) {
m_pszOptionText = m_szShort; // invalid option
m_nLastError = (ESOError) nTableIdx; // error code
m_nLastError = ESOError(nTableIdx); // error code
return false;
}
@ -951,11 +951,11 @@ CSimpleOptTempl<SOCHAR>::CalcMatch(
}
// match and skip leading hyphens
while (*a_pszSource == (SOCHAR)'-' && *a_pszSource == *a_pszTest) {
while (*a_pszSource == SOCHAR('-') && *a_pszSource == *a_pszTest) {
++a_pszSource;
++a_pszTest;
}
if (*a_pszSource == (SOCHAR)'-' || *a_pszTest == (SOCHAR)'-') {
if (*a_pszSource == SOCHAR('-') || *a_pszTest == SOCHAR('-')) {
return 0;
}
@ -1027,7 +1027,7 @@ CSimpleOptTempl<SOCHAR>::MultiArg(
if (!HasFlag(SO_O_NOERR)) {
for (int n = 0; n < a_nCount; ++n) {
SOCHAR ch = PrepareArg(rgpszArg[n]);
if (rgpszArg[n][0] == (SOCHAR)'-') {
if (rgpszArg[n][0] == SOCHAR('-')) {
rgpszArg[n][0] = ch;
m_nLastError = SO_ARG_INVALID_DATA;
return nullptr;