[colobot] 157/377: Removed CBotStringArray
Didier Raboud
odyx at moszumanska.debian.org
Wed Mar 30 13:34:10 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 3eeab0f9b788e66a299bcf19a99b6ec0df8648de
Author: krzys-h <krzys_h at interia.pl>
Date: Sun Dec 20 14:49:30 2015 +0100
Removed CBotStringArray
---
src/CBot/CBot.h | 1 -
src/CBot/CBotInstr/CBotInstr.cpp | 6 +--
src/CBot/CBotInstr/CBotInstr.h | 8 +---
src/CBot/CBotProgram.cpp | 6 +--
src/CBot/CBotProgram.h | 4 +-
src/CBot/CBotStringArray.cpp | 61 -------------------------------
src/CBot/CBotStringArray.h | 79 ----------------------------------------
src/CBot/CBotToken.cpp | 24 ++++++------
src/CBot/CBotToken.h | 11 ++----
src/CBot/CMakeLists.txt | 1 -
src/script/script.cpp | 8 ++--
test/cbot/console/main.cpp | 7 ++--
12 files changed, 33 insertions(+), 183 deletions(-)
diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h
index d0f42f1..7832144 100644
--- a/src/CBot/CBot.h
+++ b/src/CBot/CBot.h
@@ -26,7 +26,6 @@
// Modules inlcude
#include "CBot/CBotFileUtils.h"
#include "CBot/CBotString.h"
-#include "CBot/CBotStringArray.h"
#include "CBot/CBotClass.h"
#include "CBot/CBotToken.h"
#include "CBot/CBotProgram.h"
diff --git a/src/CBot/CBotInstr/CBotInstr.cpp b/src/CBot/CBotInstr/CBotInstr.cpp
index 9d6aac3..66aff75 100644
--- a/src/CBot/CBotInstr/CBotInstr.cpp
+++ b/src/CBot/CBotInstr/CBotInstr.cpp
@@ -50,7 +50,7 @@
////////////////////////////////////////////////////////////////////////////////
int CBotInstr::m_LoopLvl = 0;
-CBotStringArray CBotInstr::m_labelLvl = CBotStringArray();
+std::vector<CBotString> CBotInstr::m_labelLvl = std::vector<CBotString>();
////////////////////////////////////////////////////////////////////////////////
CBotInstr::CBotInstr()
@@ -74,7 +74,7 @@ CBotInstr::~CBotInstr()
////////////////////////////////////////////////////////////////////////////////
void CBotInstr::IncLvl(CBotString& label)
{
- m_labelLvl.SetSize(m_LoopLvl+1);
+ m_labelLvl.resize(m_LoopLvl+1);
m_labelLvl[m_LoopLvl] = label;
m_LoopLvl++;
}
@@ -82,7 +82,7 @@ void CBotInstr::IncLvl(CBotString& label)
////////////////////////////////////////////////////////////////////////////////
void CBotInstr::IncLvl()
{
- m_labelLvl.SetSize(m_LoopLvl+1);
+ m_labelLvl.resize(m_LoopLvl+1);
m_labelLvl[m_LoopLvl] = "#SWITCH";
m_LoopLvl++;
}
diff --git a/src/CBot/CBotInstr/CBotInstr.h b/src/CBot/CBotInstr/CBotInstr.h
index acf3678..9ed637c 100644
--- a/src/CBot/CBotInstr/CBotInstr.h
+++ b/src/CBot/CBotInstr/CBotInstr.h
@@ -19,14 +19,10 @@
#pragma once
-// Modules inlcude
#include "CBot/CBotToken.h"
-
#include "CBot/CBotCStack.h"
-// Local include
-
-// Global include
+#include <vector>
/*
for example, the following program
@@ -262,5 +258,5 @@ protected:
private:
//! List of labels used.
- static CBotStringArray m_labelLvl;
+ static std::vector<CBotString> m_labelLvl;
};
diff --git a/src/CBot/CBotProgram.cpp b/src/CBot/CBotProgram.cpp
index e2058a8..5ad9119 100644
--- a/src/CBot/CBotProgram.cpp
+++ b/src/CBot/CBotProgram.cpp
@@ -80,7 +80,7 @@ CBotProgram::~CBotProgram()
}
////////////////////////////////////////////////////////////////////////////////
-bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions, void* pUser )
+bool CBotProgram::Compile( const char* program, std::vector<CBotString>& ListFonctions, void* pUser )
{
int error = 0;
Stop();
@@ -91,7 +91,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
m_pClass = nullptr;
delete m_Prog; m_Prog= nullptr;
- ListFonctions.SetSize(0);
+ ListFonctions.clear();
m_ErrorCode = 0;
// transforms the program in Tokens
@@ -152,7 +152,7 @@ bool CBotProgram::Compile( const char* program, CBotStringArray& ListFonctions,
{
m_bCompileClass = false;
CBotFunction::Compile(p, pStack, next);
- if (next->IsExtern()) ListFonctions.Add(next->GetName()/* + next->GetParams()*/);
+ if (next->IsExtern()) ListFonctions.push_back(next->GetName()/* + next->GetParams()*/);
next->m_pProg = this; // keeps pointers to the module
next = next->Next();
}
diff --git a/src/CBot/CBotProgram.h b/src/CBot/CBotProgram.h
index 98854b3..26aeb68 100644
--- a/src/CBot/CBotProgram.h
+++ b/src/CBot/CBotProgram.h
@@ -22,13 +22,13 @@
// Modules inlcude
#include "CBot/CBotTypResult.h"
#include "CBot/CBotString.h"
-#include "CBot/CBotStringArray.h"
#include "CBot/CBotEnums.h"
// Local include
// Global include
+#include <vector>
// Forward declaration
class CBotFunction;
@@ -84,7 +84,7 @@ public:
* \return false if an error at compile.
* \see GetCompileError() to retrieve the error.
*/
- bool Compile( const char* program, CBotStringArray& ListFonctions, void* pUser = nullptr);
+ bool Compile( const char* program, std::vector<CBotString>& ListFonctions, void* pUser = nullptr);
/*!
* \brief SetIdent Associates an identifier with the instance CBotProgram.
diff --git a/src/CBot/CBotStringArray.cpp b/src/CBot/CBotStringArray.cpp
deleted file mode 100644
index 759aa6a..0000000
--- a/src/CBot/CBotStringArray.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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
- */
-
-#include "CBot/CBotStringArray.h"
-
-////////////////////////////////////////////////////////////////////////////////
-CBotStringArray::CBotStringArray()
-{
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotStringArray::~CBotStringArray()
-{
- m_data.clear(); // destroys data !
-}
-
-////////////////////////////////////////////////////////////////////////////////
-int CBotStringArray::GetSize()
-{
- return m_data.size();
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void CBotStringArray::Add(const CBotString& str)
-{
- m_data.push_back(str);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-void CBotStringArray::SetSize(int nNewSize)
-{
- m_data.resize(nNewSize);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotString& CBotStringArray::operator[](int nIndex)
-{
- return ElementAt(nIndex);
-}
-
-////////////////////////////////////////////////////////////////////////////////
-CBotString& CBotStringArray::ElementAt(int nIndex)
-{
- return m_data[nIndex];
-}
diff --git a/src/CBot/CBotStringArray.h b/src/CBot/CBotStringArray.h
deleted file mode 100644
index fb755be..0000000
--- a/src/CBot/CBotStringArray.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * 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
-
-#include "CBot/CBotString.h"
-
-#include <vector>
-
-/*!
- * \brief The CBotStringArray class Class used to arrays of strings management.
- * TODO: refactor code to use std::vector instead
- */
-class CBotStringArray : public CBotString
-{
-public:
-
- /*!
- * \brief CBotStringArray
- */
- CBotStringArray();
-
- /*!
- * \brief ~CBotStringArray
- */
- ~CBotStringArray();
-
- /*!
- * \brief SetSize Set the array size.
- * \param nb
- */
- void SetSize(int nb);
-
- /*!
- * \brief GetSize
- * \return
- */
- int GetSize();
-
- /*!
- * \brief Add
- * \param str
- */
- void Add(const CBotString& str);
-
- /*!
- * \brief operator []
- * \param nIndex
- * \return
- */
- CBotString& operator[](int nIndex);
-
- /*!
- * \brief ElementAt
- * \param nIndex
- * \return
- */
- CBotString& ElementAt(int nIndex);
-
-private:
-
- std::vector<CBotString> m_data;
-};
diff --git a/src/CBot/CBotToken.cpp b/src/CBot/CBotToken.cpp
index 6b34d68..e1465ad 100644
--- a/src/CBot/CBotToken.cpp
+++ b/src/CBot/CBotToken.cpp
@@ -26,9 +26,9 @@
#include <cstdarg>
////////////////////////////////////////////////////////////////////////////////
-CBotStringArray CBotToken::m_ListKeyWords;
+std::vector<CBotString> CBotToken::m_ListKeyWords;
int CBotToken::m_ListIdKeyWords[200];
-CBotStringArray CBotToken::m_ListKeyDefine;
+std::vector<CBotString> CBotToken::m_ListKeyDefine;
long CBotToken::m_ListKeyNums[MAXDEFNUM];
////////////////////////////////////////////////////////////////////////////////
@@ -104,7 +104,7 @@ CBotToken::~CBotToken()
////////////////////////////////////////////////////////////////////////////////
void CBotToken::Free()
{
- m_ListKeyDefine.SetSize(0);
+ m_ListKeyDefine.clear();
}
////////////////////////////////////////////////////////////////////////////////
@@ -438,12 +438,12 @@ void CBotToken::Delete(CBotToken* pToken)
int CBotToken::GetKeyWords(const char* w)
{
int i;
- int l = m_ListKeyWords.GetSize();
+ int l = m_ListKeyWords.size();
if (l == 0)
{
LoadKeyWords(); // takes the list for the first time
- l = m_ListKeyWords.GetSize();
+ l = m_ListKeyWords.size();
}
for (i = 0; i < l; i++)
@@ -458,7 +458,7 @@ int CBotToken::GetKeyWords(const char* w)
bool CBotToken::GetKeyDefNum(const char* w, CBotToken* &token)
{
int i;
- int l = m_ListKeyDefine.GetSize();
+ int l = m_ListKeyDefine.size();
for (i = 0; i < l; i++)
{
@@ -482,14 +482,14 @@ void CBotToken::LoadKeyWords()
i = TokenKeyWord; //start with keywords of the language
while (s.LoadString(i))
{
- m_ListKeyWords.Add(s);
+ m_ListKeyWords.push_back(s);
m_ListIdKeyWords[n++] = i++;
}
i = TokenKeyDeclare; //keywords of declarations
while (s.LoadString(i))
{
- m_ListKeyWords.Add(s);
+ m_ListKeyWords.push_back(s);
m_ListIdKeyWords[n++] = i++;
}
@@ -497,14 +497,14 @@ void CBotToken::LoadKeyWords()
i = TokenKeyVal; //keywords of values
while (s.LoadString(i))
{
- m_ListKeyWords.Add(s);
+ m_ListKeyWords.push_back(s);
m_ListIdKeyWords[n++] = i++;
}
i = TokenKeyOp; //operators
while (s.LoadString(i))
{
- m_ListKeyWords.Add(s);
+ m_ListKeyWords.push_back(s);
m_ListIdKeyWords[n++] = i++;
}
}
@@ -513,7 +513,7 @@ void CBotToken::LoadKeyWords()
bool CBotToken::DefineNum(const char* name, long val)
{
int i;
- int l = m_ListKeyDefine.GetSize();
+ int l = m_ListKeyDefine.size();
for (i = 0; i < l; i++)
{
@@ -521,7 +521,7 @@ bool CBotToken::DefineNum(const char* name, long val)
}
if ( i == MAXDEFNUM ) return false;
- m_ListKeyDefine.Add( name );
+ m_ListKeyDefine.push_back( name );
m_ListKeyNums[i] = val;
return true;
}
diff --git a/src/CBot/CBotToken.h b/src/CBot/CBotToken.h
index 12be45c..1dbe39b 100644
--- a/src/CBot/CBotToken.h
+++ b/src/CBot/CBotToken.h
@@ -19,12 +19,9 @@
#pragma once
-// Modules inlcude
-#include "CBot/CBotStringArray.h"
+#include "CBot/CBotString.h"
-// Local include
-
-// Global include
+#include <vector>
/////////////////////////////////////////////////////////////////////////////////////
// Token management (tokens)
@@ -248,7 +245,7 @@ private:
static void LoadKeyWords();
//! List of keywords of the CBot language (if, +, for, while, case, extern ...)
- static CBotStringArray m_ListKeyWords;
+ static std::vector<CBotString> m_ListKeyWords;
//! List of id correponding to the keywords of the CBot language
static int m_ListIdKeyWords[200];
@@ -256,7 +253,7 @@ private:
//! This keywords are defined in :
//! - void CScriptFunctions::Init()
//! - void CBotProgram::Init()
- static CBotStringArray m_ListKeyDefine;
+ static std::vector<CBotString> m_ListKeyDefine;
//! List of id correponding to the defined words
static long m_ListKeyNums[MAXDEFNUM];
diff --git a/src/CBot/CMakeLists.txt b/src/CBot/CMakeLists.txt
index b38ff61..33e47af 100644
--- a/src/CBot/CMakeLists.txt
+++ b/src/CBot/CMakeLists.txt
@@ -10,7 +10,6 @@ set(SOURCES
CBotCall.cpp
CBotDefParam.cpp
CBotCallMethode.cpp
- CBotStringArray.cpp
CBotTypResult.cpp
StringFunctions.cpp
CBotInstr/CBotInstr.cpp
diff --git a/src/script/script.cpp b/src/script/script.cpp
index 5908d43..42d2fd6 100644
--- a/src/script/script.cpp
+++ b/src/script/script.cpp
@@ -228,7 +228,7 @@ bool CScript::CheckToken()
bool CScript::Compile()
{
- CBotStringArray liste;
+ std::vector<CBotString> functionList;
int i;
const char* p;
@@ -250,16 +250,16 @@ bool CScript::Compile()
m_botProg = MakeUnique<CBotProgram>(m_object->GetBotVar());
}
- if ( m_botProg->Compile(m_script.get(), liste, this) )
+ if ( m_botProg->Compile(m_script.get(), functionList, this) )
{
- if ( liste.GetSize() == 0 )
+ if (functionList.empty())
{
strcpy(m_title, "<extern missing>");
m_mainFunction[0] = 0;
}
else
{
- p = liste[0];
+ p = functionList[0];
i = 0;
bool titleDone = false;
while ( true )
diff --git a/test/cbot/console/main.cpp b/test/cbot/console/main.cpp
index 54ea169..721105a 100644
--- a/test/cbot/console/main.cpp
+++ b/test/cbot/console/main.cpp
@@ -44,7 +44,7 @@ int main(int argc, char* argv[])
CBotProgram::AddFunction("message", rMessage, cMessage);
// Compile the program
- CBotStringArray externFunctions;
+ std::vector<CBotString> externFunctions;
std::unique_ptr<CBotProgram> program{new CBotProgram(nullptr)};
if (!program->Compile(code.c_str(), externFunctions, nullptr))
{
@@ -57,15 +57,14 @@ int main(int argc, char* argv[])
}
// Execute all compiled functions marked as "extern"
- if (externFunctions.GetSize() == 0)
+ if (externFunctions.empty())
{
std::cerr << "NO EXTERN FUNCTIONS FOUND";
return 2;
}
bool runErrors = false;
- for (int i = 0; i < externFunctions.GetSize(); i++)
+ for (const char* func : externFunctions)
{
- const char* func = externFunctions[i];
if (!program->Start(func))
{
std::cerr << "FAILED TO START: " << func << std::endl;
--
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