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