mirror of https://github.com/axmolengine/axmol.git
Merge pull request #488 from rh101/long-changes
Usage of long and unsigned long changed to platform independent fixed-sized types where appropriate.
This commit is contained in:
commit
1401e61702
|
@ -376,8 +376,8 @@ bool FontAtlas::prepareLetterDefinitions(const std::u32string& utf32Text)
|
||||||
|
|
||||||
int adjustForDistanceMap = _letterPadding / 2;
|
int adjustForDistanceMap = _letterPadding / 2;
|
||||||
int adjustForExtend = _letterEdgeExtend / 2;
|
int adjustForExtend = _letterEdgeExtend / 2;
|
||||||
long bitmapWidth;
|
int32_t bitmapWidth;
|
||||||
long bitmapHeight;
|
int32_t bitmapHeight;
|
||||||
int glyphHeight;
|
int glyphHeight;
|
||||||
Rect tempRect;
|
Rect tempRect;
|
||||||
FontLetterDefinition tempDef;
|
FontLetterDefinition tempDef;
|
||||||
|
|
|
@ -229,13 +229,13 @@ std::set<unsigned int>* BMFontConfiguration::parseConfigFile(const std::string&
|
||||||
return validCharsString;
|
return validCharsString;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char* pData, unsigned long size, const std::string& controlFile)
|
std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char* pData, uint32_t size, const std::string& controlFile)
|
||||||
{
|
{
|
||||||
/* based on http://www.angelcode.com/products/bmfont/doc/file_format.html file format */
|
/* based on http://www.angelcode.com/products/bmfont/doc/file_format.html file format */
|
||||||
|
|
||||||
std::set<unsigned int> *validCharsString = new (std::nothrow) std::set<unsigned int>();
|
std::set<unsigned int> *validCharsString = new (std::nothrow) std::set<unsigned int>();
|
||||||
|
|
||||||
unsigned long remains = size;
|
uint32_t remains = size;
|
||||||
|
|
||||||
CCASSERT(pData[3] == 3, "Only version 3 is supported");
|
CCASSERT(pData[3] == 3, "Only version 3 is supported");
|
||||||
|
|
||||||
|
@ -324,9 +324,9 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
||||||
chnl 1 uint 19+c*20
|
chnl 1 uint 19+c*20
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned long count = blockSize / 20;
|
uint32_t count = blockSize / 20;
|
||||||
|
|
||||||
for (unsigned long i = 0; i < count; i++)
|
for (uint32_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
uint32_t charId = 0; memcpy(&charId, pData + (i * 20), 4);
|
uint32_t charId = 0; memcpy(&charId, pData + (i * 20), 4);
|
||||||
|
|
||||||
|
@ -364,9 +364,9 @@ std::set<unsigned int>* BMFontConfiguration::parseBinaryConfigFile(unsigned char
|
||||||
amount 2 int 8+c*10
|
amount 2 int 8+c*10
|
||||||
*/
|
*/
|
||||||
|
|
||||||
unsigned long count = blockSize / 20;
|
uint32_t count = blockSize / 20;
|
||||||
|
|
||||||
for (unsigned long i = 0; i < count; i++)
|
for (uint32_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
uint32_t first = 0; memcpy(&first, pData + (i * 10), 4);
|
uint32_t first = 0; memcpy(&first, pData + (i * 10), 4);
|
||||||
uint32_t second = 0; memcpy(&second, pData + (i * 10) + 4, 4);
|
uint32_t second = 0; memcpy(&second, pData + (i * 10) + 4, 4);
|
||||||
|
|
|
@ -123,7 +123,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual std::set<unsigned int>* parseConfigFile(const std::string& controlFile);
|
virtual std::set<unsigned int>* parseConfigFile(const std::string& controlFile);
|
||||||
virtual std::set<unsigned int>* parseBinaryConfigFile(unsigned char* pData, unsigned long size, const std::string& controlFile);
|
virtual std::set<unsigned int>* parseBinaryConfigFile(unsigned char* pData, uint32_t size, const std::string& controlFile);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned int parseCharacterDefinition(const char* line);
|
unsigned int parseCharacterDefinition(const char* line);
|
||||||
|
|
|
@ -63,9 +63,9 @@ static std::unordered_map<std::string, DataRef> s_cacheFontData;
|
||||||
|
|
||||||
// ------ freetype2 stream parsing support ---
|
// ------ freetype2 stream parsing support ---
|
||||||
static unsigned long ft_stream_read_callback(FT_Stream stream,
|
static unsigned long ft_stream_read_callback(FT_Stream stream,
|
||||||
unsigned long offset,
|
unsigned long offset,
|
||||||
unsigned char* buf,
|
unsigned char* buf,
|
||||||
unsigned long size)
|
unsigned long size)
|
||||||
{
|
{
|
||||||
auto fd = (FileStream*)stream->descriptor.pointer;
|
auto fd = (FileStream*)stream->descriptor.pointer;
|
||||||
if (!fd)
|
if (!fd)
|
||||||
|
@ -388,8 +388,8 @@ const char* FontFreeType::getFontFamily() const
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar,
|
unsigned char* FontFreeType::getGlyphBitmap(uint64_t theChar,
|
||||||
long& outWidth,
|
int32_t& outWidth,
|
||||||
long& outHeight,
|
int32_t& outHeight,
|
||||||
Rect& outRect,
|
Rect& outRect,
|
||||||
int& xAdvance)
|
int& xAdvance)
|
||||||
{
|
{
|
||||||
|
@ -543,8 +543,8 @@ unsigned char* FontFreeType::getGlyphBitmapWithOutline(uint64_t theChar, FT_BBox
|
||||||
{
|
{
|
||||||
FT_Outline* outline = &reinterpret_cast<FT_OutlineGlyph>(glyph)->outline;
|
FT_Outline* outline = &reinterpret_cast<FT_OutlineGlyph>(glyph)->outline;
|
||||||
FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_GRIDFIT, &bbox);
|
FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_GRIDFIT, &bbox);
|
||||||
long width = (bbox.xMax - bbox.xMin) >> 6;
|
int32_t width = (bbox.xMax - bbox.xMin) >> 6;
|
||||||
long rows = (bbox.yMax - bbox.yMin) >> 6;
|
int32_t rows = (bbox.yMax - bbox.yMin) >> 6;
|
||||||
|
|
||||||
FT_Bitmap bmp;
|
FT_Bitmap bmp;
|
||||||
bmp.buffer = new (std::nothrow) unsigned char[width * rows];
|
bmp.buffer = new (std::nothrow) unsigned char[width * rows];
|
||||||
|
@ -573,9 +573,9 @@ unsigned char* FontFreeType::getGlyphBitmapWithOutline(uint64_t theChar, FT_BBox
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* makeDistanceMap(unsigned char* img, long width, long height)
|
unsigned char* makeDistanceMap(unsigned char* img, int32_t width, int32_t height)
|
||||||
{
|
{
|
||||||
long pixelAmount = (width + 2 * FontFreeType::DistanceMapSpread) * (height + 2 * FontFreeType::DistanceMapSpread);
|
int32_t pixelAmount = (width + 2 * FontFreeType::DistanceMapSpread) * (height + 2 * FontFreeType::DistanceMapSpread);
|
||||||
|
|
||||||
short* xdist = (short*)malloc(pixelAmount * sizeof(short));
|
short* xdist = (short*)malloc(pixelAmount * sizeof(short));
|
||||||
short* ydist = (short*)malloc(pixelAmount * sizeof(short));
|
short* ydist = (short*)malloc(pixelAmount * sizeof(short));
|
||||||
|
@ -584,10 +584,10 @@ unsigned char* makeDistanceMap(unsigned char* img, long width, long height)
|
||||||
double* data = (double*)calloc(pixelAmount, sizeof(double));
|
double* data = (double*)calloc(pixelAmount, sizeof(double));
|
||||||
double* outside = (double*)calloc(pixelAmount, sizeof(double));
|
double* outside = (double*)calloc(pixelAmount, sizeof(double));
|
||||||
double* inside = (double*)calloc(pixelAmount, sizeof(double));
|
double* inside = (double*)calloc(pixelAmount, sizeof(double));
|
||||||
long i, j;
|
int32_t i, j;
|
||||||
|
|
||||||
// Convert img into double (data) rescale image levels between 0 and 1
|
// Convert img into double (data) rescale image levels between 0 and 1
|
||||||
long outWidth = width + 2 * FontFreeType::DistanceMapSpread;
|
int32_t outWidth = width + 2 * FontFreeType::DistanceMapSpread;
|
||||||
for (i = 0; i < width; ++i)
|
for (i = 0; i < width; ++i)
|
||||||
{
|
{
|
||||||
for (j = 0; j < height; ++j)
|
for (j = 0; j < height; ++j)
|
||||||
|
@ -660,8 +660,8 @@ void FontFreeType::renderCharAt(unsigned char* dest,
|
||||||
int posX,
|
int posX,
|
||||||
int posY,
|
int posY,
|
||||||
unsigned char* bitmap,
|
unsigned char* bitmap,
|
||||||
long bitmapWidth,
|
int32_t bitmapWidth,
|
||||||
long bitmapHeight)
|
int32_t bitmapHeight)
|
||||||
{
|
{
|
||||||
int iX = posX;
|
int iX = posX;
|
||||||
int iY = posY;
|
int iY = posY;
|
||||||
|
@ -673,11 +673,11 @@ void FontFreeType::renderCharAt(unsigned char* dest,
|
||||||
bitmapWidth += 2 * DistanceMapSpread;
|
bitmapWidth += 2 * DistanceMapSpread;
|
||||||
bitmapHeight += 2 * DistanceMapSpread;
|
bitmapHeight += 2 * DistanceMapSpread;
|
||||||
|
|
||||||
for (long y = 0; y < bitmapHeight; ++y)
|
for (int32_t y = 0; y < bitmapHeight; ++y)
|
||||||
{
|
{
|
||||||
long bitmap_y = y * bitmapWidth;
|
int32_t bitmap_y = y * bitmapWidth;
|
||||||
|
|
||||||
for (long x = 0; x < bitmapWidth; ++x)
|
for (int32_t x = 0; x < bitmapWidth; ++x)
|
||||||
{
|
{
|
||||||
/* Dual channel 16-bit output (more complicated, but good precision and range) */
|
/* Dual channel 16-bit output (more complicated, but good precision and range) */
|
||||||
/*int index = (iX + ( iY * destSize )) * 3;
|
/*int index = (iX + ( iY * destSize )) * 3;
|
||||||
|
@ -700,9 +700,9 @@ void FontFreeType::renderCharAt(unsigned char* dest,
|
||||||
else if (_outlineSize > 0)
|
else if (_outlineSize > 0)
|
||||||
{
|
{
|
||||||
unsigned char tempChar;
|
unsigned char tempChar;
|
||||||
for (long y = 0; y < bitmapHeight; ++y)
|
for (int32_t y = 0; y < bitmapHeight; ++y)
|
||||||
{
|
{
|
||||||
long bitmap_y = y * bitmapWidth;
|
int32_t bitmap_y = y * bitmapWidth;
|
||||||
|
|
||||||
for (int x = 0; x < bitmapWidth; ++x)
|
for (int x = 0; x < bitmapWidth; ++x)
|
||||||
{
|
{
|
||||||
|
@ -721,9 +721,9 @@ void FontFreeType::renderCharAt(unsigned char* dest,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (long y = 0; y < bitmapHeight; ++y)
|
for (int32_t y = 0; y < bitmapHeight; ++y)
|
||||||
{
|
{
|
||||||
long bitmap_y = y * bitmapWidth;
|
int32_t bitmap_y = y * bitmapWidth;
|
||||||
|
|
||||||
for (int x = 0; x < bitmapWidth; ++x)
|
for (int x = 0; x < bitmapWidth; ++x)
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,14 +86,14 @@ public:
|
||||||
int posX,
|
int posX,
|
||||||
int posY,
|
int posY,
|
||||||
unsigned char* bitmap,
|
unsigned char* bitmap,
|
||||||
long bitmapWidth,
|
int32_t bitmapWidth,
|
||||||
long bitmapHeight);
|
int32_t bitmapHeight);
|
||||||
|
|
||||||
FT_Encoding getEncoding() const { return _encoding; }
|
FT_Encoding getEncoding() const { return _encoding; }
|
||||||
|
|
||||||
int* getHorizontalKerningForTextUTF32(const std::u32string& text, int& outNumLetters) const override;
|
int* getHorizontalKerningForTextUTF32(const std::u32string& text, int& outNumLetters) const override;
|
||||||
|
|
||||||
unsigned char* getGlyphBitmap(uint64_t theChar, long& outWidth, long& outHeight, Rect& outRect, int& xAdvance);
|
unsigned char* getGlyphBitmap(uint64_t theChar, int32_t& outWidth, int32_t& outHeight, Rect& outRect, int& xAdvance);
|
||||||
|
|
||||||
int getFontAscender() const;
|
int getFontAscender() const;
|
||||||
const char* getFontFamily() const;
|
const char* getFontFamily() const;
|
||||||
|
|
|
@ -466,8 +466,8 @@ void ParticleBatchNode::draw(Renderer* renderer, const Mat4 & transform, uint32_
|
||||||
void ParticleBatchNode::increaseAtlasCapacityTo(ssize_t quantity)
|
void ParticleBatchNode::increaseAtlasCapacityTo(ssize_t quantity)
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: ParticleBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
|
CCLOG("cocos2d: ParticleBatchNode: resizing TextureAtlas capacity from [%lu] to [%lu].",
|
||||||
(long)_textureAtlas->getCapacity(),
|
(int32_t)_textureAtlas->getCapacity(),
|
||||||
(long)quantity);
|
(int32_t)quantity);
|
||||||
|
|
||||||
if( ! _textureAtlas->resizeCapacity(quantity) ) {
|
if( ! _textureAtlas->resizeCapacity(quantity) ) {
|
||||||
// serious problems
|
// serious problems
|
||||||
|
|
|
@ -127,7 +127,7 @@ ssize_t BundleReader::tell()
|
||||||
return _position;
|
return _position;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BundleReader::seek(long int offset, int origin)
|
bool BundleReader::seek(int32_t offset, int origin)
|
||||||
{
|
{
|
||||||
if (!_buffer)
|
if (!_buffer)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -100,7 +100,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Sets the position of the file pointer.
|
* Sets the position of the file pointer.
|
||||||
*/
|
*/
|
||||||
bool seek(long int offset, int origin);
|
bool seek(int32_t offset, int origin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the file pointer at the start of the file.
|
* Sets the file pointer at the start of the file.
|
||||||
|
|
|
@ -36,7 +36,7 @@
|
||||||
|
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
typedef struct _GUID {
|
typedef struct _GUID {
|
||||||
unsigned long Data1;
|
uint32_t Data1;
|
||||||
unsigned short Data2;
|
unsigned short Data2;
|
||||||
unsigned short Data3;
|
unsigned short Data3;
|
||||||
unsigned char Data4[8];
|
unsigned char Data4[8];
|
||||||
|
|
|
@ -169,7 +169,7 @@ namespace cocos2d {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
long rate = 0;
|
int32_t rate = 0;
|
||||||
int error = MPG123_OK;
|
int error = MPG123_OK;
|
||||||
int mp3Encoding = 0;
|
int mp3Encoding = 0;
|
||||||
int channel = 0;
|
int channel = 0;
|
||||||
|
|
|
@ -113,7 +113,7 @@ namespace cocos2d {
|
||||||
{
|
{
|
||||||
int currentSection = 0;
|
int currentSection = 0;
|
||||||
int bytesToRead = framesToBytes(framesToRead);
|
int bytesToRead = framesToBytes(framesToRead);
|
||||||
long bytesRead = ov_read(&_vf, pcmBuf, bytesToRead, 0, 2, 1, ¤tSection);
|
int32_t bytesRead = ov_read(&_vf, pcmBuf, bytesToRead, 0, 2, 1, ¤tSection);
|
||||||
return bytesToFrames(bytesRead);
|
return bytesToFrames(bytesRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -230,7 +230,7 @@ namespace cocos2d {
|
||||||
uint32_t AudioDecoderWav::read(uint32_t framesToRead, char* pcmBuf)
|
uint32_t AudioDecoderWav::read(uint32_t framesToRead, char* pcmBuf)
|
||||||
{
|
{
|
||||||
auto bytesToRead = framesToBytes(framesToRead);
|
auto bytesToRead = framesToBytes(framesToRead);
|
||||||
long bytesRead = wav_read(&_wavf, pcmBuf, bytesToRead);
|
int32_t bytesRead = wav_read(&_wavf, pcmBuf, bytesToRead);
|
||||||
return bytesToFrames(bytesRead);
|
return bytesToFrames(bytesRead);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1169,8 +1169,8 @@ void Director::showStats()
|
||||||
_isStatusLabelUpdated = false;
|
_isStatusLabelUpdated = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned long prevCalls = 0;
|
static uint32_t prevCalls = 0;
|
||||||
static unsigned long prevVerts = 0;
|
static uint32_t prevVerts = 0;
|
||||||
|
|
||||||
++_frames;
|
++_frames;
|
||||||
_accumDt += _deltaTime;
|
_accumDt += _deltaTime;
|
||||||
|
@ -1190,8 +1190,8 @@ void Director::showStats()
|
||||||
_frames = 0;
|
_frames = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto currentCalls = (unsigned long)_renderer->getDrawnBatches();
|
auto currentCalls = (uint32_t)_renderer->getDrawnBatches();
|
||||||
auto currentVerts = (unsigned long)_renderer->getDrawnVertices();
|
auto currentVerts = (uint32_t)_renderer->getDrawnVertices();
|
||||||
if( currentCalls != prevCalls ) {
|
if( currentCalls != prevCalls ) {
|
||||||
sprintf(buffer, "GL calls:%6lu", currentCalls);
|
sprintf(buffer, "GL calls:%6lu", currentCalls);
|
||||||
_drawnBatchesLabel->setString(buffer);
|
_drawnBatchesLabel->setString(buffer);
|
||||||
|
|
|
@ -115,7 +115,7 @@ std::string ProfilingTimer::getDescription() const
|
||||||
{
|
{
|
||||||
static char s_description[512] = {0};
|
static char s_description[512] = {0};
|
||||||
|
|
||||||
sprintf(s_description, "%s ::\tavg1: %ldu,\tavg2: %ldu,\tmin: %ldu,\tmax: %ldu,\ttotal: %.2fs,\tnr calls: %ld", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls);
|
sprintf(s_description, "%s ::\tavg1: %u,\tavg2: %u,\tmin: %u,\tmax: %u,\ttotal: %.2fs,\tnr calls: %d", _nameStr.c_str(), _averageTime1, _averageTime2, minTime, maxTime, totalTime/1000000., numberOfCalls);
|
||||||
return s_description;
|
return s_description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ void ProfilingEndTimingBlock(const char *timerName)
|
||||||
CCASSERT(timer, "CCProfilingTimer not found");
|
CCASSERT(timer, "CCProfilingTimer not found");
|
||||||
|
|
||||||
|
|
||||||
long duration = static_cast<long>(chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count());
|
int32_t duration = static_cast<int32_t>(chrono::duration_cast<chrono::microseconds>(now - timer->_startTime).count());
|
||||||
|
|
||||||
timer->totalTime += duration;
|
timer->totalTime += duration;
|
||||||
timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f;
|
timer->_averageTime1 = (timer->_averageTime1 + duration) / 2.0f;
|
||||||
|
|
|
@ -133,12 +133,12 @@ public:
|
||||||
|
|
||||||
std::string _nameStr;
|
std::string _nameStr;
|
||||||
std::chrono::high_resolution_clock::time_point _startTime;
|
std::chrono::high_resolution_clock::time_point _startTime;
|
||||||
long _averageTime1;
|
int32_t _averageTime1;
|
||||||
long _averageTime2;
|
int32_t _averageTime2;
|
||||||
long minTime;
|
int32_t minTime;
|
||||||
long maxTime;
|
int32_t maxTime;
|
||||||
long totalTime;
|
int32_t totalTime;
|
||||||
long numberOfCalls;
|
int32_t numberOfCalls;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void CC_DLL ProfilingBeginTimingBlock(const char *timerName);
|
extern void CC_DLL ProfilingBeginTimingBlock(const char *timerName);
|
||||||
|
|
|
@ -895,25 +895,6 @@ float Properties::getFloat(const char* name) const
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
long Properties::getLong(const char* name) const
|
|
||||||
{
|
|
||||||
const char* valueString = getString(name);
|
|
||||||
if (valueString)
|
|
||||||
{
|
|
||||||
long value;
|
|
||||||
int scanned;
|
|
||||||
scanned = sscanf(valueString, "%ld", &value);
|
|
||||||
if (scanned != 1)
|
|
||||||
{
|
|
||||||
CCLOGERROR("Error attempting to parse property '%s' as a long integer.", name);
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0L;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Properties::getMat4(const char* name, Mat4* out) const
|
bool Properties::getMat4(const char* name, Mat4* out) const
|
||||||
{
|
{
|
||||||
CCASSERT(out, "Invalid out");
|
CCASSERT(out, "Invalid out");
|
||||||
|
|
|
@ -327,18 +327,6 @@ public:
|
||||||
*/
|
*/
|
||||||
float getFloat(const char* name = NULL) const;
|
float getFloat(const char* name = NULL) const;
|
||||||
|
|
||||||
/**
|
|
||||||
* Interpret the value of the given property as a long integer.
|
|
||||||
* If the property does not exist, zero will be returned.
|
|
||||||
* If the property exists but could not be scanned, an error will be logged and zero will be returned.
|
|
||||||
*
|
|
||||||
* @param name The name of the property to interpret, or NULL to return the current property's value.
|
|
||||||
*
|
|
||||||
* @return The value of the given property interpreted as a long.
|
|
||||||
* Zero if the property does not exist or could not be scanned.
|
|
||||||
*/
|
|
||||||
long getLong(const char* name = NULL) const;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interpret the value of the given property as a Matrix.
|
* Interpret the value of the given property as a Matrix.
|
||||||
* If the property does not exist, out will be set to the identity matrix.
|
* If the property does not exist, out will be set to the identity matrix.
|
||||||
|
|
|
@ -382,8 +382,8 @@ void UserDefault::lazyInit()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int filesize = static_cast<int>(posix_lseek(_fd, 0, SEEK_END));
|
int filesize = static_cast<int>(posix_lseek64(_fd, 0, SEEK_END));
|
||||||
posix_lseek(_fd, 0, SEEK_SET);
|
posix_lseek64(_fd, 0, SEEK_SET);
|
||||||
|
|
||||||
if (filesize < _curMapSize) { // construct a empty file mapping
|
if (filesize < _curMapSize) { // construct a empty file mapping
|
||||||
posix_fsetsize(_fd, _curMapSize);
|
posix_fsetsize(_fd, _curMapSize);
|
||||||
|
|
|
@ -33,11 +33,11 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
static bool tgaLoadRLEImageData(unsigned char* Buffer, unsigned long bufSize, tImageTGA *info);
|
static bool tgaLoadRLEImageData(unsigned char* Buffer, uint32_t bufSize, tImageTGA *info);
|
||||||
void tgaFlipImage( tImageTGA *info );
|
void tgaFlipImage( tImageTGA *info );
|
||||||
|
|
||||||
// load the image header field from stream
|
// load the image header field from stream
|
||||||
bool tgaLoadHeader(unsigned char* buffer, unsigned long bufSize, tImageTGA *info)
|
bool tgaLoadHeader(unsigned char* buffer, uint32_t bufSize, tImageTGA *info)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ bool tgaLoadHeader(unsigned char* buffer, unsigned long bufSize, tImageTGA *info
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *info)
|
bool tgaLoadImageData(unsigned char *Buffer, uint32_t bufSize, tImageTGA *info)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ bool tgaLoadImageData(unsigned char *Buffer, unsigned long bufSize, tImageTGA *i
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool tgaLoadRLEImageData(unsigned char* buffer, unsigned long bufSize, tImageTGA *info)
|
static bool tgaLoadRLEImageData(unsigned char* buffer, uint32_t bufSize, tImageTGA *info)
|
||||||
{
|
{
|
||||||
unsigned int mode,total,i, index = 0;
|
unsigned int mode,total,i, index = 0;
|
||||||
unsigned char aux[4], runlength = 0;
|
unsigned char aux[4], runlength = 0;
|
||||||
|
@ -195,7 +195,7 @@ void tgaFlipImage( tImageTGA *info )
|
||||||
info->flipped = 0;
|
info->flipped = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size)
|
tImageTGA* tgaLoadBuffer(unsigned char* buffer, int32_t size)
|
||||||
{
|
{
|
||||||
int mode,total;
|
int mode,total;
|
||||||
tImageTGA *info = nullptr;
|
tImageTGA *info = nullptr;
|
||||||
|
|
|
@ -28,6 +28,8 @@ THE SOFTWARE.
|
||||||
#define __SUPPORT_DATA_SUPPORT_TGALIB_H__
|
#define __SUPPORT_DATA_SUPPORT_TGALIB_H__
|
||||||
/// @cond DO_NOT_SHOW
|
/// @cond DO_NOT_SHOW
|
||||||
|
|
||||||
|
#include "stdint.h"
|
||||||
|
|
||||||
namespace cocos2d {
|
namespace cocos2d {
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -56,13 +58,13 @@ typedef struct sImageTGA {
|
||||||
} tImageTGA;
|
} tImageTGA;
|
||||||
|
|
||||||
/// load the image header fields. We only keep those that matter!
|
/// load the image header fields. We only keep those that matter!
|
||||||
bool tgaLoadHeader(unsigned char *buffer, unsigned long bufSize, tImageTGA *info);
|
bool tgaLoadHeader(unsigned char *buffer, uint32_t bufSize, tImageTGA *info);
|
||||||
|
|
||||||
/// loads the image pixels. You shouldn't call this function directly
|
/// loads the image pixels. You shouldn't call this function directly
|
||||||
bool tgaLoadImageData(unsigned char *buffer, unsigned long bufSize, tImageTGA *info);
|
bool tgaLoadImageData(unsigned char *buffer, uint32_t bufSize, tImageTGA *info);
|
||||||
|
|
||||||
/// this is the function to call when we want to load an image buffer.
|
/// this is the function to call when we want to load an image buffer.
|
||||||
tImageTGA* tgaLoadBuffer(unsigned char* buffer, long size);
|
tImageTGA* tgaLoadBuffer(unsigned char* buffer, int32_t size);
|
||||||
|
|
||||||
/// this is the function to call when we want to load an image
|
/// this is the function to call when we want to load an image
|
||||||
tImageTGA * tgaLoad(const char *filename);
|
tImageTGA * tgaLoad(const char *filename);
|
||||||
|
|
|
@ -543,7 +543,7 @@ struct ZipFilePrivate
|
||||||
|
|
||||||
auto* fs = (FileStream*) stream;
|
auto* fs = (FileStream*) stream;
|
||||||
|
|
||||||
return fs->seek((long) offset, origin); // must return 0 for success or -1 for error
|
return fs->seek((int32_t) offset, origin); // must return 0 for success or -1 for error
|
||||||
}
|
}
|
||||||
|
|
||||||
static voidpf ZipFile_open_file_func(voidpf opaque, const char* filename, int mode) {
|
static voidpf ZipFile_open_file_func(voidpf opaque, const char* filename, int mode) {
|
||||||
|
@ -914,9 +914,9 @@ int ZipFile::zfread(ZipFileStream* zfs, void* buf, unsigned int size)
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
long ZipFile::zfseek(ZipFileStream* zfs, long offset, int origin)
|
int32_t ZipFile::zfseek(ZipFileStream* zfs, int32_t offset, int origin)
|
||||||
{
|
{
|
||||||
long result = -1;
|
int32_t result = -1;
|
||||||
if (zfs != nullptr) {
|
if (zfs != nullptr) {
|
||||||
switch (origin) {
|
switch (origin) {
|
||||||
case SEEK_SET:
|
case SEEK_SET:
|
||||||
|
@ -926,7 +926,7 @@ long ZipFile::zfseek(ZipFileStream* zfs, long offset, int origin)
|
||||||
result = zfs->offset + offset;
|
result = zfs->offset + offset;
|
||||||
break;
|
break;
|
||||||
case SEEK_END:
|
case SEEK_END:
|
||||||
result = (long)zfs->entry->uncompressed_size + offset;
|
result = (int32_t)zfs->entry->uncompressed_size + offset;
|
||||||
break;
|
break;
|
||||||
default:;
|
default:;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ namespace cocos2d
|
||||||
struct ZipFileStream
|
struct ZipFileStream
|
||||||
{
|
{
|
||||||
ZipEntryInfo* entry;
|
ZipEntryInfo* entry;
|
||||||
long offset;
|
int32_t offset;
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Zip file - reader helper class.
|
* Zip file - reader helper class.
|
||||||
|
@ -301,7 +301,7 @@ namespace cocos2d
|
||||||
*/
|
*/
|
||||||
bool zfopen(const std::string& fileName, ZipFileStream* zfs);
|
bool zfopen(const std::string& fileName, ZipFileStream* zfs);
|
||||||
int zfread(ZipFileStream* zfs, void* buf, unsigned int size);
|
int zfread(ZipFileStream* zfs, void* buf, unsigned int size);
|
||||||
long zfseek(ZipFileStream* zfs, long offset, int origin);
|
int32_t zfseek(ZipFileStream* zfs, int32_t offset, int origin);
|
||||||
void zfclose(ZipFileStream* zfs);
|
void zfclose(ZipFileStream* zfs);
|
||||||
long long zfsize(ZipFileStream* zfs);
|
long long zfsize(ZipFileStream* zfs);
|
||||||
|
|
||||||
|
|
|
@ -351,7 +351,7 @@ std::vector<char16_t> getChar16VectorFromUTF16String(const std::u16string& utf16
|
||||||
return std::vector<char16_t>(utf16.begin(), utf16.end());
|
return std::vector<char16_t>(utf16.begin(), utf16.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
long getCharacterCountInUTF8String(const std::string& utf8) {
|
int32_t getCharacterCountInUTF8String(const std::string& utf8) {
|
||||||
return getUTF8StringLength((const UTF8*) utf8.c_str());
|
return getUTF8StringLength((const UTF8*) utf8.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@ CC_DLL bool isUnicodeNonBreaking(char32_t ch);
|
||||||
* @param utf8 An UTF-8 encoded string.
|
* @param utf8 An UTF-8 encoded string.
|
||||||
* @returns The length of the string in characters.
|
* @returns The length of the string in characters.
|
||||||
*/
|
*/
|
||||||
CC_DLL long getCharacterCountInUTF8String(const std::string& utf8);
|
CC_DLL int32_t getCharacterCountInUTF8String(const std::string& utf8);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Gets the index of the last character that is not equal to the character given.
|
* @brief Gets the index of the last character that is not equal to the character given.
|
||||||
|
|
|
@ -636,7 +636,7 @@ std::vector<int> parseIntegerList(const std::string &intsString) {
|
||||||
const char *cStr = intsString.c_str();
|
const char *cStr = intsString.c_str();
|
||||||
char *endptr;
|
char *endptr;
|
||||||
|
|
||||||
for (long int i = strtol(cStr, &endptr, 10); endptr != cStr; i = strtol(cStr, &endptr, 10)) {
|
for (int32_t i = strtol(cStr, &endptr, 10); endptr != cStr; i = strtol(cStr, &endptr, 10)) {
|
||||||
if (errno == ERANGE) {
|
if (errno == ERANGE) {
|
||||||
errno = 0;
|
errno = 0;
|
||||||
CCLOGWARN("%s contains out of range integers", intsString.c_str());
|
CCLOGWARN("%s contains out of range integers", intsString.c_str());
|
||||||
|
|
|
@ -483,8 +483,8 @@ private:
|
||||||
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, hints.timeoutInSeconds);
|
curl_easy_setopt(handle, CURLOPT_CONNECTTIMEOUT, hints.timeoutInSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const long LOW_SPEED_LIMIT = 1;
|
static const int32_t LOW_SPEED_LIMIT = 1;
|
||||||
static const long LOW_SPEED_TIME = 10;
|
static const int32_t LOW_SPEED_TIME = 10;
|
||||||
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_LIMIT, LOW_SPEED_LIMIT);
|
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_LIMIT, LOW_SPEED_LIMIT);
|
||||||
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_TIME, LOW_SPEED_TIME);
|
curl_easy_setopt(handle, CURLOPT_LOW_SPEED_TIME, LOW_SPEED_TIME);
|
||||||
|
|
||||||
|
@ -506,7 +506,7 @@ private:
|
||||||
bool _getHeaderInfoProc(CURL* handle, DownloadTaskCURL* coTask) {
|
bool _getHeaderInfoProc(CURL* handle, DownloadTaskCURL* coTask) {
|
||||||
CURLcode rc = CURLE_OK;
|
CURLcode rc = CURLE_OK;
|
||||||
do {
|
do {
|
||||||
long httpResponseCode = 0;
|
int32_t httpResponseCode = 0;
|
||||||
rc = curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &httpResponseCode);
|
rc = curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &httpResponseCode);
|
||||||
if (CURLE_OK != rc) {
|
if (CURLE_OK != rc) {
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -141,7 +141,7 @@ std::shared_ptr<DownloadTask> Downloader::createDownloadFileTask(const std::stri
|
||||||
//{
|
//{
|
||||||
// // Find file name and file extension
|
// // Find file name and file extension
|
||||||
// std::string filename;
|
// std::string filename;
|
||||||
// unsigned long found = srcUrl.find_last_of("/\\");
|
// unsigned int32_t found = srcUrl.find_last_of("/\\");
|
||||||
// if (found != std::string::npos)
|
// if (found != std::string::npos)
|
||||||
// filename = srcUrl.substr(found+1);
|
// filename = srcUrl.substr(found+1);
|
||||||
// return filename;
|
// return filename;
|
||||||
|
|
|
@ -122,7 +122,7 @@ public:
|
||||||
* Get the http response code to judge whether response is successful or not.
|
* Get the http response code to judge whether response is successful or not.
|
||||||
* I know that you want to see the _responseCode is 200.
|
* I know that you want to see the _responseCode is 200.
|
||||||
* If _responseCode is not 200, you should check the meaning for _responseCode by the net.
|
* If _responseCode is not 200, you should check the meaning for _responseCode by the net.
|
||||||
* @return long the value of _responseCode
|
* @return int32_t the value of _responseCode
|
||||||
*/
|
*/
|
||||||
int getResponseCode() const
|
int getResponseCode() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,7 @@ public:
|
||||||
* @param origin SEEK_SET | SEEK_CUR | SEEK_END
|
* @param origin SEEK_SET | SEEK_CUR | SEEK_END
|
||||||
* @return 0 if successful, -1 if not
|
* @return 0 if successful, -1 if not
|
||||||
*/
|
*/
|
||||||
virtual long seek(int64_t offset, int origin) = 0;
|
virtual int seek(int64_t offset, int origin) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read data from file stream
|
* Read data from file stream
|
||||||
|
|
|
@ -380,7 +380,7 @@ void GLView::handleTouchesMove(int num, intptr_t ids[], float xs[], float ys[],
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// It is error, should return.
|
// It is error, should return.
|
||||||
CCLOG("Moving touches with id: %ld error", (long int)id);
|
CCLOG("Moving touches with id: %d error", static_cast<int32_t>(id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ void GLView::handleTouchesOfEndOrCancel(EventTouch::EventCode eventCode, int num
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
CCLOG("Ending touches with id: %ld error", static_cast<long>(id));
|
CCLOG("Ending touches with id: %d error", static_cast<int32_t>(id));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -982,7 +982,7 @@ bool Image::initWithJpgData(uint8_t * data, ssize_t dataLen)
|
||||||
struct MyErrorMgr jerr;
|
struct MyErrorMgr jerr;
|
||||||
/* libjpeg data structure for storing one row, that is, scanline of an image */
|
/* libjpeg data structure for storing one row, that is, scanline of an image */
|
||||||
JSAMPROW row_pointer[1] = {0};
|
JSAMPROW row_pointer[1] = {0};
|
||||||
unsigned long location = 0;
|
uint32_t location = 0;
|
||||||
|
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
do
|
do
|
||||||
|
|
|
@ -13,7 +13,7 @@ NS_CC_BEGIN
|
||||||
|
|
||||||
struct PXIoF {
|
struct PXIoF {
|
||||||
int(*read)(PXFileHandle& handle, void*, unsigned int);
|
int(*read)(PXFileHandle& handle, void*, unsigned int);
|
||||||
long(*seek)(PXFileHandle& handle, long, int);
|
int64_t(*seek)(PXFileHandle& handle, int64_t, int);
|
||||||
int(*close)(PXFileHandle& handle);
|
int(*close)(PXFileHandle& handle);
|
||||||
long long(*size)(PXFileHandle& handle);
|
long long(*size)(PXFileHandle& handle);
|
||||||
};
|
};
|
||||||
|
@ -41,7 +41,7 @@ static int pfs_posix_open(const std::string& path, FileStream::Mode mode, PXFile
|
||||||
|
|
||||||
// posix standard wrappers
|
// posix standard wrappers
|
||||||
static int pfs_posix_read(PXFileHandle& handle, void* buf, unsigned int size) { return static_cast<int>(posix_read(handle._fd, buf, size)); }
|
static int pfs_posix_read(PXFileHandle& handle, void* buf, unsigned int size) { return static_cast<int>(posix_read(handle._fd, buf, size)); }
|
||||||
static long pfs_posix_seek(PXFileHandle& handle, long offst, int origin) { return posix_lseek(handle._fd, offst, origin); }
|
static int64_t pfs_posix_seek(PXFileHandle& handle, int64_t offst, int origin) { return posix_lseek64(handle._fd, offst, origin); }
|
||||||
static int pfs_posix_close(PXFileHandle& handle) {
|
static int pfs_posix_close(PXFileHandle& handle) {
|
||||||
int fd = handle._fd;
|
int fd = handle._fd;
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
|
@ -74,7 +74,7 @@ static PXIoF pfs_posix_iof = {
|
||||||
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
#if CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID
|
||||||
// android AssetManager wrappers
|
// android AssetManager wrappers
|
||||||
static int pfs_asset_read(PXFileHandle& handle, void* buf, unsigned int size) { return AAsset_read(handle._asset, buf, size); }
|
static int pfs_asset_read(PXFileHandle& handle, void* buf, unsigned int size) { return AAsset_read(handle._asset, buf, size); }
|
||||||
static long pfs_asset_seek(PXFileHandle& handle, long offst, int origin) { return AAsset_seek(handle._asset, offst, origin); }
|
static int64_t pfs_asset_seek(PXFileHandle& handle, int64_t offst, int origin) { return AAsset_seek(handle._asset, offst, origin); }
|
||||||
static int pfs_asset_close(PXFileHandle& handle) {
|
static int pfs_asset_close(PXFileHandle& handle) {
|
||||||
if (handle._asset != nullptr) {
|
if (handle._asset != nullptr) {
|
||||||
AAsset_close(handle._asset);
|
AAsset_close(handle._asset);
|
||||||
|
@ -95,7 +95,7 @@ static PXIoF pfs_asset_iof = {
|
||||||
|
|
||||||
// android obb
|
// android obb
|
||||||
static int pfs_obb_read(PXFileHandle& handle, void* buf, unsigned int size) { return FileUtilsAndroid::getObbFile()->zfread(&handle._zfs, buf, size); }
|
static int pfs_obb_read(PXFileHandle& handle, void* buf, unsigned int size) { return FileUtilsAndroid::getObbFile()->zfread(&handle._zfs, buf, size); }
|
||||||
static long pfs_obb_seek(PXFileHandle& handle, long offset, int origin) { return FileUtilsAndroid::getObbFile()->zfseek(&handle._zfs, offset, origin); }
|
static int64_t pfs_obb_seek(PXFileHandle& handle, int64_t offset, int origin) { return FileUtilsAndroid::getObbFile()->zfseek(&handle._zfs, offset, origin); }
|
||||||
static int pfs_obb_close(PXFileHandle& handle) {
|
static int pfs_obb_close(PXFileHandle& handle) {
|
||||||
FileUtilsAndroid::getObbFile()->zfclose(&handle._zfs);
|
FileUtilsAndroid::getObbFile()->zfclose(&handle._zfs);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -178,7 +178,7 @@ int PosixFileStream::close()
|
||||||
return internalClose();
|
return internalClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
long PosixFileStream::seek(int64_t offset, int origin)
|
int PosixFileStream::seek(int64_t offset, int origin)
|
||||||
{
|
{
|
||||||
const auto result = _iof->seek(_handle, static_cast<int32_t>(offset), origin); // this returns -1 for error, and resulting offset on success
|
const auto result = _iof->seek(_handle, static_cast<int32_t>(offset), origin); // this returns -1 for error, and resulting offset on success
|
||||||
return result < 0 ? -1 : 0; // return 0 for success
|
return result < 0 ? -1 : 0; // return 0 for success
|
||||||
|
|
|
@ -36,11 +36,19 @@
|
||||||
#define posix_open(path, ...) ::_wopen(ntcvt::from_chars(path).c_str(), ##__VA_ARGS__)
|
#define posix_open(path, ...) ::_wopen(ntcvt::from_chars(path).c_str(), ##__VA_ARGS__)
|
||||||
#define posix_close ::_close
|
#define posix_close ::_close
|
||||||
#define posix_lseek ::_lseek
|
#define posix_lseek ::_lseek
|
||||||
|
#define posix_lseek64 ::_lseeki64
|
||||||
#define posix_read ::_read
|
#define posix_read ::_read
|
||||||
#define posix_write ::_write
|
#define posix_write ::_write
|
||||||
#define posix_fd2fh(fd) reinterpret_cast<HANDLE>(_get_osfhandle(fd))
|
#define posix_fd2fh(fd) reinterpret_cast<HANDLE>(_get_osfhandle(fd))
|
||||||
#define posix_fsetsize(fd, size) ::_chsize(fd, size)
|
#define posix_fsetsize(fd, size) ::_chsize(fd, size)
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
# define posix_lseek64 ::lseek
|
||||||
|
#else
|
||||||
|
# define posix_lseek64 ::lseek64
|
||||||
|
#endif
|
||||||
|
|
||||||
#define O_READ_FLAGS O_RDONLY
|
#define O_READ_FLAGS O_RDONLY
|
||||||
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_TRUNC, S_IRWXU
|
#define O_WRITE_FLAGS O_CREAT | O_RDWR | O_TRUNC, S_IRWXU
|
||||||
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR, S_IRWXU
|
#define O_APPEND_FLAGS O_APPEND | O_CREAT | O_RDWR, S_IRWXU
|
||||||
|
@ -109,7 +117,7 @@ public:
|
||||||
bool open(const std::string& path, FileStream::Mode mode) override;
|
bool open(const std::string& path, FileStream::Mode mode) override;
|
||||||
int close() override;
|
int close() override;
|
||||||
|
|
||||||
long seek(int64_t offset, int origin) override;
|
int seek(int64_t offset, int origin) override;
|
||||||
int read(void* buf, unsigned int size) override;
|
int read(void* buf, unsigned int size) override;
|
||||||
int write(const void* buf, unsigned int size) override;
|
int write(const void* buf, unsigned int size) override;
|
||||||
int64_t tell() override;
|
int64_t tell() override;
|
||||||
|
|
|
@ -114,7 +114,7 @@ std::string getPackageNameJNI() {
|
||||||
return JniHelper::callStaticStringMethod(className, "getCocos2dxPackageName");
|
return JniHelper::callStaticStringMethod(className, "getCocos2dxPackageName");
|
||||||
}
|
}
|
||||||
|
|
||||||
int getObbAssetFileDescriptorJNI(const char* path, long* startOffset, long* size) {
|
int getObbAssetFileDescriptorJNI(const char* path, int64_t* startOffset, int64_t* size) {
|
||||||
JniMethodInfo methodInfo;
|
JniMethodInfo methodInfo;
|
||||||
int fd = 0;
|
int fd = 0;
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ typedef void (*EditTextCallback)(const char* text, void* ctx);
|
||||||
|
|
||||||
extern const char * getApkPath();
|
extern const char * getApkPath();
|
||||||
extern std::string getPackageNameJNI();
|
extern std::string getPackageNameJNI();
|
||||||
extern int getObbAssetFileDescriptorJNI(const char* path, long* startOffset, long* size);
|
extern int getObbAssetFileDescriptorJNI(const char* path, int64_t* startOffset, int64_t* size);
|
||||||
extern void conversionEncodingJNI(const char* src, int byteSize, const char* fromCharset, char* dst, const char* newCharset);
|
extern void conversionEncodingJNI(const char* src, int byteSize, const char* fromCharset, char* dst, const char* newCharset);
|
||||||
|
|
||||||
extern int getDeviceSampleRate();
|
extern int getDeviceSampleRate();
|
||||||
|
|
|
@ -37,8 +37,8 @@ NS_CC_BEGIN
|
||||||
// sharedApplication pointer
|
// sharedApplication pointer
|
||||||
Application * Application::sm_pSharedApplication = nullptr;
|
Application * Application::sm_pSharedApplication = nullptr;
|
||||||
|
|
||||||
static long getCurrentMillSecond() {
|
static int32_t getCurrentMillSecond() {
|
||||||
long lLastTime;
|
int32_t lLastTime;
|
||||||
struct timeval stCurrentTime;
|
struct timeval stCurrentTime;
|
||||||
|
|
||||||
gettimeofday(&stCurrentTime,NULL);
|
gettimeofday(&stCurrentTime,NULL);
|
||||||
|
@ -68,8 +68,8 @@ int Application::run()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastTime = 0L;
|
int32_t lastTime = 0L;
|
||||||
long curTime = 0L;
|
int32_t curTime = 0L;
|
||||||
|
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto glview = director->getOpenGLView();
|
auto glview = director->getOpenGLView();
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual Platform getTargetPlatform() override;
|
virtual Platform getTargetPlatform() override;
|
||||||
protected:
|
protected:
|
||||||
long _animationInterval; //micro second
|
int32_t _animationInterval; //micro second
|
||||||
std::string _resourceRootPath;
|
std::string _resourceRootPath;
|
||||||
|
|
||||||
static Application * sm_pSharedApplication;
|
static Application * sm_pSharedApplication;
|
||||||
|
|
|
@ -99,7 +99,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
static Application * sm_pSharedApplication;
|
static Application * sm_pSharedApplication;
|
||||||
|
|
||||||
long _animationInterval; //micro second
|
int32_t _animationInterval; //micro second
|
||||||
std::string _resourceRootPath;
|
std::string _resourceRootPath;
|
||||||
std::string _startupScriptFilename;
|
std::string _startupScriptFilename;
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,9 +36,9 @@ THE SOFTWARE.
|
||||||
|
|
||||||
NS_CC_BEGIN
|
NS_CC_BEGIN
|
||||||
|
|
||||||
static long getCurrentMillSecond()
|
static int32_t getCurrentMillSecond()
|
||||||
{
|
{
|
||||||
long lLastTime = 0;
|
int32_t lLastTime = 0;
|
||||||
struct timeval stCurrentTime;
|
struct timeval stCurrentTime;
|
||||||
|
|
||||||
gettimeofday(&stCurrentTime,NULL);
|
gettimeofday(&stCurrentTime,NULL);
|
||||||
|
@ -69,8 +69,8 @@ int Application::run()
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastTime = 0L;
|
int32_t lastTime = 0L;
|
||||||
long curTime = 0L;
|
int32_t curTime = 0L;
|
||||||
|
|
||||||
auto director = Director::getInstance();
|
auto director = Director::getInstance();
|
||||||
auto glview = director->getOpenGLView();
|
auto glview = director->getOpenGLView();
|
||||||
|
|
|
@ -107,7 +107,7 @@ bool FileUtilsWin32::init()
|
||||||
|
|
||||||
bool FileUtilsWin32::isDirectoryExistInternal(const std::string& dirPath) const
|
bool FileUtilsWin32::isDirectoryExistInternal(const std::string& dirPath) const
|
||||||
{
|
{
|
||||||
unsigned long fAttrib = GetFileAttributesW(ntcvt::from_chars(dirPath).c_str());
|
uint32_t fAttrib = GetFileAttributesW(ntcvt::from_chars(dirPath).c_str());
|
||||||
return (fAttrib != INVALID_FILE_ATTRIBUTES &&
|
return (fAttrib != INVALID_FILE_ATTRIBUTES &&
|
||||||
(fAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
(fAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,8 @@ int gettimeofday(struct timeval * val, struct timezone *)
|
||||||
LARGE_INTEGER liTime, liFreq;
|
LARGE_INTEGER liTime, liFreq;
|
||||||
QueryPerformanceFrequency( &liFreq );
|
QueryPerformanceFrequency( &liFreq );
|
||||||
QueryPerformanceCounter( &liTime );
|
QueryPerformanceCounter( &liTime );
|
||||||
val->tv_sec = (long)( liTime.QuadPart / liFreq.QuadPart );
|
val->tv_sec = (int32_t)( liTime.QuadPart / liFreq.QuadPart );
|
||||||
val->tv_usec = (long)( liTime.QuadPart * 1000000.0 / liFreq.QuadPart - val->tv_sec * 1000000.0 );
|
val->tv_usec = (int32_t)( liTime.QuadPart * 1000000.0 / liFreq.QuadPart - val->tv_sec * 1000000.0 );
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ void RenderState::bindPass(Pass* pass, MeshCommand* command)
|
||||||
//pipelineDescriptor.blendDescriptor.blendEnabled = true;
|
//pipelineDescriptor.blendDescriptor.blendEnabled = true;
|
||||||
|
|
||||||
// Get the combined modified state bits for our RenderState hierarchy.
|
// Get the combined modified state bits for our RenderState hierarchy.
|
||||||
long overrideBits = _state._modifiedBits;
|
int32_t overrideBits = _state._modifiedBits;
|
||||||
overrideBits |= technique->getStateBlock()._modifiedBits;
|
overrideBits |= technique->getStateBlock()._modifiedBits;
|
||||||
overrideBits |= material->getStateBlock()._modifiedBits;
|
overrideBits |= material->getStateBlock()._modifiedBits;
|
||||||
|
|
||||||
|
@ -140,7 +140,7 @@ void RenderState::StateBlock::apply(PipelineDescriptor *pipelineDescriptor)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderState::StateBlock::restoreUnmodifiedStates(long overrideBits, PipelineDescriptor *programState)
|
void RenderState::StateBlock::restoreUnmodifiedStates(int32_t overrideBits, PipelineDescriptor *programState)
|
||||||
{
|
{
|
||||||
auto renderer = Director::getInstance()->getRenderer();
|
auto renderer = Director::getInstance()->getRenderer();
|
||||||
auto &blend = programState->blendDescriptor;
|
auto &blend = programState->blendDescriptor;
|
||||||
|
|
|
@ -227,7 +227,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void apply(PipelineDescriptor *pipelineDescriptor);
|
void apply(PipelineDescriptor *pipelineDescriptor);
|
||||||
|
|
||||||
static void restoreUnmodifiedStates(long flags, PipelineDescriptor *pipelineDescriptor);
|
static void restoreUnmodifiedStates(int32_t flags, PipelineDescriptor *pipelineDescriptor);
|
||||||
|
|
||||||
|
|
||||||
bool _cullFaceEnabled = false;
|
bool _cullFaceEnabled = false;
|
||||||
|
@ -239,7 +239,7 @@ public:
|
||||||
backend::BlendFactor _blendDst = backend::BlendFactor::ZERO;
|
backend::BlendFactor _blendDst = backend::BlendFactor::ZERO;
|
||||||
CullFaceSide _cullFaceSide = CullFaceSide::BACK;
|
CullFaceSide _cullFaceSide = CullFaceSide::BACK;
|
||||||
FrontFace _frontFace = FrontFace::COUNTER_CLOCK_WISE;
|
FrontFace _frontFace = FrontFace::COUNTER_CLOCK_WISE;
|
||||||
long _modifiedBits = 0L;
|
int32_t _modifiedBits = 0L;
|
||||||
|
|
||||||
mutable uint32_t _hash;
|
mutable uint32_t _hash;
|
||||||
mutable bool _hashDirty;
|
mutable bool _hashDirty;
|
||||||
|
|
|
@ -284,7 +284,7 @@ bool Texture2D::updateWithMipmaps(MipmapInfo* mipmaps, int mipmapsNum, backend::
|
||||||
auto& pfd = backend::PixelFormatUtils::getFormatDescriptor(pixelFormat);
|
auto& pfd = backend::PixelFormatUtils::getFormatDescriptor(pixelFormat);
|
||||||
if (!pfd.bpp)
|
if (!pfd.bpp)
|
||||||
{
|
{
|
||||||
CCLOG("cocos2d: WARNING: unsupported pixelformat: %lx", (unsigned long)pixelFormat);
|
CCLOG("cocos2d: WARNING: unsupported pixelformat: %x", (uint32_t)pixelFormat);
|
||||||
#ifdef CC_USE_METAL
|
#ifdef CC_USE_METAL
|
||||||
CCASSERT(false, "pixeformat not found in _pixelFormatInfoTables, register required!");
|
CCASSERT(false, "pixeformat not found in _pixelFormatInfoTables, register required!");
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -652,14 +652,14 @@ std::string TextureCache::getCachedTextureInfo() const
|
||||||
auto bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
|
auto bytes = tex->getPixelsWide() * tex->getPixelsHigh() * bpp / 8;
|
||||||
totalBytes += bytes;
|
totalBytes += bytes;
|
||||||
count++;
|
count++;
|
||||||
snprintf(buftmp, sizeof(buftmp) - 1, "\"%s\" rc=%lu id=%p %lu x %lu @ %ld bpp => %lu KB\n",
|
snprintf(buftmp, sizeof(buftmp) - 1, "\"%s\" rc=%d id=%p %d x %d @ %d bpp => %d KB\n",
|
||||||
texture.first.c_str(),
|
texture.first.c_str(),
|
||||||
(long)tex->getReferenceCount(),
|
(int32_t)tex->getReferenceCount(),
|
||||||
tex->getBackendTexture(),
|
tex->getBackendTexture(),
|
||||||
(long)tex->getPixelsWide(),
|
(int32_t)tex->getPixelsWide(),
|
||||||
(long)tex->getPixelsHigh(),
|
(int32_t)tex->getPixelsHigh(),
|
||||||
(long)bpp,
|
(int32_t)bpp,
|
||||||
(long)bytes / 1024);
|
(int32_t)bytes / 1024);
|
||||||
|
|
||||||
buffer += buftmp;
|
buffer += buftmp;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,8 @@
|
||||||
inView:(NSView *)controlView
|
inView:(NSView *)controlView
|
||||||
editor:(NSText *)textObj
|
editor:(NSText *)textObj
|
||||||
delegate:(id)anObject
|
delegate:(id)anObject
|
||||||
start:(long)selStart
|
start:(int32_t)selStart
|
||||||
length:(long)selLength
|
length:(int32_t)selLength
|
||||||
{
|
{
|
||||||
aRect = [self drawingRectForBounds:aRect];
|
aRect = [self drawingRectForBounds:aRect];
|
||||||
mIsEditingOrSelecting = YES;
|
mIsEditingOrSelecting = YES;
|
||||||
|
|
|
@ -66,8 +66,8 @@
|
||||||
inView:(NSView *)controlView
|
inView:(NSView *)controlView
|
||||||
editor:(NSText *)textObj
|
editor:(NSText *)textObj
|
||||||
delegate:(id)anObject
|
delegate:(id)anObject
|
||||||
start:(long)selStart
|
start:(int32_t)selStart
|
||||||
length:(long)selLength
|
length:(int32_t)selLength
|
||||||
{
|
{
|
||||||
aRect = [self drawingRectForBounds:aRect];
|
aRect = [self drawingRectForBounds:aRect];
|
||||||
mIsEditingOrSelecting = YES;
|
mIsEditingOrSelecting = YES;
|
||||||
|
|
|
@ -123,7 +123,7 @@ std::string Helper::getSubStringOfUTF8String(const std::string& str, std::string
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
if (utf32.size() < start) {
|
if (utf32.size() < start) {
|
||||||
CCLOGERROR("'start' is out of range: %ld, %s", static_cast<long>(start), str.c_str());
|
CCLOGERROR("'start' is out of range: %d, %s", static_cast<int32_t>(start), str.c_str());
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
std::string result;
|
std::string result;
|
||||||
|
|
|
@ -126,7 +126,7 @@ void UICCTextField::insertText(const char* text, size_t len)
|
||||||
{
|
{
|
||||||
if (_maxLengthEnabled)
|
if (_maxLengthEnabled)
|
||||||
{
|
{
|
||||||
long text_count = StringUtils::getCharacterCountInUTF8String(getString());
|
int32_t text_count = StringUtils::getCharacterCountInUTF8String(getString());
|
||||||
if (text_count >= _maxLength)
|
if (text_count >= _maxLength)
|
||||||
{
|
{
|
||||||
// password
|
// password
|
||||||
|
@ -137,12 +137,12 @@ void UICCTextField::insertText(const char* text, size_t len)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long input_count = StringUtils::getCharacterCountInUTF8String(text);
|
int32_t input_count = StringUtils::getCharacterCountInUTF8String(text);
|
||||||
long total = text_count + input_count;
|
int32_t total = text_count + input_count;
|
||||||
|
|
||||||
if (total > _maxLength)
|
if (total > _maxLength)
|
||||||
{
|
{
|
||||||
long length = _maxLength - text_count;
|
int32_t length = _maxLength - text_count;
|
||||||
|
|
||||||
input_text = Helper::getSubStringOfUTF8String(input_text, 0, length);
|
input_text = Helper::getSubStringOfUTF8String(input_text, 0, length);
|
||||||
len = input_text.length();
|
len = input_text.length();
|
||||||
|
@ -205,8 +205,8 @@ void UICCTextField::setPasswordStyleText(const std::string& styleText)
|
||||||
void UICCTextField::setPasswordText(const std::string& text)
|
void UICCTextField::setPasswordText(const std::string& text)
|
||||||
{
|
{
|
||||||
std::string tempStr = "";
|
std::string tempStr = "";
|
||||||
long text_count = StringUtils::getCharacterCountInUTF8String(text);
|
int32_t text_count = StringUtils::getCharacterCountInUTF8String(text);
|
||||||
long max = text_count;
|
int32_t max = text_count;
|
||||||
|
|
||||||
if (_maxLengthEnabled)
|
if (_maxLengthEnabled)
|
||||||
{
|
{
|
||||||
|
@ -373,7 +373,7 @@ void TextField::setString(const std::string& text)
|
||||||
if (isMaxLengthEnabled())
|
if (isMaxLengthEnabled())
|
||||||
{
|
{
|
||||||
int max = _textFieldRenderer->getMaxLength();
|
int max = _textFieldRenderer->getMaxLength();
|
||||||
long text_count = StringUtils::getCharacterCountInUTF8String(text);
|
int32_t text_count = StringUtils::getCharacterCountInUTF8String(text);
|
||||||
if (text_count > max)
|
if (text_count > max)
|
||||||
{
|
{
|
||||||
strText = Helper::getSubStringOfUTF8String(strText, 0, max);
|
strText = Helper::getSubStringOfUTF8String(strText, 0, max);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2326,6 +2326,9 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -773,7 +773,7 @@ void ActionSequence2::callback2(Node* sender)
|
||||||
addChild(label);
|
addChild(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionSequence2::callback3(Node* sender, long data)
|
void ActionSequence2::callback3(Node* sender, int32_t data)
|
||||||
{
|
{
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
auto label = Label::createWithTTF("callback 3 called", "fonts/Marker Felt.ttf", 16.0f);
|
auto label = Label::createWithTTF("callback 3 called", "fonts/Marker Felt.ttf", 16.0f);
|
||||||
|
@ -950,14 +950,14 @@ void ActionCallFunction::callback2(Node* sender)
|
||||||
CCLOG("sender is: %p", sender);
|
CCLOG("sender is: %p", sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionCallFunction::callback3(Node* sender, long data)
|
void ActionCallFunction::callback3(Node* sender, int32_t data)
|
||||||
{
|
{
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
auto label = Label::createWithTTF("callback 3 called", "fonts/Marker Felt.ttf", 16.0f);
|
auto label = Label::createWithTTF("callback 3 called", "fonts/Marker Felt.ttf", 16.0f);
|
||||||
label->setPosition(s.width/4*3,s.height/2);
|
label->setPosition(s.width/4*3,s.height/2);
|
||||||
addChild(label);
|
addChild(label);
|
||||||
|
|
||||||
CCLOG("target is: %p, data is: %ld", sender, data);
|
CCLOG("target is: %p, data is: %d", sender, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ActionCallFunction::subtitle() const
|
std::string ActionCallFunction::subtitle() const
|
||||||
|
|
|
@ -205,7 +205,7 @@ public:
|
||||||
|
|
||||||
void callback1();
|
void callback1();
|
||||||
void callback2(Node* sender);
|
void callback2(Node* sender);
|
||||||
void callback3(Node* sender, long data);
|
void callback3(Node* sender, int32_t data);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ActionSequence3 : public ActionsDemo
|
class ActionSequence3 : public ActionsDemo
|
||||||
|
@ -351,7 +351,7 @@ public:
|
||||||
|
|
||||||
void callback1();
|
void callback1();
|
||||||
void callback2(Node* pTarget);
|
void callback2(Node* pTarget);
|
||||||
void callback3(Node* pTarget, long data);
|
void callback3(Node* pTarget, int32_t data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ bool Bug14327Layer::init()
|
||||||
|
|
||||||
void Bug14327Layer::update(float dt)
|
void Bug14327Layer::update(float dt)
|
||||||
{
|
{
|
||||||
long delta = _removeTime - time(nullptr);
|
int32_t delta = _removeTime - time(nullptr);
|
||||||
if (delta > 0)
|
if (delta > 0)
|
||||||
{
|
{
|
||||||
ldiv_t ret = ldiv(delta, 60L);
|
ldiv_t ret = ldiv(delta, 60L);
|
||||||
|
|
|
@ -900,7 +900,7 @@ void CameraCullingDemo::addSpriteCallback(Ref* sender)
|
||||||
|
|
||||||
// update sprite number
|
// update sprite number
|
||||||
char szText[16];
|
char szText[16];
|
||||||
sprintf(szText,"%ld sprits", static_cast<long>(_layer3D->getChildrenCount()));
|
sprintf(szText,"%d sprits", static_cast<int32_t>(_layer3D->getChildrenCount()));
|
||||||
_labelSprite3DCount->setString(szText);
|
_labelSprite3DCount->setString(szText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ void CameraCullingDemo::delSpriteCallback(Ref* sender)
|
||||||
|
|
||||||
// update sprite number
|
// update sprite number
|
||||||
char szText[16];
|
char szText[16];
|
||||||
sprintf(szText,"%ld sprits", static_cast<long>(_layer3D->getChildrenCount()));
|
sprintf(szText,"%l sprits", static_cast<int32_t>(_layer3D->getChildrenCount()));
|
||||||
_labelSprite3DCount->setString(szText);
|
_labelSprite3DCount->setString(szText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ bool TableViewTest::init()
|
||||||
|
|
||||||
void TableViewTest::tableCellTouched(TableView* table, TableViewCell* cell)
|
void TableViewTest::tableCellTouched(TableView* table, TableViewCell* cell)
|
||||||
{
|
{
|
||||||
CCLOG("cell touched at index: %ld", static_cast<long>(cell->getIdx()));
|
CCLOG("cell touched at index: %d", static_cast<int32_t>(cell->getIdx()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Size TableViewTest::tableCellSizeForIndex(TableView *table, ssize_t idx)
|
Size TableViewTest::tableCellSizeForIndex(TableView *table, ssize_t idx)
|
||||||
|
@ -84,7 +84,7 @@ Size TableViewTest::tableCellSizeForIndex(TableView *table, ssize_t idx)
|
||||||
|
|
||||||
TableViewCell* TableViewTest::tableCellAtIndex(TableView *table, ssize_t idx)
|
TableViewCell* TableViewTest::tableCellAtIndex(TableView *table, ssize_t idx)
|
||||||
{
|
{
|
||||||
auto string = StringUtils::format("%ld", static_cast<long>(idx));
|
auto string = StringUtils::format("%d", static_cast<int32_t>(idx));
|
||||||
TableViewCell *cell = table->dequeueCell();
|
TableViewCell *cell = table->dequeueCell();
|
||||||
if (!cell) {
|
if (!cell) {
|
||||||
cell = new (std::nothrow) CustomTableViewCell();
|
cell = new (std::nothrow) CustomTableViewCell();
|
||||||
|
|
|
@ -373,8 +373,8 @@ void TestFileFuncs::onEnter()
|
||||||
this->addChild(label);
|
this->addChild(label);
|
||||||
|
|
||||||
// getFileSize Test
|
// getFileSize Test
|
||||||
long size = sharedFileUtils->getFileSize(filepath);
|
int32_t size = sharedFileUtils->getFileSize(filepath);
|
||||||
msg = StringUtils::format("getFileSize: Test file size equals %ld", size);
|
msg = StringUtils::format("getFileSize: Test file size equals %d", size);
|
||||||
label = Label::createWithSystemFont(msg, "", 20);
|
label = Label::createWithSystemFont(msg, "", 20);
|
||||||
label->setPosition(x, y * 3);
|
label->setPosition(x, y * 3);
|
||||||
this->addChild(label);
|
this->addChild(label);
|
||||||
|
@ -1160,8 +1160,8 @@ void TestFileFuncsAsync::onEnter()
|
||||||
label->setPosition(x, y * 4);
|
label->setPosition(x, y * 4);
|
||||||
this->addChild(label);
|
this->addChild(label);
|
||||||
|
|
||||||
sharedFileUtils->getFileSize(filepath, [=](long size) {
|
sharedFileUtils->getFileSize(filepath, [=](int32_t size) {
|
||||||
auto msg = StringUtils::format("getFileSize: Test file size equals %ld", size);
|
auto msg = StringUtils::format("getFileSize: Test file size equals %d", size);
|
||||||
auto label = Label::createWithSystemFont(msg, "", 20);
|
auto label = Label::createWithSystemFont(msg, "", 20);
|
||||||
label->setPosition(x, y * 3);
|
label->setPosition(x, y * 3);
|
||||||
this->addChild(label);
|
this->addChild(label);
|
||||||
|
|
|
@ -311,11 +311,11 @@ void HttpClientTest::onHttpRequestCompleted(HttpClient *sender, HttpResponse *re
|
||||||
log("%s completed", response->getHttpRequest()->getTag());
|
log("%s completed", response->getHttpRequest()->getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
long statusCode = response->getResponseCode();
|
int32_t statusCode = response->getResponseCode();
|
||||||
char statusString[64] = {};
|
char statusString[64] = {};
|
||||||
sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag());
|
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
|
||||||
_labelStatusCode->setString(statusString);
|
_labelStatusCode->setString(statusString);
|
||||||
log("response code: %ld", statusCode);
|
log("response code: %d", statusCode);
|
||||||
|
|
||||||
if (response->getResponseCode() != 200)
|
if (response->getResponseCode() != 200)
|
||||||
{
|
{
|
||||||
|
@ -460,11 +460,11 @@ void HttpClientClearRequestsTest::onHttpRequestCompleted(HttpClient *sender, Htt
|
||||||
log("%s completed", response->getHttpRequest()->getTag());
|
log("%s completed", response->getHttpRequest()->getTag());
|
||||||
}
|
}
|
||||||
|
|
||||||
long statusCode = response->getResponseCode();
|
int32_t statusCode = response->getResponseCode();
|
||||||
char statusString[64] = {};
|
char statusString[64] = {};
|
||||||
sprintf(statusString, "HTTP Status Code: %ld, tag = %s", statusCode, response->getHttpRequest()->getTag());
|
sprintf(statusString, "HTTP Status Code: %d, tag = %s", statusCode, response->getHttpRequest()->getTag());
|
||||||
_labelStatusCode->setString(statusString);
|
_labelStatusCode->setString(statusString);
|
||||||
log("response code: %ld", statusCode);
|
log("response code: %d", statusCode);
|
||||||
|
|
||||||
_totalProcessedRequests++;
|
_totalProcessedRequests++;
|
||||||
sprintf(statusString, "Got %d of %d expected http requests", _totalProcessedRequests, _totalExpectedRequests);
|
sprintf(statusString, "Got %d of %d expected http requests", _totalProcessedRequests, _totalExpectedRequests);
|
||||||
|
|
|
@ -885,7 +885,7 @@ void AsyncLoadSprite3DTest::menuCallback_asyncLoadSprite(Ref* sender)
|
||||||
|
|
||||||
//remove cache data
|
//remove cache data
|
||||||
Sprite3DCache::getInstance()->removeAllSprite3DData();
|
Sprite3DCache::getInstance()->removeAllSprite3DData();
|
||||||
long index = 0;
|
int32_t index = 0;
|
||||||
for (const auto& path : _paths) {
|
for (const auto& path : _paths) {
|
||||||
Sprite3D::createAsync(path, CC_CALLBACK_2(AsyncLoadSprite3DTest::asyncLoad_Callback, this), (void*)index++);
|
Sprite3D::createAsync(path, CC_CALLBACK_2(AsyncLoadSprite3DTest::asyncLoad_Callback, this), (void*)index++);
|
||||||
}
|
}
|
||||||
|
@ -893,7 +893,7 @@ void AsyncLoadSprite3DTest::menuCallback_asyncLoadSprite(Ref* sender)
|
||||||
|
|
||||||
void AsyncLoadSprite3DTest::asyncLoad_Callback(Sprite3D* sprite, void* param)
|
void AsyncLoadSprite3DTest::asyncLoad_Callback(Sprite3D* sprite, void* param)
|
||||||
{
|
{
|
||||||
long index = (long)param;
|
auto index = static_cast<int>((uintptr_t)param);
|
||||||
auto node = getChildByTag(101);
|
auto node = getChildByTag(101);
|
||||||
auto s = Director::getInstance()->getWinSize();
|
auto s = Director::getInstance()->getWinSize();
|
||||||
float width = s.width / _paths.size();
|
float width = s.width / _paths.size();
|
||||||
|
@ -1324,7 +1324,7 @@ Sprite3DReskinTest::Sprite3DReskinTest()
|
||||||
}
|
}
|
||||||
void Sprite3DReskinTest::menuCallback_reSkin(Ref* sender)
|
void Sprite3DReskinTest::menuCallback_reSkin(Ref* sender)
|
||||||
{
|
{
|
||||||
long index = (long)(((MenuItemLabel*)sender)->getUserData());
|
auto index = static_cast<int>((uintptr_t)(((MenuItemLabel*)sender)->getUserData()));
|
||||||
if (index < (int)SkinType::MAX_TYPE)
|
if (index < (int)SkinType::MAX_TYPE)
|
||||||
{
|
{
|
||||||
_curSkin[index] = (_curSkin[index] + 1) % _skins[index].size();
|
_curSkin[index] = (_curSkin[index] + 1) % _skins[index].size();
|
||||||
|
|
|
@ -129,7 +129,7 @@ void UIPageViewTest::pageViewEvent(Ref *pSender, PageView::EventType type)
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
_displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
|
_displayValueLabel->setString(StringUtils::format("page = %d", static_cast<int32_t>(pageView->getCurrentPageIndex() + 1)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -241,7 +241,7 @@ void UIPageViewButtonTest::pageViewEvent(Ref *pSender, PageView::EventType type)
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
_displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
|
_displayValueLabel->setString(StringUtils::format("page = %d", static_cast<int32_t>(pageView->getCurrentPageIndex() + 1)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -438,7 +438,7 @@ void UIPageViewTouchPropagationTest::pageViewEvent(Ref *pSender, PageView::Event
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
_displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
|
_displayValueLabel->setString(StringUtils::format("page = %d", static_cast<int32_t>(pageView->getCurrentPageIndex() + 1)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -558,7 +558,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
pageView->pushBackCustomItem(outerBox);
|
pageView->pushBackCustomItem(outerBox);
|
||||||
_displayValueLabel->setString(StringUtils::format("page count = %ld", static_cast<long>(pageView->getItems().size())));
|
_displayValueLabel->setString(StringUtils::format("page count = %d", static_cast<int32_t>(pageView->getItems().size())));
|
||||||
CCLOG("current page index = %zd", pageView->getCurrentPageIndex());
|
CCLOG("current page index = %zd", pageView->getCurrentPageIndex());
|
||||||
});
|
});
|
||||||
_uiLayer->addChild(button);
|
_uiLayer->addChild(button);
|
||||||
|
@ -579,7 +579,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init()
|
||||||
{
|
{
|
||||||
CCLOG("There is no page to remove!");
|
CCLOG("There is no page to remove!");
|
||||||
}
|
}
|
||||||
_displayValueLabel->setString(StringUtils::format("page count = %ld", static_cast<long>(pageView->getItems().size())));
|
_displayValueLabel->setString(StringUtils::format("page count = %d", static_cast<int32_t>(pageView->getItems().size())));
|
||||||
CCLOG("current page index = %zd", pageView->getCurrentPageIndex());
|
CCLOG("current page index = %zd", pageView->getCurrentPageIndex());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -594,7 +594,7 @@ bool UIPageViewDynamicAddAndRemoveTest::init()
|
||||||
button3->addClickEventListener([=](Ref* sender)
|
button3->addClickEventListener([=](Ref* sender)
|
||||||
{
|
{
|
||||||
pageView->removeAllItems();
|
pageView->removeAllItems();
|
||||||
_displayValueLabel->setString(StringUtils::format("page count = %ld", static_cast<long>(pageView->getItems().size())));
|
_displayValueLabel->setString(StringUtils::format("page count = %d", static_cast<int32_t>(pageView->getItems().size())));
|
||||||
CCLOG("current page index = %zd", pageView->getCurrentPageIndex());
|
CCLOG("current page index = %zd", pageView->getCurrentPageIndex());
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -623,7 +623,7 @@ void UIPageViewDynamicAddAndRemoveTest::pageViewEvent(Ref *pSender, PageView::Ev
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
_displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>((pageView->getCurrentPageIndex() + 1))));
|
_displayValueLabel->setString(StringUtils::format("page = %d", static_cast<int32_t>((pageView->getCurrentPageIndex() + 1))));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -825,7 +825,7 @@ void UIPageViewVerticalTest::pageViewEvent(Ref *pSender, PageView::EventType typ
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
_displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
|
_displayValueLabel->setString(StringUtils::format("page = %d", static_cast<int32_t>(pageView->getCurrentPageIndex() + 1)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -984,7 +984,7 @@ void UIPageViewChildSizeTest::pageViewEvent(Ref *pSender, PageView::EventType ty
|
||||||
{
|
{
|
||||||
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
PageView* pageView = dynamic_cast<PageView*>(pSender);
|
||||||
|
|
||||||
_displayValueLabel->setString(StringUtils::format("page = %ld", static_cast<long>(pageView->getCurrentPageIndex() + 1)));
|
_displayValueLabel->setString(StringUtils::format("page = %d", static_cast<int32_t>(pageView->getCurrentPageIndex() + 1)));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -67,14 +67,14 @@ bool UIRichTextTest::init()
|
||||||
|
|
||||||
std::string str1 = config->getValue("Chinese").asString();
|
std::string str1 = config->getValue("Chinese").asString();
|
||||||
std::string str2 = config->getValue("Japanese").asString();
|
std::string str2 = config->getValue("Japanese").asString();
|
||||||
CCLOG("str1:%s ascii length = %ld, utf8 length = %ld, substr = %s",
|
CCLOG("str1:%s ascii length = %d, utf8 length = %d, substr = %s",
|
||||||
str1.c_str(),
|
str1.c_str(),
|
||||||
static_cast<long>(str1.length()),
|
static_cast<int32_t>(str1.length()),
|
||||||
StringUtils::getCharacterCountInUTF8String(str1),
|
StringUtils::getCharacterCountInUTF8String(str1),
|
||||||
Helper::getSubStringOfUTF8String(str1, 0, 5).c_str());
|
Helper::getSubStringOfUTF8String(str1, 0, 5).c_str());
|
||||||
CCLOG("str2:%s ascii length = %ld, utf8 length = %ld, substr = %s",
|
CCLOG("str2:%s ascii length = %d, utf8 length = %d, substr = %s",
|
||||||
str2.c_str(),
|
str2.c_str(),
|
||||||
static_cast<long>(str2.length()),
|
static_cast<int32_t>(str2.length()),
|
||||||
StringUtils::getCharacterCountInUTF8String(str2),
|
StringUtils::getCharacterCountInUTF8String(str2),
|
||||||
Helper::getSubStringOfUTF8String(str2, 0, 2).c_str());
|
Helper::getSubStringOfUTF8String(str2, 0, 2).c_str());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue