Changeset 268 for Include/Classes/System
- Timestamp:
- Jun 2, 2007, 7:04:19 PM (17 years ago)
- Location:
- Include/Classes/System
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
Include/Classes/System/DateTime.ab
r263 r268 52 52 53 53 'Copy Constructor 54 Sub DateTime( ByRefdateTime As DateTime)54 Sub DateTime(dateTime As DateTime) 55 55 This.m_Date = dateTime.m_Date 56 56 End Sub … … 59 59 End Sub 60 60 61 Function Operator + ( ByRefvalue As TimeSpan) As DateTime61 Function Operator + (value As TimeSpan) As DateTime 62 62 Return New DateTime(Ticks + value.Ticks) 63 63 End Function 64 64 65 Function Operator - ( ByRefvalue As DateTime) As TimeSpan65 Function Operator - (value As DateTime) As TimeSpan 66 66 Return TimeSpan.FromTicks(Ticks - value.Ticks) 67 67 End Function 68 68 69 Function Operator - ( ByRefvalue As TimeSpan) As DateTime69 Function Operator - (value As TimeSpan) As DateTime 70 70 Return New DateTime(Ticks - value.Ticks) 71 71 End Function 72 72 73 Function Operator == ( ByRefvalue As DateTime) As Boolean73 Function Operator == (value As DateTime) As Boolean 74 74 Return Equals(value) 75 75 End Function 76 76 77 Function Operator <> ( ByRefvalue As DateTime) As Boolean77 Function Operator <> (value As DateTime) As Boolean 78 78 Return Not Equals(value) 79 79 End Function 80 80 81 Function Operator > ( ByRefvalue As DateTime) As Boolean81 Function Operator > (value As DateTime) As Boolean 82 82 If DateTime.Compare(This, value) > 0 Then 83 83 Return True … … 87 87 End Function 88 88 89 Function Operator < ( ByRefvalue As DateTime) As Boolean89 Function Operator < (value As DateTime) As Boolean 90 90 If DateTime.Compare(This, value) < 0 Then 91 91 Return True … … 95 95 End Function 96 96 97 Function Operator >= ( ByRefvalue As DateTime) As Boolean97 Function Operator >= (value As DateTime) As Boolean 98 98 If DateTime.Compare(This, value) => 0 Then 99 99 Return True … … 103 103 End Function 104 104 105 Function Operator <= ( ByRefvalue As DateTime) As Boolean105 Function Operator <= (value As DateTime) As Boolean 106 106 If DateTime.Compare(This, value) <= 0 Then 107 107 Return True … … 191 191 192 192 'Public Methods 193 Static Function Compare( ByRef t1 As DateTime, ByReft2 As DateTime) As Int64193 Static Function Compare(t1 As DateTime, t2 As DateTime) As Int64 194 194 Return t1.Ticks - t2.Ticks 195 195 End Function 196 196 197 Function Equals( ByRefvalue As DateTime) As Boolean197 Function Equals(value As DateTime) As Boolean 198 198 If value.m_Date = m_Date Then 199 199 Return True … … 203 203 End Function 204 204 205 Static Function Equals( ByRef t1 As DateTime, ByReft2 As DateTime) As Boolean205 Static Function Equals(t1 As DateTime, t2 As DateTime) As Boolean 206 206 If t1.m_Date = t2.m_Date Then 207 207 Return True … … 215 215 End Function 216 216 217 Function Add( ByRefvalue As TimeSpan) As DateTime217 Function Add(value As TimeSpan) As DateTime 218 218 Return This + value 219 219 End Function … … 259 259 End Function 260 260 261 Function Subtract( ByRefvalue As DateTime) As TimeSpan262 Return New DateTime(This - value)263 End Function 264 265 Function Subtract( ByRefvalue As TimeSpan) As DateTime266 Return New DateTime(This - value)261 Function Subtract(value As DateTime) As TimeSpan 262 Return This - value 263 End Function 264 265 Function Subtract(value As TimeSpan) As DateTime 266 Return This - value 267 267 End Function 268 268 -
Include/Classes/System/Environment.ab
r258 r268 3 3 #require <api_psapi.sbp> 4 4 #require <Classes/System/OperatingSystem.ab> 5 #require <Classes/ActiveBasic/Windows/index.ab> 6 7 Declare Function _System_SetEnvironmentVariable Lib "kernel32" Alias _FuncName_SetEnvironmentVariable (lpName As LPCTSTR, lpValue As LPTSTR) As BOOL 8 Declare Function _System_GetEnvironmentVariable Lib "kernel32" Alias _FuncName_GetEnvironmentVariable (lpName As PCTSTR, lpBuffer As PTSTR, nSize As DWord) As DWord 5 9 6 10 Namespace System … … 8 12 Namespace Detail 9 13 TypeDef PFNGetProcessMemoryInfo = *Function(Process As HANDLE, ByRef mc As PROCESS_MEMORY_COUNTERS, cb As DWord) As BOOL 14 15 Dim hasShutdownStarted As Boolean 10 16 End Namespace 11 17 … … 48 54 49 55 Static Function HasShutdownStarted() As Boolean 50 Return False56 Return Detail.hasShutdownStarted 51 57 End Function 52 58 … … 59 65 End If 60 66 Return machineName 61 End Function 67 End Function 62 68 63 69 Static Function NewLine() As String … … 92 98 sysDir = New String(p, len As Long) 93 99 _System_free(p) 94 End I F100 End If 95 101 Return sysDir 96 102 End Function … … 112 118 End If 113 119 Return userName 114 End Function 120 End Function 115 121 116 122 ' Version … … 126 132 If pGetProcessMemoryInfo(GetCurrentProcess(), mc, Len (mc)) <> FALSE Then 127 133 WorkingSet = mc.WorkingSetSize 128 129 134 End If 130 135 End If … … 154 159 ' GetCommandLineArgs 155 160 156 ' GetEnvironmentVariable 161 Static Function GetEnvironmentVariable(variable As String) As String 162 Dim tcsVariable = ToTCStr(variable) 163 Dim size = _System_GetEnvironmentVariable(tcsVariable, 0, 0) 164 Dim p = _System_malloc(SizeOf (TCHAR) * size) As PTSTR 165 Dim len = _System_GetEnvironmentVariable(tcsVariable, p, size) 166 GetEnvironmentVariable = New String(p, len As Long) 167 _System_free(p) 168 End Function 157 169 158 170 ' GetEnvironmentVariables … … 169 181 ' GetLogicalDrives 170 182 171 ' SetEnvironmentVariable 183 Static Sub SetEnvironmentVariable(variable As String, value As String) 184 _System_SetEnvironmentVariable(ToTCStr(variable), ToTCStr(value)) 185 End Sub 172 186 173 187 Private … … 207 221 End Enum 208 222 209 210 223 End Namespace 'System -
Include/Classes/System/Math.ab
r257 r268 1 1 ' Classes/System/Math.ab 2 3 #require <Classes/ActiveBasic/Math/Math.ab> 2 4 3 5 #ifndef __SYSTEM_MATH_AB__ 4 6 #define __SYSTEM_MATH_AB__ 7 8 Namespace System 5 9 6 10 Class Math … … 56 60 Static Function Acos(x As Double) As Double 57 61 If x < -1 Or x > 1 Then 58 Acos = _System_GetNaN()62 Acos = ActiveBasic.Math.Detail.GetNaN() 59 63 Else 60 64 Acos = _System_HalfPI - Asin(x) … … 64 68 Static Function Asin(x As Double) As Double 65 69 If x < -1 Or x > 1 Then 66 Asin = _System_GetNaN()70 Asin = ActiveBasic.Math.Detail.GetNaN() 67 71 Else 68 72 Asin = Math.Atan(x / Sqrt(1 - x * x)) … … 71 75 72 76 Static Function Atan(x As Double) As Double 73 If IsNaN(x) Then77 If ActiveBasic.Math.IsNaN(x) Then 74 78 Atan = x 75 79 Exit Function 76 ElseIf IsInf(x) Then77 Atan = CopySign(_System_PI, x)80 ElseIf ActiveBasic.Math.IsInf(x) Then 81 Atan = ActiveBasic.Math.CopySign(_System_PI, x) 78 82 Exit Function 79 83 End If … … 113 117 Atan2 = Atn(y / x) 114 118 If x < 0 Then 115 Atan2 += CopySign(_System_PI, y)119 Atan2 += ActiveBasic.Math.CopySign(_System_PI, y) 116 120 End If 117 121 End If … … 131 135 132 136 Static Function Cos(x As Double) As Double 133 If IsNaN(x) Then137 If ActiveBasic.Math.IsNaN(x) Then 134 138 Return x 135 ElseIf IsInf(x) Then136 Return _System_GetNaN()139 ElseIf ActiveBasic.Math.IsInf(x) Then 140 Return ActiveBasic.Math.Detail.GetNaN() 137 141 End If 138 142 … … 159 163 160 164 Static Function Exp(x As Double) As Double 161 If IsNaN(x) Then165 If ActiveBasic.Math.IsNaN(x) Then 162 166 Return x 163 Else If IsInf(x) Then167 Else If ActiveBasic.Math.IsInf(x) Then 164 168 If 0 > x Then 165 169 Return 0 … … 200 204 201 205 Static Function IEEERemainder(x As Double, y As Double) As Double 202 If y = 0 Then Return _System_GetNaN()206 If y = 0 Then Return ActiveBasic.Math.Detail.GetNaN() 203 207 Dim q = x / y 204 208 If q <> Int(q) Then … … 224 228 Static Function Log(x As Double) As Double 225 229 If x = 0 Then 226 Log = _System_GetInf(True)227 ElseIf x < 0 Or IsNaN(x) Then228 Log = _System_GetNaN()229 ElseIf IsInf(x) Then230 Log = ActiveBasic.Math.Detail.GetInf(True) 231 ElseIf x < 0 Or ActiveBasic.Math.IsNaN(x) Then 232 Log = ActiveBasic.Math.Detail.GetNaN() 233 ElseIf ActiveBasic.Math.IsInf(x) Then 230 234 Log = x 231 235 Else … … 236 240 SetQWord(p, m + &h0010000000000000) 237 241 x /= tmp 238 Log = _System_LOG2 * k + _System_Log1p(x - 1)242 Log = _System_LOG2 * k + ActiveBasic.Math.Detail.Log1p(x - 1) 239 243 End If 240 244 End Function … … 481 485 482 486 Static Function Sin(value As Double) As Double 483 If IsNaN(value) Then487 If ActiveBasic.Math.IsNaN(value) Then 484 488 Return value 485 ElseIf IsInf(value) Then486 Return _System_GetNaN()489 ElseIf ActiveBasic.Math.IsInf(value) Then 490 Return ActiveBasic.Math.Detail.GetNaN() 487 491 Exit Function 488 492 End If … … 514 518 Dim i As *Word, j As Long, jj As Long, k As Long 515 519 If x > 0 Then 516 If IsInf(x) Then520 If ActiveBasic.Math.IsInf(x) Then 517 521 Sqrt = x 518 522 Else … … 530 534 End If 531 535 ElseIf x < 0 Then 532 Sqrt = _System_GetNaN()536 Sqrt = ActiveBasic.Math.Detail.GetNaN() 533 537 Else 534 538 'x = 0 Or NaN … … 538 542 539 543 Static Function Tan(x As Double) As Double 540 If IsNaN(x) Then544 If ActiveBasic.Math.IsNaN(x) Then 541 545 Tan = x 542 546 Exit Function 543 ElseIf IsInf(x) Then544 Tan = _System_GetNaN()547 ElseIf ActiveBasic.Math.IsInf(x) Then 548 Tan = ActiveBasic.Math.Detail.GetNaN() 545 549 Exit Function 546 550 End If … … 554 558 Return -1 / t 555 559 Else 556 Return CopySign(_System_GetInf(FALSE), -t)560 Return ActiveBasic.Math.CopySign(ActiveBasic.Math.Detail.GetInf(False), -t) 557 561 End If 558 562 End Function … … 599 603 End Class 600 604 605 End Namespace 606 601 607 Const _System_HalfPI = (_System_PI * 0.5) 602 608 Const _System_InverseHalfPI = (2 / _System_PI) '1 / (PI / 2) … … 604 610 Const _System_InverseSqrt2 = 0.70710678118654752440084436210485 '1 / (√2) 605 611 606 607 612 #endif '__SYSTEM_MATH_AB__ -
Include/Classes/System/String.ab
r253 r268 216 216 Sub ReSize(allocLength As Long) 217 217 If allocLength < 0 Then Exit Sub 218 If allocLength > m_Length Then 219 Dim oldLength As Long 220 oldLength = m_Length 221 If AllocStringBuffer(allocLength) <> 0 Then 218 Dim oldLength = m_Length 219 If AllocStringBuffer(allocLength) <> 0 Then 220 If allocLength > oldLength Then 222 221 ZeroMemory(VarPtr(Chars[oldLength]), SizeOf (StrChar) * (m_Length - oldLength + 1)) 222 Else 223 Chars[m_Length] = 0 223 224 End If 224 Else 225 m_Length = allocLength 225 End If 226 End Sub 227 228 Sub ReSize(allocLength As Long, c As StrChar) 229 If allocLength < 0 Then Exit Sub 230 Dim oldLength = m_Length 231 If AllocStringBuffer(allocLength) <> 0 Then 232 If allocLength > oldLength Then 233 _System_FillChar(VarPtr(Chars[oldLength]), (m_Length - oldLength) As SIZE_T, c) 234 End If 226 235 Chars[m_Length] = 0 227 236 End If 228 End Sub229 230 Sub ReSize(allocLength As Long, c As StrChar)231 If allocLength < 0 Then232 Exit Sub233 ElseIf allocLength > m_Length Then234 Dim oldLength As Long235 oldLength = m_Length236 If AllocStringBuffer(allocLength) <> 0 Then237 Dim p = VarPtr(Chars[oldLength]) As *StrChar238 Dim fillLen = m_Length - oldLength239 Dim i As Long240 For i = 0 To ELM(fillLen)241 p[i] = c242 Next243 End If244 Else245 m_Length = allocLength246 End If247 Chars[m_Length] = 0248 237 End Sub 249 238 -
Include/Classes/System/TimeSpan.ab
r265 r268 20 20 End Sub 21 21 22 Sub TimeSpan( ByRefts As TimeSpan)22 Sub TimeSpan(ts As TimeSpan) 23 23 m_Time = ts.m_Time 24 24 End Sub … … 27 27 End Sub 28 28 29 Function Operator+ ( ByRefts As TimeSpan) As TimeSpan29 Function Operator+ (ts As TimeSpan) As TimeSpan 30 30 Return FromTicks(m_Time + ts.m_Time) 31 31 End Function 32 32 33 Function Operator- ( ByRefts As TimeSpan) As TimeSpan33 Function Operator- (ts As TimeSpan) As TimeSpan 34 34 Return FromTicks(m_Time - ts.m_Time) 35 35 End Function … … 43 43 End Function 44 44 45 Function Operator== ( ByRefts As TimeSpan) As Boolean45 Function Operator== (ts As TimeSpan) As Boolean 46 46 Return Equals(ts) 47 47 End Function 48 48 49 Function Operator<> ( ByRefts As TimeSpan) As Boolean49 Function Operator<> (ts As TimeSpan) As Boolean 50 50 Return Not Equals(ts) 51 51 End Function 52 52 53 Function Operator> ( ByRefts As TimeSpan) As Boolean53 Function Operator> (ts As TimeSpan) As Boolean 54 54 If CompareTo(ts) > 0 Then 55 55 Return True … … 59 59 End Function 60 60 61 Function Operator< ( ByRefts As TimeSpan) As Boolean61 Function Operator< (ts As TimeSpan) As Boolean 62 62 If CompareTo(ts) < 0 Then 63 63 Return True … … 67 67 End Function 68 68 69 Function Operator>= ( ByRefts As TimeSpan) As Boolean69 Function Operator>= (ts As TimeSpan) As Boolean 70 70 If CompareTo(ts) => 0 Then 71 71 Return True … … 75 75 End Function 76 76 77 Function Operator<= ( ByRefts As TimeSpan) As Boolean77 Function Operator<= (ts As TimeSpan) As Boolean 78 78 If CompareTo(ts) <= 0 Then 79 79 Return True … … 128 128 End Function 129 129 130 Function Add( ByRefts As TimeSpan) As TimeSpan130 Function Add(ts As TimeSpan) As TimeSpan 131 131 Return FromTicks(m_Time + ts.m_Time) 132 132 End Function 133 133 134 Static Function Compare( ByRef ts1 As TimeSpan, ByRefts2 As TimeSpan) As Long134 Static Function Compare(ts1 As TimeSpan, ts2 As TimeSpan) As Long 135 135 If ts1.m_Time < ts2.m_Time Then 136 136 Return -1 … … 142 142 End Function 143 143 144 Function CompareTo( ByRefts As TimeSpan) As Long144 Function CompareTo(ts As TimeSpan) As Long 145 145 Return (m_Time - ts.m_Time) As Long 146 146 End Function 147 147 148 148 Function Duration() As TimeSpan 149 Return FromTicks( Math.Abs(m_Time))150 End Function 151 152 Function Equals( ByRefts As TimeSpan) As Boolean149 Return FromTicks(System.Math.Abs(m_Time)) 150 End Function 151 152 Function Equals(ts As TimeSpan) As Boolean 153 153 Return Equals(This, ts) 154 154 End Function 155 155 156 Static Function Equals( ByRef ts1 As TimeSpan, ByRefts2 As TimeSpan) As Boolean156 Static Function Equals(ts1 As TimeSpan, ts2 As TimeSpan) As Boolean 157 157 If ts1.m_Time = ts2.m_Time Then 158 158 Return True … … 195 195 End Function 196 196 197 Function Subtract( ByRefts As TimeSpan) As TimeSpan197 Function Subtract(ts As TimeSpan) As TimeSpan 198 198 Return FromTicks(m_Time - ts.m_Time) 199 199 End Function
Note:
See TracChangeset
for help on using the changeset viewer.