makes asmnostackframe work with cpp member #22411 (#22429)

This commit is contained in:
Juan M Gómez
2023-08-09 19:57:52 +01:00
committed by GitHub
parent 91c3221855
commit 6ec1c80779
2 changed files with 41 additions and 3 deletions

View File

@@ -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()