/// Helpers to transmit nanobind C++ → Python bindings Python → Rust → C++.
#include <Python.h>
#include <nanobind/nanobind.h>

#include "pointsource_pde/include/dolfinx_access/nanobind_helpers.h"

using namespace nanobind;

namespace dolfinx_access {
    bool check_Function_f64(const PyObject* obj) {
        auto handle = nanobind::handle(obj);
        return nanobind::isinstance<Function_f64>(handle);
    }

    const Function_f64* cast_Function_f64(const PyObject* obj) {
        auto handle = nanobind::handle(obj);
        return nanobind::cast<const Function_f64*>(handle);
    }

    Function_f64* cast_mut_Function_f64(PyObject* obj) {
        auto handle = nanobind::handle(obj);
        return nanobind::cast<Function_f64*>(handle);
    }

    PyObject* wrap_Function_f64(Function_f64* f) {
        return nanobind::cast(f).release().ptr();
    }

} // namespace dolfinx_access
