mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[0.1.x] added : "subscription" for UDT typedVar
git-svn-id: https://pykd.svn.codeplex.com/svn@76519 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
f05e0e2658
commit
b3e8165aa1
@ -252,6 +252,31 @@ UdtTypedVar::getField( const std::string &fieldName )
|
|||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
TypedVarPtr
|
||||||
|
UdtTypedVar::getElementByIndex( ULONG index )
|
||||||
|
{
|
||||||
|
TypeInfoPtr fieldType = m_typeInfo->getFieldByIndex(index);
|
||||||
|
|
||||||
|
if ( fieldType->isStaticMember() )
|
||||||
|
{
|
||||||
|
if ( fieldType->getStaticOffset() == 0 )
|
||||||
|
throw ImplementException( __FILE__, __LINE__, "Fix ME");
|
||||||
|
|
||||||
|
return TypedVar::getTypedVar( m_client, fieldType, VarDataMemory::factory(m_dataSpaces, fieldType->getStaticOffset() ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
ULONG fieldOffset = fieldType->getOffset();
|
||||||
|
|
||||||
|
if ( fieldType->isVirtualMember() )
|
||||||
|
{
|
||||||
|
fieldOffset += getVirtualBaseDisplacement( fieldType );
|
||||||
|
}
|
||||||
|
|
||||||
|
return TypedVar::getTypedVar( m_client, fieldType, m_varData->fork(fieldOffset) );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
LONG UdtTypedVar::getVirtualBaseDisplacement( TypeInfoPtr& typeInfo )
|
LONG UdtTypedVar::getVirtualBaseDisplacement( TypeInfoPtr& typeInfo )
|
||||||
{
|
{
|
||||||
ULONG virtualBasePtr, virtualDispIndex, virtualDispSize;
|
ULONG virtualBasePtr, virtualDispIndex, virtualDispSize;
|
||||||
|
@ -68,7 +68,7 @@ public:
|
|||||||
throw PyException( PyExc_TypeError, "object is unsubscriptable");
|
throw PyException( PyExc_TypeError, "object is unsubscriptable");
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual TypedVarPtr getElementByIndexPtr( const TypedVarPtr& tv ) {
|
TypedVarPtr getElementByIndexPtr( const TypedVarPtr& tv ) {
|
||||||
return getElementByIndex( boost::apply_visitor( VariantToULong(), tv->getValue() ) );
|
return getElementByIndex( boost::apply_visitor( VariantToULong(), tv->getValue() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,12 +172,20 @@ public:
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
virtual std::string print();
|
virtual std::string print();
|
||||||
|
|
||||||
virtual std::string printValue();
|
virtual std::string printValue();
|
||||||
|
|
||||||
virtual TypedVarPtr getField( const std::string &fieldName );
|
virtual TypedVarPtr getField( const std::string &fieldName );
|
||||||
|
|
||||||
|
virtual ULONG getElementCount() {
|
||||||
|
return m_typeInfo->getFieldCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual TypedVarPtr getElementByIndex( ULONG index );
|
||||||
|
|
||||||
LONG getVirtualBaseDisplacement( TypeInfoPtr& typeInfo );
|
LONG getVirtualBaseDisplacement( TypeInfoPtr& typeInfo );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -529,6 +529,9 @@ TypeInfoPtr UdtTypeInfo::getFieldByIndex( ULONG index )
|
|||||||
getVirtualFields();
|
getVirtualFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( index >= m_fields.size() )
|
||||||
|
throw PyException( PyExc_IndexError, "Index out of range");
|
||||||
|
|
||||||
return m_fields[ index ].second;
|
return m_fields[ index ].second;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,6 +545,9 @@ std::string UdtTypeInfo::getFieldNameByIndex( ULONG index )
|
|||||||
getVirtualFields();
|
getVirtualFields();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( index >= m_fields.size() )
|
||||||
|
throw PyException( PyExc_IndexError, "Index out of range");
|
||||||
|
|
||||||
return m_fields[ index ].first;
|
return m_fields[ index ].first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,3 +254,10 @@ class TypedVarTest( unittest.TestCase ):
|
|||||||
g_map = target.module.typedVar( "g_map" )
|
g_map = target.module.typedVar( "g_map" )
|
||||||
self.assertEqual( 1, g_map._Mysize )
|
self.assertEqual( 1, g_map._Mysize )
|
||||||
|
|
||||||
|
|
||||||
|
def testUdtSubscribe(self):
|
||||||
|
tv = pykd.typedVar( "g_virtChild" )
|
||||||
|
self.assertEqual( 5, len(tv) )
|
||||||
|
self.assertEqual( tv[4], tv.m_baseField )
|
||||||
|
for field in tv:
|
||||||
|
str( field )
|
||||||
|
Loading…
Reference in New Issue
Block a user