source: trunk/Include/Classes/System/Object.ab@ 464

Last change on this file since 464 was 449, checked in by dai, 17 years ago

GCがオブジェクト内の参照をスキャンする際、平たくスキャンするのではなく、基底クラスをたどるような実装に変更した。

File size: 1.7 KB
Line 
1
2Namespace System
3
4 Class Object
5
6 Public
7
8 Sub Object()
9 End Sub
10 Sub ~Object()
11 End Sub
12
13 ' 2つのオブジェクトが等しいかどうかを判断する
14 Virtual Function Equals( object As Object ) As Boolean
15 If ObjPtr(This) = ObjPtr(object) Then
16 ' If This.GetHashCode() = object.GetHashCode() Then
17 Return True
18 Else
19 Return False
20 End If
21 End Function
22
23 Static Function Equals( objectA As Object, objectB As Object ) As Boolean
24 If ObjPtr(objectA) = NULL /*objectA = Nothing*/ Then
25 Return ObjPtr(objectB) = NULL 'objectB = Nothing
26 Else
27 Return objectA.Equals(objectB)
28 End If
29 End Function
30
31 ' 参照先が等しいか判断する
32 Static Function ReferenceEquals(objectA As Object, objectB As Object) As Boolean
33 If ObjPtr( objectA ) = ObjPtr( objectB) Then
34 Return True
35 Else
36 Return False
37 End If
38 End Function
39
40 ' ハッシュコードを取得する
41 Virtual Function GetHashCode() As Long
42 Return ObjPtr( This ) As Long
43 End Function
44
45 ' オブジェクトに関係する文字列を返す
46 Virtual Function ToString() As String
47 Return GetType().Name
48 End Function
49
50 /*
51 Function Operator Downcast() As VoidPtr
52 End Function
53 */
54
55
56 '----------------------------------------------------------------
57 ' 実行時型情報
58 '----------------------------------------------------------------
59
60 Private
61 _system_object_member_typeInfo As TypeInfo
62
63 Public
64 Sub _System_SetType( typeInfo As TypeInfo )
65 If ActiveBasic.Core._System_TypeBase.IsReady() = False Then
66 Return
67 End If
68
69 This._system_object_member_typeInfo = typeInfo
70 End Sub
71
72 Virtual Function GetType() As TypeInfo
73 Return _system_object_member_typeInfo
74 End Function
75
76 End Class
77
78End Namespace
Note: See TracBrowser for help on using the repository browser.