Skip to content

Commit

Permalink
Fixed GLM_FORCE_SIZE_FUNC and added test #245
Browse files Browse the repository at this point in the history
  • Loading branch information
Groovounet committed Oct 12, 2014
1 parent b2ce1a7 commit 85037a1
Show file tree
Hide file tree
Showing 32 changed files with 207 additions and 90 deletions.
16 changes: 4 additions & 12 deletions glm/detail/_swizzle.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,15 @@ namespace detail

GLM_FUNC_QUALIFIER value_type& operator[] (size_t i)
{
#ifndef __CUDA_ARCH__
static
#endif
const int offset_dst[4] = { E0, E1, E2, E3 };
const int offset_dst[4] = { E0, E1, E2, E3 };
return this->elem(offset_dst[i]);
}
GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const
{
#ifndef __CUDA_ARCH__
static
#endif
const int offset_dst[4] = { E0, E1, E2, E3 };
const int offset_dst[4] = { E0, E1, E2, E3 };
return this->elem(offset_dst[i]);
}

protected:
template <typename T>
GLM_FUNC_QUALIFIER void _apply_op(const VecType& that, T op)
Expand Down Expand Up @@ -179,10 +174,7 @@ namespace detail

GLM_FUNC_QUALIFIER value_type operator[] (size_t i) const
{
#ifndef __CUDA_ARCH__
static
#endif
const int offset_dst[4] = { E0, E1, E2, E3 };
const int offset_dst[4] = { E0, E1, E2, E3 };
return this->elem(offset_dst[i]);
}
};
Expand Down
16 changes: 8 additions & 8 deletions glm/detail/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -808,21 +808,21 @@ namespace glm

namespace detail
{
# ifdef GLM_FORCE_SIZE_FUNC
typedef size_t component_count_t;
# else
typedef length_t component_count_t;
# endif

template <typename genType>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR length_t component_count(genType const & m)
GLM_FUNC_QUALIFIER GLM_CONSTEXPR component_count_t component_count(genType const & m)
{
# if GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
return m.size();
# else
return m.length();
# endif
}

# if GLM_FORCE_SIZE_FUNC
typedef size_t component_count_t;
# else
typedef length_t component_count_t;
# endif
}//namespace detail
}//namespace glm

Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat2x2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace glm
typedef tmat2x2<T, P> type;
typedef tmat2x2<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

template <typename U, precision Q>
friend tvec2<U, Q> operator/(tmat2x2<U, Q> const & m, tvec2<U, Q> const & v);
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat2x2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace detail
}
}//namespace detail

#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x2<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat2x3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace glm
typedef tmat2x3<T, P> type;
typedef tmat3x2<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

private:
// Data
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat2x3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x3<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat2x4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace glm
typedef tmat2x4<T, P> type;
typedef tmat4x2<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

private:
// Data
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat2x4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat2x4<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat3x2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace glm
typedef tmat3x2<T, P> type;
typedef tmat2x3<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

private:
// Data
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat3x2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x2<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat3x3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace glm
typedef tmat3x3<T, P> type;
typedef tmat3x3<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

template <typename U, precision Q>
friend tvec3<U, Q> operator/(tmat3x3<U, Q> const & m, tvec3<U, Q> const & v);
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat3x3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace detail
}
}//namespace detail

#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x3<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat3x4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace glm
typedef tmat3x4<T, P> type;
typedef tmat4x3<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

private:
// Data
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat3x4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat3x4<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat4x2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace glm
typedef tmat4x2<T, P> type;
typedef tmat2x4<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

private:
// Data
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat4x2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x2<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat4x3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ namespace glm
typedef tmat4x3<T, P> type;
typedef tmat3x4<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

private:
// Data
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat4x3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x3<T, P>::size() const
{
Expand Down
10 changes: 5 additions & 5 deletions glm/detail/type_mat4x4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ namespace glm
typedef tmat4x4<T, P> type;
typedef tmat4x4<T, P> transpose_type;

#if GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
#else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
#endif//GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
GLM_FUNC_DECL GLM_CONSTEXPR length_t length() const;
# endif//GLM_FORCE_SIZE_FUNC

template <typename U, precision Q>
friend tvec4<U, Q> operator/(tmat4x4<U, Q> const & m, tvec4<U, Q> const & v);
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_mat4x4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace detail
}
}//namespace detail

#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tmat4x4<T, P>::size() const
{
Expand Down
3 changes: 3 additions & 0 deletions glm/detail/type_vec.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespace glm
typedef tvec1<float, highp> highp_vec1_t;
typedef tvec1<float, mediump> mediump_vec1_t;
typedef tvec1<float, lowp> lowp_vec1_t;
typedef tvec1<double, highp> highp_dvec1_t;
typedef tvec1<double, mediump> mediump_dvec1_t;
typedef tvec1<double, lowp> lowp_dvec1_t;
typedef tvec1<int, highp> highp_ivec1_t;
typedef tvec1<int, mediump> mediump_ivec1_t;
typedef tvec1<int, lowp> lowp_ivec1_t;
Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_vec1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace glm
//////////////////////////////////////
// Helper

# if GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
Expand Down
6 changes: 3 additions & 3 deletions glm/detail/type_vec1.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec1<T, P>::size() const
{
Expand All @@ -48,14 +48,14 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec1<T, P>::operator[](length_t i)
{
assert(i >= 0 && i < this->length());
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}

template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec1<T, P>::operator[](length_t i) const
{
assert(i >= 0 && i < this->length());
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}

Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_vec2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace glm
//////////////////////////////////////
// Helper

# if GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
Expand Down
6 changes: 3 additions & 3 deletions glm/detail/type_vec2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

namespace glm
{
#if GLM_FORCE_SIZE_FUNC
#ifdef GLM_FORCE_SIZE_FUNC
template <typename T, precision P>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR size_t tvec2<T, P>::size() const
{
Expand All @@ -48,14 +48,14 @@ namespace glm
template <typename T, precision P>
GLM_FUNC_QUALIFIER T & tvec2<T, P>::operator[](length_t i)
{
assert(i >= 0 && i < this->length());
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}

template <typename T, precision P>
GLM_FUNC_QUALIFIER T const & tvec2<T, P>::operator[](length_t i) const
{
assert(i >= 0 && i < this->length());
assert(i >= 0 && static_cast<detail::component_count_t>(i) < detail::component_count(*this));
return (&x)[i];
}

Expand Down
2 changes: 1 addition & 1 deletion glm/detail/type_vec3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace glm
//////////////////////////////////////
// Helper

# if GLM_FORCE_SIZE_FUNC
# ifdef GLM_FORCE_SIZE_FUNC
/// Return the count of components of the vector
GLM_FUNC_DECL GLM_CONSTEXPR size_t size() const;
# else
Expand Down
Loading

0 comments on commit 85037a1

Please sign in to comment.