mirror of
https://github.com/ivellioscolin/pykd.git
synced 2025-04-20 03:23:23 +08:00
[0.3.x] added : __dir__ method for typedVar ( return list of fields name )
git-svn-id: https://pykd.svn.codeplex.com/svn@90852 9b283d60-5439-405e-af05-b73fd8c4d996
This commit is contained in:
parent
63e824d50a
commit
a18dda466f
@ -773,6 +773,7 @@ BOOST_PYTHON_MODULE( pykd )
|
||||
.def( "__str__", TypedVarAdapter::print )
|
||||
.def("__len__", TypedVarAdapter::getElementCount )
|
||||
.def("__getitem__", TypedVarAdapter::getElementByIndex )
|
||||
.def("__dir__", TypedVarAdapter::getElementsDir)
|
||||
//.def("__getitem__", &kdlib::TypedVar::getElementByIndexPtr )
|
||||
;
|
||||
|
||||
|
@ -97,5 +97,31 @@ python::list TypedVarAdapter::getFields( kdlib::TypedVar& typedVar )
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
python::list TypedVarAdapter::getElementsDir(kdlib::TypedVar& typedVar)
|
||||
{
|
||||
std::list<std::wstring> lst;
|
||||
|
||||
do {
|
||||
|
||||
AutoRestorePyState pystate;
|
||||
|
||||
for (size_t i = 0; i < typedVar.getElementCount(); ++i)
|
||||
{
|
||||
std::wstring name = typedVar.getElementName(i);
|
||||
lst.push_back(name);
|
||||
}
|
||||
|
||||
} while (false);
|
||||
|
||||
python::list pylst;
|
||||
|
||||
for (std::list<std::wstring>::const_iterator it = lst.begin(); it != lst.end(); ++it)
|
||||
pylst.append(*it);
|
||||
|
||||
return pylst;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
} // namesapce pykd
|
||||
|
||||
|
@ -124,6 +124,7 @@ struct TypedVarAdapter {
|
||||
return typedVar.deref();
|
||||
}
|
||||
|
||||
static python::list getElementsDir(kdlib::TypedVar& typedVar);
|
||||
};
|
||||
|
||||
} // end namespace pykd
|
||||
|
Loading…
Reference in New Issue
Block a user