import macros
type
S = string
I = int
O = object
i: int
P = ref O
var i: I
var s: S
var p: P
var o: O
macro mconnect(arg: typed): typed =
let at = getType(arg)
echo $(at.toStrLit)
if at.len > 1:
echo $(at[1].toStrLit)
mconnect(s)
mconnect(i)
mconnect(p)
mconnect(o)
Output is
Hint: macros [Processing]
string
int
ref[O]
O
object
i
How can I get P instead of ref[O] and O instead of object i ? I need that for a cast in gtk connect macro. (I think I may get what I need when I use type() outside of the macro and pass the result as an additional parameter to the macro. But I had the feeling that getType() can do it also?)
Use getTypeInst instead of getType. Both are in macros module.
Yes, that is exactly what I need.
I read the doc comment in macros module some monts ago:
proc getTypeInst(n: NimNode): NimNode {..}
#Like getType except it includes generic parameters for a specific instance
But it was not really obvious for me...