[colobot] 77/377: Moving CBotPostIncExpr class in its own header and source files.

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository colobot.

commit 5343c15d603096493189812b6d645440dc34e02d
Author: Grunaka <dev at romainbreton.fr>
Date:   Wed Nov 11 18:22:04 2015 +0100

    Moving CBotPostIncExpr class in its own header and source files.
---
 src/CBot/CBot.cpp                      | 63 +------------------------
 src/CBot/CBot.h                        | 15 ------
 src/CBot/CBotInstr/CBotPostIncExpr.cpp | 85 ++++++++++++++++++++++++++++++++++
 src/CBot/CBotInstr/CBotPostIncExpr.h   | 69 +++++++++++++++++++++++++++
 src/CBot/CMakeLists.txt                |  1 +
 5 files changed, 156 insertions(+), 77 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index f6c11ca..b7c8287 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -51,6 +51,7 @@
 #include "CBotInstr/CBotExprBool.h"
 #include "CBotInstr/CBotLeftExprVar.h"
 #include "CBotInstr/CBotPreIncExpr.h"
+#include "CBotInstr/CBotPostIncExpr.h"
 
 // Local include
 
@@ -1983,68 +1984,6 @@ CBotInstr* CBotParExpr::Compile(CBotToken* &p, CBotCStack* pStack)
     return pStack->Return(nullptr, pStk);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
-
-//////////////////////////////////////////////////////////////////////////////////////
-// Management of pre-and post increment / decrement
-// There is no routine Compiles, the object is created directly
-// Compiles in CBotParExpr ::
-
-
-CBotPostIncExpr::CBotPostIncExpr()
-{
-    m_Instr = nullptr;
-    name    = "CBotPostIncExpr";
-}
-
-CBotPostIncExpr::~CBotPostIncExpr()
-{
-    delete    m_Instr;
-}
-
-bool CBotPostIncExpr::Execute(CBotStack* &pj)
-{
-    CBotStack*    pile1 = pj->AddStack(this);
-    CBotStack*    pile2 = pile1;
-
-    CBotVar*    var1 = nullptr;
-
-    // retrieves the variable fields and indexes according
-    if (!(static_cast<CBotExprVar*>(m_Instr))->ExecuteVar(var1, pile2, nullptr, true)) return false;
-
-    pile1->SetState(1);
-    pile1->SetCopyVar(var1);                                // places the result (before incrementation);
-
-    CBotStack* pile3 = pile2->AddStack(this);
-    if (pile3->IfStep()) return false;
-
-    if (var1->IsNAN())
-    {
-        pile1->SetError(TX_OPNAN, &m_token);
-    }
-
-    if (!var1->IsDefined())
-    {
-        pile1->SetError(TX_NOTINIT, &m_token);
-    }
-
-    if (GetTokenType() == ID_INC) var1->Inc();
-    else                          var1->Dec();
-
-    return pj->Return(pile1);                        // operation done, result on pile2
-}
-
-void CBotPostIncExpr::RestoreState(CBotStack* &pj, bool bMain)
-{
-    if (!bMain) return;
-
-    CBotStack*    pile1 = pj->RestoreStack(this);
-    if (pile1 == nullptr) return;
-
-    (static_cast<CBotExprVar*>(m_Instr))->RestoreStateVar(pile1, bMain);
-
-    if (pile1 != nullptr) pile1->RestoreStack(this);
-}
 
 //////////////////////////////////////////////////////////////////////////////////////
 // compile an unary expression
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 814183b..6b27e56 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -900,21 +900,6 @@ public:
     void        RestoreStateVar(CBotStack* &pj, bool bMain) override;
 };
 
-class CBotPostIncExpr : public CBotInstr
-{
-private:
-    CBotInstr*    m_Instr;
-    friend class CBotParExpr;
-
-public:
-                CBotPostIncExpr();
-                ~CBotPostIncExpr();
-//    static
-//    CBotInstr*    Compile(CBotToken* &p, CBotCStack* pStack);
-    bool        Execute(CBotStack* &pj) override;
-    void        RestoreState(CBotStack* &pj, bool bMain) override;
-};
-
 #define    MAX(a,b)    ((a>b) ? a : b)
 
 
