provide equivalent of CCTK_PASS_CTOC and CCTK_PASS_FTOF between languages
It is occasionally (such as when interfacing with legacy code) code useful to use the equivalent of CCTK_PASS_CTOF
and CCTK_PASS_FTOC
.
This seems to be impossible to directly. Workarounds are declare the C function to take cGH ** p_cctkGH
as an argument then set up a local cGH *cctkGH = *p_cctkGH
before DECLARE_CCTK_ARGUMENTS
for CCTK_PASS_FTOC
while for CCTK_PASS_CTOF
one seems to have to resort to CCTK_FortranWrapper
and call the returned wrapper with cctkGH and the (Fortran) function pointer.
Note: this of course suffers from combinatorial explosion of options when Cactus starts to support Lua/Python/Tcl/Java/Forth. It might be useful to instead provide a set of functions that allow this to be done "officially". Something like:
call CCTK_PASSFTOC(Cfunc)
and
CCTK_PASSCTOF(CCTK_FNAME(Ffunc));
where the later is essentially
#define CCTK_PASSCTOF(fun) (CCTK_FortranWrapper(CCTK_THORNSTRING))(fun, cctkGH)
and the former
#define CCTK_PASSFTOC(fun) CCTK_PassFtoC(fun, cctkGH)
void CCTK_FNAME(CCTK_PassFtoC)(void (*f)(cGH *cctkGH), cGH **p_cctkGH)
{
f(*p_cctkGH);
}
Keyword: