t23962.nim 489 B

1234567891011121314151617181920212223242526272829303132
  1. discard """
  2. cmd: "nim cpp $file"
  3. output: '''
  4. Ctor Foo(-1)
  5. Destory Foo(-1)
  6. Ctor Foo(-1)
  7. Destory Foo(-1)
  8. Ctor Foo(-1)
  9. Destory Foo(-1)
  10. Foo.x = 1
  11. Foo.x = 2
  12. Foo.x = -1
  13. '''
  14. """
  15. type
  16. Foo {.importcpp, header: "23962.h".} = object
  17. x: cint
  18. proc print(f: Foo) {.importcpp.}
  19. #also tests the right constructor is used
  20. proc makeFoo(x: int32 = -1): Foo {.importcpp:"Foo(#)", constructor.}
  21. proc test =
  22. var xs = newSeq[Foo](3)
  23. xs[0].x = 1
  24. xs[1].x = 2
  25. for x in xs:
  26. x.print
  27. test()