source: branch/egtra-gdiplus/basic.sbp@ 374

Last change on this file since 374 was 214, checked in by dai, 18 years ago

GCでのメモリ回収処理を、実行時型情報を元に行うようにした。

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