Tooling for UCLification

From: David Chisnall <theraven_at_FreeBSD.org>
Date: Sun, 8 Aug 2021 14:55:01 +0100
Hi everyone,

A few years ago at BSDCam I started working on a tool that would parse data structures using libclang and provide libucl wrappers for serialising and deserialising the code.  After working on it for a bit, I came to the conclusion that the approach was the wrong way around and what I actually wanted to do was describe the config file and reflect that into code.

I’ve written a tool (still quite WIP, but now in a usable state) that takes a JSON Schema describing the config file and produces some modern idiomatic C++ wrappers for exposing it.  JSON Schema is the same format the UCL can validate, so you can write the schema once, use it to validate config files, and also use it to generate the code that exposes the config files into your program.

I hope it’s useful to anyone working on adding UCL support to tools:

https://github.com/davidchisnall/config-gen

There are a couple of simple examples in the tests directory that show the schema, some example configs, and the code used for accessing them.

David
Received on Sun Aug 08 2021 - 13:55:01 UTC

Original text of this message