fixed #1649: Changed return type to const reference for member variable access.

This commit is contained in:
James Chen 2013-01-14 15:51:53 +08:00
parent 0fd16e7b31
commit 6565fa92cc
24 changed files with 49 additions and 47 deletions

View File

@ -142,7 +142,7 @@ void CCAtlasNode::draw(void)
// CCAtlasNode - RGBA protocol // CCAtlasNode - RGBA protocol
ccColor3B CCAtlasNode:: getColor() const ccColor3B& CCAtlasNode:: getColor()
{ {
if(m_bIsOpacityModifyRGB) if(m_bIsOpacityModifyRGB)
{ {

View File

@ -270,7 +270,7 @@ void CCNode::setScaleY(float newScaleY)
} }
/// position getter /// position getter
CCPoint CCNode::getPosition() const CCPoint& CCNode::getPosition()
{ {
return m_obPosition; return m_obPosition;
} }
@ -368,13 +368,13 @@ void CCNode::setVisible(bool var)
m_bVisible = var; m_bVisible = var;
} }
CCPoint CCNode::getAnchorPointInPoints() const CCPoint& CCNode::getAnchorPointInPoints()
{ {
return m_obAnchorPointInPoints; return m_obAnchorPointInPoints;
} }
/// anchorPoint getter /// anchorPoint getter
CCPoint CCNode::getAnchorPoint() const CCPoint& CCNode::getAnchorPoint()
{ {
return m_obAnchorPoint; return m_obAnchorPoint;
} }
@ -390,7 +390,7 @@ void CCNode::setAnchorPoint(const CCPoint& point)
} }
/// contentSize getter /// contentSize getter
CCSize CCNode::getContentSize() const CCSize& CCNode::getContentSize()
{ {
return m_obContentSize; return m_obContentSize;
} }

View File

@ -238,7 +238,7 @@ public:
virtual void setScaleY(float fScaleY); virtual void setScaleY(float fScaleY);
/** Position (x,y) of the node in OpenGL coordinates. (0,0) is the left-bottom corner. */ /** Position (x,y) of the node in OpenGL coordinates. (0,0) is the left-bottom corner. */
virtual CCPoint getPosition(); virtual const CCPoint& getPosition();
virtual void setPosition(const CCPoint &position); virtual void setPosition(const CCPoint &position);
/** The X skew angle of the node in degrees. /** The X skew angle of the node in degrees.
@ -320,20 +320,20 @@ public:
The default anchorPoint is (0.5,0.5), so it starts in the center of the node. The default anchorPoint is (0.5,0.5), so it starts in the center of the node.
@since v0.8 @since v0.8
*/ */
virtual CCPoint getAnchorPoint(); virtual const CCPoint& getAnchorPoint();
virtual void setAnchorPoint(const CCPoint &anchorPoint); virtual void setAnchorPoint(const CCPoint &anchorPoint);
/** The anchorPoint in absolute pixels. /** The anchorPoint in absolute pixels.
Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead Since v0.8 you can only read it. If you wish to modify it, use anchorPoint instead
*/ */
virtual CCPoint getAnchorPointInPoints(); virtual const CCPoint& getAnchorPointInPoints();
/** The untransformed size of the node. /** The untransformed size of the node.
The contentSize remains the same no matter the node is scaled or rotated. The contentSize remains the same no matter the node is scaled or rotated.
All nodes has a size. Layer and Scene has the same size of the screen. All nodes has a size. Layer and Scene has the same size of the screen.
@since v0.8 @since v0.8
*/ */
virtual CCSize getContentSize(); virtual const CCSize& getContentSize();
virtual void setContentSize(const CCSize &contentSize); virtual void setContentSize(const CCSize &contentSize);
virtual bool isVisible(); virtual bool isVisible();

View File

@ -44,7 +44,7 @@ public:
/** returns the color /** returns the color
@since v0.8 @since v0.8
*/ */
virtual ccColor3B getColor(void) = 0; virtual const ccColor3B& getColor(void) = 0;
// returns the opacity // returns the opacity
virtual GLubyte getOpacity(void) = 0; virtual GLubyte getOpacity(void) = 0;

View File

@ -1069,7 +1069,7 @@ void CCLabelBMFont::setColor(const ccColor3B& var)
} }
} }
ccColor3B CCLabelBMFont::getColor() const ccColor3B& CCLabelBMFont::getColor()
{ {
return m_tColor; return m_tColor;
} }

View File

