Merge branch 'master' of github.com:Araq/Nimrod
This commit is contained in:
commit
8c8400ea3a
3 changed files with 18 additions and 5 deletions
|
|
@ -864,8 +864,7 @@ proc evalTypeTrait*(n: PNode, context: PSym): PNode =
|
||||||
## XXX: This should be pretty much guaranteed to be true
|
## XXX: This should be pretty much guaranteed to be true
|
||||||
# by the type traits procs' signatures, but until the
|
# by the type traits procs' signatures, but until the
|
||||||
# code is more mature it doesn't hurt to be extra safe
|
# code is more mature it doesn't hurt to be extra safe
|
||||||
internalAssert n.sons.len >= 2 and n.sons[1].kind == nkSym and
|
internalAssert n.sons.len >= 2 and n.sons[1].kind == nkSym
|
||||||
n.sons[1].sym.typ.kind == tyTypeDesc
|
|
||||||
|
|
||||||
let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc})
|
let typ = n.sons[1].sym.typ.skipTypes({tyTypeDesc})
|
||||||
case n.sons[0].sym.name.s.normalize
|
case n.sons[0].sym.name.s.normalize
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
discard """
|
discard """
|
||||||
msg: "int\nstring\nTBar[int]"
|
msg: "int\nstring\nTBar[int]"
|
||||||
output: "int\nstring\nTBar[int]"
|
output: "int\nstring\nTBar[int]\nint\nrange 0..2"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import typetraits
|
import typetraits
|
||||||
|
|
||||||
|
# simple case of type trait usage inside/outside of static blocks
|
||||||
proc foo(x) =
|
proc foo(x) =
|
||||||
static:
|
static:
|
||||||
var t = type(x)
|
var t = type(x)
|
||||||
|
|
@ -22,3 +23,16 @@ foo 10
|
||||||
foo "test"
|
foo "test"
|
||||||
foo bar
|
foo bar
|
||||||
|
|
||||||
|
# generic params on user types work too
|
||||||
|
proc foo2[T](x: TBar[T]) =
|
||||||
|
echo T.name
|
||||||
|
|
||||||
|
foo2 bar
|
||||||
|
|
||||||
|
# less usual generic params on built-in types
|
||||||
|
var arr: array[0..2, int] = [1, 2, 3]
|
||||||
|
|
||||||
|
proc foo3[R, T](x: array[R, T]) =
|
||||||
|
echo name(R)
|
||||||
|
|
||||||
|
foo3 arr
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ proc FileSaveClicked(menuitem: PMenuItem, userdata: pgpointer) {.cdecl.} =
|
||||||
error(w, "Unable to write to file")
|
error(w, "Unable to write to file")
|
||||||
|
|
||||||
proc inputKeyPressed(widget: PWidget, event: PEventKey,
|
proc inputKeyPressed(widget: PWidget, event: PEventKey,
|
||||||
userdata: pgpointer): bool =
|
userdata: pgpointer): bool {.cdecl.} =
|
||||||
if ($keyval_name(event.keyval)).tolower() == "shift_l":
|
if ($keyval_name(event.keyval)).tolower() == "shift_l":
|
||||||
# SHIFT is pressed
|
# SHIFT is pressed
|
||||||
shiftPressed = True
|
shiftPressed = True
|
||||||
|
|
@ -72,7 +72,7 @@ proc setError(msg: string) =
|
||||||
outputTextBuffer.setText(msg, msg.len.gint)
|
outputTextBuffer.setText(msg, msg.len.gint)
|
||||||
|
|
||||||
proc inputKeyReleased(widget: PWidget, event: PEventKey,
|
proc inputKeyReleased(widget: PWidget, event: PEventKey,
|
||||||
userdata: pgpointer): bool =
|
userdata: pgpointer): bool {.cdecl.} =
|
||||||
#echo(keyval_name(event.keyval))
|
#echo(keyval_name(event.keyval))
|
||||||
if ($keyval_name(event.keyval)).tolower() == "shift_l":
|
if ($keyval_name(event.keyval)).tolower() == "shift_l":
|
||||||
# SHIFT is released
|
# SHIFT is released
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue