tcodegendecl.nim 435 B

1234567891011121314151617
  1. discard """
  2. targets: "cpp"
  3. cmd: "nim cpp $file"
  4. output: "3"
  5. """
  6. {.emit:"""/*TYPESECTION*/
  7. int operate(int x, int y, int (*func)(const int&, const int&)){
  8. return func(x, y);
  9. };
  10. """.}
  11. proc operate(x, y: int32, fn: proc(x, y: int32 ): int32 {.cdecl.}): int32 {.importcpp:"$1(@)".}
  12. proc add(a {.codegenDecl:"const $#& $#".}, b {.codegenDecl:"const $# $#", byref.}: int32): int32 {.cdecl.} = a + b
  13. echo operate(1, 2, add)