grasph / wrapit

Automatization of C++--Julia wrapper generation
MIT License
98 stars 12 forks source link

Fix missing `WrappedType` substitutions #29

Closed halleysfifthinc closed 7 months ago

halleysfifthinc commented 1 year ago

While working on wrapping a template heavy C++ library, I noticed several issues relating to the output of input and return argument types.

Examples of all the fixes:

-DEBUG_MSG("Adding wrapper for const Static::Vec::Transp & Static::Vec::transpose() (" __HERE__ ")");
-// signature to use in the veto list: const Static::Vec::Transp & Static::Vec::transpose()
+DEBUG_MSG("Adding wrapper for const Static::Vec::Transp & WrappedType::transpose() (" __HERE__ ")");
+// signature to use in the veto list: const Static::Vec::Transp & WrappedType::transpose()
 // defined in ./VecRow.h:13:17
-wrapped.method("transpose", static_cast<const typename WrappedType::Transp & (WrappedType::*)()  const>(&WrappedType::transpose));
+wrapped.method("transpose", static_cast<const Static::Vec::Transp & (WrappedType::*)()  const>(&WrappedType::transpose));
-DEBUG_MSG("Adding wrapper for Vec<N, T> & WrappedType::updAs(Static::Vec::E *) (" __HERE__ ")");
-// signature to use in the veto list: Vec<N, T> & Static::Vec::updAs(typename WrappedType::E *)
+DEBUG_MSG("Adding wrapper for Vec<N, T> & Static::Vec::updAs(typename WrappedType::E *) (" __HERE__ ")");
+// signature to use in the veto list: Vec<N, T> & WrappedType::updAs(Static::Vec::E *)
 // defined in ./VecRow.h:19:21
-wrapped.method("WrappedType!updAs", static_cast<Vec<N, T> & (*)(typename WrappedType::E *) >(&WrappedType::updAs));
+wrapped.method("Static!Vec!updAs", static_cast<WrappedType & (*)(typename WrappedType::E *) >(&WrappedType::updAs));
grasph commented 7 months ago

Hello @halleysfifthinc . This PR is still marked as WIP. Are you still working on it? What remains to be done to consider it for merging?

halleysfifthinc commented 7 months ago

Hey sorry for the delayed response. I had marked as draft because there were some cases that produced incorrect wrappers, and I never got around to producing MWEs to test against. IIRC, there were some edge cases where signature transformation wasn't correct, and where typename weren't being added.

grasph commented 7 months ago

Thanks Allen for the update and for the contribution. Don't hesitate to open a new PR if you improve the code to handle the corner cases.