[0.3.x] added : typedVar.method has optional argument 'prototype' to work with overloaded methods

git-svn-id: https://pykd.svn.codeplex.com/svn@91089 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\ussrhero_cp 2017-01-05 10:03:10 +00:00 committed by Mikhail I. Izmestev
parent d1a4b3e089
commit 03ff35d64f
4 changed files with 10 additions and 4 deletions

View File

@ -938,7 +938,7 @@ BOOST_PYTHON_MODULE( pykd )
"Return list of tuple ( filedName, fieldOffset, fieldValue )" )
.def( "fieldName", TypedVarAdapter::getElementName,
"Return name of struct field by index" )
.def("method", TypedVarAdapter::getMethodByName,
.def("method", TypedVarAdapter::getMethodByName, ( python::arg("name"), python::arg("prototype") = "" ),
"Return method of class as an object attribute" )
.def("deref",TypedVarAdapter::deref,
"Return value by pointer" )

View File

@ -129,10 +129,10 @@ struct TypedVarAdapter {
return typedVar.getElement( index );
}
static kdlib::TypedVarPtr getMethodByName(kdlib::TypedVar& typedVar, const std::wstring &name)
static kdlib::TypedVarPtr getMethodByName(kdlib::TypedVar& typedVar, const std::wstring &name, const std::wstring &prototype = L"")
{
AutoRestorePyState pystate;
return typedVar.getMethod(name);
return typedVar.getMethod(name, prototype);
}
static std::wstring print( kdlib::TypedVar& typedVar )

View File

@ -401,12 +401,18 @@ class TypedVarTest( unittest.TestCase ):
def testCallMethod(self):
g_classChild = target.module.typedVar("g_classChild")
self.assertEqual( 1000*5, g_classChild.method("childMethod").call(10) )
self.assertEqual( 1000*5, g_classChild.childMethod(10) )
def testCallStdStr(self):
g_stdString = target.module.typedVar("g_stdString")
self.assertEqual( "testString".find('S'), g_stdString.find_first_of(ord('S'), 0) )
def testCallOverloadMethod(self):
g_classChild = target.module.typedVar("g_classChild")
self.assertEqual( 10*10, g_classChild.method("overloadMethod", "Int4B(__thiscall)(Int4B)").call(10))
self.assertEqual( 5*8, g_classChild.method("overloadMethod", "Int4B(__thiscall)(Int4B,Int4B)").call(5,8))
def testGetTypedVar(self):
addr = pykd.getOffset("g_structTest")
self.assertTrue( None != target.module.type( "structTest" ).getTypedVar(addr) )

View File

@ -329,7 +329,7 @@ class TypeInfoTest( unittest.TestCase ):
self.assertRaises(pykd.TypeException, pykd.baseTypes.UInt8B.arrayOf, 0xFFFFFFFFFFFFFFFF)
def testMethodCount(self):
self.assertEqual( 8, target.module.type("classChild").getNumberMethods() )
self.assertEqual( 12, target.module.type("classChild").getNumberMethods() )
def testGetMethod(self):
self.assertEqual( "Int4B(__thiscall classChild::)(Int4B)", target.module.type("classChild").method("childMethod").name() )