Commit 68ef43b8 authored by ussrhero's avatar ussrhero

added NumConvertable class

parent e66d9b93
......@@ -30,18 +30,10 @@ typedef std::list< SymbolOffset > SymbolOffsetList;
typedef std::list< std::wstring > TypeNameList;
class Module : private boost::noncopyable {
class Module : public NumConvertable, private boost::noncopyable {
public:
operator NumVariant() {
return getBase();
}
operator NumVariant() const {
return getBase();
}
virtual std::wstring getName() = 0;
virtual MEMOFFSET_64 getBase() const = 0;
......
......@@ -70,7 +70,7 @@ TypedVarPtr loadFloatVar( float var );
TypedVarPtr loadDoubleVar( double var );
TypedVarPtr loadWCharVar( wchar_t var );
class TypedVar : private boost::noncopyable {
class TypedVar : public NumConvertable, private boost::noncopyable {
friend TypedVarPtr loadTypedVar( const SymbolPtr &symbol );
......@@ -87,14 +87,6 @@ class TypedVar : private boost::noncopyable {
friend TypedVarPtr loadTypedVar( const std::wstring &funcName, const std::wstring &prototype);
public:
operator NumVariant() {
return getValue();
}
operator NumVariant() const {
return getValue();
}
template <typename T>
operator T() {
......@@ -130,7 +122,6 @@ public:
virtual TypedVarPtr getMethod( const std::wstring &name, const std::wstring& prototype = L"") = 0;
virtual TypedVarPtr getMethod( const std::wstring &name, TypeInfoPtr prototype) = 0;
virtual TypeInfoPtr getType() const = 0;
virtual NumVariant getValue() const = 0;
virtual void setValue(const NumVariant& value) = 0;
virtual std::wstring getStrValue() const = 0;
virtual void setStrValue(const std::wstring& value) = 0;
......@@ -323,10 +314,6 @@ private:
TypedVarPtr m_value;
};
//inline
//NumBehavior::operator TypedValue() {
// return TypedValue( getValue() );
//}
TypedValue callRaw(MEMOFFSET_64 addr, CallingConventionType callingConvention, const TypedValueList& arglst);
......
......@@ -34,7 +34,7 @@ MEMOFFSET_64 getSymbolOffset( const std::wstring &name );
std::wstring findSymbol( MEMOFFSET_64 offset);
std::wstring findSymbol( MEMOFFSET_64 offset, MEMDISPLACEMENT &displacement );
class TypeInfo : private boost::noncopyable {
class TypeInfo : public NumConvertable, private boost::noncopyable {
friend TypeInfoPtr loadType( const std::wstring &symName );
friend TypeInfoPtr loadType( SymbolPtr &symbol );
......@@ -43,14 +43,6 @@ class TypeInfo : private boost::noncopyable {
public:
operator NumVariant() {
return getValue();
}
operator NumVariant() const {
return getValue();
}
virtual std::wstring str() = 0;
virtual std::wstring getName() = 0;
......@@ -113,8 +105,6 @@ public:
virtual void getBaseClassVirtualDisplacement( const std::wstring &name, MEMOFFSET_32 &virtualBasePtr, size_t &virtualDispIndex, size_t &virtualDispSize ) = 0;
virtual void getBaseClassVirtualDisplacement( size_t index, MEMOFFSET_32 &virtualBasePtr, size_t &virtualDispIndex, size_t &virtualDispSize ) = 0;
virtual NumVariant getValue() const = 0;
virtual void getVirtualDisplacement( const std::wstring& fieldName, MEMOFFSET_32 &virtualBasePtr, size_t &virtualDispIndex, size_t &virtualDispSize ) = 0;
virtual void getVirtualDisplacement( size_t fieldIndex, MEMOFFSET_32 &virtualBasePtr, size_t &virtualDispIndex, size_t &virtualDispSize ) = 0;
......
......@@ -524,121 +524,6 @@ public:
friend NumVariant operator--(NumVariant& v1, int);
friend NumVariant operator-(const NumVariant& v1);
/*
friend bool operator==(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::op<bool, equal_op >( v1, v2 );
}
friend bool operator!(const NumVariant& v1)
{
return NumVariant::op<bool, equal_op >( v1, NumVariant(0) );
}
friend bool operator<(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::op<bool, gt_op >( v1, v2 );
}
friend bool operator&&(const NumVariant& v1, const NumVariant& v2)
{
return !NumVariant::op<bool, equal_op >( v1, NumVariant(0) ) && !NumVariant::op<bool, equal_op >( v2, NumVariant(0) );
}
friend bool operator||(const NumVariant& v1, const NumVariant& v2)
{
return !NumVariant::op<bool, equal_op >( v1, NumVariant(0) ) || !NumVariant::op<bool, equal_op >( v2, NumVariant(0) );
}
friend NumVariant operator<<=( NumVariant& v1, const NumVariant& v2)
{
NumVariant::NumType safeArgType = v1.m_numType;
v1 = NumVariant::whole_op<NumVariant, lshift_op >( v1, v2 ).cast(safeArgType);
return v1;
}
friend NumVariant operator>>=( NumVariant& v1, const NumVariant& v2)
{
NumVariant::NumType safeArgType = v1.m_numType;
v1 = NumVariant::whole_op<NumVariant, rshift_op >( v1, v2 ).cast(safeArgType);
return v1;
}
friend NumVariant operator+=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::op<NumVariant, add_op >( v1, v2 );
return v1;
}
friend NumVariant operator-=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::op<NumVariant, sub_op >( v1, v2 );
return v1;
}
friend NumVariant operator*=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::op<NumVariant, mul_op >( v1, v2 );
return v1;
}
friend NumVariant operator/=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::op<NumVariant, div_op >( v1, v2 );
return v1;
}
friend NumVariant operator%=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::whole_op<NumVariant, mod_op >( v1, v2 );
return v1;
}
friend NumVariant operator|=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::whole_op<NumVariant, or_op >( v1, v2 );
return v1;
}
friend NumVariant operator&=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::whole_op<NumVariant, and_op >( v1, v2 );
return v1;
}
friend NumVariant operator^=( NumVariant& v1, const NumVariant& v2)
{
v1 = NumVariant::whole_op<NumVariant, xor_op >( v1, v2 );
return v1;
}
friend NumVariant operator~( NumVariant& v1)
{
NumVariant v2(~0ULL);
v2 = v2.cast( v1.m_numType );
return NumVariant::whole_op<NumVariant, xor_op >( v1, v2 );
}
friend NumVariant operator++( NumVariant& v1)
{
v1 = NumVariant::op<NumVariant, add_op >( v1, NumVariant(1) );
return v1;
}
friend NumVariant operator--( NumVariant& v1)
{
v1 = NumVariant::op<NumVariant, sub_op >( v1, NumVariant(1) );
return v1;
}
friend NumVariant operator-( NumVariant& v1)
{
return NumVariant::op<NumVariant, sub_op >( NumVariant(0), v1 );
}
*/
template< typename RetT, template<class> class FuncT>
static
RetT all_op( const NumVariant& v1, const NumVariant& v2 )
......@@ -1066,140 +951,22 @@ NumVariant::operator bool() {
}
/*
class NumBehavior : boost::operators<NumBehavior>, boost::left_shiftable<NumBehavior>, boost::right_shiftable<NumBehavior>
class NumConvertable
{
public:
operator NumVariant() const {
return getValue();
}
operator NumVariant() {
return getValue();
}
char asChar() {
return getValue().asChar();
}
unsigned char asUChar() {
return getValue().asUChar();
}
short asShort() {
return getValue().asShort();
}
unsigned short asUShort() {
return getValue().asUShort();
}
long asLong() {
return getValue().asLong();
}
unsigned long asULong() {
return getValue().asULong();
}
long long asLongLong() {
return getValue().asLongLong();
}
unsigned long long asULongLong() {
return getValue().asULongLong();
}
int asInt() {
return getValue().asInt();
}
unsigned int asUInt() {
return getValue().asUInt();
}
float asFloat() {
return getValue().asFloat();
}
double asDouble() {
return getValue().asDouble();
operator NumVariant() const {
return getValue();
}
template <typename T>
operator T() ;
protected:
virtual NumVariant getValue() const = 0;
virtual NumVariant getValue() const = 0;
};
inline
NumBehavior::operator char() {
return asChar();
}
inline
NumBehavior::operator unsigned char() {
return asUChar();
}
inline
NumBehavior::operator short() {
return asShort();
}
inline
NumBehavior::operator unsigned short() {
return asUShort();
}
inline
NumBehavior::operator unsigned long() {
return asULong();
}
inline
NumBehavior::operator long() {
return asLong();
}
inline
NumBehavior::operator unsigned long long() {
return asULongLong();
}
inline
NumBehavior::operator long long() {
return asLongLong();
}
inline
NumBehavior::operator float() {
return asFloat();
}
inline
NumBehavior::operator double() {
return asDouble();
}
inline
NumBehavior::operator bool() {
return asChar() != 0;
}
inline
NumBehavior::operator void*() {
return reinterpret_cast<void*>(asULongLong());
}
*/
///////////////////////////////////////////////////////////////////////////////
} // end kdlib namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment