Merge branch 'devel' of https://github.com/Araq/Nim into devel

This commit is contained in:
Araq 2015-04-20 11:44:54 +02:00
commit 2b4e233510
18 changed files with 192 additions and 54 deletions

View file

@ -0,0 +1,22 @@
discard """
cmd: "nim cpp $file"
"""
{.emit: """
namespace System {
struct Input {};
}
struct SystemManager {
template <class T>
static T* getSubsystem() { return new T; }
};
""".}
type Input {.importcpp: "System::Input".} = object
proc getSubsystem*[T](): ptr T {.importcpp: "SystemManager::getSubsystem<'*0>()".}
let input: ptr Input = getSubsystem[Input]()

View file

@ -0,0 +1,19 @@
discard """
cmd: "nim cpp $file"
"""
{.emit: """
template <class T>
struct Vector {
struct Iterator {};
};
""".}
type
Vector {.importcpp: "Vector".} [T] = object
VectorIterator {.importcpp: "Vector<'0>::Iterator".} [T] = object
var x: VectorIterator[void]

View file

@ -15,6 +15,10 @@ true
tester args
all
all args
19
-3
false
-2
'''
"""
@ -67,3 +71,13 @@ const
echo tester & " " & args|"all"
echo "all" | tester & " " & args
echo "all"|tester & " " & args
# Test arrow like operators. See also tests/macros/tclosuremacro.nim
proc `+->`(a, b: int): int = a + b*4
template `===>`(a, b: int): expr = a - b shr 1
echo 3 +-> 2 + 2 and 4
var arrowed = 3+->2 + 2 and 4 # arrowed = 4
echo arrowed ===> 15
echo (2 * 3+->2) == (2*3 +-> 2)
echo arrowed ===> 2 + 3+->2