[Scummvm-git-logs] scummvm master -> fcb8eda978fb85e3e0048ea09d49a76c0fd4896d
sev-
noreply at scummvm.org
Sat Apr 29 11:10:28 UTC 2023
This automated email contains information about 6 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
5b1239eb93 COMMON: Make the Common::Array() constructor constexpr
f5491c9e65 COMMON: Make the Common::List() constructor constexpr
6057d12816 COMMON: Make the Common::Rect() / Common::Point() constructor constexpr
c1eedd42c5 COMMON: Make the Common::String()/U32String() constructor constexpr
cfb9c4b251 MATH: Make the Rotation3D/Transform constructors constexpr
fcb8eda978 MATH: Add some constexpr to the Matrix base-classes.
Commit: 5b1239eb938bc55023d5a8a06cbd4b02eeb181c4
https://github.com/scummvm/scummvm/commit/5b1239eb938bc55023d5a8a06cbd4b02eeb181c4
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:10:23+02:00
Commit Message:
COMMON: Make the Common::Array() constructor constexpr
This lets us have constexpr structs/classes that contain Common::Array
Changed paths:
common/array.h
diff --git a/common/array.h b/common/array.h
index ae702e9d9fb..7d3e6bb8b3f 100644
--- a/common/array.h
+++ b/common/array.h
@@ -64,7 +64,7 @@ protected:
T *_storage; /*!< Memory used for element storage. */
public:
- Array() : _capacity(0), _size(0), _storage(nullptr) {}
+ constexpr Array() : _capacity(0), _size(0), _storage(nullptr) {}
/**
* Construct an array with @p count default-inserted instances of @p T. No
Commit: f5491c9e658767eaafdbdaf631b801621a4c344f
https://github.com/scummvm/scummvm/commit/f5491c9e658767eaafdbdaf631b801621a4c344f
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:10:23+02:00
Commit Message:
COMMON: Make the Common::List() constructor constexpr
This lets us have constexpr structs/classes that contain Common::List
Changed paths:
common/list.h
common/list_intern.h
diff --git a/common/list.h b/common/list.h
index dfeea7e41e5..3a1b29bb42e 100644
--- a/common/list.h
+++ b/common/list.h
@@ -59,10 +59,7 @@ public:
/**
* Construct a new empty list.
*/
- List() {
- _anchor._prev = &_anchor;
- _anchor._next = &_anchor;
- }
+ constexpr List() : _anchor(&_anchor, &_anchor) {}
List(const List<t_T> &list) { /*!< Construct a new list as a copy of the given @p list. */
_anchor._prev = &_anchor;
_anchor._next = &_anchor;
diff --git a/common/list_intern.h b/common/list_intern.h
index 1fc0e85b36b..3d9660c6f53 100644
--- a/common/list_intern.h
+++ b/common/list_intern.h
@@ -31,8 +31,11 @@ template<typename T> class List;
namespace ListInternal {
struct NodeBase {
- NodeBase *_prev;
- NodeBase *_next;
+ NodeBase *_prev = nullptr;
+ NodeBase *_next = nullptr;
+
+ constexpr NodeBase() = default;
+ constexpr NodeBase(NodeBase *prev, NodeBase *next) : _prev(prev), _next(next) {}
};
template<typename T>
Commit: 6057d1281615646c476f38082d00c76b508197b5
https://github.com/scummvm/scummvm/commit/6057d1281615646c476f38082d00c76b508197b5
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:10:23+02:00
Commit Message:
COMMON: Make the Common::Rect() / Common::Point() constructor constexpr
This lets us have constexpr structs/classes that contain Rect / Point
Changed paths:
common/rect.h
diff --git a/common/rect.h b/common/rect.h
index 937afa664c5..0a74cec6c39 100644
--- a/common/rect.h
+++ b/common/rect.h
@@ -46,12 +46,12 @@ struct Point {
int16 x; /*!< The horizontal position of the point. */
int16 y; /*!< The vertical position of the point. */
- Point() : x(0), y(0) {}
+ constexpr Point() : x(0), y(0) {}
/**
* Create a point with position defined by @p x1 and @p y1.
*/
- Point(int16 x1, int16 y1) : x(x1), y(y1) {}
+ constexpr Point(int16 x1, int16 y1) : x(x1), y(y1) {}
/**
* Determine whether the position of two points is the same.
*/
@@ -145,11 +145,11 @@ struct Rect {
int16 top, left; /*!< The point at the top left of the rectangle (part of the Rect). */
int16 bottom, right; /*!< The point at the bottom right of the rectangle (not part of the Rect). */
- Rect() : top(0), left(0), bottom(0), right(0) {}
+ constexpr Rect() : top(0), left(0), bottom(0), right(0) {}
/**
* Create a rectangle with the top-left corner at position (0, 0) and the given width @p w and height @p h.
*/
- Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
+ constexpr Rect(int16 w, int16 h) : top(0), left(0), bottom(h), right(w) {}
/**
* Create a rectangle with the top-left corner at the given position (x1, y1)
* and the bottom-right corner at the position (x2, y2).
Commit: c1eedd42c5058985e3bbb7630e0aa10a5e3887b3
https://github.com/scummvm/scummvm/commit/c1eedd42c5058985e3bbb7630e0aa10a5e3887b3
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:10:23+02:00
Commit Message:
COMMON: Make the Common::String()/U32String() constructor constexpr
This lets us have constexpr structs/classes that contain Common::String
Changed paths:
common/str-base.h
common/str.h
common/ustr.h
diff --git a/common/str-base.h b/common/str-base.h
index 9fb35571a33..aa530c5c0e7 100644
--- a/common/str-base.h
+++ b/common/str-base.h
@@ -81,7 +81,7 @@ protected:
public:
/** Construct a new empty string. */
- BaseString() : _size(0), _str(_storage) { _storage[0] = 0; }
+ constexpr BaseString() : _size(0), _str(_storage), _storage{0} {}
/** Construct a copy of the given string. */
BaseString(const BaseString &str);
diff --git a/common/str.h b/common/str.h
index d4d3cfbd6cb..e23dc1abe48 100644
--- a/common/str.h
+++ b/common/str.h
@@ -66,7 +66,7 @@ public:
typedef unsigned char unsigned_type;
/** Construct a new empty string. */
- String() : BaseString<char>() {}
+ constexpr String() : BaseString<char>() {}
/** Construct a new string from the given NULL-terminated C string. */
String(const char *str) : BaseString<char>(str) {}
diff --git a/common/ustr.h b/common/ustr.h
index ea26a259128..1ffa8fc555e 100644
--- a/common/ustr.h
+++ b/common/ustr.h
@@ -59,7 +59,7 @@ public:
typedef uint32 unsigned_type; /*!< Unsigned version of the underlying type. */
public:
/** Construct a new empty string. */
- U32String() : BaseString<u32char_type_t>() {}
+ constexpr U32String() : BaseString<u32char_type_t>() {}
/** Construct a new string from the given null-terminated C string. */
explicit U32String(const value_type *str) : BaseString<u32char_type_t>(str) {}
Commit: cfb9c4b25152ff7d396e3f18358959ee7a7c04a1
https://github.com/scummvm/scummvm/commit/cfb9c4b25152ff7d396e3f18358959ee7a7c04a1
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:10:23+02:00
Commit Message:
MATH: Make the Rotation3D/Transform constructors constexpr
This lets us have constexpr structs/classes that contain them
Changed paths:
math/rotation3d.h
math/transform.h
diff --git a/math/rotation3d.h b/math/rotation3d.h
index 806352287ee..021548d8c56 100644
--- a/math/rotation3d.h
+++ b/math/rotation3d.h
@@ -52,7 +52,7 @@ enum EulerOrder {
template<class T>
class Rotation3D : public Transform<T> {
public:
- Rotation3D();
+ constexpr Rotation3D();
/**
* Constructor and assignment from buildFromEuler
@@ -101,7 +101,7 @@ public:
};
template<class T>
-Rotation3D<T>::Rotation3D() : Transform<T>() {}
+constexpr Rotation3D<T>::Rotation3D() : Transform<T>() {}
template<class T>
void Rotation3D<T>::buildFromEuler(const Angle &first, const Angle &second, const Angle &third, EulerOrder order) {
diff --git a/math/transform.h b/math/transform.h
index e371a1e0464..0a8b9a143d7 100644
--- a/math/transform.h
+++ b/math/transform.h
@@ -27,7 +27,7 @@ namespace Math {
template<class T>
class Transform {
public:
- Transform() {}
+ constexpr Transform() {}
protected:
inline const T &getMatrix() const { return *static_cast<const T *>(this); }
Commit: fcb8eda978fb85e3e0048ea09d49a76c0fd4896d
https://github.com/scummvm/scummvm/commit/fcb8eda978fb85e3e0048ea09d49a76c0fd4896d
Author: Einar Johan Trøan SømaÌen (somaen at scummvm.org)
Date: 2023-04-29T13:10:23+02:00
Commit Message:
MATH: Add some constexpr to the Matrix base-classes.
Currently we can't quite make Matrix3's default constructor constexpr,
as the setToIdentity-call requires C++14.
Changed paths:
math/matrix.h
math/matrix3.cpp
math/matrix3.h
diff --git a/math/matrix.h b/math/matrix.h
index 133babd6a1f..e75702a5d8c 100644
--- a/math/matrix.h
+++ b/math/matrix.h
@@ -143,7 +143,7 @@ public:
Matrix<rows, cols> &operator/=(const Matrix<rows, cols> &m);
protected:
- MatrixBase();
+ constexpr MatrixBase() = default;
MatrixBase(const float *data);
MatrixBase(const MatrixBase<rows, cols> &m);
MatrixBase &operator=(const MatrixBase<rows, cols> &m);
@@ -154,7 +154,7 @@ protected:
return *static_cast<Matrix<rows, cols> *>(this); }
private:
- float _values[rows * cols];
+ float _values[rows * cols] = { 0.0f };
};
/**
@@ -164,7 +164,7 @@ private:
template<int r, int c>
class MatrixType : public MatrixBase<r, c> {
protected:
- MatrixType() : MatrixBase<r, c>() { }
+ constexpr MatrixType() : MatrixBase<r, c>() { }
MatrixType(const float *data) : MatrixBase<r, c>(data) { }
MatrixType(const MatrixBase<r, c> &m) : MatrixBase<r, c>(m) { }
};
@@ -179,7 +179,7 @@ protected:
template<int r, int c>
class Matrix : public MatrixType<r, c> {
public:
- Matrix() : MatrixType<r, c>() { }
+ constexpr Matrix() : MatrixType<r, c>() { }
Matrix(const float *data) : MatrixType<r, c>(data) { }
Matrix(const MatrixBase<r, c> &m) : MatrixType<r, c>(m) { }
};
@@ -214,13 +214,6 @@ bool operator!=(const Matrix<r, c> &m1, const Matrix<r, c> &m2);
// Constructors
-template<int rows, int cols>
-MatrixBase<rows, cols>::MatrixBase() {
- for (int i = 0; i < rows * cols; ++i) {
- _values[i] = 0.f;
- }
-}
-
template<int rows, int cols>
MatrixBase<rows, cols>::MatrixBase(const float *data) {
setData(data);
diff --git a/math/matrix3.cpp b/math/matrix3.cpp
index 161ac2e6706..23e4db688df 100644
--- a/math/matrix3.cpp
+++ b/math/matrix3.cpp
@@ -23,14 +23,6 @@
namespace Math {
-Matrix<3, 3>::Matrix() :
- MatrixType<3, 3>(), Rotation3D<Matrix<3, 3> >() {
-}
-
-Matrix<3, 3>::Matrix(const MatrixBase<3, 3> &m) :
- MatrixType<3, 3>(m), Rotation3D<Matrix<3, 3> >() {
-}
-
void swap (float &a, float &b) {
float c = a; a = b; b = c;
}
diff --git a/math/matrix3.h b/math/matrix3.h
index 4e1b77f70f5..7b2ae87efad 100644
--- a/math/matrix3.h
+++ b/math/matrix3.h
@@ -31,8 +31,10 @@ namespace Math {
template<>
class Matrix<3, 3> : public MatrixType<3, 3>, public Rotation3D<Matrix<3, 3> > {
public:
- Matrix();
- Matrix(const MatrixBase<3, 3> &m);
+ Matrix() : MatrixType<3, 3>(), Rotation3D<Matrix<3, 3> >() {}
+ Matrix(const MatrixBase<3, 3> &m) :
+ MatrixType<3, 3>(m), Rotation3D<Matrix<3, 3> >() {
+ }
void transpose();
More information about the Scummvm-git-logs
mailing list