[colobot] 74/377: Moving CBotExprBool 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 2f52520421b3972d9d5bf14ad5caa1b9fcf6894f
Author: Grunaka <dev at romainbreton.fr>
Date:   Wed Nov 11 17:59:50 2015 +0100

    Moving CBotExprBool class in its own header and source files.
---
 src/CBot/CBot.cpp                   | 54 +------------------------
 src/CBot/CBot.h                     | 15 -------
 src/CBot/CBotInstr/CBotExprBool.cpp | 79 +++++++++++++++++++++++++++++++++++++
 src/CBot/CBotInstr/CBotExprBool.h   | 68 +++++++++++++++++++++++++++++++
 src/CBot/CMakeLists.txt             |  1 +
 5 files changed, 149 insertions(+), 68 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 25efe2b..df2db44 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -48,6 +48,7 @@
 #include "CBotInstr/CBotNew.h"
 #include "CBotInstr/CBotExprNan.h"
 #include "CBotInstr/CBotExprNull.h"
+#include "CBotInstr/CBotExprBool.h"
 
 // Local include
 
@@ -2691,59 +2692,6 @@ void CBotLeftExpr::RestoreStateVar(CBotStack* &pile, bool bMain)
 }
 
 //////////////////////////////////////////////////////////////////////////////////////
-// compile a token representing true or false
-
-CBotExprBool::CBotExprBool()
-{
-    name = "CBotExprBool";
-}
-
-CBotExprBool::~CBotExprBool()
-{
-}
-
-CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack)
-{
-    CBotCStack* pStk = pStack->TokenStack();
-    CBotExprBool* inst = nullptr;
-
-    if ( p->GetType() == ID_TRUE ||
-         p->GetType() == ID_FALSE )
-    {
-        inst = new CBotExprBool();
-        inst->SetToken(p);  // stores the operation false or true
-        p = p->GetNext();
-
-        CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean);
-        pStk->SetVar(var);
-    }
-
-    return pStack->Return(inst, pStk);
-}
-
-// executes, returns true or false
-
-bool CBotExprBool::Execute(CBotStack* &pj)
-{
-    CBotStack*    pile = pj->AddStack(this);
-
-    if (pile->IfStep()) return false;
-
-    CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean);
-
-    if (GetTokenType() == ID_TRUE)      var->SetValInt(1);
-    else                              var->SetValInt(0);
-
-    pile->SetVar(var);  // put on the stack
-    return pj->Return(pile);    // forwards below
-}
-
-void CBotExprBool::RestoreState(CBotStack* &pj, bool bMain)
-{
-    if (bMain) pj->RestoreStack(this);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
 // compile a variable name
 // check that it is known on the stack
 // and it has been initialized
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index e860c4a..eebdb95 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -948,21 +948,6 @@ public:
     void        RestoreState(CBotStack* &pj, bool bMain) override;
 };
 
-
-class CBotExprBool : public CBotInstr
-{
-private:
-
-public:
-                CBotExprBool();
-                ~CBotExprBool();
-
-    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/CBotExprBool.cpp b/src/CBot/CBotInstr/CBotExprBool.cpp
new file mode 100644
index 0000000..17c09e5
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotExprBool.cpp
@@ -0,0 +1,79 @@
+/*
+ * 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 "CBotExprBool.h"
+
+// Local include
+
+// Global include
+
+
+////////////////////////////////////////////////////////////////////////////////
+CBotExprBool::CBotExprBool()
+{
+    name = "CBotExprBool";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotExprBool::~CBotExprBool()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotExprBool::Compile(CBotToken* &p, CBotCStack* pStack)
+{
+    CBotCStack* pStk = pStack->TokenStack();
+    CBotExprBool* inst = nullptr;
+
+    if ( p->GetType() == ID_TRUE ||
+         p->GetType() == ID_FALSE )
+    {
+        inst = new CBotExprBool();
+        inst->SetToken(p);  // stores the operation false or true
+        p = p->GetNext();
+
+        CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean);
+        pStk->SetVar(var);
+    }
+
+    return pStack->Return(inst, pStk);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotExprBool::Execute(CBotStack* &pj)
+{
+    CBotStack*    pile = pj->AddStack(this);
+
+    if (pile->IfStep()) return false;
+
+    CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypBoolean);
+
+    if (GetTokenType() == ID_TRUE)      var->SetValInt(1);
+    else                              var->SetValInt(0);
+
+    pile->SetVar(var);  // put on the stack
+    return pj->Return(pile);    // forwards below
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotExprBool::RestoreState(CBotStack* &pj, bool bMain)
+{
+    if (bMain) pj->RestoreStack(this);
+}
diff --git a/src/CBot/CBotInstr/CBotExprBool.h b/src/CBot/CBotInstr/CBotExprBool.h
new file mode 100644
index 0000000..a2609e2
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotExprBool.h
@@ -0,0 +1,68 @@
+/*
+ * 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
+
+
+/*!
+ * \brief The CBotExprBool class Compile a token representing true or false.
+ */
+class CBotExprBool : public CBotInstr
+{
+public:
+
+    /*!
+     * \brief CBotExprBool
+     */
+    CBotExprBool();
+
+    /*!
+     * \brief ~CBotExprBool
+     */
+    ~CBotExprBool();
+
+    /*!
+     * \brief Compile
+     * \param p
+     * \param pStack
+     * \return
+     */
+    static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
+
+    /*!
+     * \brief Execute Executes, returns true or false.
+     * \param pj
+     * \return
+     */
+    bool Execute(CBotStack* &pj) override;
+
+    /*!
+     * \brief RestoreState
+     * \param pj
+     * \param bMain
+     */
+    void RestoreState(CBotStack* &pj, bool bMain) override;
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 5701d39..104e2b1 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -24,6 +24,7 @@ set(SOURCES
     CBotInstr/CBotNew.cpp
     CBotInstr/CBotExprNan.cpp
     CBotInstr/CBotExprNull.cpp
+    CBotInstr/CBotExprBool.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