mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
added : typeInfo.getMethodName ( Return method's name )
added : typeInfo.methods ( Return list of tuples ( methodName, methodType ) )
This commit is contained in:
parent
67c66c593c
commit
2509de349b
2
kdlibcpp
2
kdlibcpp
@ -1 +1 @@
|
|||||||
Subproject commit c1cd0e4fd727d87d23e1cf26e214ca45068d00e5
|
Subproject commit 65930b3307d248503d3c1051f61b50476437845b
|
@ -2,7 +2,7 @@
|
|||||||
#define PYKD_VERSION_MAJOR 0
|
#define PYKD_VERSION_MAJOR 0
|
||||||
#define PYKD_VERSION_MINOR 3
|
#define PYKD_VERSION_MINOR 3
|
||||||
#define PYKD_VERSION_SUBVERSION 4
|
#define PYKD_VERSION_SUBVERSION 4
|
||||||
#define PYKD_VERSION_BUILDNO 0
|
#define PYKD_VERSION_BUILDNO 1
|
||||||
|
|
||||||
#define __VER_STR2__(x) #x
|
#define __VER_STR2__(x) #x
|
||||||
#define __VER_STR1__(x) __VER_STR2__(x)
|
#define __VER_STR1__(x) __VER_STR2__(x)
|
||||||
|
@ -908,6 +908,10 @@ void pykd_init()
|
|||||||
"Return method's type by name")
|
"Return method's type by name")
|
||||||
.def( "method", TypeInfoAdapter::getMethodByIndex,
|
.def( "method", TypeInfoAdapter::getMethodByIndex,
|
||||||
"Return method's by index")
|
"Return method's by index")
|
||||||
|
.def( "methodName", TypeInfoAdapter::getMethodName,
|
||||||
|
"Return method's name")
|
||||||
|
.def( "methods", TypeInfoAdapter::getMethods,
|
||||||
|
"Return list of tuples ( methodName, methodPrototype )" )
|
||||||
.def( "getNumberBaseClasses", TypeInfoAdapter::getBaseClassesCount,
|
.def( "getNumberBaseClasses", TypeInfoAdapter::getBaseClassesCount,
|
||||||
"Return number of base classes" )
|
"Return number of base classes" )
|
||||||
.def( "baseClass", TypeInfoAdapter::getBaseClassByName,
|
.def( "baseClass", TypeInfoAdapter::getBaseClassByName,
|
||||||
|
@ -103,6 +103,34 @@ python::list TypeInfoAdapter::getFields( kdlib::TypeInfo &typeInfo )
|
|||||||
return pylst;
|
return pylst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
python::list TypeInfoAdapter::getMethods(kdlib::TypeInfo &typeInfo)
|
||||||
|
{
|
||||||
|
typedef boost::tuple<std::wstring, kdlib::TypeInfoPtr> FieldTuple;
|
||||||
|
|
||||||
|
std::list<FieldTuple> lst;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
|
||||||
|
for (size_t i = 0; i < typeInfo.getMethodsCount(); ++i)
|
||||||
|
{
|
||||||
|
std::wstring name = typeInfo.getMethodName(i);
|
||||||
|
kdlib::TypeInfoPtr val = typeInfo.getMethod(i);
|
||||||
|
|
||||||
|
lst.push_back(FieldTuple(name, val));
|
||||||
|
}
|
||||||
|
|
||||||
|
} while (false);
|
||||||
|
|
||||||
|
python::list pylst;
|
||||||
|
|
||||||
|
for (std::list<FieldTuple>::const_iterator it = lst.begin(); it != lst.end(); ++it)
|
||||||
|
pylst.append(python::make_tuple(it->get<0>(), it->get<1>()));
|
||||||
|
|
||||||
|
return pylst;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, const std::wstring &name)
|
kdlib::TypeInfoPtr TypeInfoAdapter::getElementAttr(kdlib::TypeInfo &typeInfo, const std::wstring &name)
|
||||||
|
@ -178,6 +178,12 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
|
|||||||
return typeInfo.getMethod(index);
|
return typeInfo.getMethod(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::wstring getMethodName(kdlib::TypeInfo &typeInfo, size_t index)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return typeInfo.getMethodName(index);
|
||||||
|
}
|
||||||
|
|
||||||
static size_t getBaseClassesCount(kdlib::TypeInfo &typeInfo )
|
static size_t getBaseClassesCount(kdlib::TypeInfo &typeInfo )
|
||||||
{
|
{
|
||||||
AutoRestorePyState pystate;
|
AutoRestorePyState pystate;
|
||||||
@ -306,6 +312,8 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
|
|||||||
|
|
||||||
static python::list getFields( kdlib::TypeInfo &typeInfo );
|
static python::list getFields( kdlib::TypeInfo &typeInfo );
|
||||||
|
|
||||||
|
static python::list getMethods(kdlib::TypeInfo &typeInfo);
|
||||||
|
|
||||||
static python::list getElementDir(kdlib::TypeInfo &typeInfo);
|
static python::list getElementDir(kdlib::TypeInfo &typeInfo);
|
||||||
|
|
||||||
static bool isZero(kdlib::TypeInfo &typeInfo) {
|
static bool isZero(kdlib::TypeInfo &typeInfo) {
|
||||||
|
@ -331,14 +331,17 @@ class TypeInfoTest( unittest.TestCase ):
|
|||||||
self.assertRaises(pykd.TypeException, pykd.baseTypes.UInt8B.arrayOf, 0xFFFFFFFFFFFFFFFF)
|
self.assertRaises(pykd.TypeException, pykd.baseTypes.UInt8B.arrayOf, 0xFFFFFFFFFFFFFFFF)
|
||||||
|
|
||||||
def testMethodCount(self):
|
def testMethodCount(self):
|
||||||
self.assertEqual( 12, target.module.type("classChild").getNumberMethods() )
|
self.assertEqual( 14, target.module.type("classChild").getNumberMethods() )
|
||||||
|
|
||||||
def testGetMethod(self):
|
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("childMethod").name() )
|
||||||
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").childMethod.name() )
|
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").childMethod.name() )
|
||||||
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").method(1).name() )
|
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").method(1).name() )
|
||||||
|
|
||||||
def testGteBaseClass(self):
|
def testMethods(self):
|
||||||
|
self.assertEqual( 14, len(target.module.type("classChild").methods()))
|
||||||
|
|
||||||
|
def testGetBaseClass(self):
|
||||||
classChild = target.module.type("classChild")
|
classChild = target.module.type("classChild")
|
||||||
self.assertEqual( ["classBase1", "classBase2"], [ classChild.baseClass(i).name() for i in range(classChild.getNumberBaseClasses()) ] )
|
self.assertEqual( ["classBase1", "classBase2"], [ classChild.baseClass(i).name() for i in range(classChild.getNumberBaseClasses()) ] )
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user