Merge pull request #122 from WenhaiLin/master

Use const references whenever possible
This commit is contained in:
Wenhai Lin
2016-05-18 14:57:30 +08:00
20 changed files with 42 additions and 42 deletions
@@ -69,7 +69,7 @@ void ControlButtonLoader::onHandlePropTypeFloatScale(Node * pNode, Node * pParen
}
}
void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) {
void ControlButtonLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, const Vec2& pPoint, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) {
((ControlButton *)pNode)->setLabelAnchorPoint(pPoint);
} else {
@@ -29,7 +29,7 @@ class CC_DLL ControlButtonLoader : public ControlLoader {
virtual void onHandlePropTypeString(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pString, CCBReader * ccbReader);
virtual void onHandlePropTypeFontTTF(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * ccbReader);
virtual void onHandlePropTypeFloatScale(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, float pFloatScale, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const cocos2d::Vec2& pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader);
virtual void onHandlePropTypeSpriteFrame(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::SpriteFrame * pSpriteFrame, CCBReader * ccbReader);
virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader);
@@ -40,7 +40,7 @@ void LayerGradientLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent
}
void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) {
void LayerGradientLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, const Vec2& pPoint, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) {
((LayerGradient *)pNode)->setVector(pPoint);
@@ -22,7 +22,7 @@ protected:
virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader);
virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const cocos2d::Vec2& pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader);
};
@@ -998,7 +998,7 @@ Node * NodeLoader::parsePropTypeCCBFile(Node * pNode, Node * pParent, CCBReader
void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const char* pPropertyName, Vec2 pPosition, CCBReader * ccbReader) {
void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const char* pPropertyName, const Vec2& pPosition, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) {
pNode->setPosition(pPosition);
} else {
@@ -1006,7 +1006,7 @@ void NodeLoader::onHandlePropTypePosition(Node * pNode, Node * pParent, const ch
}
}
void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* pPropertyName, Vec2 pPoint, CCBReader * ccbReader) {
void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char* pPropertyName, const Vec2& pPoint, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) {
pNode->setAnchorPoint(pPoint);
} else {
@@ -1014,11 +1014,11 @@ void NodeLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char*
}
}
void NodeLoader::onHandlePropTypePointLock(Node * pNode, Node * pParent, const char* pPropertyName, Vec2 pPointLock, CCBReader * ccbReader) {
void NodeLoader::onHandlePropTypePointLock(Node * pNode, Node * pParent, const char* pPropertyName, const Vec2& pPointLock, CCBReader * ccbReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
}
void NodeLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char* pPropertyName, Size pSize, CCBReader * ccbReader) {
void NodeLoader::onHandlePropTypeSize(Node * pNode, Node * pParent, const char* pPropertyName, const Size& pSize, CCBReader * ccbReader) {
if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) {
pNode->setContentSize(pSize);
} else {
@@ -1115,7 +1115,7 @@ void NodeLoader::onHandlePropTypeByte(Node * pNode, Node * pParent, const char*
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
}
void NodeLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, Color3B pColor3B, CCBReader * ccbReader) {
void NodeLoader::onHandlePropTypeColor3(Node * pNode, Node * pParent, const char* pPropertyName, const Color3B& pColor3B, CCBReader * ccbReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
}
@@ -1127,7 +1127,7 @@ void NodeLoader::onHandlePropTypeFlip(Node * pNode, Node * pParent, const char*
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
}
void NodeLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, BlendFunc pBlendFunc, CCBReader * ccbReader) {
void NodeLoader::onHandlePropTypeBlendFunc(Node * pNode, Node * pParent, const char* pPropertyName, const BlendFunc& pBlendFunc, CCBReader * ccbReader) {
ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName);
}
@@ -108,10 +108,10 @@ class CC_DLL NodeLoader : public cocos2d::Ref {
virtual float * parsePropTypeFloatXY(cocos2d::Node * pNode, cocos2d::Node * pParent, CCBReader * ccbReader);
virtual void onHandlePropTypePosition(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char* pPropertyName, cocos2d::Vec2 pPosition, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypePointLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Vec2 pPointLock, CCBReader * ccbReader);
virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Size pSize, CCBReader * ccbReader);
virtual void onHandlePropTypePosition(cocos2d::Node * pNode,cocos2d:: Node * pParent, const char* pPropertyName, const cocos2d::Vec2& pPosition, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const cocos2d::Vec2& pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypePointLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const cocos2d::Vec2& pPointLock, CCBReader * ccbReader);
virtual void onHandlePropTypeSize(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const cocos2d::Size& pSize, CCBReader * ccbReader);
virtual void onHandlePropTypeScaleLock(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float * pScaleLock, CCBReader * ccbReader);
virtual void onHandlePropTypeFloat(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float pFloat, CCBReader * ccbReader);
virtual void onHandlePropTypeDegrees(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, float pDegrees, CCBReader * ccbReader);
@@ -126,10 +126,10 @@ class CC_DLL NodeLoader : public cocos2d::Ref {
virtual void onHandlePropTypeAnimation(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Animation * pAnimation, CCBReader * ccbReader);
virtual void onHandlePropTypeTexture(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Texture2D * pTexture2D, CCBReader * ccbReader);
virtual void onHandlePropTypeByte(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, unsigned char pByte, CCBReader * ccbReader);
virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Color3B pColor3B, CCBReader * ccbReader);
virtual void onHandlePropTypeColor3(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const cocos2d::Color3B& pColor3B, CCBReader * ccbReader);
virtual void onHandlePropTypeColor4FVar(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::Color4F * pColor4FVar, CCBReader * ccbReader);
virtual void onHandlePropTypeFlip(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, bool * pFlip, CCBReader * ccbReader);
virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, cocos2d::BlendFunc pBlendFunc, CCBReader * ccbReader);
virtual void onHandlePropTypeBlendFunc(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const cocos2d::BlendFunc& pBlendFunc, CCBReader * ccbReader);
virtual void onHandlePropTypeFntFile(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pFntFile, CCBReader * ccbReader);
virtual void onHandlePropTypeString(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pString, CCBReader * ccbReader);
virtual void onHandlePropTypeText(cocos2d::Node * pNode, cocos2d::Node * pParent, const char* pPropertyName, const char * pText, CCBReader * ccbReader);
@@ -35,7 +35,7 @@ void ParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(Node * pNode, Node
}
}
void ParticleSystemQuadLoader::onHandlePropTypePoint(Node * pNode, Node * pParent, const char * pPropertyName, Vec2 pPoint, CCBReader * ccbReader) {
void ParticleSystemQuadLoader::onHandlePropTypePoint(Node* pNode, Node* pParent, const char* pPropertyName, const Vec2& pPoint, CCBReader* ccbReader) {
if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) {
((ParticleSystemQuad *)pNode)->setPosVar(pPoint);
} else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) {
@@ -39,7 +39,7 @@ protected:
* @js NA
* @lua NA
*/
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, cocos2d::Vec2 pPoint, CCBReader * ccbReader);
virtual void onHandlePropTypePoint(cocos2d::Node * pNode, cocos2d::Node * pParent, const char * pPropertyName, const cocos2d::Vec2& pPoint, CCBReader * ccbReader);
/**
* @js NA
* @lua NA
@@ -46,7 +46,7 @@ bool isSpriteContainPoint(Sprite *sprite, const Vec2& point)
}
Vec2 bezierTo(float t, Vec2 &point1, Vec2 &point2, Vec2 &point3)
Vec2 bezierTo(float t, const Vec2 &point1, const Vec2 &point2, const Vec2 &point3)
{
Vec2 p;
@@ -57,7 +57,7 @@ Vec2 bezierTo(float t, Vec2 &point1, Vec2 &point2, Vec2 &point3)
return p;
}
Vec2 bezierTo(float t, Vec2 &point1, Vec2 &point2, Vec2 &point3, Vec2 &point4)
Vec2 bezierTo(float t, const Vec2 &point1, const Vec2 &point2, const Vec2 &point3, const Vec2 &point4)
{
Vec2 p;
@@ -67,7 +67,7 @@ Vec2 bezierTo(float t, Vec2 &point1, Vec2 &point2, Vec2 &point3, Vec2 &point4)
return p;
}
Vec2 circleTo(float t, Vec2 &center, float radius, float fromRadian, float radianDif)
Vec2 circleTo(float t, const Vec2 &center, float radius, float fromRadian, float radianDif)
{
Vec2 p;
@@ -46,10 +46,10 @@ bool CC_STUDIO_DLL isSpriteContainPoint(cocos2d::Sprite *sprite, const cocos2d::
//! motion curve function
cocos2d::Vec2 CC_STUDIO_DLL bezierTo(float t, cocos2d::Vec2 &point1, cocos2d::Vec2 &point2, cocos2d::Vec2 &point3);
cocos2d::Vec2 CC_STUDIO_DLL bezierTo(float t, cocos2d::Vec2 &point1, cocos2d::Vec2 &point2, cocos2d::Vec2 &point3, cocos2d::Vec2 &point4);
cocos2d::Vec2 CC_STUDIO_DLL bezierTo(float t, const cocos2d::Vec2 &point1, const cocos2d::Vec2 &point2, const cocos2d::Vec2 &point3);
cocos2d::Vec2 CC_STUDIO_DLL bezierTo(float t, const cocos2d::Vec2 &point1, const cocos2d::Vec2 &point2, const cocos2d::Vec2 &point3, const cocos2d::Vec2 &point4);
cocos2d::Vec2 CC_STUDIO_DLL circleTo(float t, cocos2d::Vec2 &center, float radius, float fromRadian, float radianDif);
cocos2d::Vec2 CC_STUDIO_DLL circleTo(float t, const cocos2d::Vec2 &center, float radius, float fromRadian, float radianDif);
}
@@ -49,7 +49,7 @@ ControlHuePicker::~ControlHuePicker()
CC_SAFE_RELEASE(_slider);
}
ControlHuePicker* ControlHuePicker::create(Node* target, Vec2 pos)
ControlHuePicker* ControlHuePicker::create(Node* target, const Vec2& pos)
{
ControlHuePicker *pRet = new (std::nothrow) ControlHuePicker();
pRet->initWithTargetAndPos(target, pos);
@@ -58,7 +58,7 @@ ControlHuePicker* ControlHuePicker::create(Node* target, Vec2 pos)
}
bool ControlHuePicker::initWithTargetAndPos(Node* target, Vec2 pos)
bool ControlHuePicker::initWithTargetAndPos(Node* target, const Vec2& pos)
{
if (Control::init())
{
@@ -49,7 +49,7 @@ NS_CC_EXT_BEGIN
class CC_EX_DLL ControlHuePicker : public Control
{
public:
static ControlHuePicker* create(Node* target, Vec2 pos);
static ControlHuePicker* create(Node* target, const Vec2& pos);
/**
* @js ctor
*/
@@ -59,7 +59,7 @@ public:
* @lua NA
*/
virtual ~ControlHuePicker();
virtual bool initWithTargetAndPos(Node* target, Vec2 pos);
virtual bool initWithTargetAndPos(Node* target, const Vec2& pos);
virtual void setEnabled(bool enabled) override;
@@ -56,7 +56,7 @@ ControlSaturationBrightnessPicker::~ControlSaturationBrightnessPicker()
_slider = nullptr;
}
bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, Vec2 pos)
bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, const Vec2& pos)
{
if (Control::init())
{
@@ -77,7 +77,7 @@ bool ControlSaturationBrightnessPicker::initWithTargetAndPos(Node* target, Vec2
}
}
ControlSaturationBrightnessPicker* ControlSaturationBrightnessPicker::create(Node* target, Vec2 pos)
ControlSaturationBrightnessPicker* ControlSaturationBrightnessPicker::create(Node* target, const Vec2& pos)
{
ControlSaturationBrightnessPicker *pRet = new (std::nothrow) ControlSaturationBrightnessPicker();
pRet->initWithTargetAndPos(target, pos);
@@ -74,9 +74,9 @@ public:
* @lua NA
*/
virtual ~ControlSaturationBrightnessPicker();
virtual bool initWithTargetAndPos(Node* target, Vec2 pos);
virtual bool initWithTargetAndPos(Node* target, const Vec2& pos);
static ControlSaturationBrightnessPicker* create(Node* target, Vec2 pos);
static ControlSaturationBrightnessPicker* create(Node* target, const Vec2& pos);
virtual void setEnabled(bool enabled) override;
/**
@@ -26,7 +26,7 @@ THE SOFTWARE.
NS_CC_EXT_BEGIN
Sprite* ControlUtils::addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vec2 pos, Vec2 anchor)
Sprite* ControlUtils::addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, const Vec2& pos, const Vec2& anchor)
{
Sprite *sprite =Sprite::createWithSpriteFrameName(spriteName);
@@ -81,7 +81,7 @@ public:
* @js NA
* @lua NA
*/
static Sprite* addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, Vec2 pos, Vec2 anchor);
static Sprite* addSpriteToTargetWithPosAndAnchor(const char* spriteName, Node * target, const Vec2& pos, const Vec2& anchor);
/**
* @js NA
* @lua NA
@@ -74,7 +74,7 @@ ScrollView::~ScrollView()
}
ScrollView* ScrollView::create(Size size, Node* container/* = nullptr*/)
ScrollView* ScrollView::create(const Size& size, Node* container/* = nullptr*/)
{
ScrollView* pRet = new (std::nothrow) ScrollView();
if (pRet && pRet->initWithViewSize(size, container))
@@ -103,7 +103,7 @@ ScrollView* ScrollView::create()
}
bool ScrollView::initWithViewSize(Size size, Node *container/* = nullptr*/)
bool ScrollView::initWithViewSize(const Size& size, Node *container/* = nullptr*/)
{
if (Layer::init())
{
@@ -326,7 +326,7 @@ void ScrollView::updateTweenAction(float value, const std::string& key)
this->setZoomScale(value);
}
void ScrollView::setViewSize(Size size)
void ScrollView::setViewSize(const Size& size)
{
_viewSize = size;
Layer::setContentSize(size);
@@ -83,7 +83,7 @@ public:
* @param container parent object
* @return autoreleased scroll view object
*/
static ScrollView* create(Size size, Node* container = NULL);
static ScrollView* create(const Size& size, Node* container = NULL);
/**
* Returns an autoreleased scroll view object.
@@ -110,7 +110,7 @@ public:
* @param container parent object
* @return scroll view object
*/
bool initWithViewSize(Size size, Node* container = NULL);
bool initWithViewSize(const Size& size, Node* container = NULL);
/**
* Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView)
@@ -208,7 +208,7 @@ public:
* Hence, this scroll view will use a separate size property.
*/
Size getViewSize() const { return _viewSize; }
void setViewSize(Size size);
void setViewSize(const Size& size);
Node * getContainer();
void setContainer(Node * pContainer);
@@ -50,7 +50,7 @@ TableView* TableView::create(TableViewDataSource* dataSource, Size size, Node *c
return table;
}
bool TableView::initWithViewSize(Size size, Node* container/* = nullptr*/)
bool TableView::initWithViewSize(const Size& size, Node* container/* = nullptr*/)
{
if (ScrollView::initWithViewSize(size,container))
{
@@ -197,7 +197,7 @@ public:
*/
virtual ~TableView();
bool initWithViewSize(Size size, Node* container = NULL);
bool initWithViewSize(const Size& size, Node* container = NULL);
/**
* data source