diff --git a/pykd/pymod.cpp b/pykd/pymod.cpp index 6191413..f18f422 100644 --- a/pykd/pymod.cpp +++ b/pykd/pymod.cpp @@ -832,6 +832,11 @@ BOOST_PYTHON_MODULE( pykd ) .def("__getitem__", TypedVarAdapter::getElementByIndex ) .def("__dir__", TypedVarAdapter::getElementsDir) //.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) diff --git a/pykd/pytypedvar.h b/pykd/pytypedvar.h index 4f7caf0..00d190f 100644 --- a/pykd/pytypedvar.h +++ b/pykd/pytypedvar.h @@ -162,6 +162,17 @@ struct TypedVarAdapter { } 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