1
0
forked from 0ad/0ad

Clean up header includes, add new forward declarations.

This cleans up many un-necessary header includes, either simply
providing nothing or forward declarations in their place.

No major compilation time change here, though this does reduce depencies
in some headers.

Also fix up old MacOS STL-include fixes that are no longer relevant.

Differential Revision: https://code.wildfiregames.com/D3128
This was SVN commit r24227.
This commit is contained in:
wraitii 2020-11-21 11:20:29 +00:00
parent 8726a2abbf
commit f6348b9617
48 changed files with 136 additions and 178 deletions

View File

@ -23,7 +23,6 @@
#include <map>
class CStrW;
struct UnifontGlyphData;
/**

View File

@ -24,7 +24,8 @@
#ifndef INCLUDED_HEIGHTMIPMAP
#define INCLUDED_HEIGHTMIPMAP
#include "lib/file/vfs/vfs_path.h"
class Path;
using VfsPath = Path;
struct SMipmap
{

View File

@ -18,11 +18,11 @@
#include "lib/ogl.h"
#include "maths/Matrix3D.h"
#include "simulation2/components/ICmpRangeManager.h"
#include "graphics/ShaderManager.h"
#include "graphics/ShaderTechniquePtr.h"
class CLosQuerier;
class CSimulation2;
/**

View File

@ -19,9 +19,10 @@
#define INCLUDED_MAPREADER
#include "MapIO.h"
#include "graphics/LightEnv.h"
#include "lib/res/handle.h"
#include "ps/CStr.h"
#include "LightEnv.h"
#include "ps/FileIo.h"
#include "scriptinterface/ScriptInterface.h"
#include "simulation2/system/Entity.h"

View File

@ -23,6 +23,7 @@
#define INCLUDED_MODELDEF
#include "ps/CStr.h"
#include "maths/Matrix3D.h"
#include "maths/Vector2D.h"
#include "maths/Vector3D.h"
#include "maths/Quaternion.h"

View File

@ -19,6 +19,7 @@
#define INCLUDED_SHADERTECHNIQUE
#include "graphics/ShaderProgramPtr.h"
#include "graphics/ShaderTechniquePtr.h"
#include "lib/ogl.h"
/**
@ -110,6 +111,4 @@ private:
bool m_SortByDistance;
};
typedef shared_ptr<CShaderTechnique> CShaderTechniquePtr;
#endif // INCLUDED_SHADERTECHNIQUE

View File

@ -0,0 +1,30 @@
/* Copyright (C) 2020 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. 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 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SHADERTECHNIQUEPTR
#define INCLUDED_SHADERTECHNIQUEPTR
/*
* Forward declaration, to reduce the number of header files that have to pull
* in the whole of ShaderTechnique.h
*/
class CShaderTechnique;
typedef std::shared_ptr<CShaderTechnique> CShaderTechniquePtr;
#endif // INCLUDED_SHADERTECHNIQUEPTR

View File

@ -23,6 +23,7 @@
#include "SkeletonAnimDef.h"
#include "maths/MathUtil.h"
#include "maths/Matrix3D.h"
#include "ps/FileIo.h"

View File

@ -25,6 +25,10 @@
#include "gui/GUIRenderer.h"
#include "gui/SettingTypes/CGUISize.h"
#include "gui/SettingTypes/CGUIColor.h"
#include "lib/ogl.h"
#include "lib/file/vfs/vfs_path.h"
#include "ps/CStr.h"
#include <map>
#include <memory>

View File

@ -18,17 +18,19 @@
#ifndef INCLUDED_GUIRENDERER
#define INCLUDED_GUIRENDERER
#include "graphics/ShaderTechnique.h"
#include "graphics/Color.h"
#include "graphics/ShaderTechniquePtr.h"
#include "graphics/Texture.h"
#include "gui/SettingTypes/CGUIColor.h"
#include "lib/res/handle.h"
#include "ps/CStr.h"
#include "ps/Shapes.h"
#include <map>
#include <vector>
class CGUI;
class CGUISprite;
class CStr8;
struct CGUIColor;
struct SGUIImage;
namespace GUIRenderer
@ -67,7 +69,7 @@ namespace GUIRenderer
DrawCalls& operator=(const DrawCalls&);
};
void UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const CStr& SpriteName, const CRect& Size, int CellID, std::map<CStr, const CGUISprite*>& Sprites);
void UpdateDrawCallCache(const CGUI& pGUI, DrawCalls& Calls, const CStr8& SpriteName, const CRect& Size, int CellID, std::map<CStr8, const CGUISprite*>& Sprites);
void Draw(DrawCalls& Calls, float Z);
}

