Chaste / cppwg

An automatic Python wrapper generator for C++ code.
BSD 3-Clause "New" or "Revised" License
45 stars 8 forks source link

Fix handling of double pointers #6

Closed kwabenantim closed 5 months ago

kwabenantim commented 8 months ago

Description Wrappers generated for member functions with double pointer args do not compile.

Example:

class TysonNovak2001OdeSystem : public AbstractOdeSystemWithAnalyticJacobian
{
public:
    virtual void AnalyticJacobian(const std::vector<double>& rSolutionGuess, double** jacobian, double time, double timeStep);
};

produces:

.def(
    "AnalyticJacobian", 
    (void(TysonNovak2001OdeSystem::*)(::std::vector<double> const &, double * *, double, double)) &TysonNovak2001OdeSystem::AnalyticJacobian, 
    " " , py::arg("rSolutionGuess"), py::arg("jacobian"), py::arg("time"), py::arg("timeStep") )

Error

pybind11/include/pybind11/cast.h:1217
error: no matching function for call to ‘pybind11::detail::type_caster<double, void>::cast(double**&, pybind11::return_value_policy, std::nullptr_t)’
kwabenantim commented 5 months ago

This is not supported natively by Pybind11:

https://github.com/pybind/pybind11/issues/417
https://github.com/pybind/pybind11/issues/1824
kwabenantim commented 5 months ago

The workaround for this requires manual wrappers. This can be handled on a case-by-case basis by including custom wrapper code. This cannot sensibly be automatically generated.

Closing as wontfix.