From d0c0ffe0ed29fabbc8a3a87b314fd200f8b3fea4 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Thu, 8 Feb 2024 12:05:51 -0700 Subject: [PATCH] checks --- src/apatheia/tasks.nim | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/apatheia/tasks.nim b/src/apatheia/tasks.nim index a2c5516..4672dcb 100644 --- a/src/apatheia/tasks.nim +++ b/src/apatheia/tasks.nim @@ -3,6 +3,11 @@ import std/[macros, strutils] import macroutils +template checkParamType(obj: object) = + for name, field in obj.fieldPairs(): + echo "field name: ", name + + macro asyncTask*(p: untyped): untyped = let @@ -22,17 +27,28 @@ macro asyncTask*(p: untyped): untyped = let tcall = mkCall(ident"test", params) echo "ASYNC_TASK: call: \n", tcall.treeRepr + var checks = newStmtList() + for paramId, paramType in paramsIter(params): + echo "param: ", paramId, " tp: ", paramType.treeRepr + checks.add newCall("checkParamType", paramId) + + echo "asyncTask:checks:\n", checks.repr + result = p + echo "asyncTask:body:\n", result.repr + type HashOptions* = object striped*: bool proc doHashes*(data: openArray[byte], opts: HashOptions) {.asyncTask.} = - echo "args: ", args.len() + # echo "args: ", args.len() + discard proc doHashesRes*(data: openArray[byte], opts: HashOptions): int {.asyncTask.} = - echo "args: ", args.len() + discard + # echo "args: ", args.len() result = 10