Skip to content

Commit 4627796

Browse files
committed
checkstyle
1 parent 0ed6cce commit 4627796

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

python-pybind/src/compiler/py_dictionary_compilers.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -15,41 +15,41 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include <pybind11/pybind11.h>
1918
#include <pybind11/functional.h>
19+
#include <pybind11/pybind11.h>
2020

2121
#include "keyvi/dictionary/dictionary_types.h"
2222

2323
namespace py = pybind11;
2424
namespace kd = keyvi::dictionary;
2525

2626
void init_keyvi_dictionary_compilers(const py::module_ &m) {
27-
#define CREATE_COMPILER(compiler, name) \
28-
py::class_<compiler>(m, name) \
29-
.def(py::init<>()) \
30-
.def("__enter__", [](compiler &c) { return &c; }) \
31-
.def("__exit__", [](compiler &c, void *exc_type, void *exc_value, void *traceback) { c.Compile(); }) \
32-
.def("__setitem__", &compiler::Add) \
33-
.def("add", &compiler::Add) \
34-
.def("compile", [](compiler &c, std::function<void(const size_t a, const size_t b)> progress_callback) { \
35-
if (progress_callback == nullptr) { \
36-
c.Compile(); \
37-
return; \
38-
} \
39-
auto progress_compiler_callback = [](size_t a, size_t b, void *user_data) { \
40-
auto py_callback = *reinterpret_cast<std::function<void(const size_t, const size_t)>*>(user_data); \
41-
py_callback(a,b); \
42-
}; \
43-
void* user_data = reinterpret_cast<void*>(&progress_callback); \
44-
c.Compile(progress_compiler_callback, user_data); \
45-
}, py::arg("progress_callback") = static_cast<std::function<void(const size_t a, const size_t b)> *>(nullptr)) \
46-
.def("set_manifest", &compiler::SetManifest) \
47-
.def("write_to_file", &compiler::WriteToFile);
27+
#define CREATE_COMPILER(compiler, name) \
28+
py::class_<compiler>(m, name) \
29+
.def(py::init<>()) \
30+
.def("__enter__", [](compiler &c) { return &c; }) \
31+
.def("__exit__", [](compiler &c, void *exc_type, void *exc_value, void *traceback) { c.Compile(); }) \
32+
.def("__setitem__", &compiler::Add) \
33+
.def("add", &compiler::Add) \
34+
.def( \
35+
"compile", \
36+
[](compiler &c, std::function<void(const size_t a, const size_t b)> progress_callback) { \
37+
if (progress_callback == nullptr) { \
38+
c.Compile(); \
39+
return; \
40+
} \
41+
auto progress_compiler_callback = [](size_t a, size_t b, void *user_data) { \
42+
auto py_callback = *reinterpret_cast<std::function<void(const size_t, const size_t)> *>(user_data); \
43+
py_callback(a, b); \
44+
}; \
45+
void *user_data = reinterpret_cast<void *>(&progress_callback); \
46+
c.Compile(progress_compiler_callback, user_data); \
47+
}, \
48+
py::arg("progress_callback") = static_cast<std::function<void(const size_t a, const size_t b)> *>(nullptr)) \
49+
.def("set_manifest", &compiler::SetManifest) \
50+
.def("write_to_file", &compiler::WriteToFile);
4851

4952
CREATE_COMPILER(kd::CompletionDictionaryCompiler, "CompletionDictionaryCompiler");
5053

51-
#undef CREATE_COMPILER
54+
#undef CREATE_COMPILER
5255
}
53-
54-
//cdef void progress_compiler_callback(size_t a, size_t b, void* py_callback) noexcept with gil:
55-
// (<object>py_callback)(a, b)

0 commit comments

Comments
 (0)