[0.3.x] added : method 'typeInfo.method' ( return method's type by name )

git-svn-id: https://pykd.svn.codeplex.com/svn@91073 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2016-12-03 16:29:50 +00:00 committed by Mikhail I. Izmestev
parent be9f1420ec
commit 1d4c95497e
3 changed files with 31 additions and 1 deletions

View File

@ -846,6 +846,12 @@ BOOST_PYTHON_MODULE( pykd )
"Return name of struct field by index" ) "Return name of struct field by index" )
.def( "fields", TypeInfoAdapter::getFields, .def( "fields", TypeInfoAdapter::getFields,
"Return list of tuple ( filedName, fieldType )" ) "Return list of tuple ( filedName, fieldType )" )
.def( "getNumberMethods", TypeInfoAdapter::getMethodsCount,
"Return number of methods" )
.def( "method", TypeInfoAdapter::getMethodByName,
"Return method's type by name")
.def( "method", TypeInfoAdapter::getMethodByIndex,
"Return method's by index")
.def( "deref", TypeInfoAdapter::deref, .def( "deref", TypeInfoAdapter::deref,
"Return type of pointer" ) "Return type of pointer" )
.def( "append", TypeInfoAdapter::appendField, .def( "append", TypeInfoAdapter::appendField,

View File

@ -145,6 +145,24 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
return typeInfo.getElement(index); return typeInfo.getElement(index);
} }
static size_t getMethodsCount( kdlib::TypeInfo &typeInfo )
{
AutoRestorePyState pystate;
return typeInfo.getMethodsCount();
}
static kdlib::TypeInfoPtr getMethodByName( kdlib::TypeInfo &typeInfo, const std::wstring& methodName)
{
AutoRestorePyState pystate;
return typeInfo.getMethod(methodName);
}
static kdlib::TypeInfoPtr getMethodByIndex( kdlib::TypeInfo &typeInfo, size_t index )
{
AutoRestorePyState pystate;
return typeInfo.getMethod(index);
}
static kdlib::TypeInfoPtr ptrTo( kdlib::TypeInfo &typeInfo, size_t ptrSize = 0 ) static kdlib::TypeInfoPtr ptrTo( kdlib::TypeInfo &typeInfo, size_t ptrSize = 0 )
{ {
AutoRestorePyState pystate; AutoRestorePyState pystate;

View File

@ -325,6 +325,12 @@ class TypeInfoTest( unittest.TestCase ):
lst = target.module.enumTypes("NonExsistType") lst = target.module.enumTypes("NonExsistType")
self.assertEqual([],lst) self.assertEqual([],lst)
def testArrayOverflow(self): def testArrayOverflow(self):
self.assertRaises(pykd.TypeException, pykd.baseTypes.UInt8B.arrayOf, 0xFFFFFFFFFFFFFFFF) self.assertRaises(pykd.TypeException, pykd.baseTypes.UInt8B.arrayOf, 0xFFFFFFFFFFFFFFFF)
def testMethodCount(self):
self.assertEqual( 8, target.module.type("classChild").getNumberMethods() )
def testGetMethod(self):
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").method("childMethod").name() )
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").method(1).name() )