From 1a6b5ded640c1a606d85fd5b5d1b68254b855423 Mon Sep 17 00:00:00 2001 From: Grunaka Date: Sun, 22 Nov 2015 16:42:51 +0100 Subject: [PATCH] Delete CBotDll.h --- src/CBot/CBot.h | 1 - src/CBot/CBotCStack.h | 5 +- src/CBot/CBotCall.h | 7 +- src/CBot/CBotClass.h | 9 +- src/CBot/CBotDefParam.h | 1 - src/CBot/CBotDll.h | 207 ---------------------------- src/CBot/CBotProgram.h | 16 ++- src/CBot/CBotStack.h | 3 + src/CBot/CBotString.h | 1 + src/CBot/CBotStringArray.cpp | 2 + src/CBot/CBotToken.h | 2 - src/CBot/CBotUtils.cpp | 2 +- src/CBot/CBotUtils.h | 7 +- src/CBot/CBotVar/CBotVar.h | 5 +- src/CBot/CBotVar/CBotVarBoolean.cpp | 21 +-- src/CBot/CBotVar/CBotVarFloat.cpp | 2 + src/CBot/CBotVar/CBotVarFloat.h | 2 - src/CBot/CBotVar/CBotVarInt.cpp | 2 + src/CBot/CBotVar/CBotVarInt.h | 2 - src/CBot/CBotVar/CBotVarString.cpp | 2 + src/CBot/CBotVar/CBotVarString.h | 2 - src/level/robotmain.cpp | 1 - src/object/old_object.cpp | 2 - src/script/script.h | 1 - src/script/scriptfunc.h | 2 +- src/ui/studio.cpp | 2 - test/cbot/console/main.cpp | 5 +- test/unit/CBot/CBotString_test.cpp | 2 - 28 files changed, 62 insertions(+), 254 deletions(-) delete mode 100644 src/CBot/CBotDll.h diff --git a/src/CBot/CBot.h b/src/CBot/CBot.h index 2f2bdffa..1e281109 100644 --- a/src/CBot/CBot.h +++ b/src/CBot/CBot.h @@ -26,7 +26,6 @@ #pragma once #include "resource.h" -#include "CBotDll.h" // public definitions #include "CBotToken.h" // token management #include "CBotProgram.h" diff --git a/src/CBot/CBotCStack.h b/src/CBot/CBotCStack.h index 28e9e886..70ce456a 100644 --- a/src/CBot/CBotCStack.h +++ b/src/CBot/CBotCStack.h @@ -20,14 +20,13 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotProgram.h" // Local include // Global include - +class CBotInstr; +class CBotDefParam; /*! * \brief The CBotCStack class Management of the stack of compilation. diff --git a/src/CBot/CBotCall.h b/src/CBot/CBotCall.h index 103d1fc4..b4dc4fe9 100644 --- a/src/CBot/CBotCall.h +++ b/src/CBot/CBotCall.h @@ -20,15 +20,16 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotString.h" // Local include // Global include -#define STACKRUN 1 /// \def return execution directly on a suspended routine +// Forward declaration +class CBotStack; + +#define STACKRUN 1 //! \def return execution directly on a suspended routine /*! * \brief The CBotCall class. Class for routine calls (external). diff --git a/src/CBot/CBotClass.h b/src/CBot/CBotClass.h index b776fb5a..ac9e418d 100644 --- a/src/CBot/CBotClass.h +++ b/src/CBot/CBotClass.h @@ -20,8 +20,6 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotDefines.h" #include "CBotTypResult.h" @@ -32,7 +30,14 @@ // Global include +// Forward declaration +class CBotVar; +class CBotClass; +class CBotCallMethode; +class CBotFunction; class CBotProgram; +class CBotStack; +class CBotDefParam; /*! * \brief The CBotClass class Class to define new classes in the language CBOT diff --git a/src/CBot/CBotDefParam.h b/src/CBot/CBotDefParam.h index 705660e3..6da8e2cd 100644 --- a/src/CBot/CBotDefParam.h +++ b/src/CBot/CBotDefParam.h @@ -20,7 +20,6 @@ #pragma once // Modules inlcude -#include "CBotDll.h" #include "CBotToken.h" #include "CBotStack.h" diff --git a/src/CBot/CBotDll.h b/src/CBot/CBotDll.h deleted file mode 100644 index 118263c6..00000000 --- a/src/CBot/CBotDll.h +++ /dev/null @@ -1,207 +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 - */ - -//////////////////////////////////////////////////////////////////////// - -/** - * \file CBotDll.h - * \brief Library for interpretation of CBOT language - */ - -#pragma once - -// Modules inlcude -#include "resource.h" -#include "CBotEnums.h" - -// Local include - -// Global include -#include -#include -#include - -//////////////////////////////////////////////////////////////////////// -// forward declaration of needed classes - -class CBotToken; // program turned into "tokens -class CBotStack; // for the execution stack -class CBotClass; // class of object -class CBotInstr; // instruction to be executed -class CBotFunction; // user functions -class CBotVar; // variables -class CBotVarClass; // instance of class -class CBotVarPointer; // pointer to an instance of class -class CBotCall; // functions -class CBotCallMethode; // methods -class CBotDefParam; // parameter list -class CBotCStack; // stack - - -//////////////////////////////////////////////////////////////////////// -// Variables management -//////////////////////////////////////////////////////////////////////// -//n = not implemented yet - -// other values ​​may be returned -// for example exceptions returned by external routines -// and " throw " with any number. - - -#if 0 -/* -(**) Note: - To define an external function, proceed as follows: - - a) define a routine for compilation - this routine receive list of parameters (no values) - and either returns a result type (CBotTyp... or 0 = void) - or an error number - b) define a routine for the execution - this routine receive list of parameters (with valeurs), - a variable to store the result (according to the given type at compile time) - - For example, a routine which calculates the mean of a parameter list */ - -int cMean(CBotVar* &pVar, CBotString& ClassName) -{ - if ( pVar == nullptr ) return 6001; // there is no parameter! - - while ( pVar != nullptr ) - { - if ( pVar->GetType() > CBotTypDouble ) return 6002; // this is not a number - pVar = pVar -> GetNext(); - } - - return CBotTypFloat; // the type of the result may depend on the parameters! -} - - -bool rMean(CBotVar* pVar, CBotVar* pResult, int& Exception) -{ - float total = 0; - int nb = 0; - while (pVar != nullptr) - { - total += pVar->GetValFloat(); - pVar = pVar->GetNext(); - nb++; - } - pResult->SetValFloat(total/nb); // returns the mean value - - return true; // operation fully completed -} - -#endif - -/* -//////////////////////////////////////////////////////////////////////// -// Examples of use -// Definition classes and functions - - -// define the global class CPoint -// -------------------------------- - m_pClassPoint = new CBotClass("CPoint", nullptr); - // adds the component ".x" - m_pClassPoint->AddItem("x", CBotTypResult(CBotTypFloat)); - // adds the component ".y" - m_pClassPoint->AddItem("y", CBotTypResult(CBotTypFloat)); - // the player can then use the instructions - // CPoint position; position.x = 12; position.y = -13.6 - -// define class CColobotObject -// -------------------------------- -// This class manages all the objects in the world of COLOBOT -// the "main" user program belongs to this class - m_pClassObject = new CBotClass("CColobotObject", m_pClassBase); - // adds the component ".position" - m_pClassObject->AddItem("position", m_pClassPoint); - // adds the component ".type" - m_pClassObject->AddItem("type", CBotTypResult(CBotTypShort)); - // adds a definition of constant - m_pClassObject->AddConst("ROBOT", CBotTypShort, 1); // ROBOT equivalent to the value 1 - // adds the FIND routine - m_pClassObject->AddFunction( rCompFind, rDoFind ); - // the player can now use the instructions - // CColobotObject chose; chose = FIND( ROBOT ) - - - -// define class CColobotRobot derived from CColobotObject -// --------------------------------------------------------- -// programs "main" associated with robots as a part of this class - m_pClassRobot = new CBotClass("CColobotRobot", m_pClassObject); - // add routine GOTO - m_pClassRobot->AddFunction( rCompGoto, rDoGoto ); - // the player can now use - // GOTO( FIND ( ROBOT ) ); - - -// creates an instance of the class Robot -// ------------------------------------ -// for example a new robot which has just been manufactured - CBotVar* m_pMonRobot = new CBotVar("MonRobot", m_pClassRobot); - -// compiles the program by hand for this robot -// ------------------------------------------ - CString LeProgramme( "void main() {GOTO(0, 0); return 0;}" ); - if ( !m_pMonRobot->Compile( LeProgramme ) ) {error handling ...}; - -// build a stack for interpreter -// -------------------------------------- - CBotStack* pStack = new CBotStack(nullptr); - -// executes the main program -// ------------------------- - while( false = m_pMonRobot->Execute( "main", pStack )) - { - // program suspended - // could be pass a handle to another (safeguarding pstack for the robot one) - }; - // programme "main" finished ! - - - - -// routine that implements the GOTO (CPoint pos) -bool rDoGoto( CBotVar* pVar, CBotVar* pResult, int& exception ) -{ - if (pVar->GetType() != CBotTypeClass || - pVar->IsElemOfClas("CPoint") ) { exception = 6522; return false; ) - // the parameter is not the right class? - // in fact the control is done to the routine of compilation - - m_PosToGo.Copy( pVar ); // keeps the target position (object type CBotVar) - - // or so - CBotVar* temp; - temp = pVar->GetItem("x"); // is necessary for the object of type CPoint - ASSERT (temp != nullptr && temp->GetType() == CBotTypFloat); - m_PosToGo.x = temp->GetValFloat(); - - temp = pVar->GetItem("y"); // is necessary for the object of type CPoint - ASSERT (temp != nullptr && temp->GetType() == CBotTypFloat); - m_PosToGo.y = temp->GetValFloat(); - - return (m_CurentPos == m_PosToGo); // makes true if the position is reached - // returns false if one had wait yet -} - -*/ diff --git a/src/CBot/CBotProgram.h b/src/CBot/CBotProgram.h index f13a1af8..87dff3c2 100644 --- a/src/CBot/CBotProgram.h +++ b/src/CBot/CBotProgram.h @@ -24,10 +24,18 @@ #include "CBotString.h" #include "CBotStringArray.h" +#include "CBotEnums.h" + // Local include // Global include +// Forward declaration +class CBotFunction; +class CBotClass; +class CBotStack; +class CBotVar; + /*! * \brief The CBotProgram class Main class managing CBot program. */ @@ -225,9 +233,11 @@ public: * \param modestop * \return */ - bool GetPosition(const char* name, int& start, int& stop, - CBotGet modestart = GetPosExtern, - CBotGet modestop = GetPosBloc); + bool GetPosition(const char* name, + int& start, + int& stop, + CBotGet modestart = GetPosExtern, + CBotGet modestop = GetPosBloc); /*! * \brief GetFunctions diff --git a/src/CBot/CBotStack.h b/src/CBot/CBotStack.h index df69a0d4..36f45b1e 100644 --- a/src/CBot/CBotStack.h +++ b/src/CBot/CBotStack.h @@ -26,6 +26,9 @@ // Global include +// Forward declaration +class CBotInstr; +class CBotCall; /*! * \class CBotStack diff --git a/src/CBot/CBotString.h b/src/CBot/CBotString.h index 3297c2b7..ea065b29 100644 --- a/src/CBot/CBotString.h +++ b/src/CBot/CBotString.h @@ -21,6 +21,7 @@ // Modules inlcude #include "CBotUtils.h" +#include "resource.h" // Local include diff --git a/src/CBot/CBotStringArray.cpp b/src/CBot/CBotStringArray.cpp index ecf53bf0..6d5d6617 100644 --- a/src/CBot/CBotStringArray.cpp +++ b/src/CBot/CBotStringArray.cpp @@ -26,6 +26,8 @@ // Global include +// Forward declaration +#include //////////////////////////////////////////////////////////////////////////////// CBotStringArray::CBotStringArray() diff --git a/src/CBot/CBotToken.h b/src/CBot/CBotToken.h index e8fd0432..85dc6988 100644 --- a/src/CBot/CBotToken.h +++ b/src/CBot/CBotToken.h @@ -20,8 +20,6 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotStringArray.h" // Local include diff --git a/src/CBot/CBotUtils.cpp b/src/CBot/CBotUtils.cpp index 1a226dbc..c59f8745 100644 --- a/src/CBot/CBotUtils.cpp +++ b/src/CBot/CBotUtils.cpp @@ -30,7 +30,7 @@ // Local include // Global include - +#include //////////////////////////////////////////////////////////////////////////////// CBotVar* MakeListVars(CBotVar** ppVars, bool bSetVal) diff --git a/src/CBot/CBotUtils.h b/src/CBot/CBotUtils.h index 739800eb..bf958bc8 100644 --- a/src/CBot/CBotUtils.h +++ b/src/CBot/CBotUtils.h @@ -20,16 +20,19 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotString.h" #include "CBotTypResult.h" // Local include // Global include +#include +// Forward declaration class CBotString; +class CBotVar; +class CBotToken; +class CBotCStack; /*! * \brief MakeListVars Transforms the array of pointers to variables in a diff --git a/src/CBot/CBotVar/CBotVar.h b/src/CBot/CBotVar/CBotVar.h index 68132ad2..1abedb33 100644 --- a/src/CBot/CBotVar/CBotVar.h +++ b/src/CBot/CBotVar/CBotVar.h @@ -20,8 +20,6 @@ #pragma once // Modules inlcude -#include "../CBotDll.h" - #include "../CBotDefines.h" #include "../CBotString.h" @@ -30,6 +28,9 @@ // Global include +// Forward declaration +class CBotVarClass; +class CBotInstr; /*! * \brief The CBotVar class Class for managing variables. May be useful to the diff --git a/src/CBot/CBotVar/CBotVarBoolean.cpp b/src/CBot/CBotVar/CBotVarBoolean.cpp index f1c59347..b7680078 100644 --- a/src/CBot/CBotVar/CBotVarBoolean.cpp +++ b/src/CBot/CBotVar/CBotVarBoolean.cpp @@ -20,6 +20,8 @@ // Modules inlcude #include "CBotVarBoolean.h" +#include "CBotEnums.h" + #include "CBotUtils.h" // Local include @@ -30,18 +32,17 @@ //////////////////////////////////////////////////////////////////////////////// CBotVarBoolean::CBotVarBoolean( const CBotToken* name ) { - m_token = new CBotToken(name); - m_next = nullptr; - m_pMyThis = nullptr; - m_pUserPtr = nullptr; + m_token = new CBotToken(name); + m_next = nullptr; + m_pMyThis = nullptr; + m_pUserPtr = nullptr; m_InitExpr = nullptr; - m_LimExpr = nullptr; - m_type = CBotTypBoolean; - m_binit = InitType::UNDEF; - m_bStatic = false; + m_LimExpr = nullptr; + m_type = CBotTypBoolean; + m_binit = InitType::UNDEF; + m_bStatic = false; m_mPrivate = 0; - - m_val = 0; + m_val = 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/CBot/CBotVar/CBotVarFloat.cpp b/src/CBot/CBotVar/CBotVarFloat.cpp index 465c2940..9f25fbb7 100644 --- a/src/CBot/CBotVar/CBotVarFloat.cpp +++ b/src/CBot/CBotVar/CBotVarFloat.cpp @@ -20,6 +20,8 @@ // Modules inlcude #include "CBotVarFloat.h" +#include "CBotEnums.h" + #include "CBotToken.h" #include "CBotUtils.h" diff --git a/src/CBot/CBotVar/CBotVarFloat.h b/src/CBot/CBotVar/CBotVarFloat.h index 07a3ecc6..e55378a7 100644 --- a/src/CBot/CBotVar/CBotVarFloat.h +++ b/src/CBot/CBotVar/CBotVarFloat.h @@ -20,8 +20,6 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotVar/CBotVar.h" // Local include diff --git a/src/CBot/CBotVar/CBotVarInt.cpp b/src/CBot/CBotVar/CBotVarInt.cpp index 76f89c12..67220a1a 100644 --- a/src/CBot/CBotVar/CBotVarInt.cpp +++ b/src/CBot/CBotVar/CBotVarInt.cpp @@ -20,6 +20,8 @@ // Modules inlcude #include "CBotVarInt.h" +#include "CBotEnums.h" + #include "CBotToken.h" #include "CBotUtils.h" diff --git a/src/CBot/CBotVar/CBotVarInt.h b/src/CBot/CBotVar/CBotVarInt.h index 65ebb8c3..524c2762 100644 --- a/src/CBot/CBotVar/CBotVarInt.h +++ b/src/CBot/CBotVar/CBotVarInt.h @@ -20,8 +20,6 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotVar/CBotVar.h" // Local include diff --git a/src/CBot/CBotVar/CBotVarString.cpp b/src/CBot/CBotVar/CBotVarString.cpp index 7b740147..09c4e761 100644 --- a/src/CBot/CBotVar/CBotVarString.cpp +++ b/src/CBot/CBotVar/CBotVarString.cpp @@ -20,6 +20,8 @@ // Modules inlcude #include "CBotVarString.h" +#include "CBotEnums.h" + #include "CBotToken.h" #include "CBotUtils.h" diff --git a/src/CBot/CBotVar/CBotVarString.h b/src/CBot/CBotVar/CBotVarString.h index 93007bee..75b4b1d0 100644 --- a/src/CBot/CBotVar/CBotVarString.h +++ b/src/CBot/CBotVar/CBotVarString.h @@ -20,8 +20,6 @@ #pragma once // Modules inlcude -#include "CBotDll.h" - #include "CBotVar/CBotVar.h" // Local include diff --git a/src/level/robotmain.cpp b/src/level/robotmain.cpp index 7cd1bdb0..e2c82908 100644 --- a/src/level/robotmain.cpp +++ b/src/level/robotmain.cpp @@ -19,7 +19,6 @@ #include "level/robotmain.h" -#include "CBot/CBotDll.h" #include "CBot/CBotFileUtils.h" // TODO must be replaced by CBot.h #include "CBot/CBotClass.h" diff --git a/src/object/old_object.cpp b/src/object/old_object.cpp index 1939f655..b7a7929d 100644 --- a/src/object/old_object.cpp +++ b/src/object/old_object.cpp @@ -20,8 +20,6 @@ #include "object/old_object.h" -#include "CBot/CBotDll.h" - #include "app/app.h" #include "common/global.h" diff --git a/src/script/script.h b/src/script/script.h index d4a42eb7..be3f055a 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -25,7 +25,6 @@ #pragma once // TODO replace by CBot.h -#include "CBot/CBotDll.h" #include "CBot/CBotProgram.h" #include diff --git a/src/script/scriptfunc.h b/src/script/scriptfunc.h index 07b21cb9..13c48893 100644 --- a/src/script/scriptfunc.h +++ b/src/script/scriptfunc.h @@ -24,7 +24,6 @@ #pragma once -#include "CBot/CBotDll.h" #include "CBot/CBotTypResult.h" #include "common/error.h" @@ -36,6 +35,7 @@ class CObject; class CScript; class CExchangePost; +class CBotVar; class CScriptFunctions diff --git a/src/ui/studio.cpp b/src/ui/studio.cpp index 614a2888..511372fb 100644 --- a/src/ui/studio.cpp +++ b/src/ui/studio.cpp @@ -20,8 +20,6 @@ #include "ui/studio.h" -#include "CBot/CBotDll.h" - #include "app/app.h" #include "app/pausemanager.h" diff --git a/test/cbot/console/main.cpp b/test/cbot/console/main.cpp index 83e06dea..54ea1690 100644 --- a/test/cbot/console/main.cpp +++ b/test/cbot/console/main.cpp @@ -2,7 +2,8 @@ #include #include "common/restext.h" -#include "CBot/CBotDll.h" + +#include "CBot/CBot.h" CBotTypResult cMessage(CBotVar* &var, void* user) { @@ -91,4 +92,4 @@ int main(int argc, char* argv[]) } return runErrors ? 3 : 0; -} \ No newline at end of file +} diff --git a/test/unit/CBot/CBotString_test.cpp b/test/unit/CBot/CBotString_test.cpp index b0d1ede8..3e6b6da0 100644 --- a/test/unit/CBot/CBotString_test.cpp +++ b/test/unit/CBot/CBotString_test.cpp @@ -18,8 +18,6 @@ */ // Modules inlcude -#include "CBot/CBotDll.h" - #include "CBot/CBotString.h" // Local include