Cannot capitalize symbols using `rename` and `renameCallback`.
nayr7 opened this issue · 2 comments
Hello! This is a very nice tool for C interop, unfortunately while wrapping libvips
, I tried to make futhark generate nep1 compliant symbols using rename
and renameCallback
but capitalizing anything but the first word of a symbol is ineffective.
Example:
rename "VipsPrecision", "PrecisionTest"
generatesPrecisiontest
rename "VipsPrecision", "precisiontest"
generatesprecisiontest
Setup:
Distro: Ubuntu 23.04
Nim Version: 1.6.10
Futhark Version: 0.9.1
Code Prototype:
when defined(useFuthark):
import futhark
importc:
outputPath currentSourcePath.parentDir / "private/generated.nim"
sysPath "/usr/lib/clang/15/include"
sysPath "/usr/include/glib-2.0"
sysPath "/usr/lib/x86_64-linux-gnu/glib-2.0/include"
path "/usr/local/include/vips"
rename "VipsPrecision", "PrecisionTest" # does not work
rename "vips_object_get_type", "vipsObjectGetType1" # does not work
"vips.h"
else:
include private/generated
Ideally we should be able to tell futhark to generate nep1 compliant symbols for us through a define option, but this is merely a convenience and we should be able to use rename
and renameCallback
for this, if only they did work ...
The reason why this doesn't work is that Futhark internally uses these identifiers in a hash table. So the representation that is kept is the most cleaned version (capital letters kept, all underscores removed, and all other letters made lowercase). Since Nim is style agnostic this shouldn't make a difference to how you can use the code, but it can make it a bit more confusing to read the documentation or code generated.
In order to fix this I think it would be best to create a table of identifiers to "pretty names" and then as the code is about to be written substitute the names for these ones. This should give the wanted effect at the lowest overhead.