Skip to content

Commit

Permalink
Fix typo and update the changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
romainthomas committed Nov 18, 2023
1 parent 529d5a8 commit df97777
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 38 deletions.
23 changes: 10 additions & 13 deletions api/python/lief/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class ARCHITECTURES:
def value(self) -> int: ...

class Binary(Object):
class FORMATS:
ELF: ClassVar[Binary.FORMATS] = ...
MACHO: ClassVar[Binary.FORMATS] = ...
OAT: ClassVar[Binary.FORMATS] = ...
PE: ClassVar[Binary.FORMATS] = ...
UNKNOWN: ClassVar[Binary.FORMATS] = ...
__name__: Any
def __init__(self, *args, **kwargs) -> None: ...

class VA_TYPES:
AUTO: ClassVar[Binary.VA_TYPES] = ...
RVA: ClassVar[Binary.VA_TYPES] = ...
Expand Down Expand Up @@ -81,7 +90,7 @@ class Binary(Object):
@property
def exported_functions(self) -> list[lief.Function]: ...
@property
def format(self) -> lief.EXE_FORMATS: ...
def format(self) -> lief.Binary.FORMATS: ...
@property
def has_nx(self) -> bool: ...
@property
Expand Down Expand Up @@ -112,18 +121,6 @@ class ENDIANNESS:
@property
def value(self) -> int: ...

class EXE_FORMATS:
ELF: ClassVar[EXE_FORMATS] = ...
MACHO: ClassVar[EXE_FORMATS] = ...
PE: ClassVar[EXE_FORMATS] = ...
UNKNOWN: ClassVar[EXE_FORMATS] = ...
__name__: Any
def __init__(self, *args, **kwargs) -> None: ...
@staticmethod
def from_value(arg: int, /) -> lief.EXE_FORMATS: ...
@property
def value(self) -> int: ...

class Function(Symbol):
class FLAGS:
CONSTRUCTOR: ClassVar[Function.FLAGS] = ...
Expand Down
4 changes: 2 additions & 2 deletions api/python/src/Abstract/pyBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void create<Binary>(nb::module_& m) {
# undef ENTRY

# define ENTRY(X) .value(to_string(Binary::FORMATS::X), Binary::FORMATS::X)
nb::enum_<Binary::FORMATS>(pybinary, "VA_TYPES")
nb::enum_<Binary::FORMATS>(pybinary, "FORMATS")
ENTRY(UNKNOWN)
ENTRY(ELF)
ENTRY(PE)
Expand All @@ -72,7 +72,7 @@ void create<Binary>(nb::module_& m) {
pybinary
.def_prop_ro("format",
&Binary::format,
"File format " RST_CLASS_REF(lief.EXE_FORMATS) " of the underlying binary."_doc)
"File format (:class:`~.FORMATS`) of the underlying binary."_doc)

.def_prop_ro("is_pie",
&Binary::is_pie,
Expand Down
3 changes: 0 additions & 3 deletions doc/sphinx/api/cpp/abstract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ Function
Enums
*****

.. doxygenenum:: LIEF::EXE_FORMATS
:project: lief

.. doxygenenum:: LIEF::OBJECT_TYPES
:project: lief

Expand Down
9 changes: 0 additions & 9 deletions doc/sphinx/api/python/abstract.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,6 @@ Function
Enums
*****


Executable formats
~~~~~~~~~~~~~~~~~~

.. autoclass:: lief.EXE_FORMATS

----------


Object types
~~~~~~~~~~~~

Expand Down
12 changes: 12 additions & 0 deletions doc/sphinx/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,18 @@ Changelog
pe = lief.PE.parse("pe.exe", config)
:Abstraction:

* `LIEF::EXE_FORMATS` is now scoped in `LIEF::Binary::FORMATS`
* All the `Binary` classes now implement `classof`:

.. code-block:: cpp
std::unique_ptr<LIEF::Binary> bin = LIEF::Parser::parse("...");
if (LIEF::PE::Binary::classof(bin.get())) {
auto& pe_file = static_cast<LIEF::PE::Binary&>(*bin);
}
:General Design:

* Python parser functions (like: :func:`lief.PE.parse`) now accept `os.PathLike`
Expand Down
8 changes: 0 additions & 8 deletions include/LIEF/Abstract/enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,6 @@

namespace LIEF {

//! LIEF executable format
enum EXE_FORMATS {
FORMAT_UNKNOWN = 0,
FORMAT_ELF = 1, /// ELF. See: LIEF::ELF
FORMAT_PE = 2, /// PE. See: LIEF::PE
FORMAT_MACHO = 3, /// Mach-O. See: LIEF::MachO
};

enum OBJECT_TYPES {
TYPE_NONE = 0,
TYPE_EXECUTABLE = 1,
Expand Down
6 changes: 3 additions & 3 deletions tests/abstract/test_abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ def test_endianness():

def test_format():
binary = lief.parse(get_sample('ELF/ELF32_x86_binary_ls.bin'))
binary.abstract.format == lief.EXE_FORMATS.ELF
binary.abstract.format == lief.Binary.FORMATS.ELF

binary = lief.parse(get_sample('MachO/MachO64_x86-64_binary_id.bin'))
binary.abstract.format == lief.EXE_FORMATS.MACHO
binary.abstract.format == lief.Binary.FORMATS.MACHO

binary = lief.parse(get_sample('PE/PE64_x86-64_binary_ConsoleApplication1.exe'))
binary.abstract.format == lief.EXE_FORMATS.PE
binary.abstract.format == lief.Binary.FORMATS.PE

def test_pie():
binary = lief.parse(get_sample('ELF/ELF32_ARM_binary-pie_ls.bin'))
Expand Down

0 comments on commit df97777

Please sign in to comment.