forked from nim-lang/Nim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
…n and finalizer for ORC (nim-lang#20295) * fixes nim-lang#19401; fixes nim-lang#19402; rework Forward declaration and finalizer for ORC * add more tests * give it a name * make more tests * fixes tests * hidden addr for cpp * move code to a function
- Loading branch information
Showing
3 changed files
with
112 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
discard """ | ||
output: ''' | ||
delete foo | ||
delete foo | ||
delete foo | ||
''' | ||
matrix: "--mm:arc" | ||
""" | ||
|
||
type Foo = ref object | ||
data: int | ||
proc delete(self: Foo) | ||
proc newFoo: Foo = | ||
let x = 12 | ||
discard x | ||
new(result, delete) | ||
result.data = x | ||
proc delete(self: Foo) = | ||
doAssert self.data == 12 | ||
echo("delete foo") | ||
|
||
if isMainModule: | ||
proc test() = | ||
let x1 = newFoo() | ||
let x2 = newFoo() | ||
discard x1 | ||
discard x2 | ||
var x3: Foo | ||
new(x3, delete) | ||
x3.data = 12 | ||
discard x3 | ||
test() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
discard """ | ||
output: ''' | ||
delete foo | ||
delete foo | ||
delete foo | ||
''' | ||
matrix: "--mm:arc" | ||
""" | ||
|
||
type Foo = ref object of RootObj | ||
data: int | ||
proc delete(self: Foo) | ||
proc newFoo: Foo = | ||
let x = 12 | ||
discard x | ||
new(result, delete) | ||
result.data = x | ||
proc delete(self: Foo) = | ||
doAssert self.data == 12 | ||
echo("delete foo") | ||
|
||
if isMainModule: | ||
proc test() = | ||
let x1 = newFoo() | ||
let x2 = newFoo() | ||
discard x1 | ||
discard x2 | ||
var x3: Foo | ||
new(x3, delete) | ||
x3.data = 12 | ||
discard x3 | ||
test() |