Skip to content

Commit 01b4ec4

Browse files
committed
cleanup
1 parent 5261c53 commit 01b4ec4

File tree

1 file changed

+14
-59
lines changed

1 file changed

+14
-59
lines changed

src/export_pyjs_module.cpp

Lines changed: 14 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,17 @@ namespace em = emscripten;
1818
namespace pyjs
1919
{
2020

21-
struct LoopContext
22-
{
23-
py::object m_callback;
24-
bool m_cancel_loop_on_error = true; // default to true
25-
bool m_exit_loop = false;
26-
27-
LoopContext(py::object callback, bool cancel_loop_on_error)
28-
: m_callback(std::move(callback)), m_cancel_loop_on_error(cancel_loop_on_error), m_exit_loop(false) {}
29-
};
30-
31-
21+
// struct LoopContext
22+
// {
23+
// py::object m_callback;
24+
// bool m_cancel_loop_on_error = true; // default to true
25+
// bool m_exit_loop = false;
26+
27+
// LoopContext(py::object callback, bool cancel_loop_on_error)
28+
// : m_callback(std::move(callback)), m_cancel_loop_on_error(cancel_loop_on_error), m_exit_loop(false) {}
29+
// };
3230

3331

34-
// void wrapped_callback_without_cancel(void* cb_ptr) {
35-
// // Reinterpret the void pointer back to a PyObject pointer
36-
// auto py_object = reinterpret_cast<PyObject*>(cb_ptr);
37-
// // We can use PyObject_CallObject to call the Python function
38-
// if (PyObject_CallNoArgs(py_object) == nullptr) {
39-
// // If the call fails, we can print the error
40-
// std::cerr << "Error calling Python callback." << std::endl;
41-
// PyErr_Print();
42-
43-
// }
44-
// };
4532
void wrapped_callback(void* cb_ptr) {
4633
// Reinterpret the void pointer back to a PyObject pointer
4734
auto py_object = reinterpret_cast<PyObject*>(cb_ptr);
@@ -75,14 +62,12 @@ namespace pyjs
7562

7663

7764

78-
// class for loop context
79-
py::class_<LoopContext>(pyjs_module, "LoopContext")
80-
.def(py::init<py::object, bool>(), py::arg("callback"), py::arg("cancel_loop_on_error") = true)
81-
.def_readwrite("exit_loop", &LoopContext::m_exit_loop)
82-
;
65+
// // class for loop context
66+
// py::class_<LoopContext>(pyjs_module, "LoopContext")
67+
// .def(py::init<py::object, bool>(), py::arg("callback"), py::arg("cancel_loop_on_error") = true)
68+
// .def_readwrite("exit_loop", &LoopContext::m_exit_loop)
69+
// ;
8370

84-
85-
8671

8772

8873
// Export main loop callbacks
@@ -114,36 +99,6 @@ namespace pyjs
11499
// This will set a no-op main loop
115100
emscripten_set_main_loop(noop_callback, 1, false); // set a no-op loop to avoid errors
116101
});
117-
118-
119-
// pyjs_module.def("set_main_loop_callback_hl", [](py::handle & callback, int fps) {
120-
121-
// // get a PyObject * from the handle
122-
// void * handle_ptr = reinterpret_cast<void*>(&callback);
123-
124-
125-
126-
// // create a lambda without any caputres taking the callback pointer
127-
// auto wrapped_callback = [](void* cb_ptr) {
128-
129-
130-
// py::handle* handle = reinterpret_cast<py::handle*>(cb_ptr);
131-
132-
133-
// // We can use PyObject_CallObject to call the Python function
134-
135-
// };
136-
137-
// // use emscripten_set_main_loop_arg
138-
// emscripten_set_main_loop_arg(
139-
// wrapped_callback,
140-
// callback_ptr, // pass the callback pointer as argument
141-
// fps, // frames per second
142-
// false
143-
// );
144-
// });
145-
146-
147102

148103
}
149104

0 commit comments

Comments
 (0)