code refactoring. 19/88019/2
authorHermet Park <hermet@hermet.pe.kr>
Mon, 12 Sep 2016 12:49:18 +0000 (21:49 +0900)
committerHermet Park <hermet@hermet.pe.kr>
Mon, 12 Sep 2016 12:51:14 +0000 (21:51 +0900)
use auto specifier for simplifying code.

Change-Id: I5d4c84d1c352762fc212fd1a557103d3f48cfc1e

12 files changed:
src/examples/efl/cpp/main.cpp
src/examples/efl/cpp/page11.h
src/examples/efl/cpp/page12.h
src/lib/efl/UiBaseKeyListener.cpp
src/lib/efl/UiBaseView.cpp
src/lib/efl/UiBaseViewmgr.cpp
src/lib/efl/mobile/UiStandardView.cpp
src/lib/efl/mobile/UiView.cpp
src/lib/efl/mobile/c/ui_view.cpp
src/lib/interface/UiIfaceApp.cpp
src/lib/interface/UiIfaceView.cpp
src/lib/interface/UiIfaceViewmgr.cpp

index c84b0bd25d273d8396a5596d3258a4f49f1059bd..272935fa00dc14c39a40d290dffe26eeea6bfc64 100644 (file)
@@ -61,7 +61,7 @@ protected:
 int main(int argc, char *argv[])
 {
        try {
-               SampleApp app = SampleApp();
+               SampleApp app;
                app.run(argc, argv);
        } catch (UiException& ex)
        {
index 535160f467b42a6144b950a9b8d66c0c0c1e680a..487c7822d7ba308808587a8399ea52561ffaec97 100644 (file)
@@ -21,7 +21,7 @@
  */
 static void _ctxpopupItemSelectCb(void *data, Evas_Object *obj, void *event_info)
 {
-       Elm_Object_Item *it = static_cast<Elm_Object_Item *>(event_info);
+       auto it = static_cast<Elm_Object_Item *>(event_info);
        LOGE("Item (%s) is selected", elm_object_item_text_get(it));
        elm_ctxpopup_dismiss(obj);
 }
index af54b5eeb2734ca76dd41ab839ba747da67d5e90..3aad58e6d76609073c28a71eca54c896d3f3d316 100644 (file)
@@ -23,7 +23,7 @@
 static void _popupDismissedCb(void *data, Evas_Object *obj, void *event_info)
 {
        evas_object_smart_callback_del(obj, "dismissed", _popupDismissedCb);
-       UiPopup *popup = static_cast<UiPopup *>(data);
+       auto popup = static_cast<UiPopup *>(data);
        delete (popup);
 }
 
index 983211f8ae65840bffa84b73915b3f9ed3aca3ca..3b1a4990addaf2560c2bfd1a9b677271559586ec 100644 (file)
@@ -59,11 +59,11 @@ UiBaseKeyListenerImpl::UiBaseKeyListenerImpl(UiBaseKeyListener *keyListener, UiB
 void UiBaseKeyListenerImpl::eventProc(Evas_Event_Key_Down *ev)
 {
        //Only if view manager is activated
-       UiBaseViewmgr *viewmgr = this->keyListener->getViewmgr();
+       auto viewmgr = this->keyListener->getViewmgr();
        if (!viewmgr->isActivated()) return;
 
        //Get Top View
-       UiBaseView *view = viewmgr->getLastView();
+       auto view = viewmgr->getLastView();
        if (!view) return;
 
        this->keyListener->extendEventProc(view, ev);
index 20be99afee6bc9239e1b792e49786e4d4b601cb3..998a00e9b9652d1d97011e63b35ebf2fdf78dc19 100644 (file)
@@ -33,7 +33,7 @@ class UiBaseViewImpl;
 
 static void _contentDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       UiBaseView *view = static_cast<UiBaseView *>(data);
+       auto view = static_cast<UiBaseView *>(data);
        view->unsetContent();
 }
 
@@ -76,7 +76,7 @@ Evas_Object *UiBaseView::unsetContent()
 
 Evas_Object *UiBaseView::getBase()
 {
-       UiBaseViewmgr *viewmgr = UI_BASE_VIEWMGR;
+       auto viewmgr = UI_BASE_VIEWMGR;
 
        if (!viewmgr) {
                return NULL;
@@ -87,7 +87,7 @@ Evas_Object *UiBaseView::getBase()
 
 Evas_Object *UiBaseView ::getParent()
 {
-       UiBaseViewmgr *viewmgr = UI_BASE_VIEWMGR;
+       auto viewmgr = UI_BASE_VIEWMGR;
 
        if (!viewmgr) {
                LOGE("Failed to get a viewmgr");
@@ -103,7 +103,7 @@ void UiBaseView::setIndicator(UiViewIndicator indicator)
 
        UiIfaceView::setIndicator(indicator);
 
-       UiBaseViewmgr *viewmgr = UI_BASE_VIEWMGR;
+       auto viewmgr = UI_BASE_VIEWMGR;
 
        if (!viewmgr) {
                LOGE("Failed to get a viewmgr");
@@ -123,7 +123,7 @@ bool UiBaseView::setAvailableRotations(const int *rotations, unsigned int count)
                return false;
        }
 
-       UiBaseViewmgr *viewmgr = UI_BASE_VIEWMGR;
+       auto viewmgr = UI_BASE_VIEWMGR;
 
        if (!viewmgr) {
                LOGE("Failed to get a viewmgr");
@@ -157,7 +157,7 @@ void UiBaseView::setEventBlock(bool block)
 
 int UiBaseView::getDegree()
 {
-       UiBaseViewmgr *viewmgr = UI_BASE_VIEWMGR;
+       auto viewmgr = UI_BASE_VIEWMGR;
 
        if (!viewmgr) {
                LOGE("Failed to get a viewmgr");
index b1fb4c8f94d3308a57cdcf7ce0dbbf07ebdce46a..0d86e2edf6589055838974b8962c4f59092accf8 100644 (file)
@@ -97,7 +97,7 @@ bool UiBaseViewmgrImpl::_createBaseLayout(Elm_Scroller *scroller, const char *st
        elm_layout_signal_callback_add(layout, "push,finished", "viewmgr",
                        [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void
                        {
-                               UiBaseViewmgr *viewmgr = static_cast<UiBaseViewmgr *>(data);
+                               auto viewmgr = static_cast<UiBaseViewmgr *>(data);
                                UiBaseView *pview = viewmgr->getView(viewmgr->getViewCount() - 2);
                                UiBaseView *view = viewmgr->getLastView();
                                if (pview) viewmgr->pushViewFinished(pview);
@@ -109,7 +109,7 @@ bool UiBaseViewmgrImpl::_createBaseLayout(Elm_Scroller *scroller, const char *st
        elm_layout_signal_callback_add(layout, "pop,finished", "viewmgr",
                        [](void *data, Evas_Object *obj, const char *emission, const char *source) -> void
                        {
-                               UiBaseViewmgr *viewmgr = static_cast<UiBaseViewmgr *>(data);
+                               auto viewmgr = static_cast<UiBaseViewmgr *>(data);
                                UiBaseView *pview = viewmgr->getView(viewmgr->getViewCount() - 2);
                                UiBaseView *view = viewmgr->getLastView();
                                if (pview) viewmgr->popViewFinished(pview);
@@ -161,7 +161,7 @@ void UiBaseViewmgrImpl::_activateTopView()
        Evas_Object *pcontent = elm_object_part_content_unset(this->getBase(), "content");
        if (pcontent) evas_object_hide(pcontent);
 
-       UiBaseView *view = this->_viewmgr->getLastView();
+       auto view = this->_viewmgr->getLastView();
 
        //In case of UiBaseView, it doesn't have any base form. It uses viewmgr base instead.
        Evas_Object *content;
@@ -272,8 +272,7 @@ UiBaseViewmgrImpl::UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, const char *pkg, Ui
        //FIXME: Make a method? to set available rotation degree.
        //Set window rotation
        if (elm_win_wm_rotation_supported_get(this->_win)) {
-               int rots[4] =
-               { 0, 90, 180, 270 };
+               int rots[4] = { 0, 90, 180, 270 };
                elm_win_wm_rotation_available_rotations_set(this->_win, (const int *) (&rots), 4);
        }
        evas_object_smart_callback_add(this->_win, "wm,rotation,changed",
@@ -281,7 +280,7 @@ UiBaseViewmgrImpl::UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, const char *pkg, Ui
                        {
                                int rot = elm_win_rotation_get(obj);
 
-                               UiBaseViewmgr *viewmgr = static_cast<UiBaseViewmgr *>(data);
+                               auto viewmgr = static_cast<UiBaseViewmgr *>(data);
                                UiBaseView *view = viewmgr->getLastView();
                                view->onRotate(rot);
 
@@ -294,7 +293,7 @@ UiBaseViewmgrImpl::UiBaseViewmgrImpl(UiBaseViewmgr *viewmgr, const char *pkg, Ui
        evas_object_smart_callback_add(this->_win, "delete,request",
                        [](void *data, Evas_Object *obj, void *event_info) -> void
                        {
-                               UiBaseViewmgr *viewmgr = static_cast<UiBaseViewmgr*>(data);
+                               auto viewmgr = static_cast<UiBaseViewmgr*>(data);
                                delete(viewmgr);
                        },
                        this->_viewmgr);
@@ -358,8 +357,8 @@ bool UiBaseViewmgrImpl::deactivate()
 
 bool UiBaseViewmgrImpl::popView()
 {
-       UiBaseView *pview = this->_viewmgr->getView(this->_viewmgr->getViewCount() - 2);
-       UiBaseView *view = this->_viewmgr->getLastView();
+       auto pview = this->_viewmgr->getView(this->_viewmgr->getViewCount() - 2);
+       auto view = this->_viewmgr->getLastView();
 
        //In case, if view doesn't have any transition effects.
        if (!strcmp(view->getTransitionStyle(), "none")) {
index 5aedd37491b6e54d4d4848280cee75be0d8601e7..751e9cb7b90da2e41e57a330d98f66bb7f9a1d4f 100644 (file)
@@ -83,21 +83,21 @@ public:
 
 static void _titleLeftBtnDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       UiStandardView *view = static_cast<UiStandardView *>(data);
+       auto view = static_cast<UiStandardView *>(data);
 
        view->unsetTitleLeftBtn();
 }
 
 static void _titleRightBtnDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       UiStandardView *view = static_cast<UiStandardView *>(data);
+       auto view = static_cast<UiStandardView *>(data);
 
        view->unsetTitleRightBtn();
 }
 
 static void _toolbarDelCb(void *data, Evas *e, Evas_Object *obj, void *event_info)
 {
-       UiStandardView *view = static_cast<UiStandardView *>(data);
+       auto view = static_cast<UiStandardView *>(data);
 
        view->unsetToolbar();
 }
@@ -136,7 +136,7 @@ bool UiStandardViewImpl::_createLayout()
        }
 
        //Set software back key, if it's needed
-       UiViewmgr *viewmgr = UI_VIEWMGR;
+       auto viewmgr = UI_VIEWMGR;
        if (viewmgr && viewmgr->needSoftKey()) {
                Elm_Button *prevBtn = elm_button_add(layout);
 
@@ -145,7 +145,7 @@ bool UiStandardViewImpl::_createLayout()
                } else {
                        evas_object_smart_callback_add(prevBtn, "clicked", [](void *data, Evas_Object *obj, void *event_info) -> void
                        {
-                               UiViewmgr *viewmgr = static_cast<UiViewmgr *>(data);
+                               auto viewmgr = static_cast<UiViewmgr *>(data);
                                viewmgr->popView();
                        }, viewmgr);
 
index 621e1fff84f591b25a064aa86a814d1e1785f732..4c7d17f4a0b72b1a1196db96f97245863a4b5c17 100644 (file)
@@ -77,7 +77,7 @@ void UiViewImpl::_disconnectPopup(UiPopup *popup)
 bool UiViewImpl::_deactivatePopup(bool topOne)
 {
        for (auto it = this->_popupList.rbegin(); it != this->_popupList.rend(); it++) {
-               UiPopup *popup = *it;
+               auto popup = *it;
                if (!popup->isActivated()) continue;
                popup->onBack();
                //deactivate only one top one? or all popups?
index 9ec890ea745656cb84595bcffcf0593f6fcb5d67..ee994c42e0eb60e3b87fae2a36d056c47d35f5ad 100644 (file)
@@ -149,7 +149,7 @@ EAPI bool ui_view_set_lifecycle_callbacks(ui_view *view, ui_view_lifecycle_callb
 {
        if (!validate_view(view)) return false;
 
-       ui_common_view_capi *event_attr = dynamic_cast<ui_common_view_capi *>(view);
+       auto event_attr = dynamic_cast<ui_common_view_capi *>(view);
        if (!event_attr)
        {
                LOGE("This view(%p) doesn't allow lifecycle callback?!");
@@ -169,7 +169,7 @@ EAPI bool ui_view_set_event_callbacks(ui_view *view, ui_view_event_callback_s *e
 {
        if (!validate_view(view)) return false;
 
-       ui_common_view_capi *event_attr = dynamic_cast<ui_common_view_capi *>(view);
+       auto event_attr = dynamic_cast<ui_common_view_capi *>(view);
        if (!event_attr)
        {
                LOGE("This view(%p) doesn't allow event callback?!");
index db0b08d93815427042e28d47fca34832097b0561..5d257c5adf7792f03ecf4d001b241b08ca7d2fca 100644 (file)
@@ -58,61 +58,61 @@ public:
 
 static bool appCreate(void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        return app->onCreate();
 }
 
 static void appTerminate(void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onTerminate();
 }
 
 static void appPause(void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onPause();
 }
 
 static void appResume(void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onResume();
 }
 
 static void appControl(app_control_s *app_control, void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onControl(app_control);
 }
 
 static void uiAppLangChanged(app_event_info_h event_info, void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onLangChanged(event_info);
 }
 
 static void uiAppOrientChanged(app_event_info_h event_info, void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onOrientChanged(event_info);
 }
 
 static void uiAppRegionChanged(app_event_info_h event_info, void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onRegionChanged(event_info);
 }
 
 static void uiAppLowBattery(app_event_info_h event_info, void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onLowBattery(event_info);
 }
 
 static void uiAppLowMemory(app_event_info_h event_info, void *data)
 {
-       UiIfaceAppImpl *app = static_cast<UiIfaceAppImpl *>(data);
+       auto app = static_cast<UiIfaceAppImpl *>(data);
        app->onLowMemory(event_info);
 }
 
@@ -241,13 +241,13 @@ void UiIfaceApp::onLangChanged(app_event_info_h event_info)
 
 void UiIfaceApp::onLowMemory(app_event_info_h event_info)
 {
-       UiIfaceView *view = this->_impl->viewmgr->getLastView();
+       auto view = this->_impl->viewmgr->getLastView();
        view->onLowMemory();
 }
 
 void UiIfaceApp::onLowBattery(app_event_info_h event_info)
 {
-       UiIfaceView *view = this->_impl->viewmgr->getLastView();
+       auto view = this->_impl->viewmgr->getLastView();
        view->onLowBattery();
 }
 
@@ -260,7 +260,7 @@ void UiIfaceApp::onRegionChanged(app_event_info_h event_info)
                return;
        }
 
-       UiIfaceView *view = this->_impl->viewmgr->getLastView();
+       auto view = this->_impl->viewmgr->getLastView();
        view->onRegionChanged(region);
 }
 
index 58bed2b48e34fff2c19fad573892d6557470f0f4..8a433e2cea83449ea40cc77b4a4166b490bfb00e 100644 (file)
@@ -184,7 +184,7 @@ bool UiIfaceViewImpl::setAvailableRotations(const int *rotations, unsigned int c
                return false;
        }
 
-       for (unsigned int i = 0; i < count; i++) {
+       for (auto i = 0; i < count; i++) {
                this->_rotations[i] = rotations[i];
        }
 
@@ -239,7 +239,7 @@ UiViewIndicator UiIfaceViewImpl::getIndicator()
 
 void UiIfaceViewImpl::onBack()
 {
-       UiIfaceViewmgr *viewmgr = this->_viewmgr;
+       auto viewmgr = this->_viewmgr;
        if (!viewmgr) {
                LOGE("Failed to get a viewmgr, view =%p", this);
                return;
index 27ac7153091a50dd0900efcda36ba6b2a8b9ed39..ea4a715ab0429eafa8b6e0d519d07f9120612994 100644 (file)
@@ -124,7 +124,7 @@ bool UiIfaceViewmgrImpl::connectView(UiIfaceView *view)
        int nameLen = strlen(view->getName());
        const char *name = view->getName();
 
-       for (UiIfaceView *v : this->_viewList) {
+       for (auto v : this->_viewList) {
                const char *viewName = v->getName();
                if (!viewName) continue;
                int viewNameLen = strlen(viewName);
@@ -154,7 +154,7 @@ void UiIfaceViewmgrImpl::setEventBlock(UiIfaceView *view, bool block)
 
 bool UiIfaceViewmgrImpl::pushViewFinished(UiIfaceView *view)
 {
-       UiIfaceView *last = this->_viewList.back();
+       auto last = this->_viewList.back();
 
        //The previous view has been pushed. This should be unload.
        if (last != view) {
@@ -171,7 +171,7 @@ bool UiIfaceViewmgrImpl::pushViewFinished(UiIfaceView *view)
 
 bool UiIfaceViewmgrImpl::popViewFinished(UiIfaceView *view)
 {
-       UiIfaceView *last = this->_viewList.back();
+       auto last = this->_viewList.back();
 
        //This view has been popped. It should be destroyed.
        if (last == view) {
@@ -198,7 +198,7 @@ UiIfaceViewmgrImpl::~UiIfaceViewmgrImpl()
        //Terminate views
        this->_destroying = EINA_TRUE;
        for (auto ritr = this->_viewList.rbegin(); ritr != this->_viewList.rend(); ritr++) {
-               UiIfaceView *view = *ritr;
+               auto view = *ritr;
                if ((view->getState() != UI_VIEW_STATE_DEACTIVATE) &&
                        (view->getState() != UI_VIEW_STATE_UNLOAD)) {
                        view->onDeactivate();
@@ -256,7 +256,7 @@ UiIfaceView *UiIfaceViewmgrImpl::pushView(UiIfaceView *view)
 bool UiIfaceViewmgrImpl::popView()
 {
        //last page to be popped.
-       UiIfaceView*view = this->_viewList.back();
+       auto view = this->_viewList.back();
 
        if (view->getEventBlock()) {
                return false;
@@ -287,7 +287,7 @@ bool UiIfaceViewmgrImpl::popView()
        //Make this getter method? or define instance?
        //previous page is to be an active page.
        auto nx = prev(this->_viewList.end(), 2);
-       UiIfaceView*pview = *nx;
+       auto pview = *nx;
        pview->onLoad();
        pview->onDeactivate();
        this->setEventBlock(pview, true);
@@ -350,7 +350,7 @@ int UiIfaceViewmgrImpl::getViewIndex(const UiIfaceView *view)
 {
        int idx = 0;
 
-       for (UiIfaceView *v : this->_viewList) {
+       for (auto v : this->_viewList) {
                if (view == v) return idx;
                ++idx;
        }
@@ -371,7 +371,7 @@ bool UiIfaceViewmgrImpl::activate()
        if (this->getViewCount() == 0) return false;
        this->_activated = true;
 
-       UiIfaceView *view = this->getLastView();
+       auto view = this->getLastView();
 
        view->onLoad();
        view->onDeactivate();
@@ -385,7 +385,7 @@ bool UiIfaceViewmgrImpl::deactivate()
        if (!this->_activated) return false;
        this->_activated = false;
 
-       UiIfaceView *view = this->getLastView();
+       auto view = this->getLastView();
 
        if ((view->getState() != UI_VIEW_STATE_DEACTIVATE) &&
                (view->getState() != UI_VIEW_STATE_UNLOAD)) {
@@ -403,7 +403,7 @@ UiIfaceView *UiIfaceViewmgrImpl::getView(const char *name)
        if (!name) return NULL;
        int nameLen = strlen(name);
 
-       for (UiIfaceView *v : this->_viewList) {
+       for (auto v : this->_viewList) {
                const char *viewName = v->getName();
                if (!viewName) continue;
                int viewNameLen = strlen(viewName);