mirror of
https://github.com/lief-project/LIEF
synced 2026-06-08 15:30:44 +00:00
Improve API of ELF's Section
API changes: - 'has_flag' renamed to 'has' - 'add_flag' renamed to 'add' - 'remove_flag' renamed to 'remove' - operator+= to add a flag - added - operator-= to remove a flag - added - 'has' for Segment object - added
This commit is contained in:
@@ -103,12 +103,30 @@ void init_ELF_Section_class(py::module& m) {
|
||||
"Return segment(s) associated with the given section",
|
||||
py::return_value_policy::reference_internal)
|
||||
|
||||
.def("__contains__",
|
||||
[] (const Section §ion, SECTION_FLAGS flag)
|
||||
{
|
||||
return section.has_flag(flag);
|
||||
}, "Test if the current section has the given flag")
|
||||
|
||||
.def("add",
|
||||
&Section::add,
|
||||
"Add the given " RST_CLASS_REF(lief.ELF.SECTION_FLAGS) " to the list of "
|
||||
":attr:`~lief.ELF.Section.flags`",
|
||||
"flag"_a)
|
||||
|
||||
.def("remove",
|
||||
&Section::remove,
|
||||
"Remove the given " RST_CLASS_REF(lief.ELF.SECTION_FLAGS) " to the list of "
|
||||
":attr:`~lief.ELF.Section.flags`",
|
||||
"flag"_a)
|
||||
|
||||
|
||||
.def("has",
|
||||
static_cast<bool (Section::*)(SECTION_FLAGS) const>(&Section::has),
|
||||
"Check if the given " RST_CLASS_REF(lief.ELF.SECTION_FLAGS) " is present",
|
||||
"flag"_a)
|
||||
|
||||
.def("has",
|
||||
static_cast<bool (Section::*)(const Segment&) const>(&Section::has),
|
||||
"Check if the given " RST_CLASS_REF(lief.ELF.Segment) " is present "
|
||||
"in :attr:`~lief.ELF.Section.segments`",
|
||||
"segment"_a)
|
||||
|
||||
.def("__eq__", &Section::operator==)
|
||||
.def("__ne__", &Section::operator!=)
|
||||
@@ -117,6 +135,19 @@ void init_ELF_Section_class(py::module& m) {
|
||||
return LIEF::Hash::hash(section);
|
||||
})
|
||||
|
||||
.def(py::self += SECTION_FLAGS())
|
||||
.def(py::self -= SECTION_FLAGS())
|
||||
|
||||
.def("__contains__",
|
||||
static_cast<bool (Section::*)(SECTION_FLAGS) const>(&Section::has),
|
||||
"Check if the given " RST_CLASS_REF(lief.ELF.SECTION_FLAGS) " is present")
|
||||
|
||||
|
||||
.def("__contains__",
|
||||
static_cast<bool (Section::*)(const Segment&) const>(&Section::has),
|
||||
"Check if the given " RST_CLASS_REF(lief.ELF.Segment) " is present "
|
||||
"in :attr:`~lief.ELF.Section.segments`")
|
||||
|
||||
.def("__str__",
|
||||
[] (const Section& section)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user