diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpp/tvirtual.nim | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/cpp/tvirtual.nim b/tests/cpp/tvirtual.nim index 7acec21ba..fb792380b 100644 --- a/tests/cpp/tvirtual.nim +++ b/tests/cpp/tvirtual.nim @@ -79,3 +79,40 @@ type Doo = object proc naiveMember(x: Doo): int {. virtual .} = 2 discard naiveMember(Doo()) +#asmnostackframe works with virtual +{.emit:"""/*TYPESECTION*/ + template<typename T> + struct Box { + T* first; + + Box(int x){ + first = new T(x); + }; + }; + struct Inner { + int val; + //Coo() = default; + Inner(int x){ + val = x; + }; + }; + struct Base { + virtual Box<Inner> test() = 0; + }; +""".} + +type + Inner {.importcpp.} = object + Base {.importcpp, inheritable.} = object + Child = object of Base + Box[T] {.importcpp, inheritable.} = object + first: T + +proc makeBox[T](x:int32): Box[T] {.importcpp:"Box<'0>(@)", constructor.} + +proc test(self: Child): Box[Inner] {.virtual, asmnostackframe.} = + let res {.exportc.} = makeBox[Inner](100) + {.emit:"return res;".} + + +discard Child().test() \ No newline at end of file |