mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.3.x] added : __bool__ operator for typedVar class
git-svn-id: https://pykd.svn.codeplex.com/svn@90968 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
c971656625
commit
4ea9cf304e
@ -832,6 +832,11 @@ BOOST_PYTHON_MODULE( pykd )
|
|||||||
.def("__getitem__", TypedVarAdapter::getElementByIndex )
|
.def("__getitem__", TypedVarAdapter::getElementByIndex )
|
||||||
.def("__dir__", TypedVarAdapter::getElementsDir)
|
.def("__dir__", TypedVarAdapter::getElementsDir)
|
||||||
//.def("__getitem__", &kdlib::TypedVar::getElementByIndexPtr )
|
//.def("__getitem__", &kdlib::TypedVar::getElementByIndexPtr )
|
||||||
|
#if PY_VERSION_HEX >= 0x03000000
|
||||||
|
.def("__bool__", TypedVarAdapter::isNotZero)
|
||||||
|
#else
|
||||||
|
.def("__iszero__", TypedVarAdapter::isZero)
|
||||||
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
python::class_<BaseTypesEnum>("baseTypes", "base types enumeration", boost::python::no_init)
|
python::class_<BaseTypesEnum>("baseTypes", "base types enumeration", boost::python::no_init)
|
||||||
|
@ -162,6 +162,17 @@ struct TypedVarAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static python::list getElementsDir(kdlib::TypedVar& typedVar);
|
static python::list getElementsDir(kdlib::TypedVar& typedVar);
|
||||||
|
|
||||||
|
static bool isZero(kdlib::TypedVar& typedVar)
|
||||||
|
{
|
||||||
|
AutoRestorePyState pystate;
|
||||||
|
return typedVar.getValue() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool isNotZero(kdlib::TypedVar& typedVar)
|
||||||
|
{
|
||||||
|
return !isZero(typedVar);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace pykd
|
} // end namespace pykd
|
||||||
|
Loading…
Reference in New Issue
Block a user