View File

@ -25,7 +25,9 @@
#define INCLUDED_IGUISCROLLBAR
#include "gui/CGUISprite.h"
#include "ps/CStr.h"
class CGUI;
class IGUIScrollBarOwner;
struct SGUIMessage;

View File

@ -27,6 +27,7 @@
#define INCLUDED_IGUIBUTTONBEHAVIOR
#include "gui/ObjectBases/IGUIObject.h"
#include "ps/CStr.h"
class CGUISpriteInstance;

View File

@ -32,8 +32,6 @@ class ScriptInterface;
*
* Used to create new hotkey combinations in-game. Mostly custom.
* This object does not draw anything.
*
* NB: because of how input is handled, mouse clicks
*/
class CHotkeyPicker : public IGUIObject
{

View File

@ -46,6 +46,7 @@
#include "scriptinterface/ScriptInterface.h"
#include "simulation2/Simulation2.h"
#include "simulation2/components/ICmpMinimap.h"
#include "simulation2/components/ICmpRangeManager.h"
#include "simulation2/helpers/Los.h"
#include "simulation2/system/ParamNode.h"

View File

@ -19,9 +19,9 @@
#define INCLUDED_GUICOLOR
#include "graphics/Color.h"
#include "ps/CStr.h"
class CGUI;
class CStr8;
/**
* Same as the CColor class, but this one can also parse colors predefined in the GUI page (such as "yellow").
@ -51,11 +51,11 @@ struct CGUIColor : CColor
/**
* Load color depending on current GUI page.
*/
bool ParseString(const CGUI& pGUI, const CStr& value, int defaultAlpha = 255);
bool ParseString(const CGUI& pGUI, const CStr8& value, int defaultAlpha = 255);
/**
* Ensure that all users check for predefined colors.
*/
bool ParseString(const CStr& value, int defaultAlpha = 255) = delete;
bool ParseString(const CStr8& value, int defaultAlpha = 255) = delete;
};
#endif // INCLUDED_GUICOLOR

View File

@ -18,9 +18,10 @@
#ifndef INCLUDED_CGUISIZE
#define INCLUDED_CGUISIZE
#include "ps/CStr.h"
#include "ps/Shapes.h"
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptForward.h"
class CStr8;
/**
* This class represents a rectangle relative to a parent rectangle
@ -60,7 +61,7 @@ public:
*
* @return true if success, otherwise size will remain unchanged.
*/
bool FromString(const CStr& Value);
bool FromString(const CStr8& Value);
bool operator==(const CGUISize& other) const
{

View File

@ -52,8 +52,8 @@ namespace ERR
// null character. to protect against access violations, only the
// first <max_len> characters are examined; if the null character is
// not encountered by then, <max_len> is returned.
// strnlen is available on OpenBSD
#if !OS_OPENBSD
// strnlen is available on OpenBSD and MacOS
#if !OS_OPENBSD && !OS_MACOSX
extern size_t strnlen(const char* str, size_t max_len);
#endif
extern size_t wcsnlen(const wchar_t* str, size_t max_len);

View File

@ -1,121 +0,0 @@
/* Copyright (C) 2013 Wildfire Games.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef OSX_STL_FIXES_H
#define OSX_STL_FIXES_H
#include <istream>
#include <ostream>
#include <AvailabilityMacros.h> // MAC_OS_X_VERSION_*
/**
* This file adds some explicit template instantiations that are
* declared external on 10.6+ SDKs but are missing from stdc++ on 10.5
* (this causes a failure to load due to missing symbols on 10.5)
**/
#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
_GLIBCXX_BEGIN_NAMESPACE(std)
// ostream_insert.h:
# if _GLIBCXX_EXTERN_TEMPLATE
template ostream& __ostream_insert(ostream&, const char*, streamsize);
# ifdef _GLIBCXX_USE_WCHAR_T
template wostream& __ostream_insert(wostream&, const wchar_t*,
streamsize);
# endif
# endif
// istream.tcc:
# if _GLIBCXX_EXTERN_TEMPLATE
template istream& istream::_M_extract(unsigned short&);
template istream& istream::_M_extract(unsigned int&);
template istream& istream::_M_extract(long&);
template istream& istream::_M_extract(unsigned long&);
template istream& istream::_M_extract(bool&);
# ifdef _GLIBCXX_USE_LONG_LONG
template istream& istream::_M_extract(long long&);
template istream& istream::_M_extract(unsigned long long&);
# endif
template istream& istream::_M_extract(float&);
template istream& istream::_M_extract(double&);
template istream& istream::_M_extract(long double&);
template istream& istream::_M_extract(void*&);
template class basic_iostream<char>;
# ifdef _GLIBCXX_USE_WCHAR_T
template wistream& wistream::_M_extract(unsigned short&);
template wistream& wistream::_M_extract(unsigned int&);
template wistream& wistream::_M_extract(long&);
template wistream& wistream::_M_extract(unsigned long&);
template wistream& wistream::_M_extract(bool&);
# ifdef _GLIBCXX_USE_LONG_LONG
template wistream& wistream::_M_extract(long long&);
template wistream& wistream::_M_extract(unsigned long long&);
# endif
template wistream& wistream::_M_extract(float&);
template wistream& wistream::_M_extract(double&);
template wistream& wistream::_M_extract(long double&);
template wistream& wistream::_M_extract(void*&);
template class basic_iostream<wchar_t>;
# endif
# endif
// ostream.tcc:
# if _GLIBCXX_EXTERN_TEMPLATE
template ostream& ostream::_M_insert(long);
template ostream& ostream::_M_insert(unsigned long);
template ostream& ostream::_M_insert(bool);
# ifdef _GLIBCXX_USE_LONG_LONG
template ostream& ostream::_M_insert(long long);
template ostream& ostream::_M_insert(unsigned long long);
# endif
template ostream& ostream::_M_insert(double);
template ostream& ostream::_M_insert(long double);
template ostream& ostream::_M_insert(const void*);
# ifdef _GLIBCXX_USE_WCHAR_T
template wostream& wostream::_M_insert(long);
template wostream& wostream::_M_insert(unsigned long);
template wostream& wostream::_M_insert(bool);
# ifdef _GLIBCXX_USE_LONG_LONG
template wostream& wostream::_M_insert(long long);
template wostream& wostream::_M_insert(unsigned long long);
# endif
template wostream& wostream::_M_insert(double);
template wostream& wostream::_M_insert(long double);
template wostream& wostream::_M_insert(const void*);
# endif
# endif
_GLIBCXX_END_NAMESPACE
#endif // MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 && MAC_OS_X_VERSION_MIN_REQUIRED < 1060
#endif // OSX_STL_FIXES_H

View File

@ -72,10 +72,4 @@
# endif
#endif
// OS X - fix some stream template instantiations that break 10.5 compatibility on newer SDKs
#if OS_MACOSX
# include "os/osx/osx_stl_fixes.h"
#endif
#endif // #ifndef INCLUDED_STL

View File

@ -18,7 +18,9 @@
#include "precompiled.h"
#include "Quaternion.h"
#include "MathUtil.h"
#include "Matrix3D.h"
const float EPSILON=0.0001f;

View File

@ -18,9 +18,10 @@
#ifndef INCLUDED_QUATERNION
#define INCLUDED_QUATERNION
#include "Matrix3D.h"
#include "Vector3D.h"
class CMatrix3D;
class CQuaternion
{
public:

View File

@ -22,6 +22,7 @@
#include "NetServer.h"
#include "NetSession.h"
#include "lib/utf8.h"
#include "ps/CLogger.h"
#include "simulation2/system/TurnManager.h"

View File

@ -30,11 +30,13 @@
#ifndef INCLUDED_FILEPACKER
#define INCLUDED_FILEPACKER
#include "CStr.h"
#include "lib/file/vfs/vfs_path.h"
#include "ps/Filesystem.h" // WriteBuffer
#include "ps/Errors.h"
class CStr8;
ERROR_GROUP(File);
ERROR_TYPE(File, OpenFailed);
ERROR_TYPE(File, WriteFailed);
@ -83,7 +85,7 @@ public:
* pack a string onto the end of the data stream
* (encoded as a 32-bit length followed by the characters)
**/
void PackString(const CStr& str);
void PackString(const CStr8& str);
private:
/**

View File

@ -23,9 +23,10 @@
#include "lib/file/io/write_buffer.h"
#include "lib/file/vfs/vfs_util.h"
#include "ps/CStr.h"
#include "ps/Errors.h"
class CStr8;
extern PIVFS g_VFS;
extern bool VfsFileExists(const VfsPath& pathname);
@ -92,13 +93,13 @@ public:
* Returns contents of file as a string
* @note file must have been successfully loaded
*/
CStr GetAsString() const;
CStr8 GetAsString() const;
/**
* Returns contents of a UTF-8 encoded file as a string with optional BOM removed
* @note file must have been successfully loaded
*/
CStr DecodeUTF8() const;
CStr8 DecodeUTF8() const;
private:
shared_ptr<u8> m_Buffer;

View File

@ -18,8 +18,8 @@
#ifndef INCLUDED_GUID
#define INCLUDED_GUID
#include "ps/CStr.h"
class CStr8;
CStr ps_generate_guid(void);
CStr8 ps_generate_guid(void);
#endif

View File

@ -20,6 +20,7 @@
#include <vector>
#include "ps/CStr.h"
#include "ps/Errors.h"
#include "ps/Filesystem.h"
#include "scriptinterface/ScriptTypes.h"

View File

@ -40,9 +40,6 @@
class CProfileManager;
class CProfileNodeTable;
class CStr8;
class CStrW;
// To profile scripts usefully, we use a call hook that's called on every enter/exit,
// and need to find the function name. But most functions are anonymous so we make do
// with filename plus line number instead.

View File

@ -61,9 +61,9 @@
* end of XMLWriter.cpp.
*/
#include "ps/CStr.h"
#include "lib/file/vfs/vfs.h"
class CStr8;
class XMBElement;
class XMBFile;
class XMLWriter_Element;
@ -80,7 +80,7 @@ public:
void XMB(const XMBFile& file);
bool StoreVFS(const PIVFS& vfs, const VfsPath& pathname);
const CStr& GetOutput();
const CStr8& GetOutput();
private:
@ -94,11 +94,11 @@ private:
void ElementClose();
void ElementEnd(const char* name, int type);
CStr Indent();
CStr8 Indent();
bool m_PrettyPrint;
CStr m_Data;
CStr8 m_Data;
int m_Indent;
XMLWriter_Element* m_LastElement;
};
@ -119,7 +119,7 @@ private:
friend class XMLWriter_File;
XMLWriter_File* m_File;
CStr m_Name;
CStr8 m_Name;
int m_Type;
};

