tpassbypragmas.nim 471 B

123456789101112131415161718192021222324252627
  1. discard """
  2. targets: "cpp"
  3. cmd: "nim cpp $file"
  4. """
  5. {.emit:"""/*TYPESECTION*/
  6. template<typename T>
  7. struct Box {
  8. T first;
  9. };
  10. struct Foo {
  11. void test(void (*func)(Box<Foo>& another)){
  12. };
  13. };
  14. """.}
  15. type
  16. Foo {.importcpp.} = object
  17. Box[T] {.importcpp:"Box<'0>".} = object
  18. first: T
  19. proc test(self: Foo, fn: proc(another {.byref.}: Box[Foo]) {.cdecl.}) {.importcpp.}
  20. proc fn(another {.byref.} : Box[Foo]) {.cdecl.} = discard
  21. Foo().test(fn)