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

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:33:58 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 8da5c675a4e2cdff852bcbfcf1860f4ef0a4ce0c
Author: Grunaka <dev at romainbreton.fr>
Date:   Sun Nov 8 19:20:06 2015 +0100

    Moving CBotBreak class in its own header and source files.
---
 src/CBot/CBot.cpp                |  1 +
 src/CBot/CBot.h                  | 14 ------
 src/CBot/CBotInstr/CBotBreak.cpp | 93 ++++++++++++++++++++++++++++++++++++++++
 src/CBot/CBotInstr/CBotBreak.h   | 75 ++++++++++++++++++++++++++++++++
 src/CBot/CBotWhile.cpp           | 67 -----------------------------
 src/CBot/CMakeLists.txt          |  1 +
 6 files changed, 170 insertions(+), 81 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 97bcc77..9b1083e 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -39,6 +39,7 @@
 #include "CBotInstr/CBotDo.h"
 #include "CBotInstr/CBotFor.h"
 #include "CBotInstr/CBotSwitch.h"
+#include "CBotInstr/CBotBreak.h"
 
 // Local include
 
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 45260f2..cb337af 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -483,20 +483,6 @@ public:
     void        RestoreState(CBotStack* &pj, bool bMain) override;
 };
 
-class CBotBreak : public CBotInstr
-{
-private:
-    CBotString    m_label;            // a label if there is
-
-public:
-                CBotBreak();
-                ~CBotBreak();
-    static
-    CBotInstr*    Compile(CBotToken* &p, CBotCStack* pStack);
-    bool        Execute(CBotStack* &pj) override;
-    void        RestoreState(CBotStack* &pj, bool bMain) override;
-};
-
 class CBotReturn : public CBotInstr
 {
 private:
diff --git a/src/CBot/CBotInstr/CBotBreak.cpp b/src/CBot/CBotInstr/CBotBreak.cpp
new file mode 100644
index 0000000..06f53ae
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotBreak.cpp
@@ -0,0 +1,93 @@
+/*
+ * 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 "CBotBreak.h"
+
+// Local include
+
+// Global include
+
+////////////////////////////////////////////////////////////////////////////////
+CBotBreak::CBotBreak()
+{
+    name = "CBotBreak";     // debug
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotBreak::~CBotBreak()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
+{
+    CBotToken*  pp = p;                         // preserves at the ^ token (starting position)
+    int type = p->GetType();
+
+    if (!IsOfType(p, ID_BREAK, ID_CONTINUE)) return nullptr;   // should never happen
+
+    if ( !ChkLvl(CBotString(), type ) )
+    {
+        pStack->SetError(TX_BREAK, pp);
+        return nullptr;                            // no object, the error is on the stack
+    }
+
+    CBotBreak*  inst = new CBotBreak();         // creates the object
+    inst->SetToken(pp);                         // keeps the operation
+
+    pp = p;
+    if ( IsOfType( p, TokenTypVar ) )
+    {
+        inst->m_label = pp->GetString();        // register the name of label
+        if ( !ChkLvl(inst->m_label, type ) )
+        {
+            delete inst;
+            pStack->SetError(TX_NOLABEL, pp);
+            return nullptr;                            // no object, the error is on the stack
+        }
+    }
+
+    if (IsOfType(p, ID_SEP))
+    {
+        return  inst;                           // return what it wants
+    }
+    delete inst;
+
+    pStack->SetError(TX_ENDOF, p->GetStart());
+    return nullptr;                            // no object, the error is on the stack
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotBreak :: Execute(CBotStack* &pj)
+{
+    CBotStack* pile = pj->AddStack(this);
+//  if ( pile == EOX ) return true;
+
+    if ( pile->IfStep() ) return false;
+
+    pile->SetBreak(m_token.GetType()==ID_BREAK ? 1 : 2, m_label);
+    return pj->Return(pile);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain)
+{
+    if ( bMain ) pj->RestoreStack(this);
+}
diff --git a/src/CBot/CBotInstr/CBotBreak.h b/src/CBot/CBotInstr/CBotBreak.h
new file mode 100644
index 0000000..0ad3940
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotBreak.h
@@ -0,0 +1,75 @@
+/*
+ * 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 CBotBreak class Compiles instruction "break" or "continu".
+ */
+class CBotBreak : public CBotInstr
+{
+
+public:
+
+    /*!
+     * \brief CBotBreak
+     */
+    CBotBreak();
+
+    /*!
+     * \brief CBotBreak
+     */
+    ~CBotBreak();
+
+    /*!
+     * \brief Compile
+     * \param p
+     * \param pStack
+     * \return
+     */
+    static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
+
+    /*!
+     * \brief Execute Execution of statement "break" or "continu"
+     * \param pj
+     * \return
+     */
+    bool Execute(CBotStack* &pj) override;
+
+    /*!
+     * \brief RestoreState
+     * \param pj
+     * \param bMain
+     */
+    void RestoreState(CBotStack* &pj, bool bMain) override;
+
+
+private:
+    //! A label if there is
+    CBotString m_label;
+
+};
diff --git a/src/CBot/CBotWhile.cpp b/src/CBot/CBotWhile.cpp
index 680dd71..42b024b 100644
--- a/src/CBot/CBotWhile.cpp
+++ b/src/CBot/CBotWhile.cpp
@@ -157,73 +157,6 @@ void CBotWhile :: RestoreState(CBotStack* &pj, bool bMain)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////
-// compiles instruction "break" or "continu"
-
-CBotBreak::CBotBreak()
-{
-    name = "CBotBreak";     // debug
-}
-
-CBotBreak::~CBotBreak()
-{
-}
-
-CBotInstr* CBotBreak::Compile(CBotToken* &p, CBotCStack* pStack)
-{
-    CBotToken*  pp = p;                         // preserves at the ^ token (starting position)
-    int type = p->GetType();
-
-    if (!IsOfType(p, ID_BREAK, ID_CONTINUE)) return nullptr;   // should never happen
-
-    if ( !ChkLvl(CBotString(), type ) )
-    {
-        pStack->SetError(TX_BREAK, pp);
-        return nullptr;                            // no object, the error is on the stack
-    }
-
-    CBotBreak*  inst = new CBotBreak();         // creates the object
-    inst->SetToken(pp);                         // keeps the operation
-
-    pp = p;
-    if ( IsOfType( p, TokenTypVar ) )
-    {
-        inst->m_label = pp->GetString();        // register the name of label
-        if ( !ChkLvl(inst->m_label, type ) )
-        {
-            delete inst;
-            pStack->SetError(TX_NOLABEL, pp);
-            return nullptr;                            // no object, the error is on the stack
-        }
-    }
-
-    if (IsOfType(p, ID_SEP))
-    {
-        return  inst;                           // return what it wants
-    }
-    delete inst;
-
-    pStack->SetError(TX_ENDOF, p->GetStart());
-    return nullptr;                            // no object, the error is on the stack
-}
-
-// execution of statement "break" or "continu"
-
-bool CBotBreak :: Execute(CBotStack* &pj)
-{
-    CBotStack* pile = pj->AddStack(this);
-//  if ( pile == EOX ) return true;
-
-    if ( pile->IfStep() ) return false;
-
-    pile->SetBreak(m_token.GetType()==ID_BREAK ? 1 : 2, m_label);
-    return pj->Return(pile);
-}
-
-void CBotBreak :: RestoreState(CBotStack* &pj, bool bMain)
-{
-    if ( bMain ) pj->RestoreStack(this);
-}
 
 
 ///////////////////////////////////////////////////////////////////////////
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index ac39e66..07564cb 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -15,6 +15,7 @@ set(SOURCES
     CBotInstr/CBotListExpression.cpp
     CBotInstr/CBotSwitch.cpp
     CBotInstr/CBotCase.cpp
+    CBotInstr/CBotBreak.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