Switch the bindings to nanobind (and update the CI)

This commit is contained in:
Romain Thomas
2023-07-09 21:33:43 +02:00
parent 7e387675ac
commit e37ffa9ec8
377 changed files with 12540 additions and 15730 deletions
+42 -46
View File
@@ -13,62 +13,58 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "pyMachO.hpp"
#include "MachO/pyMachO.hpp"
#include <nanobind/stl/pair.h>
#include <nanobind/stl/string.h>
#include <nanobind/stl/vector.h>
#include "LIEF/MachO/utils.hpp"
#include "LIEF/MachO/FatBinary.hpp"
#include "LIEF/MachO/Binary.hpp"
namespace LIEF {
namespace MachO {
namespace LIEF::MachO::py {
void init_utils(py::module& m) {
void init_utils(nb::module_& m) {
nb::module_ lief_mod = nb::module_::import_(LIEF_MOD_NAME);
m.def("is_macho",
static_cast<bool (*)(const std::string&)>(&is_macho),
"Check if the given file is a ``MachO`` (from filename)",
"filename"_a);
lief_mod.def("is_macho",
nb::overload_cast<const std::string&>(&is_macho),
"Check if the given file is a ``MachO`` (from filename)"_doc,
"filename"_a);
lief_mod.def("is_macho",
nb::overload_cast<const std::vector<uint8_t>&>(&is_macho),
"Check if the given raw data is a ``MachO``"_doc,
"raw"_a);
m.def("is_macho",
static_cast<bool (*)(const std::vector<uint8_t>&)>(&is_macho),
"Check if the given raw data is a ``MachO``",
"raw"_a);
m.def("is_fat", &is_fat,
"Check if the given Mach-O is fat"_doc,
"file"_a);
m.def("is_fat",
&is_fat,
"Check if the given Mach-O is fat",
"file"_a);
m.def("is_64",
&is_64,
"Check if the given Mach-O is 64-bits",
"file"_a);
m.def("check_layout",
[] (const Binary& bin) {
std::string on_error;
bool is_valid = check_layout(bin, &on_error);
return std::pair<bool, std::string>{is_valid, on_error};
},
"Check the layout of the given Mach-O binary. It checks if it can be signed "
"according to ``cctools-921/libstuff/checkout.c``",
"file"_a);
m.def("check_layout",
[] (const FatBinary& bin) {
std::string on_error;
bool is_valid = check_layout(bin, &on_error);
return std::pair<bool, std::string>{is_valid, on_error};
},
R"delim(
Check the layout of the given FAT Mach-O by checking individually the layout
of the binaries embedded in the FAT.
)delim",
"file"_a);
m.def("is_64", &is_64,
"Check if the given Mach-O is 64-bits"_doc,
"file"_a);
m.def("check_layout",
[] (const Binary& bin) {
std::string on_error;
const bool is_valid = check_layout(bin, &on_error);
return std::pair<bool, std::string>{is_valid, on_error};
},
"Check the layout of the given Mach-O binary. It checks if it can be signed "
"according to ``cctools-921/libstuff/checkout.c``"_doc,
"file"_a);
m.def("check_layout",
[] (const FatBinary& bin) {
std::string on_error;
const bool is_valid = check_layout(bin, &on_error);
return std::pair<bool, std::string>{is_valid, on_error};
},
R"delim(
Check the layout of the given FAT Mach-O by checking individually the layout
of the binaries embedded in the FAT.
)delim"_doc,
"file"_a);
}
} // namespace Mach-O
}