diff --git a/src/papi/lz4/module.cpp b/src/papi/lz4/module.cpp index 6ee5e2f..716e95b 100644 --- a/src/papi/lz4/module.cpp +++ b/src/papi/lz4/module.cpp @@ -11,33 +11,33 @@ static test_initializer modules([](py::module &m) { - using namespace gsl; using namespace lz4; m.def_submodule("lz4") .def("VERSION_NUMBER", VERSION_NUMBER) .def("VERSION", [](){ - return py::make_tuple(VERSION_MAJOR(), VERSION_MINOR(), VERSION_RELEASE()); - }) + return py::make_tuple(VERSION_MAJOR(), VERSION_MINOR(), VERSION_RELEASE()); + }) .def("__version__", [](){ - return py::str(VERSION_STRING()); - }) - .def("compress", [](const py::bytes& buffer){ - - std::string source{buffer}; - auto size = lz4::api::compressBound(source.length()); + return py::str(VERSION_STRING()); + }) + .def("compress", compress) + ; +}); +py::bytes lz4::compress(const py::bytes& buffer) +{ + std::string source{buffer}; + auto size = api::compressBound(source.length()); - std::vector dest(size); - auto res = lz4::api::compress_default(source, dest); + std::vector dest(size); - if (res == 0) { - throw std::exception("compression failed"); - } + auto res = api::compress_default(source, dest); + if (res == 0) { + throw std::exception("compression failed"); + } - return py::bytes(dest.data(), res); - }) - ; -}); + return py::bytes(dest.data(), res); +}; diff --git a/src/papi/lz4/module.h b/src/papi/lz4/module.h index 9c9bc60..0bbdc0d 100644 --- a/src/papi/lz4/module.h +++ b/src/papi/lz4/module.h @@ -6,12 +6,18 @@ #include "api.h" +namespace py = pybind11; +using namespace pybind11::literals; + namespace lz4 { + class context { context(); ~context(); }; + + py::bytes compress(const py::bytes& buffer); }; #endif // __CINT_LZ4_MODULE__ \ No newline at end of file