提交 9a5b15dc 编写于 作者: B Behdad Esfahbod

[C++11] Replace BEInt.set() with operator=

上级 0aa59b1d
......@@ -682,7 +682,11 @@ template <typename Type>
struct BEInt<Type, 1>
{
public:
void set (Type V) { v = V; }
BEInt<Type, 1>& operator = (Type V)
{
v = V;
return *this;
}
operator Type () const { return v; }
private: uint8_t v;
};
......@@ -690,10 +694,11 @@ template <typename Type>
struct BEInt<Type, 2>
{
public:
void set (Type V)
BEInt<Type, 2>& operator = (Type V)
{
v[0] = (V >> 8) & 0xFF;
v[1] = (V ) & 0xFF;
return *this;
}
operator Type () const
{
......@@ -718,11 +723,12 @@ template <typename Type>
struct BEInt<Type, 3>
{
public:
void set (Type V)
BEInt<Type, 3>& operator = (Type V)
{
v[0] = (V >> 16) & 0xFF;
v[1] = (V >> 8) & 0xFF;
v[2] = (V ) & 0xFF;
return *this;
}
operator Type () const
{
......@@ -737,12 +743,13 @@ struct BEInt<Type, 4>
{
public:
typedef Type type;
void set (Type V)
BEInt<Type, 4>& operator = (Type V)
{
v[0] = (V >> 24) & 0xFF;
v[1] = (V >> 16) & 0xFF;
v[2] = (V >> 8) & 0xFF;
v[3] = (V ) & 0xFF;
return *this;
}
operator Type () const
{
......
......@@ -59,8 +59,8 @@ struct IntType
typedef Type type;
typedef typename hb_signedness_int (hb_is_signed (Type)) wide_type;
IntType<Type, Size>& operator = (wide_type i) { v.set (i); return *this; }
void set (wide_type i) { v.set (i); }
IntType<Type, Size>& operator = (wide_type i) { v = i; return *this; }
void set (wide_type i) { v = i; }
operator wide_type () const { return v; }
bool operator == (const IntType<Type,Size> &o) const { return (Type) v == (Type) o.v; }
bool operator != (const IntType<Type,Size> &o) const { return !(*this == o); }
......@@ -109,7 +109,7 @@ struct F2DOT14 : HBINT16
{
// 16384 means 1<<14
float to_float () const { return ((int32_t) v) / 16384.f; }
void set_float (float f) { v.set (round (f * 16384.f)); }
void set_float (float f) { v = round (f * 16384.f); }
public:
DEFINE_SIZE_STATIC (2);
};
......@@ -119,7 +119,7 @@ struct Fixed : HBINT32
{
// 65536 means 1<<16
float to_float () const { return ((int32_t) v) / 65536.f; }
void set_float (float f) { v.set (round (f * 65536.f)); }
void set_float (float f) { v = round (f * 65536.f); }
public:
DEFINE_SIZE_STATIC (4);
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册