source: branch/egtra-stream-without-en_dec/Classes/System/Blittable.ab@ 673

Last change on this file since 673 was 392, checked in by イグトランス (egtra), 17 years ago

GetHashCode, Equalsの実装

File size: 8.8 KB
Line 
1Namespace System
2
3 Class Blittable(SByte) SByte
4 value As SByte
5 Public
6 Static Function MaxValue() As SByte
7 Return 127
8 End Function
9 Static Function MinValue() As SByte
10 Return -128
11 End Function
12
13 Sub SByte( value As SByte )
14 This.value = value
15 End Sub
16
17 Override Function ToString() As String
18 Return Str$(value)
19 End Function
20
21 Override Function Equals(y As Object) As Boolean
22 If Object.ReferenceEquals(GetType(), y.GetType()) Then
23 Return Equals(y As System.SByte)
24 End If
25 End Function
26
27 Function Equals(y As SByte) As Boolean
28 Return value = y
29 End Function
30
31 Override Function GetHashCode() As Long
32 Return value
33 End Function
34
35 Function Operator() As SByte
36 Return value
37 End Function
38
39 Static Function _Create( value As SByte ) As System.SByte
40 Return New System.SByte( value )
41 End Function
42 End Class
43
44 Class Blittable(Byte) Byte
45 value As Byte
46 Public
47 Static Function MaxValue() As Byte
48 Return 255
49 End Function
50 Static Function MinValue() As Byte
51 Return 0
52 End Function
53
54 Sub Byte( value As Byte )
55 This.value = value
56 End Sub
57
58 Override Function ToString() As String
59 Return Str$(value)
60 End Function
61
62 Override Function Equals(y As Object) As Boolean
63 If Object.ReferenceEquals(GetType(), y.GetType()) Then
64 Return Equals(y As System.Byte)
65 End If
66 End Function
67
68 Function Equals(y As Byte) As Boolean
69 Return value = y
70 End Function
71
72 Override Function GetHashCode() As Long
73 Return value
74 End Function
75
76 Function Operator() As Byte
77 Return value
78 End Function
79
80 Static Function _Create( value As Byte ) As System.Byte
81 Return New System.Byte( value )
82 End Function
83 End Class
84
85 Class Blittable(Integer) Int16
86 value As Integer
87 Public
88 Static Function MaxValue() As Integer
89 Return 32767
90 End Function
91 Static Function MinValue() As Integer
92 Return -32768
93 End Function
94
95 Sub Int16( value As Integer )
96 This.value = value
97 End Sub
98
99 Override Function ToString() As String
100 Return Str$(value)
101 End Function
102
103 Override Function Equals(y As Object) As Boolean
104 If Object.ReferenceEquals(GetType(), y.GetType()) Then
105 Return Equals(y As System.Int16)
106 End If
107 End Function
108
109 Function Equals(y As Integer) As Boolean
110 Return value = y
111 End Function
112
113 Override Function GetHashCode() As Long
114 Return value
115 End Function
116
117 Function Operator() As Integer
118 Return value
119 End Function
120
121 Static Function _Create( value As Integer ) As System.Int16
122 Return New System.Int16( value )
123 End Function
124 End Class
125
126 Class Blittable(Word) UInt16
127 value As Word
128 Public
129 Static Function MaxValue() As Word
130 Return 65535
131 End Function
132 Static Function MinValue() As Word
133 Return 0
134 End Function
135
136 Sub UInt16( value As Word )
137 This.value = value
138 End Sub
139
140 Override Function ToString() As String
141 Return Str$(value)
142 End Function
143
144 Override Function Equals(y As Object) As Boolean
145 If Object.ReferenceEquals(GetType(), y.GetType()) Then
146 Return Equals(y As UInt16)
147 End If
148 End Function
149
150 Function Equals(y As Word) As Boolean
151 Return value = y
152 End Function
153
154 Override Function GetHashCode() As Long
155 Return value
156 End Function
157
158 Function Operator() As Word
159 Return value
160 End Function
161
162 Static Function _Create( value As Word ) As UInt16
163 Return New UInt16( value )
164 End Function
165 End Class
166
167 Class Blittable(Long) Int32
168 value As Long
169 Public
170 Static Function MaxValue() As Long
171 Return 2147483647
172 End Function
173 Static Function MinValue() As Long
174 Return -2147483648
175 End Function
176
177 Sub Int32( value As Long )
178 This.value = value
179 End Sub
180
181 Override Function ToString() As String
182 Return Str$(value)
183 End Function
184
185 Override Function Equals(y As Object) As Boolean
186 If Object.ReferenceEquals(GetType(), y.GetType()) Then
187 Return Equals(y As Int32)
188 End If
189 End Function
190
191 Function Equals(y As Long) As Boolean
192 Return value = y
193 End Function
194
195 Override Function GetHashCode() As Long
196 Return value
197 End Function
198
199 Function Operator() As Long
200 Return value
201 End Function
202
203 Static Function _Create( value As Long ) As Int32
204 Return New Int32( value )
205 End Function
206 End Class
207
208 Class Blittable(DWord) UInt32
209 value As DWord
210 Public
211 Static Function MaxValue() As DWord
212 Return 4294967295
213 End Function
214 Static Function MinValue() As DWord
215 Return 0
216 End Function
217
218 Sub UInt32( value As DWord )
219 This.value = value
220 End Sub
221
222 Override Function ToString() As String
223 Return Str$(value)
224 End Function
225
226 Override Function Equals(y As Object) As Boolean
227 If Object.ReferenceEquals(GetType(), y.GetType()) Then
228 Return Equals(y As UInt32)
229 End If
230 End Function
231
232 Function Equals(y As DWord) As Boolean
233 Return value = y
234 End Function
235
236 Override Function GetHashCode() As Long
237 Return value As Long
238 End Function
239
240 Function Operator() As DWord
241 Return value
242 End Function
243
244 Static Function _Create( value As DWord ) As UInt32
245 Return New UInt32( value )
246 End Function
247 End Class
248
249 Class Blittable(Int64) Int64
250 value As Int64
251 Public
252 Static Function MaxValue() As Int64
253 Return &H7FFFFFFFFFFFFFFF As Int64
254 End Function
255 Static Function MinValue() As Int64
256 Return &H8000000000000000 As Int64
257 End Function
258
259 Sub Int64( value As Int64 )
260 This.value = value
261 End Sub
262
263 Override Function ToString() As String
264 Return Str$(value)
265 End Function
266
267 Override Function Equals(y As Object) As Boolean
268 If Object.ReferenceEquals(GetType(), y.GetType()) Then
269 Return Equals(y As System.Int64)
270 End If
271 End Function
272
273 Function Equals(y As Int64) As Boolean
274 Return value = y
275 End Function
276
277 Override Function GetHashCode() As Long
278 Return _System_HashFromUInt(value As QWord)
279 End Function
280
281 Function Operator() As Int64
282 Return value
283 End Function
284
285 Static Function _Create( value As Int64 ) As System.Int64
286 Return New System.Int64( value )
287 End Function
288 End Class
289
290 Class Blittable(QWord) UInt64
291 value As QWord
292 Public
293 Static Function MaxValue() As QWord
294 Return &HFFFFFFFFFFFFFFFF
295 End Function
296 Static Function MinValue() As QWord
297 Return 0
298 End Function
299
300 Sub UInt64( value As QWord )
301 This.value = value
302 End Sub
303
304 Override Function ToString() As String
305 Return Str$(value)
306 End Function
307
308 Override Function Equals(y As Object) As Boolean
309 If Object.ReferenceEquals(GetType(), y.GetType()) Then
310 Return Equals(y As UInt64)
311 End If
312 End Function
313
314 Function Equals(y As QWord) As Boolean
315 Return value = y
316 End Function
317
318 Override Function GetHashCode() As Long
319 Return _System_HashFromUInt(value)
320 End Function
321
322 Function Operator() As QWord
323 Return value
324 End Function
325
326 Static Function _Create( value As QWord ) As System.UInt64
327 Return New System.UInt64( value )
328 End Function
329 End Class
330
331 Class Blittable(Single) Single
332 value As Single
333 Public
334 Static Function MaxValue() As Single
335 Return 3.4e+38
336 End Function
337 Static Function MinValue() As Single
338 Return 3.4e-38
339 End Function
340
341 Sub Single( value As Single )
342 This.value = value
343 End Sub
344
345 Override Function ToString() As String
346 Return Str$(value)
347 End Function
348
349 Override Function Equals(y As Object) As Boolean
350 If Object.ReferenceEquals(GetType(), y.GetType()) Then
351 Return Equals(y As System.Single)
352 End If
353 End Function
354
355 Function Equals(y As Single) As Boolean
356 Return value = y
357 End Function
358
359 Override Function GetHashCode() As Long
360 Return GetDWord(VarPtr(value)) As Long
361 End Function
362
363 Function Operator() As Single
364 Return value
365 End Function
366
367 Static Function _Create( value As Single ) As System.Single
368 Return New System.Single( value )
369 End Function
370 End Class
371
372 Class Blittable(Double) Double
373 value As Double
374 Public
375 Static Function MaxValue() As Double
376 Return 1.7e+308
377 End Function
378 Static Function MinValue() As Double
379 Return 1.7e-308
380 End Function
381
382 Sub Double( value As Double )
383 This.value = value
384 End Sub
385
386 Override Function ToString() As String
387 Return Str$(value)
388 End Function
389
390 Override Function Equals(y As Object) As Boolean
391 If Object.ReferenceEquals(GetType(), y.GetType()) Then
392 Return Equals(y As System.Double)
393 End If
394 End Function
395
396 Function Equals(y As Double) As Boolean
397 Return value = y
398 End Function
399
400 Override Function GetHashCode() As Long
401 Return _System_HashFromUInt(GetQWord(VarPtr(value)))
402 End Function
403
404 Function Operator() As Double
405 Return value
406 End Function
407
408 Static Function _Create( value As Double ) As System.Double
409 Return New System.Double( value )
410 End Function
411 End Class
412
413End Namespace
Note: See TracBrowser for help on using the repository browser.