Delphi 7 bindings generator for IBM System Object Model 2.1
Revision | 78e1946d370aaab9f3fd250ff39d1fdadac49084 (tree) |
---|---|
Zeit | 2013-08-08 00:12:27 |
Autor | Ivan Levashew <il@payp...> |
Commiter | Ivan Levashew |
Начало портирования
@@ -0,0 +1,5 @@ | ||
1 | +syntax: glob | |
2 | +*.exe | |
3 | +*.dcu | |
4 | +*.cfg | |
5 | +*.dof |
@@ -0,0 +1,20 @@ | ||
1 | +{$IF CompilerVersion >= 16.0} | |
2 | + {$DEFINE DELPHI_HAS_UINT64} | |
3 | +{$IFEND} | |
4 | + | |
5 | +{$IF CompilerVersion >= 17.0} | |
6 | + {$DEFINE DELPHI_HAS_INLINE} | |
7 | +{$IFEND} | |
8 | + | |
9 | +{$IF CompilerVersion >= 18.0} | |
10 | + {$DEFINE DELPHI_CLASS_CAN_BE_ABSTRACT} | |
11 | + {$DEFINE DELPHI_HAS_RECORDS} | |
12 | +{$IFEND} | |
13 | + | |
14 | +{$IF CompilerVersion >= 20.0} | |
15 | + {$DEFINE DELPHI_IS_UNICODE} | |
16 | +{$IFEND} | |
17 | + | |
18 | +{$IF CompilerVersion >= 21.0} | |
19 | + {$DEFINE DELPHI_HAS_RTTI} | |
20 | +{$IFEND} |
@@ -0,0 +1,35 @@ | ||
1 | +unit | |
2 | + SOM.DelphiFeatures; | |
3 | + | |
4 | +interface | |
5 | + | |
6 | +{$INCLUDE 'SOM.DelphiFeatures.inc'} | |
7 | + | |
8 | +{$IFNDEF DELPHI_IS_UNICODE} | |
9 | +type | |
10 | + UnicodeString = type WideString; | |
11 | + | |
12 | +function UTF8ToUnicodeString(const S: UTF8String): UnicodeString; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
13 | +// Decode is deprecated, Encode is not | |
14 | +// because Encode can decide on its argument type | |
15 | + | |
16 | +{$ENDIF} | |
17 | + | |
18 | + | |
19 | +{$IFNDEF DELPHI_HAS_UINT64} | |
20 | +type | |
21 | + UInt64 = type Int64; | |
22 | +{$ENDIF} | |
23 | + | |
24 | +implementation | |
25 | + | |
26 | +{$IFNDEF DELPHI_IS_UNICODE} | |
27 | +function UTF8ToUnicodeString(const S: UTF8String): UnicodeString; | |
28 | +begin | |
29 | + Result := UTF8Decode(S); | |
30 | +end; | |
31 | +{$ENDIF} | |
32 | + | |
33 | + | |
34 | +end. | |
35 | + |
@@ -0,0 +1,260 @@ | ||
1 | +{$R-} | |
2 | + | |
3 | +unit SOM.Thin; | |
4 | + | |
5 | +interface | |
6 | + | |
7 | +uses | |
8 | + SOM.DelphiFeatures; //, Corba; | |
9 | + | |
10 | +{$INCLUDE 'SOM.DelphiFeatures.inc'} | |
11 | + | |
12 | +// #include <somplatf.h> | |
13 | + | |
14 | +type | |
15 | + somLibraryHandle = System.HMODULE; | |
16 | + | |
17 | +// #include <sombtype.h> | |
18 | + | |
19 | + somMethodProc = function(var somSelf): Pointer; cdecl; | |
20 | + somMethodPtr = somMethodProc; | |
21 | + somTP_somClassInitFunc = procedure(var somSelf); | |
22 | + | |
23 | + integer1 = Byte; (* char is unsigned by default in VisualAge C++ *) | |
24 | + integer2 = SmallInt; | |
25 | + uinteger2 = Word; | |
26 | + integer4 = LongInt; | |
27 | + uinteger4 = LongWord; | |
28 | + float4 = Single; | |
29 | + float8 = Double; | |
30 | + zString = PAnsiChar; (* NULL terminated string *) | |
31 | + fString = PAnsiChar; (* non-terminated string *) | |
32 | + somId = ^PAnsiChar; | |
33 | + somToken = Pointer; (* Uninterpretted value *) | |
34 | + signed_char = ShortInt; | |
35 | + | |
36 | +// #include <somtypes.h> | |
37 | + | |
38 | + somMethodTabStruct = record end; | |
39 | + SOMAny = record | |
40 | + mtab: ^somMethodTabStruct; | |
41 | + body: array[0 .. 0] of integer4; | |
42 | + end; | |
43 | + SOMAny_struct = SOMAny; | |
44 | + | |
45 | +(* SOM Primitive Classes *) | |
46 | +// #define SOMObject SOMAny | |
47 | +// #define SOMClass SOMAny | |
48 | +// #define SOMClassMgr SOMAny | |
49 | + | |
50 | +// #include <somcdev.h> | |
51 | + | |
52 | +(* Control the printing of method and procedure entry messages, *) | |
53 | +(* 0-none, 1-user, 2-core&user *) | |
54 | +function SOM_TraceLevel: PInteger; | |
55 | + | |
56 | +(* Control the printing of warning messages, 0-none, 1-all *) | |
57 | +function SOM_WarnLevel: PInteger; | |
58 | + | |
59 | +(* Control the printing of successful assertions, 0-none, 1-user, *) | |
60 | +(* 2-core&user *) | |
61 | +function SOM_AssertLevel: PInteger; | |
62 | + | |
63 | +(* | |
64 | + * Scans argv looking for flags -somt, -somtc, -soma -somac -somw setting | |
65 | + * SOM_TraceLevel, SOM_AssertLevel and SOM_WarnLevel as appropriate. | |
66 | + * argv is not modified | |
67 | + *) | |
68 | +procedure somCheckArgs(argc: Integer; argv: PPAnsiChar); stdcall; | |
69 | + | |
70 | + | |
71 | +(*---------------------------------------------------------------------- | |
72 | + * SOM Implementation Section | |
73 | + *---------------------------------------------------------------------*) | |
74 | + | |
75 | +(* | |
76 | + * Externals used in the implementation of SOM_Test and SOM_Assert, | |
77 | + * but not part of the SOM API. | |
78 | + *) | |
79 | +procedure somTest ( | |
80 | + condition: Integer; | |
81 | + severity: Integer; | |
82 | + fileName: PAnsiChar; | |
83 | + lineNum: Integer; | |
84 | + msg: PAnsiChar); stdcall; | |
85 | + | |
86 | +procedure somAssert ( | |
87 | + condition: Integer; | |
88 | + ecode: Integer; | |
89 | + fileName: PAnsiChar; | |
90 | + lineNum: Integer; | |
91 | + msg: PAnsiChar); stdcall; | |
92 | + | |
93 | +(* | |
94 | + * Error severity codes, these are added to the base error number to | |
95 | + * produce the full error code | |
96 | + *) | |
97 | + | |
98 | +const | |
99 | + SOM_Ok = $0; | |
100 | + SOM_Warn = $1; | |
101 | + SOM_Ignore = $2; (* don't do anything *) | |
102 | + SOM_Fatal = $9; (* terminate the program *) | |
103 | + SOM_Template = $5; (* use to identify msg templates *) | |
104 | + | |
105 | + SOM_EB = 20000; | |
106 | +function SOM_FatalCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
107 | +function SOM_WarnCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
108 | +function SOM_IgnoreCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
109 | +function SOM_OkCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
110 | +function SOM_TemplateCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
111 | +function SOM_MsgCode(ecode: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
112 | + | |
113 | +const | |
114 | + SOMERROR_MustOverride = SOM_EB + 18 * 10 + SOM_Fatal | |
115 | + | |
116 | +// #include <somcorba.h> | |
117 | +// #include <somapi.h> | |
118 | + | |
119 | +// #include <somobj.h> | |
120 | +// #include <somcls.h> | |
121 | +// #include <somcm.h> | |
122 | + | |
123 | +implementation | |
124 | + | |
125 | +uses | |
126 | + Windows; | |
127 | + | |
128 | +const | |
129 | + SOM_DLL_Name = 'som.dll'; | |
130 | +var | |
131 | + SOM_DLL: System.HMODULE = 0; | |
132 | + DLLLoad_CriticalSection : Windows.TRTLCriticalSection; | |
133 | + | |
134 | +// #include <somcdev.h> | |
135 | +var | |
136 | + SOM_DLL_SOM_TraceLevel: PInteger; | |
137 | + | |
138 | +function SOM_TraceLevel: PInteger; | |
139 | +begin | |
140 | + if Assigned(SOM_DLL_SOM_TraceLevel) then | |
141 | + Result := SOM_DLL_SOM_TraceLevel | |
142 | + else | |
143 | + begin | |
144 | + if SOM_DLL = 0 then | |
145 | + begin | |
146 | + Windows.EnterCriticalSection(DLLLoad_CriticalSection); | |
147 | + if SOM_DLL = 0 then | |
148 | + SOM_DLL := Windows.LoadLibrary(SOM_DLL_Name); | |
149 | + Windows.LeaveCriticalSection(DLLLoad_CriticalSection); | |
150 | + end; | |
151 | + if SOM_DLL = 0 then | |
152 | + Result := nil | |
153 | + else | |
154 | + begin | |
155 | + SOM_DLL_SOM_TraceLevel := Windows.GetProcAddress(SOM_DLL, 'SOM_TraceLevel'); | |
156 | + Result := SOM_DLL_SOM_TraceLevel; | |
157 | + end; | |
158 | + end; | |
159 | +end; | |
160 | + | |
161 | +var | |
162 | + SOM_DLL_SOM_WarnLevel: PInteger; | |
163 | + | |
164 | +function SOM_WarnLevel: PInteger; | |
165 | +begin | |
166 | + if Assigned(SOM_DLL_SOM_WarnLevel) then | |
167 | + Result := SOM_DLL_SOM_WarnLevel | |
168 | + else | |
169 | + begin | |
170 | + if SOM_DLL = 0 then | |
171 | + begin | |
172 | + Windows.EnterCriticalSection(DLLLoad_CriticalSection); | |
173 | + if SOM_DLL = 0 then | |
174 | + SOM_DLL := Windows.LoadLibrary(SOM_DLL_Name); | |
175 | + Windows.LeaveCriticalSection(DLLLoad_CriticalSection); | |
176 | + end; | |
177 | + if SOM_DLL = 0 then | |
178 | + Result := nil | |
179 | + else | |
180 | + begin | |
181 | + SOM_DLL_SOM_WarnLevel := Windows.GetProcAddress(SOM_DLL, 'SOM_WarnLevel'); | |
182 | + Result := SOM_DLL_SOM_WarnLevel; | |
183 | + end; | |
184 | + end; | |
185 | +end; | |
186 | + | |
187 | +var | |
188 | + SOM_DLL_SOM_AssertLevel: PInteger; | |
189 | + | |
190 | +function SOM_AssertLevel: PInteger; | |
191 | +begin | |
192 | + if Assigned(SOM_DLL_SOM_AssertLevel) then | |
193 | + Result := SOM_DLL_SOM_AssertLevel | |
194 | + else | |
195 | + begin | |
196 | + if SOM_DLL = 0 then | |
197 | + begin | |
198 | + Windows.EnterCriticalSection(DLLLoad_CriticalSection); | |
199 | + if SOM_DLL = 0 then | |
200 | + SOM_DLL := Windows.LoadLibrary(SOM_DLL_Name); | |
201 | + Windows.LeaveCriticalSection(DLLLoad_CriticalSection); | |
202 | + end; | |
203 | + if SOM_DLL = 0 then | |
204 | + Result := nil | |
205 | + else | |
206 | + begin | |
207 | + SOM_DLL_SOM_AssertLevel := Windows.GetProcAddress(SOM_DLL, 'SOM_AssertLevel'); | |
208 | + Result := SOM_DLL_SOM_AssertLevel; | |
209 | + end; | |
210 | + end; | |
211 | +end; | |
212 | + | |
213 | +procedure somCheckArgs; external SOM_DLL_Name; | |
214 | +procedure somTest; external SOM_DLL_Name; | |
215 | +procedure somAssert; external SOM_DLL_Name; | |
216 | + | |
217 | +function SOM_FatalCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
218 | +begin | |
219 | + Result := SOM_EB + code * 10 + SOM_Fatal; | |
220 | +end; | |
221 | +function SOM_WarnCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
222 | +begin | |
223 | + Result := SOM_EB + code * 10 + SOM_Warn; | |
224 | +end; | |
225 | +function SOM_IgnoreCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
226 | +begin | |
227 | + Result := SOM_EB + code * 10 + SOM_Ignore; | |
228 | +end; | |
229 | +function SOM_OkCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
230 | +begin | |
231 | + Result := SOM_EB + code * 10 + SOM_Ok; | |
232 | +end; | |
233 | +function SOM_TemplateCode(code: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
234 | +begin | |
235 | + Result := SOM_EB + code * 10 + SOM_Template; | |
236 | +end; | |
237 | +function SOM_MsgCode(ecode: Integer): Integer; {$IFDEF DELPHI_HAS_INLINE} inline; {$ENDIF} | |
238 | +begin | |
239 | + Result := (ecode - SOM_EB) div 10; | |
240 | +end; | |
241 | + | |
242 | +// #include <somcorba.h> | |
243 | +// #include <somapi.h> | |
244 | + | |
245 | +// #include <somobj.h> | |
246 | +// #include <somcls.h> | |
247 | +// #include <somcm.h> | |
248 | + | |
249 | +initialization | |
250 | + Windows.InitializeCriticalSection(DLLLoad_CriticalSection); | |
251 | + | |
252 | +finalization | |
253 | + if SOM_DLL <> 0 then | |
254 | + begin | |
255 | + Windows.EnterCriticalSection(DLLLoad_CriticalSection); | |
256 | + FreeLibrary(SOM_DLL); | |
257 | + Windows.LeaveCriticalSection(DLLLoad_CriticalSection); | |
258 | + end; | |
259 | + Windows.DeleteCriticalSection(DLLLoad_CriticalSection); | |
260 | +end. |
@@ -0,0 +1,7 @@ | ||
1 | +unit SOM; | |
2 | + | |
3 | +interface | |
4 | + | |
5 | +implementation | |
6 | + | |
7 | +end. |
@@ -0,0 +1,13 @@ | ||
1 | +program SOMClientTest; | |
2 | + | |
3 | +{$APPTYPE CONSOLE} | |
4 | + | |
5 | +uses | |
6 | + SysUtils, | |
7 | + SOM in 'SOM.pas', | |
8 | + SOM.Thin in 'SOM.Thin.pas', | |
9 | + SOM.DelphiFeatures in 'SOM.DelphiFeatures.pas'; | |
10 | + | |
11 | +begin | |
12 | + { TODO -oUser -cConsole Main : Insert code here } | |
13 | +end. |