This is an automated email from the git hooks/post-receive script. odyx pushed a commit to branch debian/master in repository colobot.
commit 8c04d7fc652728753f154c33a2e35d03d2419e1a Author: Grunaka <d...@romainbreton.fr> Date: Sat Nov 14 11:59:32 2015 +0100 Moving CBotIf class in its own header and source files. --- src/CBot/CBot.cpp | 1 + src/CBot/CBot.h | 17 -------- src/CBot/{ => CBotInstr}/CBotIf.cpp | 25 ++++++------ src/CBot/CBotInstr/CBotIf.h | 77 +++++++++++++++++++++++++++++++++++++ src/CBot/CMakeLists.txt | 2 +- 5 files changed, 91 insertions(+), 31 deletions(-) diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp index 4d6a14b..03c6aab 100644 --- a/src/CBot/CBot.cpp +++ b/src/CBot/CBot.cpp @@ -67,6 +67,7 @@ #include "CBotInstr/CBotBoolean.h" #include "CBotInstr/CBotEmpty.h" #include "CBotInstr/CBotReturn.h" +#include "CBotInstr/CBotIf.h" // Local include diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index 9707b60..d180474 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -467,23 +467,6 @@ public: bool IsOfClass(CBotString name); }; -class CBotIf : public CBotInstr -{ -private: - CBotInstr* m_Condition; // condition - CBotInstr* m_Block; // instructions - CBotInstr* m_BlockElse; // instructions - -public: - CBotIf(); - ~CBotIf(); - static - CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); - bool Execute(CBotStack* &pj) override; - void RestoreState(CBotStack* &pj, bool bMain) override; -}; - - // definition of an integer class CBotInt : public CBotInstr diff --git a/src/CBot/CBotIf.cpp b/src/CBot/CBotInstr/CBotIf.cpp similarity index 92% rename from src/CBot/CBotIf.cpp rename to src/CBot/CBotInstr/CBotIf.cpp index 551ecb1..2ae5acf 100644 --- a/src/CBot/CBotIf.cpp +++ b/src/CBot/CBotInstr/CBotIf.cpp @@ -17,15 +17,17 @@ * along with this program. If not, see http://gnu.org/licenses */ -/////////////////////////////////////////////////////////////////////// -// instruction if (condition) operation1 else operation2; - -#include "CBot.h" - +// Modules inlcude +#include "CBotIf.h" #include "CBotInstr/CBotBlock.h" #include "CBotInstr/CBotCondition.h" -// various constructors / destructors +// Local include + +// Global include + + +//////////////////////////////////////////////////////////////////////////////// CBotIf::CBotIf() { m_Condition = @@ -34,6 +36,7 @@ CBotIf::CBotIf() name = "CBotIf"; // debug } +//////////////////////////////////////////////////////////////////////////////// CBotIf::~CBotIf() { delete m_Condition; // frees the condition @@ -41,9 +44,7 @@ CBotIf::~CBotIf() delete m_BlockElse; // frees the block of instruction2 } -// compilation (static routine) -// called when the token "if" has been found - +//////////////////////////////////////////////////////////////////////////////// CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack) { CBotToken* pp = p; // preserves at the ^ token (starting instruction) @@ -89,9 +90,7 @@ CBotInstr* CBotIf::Compile(CBotToken* &p, CBotCStack* pStack) return pStack->Return(nullptr, pStk); } - -// execution of the instruction - +//////////////////////////////////////////////////////////////////////////////// bool CBotIf :: Execute(CBotStack* &pj) { CBotStack* pile = pj->AddStack(this); // adds an item to the stack @@ -134,7 +133,7 @@ bool CBotIf :: Execute(CBotStack* &pj) return pj->Return(pile); } - +//////////////////////////////////////////////////////////////////////////////// void CBotIf :: RestoreState(CBotStack* &pj, bool bMain) { if ( !bMain ) return; diff --git a/src/CBot/CBotInstr/CBotIf.h b/src/CBot/CBotInstr/CBotIf.h new file mode 100644 index 0000000..6ea6ee9 --- /dev/null +++ b/src/CBot/CBotInstr/CBotIf.h @@ -0,0 +1,77 @@ +/* + * 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 CBotIf class Instruction if (condition) operation1 else operation2; + */ +class CBotIf : public CBotInstr +{ +public: + + /*! + * \brief CBotIf + */ + CBotIf(); + + /*! + * \brief ~CBotIf + */ + ~CBotIf(); + + /*! + * \brief Compile Compilation (static routine) called when the token "if" + * has been found + * \param p + * \param pStack + * \return + */ + static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack); + + /*! + * \brief Execute Execution of the instruction. + * \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; + //! Instruction + CBotInstr* m_Block; + //! Instruction + CBotInstr* m_BlockElse; +}; diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt index 2d25fca..8469f46 100644 --- a/src/CBot/CMakeLists.txt +++ b/src/CBot/CMakeLists.txt @@ -2,7 +2,6 @@ set(SOURCES CBot.cpp CBotClass.cpp CBotFunction.cpp - CBotIf.cpp CBotProgram.cpp CBotStack.cpp CBotString.cpp @@ -48,6 +47,7 @@ set(SOURCES CBotInstr/CBotBoolean.cpp CBotInstr/CBotEmpty.cpp CBotInstr/CBotReturn.cpp + CBotInstr/CBotIf.cpp ) # Includes -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git _______________________________________________ Pkg-games-commits mailing list Pkg-games-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits