From 99ae4d86d36ce9e111795c588deb794139a3b8c2 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Thu, 19 Dec 2013 12:23:42 -0800 Subject: [PATCH] fixes compiler warnings * converts some `int` to `ssize_t` * adds `const` to `title()` and `subtitle()` --- cocos/editor-support/cocostudio/CCActionNode.cpp | 4 ++-- cocos/gui/UIHelper.cpp | 8 ++++---- cocos/gui/UIInputManager.cpp | 10 +++++----- cocos/gui/UILayout.cpp | 12 ++++++------ cocos/gui/UIListView.cpp | 6 +++--- cocos/gui/UIPageView.cpp | 14 +++++++------- cocos/gui/UIWidget.cpp | 14 +++++++------- .../CocoStudioArmatureTest/ArmatureScene.cpp | 7 ++----- .../CocoStudioArmatureTest/ArmatureScene.h | 10 +++++----- .../Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp | 8 ++++---- samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h | 12 ++++++------ .../TestCpp/Classes/ParticleTest/ParticleTest.h | 2 +- 12 files changed, 52 insertions(+), 55 deletions(-) diff --git a/cocos/editor-support/cocostudio/CCActionNode.cpp b/cocos/editor-support/cocostudio/CCActionNode.cpp index 1947eeb0bf..424b6a1498 100644 --- a/cocos/editor-support/cocostudio/CCActionNode.cpp +++ b/cocos/editor-support/cocostudio/CCActionNode.cpp @@ -399,7 +399,7 @@ int ActionNode::getLastFrameIndex() continue; } bFindFrame = true; - int lastInex = cArray->count() - 1; + ssize_t lastInex = cArray->count() - 1; ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(lastInex)); int iFrameIndex = frame->getFrameIndex(); @@ -428,7 +428,7 @@ bool ActionNode::updateActionToTimeLine(float fTime) { continue; } - int frameCount = cArray->count(); + ssize_t frameCount = cArray->count(); for (int i = 0; i < frameCount; i++) { ActionFrame* frame = (ActionFrame*)(cArray->getObjectAtIndex(i)); diff --git a/cocos/gui/UIHelper.cpp b/cocos/gui/UIHelper.cpp index 5385e84ce8..f71e28a086 100644 --- a/cocos/gui/UIHelper.cpp +++ b/cocos/gui/UIHelper.cpp @@ -37,7 +37,7 @@ UIWidget* UIHelper::seekWidgetByTag(UIWidget* root, int tag) return root; } cocos2d::ccArray* arrayRootChildren = root->getChildren()->data; - int length = arrayRootChildren->num; + ssize_t length = arrayRootChildren->num; for (int i=0;iarr[i]); @@ -61,7 +61,7 @@ UIWidget* UIHelper::seekWidgetByName(UIWidget* root, const char *name) return root; } cocos2d::ccArray* arrayRootChildren = root->getChildren()->data; - int length = arrayRootChildren->num; + ssize_t length = arrayRootChildren->num; for (int i=0;iarr[i]); @@ -81,7 +81,7 @@ UIWidget* UIHelper::seekWidgetByRelativeName(UIWidget *root, const char *name) return nullptr; } cocos2d::ccArray* arrayRootChildren = root->getChildren()->data; - int length = arrayRootChildren->num; + ssize_t length = arrayRootChildren->num; for (int i=0;iarr[i]); @@ -106,7 +106,7 @@ UIWidget* UIHelper::seekActionWidgetByActionTag(UIWidget* root, int tag) return root; } cocos2d::ccArray* arrayRootChildren = root->getChildren()->data; - int length = arrayRootChildren->num; + ssize_t length = arrayRootChildren->num; for (int i=0;iarr[i]); diff --git a/cocos/gui/UIInputManager.cpp b/cocos/gui/UIInputManager.cpp index 04aac38a82..a8cd486f61 100644 --- a/cocos/gui/UIInputManager.cpp +++ b/cocos/gui/UIInputManager.cpp @@ -71,8 +71,8 @@ void UIInputManager::registWidget(UIWidget* widget) bool UIInputManager::checkTouchEvent(UIWidget *root, const Point &touchPoint) { ccArray* arrayRootChildren = root->getChildren()->data; - int length = arrayRootChildren->num; - for (int i=length-1; i >= 0; i--) + ssize_t length = arrayRootChildren->num; + for (ssize_t i=length-1; i >= 0; i--) { UIWidget* widget = (UIWidget*)(arrayRootChildren->arr[i]); if (checkTouchEvent(widget, touchPoint)) @@ -130,7 +130,7 @@ void UIInputManager::update(float dt) } } ccArray* arrayWidget = _checkedDoubleClickWidget->data; - int widgetCount = arrayWidget->num; + ssize_t widgetCount = arrayWidget->num; for (int i=0;iarr[i]); @@ -173,7 +173,7 @@ void UIInputManager::onTouchEnd(Touch* touch) _touchEndedPoint.x = touch->getLocation().x; _touchEndedPoint.y = touch->getLocation().y; ccArray* selectedWidgetArray = _selectedWidgets->data; - int length = selectedWidgetArray->num; + ssize_t length = selectedWidgetArray->num; for (int i=0; iarr[0]); @@ -188,7 +188,7 @@ void UIInputManager::onTouchCancelled(Touch* touch) _touchEndedPoint.x = touch->getLocation().x; _touchEndedPoint.y = touch->getLocation().y; ccArray* selectedWidgetArray = _selectedWidgets->data; - int length = selectedWidgetArray->num; + ssize_t length = selectedWidgetArray->num; for (int i=0; iarr[0]); diff --git a/cocos/gui/UILayout.cpp b/cocos/gui/UILayout.cpp index 68d686eb1e..578667ff93 100644 --- a/cocos/gui/UILayout.cpp +++ b/cocos/gui/UILayout.cpp @@ -128,7 +128,7 @@ void UILayout::onSizeChanged() if (strcmp(getDescription(), "Layout") == 0) { cocos2d::ccArray* arrayChildren = _children->data; - int length = arrayChildren->num; + ssize_t length = arrayChildren->num; for (int i=0; iarr[i]; @@ -452,7 +452,7 @@ void UILayout::setLayoutType(LayoutType type) _layoutType = type; cocos2d::ccArray* layoutChildrenArray = getChildren()->data; - int length = layoutChildrenArray->num; + ssize_t length = layoutChildrenArray->num; for (int i=0; i(layoutChildrenArray->arr[i]); @@ -474,7 +474,7 @@ void UILayout::doLayout() case LAYOUT_LINEAR_VERTICAL: { cocos2d::ccArray* layoutChildrenArray = getChildren()->data; - int length = layoutChildrenArray->num; + ssize_t length = layoutChildrenArray->num; cocos2d::Size layoutSize = getSize(); float topBoundary = layoutSize.height; for (int i=0; idata; - int length = layoutChildrenArray->num; + ssize_t length = layoutChildrenArray->num; cocos2d::Size layoutSize = getSize(); float leftBoundary = 0.0f; for (int i=0; idata; - int length = layoutChildrenArray->num; - int unlayoutChildCount = length; + ssize_t length, unlayoutChildCount; + length = unlayoutChildCount = layoutChildrenArray->num; cocos2d::Size layoutSize = getSize(); for (int i=0; icount(); + ssize_t childrenCount = _items->count(); float totalHeight = _model->getSize().height * childrenCount + (childrenCount - 1) * _itemsMargin; float finalWidth = _size.width; float finalHeight = totalHeight; @@ -101,7 +101,7 @@ void UIListView::updateInnerContainerSize() } case SCROLLVIEW_DIR_HORIZONTAL: { - int childrenCount = _items->count(); + ssize_t childrenCount = _items->count(); float totalWidth = _model->getSize().width * childrenCount + (childrenCount - 1) * _itemsMargin; float finalWidth = totalWidth; float finalHeight = _size.height; @@ -373,7 +373,7 @@ void UIListView::refreshView() return; } cocos2d::ccArray* arrayItems = _items->data; - int length = arrayItems->num; + ssize_t length = arrayItems->num; for (int i=0; iarr[i]); diff --git a/cocos/gui/UIPageView.cpp b/cocos/gui/UIPageView.cpp index c6c51ae381..a3693a9bf4 100644 --- a/cocos/gui/UIPageView.cpp +++ b/cocos/gui/UIPageView.cpp @@ -91,7 +91,7 @@ void UIPageView::addWidgetToPage(UIWidget *widget, int pageIdx, bool forceCreate { return; } - int pageCount = _pages->count(); + ssize_t pageCount = _pages->count(); if (pageIdx < 0 || pageIdx >= pageCount) { if (forceCreate) @@ -168,7 +168,7 @@ void UIPageView::insertPage(UILayout* page, int idx) return; } - int pageCount = _pages->count(); + ssize_t pageCount = _pages->count(); if (idx >= pageCount) { addPage(page); @@ -186,7 +186,7 @@ void UIPageView::insertPage(UILayout* page, int idx) page->setSize(pvSize); } cocos2d::ccArray* arrayPages = _pages->data; - int length = arrayPages->num; + ssize_t length = arrayPages->num; for (int i=(idx+1); i(arrayPages->arr[i]); cocos2d::Point formerPos = behindPage->getPosition(); @@ -286,7 +286,7 @@ void UIPageView::updateChildrenPosition() return; } - int pageCount = _pages->data->num; + ssize_t pageCount = _pages->data->num; if (pageCount <= 0) { _curPageIdx = 0; @@ -411,7 +411,7 @@ void UIPageView::onTouchEnded(const cocos2d::Point &touchPoint) void UIPageView::movePages(float offset) { cocos2d::ccArray* arrayPages = _pages->data; - int length = arrayPages->num; + ssize_t length = arrayPages->num; for (int i = 0; i < length; i++) { UIWidget* child = (UIWidget*)(arrayPages->arr[i]); @@ -502,7 +502,7 @@ void UIPageView::handleReleaseLogic(const cocos2d::Point &touchPoint) if (curPage) { cocos2d::Point curPagePos = curPage->getPosition(); - int pageCount = _pages->count(); + ssize_t pageCount = _pages->count(); float curPageLocation = curPagePos.x; float pageWidth = getSize().width; float boundary = pageWidth/2.0f; @@ -613,7 +613,7 @@ UIWidget* UIPageView::createCloneInstance() void UIPageView::copyClonedWidgetChildren(UIWidget* model) { cocos2d::ccArray* arrayPages = dynamic_cast(model)->getPages()->data; - int length = arrayPages->num; + ssize_t length = arrayPages->num; for (int i=0; iarr[i]); diff --git a/cocos/gui/UIWidget.cpp b/cocos/gui/UIWidget.cpp index 8db95af192..38ea49a08f 100644 --- a/cocos/gui/UIWidget.cpp +++ b/cocos/gui/UIWidget.cpp @@ -149,7 +149,7 @@ bool UIWidget::addChild(UIWidget *child) return false; } child->setParent(this); - int childrenCount = _children->data->num; + ssize_t childrenCount = _children->data->num; if (childrenCount <= 0) { _children->addObject(child); @@ -158,7 +158,7 @@ bool UIWidget::addChild(UIWidget *child) { bool seekSucceed = false; cocos2d::ccArray* arrayChildren = _children->data; - for (int i=childrenCount-1; i>=0; --i) + for (ssize_t i=childrenCount-1; i>=0; --i) { UIWidget* widget = (UIWidget*)(arrayChildren->arr[i]); if (child->getZOrder() >= widget->getZOrder()) @@ -226,7 +226,7 @@ void UIWidget::removeAllChildren() { return; } - int times = _children->data->num; + ssize_t times = _children->data->num; for (int i=0; igetLastObject()); @@ -238,7 +238,7 @@ void UIWidget::reorderChild(UIWidget* child) { CC_SAFE_RETAIN(child); _children->removeObject(child); - int childrenCount = _children->data->num; + ssize_t childrenCount = _children->data->num; if (childrenCount <= 0) { _children->addObject(child); @@ -247,7 +247,7 @@ void UIWidget::reorderChild(UIWidget* child) { bool seekSucceed = false; cocos2d::ccArray* arrayChildren = _children->data; - for (int i=childrenCount-1; i>=0; --i) + for (ssize_t i=childrenCount-1; i>=0; --i) { UIWidget* widget = (UIWidget*)(arrayChildren->arr[i]); if (child->getZOrder() >= widget->getZOrder()) @@ -287,7 +287,7 @@ void UIWidget::setEnabled(bool enabled) dynamic_cast(_renderer)->setEnabled(enabled); } cocos2d::ccArray* arrayChildren = _children->data; - int childrenCount = arrayChildren->num; + ssize_t childrenCount = arrayChildren->num; for (int i = 0; i < childrenCount; i++) { UIWidget* child = dynamic_cast(arrayChildren->arr[i]); @@ -1166,7 +1166,7 @@ UIWidget* UIWidget::createCloneInstance() void UIWidget::copyClonedWidgetChildren(UIWidget* model) { cocos2d::ccArray* arrayWidgetChildren = model->getChildren()->data; - int length = arrayWidgetChildren->num; + ssize_t length = arrayWidgetChildren->num; for (int i=0; iarr[i]); diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp index 059313e410..37f6f0e7ba 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.cpp @@ -1428,9 +1428,6 @@ void TestEasing::updateSubTitle() label->setString(str.c_str()); } - - - void TestChangeAnimationInternal::onEnter() { ArmatureTestLayer::onEnter(); @@ -1451,11 +1448,11 @@ void TestChangeAnimationInternal::onExit() { Director::getInstance()->setAnimationInterval(1/60.0f); } -std::string TestChangeAnimationInternal::title() +std::string TestChangeAnimationInternal::title() const { return "Test change animation internal"; } -std::string TestChangeAnimationInternal::subtitle() +std::string TestChangeAnimationInternal::subtitle() const { return "Touch to change animation internal"; } diff --git a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h index b118589f64..933a1edf59 100644 --- a/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h +++ b/samples/Cpp/TestCpp/Classes/ExtensionsTest/CocoStudioArmatureTest/ArmatureScene.h @@ -362,7 +362,7 @@ public: class TestEasing : public ArmatureTestLayer { public: - virtual void onEnter(); + virtual void onEnter() override; virtual std::string title() const override; virtual std::string subtitle() const override; @@ -376,10 +376,10 @@ public: class TestChangeAnimationInternal : public ArmatureTestLayer { public: - virtual void onEnter(); - virtual void onExit(); - virtual std::string title(); - virtual std::string subtitle(); + virtual void onEnter()override; + virtual void onExit() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; void onTouchesEnded(const std::vector& touches, Event* event); }; diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp index 88639a5399..9467a3cf39 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.cpp @@ -899,12 +899,12 @@ void LayerBug3162A::step(float dt) _layer[0]->setCascadeOpacityEnabled(!_layer[0]->isCascadeOpacityEnabled()); } -std::string LayerBug3162A::title() +std::string LayerBug3162A::title() const { return "Bug 3162 red layer cascade opacity eable/disable"; } -std::string LayerBug3162A::subtitle() +std::string LayerBug3162A::subtitle() const { return "g and b layer opacity is effected/diseffected with r layer"; } @@ -945,12 +945,12 @@ void LayerBug3162B::step(float dt) _layer[0]->setCascadeColorEnabled(!_layer[0]->isCascadeColorEnabled()); } -std::string LayerBug3162B::title() +std::string LayerBug3162B::title() const { return "Bug 3162 bottom layer cascade color eable/disable"; } -std::string LayerBug3162B::subtitle() +std::string LayerBug3162B::subtitle() const { return "u and m layer color is effected/diseffected with b layer"; } diff --git a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h index b1b41c1a20..61a8602200 100644 --- a/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h +++ b/samples/Cpp/TestCpp/Classes/LayerTest/LayerTest.h @@ -178,9 +178,9 @@ class LayerBug3162A : public LayerTest { public: CREATE_FUNC(LayerBug3162A); - virtual void onEnter(); - virtual std::string title(); - virtual std::string subtitle(); + virtual void onEnter() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; void step(float dt); @@ -192,9 +192,9 @@ class LayerBug3162B : public LayerTest { public: CREATE_FUNC(LayerBug3162B); - virtual void onEnter(); - virtual std::string title(); - virtual std::string subtitle(); + virtual void onEnter() override; + virtual std::string title() const override; + virtual std::string subtitle() const override; void step(float dt); diff --git a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h index 86801dc30b..2bf2f530a2 100644 --- a/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h +++ b/samples/Cpp/TestCpp/Classes/ParticleTest/ParticleTest.h @@ -162,7 +162,7 @@ public: _title = file; } virtual void onEnter(); - virtual std::string title() + virtual std::string title() const override { return _title; }