12 #include "ParaEngine.h" 34 static inline void Swap2(
void* _szOut)
39 uint16_t*
const szOut =
reinterpret_cast<uint16_t*
>(_szOut);
40 *szOut = _byteswap_ushort(*szOut);
42 uint8_t*
const szOut =
reinterpret_cast<uint8_t*
>(_szOut);
43 std::swap(szOut[0],szOut[1]);
50 static inline void Swap4(
void* _szOut)
55 uint32_t*
const szOut =
reinterpret_cast<uint32_t*
>(_szOut);
56 *szOut = _byteswap_ulong(*szOut);
58 uint8_t*
const szOut =
reinterpret_cast<uint8_t*
>(_szOut);
59 std::swap(szOut[0],szOut[3]);
60 std::swap(szOut[1],szOut[2]);
67 static inline void Swap8(
void* _szOut)
72 uint64_t*
const szOut =
reinterpret_cast<uint64_t*
>(_szOut);
73 *szOut = _byteswap_uint64(*szOut);
75 uint8_t*
const szOut =
reinterpret_cast<uint8_t*
>(_szOut);
76 std::swap(szOut[0],szOut[7]);
77 std::swap(szOut[1],szOut[6]);
78 std::swap(szOut[2],szOut[5]);
79 std::swap(szOut[3],szOut[4]);
86 static inline void Swap(
float* fOut) {
93 static inline void Swap(
double* fOut) {
101 static inline void Swap(int16_t* fOut) {
105 static inline void Swap(uint16_t* fOut) {
112 static inline void Swap(int32_t* fOut){
116 static inline void Swap(uint32_t* fOut){
123 static inline void Swap(int64_t* fOut) {
127 static inline void Swap(uint64_t* fOut) {
134 template<
typename Type>
137 return _swapper<Type,sizeof(Type)>()(tOut);
142 template <
typename T,
size_t size>
struct _swapper;
145 template <
typename T>
struct ByteSwap::_swapper<T,2> {
146 T operator() (T tOut) {
152 template <
typename T>
struct ByteSwap::_swapper<T,4> {
153 T operator() (T tOut) {
159 template <
typename T>
struct ByteSwap::_swapper<T,8> {
160 T operator() (T tOut) {
170 #if ! PLATFORM_LITTLE_ENDIAN 171 # define PE_LE(t) (t) 172 # define PE_BE(t) ByteSwap::Swapped(t) 173 # define PE_LSWAP2(p) 174 # define PE_LSWAP4(p) 175 # define PE_LSWAP8(p) 176 # define PE_LSWAP2P(p) 177 # define PE_LSWAP4P(p) 178 # define PE_LSWAP8P(p) 179 # define LE_NCONST const 180 # define PE_SWAP2(p) ByteSwap::Swap2(&(p)) 181 # define PE_SWAP4(p) ByteSwap::Swap4(&(p)) 182 # define PE_SWAP8(p) ByteSwap::Swap8(&(p)) 183 # define PE_SWAP2P(p) ByteSwap::Swap2((p)) 184 # define PE_SWAP4P(p) ByteSwap::Swap4((p)) 185 # define PE_SWAP8P(p) ByteSwap::Swap8((p)) 188 # define PE_BE(t) (t) 189 # define PE_LE(t) ByteSwap::Swapped(t) 193 # define PE_SWAP2P(p) 194 # define PE_SWAP4P(p) 195 # define PE_SWAP8P(p) 196 # define BE_NCONST const 197 # define PE_LSWAP2(p) ByteSwap::Swap2(&(p)) 198 # define PE_LSWAP4(p) ByteSwap::Swap4(&(p)) 199 # define PE_LSWAP8(p) ByteSwap::Swap8(&(p)) 200 # define PE_LSWAP2P(p) ByteSwap::Swap2((p)) 201 # define PE_LSWAP4P(p) ByteSwap::Swap4((p)) 202 # define PE_LSWAP8P(p) ByteSwap::Swap8((p)) 210 template <
typename T,
bool doit>
212 void operator() (T* inout) {
217 template <
typename T>
219 void operator() (T*) {
224 template <
bool SwapEndianess,
typename T,
bool RuntimeSwitch>
226 void operator() (T* inout,
bool le) {
227 #ifdef AI_BUILD_BIG_ENDIAN 239 template <
bool SwapEndianess,
typename T>
242 void operator() (T* inout,
bool ) {
static void Swap4(void *_szOut)
Swap four bytes of data.
Definition: ByteSwap.h:50
static void Swap8(void *_szOut)
Swap eight bytes of data.
Definition: ByteSwap.h:67
different physics engine has different winding order.
Definition: EventBinding.h:32
static Type Swapped(Type tOut)
Templatized ByteSwap.
Definition: ByteSwap.h:135
static void Swap(int16_t *fOut)
ByteSwap an int16t.
Definition: ByteSwap.h:101
static void Swap(int64_t *fOut)
ByteSwap an int64t.
Definition: ByteSwap.h:123
Definition: ByteSwap.h:211
Defines some useful byte order swap routines.
Definition: ByteSwap.h:25
static void Swap(int32_t *fOut)
ByteSwap an int32t.
Definition: ByteSwap.h:112
static void Swap(double *fOut)
ByteSwap a double.
Definition: ByteSwap.h:93
static void Swap(float *fOut)
ByteSwap a float.
Definition: ByteSwap.h:86
Definition: ByteSwap.h:218
static void Swap2(void *_szOut)
Swap two bytes of data.
Definition: ByteSwap.h:34
Definition: ByteSwap.h:225