[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 |
|
---|
[170] | 40 | ' Boolean型の定数
|
---|
[79] | 41 | Const True = 1 As Boolean
|
---|
| 42 | Const False = 0 As Boolean
|
---|
[1] | 43 |
|
---|
[170] | 44 | ' BOOL型の定数(Booleanへの移行を推奨)
|
---|
| 45 | Const _System_TRUE = -1
|
---|
| 46 | Const _System_FALSE = 0
|
---|
| 47 |
|
---|
[168] | 48 | ' 文字型
|
---|
| 49 | #ifdef UNICODE
|
---|
| 50 | TypeDef Char = Word
|
---|
| 51 | #else
|
---|
| 52 | TypeDef Char = SByte
|
---|
| 53 | #endif
|
---|
[48] | 54 |
|
---|
| 55 |
|
---|
[1] | 56 | '------------------
|
---|
| 57 | ' Types of pointer
|
---|
| 58 | '------------------
|
---|
| 59 | TypeDef BytePtr = *Byte
|
---|
| 60 | TypeDef WordPtr = *Word
|
---|
| 61 | TypeDef DWordPtr = *DWord
|
---|
| 62 | TypeDef SinglePtr = *Single
|
---|
| 63 | TypeDef DoublePtr = *Double
|
---|
| 64 |
|
---|
[150] | 65 | Sub SetPointer(pPtr As VoidPtr, p As VoidPtr)
|
---|
| 66 | Set_LONG_PTR(pPtr, p As LONG_PTR)
|
---|
| 67 | End Sub
|
---|
| 68 |
|
---|
| 69 | Function GetPointer(pPtr As VoidPtr) As VoidPtr
|
---|
| 70 | GetPointer = Get_LONG_PTR(pPtr) As VoidPtr
|
---|
| 71 | End Function
|
---|
| 72 |
|
---|
[1] | 73 | Sub Set_LONG_PTR(pPtr As VoidPtr, lpData As LONG_PTR)
|
---|
| 74 | #ifdef _WIN64
|
---|
| 75 | SetQWord(pPtr,lpData)
|
---|
| 76 | #else
|
---|
| 77 | SetDWord(pPtr,lpData)
|
---|
| 78 | #endif
|
---|
| 79 | End Sub
|
---|
| 80 |
|
---|
| 81 | Function Get_LONG_PTR(pPtr As VoidPtr) As LONG_PTR
|
---|
| 82 | #ifdef _WIN64
|
---|
| 83 | Get_LONG_PTR = GetQWord(pPtr)
|
---|
| 84 | #else
|
---|
| 85 | Get_LONG_PTR = GetDWord(pPtr)
|
---|
| 86 | #endif
|
---|
| 87 | End Function
|
---|
| 88 |
|
---|
[121] | 89 | Sub SetChar(p As *Char, c As Char)
|
---|
| 90 | p[0] = c
|
---|
| 91 | End Sub
|
---|
| 92 |
|
---|
| 93 | Function GetChar(p As *Char) As Char
|
---|
| 94 | GetChar = p[0]
|
---|
| 95 | End Function
|
---|
| 96 |
|
---|
[1] | 97 | '--------------------------
|
---|
| 98 | ' Specify elements number
|
---|
| 99 | '--------------------------
|
---|
[121] | 100 | Const ELM(n) = (n - 1)
|
---|
[1] | 101 |
|
---|
| 102 | #include <windows.sbp>
|
---|
| 103 | #include <crt.sbp>
|
---|
| 104 | #include <objbase.sbp>
|
---|
| 105 |
|
---|
| 106 |
|
---|
| 107 | Sub _System_GetEip() 'dummy
|
---|
| 108 | End Sub
|
---|
| 109 |
|
---|
| 110 |
|
---|
| 111 | Dim _System_CriticalSection As CRITICAL_SECTION
|
---|
| 112 | Dim _System_hProcessHeap As HANDLE
|
---|
| 113 |
|
---|
| 114 | Sub _System_StartupProgram()
|
---|
[146] | 115 | 'Unsafe
|
---|
[1] | 116 |
|
---|
[146] | 117 | 'この関数はアプリケーションの起動時にシステムからコールバックされます
|
---|
[1] | 118 |
|
---|
[146] | 119 | InitializeCriticalSection(_System_CriticalSection)
|
---|
[1] | 120 |
|
---|
[146] | 121 | _System_hProcessHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0)
|
---|
[1] | 122 |
|
---|
[146] | 123 | ' GC管理オブジェクトを生成
|
---|
| 124 | _System_pGC = _System_calloc( SizeOf( _System_CGarbageCollection ) )
|
---|
| 125 | _System_pGC->Begin()
|
---|
[1] | 126 |
|
---|
[146] | 127 | 'Initialize global variables
|
---|
| 128 | _System_InitDllGlobalVariables()
|
---|
| 129 |
|
---|
| 130 | 'Initialize static variables
|
---|
| 131 | _System_InitStaticLocalVariables()
|
---|
| 132 |
|
---|
| 133 | 'TODO:
|
---|
| 134 | ' Set current thread priority
|
---|
| 135 | 'Dim thread = Thread.CurrentThread()
|
---|
| 136 | 'thread.Priority = ThreadPriority.Normal
|
---|
| 137 |
|
---|
| 138 | 'End Unsafe
|
---|
[1] | 139 | End Sub
|
---|
| 140 |
|
---|
| 141 | Sub _System_EndProgram()
|
---|
[146] | 142 | 'Unsafe
|
---|
| 143 |
|
---|
| 144 | _System_Call_Destructor_of_GlobalObject()
|
---|
| 145 |
|
---|
| 146 | ' GC管理オブジェクトを破棄
|
---|
| 147 | _System_pGC->Finish()
|
---|
| 148 | _System_free( _System_pGC )
|
---|
| 149 |
|
---|
| 150 | DeleteCriticalSection(_System_CriticalSection)
|
---|
| 151 |
|
---|
| 152 | HeapDestroy( _System_hProcessHeap )
|
---|
| 153 |
|
---|
| 154 | 'End Unsafe
|
---|
[1] | 155 | End Sub
|
---|
| 156 |
|
---|
| 157 |
|
---|
| 158 |
|
---|
| 159 | #include <system\string.sbp>
|
---|
| 160 | #include <system\debug.sbp>
|
---|
| 161 | #include <system\gc.sbp>
|
---|
| 162 | #include <system\enum.sbp>
|
---|
[58] | 163 | #include <system\exception.ab>
|
---|
[1] | 164 |
|
---|
| 165 | #include <Classes\index.ab>
|
---|
| 166 |
|
---|
| 167 |
|
---|
| 168 | #include <basic\function.sbp>
|
---|
| 169 | #include <basic\command.sbp>
|
---|
| 170 |
|
---|
| 171 |
|
---|
| 172 | #endif '_INC_BASIC
|
---|