[colobot] 113/377: Moving CBotVarClass 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 c624d65649c24cf79958c92f7ee27cfc5bab588f
Author: Grunaka <dev at romainbreton.fr>
Date: Sun Nov 15 19:25:35 2015 +0100
Moving CBotVarClass class in its own header and source files.
---
src/CBot/CBot.h | 59 -----------
src/CBot/CBotDefParam.cpp | 2 +
src/CBot/CBotInstr/CBotClassInst.cpp | 1 +
src/CBot/CBotInstr/CBotFieldExpr.cpp | 2 +
src/CBot/CBotStack.cpp | 1 +
src/CBot/CBotVar.cpp | 92 +----------------
src/CBot/CBotVar/CBotVarArray.cpp | 1 +
src/CBot/CBotVar/CBotVarClass.cpp | 110 ++++++++++++++++++++
src/CBot/CBotVar/CBotVarClass.h | 194 +++++++++++++++++++++++++++++++++++
src/CBot/CBotVar/CBotVarPointer.cpp | 2 +-
src/CBot/CMakeLists.txt | 1 +
11 files changed, 314 insertions(+), 151 deletions(-)
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index a2d083a..8c5f411 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -373,65 +373,6 @@ public:
};
-// class management class instances
-class CBotVarClass : public CBotVar
-{
-private:
- static
- CBotVarClass* m_ExClass; // list of existing instances at some point
- CBotVarClass* m_ExNext; // for this general list
- CBotVarClass* m_ExPrev; // for this general list
-
-private:
- CBotClass* m_pClass; // the class definition
- CBotVarClass* m_pParent; // the instance of a parent class
- CBotVar* m_pVar; // contents
- friend class CBotVar; // my daddy is a buddy WHAT? :D(\TODO mon papa est un copain )
- friend class CBotVarPointer; // and also the pointer
- int m_CptUse; // counter usage
- long m_ItemIdent; // identifier (unique) of an instance
- bool m_bConstructor; // set if a constructor has been called
-
-public:
- CBotVarClass( const CBotToken* name, const CBotTypResult& type );
-// CBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent );
- ~CBotVarClass();
-// void InitCBotVarClass( const CBotToken* name, CBotTypResult& type, int &nIdent );
-
- void Copy(CBotVar* pSrc, bool bName=true) override;
- void SetClass(CBotClass* pClass) override; //, int &nIdent);
- CBotClass* GetClass() override;
- CBotVar* GetItem(const char* name) override; // return an element of a class according to its name (*)
- CBotVar* GetItemRef(int nIdent) override;
-
- CBotVar* GetItem(int n, bool bExtend) override;
- CBotVar* GetItemList() override;
-
- CBotString GetValString() override;
-
- bool Save1State(FILE* pf) override;
- void Maj(void* pUser, bool bContinue) override;
-
- void IncrementUse(); // a reference to incrementation
- void DecrementUse(); // a reference to decrementation
-
- CBotVarClass*
- GetPointer() override;
- void SetItemList(CBotVar* pVar);
-
- void SetIdent(long n) override;
-
- static CBotVarClass* Find(long id);
-
-
-// CBotVar* GetMyThis();
-
- bool Eq(CBotVar* left, CBotVar* right) override;
- bool Ne(CBotVar* left, CBotVar* right) override;
-
- void ConstructorSet() override;
-};
-
extern CBotInstr* CompileParams(CBotToken* &p, CBotCStack* pStack, CBotVar** ppVars);
extern bool TypeCompatible( CBotTypResult& type1, CBotTypResult& type2, int op = 0 );
diff --git a/src/CBot/CBotDefParam.cpp b/src/CBot/CBotDefParam.cpp
index 3a91f60..601e567 100644
--- a/src/CBot/CBotDefParam.cpp
+++ b/src/CBot/CBotDefParam.cpp
@@ -24,6 +24,8 @@
#include "CBotUtils.h"
+#include "CBotVar/CBotVarClass.h"
+
// Local include
// Global include
diff --git a/src/CBot/CBotInstr/CBotClassInst.cpp b/src/CBot/CBotInstr/CBotClassInst.cpp
index d473188..8426422 100644
--- a/src/CBot/CBotInstr/CBotClassInst.cpp
+++ b/src/CBot/CBotInstr/CBotClassInst.cpp
@@ -27,6 +27,7 @@
#include "CBotClass.h"
#include "CBotVar/CBotVarPointer.h"
+#include "CBotVar/CBotVarClass.h"
// Local include
diff --git a/src/CBot/CBotInstr/CBotFieldExpr.cpp b/src/CBot/CBotInstr/CBotFieldExpr.cpp
index 592d4a7..bad06d9 100644
--- a/src/CBot/CBotInstr/CBotFieldExpr.cpp
+++ b/src/CBot/CBotInstr/CBotFieldExpr.cpp
@@ -23,6 +23,8 @@
#include "CBotStack.h"
#include "CBotClass.h"
+#include "CBotVar/CBotVarClass.h"
+
// Local include
// Global include
diff --git a/src/CBot/CBotStack.cpp b/src/CBot/CBotStack.cpp
index 5678c8f..1a21dd2 100644
--- a/src/CBot/CBotStack.cpp
+++ b/src/CBot/CBotStack.cpp
@@ -24,6 +24,7 @@
#include "CBotInstr/CBotFunction.h"
#include "CBotVar/CBotVarPointer.h"
+#include "CBotVar/CBotVarClass.h"
// Local include
diff --git a/src/CBot/CBotVar.cpp b/src/CBot/CBotVar.cpp
index ad73639..dc2517d 100644
--- a/src/CBot/CBotVar.cpp
+++ b/src/CBot/CBotVar.cpp
@@ -29,6 +29,7 @@
#include "CBotVar/CBotVarArray.h"
#include "CBotVar/CBotVarPointer.h"
+#include "CBotVar/CBotVarClass.h"
#include "CBotDefines.h"
#include "CBotClass.h"
@@ -117,97 +118,6 @@ CBotVarBoolean::CBotVarBoolean( const CBotToken* name )
m_val = 0;
}
-CBotVarClass* CBotVarClass::m_ExClass = nullptr;
-
-CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type)
-{
-/*
-// int nIdent = 0;
- InitCBotVarClass( name, type ) //, nIdent );
-}
-
-CBotVarClass::CBotVarClass( const CBotToken* name, CBotTypResult& type) //, int &nIdent )
-{
- InitCBotVarClass( name, type ); //, nIdent );
-}
-
-void CBotVarClass::InitCBotVarClass( const CBotToken* name, CBotTypResult& type ) //, int &nIdent )
-{*/
- if ( !type.Eq(CBotTypClass) &&
- !type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types
- !type.Eq(CBotTypPointer) &&
- !type.Eq(CBotTypArrayPointer) &&
- !type.Eq(CBotTypArrayBody)) assert(0);
-
- m_token = new CBotToken(name);
- m_next = nullptr;
- m_pMyThis = nullptr;
- m_pUserPtr = OBJECTCREATED;//nullptr;
- m_InitExpr = nullptr;
- m_LimExpr = nullptr;
- m_pVar = nullptr;
- m_type = type;
- if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody );
- else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass );
- // officel type for this object
-
- m_pClass = nullptr;
- m_pParent = nullptr;
- m_binit = InitType::UNDEF;
- m_bStatic = false;
- m_mPrivate = 0;
- m_bConstructor = false;
- m_CptUse = 0;
- m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum();
-
- // se place tout seul dans la liste
- // TODO stands alone in the list (stands only in a list)
- if (m_ExClass) m_ExClass->m_ExPrev = this;
- m_ExNext = m_ExClass;
- m_ExPrev = nullptr;
- m_ExClass = this;
-
- CBotClass* pClass = type.GetClass();
- CBotClass* pClass2 = pClass->GetParent();
- if ( pClass2 != nullptr )
- {
- // also creates an instance of the parent class
- m_pParent = new CBotVarClass(name, CBotTypResult(type.GetType(),pClass2) ); //, nIdent);
- }
-
- SetClass( pClass ); //, nIdent );
-
-}
-
-CBotVarClass::~CBotVarClass( )
-{
- if ( m_CptUse != 0 )
- assert(0);
-
- if ( m_pParent ) delete m_pParent;
- m_pParent = nullptr;
-
- // frees the indirect object if necessary
-// if ( m_Indirect != nullptr )
-// m_Indirect->DecrementUse();
-
- // removes the class list
- if ( m_ExPrev ) m_ExPrev->m_ExNext = m_ExNext;
- else m_ExClass = m_ExNext;
-
- if ( m_ExNext ) m_ExNext->m_ExPrev = m_ExPrev;
- m_ExPrev = nullptr;
- m_ExNext = nullptr;
-
- delete m_pVar;
-}
-
-void CBotVarClass::ConstructorSet()
-{
- m_bConstructor = true;
-}
-
-
CBotVar::~CBotVar( )
{
delete m_token;
diff --git a/src/CBot/CBotVar/CBotVarArray.cpp b/src/CBot/CBotVar/CBotVarArray.cpp
index 35f55a5..b030e7a 100644
--- a/src/CBot/CBotVar/CBotVarArray.cpp
+++ b/src/CBot/CBotVar/CBotVarArray.cpp
@@ -19,6 +19,7 @@
// Modules inlcude
#include "CBotVarArray.h"
+#include "CBotVarClass.h"
// Local include
diff --git a/src/CBot/CBotVar/CBotVarClass.cpp b/src/CBot/CBotVar/CBotVarClass.cpp
new file mode 100644
index 0000000..73d14ac
--- /dev/null
+++ b/src/CBot/CBotVar/CBotVarClass.cpp
@@ -0,0 +1,110 @@
+/*
+ * 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 "CBotVarClass.h"
+
+#include "CBotClass.h"
+
+// Local include
+
+// Global include
+#include <cassert>
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVarClass* CBotVarClass::m_ExClass = nullptr;
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVarClass::CBotVarClass( const CBotToken* name, const CBotTypResult& type)
+{
+ if ( !type.Eq(CBotTypClass) &&
+ !type.Eq(CBotTypIntrinsic) && // by convenience there accepts these types
+ !type.Eq(CBotTypPointer) &&
+ !type.Eq(CBotTypArrayPointer) &&
+ !type.Eq(CBotTypArrayBody)) assert(0);
+
+ m_token = new CBotToken(name);
+ m_next = nullptr;
+ m_pMyThis = nullptr;
+ m_pUserPtr = OBJECTCREATED;//nullptr;
+ m_InitExpr = nullptr;
+ m_LimExpr = nullptr;
+ m_pVar = nullptr;
+ m_type = type;
+ if ( type.Eq(CBotTypArrayPointer) ) m_type.SetType( CBotTypArrayBody );
+ else if ( !type.Eq(CBotTypArrayBody) ) m_type.SetType( CBotTypClass );
+ // officel type for this object
+
+ m_pClass = nullptr;
+ m_pParent = nullptr;
+ m_binit = InitType::UNDEF;
+ m_bStatic = false;
+ m_mPrivate = 0;
+ m_bConstructor = false;
+ m_CptUse = 0;
+ m_ItemIdent = type.Eq(CBotTypIntrinsic) ? 0 : CBotVar::NextUniqNum();
+
+ // se place tout seul dans la liste
+ // TODO stands alone in the list (stands only in a list)
+ if (m_ExClass) m_ExClass->m_ExPrev = this;
+ m_ExNext = m_ExClass;
+ m_ExPrev = nullptr;
+ m_ExClass = this;
+
+ CBotClass* pClass = type.GetClass();
+ CBotClass* pClass2 = pClass->GetParent();
+ if ( pClass2 != nullptr )
+ {
+ // also creates an instance of the parent class
+ m_pParent = new CBotVarClass(name, CBotTypResult(type.GetType(),pClass2) ); //, nIdent);
+ }
+
+ SetClass( pClass ); //, nIdent );
+
+}
+
+////////////////////////////////////////////////////////////////////////////////
+CBotVarClass::~CBotVarClass( )
+{
+ if ( m_CptUse != 0 )
+ assert(0);
+
+ if ( m_pParent ) delete m_pParent;
+ m_pParent = nullptr;
+
+ // frees the indirect object if necessary
+// if ( m_Indirect != nullptr )
+// m_Indirect->DecrementUse();
+
+ // removes the class list
+ if ( m_ExPrev ) m_ExPrev->m_ExNext = m_ExNext;
+ else m_ExClass = m_ExNext;
+
+ if ( m_ExNext ) m_ExNext->m_ExPrev = m_ExPrev;
+ m_ExPrev = nullptr;
+ m_ExNext = nullptr;
+
+ delete m_pVar;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+void CBotVarClass::ConstructorSet()
+{
+ m_bConstructor = true;
+}
diff --git a/src/CBot/CBotVar/CBotVarClass.h b/src/CBot/CBotVar/CBotVarClass.h
new file mode 100644
index 0000000..b6a256f
--- /dev/null
+++ b/src/CBot/CBotVar/CBotVarClass.h
@@ -0,0 +1,194 @@
+/*
+ * 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 CBotVarClass class Class management class instances.
+ */
+class CBotVarClass : public CBotVar
+{
+public:
+
+ /*!
+ * \brief CBotVarClass
+ * \param name
+ * \param type
+ */
+ CBotVarClass( const CBotToken* name, const CBotTypResult& type );
+
+ /*!
+ * \brief ~CBotVarClass
+ */
+ ~CBotVarClass();
+
+ /*!
+ * \brief Copy
+ * \param pSrc
+ * \param bName
+ */
+ void Copy(CBotVar* pSrc, bool bName=true) override;
+
+ /*!
+ * \brief SetClass
+ * \param pClass
+ */
+ void SetClass(CBotClass* pClass) override;
+
+ /*!
+ * \brief GetClass
+ * \return
+ */
+ CBotClass* GetClass() override;
+
+ /*!
+ * \brief GetItem Return an element of a class according to its name (*).
+ * \param name
+ * \return
+ */
+ CBotVar* GetItem(const char* name) override;
+
+ /*!
+ * \brief GetItemRef
+ * \param nIdent
+ * \return
+ */
+ CBotVar* GetItemRef(int nIdent) override;
+
+ /*!
+ * \brief GetItem
+ * \param n
+ * \param bExtend
+ * \return
+ */
+ CBotVar* GetItem(int n, bool bExtend) override;
+
+ /*!
+ * \brief GetItemList
+ * \return
+ */
+ CBotVar* GetItemList() override;
+
+ /*!
+ * \brief GetValString
+ * \return
+ */
+ CBotString GetValString() override;
+
+ /*!
+ * \brief Save1State
+ * \param pf
+ * \return
+ */
+ bool Save1State(FILE* pf) override;
+
+ /*!
+ * \brief Maj
+ * \param pUser
+ * \param bContinue
+ */
+ void Maj(void* pUser, bool bContinue) override;
+
+ /*!
+ * \brief IncrementUse A reference to incrementation.
+ */
+ void IncrementUse();
+
+ /*!
+ * \brief DecrementUse A reference to decrementation.
+ */
+ void DecrementUse();
+
+ /*!
+ * \brief GetPointer
+ * \return
+ */
+ CBotVarClass* GetPointer() override;
+
+ /*!
+ * \brief SetItemList
+ * \param pVar
+ */
+ void SetItemList(CBotVar* pVar);
+
+ /*!
+ * \brief SetIdent
+ * \param n
+ */
+ void SetIdent(long n) override;
+
+ /*!
+ * \brief Find
+ * \param id
+ * \return
+ */
+ static CBotVarClass* Find(long id);
+
+ /*!
+ * \brief Eq
+ * \param left
+ * \param right
+ * \return
+ */
+ bool Eq(CBotVar* left, CBotVar* right) override;
+
+ /*!
+ * \brief Ne
+ * \param left
+ * \param right
+ * \return
+ */
+ bool Ne(CBotVar* left, CBotVar* right) override;
+
+ /*!
+ * \brief ConstructorSet
+ */
+ void ConstructorSet() override;
+
+private:
+ //! List of existing instances at some point.
+ static CBotVarClass* m_ExClass;
+ //! For this general list.
+ CBotVarClass* m_ExNext;
+ //! For this general list.
+ CBotVarClass* m_ExPrev;
+ //! The class definition.
+ CBotClass* m_pClass;
+ //! The instance of a parent class.
+ CBotVarClass* m_pParent;
+ //! Contents.
+ CBotVar* m_pVar;
+ //! Counter usage.
+ int m_CptUse;
+ //! Identifier (unique) of an instance.
+ long m_ItemIdent;
+ //! Set if a constructor has been called.
+ bool m_bConstructor;
+
+ friend class CBotVar;
+ friend class CBotVarPointer;
+};
diff --git a/src/CBot/CBotVar/CBotVarPointer.cpp b/src/CBot/CBotVar/CBotVarPointer.cpp
index c669a2a..df33322 100644
--- a/src/CBot/CBotVar/CBotVarPointer.cpp
+++ b/src/CBot/CBotVar/CBotVarPointer.cpp
@@ -22,7 +22,7 @@
#include "CBotToken.h"
#include "CBot.h"
#include "CBotClass.h"
-
+#include "CBotVarClass.h"
// Local include
// Global include
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index a8ce7ac..098868e 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -57,6 +57,7 @@ set(SOURCES
CBotInstr/CBotFunction.cpp
CBotVar/CBotVarArray.cpp
CBotVar/CBotVarPointer.cpp
+ CBotVar/CBotVarClass.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