Changeset 237 for Include/Classes
- Timestamp:
- May 7, 2007, 4:22:52 PM (18 years ago)
- Location:
- Include/Classes/System
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/DateTime.ab
r228 r237 157 157 158 158 Function DayOfWeek() As Long 'As DayOfWeek 159 Return ( Ticks \ TimeSpan.TicksPerDay) Mod 7- 1159 Return ((Ticks \ TimeSpan.TicksPerDay) Mod 7) As Long - 1 160 160 End Function 161 161 -
Include/Classes/System/Environment.ab
r233 r237 1 1 ' System/Environment.ab 2 2 3 #require <api_psapi.sbp> 3 4 #require <Classes/System/OperatingSystem.ab> 4 5 … … 8 9 9 10 Static Function CommandLine() As String 10 If cmdLine = NothingThen11 If Object.ReferenceEquals(cmdLine, Nothing) Then 11 12 #ifdef __STRING_IS_NOT_UNICODE 12 13 cmdLine = New String(GetCommandLineA()) … … 51 52 52 53 Static Function OSVersion() As OperatingSystem 53 If osVer = NothingThen54 If Object.ReferenceEquals(osVer, Nothing) Then 54 55 Dim vi As OSVERSIONINFO 55 56 GetVersionEx(vi) … … 71 72 72 73 Static Function SystemDirectory() As String 73 If sysDir = NothingThen74 If Object.ReferenceEquals(sysDir, Nothing) Then 74 75 Dim size = GetSystemDirectory(0, 0) 75 Dim p = _System_malloc(SizeOf (TCHAR) * size) 76 Dim len = GetSystemDirectory( size, p)76 Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 77 Dim len = GetSystemDirectory(p, size) 77 78 sysDir = New String(p, len As Long) 78 79 _System_free(p) … … 94 95 95 96 Static Function WorkingSet() As Int64 96 Dim pGetProcessMemoryInfo As *Function(Process As HANDLE, ByRef mc As PPROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 97 TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 98 Dim pGetProcessMemoryInfo As PFNGetProcessMemoryInfo 97 99 Dim hmodPSAPI = LoadLibrary("PSAPI.DLL") 98 100 If hmodPSAPI = 0 Then Return 0 99 pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) 101 pGetProcessMemoryInfo = GetProcAddress(hmodPSAPI, ToMBStr("GetProcessMemoryInfo")) As PFNGetProcessMemoryInfo 100 102 If pGetProcessMemoryInfo <> 0 Then 101 Dim mc As P PROCESS_MEMORY_COUNTERS103 Dim mc As PROCESS_MEMORY_COUNTERS 102 104 If pGetProcessMemoryInfo(GetCurrentProcess(), mc, Len (mc)) <> FALSE Then 103 105 WorkingSet = mc.WorkingSetSize 106 104 107 End If 105 108 End If … … 117 120 Dim src = ToTCStr(s) 118 121 Dim size = ExpandEnvironmentStrings(src, 0, 0) 119 Dim dst = _System_malloc(SizeOf (TCHAR) * size) 122 Dim dst = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 120 123 ExpandEnvironmentStrings(src, dst, size) 121 124 ExpandEnvironmentVariables = New String(dst, size - 1) -
Include/Classes/System/Math.ab
r233 r237 194 194 195 195 Static Function Floor(value As Double) As Long 196 return Int(value)196 Return Int(value) 197 197 End Function 198 198 … … 201 201 'GetType 202 202 203 Static Function IEEERemainder(value1 As Double, value2 As Double) As Double 204 Dim q As Double 205 If value2=0 then return _System_GetNaN() 206 q=value1/value2 207 If q<>Int(q) then 208 If q+0.5<>Int(q+0.5) then 209 q=Int(q+0.5) 210 ElseIf Int(q+0.5)=Int(q*2+1)/2 then 211 q=Int(q+0.5) 203 Static Function IEEERemainder(x As Double, y As Double) As Double 204 If y = 0 Then Return _System_GetNaN() 205 Dim q = x / y 206 If q <> Int(q) Then 207 If q + 0.5 <> Int(q + 0.5) Then 208 q = Int(q + 0.5) 209 ElseIf Int(q + 0.5) = Int(q * 2 + 1) / 2 Then 210 q = Int(q + 0.5) 212 211 Else 213 q =Int(q-0.5)212 q = Int(q - 0.5) 214 213 End If 215 214 End If 216 If x -y*q=0 then217 If x >0 then218 return +0215 If x - y * q = 0 Then 216 If x > 0 Then 217 Return +0 219 218 Else 220 return -0219 Return -0 221 220 End If 222 221 Else 223 return x-y*q222 Return x-y*q 224 223 End If 225 224 End Function … … 252 251 253 252 Static Function Log10(x As Double) As Double 254 Return Math.Log(x) / Math.Log(10)253 Return Math.Log(x) / _System_Ln10 255 254 End Function 256 255 … … 582 581 583 582 Static Function Truncate(x As Double) As Double 584 return Fix(x)583 Return Fix(x) 585 584 End Function 586 585 … … 611 610 Const _System_HalfPI = (_System_PI * 0.5) 612 611 Const _System_InverseHalfPI = (2 / _System_PI) '1 / (PI / 2) 612 Const _System_Ln10 = 2.3025850929940456840179914546844 '10の自然対数 613 613 614 614 #endif '__SYSTEM_MATH_AB__ -
Include/Classes/System/Object.ab
r232 r237 10 10 ' 2つのオブジェクトが等しいかどうかを判断する 11 11 Virtual Function Equals( object As Object ) As Boolean 12 If This.GetHashCode() = object.GetHashCode() Then 12 If ObjPtr(This) = ObjPtr(object) Then 13 ' If This.GetHashCode() = object.GetHashCode() Then 13 14 Return True 14 15 Else … … 16 17 End If 17 18 End Function 19 18 20 Static Function Equals( objectA As Object, objectB As Object ) As Boolean 19 21 If ObjPtr(objectA) = NULL /*objectA = Nothing*/ Then 20 22 Return ObjPtr(objectB) = NULL 'objectB = Nothing 21 23 Else 22 Return objectA.Equals( objectB)24 Return objectA.Equals(objectB) 23 25 End If 24 26 End Function … … 35 37 ' ハッシュコードを取得する 36 38 Virtual Function GetHashCode() As Long 37 Return VarPtr( This ) As Long39 Return ObjPtr( This ) As Long 38 40 End Function 39 41 -
Include/Classes/System/OperatingSystem.ab
r233 r237 17 17 18 18 Sub OperatingSystem(vi As OSVERSIONINFOA) 19 pf = vi.dwPlatformId As PlatformID ,19 pf = vi.dwPlatformId As PlatformID 20 20 ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber) 21 sp = vi.szCSDVersion21 sp = New String(vi.szCSDVersion As PCSTR) 22 22 End Sub 23 23 24 24 Sub OperatingSystem(vi As OSVERSIONINFOW) 25 pf = vi.dwPlatformId As PlatformID ,25 pf = vi.dwPlatformId As PlatformID 26 26 ver = New Version(vi.dwMajorVersion, vi.dwMinorVersion, vi.dwBuildNumber) 27 sp = vi.szCSDVersion27 sp = New String(vi.szCSDVersion As PCSTR) 28 28 End Sub 29 29 -
Include/Classes/System/String.ab
r227 r237 184 184 185 185 Static Function CompareOrdinal(x As String, indexX As Long, y As String, indexY As Long, length As Long) As Long 186 If x = NothingThen187 If y = NothingThen186 If Object.ReferenceEquals(x, Nothing) Then 187 If Object.ReferenceEquals(y, Nothing) Then 188 188 Return 0 189 189 Else 190 190 Return -1 191 191 End If 192 ElseIf y = NothingThen192 ElseIf Object.ReferenceEquals(y, Nothing) Then 193 193 Return 1 194 194 End If 195 Return _System_StrCmpN(VarPtr(x.Chars[indexX]), VarPtr(y.Chars[indexY]), length )195 Return _System_StrCmpN(VarPtr(x.Chars[indexX]), VarPtr(y.Chars[indexY]), length As SIZE_T) 196 196 End Function 197 197 … … 344 344 #ifdef __STRING_IS_NOT_UNICODE 345 345 With Concat 346 Dim lenA = MultiByteToWideChar(CP_THREAD_ACP, 0, text, len, 0, 0, 0, 0)346 Dim lenA = WideCharToMultiByte(CP_THREAD_ACP, 0, text, len, 0, 0, 0, 0) 347 347 .AllocStringBuffer(m_Length + lenA) 348 348 memcpy(.Chars, This.Chars, m_Length) 349 MultiByteToWideChar(CP_THREAD_ACP, 0, text, len, VarPtr(.Chars[m_Length]), lenA, 0, 0)349 WideCharToMultiByte(CP_THREAD_ACP, 0, text, len, VarPtr(.Chars[m_Length]), lenA, 0, 0) 350 350 .Chars[m_Length + lenA] = 0 351 351 End With … … 473 473 temp.AllocStringBuffer(length) 474 474 memcpy(temp.Chars, VarPtr(Chars[startIndex]), SizeOf (StrChar) * length) 475 Chars[m_Length] = 0475 temp.Chars[m_Length] = 0 476 476 Return temp 477 477 End Function … … 527 527 End Function 528 528 529 Const Function Replace(oldStr As *StrChar, newStr As *StrChar) 529 Const Function Replace(oldStr As *StrChar, newStr As *StrChar) As String 530 530 If oldStr = 0 Then Debug 'Throw ArgumentNullException 531 531 If newStr = 0 Then newStr = "" 532 Return ReplaceCore(oldStr, lstrlen(oldStr), newStr, lstrlen(newStr)) As String532 Return ReplaceCore(oldStr, lstrlen(oldStr), newStr, lstrlen(newStr)) 533 533 End Function 534 534 -
Include/Classes/System/Threading/Thread.ab
r234 r237 52 52 End Sub 53 53 54 Sub Thread(hThread As HANDLE, dwThreadId As DWord,dummy As Long)54 Sub Thread(hThread As HANDLE, dwThreadId As DWord, dummy As Long) 55 55 m_hThread=hThread 56 56 m_dwThreadId=dwThreadId … … 61 61 62 62 63 Function Equals( thread As Thread ) As Boolean 64 If m_dwThreadId = thread.m_dwThreadId Then 65 Return True 66 End If 67 Return False 68 End Function 69 70 63 Function Equals(thread As Thread) As Boolean 64 Return m_dwThreadId = thread.m_dwThreadId 65 End Function 71 66 72 67 '----------------------- … … 74 69 '----------------------- 75 70 71 76 72 'Priority Property 77 73 Sub Priority(value As ThreadPriority) … … 87 83 Return m_dwThreadId 88 84 End Function 85 89 86 90 87 … … 314 311 315 312 'カレントスレッドを取得 316 Function CurrentThread(ByRef obj_Thread As Thread) As B OOL313 Function CurrentThread(ByRef obj_Thread As Thread) As Boolean 317 314 Dim dwNowThreadId As DWord 318 315 dwNowThreadId=GetCurrentThreadId() … … 322 319 If ppobj_Thread[i]->ThreadId=dwNowThreadId Then 323 320 obj_Thread.Thread(ByVal ppobj_Thread[i]) 324 Return 1325 End If 326 Next 327 328 Return 0321 Return True 322 End If 323 Next 324 325 Return False 329 326 End Function 330 327 -
Include/Classes/System/Threading/WaitHandle.ab
r119 r237 63 63 64 64 Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL 65 Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") _66 As *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord65 TypeDef PFNSignalObjectAndWait = *Function(hObjectToSignal As HANDLE, hObjectToWaitOn As HANDLE, dwMilliseconds As DWord, bAlertable As DWord) As DWord 66 Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As PFNSignalObjectAndWait 67 67 If pSignalObjectAndWait = 0 Then 68 68 ' PlatformNotSupportedException 69 69 Debug 70 ExitThread( 0)70 ExitThread(-1) 71 71 End If 72 Return WaitHandle.AfterWait(pSignal AndWait(toSignal.Handle, toWaitOn.Handle, millisecondsTimeout As DWord), 1)72 Return WaitHandle.AfterWait(pSignalObjectAndWait(toSignal.Handle, toWaitOn.Handle, millisecondsTimeout As DWord, FALSE), 1) 73 73 End Function 74 74
Note:
See TracChangeset
for help on using the changeset viewer.