source: Include/basic.sbp@ 258

Last change on this file since 258 was 258, checked in by イグトランス (egtra), 17 years ago

Prompt.sbp内を名前空間に入れた。EnvironmentのMachineName, UserName, GetFolderPathを実装。

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