1 | 'basic.sbp
|
---|
2 |
|
---|
3 | #_core
|
---|
4 |
|
---|
5 | ' Unicodeが不安定な間の暫定対応
|
---|
6 | #define __STRING_IS_NOT_ALWAYS_UNICODE
|
---|
7 |
|
---|
8 |
|
---|
9 | #ifndef _INC_BASIC
|
---|
10 | #define _INC_BASIC
|
---|
11 |
|
---|
12 | Sub _System_InitDllGlobalVariables() 'dummy
|
---|
13 | End Sub
|
---|
14 |
|
---|
15 | Const QWORD_MAX = &HFFFFFFFFFFFFFFFF As QWord
|
---|
16 | Const INT64_MAX = &H7FFFFFFFFFFFFFFF As Int64
|
---|
17 | Const INT64_MIN = &H8000000000000000 As Int64
|
---|
18 |
|
---|
19 | Const DWORD_MAX = &HFFFFFFFF As DWord
|
---|
20 | Const LONG_MAX = &H7FFFFFFF As Long
|
---|
21 | Const LONG_MIN = &H80000000 As Long
|
---|
22 |
|
---|
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 |
|
---|
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
|
---|
46 | 'TypeDef Int32 = Long
|
---|
47 | 'DWord
|
---|
48 | 'Int64
|
---|
49 | 'QWord
|
---|
50 | 'Single
|
---|
51 | 'Double
|
---|
52 |
|
---|
53 | TypeDef Int16 = Integer
|
---|
54 | TypeDef Int8 = SByte
|
---|
55 |
|
---|
56 | ' Boolena型の定数
|
---|
57 | Const True = 1 As Boolean
|
---|
58 | Const False = 0 As Boolean
|
---|
59 |
|
---|
60 | ' 文字型の定義
|
---|
61 | TypeDef WCHAR = Word
|
---|
62 | #ifdef UNICODE
|
---|
63 | TypeDef Char = WCHAR
|
---|
64 | #else
|
---|
65 | TypeDef Char = SByte
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | ' 文字型
|
---|
69 | #ifdef UNICODE
|
---|
70 | TypeDef Char = Word
|
---|
71 | #else
|
---|
72 | TypeDef Char = SByte
|
---|
73 | #endif
|
---|
74 |
|
---|
75 |
|
---|
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 |
|
---|
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 |
|
---|
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 |
|
---|
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 |
|
---|
117 |
|
---|
118 | '--------------------------
|
---|
119 | ' Specify elements number
|
---|
120 | '--------------------------
|
---|
121 | Const ELM(n) = ((n) - 1)
|
---|
122 |
|
---|
123 | #require <windows.sbp>
|
---|
124 | #require <crt.sbp>
|
---|
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()
|
---|
135 | 'Unsafe
|
---|
136 |
|
---|
137 | 'この関数はアプリケーションの起動時にシステムからコールバックされます
|
---|
138 |
|
---|
139 | InitializeCriticalSection(_System_CriticalSection)
|
---|
140 |
|
---|
141 | _System_hProcessHeap=HeapCreate(HEAP_GENERATE_EXCEPTIONS,0,0)
|
---|
142 |
|
---|
143 | ' GC管理オブジェクトを初期化
|
---|
144 | _System_CGarbageCollection.Initialize()
|
---|
145 |
|
---|
146 | ' 動的型情報を生成
|
---|
147 | ActiveBasic.Core._System_TypeBase.Initialize()
|
---|
148 |
|
---|
149 | 'Initialize static variables
|
---|
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
|
---|
158 | End Sub
|
---|
159 |
|
---|
160 | Sub _System_EndProgram()
|
---|
161 | 'Unsafe
|
---|
162 |
|
---|
163 | _System_Call_Destructor_of_GlobalObject()
|
---|
164 |
|
---|
165 | ' GC管理オブジェクトを破棄
|
---|
166 | _System_pGC->Finish()
|
---|
167 | ' _System_free( _System_pGC )
|
---|
168 |
|
---|
169 | DeleteCriticalSection(_System_CriticalSection)
|
---|
170 |
|
---|
171 | HeapDestroy( _System_hProcessHeap )
|
---|
172 |
|
---|
173 | 'End Unsafe
|
---|
174 | End Sub
|
---|
175 |
|
---|
176 |
|
---|
177 | #require <system\built_in.ab>
|
---|
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>
|
---|
183 |
|
---|
184 | #require <Classes\index.ab>
|
---|
185 |
|
---|
186 |
|
---|
187 | #require <basic\function.sbp>
|
---|
188 | #require <basic\command.sbp>
|
---|
189 |
|
---|
190 |
|
---|
191 | #endif '_INC_BASIC
|
---|