@ -517,7 +517,7 @@ void CCLayerColor::setOpacity(GLubyte var)
} }
/// color getter /// color getter
ccColor3B CCLayerColor::getColor() const ccColor3B& CCLayerColor::getColor()
{ {
return m_tColor; return m_tColor;
} }
@ -807,7 +807,7 @@ void CCLayerGradient::updateColor()
m_pSquareColors[3].a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c)); m_pSquareColors[3].a = E.a + (S.a - E.a) * ((c - u.x - u.y) / (2.0f * c));
} }
ccColor3B CCLayerGradient::getStartColor() const ccColor3B& CCLayerGradient::getStartColor()
{ {
return m_tColor; return m_tColor;
} }
@ -823,7 +823,7 @@ void CCLayerGradient::setEndColor(const ccColor3B& color)
updateColor(); updateColor();
} }
ccColor3B CCLayerGradient::getEndColor() const ccColor3B& CCLayerGradient::getEndColor()
{ {
return m_endColor; return m_endColor;
} }
@ -856,7 +856,7 @@ void CCLayerGradient::setVector(const CCPoint& var)
updateColor(); updateColor();
} }
CCPoint CCLayerGradient::getVector() const CCPoint& CCLayerGradient::getVector()
{ {
return m_AlongVector; return m_AlongVector;
} }

View File

@ -630,7 +630,7 @@ void CCMenu::setColor(const ccColor3B& var)
} }
} }
ccColor3B CCMenu::getColor(void) const ccColor3B& CCMenu::getColor(void)
{ {
return m_tColor; return m_tColor;
} }

View File

@ -153,7 +153,7 @@ void CCMenuItem::setTarget(CCObject *rec, SEL_MenuHandler selector)
//CCMenuItemLabel //CCMenuItemLabel
// //
ccColor3B CCMenuItemLabel::getDisabledColor() const ccColor3B& CCMenuItemLabel::getDisabledColor()
{ {
return m_tDisabledColor; return m_tDisabledColor;
} }
@ -296,7 +296,7 @@ void CCMenuItemLabel::setColor(const ccColor3B& color)
dynamic_cast<CCRGBAProtocol*>(m_pLabel)->setColor(color); dynamic_cast<CCRGBAProtocol*>(m_pLabel)->setColor(color);
} }
ccColor3B CCMenuItemLabel::getColor() const ccColor3B& CCMenuItemLabel::getColor()
{ {
return dynamic_cast<CCRGBAProtocol*>(m_pLabel)->getColor(); return dynamic_cast<CCRGBAProtocol*>(m_pLabel)->getColor();
} }
@ -538,7 +538,7 @@ GLubyte CCMenuItemSprite::getOpacity()
return dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->getOpacity(); return dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->getOpacity();
} }
ccColor3B CCMenuItemSprite::getColor() const ccColor3B& CCMenuItemSprite::getColor()
{ {
return dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->getColor(); return dynamic_cast<CCRGBAProtocol*>(m_pNormalImage)->getColor();
} }
@ -918,7 +918,7 @@ void CCMenuItemToggle::setOpacity(GLubyte opacity)
} }
} }
ccColor3B CCMenuItemToggle::getColor() const ccColor3B& CCMenuItemToggle::getColor()
{ {
return m_tColor; return m_tColor;
} }

View File

@ -143,7 +143,7 @@ public:
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);
virtual GLubyte getOpacity(); virtual GLubyte getOpacity();
virtual void setColor(const ccColor3B& color); virtual void setColor(const ccColor3B& color);
virtual ccColor3B getColor(); virtual const ccColor3B& getColor();
virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);}
virtual bool isOpacityModifyRGB(void) { return false;} virtual bool isOpacityModifyRGB(void) { return false;}
@ -255,7 +255,7 @@ public:
bool initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); bool initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector);
// super methods // super methods
virtual void setColor(const ccColor3B& color); virtual void setColor(const ccColor3B& color);
virtual ccColor3B getColor(); virtual const ccColor3B& getColor();
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);
virtual GLubyte getOpacity(); virtual GLubyte getOpacity();

View File

@ -185,7 +185,7 @@ void CCMotionStreak::setColor(const ccColor3B& color)
m_tColor = color; m_tColor = color;
} }
ccColor3B CCMotionStreak::getColor(void) const ccColor3B& CCMotionStreak::getColor(void)
{ {
return m_tColor; return m_tColor;
} }

View File

@ -73,7 +73,7 @@ public:
virtual void setBlendFunc(ccBlendFunc blendFunc); virtual void setBlendFunc(ccBlendFunc blendFunc);
virtual ccBlendFunc getBlendFunc(void); virtual ccBlendFunc getBlendFunc(void);
virtual void setColor(const ccColor3B& color); virtual void setColor(const ccColor3B& color);
virtual ccColor3B getColor(void); virtual const ccColor3B& getColor(void);
virtual GLubyte getOpacity(void); virtual GLubyte getOpacity(void);
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);
virtual void setOpacityModifyRGB(bool bValue); virtual void setOpacityModifyRGB(bool bValue);

