From: Gökçen E. <gok...@gm...> - 2017-01-21 16:44:24
|
Hi everyone, I'm playing around with Swig to see whether I can generate Eigen[1] bindings for Go (and maybe for other languages as well) which may or may not be useful for some people. As a template monster, it's a bit tricky to deal with Eigen. I had to make some workarounds to solve some annoying preprocessor issues[2] but I got stuck at some point. What I'd like to wrap eventually is the Matrix class[3] and some instances of its templates. Matrix class inherits PlainObjectBase[4]: template<typename _Scalar, int _Rows, int _Cols, int _Options, int _MaxRows, int _MaxCols> class Matrix : public PlainObjectBase<Matrix<_Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols> > Wrappers of this part works fine, so the Matrix wrapper actually inherits methods from PlainObjectBase. So far so good. However, PlainObjectBase cannot inherit methods from its parent class because it gets its base class name from a field of a struct template[5] like this: template<typename Derived> class PlainObjectBase : public internal::dense_xpr_base<Derived>::type where dense_xpr_base is defined as: template<typename Derived, typename XprKind = typename traits<Derived>::XprKind> struct dense_xpr_base { }; template<typename Derived> struct dense_xpr_base<Derived, MatrixXpr> { typedef MatrixBase<Derived> type; }; When I wrap MatrixBase, PlainObjectBase and Matrix classes and instantiate some of the templates properly, members and methods of MatrixBase is not passed down to PlainObjectBase and Matrix classes, which is indicated by this warning by Swig: Nothing known about base class 'internal::dense_xpr_base<DenseXprXd >::type'. Ignored. Is it possible to instantiate this template or solve the problem in any other way to fully inform Swig about the Matrix class hierarchy? Here is the interface file I wrote so far: https://github.com/gokceneraslan/eigon/blob/master/eigon.i You can (recursively) clone the repo and run make to reproduce the issue. Best regards, Gokcen. [1] https://eigen.tuxfamily.org/ [2] https://github.com/gokceneraslan/eigen/commit/51c5bd1275ff4a9ac790b1026d7cc5fdc5a6e64a [3] https://github.com/gokceneraslan/eigen/blob/master/Eigen/src/Core/Matrix.h#L178 [4] https://github.com/gokceneraslan/eigen/blob/master/Eigen/src/Core/PlainObjectBase.h#L98 [5] https://github.com/gokceneraslan/eigen/blob/master/Eigen/src/Core/util/XprHelper.h#L469 |