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

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:33:59 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 a0c2c90c9c08e2a4df5e6ca726d0508b868659ed
Author: Grunaka <dev at romainbreton.fr>
Date:   Wed Nov 11 17:24:37 2015 +0100

    Moving CBotExprAlpha class in its own header and source files.
---
 src/CBot/CBot.cpp                    | 58 +--------------------------
 src/CBot/CBot.h                      | 16 --------
 src/CBot/CBotInstr/CBotExprAlpha.cpp | 77 ++++++++++++++++++++++++++++++++++++
 src/CBot/CBotInstr/CBotExprAlpha.h   | 67 +++++++++++++++++++++++++++++++
 src/CBot/CMakeLists.txt              |  1 +
 5 files changed, 146 insertions(+), 73 deletions(-)

diff --git a/src/CBot/CBot.cpp b/src/CBot/CBot.cpp
index 949ad2d..8332a1b 100644
--- a/src/CBot/CBot.cpp
+++ b/src/CBot/CBot.cpp
@@ -43,6 +43,7 @@
 #include "CBotInstr/CBotTry.h"
 #include "CBotInstr/CBotThrow.h"
 #include "CBotInstr/CBotWhile.h"
+#include "CBotInstr/CBotExprAlpha.h"
 
 // Local include
 
@@ -2871,63 +2872,6 @@ void CBotExprNum::RestoreState(CBotStack* &pj, bool bMain)
     if (bMain) pj->RestoreStack(this);
 }
 
-//////////////////////////////////////////////////////////////////////////////////////////
-
-
-//////////////////////////////////////////////////////////////////////////////////////
-// compile a token representing a string
-
-CBotExprAlpha::CBotExprAlpha()
-{
-    name    = "CBotExprAlpha";
-}
-
-CBotExprAlpha::~CBotExprAlpha()
-{
-}
-
-CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack)
-{
-    CBotCStack* pStk = pStack->TokenStack();
-
-    CBotExprAlpha* inst = new CBotExprAlpha();
-
-    inst->SetToken(p);
-    p = p->GetNext();
-
-    CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypString);
-    pStk->SetVar(var);
-
-    return pStack->Return(inst, pStk);
-}
-
-// execute, returns the corresponding string
-
-bool CBotExprAlpha::Execute(CBotStack* &pj)
-{
-    CBotStack*    pile = pj->AddStack(this);
-
-    if (pile->IfStep()) return false;
-
-    CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypString);
-
-    CBotString    chaine = m_token.GetString();
-    chaine = chaine.Mid(1, chaine.GetLength()-2);    // removes the quotes
-
-    var->SetValString(chaine);                    // value of the number
-
-    pile->SetVar(var);                            // put on the stack
-
-    return pj->Return(pile);
-}
-
-void CBotExprAlpha::RestoreState(CBotStack* &pj, bool bMain)
-{
-    if (bMain) pj->RestoreStack(this);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////////
-
 
 //////////////////////////////////////////////////////////////////////////////////////
 // compile a token representing true or false
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 5fb3959..cc1436a 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -1026,22 +1026,6 @@ public:
 
 
 
-// expression representing a string
-
-class CBotExprAlpha : public CBotInstr
-{
-private:
-
-public:
-                CBotExprAlpha();
-                ~CBotExprAlpha();
-    static
-    CBotInstr*    Compile(CBotToken* &p, CBotCStack* pStack);
-    bool        Execute(CBotStack* &pj) override;
-    void        RestoreState(CBotStack* &pj, bool bMain) override;
-};
-
-
 #define    MAX(a,b)    ((a>b) ? a : b)
 
 
diff --git a/src/CBot/CBotInstr/CBotExprAlpha.cpp b/src/CBot/CBotInstr/CBotExprAlpha.cpp
new file mode 100644
index 0000000..c412ac0
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotExprAlpha.cpp
@@ -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
+ */
+
+// Modules inlcude
+#include "CBotExprAlpha.h"
+
+// Local include
+
+// Global include
+
+////////////////////////////////////////////////////////////////////////////////
+CBotExprAlpha::CBotExprAlpha()
+{
+    name    = "CBotExprAlpha";
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotExprAlpha::~CBotExprAlpha()
+{
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotInstr* CBotExprAlpha::Compile(CBotToken* &p, CBotCStack* pStack)
+{
+    CBotCStack* pStk = pStack->TokenStack();
+
+    CBotExprAlpha* inst = new CBotExprAlpha();
+
+    inst->SetToken(p);
+    p = p->GetNext();
+
+    CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypString);
+    pStk->SetVar(var);
+
+    return pStack->Return(inst, pStk);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+bool CBotExprAlpha::Execute(CBotStack* &pj)
+{
+    CBotStack*    pile = pj->AddStack(this);
+
+    if (pile->IfStep()) return false;
+
+    CBotVar*    var = CBotVar::Create(static_cast<CBotToken*>(nullptr), CBotTypString);
+
+    CBotString    chaine = m_token.GetString();
+    chaine = chaine.Mid(1, chaine.GetLength()-2);    // removes the quotes
+
+    var->SetValString(chaine);                    // value of the number
+
+    pile->SetVar(var);                            // put on the stack
+
+    return pj->Return(pile);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotExprAlpha::RestoreState(CBotStack* &pj, bool bMain)
+{
+    if (bMain) pj->RestoreStack(this);
+}
diff --git a/src/CBot/CBotInstr/CBotExprAlpha.h b/src/CBot/CBotInstr/CBotExprAlpha.h
new file mode 100644
index 0000000..3f82060
--- /dev/null
+++ b/src/CBot/CBotInstr/CBotExprAlpha.h
@@ -0,0 +1,67 @@
+/*
+ * 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 CBotExprAlpha class Expression representing a string.
+ */
+class CBotExprAlpha : public CBotInstr
+{
+public:
+
+    /*!
+     * \brief CBotExprAlpha
+     */
+    CBotExprAlpha();
+
+    /*!
+     * \brief CBotExprAlpha
+     */
+    ~CBotExprAlpha();
+
+    /*!
+     * \brief Compile
+     * \param p
+     * \param pStack
+     * \return
+     */
+    static CBotInstr* Compile(CBotToken* &p, CBotCStack* pStack);
+
+    /*!
+     * \brief Execute Execute, returns the corresponding string.
+     * \param pj
+     * \return
+     */
+    bool Execute(CBotStack* &pj) override;
+
+    /*!
+     * \brief RestoreState
+     * \param pj
+     * \param bMain
+     */
+    void RestoreState(CBotStack* &pj, bool bMain) override;
+};
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index af6a1e9..60363d3 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -19,6 +19,7 @@ set(SOURCES
     CBotInstr/CBotTry.cpp
     CBotInstr/CBotCatch.cpp
     CBotInstr/CBotThrow.cpp
+    CBotInstr/CBotExprAlpha.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