Removed CBotStringArray
parent
6832c91496
commit
3eeab0f9b7
|
@ -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"
|
||||
|
|
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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];
|
||||
}
|
|
@ -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;
|
||||
};
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ set(SOURCES
|
|||
CBotCall.cpp
|
||||
CBotDefParam.cpp
|
||||
CBotCallMethode.cpp
|
||||
CBotStringArray.cpp
|
||||
CBotTypResult.cpp
|
||||
StringFunctions.cpp
|
||||
CBotInstr/CBotInstr.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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue