mirror of https://github.com/axmolengine/axmol.git
use ssize_t for index and capacity
This commit is contained in:
parent
ab23b47043
commit
1e9c763b40
|
@ -87,7 +87,7 @@ void ActionManager::actionAllocWithHashElement(tHashElement *element)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionManager::removeActionAtIndex(int index, tHashElement *element)
|
void ActionManager::removeActionAtIndex(ssize_t index, tHashElement *element)
|
||||||
{
|
{
|
||||||
Action *action = (Action*)element->actions->arr[index];
|
Action *action = (Action*)element->actions->arr[index];
|
||||||
|
|
||||||
|
@ -324,7 +324,7 @@ Action* ActionManager::getActionByTag(int tag, const Node *target) const
|
||||||
|
|
||||||
// XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer
|
// XXX: Passing "const O *" instead of "const O&" because HASH_FIND_IT requries the address of a pointer
|
||||||
// and, it is not possible to get the address of a reference
|
// and, it is not possible to get the address of a reference
|
||||||
int ActionManager::getNumberOfRunningActionsInTarget(const Node *target) const
|
ssize_t ActionManager::getNumberOfRunningActionsInTarget(const Node *target) const
|
||||||
{
|
{
|
||||||
tHashElement *element = NULL;
|
tHashElement *element = NULL;
|
||||||
HASH_FIND_PTR(_targets, &target, element);
|
HASH_FIND_PTR(_targets, &target, element);
|
||||||
|
|
|
@ -100,10 +100,10 @@ public:
|
||||||
* - If you are running 1 Sequence of 7 actions, it will return 1.
|
* - If you are running 1 Sequence of 7 actions, it will return 1.
|
||||||
* - If you are running 7 Sequences of 2 actions, it will return 7.
|
* - If you are running 7 Sequences of 2 actions, it will return 7.
|
||||||
*/
|
*/
|
||||||
int getNumberOfRunningActionsInTarget(const Node *target) const;
|
ssize_t getNumberOfRunningActionsInTarget(const Node *target) const;
|
||||||
|
|
||||||
/** @deprecated use getNumberOfRunningActionsInTarget() instead */
|
/** @deprecated use getNumberOfRunningActionsInTarget() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE inline int numberOfRunningActionsInTarget(Node *target) const { return getNumberOfRunningActionsInTarget(target); }
|
CC_DEPRECATED_ATTRIBUTE inline ssize_t numberOfRunningActionsInTarget(Node *target) const { return getNumberOfRunningActionsInTarget(target); }
|
||||||
|
|
||||||
/** Pauses the target: all running actions and newly added actions will be paused.
|
/** Pauses the target: all running actions and newly added actions will be paused.
|
||||||
*/
|
*/
|
||||||
|
@ -124,7 +124,7 @@ public:
|
||||||
protected:
|
protected:
|
||||||
// declared in ActionManager.m
|
// declared in ActionManager.m
|
||||||
|
|
||||||
void removeActionAtIndex(int index, struct _hashElement *pElement);
|
void removeActionAtIndex(ssize_t index, struct _hashElement *pElement);
|
||||||
void deleteHashElement(struct _hashElement *pElement);
|
void deleteHashElement(struct _hashElement *pElement);
|
||||||
void actionAllocWithHashElement(struct _hashElement *pElement);
|
void actionAllocWithHashElement(struct _hashElement *pElement);
|
||||||
void update(float dt);
|
void update(float dt);
|
||||||
|
|
|
@ -595,7 +595,7 @@ void Director::replaceScene(Scene *scene)
|
||||||
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
CCASSERT(_runningScene, "Use runWithScene: instead to start the director");
|
||||||
CCASSERT(scene != nullptr, "the scene should not be null");
|
CCASSERT(scene != nullptr, "the scene should not be null");
|
||||||
|
|
||||||
int index = _scenesStack.size();
|
ssize_t index = _scenesStack.size();
|
||||||
|
|
||||||
_sendCleanupToScene = true;
|
_sendCleanupToScene = true;
|
||||||
_scenesStack.replace(index - 1, scene);
|
_scenesStack.replace(index - 1, scene);
|
||||||
|
@ -618,7 +618,7 @@ void Director::popScene(void)
|
||||||
CCASSERT(_runningScene != nullptr, "running scene should not null");
|
CCASSERT(_runningScene != nullptr, "running scene should not null");
|
||||||
|
|
||||||
_scenesStack.popBack();
|
_scenesStack.popBack();
|
||||||
int c = _scenesStack.size();
|
ssize_t c = _scenesStack.size();
|
||||||
|
|
||||||
if (c == 0)
|
if (c == 0)
|
||||||
{
|
{
|
||||||
|
@ -639,7 +639,7 @@ void Director::popToRootScene(void)
|
||||||
void Director::popToSceneStackLevel(int level)
|
void Director::popToSceneStackLevel(int level)
|
||||||
{
|
{
|
||||||
CCASSERT(_runningScene != nullptr, "A running Scene is needed");
|
CCASSERT(_runningScene != nullptr, "A running Scene is needed");
|
||||||
int c = _scenesStack.size();
|
ssize_t c = _scenesStack.size();
|
||||||
|
|
||||||
// level 0? -> end
|
// level 0? -> end
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
|
|
|
@ -395,7 +395,7 @@ void Node::setPositionY(float y)
|
||||||
setPosition(Point(_position.x, y));
|
setPosition(Point(_position.x, y));
|
||||||
}
|
}
|
||||||
|
|
||||||
int Node::getChildrenCount() const
|
ssize_t Node::getChildrenCount() const
|
||||||
{
|
{
|
||||||
return _children.size();
|
return _children.size();
|
||||||
}
|
}
|
||||||
|
@ -683,7 +683,7 @@ void Node::removeChild(Node* child, bool cleanup /* = true */)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto index = _children.getIndex(child);
|
ssize_t index = _children.getIndex(child);
|
||||||
if( index != CC_INVALID_INDEX )
|
if( index != CC_INVALID_INDEX )
|
||||||
this->detachChild( child, index, cleanup );
|
this->detachChild( child, index, cleanup );
|
||||||
}
|
}
|
||||||
|
@ -741,7 +741,7 @@ void Node::removeAllChildrenWithCleanup(bool cleanup)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::detachChild(Node *child, int childIndex, bool doCleanup)
|
void Node::detachChild(Node *child, ssize_t childIndex, bool doCleanup)
|
||||||
{
|
{
|
||||||
// IMPORTANT:
|
// IMPORTANT:
|
||||||
// -1st do onExit
|
// -1st do onExit
|
||||||
|
@ -1055,7 +1055,7 @@ Action * Node::getActionByTag(int tag)
|
||||||
return _actionManager->getActionByTag(tag, this);
|
return _actionManager->getActionByTag(tag, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Node::getNumberOfRunningActions() const
|
ssize_t Node::getNumberOfRunningActions() const
|
||||||
{
|
{
|
||||||
return _actionManager->getNumberOfRunningActionsInTarget(this);
|
return _actionManager->getNumberOfRunningActionsInTarget(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,7 @@ public:
|
||||||
*
|
*
|
||||||
* @return The amount of children.
|
* @return The amount of children.
|
||||||
*/
|
*/
|
||||||
int getChildrenCount() const;
|
ssize_t getChildrenCount() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the parent node
|
* Sets the parent node
|
||||||
|
@ -1041,10 +1041,10 @@ public:
|
||||||
*
|
*
|
||||||
* @return The number of actions that are running plus the ones that are schedule to run
|
* @return The number of actions that are running plus the ones that are schedule to run
|
||||||
*/
|
*/
|
||||||
int getNumberOfRunningActions() const;
|
ssize_t getNumberOfRunningActions() const;
|
||||||
|
|
||||||
/** @deprecated Use getNumberOfRunningActions() instead */
|
/** @deprecated Use getNumberOfRunningActions() instead */
|
||||||
CC_DEPRECATED_ATTRIBUTE int numberOfRunningActions() const { return getNumberOfRunningActions(); };
|
CC_DEPRECATED_ATTRIBUTE ssize_t numberOfRunningActions() const { return getNumberOfRunningActions(); };
|
||||||
|
|
||||||
/// @} end of Actions
|
/// @} end of Actions
|
||||||
|
|
||||||
|
@ -1401,7 +1401,7 @@ protected:
|
||||||
void insertChild(Node* child, int z);
|
void insertChild(Node* child, int z);
|
||||||
|
|
||||||
/// Removes a child, call child->onExit(), do cleanup, remove it from children array.
|
/// Removes a child, call child->onExit(), do cleanup, remove it from children array.
|
||||||
void detachChild(Node *child, int index, bool doCleanup);
|
void detachChild(Node *child, ssize_t index, bool doCleanup);
|
||||||
|
|
||||||
/// Convert cocos2d coordinates to UI windows coordinate.
|
/// Convert cocos2d coordinates to UI windows coordinate.
|
||||||
Point convertToWindowSpace(const Point& nodePoint) const;
|
Point convertToWindowSpace(const Point& nodePoint) const;
|
||||||
|
|
|
@ -143,7 +143,7 @@ int NotificationCenter::removeAllObservers(Object *target)
|
||||||
}
|
}
|
||||||
|
|
||||||
_observers->removeObjectsInArray(toRemove);
|
_observers->removeObjectsInArray(toRemove);
|
||||||
return toRemove->count();
|
return static_cast<int>(toRemove->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationCenter::registerScriptObserver( Object *target, int handler,const char* name)
|
void NotificationCenter::registerScriptObserver( Object *target, int handler,const char* name)
|
||||||
|
|
|
@ -412,7 +412,7 @@ void ParticleBatchNode::draw(void)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ParticleBatchNode::increaseAtlasCapacityTo(int 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(),
|
(long)_textureAtlas->getCapacity(),
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateAllAtlasIndexes();
|
void updateAllAtlasIndexes();
|
||||||
void increaseAtlasCapacityTo(int quantity);
|
void increaseAtlasCapacityTo(ssize_t quantity);
|
||||||
int searchNewPositionInChildrenForZ(int z);
|
int searchNewPositionInChildrenForZ(int z);
|
||||||
void getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z);
|
void getCurrentIndex(int* oldIndex, int* newIndex, Node* child, int z);
|
||||||
int addChildHelper(ParticleSystem* child, int z, int aTag);
|
int addChildHelper(ParticleSystem* child, int z, int aTag);
|
||||||
|
|
|
@ -677,7 +677,7 @@ unsigned int Scheduler::scheduleScriptFunc(unsigned int handler, float interval,
|
||||||
|
|
||||||
void Scheduler::unscheduleScriptEntry(unsigned int scheduleScriptEntryID)
|
void Scheduler::unscheduleScriptEntry(unsigned int scheduleScriptEntryID)
|
||||||
{
|
{
|
||||||
for (int i = _scriptHandlerEntries.size() - 1; i >= 0; i--)
|
for (ssize_t i = _scriptHandlerEntries.size() - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
SchedulerScriptHandlerEntry* entry = _scriptHandlerEntries.at(i);
|
SchedulerScriptHandlerEntry* entry = _scriptHandlerEntries.at(i);
|
||||||
if (entry->getEntryId() == (int)scheduleScriptEntryID)
|
if (entry->getEntryId() == (int)scheduleScriptEntryID)
|
||||||
|
|
|
@ -1052,7 +1052,7 @@ void Sprite::setSpriteFrame(SpriteFrame *spriteFrame)
|
||||||
setTextureRect(spriteFrame->getRect(), _rectRotated, spriteFrame->getOriginalSize());
|
setTextureRect(spriteFrame->getRect(), _rectRotated, spriteFrame->getOriginalSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex)
|
void Sprite::setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex)
|
||||||
{
|
{
|
||||||
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
|
CCASSERT(animationName.size()>0, "CCSprite#setDisplayFrameWithAnimationName. animationName must not be NULL");
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,7 @@ public:
|
||||||
* Changes the display frame with animation name and index.
|
* Changes the display frame with animation name and index.
|
||||||
* The animation name will be get from the AnimationCache
|
* The animation name will be get from the AnimationCache
|
||||||
*/
|
*/
|
||||||
virtual void setDisplayFrameWithAnimationName(const std::string& animationName, int frameIndex);
|
virtual void setDisplayFrameWithAnimationName(const std::string& animationName, ssize_t frameIndex);
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,13 +291,13 @@ public:
|
||||||
/**
|
/**
|
||||||
* Returns the index used on the TextureAtlas.
|
* Returns the index used on the TextureAtlas.
|
||||||
*/
|
*/
|
||||||
inline int getAtlasIndex(void) const { return _atlasIndex; }
|
inline ssize_t getAtlasIndex(void) const { return _atlasIndex; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the index used on the TextureAtlas.
|
* Sets the index used on the TextureAtlas.
|
||||||
* @warning Don't modify this value unless you know what you are doing
|
* @warning Don't modify this value unless you know what you are doing
|
||||||
*/
|
*/
|
||||||
inline void setAtlasIndex(int atlasIndex) { _atlasIndex = atlasIndex; }
|
inline void setAtlasIndex(ssize_t atlasIndex) { _atlasIndex = atlasIndex; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the rect of the Sprite in points
|
* Returns the rect of the Sprite in points
|
||||||
|
@ -535,7 +535,7 @@ protected:
|
||||||
// Data used when the sprite is rendered using a SpriteSheet
|
// Data used when the sprite is rendered using a SpriteSheet
|
||||||
//
|
//
|
||||||
TextureAtlas* _textureAtlas; /// SpriteBatchNode texture atlas (weak reference)
|
TextureAtlas* _textureAtlas; /// SpriteBatchNode texture atlas (weak reference)
|
||||||
int _atlasIndex; /// Absolute (real) Index on the SpriteSheet
|
ssize_t _atlasIndex; /// Absolute (real) Index on the SpriteSheet
|
||||||
SpriteBatchNode* _batchNode; /// Used batch node (weak reference)
|
SpriteBatchNode* _batchNode; /// Used batch node (weak reference)
|
||||||
|
|
||||||
bool _dirty; /// Whether the sprite needs to be updated
|
bool _dirty; /// Whether the sprite needs to be updated
|
||||||
|
|
|
@ -51,7 +51,7 @@ NS_CC_BEGIN
|
||||||
* creation with Texture2D
|
* creation with Texture2D
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, int capacity/* = DEFAULT_CAPACITY*/)
|
SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
||||||
{
|
{
|
||||||
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
||||||
batchNode->initWithTexture(tex, capacity);
|
batchNode->initWithTexture(tex, capacity);
|
||||||
|
@ -64,7 +64,7 @@ SpriteBatchNode* SpriteBatchNode::createWithTexture(Texture2D* tex, int capacity
|
||||||
* creation with File Image
|
* creation with File Image
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* = DEFAULT_CAPACITY*/)
|
SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, ssize_t capacity/* = DEFAULT_CAPACITY*/)
|
||||||
{
|
{
|
||||||
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
SpriteBatchNode *batchNode = new SpriteBatchNode();
|
||||||
batchNode->initWithFile(fileImage, capacity);
|
batchNode->initWithFile(fileImage, capacity);
|
||||||
|
@ -76,7 +76,7 @@ SpriteBatchNode* SpriteBatchNode::create(const char *fileImage, int capacity/* =
|
||||||
/*
|
/*
|
||||||
* init with Texture2D
|
* init with Texture2D
|
||||||
*/
|
*/
|
||||||
bool SpriteBatchNode::initWithTexture(Texture2D *tex, int capacity)
|
bool SpriteBatchNode::initWithTexture(Texture2D *tex, ssize_t capacity)
|
||||||
{
|
{
|
||||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ bool SpriteBatchNode::init()
|
||||||
/*
|
/*
|
||||||
* init with FileImage
|
* init with FileImage
|
||||||
*/
|
*/
|
||||||
bool SpriteBatchNode::initWithFile(const char* fileImage, int capacity)
|
bool SpriteBatchNode::initWithFile(const char* fileImage, ssize_t capacity)
|
||||||
{
|
{
|
||||||
Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage);
|
Texture2D *texture2D = Director::getInstance()->getTextureCache()->addImage(fileImage);
|
||||||
return initWithTexture(texture2D, capacity);
|
return initWithTexture(texture2D, capacity);
|
||||||
|
@ -215,7 +215,7 @@ void SpriteBatchNode::removeChild(Node *child, bool cleanup)
|
||||||
Node::removeChild(sprite, cleanup);
|
Node::removeChild(sprite, cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteBatchNode::removeChildAtIndex(int index, bool doCleanup)
|
void SpriteBatchNode::removeChildAtIndex(ssize_t index, bool doCleanup)
|
||||||
{
|
{
|
||||||
CCASSERT(index>=0 && index < _children.size(), "Invalid index");
|
CCASSERT(index>=0 && index < _children.size(), "Invalid index");
|
||||||
removeChild(_children.at(index), doCleanup);
|
removeChild(_children.at(index), doCleanup);
|
||||||
|
@ -274,7 +274,7 @@ void SpriteBatchNode::sortAllChildren()
|
||||||
child->sortAllChildren();
|
child->sortAllChildren();
|
||||||
});
|
});
|
||||||
|
|
||||||
int index=0;
|
ssize_t index=0;
|
||||||
|
|
||||||
//fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact)
|
//fast dispatch, give every child a new atlasIndex based on their relative zOrder (keep parent -> child relations intact)
|
||||||
// and at the same time reorder descendants and the quads to the right index
|
// and at the same time reorder descendants and the quads to the right index
|
||||||
|
@ -288,12 +288,12 @@ void SpriteBatchNode::sortAllChildren()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex)
|
void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, ssize_t* curIndex)
|
||||||
{
|
{
|
||||||
auto& array = sprite->getChildren();
|
auto& array = sprite->getChildren();
|
||||||
auto count = array.size();
|
auto count = array.size();
|
||||||
|
|
||||||
int oldIndex = 0;
|
ssize_t oldIndex = 0;
|
||||||
|
|
||||||
if( count == 0 )
|
if( count == 0 )
|
||||||
{
|
{
|
||||||
|
@ -354,7 +354,7 @@ void SpriteBatchNode::updateAtlasIndex(Sprite* sprite, int* curIndex)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteBatchNode::swap(int oldIndex, int newIndex)
|
void SpriteBatchNode::swap(ssize_t oldIndex, ssize_t newIndex)
|
||||||
{
|
{
|
||||||
CCASSERT(oldIndex>=0 && oldIndex < (int)_descendants.size() && newIndex >=0 && newIndex < (int)_descendants.size(), "Invalid index");
|
CCASSERT(oldIndex>=0 && oldIndex < (int)_descendants.size() && newIndex >=0 && newIndex < (int)_descendants.size(), "Invalid index");
|
||||||
|
|
||||||
|
@ -406,9 +406,9 @@ void SpriteBatchNode::increaseAtlasCapacity(void)
|
||||||
// if we're going beyond the current TextureAtlas's capacity,
|
// if we're going beyond the current TextureAtlas's capacity,
|
||||||
// all the previously initialized sprites will need to redo their texture coords
|
// all the previously initialized sprites will need to redo their texture coords
|
||||||
// this is likely computationally expensive
|
// this is likely computationally expensive
|
||||||
int quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3;
|
ssize_t quantity = (_textureAtlas->getCapacity() + 1) * 4 / 3;
|
||||||
|
|
||||||
CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%d] to [%d].",
|
CCLOG("cocos2d: SpriteBatchNode: resizing TextureAtlas capacity from [%zd] to [%zd].",
|
||||||
_textureAtlas->getCapacity(),
|
_textureAtlas->getCapacity(),
|
||||||
quantity);
|
quantity);
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ void SpriteBatchNode::increaseAtlasCapacity(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, int index)
|
ssize_t SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, ssize_t index)
|
||||||
{
|
{
|
||||||
CCASSERT(index>=0 && index < _children.size(), "Invalid index");
|
CCASSERT(index>=0 && index < _children.size(), "Invalid index");
|
||||||
|
|
||||||
|
@ -452,7 +452,7 @@ int SpriteBatchNode::rebuildIndexInOrder(Sprite *parent, int index)
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpriteBatchNode::highestAtlasIndexInChild(Sprite *sprite)
|
ssize_t SpriteBatchNode::highestAtlasIndexInChild(Sprite *sprite)
|
||||||
{
|
{
|
||||||
auto& children = sprite->getChildren();
|
auto& children = sprite->getChildren();
|
||||||
|
|
||||||
|
@ -466,7 +466,7 @@ int SpriteBatchNode::highestAtlasIndexInChild(Sprite *sprite)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpriteBatchNode::lowestAtlasIndexInChild(Sprite *sprite)
|
ssize_t SpriteBatchNode::lowestAtlasIndexInChild(Sprite *sprite)
|
||||||
{
|
{
|
||||||
auto& children = sprite->getChildren();
|
auto& children = sprite->getChildren();
|
||||||
|
|
||||||
|
@ -480,7 +480,7 @@ int SpriteBatchNode::lowestAtlasIndexInChild(Sprite *sprite)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ)
|
ssize_t SpriteBatchNode::atlasIndexForChild(Sprite *sprite, int nZ)
|
||||||
{
|
{
|
||||||
auto& siblings = sprite->getParent()->getChildren();
|
auto& siblings = sprite->getParent()->getChildren();
|
||||||
auto childIndex = siblings.getIndex(sprite);
|
auto childIndex = siblings.getIndex(sprite);
|
||||||
|
@ -627,7 +627,7 @@ void SpriteBatchNode::setTexture(Texture2D *texture)
|
||||||
// SpriteSheet Extension
|
// SpriteSheet Extension
|
||||||
//implementation SpriteSheet (TMXTiledMapExtension)
|
//implementation SpriteSheet (TMXTiledMapExtension)
|
||||||
|
|
||||||
void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, int index)
|
void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, ssize_t index)
|
||||||
{
|
{
|
||||||
CCASSERT( sprite != NULL, "Argument must be non-NULL");
|
CCASSERT( sprite != NULL, "Argument must be non-NULL");
|
||||||
CCASSERT( dynamic_cast<Sprite*>(sprite), "CCSpriteBatchNode only supports Sprites as children");
|
CCASSERT( dynamic_cast<Sprite*>(sprite), "CCSpriteBatchNode only supports Sprites as children");
|
||||||
|
@ -652,7 +652,7 @@ void SpriteBatchNode::insertQuadFromSprite(Sprite *sprite, int index)
|
||||||
sprite->updateTransform();
|
sprite->updateTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, int index)
|
void SpriteBatchNode::updateQuadFromSprite(Sprite *sprite, ssize_t index)
|
||||||
{
|
{
|
||||||
CCASSERT(sprite != NULL, "Argument must be non-nil");
|
CCASSERT(sprite != NULL, "Argument must be non-nil");
|
||||||
CCASSERT(dynamic_cast<Sprite*>(sprite) != NULL, "CCSpriteBatchNode only supports Sprites as children");
|
CCASSERT(dynamic_cast<Sprite*>(sprite) != NULL, "CCSpriteBatchNode only supports Sprites as children");
|
||||||
|
|
|
@ -68,13 +68,13 @@ public:
|
||||||
/** creates a SpriteBatchNode with a texture2d and capacity of children.
|
/** creates a SpriteBatchNode with a texture2d and capacity of children.
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
*/
|
*/
|
||||||
static SpriteBatchNode* createWithTexture(Texture2D* tex, int capacity = DEFAULT_CAPACITY);
|
static SpriteBatchNode* createWithTexture(Texture2D* tex, ssize_t capacity = DEFAULT_CAPACITY);
|
||||||
|
|
||||||
/** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
|
/** creates a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children.
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
The file will be loaded using the TextureMgr.
|
The file will be loaded using the TextureMgr.
|
||||||
*/
|
*/
|
||||||
static SpriteBatchNode* create(const char* fileImage, int capacity = DEFAULT_CAPACITY);
|
static SpriteBatchNode* create(const char* fileImage, ssize_t capacity = DEFAULT_CAPACITY);
|
||||||
/**
|
/**
|
||||||
* @js ctor
|
* @js ctor
|
||||||
*/
|
*/
|
||||||
|
@ -88,14 +88,14 @@ public:
|
||||||
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
|
/** initializes a SpriteBatchNode with a texture2d and capacity of children.
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
*/
|
*/
|
||||||
bool initWithTexture(Texture2D *tex, int capacity);
|
bool initWithTexture(Texture2D *tex, ssize_t capacity);
|
||||||
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
|
/** initializes a SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
|
||||||
The capacity will be increased in 33% in runtime if it run out of space.
|
The capacity will be increased in 33% in runtime if it run out of space.
|
||||||
The file will be loaded using the TextureMgr.
|
The file will be loaded using the TextureMgr.
|
||||||
* @js init
|
* @js init
|
||||||
* @lua init
|
* @lua init
|
||||||
*/
|
*/
|
||||||
bool initWithFile(const char* fileImage, int capacity);
|
bool initWithFile(const char* fileImage, ssize_t capacity);
|
||||||
bool init();
|
bool init();
|
||||||
|
|
||||||
/** returns the TextureAtlas object */
|
/** returns the TextureAtlas object */
|
||||||
|
@ -121,15 +121,15 @@ public:
|
||||||
/** removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.
|
/** removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.
|
||||||
@warning Removing a child from a SpriteBatchNode is very slow
|
@warning Removing a child from a SpriteBatchNode is very slow
|
||||||
*/
|
*/
|
||||||
void removeChildAtIndex(int index, bool doCleanup);
|
void removeChildAtIndex(ssize_t index, bool doCleanup);
|
||||||
|
|
||||||
void appendChild(Sprite* sprite);
|
void appendChild(Sprite* sprite);
|
||||||
void removeSpriteFromAtlas(Sprite *sprite);
|
void removeSpriteFromAtlas(Sprite *sprite);
|
||||||
|
|
||||||
int rebuildIndexInOrder(Sprite *parent, int index);
|
ssize_t rebuildIndexInOrder(Sprite *parent, ssize_t index);
|
||||||
int highestAtlasIndexInChild(Sprite *sprite);
|
ssize_t highestAtlasIndexInChild(Sprite *sprite);
|
||||||
int lowestAtlasIndexInChild(Sprite *sprite);
|
ssize_t lowestAtlasIndexInChild(Sprite *sprite);
|
||||||
int atlasIndexForChild(Sprite *sprite, int z);
|
ssize_t atlasIndexForChild(Sprite *sprite, int z);
|
||||||
/* Sprites use this to start sortChildren, don't call this manually */
|
/* Sprites use this to start sortChildren, don't call this manually */
|
||||||
void reorderBatch(bool reorder);
|
void reorderBatch(bool reorder);
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public:
|
||||||
// Overrides
|
// Overrides
|
||||||
//
|
//
|
||||||
// TextureProtocol
|
// TextureProtocol
|
||||||
virtual Texture2D* getTexture(void) const override;
|
virtual Texture2D* getTexture() const override;
|
||||||
virtual void setTexture(Texture2D *texture) override;
|
virtual void setTexture(Texture2D *texture) override;
|
||||||
/**
|
/**
|
||||||
*@code
|
*@code
|
||||||
|
@ -151,9 +151,9 @@ public:
|
||||||
* @js NA
|
* @js NA
|
||||||
* @lua NA
|
* @lua NA
|
||||||
*/
|
*/
|
||||||
virtual const BlendFunc& getBlendFunc(void) const override;
|
virtual const BlendFunc& getBlendFunc() const override;
|
||||||
|
|
||||||
virtual void visit(void) override;
|
virtual void visit() override;
|
||||||
virtual void addChild(Node* child) override{ Node::addChild(child);}
|
virtual void addChild(Node* child) override{ Node::addChild(child);}
|
||||||
virtual void addChild(Node * child, int zOrder) override { Node::addChild(child, zOrder);}
|
virtual void addChild(Node * child, int zOrder) override { Node::addChild(child, zOrder);}
|
||||||
virtual void addChild(Node * child, int zOrder, int tag) override;
|
virtual void addChild(Node * child, int zOrder, int tag) override;
|
||||||
|
@ -162,26 +162,26 @@ public:
|
||||||
virtual void removeChild(Node *child, bool cleanup) override;
|
virtual void removeChild(Node *child, bool cleanup) override;
|
||||||
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
||||||
virtual void sortAllChildren() override;
|
virtual void sortAllChildren() override;
|
||||||
virtual void draw(void) override;
|
virtual void draw() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
|
/** Inserts a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
|
||||||
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
|
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
|
||||||
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
|
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
|
||||||
*/
|
*/
|
||||||
void insertQuadFromSprite(Sprite *sprite, int index);
|
void insertQuadFromSprite(Sprite *sprite, ssize_t index);
|
||||||
/** Updates a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
|
/** Updates a quad at a certain index into the texture atlas. The Sprite won't be added into the children array.
|
||||||
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
|
This method should be called only when you are dealing with very big AtlasSrite and when most of the Sprite won't be updated.
|
||||||
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
|
For example: a tile map (TMXMap) or a label with lots of characters (LabelBMFont)
|
||||||
*/
|
*/
|
||||||
void updateQuadFromSprite(Sprite *sprite, int index);
|
void updateQuadFromSprite(Sprite *sprite, ssize_t index);
|
||||||
/* This is the opposite of "addQuadFromSprite.
|
/* This is the opposite of "addQuadFromSprite.
|
||||||
It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas
|
It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas
|
||||||
*/
|
*/
|
||||||
SpriteBatchNode * addSpriteWithoutQuad(Sprite *child, int z, int aTag);
|
SpriteBatchNode * addSpriteWithoutQuad(Sprite *child, int z, int aTag);
|
||||||
|
|
||||||
void updateAtlasIndex(Sprite* sprite, int* curIndex);
|
void updateAtlasIndex(Sprite* sprite, ssize_t* curIndex);
|
||||||
void swap(int oldIndex, int newIndex);
|
void swap(ssize_t oldIndex, ssize_t newIndex);
|
||||||
void updateBlendFunc();
|
void updateBlendFunc();
|
||||||
|
|
||||||
TextureAtlas *_textureAtlas;
|
TextureAtlas *_textureAtlas;
|
||||||
|
|
|
@ -340,8 +340,8 @@ Sprite * TMXLayer::getTileAt(const Point& pos)
|
||||||
tile->setAnchorPoint(Point::ZERO);
|
tile->setAnchorPoint(Point::ZERO);
|
||||||
tile->setOpacity(_opacity);
|
tile->setOpacity(_opacity);
|
||||||
|
|
||||||
unsigned int indexForZ = atlasIndexForExistantZ(z);
|
ssize_t indexForZ = atlasIndexForExistantZ(z);
|
||||||
this->addSpriteWithoutQuad(tile, indexForZ, z);
|
this->addSpriteWithoutQuad(tile, static_cast<int>(indexForZ), z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,7 +379,7 @@ Sprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos)
|
||||||
setupTileSprite(tile, pos, gid);
|
setupTileSprite(tile, pos, gid);
|
||||||
|
|
||||||
// get atlas index
|
// get atlas index
|
||||||
unsigned int indexForZ = atlasIndexForNewZ(static_cast<int>(z));
|
ssize_t indexForZ = atlasIndexForNewZ(static_cast<int>(z));
|
||||||
|
|
||||||
// Optimization: add the quad without adding a child
|
// Optimization: add the quad without adding a child
|
||||||
this->insertQuadFromSprite(tile, indexForZ);
|
this->insertQuadFromSprite(tile, indexForZ);
|
||||||
|
@ -393,7 +393,7 @@ Sprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos)
|
||||||
Sprite* sp = static_cast<Sprite*>(child);
|
Sprite* sp = static_cast<Sprite*>(child);
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
int ai = sp->getAtlasIndex();
|
ssize_t ai = sp->getAtlasIndex();
|
||||||
if ( ai >= indexForZ )
|
if ( ai >= indexForZ )
|
||||||
{
|
{
|
||||||
sp->setAtlasIndex(ai+1);
|
sp->setAtlasIndex(ai+1);
|
||||||
|
@ -416,7 +416,7 @@ Sprite * TMXLayer::updateTileForGID(unsigned int gid, const Point& pos)
|
||||||
setupTileSprite(tile ,pos ,gid);
|
setupTileSprite(tile ,pos ,gid);
|
||||||
|
|
||||||
// get atlas index
|
// get atlas index
|
||||||
unsigned int indexForZ = atlasIndexForExistantZ(z);
|
ssize_t indexForZ = atlasIndexForExistantZ(z);
|
||||||
tile->setAtlasIndex(indexForZ);
|
tile->setAtlasIndex(indexForZ);
|
||||||
tile->setDirty(true);
|
tile->setDirty(true);
|
||||||
tile->updateTransform();
|
tile->updateTransform();
|
||||||
|
@ -441,7 +441,7 @@ Sprite * TMXLayer::appendTileForGID(unsigned int gid, const Point& pos)
|
||||||
// optimization:
|
// optimization:
|
||||||
// The difference between appendTileForGID and insertTileforGID is that append is faster, since
|
// The difference between appendTileForGID and insertTileforGID is that append is faster, since
|
||||||
// it appends the tile at the end of the texture atlas
|
// it appends the tile at the end of the texture atlas
|
||||||
unsigned int indexForZ = _atlasIndexArray->num;
|
ssize_t indexForZ = _atlasIndexArray->num;
|
||||||
|
|
||||||
// don't add it using the "standard" way.
|
// don't add it using the "standard" way.
|
||||||
insertQuadFromSprite(tile, indexForZ);
|
insertQuadFromSprite(tile, indexForZ);
|
||||||
|
@ -458,24 +458,24 @@ static inline int compareInts(const void * a, const void * b)
|
||||||
return ((*(int*)a) - (*(int*)b));
|
return ((*(int*)a) - (*(int*)b));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int TMXLayer::atlasIndexForExistantZ(unsigned int z)
|
ssize_t TMXLayer::atlasIndexForExistantZ(unsigned int z)
|
||||||
{
|
{
|
||||||
int key=z;
|
int key=z;
|
||||||
int *item = (int*)bsearch((void*)&key, (void*)&_atlasIndexArray->arr[0], _atlasIndexArray->num, sizeof(void*), compareInts);
|
int *item = (int*)bsearch((void*)&key, (void*)&_atlasIndexArray->arr[0], _atlasIndexArray->num, sizeof(void*), compareInts);
|
||||||
|
|
||||||
CCASSERT(item, "TMX atlas index not found. Shall not happen");
|
CCASSERT(item, "TMX atlas index not found. Shall not happen");
|
||||||
|
|
||||||
int index = ((size_t)item - (size_t)_atlasIndexArray->arr) / sizeof(void*);
|
ssize_t index = ((size_t)item - (size_t)_atlasIndexArray->arr) / sizeof(void*);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int TMXLayer::atlasIndexForNewZ(int z)
|
ssize_t TMXLayer::atlasIndexForNewZ(int z)
|
||||||
{
|
{
|
||||||
// XXX: This can be improved with a sort of binary search
|
// XXX: This can be improved with a sort of binary search
|
||||||
int i=0;
|
ssize_t i=0;
|
||||||
for (i=0; i< _atlasIndexArray->num ; i++)
|
for (i=0; i< _atlasIndexArray->num ; i++)
|
||||||
{
|
{
|
||||||
int val = (size_t) _atlasIndexArray->arr[i];
|
ssize_t val = (size_t) _atlasIndexArray->arr[i];
|
||||||
if (z < val)
|
if (z < val)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -558,8 +558,8 @@ void TMXLayer::removeChild(Node* node, bool cleanup)
|
||||||
|
|
||||||
CCASSERT(_children.contains(sprite), "Tile does not belong to TMXLayer");
|
CCASSERT(_children.contains(sprite), "Tile does not belong to TMXLayer");
|
||||||
|
|
||||||
unsigned int atlasIndex = sprite->getAtlasIndex();
|
ssize_t atlasIndex = sprite->getAtlasIndex();
|
||||||
unsigned int zz = (size_t)_atlasIndexArray->arr[atlasIndex];
|
ssize_t zz = (size_t)_atlasIndexArray->arr[atlasIndex];
|
||||||
_tiles[zz] = 0;
|
_tiles[zz] = 0;
|
||||||
ccCArrayRemoveValueAtIndex(_atlasIndexArray, atlasIndex);
|
ccCArrayRemoveValueAtIndex(_atlasIndexArray, atlasIndex);
|
||||||
SpriteBatchNode::removeChild(sprite, cleanup);
|
SpriteBatchNode::removeChild(sprite, cleanup);
|
||||||
|
@ -575,7 +575,7 @@ void TMXLayer::removeTileAt(const Point& pos)
|
||||||
if (gid)
|
if (gid)
|
||||||
{
|
{
|
||||||
unsigned int z = (unsigned int)(pos.x + pos.y * _layerSize.width);
|
unsigned int z = (unsigned int)(pos.x + pos.y * _layerSize.width);
|
||||||
unsigned int atlasIndex = atlasIndexForExistantZ(z);
|
ssize_t atlasIndex = atlasIndexForExistantZ(z);
|
||||||
|
|
||||||
// remove tile from GID map
|
// remove tile from GID map
|
||||||
_tiles[z] = 0;
|
_tiles[z] = 0;
|
||||||
|
@ -598,7 +598,7 @@ void TMXLayer::removeTileAt(const Point& pos)
|
||||||
Sprite* child = static_cast<Sprite*>(obj);
|
Sprite* child = static_cast<Sprite*>(obj);
|
||||||
if (child)
|
if (child)
|
||||||
{
|
{
|
||||||
unsigned int ai = child->getAtlasIndex();
|
ssize_t ai = child->getAtlasIndex();
|
||||||
if ( ai >= atlasIndex )
|
if ( ai >= atlasIndex )
|
||||||
{
|
{
|
||||||
child->setAtlasIndex(ai-1);
|
child->setAtlasIndex(ai-1);
|
||||||
|
|
|
@ -209,8 +209,8 @@ private:
|
||||||
int getVertexZForPos(const Point& pos);
|
int getVertexZForPos(const Point& pos);
|
||||||
|
|
||||||
// index
|
// index
|
||||||
unsigned int atlasIndexForExistantZ(unsigned int z);
|
ssize_t atlasIndexForExistantZ(unsigned int z);
|
||||||
unsigned int atlasIndexForNewZ(int z);
|
ssize_t atlasIndexForNewZ(int z);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! name of the layer
|
//! name of the layer
|
||||||
|
|
|
@ -74,12 +74,12 @@ TextureAtlas::~TextureAtlas()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextureAtlas::getTotalQuads() const
|
ssize_t TextureAtlas::getTotalQuads() const
|
||||||
{
|
{
|
||||||
return _totalQuads;
|
return _totalQuads;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TextureAtlas::getCapacity() const
|
ssize_t TextureAtlas::getCapacity() const
|
||||||
{
|
{
|
||||||
return _capacity;
|
return _capacity;
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ void TextureAtlas::setQuads(V3F_C4B_T2F_Quad* quads)
|
||||||
|
|
||||||
// TextureAtlas - alloc & init
|
// TextureAtlas - alloc & init
|
||||||
|
|
||||||
TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
TextureAtlas * TextureAtlas::create(const char* file, ssize_t capacity)
|
||||||
{
|
{
|
||||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||||
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
if(textureAtlas && textureAtlas->initWithFile(file, capacity))
|
||||||
|
@ -122,7 +122,7 @@ TextureAtlas * TextureAtlas::create(const char* file, int capacity)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
|
TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, ssize_t capacity)
|
||||||
{
|
{
|
||||||
TextureAtlas * textureAtlas = new TextureAtlas();
|
TextureAtlas * textureAtlas = new TextureAtlas();
|
||||||
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
|
if (textureAtlas && textureAtlas->initWithTexture(texture, capacity))
|
||||||
|
@ -134,7 +134,7 @@ TextureAtlas * TextureAtlas::createWithTexture(Texture2D *texture, int capacity)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureAtlas::initWithFile(const char * file, int capacity)
|
bool TextureAtlas::initWithFile(const char * file, ssize_t capacity)
|
||||||
{
|
{
|
||||||
// retained in property
|
// retained in property
|
||||||
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
|
Texture2D *texture = Director::getInstance()->getTextureCache()->addImage(file);
|
||||||
|
@ -150,7 +150,7 @@ bool TextureAtlas::initWithFile(const char * file, int capacity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TextureAtlas::initWithTexture(Texture2D *texture, int capacity)
|
bool TextureAtlas::initWithTexture(Texture2D *texture, ssize_t capacity)
|
||||||
{
|
{
|
||||||
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
CCASSERT(capacity>=0, "Capacity must be >= 0");
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ void TextureAtlas::listenBackToForeground(Object *obj)
|
||||||
|
|
||||||
const char* TextureAtlas::description() const
|
const char* TextureAtlas::description() const
|
||||||
{
|
{
|
||||||
return String::createWithFormat("<TextureAtlas | totalQuads = %d>", _totalQuads)->getCString();
|
return String::createWithFormat("<TextureAtlas | totalQuads = %zd>", _totalQuads)->getCString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -317,7 +317,7 @@ void TextureAtlas::mapBuffers()
|
||||||
|
|
||||||
// TextureAtlas - Update, Insert, Move & Remove
|
// TextureAtlas - Update, Insert, Move & Remove
|
||||||
|
|
||||||
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
|
void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, ssize_t index)
|
||||||
{
|
{
|
||||||
CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
CCASSERT( index >= 0 && index < _capacity, "updateQuadWithTexture: Invalid index");
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ void TextureAtlas::updateQuad(V3F_C4B_T2F_Quad *quad, int index)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
|
void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, ssize_t index)
|
||||||
{
|
{
|
||||||
CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index");
|
CCASSERT( index>=0 && index<_capacity, "insertQuadWithTexture: Invalid index");
|
||||||
|
|
||||||
|
@ -354,7 +354,7 @@ void TextureAtlas::insertQuad(V3F_C4B_T2F_Quad *quad, int index)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
|
void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, ssize_t index, ssize_t amount)
|
||||||
{
|
{
|
||||||
CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount");
|
CCASSERT(index>=0 && amount>=0 && index+amount<=_capacity, "insertQuadWithTexture: Invalid index + amount");
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
|
||||||
|
|
||||||
auto max = index + amount;
|
auto max = index + amount;
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = index; i < max ; i++)
|
for (ssize_t i = index; i < max ; i++)
|
||||||
{
|
{
|
||||||
_quads[index] = quads[j];
|
_quads[index] = quads[j];
|
||||||
index++;
|
index++;
|
||||||
|
@ -385,7 +385,7 @@ void TextureAtlas::insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount)
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
|
void TextureAtlas::insertQuadFromIndex(ssize_t oldIndex, ssize_t newIndex)
|
||||||
{
|
{
|
||||||
CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
CCASSERT( newIndex >= 0 && newIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||||
CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
CCASSERT( oldIndex >= 0 && oldIndex < _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||||
|
@ -414,7 +414,7 @@ void TextureAtlas::insertQuadFromIndex(int oldIndex, int newIndex)
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::removeQuadAtIndex(int index)
|
void TextureAtlas::removeQuadAtIndex(ssize_t index)
|
||||||
{
|
{
|
||||||
CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index");
|
CCASSERT( index>=0 && index<_totalQuads, "removeQuadAtIndex: Invalid index");
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ void TextureAtlas::removeQuadAtIndex(int index)
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::removeQuadsAtIndex(int index, int amount)
|
void TextureAtlas::removeQuadsAtIndex(ssize_t index, ssize_t amount)
|
||||||
{
|
{
|
||||||
CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds");
|
CCASSERT(index>=0 && amount>=0 && index+amount<=_totalQuads, "removeQuadAtIndex: index + amount out of bounds");
|
||||||
|
|
||||||
|
@ -455,7 +455,7 @@ void TextureAtlas::removeAllQuads()
|
||||||
}
|
}
|
||||||
|
|
||||||
// TextureAtlas - Resize
|
// TextureAtlas - Resize
|
||||||
bool TextureAtlas::resizeCapacity(int newCapacity)
|
bool TextureAtlas::resizeCapacity(ssize_t newCapacity)
|
||||||
{
|
{
|
||||||
CCASSERT(newCapacity>=0, "capacity >= 0");
|
CCASSERT(newCapacity>=0, "capacity >= 0");
|
||||||
if( newCapacity == _capacity )
|
if( newCapacity == _capacity )
|
||||||
|
@ -529,13 +529,13 @@ bool TextureAtlas::resizeCapacity(int newCapacity)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::increaseTotalQuadsWith(int amount)
|
void TextureAtlas::increaseTotalQuadsWith(ssize_t amount)
|
||||||
{
|
{
|
||||||
CCASSERT(amount>=0, "amount >= 0");
|
CCASSERT(amount>=0, "amount >= 0");
|
||||||
_totalQuads += amount;
|
_totalQuads += amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
|
void TextureAtlas::moveQuadsFromIndex(ssize_t oldIndex, ssize_t amount, ssize_t newIndex)
|
||||||
{
|
{
|
||||||
CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0");
|
CCASSERT(oldIndex>=0 && amount>=0 && newIndex>=0, "values must be >= 0");
|
||||||
CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
CCASSERT(newIndex + amount <= _totalQuads, "insertQuadFromIndex:atIndex: Invalid index");
|
||||||
|
@ -567,7 +567,7 @@ void TextureAtlas::moveQuadsFromIndex(int oldIndex, int amount, int newIndex)
|
||||||
_dirty = true;
|
_dirty = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
|
void TextureAtlas::moveQuadsFromIndex(ssize_t index, ssize_t newIndex)
|
||||||
{
|
{
|
||||||
CCASSERT(index>=0 && newIndex>=0, "values must be >= 0");
|
CCASSERT(index>=0 && newIndex>=0, "values must be >= 0");
|
||||||
CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
|
CCASSERT(newIndex + (_totalQuads - index) <= _capacity, "moveQuadsFromIndex move is out of bounds");
|
||||||
|
@ -575,14 +575,14 @@ void TextureAtlas::moveQuadsFromIndex(int index, int newIndex)
|
||||||
memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0]));
|
memmove(_quads + newIndex,_quads + index, (_totalQuads - index) * sizeof(_quads[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::fillWithEmptyQuadsFromIndex(int index, int amount)
|
void TextureAtlas::fillWithEmptyQuadsFromIndex(ssize_t index, ssize_t amount)
|
||||||
{
|
{
|
||||||
CCASSERT(index>=0 && amount>=0, "values must be >= 0");
|
CCASSERT(index>=0 && amount>=0, "values must be >= 0");
|
||||||
V3F_C4B_T2F_Quad quad;
|
V3F_C4B_T2F_Quad quad;
|
||||||
memset(&quad, 0, sizeof(quad));
|
memset(&quad, 0, sizeof(quad));
|
||||||
|
|
||||||
auto to = index + amount;
|
auto to = index + amount;
|
||||||
for (int i = index ; i < to ; i++)
|
for (ssize_t i = index ; i < to ; i++)
|
||||||
{
|
{
|
||||||
_quads[i] = quad;
|
_quads[i] = quad;
|
||||||
}
|
}
|
||||||
|
@ -595,13 +595,13 @@ void TextureAtlas::drawQuads()
|
||||||
this->drawNumberOfQuads(_totalQuads, 0);
|
this->drawNumberOfQuads(_totalQuads, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::drawNumberOfQuads(int numberOfQuads)
|
void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads)
|
||||||
{
|
{
|
||||||
CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0");
|
CCASSERT(numberOfQuads>=0, "numberOfQuads must be >= 0");
|
||||||
this->drawNumberOfQuads(numberOfQuads, 0);
|
this->drawNumberOfQuads(numberOfQuads, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TextureAtlas::drawNumberOfQuads(int numberOfQuads, int start)
|
void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start)
|
||||||
{
|
{
|
||||||
CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0");
|
CCASSERT(numberOfQuads>=0 && start>=0, "numberOfQuads and start must be >= 0");
|
||||||
|
|
||||||
|
|
|
@ -59,13 +59,13 @@ public:
|
||||||
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
|
/** creates a TextureAtlas with an filename and with an initial capacity for Quads.
|
||||||
* The TextureAtlas capacity can be increased in runtime.
|
* The TextureAtlas capacity can be increased in runtime.
|
||||||
*/
|
*/
|
||||||
static TextureAtlas* create(const char* file , int capacity);
|
static TextureAtlas* create(const char* file , ssize_t capacity);
|
||||||
|
|
||||||
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
/** creates a TextureAtlas with a previously initialized Texture2D object, and
|
||||||
* with an initial capacity for n Quads.
|
* with an initial capacity for n Quads.
|
||||||
* The TextureAtlas capacity can be increased in runtime.
|
* The TextureAtlas capacity can be increased in runtime.
|
||||||
*/
|
*/
|
||||||
static TextureAtlas* createWithTexture(Texture2D *texture, int capacity);
|
static TextureAtlas* createWithTexture(Texture2D *texture, ssize_t capacity);
|
||||||
/**
|
/**
|
||||||
* @js ctor
|
* @js ctor
|
||||||
*/
|
*/
|
||||||
|
@ -81,7 +81,7 @@ public:
|
||||||
*
|
*
|
||||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||||
*/
|
*/
|
||||||
bool initWithFile(const char* file, int capacity);
|
bool initWithFile(const char* file, ssize_t capacity);
|
||||||
|
|
||||||
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
|
/** initializes a TextureAtlas with a previously initialized Texture2D object, and
|
||||||
* with an initial capacity for Quads.
|
* with an initial capacity for Quads.
|
||||||
|
@ -89,43 +89,43 @@ public:
|
||||||
*
|
*
|
||||||
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
* WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
|
||||||
*/
|
*/
|
||||||
bool initWithTexture(Texture2D *texture, int capacity);
|
bool initWithTexture(Texture2D *texture, ssize_t capacity);
|
||||||
|
|
||||||
/** updates a Quad (texture, vertex and color) at a certain index
|
/** updates a Quad (texture, vertex and color) at a certain index
|
||||||
* index must be between 0 and the atlas capacity - 1
|
* index must be between 0 and the atlas capacity - 1
|
||||||
@since v0.8
|
@since v0.8
|
||||||
*/
|
*/
|
||||||
void updateQuad(V3F_C4B_T2F_Quad* quad, int index);
|
void updateQuad(V3F_C4B_T2F_Quad* quad, ssize_t index);
|
||||||
|
|
||||||
/** Inserts a Quad (texture, vertex and color) at a certain index
|
/** Inserts a Quad (texture, vertex and color) at a certain index
|
||||||
index must be between 0 and the atlas capacity - 1
|
index must be between 0 and the atlas capacity - 1
|
||||||
@since v0.8
|
@since v0.8
|
||||||
*/
|
*/
|
||||||
void insertQuad(V3F_C4B_T2F_Quad* quad, int index);
|
void insertQuad(V3F_C4B_T2F_Quad* quad, ssize_t index);
|
||||||
|
|
||||||
/** Inserts a c array of quads at a given index
|
/** Inserts a c array of quads at a given index
|
||||||
index must be between 0 and the atlas capacity - 1
|
index must be between 0 and the atlas capacity - 1
|
||||||
this method doesn't enlarge the array when amount + index > totalQuads
|
this method doesn't enlarge the array when amount + index > totalQuads
|
||||||
@since v1.1
|
@since v1.1
|
||||||
*/
|
*/
|
||||||
void insertQuads(V3F_C4B_T2F_Quad* quads, int index, int amount);
|
void insertQuads(V3F_C4B_T2F_Quad* quads, ssize_t index, ssize_t amount);
|
||||||
|
|
||||||
/** Removes the quad that is located at a certain index and inserts it at a new index
|
/** Removes the quad that is located at a certain index and inserts it at a new index
|
||||||
This operation is faster than removing and inserting in a quad in 2 different steps
|
This operation is faster than removing and inserting in a quad in 2 different steps
|
||||||
@since v0.7.2
|
@since v0.7.2
|
||||||
*/
|
*/
|
||||||
void insertQuadFromIndex(int fromIndex, int newIndex);
|
void insertQuadFromIndex(ssize_t fromIndex, ssize_t newIndex);
|
||||||
|
|
||||||
/** removes a quad at a given index number.
|
/** removes a quad at a given index number.
|
||||||
The capacity remains the same, but the total number of quads to be drawn is reduced in 1
|
The capacity remains the same, but the total number of quads to be drawn is reduced in 1
|
||||||
@since v0.7.2
|
@since v0.7.2
|
||||||
*/
|
*/
|
||||||
void removeQuadAtIndex(int index);
|
void removeQuadAtIndex(ssize_t index);
|
||||||
|
|
||||||
/** removes a amount of quads starting from index
|
/** removes a amount of quads starting from index
|
||||||
@since 1.1
|
@since 1.1
|
||||||
*/
|
*/
|
||||||
void removeQuadsAtIndex(int index, int amount);
|
void removeQuadsAtIndex(ssize_t index, ssize_t amount);
|
||||||
/** removes all Quads.
|
/** removes all Quads.
|
||||||
The TextureAtlas capacity remains untouched. No memory is freed.
|
The TextureAtlas capacity remains untouched. No memory is freed.
|
||||||
The total number of quads to be drawn will be 0
|
The total number of quads to be drawn will be 0
|
||||||
|
@ -138,19 +138,19 @@ public:
|
||||||
* It returns true if the resize was successful.
|
* It returns true if the resize was successful.
|
||||||
* If it fails to resize the capacity it will return false with a new capacity of 0.
|
* If it fails to resize the capacity it will return false with a new capacity of 0.
|
||||||
*/
|
*/
|
||||||
bool resizeCapacity(int capacity);
|
bool resizeCapacity(ssize_t capacity);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Used internally by ParticleBatchNode
|
Used internally by ParticleBatchNode
|
||||||
don't use this unless you know what you're doing
|
don't use this unless you know what you're doing
|
||||||
@since 1.1
|
@since 1.1
|
||||||
*/
|
*/
|
||||||
void increaseTotalQuadsWith(int amount);
|
void increaseTotalQuadsWith(ssize_t amount);
|
||||||
|
|
||||||
/** Moves an amount of quads from oldIndex at newIndex
|
/** Moves an amount of quads from oldIndex at newIndex
|
||||||
@since v1.1
|
@since v1.1
|
||||||
*/
|
*/
|
||||||
void moveQuadsFromIndex(int oldIndex, int amount, int newIndex);
|
void moveQuadsFromIndex(ssize_t oldIndex, ssize_t amount, ssize_t newIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Moves quads from index till totalQuads to the newIndex
|
Moves quads from index till totalQuads to the newIndex
|
||||||
|
@ -158,26 +158,26 @@ public:
|
||||||
This method doesn't enlarge the array if newIndex + quads to be moved > capacity
|
This method doesn't enlarge the array if newIndex + quads to be moved > capacity
|
||||||
@since 1.1
|
@since 1.1
|
||||||
*/
|
*/
|
||||||
void moveQuadsFromIndex(int index, int newIndex);
|
void moveQuadsFromIndex(ssize_t index, ssize_t newIndex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Ensures that after a realloc quads are still empty
|
Ensures that after a realloc quads are still empty
|
||||||
Used internally by ParticleBatchNode
|
Used internally by ParticleBatchNode
|
||||||
@since 1.1
|
@since 1.1
|
||||||
*/
|
*/
|
||||||
void fillWithEmptyQuadsFromIndex(int index, int amount);
|
void fillWithEmptyQuadsFromIndex(ssize_t index, ssize_t amount);
|
||||||
|
|
||||||
/** draws n quads
|
/** draws n quads
|
||||||
* n can't be greater than the capacity of the Atlas
|
* n can't be greater than the capacity of the Atlas
|
||||||
*/
|
*/
|
||||||
void drawNumberOfQuads(int n);
|
void drawNumberOfQuads(ssize_t n);
|
||||||
|
|
||||||
/** draws n quads from an index (offset).
|
/** draws n quads from an index (offset).
|
||||||
n + start can't be greater than the capacity of the atlas
|
n + start can't be greater than the capacity of the atlas
|
||||||
|
|
||||||
@since v1.0
|
@since v1.0
|
||||||
*/
|
*/
|
||||||
void drawNumberOfQuads(int numberOfQuads, int start);
|
void drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start);
|
||||||
|
|
||||||
/** draws all the Atlas's Quads
|
/** draws all the Atlas's Quads
|
||||||
*/
|
*/
|
||||||
|
@ -197,10 +197,10 @@ public:
|
||||||
const char* description() const;
|
const char* description() const;
|
||||||
|
|
||||||
/** Gets the quantity of quads that are going to be drawn */
|
/** Gets the quantity of quads that are going to be drawn */
|
||||||
int getTotalQuads() const;
|
ssize_t getTotalQuads() const;
|
||||||
|
|
||||||
/** Gets the quantity of quads that can be stored with the current texture atlas size */
|
/** Gets the quantity of quads that can be stored with the current texture atlas size */
|
||||||
int getCapacity() const;
|
ssize_t getCapacity() const;
|
||||||
|
|
||||||
/** Gets the texture of the texture atlas */
|
/** Gets the texture of the texture atlas */
|
||||||
Texture2D* getTexture() const;
|
Texture2D* getTexture() const;
|
||||||
|
@ -226,9 +226,9 @@ protected:
|
||||||
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
GLuint _buffersVBO[2]; //0: vertex 1: indices
|
||||||
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
|
bool _dirty; //indicates whether or not the array buffer of the VBO needs to be updated
|
||||||
/** quantity of quads that are going to be drawn */
|
/** quantity of quads that are going to be drawn */
|
||||||
int _totalQuads;
|
ssize_t _totalQuads;
|
||||||
/** quantity of quads that can be stored with the current texture atlas size */
|
/** quantity of quads that can be stored with the current texture atlas size */
|
||||||
int _capacity;
|
ssize_t _capacity;
|
||||||
/** Texture of the texture atlas */
|
/** Texture of the texture atlas */
|
||||||
Texture2D* _texture;
|
Texture2D* _texture;
|
||||||
/** Quads that are going to be rendered */
|
/** Quads that are going to be rendered */
|
||||||
|
|
|
@ -222,7 +222,7 @@ void TileMapAtlas::updateAtlasValueAt(const Point& pos, const Color3B& value, in
|
||||||
quad->bl.colors = color;
|
quad->bl.colors = color;
|
||||||
|
|
||||||
_textureAtlas->setDirty(true);
|
_textureAtlas->setDirty(true);
|
||||||
int totalQuads = _textureAtlas->getTotalQuads();
|
ssize_t totalQuads = _textureAtlas->getTotalQuads();
|
||||||
if (index + 1 > totalQuads) {
|
if (index + 1 > totalQuads) {
|
||||||
_textureAtlas->increaseTotalQuadsWith(index + 1 - totalQuads);
|
_textureAtlas->increaseTotalQuadsWith(index + 1 - totalQuads);
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,7 +141,7 @@ void PoolManager::pop()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int count = _releasePoolStack.size();
|
ssize_t count = _releasePoolStack.size();
|
||||||
|
|
||||||
_curReleasePool->clear();
|
_curReleasePool->clear();
|
||||||
|
|
||||||
|
|
|
@ -37,34 +37,6 @@ template<class T>
|
||||||
class CC_DLL Vector
|
class CC_DLL Vector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ------------------------------------------
|
|
||||||
// Iterators
|
|
||||||
// ------------------------------------------
|
|
||||||
typedef typename std::vector<T>::iterator iterator;
|
|
||||||
typedef typename std::vector<T>::const_iterator const_iterator;
|
|
||||||
|
|
||||||
typedef typename std::vector<T>::reverse_iterator reverse_iterator;
|
|
||||||
typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
|
|
||||||
|
|
||||||
iterator begin() { return _data.begin(); }
|
|
||||||
const_iterator begin() const { return _data.begin(); }
|
|
||||||
|
|
||||||
iterator end() { return _data.end(); }
|
|
||||||
const_iterator end() const { return _data.end(); }
|
|
||||||
|
|
||||||
const_iterator cbegin() const { return _data.cbegin(); }
|
|
||||||
const_iterator cend() const { return _data.cend(); }
|
|
||||||
|
|
||||||
reverse_iterator rbegin() { return _data.rbegin(); }
|
|
||||||
const_reverse_iterator rbegin() const { return _data.rbegin(); }
|
|
||||||
|
|
||||||
reverse_iterator rend() { return _data.rend(); }
|
|
||||||
const_reverse_iterator rend() const { return _data.rend(); }
|
|
||||||
|
|
||||||
const_reverse_iterator crbegin() const { return _data.crbegin(); }
|
|
||||||
const_reverse_iterator crend() const { return _data.crend(); }
|
|
||||||
|
|
||||||
/** Constructor */
|
|
||||||
Vector<T>()
|
Vector<T>()
|
||||||
: _data()
|
: _data()
|
||||||
{
|
{
|
||||||
|
@ -133,7 +105,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns capacity of the array */
|
/** Returns capacity of the array */
|
||||||
int capacity() const
|
ssize_t capacity() const
|
||||||
{
|
{
|
||||||
return _data.capacity();
|
return _data.capacity();
|
||||||
}
|
}
|
||||||
|
@ -141,9 +113,9 @@ public:
|
||||||
// Querying an Array
|
// Querying an Array
|
||||||
|
|
||||||
/** Returns element count of the array */
|
/** Returns element count of the array */
|
||||||
int size() const
|
ssize_t size() const
|
||||||
{
|
{
|
||||||
return static_cast<int>(_data.size());
|
return _data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const
|
bool empty() const
|
||||||
|
@ -154,23 +126,18 @@ public:
|
||||||
/** Returns index of a certain object, return UINT_MAX if doesn't contain the object */
|
/** Returns index of a certain object, return UINT_MAX if doesn't contain the object */
|
||||||
ssize_t getIndex(T object) const
|
ssize_t getIndex(T object) const
|
||||||
{
|
{
|
||||||
auto iter = std::find(_data.begin(), _data.end(), object);
|
ssize_t i = 0;
|
||||||
if (iter != _data.end())
|
for (auto it = _data.begin(); it != _data.end(); ++it, ++i)
|
||||||
return iter - _data.begin();
|
{
|
||||||
|
if (*it == object)
|
||||||
|
{
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_iterator find(T object) const
|
|
||||||
{
|
|
||||||
return std::find(_data.begin(), _data.end(), object);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator find(T object)
|
|
||||||
{
|
|
||||||
return std::find(_data.begin(), _data.end(), object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns an element with a certain index */
|
/** Returns an element with a certain index */
|
||||||
T at(ssize_t index) const
|
T at(ssize_t index) const
|
||||||
{
|
{
|
||||||
|
@ -194,7 +161,7 @@ public:
|
||||||
{
|
{
|
||||||
if (!_data.empty())
|
if (!_data.empty())
|
||||||
{
|
{
|
||||||
int randIdx = rand() % _data.size();
|
ssize_t randIdx = rand() % _data.size();
|
||||||
return *(_data.begin() + randIdx);
|
return *(_data.begin() + randIdx);
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -263,7 +230,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Remove a certain object */
|
/** Remove a certain object */
|
||||||
void erase(T object, bool toRelease = true)
|
void removeObject(T object, bool toRelease = true)
|
||||||
{
|
{
|
||||||
CCASSERT(object != nullptr, "The object should not be nullptr");
|
CCASSERT(object != nullptr, "The object should not be nullptr");
|
||||||
auto iter = std::find(_data.begin(), _data.end(), object);
|
auto iter = std::find(_data.begin(), _data.end(), object);
|
||||||
|
@ -274,24 +241,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Removes an element with a certain index */
|
/** Removes an element with a certain index */
|
||||||
iterator erase(iterator position)
|
void remove(ssize_t index)
|
||||||
{
|
|
||||||
CCASSERT(position >= _data.begin() && position < _data.end(), "Invalid position!");
|
|
||||||
(*position)->release();
|
|
||||||
return _data.erase(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
iterator erase(const_iterator first, const_iterator last)
|
|
||||||
{
|
|
||||||
for (auto iter = first; iter != last; ++iter)
|
|
||||||
{
|
|
||||||
(*iter)->release();
|
|
||||||
}
|
|
||||||
|
|
||||||
return _data.erase(first, last);
|
|
||||||
}
|
|
||||||
|
|
||||||
void erase(int index)
|
|
||||||
{
|
{
|
||||||
CCASSERT(!_data.empty() && index >=0 && index < size(), "Invalid index!");
|
CCASSERT(!_data.empty() && index >=0 && index < size(), "Invalid index!");
|
||||||
auto it = std::next( begin(), index );
|
auto it = std::next( begin(), index );
|
||||||
|
@ -402,6 +352,33 @@ public:
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------
|
||||||
|
// Iterators
|
||||||
|
// ------------------------------------------
|
||||||
|
typedef typename std::vector<T>::iterator iterator;
|
||||||
|
typedef typename std::vector<T>::const_iterator const_iterator;
|
||||||
|
|
||||||
|
typedef typename std::vector<T>::reverse_iterator reverse_iterator;
|
||||||
|
typedef typename std::vector<T>::const_reverse_iterator const_reverse_iterator;
|
||||||
|
|
||||||
|
iterator begin() { return _data.begin(); }
|
||||||
|
const_iterator begin() const { return _data.begin(); }
|
||||||
|
|
||||||
|
iterator end() { return _data.end(); }
|
||||||
|
const_iterator end() const { return _data.end(); }
|
||||||
|
|
||||||
|
const_iterator cbegin() const { return _data.cbegin(); }
|
||||||
|
const_iterator cend() const { return _data.cend(); }
|
||||||
|
|
||||||
|
reverse_iterator rbegin() { return _data.rbegin(); }
|
||||||
|
const_reverse_iterator rbegin() const { return _data.rbegin(); }
|
||||||
|
|
||||||
|
reverse_iterator rend() { return _data.rend(); }
|
||||||
|
const_reverse_iterator rend() const { return _data.rend(); }
|
||||||
|
|
||||||
|
const_reverse_iterator crbegin() const { return _data.crbegin(); }
|
||||||
|
const_reverse_iterator crend() const { return _data.crend(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void addRefForAllObjects()
|
void addRefForAllObjects()
|
||||||
|
|
|
@ -623,7 +623,7 @@ Object* CCBAnimationManager::actionForCallbackChannel(CCBSequenceProperty* chann
|
||||||
|
|
||||||
Vector<FiniteTimeAction*> actions;
|
Vector<FiniteTimeAction*> actions;
|
||||||
auto& keyframes = channel->getKeyframes();
|
auto& keyframes = channel->getKeyframes();
|
||||||
int numKeyframes = keyframes.size();
|
ssize_t numKeyframes = keyframes.size();
|
||||||
|
|
||||||
for (long i = 0; i < numKeyframes; ++i)
|
for (long i = 0; i < numKeyframes; ++i)
|
||||||
{
|
{
|
||||||
|
@ -712,7 +712,7 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel)
|
||||||
|
|
||||||
Vector<FiniteTimeAction*> actions;
|
Vector<FiniteTimeAction*> actions;
|
||||||
auto& keyframes = channel->getKeyframes();
|
auto& keyframes = channel->getKeyframes();
|
||||||
int numKeyframes = keyframes.size();
|
ssize_t numKeyframes = keyframes.size();
|
||||||
|
|
||||||
for (int i = 0; i < numKeyframes; ++i)
|
for (int i = 0; i < numKeyframes; ++i)
|
||||||
{
|
{
|
||||||
|
@ -753,7 +753,7 @@ Object* CCBAnimationManager::actionForSoundChannel(CCBSequenceProperty* channel)
|
||||||
void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration)
|
void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp, float fTweenDuration)
|
||||||
{
|
{
|
||||||
auto& keyframes = pSeqProp->getKeyframes();
|
auto& keyframes = pSeqProp->getKeyframes();
|
||||||
int numKeyframes = keyframes.size();
|
ssize_t numKeyframes = keyframes.size();
|
||||||
|
|
||||||
if (numKeyframes > 1)
|
if (numKeyframes > 1)
|
||||||
{
|
{
|
||||||
|
@ -768,7 +768,7 @@ void CCBAnimationManager::runAction(Node *pNode, CCBSequenceProperty *pSeqProp,
|
||||||
actions.pushBack(DelayTime::create(timeFirst));
|
actions.pushBack(DelayTime::create(timeFirst));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numKeyframes - 1; ++i)
|
for (ssize_t i = 0; i < numKeyframes - 1; ++i)
|
||||||
{
|
{
|
||||||
CCBKeyframe *kf0 = keyframes.at(i);
|
CCBKeyframe *kf0 = keyframes.at(i);
|
||||||
CCBKeyframe *kf1 = keyframes.at(i+1);
|
CCBKeyframe *kf1 = keyframes.at(i+1);
|
||||||
|
|
|
@ -970,9 +970,9 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
|
||||||
if (!ownerCallbackNames.empty() && !ownerCallbackNodes.empty())
|
if (!ownerCallbackNames.empty() && !ownerCallbackNodes.empty())
|
||||||
{
|
{
|
||||||
CCASSERT(ownerCallbackNames.size() == ownerCallbackNodes.size(), "");
|
CCASSERT(ownerCallbackNames.size() == ownerCallbackNodes.size(), "");
|
||||||
int nCount = ownerCallbackNames.size();
|
ssize_t nCount = ownerCallbackNames.size();
|
||||||
|
|
||||||
for (int i = 0 ; i < nCount; i++)
|
for (ssize_t i = 0 ; i < nCount; i++)
|
||||||
{
|
{
|
||||||
pCCBReader->addOwnerCallbackName(ownerCallbackNames[i].asString());
|
pCCBReader->addOwnerCallbackName(ownerCallbackNames[i].asString());
|
||||||
pCCBReader->addOwnerCallbackNode(ownerCallbackNodes.at(i));
|
pCCBReader->addOwnerCallbackNode(ownerCallbackNodes.at(i));
|
||||||
|
@ -984,9 +984,9 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
|
||||||
if (!ownerOutletNames.empty() && !ownerOutletNodes.empty())
|
if (!ownerOutletNames.empty() && !ownerOutletNodes.empty())
|
||||||
{
|
{
|
||||||
CCASSERT(ownerOutletNames.size() == ownerOutletNodes.size(), "");
|
CCASSERT(ownerOutletNames.size() == ownerOutletNodes.size(), "");
|
||||||
int nCount = ownerOutletNames.size();
|
ssize_t nCount = ownerOutletNames.size();
|
||||||
|
|
||||||
for (int i = 0 ; i < nCount; i++)
|
for (ssize_t i = 0 ; i < nCount; i++)
|
||||||
{
|
{
|
||||||
pCCBReader->addOwnerOutletName(ownerOutletNames.at(i).asString());
|
pCCBReader->addOwnerOutletName(ownerOutletNames.at(i).asString());
|
||||||
pCCBReader->addOwnerOutletNode(ownerOutletNodes.at(i));
|
pCCBReader->addOwnerOutletNode(ownerOutletNodes.at(i));
|
||||||
|
|
|
@ -61,7 +61,7 @@ void SkeletonJson_dispose (SkeletonJson* self) {
|
||||||
|
|
||||||
void _SkeletonJson_setError (SkeletonJson* self, Json* root, const char* value1, const char* value2) {
|
void _SkeletonJson_setError (SkeletonJson* self, Json* root, const char* value1, const char* value2) {
|
||||||
char message[256];
|
char message[256];
|
||||||
int length;
|
size_t length;
|
||||||
FREE(self->error);
|
FREE(self->error);
|
||||||
strcpy(message, value1);
|
strcpy(message, value1);
|
||||||
length = strlen(value1);
|
length = strlen(value1);
|
||||||
|
|
|
@ -50,10 +50,10 @@ void _setFree (void (*free) (void* ptr)) {
|
||||||
freeFunc = free;
|
freeFunc = free;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* _readFile (const char* path, int* length) {
|
char* _readFile (const char* path, ssize_t* length) {
|
||||||
char *data;
|
char *data;
|
||||||
FILE *file = fopen(path, "rb");
|
FILE *file = fopen(path, "rb");
|
||||||
int readBytes = 0;
|
ssize_t readBytes = 0;
|
||||||
if (!file) return 0;
|
if (!file) return 0;
|
||||||
|
|
||||||
fseek(file, 0, SEEK_END);
|
fseek(file, 0, SEEK_END);
|
||||||
|
|
|
@ -114,7 +114,7 @@ void _free (void* ptr);
|
||||||
void _setMalloc (void* (*_malloc) (size_t size));
|
void _setMalloc (void* (*_malloc) (size_t size));
|
||||||
void _setFree (void (*_free) (void* ptr));
|
void _setFree (void (*_free) (void* ptr));
|
||||||
|
|
||||||
char* _readFile (const char* path, int* length);
|
char* _readFile (const char* path, ssize_t* length);
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ public:
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
/** Get the size of request data back */
|
/** Get the size of request data back */
|
||||||
inline int getRequestDataSize()
|
inline ssize_t getRequestDataSize()
|
||||||
{
|
{
|
||||||
return _requestData.size();
|
return _requestData.size();
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,7 +107,7 @@ public:
|
||||||
/** Get the http response errorCode
|
/** Get the http response errorCode
|
||||||
* I know that you want to see http 200 :)
|
* I know that you want to see http 200 :)
|
||||||
*/
|
*/
|
||||||
inline int getResponseCode()
|
inline long getResponseCode()
|
||||||
{
|
{
|
||||||
return _responseCode;
|
return _responseCode;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ public:
|
||||||
|
|
||||||
/** Set the http response errorCode
|
/** Set the http response errorCode
|
||||||
*/
|
*/
|
||||||
inline void setResponseCode(int value)
|
inline void setResponseCode(long value)
|
||||||
{
|
{
|
||||||
_responseCode = value;
|
_responseCode = value;
|
||||||
}
|
}
|
||||||
|
@ -172,7 +172,7 @@ protected:
|
||||||
bool _succeed; /// to indecate if the http reqeust is successful simply
|
bool _succeed; /// to indecate if the http reqeust is successful simply
|
||||||
std::vector<char> _responseData; /// the returned raw data. You can also dump it as a string
|
std::vector<char> _responseData; /// the returned raw data. You can also dump it as a string
|
||||||
std::vector<char> _responseHeader; /// the returned raw header data. You can also dump it as a string
|
std::vector<char> _responseHeader; /// the returned raw header data. You can also dump it as a string
|
||||||
int _responseCode; /// the status code returned from libcurl, e.g. 200, 404
|
long _responseCode; /// the status code returned from libcurl, e.g. 200, 404
|
||||||
std::string _errorBuffer; /// if _responseCode != 200, please read _errorBuffer to find the reason
|
std::string _errorBuffer; /// if _responseCode != 200, please read _errorBuffer to find the reason
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -123,7 +123,7 @@ void TableView::reloadData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TableViewCell *TableView::cellAtIndex(long idx)
|
TableViewCell *TableView::cellAtIndex(ssize_t idx)
|
||||||
{
|
{
|
||||||
if (_indices->find(idx) != _indices->end())
|
if (_indices->find(idx) != _indices->end())
|
||||||
{
|
{
|
||||||
|
@ -139,7 +139,7 @@ TableViewCell *TableView::cellAtIndex(long idx)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableView::updateCellAtIndex(long idx)
|
void TableView::updateCellAtIndex(ssize_t idx)
|
||||||
{
|
{
|
||||||
if (idx == CC_INVALID_INDEX)
|
if (idx == CC_INVALID_INDEX)
|
||||||
{
|
{
|
||||||
|
@ -161,7 +161,7 @@ void TableView::updateCellAtIndex(long idx)
|
||||||
this->_addCellIfNecessary(cell);
|
this->_addCellIfNecessary(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableView::insertCellAtIndex(long idx)
|
void TableView::insertCellAtIndex(ssize_t idx)
|
||||||
{
|
{
|
||||||
if (idx == CC_INVALID_INDEX)
|
if (idx == CC_INVALID_INDEX)
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ void TableView::insertCellAtIndex(long idx)
|
||||||
this->_updateContentSize();
|
this->_updateContentSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableView::removeCellAtIndex(long idx)
|
void TableView::removeCellAtIndex(ssize_t idx)
|
||||||
{
|
{
|
||||||
if (idx == CC_INVALID_INDEX)
|
if (idx == CC_INVALID_INDEX)
|
||||||
{
|
{
|
||||||
|
@ -210,7 +210,7 @@ void TableView::removeCellAtIndex(long idx)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int newIdx = 0;
|
ssize_t newIdx = 0;
|
||||||
|
|
||||||
TableViewCell* cell = this->cellAtIndex(idx);
|
TableViewCell* cell = this->cellAtIndex(idx);
|
||||||
if (!cell)
|
if (!cell)
|
||||||
|
@ -226,7 +226,7 @@ void TableView::removeCellAtIndex(long idx)
|
||||||
_indices->erase(idx);
|
_indices->erase(idx);
|
||||||
this->_updateCellPositions();
|
this->_updateCellPositions();
|
||||||
|
|
||||||
for (int i = _cellsUsed.size()-1; i > newIdx; i--)
|
for (ssize_t i = _cellsUsed.size()-1; i > newIdx; i--)
|
||||||
{
|
{
|
||||||
cell = _cellsUsed.at(i);
|
cell = _cellsUsed.at(i);
|
||||||
this->_setIndexForCell(cell->getIdx()-1, cell);
|
this->_setIndexForCell(cell->getIdx()-1, cell);
|
||||||
|
@ -262,7 +262,7 @@ void TableView::_addCellIfNecessary(TableViewCell * cell)
|
||||||
void TableView::_updateContentSize()
|
void TableView::_updateContentSize()
|
||||||
{
|
{
|
||||||
Size size = Size::ZERO;
|
Size size = Size::ZERO;
|
||||||
unsigned int cellsCount = _dataSource->numberOfCellsInTableView(this);
|
ssize_t cellsCount = _dataSource->numberOfCellsInTableView(this);
|
||||||
|
|
||||||
if (cellsCount > 0)
|
if (cellsCount > 0)
|
||||||
{
|
{
|
||||||
|
@ -296,7 +296,7 @@ void TableView::_updateContentSize()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Point TableView::_offsetFromIndex(long index)
|
Point TableView::_offsetFromIndex(ssize_t index)
|
||||||
{
|
{
|
||||||
Point offset = this->__offsetFromIndex(index);
|
Point offset = this->__offsetFromIndex(index);
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ Point TableView::_offsetFromIndex(long index)
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
Point TableView::__offsetFromIndex(long index)
|
Point TableView::__offsetFromIndex(ssize_t index)
|
||||||
{
|
{
|
||||||
Point offset;
|
Point offset;
|
||||||
Size cellSize;
|
Size cellSize;
|
||||||
|
@ -409,7 +409,7 @@ void TableView::_moveCellOutOfSight(TableViewCell *cell)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableView::_setIndexForCell(long index, TableViewCell *cell)
|
void TableView::_setIndexForCell(ssize_t index, TableViewCell *cell)
|
||||||
{
|
{
|
||||||
cell->setAnchorPoint(Point(0.0f, 0.0f));
|
cell->setAnchorPoint(Point(0.0f, 0.0f));
|
||||||
cell->setPosition(this->_offsetFromIndex(index));
|
cell->setPosition(this->_offsetFromIndex(index));
|
||||||
|
@ -464,7 +464,7 @@ void TableView::scrollViewDidScroll(ScrollView* view)
|
||||||
_tableViewDelegate->scrollViewDidScroll(this);
|
_tableViewDelegate->scrollViewDidScroll(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
long startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0;
|
ssize_t startIdx = 0, endIdx = 0, idx = 0, maxIdx = 0;
|
||||||
Point offset = this->getContentOffset() * -1;
|
Point offset = this->getContentOffset() * -1;
|
||||||
maxIdx = MAX(countOfItems-1, 0);
|
maxIdx = MAX(countOfItems-1, 0);
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
* @param idx the index of a cell to get a size
|
* @param idx the index of a cell to get a size
|
||||||
* @return size of a cell at given index
|
* @return size of a cell at given index
|
||||||
*/
|
*/
|
||||||
virtual Size tableCellSizeForIndex(TableView *table, long idx) {
|
virtual Size tableCellSizeForIndex(TableView *table, ssize_t idx) {
|
||||||
return cellSizeForTable(table);
|
return cellSizeForTable(table);
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
|
@ -123,7 +123,7 @@ public:
|
||||||
* @param idx index to search for a cell
|
* @param idx index to search for a cell
|
||||||
* @return cell found at idx
|
* @return cell found at idx
|
||||||
*/
|
*/
|
||||||
virtual TableViewCell* tableCellAtIndex(TableView *table, long idx) = 0;
|
virtual TableViewCell* tableCellAtIndex(TableView *table, ssize_t idx) = 0;
|
||||||
/**
|
/**
|
||||||
* Returns number of cells in a given table view.
|
* Returns number of cells in a given table view.
|
||||||
*
|
*
|
||||||
|
@ -228,19 +228,19 @@ public:
|
||||||
*
|
*
|
||||||
* @param idx index to find a cell
|
* @param idx index to find a cell
|
||||||
*/
|
*/
|
||||||
void updateCellAtIndex(long idx);
|
void updateCellAtIndex(ssize_t idx);
|
||||||
/**
|
/**
|
||||||
* Inserts a new cell at a given index
|
* Inserts a new cell at a given index
|
||||||
*
|
*
|
||||||
* @param idx location to insert
|
* @param idx location to insert
|
||||||
*/
|
*/
|
||||||
void insertCellAtIndex(long idx);
|
void insertCellAtIndex(ssize_t idx);
|
||||||
/**
|
/**
|
||||||
* Removes a cell at a given index
|
* Removes a cell at a given index
|
||||||
*
|
*
|
||||||
* @param idx index to find a cell
|
* @param idx index to find a cell
|
||||||
*/
|
*/
|
||||||
void removeCellAtIndex(long idx);
|
void removeCellAtIndex(ssize_t idx);
|
||||||
/**
|
/**
|
||||||
* reloads data from data source. the view will be refreshed.
|
* reloads data from data source. the view will be refreshed.
|
||||||
*/
|
*/
|
||||||
|
@ -258,7 +258,7 @@ public:
|
||||||
* @param idx index
|
* @param idx index
|
||||||
* @return a cell at a given index
|
* @return a cell at a given index
|
||||||
*/
|
*/
|
||||||
TableViewCell *cellAtIndex(long idx);
|
TableViewCell *cellAtIndex(ssize_t idx);
|
||||||
|
|
||||||
// Overrides
|
// Overrides
|
||||||
virtual void scrollViewDidScroll(ScrollView* view) override;
|
virtual void scrollViewDidScroll(ScrollView* view) override;
|
||||||
|
@ -271,11 +271,11 @@ public:
|
||||||
protected:
|
protected:
|
||||||
long __indexFromOffset(Point offset);
|
long __indexFromOffset(Point offset);
|
||||||
long _indexFromOffset(Point offset);
|
long _indexFromOffset(Point offset);
|
||||||
Point __offsetFromIndex(long index);
|
Point __offsetFromIndex(ssize_t index);
|
||||||
Point _offsetFromIndex(long index);
|
Point _offsetFromIndex(ssize_t index);
|
||||||
|
|
||||||
void _moveCellOutOfSight(TableViewCell *cell);
|
void _moveCellOutOfSight(TableViewCell *cell);
|
||||||
void _setIndexForCell(long index, TableViewCell *cell);
|
void _setIndexForCell(ssize_t index, TableViewCell *cell);
|
||||||
void _addCellIfNecessary(TableViewCell * cell);
|
void _addCellIfNecessary(TableViewCell * cell);
|
||||||
|
|
||||||
void _updateCellPositions();
|
void _updateCellPositions();
|
||||||
|
@ -290,7 +290,7 @@ protected:
|
||||||
/**
|
/**
|
||||||
* index set to query the indexes of the cells used.
|
* index set to query the indexes of the cells used.
|
||||||
*/
|
*/
|
||||||
std::set<long>* _indices;
|
std::set<ssize_t>* _indices;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vector with all cell positions
|
* vector with all cell positions
|
||||||
|
|
|
@ -116,7 +116,7 @@ std::string valueToQuotedString( const char *value )
|
||||||
// We have to walk value and escape any special characters.
|
// We have to walk value and escape any special characters.
|
||||||
// Appending to std::string is not efficient, but this should be rare.
|
// Appending to std::string is not efficient, but this should be rare.
|
||||||
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
// (Note: forward slashes are *not* rare, but I am not escaping them.)
|
||||||
unsigned maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL
|
size_t maxsize = strlen(value)*2 + 3; // allescaped+quotes+NULL
|
||||||
std::string result;
|
std::string result;
|
||||||
result.reserve(maxsize); // to avoid lots of mallocs
|
result.reserve(maxsize); // to avoid lots of mallocs
|
||||||
result += "\"";
|
result += "\"";
|
||||||
|
|
Loading…
Reference in New Issue