[1] | 1 | 'basic.sbp
|
---|
| 2 |
|
---|
[304] | 3 | #_core
|
---|
| 4 |
|
---|
[168] | 5 | ' Unicodeが不安定な間の暫定対応
|
---|
| 6 | #define __STRING_IS_NOT_ALWAYS_UNICODE
|
---|
[1] | 7 |
|
---|
[168] | 8 |
|
---|
[1] | 9 | #ifndef _INC_BASIC
|
---|
| 10 | #define _INC_BASIC
|
---|
| 11 |
|
---|
| 12 | Sub _System_InitDllGlobalVariables() 'dummy
|
---|
| 13 | End Sub
|
---|
| 14 |
|
---|
[258] | 15 | Const QWORD_MAX = &HFFFFFFFFFFFFFFFF As QWord
|
---|
| 16 | Const INT64_MAX = &H7FFFFFFFFFFFFFFF As Int64
|
---|
| 17 | Const INT64_MIN = &H8000000000000000 As Int64
|
---|
[1] | 18 |
|
---|
[258] | 19 | Const DWORD_MAX = &HFFFFFFFF As DWord
|
---|
| 20 | Const LONG_MAX = &H7FFFFFFF As Long
|
---|
| 21 | Const LONG_MIN = &H80000000 As Long
|
---|
[1] | 22 |
|
---|
[258] | 23 | Const WORD_MAX = &HFFFF As Word
|
---|
| 24 | Const INTEGER_MAX = &H7FFF As Integer
|
---|
| 25 | Const INTEGER_MIN = &H8000 As Integer
|
---|
| 26 |
|
---|
| 27 | Const BYTE_MAX = &HFF As Byte
|
---|
| 28 | Const SBYTE_MAX = &H7F As SByte
|
---|
| 29 | Const SBYTE_MIN = &H80 As SByte
|
---|
| 30 |
|
---|
| 31 | Const DBL_MAX = 1.7976931348623158e+308
|
---|
| 32 | Const DBL_MIN = 2.2250738585072014e-308
|
---|
| 33 |
|
---|
[1] | 34 | Const FLT_MAX = 3.402823466e+38
|
---|
| 35 | Const FLT_MIN = 1.175494351e-38
|
---|
| 36 |
|
---|
| 37 | '-------------
|
---|
| 38 | ' Basic Types
|
---|
| 39 | '-------------
|
---|
| 40 |
|
---|
| 41 | 'Char
|
---|
| 42 | 'Byte
|
---|
| 43 | 'Integer
|
---|
| 44 | 'Word
|
---|
| 45 | 'Long
|
---|
[255] | 46 | 'TypeDef Int32 = Long
|
---|
[1] | 47 | 'DWord
|
---|
| 48 | 'Int64
|
---|
| 49 | 'QWord
|
---|
| 50 | 'Single
|
---|
| 51 | 'Double
|
---|
| 52 |
|
---|
[142] | 53 | TypeDef Int16 = Integer
|
---|
| 54 | TypeDef Int8 = SByte
|
---|
| 55 |
|
---|
[179] | 56 | ' Boolena型の定数
|
---|
[79] | 57 | Const True = 1 As Boolean
|
---|
| 58 | Const False = 0 As Boolean
|
---|
[1] | 59 |
|
---|
[179] | 60 | ' 文字型の定義
|
---|
| 61 | TypeDef WCHAR = Word
|
---|
| 62 | #ifdef UNICODE
|
---|
| 63 | TypeDef Char = WCHAR
|
---|
| 64 | #else
|
---|
| 65 | TypeDef Char = SByte
|
---|
| 66 | #endif
|
---|
[170] | 67 |
|
---|
[168] | 68 | ' 文字型
|
---|
| 69 | #ifdef UNICODE
|
---|
| 70 | TypeDef Char = Word
|
---|
| 71 | #else
|
---|
| 72 | TypeDef Char = SByte
|
---|
| 73 | #endif
|
---|
[48] | 74 |
|
---|
| 75 |
|
---|
[1] | 76 | '------------------
|
---|
| 77 | ' Types of pointer
|
---|
| 78 | '------------------
|
---|
| 79 | TypeDef BytePtr = *Byte
|
---|
| 80 | TypeDef WordPtr = *Word
|
---|
| 81 | TypeDef DWordPtr = *DWord
|
---|
| 82 | TypeDef SinglePtr = *Single
|
---|
| 83 | TypeDef DoublePtr = *Double
|
---|
| 84 |
|
---|
[150] | 85 | Sub SetPointer(pPtr As VoidPtr, p As VoidPtr)
|
---|
| 86 | Set_LONG_PTR(pPtr, p As LONG_PTR)
|
---|
| 87 | End Sub
|
---|
| 88 |
|
---|
| 89 | Function GetPointer(pPtr As VoidPtr) As VoidPtr
|
---|
| 90 | GetPointer = Get_LONG_PTR(pPtr) As VoidPtr
|
---|
| 91 | End Function
|
---|
| 92 |
|
---|
[1] | 93 | Sub Set_LONG_PTR(pPtr As VoidPtr, lpData As LONG_PTR)
|
---|
| 94 | #ifdef _WIN64
|
---|
| 95 | SetQWord(pPtr,lpData)
|
---|
| 96 | #else
|
---|
| 97 | SetDWord(pPtr,lpData)
|
---|
| 98 | #endif
|
---|
| 99 | End Sub
|
---|
| 100 |
|
---|
| 101 | Function Get_LONG_PTR(pPtr As VoidPtr) As LONG_PTR
|
---|
| 102 | #ifdef _WIN64
|
---|
| 103 | Get_LONG_PTR = GetQWord(pPtr)
|
---|
| 104 | #else
|
---|
| 105 | Get_LONG_PTR = GetDWord(pPtr)
|
---|
| 106 | #endif
|
---|
| 107 | End Function
|
---|
| 108 |
|
---|
[121] | 109 | Sub SetChar(p As *Char, c As Char)
|
---|
| 110 | p[0] = c
|
---|
| 111 | End Sub
|
---|
| 112 |
|
---|
| 113 | Function GetChar(p As *Char) As Char
|
---|
| 114 | GetChar = p[0]
|
---|
| 115 | End Function
|
---|
| 116 |
|
---|
[179] | 117 |
|
---|
[1] | 118 | '--------------------------
|
---|
| 119 | ' Specify elements number
|
---|
| 120 | '--------------------------
|
---|
[303] | 121 | Const ELM(n) = ((n) - 1)
|
---|
[1] | 122 |
|
---|
[303] | 123 | #require <windows.sbp>
|
---|
| 124 | #require <crt.sbp>
|
---|
[1] | 125 |
|
---|
| 126 |
|
---|
| 127 | Sub _System_GetEip() 'dummy
|
---|
| 128 | End Sub
|
---|
| 129 |
|
---|
| 130 |
|
---|
| 131 | Dim _System_CriticalSection As CRITICAL_SECTION
|
---|
| 132 | Dim _System_hProcessHeap As HANDLE
|
---|
| 133 |
|
---|
| 134 | Sub _System_StartupProgram()
|
---|
[146] | 135 | 'Unsafe
|
---|
[303] | 136 |
|
---|
[146] | 137 | 'この関数はアプリケーションの起動時にシステムからコールバックされます
|
---|
[1] | 138 |
|
---|
[146] | 139 | InitializeCriticalSection(_System_CriticalSection)
|
---|
[1] | 140 |
|
---|
[146] | 141 | _System_hProcessHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0)
|
---|
[1] | 142 |
|
---|
[266] | 143 | ' GC管理オブジェクトを初期化
|
---|
| 144 | _System_CGarbageCollection.Initialize()
|
---|
[1] | 145 |
|
---|
[214] | 146 | ' 動的型情報を生成
|
---|
[275] | 147 | ActiveBasic.Core._System_TypeBase.Initialize()
|
---|
[207] | 148 |
|
---|
[303] | 149 | 'Initialize static variables
|
---|
[146] | 150 | _System_InitStaticLocalVariables()
|
---|
| 151 |
|
---|
| 152 | 'TODO:
|
---|
| 153 | ' Set current thread priority
|
---|
| 154 | 'Dim thread = Thread.CurrentThread()
|
---|
| 155 | 'thread.Priority = ThreadPriority.Normal
|
---|
| 156 |
|
---|
| 157 | 'End Unsafe
|
---|
[1] | 158 | End Sub
|
---|
| 159 |
|
---|
| 160 | Sub _System_EndProgram()
|
---|
[146] | 161 | 'Unsafe
|
---|
| 162 |
|
---|
| 163 | _System_Call_Destructor_of_GlobalObject()
|
---|
| 164 |
|
---|
| 165 | ' GC管理オブジェクトを破棄
|
---|
| 166 | _System_pGC->Finish()
|
---|
[303] | 167 | ' _System_free( _System_pGC )
|
---|
[146] | 168 |
|
---|
| 169 | DeleteCriticalSection(_System_CriticalSection)
|
---|
| 170 |
|
---|
| 171 | HeapDestroy( _System_hProcessHeap )
|
---|
| 172 |
|
---|
| 173 | 'End Unsafe
|
---|
[1] | 174 | End Sub
|
---|
| 175 |
|
---|
| 176 |
|
---|
[304] | 177 | #require <system\built_in.ab>
|
---|
[303] | 178 | #require <system\string.sbp>
|
---|
| 179 | #require <system\debug.sbp>
|
---|
| 180 | #require <system\gc.sbp>
|
---|
| 181 | #require <system\enum.sbp>
|
---|
| 182 | #require <system\exception.ab>
|
---|
[1] | 183 |
|
---|
[303] | 184 | #require <Classes\index.ab>
|
---|
[1] | 185 |
|
---|
| 186 |
|
---|
[303] | 187 | #require <basic\function.sbp>
|
---|
| 188 | #require <basic\command.sbp>
|
---|
[1] | 189 |
|
---|
[303] | 190 |
|
---|
[1] | 191 | #endif '_INC_BASIC
|
---|