remove: SystemException

This commit is contained in:
Nomango 2018-09-10 20:55:20 +08:00
parent f26f385854
commit 6f489a77fe
17 changed files with 101 additions and 187 deletions

View File

@ -14,8 +14,8 @@ namespace e2d
// 基础动作 // 基础动作
class Action : class Action
public Ref : public Ref
{ {
friend class ActionManager; friend class ActionManager;
friend class Loop; friend class Loop;
@ -90,8 +90,8 @@ namespace e2d
// 持续动作 // 持续动作
class FiniteTimeAction : class FiniteTimeAction
public Action : public Action
{ {
public: public:
// 创建特定时长的持续动作 // 创建特定时长的持续动作
@ -121,8 +121,8 @@ namespace e2d
// 相对位移动作 // 相对位移动作
class MoveBy : class MoveBy
public FiniteTimeAction : public FiniteTimeAction
{ {
public: public:
explicit MoveBy( explicit MoveBy(
@ -153,8 +153,8 @@ namespace e2d
// 位移动作 // 位移动作
class MoveTo : class MoveTo
public MoveBy : public MoveBy
{ {
public: public:
explicit MoveTo( explicit MoveTo(
@ -184,8 +184,8 @@ namespace e2d
// 相对跳跃动作 // 相对跳跃动作
class JumpBy : class JumpBy
public FiniteTimeAction : public FiniteTimeAction
{ {
public: public:
explicit JumpBy( explicit JumpBy(
@ -220,8 +220,8 @@ namespace e2d
// 跳跃动作 // 跳跃动作
class JumpTo : class JumpTo
public JumpBy : public JumpBy
{ {
public: public:
explicit JumpTo( explicit JumpTo(
@ -253,8 +253,8 @@ namespace e2d
// 相对缩放动作 // 相对缩放动作
class ScaleBy : class ScaleBy
public FiniteTimeAction : public FiniteTimeAction
{ {
public: public:
explicit ScaleBy( explicit ScaleBy(
@ -292,8 +292,8 @@ namespace e2d
// 缩放动作 // 缩放动作
class ScaleTo : class ScaleTo
public ScaleBy : public ScaleBy
{ {
public: public:
explicit ScaleTo( explicit ScaleTo(
@ -330,8 +330,8 @@ namespace e2d
// 透明度相对渐变动作 // 透明度相对渐变动作
class OpacityBy : class OpacityBy
public FiniteTimeAction : public FiniteTimeAction
{ {
public: public:
explicit OpacityBy( explicit OpacityBy(
@ -361,8 +361,8 @@ namespace e2d
// 透明度渐变动作 // 透明度渐变动作
class OpacityTo : class OpacityTo
public OpacityBy : public OpacityBy
{ {
public: public:
explicit OpacityTo( explicit OpacityTo(
@ -392,8 +392,8 @@ namespace e2d
// 淡入动作 // 淡入动作
class FadeIn : class FadeIn
public OpacityTo : public OpacityTo
{ {
public: public:
// 创建淡入动作 // 创建淡入动作
@ -407,8 +407,8 @@ namespace e2d
// 淡出动作 // 淡出动作
class FadeOut : class FadeOut
public OpacityTo : public OpacityTo
{ {
public: public:
// 创建淡出动作 // 创建淡出动作
@ -422,8 +422,8 @@ namespace e2d
// 相对旋转动作 // 相对旋转动作
class RotateBy : class RotateBy
public FiniteTimeAction : public FiniteTimeAction
{ {
public: public:
explicit RotateBy( explicit RotateBy(
@ -453,8 +453,8 @@ namespace e2d
// 旋转动作 // 旋转动作
class RotateTo : class RotateTo
public RotateBy : public RotateBy
{ {
public: public:
explicit RotateTo( explicit RotateTo(
@ -484,8 +484,8 @@ namespace e2d
// 延时动作 // 延时动作
class Delay : class Delay
public Action : public Action
{ {
public: public:
explicit Delay( explicit Delay(
@ -520,8 +520,8 @@ namespace e2d
// 循环动作 // 循环动作
class Loop : class Loop
public Action : public Action
{ {
public: public:
explicit Loop( explicit Loop(
@ -560,8 +560,8 @@ namespace e2d
// 回调动作 // 回调动作
class Callback : class Callback
public Action : public Action
{ {
public: public:
explicit Callback( explicit Callback(
@ -589,8 +589,8 @@ namespace e2d
// 顺序动作 // 顺序动作
class Sequence : class Sequence
public Action : public Action
{ {
public: public:
typedef std::vector<Action*> Actions; typedef std::vector<Action*> Actions;
@ -641,8 +641,8 @@ namespace e2d
// 同步动作 // 同步动作
class Spawn : class Spawn
public Action : public Action
{ {
public: public:
typedef std::vector<Action*> Actions; typedef std::vector<Action*> Actions;
@ -692,8 +692,8 @@ namespace e2d
// 帧动画 // 帧动画
class Animation : class Animation
public Ref : public Ref
{ {
public: public:
typedef std::vector<Image*> Images; typedef std::vector<Image*> Images;
@ -752,8 +752,8 @@ namespace e2d
// 精灵动作 // 精灵动作
class Animate : class Animate
public Action : public Action
{ {
public: public:
Animate(); Animate();

View File

@ -5,8 +5,8 @@ namespace e2d
{ {
class Button : class Button
public Node : public Node
{ {
public: public:
Button(); Button();
@ -113,8 +113,8 @@ namespace e2d
// 꽉데 // 꽉데
class Menu : class Menu
public Node : public Node
{ {
public: public:
Menu(); Menu();

View File

@ -137,36 +137,22 @@ namespace e2d
}; };
// 异常 // 运行时异常
class Exception class RuntimeException
: public std::exception
{ {
public: public:
Exception() E2D_NOEXCEPT; RuntimeException() E2D_NOEXCEPT
: exception("unknown runtime exception", 1)
{
}
explicit Exception(const char * message) E2D_NOEXCEPT; explicit RuntimeException(
char const* const message
Exception(Exception const& other) E2D_NOEXCEPT; ) E2D_NOEXCEPT
: exception(message, 1)
virtual ~Exception() E2D_NOEXCEPT; {
}
Exception& operator=(Exception const& other) E2D_NOEXCEPT;
// 获取异常信息
virtual const char * GetMsg() const;
private:
const char * message_;
};
// 系统异常
class SystemException
: public Exception
{
public:
SystemException() E2D_NOEXCEPT;
explicit SystemException(const char * message) E2D_NOEXCEPT;
}; };
@ -177,7 +163,7 @@ namespace e2d
// 在此处设置断点以捕获 D2D API 异常. // 在此处设置断点以捕获 D2D API 异常.
static char s_str[64] = {}; static char s_str[64] = {};
sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(hr)); sprintf_s(s_str, "Failure with HRESULT of %08X", static_cast<unsigned int>(hr));
throw SystemException(s_str); throw RuntimeException(s_str);
} }
} }

View File

@ -8,8 +8,8 @@ namespace e2d
// 图片 // 图片
class Image : class Image
public Ref : public Ref
{ {
public: public:
Image(); Image();
@ -111,9 +111,9 @@ namespace e2d
class Node; class Node;
// 场景 // 场景
class Scene : class Scene
public Ref, : public Ref
public EventTarget , public EventTarget
{ {
public: public:
Scene(); Scene();
@ -306,8 +306,8 @@ namespace e2d
// 定时任务 // 定时任务
class Task : class Task
public Ref : public Ref
{ {
friend class Node; friend class Node;
@ -406,9 +406,9 @@ namespace e2d
class Action; class Action;
// 节点 // 节点
class Node : class Node
public Ref, : public Ref
public EventTarget , public EventTarget
{ {
friend class Scene; friend class Scene;
friend class Collider; friend class Collider;
@ -875,9 +875,9 @@ namespace e2d
// 精灵 // 精灵
class Sprite : class Sprite
public Node, : public Node
public Drawable , public Drawable
{ {
public: public:
Sprite(); Sprite();
@ -941,9 +941,9 @@ namespace e2d
// 文本 // 文本
class Text : class Text
public Node, : public Node
public Drawable , public Drawable
{ {
public: public:
// 文本对齐方式 // 文本对齐方式
@ -1159,9 +1159,9 @@ namespace e2d
// 画布 // 画布
class Canvas : class Canvas
public Node, : public Node
public Drawable , public Drawable
{ {
public: public:
Canvas( Canvas(

View File

@ -50,8 +50,8 @@ namespace e2d
// 稜있 // 稜있
class Music : class Music
public Ref : public Ref
{ {
public: public:
Music(); Music();

View File

@ -9,8 +9,8 @@ namespace e2d
class Scene; class Scene;
// 场景过渡 // 场景过渡
class Transition : class Transition
public Ref : public Ref
{ {
friend class Game; friend class Game;
@ -58,8 +58,8 @@ namespace e2d
// 淡入淡出过渡 // 淡入淡出过渡
class FadeTransition : class FadeTransition
public Transition : public Transition
{ {
public: public:
explicit FadeTransition( explicit FadeTransition(
@ -78,8 +78,8 @@ namespace e2d
// 渐变过渡 // 渐变过渡
class EmergeTransition : class EmergeTransition
public Transition : public Transition
{ {
public: public:
explicit EmergeTransition( explicit EmergeTransition(
@ -97,8 +97,8 @@ namespace e2d
// 盒状过渡 // 盒状过渡
class BoxTransition : class BoxTransition
public Transition : public Transition
{ {
public: public:
explicit BoxTransition( explicit BoxTransition(
@ -116,8 +116,8 @@ namespace e2d
// 移入过渡 // 移入过渡
class MoveTransition : class MoveTransition
public Transition : public Transition
{ {
public: public:
explicit MoveTransition( explicit MoveTransition(

View File

@ -468,15 +468,15 @@ namespace e2d
); );
template<typename Func> template<typename Func>
Function(Func func) : func_(func) {} Function(Func func)
: func_(func)
{
}
template<typename Func, typename Object> template<typename Func, typename Object>
Function( Function(Func&& func, Object&& obj)
Func&& func, /* 对象的成员函数 */ : func_(std::bind(func, obj))
Object&& obj /* 对象指针 */
)
{ {
func_ = std::bind(func, obj);
} }
void operator() (void) const; void operator() (void) const;

View File

@ -1,37 +0,0 @@
#include "..\e2dimpl.h"
e2d::Exception::Exception() E2D_NOEXCEPT
: message_()
{
}
e2d::Exception::Exception(const char * message) E2D_NOEXCEPT
: message_(message)
{
}
e2d::Exception::Exception(Exception const& other) E2D_NOEXCEPT
: message_(other.message_)
{
}
e2d::Exception& e2d::Exception::operator=(Exception const& other) E2D_NOEXCEPT
{
if (this == &other)
{
return *this;
}
message_ = other.message_;
return *this;
}
e2d::Exception::~Exception() E2D_NOEXCEPT
{
}
const char * e2d::Exception::GetMsg() const
{
return message_;
}

View File

@ -1,11 +0,0 @@
#include "..\e2dimpl.h"
e2d::SystemException::SystemException() E2D_NOEXCEPT
: Exception("Unknown system exception")
{
}
e2d::SystemException::SystemException(const char * message) E2D_NOEXCEPT
: Exception(message)
{
}

View File

@ -200,7 +200,7 @@ HWND e2d::Window::GetHWnd()
else else
{ {
::UnregisterClass(REGISTER_CLASS, HINST_THISCOMPONENT); ::UnregisterClass(REGISTER_CLASS, HINST_THISCOMPONENT);
throw SystemException("Create window failed"); throw RuntimeException("Create window failed");
} }
} }
return hWnd_; return hWnd_;

View File

@ -671,14 +671,14 @@ void e2d::Node::AddChild(Node * child, int order /* = 0 */)
{ {
if (child->parent_ != nullptr) if (child->parent_ != nullptr)
{ {
throw Exception("节点已有父节点, 不能再添加到其他节点"); throw RuntimeException("节点已有父节点, 不能再添加到其他节点");
} }
for (Node * parent = this; parent != nullptr; parent = parent->GetParent()) for (Node * parent = this; parent != nullptr; parent = parent->GetParent())
{ {
if (child == parent) if (child == parent)
{ {
throw Exception("一个节点不能同时是另一个节点的父节点和子节点"); throw RuntimeException("一个节点不能同时是另一个节点的父节点和子节点");
} }
} }
@ -855,7 +855,7 @@ void e2d::Node::RunAction(Action * action)
} }
else else
{ {
throw Exception("该 Action 已有执行目标"); throw RuntimeException("该 Action 已有执行目标");
} }
} }
} }

View File

@ -45,8 +45,6 @@
<ClCompile Include="..\..\core\event\Collision.cpp" /> <ClCompile Include="..\..\core\event\Collision.cpp" />
<ClCompile Include="..\..\core\event\KeyEvent.cpp" /> <ClCompile Include="..\..\core\event\KeyEvent.cpp" />
<ClCompile Include="..\..\core\event\MouseEvent.cpp" /> <ClCompile Include="..\..\core\event\MouseEvent.cpp" />
<ClCompile Include="..\..\core\impl\Exception.cpp" />
<ClCompile Include="..\..\core\impl\SystemException.cpp" />
<ClCompile Include="..\..\core\impl\TextRenderer.cpp" /> <ClCompile Include="..\..\core\impl\TextRenderer.cpp" />
<ClCompile Include="..\..\core\impl\VoiceCallback.cpp" /> <ClCompile Include="..\..\core\impl\VoiceCallback.cpp" />
<ClCompile Include="..\..\core\manager\CollisionManager.cpp" /> <ClCompile Include="..\..\core\manager\CollisionManager.cpp" />

View File

@ -150,12 +150,6 @@
<ClCompile Include="..\..\core\components\Menu.cpp"> <ClCompile Include="..\..\core\components\Menu.cpp">
<Filter>components</Filter> <Filter>components</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\impl\Exception.cpp">
<Filter>impl</Filter>
</ClCompile>
<ClCompile Include="..\..\core\impl\SystemException.cpp">
<Filter>impl</Filter>
</ClCompile>
<ClCompile Include="..\..\core\impl\TextRenderer.cpp"> <ClCompile Include="..\..\core\impl\TextRenderer.cpp">
<Filter>impl</Filter> <Filter>impl</Filter>
</ClCompile> </ClCompile>

View File

@ -189,8 +189,6 @@
<ClCompile Include="..\..\core\event\Collision.cpp" /> <ClCompile Include="..\..\core\event\Collision.cpp" />
<ClCompile Include="..\..\core\event\KeyEvent.cpp" /> <ClCompile Include="..\..\core\event\KeyEvent.cpp" />
<ClCompile Include="..\..\core\event\MouseEvent.cpp" /> <ClCompile Include="..\..\core\event\MouseEvent.cpp" />
<ClCompile Include="..\..\core\impl\Exception.cpp" />
<ClCompile Include="..\..\core\impl\SystemException.cpp" />
<ClCompile Include="..\..\core\impl\TextRenderer.cpp" /> <ClCompile Include="..\..\core\impl\TextRenderer.cpp" />
<ClCompile Include="..\..\core\impl\VoiceCallback.cpp" /> <ClCompile Include="..\..\core\impl\VoiceCallback.cpp" />
<ClCompile Include="..\..\core\manager\CollisionManager.cpp" /> <ClCompile Include="..\..\core\manager\CollisionManager.cpp" />

View File

@ -150,12 +150,6 @@
<ClCompile Include="..\..\core\components\Menu.cpp"> <ClCompile Include="..\..\core\components\Menu.cpp">
<Filter>components</Filter> <Filter>components</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\impl\Exception.cpp">
<Filter>impl</Filter>
</ClCompile>
<ClCompile Include="..\..\core\impl\SystemException.cpp">
<Filter>impl</Filter>
</ClCompile>
<ClCompile Include="..\..\core\impl\TextRenderer.cpp"> <ClCompile Include="..\..\core\impl\TextRenderer.cpp">
<Filter>impl</Filter> <Filter>impl</Filter>
</ClCompile> </ClCompile>

View File

@ -222,8 +222,6 @@
<ClCompile Include="..\..\core\event\Collision.cpp" /> <ClCompile Include="..\..\core\event\Collision.cpp" />
<ClCompile Include="..\..\core\event\KeyEvent.cpp" /> <ClCompile Include="..\..\core\event\KeyEvent.cpp" />
<ClCompile Include="..\..\core\event\MouseEvent.cpp" /> <ClCompile Include="..\..\core\event\MouseEvent.cpp" />
<ClCompile Include="..\..\core\impl\Exception.cpp" />
<ClCompile Include="..\..\core\impl\SystemException.cpp" />
<ClCompile Include="..\..\core\impl\TextRenderer.cpp" /> <ClCompile Include="..\..\core\impl\TextRenderer.cpp" />
<ClCompile Include="..\..\core\impl\VoiceCallback.cpp" /> <ClCompile Include="..\..\core\impl\VoiceCallback.cpp" />
<ClCompile Include="..\..\core\manager\CollisionManager.cpp" /> <ClCompile Include="..\..\core\manager\CollisionManager.cpp" />

View File

@ -150,12 +150,6 @@
<ClCompile Include="..\..\core\components\Menu.cpp"> <ClCompile Include="..\..\core\components\Menu.cpp">
<Filter>components</Filter> <Filter>components</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\core\impl\Exception.cpp">
<Filter>impl</Filter>
</ClCompile>
<ClCompile Include="..\..\core\impl\SystemException.cpp">
<Filter>impl</Filter>
</ClCompile>
<ClCompile Include="..\..\core\impl\TextRenderer.cpp"> <ClCompile Include="..\..\core\impl\TextRenderer.cpp">
<Filter>impl</Filter> <Filter>impl</Filter>
</ClCompile> </ClCompile>