mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-19 22:10:33 +00:00
added test for #2536
This commit is contained in:
38
tests/cpp/tvectorseq.nim
Normal file
38
tests/cpp/tvectorseq.nim
Normal file
@@ -0,0 +1,38 @@
|
||||
discard """
|
||||
output: '''(x: 1.0)
|
||||
(x: 0.0)'''
|
||||
cmd: "nim cpp $file"
|
||||
disabled: "true"
|
||||
"""
|
||||
|
||||
# This cannot work yet because we omit type information for importcpp'ed types.
|
||||
# Fixing this is not hard, but also requires fixing Urhonimo.
|
||||
|
||||
# bug #2536
|
||||
|
||||
{.emit: """/*TYPESECTION*/
|
||||
struct Vector3 {
|
||||
public:
|
||||
Vector3(): x(5) {}
|
||||
Vector3(float x_): x(x_) {}
|
||||
float x;
|
||||
};
|
||||
""".}
|
||||
|
||||
type Vector3 {.importcpp: "Vector3", nodecl} = object
|
||||
x: cfloat
|
||||
|
||||
proc constructVector3(a: cfloat): Vector3 {.importcpp: "Vector3(@)", nodecl}
|
||||
|
||||
# hack around another codegen issue: Generics are attached to where they came
|
||||
# from:
|
||||
proc `$!`(v: seq[Vector3]): string = "(x: " & $v[0].x & ")"
|
||||
|
||||
proc vec3List*(): seq[Vector3] =
|
||||
let s = @[constructVector3(cfloat(1))]
|
||||
echo($!s)
|
||||
result = s
|
||||
echo($!result)
|
||||
|
||||
let f = vec3List()
|
||||
#echo($!f)
|
||||
Reference in New Issue
Block a user