Some cbindgen tests have a toml config file.
That config file must work with multiple languages.
Hard to understand tricks are used, making it harder for cbindgen contributors to make tests for their code.
A better solution is to allow language-specific text in text fields that allow "code".
Changes:
This PR attempts to do that, while maintaining backwards compatibility.
I chose a serde-compatible way to represent the data (untagged enums) but can change to whatever you want.
Only header, trailer, after_includes were changed.
Other fields that output raw "code" can be changed too.
No idea how docs.md should be changed so I left it alone.
Fields:
Text field can be a line field or a sequence of lines or structs:
field = [
"sequence of lines",
{ language = "C", line = "or structs" },
]
Line field can be a single line or a struct:
field = "line"
field = { language = "C", line = "struct" }
Motivation:
Some cbindgen tests have a toml config file. That config file must work with multiple languages. Hard to understand tricks are used, making it harder for cbindgen contributors to make tests for their code. A better solution is to allow language-specific text in text fields that allow "code".
Changes:
This PR attempts to do that, while maintaining backwards compatibility. I chose a serde-compatible way to represent the data (untagged enums) but can change to whatever you want.
Only header, trailer, after_includes were changed. Other fields that output raw "code" can be changed too. No idea how docs.md should be changed so I left it alone.
Fields:
Text field can be a line field or a sequence of lines or structs:
Line field can be a single line or a struct: