mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 12:53:23 +08:00
[0.2.x] fixed : issue #12335 ( TypeError: object has no len() for array )
git-svn-id: https://pykd.svn.codeplex.com/svn@85918 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
cf6eea3f78
commit
5cb3fc858b
@ -203,7 +203,7 @@ public:
|
||||
throw PyException( PyExc_TypeError, "object has no len()" );
|
||||
}
|
||||
|
||||
virtual python::tuple getElementByIndex( ULONG index ) {
|
||||
virtual python::object getElementByIndex( ULONG index ) {
|
||||
throw PyException( PyExc_TypeError, "object is unsubscriptable");
|
||||
}
|
||||
|
||||
@ -400,7 +400,7 @@ protected:
|
||||
return getFieldCount();
|
||||
}
|
||||
|
||||
virtual python::tuple getElementByIndex( ULONG index ) {
|
||||
virtual python::object getElementByIndex( ULONG index ) {
|
||||
return python::make_tuple( getFieldNameByIndex(index), getFieldByIndex(index) );
|
||||
}
|
||||
|
||||
@ -542,6 +542,14 @@ protected:
|
||||
return getSize();
|
||||
}
|
||||
|
||||
virtual ULONG getElementCount() {
|
||||
return getFieldCount();
|
||||
}
|
||||
|
||||
virtual python::object getElementByIndex( ULONG index ) {
|
||||
return python::make_tuple( getFieldNameByIndex(index), getFieldByIndex(index) );
|
||||
}
|
||||
|
||||
SymbolPtr m_dia;
|
||||
};
|
||||
|
||||
@ -630,6 +638,16 @@ public:
|
||||
return m_count;
|
||||
}
|
||||
|
||||
virtual ULONG getElementCount() {
|
||||
return getCount();
|
||||
}
|
||||
|
||||
virtual python::object getElementByIndex( ULONG index ) {
|
||||
if( index < m_count )
|
||||
return python::object( m_derefType );
|
||||
throw PyException( PyExc_IndexError, "index out of range" );
|
||||
}
|
||||
|
||||
virtual TypeInfoPtr getElementType() {
|
||||
return m_derefType;
|
||||
}
|
||||
|
@ -214,6 +214,19 @@ class TypeInfoTest( unittest.TestCase ):
|
||||
for field in ti:
|
||||
str( field )
|
||||
|
||||
def testArraySubscribe(self):
|
||||
ti = pykd.typeInfo("g_testArray")
|
||||
self.assertEqual(2, len(ti) )
|
||||
for field in ti:
|
||||
str( field )
|
||||
|
||||
def testEnumSubscribe(self):
|
||||
ti = pykd.typeInfo("enumType")
|
||||
self.assertEqual(3, len(ti) )
|
||||
self.assertEqual( ( "TWO", 2 ), ti[1] )
|
||||
for field in ti:
|
||||
str( field )
|
||||
|
||||
def testStructNullSize(self):
|
||||
ti = target.module.type("structNullSize")
|
||||
self.assertEqual( 0, len(ti) )
|
||||
|
Loading…
Reference in New Issue
Block a user