fix compilation issue detected in logos-delivery

This commit is contained in:
Ivan FB 2026-05-08 18:05:36 +02:00
parent 5c31d2f313
commit 4290e8893a
No known key found for this signature in database
GPG Key ID: DF0C67A04C543270
2 changed files with 18 additions and 6 deletions

View File

@ -1,7 +1,7 @@
import std/[macros, atomics], strformat, chronicles, chronos
import ../codegen/meta
macro declareLibraryBase(libraryName: static[string]): untyped =
macro declareLibraryBase*(libraryName: static[string]): untyped =
# Record the library name for binding generation
currentLibName = libraryName

View File

@ -744,15 +744,27 @@ macro ffi*(prc: untyped): untyped =
let cIdent = ident(cParamName(extraParamNames[i], extraParamTypes[i]))
let paramIdent = ident(extraParamNames[i])
let ptype = extraParamTypes[i]
lambdaBody.add quote do:
let `paramIdent` = ffiDeserialize(`cIdent`, `ptype`).valueOr:
return err($error)
if $cIdent != $paramIdent:
# Non-string param: cIdent has a Json suffix. Deserialize into paramIdent.
# buildProcessFFIRequestProc unpacks cIdent from the req struct, so no name clash.
lambdaBody.add quote do:
let `paramIdent` = ffiDeserialize(`cIdent`, `ptype`).valueOr:
return err($error)
# String params (cIdent == paramIdent): buildProcessFFIRequestProc already
# unpacks the cstring under the same name; we convert inline in the helperCall below.
let ctxMyLib = newDotExpr(newTree(nnkDerefExpr, ctxHandlerName), ident("myLib"))
let libValDeref = newTree(nnkDerefExpr, ctxMyLib)
let helperCall = newTree(nnkCall, helperProcName, libValDeref)
for name in extraParamNames:
helperCall.add(ident(name))
for i in 0 ..< extraParamNames.len:
let cIdent = ident(cParamName(extraParamNames[i], extraParamTypes[i]))
let paramIdent = ident(extraParamNames[i])
if $cIdent == $paramIdent:
# String param: cIdent/paramIdent is the cstring from the req unpack;
# convert to string with $ (ffiDeserialize for string is just ok($s)).
helperCall.add(newCall(ident("$"), paramIdent))
else:
helperCall.add(paramIdent)
let retValIdent = ident("retVal")
lambdaBody.add quote do: