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