diff options
author | Juan M Gómez <info@jmgomez.me> | 2023-07-23 15:42:20 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-23 16:42:20 +0200 |
commit | 49a108b3027914eec18fab4bc47d9b4846eb362e (patch) | |
tree | 3d72015c55c30ee56bcf8ef0b1390b2a29ba59dd /tests/cpp/tcodegendecl.nim | |
parent | 808c9c6c2a93e6076c17b6f9bbab367df4c27772 (diff) | |
download | Nim-49a108b3027914eec18fab4bc47d9b4846eb362e.tar.gz |
Expands codegenDecl to work in function params. fixes #22306 (#22307)
* Expands codegenDecl to work in function params. fixes #22306 * makes the test more concrete so T{lit} params dont match * adds sfCodegenDecl
Diffstat (limited to 'tests/cpp/tcodegendecl.nim')
-rw-r--r-- | tests/cpp/tcodegendecl.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/cpp/tcodegendecl.nim b/tests/cpp/tcodegendecl.nim new file mode 100644 index 000000000..e128c5eb7 --- /dev/null +++ b/tests/cpp/tcodegendecl.nim @@ -0,0 +1,17 @@ +discard """ + targets: "cpp" + cmd: "nim cpp $file" + output: "3" +""" + +{.emit:"""/*TYPESECTION*/ + int operate(int x, int y, int (*func)(const int&, const int&)){ + return func(x, y); + }; +""".} + +proc operate(x, y: int32, fn: proc(x, y: int32 ): int32 {.cdecl.}): int32 {.importcpp:"$1(@)".} + +proc add(a {.codegenDecl:"const $#& $#".}, b {.codegenDecl:"const $# $#", byref.}: int32): int32 {.cdecl.} = a + b + +echo operate(1, 2, add) \ No newline at end of file |