nim-lang / c2nim

c2nim is a tool to translate Ansi C code to Nim. The output is human-readable Nim code that is meant to be tweaked by hand before and after the translation process.
MIT License
509 stars 63 forks source link

Add varargs to defines, defines as C imports, and CLI mangle option #222

Closed elcritch closed 1 year ago

elcritch commented 3 years ago

Hey! Thanks for keeping c2nim up and working!

I decided to take the time to fix/tweak a few things that I run into a lot and figure others might find them useful.

I'll work on adding the test cases I'm using tomorrow. I haven't run the test suite yet, but I'll do that tomorrow. However, I wanted to get this up so I wouldn't forget to PR it later.

Also, any feedback/changes would be great. I tried to follow the coding style as much as I could. Still I'm not entirely familiar with the correct PNode structures for some of the items. Particularly if there's a "proper" way to handle some of the constructs.

Araq commented 3 years ago

Looks very good, will review it in more detail later. Feel free to ping me again in order to remind me.

elcritch commented 3 years ago

Ok, nice. I used it on some bigger files and there is one issue so far. The "import as proc" seems to only spit out the first import if there's multiple definitions in a row without comments in between. That'll need fixed. I'll put it on my docket for next week.