/* Copyright 2017 R. Thomas * Copyright 2017 Quarkslab * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "pyAbstract.hpp" #include "LIEF/Abstract/Symbol.hpp" #include #include #define PY_ENUM(x) LIEF::to_string(x), x namespace LIEF { template using getter_t = T (Function::*)(void) const; template using setter_t = void (Function::*)(T); template<> void create(py::module& m) { py::class_ pyfunction(m, "Function"); py::enum_(pyfunction, "FLAGS") .value(PY_ENUM(Function::FLAGS::IMPORTED)) .value(PY_ENUM(Function::FLAGS::EXPORTED)) .value(PY_ENUM(Function::FLAGS::CONSTRUCTOR)) .value(PY_ENUM(Function::FLAGS::DESTRUCTOR)) .value(PY_ENUM(Function::FLAGS::DEBUG)); pyfunction .def(py::init()) .def(py::init()) .def(py::init()) .def(py::init()) .def_property("address", static_cast>(&Function::address), static_cast>(&Function::address), "Symbol's value") .def("__str__", [] (const Function& f) { std::ostringstream stream; stream << f; std::string str = stream.str(); return str; }); } }