[colobot] 92/377: Moving CBotCondition class in its own header and source files.
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:01 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 dc8a6b32739c47ccb51571f7c587a21cdb2137b8
Author: Grunaka <dev at romainbreton.fr>
Date: Wed Nov 11 22:24:37 2015 +0100
Moving CBotCondition class in its own header and source files.
---
src/CBot/CBot.cpp | 31 ----------------------
src/CBot/CBot.h | 10 --------
src/CBot/CBotIf.cpp | 1 +
src/CBot/CBotInstr/CBotCondition.cpp | 50 ++++++++++++++++++++++++++++++++++++
src/CBot/CBotInstr/CBotCondition.h | 46 +++++++++++++++++++++++++++++++++
src/CBot/CBotInstr/CBotDo.cpp | 1 +
src/CBot/CBotInstr/CBotWhile.cpp | 1 +
src/CBot/CMakeLists.txt | 1 +
8 files changed, 100 insertions(+), 41 deletions(-)
diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index c4ac287..7ad12b3 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -1348,37 +1348,6 @@ void CBotIString::RestoreState(CBotStack* &pj, bool bMain)
m_next2b->RestoreState(pile, bMain);
}
-
-//////////////////////////////////////////////////////////////////////////////////////
-// compile a statement such as "(condition)"
-// the condition must be Boolean
-
-// this class has no constructor, because there is never an instance of this class
-// the object returned by Compile is usually type CBotExpression
-
-
-CBotInstr* CBotCondition::Compile(CBotToken* &p, CBotCStack* pStack)
-{
- pStack->SetStartError(p->GetStart());
- if (IsOfType(p, ID_OPENPAR))
- {
- CBotInstr* inst = CBotBoolExpr::Compile(p, pStack);
- if (nullptr != inst)
- {
- if (IsOfType(p, ID_CLOSEPAR))
- {
- return inst;
- }
- pStack->SetError(TX_CLOSEPAR, p->GetStart()); // missing parenthesis
- }
- delete inst;
- }
-
- pStack->SetError(TX_OPENPAR, p->GetStart()); // missing parenthesis
-
- return nullptr;
-}
-
//////////////////////////////////////////////////////////////////////////////////////////
// compile a list of parameters
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 481335e..1b038cb 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -638,16 +638,6 @@ public:
void RestoreState(CBotStack* &pj, bool bMain) override;
};
-class CBotCondition : public CBotInstr
-{
-private:
-
-public:
-
- static
- CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
-};
-
#define MAX(a,b) ((a>b) ? a : b)
diff --git a/src/CBot/CBotIf.cpp b/src/CBot/CBotIf.cpp
index 781ec12..551ecb1 100644
--- a/src/CBot/CBotIf.cpp
+++ b/src/CBot/CBotIf.cpp
@@ -23,6 +23,7 @@
#include "CBot.h"
#include "CBotInstr/CBotBlock.h"
+#include "CBotInstr/CBotCondition.h"
// various constructors / destructors
CBotIf::CBotIf()
diff --git a/src/CBot/CBotInstr/CBotCondition.cpp b/src/CBot/CBotInstr/CBotCondition.cpp
new file mode 100644
index 0000000..d87c451
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotCondition.cpp
@@ -0,0 +1,50 @@
+/*
+ * 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 "CBotCondition.h"
+#include "CBotBoolExpr.h"
+
+// Local include
+
+// Global include
+
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotCondition::Compile(CBotToken* &p, CBotCStack* pStack)
+{
+ pStack->SetStartError(p->GetStart());
+ if (IsOfType(p, ID_OPENPAR))
+ {
+ CBotInstr* inst = CBotBoolExpr::Compile(p, pStack);
+ if (nullptr != inst)
+ {
+ if (IsOfType(p, ID_CLOSEPAR))
+ {
+ return inst;
+ }
+ pStack->SetError(TX_CLOSEPAR, p->GetStart()); // missing parenthesis
+ }
+ delete inst;
+ }
+
+ pStack->SetError(TX_OPENPAR, p->GetStart()); // missing parenthesis
+
+ return nullptr;
+}
diff --git a/src/CBot/CBotInstr/CBotCondition.h b/src/CBot/CBotInstr/CBotCondition.h
new file mode 100644
index 0000000..08996db
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotCondition.h
@@ -0,0 +1,46 @@
+/*
+ * 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 CBotCondition class This class has no constructor, because there
+ * is never an instance of this class the object returned by Compile is usually
+ * type CBotExpression
+ */
+class CBotCondition : public CBotInstr
+{
+public:
+
+ /*!
+ * \brief Compile Compile a statement such as "(condition)" the condition
+ * must be Boolean
+ * \param p
+ * \param pStack
+ * \return
+ */
+ static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
+};
diff --git a/src/CBot/CBotInstr/CBotDo.cpp b/src/CBot/CBotInstr/CBotDo.cpp
index 94c281d..3bf3aef 100644
--- a/src/CBot/CBotInstr/CBotDo.cpp
+++ b/src/CBot/CBotInstr/CBotDo.cpp
@@ -20,6 +20,7 @@
// Modules inlcude
#include "CBotDo.h"
#include "CBotBlock.h"
+#include "CBotCondition.h"
// Local include
diff --git a/src/CBot/CBotInstr/CBotWhile.cpp b/src/CBot/CBotInstr/CBotWhile.cpp
index 340cc23..c24084b 100644
--- a/src/CBot/CBotInstr/CBotWhile.cpp
+++ b/src/CBot/CBotInstr/CBotWhile.cpp
@@ -20,6 +20,7 @@
// Modules inlcude
#include "CBotWhile.h"
#include "CBotBlock.h"
+#include "CBotCondition.h"
// Local include
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 028c4d8..e94bf82 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -41,6 +41,7 @@ set(SOURCES
CBotInstr/CBotIndexExpr.cpp
CBotInstr/CBotFieldExpr.cpp
CBotInstr/CBotLeftExpr.cpp
+ CBotInstr/CBotCondition.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