The static_assert() methods are now not bound in SWIG

The ReducedStorageType here is to work around a bug in SWIG.
This commit is contained in:
Matt Williams 2012-12-24 15:51:40 +00:00
parent f22410ed9a
commit fc74ec5f0f
2 changed files with 23 additions and 28 deletions

View File

@ -53,9 +53,7 @@ namespace PolyVox
template <uint32_t Size,typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
{
#ifndef SWIGPYTHON // SWIG instantiates all constructors, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size == 2, "This constructor should only be used for vectors with two elements.");
#endif
m_tElements[0] = x;
m_tElements[1] = y;
@ -70,9 +68,7 @@ namespace PolyVox
template <uint32_t Size,typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
{
#ifndef SWIGPYTHON // SWIG instantiates all constructors, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size == 3, "This constructor should only be used for vectors with three elements.");
#endif
m_tElements[0] = x;
m_tElements[1] = y;
@ -90,9 +86,7 @@ namespace PolyVox
template <uint32_t Size,typename StorageType, typename OperationType>
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
{
#ifndef SWIGPYTHON // SWIG instantiates all constructors, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size == 4, "This constructor should only be used for vectors with four elements.");
#endif
m_tElements[0] = x;
m_tElements[1] = y;
@ -448,9 +442,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType>
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
{
#ifndef SWIGPYTHON // SWIG instantiates all getters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size >= 3, "You can only get the 'z' component from a vector with at least three elements.");
#endif
return m_tElements[2];
}
@ -461,9 +453,7 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType>
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
{
#ifndef SWIGPYTHON // SWIG instantiates all getters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size >= 4, "You can only get the 'w' component from a vector with at least four elements.");
#endif
return m_tElements[3];
}
@ -501,9 +491,8 @@ namespace PolyVox
template <uint32_t Size,typename StorageType, typename OperationType>
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
{
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size >= 3, "You can only use this version of setElements() on a vector with at least three elements.");
#endif
m_tElements[0] = x;
m_tElements[1] = y;
m_tElements[2] = z;
@ -519,9 +508,8 @@ namespace PolyVox
template <uint32_t Size,typename StorageType, typename OperationType>
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
{
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size >= 4, "You can only use this version of setElements() on a vector with at least four elements.");
#endif
m_tElements[0] = x;
m_tElements[1] = y;
m_tElements[2] = z;
@ -552,9 +540,8 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType>
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
{
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size >= 3, "You can only set the 'w' component from a vector with at least three elements.");
#endif
m_tElements[2] = tZ;
}
@ -564,9 +551,8 @@ namespace PolyVox
template <uint32_t Size, typename StorageType, typename OperationType>
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
{
#ifndef SWIGPYTHON // SWIG instantiates all setters, unless we can find a way around that. Should we use SWIGIMPORT here, and then %import this file rather then %include it?
static_assert(Size >= 4, "You can only set the 'w' component from a vector with at least four elements.");
#endif
m_tElements[3] = tW;
}

View File

@ -34,13 +34,22 @@ PROPERTY(PolyVox::Vector, z, getZ, setZ)
STR()
};
%template(Vector3DFloat) PolyVox::Vector<3,float,float>;
%template(Vector3DDouble) PolyVox::Vector<3,double,double>;
%template(Vector3DInt8) PolyVox::Vector<3,int8_t,int32_t>;
%template(Vector3DUint8) PolyVox::Vector<3,uint8_t,int32_t>;
%template(Vector3DInt16) PolyVox::Vector<3,int16_t,int32_t>;
%template(Vector3DUint16) PolyVox::Vector<3,uint16_t,int32_t>;
%template(Vector3DInt32) PolyVox::Vector<3,int32_t,int32_t>;
%template(Vector3DUint32) PolyVox::Vector<3,uint32_t,int32_t>;
%define VECTOR3(StorageType,OperationType,ReducedStorageType)
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
%ignore PolyVox::Vector<3,StorageType,OperationType>::Vector(ReducedStorageType,ReducedStorageType);
%ignore PolyVox::Vector<3,StorageType,OperationType>::getW() const;
%ignore PolyVox::Vector<3,StorageType,OperationType>::setW(ReducedStorageType);
%ignore PolyVox::Vector<3,StorageType,OperationType>::setElements(ReducedStorageType,ReducedStorageType,ReducedStorageType,ReducedStorageType);
%template(Vector3D ## StorageType) PolyVox::Vector<3,StorageType,OperationType>;
%enddef
VECTOR3(float,float,float)
VECTOR3(double,double,double)
VECTOR3(int8_t,int32_t,signed char)
VECTOR3(uint8_t,int32_t,unsigned char)
VECTOR3(int16_t,int32_t,signed short)
VECTOR3(uint16_t,int32_t,unsigned short)
VECTOR3(int32_t,int32_t,signed int)
VECTOR3(uint32_t,int32_t,unsigned int)
//%rename(assign) Vector3DFloat::operator=;