[colobot] 86/377: Moving CBotLogicExpr 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 8ee0b7df5687f03a5224172f5108fa4002324a7f
Author: Grunaka <dev at romainbreton.fr>
Date: Wed Nov 11 21:03:16 2015 +0100
Moving CBotLogicExpr class in its own header and source files.
---
src/CBot/CBot.h | 19 --------
src/CBot/CBotInstr/CBotLogicExpr.cpp | 92 ++++++++++++++++++++++++++++++++++++
src/CBot/CBotInstr/CBotLogicExpr.h | 70 +++++++++++++++++++++++++++
src/CBot/CBotTwoOpExpr.cpp | 65 +------------------------
src/CBot/CMakeLists.txt | 1 +
5 files changed, 164 insertions(+), 83 deletions(-)
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 1ad497e..976789c 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -727,25 +727,6 @@ public:
void RestoreState(CBotStack* &pj, bool bMain) override;
};
-class CBotLogicExpr : public CBotInstr
-{
-private:
- CBotInstr* m_condition; // test to evaluate
- CBotInstr* m_op1; // left element
- CBotInstr* m_op2; // right element
- friend class CBotTwoOpExpr;
-
-public:
- CBotLogicExpr();
- ~CBotLogicExpr();
-// static
-// CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
- bool Execute(CBotStack* &pStack) override;
- void RestoreState(CBotStack* &pj, bool bMain) override;
-};
-
-
-
// all operations with two operands
diff --git a/src/CBot/CBotInstr/CBotLogicExpr.cpp b/src/CBot/CBotInstr/CBotLogicExpr.cpp
new file mode 100644
index 0000000..bfa6af1
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotLogicExpr.cpp
@@ -0,0 +1,92 @@
+/*
+ * 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 "CBotLogicExpr.h"
+
+// Local include
+
+// Global include
+
+////////////////////////////////////////////////////////////////////////////////
+CBotLogicExpr::CBotLogicExpr()
+{
+ m_condition =
+ m_op1 =
+ m_op2 = nullptr; // nullptr to be able to delete without other
+ name = "CBotLogicExpr"; // debug
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotLogicExpr::~CBotLogicExpr()
+{
+ delete m_condition;
+ delete m_op1;
+ delete m_op2;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotLogicExpr::Execute(CBotStack* &pStack)
+{
+ CBotStack* pStk1 = pStack->AddStack(this); // adds an item to the stack
+ // or return in case of recovery
+// if ( pStk1 == EOX ) return true;
+
+ if ( pStk1->GetState() == 0 )
+ {
+ if ( !m_condition->Execute(pStk1) ) return false;
+ if (!pStk1->SetState(1)) return false;
+ }
+
+ if ( pStk1->GetVal() == true )
+ {
+ if ( !m_op1->Execute(pStk1) ) return false;
+ }
+ else
+ {
+ if ( !m_op2->Execute(pStk1) ) return false;
+ }
+
+ return pStack->Return(pStk1); // transmits the result
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain)
+{
+ if ( !bMain ) return;
+
+ CBotStack* pStk1 = pStack->RestoreStack(this); // adds an item to the stack
+ if ( pStk1 == nullptr ) return;
+
+ if ( pStk1->GetState() == 0 )
+ {
+ m_condition->RestoreState(pStk1, bMain);
+ return;
+ }
+
+ if ( pStk1->GetVal() == true )
+ {
+ m_op1->RestoreState(pStk1, bMain);
+ }
+ else
+ {
+ m_op2->RestoreState(pStk1, bMain);
+ }
+}
+
diff --git a/src/CBot/CBotInstr/CBotLogicExpr.h b/src/CBot/CBotInstr/CBotLogicExpr.h
new file mode 100644
index 0000000..2bffc24
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotLogicExpr.h
@@ -0,0 +1,70 @@
+/*
+ * 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 CBotLogicExpr class
+ */
+class CBotLogicExpr : public CBotInstr
+{
+public:
+
+ /*!
+ * \brief CBotLogicExpr
+ */
+ CBotLogicExpr();
+
+ /*!
+ * \brief ~CBotLogicExpr
+ */
+ ~CBotLogicExpr();
+
+ /*!
+ * \brief Execute
+ * \param pStack
+ * \return
+ */
+ bool Execute(CBotStack* &pStack) override;
+
+ /*!
+ * \brief RestoreState
+ * \param pj
+ * \param bMain
+ */
+ void RestoreState(CBotStack* &pj, bool bMain) override;
+
+private:
+
+ //! Test to evaluate
+ CBotInstr* m_condition;
+ //! Left element
+ CBotInstr* m_op1;
+ //! Right element
+ CBotInstr* m_op2;
+ friend class CBotTwoOpExpr;
+};
diff --git a/src/CBot/CBotTwoOpExpr.cpp b/src/CBot/CBotTwoOpExpr.cpp
index 9f4cb2c..d9173d6 100644
--- a/src/CBot/CBotTwoOpExpr.cpp
+++ b/src/CBot/CBotTwoOpExpr.cpp
@@ -24,6 +24,7 @@
#include "CBot.h"
#include "CBotInstr/CBotParExpr.h"
+#include "CBotInstr/CBotLogicExpr.h"
#include <cassert>
@@ -50,22 +51,6 @@ CBotTwoOpExpr::~CBotTwoOpExpr()
delete m_rightop;
}
-CBotLogicExpr::CBotLogicExpr()
-{
- m_condition =
- m_op1 =
- m_op2 = nullptr; // nullptr to be able to delete without other
- name = "CBotLogicExpr"; // debug
-}
-
-CBotLogicExpr::~CBotLogicExpr()
-{
- delete m_condition;
- delete m_op1;
- delete m_op2;
-}
-
-
// type of operands accepted by operations
#define ENTIER ((1<<CBotTypByte)|(1<<CBotTypShort)|(1<<CBotTypChar)|(1<<CBotTypInt)|(1<<CBotTypLong))
#define FLOTANT ((1<<CBotTypFloat)|(1<<CBotTypDouble))
@@ -517,54 +502,6 @@ void CBotTwoOpExpr::RestoreState(CBotStack* &pStack, bool bMain)
}
}
-
-bool CBotLogicExpr::Execute(CBotStack* &pStack)
-{
- CBotStack* pStk1 = pStack->AddStack(this); // adds an item to the stack
- // or return in case of recovery
-// if ( pStk1 == EOX ) return true;
-
- if ( pStk1->GetState() == 0 )
- {
- if ( !m_condition->Execute(pStk1) ) return false;
- if (!pStk1->SetState(1)) return false;
- }
-
- if ( pStk1->GetVal() == true )
- {
- if ( !m_op1->Execute(pStk1) ) return false;
- }
- else
- {
- if ( !m_op2->Execute(pStk1) ) return false;
- }
-
- return pStack->Return(pStk1); // transmits the result
-}
-
-void CBotLogicExpr::RestoreState(CBotStack* &pStack, bool bMain)
-{
- if ( !bMain ) return;
-
- CBotStack* pStk1 = pStack->RestoreStack(this); // adds an item to the stack
- if ( pStk1 == nullptr ) return;
-
- if ( pStk1->GetState() == 0 )
- {
- m_condition->RestoreState(pStk1, bMain);
- return;
- }
-
- if ( pStk1->GetVal() == true )
- {
- m_op1->RestoreState(pStk1, bMain);
- }
- else
- {
- m_op2->RestoreState(pStk1, bMain);
- }
-}
-
#if 0
void t()
{
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index 697dd01..150724a 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -36,6 +36,7 @@ set(SOURCES
CBotInstr/CBotExprUnaire.cpp
CBotInstr/CBotParExpr.cpp
CBotInstr/CBotBoolExpr.cpp
+ CBotInstr/CBotLogicExpr.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