JuliaInterop / libcxxwrap-julia

C++ library for backing CxxWrap.jl
Other
84 stars 43 forks source link

Mutually dependent `typedef`s can't be wrapped #119

Open halleysfifthinc opened 1 year ago

halleysfifthinc commented 1 year ago

A library I'm working to wrap has a StaticArrays.jl equivalent functionality, with template Vec and Row classes. Both the classes define a transpose function to return the vec/row as it's transposed type:

template<int N, typename T> class Vec;
template<int N, typename T> class Row;

template<int N, typename T>
class Vec
{
  public:
  typedef Row<N,T> Transp;

  const Transp& transpose()    const { return *reinterpret_cast<const Transp*>(this); }

/* further definitions omitted */
};

with the same for the Row class definition. A wrapper including both types (see gist for complete MWE) compiles with no errors, but loading it in Julia throws an error:

"C++ exception while wrapping module jlsimbody: No appropriate factory for type N9paramtest3RowILi3EiEE ERROR: No appropriate factory for type N9paramtest3RowILi3EiEE"

As both types do exist/are wrapped, this seems to be an order of declaration/wrapping issue, since the type for Row<3,int> hasn't been wrapped when the transpose method for Vec<3,int> is added?

I don't know what (or if) there is a solution to be had besides not wrapping the offending methods; at the very least, could the error be made more relevant?