| |
1 /// Helpers to transmit nanobind C++ → Python bindings Python → Rust → C++. |
| |
2 #include <Python.h> |
| |
3 #include <nanobind/nanobind.h> |
| |
4 |
| |
5 #include "pointsource_pde/include/dolfinx_access/nanobind_helpers.h" |
| |
6 |
| |
7 using namespace nanobind; |
| |
8 |
| |
9 namespace dolfinx_access { |
| |
10 bool check_Function_f64(const PyObject* obj) { |
| |
11 auto handle = nanobind::handle(obj); |
| |
12 return nanobind::isinstance<Function_f64>(handle); |
| |
13 } |
| |
14 |
| |
15 const Function_f64* cast_Function_f64(const PyObject* obj) { |
| |
16 auto handle = nanobind::handle(obj); |
| |
17 return nanobind::cast<const Function_f64*>(handle); |
| |
18 } |
| |
19 |
| |
20 Function_f64* cast_mut_Function_f64(PyObject* obj) { |
| |
21 auto handle = nanobind::handle(obj); |
| |
22 return nanobind::cast<Function_f64*>(handle); |
| |
23 } |
| |
24 |
| |
25 PyObject* wrap_Function_f64(Function_f64* f) { |
| |
26 return nanobind::cast(f).release().ptr(); |
| |
27 } |
| |
28 |
| |
29 } // namespace dolfinx_access |