Last change
on this file since 364 was 340, checked in by dai, 17 years ago |
デリゲートを試験実装
【現状のデリゲート制約】
・ダイナミックメソッド限定
・パラメータ相違チェックは行っていない
GCHandle.allocatedメンバをListクラスに変更。
List.Removeメソッドを追加
|
File size:
1.5 KB
|
Rev | Line | |
---|
[203] | 1 | ' Classes/System/Runtime/InteropServices/GCHandle.ab
|
---|
| 2 |
|
---|
[282] | 3 | Namespace System
|
---|
| 4 | Namespace Runtime
|
---|
| 5 | Namespace InteropServices
|
---|
| 6 |
|
---|
[203] | 7 | Class GCHandle
|
---|
| 8 | Public
|
---|
| 9 | Function Target() As Object
|
---|
| 10 | Dim pobj = VarPtr(handle) As *Object
|
---|
| 11 | Return pobj[0]
|
---|
| 12 | End Function
|
---|
| 13 |
|
---|
| 14 | Sub Target(obj As Object)
|
---|
| 15 | allocated.Add(obj)
|
---|
[257] | 16 | handle = ObjPtr(obj)
|
---|
[203] | 17 | End Sub
|
---|
| 18 |
|
---|
| 19 | Const Function IsAllocated() As Boolean
|
---|
[233] | 20 | Return handle <> 0
|
---|
[203] | 21 | End Function
|
---|
| 22 |
|
---|
| 23 | Static Function Alloc(obj As Object) As GCHandle
|
---|
| 24 | Alloc = New GCHandle
|
---|
| 25 | Alloc.Target = obj
|
---|
| 26 | End Function
|
---|
| 27 |
|
---|
| 28 | Sub Free()
|
---|
| 29 | allocated.Remove(Target)
|
---|
| 30 | handle = 0
|
---|
| 31 | End Sub
|
---|
| 32 |
|
---|
| 33 | Static Function ToIntPtr(h As GCHandle) As LONG_PTR
|
---|
[223] | 34 | Return h.handle As LONG_PTR
|
---|
[203] | 35 | End Function
|
---|
| 36 |
|
---|
| 37 | Static Function FromIntPtr(ip As LONG_PTR) As GCHandle
|
---|
| 38 | FromIntPtr = New GCHandle
|
---|
[223] | 39 | FromIntPtr.handle = ip As VoidPtr
|
---|
[203] | 40 | End Function
|
---|
| 41 |
|
---|
| 42 | Override Function GetHashCode() As Long
|
---|
| 43 | Return _System_HashFromPtr(handle)
|
---|
| 44 | End Function
|
---|
| 45 |
|
---|
| 46 | Function Equals(y As GCHandle) As Boolean
|
---|
| 47 | Return handle = y.handle
|
---|
| 48 | End Function
|
---|
| 49 |
|
---|
[208] | 50 | Function Operator == (y As GCHandle) As Boolean
|
---|
[203] | 51 | Return Equals(y)
|
---|
| 52 | End Function
|
---|
| 53 |
|
---|
| 54 | Function Operator <> (y As GCHandle) As Boolean
|
---|
| 55 | Return Not Equals(y)
|
---|
| 56 | End Function
|
---|
| 57 |
|
---|
[208] | 58 | Override Function ToString() As String
|
---|
| 59 | Return "System.Runtime.InteropServices.GCHandle"
|
---|
| 60 | End Function
|
---|
| 61 |
|
---|
[203] | 62 | 'Private
|
---|
| 63 | Sub GCHandle()
|
---|
| 64 | End Sub
|
---|
| 65 |
|
---|
| 66 | Private
|
---|
| 67 | handle As VoidPtr
|
---|
| 68 |
|
---|
[340] | 69 | Static allocated = New System.Collections.Generic.List<Object>
|
---|
[203] | 70 | End Class
|
---|
[282] | 71 |
|
---|
| 72 | End Namespace 'System
|
---|
| 73 | End Namespace 'Runtime
|
---|
| 74 | End Namespace 'InteropServices
|
---|
Note:
See
TracBrowser
for help on using the repository browser.