Changeset 2081


Ignore:
Timestamp:
Nov 17, 2012, 2:24:44 PM (8 years ago)
Author:
sam
Message:

math: prefix all convenience macros with "LOL_", make sure we #undef
them after use, and refactor them so that free functions such as
fmod() or clamp() are directly accessible in the lol namespace.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lol/math/vector.h

    r2057 r2081  
    3535#endif
    3636
    37 #define DECLARE_VECTOR_TYPEDEFS(tname, suffix) \
     37#define LOL_VECTOR_TYPEDEFS(tname, suffix) \
    3838    template <typename T> struct tname; \
    3939    typedef tname<half> f16##suffix; \
     
    5151    typedef tname<real> r##suffix; \
    5252
    53 DECLARE_VECTOR_TYPEDEFS(Vec2, vec2)
    54 DECLARE_VECTOR_TYPEDEFS(Cmplx, cmplx)
    55 DECLARE_VECTOR_TYPEDEFS(Vec3, vec3)
    56 DECLARE_VECTOR_TYPEDEFS(Vec4, vec4)
    57 DECLARE_VECTOR_TYPEDEFS(Quat, quat)
    58 DECLARE_VECTOR_TYPEDEFS(Mat2, mat2)
    59 DECLARE_VECTOR_TYPEDEFS(Mat3, mat3)
    60 DECLARE_VECTOR_TYPEDEFS(Mat4, mat4)
     53LOL_VECTOR_TYPEDEFS(Vec2, vec2)
     54LOL_VECTOR_TYPEDEFS(Cmplx, cmplx)
     55LOL_VECTOR_TYPEDEFS(Vec3, vec3)
     56LOL_VECTOR_TYPEDEFS(Vec4, vec4)
     57LOL_VECTOR_TYPEDEFS(Quat, quat)
     58LOL_VECTOR_TYPEDEFS(Mat2, mat2)
     59LOL_VECTOR_TYPEDEFS(Mat3, mat3)
     60LOL_VECTOR_TYPEDEFS(Mat4, mat4)
     61
     62#undef LOL_VECTOR_TYPEDEFS
    6163
    6264/*
     
    139141 */
    140142
    141 #define DECLARE_MEMBER_OPS(tname, first) \
     143#define LOL_MEMBER_OPS(tname, first) \
    142144    inline T& operator[](size_t n) { return *(&this->first + n); } \
    143145    inline T const& operator[](size_t n) const { return *(&this->first + n); } \
     
    247249      : BVec2<T>(v[0], v[1]) {}
    248250
    249     DECLARE_MEMBER_OPS(Vec2, x)
     251    LOL_MEMBER_OPS(Vec2, x)
    250252
    251253    template<typename U>
     
    263265    inline Cmplx(T X, T Y) : x(X), y(Y) {}
    264266
    265     DECLARE_MEMBER_OPS(Cmplx, x)
     267    LOL_MEMBER_OPS(Cmplx, x)
    266268
    267269    inline Cmplx<T> operator *(Cmplx<T> const &val) const
     
    501503    static Vec3<T> toeuler(Quat<T> const &q);
    502504
    503     DECLARE_MEMBER_OPS(Vec3, x)
     505    LOL_MEMBER_OPS(Vec3, x)
    504506
    505507    template<typename U>
     
    908910      : BVec4<T>(v[0], v[1], v[2], v[3]) {}
    909911
    910     DECLARE_MEMBER_OPS(Vec4, x)
     912    LOL_MEMBER_OPS(Vec4, x)
    911913
    912914    template<typename U>
     
    927929    Quat(Mat4<T> const &m);
    928930
    929     DECLARE_MEMBER_OPS(Quat, w)
     931    LOL_MEMBER_OPS(Quat, w)
    930932
    931933    static Quat<T> rotate(T angle, T x, T y, T z);
     
    10331035 * vec /(vec, vec)
    10341036 */
    1035 #define DECLARE_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
     1037#define LOL_VECTOR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    10361038    tprefix \
    10371039    inline tname<tf> operator op(tname<t1> const &a, tname<t2> const &b) \
     
    10491051 * vec /=(vec, vec)
    10501052 */
    1051 #define DECLARE_VECTOR_VECTOR_OP(tname, op, tprefix, type) \
     1053#define LOL_VECTOR_VECTOR_OP(tname, op, tprefix, type) \
    10521054    tprefix \
    10531055    inline tname<type> operator op##=(tname<type> &a, tname<type> const &b) \
     
    10611063 * vec min(scalar, vec)  (also max, fmod)
    10621064 */
    1063 #define DECLARE_VECTOR_MINMAX_OP(tname, op, tprefix, type) \
     1065#define LOL_VECTOR_MINMAX_FUN(tname, op, tprefix, type) \
    10641066    tprefix \
    10651067    inline tname<type> op(tname<type> const &a, tname<type> const &b) \
     
    10981100 * vec clamp(vec, scalar, scalar)
    10991101 */
    1100 #define DECLARE_VECTOR_CLAMP_OP(tname, tprefix, type) \
     1102#define LOL_VECTOR_CLAMP_FUN(tname, tprefix, type) \
    11011103    tprefix \
    11021104    inline tname<type> clamp(tname<type> const &x, \
     
    11351137 * bool <(vec, vec)
    11361138 */
    1137 #define DECLARE_VECTOR_VECTOR_BOOLOP(tname, op, op2, ret, tprefix, t1, t2) \
     1139#define LOL_VECTOR_VECTOR_BOOL_OP(tname, op, op2, ret, tprefix, t1, t2) \
    11381140    tprefix \
    11391141    inline bool operator op(tname<t1> const &a, tname<t2> const &b) \
     
    11491151 * vec /(vec, scalar)   (also complex & quaternion)
    11501152 */
    1151 #define DECLARE_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
     1153#define LOL_VECTOR_SCALAR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    11521154    tprefix \
    11531155    inline tname<tf> operator op(tname<t1> const &a, t2 const &val) \
     
    11631165 * vec /(scalar, vec)   (NOT for complex & quaternion!)
    11641166 */
    1165 #define DECLARE_SCALAR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
     1167#define LOL_SCALAR_VECTOR_COERCE_OP(tname, op, tprefix, t1, t2, tf) \
    11661168    tprefix \
    11671169    inline tname<tf> operator op(t1 const &val, tname<t2> const &a) \
     
    11771179 * vec /=(vec, scalar)   (also complex & quaternion)
    11781180 */
    1179 #define DECLARE_VECTOR_SCALAR_OP(tname, op, tprefix, type) \
     1181#define LOL_VECTOR_SCALAR_OP(tname, op, tprefix, type) \
    11801182    tprefix \
    11811183    inline tname<type> operator op##=(tname<type> &a, type const &val) \
     
    11841186    }
    11851187
    1186 #define DECLARE_UNARY_OPS(tname, tprefix, type) \
     1188#define LOL_UNARY_OPS(tname, tprefix, type) \
    11871189    tprefix \
    11881190    inline tname<type> operator -(tname<type> const &a) \
     
    11921194            ret[n] = -a[n]; \
    11931195        return ret; \
    1194     } \
    1195     \
     1196    }
     1197
     1198#define LOL_UNARY_FUNS(tname, tprefix, type) \
    11961199    tprefix \
    11971200    inline type sqlength(tname<type> const &a) \
     
    12251228    }
    12261229
    1227 #define DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
    1228     DECLARE_VECTOR_VECTOR_COERCE_OP(tname, -, tprefix, t1, t2, tf) \
    1229     DECLARE_VECTOR_VECTOR_COERCE_OP(tname, +, tprefix, t1, t2, tf) \
     1230#define LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
     1231    LOL_VECTOR_VECTOR_COERCE_OP(tname, -, tprefix, t1, t2, tf) \
     1232    LOL_VECTOR_VECTOR_COERCE_OP(tname, +, tprefix, t1, t2, tf) \
    12301233    \
    1231     DECLARE_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \
    1232     DECLARE_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \
    1233     DECLARE_SCALAR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \
     1234    LOL_VECTOR_SCALAR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \
     1235    LOL_VECTOR_SCALAR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \
     1236    LOL_SCALAR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \
    12341237    \
    1235     DECLARE_VECTOR_VECTOR_BOOLOP(tname, ==, ==, true, tprefix, t1, t2) \
    1236     DECLARE_VECTOR_VECTOR_BOOLOP(tname, !=, ==, false, tprefix, t1, t2) \
    1237     \
     1238    LOL_VECTOR_VECTOR_BOOL_OP(tname, ==, ==, true, tprefix, t1, t2) \
     1239    LOL_VECTOR_VECTOR_BOOL_OP(tname, !=, ==, false, tprefix, t1, t2)
     1240
     1241#define LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, tprefix, t1, t2, tf) \
    12381242    tprefix \
    12391243    inline tf dot(tname<t1> const &a, tname<t2> const &b) \
     
    12531257    }
    12541258
    1255 #define DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
    1256     DECLARE_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf)
    1257 
    1258 #define DECLARE_VEC_3_COERCE_OPS(tname, tprefix, t1, t2, tf) \
     1259#define LOL_BINARY_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
     1260    LOL_SCALAR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf)
     1261
     1262#define LOL_VEC_3_COERCE_FUNS(tname, tprefix, t1, t2, tf) \
    12591263    tprefix \
    12601264    inline tname<tf> cross(tname<t1> const &a, tname<t2> const &b) \
     
    12651269    }
    12661270
    1267 #define DECLARE_BINARY_NONVECTOR_OPS(tname, tprefix, type) \
    1268     DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \
     1271#define LOL_BINARY_NONVECTOR_OPS(tname, tprefix, type) \
     1272    LOL_BINARY_NONVECTOR_COERCE_OPS(tname, tprefix, type, type, type) \
    12691273    \
    1270     DECLARE_VECTOR_VECTOR_OP(tname, -, tprefix, type) \
    1271     DECLARE_VECTOR_VECTOR_OP(tname, +, tprefix, type) \
     1274    LOL_VECTOR_VECTOR_OP(tname, -, tprefix, type) \
     1275    LOL_VECTOR_VECTOR_OP(tname, +, tprefix, type) \
    12721276    \
    1273     DECLARE_VECTOR_SCALAR_OP(tname, *, tprefix, type) \
    1274     DECLARE_VECTOR_SCALAR_OP(tname, /, tprefix, type)
    1275 
    1276 #define DECLARE_BINARY_VECTOR_OPS(tname, tprefix, type) \
    1277     DECLARE_BINARY_VECTOR_COERCE_OPS(tname, tprefix, type, type, type) \
     1277    LOL_VECTOR_SCALAR_OP(tname, *, tprefix, type) \
     1278    LOL_VECTOR_SCALAR_OP(tname, /, tprefix, type)
     1279
     1280#define LOL_BINARY_NONVECTOR_FUNS(tname, tprefix, type) \
     1281    LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, tprefix, type, type, type) \
     1282
     1283#define LOL_BINARY_VECTOR_OPS(tname, tprefix, type) \
     1284    LOL_BINARY_VECTOR_COERCE_OPS(tname, tprefix, type, type, type)
     1285
     1286#define LOL_BINARY_VECTOR_FUNS(tname, tprefix, type) \
     1287    LOL_VECTOR_MINMAX_FUN(tname, min, tprefix, type) \
     1288    LOL_VECTOR_MINMAX_FUN(tname, max, tprefix, type) \
     1289    LOL_VECTOR_MINMAX_FUN(tname, fmod, tprefix, type) \
     1290    LOL_VECTOR_CLAMP_FUN(tname, tprefix, type)
     1291
     1292#define LOL_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
     1293    LOL_VECTOR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \
     1294    LOL_VECTOR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \
    12781295    \
    1279     DECLARE_VECTOR_MINMAX_OP(tname, min, tprefix, type) \
    1280     DECLARE_VECTOR_MINMAX_OP(tname, max, tprefix, type) \
    1281     DECLARE_VECTOR_MINMAX_OP(tname, fmod, tprefix, type) \
    1282     DECLARE_VECTOR_CLAMP_OP(tname, tprefix, type)
    1283 
    1284 #define DECLARE_VECTOR_COERCE_OPS(tname, tprefix, t1, t2, tf) \
    1285     DECLARE_VECTOR_VECTOR_COERCE_OP(tname, *, tprefix, t1, t2, tf) \
    1286     DECLARE_VECTOR_VECTOR_COERCE_OP(tname, /, tprefix, t1, t2, tf) \
     1296    LOL_VECTOR_VECTOR_BOOL_OP(tname, <=, <=, true, tprefix, t1, t2) \
     1297    LOL_VECTOR_VECTOR_BOOL_OP(tname, >=, >=, true, tprefix, t1, t2) \
     1298    LOL_VECTOR_VECTOR_BOOL_OP(tname, <, <, true, tprefix, t1, t2) \
     1299    LOL_VECTOR_VECTOR_BOOL_OP(tname, >, >, true, tprefix, t1, t2)
     1300
     1301#define LOL_VECTOR_OPS(tname, tprefix, type) \
     1302    LOL_VECTOR_COERCE_OPS(tname, static, type, type, type) \
    12871303    \
    1288     DECLARE_VECTOR_VECTOR_BOOLOP(tname, <=, <=, true, tprefix, t1, t2) \
    1289     DECLARE_VECTOR_VECTOR_BOOLOP(tname, >=, >=, true, tprefix, t1, t2) \
    1290     DECLARE_VECTOR_VECTOR_BOOLOP(tname, <, <, true, tprefix, t1, t2) \
    1291     DECLARE_VECTOR_VECTOR_BOOLOP(tname, >, >, true, tprefix, t1, t2)
    1292 
    1293 #define DECLARE_VECTOR_OPS(tname, tprefix, type) \
    1294     DECLARE_VECTOR_COERCE_OPS(tname, static, type, type, type) \
     1304    LOL_VECTOR_VECTOR_OP(tname, *, tprefix, type) \
     1305    LOL_VECTOR_VECTOR_OP(tname, /, tprefix, type)
     1306
     1307#define LOL_ALL_NONVECTOR_OPS_AND_FUNS(tname) \
     1308    LOL_BINARY_NONVECTOR_OPS(tname, template<typename T> static, T) \
     1309    LOL_BINARY_NONVECTOR_FUNS(tname, template<typename T> static, T) \
     1310    LOL_UNARY_OPS(tname, template<typename T> static, T) \
     1311    LOL_UNARY_FUNS(tname, template<typename T> static, T)
     1312
     1313#define LOL_ALL_VECTOR_OPS_INNER(tname, type) \
     1314    LOL_BINARY_VECTOR_OPS(tname, static, type) \
     1315    LOL_BINARY_NONVECTOR_OPS(tname, static, type) \
     1316    LOL_UNARY_OPS(tname, static, type) \
     1317    LOL_VECTOR_OPS(tname, static, type)
     1318
     1319#define LOL_ALL_VECTOR_FUNS_INNER(tname, type) \
     1320    LOL_BINARY_VECTOR_FUNS(tname, static, type) \
     1321    LOL_BINARY_NONVECTOR_FUNS(tname, static, type) \
     1322    LOL_UNARY_FUNS(tname, static, type)
     1323
     1324#define LOL_ALL_VECTOR_OPS_AND_FUNS(type) \
     1325    namespace x##type \
     1326    { \
     1327        LOL_ALL_VECTOR_OPS_INNER(Vec2, type) \
     1328        LOL_ALL_VECTOR_OPS_INNER(Vec3, type) \
     1329        LOL_ALL_VECTOR_OPS_INNER(Vec4, type) \
     1330    } \
     1331    using namespace x##type; \
     1332    LOL_ALL_VECTOR_FUNS_INNER(Vec2, type) \
     1333    LOL_ALL_VECTOR_FUNS_INNER(Vec3, type) \
     1334    LOL_ALL_VECTOR_FUNS_INNER(Vec4, type) \
     1335    LOL_VEC_3_COERCE_FUNS(Vec3, static, type, type, type)
     1336
     1337#define LOL_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \
     1338    LOL_BINARY_NONVECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
     1339    LOL_BINARY_NONVECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \
     1340    LOL_BINARY_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
     1341    LOL_BINARY_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \
    12951342    \
    1296     DECLARE_VECTOR_VECTOR_OP(tname, *, tprefix, type) \
    1297     DECLARE_VECTOR_VECTOR_OP(tname, /, tprefix, type)
    1298 
    1299 #define DECLARE_ALL_NONVECTOR_OPS(tname) \
    1300     DECLARE_BINARY_NONVECTOR_OPS(tname, template<typename T> static, T) \
    1301     DECLARE_UNARY_OPS(tname, template<typename T> static, T)
    1302 
    1303 #define DECLARE_ALL_VECTOR_OPS_INNER(tname, type) \
    1304     DECLARE_BINARY_VECTOR_OPS(tname, static, type) \
    1305     DECLARE_BINARY_NONVECTOR_OPS(tname, static, type) \
    1306     DECLARE_UNARY_OPS(tname, static, type) \
    1307     DECLARE_VECTOR_OPS(tname, static, type) \
    1308 
    1309 #define DECLARE_ALL_VECTOR_OPS(type) \
    1310     namespace x##type \
    1311     { \
    1312         DECLARE_ALL_VECTOR_OPS_INNER(Vec2, type) \
    1313         DECLARE_ALL_VECTOR_OPS_INNER(Vec3, type) \
    1314         DECLARE_ALL_VECTOR_OPS_INNER(Vec4, type) \
    1315         \
    1316         DECLARE_VEC_3_COERCE_OPS(Vec3, static, type, type, type) \
    1317     }
    1318 
    1319 #define DECLARE_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \
    1320     DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
    1321     DECLARE_BINARY_NONVECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \
    1322     DECLARE_BINARY_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
    1323     DECLARE_BINARY_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh) \
    1324     \
    1325     DECLARE_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
    1326     DECLARE_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh)
    1327 
    1328 #define DECLARE_ALL_VECTOR_COERCE_OPS(tlow, thigh) \
     1343    LOL_VECTOR_COERCE_OPS(tname, static, tlow, thigh, thigh) \
     1344    LOL_VECTOR_COERCE_OPS(tname, static, thigh, tlow, thigh)
     1345
     1346#define LOL_VEC_ANY_COERCE_FUNS(tname, tlow, thigh) \
     1347    LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, static, tlow, thigh, thigh) \
     1348    LOL_BINARY_NONVECTOR_COERCE_FUNS(tname, static, thigh, tlow, thigh)
     1349
     1350#define LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(tlow, thigh) \
    13291351    namespace x##tlow##thigh \
    13301352    { \
    1331         DECLARE_VEC_ANY_COERCE_OPS(Vec2, tlow, thigh) \
    1332         DECLARE_VEC_ANY_COERCE_OPS(Vec3, tlow, thigh) \
    1333         DECLARE_VEC_ANY_COERCE_OPS(Vec4, tlow, thigh) \
     1353        LOL_VEC_ANY_COERCE_OPS(Vec2, tlow, thigh) \
     1354        LOL_VEC_ANY_COERCE_OPS(Vec3, tlow, thigh) \
     1355        LOL_VEC_ANY_COERCE_OPS(Vec4, tlow, thigh) \
    13341356    } \
    1335     namespace y##tlow##thigh \
    1336     { \
    1337         DECLARE_VEC_3_COERCE_OPS(Vec3, static, tlow, thigh, thigh) \
    1338         DECLARE_VEC_3_COERCE_OPS(Vec3, static, thigh, tlow, thigh) \
    1339     } \
    1340 
    1341 DECLARE_ALL_NONVECTOR_OPS(Cmplx)
    1342 DECLARE_ALL_NONVECTOR_OPS(Quat)
     1357    LOL_VEC_ANY_COERCE_FUNS(Vec2, tlow, thigh) \
     1358    LOL_VEC_ANY_COERCE_FUNS(Vec3, tlow, thigh) \
     1359    LOL_VEC_ANY_COERCE_FUNS(Vec4, tlow, thigh) \
     1360    LOL_VEC_3_COERCE_FUNS(Vec3, static, tlow, thigh, thigh) \
     1361    LOL_VEC_3_COERCE_FUNS(Vec3, static, thigh, tlow, thigh)
     1362
     1363LOL_ALL_NONVECTOR_OPS_AND_FUNS(Cmplx)
     1364LOL_ALL_NONVECTOR_OPS_AND_FUNS(Quat)
    13431365
    13441366/* Disable warning about unary operator applied to unsigned type */
     
    13481370#endif
    13491371
    1350 DECLARE_ALL_VECTOR_OPS(half)
    1351 DECLARE_ALL_VECTOR_OPS(float)
    1352 DECLARE_ALL_VECTOR_OPS(double)
    1353 DECLARE_ALL_VECTOR_OPS(ldouble)
    1354 DECLARE_ALL_VECTOR_OPS(int8_t)
    1355 DECLARE_ALL_VECTOR_OPS(uint8_t)
    1356 DECLARE_ALL_VECTOR_OPS(int16_t)
    1357 DECLARE_ALL_VECTOR_OPS(uint16_t)
    1358 DECLARE_ALL_VECTOR_OPS(int32_t)
    1359 DECLARE_ALL_VECTOR_OPS(uint32_t)
    1360 DECLARE_ALL_VECTOR_OPS(int64_t)
    1361 DECLARE_ALL_VECTOR_OPS(uint64_t)
     1372LOL_ALL_VECTOR_OPS_AND_FUNS(half)
     1373LOL_ALL_VECTOR_OPS_AND_FUNS(float)
     1374LOL_ALL_VECTOR_OPS_AND_FUNS(double)
     1375LOL_ALL_VECTOR_OPS_AND_FUNS(ldouble)
     1376LOL_ALL_VECTOR_OPS_AND_FUNS(int8_t)
     1377LOL_ALL_VECTOR_OPS_AND_FUNS(uint8_t)
     1378LOL_ALL_VECTOR_OPS_AND_FUNS(int16_t)
     1379LOL_ALL_VECTOR_OPS_AND_FUNS(uint16_t)
     1380LOL_ALL_VECTOR_OPS_AND_FUNS(int32_t)
     1381LOL_ALL_VECTOR_OPS_AND_FUNS(uint32_t)
     1382LOL_ALL_VECTOR_OPS_AND_FUNS(int64_t)
     1383LOL_ALL_VECTOR_OPS_AND_FUNS(uint64_t)
    13621384
    13631385#if defined _MSC_VER
     
    13831405 * of always promoting smaller types to int, we allow int8_t op int16_t to
    13841406 * return an int16_t. */
    1385 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint8_t)
    1386 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int16_t)
    1387 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint16_t)
    1388 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int32_t)
    1389 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint32_t)
    1390 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int64_t)
    1391 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint64_t)
    1392 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, float)
    1393 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, double)
    1394 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, ldouble)
    1395 
    1396 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int16_t)
    1397 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint16_t)
    1398 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int32_t)
    1399 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint32_t)
    1400 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int64_t)
    1401 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint64_t)
    1402 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, float)
    1403 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, double)
    1404 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, ldouble)
    1405 
    1406 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint16_t)
    1407 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, int32_t)
    1408 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint32_t)
    1409 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, int64_t)
    1410 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint64_t)
    1411 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, float)
    1412 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, double)
    1413 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, ldouble)
    1414 
    1415 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, int32_t)
    1416 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, uint32_t)
    1417 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, int64_t)
    1418 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, uint64_t)
    1419 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, float)
    1420 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, double)
    1421 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, ldouble)
    1422 
    1423 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, uint32_t)
    1424 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, int64_t)
    1425 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, uint64_t)
    1426 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, float)
    1427 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, double)
    1428 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, ldouble)
    1429 
    1430 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, int64_t)
    1431 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, uint64_t)
    1432 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, float)
    1433 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, double)
    1434 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, ldouble)
    1435 
    1436 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, uint64_t)
    1437 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, float)
    1438 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, double)
    1439 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, ldouble)
    1440 
    1441 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, float)
    1442 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, double)
    1443 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, ldouble)
    1444 
    1445 DECLARE_ALL_VECTOR_COERCE_OPS(float, double)
    1446 DECLARE_ALL_VECTOR_COERCE_OPS(float, ldouble)
    1447 
    1448 DECLARE_ALL_VECTOR_COERCE_OPS(double, ldouble)
     1407LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint8_t)
     1408LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int16_t)
     1409LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint16_t)
     1410LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int32_t)
     1411LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint32_t)
     1412LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, int64_t)
     1413LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, uint64_t)
     1414LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, float)
     1415LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, double)
     1416LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, ldouble)
     1417
     1418LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int16_t)
     1419LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint16_t)
     1420LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int32_t)
     1421LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint32_t)
     1422LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, int64_t)
     1423LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, uint64_t)
     1424LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, float)
     1425LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, double)
     1426LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, ldouble)
     1427
     1428LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint16_t)
     1429LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, int32_t)
     1430LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint32_t)
     1431LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, int64_t)
     1432LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, uint64_t)
     1433LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, float)
     1434LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, double)
     1435LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, ldouble)
     1436
     1437LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, int32_t)
     1438LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, uint32_t)
     1439LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, int64_t)
     1440LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, uint64_t)
     1441LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, float)
     1442LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, double)
     1443LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, ldouble)
     1444
     1445LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, uint32_t)
     1446LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, int64_t)
     1447LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, uint64_t)
     1448LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, float)
     1449LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, double)
     1450LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, ldouble)
     1451
     1452LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, int64_t)
     1453LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, uint64_t)
     1454LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, float)
     1455LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, double)
     1456LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, ldouble)
     1457
     1458LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, uint64_t)
     1459LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, float)
     1460LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, double)
     1461LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, ldouble)
     1462
     1463LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, float)
     1464LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, double)
     1465LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, ldouble)
     1466
     1467LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, double)
     1468LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, ldouble)
     1469
     1470LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(double, ldouble)
    14491471
    14501472/* FIXME: vectors of "half" are deactivated for now, because they
     
    14541476/* All integer types are promoted to half; all floating point types
    14551477 * cause half to be promoted. */
    1456 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, half)
    1457 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, half)
    1458 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, half)
    1459 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, half)
    1460 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, half)
    1461 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, half)
    1462 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, half)
    1463 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, half)
    1464 
    1465 DECLARE_ALL_VECTOR_COERCE_OPS(half, float)
    1466 DECLARE_ALL_VECTOR_COERCE_OPS(half, double)
    1467 DECLARE_ALL_VECTOR_COERCE_OPS(half, ldouble)
     1478LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, half)
     1479LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, half)
     1480LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, half)
     1481LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, half)
     1482LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, half)
     1483LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, half)
     1484LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, half)
     1485LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, half)
     1486
     1487LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, float)
     1488LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, double)
     1489LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, ldouble)
    14681490#endif
    14691491
     
    14731495#if 0
    14741496/* All types are promoted to real */
    1475 DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, real)
    1476 DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, real)
    1477 DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, real)
    1478 DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, real)
    1479 DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, real)
    1480 DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, real)
    1481 DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, real)
    1482 DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, real)
    1483 DECLARE_ALL_VECTOR_COERCE_OPS(half, real)
    1484 DECLARE_ALL_VECTOR_COERCE_OPS(float, real)
    1485 DECLARE_ALL_VECTOR_COERCE_OPS(double, real)
    1486 DECLARE_ALL_VECTOR_COERCE_OPS(ldouble, real)
     1497LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int8_t, real)
     1498LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint8_t, real)
     1499LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int16_t, real)
     1500LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint16_t, real)
     1501LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int32_t, real)
     1502LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint32_t, real)
     1503LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(int64_t, real)
     1504LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(uint64_t, real)
     1505LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(half, real)
     1506LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(float, real)
     1507LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(double, real)
     1508LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS(ldouble, real)
    14871509#endif
    14881510
     
    14911513#define ACTIVATE_COERCE_NAMESPACES_INNER(tlow, thigh) \
    14921514    namespace x##tlow##thigh {} \
    1493     namespace y##tlow##thigh {} \
    1494     using namespace x##tlow##thigh; \
    1495     using namespace y##tlow##thigh;
     1515    using namespace x##tlow##thigh;
    14961516
    14971517#define ACTIVATE_COERCE_NAMESPACES(tlow) \
     
    15321552#endif
    15331553
    1534 #undef DECLARE_VECTOR_TYPEDEFS
    1535 #undef DECLARE_MEMBER_OPS
    1536 #undef DECLARE_VECTOR_VECTOR_OP
    1537 #undef DECLARE_VECTOR_VECTOR_BOOLOP
    1538 #undef DECLARE_VECTOR_SCALAR_OP
    1539 #undef DECLARE_BINARY_VECTOR_OPS
    1540 #undef DECLARE_BINARY_NONVECTOR_OPS
    1541 #undef DECLARE_UNARY_OPS
    1542 #undef DECLARE_ALL_NONVECTOR_OPS
    1543 #undef DECLARE_ALL_VECTOR_OPS_INNER
    1544 #undef DECLARE_ALL_VECTOR_OPS
     1554#undef LOL_MEMBER_OPS
     1555
     1556#undef LOL_VECTOR_VECTOR_COERCE_OP
     1557#undef LOL_VECTOR_VECTOR_OP
     1558#undef LOL_VECTOR_MINMAX_FUN
     1559#undef LOL_VECTOR_CLAMP_FUN
     1560#undef LOL_VECTOR_VECTOR_BOOL_OP
     1561#undef LOL_VECTOR_SCALAR_COERCE_OP
     1562#undef LOL_SCALAR_VECTOR_COERCE_OP
     1563#undef LOL_VECTOR_SCALAR_OP
     1564
     1565#undef LOL_BINARY_VECTOR_OPS
     1566#undef LOL_BINARY_VECTOR_FUNS
     1567#undef LOL_BINARY_NONVECTOR_OPS
     1568#undef LOL_BINARY_NONVECTOR_FUNS
     1569#undef LOL_UNARY_OPS
     1570#undef LOL_UNARY_FUNS
     1571#undef LOL_BINARY_NONVECTOR_COERCE_OPS
     1572#undef LOL_BINARY_NONVECTOR_COERCE_FUNS
     1573#undef LOL_BINARY_VECTOR_COERCE_OPS
     1574#undef LOL_VECTOR_COERCE_OPS
     1575#undef LOL_VEC_3_COERCE_FUNS
     1576#undef LOL_VEC_ANY_COERCE_OPS
     1577#undef LOL_VEC_ANY_COERCE_FUNS
     1578#undef LOL_VECTOR_OPS
     1579
     1580#undef LOL_ALL_NONVECTOR_OPS_AND_FUNS
     1581#undef LOL_ALL_VECTOR_OPS_INNER
     1582#undef LOL_ALL_VECTOR_FUNS_INNER
     1583#undef LOL_ALL_VECTOR_OPS_AND_FUNS
     1584#undef LOL_ALL_VECTOR_COERCE_OPS_AND_FUNS
    15451585
    15461586/*
Note: See TracChangeset for help on using the changeset viewer.