Commit dd9c6bb0 authored by Administrator's avatar Administrator
Browse files

Merge branch 'vs2017-support' into 'dev-1.0'

Vs2017 support

See merge request kdlibcpp/kdlibcpp!11
parents b4c87cee 9fa21ea2
......@@ -30,7 +30,7 @@ typedef std::list< SymbolOffset > SymbolOffsetList;
typedef std::list< std::wstring > TypeNameList;
class Module : private boost::noncopyable, public NumBehavior {
class Module : public NumConvertable, private boost::noncopyable {
public:
......
......@@ -70,7 +70,7 @@ TypedVarPtr loadFloatVar( float var );
TypedVarPtr loadDoubleVar( double var );
TypedVarPtr loadWCharVar( wchar_t var );
class TypedVar : public NumBehavior {
class TypedVar : public NumConvertable, private boost::noncopyable {
friend TypedVarPtr loadTypedVar( const SymbolPtr &symbol );
......@@ -88,6 +88,16 @@ class TypedVar : public NumBehavior {
public:
template <typename T>
operator T() {
return static_cast<T>(getValue());
}
template <typename T>
operator T() const {
return static_cast<T>(getValue());
}
virtual std::wstring str() = 0;
virtual VarStorage getStorage() const = 0;
virtual std::wstring getRegisterName() const = 0;
......@@ -112,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;
......@@ -136,9 +145,20 @@ protected:
///////////////////////////////////////////////////////////////////////////////
class TypedValue : public NumBehavior
class TypedValue
{
public:
operator NumVariant() {
return getValue();
}
operator NumVariant() const {
return getValue();
}
TypedValue();
TypedValue(const TypedVarPtr& var) : m_value(var){}
......@@ -294,13 +314,11 @@ private:
TypedVarPtr m_value;
};
inline
NumBehavior::operator TypedValue() {
return TypedValue( getValue() );
}
TypedValue callRaw(MEMOFFSET_64 addr, CallingConventionType callingConvention, const TypedValueList& arglst);
TypedValue evalExpr(const std::wstring& expr, const std::list< std::pair<std::wstring, TypedValue> >& scope = {});
///////////////////////////////////////////////////////////////////////////////
} // end kdlib namespace
......@@ -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, public NumBehavior {
class TypeInfo : public NumConvertable, private boost::noncopyable {
friend TypeInfoPtr loadType( const std::wstring &symName );
friend TypeInfoPtr loadType( SymbolPtr &symbol );
......@@ -105,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;
......@@ -135,7 +133,7 @@ protected:
static bool isComplexType( const std::wstring &typeName );
static TypeInfoPtr getTypeInfoFromCache(const std::wstring &typeName );
static TypeInfoPtr getBaseTypeInfo( const std::wstring &typeName, size_t ptrSize );
static TypeInfoPtr getBaseTypeInfo( const std::wstring &typeName, size_t ptrSize = 0);
static TypeInfoPtr getBaseTypeInfo( SymbolPtr &symbolScope );
static TypeInfoPtr getComplexTypeInfo( const std::wstring &typeName, SymbolPtr &symbolScope );
......
......@@ -117,7 +117,7 @@ struct rshift_op {
class NumVariant : boost::operators<NumVariant>, boost::left_shiftable<NumVariant>, boost::right_shiftable<NumVariant>
class NumVariant
{
public:
......@@ -491,121 +491,42 @@ public:
m_doubleVal = val;
}
friend bool operator==(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::op<bool, equal_op >( v1, v2 );
}
friend bool operator==(const NumVariant& v1, const NumVariant& v2);
friend bool operator!=(const NumVariant& v1, const NumVariant& v2);
friend bool operator<(const NumVariant& v1, const NumVariant& v2);
friend bool operator<=(const NumVariant& v1, const NumVariant& v2);
friend bool operator>(const NumVariant& v1, const NumVariant& v2);
friend bool operator>=(const NumVariant& v1, const NumVariant& v2);
friend bool operator&&(const NumVariant& v1, const NumVariant& v2);
friend bool operator||(const NumVariant& v1, const NumVariant& 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 NumVariant operator+(const NumVariant& v1, const NumVariant& v2);
friend NumVariant operator-(const NumVariant& v1, const NumVariant& v2);
friend NumVariant operator*(const NumVariant& v1, const NumVariant& v2);
friend NumVariant operator/(const NumVariant& v1, const NumVariant& 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 NumVariant operator^(const NumVariant& v1, const NumVariant& v2);
friend NumVariant operator&(const NumVariant& v1, const NumVariant& v2);
friend NumVariant operator|(const NumVariant& v1, const NumVariant& 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 NumVariant operator%(const NumVariant& v1, const NumVariant& v2);
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<<(const NumVariant& v1, const NumVariant& v2);
friend NumVariant operator>>(const NumVariant& v1, const NumVariant& v2);
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~(const NumVariant& v1);
friend bool operator!(const NumVariant& 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 );
}
friend NumVariant operator++(NumVariant& v1);
friend NumVariant operator--(NumVariant& v1);
friend NumVariant operator++(NumVariant& v1, int);
friend NumVariant operator--(NumVariant& v1, int);
friend NumVariant operator-(const NumVariant& v1);
template< typename RetT, template<class> class FuncT>
static
RetT op( const NumVariant& v1, const NumVariant& v2 )
RetT all_op( const NumVariant& v1, const NumVariant& v2 )
{
NumVariant::NumType t = maxType( v1, v2 );
NumVariant v3 = v1.cast( t );
......@@ -620,12 +541,12 @@ public:
return FuncT<double>()(v3.m_doubleVal, v4.m_doubleVal);
}
return whole_op<RetT, FuncT>( v3, v4 );
return int_op<RetT, FuncT>( v3, v4 );
}
template< typename RetT, template<class> class FuncT>
static
RetT whole_op( const NumVariant& v1, const NumVariant& v2 )
RetT int_op( const NumVariant& v1, const NumVariant& v2 )
{
NumVariant::NumType t = maxType( v1, v2 );
NumVariant v3 = v1.cast( t );
......@@ -671,6 +592,9 @@ public:
throw NumVariantError();
}
template <typename T>
operator T();
private:
enum NumType { charT, ucharT, shortT, ushortT, longT, ulongT, longlongT, ulonglongT, intT, uintT, floatT, doubleT, maxT };
......@@ -835,136 +759,213 @@ private:
};
inline bool operator==(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::all_op<bool, equal_op>(v1, v2);
}
class NumBehavior : boost::operators<NumBehavior>, boost::left_shiftable<NumBehavior>, boost::right_shiftable<NumBehavior>
inline bool operator!=(const NumVariant& v1, const NumVariant& v2)
{
return !(v1 == v2);
}
public:
inline bool operator<(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::all_op<bool, gt_op>(v1, v2);
}
operator NumVariant() const {
return getValue();
}
inline bool operator<=(const NumVariant& v1, const NumVariant& v2)
{
return !(v1 > v2);
}
operator NumVariant() {
return getValue();
}
inline bool operator>(const NumVariant& v1, const NumVariant& v2)
{
return v2 < v1;
}
char asChar() {
return getValue().asChar();
}
inline bool operator>=(const NumVariant& v1, const NumVariant& v2)
{
return !(v1 < v2);
}
unsigned char asUChar() {
return getValue().asUChar();
}
inline bool operator&&(const NumVariant& v1, const NumVariant& v2)
{
return !(NumVariant::all_op<bool, equal_op >(v1, NumVariant(0)) || NumVariant::all_op<bool, equal_op >(v2, NumVariant(0)));
}
short asShort() {
return getValue().asShort();
}
inline bool operator||(const NumVariant& v1, const NumVariant& v2)
{
return !(NumVariant::all_op<bool, equal_op >(v1, NumVariant(0)) && NumVariant::all_op<bool, equal_op >(v2, NumVariant(0)));
}
unsigned short asUShort() {
return getValue().asUShort();
}
inline NumVariant operator+(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::all_op<NumVariant, add_op>(v1, v2);
}
long asLong() {
return getValue().asLong();
}
inline NumVariant operator-(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::all_op<NumVariant, sub_op>(v1, v2);
}
unsigned long asULong() {
return getValue().asULong();
}
inline NumVariant operator*(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::all_op<NumVariant, mul_op>(v1, v2);
}
long long asLongLong() {
return getValue().asLongLong();
}
inline NumVariant operator/(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::all_op<NumVariant, div_op>(v1, v2);
}
unsigned long long asULongLong() {
return getValue().asULongLong();
}
inline NumVariant operator%(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::int_op<NumVariant, mod_op>(v1, v2);
}
int asInt() {
return getValue().asInt();
}
inline NumVariant operator^(const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::int_op<NumVariant, xor_op >(v1, v2);
}
unsigned int asUInt() {
return getValue().asUInt();
}
inline NumVariant operator& (const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::int_op<NumVariant, and_op >(v1, v2);
}
float asFloat() {
return getValue().asFloat();
}
inline NumVariant operator| (const NumVariant& v1, const NumVariant& v2)
{
return NumVariant::int_op<NumVariant, or_op >(v1, v2);
}
double asDouble() {
return getValue().asDouble();
}
inline NumVariant operator<<(const NumVariant& v1, const NumVariant& v2)
{
NumVariant::NumType safeArgType = v1.m_numType;
return NumVariant::int_op<NumVariant, lshift_op >(v1, v2).cast(safeArgType);
}
template <typename T>
operator T() ;
inline NumVariant operator>>(const NumVariant& v1, const NumVariant& v2)
{
NumVariant::NumType safeArgType = v1.m_numType;
return NumVariant::int_op<NumVariant, rshift_op >(v1, v2).cast(safeArgType);
}
protected:
inline NumVariant operator~(const NumVariant& v1)
{
NumVariant v2(~0ULL);
v2 = v2.cast(v1.m_numType);
return NumVariant::int_op<NumVariant, xor_op >(v1, v2);
}
virtual NumVariant getValue() const = 0;
inline bool operator!(const NumVariant& v1)
{
return NumVariant::all_op<bool, equal_op >(v1, NumVariant(0));
}
};
inline NumVariant operator++(NumVariant& v1)
{
v1 = v1 + NumVariant(1).cast(v1.m_numType);
return v1;
}
inline NumVariant operator--(NumVariant& v1)
{
v1 = v1 - NumVariant(1).cast(v1.m_numType);
return v1;
}
inline NumVariant operator++(NumVariant& v1, int)
{
auto t = v1;
v1 = v1 + NumVariant(1).cast(v1.m_numType);
return t;
}
inline
NumBehavior::operator char() {
inline NumVariant operator--(NumVariant& v1, int)
{
auto t = v1;
v1 = v1 - NumVariant(1).cast(v1.m_numType);
return t;
}
inline NumVariant operator-(const NumVariant& v1)
{
return NumVariant(0).cast(v1.m_numType) - v1;
}
inline
NumVariant::operator char() {
return asChar();
}
inline
NumBehavior::operator unsigned char() {
inline
NumVariant::operator unsigned char() {
return asUChar();
}
inline
NumBehavior::operator short() {
inline
NumVariant::operator short() {
return asShort();
}
inline
NumBehavior::operator unsigned short() {
inline
NumVariant::operator unsigned short() {
return asUShort();
}
inline
NumBehavior::operator unsigned long() {
return asULong();
NumVariant::operator unsigned long() {
return asULong();
}
inline
NumBehavior::operator long() {
return asLong();
NumVariant::operator long() {
return asLong();
}
inline
NumBehavior::operator unsigned long long() {
return asULongLong();
NumVariant::operator unsigned long long() {
return asULongLong();
}
inline
NumBehavior::operator long long() {
return asLongLong();
NumVariant::operator long long() {
return asLongLong();
}
inline
NumBehavior::operator float() {
return asFloat();
NumVariant::operator float() {
return asFloat();
}
inline
NumBehavior::operator double() {
return asDouble();
NumVariant::operator double() {
return asDouble();
}
inline
NumBehavior::operator bool() {
return asChar() != 0;
NumVariant::operator bool() {
return asChar() != 0;
}
inline
NumBehavior::operator void*() {
return reinterpret_cast<void*>(asULongLong());
}
class NumConvertable
{
public:
operator NumVariant() {
return getValue();
}
operator NumVariant() const {
return getValue();
}
virtual NumVariant getValue() const = 0;
};
///////////////////////////////////////////////////////////////////////////////
......
......@@ -3,6 +3,7 @@
#include <vector>
#include <string>
#include <list>
#include <memory>
#include <atlcomcli.h>
#include <DbgEng.h>
......@@ -35,7 +36,7 @@ public:
private:
std::auto_ptr<T> m_impl;
std::unique_ptr<T> m_impl;
};