Ignore:
Timestamp:
Mar 27, 2012, 9:53:54 PM (9 years ago)
Author:
sam
Message:

math: add vectors of "half" to vector.h.

File:
1 edited

Legend:

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

    r1175 r1176  
    11241124    DECLARE_VEC_3_COERCE_OPS(Vec3, static, type, type, type)
    11251125
    1126 #define DECLARE_ALL_VECTOR_COERCE_OPS_INNER(tname, tlow, thigh) \
     1126#define DECLARE_VEC_ANY_COERCE_OPS(tname, tlow, thigh) \
    11271127    DECLARE_BINARY_COERCE_OPS(tname, static, tlow, thigh, thigh) \
    11281128    DECLARE_BINARY_COERCE_OPS(tname, static, thigh, tlow, thigh) \
     
    11321132
    11331133#define DECLARE_ALL_VECTOR_COERCE_OPS(tlow, thigh) \
    1134     DECLARE_ALL_VECTOR_COERCE_OPS_INNER(Vec2, tlow, thigh) \
    1135     DECLARE_ALL_VECTOR_COERCE_OPS_INNER(Vec3, tlow, thigh) \
    1136     DECLARE_ALL_VECTOR_COERCE_OPS_INNER(Vec4, tlow, thigh) \
     1134    DECLARE_VEC_ANY_COERCE_OPS(Vec2, tlow, thigh) \
     1135    DECLARE_VEC_ANY_COERCE_OPS(Vec3, tlow, thigh) \
     1136    DECLARE_VEC_ANY_COERCE_OPS(Vec4, tlow, thigh) \
    11371137    \
    11381138    DECLARE_VEC_3_COERCE_OPS(Vec3, static, tlow, thigh, thigh) \
    11391139    DECLARE_VEC_3_COERCE_OPS(Vec3, static, thigh, tlow, thigh)
     1140
     1141DECLARE_ALL_NONVECTOR_OPS(Cmplx)
     1142DECLARE_ALL_NONVECTOR_OPS(Quat)
    11401143
    11411144/* Disable warning about unary operator applied to unsigned type */
     
    11441147#   pragma warning(disable: 4146)
    11451148#endif
    1146 
    1147 DECLARE_ALL_NONVECTOR_OPS(Cmplx)
    1148 DECLARE_ALL_NONVECTOR_OPS(Quat)
    11491149
    11501150DECLARE_ALL_VECTOR_OPS(half)
     
    11791179#endif
    11801180
    1181 /* Apply the same coercion rules as in the C++ standard. However,   */
    1182 /* instead of promoting int8_t etc. to int, we apply our own rules. */
    1183 /* FIXME: "half" and "real" are deactivated for now, because we do  */
    1184 /* not implement all combinations of operators for these types yet. */
     1181/* Apply the same coercion rules as in the C++ standard. However, instead
     1182 * of always promoting smaller types to int, we allow int8_t op int16_t to
     1183 * return an int16_t. */
    11851184DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint8_t)
    11861185DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int16_t)
     
    11901189DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, int64_t)
    11911190DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, uint64_t)
    1192 /* DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, half) */
    11931191DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, float)
    11941192DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, double)
    11951193DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, long double)
    1196 /* DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, real) */
    11971194
    11981195DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int16_t)
     
    12021199DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, int64_t)
    12031200DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, uint64_t)
    1204 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, half) */
    12051201DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, float)
    12061202DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, double)
    12071203DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, long double)
    1208 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, real) */
    12091204
    12101205DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint16_t)
     
    12131208DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, int64_t)
    12141209DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, uint64_t)
    1215 /* DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, half) */
    12161210DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, float)
    12171211DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, double)
    12181212DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, long double)
    1219 /* DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, real) */
    12201213
    12211214DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, int32_t)
     
    12231216DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, int64_t)
    12241217DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, uint64_t)
    1225 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, half) */
    12261218DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, float)
    12271219DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, double)
    12281220DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, long double)
    1229 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, real) */
    12301221
    12311222DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, uint32_t)
    12321223DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, int64_t)
    12331224DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, uint64_t)
    1234 /* DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, half) */
    12351225DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, float)
    12361226DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, double)
    12371227DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, long double)
    1238 /* DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, real) */
    12391228
    12401229DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, int64_t)
    12411230DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, uint64_t)
    1242 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, half) */
    12431231DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, float)
    12441232DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, double)
    12451233DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, long double)
    1246 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, real) */
    12471234
    12481235DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, uint64_t)
    1249 /* DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, half) */
    12501236DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, float)
    12511237DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, double)
    12521238DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, long double)
    1253 /* DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, real) */
    1254 
    1255 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, half) */
     1239
    12561240DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, float)
    12571241DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, double)
    12581242DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, long double)
    1259 /* DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, real) */
    1260 
    1261 /* DECLARE_ALL_VECTOR_COERCE_OPS(half, float) */
    1262 /* DECLARE_ALL_VECTOR_COERCE_OPS(half, double) */
    1263 /* DECLARE_ALL_VECTOR_COERCE_OPS(half, long double) */
    1264 /* DECLARE_ALL_VECTOR_COERCE_OPS(half, real) */
    12651243
    12661244DECLARE_ALL_VECTOR_COERCE_OPS(float, double)
    12671245DECLARE_ALL_VECTOR_COERCE_OPS(float, long double)
    1268 /* DECLARE_ALL_VECTOR_COERCE_OPS(float, real) */
    12691246
    12701247DECLARE_ALL_VECTOR_COERCE_OPS(double, long double)
    1271 /* DECLARE_ALL_VECTOR_COERCE_OPS(double, real) */
    1272 
    1273 /* DECLARE_ALL_VECTOR_COERCE_OPS(long double, real) */
     1248
     1249/* All integer types are promoted to half; all floating point types
     1250 * cause half to be promoted. */
     1251DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, half)
     1252DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, half)
     1253DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, half)
     1254DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, half)
     1255DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, half)
     1256DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, half)
     1257DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, half)
     1258DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, half)
     1259
     1260DECLARE_ALL_VECTOR_COERCE_OPS(half, float)
     1261DECLARE_ALL_VECTOR_COERCE_OPS(half, double)
     1262DECLARE_ALL_VECTOR_COERCE_OPS(half, long double)
     1263
     1264/* FIXME: vectors of "real" are deactivated for now, because we do
     1265 * not implement all combinations of operators for these types yet. */
     1266
     1267#if 0
     1268/* All types are promoted to real */
     1269DECLARE_ALL_VECTOR_COERCE_OPS(int8_t, real)
     1270DECLARE_ALL_VECTOR_COERCE_OPS(uint8_t, real)
     1271DECLARE_ALL_VECTOR_COERCE_OPS(int16_t, real)
     1272DECLARE_ALL_VECTOR_COERCE_OPS(uint16_t, real)
     1273DECLARE_ALL_VECTOR_COERCE_OPS(int32_t, real)
     1274DECLARE_ALL_VECTOR_COERCE_OPS(uint32_t, real)
     1275DECLARE_ALL_VECTOR_COERCE_OPS(int64_t, real)
     1276DECLARE_ALL_VECTOR_COERCE_OPS(uint64_t, real)
     1277DECLARE_ALL_VECTOR_COERCE_OPS(half, real)
     1278DECLARE_ALL_VECTOR_COERCE_OPS(float, real)
     1279DECLARE_ALL_VECTOR_COERCE_OPS(double, real)
     1280DECLARE_ALL_VECTOR_COERCE_OPS(long double, real)
     1281#endif
    12741282
    12751283#if defined __GNUC__ && (__GNUC__ >= 4)
Note: See TracChangeset for help on using the changeset viewer.