Commit 85028a9a authored by ussrhero's avatar ussrhero
Browse files

added TypeInfo.isConstField method (return True if a field is a const field)

parent 7d9b0faf
......@@ -917,6 +917,10 @@ void pykd_init()
"Return True if a field is a static field by field name")
.def("isStaticField", TypeInfoAdapter::isStaticFieldByIndex,
"Return True if a field is a static field by field name")
.def("isConstField", TypeInfoAdapter::isConstField,
"Return True if a field is a const field by field name")
.def("isConstField", TypeInfoAdapter::isConstFieldByIndex,
"Return True if a field is a const field by field name")
.def("bitOffset", TypeInfoAdapter::getBitOffset,
"Return bit field's offset")
.def("bitWidth", TypeInfoAdapter::getBitWidth,
......
......@@ -155,6 +155,19 @@ struct TypeInfoAdapter : public kdlib::TypeInfo {
return typeInfo->isStaticMember(index);
}
static bool isConstField(const kdlib::TypeInfoPtr &typeInfo, const std::wstring &name)
{
AutoRestorePyState pystate;
return typeInfo->isConstMember(name);
}
static bool isConstFieldByIndex(const kdlib::TypeInfoPtr &typeInfo, size_t index)
{
AutoRestorePyState pystate;
return typeInfo->isConstMember(index);
}
static kdlib::TypeInfoPtr getElementByName( kdlib::TypeInfo &typeInfo, const std::wstring &name )
{
AutoRestorePyState pystate;
......
......@@ -380,4 +380,9 @@ class TypeInfoTest( unittest.TestCase ):
def testIsStaticField(self):
ti = pykd.typeInfo("classChild")
self.assertTrue(ti.isStaticField("m_staticField"))
self.assertFalse(ti.isStaticField("m_baseField"))
\ No newline at end of file
self.assertFalse(ti.isStaticField("m_baseField"))
def testIsConstField(self):
ti = pykd.typeInfo("classChild")
self.assertTrue(ti.isStaticField("m_staticConst"))
self.assertFalse(ti.isConstField("m_staticConst"))
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment