summary refs log tree commit diff stats
path: root/tests/macros
diff options
context:
space:
mode:
authorandri lim <jangko128@gmail.com>2018-08-02 17:56:44 +0700
committerAndreas Rumpf <rumpf_a@web.de>2018-08-02 12:56:44 +0200
commit78c0ac54070e860ec0ed8ac0b58658f7ad52227a (patch)
treedc20154f92f6178df405cf8da99612ee2f99323c /tests/macros
parent674bd7bfad100a07e051e0a310bcf0a64c355a79 (diff)
downloadNim-78c0ac54070e860ec0ed8ac0b58658f7ad52227a.tar.gz
fixes #7827, bindSym enhancement (#8499)
* 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
Diffstat (limited to 'tests/macros')
-rw-r--r--tests/macros/tbindsym.nim42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/macros/tbindsym.nim b/tests/macros/tbindsym.nim
index 6289d3eb2..2abcd98ce 100644
--- a/tests/macros/tbindsym.nim
+++ b/tests/macros/tbindsym.nim
@@ -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()