[colobot] 82/377: Moving CBotBlock 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 8eff62a78cf9ee1c45e226112844118e073773f1
Author: Grunaka <dev at romainbreton.fr>
Date:   Wed Nov 11 19:53:00 2015 +0100

    Moving CBotBlock class in its own header and source files.
---
 src/CBot/CBot.cpp                    | 52 ---------------------------
 src/CBot/CBot.h                      | 16 ---------
 src/CBot/CBotFunction.cpp            |  2 ++
 src/CBot/CBotIf.cpp                  |  2 ++
 src/CBot/CBotInstr/CBotBlock.cpp     | 69 ++++++++++++++++++++++++++++++++++++
 src/CBot/CBotInstr/CBotBlock.h       | 64 +++++++++++++++++++++++++++++++++
 src/CBot/CBotInstr/CBotCatch.cpp     |  1 +
 src/CBot/CBotInstr/CBotDo.cpp        |  1 +
 src/CBot/CBotInstr/CBotFor.cpp       |  1 +
 src/CBot/CBotInstr/CBotListInstr.cpp |  1 +
 src/CBot/CBotInstr/CBotSwitch.cpp    |  1 +
 src/CBot/CBotInstr/CBotTry.cpp       |  1 +
 src/CBot/CBotInstr/CBotWhile.cpp     |  1 +
 src/CBot/CMakeLists.txt              |  1 +
 14 files changed, 145 insertions(+), 68 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 98e04d9..042e4c7 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -357,58 +357,6 @@ bool CBotInstr::CompCase(CBotStack* &pj, int val)
     return false;
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-// compiles a statement block " { i ; i ; } "
-
-// this class have no constructor because there is never an instance of this
-// class
-// the object returned by Compile is usually of type CBotListInstr
-
-
-CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal)
-{
-    pStack->SetStartError(p->GetStart());
-
-    if (IsOfType(p, ID_OPBLK))
-    {
-        CBotInstr* inst = CBotListInstr::Compile(p, pStack, bLocal);
-
-        if (IsOfType(p, ID_CLBLK))
-        {
-            return inst;
-        }
-
-        pStack->SetError(TX_CLOSEBLK, p->GetStart());    // missing parenthesis
-        delete inst;
-        return nullptr;
-    }
-
-    pStack->SetError(TX_OPENBLK, p->GetStart());
-    return nullptr;
-}
-
-CBotInstr* CBotBlock::CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal)
-{
-    // is this a new block
-    if (p->GetType() == ID_OPBLK) return CBotBlock::Compile(p, pStack);
-
-    // otherwise, look for a single statement instead
-
-    // to handle the case with local definition instruction (*)
-    CBotCStack* pStk = pStack->TokenStack(p, bLocal);
-
-    return pStack->Return( CBotInstr::Compile(p, pStk),    // a single instruction
-                           pStk);
-}
-
-// (*) is the case in the following statement
-// if (1 == 1) int x = 0;
-// where the variable x is known only in the block following the if
-
-
 //////////////////////////////////////////////////////////////////////////////////////
 // defining an array of any type
 // int a[12];
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 326a79e..32cdb69 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -799,22 +799,6 @@ public:
     void        RestoreState(CBotStack* &pj, bool bMain) override;
 };
 
-
-
-
-// an instruction block { .... }
-class CBotBlock : public CBotInstr
-{
-public:
-    static
-    CBotInstr*    Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true);
-    static
-    CBotInstr*    CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal = false);
-private:
-    CBotBlock() = delete;
-    CBotBlock(const CBotBlock &) = delete;
-};
-
 #define    MAX(a,b)    ((a>b) ? a : b)
 
 
diff --git a/src/CBot/CBotFunction.cpp b/src/CBot/CBotFunction.cpp
index 226add2..6ebad17 100644
--- a/src/CBot/CBotFunction.cpp
+++ b/src/CBot/CBotFunction.cpp
@@ -23,6 +23,8 @@
 
 #include "CBot.h"
 
+#include "CBotInstr/CBotBlock.h"
+
 #include <cassert>
 
 
diff --git a/src/CBot/CBotIf.cpp b/src/CBot/CBotIf.cpp
index 15770af..781ec12 100644
--- a/src/CBot/CBotIf.cpp
+++ b/src/CBot/CBotIf.cpp
@@ -22,6 +22,8 @@
 
 #include "CBot.h"
 
