Changeset 598
- Timestamp:
- Aug 20, 2008, 12:22:49 AM (16 years ago)
- Location:
- trunk/ab5.0/ablib/src/Classes
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/ablib/src/Classes/System/Runtime/InteropServices/GCHandle.ab
r536 r598 8 8 Public 9 9 Function Target() As Object 10 Target = _System_PtrObj(handle)10 Target = ActiveBasic.GetObjectFromHandle(handle) 11 11 End Function 12 12 13 13 Sub Target(obj As Object) 14 14 If handle <> 0 Then 15 Dim i = allocated.IndexOf(Target()) 16 'assert(i <> -1) 17 allocated[i] = obj 15 ActiveBasic.ReleaseObjectHandle(handle) 18 16 End If 19 allocated.Add(obj) 20 handle = ObjPtr(obj) 17 handle = ActiveBasic.AllocObjectHandle(obj) 21 18 End Sub 22 19 … … 31 28 32 29 Sub Free() 33 allocated.Remove(Target) 30 If handle = 0 Then 31 Throw New InvalidOperationException 32 End If 33 ActiveBasic.ReleaseObjectHandle(handle) 34 34 handle = 0 35 35 End Sub 36 36 37 37 Static Function ToIntPtr(h As GCHandle) As LONG_PTR 38 Return h.handle As LONG_PTR38 Return h.handle 39 39 End Function 40 40 … … 44 44 End If 45 45 FromIntPtr = New GCHandle 46 FromIntPtr.handle = ip As VoidPtr46 FromIntPtr.handle = ip 47 47 End Function 48 48 49 49 Override Function GetHashCode() As Long 50 Return _System_HashFromPtr(handle )50 Return _System_HashFromPtr(handle As VoidPtr) 51 51 End Function 52 52 … … 67 67 End Function 68 68 69 'Private69 Private 70 70 Sub GCHandle() 71 71 End Sub 72 72 73 73 Private 74 handle As VoidPtr 75 76 Static allocated = New System.Collections.Generic.List<Object> 74 handle As LONG_PTR 77 75 End Class 78 76 -
trunk/ab5.0/ablib/src/Classes/index.ab
r577 r598 1 1 #require "./ActiveBasic/misc.ab" 2 #require "./ActiveBasic/ObjectHandle.ab" 2 3 #require "./ActiveBasic/Core/InterfaceInfo.ab" 3 4 #require "./ActiveBasic/Core/TypeInfo.ab"
Note:
See TracChangeset
for help on using the changeset viewer.