[0.3.x] updated: typeInfo for function prototype( args-type and calling convention)

git-svn-id: https://pykd.svn.codeplex.com/svn@84449 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
SND\EreTIk_cp 2013-07-24 12:22:19 +00:00 committed by Mikhail I. Izmestev
parent 727c8b33bb
commit 0eeb81b022
2 changed files with 76 additions and 10 deletions

View File

@ -455,6 +455,26 @@ BOOST_PYTHON_MODULE( pykd )
"Return pointer to the type" ) "Return pointer to the type" )
.def( "arrayOf", &kdlib::TypeInfo::arrayOf, .def( "arrayOf", &kdlib::TypeInfo::arrayOf,
"Return array of the type" ) "Return array of the type" )
.def( "isArray", &kdlib::TypeInfo::isArray,
"Return flag: type is array" )
.def( "isPointer", &kdlib::TypeInfo::isPointer,
"Return flag: type is pointer" )
.def( "isVoid", &kdlib::TypeInfo::isVoid,
"Return flag: type is void" )
.def( "isBase", &kdlib::TypeInfo::isBase,
"Return flag: type is base" )
.def( "isUserDefined", &kdlib::TypeInfo::isUserDefined,
"Return flag: type is UDT" )
.def( "isEnum", &kdlib::TypeInfo::isEnum,
"Return flag: type is enum" )
.def( "isBitField", &kdlib::TypeInfo::isBitField,
"Return flag: type is bit field" )
.def( "isFunction", &kdlib::TypeInfo::isFunction,
"Return flag: type is function" )
.def( "isConstant", &kdlib::TypeInfo::isConstant,
"Return flag: type is constant" )
.def( "getCallingConvention", &kdlib::TypeInfo::getCallingConvention,
"Returns an indicator of a methods calling convention: callingConvention" )
.def( "__str__", &kdlib::TypeInfo::str, .def( "__str__", &kdlib::TypeInfo::str,
"Return type as a printable string" ) "Return type as a printable string" )
.def( "__getattr__", TypeInfoAdapter::getElementByName ) .def( "__getattr__", TypeInfoAdapter::getElementByName )
@ -659,6 +679,33 @@ BOOST_PYTHON_MODULE( pykd )
.value("NoDebuggee", kdlib::DebugStatusNoDebuggee ) .value("NoDebuggee", kdlib::DebugStatusNoDebuggee )
.export_values(); .export_values();
python::enum_<kdlib::CallingConventionType>("callingConvention", "Calling convention for a function")
.value("NearC", kdlib::CallConv_NearC )
.value("FarC", kdlib::CallConv_FarC )
.value("NearPascal", kdlib::CallConv_NearPascal )
.value("FarPascal", kdlib::CallConv_FarPascal )
.value("NearFast", kdlib::CallConv_NearFast )
.value("FarFast", kdlib::CallConv_FarFast )
.value("Skipped", kdlib::CallConv_Skipped )
.value("NearStd", kdlib::CallConv_NearStd )
.value("FarStd0", kdlib::CallConv_FarStd )
.value("NearSys", kdlib::CallConv_NearSys )
.value("FarSys", kdlib::CallConv_FarSys )
.value("ThisCall", kdlib::CallConv_ThisCall )
.value("MipsCall", kdlib::CallConv_MipsCall )
.value("Generic", kdlib::CallConv_Generic )
.value("AlphaCall ", kdlib::CallConv_AlphaCall )
.value("PpcCall", kdlib::CallConv_PpcCall )
.value("ShCall", kdlib::CallConv_ShCall )
.value("ArmCall", kdlib::CallConv_ArmCall )
.value("Am33Call", kdlib::CallConv_Am33Call )
.value("TriCall", kdlib::CallConv_TriCall )
.value("Sh5Call", kdlib::CallConv_Sh5Call )
.value("M32RCall", kdlib::CallConv_M32RCall )
.value("ClrCall", kdlib::CallConv_ClrCall )
.value("Inline", kdlib::CallConv_Inline )
.export_values();
python::class_<EventHandler, EventHandlerPtr, boost::noncopyable>( python::class_<EventHandler, EventHandlerPtr, boost::noncopyable>(
"eventHandler", "Base class for overriding and handling debug notifications" ) "eventHandler", "Base class for overriding and handling debug notifications" )
.def( "onBreakpoint", &EventHandler::onBreakpoint, .def( "onBreakpoint", &EventHandler::onBreakpoint,

View File

@ -240,3 +240,22 @@ class TypeInfoTest( unittest.TestCase ):
ti = pykd.typeInfo("UInt8B").arrayOf(10) ti = pykd.typeInfo("UInt8B").arrayOf(10)
self.assertTrue( "UInt8B[10]", ti.name() ) self.assertTrue( "UInt8B[10]", ti.name() )
def testFunction(self):
functype = target.module.typedVar( "CdeclFuncPtr" ).type().deref()
self.assertTrue( functype.isFunction() )
def testFunctionArgs(self):
functype = target.module.typedVar( "CdeclFuncPtr" ).type().deref()
self.assertEqual( [ arg.name() for arg in functype ], ["Int4B", "Float"] )
def testFunctionCallConv(self):
functype = target.module.typedVar( "CdeclFuncPtr" ).type().deref()
self.assertEqual( functype.getCallingConvention(), pykd.callingConvention.NearC )
def testFunctionThis(self):
functype = target.module.typedVar( "MethodPtr" ).type().deref()
self.assertEqual( [ arg.name() for arg in functype ], ["FuncTestClass*"] )
functype = target.module.typedVar( "CdeclStaticMethodPtr" ).type().deref()
self.assertEqual( [ arg.name() for arg in functype ], [] )