Best way to generate a julia file full of wrapper functions

I have an API defined in an XML. On the low level it only uses a few simple functions for passing messages, and the entire XML declares higher level functions that should be wrappers around them. How should I generate a file with those wrapper functions? Should I just manually construct them via string interpolation/concatenation and output them to a file? Or maybe do a module that uses metaprogramming to generate everything on compile? Or both? Is there a way to turn expressions generated via metaprogramming back into a sane script file?

For those interested, the API is Wayland. Its C implementation uses a tool called wayland-scanner, which reads the XML and generates adequate C headers file via string concatenation.

TensorFlow.jl uses this

To generate buld wrappers. (also to have a macro that generates even more on demand)
But I think better is to do something more like
what WordTokenizers.jl does and use @eval
to do it at compile time without serializing to file.

1 Like