Refactor utility/decomp headers (#318)

This commit is contained in:
Christian Semmler
2023-12-11 16:33:46 -05:00
committed by GitHub
parent 3b30607337
commit a7194266b3
21 changed files with 42 additions and 32 deletions

View File

@@ -1,42 +0,0 @@
#ifndef ISLECOMPAT_H
#define ISLECOMPAT_H
// Various macros to enable compiling with other/newer compilers.
// Use `COMPAT_CONST` where something ought to be 'const', and a newer compiler would complain if it
// wasn't, but we know it isn't 'const' in the original code.
#ifdef __MINGW32__
#define COMPAT_CONST const
#else
#define COMPAT_CONST
#endif
// DIsable "nonstandard extension used : 'bool'" warning spam
#pragma warning(disable : 4237)
// Disable "identifier was truncated to '255' characters" warning.
// Impossible to avoid this if using STL map or set.
// This removes most (but not all) occurrences of the warning.
#pragma warning(disable : 4786)
#define MSVC420_VERSION 1020
// STL compatibility.
#if defined(_MSC_VER) && _MSC_VER <= MSVC420_VERSION
#include "mxstl.h"
#else
#include <algorithm>
#include <list>
#include <set>
using std::list;
using std::set;
#endif
// We use `override` so newer compilers can tell us our vtables are valid,
// however this keyword was added in C++11, so we define it as empty for
// compatibility with older compilers.
#if defined(_MSC_VER) && _MSC_VER <= 1200 // 1200 corresponds to VC6.0 but "override" was probably added even later
#define override
#endif
#endif // ISLECOMPAT_H

View File

@@ -1,24 +0,0 @@
#ifndef DECOMP_H
#define DECOMP_H
#if defined(_MSC_VER)
#define DECOMP_STATIC_ASSERT(V) \
namespace \
{ \
typedef int foo[(V) ? 1 : -1]; \
}
#define DECOMP_SIZE_ASSERT(T, S) DECOMP_STATIC_ASSERT(sizeof(T) == S)
#else
#define DECOMP_STATIC_ASSERT(V)
#define DECOMP_SIZE_ASSERT(T, S)
#endif
#ifndef _countof
#define _countof(arr) sizeof(arr) / sizeof(arr[0])
#endif
typedef unsigned char undefined;
typedef unsigned short undefined2;
typedef unsigned int undefined4;
#endif // DECOMP_H

View File

@@ -1,7 +1,7 @@
#ifndef MXATOMIDCOUNTER_H
#define MXATOMIDCOUNTER_H
#include "compat.h" // STL
#include "mxstl/stlcompat.h"
#include "mxstring.h"
// Counts the number of existing MxAtomId objects based

View File

@@ -1,8 +1,8 @@
#ifndef MXCOMPOSITEPRESENTER_H
#define MXCOMPOSITEPRESENTER_H
#include "compat.h" // STL
#include "mxpresenter.h"
#include "mxstl/stlcompat.h"
class MxCompositePresenterList : public list<MxPresenter*> {};

View File

@@ -1,9 +1,9 @@
#ifndef MXDISKSTREAMCONTROLLER_H
#define MXDISKSTREAMCONTROLLER_H
#include "compat.h" // STL
#include "decomp.h"
#include "mxdsbuffer.h"
#include "mxstl/stlcompat.h"
#include "mxstreamcontroller.h"
#include "mxtypes.h"

View File

@@ -1,10 +1,10 @@
#ifndef MXNOTIFICATIONMANAGER_H
#define MXNOTIFICATIONMANAGER_H
#include "compat.h"
#include "mxcore.h"
#include "mxcriticalsection.h"
#include "mxnotificationparam.h"
#include "mxstl/stlcompat.h"
#include "mxtypes.h"
class MxNotification {

18
LEGO1/mxstl/stlcompat.h Normal file
View File

@@ -0,0 +1,18 @@
#ifndef STLCOMPAT_H
#define STLCOMPAT_H
#include "compat.h"
#if defined(_MSC_VER) && _MSC_VER <= MSVC420_VERSION
// Disable "nonstandard extension used : 'bool'" warning spam
#pragma warning(disable : 4237)
#include "mxstl.h"
#else
#include <algorithm>
#include <list>
#include <set>
using std::list;
using std::set;
#endif
#endif // STLCOMPAT_H

View File

@@ -1,13 +1,13 @@
#ifndef MXSTREAMCONTROLLER_H
#define MXSTREAMCONTROLLER_H
#include "compat.h" // STL
#include "decomp.h"
#include "mxatomid.h"
#include "mxcore.h"
#include "mxcriticalsection.h"
#include "mxdsaction.h"
#include "mxdsobject.h"
#include "mxstl/stlcompat.h"
#include "mxstreamlist.h"
#include "mxstreamprovider.h"

View File

@@ -1,10 +1,10 @@
#ifndef MXSTREAMLIST_H
#define MXSTREAMLIST_H
#include "compat.h" // STL
#include "mxdsaction.h"
#include "mxdssubscriber.h"
#include "mxnextactiondatastart.h"
#include "mxstl/stlcompat.h"
template <class T>
class MxStreamList : public list<T> {};

View File

@@ -1,8 +1,8 @@
#ifndef MXTICKLEMANAGER_H
#define MXTICKLEMANAGER_H
#include "compat.h"
#include "mxcore.h"
#include "mxstl/stlcompat.h"
#include "mxtypes.h"
class MxTickleClient {

View File

@@ -1,7 +1,7 @@
#include "matrix.h"
#include "../decomp.h"
#include "decomp.h"
#include "math.h"
#include <memory.h>

View File

@@ -1,6 +1,6 @@
#include "orientableroi.h"
#include "../decomp.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(OrientableROI, 0xdc)

View File

@@ -3,9 +3,9 @@
// ROI stands for Real-time Object Instance.
#include "../compat.h"
#include "../mxstl.h"
#include "../mxstl/stlcompat.h"
#include "../realtime/realtime.h"
#include "compat.h"
#include "lodlist.h"
#include "vector.h"

View File

@@ -1,7 +1,7 @@
#include "vector.h"
#include "../decomp.h"
#include "decomp.h"
#include <math.h>
#include <memory.h>

View File

@@ -1,6 +1,6 @@
#include "../../decomp.h"
#include "../tgl.h"
#include "decomp.h"
#include <d3drm.h>

View File

@@ -1,9 +1,9 @@
#ifndef VIEWLODLIST_H
#define VIEWLODLIST_H
#include "../compat.h"
#include "../realtime/lodlist.h"
#include "assert.h"
#include "compat.h"
#pragma warning(disable : 4786)

View File

@@ -1,6 +1,6 @@
#include "viewroi.h"
#include "../decomp.h"
#include "decomp.h"
DECOMP_SIZE_ASSERT(ViewROI, 0xe0)