From fc74ec5f0f6dd5b7b9d9dd537099c36b7f70adbc Mon Sep 17 00:00:00 2001 From: Matt Williams Date: Mon, 24 Dec 2012 15:51:40 +0000 Subject: [PATCH] The static_assert() methods are now not bound in SWIG The ReducedStorageType here is to work around a bug in SWIG. --- .../include/PolyVoxCore/Vector.inl | 26 +++++-------------- library/bindings/Vector.i | 25 ++++++++++++------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl index 09501f18..22d3009e 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/Vector.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/Vector.inl @@ -53,9 +53,7 @@ namespace PolyVox template Vector::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 Vector::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 Vector::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 inline StorageType Vector::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 inline StorageType Vector::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 inline void Vector::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 inline void Vector::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,10 +540,9 @@ namespace PolyVox template inline void Vector::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; + + m_tElements[2] = tZ; } /** @@ -564,10 +551,9 @@ namespace PolyVox template inline void Vector::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; + + m_tElements[3] = tW; } /** diff --git a/library/bindings/Vector.i b/library/bindings/Vector.i index 15830de6..555b7d15 100644 --- a/library/bindings/Vector.i +++ b/library/bindings/Vector.i @@ -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=;