This commit is contained in:
Jaremy Creechley 2024-02-08 20:20:21 -07:00
parent 8413c39058
commit 22566c40ff
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
5 changed files with 21 additions and 9 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
*
!*/
!*.*
.tool-versions
.tool-versions
nim.cfg

View File

@ -10,3 +10,4 @@ srcDir = "src"
requires "chronos >= 4.0.0"
requires "threading"
requires "taskpool"

View File

@ -32,9 +32,6 @@ iterator paramsIter*(params: NimNode): tuple[name, ntype: NimNode] =
for j in 0 ..< arg.len-2:
yield (arg[j], argType)
proc identPub*(name: string): NimNode =
result = nnkPostfix.newTree(newIdentNode("*"), ident name)
proc signalTuple*(sig: NimNode): NimNode =
let otp = nnkEmpty.newTree()
# echo "signalObjRaw:sig1: ", sig.treeRepr
@ -120,6 +117,16 @@ proc mkParamsType*(paramsIdent, paramsType, params, genericParams: NimNode): Nim
result[0][1] = genericParams.copyNimTree()
# echo "mkParamsType: ", genericParams.treeRepr
proc identPub*(name: string): NimNode =
result = nnkPostfix.newTree(newIdentNode("*"), ident name)
proc procIdentAppend*(id: NimNode, name: string): NimNode =
if id.kind == nnkPostfix:
echo "PROC ID: ", id.treeRepr
result = id
result[1] = ident(result[1].strVal & name)
else:
result = ident(result.strVal & name)
proc mkCall*(callName, params: NimNode): NimNode =
## Create local variables for each parameter in the actual RPC call proc

View File

@ -31,14 +31,17 @@ macro asyncTask*(p: untyped): untyped =
for paramId, paramType in paramsIter(params):
echo "param: ", paramId, " tp: ", paramType.treeRepr
asyncBody.add newCall("checkParamType", paramId)
let tcall = mkCall(ident name, params)
# echo "asyncTask:checks:\n", asyncBody.repr
# let tcall = mkCall(ident"tester", params)
# echo "asyncTask:tcall: ", tcall.repr
echo "asyncTask:body:\n", body.repr
let taskProc = mkProc(procId, params, body)
let tp = mkProc(procId.procIdentAppend("Tasklet"),
params, body)
result = newStmtList()
result.add taskProc
result.add tp
echo "asyncTask:body:\n", result.repr
# echo "asyncTask:body:\n", result.treeRepr

View File

@ -7,7 +7,7 @@
import unittest
import apatheia/queues
import apatheia/tasks
test "can add":
check 10 == 10