From 1d4c95497e4b5b8f59713bcca31a06095470c92b Mon Sep 17 00:00:00 2001 From: "SND\\ussrhero_cp" Date: Sat, 3 Dec 2016 16:29:50 +0000 Subject: [PATCH] [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 --- pykd/pymod.cpp | 6 ++++++ pykd/pytypeinfo.h | 18 ++++++++++++++++++ test/scripts/typeinfo.py | 8 +++++++- 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index a7eb1df..9196ded 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -846,6 +846,12 @@ BOOST_PYTHON_MODULE( pykd ) "Return name of struct field by index" ) .def( "fields", TypeInfoAdapter::getFields, "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, "Return type of pointer" ) .def( "append", TypeInfoAdapter::appendField, diff --git a/pykd/pytypeinfo.h b/pykd/pytypeinfo.h index 0a96c3f..8c7276b 100644 --- a/pykd/pytypeinfo.h +++ b/pykd/pytypeinfo.h @@ -145,6 +145,24 @@ struct TypeInfoAdapter : public kdlib::TypeInfo { 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 ) { AutoRestorePyState pystate; diff --git a/test/scripts/typeinfo.py b/test/scripts/typeinfo.py index 0120f20..83c7836 100644 --- a/test/scripts/typeinfo.py +++ b/test/scripts/typeinfo.py @@ -325,6 +325,12 @@ class TypeInfoTest( unittest.TestCase ): lst = target.module.enumTypes("NonExsistType") self.assertEqual([],lst) - def testArrayOverflow(self): 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() )