+#include "CBotInstr/CBotBlock.h"
+
 // various constructors / destructors
 CBotIf::CBotIf()
 {
diff --git a/src/CBot/CBotInstr/CBotBlock.cpp b/src/CBot/CBotInstr/CBotBlock.cpp
new file mode 100644
index 0000000..ed87b53
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotBlock.cpp
@@ -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
+ */
+
+// Modules inlcude
+#include "CBotBlock.h"
+#include "CBotListInstr.h"
+
+// Local include
+
+// Global include
+
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotBlock::Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal)
+{
+    pStack->SetStartError(p->GetStart());
+
+    if (IsOfType(p, ID_OPBLK))
+    {
+        CBotInstr* inst = CBotListInstr::Compile(p, pStack, bLocal);
+
+        if (IsOfType(p, ID_CLBLK))
+        {
+            return inst;
+        }
+
+        pStack->SetError(TX_CLOSEBLK, p->GetStart());    // missing parenthesis
+        delete inst;
+        return nullptr;
+    }
+
+    pStack->SetError(TX_OPENBLK, p->GetStart());
+    return nullptr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotBlock::CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal)
+{
+    // is this a new block
+    if (p->GetType() == ID_OPBLK) return CBotBlock::Compile(p, pStack);
+
+    // otherwise, look for a single statement instead
+
+    // to handle the case with local definition instruction (*)
+    CBotCStack* pStk = pStack->TokenStack(p, bLocal);
+
+    return pStack->Return( CBotInstr::Compile(p, pStk),    // a single instruction
+                           pStk);
+}
+
+// (*) is the case in the following statement
+// if (1 == 1) int x = 0;
+// where the variable x is known only in the block following the if
diff --git a/src/CBot/CBotInstr/CBotBlock.h b/src/CBot/CBotInstr/CBotBlock.h
new file mode 100644
index 0000000..f413e75
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotBlock.h
@@ -0,0 +1,64 @@
+/*
+ * 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 CBotBlock class An instruction block { .... }.
+ */
+class CBotBlock : public CBotInstr
+{
+public:
+
+    /*!
+     * \brief Compile Compiles a statement block " { i ; i ; } "
+     * \param p
+     * \param pStack
+     * \param bLocal
+     * \return
+     */
+    static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack, bool bLocal = true);
+
+    /*!
+     * \brief CompileBlkOrInst
+     * \param p
+     * \param pStack
+     * \param bLocal
+     * \return
+     */
+    static CBotInstr* CompileBlkOrInst(CBotToken* &p, CBotCStack* pStack, bool bLocal = false);
+
+private:
+
+    /*!
+     * \brief CBotBlock This class have no constructor because there is never an
+     * instance of this class the object returned by Compile is usually of type
+     * CBotListInstr
+     */
+    CBotBlock() = delete;
+    CBotBlock(const CBotBlock &) = delete;
+};
diff --git a/src/CBot/CBotInstr/CBotCatch.cpp b/src/CBot/CBotInstr/CBotCatch.cpp
index 4c63e02..e4a5571 100644
--- a/src/CBot/CBotInstr/CBotCatch.cpp
+++ b/src/CBot/CBotInstr/CBotCatch.cpp
@@ -19,6 +19,7 @@
 
 // Modules inlcude
 #include "CBotCatch.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CBotInstr/CBotDo.cpp b/src/CBot/CBotInstr/CBotDo.cpp
index a24e5db..94c281d 100644
--- a/src/CBot/CBotInstr/CBotDo.cpp
+++ b/src/CBot/CBotInstr/CBotDo.cpp
@@ -19,6 +19,7 @@
 
 // Modules inlcude
 #include "CBotDo.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CBotInstr/CBotFor.cpp b/src/CBot/CBotInstr/CBotFor.cpp
index 7dc07d4..32caa3c 100644
--- a/src/CBot/CBotInstr/CBotFor.cpp
+++ b/src/CBot/CBotInstr/CBotFor.cpp
@@ -20,6 +20,7 @@
 // Modules inlcude
 #include "CBotFor.h"
 #include "CBotListExpression.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CBotInstr/CBotListInstr.cpp b/src/CBot/CBotInstr/CBotListInstr.cpp
index 3d1d9c5..b2fcf49 100644
--- a/src/CBot/CBotInstr/CBotListInstr.cpp
+++ b/src/CBot/CBotInstr/CBotListInstr.cpp
@@ -19,6 +19,7 @@
 
 // Modules inlcude
 #include "CBotListInstr.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CBotInstr/CBotSwitch.cpp b/src/CBot/CBotInstr/CBotSwitch.cpp
index c0c7997..70fd803 100644
--- a/src/CBot/CBotInstr/CBotSwitch.cpp
+++ b/src/CBot/CBotInstr/CBotSwitch.cpp
@@ -22,6 +22,7 @@
 // Modules inlcude
 #include "CBotSwitch.h"
 #include "CBotCase.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CBotInstr/CBotTry.cpp b/src/CBot/CBotInstr/CBotTry.cpp
index c2b2901..89b689e 100644
--- a/src/CBot/CBotInstr/CBotTry.cpp
+++ b/src/CBot/CBotInstr/CBotTry.cpp
@@ -19,6 +19,7 @@
 
 // Modules inlcude
 #include "CBotTry.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CBotInstr/CBotWhile.cpp b/src/CBot/CBotInstr/CBotWhile.cpp
index 92b276d..340cc23 100644
--- a/src/CBot/CBotInstr/CBotWhile.cpp
+++ b/src/CBot/CBotInstr/CBotWhile.cpp
@@ -19,6 +19,7 @@
 
 // Modules inlcude
 #include "CBotWhile.h"
+#include "CBotBlock.h"
 
 // Local include
 
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 30e717b..ac6a0c0 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -32,6 +32,7 @@ set(SOURCES
     CBotInstr/CBotInstrMethode.cpp
     CBotInstr/CBotInstrCall.cpp
     CBotInstr/CBotListInstr.cpp
+    CBotInstr/CBotBlock.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