summary refs log tree commit diff stats
path: root/tests/cpp/tget_subsystem.nim
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2015-05-13 12:06:05 -0500
committerSimon Hafner <hafnersimon@gmail.com>2015-05-13 12:06:05 -0500
commit9c4a74637db266c3cfcffcfb1e65bae982c6e4bf (patch)
tree495f50a989d7ab696ddb0b7b0e815c572ab27f3c /tests/cpp/tget_subsystem.nim
parentc55f884b5c0ebc0b637138a8de446ba1fd05acdf (diff)
parent0b184f2584221543a7dec9c8ae4a700533919e0c (diff)
downloadNim-9c4a74637db266c3cfcffcfb1e65bae982c6e4bf.tar.gz
Merge branch 'devel' into jpoirier-realtimeGCTest
Diffstat (limited to 'tests/cpp/tget_subsystem.nim')
-rw-r--r--tests/cpp/tget_subsystem.nim23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/cpp/tget_subsystem.nim b/tests/cpp/tget_subsystem.nim
new file mode 100644
index 000000000..461914739
--- /dev/null
+++ b/tests/cpp/tget_subsystem.nim
@@ -0,0 +1,23 @@
+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>()", nodecl.}
+
+let input: ptr Input = getSubsystem[Input]()
+