Changeset 598 for trunk


Ignore:
Timestamp:
Aug 20, 2008, 12:22:49 AM (16 years ago)
Author:
イグトランス (egtra)
Message:

[597]でのコミット漏れ)より簡単なGC避けとしてObjectHandleを追加。
GCHandleの内部実装もObjectHandleベースへ移行。

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  
    88Public
    99    Function Target() As Object
    10         Target = _System_PtrObj(handle)
     10        Target = ActiveBasic.GetObjectFromHandle(handle)
    1111    End Function
    1212
    1313    Sub Target(obj As Object)
    1414        If handle <> 0 Then
    15             Dim i = allocated.IndexOf(Target())
    16             'assert(i <> -1)
    17             allocated[i] = obj
     15            ActiveBasic.ReleaseObjectHandle(handle)
    1816        End If
    19         allocated.Add(obj)
    20         handle = ObjPtr(obj)
     17        handle = ActiveBasic.AllocObjectHandle(obj)
    2118    End Sub
    2219
     
    3128
    3229    Sub Free()
    33         allocated.Remove(Target)
     30        If handle = 0 Then
     31            Throw New InvalidOperationException
     32        End If
     33        ActiveBasic.ReleaseObjectHandle(handle)
    3434        handle = 0
    3535    End Sub
    3636
    3737    Static Function ToIntPtr(h As GCHandle) As LONG_PTR
    38         Return h.handle As LONG_PTR
     38        Return h.handle
    3939    End Function
    4040
     
    4444        End If
    4545        FromIntPtr = New GCHandle
    46         FromIntPtr.handle = ip As VoidPtr
     46        FromIntPtr.handle = ip
    4747    End Function
    4848
    4949    Override Function GetHashCode() As Long
    50         Return _System_HashFromPtr(handle)
     50        Return _System_HashFromPtr(handle As VoidPtr)
    5151    End Function
    5252
     
    6767    End Function
    6868
    69 'Private
     69Private
    7070    Sub GCHandle()
    7171    End Sub
    7272
    7373Private
    74     handle As VoidPtr
    75 
    76     Static allocated = New System.Collections.Generic.List<Object>
     74    handle As LONG_PTR
    7775End Class
    7876
  • trunk/ab5.0/ablib/src/Classes/index.ab

    r577 r598  
    11#require "./ActiveBasic/misc.ab"
     2#require "./ActiveBasic/ObjectHandle.ab"
    23#require "./ActiveBasic/Core/InterfaceInfo.ab"
    34#require "./ActiveBasic/Core/TypeInfo.ab"
Note: See TracChangeset for help on using the changeset viewer.