diff --git a/src/CBot/CBotInstr/CBotPostIncExpr.cpp b/src/CBot/CBotInstr/CBotPostIncExpr.cpp
new file mode 100644
index 0000000..a0b24fc
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotPostIncExpr.cpp
@@ -0,0 +1,85 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+// Modules inlcude
+#include "CBotPostIncExpr.h"
+
+// Local include
+
+// Global include
+
+
+////////////////////////////////////////////////////////////////////////////////
+CBotPostIncExpr::CBotPostIncExpr()
+{
+    m_Instr = nullptr;
+    name    = "CBotPostIncExpr";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotPostIncExpr::~CBotPostIncExpr()
+{
+    delete    m_Instr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotPostIncExpr::Execute(CBotStack* &pj)
+{
+    CBotStack*    pile1 = pj->AddStack(this);
+    CBotStack*    pile2 = pile1;
+
+    CBotVar*    var1 = nullptr;
+
+    // retrieves the variable fields and indexes according
+    if (!(static_cast<CBotExprVar*>(m_Instr))->ExecuteVar(var1, pile2, nullptr, true)) return false;
+
+    pile1->SetState(1);
+    pile1->SetCopyVar(var1);                                // places the result (before incrementation);
+
+    CBotStack* pile3 = pile2->AddStack(this);
+    if (pile3->IfStep()) return false;
+
+    if (var1->IsNAN())
+    {
+        pile1->SetError(TX_OPNAN, &m_token);
+    }
+
+    if (!var1->IsDefined())
+    {
+        pile1->SetError(TX_NOTINIT, &m_token);
+    }
+
+    if (GetTokenType() == ID_INC) var1->Inc();
+    else                          var1->Dec();
+
+    return pj->Return(pile1);                        // operation done, result on pile2
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotPostIncExpr::RestoreState(CBotStack* &pj, bool bMain)
+{
+    if (!bMain) return;
+
+    CBotStack*    pile1 = pj->RestoreStack(this);
+    if (pile1 == nullptr) return;
+
+    (static_cast<CBotExprVar*>(m_Instr))->RestoreStateVar(pile1, bMain);
+
+    if (pile1 != nullptr) pile1->RestoreStack(this);
+}
diff --git a/src/CBot/CBotInstr/CBotPostIncExpr.h b/src/CBot/CBotInstr/CBotPostIncExpr.h
new file mode 100644
index 0000000..5a3240c
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotPostIncExpr.h
@@ -0,0 +1,69 @@
+/*
+ * This file is part of the Colobot: Gold Edition source code
+ * Copyright (C) 2001-2015, Daniel Roux, EPSITEC SA & TerranovaTeam
+ * http://epsitec.ch; http://colobot.info; http://github.com/colobot
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see http://gnu.org/licenses
+ */
+
+#pragma once
+
+// Modules inlcude
+#include "CBot.h"
+
+// Local include
+
+// Global include
+
+//////////////////////////////////////////////////////////////////////////////////////
+// Management of pre-and post increment / decrement
+// There is no routine Compiles, the object is created directly
+// Compiles in CBotParExpr ::
+
+/*!
+ * \brief The CBotPostIncExpr class
+ */
+class CBotPostIncExpr : public CBotInstr
+{
+
+public:
+
+    /*!
+     * \brief CBotPostIncExpr
+     */
+    CBotPostIncExpr();
+
+    /*!
+     * \brief ~CBotPostIncExpr
+     */
+    ~CBotPostIncExpr();
+
+    /*!
+     * \brief Execute
+     * \param pj
+     * \return
+     */
+    bool Execute(CBotStack* &pj) override;
+
+    /*!
+     * \brief RestoreState
+     * \param pj
+     * \param bMain
+     */
+    void RestoreState(CBotStack* &pj, bool bMain) override;
+
+private:
+    CBotInstr*    m_Instr;
+    friend class CBotParExpr;
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index b7c6349..158478b 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -27,6 +27,7 @@ set(SOURCES
     CBotInstr/CBotExprBool.cpp
     CBotInstr/CBotLeftExprVar.cpp
     CBotInstr/CBotPreIncExpr.cpp
+    CBotInstr/CBotPostIncExpr.cpp
 )
 
 # Includes

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list