diff --git a/base/functional.h b/base/functional.h index 46c516f941..05e7d15ae2 100644 --- a/base/functional.h +++ b/base/functional.h @@ -1,24 +1,53 @@ // This file simply includes and applies any necessary compatibility fixes for // strange platforms like iOS. -// Use p as the namespace for placeholders. +// Use placeholder as the namespace for placeholders. #pragma once #include +#ifdef __SYMBIAN32__ +#include +#include +#include +using namespace boost; +#else +#include +using namespace std; +#endif +#include -#if defined(IOS) || defined(MACGNUSTD) +#if defined(__SYMBIAN32__) || defined(IOS) || defined(MACGNUSTD) +#ifndef __SYMBIAN32__ #include +#include +#endif namespace std { - using tr1::bind; +#ifndef __SYMBIAN32__ + using tr1::bind; + using tr1::function; + using tr1::shared_ptr; +#endif + + template + inline shared_ptr make_shared() + { + return shared_ptr(new T()); + } + + template + inline shared_ptr make_shared(Arg1& arg1) + { + return shared_ptr(new T(arg1)); + } } #endif #ifdef __SYMBIAN32__ -#define p +#define placeholder #elif defined(IOS) -#include -namespace p = std::tr1::placeholders; +namespace placeholder = std::tr1::placeholders; #else -namespace p = std::placeholders; +namespace placeholder = std::placeholders; #endif + diff --git a/net/http_client.cpp b/net/http_client.cpp index 9860a89420..7e9128c056 100644 --- a/net/http_client.cpp +++ b/net/http_client.cpp @@ -19,7 +19,6 @@ #include "base/stringutil.h" #include "net/resolve.h" #include "net/url.h" -#include "base/functional.h" // #include "strings/strutil.h" @@ -175,7 +174,7 @@ int Client::POST(const char *resource, const std::string &data, Buffer *output) Download::Download(const std::string &url, const std::string &outfile) : url_(url), outfile_(outfile), progress_(0.0f), failed_(false) { - std::thread th(std::bind(&Download::Do, this)); + std::thread th(bind(&Download::Do, this)); th.detach(); } @@ -211,8 +210,8 @@ void Download::Do() { net::Shutdown(); } -std::shared_ptr Downloader::StartDownload(const std::string &url, const std::string &outfile) { - std::shared_ptr dl(new Download(url, outfile)); +shared_ptr Downloader::StartDownload(const std::string &url, const std::string &outfile) { + shared_ptr dl(new Download(url, outfile)); downloads_.push_back(dl); return dl; } diff --git a/net/http_client.h b/net/http_client.h index 8035d586e7..6b56a846fc 100644 --- a/net/http_client.h +++ b/net/http_client.h @@ -5,6 +5,7 @@ #include "base/basictypes.h" #include "base/buffer.h" #include "thread/thread.h" +#include "base/functional.h" #ifdef _WIN32 #include @@ -98,13 +99,13 @@ private: class Downloader { public: - std::shared_ptr StartDownload(const std::string &url, const std::string &outfile); + shared_ptr StartDownload(const std::string &url, const std::string &outfile); // Drops finished downloads from the list. void Update(); private: - std::vector> downloads_; + std::vector> downloads_; }; diff --git a/thread/threadpool.h b/thread/threadpool.h index d7d427cb49..c4bff05f06 100644 --- a/thread/threadpool.h +++ b/thread/threadpool.h @@ -2,44 +2,7 @@ #include "thread.h" #include "base/mutex.h" - -#include -#ifdef __SYMBIAN32__ -#include -#include -#include -using namespace boost; -#else -#include -using namespace std; -#endif -#include - -#if defined(__SYMBIAN32__) || defined(IOS) || defined(MACGNUSTD) -#ifndef __SYMBIAN32__ -#include -#include -#endif -namespace std { -#ifndef __SYMBIAN32__ - using tr1::bind; - using tr1::function; - using tr1::shared_ptr; -#endif - - template - inline shared_ptr make_shared() - { - return shared_ptr(new T()); - } - - template - inline shared_ptr make_shared(Arg1& arg1) - { - return shared_ptr(new T(arg1)); - } -} -#endif +#include "base/functional.h" // This is the simplest possible worker implementation I can think of // but entirely sufficient for the given purpose. @@ -90,3 +53,4 @@ private: ThreadPool(const ThreadPool& other); // prevent copies void operator =(const WorkerThread &other); }; + diff --git a/ui/view.cpp b/ui/view.cpp index 9de1542e21..db6f6c0fc4 100644 --- a/ui/view.cpp +++ b/ui/view.cpp @@ -49,7 +49,7 @@ void MeasureBySpec(Size sz, float contentWidth, MeasureSpec spec, float *measure } } -void Event::Add(std::function func) { +void Event::Add(function func) { HandlerRegistration reg; reg.func = func; handlers_.push_back(reg); diff --git a/ui/view.h b/ui/view.h index 8fb3539a00..3ae7a30495 100644 --- a/ui/view.h +++ b/ui/view.h @@ -157,14 +157,14 @@ struct EventParams { }; struct HandlerRegistration { - std::function func; + function func; }; class Event { public: Event() : triggered_(false) {} - void Add(std::function func); + void Add(function func); // Call this from input thread or whatever, it doesn't matter void Trigger(EventParams &e); @@ -410,7 +410,7 @@ class CheckBox : public ClickableItem { public: CheckBox(bool *toggle, const std::string &text, const std::string &smallText = "", LayoutParams *layoutParams = 0) : ClickableItem(layoutParams), text_(text), smallText_(smallText) { - OnClick.Add(std::bind(&CheckBox::OnClicked, this, p::_1)); + OnClick.Add(bind(&CheckBox::OnClicked, this, placeholder::_1)); } virtual void Draw(UIContext &dc); @@ -501,4 +501,4 @@ private: void MeasureBySpec(Size sz, float contentWidth, MeasureSpec spec, float *measured); -} // namespace \ No newline at end of file +} // namespace