-
Notifications
You must be signed in to change notification settings - Fork 61
Reorder comments, function attributes, and macro def args #251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Ok, I think this is ready. The new stuff has tests. Also added:
|
--def:SYM='macro()' define a C macro that gets replaced with the given | ||
definition. It's parsed by the lexer. Use it to fix | ||
function attributes: ``--def:PUBLIC='__attribute__ ()'`` | ||
--reordercomments reorder C comments to match Nim's postfix style |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this really need to be an option? ie why not always do this (since it's needed to make the comments compatible with nim doc)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two reasons: 1) to make it easier to get accepted 2) because I’d have to reorder the comments in all the tests.
Though perhaps it could default to on and use the option to disable it. Plus there may be cases it’s wrong. I sorta hack the new lines with a heuristic.
@@ -52,6 +56,7 @@ Options: | |||
for example `--mangle:'{u?}int{\d+}_t=$1int$2'` to | |||
convert C <stdint.h> to Nim equivalents | |||
(multiple --mangle options are supported) | |||
--stdints Mangle C stdint's into Nim style int's |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would feel more natural as a --no-stdints
- ie the quality of the wrapper is significantly improved when these types are recognised and it's hard to imagine code that uses these names for anything else than the standard interpretation
Some changes I've wanted for a while. Still a bit of a WIP.
__attribute__
to list of declarations for functions to help with parsing function attributes--def
arg to allow defining a macro from the command line--stdints
pre-defined mangle to convert C stdint to Nim intsExample usage:
Example re-order comments:
becomes:
Parsing
__attributes__
and--def:
makes it posible to handle the GCC C function pragmas style. For example--def:RCL_WARN_UNUSED='__attribute__ ()'
and--def:RCL_PUBLIC='__attribute__ ()'
will make the below parse:That last change is responsible for a good portion of C files not parsing properly. Eventually it'd be nice to add pragmas to the Nim procs so people could define them, but that's a project for another day.