nim-strenc
nim-strenc copied to clipboard
Error: Invalid node kind nnkArgList for macros.`$`
Hey @Yardanico , I am using your nim-strenc for a project I am working on and ran in to a bit of an issue. I'll try an be as detailed as I can but the error is outlined here:

The code that I am running is just some simple C code within Nim using the {.emit.} pragma. This snippet of code works fine on it's own and does what it needs in a smaller test.nim file. But when I try and compile it into the larger project where I am importing strenc it fails to compile.
...
{.emit: """
#include <windows.h>
int setWallpaper()
{
const wchar_t *path = L"C:\\TEMP\\wallpaper.jpg";
SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (void*)path, SPIF_UPDATEINIFILE);
return 0;
}
""".}
proc setWallpaper(): int {.importc: "setWallpaper", nodecl.} =
var result = setWallpaper()
...
I believe it is failing to compile due to the following code within strenc.nim:
# Use a term-rewriting macro to change all string literals
macro encrypt*{s}(s: string{lit}): untyped =
var encodedStr = gkkaekgaEE(estring($s), encodedCounter)
template genStuff(str, counter: untyped): untyped =
{.noRewrite.}:
gkkaekgaEE(estring(`str`), `counter`)
result = getAst(genStuff(encodedStr, encodedCounter))
encodedCounter = (encodedCounter *% 16777619) and 0x7FFFFFFF
It seems like it is trying to also encrypt the following string within the C code. Is it possible to not have it encrypt anything within a pragma or something? Or whatever makes the most sense to do in this case?
const wchar_t *path = L"C:\\TEMP\\wallpaper.jpg";