fix compiling errors by using GCC/Clang

This commit is contained in:
Jinhao 2015-07-28 01:53:41 +08:00
parent 396163c1b7
commit 894e7e61c8
11 changed files with 44 additions and 44 deletions

View File

@ -1,5 +1,5 @@
/* /*
* A filesystem Implementation * A ISO C++ filesystem Implementation
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* *
@ -195,7 +195,7 @@ namespace filesystem
directory_iterator():end_(true), handle_(nullptr){} directory_iterator():end_(true), handle_(nullptr){}
directory_iterator(const nana::string& file_path) { _m_prepare(file_path); } 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& const value_type&
operator*() const { return value_; } operator*() const { return value_; }
@ -320,9 +320,9 @@ namespace filesystem
return; return;
} }
} }
value_ = value_type(wfd_.cFileName, value_ = value_type(wfd_.cFileName,
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY, (FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
wfd_.nFileSizeLow); wfd_.nFileSizeLow);
} }
else else
end_ = true; end_ = true;
@ -339,13 +339,13 @@ namespace filesystem
return; return;
} }
} }
nana::string d_name = nana::charset(dnt->d_name);
struct stat fst; struct stat fst;
if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0) if(stat((path_ + "/" + dnt->d_name).c_str(), &fst) == 0)
value_ = value_type(static_cast<nana::string>(nana::charset(wfd_.cFileName)), value_ = value_type(std::move(d_name), (0 != S_ISDIR(fst.st_mode)), fst.st_size);
(FILE_ATTRIBUTE_DIRECTORY & wfd_.dwFileAttributes) == FILE_ATTRIBUTE_DIRECTORY,
wfd_.nFileSizeLow);
else else
value_.m_path = nana::charset(dnt->d_name); value_.m_path = path(std::move(d_name));
} }
else else
end_ = true; end_ = true;
@ -361,7 +361,7 @@ namespace filesystem
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
::FindClose(*handle); ::FindClose(*handle);
#elif defined(NANA_LINUX) #elif defined(NANA_LINUX)
::closedir(*handle); ::closedir(*handle);
#endif #endif
} }
@ -369,7 +369,7 @@ namespace filesystem
} }
}; };
private: private:
bool end_{false}; bool end_{false};
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
WIN32_FIND_DATA wfd_; WIN32_FIND_DATA wfd_;
@ -378,8 +378,7 @@ namespace filesystem
std::string path_; std::string path_;
#endif #endif
std::shared_ptr<find_handle_t> find_ptr_; std::shared_ptr<find_handle_t> find_ptr_;
find_handle_t handle_{nullptr};
find_handle_t handle_{nullptr};
value_type value_; value_type value_;
}; };
@ -406,7 +405,7 @@ namespace filesystem
bool file_attrib(const nana::string& file, attribute&); 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(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; } inline bool is_directory(const directory_entry& d) { return d.attr.directory; }
//bool is_directory(const path& p, error_code& ec) noexcept; //bool is_directory(const path& p, error_code& ec) noexcept;

View File

@ -36,7 +36,7 @@ namespace nana{
core_window_t * root_wd = wd->root_widget; core_window_t * root_wd = wd->root_widget;
auto & nimbus = root_wd->other.attribute.root->effects_edge_nimbus; 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) if (i->window == wd)
{ {

View File

@ -8,8 +8,8 @@ namespace nana{ namespace audio
//class audio_stream //class audio_stream
bool audio_stream::open(const nana::string& file) bool audio_stream::open(const nana::string& file)
{ {
std::string fname{nana::charset(file)};//static_cast<std::string>() std::string fname = nana::charset(file);
fs_.open(fname, std::ios::binary); fs_.open(fname, std::ios::binary);
if(fs_) if(fs_)
{ {
wave_spec::master_riff_chunk riff; wave_spec::master_riff_chunk riff;

View File

@ -1,6 +1,6 @@
/* /*
* A FileSystem Utility Implementation * A ISO C++ FileSystem Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -206,8 +206,8 @@ namespace nana {
struct stat fst; struct stat fst;
if (0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &fst)) if (0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &fst))
{ {
attr.bytes = fst.st_size; attr.size = fst.st_size;
attr.is_directory = (0 != (040000 & fst.st_mode)); attr.directory = (0 != (040000 & fst.st_mode));
attr.modified = *(::localtime(&fst.st_ctime)); attr.modified = *(::localtime(&fst.st_ctime));
return true; return true;
} }
@ -435,7 +435,7 @@ namespace nana {
#elif defined(NANA_LINUX) #elif defined(NANA_LINUX)
const char * s = ::getenv("PWD"); const char * s = ::getenv("PWD");
if (s) if (s)
return nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8); return static_cast<nana::string>(nana::charset(std::string(s, std::strlen(s)), nana::unicode::utf8));
#endif #endif
return nana::string(); return nana::string();
} }

View File

@ -444,7 +444,7 @@ namespace detail
arg.window_handle = reinterpret_cast<window>(wd); arg.window_handle = reinterpret_cast<window>(wd);
arg.button = ::nana::mouse::any_button; arg.button = ::nana::mouse::any_button;
int mask_state == 0; int mask_state = 0;
if (ButtonPress == msg || ButtonRelease == msg) if (ButtonPress == msg || ButtonRelease == msg)
{ {
mask_state = evt.xbutton.state; mask_state = evt.xbutton.state;
@ -483,11 +483,11 @@ namespace detail
arg.pos.y = evt.xcrossing.y - wd->pos_root.y; arg.pos.y = evt.xcrossing.y - wd->pos_root.y;
} }
arg.left_button = (Button1Mask & state); arg.left_button = (Button1Mask & mask_state);
arg.right_button = (Button2Mask & state); arg.right_button = (Button2Mask & mask_state);
arg.mid_button = (Button3Mask & state); arg.mid_button = (Button3Mask & mask_state);
arg.shift = (ShiftMask & state); arg.shift = (ShiftMask & mask_state);
arg.ctrl = (ControlMask & state); arg.ctrl = (ControlMask & mask_state);
} }
@ -1133,7 +1133,7 @@ namespace detail
brock.emit(event_code::key_release, msgwnd, arg, true, &context); 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 brock.delay_restore(2); //Restores while key release
} }
else else

View File

@ -163,7 +163,7 @@ namespace nana
btn_folder_.create(*this); btn_folder_.create(*this);
btn_folder_.caption(STR("&New Folder")); 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)); form fm(this->handle(), API::make_center(*this, 300, 35));
fm.caption(STR("Name the new folder")); fm.caption(STR("Name the new folder"));
@ -179,7 +179,7 @@ namespace nana
button btn_cancel(fm, nana::rectangle(235, 5, 60, 25)); button btn_cancel(fm, nana::rectangle(235, 5, 60, 25));
btn_cancel.caption(STR("Cancel")); 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(); fm.close();
}); });
@ -288,14 +288,14 @@ namespace nana
btn_ok_.create(*this); btn_ok_.create(*this);
btn_ok_.caption(STR("&OK")); 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(); _m_ok();
}); });
btn_cancel_.create(*this); btn_cancel_.create(*this);
btn_cancel_.caption(STR("&Cancel")); 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()); API::close_window(handle());
}); });

View File

@ -48,7 +48,7 @@ namespace nana
{ {
graph.rectangle(rectangle{0, 0, graph.width(), graph.height() - 50}, true, colors::white); graph.rectangle(rectangle{0, 0, graph.width(), graph.height() - 50}, true, colors::white);
if(ico_.empty() == false) 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; unsigned width_pixel = 45;
@ -57,7 +57,7 @@ namespace nana
place_.bind(*this); place_.bind(*this);
yes_.create(*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); _m_click(arg);
}); });
@ -69,7 +69,7 @@ namespace nana
yes_.caption(STR("Yes")); yes_.caption(STR("Yes"));
no_.create(*this); no_.create(*this);
no_.caption(STR("No")); 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); _m_click(arg);
}); });
@ -80,7 +80,7 @@ namespace nana
{ {
cancel_.create(*this); cancel_.create(*this);
cancel_.caption(STR("Cancel")); 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); _m_click(arg);
}); });
@ -303,11 +303,11 @@ namespace nana
nana::paint::pixel_buffer pxbuf(32, 32); nana::paint::pixel_buffer pxbuf(32, 32);
pxbuf.put(reinterpret_cast<const unsigned char*>(rawpx), 32, 32, 32, 4*32, true); pxbuf.put(reinterpret_cast<const unsigned char*>(rawpx), 32, 32, 32, 4*32, true);
ico_.make({32, 32}); 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_) if(arg.window_handle == yes_)
pick_ = (no_.empty() ? msgbox::pick_ok : msgbox::pick_yes); pick_ = (no_.empty() ? msgbox::pick_ok : msgbox::pick_yes);

View File

@ -114,7 +114,7 @@ namespace nana
void load_monitors() void load_monitors()
{ {
displays.clear(); displays.clear();
displays.emplace_back(0, primary_monitor_size()); displays.emplace_back(0, rectangle{primary_monitor_size()});
} }
#endif #endif

View File

@ -165,13 +165,13 @@ namespace nana{
return *this; return *this;
} }
group& group::collocate() group& group::collocate() throw ()
{ {
impl_->place_content.collocate(); impl_->place_content.collocate();
return *this; return *this;
} }
group& group::div(const char* div_str) group& group::div(const char* div_str) throw ()
{ {
if (div_str) if (div_str)
impl_->usr_div_str = div_str; impl_->usr_div_str = div_str;

View File

@ -17,6 +17,7 @@
#include <nana/unicode_bidi.hpp> #include <nana/unicode_bidi.hpp>
#include <numeric> #include <numeric>
#include <cwctype> #include <cwctype>
#include <cstring>
#include <set> #include <set>
#include <algorithm> #include <algorithm>

View File

@ -417,7 +417,7 @@ namespace nana{ namespace paint
#elif defined(NANA_X11) #elif defined(NANA_X11)
try try
{ {
storage_ = std::make_shared<pixel_buffer_storage>(drawable, sz); storage_ = std::make_shared<pixel_buffer_storage>(drawable, nana::rectangle{sz});
storage_->detach(); storage_->detach();
return true; return true;
} }