View File

@ -155,7 +155,7 @@ void CCProgressTimer::setColor(const ccColor3B& color)
updateColor(); updateColor();
} }
ccColor3B CCProgressTimer::getColor(void) const ccColor3B& CCProgressTimer::getColor(void)
{ {
return m_pSprite->getColor(); return m_pSprite->getColor();
} }

View File

@ -77,7 +77,7 @@ public:
void setAnchorPoint(CCPoint anchorPoint); void setAnchorPoint(CCPoint anchorPoint);
virtual void setColor(const ccColor3B& color); virtual void setColor(const ccColor3B& color);
virtual ccColor3B getColor(void); virtual const ccColor3B& getColor(void);
virtual GLubyte getOpacity(void); virtual GLubyte getOpacity(void);
virtual void setOpacity(GLubyte opacity); virtual void setOpacity(GLubyte opacity);
virtual void setOpacityModifyRGB(bool bValue); virtual void setOpacityModifyRGB(bool bValue);

View File

@ -1019,7 +1019,7 @@ void CCParticleSystem::setDuration(float var)
m_fDuration = var; m_fDuration = var;
} }
CCPoint CCParticleSystem::getSourcePosition() const CCPoint& CCParticleSystem::getSourcePosition()
{ {
return m_tSourcePosition; return m_tSourcePosition;
} }
@ -1029,7 +1029,7 @@ void CCParticleSystem::setSourcePosition(const CCPoint& var)
m_tSourcePosition = var; m_tSourcePosition = var;
} }
CCPoint CCParticleSystem::getPosVar() const CCPoint& CCParticleSystem::getPosVar()
{ {
return m_tPosVar; return m_tPosVar;
} }
@ -1119,7 +1119,7 @@ void CCParticleSystem::setEndSizeVar(float var)
m_fEndSizeVar = var; m_fEndSizeVar = var;
} }
ccColor4F CCParticleSystem::getStartColor() const ccColor4F& CCParticleSystem::getStartColor()
{ {
return m_tStartColor; return m_tStartColor;
} }
@ -1129,7 +1129,7 @@ void CCParticleSystem::setStartColor(const ccColor4F& var)
m_tStartColor = var; m_tStartColor = var;
} }
ccColor4F CCParticleSystem::getStartColorVar() const ccColor4F& CCParticleSystem::getStartColorVar()
{ {
return m_tStartColorVar; return m_tStartColorVar;
} }
@ -1139,7 +1139,7 @@ void CCParticleSystem::setStartColorVar(const ccColor4F& var)
m_tStartColorVar = var; m_tStartColorVar = var;
} }
ccColor4F CCParticleSystem::getEndColor() const ccColor4F& CCParticleSystem::getEndColor()
{ {
return m_tEndColor; return m_tEndColor;
} }
@ -1149,7 +1149,7 @@ void CCParticleSystem::setEndColor(const ccColor4F& var)
m_tEndColor = var; m_tEndColor = var;
} }
ccColor4F CCParticleSystem::getEndColorVar() const ccColor4F& CCParticleSystem::getEndColorVar()
{ {
return m_tEndColorVar; return m_tEndColorVar;
} }

View File

