Closed kkysen closed 1 year ago
It's a bit unfortunate that the annotations have to be written out-of-line (
*mut *mut T: [A, B]
rather than*mut {A} *mut {B} T
or similar), but parsing the latter withmacro_rules
would be a real pain.
Yeah, I agree that would be ideal, but that would be quite complex to parse and it'd probably mess up other nice-to-have stuff like syntax highlighting.
I wrote this as a
macro_rules!
macro so that we can write the pointer permission annotations inline with what the normalextern
declaration would look like. The macro checks that the declaration matcheslibc
's (or wherever it could be from) and that there are the correct number ofPermissionSet
s on each type corresponding to the number of pointers directly in that type (i.e., the number of*
).The syntax for this is an optional
: [PERM1a | PERM1b, PERM2a | PERM2b | PERM2c]
after each type in afn
signature, where the order of thePermissionSet
s corresponds to the pointers in the type in left-to-right order. For example:I'm still working on the integration of these
KnownFn
s intofn_sigs
asLFnSig
s, but I wanted to open a separate PR for how they are declared in the first place.