diff options
author | Zahary Karadjov <zahary@gmail.com> | 2015-04-14 00:03:31 +0300 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2015-04-14 00:03:31 +0300 |
commit | 6fb372d96bade748aa6cb3484fef2118b4585f26 (patch) | |
tree | 1f465c72ce40bf42d379c7115cb4bbb76712223d /tests | |
parent | 1ebf1aaa80664bfb19ca09845d4258fe6dff25df (diff) | |
download | Nim-6fb372d96bade748aa6cb3484fef2118b4585f26.tar.gz |
The getSubsystem<T> example in the manual currently fails with a codegen error
A faulty proc declaration is generated: N_NIMCALL(System::Input*, SystemManager::getSubsystem<'*0>())(void); The manual has been edited to add a nodecl pragma, which alleviates the issue Fix a typo in the vector_iterator example from the previous commit.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpp/get_subsystem.nim | 22 | ||||
-rw-r--r-- | tests/cpp/vector_iterator.nim | 6 |
2 files changed, 24 insertions, 4 deletions
diff --git a/tests/cpp/get_subsystem.nim b/tests/cpp/get_subsystem.nim new file mode 100644 index 000000000..38593b03a --- /dev/null +++ b/tests/cpp/get_subsystem.nim @@ -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]() + diff --git a/tests/cpp/vector_iterator.nim b/tests/cpp/vector_iterator.nim index bd26db351..cb5ab33af 100644 --- a/tests/cpp/vector_iterator.nim +++ b/tests/cpp/vector_iterator.nim @@ -6,16 +6,14 @@ discard """ template <class T> struct Vector { - struct Iterator { - - }; + struct Iterator {}; }; """.} type Vector {.importcpp: "Vector".} [T] = object - VectorIterator {.importcpp: "Vector<'2>::Iterator".} [T] = object + VectorIterator {.importcpp: "Vector<'0>::Iterator".} [T] = object var x: VectorIterator[void] |