C++: Now using standard C++ types instead of stdint

This commit is contained in:
Philippe Tillet
2015-05-04 21:23:05 -04:00
parent 5cdbef7b4e
commit 278109eef8
5 changed files with 273 additions and 257 deletions

View File

@@ -12,7 +12,6 @@ class array_expression;
union values_holder
{
// int8_t bool8;
int8_t int8;
u_int8_t uint8;
int16_t int16;
@@ -21,9 +20,8 @@ union values_holder
u_int32_t uint32;
int64_t int64;
u_int64_t uint64;
// cl_half float16;
cl_float float32;
cl_double float64;
float float32;
double float64;
};
class value_scalar
@@ -31,19 +29,17 @@ class value_scalar
template<class T> void init(T const &);
template<class T> T cast() const;
public:
#define ISAAC_INSTANTIATE(CLTYPE, ADTYPE) value_scalar(CLTYPE value, numeric_type dtype = ADTYPE);
// ISAAC_INSTANTIATE(cl_bool, BOOL_TYPE)
ISAAC_INSTANTIATE(int8_t, CHAR_TYPE)
ISAAC_INSTANTIATE(uint8_t, UCHAR_TYPE)
ISAAC_INSTANTIATE(int16_t, SHORT_TYPE)
ISAAC_INSTANTIATE(u_int16_t, USHORT_TYPE)
ISAAC_INSTANTIATE(int32_t, INT_TYPE)
ISAAC_INSTANTIATE(u_int32_t, UINT_TYPE)
ISAAC_INSTANTIATE(int64_t, LONG_TYPE)
ISAAC_INSTANTIATE(u_int64_t, ULONG_TYPE)
// ISAAC_INSTANTIATE(cl_half, HALF_TYPE)
ISAAC_INSTANTIATE(cl_float, FLOAT_TYPE)
ISAAC_INSTANTIATE(cl_double, DOUBLE_TYPE)
#define ISAAC_INSTANTIATE(TYPE) value_scalar(TYPE value, numeric_type dtype = to_numeric_type<TYPE>::value);
ISAAC_INSTANTIATE(char)
ISAAC_INSTANTIATE(unsigned char)
ISAAC_INSTANTIATE(short)
ISAAC_INSTANTIATE(unsigned short)
ISAAC_INSTANTIATE(int)
ISAAC_INSTANTIATE(unsigned int)
ISAAC_INSTANTIATE(long)
ISAAC_INSTANTIATE(unsigned long)
ISAAC_INSTANTIATE(float)
ISAAC_INSTANTIATE(double)
#undef ISAAC_INSTANTIATE
value_scalar(values_holder value, numeric_type dtype);
explicit value_scalar(scalar const &);
@@ -55,16 +51,16 @@ public:
#define INSTANTIATE(type) operator type() const;
INSTANTIATE(bool)
INSTANTIATE(int8_t)
INSTANTIATE(uint8_t)
INSTANTIATE(int16_t)
INSTANTIATE(u_int16_t)
INSTANTIATE(int32_t)
INSTANTIATE(u_int32_t)
INSTANTIATE(int64_t)
INSTANTIATE(u_int64_t)
INSTANTIATE(cl_float)
INSTANTIATE(cl_double)
INSTANTIATE(char)
INSTANTIATE(unsigned char)
INSTANTIATE(short)
INSTANTIATE(unsigned short)
INSTANTIATE(int)
INSTANTIATE(unsigned int)
INSTANTIATE(long)
INSTANTIATE(unsigned long)
INSTANTIATE(float)
INSTANTIATE(double)
#undef INSTANTIATE
private:
values_holder values_;
@@ -72,40 +68,40 @@ private:
};
value_scalar int8(int8_t v);
value_scalar uint8(uint8_t v);
value_scalar uint8(u_int8_t v);
value_scalar int16(int16_t v);
value_scalar uint16(u_int16_t v);
value_scalar int32(int32_t v);
value_scalar uint32(u_int32_t v);
value_scalar int64(int64_t v);
value_scalar uint64(u_int64_t v);
value_scalar float32(cl_float v);
value_scalar float64(cl_double v);
value_scalar float32(float v);
value_scalar float64(double v);
template<class T>
T cast(isaac::value_scalar const &);
#define ISAAC_DECLARE_BINARY_OPERATOR(RET, OPNAME) \
RET OPNAME (value_scalar const &, int8_t );\
RET OPNAME (value_scalar const &, uint8_t );\
RET OPNAME (value_scalar const &, int16_t );\
RET OPNAME (value_scalar const &, u_int16_t);\
RET OPNAME (value_scalar const &, int32_t );\
RET OPNAME (value_scalar const &, u_int32_t );\
RET OPNAME (value_scalar const &, int64_t );\
RET OPNAME (value_scalar const &, u_int64_t );\
RET OPNAME (value_scalar const &, cl_float );\
RET OPNAME (value_scalar const &, cl_double);\
RET OPNAME (int8_t , value_scalar const &);\
RET OPNAME (uint8_t , value_scalar const &);\
RET OPNAME (int16_t , value_scalar const &);\
RET OPNAME (u_int16_t , value_scalar const &);\
RET OPNAME (int32_t , value_scalar const &);\
RET OPNAME (u_int32_t , value_scalar const &);\
RET OPNAME (int64_t , value_scalar const &);\
RET OPNAME (u_int64_t , value_scalar const &);\
RET OPNAME (cl_float , value_scalar const &);\
RET OPNAME (cl_double , value_scalar const &);\
RET OPNAME (value_scalar const &, char );\
RET OPNAME (value_scalar const &, unsigned char );\
RET OPNAME (value_scalar const &, short );\
RET OPNAME (value_scalar const &, unsigned short);\
RET OPNAME (value_scalar const &, int );\
RET OPNAME (value_scalar const &, unsigned int );\
RET OPNAME (value_scalar const &, long );\
RET OPNAME (value_scalar const &, unsigned long );\
RET OPNAME (value_scalar const &, float );\
RET OPNAME (value_scalar const &, double);\
RET OPNAME (char , value_scalar const &);\
RET OPNAME (unsigned char , value_scalar const &);\
RET OPNAME (short , value_scalar const &);\
RET OPNAME (unsigned short , value_scalar const &);\
RET OPNAME (int , value_scalar const &);\
RET OPNAME (unsigned int , value_scalar const &);\
RET OPNAME (long , value_scalar const &);\
RET OPNAME (unsigned long , value_scalar const &);\
RET OPNAME (float , value_scalar const &);\
RET OPNAME (double , value_scalar const &);\
RET OPNAME (value_scalar const &, value_scalar const &);
ISAAC_DECLARE_BINARY_OPERATOR(value_scalar, operator +)