source: Include/Classes/System/Object.ab@ 228

Last change on this file since 228 was 224, checked in by dai, 18 years ago

Object.ReferenceEqualsを修正(後日、ObjPtr形式に書き換える必要あり)。
Object.ToStringで返す文字列を型名に変更。
Objectクラスのテストケースを用意。

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