Browse Source

Use anonymous typed enum instead of static const member variable.

The reason behind this is that it's not possible to take address of the
enum value -- the generated code can be simpler and no symbol is
exported.
pull/107/head
Vladimír Vondruš 11 years ago
parent
commit
1d9e6210d8
  1. 7
      src/Magnum/Array.h
  2. 4
      src/Magnum/BufferImage.h
  3. 4
      src/Magnum/Image.h
  4. 4
      src/Magnum/ImageReference.h
  5. 20
      src/Magnum/Implementation/BufferState.h
  6. 6
      src/Magnum/Math/BoolVector.h
  7. 4
      src/Magnum/Math/Matrix.h
  8. 22
      src/Magnum/Math/RectangularMatrix.h
  9. 7
      src/Magnum/Math/Vector.h
  10. 4
      src/Magnum/MultisampleTexture.h
  11. 5
      src/Magnum/SceneGraph/AbstractTransformation.h
  12. 4
      src/Magnum/Texture.h
  13. 4
      src/Magnum/TextureArray.h
  14. 4
      src/Magnum/Trade/ImageData.h

7
src/Magnum/Array.h

@ -48,8 +48,11 @@ don't need any math operations and fuzzy comparison (e.g. enum values). Unlike
*/
template<UnsignedInt dimensions, class T> class Array {
public:
typedef T Type; /**< @brief Data type */
const static UnsignedInt Dimensions = dimensions; /**< @brief Dimension count */
typedef T Type; /**< @brief Data type */
enum: UnsignedInt {
Dimensions = dimensions /**< Dimension count */
};
/**
* @brief Default constructor

4
src/Magnum/BufferImage.h

@ -50,7 +50,9 @@ Stores image data in GPU memory. Interchangeable with @ref Image,
*/
template<UnsignedInt dimensions> class BufferImage: public AbstractImage {
public:
const static UnsignedInt Dimensions = dimensions; /**< @brief Image dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Image dimension count */
};
/**
* @brief Constructor

4
src/Magnum/Image.h

@ -42,7 +42,9 @@ Stores image data on client memory. Interchangeable with @ref ImageReference,
*/
template<UnsignedInt dimensions> class Image: public AbstractImage {
public:
const static UnsignedInt Dimensions = dimensions; /**< @brief Image dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Image dimension count */
};
/**
* @brief Constructor

4
src/Magnum/ImageReference.h

@ -52,7 +52,9 @@ Interchangeable with @ref Image, @ref BufferImage or @ref Trade::ImageData.
*/
template<UnsignedInt dimensions> class ImageReference: public AbstractImage {
public:
const static UnsignedInt Dimensions = dimensions; /**< @brief Image dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Image dimension count */
};
/**
* @brief Constructor

20
src/Magnum/Implementation/BufferState.h

@ -30,15 +30,17 @@
namespace Magnum { namespace Implementation {
struct BufferState {
#ifndef MAGNUM_TARGET_GLES
static const std::size_t TargetCount = 13+1;
#elif !defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)
static const std::size_t TargetCount = 8+1;
#elif !defined(MAGNUM_TARGET_GLES2)
static const std::size_t TargetCount = 12+1;
#else
static const std::size_t TargetCount = 2+1;
#endif
enum: std::size_t {
#ifndef MAGNUM_TARGET_GLES
TargetCount = 13+1
#elif !defined(MAGNUM_TARGET_GLES2) && defined(MAGNUM_TARGET_WEBGL)
TargetCount = 8+1
#elif !defined(MAGNUM_TARGET_GLES2)
TargetCount = 12+1
#else
TargetCount = 2+1
#endif
};
/* Target <-> index mapping */
static std::size_t indexForTarget(Buffer::TargetHint target);

6
src/Magnum/Math/BoolVector.h

@ -67,8 +67,10 @@ template<std::size_t size> class BoolVector {
static_assert(size != 0, "BoolVector cannot have zero elements");
public:
static const std::size_t Size = size; /**< @brief Vector size */
static const std::size_t DataSize = (size-1)/8+1; /**< @brief Vector storage size */
enum: std::size_t {
Size = size, /**< Vector size */
DataSize = (size-1)/8+1 /**< Vector storage size */
};
/** @brief Construct zero-filled boolean vector */
constexpr /*implicit*/ BoolVector(ZeroInitT = ZeroInit): _data{} {}

4
src/Magnum/Math/Matrix.h

@ -49,7 +49,9 @@ See @ref matrix-vector for brief introduction.
*/
template<std::size_t size, class T> class Matrix: public RectangularMatrix<size, size, T> {
public:
const static std::size_t Size = size; /**< @brief Matrix size */
enum: std::size_t {
Size = size /**< Matrix size */
};
#ifdef MAGNUM_BUILD_DEPRECATED
/**

22
src/Magnum/Math/RectangularMatrix.h

@ -58,16 +58,18 @@ template<std::size_t cols, std::size_t rows, class T> class RectangularMatrix {
template<std::size_t, std::size_t, class> friend class RectangularMatrix;
public:
typedef T Type; /**< @brief Underlying data type */
const static std::size_t Cols = cols; /**< @brief Matrix column count */
const static std::size_t Rows = rows; /**< @brief Matrix row count */
/**
* @brief Size of matrix diagonal
*
* @see @ref fromDiagonal(), @ref diagonal()
*/
const static std::size_t DiagonalSize = (cols < rows ? cols : rows);
typedef T Type; /**< @brief Underlying data type */
enum: std::size_t {
Cols = cols, /**< Matrix column count */
Rows = rows, /**< Matrix row count */
/**
* Size of matrix diagonal
* @see @ref fromDiagonal(), @ref diagonal()
*/
DiagonalSize = (cols < rows ? cols : rows)
};
/**
* @brief Matrix from array

7
src/Magnum/Math/Vector.h

@ -89,8 +89,11 @@ template<std::size_t size, class T> class Vector {
template<std::size_t, class> friend class Vector;
public:
typedef T Type; /**< @brief Underlying data type */
const static std::size_t Size = size; /**< @brief Vector size */
typedef T Type; /**< @brief Underlying data type */
enum: std::size_t {
Size = size /**< Vector size */
};
/**
* @brief Vector from array

4
src/Magnum/MultisampleTexture.h

@ -95,7 +95,9 @@ shaders.
*/
template<UnsignedInt dimensions> class MultisampleTexture: public AbstractTexture {
public:
static const UnsignedInt Dimensions = dimensions; /**< @brief Texture dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Texture dimension count */
};
/**
* @brief Max supported multisample texture size

5
src/Magnum/SceneGraph/AbstractTransformation.h

@ -62,8 +62,9 @@ template<UnsignedInt dimensions, class T> class AbstractTransformation {
/** @brief Underlying floating-point type */
typedef T Type;
/** @brief Dimension count */
static const UnsignedInt Dimensions = dimensions;
enum: UnsignedInt {
Dimensions = dimensions /**< Dimension count */
};
explicit AbstractTransformation();

4
src/Magnum/Texture.h

@ -105,7 +105,9 @@ in shaders.
*/
template<UnsignedInt dimensions> class Texture: public AbstractTexture {
public:
static const UnsignedInt Dimensions = dimensions; /**< @brief Texture dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Texture dimension count */
};
/**
* @brief Max supported texture size

4
src/Magnum/TextureArray.h

@ -96,7 +96,9 @@ documentation for more information about usage in shaders.
*/
template<UnsignedInt dimensions> class TextureArray: public AbstractTexture {
public:
static const UnsignedInt Dimensions = dimensions; /**< @brief Texture dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Texture dimension count */
};
/**
* @brief Max supported texture array size

4
src/Magnum/Trade/ImageData.h

@ -42,7 +42,9 @@ Interchangeable with @ref Image, @ref ImageReference or @ref BufferImage.
*/
template<UnsignedInt dimensions> class ImageData: public AbstractImage {
public:
const static UnsignedInt Dimensions = dimensions; /**< @brief Image dimension count */
enum: UnsignedInt {
Dimensions = dimensions /**< Image dimension count */
};
/**
* @brief Constructor

Loading…
Cancel
Save