diff --git a/apatheia.nimble b/apatheia.nimble index ee00e68..5690a19 100644 --- a/apatheia.nimble +++ b/apatheia.nimble @@ -6,7 +6,6 @@ description = "Async support for threading primitives" license = "MIT" srcDir = "src" - # Dependencies requires "chronos >= 4.0.0" diff --git a/src/apatheia/macroutils.nim b/src/apatheia/macroutils.nim index b5b9408..5cb1509 100644 --- a/src/apatheia/macroutils.nim +++ b/src/apatheia/macroutils.nim @@ -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 ## diff --git a/src/apatheia/tasks.nim b/src/apatheia/tasks.nim index 5aee393..aca52a8 100644 --- a/src/apatheia/tasks.nim +++ b/src/apatheia/tasks.nim @@ -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() diff --git a/tests/config.nims b/tests/config.nims index 3bb69f8..80091ff 100644 --- a/tests/config.nims +++ b/tests/config.nims @@ -1 +1 @@ -switch("path", "$projectDir/../src") \ No newline at end of file +switch("path", "$projectDir/../src")