View File

@ -18,7 +18,8 @@
#ifndef INCLUDED_POSTPROCMANAGER
#define INCLUDED_POSTPROCMANAGER
#include "graphics/ShaderTechnique.h"
#include "graphics/ShaderTechniquePtr.h"
#include "lib/ogl.h"
#include "ps/CStr.h"
#include <vector>

View File

@ -0,0 +1,26 @@
/* Copyright (C) 2020 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. 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 2 of the License, or
* (at your option) any later version.
*
* 0 A.D. 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 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef INCLUDED_SCRIPTFORWARD
#define INCLUDED_SCRIPTFORWARD
#include "js/TypeDecls.h"
class ScriptInterface;
class ScriptRequest;
#endif // INCLUDED_SCRIPTFORWARD

View File

@ -27,6 +27,7 @@
#include "maths/Matrix3D.h"
#include "maths/Vector3D.h"
#include "maths/Vector2D.h"
#include "ps/CLogger.h"
#include "ps/Profile.h"
#include "renderer/Scene.h"
#include "renderer/Renderer.h"

View File

@ -20,14 +20,16 @@
#include "simulation2/system/Interface.h"
#include "simulation2/helpers/Pathfinding.h"
#include "maths/FixedVector2D.h"
#include "simulation2/helpers/Position.h"
class IObstructionTestFilter;
template<typename T>
class Grid;
struct GridUpdateInformation;
using NavcellData = u16;
class PathfinderPassability;
/**
* Obstruction manager: provides efficient spatial queries over objects in the world.

View File

@ -21,7 +21,6 @@
#include "simulation2/system/Interface.h"
#include "simulation2/components/ICmpObstruction.h"
#include "simulation2/helpers/PathGoal.h"
#include "simulation2/helpers/Pathfinding.h"
#include "maths/FixedVector2D.h"
@ -30,6 +29,7 @@
#include <vector>
class IObstructionTestFilter;
class PathGoal;
template<typename T> class Grid;

View File

@ -17,6 +17,7 @@
#include "simulation2/system/ComponentTest.h"
#include "maths/Matrix3D.h"
#include "simulation2/components/ICmpPosition.h"
#include "simulation2/components/ICmpWaterManager.h"

View File

@ -15,6 +15,7 @@
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
*/
#include "maths/Matrix3D.h"
#include "simulation2/system/ComponentTest.h"
#include "simulation2/components/ICmpRangeManager.h"
#include "simulation2/components/ICmpObstruction.h"

