Some library's C API functions look like this:
h3dAddResource
h3dDelResource
...
In my nim wrapper I use:
{.push dynlib:lib, importc:"h3d$1".}
proc AddResource(...)
proc DelResource(...)
{.pop.}
This appends "h3d" before proc name for C API. How can I also make proc names start with lower letters in bulk? Maybe there's a way to pass a translation proc? This would be perfect:
{.push dynlib:lib, importc:proc(nimName: string): string = "h3d" & nimName[0].toUpperAscii() & nimName[1..^nimName.len]}
proc addResource(...)
proc delResource(...)
You can create a custom pragma and tag your proc with it.
It will get passed the proc AST, including the name so you can add h3d and uppercase the first letter so that it matches the C API. I don't have a handy example right now though.
Alternatively, use c2nim and use a regexp on the output :D.
Alternatively, use c2nim and use a regexp on the output
c2nim offers #nep1 and #mangle, no need for post processing with regexes.