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

Didier Raboud odyx at moszumanska.debian.org
Wed Mar 30 13:34:04 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 143eecd7918409af0b3e3b91545d5556bf68d1aa
Author: Grunaka <dev at romainbreton.fr>
Date:   Sun Nov 15 18:59:15 2015 +0100

    Moving CBotCallMethode class in its own header and source files.
---
 src/CBot/CBot.h              |  34 --------
 src/CBot/CBotCallMethode.cpp | 179 +++++++++++++++++++++++++++++++++++++++++++
 src/CBot/CBotCallMethode.h   | 115 +++++++++++++++++++++++++++
 src/CBot/CBotClass.cpp       |   1 +
 src/CBot/CBotProgram.cpp     | 145 -----------------------------------
 src/CBot/CMakeLists.txt      |   1 +
 6 files changed, 296 insertions(+), 179 deletions(-)

diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index 56e483c..44b251b 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -490,37 +490,3 @@ extern float GetNumFloat( const char* p );
 #if 0
 extern void DEBUG( const char* text, int val, CBotStack* pile );
 #endif
-
-///////////////////////////////////////////
-// class managing the methods declared by AddFunction on a class
-
-class CBotCallMethode
-{
-private:
-    CBotString    m_name;
-    bool        (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user);
-    CBotTypResult
-                (*m_rComp) (CBotVar* pThis, CBotVar* &pVar);
-    CBotCallMethode*    m_next;
-    friend class CBotClass;
-    long        m_nFuncIdent;
-
-public:
-                CBotCallMethode(const char* name,
-                         bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
-                         CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
-                ~CBotCallMethode();
-
-    CBotTypResult
-                CompileCall(const char* name, CBotVar* pThis,
-                            CBotVar** ppVars, CBotCStack* pStack,
-                            long& nIdent);
-
-    int            DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pFunc);
-
-    CBotString    GetName();
-    CBotCallMethode*    Next();
-    void        AddNext(CBotCallMethode* p);
-
-};
-
diff --git a/src/CBot/CBotCallMethode.cpp b/src/CBot/CBotCallMethode.cpp
new file mode 100644
index 0000000..6611129
--- /dev/null
+++ b/src/CBot/CBotCallMethode.cpp
@@ -0,0 +1,179 @@
+/*
+ * 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 "CBotCallMethode.h"
+
+#include "CBotUtils.h"
+#include "CBotStack.h"
+
+// Local include
+
+// Global include
+
+
+////////////////////////////////////////////////////////////////////////////////
+CBotCallMethode::CBotCallMethode(const char* name,
+                   bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
+                   CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
+{
+    m_name       = name;
+    m_rExec      = rExec;
+    m_rComp      = rCompile;
+    m_next       = nullptr;
+    m_nFuncIdent = CBotVar::NextUniqNum();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotCallMethode::~CBotCallMethode()
+{
+    delete m_next;
+    m_next = nullptr;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotTypResult CBotCallMethode::CompileCall(const char* name,
+                                           CBotVar* pThis,
+                                           CBotVar** ppVar,
+                                           CBotCStack* pStack,
+                                           long& nIdent)
+{
+    CBotCallMethode*    pt = this;
+    nIdent = 0;
+
+    while ( pt != nullptr )
+    {
+        if ( pt->m_name == name )
+        {
+            CBotVar*    pVar = MakeListVars(ppVar, true);
+            CBotVar*    pVar2 = pVar;
+            CBotTypResult r = pt->m_rComp(pThis, pVar2);
+            int ret = r.GetType();
+            if ( ret > 20 )
+            {
+                if (pVar2) pStack->SetError(ret, pVar2->GetToken());
+            }
+            delete pVar;
+            nIdent = pt->m_nFuncIdent;
+            return r;
+        }
+        pt = pt->m_next;
+    }
+    return CBotTypResult(-1);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotString CBotCallMethode::GetName()
+{
+    return  m_name;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotCallMethode* CBotCallMethode::Next()
+{
+    return  m_next;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotCallMethode::AddNext(CBotCallMethode* pt)
+{
+    CBotCallMethode* p = this;
+    while ( p->m_next != nullptr ) p = p->m_next;
+
+    p->m_next = pt;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+int CBotCallMethode::DoCall(long& nIdent,
+                            const char* name,
+                            CBotVar* pThis,
+                            CBotVar** ppVars,
+                            CBotVar* &pResult,
+                            CBotStack* pStack,
+                            CBotToken* pToken)
+{
+    CBotCallMethode*    pt = this;
+
+    // search by the identifier
+
+    if ( nIdent ) while ( pt != nullptr )
+    {
+        if ( pt->m_nFuncIdent == nIdent )
+        {
+            // lists the parameters depending on the contents of the stack (pStackVar)
+
+            CBotVar*    pVar = MakeListVars(ppVars, true);
+            CBotVar*    pVarToDelete = pVar;
+
+            // then calls the routine external to the module
+
+            int         Exception = 0;
+            int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetPUser());
+            pStack->SetVar(pResult);
+
+            if (res == false)
+            {
+                if (Exception!=0)
+                {
+//                  pStack->SetError(Exception, pVar->GetToken());
+                    pStack->SetError(Exception, pToken);
+                }
+                delete pVarToDelete;
+                return false;
+            }
+            delete pVarToDelete;
+            return true;
+        }
+        pt = pt->m_next;
+    }
+
+    // search by name
+
+    while ( pt != nullptr )
+    {
+        if ( pt->m_name == name )
+        {
+            // lists the parameters depending on the contents of the stack (pStackVar)
+
+            CBotVar*    pVar = MakeListVars(ppVars, true);
+            CBotVar*    pVarToDelete = pVar;
+
+            int         Exception = 0;
+            int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetPUser());
+            pStack->SetVar(pResult);
+
+            if (res == false)
+            {
+                if (Exception!=0)
+                {
+//                  pStack->SetError(Exception, pVar->GetToken());
+                    pStack->SetError(Exception, pToken);
+                }
+                delete pVarToDelete;
+                return false;
+            }
+            delete pVarToDelete;
+            nIdent = pt->m_nFuncIdent;
+            return true;
+        }
+        pt = pt->m_next;
+    }
+
+    return -1;
+}
diff --git a/src/CBot/CBotCallMethode.h b/src/CBot/CBotCallMethode.h
new file mode 100644
index 0000000..8ea4025
--- /dev/null
+++ b/src/CBot/CBotCallMethode.h
@@ -0,0 +1,115 @@
+/*
+ * 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 CBotCallMethode class Class managing the methods declared by
+ * AddFunction on a class.
+ */
+class CBotCallMethode
+{
+public:
+
+    /*!
+     * \brief CBotCallMethode
+     * \param name
+     * \param rExec
+     * \param rCompile
+     */
+    CBotCallMethode(const char* name,
+                    bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
+                    CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar));
+
+    /*!
+     * \brief ~CBotCallMethode
+     */
+    ~CBotCallMethode();
+
+    /*!
+     * \brief CompileCall Is acceptable by a call procedure name and given
+     * parameters.
+     * \param name
+     * \param pThis
+     * \param ppVars
+     * \param pStack
+     * \param nIdent
+     * \return
+     */
+    CBotTypResult CompileCall(const char* name,
+                              CBotVar* pThis,
+                              CBotVar** ppVars,
+                              CBotCStack* pStack,
+                              long& nIdent);
+
+    /*!
+     * \brief DoCall
+     * \param nIdent
+     * \param name
+     * \param pThis
+     * \param ppVars
+     * \param pResult
+     * \param pStack
+     * \param pFunc
+     * \return
+     */
+    int DoCall(long& nIdent,
+               const char* name,
+               CBotVar* pThis,
+               CBotVar** ppVars,
+               CBotVar* &pResult,
+               CBotStack* pStack,
+               CBotToken* pFunc);
+
+    /*!
+     * \brief GetName
+     * \return
+     */
+    CBotString GetName();
+
+    /*!
+     * \brief Next
+     * \return
+     */
+    CBotCallMethode* Next();
+
+    /*!
+     * \brief AddNext
+     * \param p
+     */
+    void AddNext(CBotCallMethode* p);
+
+private:
+    CBotString m_name;
+    bool (*m_rExec) (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user);
+    CBotTypResult (*m_rComp) (CBotVar* pThis, CBotVar* &pVar);
+    CBotCallMethode* m_next;
+    friend class CBotClass;
+    long m_nFuncIdent;
+
+};
+
diff --git a/src/CBot/CBotClass.cpp b/src/CBot/CBotClass.cpp
index d2d03e9..741dfb9 100644
--- a/src/CBot/CBotClass.cpp
+++ b/src/CBot/CBotClass.cpp
@@ -31,6 +31,7 @@
 #include "CBotCall.h"
 #include "CBotStack.h"
 #include "CBotUtils.h"
