From 894e7e61c8e49d2b6c762d8cbe80d817fea28aaf Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 28 Jul 2015 01:53:41 +0800 Subject: [PATCH] fix compiling errors by using GCC/Clang --- include/nana/filesystem/filesystem.hpp | 27 ++++++++++---------- include/nana/gui/detail/effects_renderer.hpp | 2 +- source/audio/detail/audio_stream.cpp | 6 ++--- source/filesystem/filesystem.cpp | 10 ++++---- source/gui/detail/linux_X11/bedrock.cpp | 14 +++++----- source/gui/filebox.cpp | 8 +++--- source/gui/msgbox.cpp | 12 ++++----- source/gui/screen.cpp | 2 +- source/gui/widgets/group.cpp | 4 +-- source/gui/widgets/skeletons/text_editor.cpp | 1 + source/paint/pixel_buffer.cpp | 2 +- 11 files changed, 44 insertions(+), 44 deletions(-) diff --git a/include/nana/filesystem/filesystem.hpp b/include/nana/filesystem/filesystem.hpp index f1229fb1..5c4c01b8 100644 --- a/include/nana/filesystem/filesystem.hpp +++ b/include/nana/filesystem/filesystem.hpp @@ -1,5 +1,5 @@ /* - * A filesystem Implementation + * A ISO C++ filesystem Implementation * Nana C++ Library(http://www.nanapro.org) * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * @@ -195,7 +195,7 @@ namespace filesystem directory_iterator():end_(true), handle_(nullptr){} directory_iterator(const nana::string& file_path) { _m_prepare(file_path); } - //directory_iterator(const path& file_path) { _m_prepare(file_path.filename()); } + directory_iterator(const path& file_path) { _m_prepare(file_path.filename()); } const value_type& operator*() const { return value_; } @@ -320,9 +320,9 @@ namespace filesystem return; } } - value_ = value_type(wfd_.cFileName, - (FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY, - wfd_.nFileSizeLow); + value_ = value_type(wfd_.cFileName, + (FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY, + wfd_.nFileSizeLow); } else end_ = true; @@ -339,13 +339,13 @@ namespace filesystem return; } } + + nana::string d_name = nana::charset(dnt->d_name); struct stat fst; if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0) - value_ = value_type(static_cast(nana::charset(wfd_.cFileName)), - (FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY, - wfd_.nFileSizeLow); + value_ = value_type(std::move(d_name), (0 != S_ISDIR(fst.st_mode)), fst.st_size); else - value_.m_path = nana::charset(dnt->d_name); + value_.m_path = path(std::move(d_name)); } else end_ = true; @@ -361,7 +361,7 @@ namespace filesystem { #if defined(NANA_WINDOWS) ::FindClose(*handle); - #elif defined(NANA_LINUX) + #elif defined(NANA_LINUX) ::closedir(*handle); #endif } @@ -369,7 +369,7 @@ namespace filesystem } }; private: - bool end_{false}; + bool end_{false}; #if defined(NANA_WINDOWS) WIN32_FIND_DATA wfd_; @@ -378,8 +378,7 @@ namespace filesystem std::string path_; #endif std::shared_ptr find_ptr_; - - find_handle_t handle_{nullptr}; + find_handle_t handle_{nullptr}; value_type value_; }; @@ -406,7 +405,7 @@ namespace filesystem bool file_attrib(const nana::string& file, attribute&); inline bool is_directory(file_status s) { return s.type() == file_type::directory ;} - inline bool is_directory(const path& p) { return directory_iterator{ p }->attr.directory; }//works?? + inline bool is_directory(const path& p) { return directory_iterator(p)->attr.directory; }//works?? inline bool is_directory(const directory_entry& d) { return d.attr.directory; } //bool is_directory(const path& p, error_code& ec) noexcept; diff --git a/include/nana/gui/detail/effects_renderer.hpp b/include/nana/gui/detail/effects_renderer.hpp index 2c4522a3..ea2b810e 100644 --- a/include/nana/gui/detail/effects_renderer.hpp +++ b/include/nana/gui/detail/effects_renderer.hpp @@ -36,7 +36,7 @@ namespace nana{ core_window_t * root_wd = wd->root_widget; auto & nimbus = root_wd->other.attribute.root->effects_edge_nimbus; - for (auto i = nimbus.cbegin(); i != nimbus.cend(); ++i) + for (auto i = nimbus.begin(); i != nimbus.end(); ++i) { if (i->window == wd) { diff --git a/source/audio/detail/audio_stream.cpp b/source/audio/detail/audio_stream.cpp index 998b85bf..f5d4fdc1 100644 --- a/source/audio/detail/audio_stream.cpp +++ b/source/audio/detail/audio_stream.cpp @@ -8,8 +8,8 @@ namespace nana{ namespace audio //class audio_stream bool audio_stream::open(const nana::string& file) { - std::string fname{nana::charset(file)};//static_cast() - fs_.open(fname, std::ios::binary); + std::string fname = nana::charset(file); + fs_.open(fname, std::ios::binary); if(fs_) { wave_spec::master_riff_chunk riff; @@ -89,4 +89,4 @@ namespace nana{ namespace audio }//end namespace detail }//end namespace audio -}//end namespace nana \ No newline at end of file +}//end namespace nana diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index 4c6e8d22..51d70ff4 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -1,6 +1,6 @@ /* - * A FileSystem Utility Implementation - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * A ISO C++ FileSystem Implementation + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -206,8 +206,8 @@ namespace nana { struct stat fst; if (0 == ::stat(static_cast(nana::charset(file)).c_str(), &fst)) { - attr.bytes = fst.st_size; - attr.is_directory = (0 != (040000 & fst.st_mode)); + attr.size = fst.st_size; + attr.directory = (0 != (040000 & fst.st_mode)); attr.modified = *(::localtime(&fst.st_ctime)); return true; } @@ -435,7 +435,7 @@ namespace nana { #elif defined(NANA_LINUX) const char * s = ::getenv("PWD"); if (s) - return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8); + return static_cast(nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8)); #endif return nana::string(); } diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 6e31cbea..56ae68d0 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -444,7 +444,7 @@ namespace detail arg.window_handle = reinterpret_cast(wd); arg.button = ::nana::mouse::any_button; - int mask_state == 0; + int mask_state = 0; if (ButtonPress == msg || ButtonRelease == msg) { mask_state = evt.xbutton.state; @@ -483,11 +483,11 @@ namespace detail arg.pos.y = evt.xcrossing.y - wd->pos_root.y; } - arg.left_button = (Button1Mask & state); - arg.right_button = (Button2Mask & state); - arg.mid_button = (Button3Mask & state); - arg.shift = (ShiftMask & state); - arg.ctrl = (ControlMask & state); + arg.left_button = (Button1Mask & mask_state); + arg.right_button = (Button2Mask & mask_state); + arg.mid_button = (Button3Mask & mask_state); + arg.shift = (ShiftMask & mask_state); + arg.ctrl = (ControlMask & mask_state); } @@ -1133,7 +1133,7 @@ namespace detail brock.emit(event_code::key_release, msgwnd, arg, true, &context); } - if (context.platform.keychar < keyboard::os_arrow_left || keyboard::os_arrow_down < wParam) + if (context.platform.keychar < keyboard::os_arrow_left || keyboard::os_arrow_down < context.platform.keychar) brock.delay_restore(2); //Restores while key release } else diff --git a/source/gui/filebox.cpp b/source/gui/filebox.cpp index 14ab8b67..612af33e 100644 --- a/source/gui/filebox.cpp +++ b/source/gui/filebox.cpp @@ -163,7 +163,7 @@ namespace nana btn_folder_.create(*this); btn_folder_.caption(STR("&New Folder")); - btn_folder_.events().click.connect_unignorable([this](const arg_mouse&) + btn_folder_.events().click.connect_unignorable([this](const arg_click&) { form fm(this->handle(), API::make_center(*this, 300, 35)); fm.caption(STR("Name the new folder")); @@ -179,7 +179,7 @@ namespace nana button btn_cancel(fm, nana::rectangle(235, 5, 60, 25)); btn_cancel.caption(STR("Cancel")); - btn_cancel.events().click.connect_unignorable([&fm](const arg_mouse&) + btn_cancel.events().click.connect_unignorable([&fm](const arg_click&) { fm.close(); }); @@ -288,14 +288,14 @@ namespace nana btn_ok_.create(*this); btn_ok_.caption(STR("&OK")); - btn_ok_.events().click.connect_unignorable([this](const arg_mouse&) + btn_ok_.events().click.connect_unignorable([this](const arg_click&) { _m_ok(); }); btn_cancel_.create(*this); btn_cancel_.caption(STR("&Cancel")); - btn_cancel_.events().click.connect_unignorable([this](const arg_mouse&) + btn_cancel_.events().click.connect_unignorable([this](const arg_click&) { API::close_window(handle()); }); diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index de471567..c514f124 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -48,7 +48,7 @@ namespace nana { graph.rectangle(rectangle{0, 0, graph.width(), graph.height() - 50}, true, colors::white); if(ico_.empty() == false) - ico_.stretch(ico_.size(), graph, rectangle{12, 25, 32, 32}); + ico_.stretch(rectangle{ico_.size()}, graph, rectangle{12, 25, 32, 32}); }); unsigned width_pixel = 45; @@ -57,7 +57,7 @@ namespace nana place_.bind(*this); yes_.create(*this); - yes_.events().click.connect_unignorable([this](const arg_mouse& arg) + yes_.events().click.connect_unignorable([this](const arg_click& arg) { _m_click(arg); }); @@ -69,7 +69,7 @@ namespace nana yes_.caption(STR("Yes")); no_.create(*this); no_.caption(STR("No")); - no_.events().click.connect_unignorable([this](const arg_mouse& arg) + no_.events().click.connect_unignorable([this](const arg_click& arg) { _m_click(arg); }); @@ -80,7 +80,7 @@ namespace nana { cancel_.create(*this); cancel_.caption(STR("Cancel")); - cancel_.events().click.connect_unignorable([this](const arg_mouse& arg) + cancel_.events().click.connect_unignorable([this](const arg_click& arg) { _m_click(arg); }); @@ -303,11 +303,11 @@ namespace nana nana::paint::pixel_buffer pxbuf(32, 32); pxbuf.put(reinterpret_cast(rawpx), 32, 32, 32, 4*32, true); ico_.make({32, 32}); - pxbuf.paste(ico_.handle(), 0, 0); + pxbuf.paste(ico_.handle(), {}); } } - void _m_click(const arg_mouse& arg) + void _m_click(const arg_click& arg) { if(arg.window_handle == yes_) pick_ = (no_.empty() ? msgbox::pick_ok : msgbox::pick_yes); diff --git a/source/gui/screen.cpp b/source/gui/screen.cpp index f94b0dfa..1a0be98b 100644 --- a/source/gui/screen.cpp +++ b/source/gui/screen.cpp @@ -114,7 +114,7 @@ namespace nana void load_monitors() { displays.clear(); - displays.emplace_back(0, primary_monitor_size()); + displays.emplace_back(0, rectangle{primary_monitor_size()}); } #endif diff --git a/source/gui/widgets/group.cpp b/source/gui/widgets/group.cpp index 95e9428d..7380ff11 100644 --- a/source/gui/widgets/group.cpp +++ b/source/gui/widgets/group.cpp @@ -165,13 +165,13 @@ namespace nana{ return *this; } - group& group::collocate() + group& group::collocate() throw () { impl_->place_content.collocate(); return *this; } - group& group::div(const char* div_str) + group& group::div(const char* div_str) throw () { if (div_str) impl_->usr_div_str = div_str; diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index c23e4a73..68e35b05 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include diff --git a/source/paint/pixel_buffer.cpp b/source/paint/pixel_buffer.cpp index e89c3a0e..3c3a47c9 100644 --- a/source/paint/pixel_buffer.cpp +++ b/source/paint/pixel_buffer.cpp @@ -417,7 +417,7 @@ namespace nana{ namespace paint #elif defined(NANA_X11) try { - storage_ = std::make_shared(drawable, sz); + storage_ = std::make_shared(drawable, nana::rectangle{sz}); storage_->detach(); return true; }