summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-04-24 12:34:58 +0200
committerAraq <rumpf_a@web.de>2015-04-24 12:35:13 +0200
commitc01d9d081bdb834de2063f7120c24aecfc19ce9d (patch)
tree17e716e32e7078fe2afae4946b3259796c102d0a
parentc1730e1eadb4ad0090a901d578840db281cb4715 (diff)
downloadNim-c01d9d081bdb834de2063f7120c24aecfc19ce9d.tar.gz
added test for #2536
-rw-r--r--tests/cpp/tvectorseq.nim38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/cpp/tvectorseq.nim b/tests/cpp/tvectorseq.nim
new file mode 100644
index 000000000..6eb5dc9e4
--- /dev/null
+++ b/tests/cpp/tvectorseq.nim
@@ -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)
gt; 2022-01-16 11:08:38 +0100 deprecate unsafeAddr; extend addr (#19373)' href='/ahoang/Nim/commit/changelog.md?h=devel&id=d102b2f54c41f19a0545f28109d0a93550b5d886'>d102b2f54 ^
891329cd4 ^

7d17cd34b ^
50e98e6ef ^
c7c6b13a3 ^

ea475a4e9 ^
955040f0f ^
a95399143 ^
c7c6b13a3 ^
2c5b36700 ^
0ef830577 ^
e49d52eb6 ^





4a38092ac ^
42eeab5fd ^

4a38092ac ^
cda77c152 ^

8e8231f9d ^


b70fd0400 ^
5163fe7d8 ^
1b143f5e7 ^





























5933aece9 ^
a0073d2d4 ^
61d682e73 ^


c2b20516d ^
7d17cd34b ^
e47c3987c ^
f77dea01f ^

51f3ef6cb ^
50e98e6ef ^
7d17cd34b ^
17acf146a ^
a0073d2d4 ^

a236002e5 ^
908fc2a22 ^



7ff43d07b ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
                     
 
 

                                           






                                                                                                                                                                 
 


                                                                                       
                                        
                                                                                                           
 


                                                                                       

                                                                                           
                                         
 

                                                                  
                                                                           
                                                                                                                                  
                                                    
 
                                                                                                       
 





                                                                                                                                  
                                                                                                      

                                        
 

                                                                                             


                                    
                   
 





























                                                                                                  
                                                                                               
                                                                                            


                                                                            
 
                   
 

                                                                                                  
 
 
               
 

                                                                                        
 



                                                                                              

                                                                                    
# v1.8.x - yyyy-mm-dd


## Changes affecting backward compatibility

- The `Math.trunc` polyfill for targeting Internet Explorer was
  previously emitted for every JavaScript output file except if
  the symbol `nodejs` was defined via `-d:nodejs`. Now, it is only
  emitted if the symbol `nimJsMathTruncPolyfill` is defined. If you are
  targeting Internet Explorer, you may choose to enable this option
  or define your own `Math.trunc` polyfill using the [`emit` pragma](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma). Nim uses
  `Math.trunc` for the division and modulo operators for integers.

- Optional parameters in combination with `: body` syntax (RFC #405) are now opt-in via
  `experimental:flexibleOptionalParams`.

- `std/sharedstrings` module is removed.
- Constants `colors.colPaleVioletRed` and `colors.colMediumPurple` changed to match the CSS color standard.

- `addr` is now available for all addressable locations, `unsafeAddr` is deprecated and
becomes an alias for `addr`.

- io is about to move out of system; use `-d:nimPreviewSlimSystem` and import `std/syncio`.

## Standard library additions and changes

- `macros.parseExpr` and `macros.parseStmt` now accept an optional
  filename argument for more informative errors.
- Module `colors` expanded with missing colors from the CSS color standard.
- Fixed `lists.SinglyLinkedList` being broken after removing the last node ([#19353](https://github.com/nim-lang/Nim/pull/19353)).
- `md5` now works at compile time and in JavaScript.

- `std/smtp` sends `ehlo` first. If the mail server does not understand, it sends `helo` as a fallback.

- Added `IsoWeekRange`, a range type to represent the number of weeks in an ISO week-based year.
- Added `IsoYear`, a distinct int type to prevent bugs from confusing the week-based year and the regular year.
- Added `initDateTime` in `times` to create a datetime from a weekday, and ISO 8601 week number and week-based year.
- Added `getIsoWeekAndYear` in `times` to get an ISO week number along with the corresponding ISO week-based year from a datetime.
- Added `getIsoWeeksInYear` in `times` to return the number of weeks in an ISO week-based year.

- Added `std/oserrors` for OS error reporting. Added `std/envvars` for environment variables handling.
- Removed deprecated `oids.oidToString`.


- Changed mimedb to use an `OrderedTable` instead of `OrderedTableRef`, to use it in a const.

- Removed deprecated `math.c_frexp`.


## Language changes

- Pragma macros on type definitions can now return `nnkTypeSection` nodes as well as `nnkTypeDef`,
  allowing multiple type definitions to be injected in place of the original type definition.

  ```nim
  import macros

  macro multiply(amount: static int, s: untyped): untyped =
    let name = $s[0].basename
    result = newNimNode(nnkTypeSection)
    for i in 1 .. amount:
      result.add(newTree(nnkTypeDef, ident(name & $i), s[1], s[2]))

  type
    Foo = object
    Bar {.multiply: 3.} = object
      x, y, z: int
    Baz = object

  # becomes

  type
    Foo = object
    Bar1 = object
      x, y, z: int
    Bar2 = object
      x, y, z: int
    Bar3 = object
      x, y, z: int
    Baz = object
  ```
- [Case statement macros](manual.html#macros-case-statement-macros) are no longer experimental,
  meaning you no longer need to enable the experimental switch `caseStmtMacros` to use them.
- Full command syntax and block arguments i.e. `foo a, b: c` are now allowed
  for the right-hand side of type definitions in type sections. Previously
  they would error with "invalid indentation".

## Compiler changes

- `nim` can now compile version 1.4.0 as follows: `nim c --lib:lib --stylecheck:off compiler/nim`,
  without requiring `-d:nimVersion140` which is now a noop.


## Tool changes

- The `gc` switch has been renamed to `mm` ("memory management") in order to reflect the
  reality better. (Nim moved away from all techniques based on "tracing".)

- Nim now supports Nimble version 0.14 which added support for lock-files. This is done by
  a simple configuration change setting that you can do yourself too. In `$nim/config/nim.cfg`
  replace `pkgs` by `pkgs2`.

- There is a new switch `--nimMainPrefix:prefix` to influence the `NimMain` that the
  compiler produces. This is particularly useful for generating static libraries.