View File

@ -20,6 +20,7 @@
#include "Pathfinding.h"
#include "ps/CLogger.h"
#include "renderer/TerrainOverlay.h"
#include "Render.h"
#include "graphics/SColor.h"

View File

@ -20,7 +20,9 @@
#include "Pathfinding.h"
#include "graphics/Terrain.h"
#include "Grid.h"
#include "ps/CLogger.h"
#include "simulation2/helpers/Grid.h"
#include "simulation2/system/ParamNode.h"
namespace Pathfinding
{

View File

@ -20,12 +20,12 @@
#include "graphics/Terrain.h"
#include "maths/MathUtil.h"
#include "ps/CLogger.h"
#include "simulation2/system/Entity.h"
#include "simulation2/system/ParamNode.h"
#include "PathGoal.h"
class CParamNode;
typedef u16 pass_class_t;
template<typename T>
class Grid;

View File

@ -20,6 +20,7 @@
#include "Rasterize.h"
#include "simulation2/helpers/Geometry.h"
#include "simulation2/helpers/Pathfinding.h"
void SimRasterize::RasterizeRectWithClearance(Spans& spans,
const ICmpObstructionManager::ObstructionSquare& shape,

View File

@ -24,6 +24,7 @@
*/
#include "simulation2/components/ICmpObstructionManager.h"
#include "simulation2/helpers/Position.h"
namespace SimRasterize
{

View File

@ -24,6 +24,7 @@
#include "maths/BoundingBoxAligned.h"
#include "maths/BoundingBoxOriented.h"
#include "maths/MathUtil.h"
#include "maths/Matrix3D.h"
#include "maths/Quaternion.h"
#include "maths/Vector2D.h"
#include "ps/Profile.h"

View File

@ -19,10 +19,10 @@
#define INCLUDED_SELECTION
#include "ps/Profiler2.h"
#include "simulation2/components/ICmpObstruction.h"
#include "simulation2/helpers/Player.h"
#include "simulation2/Simulation2.h"
#include "simulation2/system/Entity.h"
#include "simulation2/system/IComponent.h"
#include <vector>

View File

@ -18,7 +18,7 @@
#ifndef INCLUDED_SIMULATIONCOMMAND
#define INCLUDED_SIMULATIONCOMMAND
#include "scriptinterface/ScriptInterface.h"
#include "scriptinterface/ScriptTypes.h"
#include "simulation2/helpers/Player.h"
/**

View File

@ -28,6 +28,7 @@
#include "simulation2/components/ICmpAIManager.h"
#include "simulation2/components/ICmpCommandQueue.h"
#include "simulation2/components/ICmpGuiInterface.h"
#include "simulation2/components/ICmpObstruction.h"
#include "simulation2/components/ICmpPosition.h"
#include "simulation2/components/ICmpSelectable.h"
#include "simulation2/helpers/Geometry.h"

View File

@ -20,7 +20,6 @@
#include "lib/self_test.h"
#include "maths/Matrix3D.h"
#include "maths/Vector3D.h"
#include "ps/XML/Xeromyces.h"
#include "simulation2/MessageTypes.h"

View File

@ -22,8 +22,7 @@
#include "Message.h"
#include "Entity.h"
#include "SimContext.h"
#include "scriptinterface/ScriptTypes.h"
#include "scriptinterface/ScriptForward.h"
class CParamNode;
class CMessage;

View File

@ -18,13 +18,14 @@
#ifndef INCLUDED_ACTORVIEWER
#define INCLUDED_ACTORVIEWER
#include "ps/CStr.h"
#include "simulation2/helpers/Player.h"
#include "simulation2/system/Entity.h"
struct ActorViewerImpl;
struct SColor4ub;
class CSimulation2;
class CStr8;
class CStrW;
class ActorViewer
{
@ -35,7 +36,7 @@ public:
CSimulation2* GetSimulation2();
entity_id_t GetEntity();
void SetActor(const CStrW& id, const CStr& animation, player_id_t playerID);
void SetActor(const CStrW& id, const CStr8& animation, player_id_t playerID);
void SetEnabled(bool enabled);
void UnloadObjects();
void SetBackgroundColor(const SColor4ub& color);

View File

@ -40,6 +40,7 @@
#include "ps/Game.h"
#include "ps/GameSetup/GameSetup.h"
#include "ps/Loader.h"
#include "ps/Shapes.h"
#include "ps/World.h"
#include "renderer/Renderer.h"
#include "renderer/WaterManager.h"