Mercurial > pub > dyncall > bindings
comparison lua/luadyncall/test/test_smartptr.lua @ 0:0cfcc391201f
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:26:28 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0cfcc391201f |
---|---|
1 require "smartptr" | |
2 | |
3 -- test tolightuserdata | |
4 | |
5 x = smartptr.tolightuserdata(0xCAFEbabe) | |
6 print(x) | |
7 | |
8 -- test newsmartptr and finalizer | |
9 | |
10 function finalizer(x) | |
11 print("finalizer:"..tostring(x) ) | |
12 end | |
13 | |
14 y = smartptr.new(x, finalizer) | |
15 print("dump smartptr : ".. tostring(y) ) | |
16 print("dump address : " .. tostring(y())) | |
17 y = nil -- should print FINALIZER | |
18 collectgarbage("collect") | |
19 -- test setfinalizer | |
20 | |
21 y = smartptr.new( smartptr.tolightuserdata(0xdeadc0de), finalizer) | |
22 print("smartptr : ".. tostring(y) ) | |
23 print("address : " .. tostring(y())) | |
24 function newfinalizer(x) | |
25 print("newfinalizer:"..tostring(x)) | |
26 end | |
27 smartptr.setfinalizer(y, newfinalizer) | |
28 y = nil | |
29 |