+#include "CBotCallMethode.h"
 
 // Local include
 
diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp
index 8e492ba..c06cfbe 100644
--- a/src/CBot/CBotProgram.cpp
+++ b/src/CBot/CBotProgram.cpp
@@ -641,148 +641,3 @@ void CBotProgram::Free()
     CBotCall ::Free() ;
     CBotClass::Free() ;
 }
-
-
-////////////////////////////////////////////////////////////////////////////////
-CBotCallMethode::CBotCallMethode(const char* name,
-                   bool rExec (CBotVar* pThis, CBotVar* pVar, CBotVar* pResult, int& Exception, void* user),
-                   CBotTypResult rCompile (CBotVar* pThis, CBotVar* &pVar))
-{
-    m_name       = name;
-    m_rExec      = rExec;
-    m_rComp      = rCompile;
-    m_next       = nullptr;
-    m_nFuncIdent = CBotVar::NextUniqNum();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotCallMethode::~CBotCallMethode()
-{
-    delete m_next;
-    m_next = nullptr;
-}
-
-// is acceptable by a call procedure name
-// and given parameters
-////////////////////////////////////////////////////////////////////////////////
-CBotTypResult CBotCallMethode::CompileCall(const char* name, CBotVar* pThis,
-                                           CBotVar** ppVar, CBotCStack* pStack,
-                                           long& nIdent)
-{
-    CBotCallMethode*    pt = this;
-    nIdent = 0;
-
-    while ( pt != nullptr )
-    {
-        if ( pt->m_name == name )
-        {
-            CBotVar*    pVar = MakeListVars(ppVar, true);
-            CBotVar*    pVar2 = pVar;
-            CBotTypResult r = pt->m_rComp(pThis, pVar2);
-            int ret = r.GetType();
-            if ( ret > 20 )
-            {
-                if (pVar2) pStack->SetError(ret, pVar2->GetToken());
-            }
-            delete pVar;
-            nIdent = pt->m_nFuncIdent;
-            return r;
-        }
-        pt = pt->m_next;
-    }
-    return CBotTypResult(-1);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotString CBotCallMethode::GetName()
-{
-    return  m_name;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotCallMethode* CBotCallMethode::Next()
-{
-    return  m_next;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void CBotCallMethode::AddNext(CBotCallMethode* pt)
-{
-    CBotCallMethode* p = this;
-    while ( p->m_next != nullptr ) p = p->m_next;
-
-    p->m_next = pt;
-}
-
-////////////////////////////////////////////////////////////////////////////////
-int CBotCallMethode::DoCall(long& nIdent, const char* name, CBotVar* pThis, CBotVar** ppVars, CBotVar* &pResult, CBotStack* pStack, CBotToken* pToken)
-{
-    CBotCallMethode*    pt = this;
-
-    // search by the identifier
-
-    if ( nIdent ) while ( pt != nullptr )
-    {
-        if ( pt->m_nFuncIdent == nIdent )
-        {
-            // lists the parameters depending on the contents of the stack (pStackVar)
-
-            CBotVar*    pVar = MakeListVars(ppVars, true);
-            CBotVar*    pVarToDelete = pVar;
-
-            // then calls the routine external to the module
-
-            int         Exception = 0;
-            int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetPUser());
-            pStack->SetVar(pResult);
-
-            if (res == false)
-            {
-                if (Exception!=0)
-                {
-//                  pStack->SetError(Exception, pVar->GetToken());
-                    pStack->SetError(Exception, pToken);
-                }
-                delete pVarToDelete;
-                return false;
-            }
-            delete pVarToDelete;
-            return true;
-        }
-        pt = pt->m_next;
-    }
-
-    // search by name
-
-    while ( pt != nullptr )
-    {
-        if ( pt->m_name == name )
-        {
-            // lists the parameters depending on the contents of the stack (pStackVar)
-
-            CBotVar*    pVar = MakeListVars(ppVars, true);
-            CBotVar*    pVarToDelete = pVar;
-
-            int         Exception = 0;
-            int res = pt->m_rExec(pThis, pVar, pResult, Exception, pStack->GetPUser());
-            pStack->SetVar(pResult);
-
-            if (res == false)
-            {
-                if (Exception!=0)
-                {
-//                  pStack->SetError(Exception, pVar->GetToken());
-                    pStack->SetError(Exception, pToken);
-                }
-                delete pVarToDelete;
-                return false;
-            }
-            delete pVarToDelete;
-            nIdent = pt->m_nFuncIdent;
-            return true;
-        }
-        pt = pt->m_next;
-    }
-
-    return -1;
-}
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index c2a953f..254bb66 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -9,6 +9,7 @@ set(SOURCES
     CBotCall.cpp
     CBotUtils.cpp
     CBotDefParam.cpp
+    CBotCallMethode.cpp
     CBotInstr/CBotWhile.cpp
     CBotInstr/CBotDo.cpp
     CBotInstr/CBotFor.cpp

-- 
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