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