PMunch / futhark

Automatic wrapping of C headers in Nim
MIT License
355 stars 19 forks source link

[request] Allow function overloads #102

Open heysokam opened 2 months ago

heysokam commented 2 months ago

This is perfectly legal in Nim, because they are all different functions with different shapes:

image But futhark sanitizes everything, and turns them into this instead:

proc release*(adapter: Adapter): void {.cdecl, importc: "wgpuAdapterRelease".}
proc releaseproc*(bindgroup: Bindgroup): void {.cdecl, importc: "wgpuBindGroupRelease".}
proc referenceproc00000000EAE069C7*(bindgrouplayout: Bindgrouplayout): void {.cdecl, importc: "wgpuBindGroupLayoutReference".}
proc releaseproc0000000036522FBD*(bindgrouplayout: Bindgrouplayout): void {.cdecl, importc: "wgpuBindGroupLayoutRelease".}

Would it be possible to have a flag that skips this name sanitation when opted into?

heysokam commented 2 months ago

Created a working version, but its very hacky Would appreciate your input on how you would do these Unsafe*Names config options, while respecting your existing architecture https://github.com/PMunch/futhark/compare/master...heysokam:futhark-overloads:master