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

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:33:59 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 562752b653cfb06fe90d5590c60cf3ebf7538179
Author: Grunaka <dev at romainbreton.fr>
Date:   Sun Nov 8 20:01:45 2015 +0100

    Moving CBotWhile class in its own header and source files.
---
 src/CBot/CBot.cpp                      |  1 +
 src/CBot/CBot.h                        | 14 ------
 src/CBot/{ => CBotInstr}/CBotWhile.cpp | 32 +++++---------
 src/CBot/CBotInstr/CBotWhile.h         | 79 ++++++++++++++++++++++++++++++++++
 src/CBot/CMakeLists.txt                |  2 +-
 5 files changed, 92 insertions(+), 36 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 6fda676..949ad2d 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -42,6 +42,7 @@
 #include "CBotInstr/CBotBreak.h"
 #include "CBotInstr/CBotTry.h"
 #include "CBotInstr/CBotThrow.h"
+#include "CBotInstr/CBotWhile.h"
 
 // Local include
 
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index c331ff4..5fb3959 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -467,21 +467,7 @@ public:
     bool        IsOfClass(CBotString name);
 };
 
-class CBotWhile : public CBotInstr
-{
-private:
-    CBotInstr*    m_Condition;        // condition
-    CBotInstr*    m_Block;            // instructions
-    CBotString    m_label;            // a label if there is
 
-public:
-                CBotWhile();
-                ~CBotWhile();
-    static
-    CBotInstr*    Compile(CBotToken* &p, CBotCStack* pStack);
-    bool        Execute(CBotStack* &pj) override;
-    void        RestoreState(CBotStack* &pj, bool bMain) override;
-};
 
 class CBotReturn : public CBotInstr
 {
diff --git a/src/CBot/CBotWhile.cpp b/src/CBot/CBotInstr/CBotWhile.cpp
similarity index 86%
rename from src/CBot/CBotWhile.cpp
rename to src/CBot/CBotInstr/CBotWhile.cpp
index 2891c60..92b276d 100644
--- a/src/CBot/CBotWhile.cpp
+++ b/src/CBot/CBotInstr/CBotWhile.cpp
@@ -17,26 +17,14 @@
  * along with this program. If not, see http://gnu.org/licenses
  */
 
-///////////////////////////////////////////////////////////////////////
-// This file defined the following statements:
-//      CBotWhile   "while (condition) {instructions}"
-//      CBotDo      "do {instructions} while (condition)"
-//      CBotFor     "for (init, condition, incr) {instructions}"
-//      CBotSwitch  "switch (val) {instructions}"
-//      CBotCase    "case val:"
-//      CBotBreak   "break", "break label", "continu", "continu label"
-//      CBotTry     "try {instructions}"
-//      CBotCatch   "catch (condition) {instructions}" or "finally"
-//      CBotThrow   "throw execption"
+// Modules inlcude
+#include "CBotWhile.h"
 
+// Local include
 
-#include "CBot.h"
-
-///////////////////////////////////////////////////////////////////////////
-
-///////////////////////////////////////////////////////////////////////////
-// compile an instruction "while"
+// Global include
 
+////////////////////////////////////////////////////////////////////////////////
 CBotWhile::CBotWhile()
 {
     m_Condition =
@@ -44,12 +32,14 @@ CBotWhile::CBotWhile()
     name = "CBotWhile";     // debug
 }
 
+////////////////////////////////////////////////////////////////////////////////
 CBotWhile::~CBotWhile()
 {
     delete  m_Condition;    // frees the condition
     delete  m_Block;        // releases the block instruction
 }
 
+////////////////////////////////////////////////////////////////////////////////
 CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
 {
     CBotWhile*  inst = new CBotWhile();         // creates the object
@@ -88,9 +78,8 @@ CBotInstr* CBotWhile::Compile(CBotToken* &p, CBotCStack* pStack)
     return pStack->Return(nullptr, pStk);          // no object, the error is on the stack
 }
 
-// executes a "while" instruction
-
-bool CBotWhile :: Execute(CBotStack* &pj)
+////////////////////////////////////////////////////////////////////////////////
+bool CBotWhile::Execute(CBotStack* &pj)
 {
     CBotStack* pile = pj->AddStack(this);   // adds an item to the stack
                                             // or find in case of recovery
@@ -137,7 +126,8 @@ bool CBotWhile :: Execute(CBotStack* &pj)
     }
 }
 
-void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
+////////////////////////////////////////////////////////////////////////////////
+void CBotWhile::RestoreState(CBotStack* &pj, bool bMain)
 {
     if ( !bMain ) return;
     CBotStack* pile = pj->RestoreStack(this);   // adds an item to the stack
diff --git a/src/CBot/CBotInstr/CBotWhile.h b/src/CBot/CBotInstr/CBotWhile.h
new file mode 100644
index 0000000..5d63909
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotWhile.h
@@ -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
+ */
+
+#pragma once
+
+// Modules inlcude
+#include "CBot.h"
+
+// Local include
+
+// Global include
+
+/*!
+ * \brief The CBotWhile class Compile an instruction "while".
+ */
+class CBotWhile : public CBotInstr
+{
+public:
+
+    /*!
+     * \brief CBotWhile
+     */
+    CBotWhile();
+
+    /*!
+     * \brief ~CBotWhile
+     */
+    ~CBotWhile();
+
+    /*!
+     * \brief Compile
+     * \param p
+     * \param pStack
+     * \return
+     */
+    static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
+
+    // executes a "while" instruction
+    /*!
+     * \brief Execute
+     * \param pj
+     * \return
+     */
+    bool Execute(CBotStack* &pj) override;
+
+    /*!
+     * \brief RestoreState
+     * \param pj
+     * \param bMain
+     */
+    void RestoreState(CBotStack* &pj, bool bMain) override;
+
+
+private:
+
+    //! Condition
+    CBotInstr* m_Condition;
+    //! Instructions
+    CBotInstr* m_Block;
+    //! A label if there is
+    CBotString m_label;
+
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 80b1303..af6a1e9 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -9,7 +9,7 @@ set(SOURCES
     CBotToken.cpp
     CBotTwoOpExpr.cpp
     CBotVar.cpp
-    CBotWhile.cpp
+    CBotInstr/CBotWhile.cpp
     CBotInstr/CBotDo.cpp
     CBotInstr/CBotFor.cpp
     CBotInstr/CBotListExpression.cpp

-- 
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