[Scummvm-git-logs] scummvm master -> a551722528f1f1e2ee626fa38b26d1bae5e10928
bluegr
noreply at scummvm.org
Sun Oct 12 11:11:30 UTC 2025
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
6d99163121 ENGINES: Drop Move semantics compat code for pre-C++11 compilers
026bf16e8f COMMON: Drop STATIC_ASSERT compat code for pre-C++11 compilers
7f19a83f13 COMMON: Replace STATIC_ASSERT uses with static_assert
89333ecbd6 COMMON: Adjust some comments about C++11 support
d15dc18288 SCI: Drop pre-C++11 compat code for Resource Patcher
a551722528 COMMON: Move NUMARGS() helper to common code
Commit: 6d991631211e44d1f3dcb74f3889651b05559f17
https://github.com/scummvm/scummvm/commit/6d991631211e44d1f3dcb74f3889651b05559f17
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-10-12T14:11:24+03:00
Commit Message:
ENGINES: Drop Move semantics compat code for pre-C++11 compilers
I have checked against MSVC 2015 and the RISC OS GCC 4.7 compiler (whose
C++11 support is not fully complete), and it builds fine without this
compat code (added in 2020 in commit 830a239b046fb769f9ebb87beb5dcc1493d50447).
The old "C++11 readiness" tests on the wiki also report that the feature
is available on all our supported targets:
<https://wiki.scummvm.org/index.php?title=Compiling_ScummVM/C%2B%2B11_Readiness>
Changed paths:
engines/engine.cpp
engines/engine.h
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 851e2ce880e..eb8446218aa 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -1124,7 +1124,6 @@ PauseToken::~PauseToken() {
}
}
-#if __cplusplus >= 201103L
PauseToken::PauseToken(PauseToken &&t2) : _engine(t2._engine) {
t2._engine = nullptr;
}
@@ -1136,7 +1135,6 @@ void PauseToken::operator=(PauseToken &&t2) {
_engine = t2._engine;
t2._engine = nullptr;
}
-#endif
bool Engine::gameTypeHasAddOns() const {
return false;
diff --git a/engines/engine.h b/engines/engine.h
index bc48eb4e6a5..cfabbf37377 100644
--- a/engines/engine.h
+++ b/engines/engine.h
@@ -109,17 +109,15 @@ public:
* Construct a pause token.
*/
PauseToken(const PauseToken &);
-#if __cplusplus >= 201103L
PauseToken(PauseToken &&);
-#endif
~PauseToken();
+
/**
* Assign the pause token.
*/
void operator=(const PauseToken &);
-#if __cplusplus >= 201103L
void operator=(PauseToken &&);
-#endif
+
/**
* Manually release the PauseToken.
*
Commit: 026bf16e8fd395a3814c6a15076e2ed676c1af73
https://github.com/scummvm/scummvm/commit/026bf16e8fd395a3814c6a15076e2ed676c1af73
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-10-12T14:11:24+03:00
Commit Message:
COMMON: Drop STATIC_ASSERT compat code for pre-C++11 compilers
With C++11 already being a requirement, the compat code for pre-C++11
compiler is not needed anymore.
Changed paths:
common/scummsys.h
diff --git a/common/scummsys.h b/common/scummsys.h
index cff8fc4c63b..6fe559fda3b 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -131,30 +131,18 @@
#endif
#ifndef STATIC_ASSERT
-#if __cplusplus >= 201103L || defined(_MSC_VER)
/**
* Generates a compile-time assertion.
*
* @param expression An expression that can be evaluated at compile time.
* @param message An underscore-delimited message to be presented at compile
* time if the expression evaluates to false.
- */
- #define STATIC_ASSERT(expression, message) \
- static_assert((expression), #message)
-#else
- /**
- * Generates a compile-time assertion.
*
- * @param expression An expression that can be evaluated at compile time.
- * @param message An underscore-delimited message to be presented at compile
- * time if the expression evaluates to false.
+ * TODO: Now that we require C++11, all uses of this macro could just use
+ * static_assert().
*/
#define STATIC_ASSERT(expression, message) \
- do { \
- extern int STATIC_ASSERT_##message[(expression) ? 1 : -1]; \
- (void)(STATIC_ASSERT_##message); \
- } while (false)
-#endif
+ static_assert((expression), #message)
#endif
// The following math constants are usually defined by the system math.h header, but
Commit: 7f19a83f138f46490929b407bdabfc5d16e983a4
https://github.com/scummvm/scummvm/commit/7f19a83f138f46490929b407bdabfc5d16e983a4
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-10-12T14:11:24+03:00
Commit Message:
COMMON: Replace STATIC_ASSERT uses with static_assert
The current C++11 requirement means that all targets already support
static_assert().
Changed paths:
common/endian.h
common/ptr.h
common/scummsys.h
common/span.h
common/str.h
engines/cge/cge_main.cpp
engines/cge2/cge2_main.cpp
engines/cge2/vga13h.cpp
engines/grim/emi/sound/emisound.cpp
engines/scumm/he/mixer_he.cpp
engines/testbed/graphics.cpp
engines/twine/debugger/console.cpp
engines/twine/shared.h
graphics/VectorRendererSpec.cpp
image/codecs/hnm.cpp
diff --git a/common/endian.h b/common/endian.h
index 2bfe98198d8..13dfb51d4ee 100644
--- a/common/endian.h
+++ b/common/endian.h
@@ -588,7 +588,7 @@ union SwapFloat {
uint32 u32;
};
-STATIC_ASSERT(sizeof(float) == sizeof(uint32), Unexpected_size_of_float);
+static_assert(sizeof(float) == sizeof(uint32), "Unexpected size of float");
inline float READ_LE_FLOAT32(const void *ptr) {
SwapFloat swap;
@@ -640,7 +640,7 @@ union SwapDouble {
};
#endif
-STATIC_ASSERT(sizeof(double) == sizeof(uint64) || sizeof(double) == sizeof(uint32), Unexpected_size_of_double);
+static_assert(sizeof(double) == sizeof(uint64) || sizeof(double) == sizeof(uint32), "Unexpected size of double");
template<size_t n> inline double READ_DOUBLE(const SwapDouble& sw);
template<size_t n> inline void WRITE_DOUBLE(SwapDouble &sw, double d);
diff --git a/common/ptr.h b/common/ptr.h
index dd08d13e027..567e439aae7 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -90,7 +90,7 @@ public:
protected:
void destructObject() override {
- STATIC_ASSERT(sizeof(T) > 0, SharedPtr_cannot_delete_incomplete_type);
+ static_assert(sizeof(T) > 0, "SharedPtr: cannot delete incomplete type");
delete _ptr;
}
@@ -555,7 +555,7 @@ private:
template <typename T>
struct DefaultDeleter {
inline void operator()(T *object) {
- STATIC_ASSERT(sizeof(T) > 0, cannot_delete_incomplete_type);
+ static_assert(sizeof(T) > 0, "cannot delete incomplete type");
delete object;
}
};
@@ -563,7 +563,7 @@ struct DefaultDeleter {
template <typename T>
struct ArrayDeleter {
inline void operator()(T *object) {
- STATIC_ASSERT(sizeof(T) > 0, cannot_delete_incomplete_type);
+ static_assert(sizeof(T) > 0, "cannot delete incomplete type");
delete[] object;
}
};
diff --git a/common/scummsys.h b/common/scummsys.h
index 6fe559fda3b..c658de01706 100644
--- a/common/scummsys.h
+++ b/common/scummsys.h
@@ -130,21 +130,6 @@
#include <limits>
#endif
-#ifndef STATIC_ASSERT
- /**
- * Generates a compile-time assertion.
- *
- * @param expression An expression that can be evaluated at compile time.
- * @param message An underscore-delimited message to be presented at compile
- * time if the expression evaluates to false.
- *
- * TODO: Now that we require C++11, all uses of this macro could just use
- * static_assert().
- */
- #define STATIC_ASSERT(expression, message) \
- static_assert((expression), #message)
-#endif
-
// The following math constants are usually defined by the system math.h header, but
// they are not part of the ANSI C++ standards and so can NOT be relied upon to be
// present i.e. when -std=c++11 is passed to GCC, enabling strict ANSI compliance.
diff --git a/common/span.h b/common/span.h
index 1cc5815f467..864a14bd560 100644
--- a/common/span.h
+++ b/common/span.h
@@ -322,74 +322,74 @@ public:
}
inline int8 getInt8At(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) == sizeof(uint8), int8_can_only_be_read_from_byte_or_char_spans);
+ static_assert(sizeof(value_type) == sizeof(uint8), "int8 can only be read from byte or char spans");
return (int8)getUint8At(index);
}
inline uint8 getUint8At(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) == sizeof(uint8), uint8_can_only_be_read_from_byte_or_char_spans);
+ static_assert(sizeof(value_type) == sizeof(uint8), "uint8 can only be read from byte or char spans");
impl().validate(index, sizeof(uint8));
return (uint8)impl().data()[index];
}
inline int16 getInt16BEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint16), int16_can_only_be_read_from_int16_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint16), "int16 can only be read from int16 or smaller spans");
return (int16)impl().getUint16BEAt(index);
}
inline int16 getInt16LEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint16), int16_can_only_be_read_from_int16_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint16), "int16 can only be read from int16 or smaller spans");
return (int16)impl().getUint16LEAt(index);
}
inline uint16 getUint16BEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint16), uint16_can_only_be_read_from_int16_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint16), "uint16 can only be read from int16 or smaller spans");
impl().validate(index, sizeof(uint16));
return READ_BE_UINT16(impl().data() + index);
}
inline uint16 getUint16LEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint16), uint16_can_only_be_read_from_int16_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint16), "uint16 can only be read from int16 or smaller spans");
impl().validate(index, sizeof(uint16));
return READ_LE_UINT16(impl().data() + index);
}
inline uint32 getUint24LEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= 3, uint24_can_only_be_read_from_int24_or_smaller_spans);
+ static_assert(sizeof(value_type) <= 3, "uint24 can only be read from int24 or smaller spans");
impl().validate(index, 3);
return READ_LE_UINT24(impl().data() + index);
}
inline uint32 getUint32At(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint32), uint32_can_only_be_read_from_int32_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint32), "uint32 can only be read from int32 or smaller spans");
impl().validate(index, sizeof(uint32));
return READ_UINT32(impl().data() + index);
}
inline int32 getInt32BEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint32), int32_can_only_be_read_from_int32_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint32), "int32 can only be read from int32 or smaller spans");
return (int32)impl().getUint32BEAt(index);
}
inline int32 getInt32LEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint32), int32_can_only_be_read_from_int32_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint32), "int32 can only be read from int32 or smaller spans");
return (int32)impl().getUint32LEAt(index);
}
inline uint32 getUint32BEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint32), uint32_can_only_be_read_from_int32_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint32), "uint32 can only be read from int32 or smaller spans");
impl().validate(index, sizeof(uint32));
return READ_BE_UINT32(impl().data() + index);
}
inline uint32 getUint32LEAt(const index_type index) const {
- STATIC_ASSERT(sizeof(value_type) <= sizeof(uint32), uint32_can_only_be_read_from_int32_or_smaller_spans);
+ static_assert(sizeof(value_type) <= sizeof(uint32), "uint32 can only be read from int32 or smaller spans");
impl().validate(index, sizeof(uint32));
return READ_LE_UINT32(impl().data() + index);
}
inline String getStringAt(const index_type index, size_type numEntries = kSpanMaxSize) const {
- STATIC_ASSERT(sizeof(value_type) == sizeof(char), strings_can_only_be_read_from_byte_or_char_spans);
+ static_assert(sizeof(value_type) == sizeof(char), "strings can only be read from byte or char spans");
const char *string = (const char *)impl().data() + index;
if (numEntries == kSpanMaxSize) {
diff --git a/common/str.h b/common/str.h
index 6f435e71d89..094d277ff5e 100644
--- a/common/str.h
+++ b/common/str.h
@@ -321,7 +321,7 @@ void strcpy_s(char *dst, size_t size, const char *src);
*/
template<typename T, size_t N>
FORCEINLINE void strcpy_s(T (&dst)[N], const char *src) {
- STATIC_ASSERT(sizeof(T) == sizeof(char), T_is_not_compatible_with_char);
+ static_assert(sizeof(T) == sizeof(char), "T is not compatible with char");
strcpy_s((char *)dst, N, src);
}
@@ -352,7 +352,7 @@ void strcat_s(char *dst, size_t size, const char *src);
*/
template<typename T, size_t N>
FORCEINLINE void strcat_s(T (&dst)[N], const char *src) {
- STATIC_ASSERT(sizeof(T) == sizeof(char), T_is_not_compatible_with_char);
+ static_assert(sizeof(T) == sizeof(char), "T is not compatible with char");
strcat_s((char *)dst, N, src);
}
@@ -374,7 +374,7 @@ int vsprintf_s(char *dst, size_t size, const char *format, va_list ap) GCC_PRINT
*/
template<typename T, size_t N>
FORCEINLINE GCC_PRINTF(2, 0) int vsprintf_s(T (&dst)[N], const char *format, va_list ap) {
- STATIC_ASSERT(sizeof(T) == sizeof(char), T_is_not_compatible_with_char);
+ static_assert(sizeof(T) == sizeof(char), "T is not compatible with char");
return vsprintf_s((char *)dst, N, format, ap);
}
@@ -396,7 +396,7 @@ int sprintf_s(char *dst, size_t size, MSVC_PRINTF const char *format, ...) GCC_P
*/
template<typename T, size_t N>
inline GCC_PRINTF(2, 3) int sprintf_s(T (&dst)[N], MSVC_PRINTF const char *format, ...) {
- STATIC_ASSERT(sizeof(T) == sizeof(char), T_is_not_compatible_with_char);
+ static_assert(sizeof(T) == sizeof(char), "T is not compatible with char");
int ret;
va_list ap;
va_start(ap, format);
diff --git a/engines/cge/cge_main.cpp b/engines/cge/cge_main.cpp
index 8ee6c9238cf..3c169827a30 100644
--- a/engines/cge/cge_main.cpp
+++ b/engines/cge/cge_main.cpp
@@ -1039,7 +1039,7 @@ void CGEEngine::loadSprite(const char *fname, int ref, int scene, int col = 0, i
char tmpStr[kLineMax + 1];
Common::String line;
- STATIC_ASSERT(kLineMax + 1 >= kPathMax, mergeExt_expects_kPathMax_buffer);
+ static_assert(kLineMax + 1 >= kPathMax, "mergeExt expects kPathMax buffer");
mergeExt(tmpStr, fname, kSprExt);
if (_resman->exist(tmpStr)) { // sprite description file exist
diff --git a/engines/cge2/cge2_main.cpp b/engines/cge2/cge2_main.cpp
index a0e94065f01..339fbeba3d4 100644
--- a/engines/cge2/cge2_main.cpp
+++ b/engines/cge2/cge2_main.cpp
@@ -167,7 +167,7 @@ Sprite *CGE2Engine::loadSprite(const char *fname, int ref, int scene, V3D &pos)
ID id;
char tmpStr[kLineMax + 1];
- STATIC_ASSERT(sizeof(tmpStr) >= kPathMax, mergeExt_expects_kPathMax_buffer);
+ static_assert(sizeof(tmpStr) >= kPathMax, "mergeExt expects kPathMax buffer");
mergeExt(tmpStr, fname, kSprExt);
if (_resman->exist(tmpStr)) { // sprite description file exist
diff --git a/engines/cge2/vga13h.cpp b/engines/cge2/vga13h.cpp
index 30a422c3eea..e68e8d1f952 100644
--- a/engines/cge2/vga13h.cpp
+++ b/engines/cge2/vga13h.cpp
@@ -244,7 +244,7 @@ int Sprite::labVal(Action snq, int lab) {
return i;
} else {
char tmpStr[kLineMax + 1];
- STATIC_ASSERT(sizeof(tmpStr) >= kPathMax, mergeExt_expects_kPathMax_buffer);
+ static_assert(sizeof(tmpStr) >= kPathMax, "mergeExt expects kPathMax buffer");
_vm->mergeExt(tmpStr, _file, kSprExt);
if (_vm->_resman->exist(tmpStr)) { // sprite description file exist
diff --git a/engines/grim/emi/sound/emisound.cpp b/engines/grim/emi/sound/emisound.cpp
index 2d0d9723228..ba811b480d0 100644
--- a/engines/grim/emi/sound/emisound.cpp
+++ b/engines/grim/emi/sound/emisound.cpp
@@ -668,7 +668,7 @@ void EMISound::initMusicTable() {
_musicTable = initMusicTableDemo("Music/FullMonkeyMap.imt");
_musicPrefix = "Music/";
} else if (g_grim->getGamePlatform() == Common::kPlatformPS2) {
- STATIC_ASSERT(ARRAYSIZE(emiPS2MusicTable) == 126, emiPS2MusicTable_bad_size);
+ static_assert(ARRAYSIZE(emiPS2MusicTable) == 126, "emiPS2MusicTable bad size");
_numMusicStates = 126;
_musicTable = new MusicEntry[126];
for (int i = 0; i < 126; ++i) {
diff --git a/engines/scumm/he/mixer_he.cpp b/engines/scumm/he/mixer_he.cpp
index e9a3812e9e9..a5dadf7d9c4 100644
--- a/engines/scumm/he/mixer_he.cpp
+++ b/engines/scumm/he/mixer_he.cpp
@@ -211,9 +211,9 @@ bool HEMixer::audioOverrideExists(int soundId, bool justGetInfo, int *duration,
#endif
};
- STATIC_ASSERT(
+ static_assert(
ARRAYSIZE(formats) == ARRAYSIZE(formatDecoders),
- formats_formatDecoders_must_have_same_size);
+ "formats and formatDecoders arrays must have same size");
const char *type;
if (soundId == HSND_TALKIE_SLOT) {
diff --git a/engines/testbed/graphics.cpp b/engines/testbed/graphics.cpp
index 4bcc6ba5b9f..146f5701828 100644
--- a/engines/testbed/graphics.cpp
+++ b/engines/testbed/graphics.cpp
@@ -1708,7 +1708,7 @@ void GFXtests::showPixelFormat(const Graphics::PixelFormat &pf, uint aLoss) {
const uint nTones = nLevels * (nLevels - 1) / 2;
const uint paletteSize = nStdColors + nColors * nTones;
- STATIC_ASSERT(paletteSize < 256, cant_fit_all_the_tones_into_CLUT8_palettes);
+ static_assert(paletteSize < 256, "can't fit all the tones into CLUT8 palettes");
uint level[nLevels];
for (uint i = 0; i < nLevels - 1; i++) {
diff --git a/engines/twine/debugger/console.cpp b/engines/twine/debugger/console.cpp
index 59368d27e2a..88d0ba834f8 100644
--- a/engines/twine/debugger/console.cpp
+++ b/engines/twine/debugger/console.cpp
@@ -419,7 +419,7 @@ static const char *ItemNames[] = {
"BonusList",
"CloverLeaf"
};
-STATIC_ASSERT(ARRAYSIZE(ItemNames) == InventoryItems::MaxInventoryItems, "Array size doesn't match items");
+static_assert(ARRAYSIZE(ItemNames) == InventoryItems::MaxInventoryItems, "Array size doesn't match items");
bool TwinEConsole::doGiveItem(int argc, const char **argv) {
if (argc <= 1) {
diff --git a/engines/twine/shared.h b/engines/twine/shared.h
index 832b8f5a2ca..f1cc992dace 100644
--- a/engines/twine/shared.h
+++ b/engines/twine/shared.h
@@ -101,7 +101,7 @@ struct I16Vec3 {
int16 z = 0;
};
#include "common/pack-end.h"
-STATIC_ASSERT(sizeof(I16Vec3) == 6, "Unexpected pointTab size");
+static_assert(sizeof(I16Vec3) == 6, "Unexpected pointTab size");
struct IVec2 {
constexpr IVec2() : x(0), y(0) {}
diff --git a/graphics/VectorRendererSpec.cpp b/graphics/VectorRendererSpec.cpp
index c8d841bdcfc..2ff494ce14b 100644
--- a/graphics/VectorRendererSpec.cpp
+++ b/graphics/VectorRendererSpec.cpp
@@ -431,7 +431,7 @@ namespace Graphics {
*/
template<typename PixelType>
void colorFill(PixelType *first, PixelType *last, PixelType color) {
- STATIC_ASSERT(sizeof(PixelType) == 1 || sizeof(PixelType) == 2 || sizeof(PixelType) == 4, Unsupported_PixelType);
+ static_assert(sizeof(PixelType) == 1 || sizeof(PixelType) == 2 || sizeof(PixelType) == 4, "Unsupported PixelType");
int count = (last - first);
@@ -445,7 +445,7 @@ void colorFill(PixelType *first, PixelType *last, PixelType color) {
template<typename PixelType>
void colorFillClip(PixelType *first, PixelType *last, PixelType color, int realX, int realY, Common::Rect &clippingArea) {
- STATIC_ASSERT(sizeof(PixelType) == 1 || sizeof(PixelType) == 2 || sizeof(PixelType) == 4, Unsupported_PixelType);
+ static_assert(sizeof(PixelType) == 1 || sizeof(PixelType) == 2 || sizeof(PixelType) == 4, "Unsupported PixelType");
if (realY < clippingArea.top || realY >= clippingArea.bottom)
return;
diff --git a/image/codecs/hnm.cpp b/image/codecs/hnm.cpp
index 35bd61eef03..3788c9100a1 100644
--- a/image/codecs/hnm.cpp
+++ b/image/codecs/hnm.cpp
@@ -542,12 +542,12 @@ static const int8 S4[] = {
-8, -7, -6, -5, -4, -3, -2, -1
};
-STATIC_ASSERT(ARRAYSIZE(LUMA_QUANT_TABLE) == 64, "invalid luma table size");
-STATIC_ASSERT(ARRAYSIZE(CHROMA_QUANT_TABLE) == 64, "invalid chromaa table size");
-STATIC_ASSERT(ARRAYSIZE(AAN_FACTORS) == 64, "invalid AAN factors table size");
-STATIC_ASSERT(ARRAYSIZE(ZIGZAG) == 64, "invalid zigzag table size");
-STATIC_ASSERT(ARRAYSIZE(S2) == 16 * 2, "invalid S2 table size");
-STATIC_ASSERT(ARRAYSIZE(S4) == 16, "invalid S4 table size");
+static_assert(ARRAYSIZE(LUMA_QUANT_TABLE) == 64, "invalid luma table size");
+static_assert(ARRAYSIZE(CHROMA_QUANT_TABLE) == 64, "invalid chromaa table size");
+static_assert(ARRAYSIZE(AAN_FACTORS) == 64, "invalid AAN factors table size");
+static_assert(ARRAYSIZE(ZIGZAG) == 64, "invalid zigzag table size");
+static_assert(ARRAYSIZE(S2) == 16 * 2, "invalid S2 table size");
+static_assert(ARRAYSIZE(S4) == 16, "invalid S4 table size");
static const int HEADER_SIZE = 6 * sizeof(uint32);
Commit: 89333ecbd631494762bae4ea941591547889b724
https://github.com/scummvm/scummvm/commit/89333ecbd631494762bae4ea941591547889b724
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-10-12T14:11:24+03:00
Commit Message:
COMMON: Adjust some comments about C++11 support
Changed paths:
common/array.h
common/bitstream.h
diff --git a/common/array.h b/common/array.h
index 1a8ef62df31..733b493186e 100644
--- a/common/array.h
+++ b/common/array.h
@@ -116,8 +116,6 @@ public:
* Common::Array<int> myArray = {1, 7, 42};
* @endcode
* constructs an array with 3 elements whose values are 1, 7, and 42 respectively.
- * @note
- * This constructor is only available when C++11 support is enabled.
*/
Array(std::initializer_list<T> list) : _size(list.size()) {
allocCapacity(list.size());
diff --git a/common/bitstream.h b/common/bitstream.h
index f1b1f5400cd..f00d441a9ad 100644
--- a/common/bitstream.h
+++ b/common/bitstream.h
@@ -330,9 +330,11 @@ public:
* It removes the virtual call overhead for reading bytes from a memory buffer,
* and allows directly inlining this access.
*
+ * FIXME:
* The code duplication with MemoryReadStream is not ideal.
* It might be possible to avoid this by making this a final subclass of
- * MemoryReadStream, but that is a C++11 feature.
+ * MemoryReadStream. Deviating from it would also allow faster aligned memory
+ * loads.
*/
class BitStreamMemoryStream {
private:
Commit: d15dc1828828377aef15e1b4e58aeae275454b55
https://github.com/scummvm/scummvm/commit/d15dc1828828377aef15e1b4e58aeae275454b55
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-10-12T14:11:24+03:00
Commit Message:
SCI: Drop pre-C++11 compat code for Resource Patcher
This reverts commit 17c4d6f191a433a84cdbf955b1c88644aff4437f and
commit 7aa824372e62835571ddd847417f479a5498f1f2.
Changed paths:
engines/sci/resource/resource_patcher.cpp
engines/sci/resource/resource_patcher.h
diff --git a/engines/sci/resource/resource_patcher.cpp b/engines/sci/resource/resource_patcher.cpp
index 973dbf8d112..e135c4a8271 100644
--- a/engines/sci/resource/resource_patcher.cpp
+++ b/engines/sci/resource/resource_patcher.cpp
@@ -30,16 +30,14 @@ namespace Sci {
// Start of internal resource patcher macros. Please do not use these directly
// in resource patches.
-// NOTE: The following breaks in non-C++11 compilers. It can be used to simplify the
-// _BYTEOP(), and consequently the REPLACE() and INSERT() macros below.
-//using int_c_array = int[];
-//#define _NUMARGS(...) (sizeof(int_c_array{ __VA_ARGS__ }) / sizeof(int))
+using int_c_array = int[];
+#define _NUMARGS(...) (sizeof(int_c_array{__VA_ARGS__})/sizeof(int))
#ifdef SCUMM_LITTLE_ENDIAN
#define _PACKINT32(n) (((uint32)n) & 0xFF), (((uint32)n) >> 8 & 0xFF), (((uint32)n) >> 16 & 0xFF), (((uint32)n) >> 24 & 0xFF)
#else
#define _PACKINT32(n) (((uint32)n) >> 24 & 0xFF), (((uint32)n) >> 16 & 0xFF), (((uint32)n) >> 8 & 0xFF), (((uint32)n) & 0xFF)
#endif
-#define _BYTEOP(op, numBytes, ...) op, _PACKINT32(numBytes), __VA_ARGS__
+#define _BYTEOP(op, ...) op, _PACKINT32(_NUMARGS(__VA_ARGS__)), __VA_ARGS__
#define _NUMBEROP(op, type, value) op, sizeof(type), _PACKINT32(value)
#define _FILLOP(op, numBytes, value) op, _PACKINT32(numBytes), value
// End of internal resource patcher macros
@@ -52,12 +50,12 @@ namespace Sci {
/**
* Replaces data at the current position.
*/
-#define REPLACE(numBytes, ...) _BYTEOP(kReplaceBytes, numBytes, __VA_ARGS__)
+#define REPLACE(...) _BYTEOP(kReplaceBytes, __VA_ARGS__)
/**
* Inserts new data at the current position.
*/
-#define INSERT(numBytes, ...) _BYTEOP(kInsertBytes, numBytes, __VA_ARGS__)
+#define INSERT(...) _BYTEOP(kInsertBytes, __VA_ARGS__)
/**
* Replaces a number of the given type at the current position with the given
@@ -154,7 +152,7 @@ static const byte phant1View64001Palette[] = {
static const byte pq4EnhancedAudioToggleView[] = {
INSERT_NUMBER(uint16, 16), // header size
INSERT_NUMBER(uint8, 1), // loop count
- INSERT(2, 0x00, 0x01), // unused
+ INSERT(0x00, 0x01), // unused
INSERT_NUMBER(uint8, 0), // resolution flag
INSERT_NUMBER(uint16, 0), // unused
INSERT_NUMBER(uint32, 70), // palette offset
@@ -196,7 +194,7 @@ static const byte pq4EnhancedAudioToggleView[] = {
INSERT_NUMBER(uint8, 1), // used
INSERT_NUMBER(uint8, 0), // shared used
INSERT_NUMBER(uint32, 0), // version
- INSERT(152, // color data
+ INSERT( // color data
0x01, 0x00, 0x00, 0x00, 0x01, 0x1B, 0x1B, 0x1B, 0x01, 0x2B,
0x2F, 0x2B, 0x01, 0x33, 0x33, 0x33, 0x01, 0x37, 0x3B, 0x37,
0x01, 0x47, 0x47, 0x47, 0x01, 0x4B, 0x4B, 0x4B, 0x01, 0x53,
@@ -217,7 +215,7 @@ static const byte pq4EnhancedAudioToggleView[] = {
INSERT_FILL(0x00, 872), // unused color entries
// pixel data
- INSERT(1955,
+ INSERT(
0x07, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
@@ -736,7 +734,7 @@ ResourcePatcher::PatchSizes ResourcePatcher::calculatePatchSizes(const byte *pat
}
}
- return PatchSizes(dataSize, deltaSize);
+ return { dataSize, deltaSize };
}
int32 ResourcePatcher::readBlockSize(const byte * &patchData) const {
diff --git a/engines/sci/resource/resource_patcher.h b/engines/sci/resource/resource_patcher.h
index 24442d4b1cd..df1ad39af80 100644
--- a/engines/sci/resource/resource_patcher.h
+++ b/engines/sci/resource/resource_patcher.h
@@ -126,11 +126,6 @@ private:
* data.
*/
int32 delta;
-
- PatchSizes(uint32 exp, int32 d) {
- expected = exp;
- delta = d;
- }
};
typedef Common::Array<GameResourcePatch> PatchList;
Commit: a551722528f1f1e2ee626fa38b26d1bae5e10928
https://github.com/scummvm/scummvm/commit/a551722528f1f1e2ee626fa38b26d1bae5e10928
Author: Donovan Watteau (contrib at dwatteau.fr)
Date: 2025-10-12T14:11:24+03:00
Commit Message:
COMMON: Move NUMARGS() helper to common code
Changed paths:
common/util.h
engines/sci/resource/resource_patcher.cpp
diff --git a/common/util.h b/common/util.h
index ea1fdcb4e0e..1fc198cbad6 100644
--- a/common/util.h
+++ b/common/util.h
@@ -93,6 +93,15 @@ static inline uint32 ROTATE_RIGHT_32(const uint32 x, const uint32 r) {
return (x << (32 - r)) | (x >> r);
}
+#if !defined(_MSC_VER) || _MSC_VER >= 1910
+/** Template method to return the number of arguments passed to it. */
+template<typename... A> constexpr size_t NUMARGS(A&&...) { return sizeof...(A); }
+#else
+/** Macro that returns the number of arguments passed to it. */
+using int_c_array = int[]; // MSVC 2015 doesn't like the template method above
+#define NUMARGS(...) (sizeof(int_c_array{__VA_ARGS__})/sizeof(int))
+#endif
+
#ifdef ARRAYSIZE
#undef ARRAYSIZE
#endif
diff --git a/engines/sci/resource/resource_patcher.cpp b/engines/sci/resource/resource_patcher.cpp
index e135c4a8271..85a8c51e89e 100644
--- a/engines/sci/resource/resource_patcher.cpp
+++ b/engines/sci/resource/resource_patcher.cpp
@@ -21,6 +21,7 @@
#include "common/scummsys.h"
#include "common/textconsole.h"
+#include "common/util.h"
#include "sci/sci.h"
#include "sci/engine/workarounds.h" // for SciMedia
#include "sci/resource/resource.h"
@@ -30,14 +31,12 @@ namespace Sci {
// Start of internal resource patcher macros. Please do not use these directly
// in resource patches.
-using int_c_array = int[];
-#define _NUMARGS(...) (sizeof(int_c_array{__VA_ARGS__})/sizeof(int))
#ifdef SCUMM_LITTLE_ENDIAN
#define _PACKINT32(n) (((uint32)n) & 0xFF), (((uint32)n) >> 8 & 0xFF), (((uint32)n) >> 16 & 0xFF), (((uint32)n) >> 24 & 0xFF)
#else
#define _PACKINT32(n) (((uint32)n) >> 24 & 0xFF), (((uint32)n) >> 16 & 0xFF), (((uint32)n) >> 8 & 0xFF), (((uint32)n) & 0xFF)
#endif
-#define _BYTEOP(op, ...) op, _PACKINT32(_NUMARGS(__VA_ARGS__)), __VA_ARGS__
+#define _BYTEOP(op, ...) op, _PACKINT32(NUMARGS(__VA_ARGS__)), __VA_ARGS__
#define _NUMBEROP(op, type, value) op, sizeof(type), _PACKINT32(value)
#define _FILLOP(op, numBytes, value) op, _PACKINT32(numBytes), value
// End of internal resource patcher macros
More information about the Scummvm-git-logs
mailing list