* bindSym power up, working prototype * update bindSym doc * add bindSym test * fix some typo * fix bindSym doc * get rid of specialops field from vm * add experimental: dynamicBindSym
This commit is contained in:
parent
674bd7bfad
commit
78c0ac5407
9 changed files with 183 additions and 13 deletions
|
|
@ -1,4 +1,9 @@
|
|||
discard """
|
||||
msg: '''initApple
|
||||
deinitApple
|
||||
Coral
|
||||
enum
|
||||
redCoral, blackCoral'''
|
||||
output: '''TFoo
|
||||
TBar'''
|
||||
"""
|
||||
|
|
@ -23,3 +28,40 @@ macro test: untyped =
|
|||
bindSym("TBar"))
|
||||
|
||||
test()
|
||||
|
||||
# issue 7827, bindSym power up
|
||||
{.experimental: "dynamicBindSym".}
|
||||
type
|
||||
Apple = ref object
|
||||
name: string
|
||||
color: int
|
||||
weight: int
|
||||
|
||||
proc initApple(name: string): Apple =
|
||||
discard
|
||||
|
||||
proc deinitApple(x: Apple) =
|
||||
discard
|
||||
|
||||
macro wrapObject(obj: typed, n: varargs[untyped]): untyped =
|
||||
let m = n[0]
|
||||
for x in m:
|
||||
var z = bindSym x
|
||||
echo z.repr
|
||||
|
||||
wrapObject(Apple):
|
||||
initApple
|
||||
deinitApple
|
||||
|
||||
type
|
||||
Coral = enum
|
||||
redCoral
|
||||
blackCoral
|
||||
|
||||
macro mixer(): untyped =
|
||||
let m = "Co" & "ral"
|
||||
let x = bindSym(m)
|
||||
echo x.repr
|
||||
echo getType(x).repr
|
||||
|
||||
mixer()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue