mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-02 19:22:40 +00:00
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.
This commit is contained in:
@@ -506,7 +506,7 @@ For example:
|
||||
.. code-block:: nim
|
||||
|
||||
type Input {.importcpp: "System::Input".} = object
|
||||
proc getSubsystem*[T](): ptr T {.importcpp: "SystemManager::getSubsystem<'*0>()".}
|
||||
proc getSubsystem*[T](): ptr T {.importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.}
|
||||
|
||||
let x: ptr Input = getSubsystem[Input]()
|
||||
|
||||
|
||||
22
tests/cpp/get_subsystem.nim
Normal file
22
tests/cpp/get_subsystem.nim
Normal 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]()
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user