mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-21 04:13:22 +08:00
[0.1.x] added : long converter for intBase class
git-svn-id: https://pykd.svn.codeplex.com/svn@71858 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
d778486d62
commit
43639b5476
@ -128,7 +128,9 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def( "__invert__", &intBase::invert )
|
.def( "__invert__", &intBase::invert )
|
||||||
.def( "__nonzero__", &intBase::nonzero )
|
.def( "__nonzero__", &intBase::nonzero )
|
||||||
.def( "__str__", &intBase::str )
|
.def( "__str__", &intBase::str )
|
||||||
.def( "__hex__", &intBase::hex );
|
.def( "__hex__", &intBase::hex )
|
||||||
|
.def( "__long__", &intBase::long_ )
|
||||||
|
.def( "__int__", &intBase::int_ );
|
||||||
|
|
||||||
python::class_<pykd::DebugClient, pykd::DebugClientPtr>("dbgClient", "Class representing a debugging session", python::no_init )
|
python::class_<pykd::DebugClient, pykd::DebugClientPtr>("dbgClient", "Class representing a debugging session", python::no_init )
|
||||||
.def( "addr64", &DebugClient::addr64,
|
.def( "addr64", &DebugClient::addr64,
|
||||||
|
@ -37,6 +37,15 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class VariantToPylong : public boost::static_visitor<python::object>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
template<typename T>
|
||||||
|
python::object operator()(T i ) const {
|
||||||
|
return python::long_( i );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class intBase {
|
class intBase {
|
||||||
@ -60,6 +69,16 @@ public:
|
|||||||
return boost::apply_visitor( VariantToHex(), getValue() );
|
return boost::apply_visitor( VariantToHex(), getValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
python::object
|
||||||
|
long_() {
|
||||||
|
return boost::apply_visitor( VariantToPylong(), getValue() );
|
||||||
|
}
|
||||||
|
|
||||||
|
python::object
|
||||||
|
int_() {
|
||||||
|
return boost::apply_visitor( VariantToPylong(), getValue() );
|
||||||
|
}
|
||||||
|
|
||||||
python::object eq( python::object& obj ) {
|
python::object eq( python::object& obj ) {
|
||||||
return boost::apply_visitor( VariantToPyobj(), getValue() ) == obj;
|
return boost::apply_visitor( VariantToPyobj(), getValue() ) == obj;
|
||||||
}
|
}
|
||||||
|
@ -142,5 +142,12 @@ class IntBaseTest( unittest.TestCase ):
|
|||||||
self.assertEqual( -0xFFFFFFFF, -intBase(0xFFFFFFFF) )
|
self.assertEqual( -0xFFFFFFFF, -intBase(0xFFFFFFFF) )
|
||||||
self.assertEqual( 0xFFFFFFFF, +intBase(0xFFFFFFFF) )
|
self.assertEqual( 0xFFFFFFFF, +intBase(0xFFFFFFFF) )
|
||||||
self.assertEqual( 0, ~intBase(0xFFFFFFFF) )
|
self.assertEqual( 0, ~intBase(0xFFFFFFFF) )
|
||||||
|
|
||||||
|
def testLongConvert( self ):
|
||||||
|
self.assertEqual( "100", "%d" % intBase(100) )
|
||||||
|
self.assertEqual( "FFFF", "%X" % intBase(0xFFFF) )
|
||||||
|
self.assertEqual( "-70000000000", "%d" % intBase(-70000000000) )
|
||||||
|
self.assertEqual( "FFFFFFFFFFFFFF", "%X" % intBase(0xFFFFFFFFFFFFFF) )
|
||||||
|
self.assertEqual( "0", "%d" % intBase(False) )
|
||||||
|
|
||||||
|
|
@ -54,8 +54,9 @@ if __name__ == "__main__":
|
|||||||
target.module.reload();
|
target.module.reload();
|
||||||
|
|
||||||
suite = getTestSuite()
|
suite = getTestSuite()
|
||||||
|
#suite = getTestSuite( "intbase.IntBaseTest.testLongConvert" )
|
||||||
#suite = getTestSuite( "typedvar.TypedVarTest.testStruct" )
|
#suite = getTestSuite( "typedvar.TypedVarTest.testStruct" )
|
||||||
|
|
||||||
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( suite )
|
unittest.TextTestRunner(stream=sys.stdout, verbosity=2).run( suite )
|
||||||
|
|
||||||
a = raw_input("\npress return\n")
|
#a = raw_input("\npress return\n")
|
Loading…
Reference in New Issue
Block a user