source: Include/Classes/System/Runtime/InteropServices/GCHandle.ab@ 203

Last change on this file since 203 was 203, checked in by イグトランス (egtra), 17 years ago

GCHandleの追加、String.Compareなどの追加、gc.sbpの修正

File size: 1.3 KB
Line 
1' Classes/System/Runtime/InteropServices/GCHandle.ab
2
3#require <Classes/System/Collections/ArrayList.ab>
4
5Class GCHandle
6Public
7 Function Target() As Object
8 Dim pobj = VarPtr(handle) As *Object
9 Return pobj[0]
10 End Function
11
12 Sub Target(obj As Object)
13 allocated.Add(obj)
14 End Sub
15
16 Const Function IsAllocated() As Boolean
17 Retrun handle <> 0
18 End Function
19
20 Static Function Alloc(obj As Object) As GCHandle
21 Alloc = New GCHandle
22 Alloc.Target = obj
23 End Function
24
25 Sub Free()
26 Dim pobj = VarPtr(handle) As *Object
27 allocated.Remove(Target)
28 handle = 0
29 End Sub
30
31 Static Function ToIntPtr(h As GCHandle) As LONG_PTR
32 Return h.handle As LONG_PTR Xor &hffffffff As LONG_PTR
33 End Function
34
35 Static Function FromIntPtr(ip As LONG_PTR) As GCHandle
36 FromIntPtr = New GCHandle
37 FromIntPtr.handle = (ip Xor &hffffffff As LONG_PTR) As VoidPtr
38 End Function
39
40 Override Function GetHashCode() As Long
41 Return _System_HashFromPtr(handle)
42 End Function
43
44 Function Equals(y As GCHandle) As Boolean
45 Return handle = y.handle
46 End Function
47
48 Function Operator = (y As GCHandle) As Boolean
49 Return Equals(y)
50 End Function
51
52 Function Operator <> (y As GCHandle) As Boolean
53 Return Not Equals(y)
54 End Function
55
56'Private
57 Sub GCHandle()
58 End Sub
59
60Private
61 handle As VoidPtr
62
63 Static allocated As ArrayList
64End Class
Note: See TracBrowser for help on using the repository browser.