parent
664b18302b
commit
d6c6533d39
|
|
@ -103,23 +103,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -112,23 +112,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -101,23 +101,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -46,16 +46,16 @@
|
|||
<ClInclude Include="base\TimerManager.h" />
|
||||
<ClInclude Include="base\time.h" />
|
||||
<ClInclude Include="base\window.h" />
|
||||
<ClInclude Include="common\Array.h" />
|
||||
<ClInclude Include="common\closure.hpp" />
|
||||
<ClInclude Include="common\Array.hpp" />
|
||||
<ClInclude Include="common\Closure.hpp" />
|
||||
<ClInclude Include="common\ComPtr.hpp" />
|
||||
<ClInclude Include="common\helper.h" />
|
||||
<ClInclude Include="common\IntrusiveList.hpp" />
|
||||
<ClInclude Include="common\IntrusivePtr.hpp" />
|
||||
<ClInclude Include="common\Json.h" />
|
||||
<ClInclude Include="common\noncopyable.hpp" />
|
||||
<ClInclude Include="common\Json.hpp" />
|
||||
<ClInclude Include="common\Noncopyable.hpp" />
|
||||
<ClInclude Include="common\Singleton.hpp" />
|
||||
<ClInclude Include="common\String.h" />
|
||||
<ClInclude Include="common\String.hpp" />
|
||||
<ClInclude Include="math\constants.hpp" />
|
||||
<ClInclude Include="math\ease.hpp" />
|
||||
<ClInclude Include="math\helper.h" />
|
||||
|
|
@ -214,23 +214,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -108,12 +108,6 @@
|
|||
<ClInclude Include="2d\Transition.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Array.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\closure.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\ComPtr.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -126,15 +120,9 @@
|
|||
<ClInclude Include="common\IntrusivePtr.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\noncopyable.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Singleton.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\String.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Component.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -234,9 +222,6 @@
|
|||
<ClInclude Include="utils\DataUtil.h">
|
||||
<Filter>utils</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Json.h">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="base\Timer.h">
|
||||
<Filter>base</Filter>
|
||||
</ClInclude>
|
||||
|
|
@ -264,6 +249,21 @@
|
|||
<ClInclude Include="2d\GifSprite.h">
|
||||
<Filter>2d</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Closure.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Noncopyable.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\String.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Json.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="common\Array.hpp">
|
||||
<Filter>common</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ui\Button.cpp">
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "Object.h"
|
||||
#include "../common/closure.hpp"
|
||||
#include "../common/Closure.hpp"
|
||||
#include <thread>
|
||||
#include <mutex>
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "../macros.h"
|
||||
#include "../common/noncopyable.hpp"
|
||||
#include "../common/Noncopyable.hpp"
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#pragma once
|
||||
#include "../macros.h"
|
||||
#include "../common/String.h"
|
||||
#include "../common/String.hpp"
|
||||
#include <ostream>
|
||||
#include <istream>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,343 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include <stdexcept>
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
//
|
||||
// Closure is a light weight std::function<>-like class
|
||||
//
|
||||
|
||||
namespace __closure_detail
|
||||
{
|
||||
//
|
||||
// is_callable
|
||||
//
|
||||
|
||||
namespace __callable_detail
|
||||
{
|
||||
template <typename _Ty, typename _Ret, typename... _Args>
|
||||
struct helper
|
||||
{
|
||||
template <typename _Uty> static int test(...);
|
||||
|
||||
template <typename _Uty, _Ret(_Uty::*)(_Args...)> struct class_mem;
|
||||
template <typename _Uty> static char test(class_mem<_Uty, &_Uty::operator()>*);
|
||||
|
||||
template <typename _Uty, _Ret(_Uty::*)(_Args...) const> struct class_const_mem;
|
||||
template <typename _Uty> static char test(class_const_mem<_Uty, &_Uty::operator()>*);
|
||||
|
||||
template<
|
||||
typename _Uty,
|
||||
typename _Uret = typename std::decay<decltype(std::declval<_Uty>().operator()(std::declval<_Args>()...))>::type,
|
||||
typename = typename std::enable_if<std::is_convertible<_Ret, _Uret>::value>::type>
|
||||
static char test(int);
|
||||
|
||||
static constexpr bool value = sizeof(test<_Ty>(0)) == sizeof(char);
|
||||
};
|
||||
}
|
||||
|
||||
template<typename _Ty, typename _Ret, typename... _Args>
|
||||
struct is_callable
|
||||
: public std::bool_constant<__callable_detail::helper<_Ty, _Ret, _Args...>::value>
|
||||
{
|
||||
};
|
||||
|
||||
//
|
||||
// Callable
|
||||
//
|
||||
|
||||
template<typename _Ret, typename... _Args>
|
||||
class Callable
|
||||
{
|
||||
public:
|
||||
virtual ~Callable() {}
|
||||
|
||||
virtual void AddRef() = 0;
|
||||
virtual void Release() = 0;
|
||||
virtual _Ret Invoke(_Args... args) const = 0;
|
||||
};
|
||||
|
||||
template<typename _Ret, typename... _Args>
|
||||
class RefCountCallable
|
||||
: public Callable<_Ret, _Args...>
|
||||
{
|
||||
public:
|
||||
RefCountCallable() : ref_count_(0) {}
|
||||
|
||||
virtual void AddRef() override
|
||||
{
|
||||
++ref_count_;
|
||||
}
|
||||
|
||||
virtual void Release() override
|
||||
{
|
||||
--ref_count_;
|
||||
if (ref_count_ <= 0)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int ref_count_;
|
||||
};
|
||||
|
||||
template<typename _Ty, typename _Ret, typename... _Args>
|
||||
class ProxyCallable
|
||||
: public RefCountCallable<_Ret, _Args...>
|
||||
{
|
||||
public:
|
||||
ProxyCallable(_Ty&& val)
|
||||
: callee_(std::move(val))
|
||||
{
|
||||
}
|
||||
|
||||
virtual _Ret Invoke(_Args... args) const override
|
||||
{
|
||||
return callee_(std::forward<_Args>(args)...);
|
||||
}
|
||||
|
||||
static inline Callable<_Ret, _Args...>* Make(_Ty&& val)
|
||||
{
|
||||
return new (std::nothrow) ProxyCallable<_Ty, _Ret, _Args...>(std::move(val));
|
||||
}
|
||||
|
||||
private:
|
||||
_Ty callee_;
|
||||
};
|
||||
|
||||
template<typename _Ty, typename _Ret, typename... _Args>
|
||||
class ProxyMemCallable
|
||||
: public RefCountCallable<_Ret, _Args...>
|
||||
{
|
||||
public:
|
||||
typedef _Ret(_Ty::* _FuncType)(_Args...);
|
||||
|
||||
virtual _Ret Invoke(_Args... args) const override
|
||||
{
|
||||
return (static_cast<_Ty*>(ptr_)->*func_)(std::forward<_Args>(args)...);
|
||||
}
|
||||
|
||||
static inline Callable<_Ret, _Args...>* Make(void* ptr, _FuncType func)
|
||||
{
|
||||
return new (std::nothrow) ProxyMemCallable<_Ty, _Ret, _Args...>(ptr, func);
|
||||
}
|
||||
|
||||
protected:
|
||||
ProxyMemCallable(void* ptr, _FuncType func)
|
||||
: ptr_(ptr)
|
||||
, func_(func)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void* ptr_;
|
||||
_FuncType func_;
|
||||
};
|
||||
|
||||
template<typename _Ty, typename _Ret, typename... _Args>
|
||||
class ProxyConstMemCallable
|
||||
: public RefCountCallable<_Ret, _Args...>
|
||||
{
|
||||
public:
|
||||
typedef _Ret(_Ty::* _FuncType)(_Args...) const;
|
||||
|
||||
virtual _Ret Invoke(_Args... args) const override
|
||||
{
|
||||
return (static_cast<_Ty*>(ptr_)->*func_)(std::forward<_Args>(args)...);
|
||||
}
|
||||
|
||||
static inline Callable<_Ret, _Args...>* Make(void* ptr, _FuncType func)
|
||||
{
|
||||
return new (std::nothrow) ProxyConstMemCallable<_Ty, _Ret, _Args...>(ptr, func);
|
||||
}
|
||||
|
||||
protected:
|
||||
ProxyConstMemCallable(void* ptr, _FuncType func)
|
||||
: ptr_(ptr)
|
||||
, func_(func)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
void* ptr_;
|
||||
_FuncType func_;
|
||||
};
|
||||
}
|
||||
|
||||
//
|
||||
// exceptions
|
||||
//
|
||||
class bad_function_call : public std::exception
|
||||
{
|
||||
public:
|
||||
bad_function_call() {}
|
||||
|
||||
virtual const char* what() const override
|
||||
{
|
||||
return "bad function call";
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Closure details
|
||||
//
|
||||
template<typename _Ty>
|
||||
class Closure;
|
||||
|
||||
template<typename _Ret, typename... _Args>
|
||||
class Closure<_Ret(_Args...)>
|
||||
{
|
||||
public:
|
||||
Closure()
|
||||
: callable_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Closure(std::nullptr_t)
|
||||
: callable_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Closure(const Closure& rhs)
|
||||
: callable_(rhs.callable_)
|
||||
{
|
||||
if (callable_) callable_->AddRef();
|
||||
}
|
||||
|
||||
Closure(Closure&& rhs)
|
||||
: callable_(rhs.callable_)
|
||||
{
|
||||
rhs.callable_ = nullptr;
|
||||
}
|
||||
|
||||
Closure(_Ret(*func)(_Args...))
|
||||
{
|
||||
callable_ = __closure_detail::ProxyCallable<_Ret(*)(_Args...), _Ret, _Args...>::Make(std::move(func));
|
||||
if (callable_) callable_->AddRef();
|
||||
}
|
||||
|
||||
template<
|
||||
typename _Ty,
|
||||
typename = typename std::enable_if<__closure_detail::is_callable<_Ty, _Ret, _Args...>::value, int>::type>
|
||||
Closure(_Ty val)
|
||||
{
|
||||
callable_ = __closure_detail::ProxyCallable<_Ty, _Ret, _Args...>::Make(std::move(val));
|
||||
if (callable_) callable_->AddRef();
|
||||
}
|
||||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename = typename std::enable_if<std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int>::type>
|
||||
Closure(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
|
||||
{
|
||||
callable_ = __closure_detail::ProxyMemCallable<_Ty, _Ret, _Args...>::Make(ptr, func);
|
||||
if (callable_) callable_->AddRef();
|
||||
}
|
||||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename = typename std::enable_if<std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int>::type>
|
||||
Closure(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
|
||||
{
|
||||
callable_ = __closure_detail::ProxyConstMemCallable<_Ty, _Ret, _Args...>::Make(ptr, func);
|
||||
if (callable_) callable_->AddRef();
|
||||
}
|
||||
|
||||
~Closure()
|
||||
{
|
||||
tidy();
|
||||
}
|
||||
|
||||
inline void swap(const Closure& rhs)
|
||||
{
|
||||
std::swap(callable_, rhs.callable_);
|
||||
}
|
||||
|
||||
inline _Ret operator()(_Args... args) const
|
||||
{
|
||||
if (!callable_)
|
||||
throw bad_function_call();
|
||||
return callable_->Invoke(std::forward<_Args>(args)...);
|
||||
}
|
||||
|
||||
inline operator bool() const
|
||||
{
|
||||
return !!callable_;
|
||||
}
|
||||
|
||||
inline Closure& operator=(const Closure& rhs)
|
||||
{
|
||||
tidy();
|
||||
callable_ = rhs.callable_;
|
||||
if (callable_) callable_->AddRef();
|
||||
return (*this);
|
||||
}
|
||||
|
||||
inline Closure& operator=(Closure&& rhs)
|
||||
{
|
||||
tidy();
|
||||
callable_ = rhs.callable_;
|
||||
rhs.callable_ = nullptr;
|
||||
return (*this);
|
||||
}
|
||||
|
||||
private:
|
||||
inline void tidy()
|
||||
{
|
||||
if (callable_)
|
||||
{
|
||||
callable_->Release();
|
||||
callable_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
__closure_detail::Callable<_Ret, _Args...>* callable_;
|
||||
};
|
||||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename = typename std::enable_if<
|
||||
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int
|
||||
>::type,
|
||||
typename _Ret,
|
||||
typename... _Args>
|
||||
inline Closure<_Ret(_Args...)> MakeClosure(_Uty* ptr, _Ret(_Ty::* func)(_Args...))
|
||||
{
|
||||
return Closure<_Ret(_Args...)>(ptr, func);
|
||||
}
|
||||
|
||||
template<typename _Ty,
|
||||
typename _Uty,
|
||||
typename = typename std::enable_if<
|
||||
std::is_same<_Ty, _Uty>::value || std::is_base_of<_Ty, _Uty>::value, int
|
||||
>::type,
|
||||
typename _Ret,
|
||||
typename... _Args>
|
||||
inline Closure<_Ret(_Args...)> MakeClosure(_Uty* ptr, _Ret(_Ty::* func)(_Args...) const)
|
||||
{
|
||||
return Closure<_Ret(_Args...)>(ptr, func);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (c) 2016-2018 Kiwano - Nomango
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace kiwano
|
||||
{
|
||||
class Noncopyable
|
||||
{
|
||||
protected:
|
||||
Noncopyable() = default;
|
||||
|
||||
private:
|
||||
Noncopyable(const Noncopyable&) = delete;
|
||||
|
||||
Noncopyable& operator=(const Noncopyable&) = delete;
|
||||
};
|
||||
}
|
||||
|
|
@ -19,8 +19,8 @@
|
|||
// THE SOFTWARE.
|
||||
|
||||
#pragma once
|
||||
#include "Array.h"
|
||||
#include "String.h"
|
||||
#include "Array.hpp"
|
||||
#include "String.hpp"
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
|
|
|||
|
|
@ -32,16 +32,16 @@
|
|||
// common
|
||||
//
|
||||
|
||||
#include "common/Array.h"
|
||||
#include "common/String.h"
|
||||
#include "common/Array.hpp"
|
||||
#include "common/String.hpp"
|
||||
#include "common/helper.h"
|
||||
#include "common/closure.hpp"
|
||||
#include "common/Closure.hpp"
|
||||
#include "common/IntrusiveList.hpp"
|
||||
#include "common/IntrusivePtr.hpp"
|
||||
#include "common/ComPtr.hpp"
|
||||
#include "common/noncopyable.hpp"
|
||||
#include "common/Noncopyable.hpp"
|
||||
#include "common/Singleton.hpp"
|
||||
#include "common/Json.h"
|
||||
#include "common/Json.hpp"
|
||||
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
#pragma once
|
||||
#include "../macros.h"
|
||||
#include "../common/helper.h"
|
||||
#include "../common/Json.h"
|
||||
#include "../common/Json.hpp"
|
||||
#include "../base/Resource.h"
|
||||
#include "../2d/include-forwards.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -88,23 +88,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -88,23 +88,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -88,23 +88,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
|
|
@ -88,23 +88,23 @@
|
|||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform)\</IntDir>
|
||||
<OutDir>$(ProjectDir)\output\$(Configuration).$(Platform).$(PlatformToolset)\</OutDir>
|
||||
<IntDir>$(ProjectDir)\build\$(Configuration).$(Platform).$(PlatformToolset)\</IntDir>
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
|
|
|
|||
Loading…
Reference in New Issue