Allow `=` and multiline prefix/postfix in annotations
This adds two things:
=is allowed in annotations. Previously, it was an error to have an=in the annotation but I'm doing hacky stuff (see below) and it didn't seem like there was a good reason not to permit it.- Multiline annotations are now supported by using a
\at the end of the annotated line and any following lines that should be concatenated together with newlines.
What this allows is basically:
#[cfg(target_arch = "i386")]
pub mod foo {
#[no_mangle]
/// cbindgen:prefix= \
/// #define FUNC_THAT_NEEDS_TO_BE_IFDEFED(x) \ \
/// do { \ \
/// do_something(x); \ \
/// } while (0) \
///
pub extern "C" fn bar() {}
}
Note the \ \: the last \ becomes a newline, then the line is trimmed and appended to the
annotation value. This means if you want a literal \ in your code (as you frequently do in a macro), you need two \.
after_include is useful, but it has trouble when you need to conditionally compile based on the ifdef generated for a cfg attribute. This fixes that and makes it possible to somewhat hackily embed arbitrary C code wherever you want (at the cost of having to declare something). Eventually an annotation that can occur on a free comment might be nice to eliminate this need, but the two changes added by this PR, the = allowing and multiline allowing would still be needed.
Whoops, looks like I failed the MSRV check. Will fix that.
Hmm, the clippy error is a false positive...I'll see what I can do.
At the very least this needs a test. Not opposed to this in principle tho?
Yeah it's breaking a lot of existing comments, I want to rework it and use some less silly parsing!