# Best way to generate a julia file full of wrapper functions

**URL:** <https://discourse.julialang.org/t/best-way-to-generate-a-julia-file-full-of-wrapper-functions/26390>\
**Category:** General Usage\
**Created:** [July 15, 2019, 6:26pm UTC](https://discourse.julialang.org/t/best-way-to-generate-a-julia-file-full-of-wrapper-functions/26390 "2019-07-15T18:26:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Deuxis](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/deuxis/32/6295_2.png) [@Deuxis](https://discourse.julialang.org/u/Deuxis)\
**Post date:** [July 15, 2019, 6:26pm UTC](https://discourse.julialang.org/t/best-way-to-generate-a-julia-file-full-of-wrapper-functions/26390/1 "2019-07-15T18:26:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![oxinabox](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oxinabox/32/206603_2.png) [@oxinabox](https://discourse.julialang.org/u/oxinabox)\
**Post date:** [July 15, 2019, 10:07pm UTC](https://discourse.julialang.org/t/best-way-to-generate-a-julia-file-full-of-wrapper-functions/26390/2 "2019-07-15T22:07:02Z")

</div>

TensorFlow.jl uses this  
[https://github.com/malmaud/TensorFlow.jl/blob/master/src/generate\_ops.jl](https://github.com/malmaud/TensorFlow.jl/blob/master/src/generate_ops.jl)

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.

[https://github.com/JuliaText/WordTokenizers.jl/blob/45f4aa3da4e81692c95adcef3e27a719da644296/src/words/sedbased.jl#L9-L50](https://github.com/JuliaText/WordTokenizers.jl/blob/45f4aa3da4e81692c95adcef3e27a719da644296/src/words/sedbased.jl#L9-L50)
