This commit is contained in:
Jaremy Creechley 2024-02-08 11:53:33 -07:00
parent 586582a7c7
commit 4beb2f4d40
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
4 changed files with 19 additions and 3 deletions

View File

@ -6,7 +6,6 @@ description = "Async support for threading primitives"
license = "MIT"
srcDir = "src"
# Dependencies
requires "chronos >= 4.0.0"

View File

@ -89,6 +89,15 @@ proc mkParamsVars*(paramsIdent, paramsType, params: NimNode): NimNode =
result.add varList
# echo "paramsSetup return:\n", treeRepr result
proc mkCall*(callName, params: NimNode): NimNode =
## Create local variables for each parameter in the actual RPC call proc
if params.isNil: return
var argList = newSeq[NimNode]()
for paramId, paramType in paramsIter(params):
argList.add paramId
result = newCall(callName, argList)
# echo "mkCall return:\n", treeRepr result
proc mkParamsType*(paramsIdent, paramsType, params, genericParams: NimNode): NimNode =
## Create a type that represents the arguments for this rpc call
##

View File

@ -1,6 +1,8 @@
import std/[macros, strutils]
import macroutils
macro asyncTask*(p: untyped): untyped =
let
@ -14,8 +16,14 @@ macro asyncTask*(p: untyped): untyped =
echo "ASYNC_TASK: name: ", name
echo "ASYNC_TASK: params: \n", params.treeRepr
let tcall = mkCall(ident"test", params)
echo "ASYNC_TASK: call: \n", tcall.treeRepr
proc doHashes*(args: openArray[byte]) {.asyncTask.} =
type
HashOptions* = object
striped*: bool
proc doHashes*(data: openArray[byte], opts: HashOptions) {.asyncTask.} =
echo "args: ", args.len()

View File

@ -1 +1 @@
switch("path", "$projectDir/../src")
switch("path", "$projectDir/../src")