@ -142,7 +142,7 @@ public: virtual void set##funName(varType var);
#define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)\ #define CC_PROPERTY_PASS_BY_REF(varType, varName, funName)\
protected: varType varName;\ protected: varType varName;\
public: virtual varType get##funName(void);\ public: virtual const varType& get##funName(void);\
public: virtual void set##funName(const varType& var); public: virtual void set##funName(const varType& var);
/** CC_SYNTHESIZE_READONLY is used to declare a protected variable. /** CC_SYNTHESIZE_READONLY is used to declare a protected variable.
@ -179,7 +179,7 @@ public: virtual void set##funName(varType var){ varName = var; }
#define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)\ #define CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)\
protected: varType varName;\ protected: varType varName;\
public: virtual varType get##funName(void) const { return varName; }\ public: virtual const varType& get##funName(void) const { return varName; }\
public: virtual void set##funName(const varType& var){ varName = var; } public: virtual void set##funName(const varType& var){ varName = var; }
#define CC_SYNTHESIZE_RETAIN(varType, varName, funName) \ #define CC_SYNTHESIZE_RETAIN(varType, varName, funName) \

View File

@ -931,7 +931,7 @@ void CCSprite::setOpacity(GLubyte opacity)
updateColor(); updateColor();
} }
ccColor3B CCSprite::getColor(void) const ccColor3B& CCSprite::getColor(void)
{ {
if (m_bOpacityModifyRGB) if (m_bOpacityModifyRGB)
{ {

View File

@ -270,7 +270,7 @@ void CCTextFieldTTF::draw()
setColor(color); setColor(color);
} }
ccColor3B CCTextFieldTTF::getColorSpaceHolder() const ccColor3B& CCTextFieldTTF::getColorSpaceHolder()
{ {
return m_ColorSpaceHolder; return m_ColorSpaceHolder;
} }

View File

@ -127,7 +127,7 @@ public:
CC_SYNTHESIZE(CCTextFieldDelegate *, m_pDelegate, Delegate); CC_SYNTHESIZE(CCTextFieldDelegate *, m_pDelegate, Delegate);
CC_SYNTHESIZE_READONLY(int, m_nCharCount, CharCount); CC_SYNTHESIZE_READONLY(int, m_nCharCount, CharCount);
virtual ccColor3B getColorSpaceHolder(); virtual const ccColor3B& getColorSpaceHolder();
virtual void setColorSpaceHolder(const ccColor3B& color); virtual void setColorSpaceHolder(const ccColor3B& color);
// input text property // input text property

View File

@ -239,7 +239,7 @@ void CCControl::setColor(const ccColor3B& color)
} }
} }
ccColor3B CCControl::getColor(void) const ccColor3B& CCControl::getColor(void)
{ {
return m_tColor; return m_tColor;
} }

View File

@ -618,7 +618,7 @@ void CCScale9Sprite::setColor(const ccColor3B& color3)
} }
} }
ccColor3B CCScale9Sprite::getColor(void) const ccColor3B& CCScale9Sprite::getColor(void)
{ {
return m_tColor; return m_tColor;
} }

View File

@ -432,7 +432,7 @@ void CCScrollView::performedAnimatedScroll(float dt)
} }
CCSize CCScrollView::getContentSize() const CCSize& CCScrollView::getContentSize()
{ {
return m_pContainer->getContentSize(); return m_pContainer->getContentSize();
} }

View File

@ -187,7 +187,7 @@ public:
virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent); virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);
virtual void setContentSize(const CCSize & size); virtual void setContentSize(const CCSize & size);
virtual CCSize getContentSize(); virtual const CCSize& getContentSize();
void updateInset(); void updateInset();
/** /**

View File

@ -177,10 +177,11 @@ void CCPhysicsSprite::setCPBody(cpBody *pBody)
} }
// Override the setters and getters to always reflect the body's properties. // Override the setters and getters to always reflect the body's properties.
CCPoint CCPhysicsSprite::getPosition() const CCPoint& CCPhysicsSprite::getPosition()
{ {
cpVect cpPos = cpBodyGetPos(m_pCPBody); cpVect cpPos = cpBodyGetPos(m_pCPBody);
return ccp(cpPos.x, cpPos.y); m_obPosition = ccp(cpPos.x, cpPos.y);
return m_obPosition;
} }
void CCPhysicsSprite::setPosition(const CCPoint &pos) void CCPhysicsSprite::setPosition(const CCPoint &pos)
@ -245,13 +246,14 @@ void CCPhysicsSprite::setPTMRatio(float fRatio)
} }
// Override the setters and getters to always reflect the body's properties. // Override the setters and getters to always reflect the body's properties.
CCPoint CCPhysicsSprite::getPosition() const CCPoint& CCPhysicsSprite::getPosition()
{ {
b2Vec2 pos = m_pB2Body->GetPosition(); b2Vec2 pos = m_pB2Body->GetPosition();
float x = pos.x * m_fPTMRatio; float x = pos.x * m_fPTMRatio;
float y = pos.y * m_fPTMRatio; float y = pos.y * m_fPTMRatio;
return ccp(x,y); m_obPosition = ccp(x,y);
return m_obPosition;
} }
void CCPhysicsSprite::setPosition(const CCPoint &pos) void CCPhysicsSprite::setPosition(const CCPoint &pos)

View File

@ -102,7 +102,7 @@ public:
#if CC_ENABLE_CHIPMUNK_INTEGRATION #if CC_ENABLE_CHIPMUNK_INTEGRATION
virtual CCPoint getPosition(); virtual const CCPoint& getPosition();
virtual void setPosition(const CCPoint &position); virtual void setPosition(const CCPoint &position);
virtual float getRotation(); virtual float getRotation();
virtual void setRotation(float fRotation); virtual void setRotation(float fRotation);
@ -114,7 +114,7 @@ public:
#elif CC_ENABLE_BOX2D_INTEGRATION #elif CC_ENABLE_BOX2D_INTEGRATION
virtual CCPoint getPosition(); virtual const CCPoint& getPosition();
virtual void setPosition(const CCPoint &position); virtual void setPosition(const CCPoint &position);
virtual float getRotation(); virtual float getRotation();
virtual void setRotation(float fRotation); virtual void setRotation(float fRotation);