author | Claus Gittinger <cg@exept.de> |
Mon, 14 Mar 2016 17:04:58 +0100 | |
changeset 19357 | 3e007f7f1969 |
parent 19356 | 5ca3989a13f0 |
child 19364 | 4bf0b2b33b65 |
permissions | -rw-r--r-- |
19311 | 1 |
"{ Encoding: utf8 }" |
2 |
||
8728 | 3 |
" |
4 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
9464 | 5 |
All Rights Reserved |
8728 | 6 |
|
7 |
This software is furnished under a license and may be used |
|
8 |
only in accordance with the terms of that license and with the |
|
9 |
inclusion of the above copyright notice. This software may not |
|
10 |
be provided or otherwise made available to, or used by, any |
|
11 |
other person. No title to or ownership of the software is |
|
12 |
hereby transferred. |
|
13 |
" |
|
8533 | 14 |
"{ Package: 'stx:libbasic' }" |
15 |
||
19311 | 16 |
"{ NameSpace: Smalltalk }" |
17 |
||
8533 | 18 |
ExternalFunction subclass:#ExternalLibraryFunction |
9465 | 19 |
instanceVariableNames:'flags moduleName returnType argumentTypes owningClass' |
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
20 |
classVariableNames:'DLLPATH FLAG_VIRTUAL FLAG_NONVIRTUAL FLAG_OBJECTIVEC FLAG_ASYNC |
10270 | 21 |
FLAG_UNLIMITEDSTACK FLAG_RETVAL_IS_CONST CALLTYPE_MASK |
22 |
CALLTYPE_API CALLTYPE_C CALLTYPE_OLE CALLTYPE_V8 CALLTYPE_V9 |
|
19342 | 23 |
CALLTYPE_UNIX64 DllMapping Verbose LastModuleHandleHolder |
24 |
LastModuleHandleName' |
|
9464 | 25 |
poolDictionaries:'' |
26 |
category:'System-Support' |
|
8533 | 27 |
! |
28 |
||
9322 | 29 |
!ExternalLibraryFunction primitiveDefinitions! |
30 |
%{ |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
31 |
#define VERBOSE |
9322 | 32 |
|
9337 | 33 |
#ifdef HAVE_FFI |
34 |
# include <ffi.h> |
|
9322 | 35 |
# define MAX_ARGS 128 |
9365 | 36 |
|
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
37 |
# ifdef USE_STANDARD_FFI |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
38 |
# define __get_ffi_type_sint() &ffi_type_sint |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
39 |
# define __get_ffi_type_sint8() &ffi_type_sint8 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
40 |
# define __get_ffi_type_sint16() &ffi_type_sint16 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
41 |
# define __get_ffi_type_sint32() &ffi_type_sint32 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
42 |
# define __get_ffi_type_sint64() &ffi_type_sint64 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
43 |
# define __get_ffi_type_uint() &ffi_type_uint |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
44 |
# define __get_ffi_type_uint8() &ffi_type_uint8 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
45 |
# define __get_ffi_type_uint16() &ffi_type_uint16 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
46 |
# define __get_ffi_type_uint32() &ffi_type_uint32 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
47 |
# define __get_ffi_type_uint64() &ffi_type_uint64 |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
48 |
# define __get_ffi_type_float() &ffi_type_float |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
49 |
# define __get_ffi_type_double() &ffi_type_double |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
50 |
# define __get_ffi_type_void() &ffi_type_void |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
51 |
# define __get_ffi_type_pointer() &ffi_type_pointer |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
52 |
# else |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
53 |
extern ffi_type *__get_ffi_type_sint(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
54 |
extern ffi_type *__get_ffi_type_sint8(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
55 |
extern ffi_type *__get_ffi_type_sint16(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
56 |
extern ffi_type *__get_ffi_type_sint32(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
57 |
extern ffi_type *__get_ffi_type_sint64(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
58 |
extern ffi_type *__get_ffi_type_uint(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
59 |
extern ffi_type *__get_ffi_type_uint8(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
60 |
extern ffi_type *__get_ffi_type_uint16(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
61 |
extern ffi_type *__get_ffi_type_uint32(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
62 |
extern ffi_type *__get_ffi_type_uint64(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
63 |
extern ffi_type *__get_ffi_type_float(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
64 |
extern ffi_type *__get_ffi_type_double(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
65 |
extern ffi_type *__get_ffi_type_void(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
66 |
extern ffi_type *__get_ffi_type_pointer(); |
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
67 |
# endif |
9365 | 68 |
|
9337 | 69 |
#endif |
9322 | 70 |
|
71 |
%} |
|
72 |
! ! |
|
73 |
||
8728 | 74 |
!ExternalLibraryFunction class methodsFor:'documentation'! |
75 |
||
76 |
copyright |
|
77 |
" |
|
78 |
COPYRIGHT (c) 2004 by eXept Software AG |
|
9464 | 79 |
All Rights Reserved |
8728 | 80 |
|
81 |
This software is furnished under a license and may be used |
|
82 |
only in accordance with the terms of that license and with the |
|
83 |
inclusion of the above copyright notice. This software may not |
|
84 |
be provided or otherwise made available to, or used by, any |
|
85 |
other person. No title to or ownership of the software is |
|
86 |
hereby transferred. |
|
87 |
" |
|
9322 | 88 |
! |
89 |
||
9331 | 90 |
documentation |
91 |
" |
|
92 |
instances of me are used to interface to external library functions (as found in a dll/shared object). |
|
93 |
||
12680 | 94 |
Inside a method, when a special external-call pragma such as: |
14625 | 95 |
<api: bool MessageBeep(uint)> |
12680 | 96 |
|
97 |
is encountered by the parser, the compiler generates a call via |
|
14625 | 98 |
<correspondingExternalLibraryFunctionObject> invokeWithArguments: argumentArray. |
9331 | 99 |
|
100 |
In the invoke method, the library is checked to be loaded (and loaded if not already), |
|
9336 | 101 |
the arguments are converted to C and pushed onto the C-stack, the function is called, |
9331 | 102 |
and finally, the return value is converted back from C to a smalltalk object. |
12680 | 103 |
|
104 |
The parser supports the call-syntax of various other smalltalk dialects: |
|
14625 | 105 |
Squeak / ST-X: |
106 |
<cdecl: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName > |
|
107 |
<apicall: [async] [virtual|nonVirtual][const] returnType functionNameStringOrIndex ( argType1..argTypeN ) module: moduleName > |
|
12680 | 108 |
|
14625 | 109 |
Dolphin: |
110 |
<stdcall: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN> |
|
111 |
<cdecl: [virtual|nonVirtual][const] returnType functionNameStringOrIndex argType1..argTypeN> |
|
12680 | 112 |
|
14625 | 113 |
ST/V: |
114 |
<api: functionName argType1 .. argTypeN returnType> |
|
115 |
<ccall: functionName argType1 .. argTypeN returnType> |
|
116 |
<ole: vFunctionIndex argType1 .. argTypeN returnType> |
|
12680 | 117 |
|
14625 | 118 |
VisualWorks: |
119 |
<c: ...> |
|
120 |
<c: #define NAME value> |
|
9331 | 121 |
" |
122 |
! |
|
123 |
||
9322 | 124 |
example |
125 |
" |
|
14625 | 126 |
[exBegin] |
127 |
|f| |
|
14037 | 128 |
|
14625 | 129 |
f := ExternalLibraryFunction new. |
130 |
f beCallTypeWINAPI. |
|
14037 | 131 |
|
14625 | 132 |
f name:'MessageBeep' |
133 |
module:'user32.dll' |
|
134 |
returnType:#boolean |
|
135 |
argumentTypes:#(uint). |
|
14037 | 136 |
|
14625 | 137 |
f invokeWith:1. |
138 |
[exEnd] |
|
14037 | 139 |
|
140 |
Synchronous vs. Asynchronous calls: |
|
141 |
||
14516
359e4d2234af
class: ExternalLibraryFunction
Stefan Vogel <sv@exept.de>
parents:
14506
diff
changeset
|
142 |
by default, foreign function calls are synchronous, effectively blocking the whole ST/X system |
19311 | 143 |
(that is by purpose,´because most C-code is not prepared for being interrupted, and also, normal |
14037 | 144 |
code is not prepared for a garbage collector to move objects around, while another C thread might |
145 |
access the data...). |
|
14625 | 146 |
Therefore, the following will block all ST/X activity for 10 seconds |
14037 | 147 |
(try interacting with the launcher while the Sleep is performing): |
148 |
||
14625 | 149 |
[exBegin] |
150 |
|f| |
|
9322 | 151 |
|
14625 | 152 |
f := ExternalLibraryFunction new. |
153 |
f beCallTypeWINAPI. |
|
14037 | 154 |
|
14625 | 155 |
f name:'Sleep' |
156 |
module:'kernel32.dll' |
|
157 |
returnType:#void |
|
158 |
argumentTypes:#(uint). |
|
14037 | 159 |
|
14625 | 160 |
f invokeWith:10000. |
161 |
[exEnd] |
|
9322 | 162 |
|
14037 | 163 |
if you know what you do and you do not pass any possibly moving objects (such as strings) as argument, |
164 |
the call can be made asynchronous. In that case, ONLY the calling thread will be blocked; all other smalltalk |
|
165 |
threads wil continue to execute. |
|
166 |
(try interacting now with the launcher while the Sleep is performing): |
|
14625 | 167 |
[exBegin] |
168 |
|f| |
|
14037 | 169 |
|
14625 | 170 |
f := ExternalLibraryFunction new. |
171 |
f beCallTypeWINAPI. |
|
172 |
f beAsync. |
|
14037 | 173 |
|
14625 | 174 |
f name:'Sleep' |
175 |
module:'kernel32.dll' |
|
176 |
returnType:#void |
|
177 |
argumentTypes:#(uint). |
|
14037 | 178 |
|
14625 | 179 |
f invokeWith:10000. |
180 |
[exEnd] |
|
14037 | 181 |
|
9322 | 182 |
" |
8728 | 183 |
! ! |
8533 | 184 |
|
8550 | 185 |
!ExternalLibraryFunction class methodsFor:'instance creation'! |
186 |
||
9465 | 187 |
name:functionName module:moduleName returnType:returnType argumentTypes:argTypes |
8550 | 188 |
^ self new |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
189 |
name:functionName module:moduleName |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
190 |
returnType:returnType argumentTypes:argTypes |
9465 | 191 |
|
192 |
"Created: / 01-08-2006 / 15:19:08 / cg" |
|
9463 | 193 |
! ! |
194 |
||
195 |
!ExternalLibraryFunction class methodsFor:'class initialization'! |
|
196 |
||
11050 | 197 |
addToDllPath:aDirectoryPathName |
198 |
"can be used during initialization, to add more places for dll-loading" |
|
199 |
||
11053 | 200 |
|oldPath| |
201 |
||
202 |
oldPath := self dllPath. |
|
203 |
(oldPath includes:aDirectoryPathName) ifFalse:[ |
|
11586 | 204 |
self dllPath:(oldPath asOrderedCollection copyWith:aDirectoryPathName) |
11053 | 205 |
] |
11050 | 206 |
! |
207 |
||
14103 | 208 |
dllMapping |
209 |
"allows for dll's to be replaced, |
|
210 |
for example, if you want to use the mozilla sqlite dll |
|
14625 | 211 |
C:\Program Files\Mozilla Firefox\mozsqlite3.dll |
14103 | 212 |
for the sqlite3, execute: |
14625 | 213 |
ExternalLibraryFunction |
214 |
dllMapping at:'sqlite3' |
|
215 |
put: 'C:\Program Files\Mozilla Firefox\mozsqlite3.dll' |
|
14103 | 216 |
" |
217 |
||
218 |
DllMapping isNil ifTrue:[ |
|
14625 | 219 |
DllMapping := Dictionary new. |
14103 | 220 |
]. |
221 |
^ DllMapping |
|
222 |
||
223 |
"Created: / 10-04-2012 / 12:21:45 / cg" |
|
224 |
! |
|
225 |
||
10270 | 226 |
dllPath |
13337 | 227 |
^ DLLPATH |
10270 | 228 |
! |
229 |
||
230 |
dllPath:aCollectionOfDirectoryPathNames |
|
231 |
DLLPATH := aCollectionOfDirectoryPathNames |
|
232 |
! |
|
233 |
||
9463 | 234 |
initialize |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
235 |
"using inline access to corresponding c--defines to avoid duplicate places of knowledge" |
13337 | 236 |
|
237 |
DLLPATH isNil ifTrue:[ |
|
14625 | 238 |
DLLPATH := #('.'). |
18228 | 239 |
%{ |
18240
28af09029a8b
ifdef for SCHTEAM engine changed (not relevant for ST/X)
Claus Gittinger <cg@exept.de>
parents:
18228
diff
changeset
|
240 |
#ifndef __SCHTEAM__ |
18228 | 241 |
@global(FLAG_VIRTUAL) = __MKSMALLINT(__EXTL_FLAG_VIRTUAL); // a virtual c++ call |
242 |
@global(FLAG_NONVIRTUAL) = __MKSMALLINT(__EXTL_FLAG_NONVIRTUAL); // a non-virtual c++ call |
|
243 |
@global(FLAG_OBJECTIVEC) = __MKSMALLINT(__EXTL_FLAG_OBJECTIVEC); // an objectiveC message send |
|
244 |
@global(FLAG_UNLIMITEDSTACK) = __MKSMALLINT(__EXTL_FLAG_UNLIMITEDSTACK); // unlimitedstack under unix |
|
245 |
@global(FLAG_ASYNC) = __MKSMALLINT(__EXTL_FLAG_ASYNC); // async under win32 |
|
246 |
@global(FLAG_RETVAL_IS_CONST) = __MKSMALLINT(__EXTL_FLAG_RETVAL_IS_CONST); // return value is not to be registered for finalization |
|
9463 | 247 |
|
18228 | 248 |
@global(CALLTYPE_API) = __MKSMALLINT(__EXTL_CALLTYPE_API); // WINAPI-call (win32 only) |
249 |
@global(CALLTYPE_C) = __MKSMALLINT(__EXTL_CALLTYPE_C); // regular C-call (the default) |
|
250 |
@global(CALLTYPE_V8) = __MKSMALLINT(__EXTL_CALLTYPE_V8); // v8 call (sparc only) |
|
251 |
@global(CALLTYPE_V9) = __MKSMALLINT(__EXTL_CALLTYPE_V9); // v9 call (sparc only) |
|
252 |
@global(CALLTYPE_UNIX64) = __MKSMALLINT(__EXTL_CALLTYPE_UNIX64); // unix64 call (alpha only) |
|
9463 | 253 |
|
18228 | 254 |
@global(CALLTYPE_MASK) = __MKSMALLINT(__EXTL_CALLTYPE_MASK); |
255 |
#endif |
|
256 |
%} |
|
13337 | 257 |
]. |
9465 | 258 |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
259 |
" |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
260 |
self initialize |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
261 |
" |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
262 |
|
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
263 |
"Modified: / 03-10-2006 / 21:27:47 / cg" |
11053 | 264 |
! |
265 |
||
266 |
removeFromDllPath:aDirectoryPathName |
|
267 |
"remove added places from dll-loading" |
|
268 |
||
269 |
|oldPath| |
|
270 |
||
271 |
oldPath := self dllPath. |
|
272 |
self dllPath:(oldPath asOrderedCollection copyWithout:aDirectoryPathName) |
|
273 |
||
274 |
" |
|
275 |
self dllPath. |
|
11586 | 276 |
self addToDllPath:'C:\aaa\bbb'. |
11053 | 277 |
self dllPath. |
278 |
self removeFromDllPath:'C:\aaa\bbb'. |
|
279 |
self dllPath. |
|
280 |
" |
|
8550 | 281 |
! ! |
282 |
||
9321 | 283 |
!ExternalLibraryFunction class methodsFor:'constants'! |
284 |
||
285 |
callTypeAPI |
|
9463 | 286 |
^ CALLTYPE_API |
9321 | 287 |
|
9463 | 288 |
"Modified: / 01-08-2006 / 13:44:41 / cg" |
9435 | 289 |
! |
290 |
||
9321 | 291 |
callTypeC |
9463 | 292 |
^ CALLTYPE_C |
9321 | 293 |
|
9463 | 294 |
"Modified: / 01-08-2006 / 13:44:49 / cg" |
9435 | 295 |
! |
296 |
||
9321 | 297 |
callTypeCDecl |
9463 | 298 |
^ CALLTYPE_C |
9321 | 299 |
|
9463 | 300 |
"Modified: / 01-08-2006 / 13:44:52 / cg" |
9435 | 301 |
! |
302 |
||
10619 | 303 |
callTypeMASK |
304 |
^ CALLTYPE_MASK |
|
305 |
||
306 |
"Modified: / 01-08-2006 / 13:44:57 / cg" |
|
307 |
! |
|
308 |
||
9321 | 309 |
callTypeOLE |
9463 | 310 |
^ CALLTYPE_OLE |
9435 | 311 |
|
9463 | 312 |
"Modified: / 01-08-2006 / 13:44:57 / cg" |
9321 | 313 |
! ! |
314 |
||
315 |
!ExternalLibraryFunction methodsFor:'accessing'! |
|
316 |
||
317 |
argumentTypes |
|
318 |
^ argumentTypes |
|
9463 | 319 |
! |
320 |
||
11426 | 321 |
argumentTypesString |
11586 | 322 |
^ String |
323 |
streamContents:[:s | |
|
324 |
argumentTypes do:[:eachArgType | |
|
325 |
eachArgType printOn:s. |
|
326 |
] separatedBy:[ |
|
327 |
s nextPutAll:','. |
|
328 |
]. |
|
329 |
]. |
|
11426 | 330 |
! |
331 |
||
9463 | 332 |
beAsync |
333 |
"let this execute in a separate thread, in par with the other execution thread(s). |
|
334 |
Ignored under unix/linux (until those support multiple threads too)." |
|
335 |
||
336 |
flags := (flags ? 0) bitOr: FLAG_ASYNC. |
|
337 |
||
338 |
"Created: / 01-08-2006 / 13:42:38 / cg" |
|
339 |
! |
|
340 |
||
9465 | 341 |
beCallTypeAPI |
342 |
flags := (flags ? 0) bitOr: CALLTYPE_API. |
|
343 |
||
344 |
"Created: / 01-08-2006 / 15:12:40 / cg" |
|
345 |
! |
|
346 |
||
347 |
beCallTypeC |
|
348 |
flags := (flags ? 0) bitOr: CALLTYPE_C. |
|
349 |
||
350 |
"Created: / 01-08-2006 / 15:12:40 / cg" |
|
351 |
! |
|
352 |
||
10481 | 353 |
beCallTypeOLE |
354 |
flags := (flags ? 0) bitOr: FLAG_VIRTUAL. |
|
355 |
||
356 |
"Created: / 01-08-2006 / 15:12:40 / cg" |
|
357 |
! |
|
358 |
||
9465 | 359 |
beCallTypeUNIX64 |
360 |
flags := (flags ? 0) bitOr: CALLTYPE_UNIX64. |
|
361 |
||
362 |
"Created: / 01-08-2006 / 15:13:38 / cg" |
|
363 |
! |
|
364 |
||
365 |
beCallTypeV8 |
|
366 |
flags := (flags ? 0) bitOr: CALLTYPE_V8. |
|
367 |
||
368 |
"Created: / 01-08-2006 / 15:13:28 / cg" |
|
369 |
! |
|
370 |
||
371 |
beCallTypeV9 |
|
372 |
flags := (flags ? 0) bitOr: CALLTYPE_V9. |
|
373 |
||
374 |
"Created: / 01-08-2006 / 15:13:31 / cg" |
|
375 |
! |
|
376 |
||
377 |
beCallTypeWINAPI |
|
378 |
self beCallTypeAPI |
|
379 |
||
380 |
"Modified: / 01-08-2006 / 15:14:02 / cg" |
|
381 |
! |
|
382 |
||
9525 | 383 |
beConstReturnValue |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
384 |
"specify that a pointer return value is not to be finalized |
9525 | 385 |
(i.e. points to static data or data which is freed by c)" |
386 |
||
387 |
flags := (flags ? 0) bitOr: FLAG_RETVAL_IS_CONST. |
|
388 |
||
389 |
"Created: / 01-08-2006 / 13:56:48 / cg" |
|
390 |
! |
|
391 |
||
9463 | 392 |
beNonVirtualCPP |
393 |
"specify this as a non-virtual c++-function" |
|
394 |
||
395 |
flags := (flags ? 0) bitOr: FLAG_NONVIRTUAL. |
|
396 |
||
397 |
"Created: / 01-08-2006 / 13:56:44 / cg" |
|
398 |
! |
|
399 |
||
19311 | 400 |
beObjectiveC |
401 |
"specify this as an objective-c message send" |
|
402 |
||
403 |
flags := (flags ? 0) bitOr: FLAG_OBJECTIVEC. |
|
404 |
||
405 |
"Created: / 01-08-2006 / 13:56:48 / cg" |
|
406 |
! |
|
407 |
||
9463 | 408 |
beUnlimitedStack |
409 |
"let this execute on the c-stack (as opposed to the thread-stack) |
|
410 |
for unlimited auto-sized-stack under unix/linux. |
|
411 |
Ignored under windows." |
|
412 |
||
413 |
flags := (flags ? 0) bitOr: FLAG_UNLIMITEDSTACK. |
|
414 |
||
415 |
"Created: / 01-08-2006 / 13:41:54 / cg" |
|
416 |
! |
|
417 |
||
418 |
beVirtualCPP |
|
419 |
"specify this as a virtual c++-function" |
|
420 |
||
421 |
flags := (flags ? 0) bitOr: FLAG_VIRTUAL. |
|
422 |
||
423 |
"Created: / 01-08-2006 / 13:56:48 / cg" |
|
424 |
! |
|
425 |
||
9465 | 426 |
callTypeNumber |
427 |
^ (flags ? 0) bitAnd: CALLTYPE_MASK. |
|
428 |
||
429 |
"Created: / 01-08-2006 / 15:12:10 / cg" |
|
430 |
! |
|
431 |
||
9463 | 432 |
isAsync |
433 |
"is this executed in a separate thread, in par with the other execution thread(s) ?" |
|
434 |
||
435 |
^ (flags ? 0) bitTest: FLAG_ASYNC. |
|
436 |
||
437 |
"Created: / 01-08-2006 / 13:46:53 / cg" |
|
438 |
! |
|
439 |
||
9519 | 440 |
isCPPFunction |
441 |
"is this a virtual or non-virtual c++-function ?" |
|
442 |
||
443 |
^ (flags ? 0) bitTest: (FLAG_VIRTUAL bitOr: FLAG_NONVIRTUAL). |
|
444 |
||
445 |
"Created: / 01-08-2006 / 13:56:54 / cg" |
|
446 |
! |
|
447 |
||
9465 | 448 |
isCallTypeAPI |
449 |
^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_API. |
|
450 |
||
451 |
"Created: / 01-08-2006 / 15:21:16 / cg" |
|
452 |
! |
|
453 |
||
454 |
isCallTypeC |
|
455 |
^ ((flags ? 0) bitAnd: CALLTYPE_MASK) == CALLTYPE_C. |
|
456 |
||
457 |
"Created: / 01-08-2006 / 15:21:23 / cg" |
|
458 |
! |
|
459 |
||
10483 | 460 |
isCallTypeOLE |
461 |
^ ((flags ? 0) bitTest: FLAG_VIRTUAL). |
|
462 |
||
463 |
"Created: / 01-08-2006 / 15:21:23 / cg" |
|
464 |
! |
|
465 |
||
9525 | 466 |
isConstReturnValue |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
467 |
"is the pointer return value not to be finalized |
9525 | 468 |
(i.e. points to static data or data which is freed by c)" |
469 |
||
470 |
^ (flags ? 0) bitTest: FLAG_RETVAL_IS_CONST. |
|
471 |
||
472 |
"Created: / 01-08-2006 / 13:56:48 / cg" |
|
473 |
! |
|
474 |
||
9463 | 475 |
isNonVirtualCPP |
476 |
"is this a non-virtual c++-function ?" |
|
477 |
||
478 |
^ (flags ? 0) bitTest: FLAG_NONVIRTUAL. |
|
479 |
||
480 |
"Created: / 01-08-2006 / 13:56:51 / cg" |
|
481 |
! |
|
482 |
||
19311 | 483 |
isObjectiveC |
484 |
"is this an objective-C message?" |
|
485 |
||
486 |
^ (flags ? 0) bitTest: FLAG_OBJECTIVEC. |
|
487 |
! |
|
488 |
||
9463 | 489 |
isUnlimitedStack |
490 |
"will this execute on the c-stack (as opposed to the thread-stack) |
|
491 |
for unlimited auto-sized-stack under unix/linux. |
|
492 |
Ignored under windows." |
|
493 |
||
494 |
^ (flags ? 0) bitTest: FLAG_UNLIMITEDSTACK. |
|
495 |
||
496 |
"Created: / 01-08-2006 / 14:17:07 / cg" |
|
497 |
! |
|
498 |
||
499 |
isVirtualCPP |
|
500 |
"is this a virtual c++-function ?" |
|
501 |
||
502 |
^ (flags ? 0) bitTest: FLAG_VIRTUAL. |
|
503 |
||
504 |
"Created: / 01-08-2006 / 13:56:54 / cg" |
|
10483 | 505 |
! |
506 |
||
11426 | 507 |
moduleName |
508 |
^ moduleName |
|
509 |
! |
|
510 |
||
10484 | 511 |
returnType |
512 |
^ returnType |
|
513 |
! |
|
514 |
||
10483 | 515 |
vtableIndex |
516 |
name isNumber ifFalse:[^ nil]. |
|
517 |
^ name. |
|
9321 | 518 |
! ! |
519 |
||
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
520 |
!ExternalLibraryFunction methodsFor:'invoking'! |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
521 |
|
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
522 |
invoke |
9321 | 523 |
self hasCode ifFalse:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
524 |
self prepareInvoke. |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
525 |
]. |
19311 | 526 |
^ self invokeFFIwithArguments:nil forCPPInstance:nil |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
527 |
! |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
528 |
|
9347 | 529 |
invokeCPPVirtualOn:anInstance |
9341 | 530 |
self hasCode ifFalse:[ |
11586 | 531 |
self prepareInvoke. |
9341 | 532 |
]. |
10440 | 533 |
^ self invokeCPPVirtualFFIOn:anInstance withArguments:nil |
9341 | 534 |
! |
535 |
||
9347 | 536 |
invokeCPPVirtualOn:instance with:arg |
9341 | 537 |
self hasCode ifFalse:[ |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
538 |
self prepareInvoke. |
9341 | 539 |
]. |
9347 | 540 |
^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg) |
9341 | 541 |
! |
542 |
||
9347 | 543 |
invokeCPPVirtualOn:instance with:arg1 with:arg2 |
9341 | 544 |
self hasCode ifFalse:[ |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
545 |
self prepareInvoke. |
9341 | 546 |
]. |
9347 | 547 |
^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2) |
9341 | 548 |
! |
549 |
||
9347 | 550 |
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3 |
9341 | 551 |
self hasCode ifFalse:[ |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
552 |
self prepareInvoke. |
9341 | 553 |
]. |
9347 | 554 |
^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2 with:arg3) |
9341 | 555 |
! |
556 |
||
9347 | 557 |
invokeCPPVirtualOn:instance with:arg1 with:arg2 with:arg3 with:arg4 |
9341 | 558 |
self hasCode ifFalse:[ |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
559 |
self prepareInvoke. |
9341 | 560 |
]. |
9347 | 561 |
^ self invokeCPPVirtualFFIOn:instance withArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) |
9341 | 562 |
! |
563 |
||
10481 | 564 |
invokeCPPVirtualOn:instance withArguments:args |
565 |
self hasCode ifFalse:[ |
|
11586 | 566 |
self prepareInvoke. |
10481 | 567 |
]. |
568 |
^ self invokeCPPVirtualFFIOn:instance withArguments:args |
|
569 |
! |
|
570 |
||
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
571 |
invokeWith:arg |
9321 | 572 |
self hasCode ifFalse:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
573 |
self prepareInvoke. |
9321 | 574 |
]. |
19311 | 575 |
^ self invokeFFIwithArguments:(Array with:arg) forCPPInstance:nil |
9321 | 576 |
! |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
577 |
|
9321 | 578 |
invokeWith:arg1 with:arg2 |
579 |
self hasCode ifFalse:[ |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
580 |
self prepareInvoke. |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
581 |
]. |
19311 | 582 |
^ self invokeFFIwithArguments:(Array with:arg1 with:arg2) forCPPInstance:nil |
9321 | 583 |
! |
584 |
||
585 |
invokeWith:arg1 with:arg2 with:arg3 |
|
586 |
self hasCode ifFalse:[ |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
587 |
self prepareInvoke. |
9321 | 588 |
]. |
19311 | 589 |
^ self invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3) forCPPInstance:nil |
9321 | 590 |
! |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
591 |
|
9321 | 592 |
invokeWith:arg1 with:arg2 with:arg3 with:arg4 |
593 |
self hasCode ifFalse:[ |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
594 |
self prepareInvoke. |
9321 | 595 |
]. |
19311 | 596 |
^ self invokeFFIwithArguments:(Array with:arg1 with:arg2 with:arg3 with:arg4) forCPPInstance:nil |
9321 | 597 |
! |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
598 |
|
9321 | 599 |
invokeWithArguments:argArray |
600 |
self hasCode ifFalse:[ |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
601 |
self prepareInvoke. |
9321 | 602 |
]. |
9465 | 603 |
^ self invokeFFIwithArguments:argArray forCPPInstance:nil |
604 |
||
605 |
"Modified: / 01-08-2006 / 16:04:08 / cg" |
|
9321 | 606 |
! ! |
607 |
||
608 |
!ExternalLibraryFunction methodsFor:'printing'! |
|
609 |
||
610 |
printOn:aStream |
|
611 |
aStream nextPutAll:'<'. |
|
9465 | 612 |
self isCallTypeAPI ifTrue:[ |
14625 | 613 |
'API:' printOn:aStream. |
9465 | 614 |
] ifFalse:[ |
14625 | 615 |
self isCallTypeOLE ifTrue:[ |
616 |
'OLE:' printOn:aStream. |
|
617 |
] ifFalse:[ |
|
618 |
self isCallTypeC ifTrue:[ |
|
619 |
'C:' printOn:aStream. |
|
620 |
] ifFalse:[ |
|
621 |
self error. |
|
622 |
]. |
|
623 |
]. |
|
9465 | 624 |
]. |
9321 | 625 |
aStream nextPutAll:' '. |
626 |
name printOn:aStream. |
|
9465 | 627 |
moduleName notNil ifTrue:[ |
14625 | 628 |
aStream nextPutAll:' module:'. |
629 |
moduleName printOn:aStream. |
|
9465 | 630 |
]. |
9321 | 631 |
aStream nextPutAll:'>'. |
9465 | 632 |
|
14356 | 633 |
"Modified: / 25-09-2012 / 12:06:14 / cg" |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
634 |
! ! |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
635 |
|
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
636 |
!ExternalLibraryFunction methodsFor:'private'! |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
637 |
|
10213 | 638 |
adjustTypes |
19313 | 639 |
argumentTypes notEmptyOrNil ifTrue:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
640 |
argumentTypes := argumentTypes collect:[:argType | self ffiTypeSymbolForType:argType]. |
10213 | 641 |
]. |
642 |
returnType := self ffiTypeSymbolForType:returnType. |
|
643 |
! |
|
644 |
||
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
645 |
linkToModule |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
646 |
"link this function to the external module. |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
647 |
I.e. retrieve the module handle and the code pointer." |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
648 |
|
9465 | 649 |
|handle moduleNameUsed functionName| |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
650 |
|
10481 | 651 |
name isNumber ifTrue:[ |
19355 | 652 |
self isCPPFunction ifTrue:[ |
653 |
"/ no need to load a dll. |
|
654 |
^ self |
|
655 |
] |
|
10481 | 656 |
]. |
657 |
||
13782
1994fe87f21e
comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents:
13412
diff
changeset
|
658 |
"/ in some other smalltalks, there is no moduleName in the ffi-spec; |
1994fe87f21e
comment/format in: #linkToModule
Claus Gittinger <cg@exept.de>
parents:
13412
diff
changeset
|
659 |
"/ instead, the class provides the libraryName... |
9465 | 660 |
(moduleNameUsed := moduleName) isNil ifTrue:[ |
19355 | 661 |
owningClass isNil ifTrue:[ |
662 |
self error:'Missing moduleName'. |
|
663 |
]. |
|
664 |
moduleNameUsed := owningClass theNonMetaclass libraryName asSymbol. |
|
9321 | 665 |
]. |
11586 | 666 |
moduleHandle isNil ifTrue:[ |
19355 | 667 |
"/ speedup. in 95% of all calls, the same moduleName is resolved here |
668 |
(LastModuleHandleHolder isNil |
|
669 |
or:[ (handle := LastModuleHandleHolder at:1) isNil |
|
670 |
or:[ LastModuleHandleName ~= moduleNameUsed ]]) ifTrue:[ |
|
19342 | 671 |
|
19355 | 672 |
handle := self loadLibrary:moduleNameUsed. |
673 |
handle isNil ifTrue:[ |
|
674 |
self error:('Cannot find or load dll/module: "%1"' bindWith: moduleNameUsed). |
|
675 |
]. |
|
676 |
LastModuleHandleHolder := WeakArray with:handle. |
|
677 |
LastModuleHandleName := moduleNameUsed. |
|
678 |
]. |
|
679 |
moduleHandle := handle. |
|
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
680 |
]. |
9341 | 681 |
name isNumber ifFalse:[ |
19355 | 682 |
functionName := name. |
683 |
(moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[ |
|
684 |
functionName := ('_', functionName) asSymbol. |
|
9418
df5d2576402d
resolve function - if function with name not exists add an underscore in front and retry
ca
parents:
9399
diff
changeset
|
685 |
|
19355 | 686 |
(moduleHandle getFunctionAddress:functionName into:self) isNil ifTrue:[ |
687 |
moduleHandle := nil. |
|
688 |
self error:'Missing function: ', name, ' in module: ', moduleNameUsed. |
|
689 |
]. |
|
690 |
]. |
|
9321 | 691 |
]. |
9392 | 692 |
|
14103 | 693 |
"Modified: / 10-04-2012 / 12:12:44 / cg" |
9321 | 694 |
! |
695 |
||
10270 | 696 |
loadLibrary:dllName |
12436 | 697 |
|handle nameString filename| |
10279
60c42983fdd4
first test whether the dllName is the complete filename
ca
parents:
10270
diff
changeset
|
698 |
|
14103 | 699 |
filename := dllName. |
700 |
DllMapping notNil ifTrue:[ |
|
14625 | 701 |
filename := DllMapping at:filename ifAbsent:[ filename ] |
14103 | 702 |
]. |
703 |
||
704 |
filename := filename asFilename. |
|
12436 | 705 |
nameString := filename name. |
10279
60c42983fdd4
first test whether the dllName is the complete filename
ca
parents:
10270
diff
changeset
|
706 |
|
12937 | 707 |
"try to load, maybe the system knows where to find the dll" |
708 |
handle := ObjectFileLoader loadDynamicObject:filename. |
|
709 |
handle notNil ifTrue:[^ handle ]. |
|
710 |
||
12436 | 711 |
filename isAbsolute ifFalse:[ |
14625 | 712 |
"First ask the class defining the ExternalFunction for the location of the dlls ..." |
713 |
owningClass notNil ifTrue:[ |
|
714 |
owningClass dllPath do:[:eachDirectory | |
|
715 |
handle := ObjectFileLoader |
|
716 |
loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName. |
|
717 |
handle notNil ifTrue:[^ handle ]. |
|
718 |
]. |
|
719 |
]. |
|
720 |
".. then ask the system" |
|
721 |
self class dllPath do:[:eachDirectory | |
|
722 |
handle := ObjectFileLoader |
|
723 |
loadDynamicObject:(eachDirectory asFilename construct:nameString) pathName. |
|
724 |
handle notNil ifTrue:[^ handle ]. |
|
725 |
]. |
|
10279
60c42983fdd4
first test whether the dllName is the complete filename
ca
parents:
10270
diff
changeset
|
726 |
]. |
10270 | 727 |
|
12436 | 728 |
filename suffix isEmpty ifTrue:[ |
14625 | 729 |
"/ try again with the OS-specific dll-extension |
730 |
^ self loadLibrary:(filename withSuffix:ObjectFileLoader sharedLibrarySuffix) |
|
10270 | 731 |
]. |
12436 | 732 |
|
10270 | 733 |
^ nil |
14103 | 734 |
|
735 |
"Modified: / 10-04-2012 / 12:21:06 / cg" |
|
10270 | 736 |
! |
737 |
||
9321 | 738 |
prepareInvoke |
10270 | 739 |
(moduleHandle isNil or:[self hasCode not]) ifTrue:[ |
12450 | 740 |
self linkToModule. |
741 |
self adjustTypes. |
|
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
742 |
]. |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
743 |
! ! |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
744 |
|
8550 | 745 |
!ExternalLibraryFunction methodsFor:'private-accessing'! |
746 |
||
9327 | 747 |
ffiTypeSymbolForType:aType |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
748 |
"map type to one of the ffi-supported ones: |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
749 |
sint8, sint16, sint32, sint64 |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
750 |
uint8, uint16, uint32, uint64 |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
751 |
bool void pointer handle |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
752 |
" |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
753 |
|
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
754 |
aType == #sint8 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
755 |
aType == #sint16 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
756 |
aType == #sint32 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
757 |
aType == #sint64 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
758 |
aType == #uint8 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
759 |
aType == #uint16 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
760 |
aType == #uint32 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
761 |
aType == #uint64 ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
762 |
aType == #double ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
763 |
aType == #float ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
764 |
aType == #char ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
765 |
aType == #void ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
766 |
aType == #bool ifTrue:[^ aType ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
767 |
aType == #pointer ifTrue:[^ aType ]. |
12657
7da296a8eeb6
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12656
diff
changeset
|
768 |
aType == #charPointer ifTrue:[^ aType ]. |
7da296a8eeb6
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12656
diff
changeset
|
769 |
aType == #wcharPointer ifTrue:[^ aType ]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
770 |
|
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
771 |
aType == #int8 ifTrue:[^ #sint8 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
772 |
aType == #int16 ifTrue:[^ #sint16 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
773 |
aType == #int32 ifTrue:[^ #sint32 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
774 |
aType == #int64 ifTrue:[^ #sint64 ]. |
12450 | 775 |
|
776 |
aType == #voidPointer ifTrue:[^ #pointer ]. |
|
777 |
aType == #uint8Pointer ifTrue:[^ #pointer ]. |
|
12449
ca958524b42f
comment/format in: #prepareInvoke
Claus Gittinger <cg@exept.de>
parents:
12436
diff
changeset
|
778 |
aType == #voidPointerPointer ifTrue:[^ #pointer ]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
779 |
|
10213 | 780 |
aType == #short ifTrue:[^ #sint16 ]. |
11586 | 781 |
aType == #long ifTrue:[^ #long ]. |
782 |
aType == #int ifTrue:[^ #int ]. |
|
783 |
aType == #uint ifTrue:[^ #uint ]. |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
784 |
aType == #ushort ifTrue:[^ #uint16 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
785 |
aType == #unsignedShort ifTrue:[^ #uint16 ]. |
11586 | 786 |
aType == #ulong ifTrue:[^ #ulong ]. |
787 |
aType == #unsignedLong ifTrue:[^ #ulong ]. |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
788 |
aType == #uchar ifTrue:[^ #uint8 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
789 |
aType == #unsignedChar ifTrue:[^ #uint8 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
790 |
aType == #byte ifTrue:[^ #uint8 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
791 |
aType == #dword ifTrue:[^ #uint32 ]. |
10213 | 792 |
aType == #sdword ifTrue:[^ #sint32 ]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
793 |
aType == #word ifTrue:[^ #uint16 ]. |
10213 | 794 |
aType == #sword ifTrue:[^ #sint16 ]. |
12503
cb1a875c3d63
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12474
diff
changeset
|
795 |
aType == #longlong ifTrue:[^ #sint64 ]. |
12450 | 796 |
aType == #longLong ifTrue:[^ #sint64 ]. |
12503
cb1a875c3d63
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12474
diff
changeset
|
797 |
aType == #ulonglong ifTrue:[^ #uint64 ]. |
12450 | 798 |
aType == #ulongLong ifTrue:[^ #uint64 ]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
799 |
aType == #handle ifTrue:[^ #pointer ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
800 |
aType == #lpstr ifTrue:[^ #charPointer ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
801 |
aType == #hresult ifTrue:[^ #uint32 ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
802 |
aType == #boolean ifTrue:[^ #bool ]. |
19311 | 803 |
"/ care for 64bit machines |
804 |
ExternalAddress pointerSize == 8 ifTrue:[ |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
805 |
aType == #ulongReturn ifTrue:[^ #uint64 ]. |
19311 | 806 |
] ifFalse:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
807 |
aType == #ulongReturn ifTrue:[^ #uint32 ]. |
19311 | 808 |
]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
809 |
aType == #none ifTrue:[^ #void ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
810 |
aType == #struct ifTrue:[^ #pointer ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
811 |
aType == #structIn ifTrue:[^ #pointer ]. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
812 |
aType == #structOut ifTrue:[^ #pointer ]. |
10981 | 813 |
aType == #unsigned ifTrue:[^ #uint ]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
814 |
|
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
815 |
(aType isString or:[aType isSymbol]) ifFalse:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
816 |
CType isNil ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
817 |
self error:'unknown type'. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
818 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
819 |
^ aType typeSymbol. |
9483 | 820 |
]. |
821 |
||
12579
516bba5b3e57
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12504
diff
changeset
|
822 |
(aType endsWith:'*') ifTrue:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
823 |
^ #pointer. |
12579
516bba5b3e57
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12504
diff
changeset
|
824 |
]. |
12449
ca958524b42f
comment/format in: #prepareInvoke
Claus Gittinger <cg@exept.de>
parents:
12436
diff
changeset
|
825 |
(aType endsWith:'Pointer') ifTrue:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
826 |
^ #pointer. |
12449
ca958524b42f
comment/format in: #prepareInvoke
Claus Gittinger <cg@exept.de>
parents:
12436
diff
changeset
|
827 |
]. |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
828 |
^ aType |
10625 | 829 |
|
830 |
"Modified: / 14-06-2007 / 17:21:42 / cg" |
|
9322 | 831 |
! |
832 |
||
9466 | 833 |
name:functionNameOrVirtualIndex module:aModuleName returnType:aReturnType argumentTypes:argTypes |
834 |
name := functionNameOrVirtualIndex. |
|
835 |
functionNameOrVirtualIndex isNumber ifTrue:[ |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
836 |
self beVirtualCPP. |
9466 | 837 |
]. |
8891
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
838 |
moduleName := aModuleName. |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
839 |
returnType := aReturnType. |
c30a030ff5ec
more FFI (foreign function interface) support - still incomplete
Stefan Vogel <sv@exept.de>
parents:
8728
diff
changeset
|
840 |
argumentTypes := argTypes. |
9465 | 841 |
|
842 |
"Created: / 01-08-2006 / 15:19:52 / cg" |
|
9466 | 843 |
"Modified: / 02-08-2006 / 17:20:13 / cg" |
9465 | 844 |
! |
845 |
||
11426 | 846 |
owningClass |
847 |
^ owningClass |
|
848 |
! |
|
849 |
||
9465 | 850 |
owningClass:aClass |
851 |
owningClass := aClass. |
|
852 |
||
853 |
"Created: / 01-08-2006 / 15:22:50 / cg" |
|
10603 | 854 |
! |
855 |
||
11586 | 856 |
setModuleName:aModuleName |
10603 | 857 |
aModuleName ~= moduleName ifTrue:[ |
11586 | 858 |
self code:nil. |
859 |
moduleHandle := nil. |
|
860 |
moduleName := aModuleName. |
|
10603 | 861 |
]. |
862 |
||
863 |
"Created: / 07-06-2007 / 10:20:17 / cg" |
|
8550 | 864 |
! ! |
865 |
||
9342 | 866 |
!ExternalLibraryFunction methodsFor:'private-invoking'! |
867 |
||
9347 | 868 |
invokeCPPVirtualFFIOn:instance withArguments:arguments |
9463 | 869 |
^ self invokeFFIwithArguments:arguments forCPPInstance:instance |
870 |
||
871 |
"Modified: / 01-08-2006 / 13:55:30 / cg" |
|
9342 | 872 |
! |
873 |
||
9347 | 874 |
invokeFFIWithArguments:arguments |
9463 | 875 |
^ self invokeFFIwithArguments:arguments forCPPInstance:nil |
876 |
||
877 |
"Modified: / 01-08-2006 / 13:55:35 / cg" |
|
9347 | 878 |
! |
879 |
||
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
880 |
invokeFFIwithArguments:argumentsOrNil forCPPInstance:aReceiverOrNil |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
881 |
"basic invoke mechanism. Calls the function represented by the receiver with argumentsOrNil. |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
882 |
For cplusplus, aReceiverOrNil is required to be an externalStructure like object; |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
883 |
for objectiveC, it must be an ObjectiveC object" |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
884 |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
885 |
|argTypeSymbols returnTypeSymbol failureCode failureArgNr failureInfo returnValue stClass vtOffset |
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
886 |
virtual objectiveC async unlimitedStack callTypeNumber returnValueClass argValueClass |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
887 |
oldReturnType oldArgumentTypes| |
9342 | 888 |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
889 |
argTypeSymbols := argumentTypes. |
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
890 |
returnTypeSymbol := returnType. |
9346 | 891 |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
892 |
virtual := self isVirtualCPP. |
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
893 |
objectiveC := self isObjectiveC. |
9524 | 894 |
(virtual "or:[self isNonVirtualCPP]") ifTrue:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
895 |
aReceiverOrNil isNil ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
896 |
"/ must have a c++ object instance |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
897 |
self primitiveFailed. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
898 |
]. |
9463 | 899 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
900 |
"/ and it must be a kind of ExternalStructure !! |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
901 |
(aReceiverOrNil isKindOf:ExternalStructure) ifFalse:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
902 |
self primitiveFailed. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
903 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
904 |
virtual ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
905 |
vtOffset := name. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
906 |
(vtOffset between:0 and:10000) ifFalse:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
907 |
self primitiveFailed. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
908 |
] |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
909 |
]. |
9463 | 910 |
] ifFalse:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
911 |
objectiveC ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
912 |
aReceiverOrNil isNil ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
913 |
"/ must have an objective-c object instance |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
914 |
self primitiveFailed. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
915 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
916 |
(aReceiverOrNil isObjectiveCObject) ifFalse:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
917 |
self primitiveFailed |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
918 |
] |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
919 |
] ifFalse:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
920 |
aReceiverOrNil notNil ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
921 |
"/ must NOT have a c++/objectiveC object instance |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
922 |
self primitiveFailed. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
923 |
] |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
924 |
]. |
9342 | 925 |
]. |
9463 | 926 |
async := self isAsync. |
927 |
unlimitedStack := self isUnlimitedStack. |
|
9465 | 928 |
callTypeNumber := self callTypeNumber. |
10512 | 929 |
"/ Transcript show:name; show:' async:'; showCR:async. |
9342 | 930 |
|
9459
6cd520c582b3
change from unlimited to big stack, to allow for interrupts to be handled
ca
parents:
9436
diff
changeset
|
931 |
%{ /* STACK: 100000 */ |
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
932 |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
933 |
#ifdef HAVE_FFI |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
934 |
# ifdef __GNUC__ |
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
935 |
# ifndef HAS_LONGLONG |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
936 |
# define HAS_LONGLONG |
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
937 |
# endif |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
938 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
939 |
# if defined(__BORLANDC__) || defined(__VISUALC__) |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
940 |
# define HAS_INT64 |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
941 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
942 |
|
9342 | 943 |
ffi_cif __cif; |
944 |
ffi_type *__argTypesIncludingThis[MAX_ARGS+1]; |
|
945 |
ffi_type **__argTypes = __argTypesIncludingThis; |
|
946 |
ffi_type *__returnType = NULL; |
|
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
947 |
|
9342 | 948 |
union u { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
949 |
INT iVal; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
950 |
float fVal; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
951 |
double dVal; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
952 |
void *pointerVal; |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
953 |
# if defined(HAS_LONGLONG) |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
954 |
long long longLongVal; |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
955 |
# else |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
956 |
# ifdef HAS_INT64 |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
957 |
__int64__ longLongVal; |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
958 |
# else |
19356 | 959 |
struct ll { long lo; long hi; } longLongVal; |
19357 | 960 |
# ifndef __LO32 |
961 |
# define __LO32(ll) (ll.lo) |
|
962 |
# define __HI32(ll) (ll.hi) |
|
963 |
# endif |
|
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
964 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
965 |
# endif |
9342 | 966 |
}; |
967 |
union u __argValuesIncludingThis[MAX_ARGS+1]; |
|
968 |
union u *__argValues = __argValuesIncludingThis; |
|
969 |
union u __returnValue; |
|
970 |
void *__argValuePointersIncludingThis[MAX_ARGS+1]; |
|
971 |
void **__argValuePointers = __argValuePointersIncludingThis; |
|
972 |
void *__returnValuePointer; |
|
973 |
int __numArgs, __numArgsIncludingThis; |
|
19311 | 974 |
static INT null = 0; |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
975 |
int i = -1; |
9342 | 976 |
ffi_abi __callType = FFI_DEFAULT_ABI; |
977 |
VOIDFUNC codeAddress = (VOIDFUNC)__INST(code_); |
|
10440 | 978 |
int __numArgsWanted; |
12579
516bba5b3e57
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12504
diff
changeset
|
979 |
|
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
980 |
# define __FAIL__(fcode) \ |
10603 | 981 |
{ \ |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
982 |
failureCode = fcode; failureArgNr = __mkSmallInteger(i+1); goto getOutOfHere; \ |
10603 | 983 |
} |
9342 | 984 |
|
10440 | 985 |
if (argumentsOrNil == nil) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
986 |
__numArgs = 0; |
10440 | 987 |
} else if (__isArray(argumentsOrNil)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
988 |
__numArgs = __arraySize(argumentsOrNil); |
9342 | 989 |
} else { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
990 |
__FAIL__(@symbol(BadArgumentVector)) |
10440 | 991 |
} |
992 |
if (argTypeSymbols == nil) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
993 |
__numArgsWanted = 0; |
10440 | 994 |
} else if (__isArray(argTypeSymbols)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
995 |
__numArgsWanted = __arraySize(argTypeSymbols); |
10440 | 996 |
} else { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
997 |
__FAIL__(@symbol(BadArgumentTypeVector)) |
10440 | 998 |
} |
999 |
||
1000 |
if (__numArgs != __numArgsWanted) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1001 |
__FAIL__(@symbol(ArgumentCountMismatch)) |
9342 | 1002 |
} |
1003 |
if (__numArgs > MAX_ARGS) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1004 |
__FAIL__(@symbol(TooManyArguments)) |
9342 | 1005 |
} |
1006 |
||
1007 |
/* |
|
1008 |
* validate the return type |
|
1009 |
*/ |
|
1010 |
__returnValuePointer = &__returnValue; |
|
9479 | 1011 |
|
9483 | 1012 |
if (returnTypeSymbol == @symbol(voidPointer)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1013 |
returnTypeSymbol = @symbol(handle); |
9483 | 1014 |
} |
9479 | 1015 |
|
9342 | 1016 |
if (returnTypeSymbol == @symbol(int)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1017 |
__returnType = __get_ffi_type_sint(); |
9342 | 1018 |
} else if (returnTypeSymbol == @symbol(uint)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1019 |
__returnType = __get_ffi_type_uint(); |
9479 | 1020 |
} else if (returnTypeSymbol == @symbol(uint8)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1021 |
__returnType = __get_ffi_type_uint8(); |
9479 | 1022 |
} else if (returnTypeSymbol == @symbol(uint16)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1023 |
__returnType = __get_ffi_type_uint16(); |
9479 | 1024 |
} else if (returnTypeSymbol == @symbol(uint32)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1025 |
__returnType = __get_ffi_type_uint32(); |
9479 | 1026 |
} else if (returnTypeSymbol == @symbol(uint64)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1027 |
__returnType = __get_ffi_type_uint64(); |
9479 | 1028 |
|
1029 |
} else if (returnTypeSymbol == @symbol(sint)) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1030 |
__returnType = __get_ffi_type_sint(); |
9479 | 1031 |
} else if (returnTypeSymbol == @symbol(sint8)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1032 |
__returnType = __get_ffi_type_sint8(); |
9479 | 1033 |
} else if (returnTypeSymbol == @symbol(sint16)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1034 |
__returnType = __get_ffi_type_sint16(); |
9479 | 1035 |
} else if (returnTypeSymbol == @symbol(sint32)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1036 |
__returnType = __get_ffi_type_sint32(); |
9479 | 1037 |
} else if (returnTypeSymbol == @symbol(sint64)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1038 |
__returnType = __get_ffi_type_sint64(); |
9479 | 1039 |
|
9342 | 1040 |
} else if (returnTypeSymbol == @symbol(long)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1041 |
if (sizeof(long) == 4) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1042 |
returnTypeSymbol = @symbol(sint32); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1043 |
__returnType = __get_ffi_type_sint32(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1044 |
} else if (sizeof(long) == 8) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1045 |
returnTypeSymbol = @symbol(sint64); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1046 |
__returnType = __get_ffi_type_sint64(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1047 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1048 |
__FAIL__(@symbol(UnknownReturnType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1049 |
} |
9479 | 1050 |
|
9342 | 1051 |
} else if (returnTypeSymbol == @symbol(ulong)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1052 |
if (sizeof(long) == 4) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1053 |
returnTypeSymbol = @symbol(uint32); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1054 |
__returnType = __get_ffi_type_uint32(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1055 |
}else if (sizeof(long) == 8) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1056 |
returnTypeSymbol = @symbol(uint64); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1057 |
__returnType = __get_ffi_type_uint64(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1058 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1059 |
__FAIL__(@symbol(UnknownReturnType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1060 |
} |
9479 | 1061 |
|
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
1062 |
} else if (returnTypeSymbol == @symbol(bool)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1063 |
__returnType = __get_ffi_type_uint(); |
9479 | 1064 |
|
9342 | 1065 |
} else if (returnTypeSymbol == @symbol(float)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1066 |
__returnType = __get_ffi_type_float(); |
9342 | 1067 |
} else if (returnTypeSymbol == @symbol(double)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1068 |
__returnType = __get_ffi_type_double(); |
9479 | 1069 |
|
9342 | 1070 |
} else if (returnTypeSymbol == @symbol(void)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1071 |
__returnType = __get_ffi_type_void(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1072 |
__returnValuePointer = NULL; |
11586 | 1073 |
} else if ((returnTypeSymbol == @symbol(pointer)) |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1074 |
|| (returnTypeSymbol == @symbol(handle)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1075 |
|| (returnTypeSymbol == @symbol(charPointer)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1076 |
|| (returnTypeSymbol == @symbol(bytePointer)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1077 |
|| (returnTypeSymbol == @symbol(floatPointer)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1078 |
|| (returnTypeSymbol == @symbol(doublePointer)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1079 |
|| (returnTypeSymbol == @symbol(intPointer)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1080 |
|| (returnTypeSymbol == @symbol(shortPointer)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1081 |
|| (returnTypeSymbol == @symbol(wcharPointer))) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1082 |
__returnType = __get_ffi_type_pointer(); |
9342 | 1083 |
} else { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1084 |
if (__isSymbol(returnTypeSymbol) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1085 |
&& ((returnValueClass = __GLOBAL_GET(returnTypeSymbol)) != nil)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1086 |
if (! __isBehaviorLike(returnValueClass)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1087 |
__FAIL__(@symbol(NonBehaviorReturnType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1088 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1089 |
if (! __qIsSubclassOfExternalAddress(returnValueClass)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1090 |
__FAIL__(@symbol(NonExternalAddressReturnType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1091 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1092 |
__returnType = __get_ffi_type_pointer(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1093 |
returnTypeSymbol = @symbol(pointer); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1094 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1095 |
__FAIL__(@symbol(UnknownReturnType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1096 |
} |
9342 | 1097 |
} |
1098 |
||
1099 |
/* |
|
1100 |
* validate the c++ object |
|
1101 |
*/ |
|
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
1102 |
if (aReceiverOrNil != nil) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1103 |
struct cPlusPlusInstance { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1104 |
void **vTable; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1105 |
}; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1106 |
struct cPlusPlusInstance *inst; |
9342 | 1107 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1108 |
if (__isExternalAddressLike(aReceiverOrNil)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1109 |
inst = (void *)(__externalAddressVal(aReceiverOrNil)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1110 |
} else if (__isExternalBytesLike(aReceiverOrNil)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1111 |
inst = (void *)(__externalBytesVal(aReceiverOrNil)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1112 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1113 |
__FAIL__(@symbol(InvalidInstance)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1114 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1115 |
__argValues[0].pointerVal = inst; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1116 |
__argValuePointersIncludingThis[0] = &(__argValues[0]); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1117 |
__argTypes[0] = __get_ffi_type_pointer(); |
9342 | 1118 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1119 |
__argValuePointers = &__argValuePointersIncludingThis[1]; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1120 |
__argTypes = &__argTypesIncludingThis[1]; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1121 |
__argValues = &__argValuesIncludingThis[1]; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1122 |
__numArgsIncludingThis = __numArgs + 1; |
9347 | 1123 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1124 |
if (virtual == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1125 |
if (! __isSmallInteger(vtOffset)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1126 |
__FAIL__(@symbol(InvalidVTableIndex)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1127 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1128 |
codeAddress = inst->vTable[__intVal(vtOffset)]; |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1129 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1130 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1131 |
printf("virtual codeAddress: %"_lx_"\n", (INT)codeAddress); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1132 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1133 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1134 |
} |
9342 | 1135 |
} else { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1136 |
__numArgsIncludingThis = __numArgs; |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1137 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1138 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1139 |
printf("codeAddress: %"_lx_"\n", (INT)codeAddress); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1140 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1141 |
# endif |
9342 | 1142 |
} |
1143 |
||
1144 |
/* |
|
1145 |
* validate all arg types and setup arg-buffers |
|
1146 |
*/ |
|
1147 |
for (i=0; i<__numArgs; i++) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1148 |
ffi_type *thisType; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1149 |
void *argValuePtr; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1150 |
OBJ typeSymbol; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1151 |
OBJ arg; |
9342 | 1152 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1153 |
failureInfo = __mkSmallInteger(i+1); /* in case there is one */ |
9465 | 1154 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1155 |
typeSymbol = __ArrayInstPtr(argTypeSymbols)->a_element[i]; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1156 |
arg = __ArrayInstPtr(argumentsOrNil)->a_element[i]; |
9342 | 1157 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1158 |
if (typeSymbol == @symbol(handle)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1159 |
typeSymbol = @symbol(pointer); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1160 |
} else if (typeSymbol == @symbol(voidPointer)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1161 |
typeSymbol = @symbol(pointer); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1162 |
} |
9479 | 1163 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1164 |
if (typeSymbol == @symbol(long)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1165 |
if (sizeof(long) == sizeof(int)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1166 |
typeSymbol = @symbol(sint); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1167 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1168 |
if (sizeof(long) == 4) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1169 |
typeSymbol = @symbol(sint32); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1170 |
} else if (sizeof(long) == 8) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1171 |
typeSymbol = @symbol(sint64); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1172 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1173 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1174 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1175 |
if (typeSymbol == @symbol(ulong)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1176 |
if (sizeof(unsigned long) == sizeof(unsigned int)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1177 |
typeSymbol = @symbol(uint); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1178 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1179 |
if (sizeof(long) == 4) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1180 |
typeSymbol = @symbol(uint32); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1181 |
} else if (sizeof(long) == 8) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1182 |
typeSymbol = @symbol(uint64); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1183 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1184 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1185 |
} |
9342 | 1186 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1187 |
if (typeSymbol == @symbol(int) || typeSymbol == @symbol(sint)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1188 |
thisType = __get_ffi_type_sint(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1189 |
if (__isSmallInteger(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1190 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1191 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1192 |
__argValues[i].iVal = __signedLongIntVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1193 |
if (__argValues[i].iVal == 0) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1194 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1195 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1196 |
printf("invalidArgument: arg%d sint value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1197 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1198 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1199 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1200 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1201 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1202 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1203 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1204 |
} else if (typeSymbol == @symbol(uint)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1205 |
thisType = __get_ffi_type_uint(); |
9342 | 1206 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1207 |
if (__isSmallInteger(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1208 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1209 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1210 |
__argValues[i].iVal = __unsignedLongIntVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1211 |
if (__argValues[i].iVal == 0) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1212 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1213 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1214 |
printf("invalidArgument: arg%d uint value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1215 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1216 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1217 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1218 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1219 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1220 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1221 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1222 |
} else if (typeSymbol == @symbol(uint8)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1223 |
thisType = __get_ffi_type_uint8(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1224 |
if (! __isSmallInteger(arg)) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1225 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1226 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1227 |
printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1228 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1229 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1230 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1231 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1232 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1233 |
if (((unsigned)(__argValues[i].iVal)) > 0xFF) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1234 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1235 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1236 |
printf("invalidArgument: arg%d uint8 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1237 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1238 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1239 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1240 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1241 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1242 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1243 |
} else if (typeSymbol == @symbol(sint8)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1244 |
thisType = __get_ffi_type_sint8(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1245 |
if (! __isSmallInteger(arg)) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1246 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1247 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1248 |
printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1249 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1250 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1251 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1252 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1253 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1254 |
if (((__argValues[i].iVal) < -0x80) || ((__argValues[i].iVal) > 0x7F)) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1255 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1256 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1257 |
printf("invalidArgument: arg%d sint8 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1258 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1259 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1260 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1261 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1262 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1263 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1264 |
} else if (typeSymbol == @symbol(uint16)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1265 |
thisType = __get_ffi_type_uint16(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1266 |
if (! __isSmallInteger(arg)) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1267 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1268 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1269 |
printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1270 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1271 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1272 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1273 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1274 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1275 |
if (((unsigned)(__argValues[i].iVal)) > 0xFFFF) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1276 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1277 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1278 |
printf("invalidArgument: arg%d uint16 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1279 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1280 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1281 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1282 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1283 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1284 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1285 |
} else if (typeSymbol == @symbol(sint16)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1286 |
thisType = __get_ffi_type_sint16(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1287 |
if (! __isSmallInteger(arg)) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1288 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1289 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1290 |
printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1291 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1292 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1293 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1294 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1295 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1296 |
if (((__argValues[i].iVal) < -0x8000) || ((__argValues[i].iVal) > 0x7FFF)) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1297 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1298 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1299 |
printf("invalidArgument: arg%d sint16 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1300 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1301 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1302 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1303 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1304 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1305 |
|
19334 | 1306 |
} else if (typeSymbol == @symbol(uint32)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1307 |
thisType = __get_ffi_type_uint32(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1308 |
if (__isSmallInteger(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1309 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1310 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1311 |
__argValues[i].iVal = __unsignedLongIntVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1312 |
if (__argValues[i].iVal == 0) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1313 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1314 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1315 |
printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1316 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1317 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1318 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1319 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1320 |
} |
19334 | 1321 |
# if __POINTER_SIZE__ == 8 |
1322 |
if ((__argValues[i].iVal) < 0) { |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1323 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1324 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1325 |
printf("invalidArgument: arg%d uint32 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1326 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1327 |
# endif |
19334 | 1328 |
__FAIL__(@symbol(InvalidArgument)) |
1329 |
} |
|
1330 |
# endif |
|
1331 |
argValuePtr = &(__argValues[i].iVal); |
|
1332 |
||
1333 |
} else if (typeSymbol == @symbol(sint32)) { |
|
1334 |
thisType = __get_ffi_type_uint32(); |
|
1335 |
if (__isSmallInteger(arg)) { |
|
1336 |
__argValues[i].iVal = __intVal(arg); |
|
1337 |
} else { |
|
1338 |
__argValues[i].iVal = __signedLongIntVal(arg); |
|
1339 |
if (__argValues[i].iVal == 0) { |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1340 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1341 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1342 |
printf("invalidArgument: arg%d sint32 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1343 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1344 |
# endif |
19334 | 1345 |
__FAIL__(@symbol(InvalidArgument)) |
1346 |
} |
|
1347 |
} |
|
1348 |
# if __POINTER_SIZE__ == 8 |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1349 |
if (((__argValues[i].iVal) < -0x80000000LL) || ((__argValues[i].iVal) > 0x7FFFFFFFLL)) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1350 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1351 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1352 |
printf("invalidArgument: arg%d sint32 value (%"_lx_") out of range [%d]\n", i+1, __argValues[i].iVal, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1353 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1354 |
# endif |
19334 | 1355 |
__FAIL__(@symbol(InvalidArgument)) |
1356 |
} |
|
1357 |
# endif |
|
1358 |
argValuePtr = &(__argValues[i].iVal); |
|
1359 |
||
1360 |
} else if (typeSymbol == @symbol(uint64)) { |
|
1361 |
thisType = __get_ffi_type_uint64(); |
|
1362 |
if (__isSmallInteger(arg)) { |
|
1363 |
__argValues[i].iVal = __intVal(arg); |
|
1364 |
} else { |
|
1365 |
__argValues[i].iVal = __unsignedLongIntVal(arg); |
|
1366 |
if (__argValues[i].iVal == 0) { |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1367 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1368 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1369 |
printf("invalidArgument: arg%d uint64 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1370 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1371 |
# endif |
19334 | 1372 |
__FAIL__(@symbol(InvalidArgument)) |
1373 |
} |
|
1374 |
} |
|
1375 |
argValuePtr = &(__argValues[i].iVal); |
|
1376 |
||
1377 |
} else if (typeSymbol == @symbol(sint64)) { |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1378 |
thisType = __get_ffi_type_sint64(); |
19334 | 1379 |
if (__isSmallInteger(arg)) { |
1380 |
__argValues[i].iVal = __intVal(arg); |
|
1381 |
} else { |
|
1382 |
__argValues[i].iVal = __signedLongIntVal(arg); |
|
1383 |
if (__argValues[i].iVal == 0) { |
|
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1384 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1385 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1386 |
printf("invalidArgument: arg%d sint64 value out of range [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1387 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1388 |
# endif |
19334 | 1389 |
__FAIL__(@symbol(InvalidArgument)) |
1390 |
} |
|
1391 |
} |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1392 |
argValuePtr = &(__argValues[i].iVal); |
9479 | 1393 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1394 |
} else if (typeSymbol == @symbol(float)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1395 |
thisType = __get_ffi_type_float(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1396 |
if (__isSmallInteger(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1397 |
__argValues[i].fVal = (float)(__intVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1398 |
} else if (__isFloat(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1399 |
__argValues[i].fVal = (float)(__floatVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1400 |
} else if (__isShortFloat(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1401 |
__argValues[i].fVal = (float)(__shortFloatVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1402 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1403 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1404 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1405 |
printf("invalidArgument: arg%d non float value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1406 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1407 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1408 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1409 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1410 |
argValuePtr = &(__argValues[i].fVal); |
9479 | 1411 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1412 |
} else if (typeSymbol == @symbol(double)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1413 |
thisType = __get_ffi_type_double(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1414 |
if (__isSmallInteger(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1415 |
__argValues[i].dVal = (double)(__intVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1416 |
} else if (__isFloat(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1417 |
__argValues[i].dVal = (double)(__floatVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1418 |
} else if (__isShortFloat(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1419 |
__argValues[i].dVal = (double)(__shortFloatVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1420 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1421 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1422 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1423 |
printf("invalidArgument: arg%d non double value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1424 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1425 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1426 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1427 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1428 |
argValuePtr = &(__argValues[i].dVal); |
9479 | 1429 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1430 |
} else if (typeSymbol == @symbol(void)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1431 |
thisType = __get_ffi_type_void(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1432 |
argValuePtr = &null; |
9479 | 1433 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1434 |
} else if (typeSymbol == @symbol(charPointer)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1435 |
thisType = __get_ffi_type_pointer(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1436 |
if (__isStringLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1437 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1438 |
__argValues[i].pointerVal = (void *)(__stringVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1439 |
} else if (__isBytes(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1440 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1441 |
__argValues[i].pointerVal = (void *)(__byteArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1442 |
} else if (__isExternalAddressLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1443 |
__argValues[i].pointerVal = (void *)(__externalAddressVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1444 |
} else if (__isExternalBytesLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1445 |
__argValues[i].pointerVal = (void *)(__externalBytesVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1446 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1447 |
if (arg == nil) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1448 |
__argValues[i].pointerVal = (void *)0; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1449 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1450 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1451 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1452 |
printf("invalidArgument: arg%d non charPointer value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1453 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1454 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1455 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1456 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1457 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1458 |
argValuePtr = &(__argValues[i].pointerVal);; |
10603 | 1459 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1460 |
} else if (typeSymbol == @symbol(wcharPointer)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1461 |
thisType = __get_ffi_type_pointer(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1462 |
if (__isUnicode16String(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1463 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1464 |
__argValues[i].pointerVal = (void *)(__unicode16StringVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1465 |
} else if (__isBytes(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1466 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1467 |
__argValues[i].pointerVal = (void *)(__byteArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1468 |
} else if (__isExternalAddressLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1469 |
__argValues[i].pointerVal = (void *)(__externalAddressVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1470 |
} else if (__isExternalBytesLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1471 |
__argValues[i].pointerVal = (void *)(__externalBytesVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1472 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1473 |
if (arg == nil) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1474 |
__argValues[i].pointerVal = (void *)0; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1475 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1476 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1477 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1478 |
printf("invalidArgument: arg%d non wcharPointer value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1479 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1480 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1481 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1482 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1483 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1484 |
argValuePtr = &(__argValues[i].pointerVal);; |
12656 | 1485 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1486 |
} else if (typeSymbol == @symbol(floatPointer)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1487 |
thisType = __get_ffi_type_pointer(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1488 |
if (__isBytes(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1489 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1490 |
__argValues[i].pointerVal = (void *)(__byteArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1491 |
} else if (__isExternalAddressLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1492 |
__argValues[i].pointerVal = (void *)(__externalAddressVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1493 |
} else if (__isExternalBytesLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1494 |
__argValues[i].pointerVal = (void *)(__externalBytesVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1495 |
} else if (__isFloats(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1496 |
char *p = (char *)(__FloatArrayInstPtr(arg)->f_element); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1497 |
int nInstBytes; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1498 |
OBJ cls; |
10603 | 1499 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1500 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1501 |
cls = __qClass(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1502 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1503 |
p = p + nInstBytes; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1504 |
__argValues[i].pointerVal = p; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1505 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1506 |
if (arg == nil) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1507 |
__argValues[i].pointerVal = (void *)0; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1508 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1509 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1510 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1511 |
printf("invalidArgument: arg%d non floatPointer value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1512 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1513 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1514 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1515 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1516 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1517 |
argValuePtr = &(__argValues[i].pointerVal);; |
10603 | 1518 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1519 |
} else if (typeSymbol == @symbol(doublePointer)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1520 |
thisType = __get_ffi_type_pointer(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1521 |
if (__isBytes(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1522 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1523 |
__argValues[i].pointerVal = (void *)(__byteArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1524 |
} else if (__isExternalAddressLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1525 |
__argValues[i].pointerVal = (void *)(__externalAddressVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1526 |
} else if (__isExternalBytesLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1527 |
__argValues[i].pointerVal = (void *)(__externalBytesVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1528 |
} else if (__isDoubles(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1529 |
char *p = (char *)(__DoubleArrayInstPtr(arg)->d_element); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1530 |
int nInstBytes; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1531 |
OBJ cls; |
10603 | 1532 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1533 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1534 |
cls = __qClass(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1535 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1536 |
p = p + nInstBytes; |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1537 |
# ifdef __NEED_DOUBLE_ALIGN |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1538 |
if ((INT)(__DoubleArrayInstPtr(arg)->d_element) & (__DOUBLE_ALIGN-1)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1539 |
int delta = __DOUBLE_ALIGN - ((INT)p & (__DOUBLE_ALIGN-1)); |
10603 | 1540 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1541 |
p += delta; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1542 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1543 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1544 |
__argValues[i].pointerVal = p; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1545 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1546 |
if (arg == nil) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1547 |
__argValues[i].pointerVal = (void *)0; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1548 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1549 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1550 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1551 |
printf("invalidArgument: arg%d non doublePointer value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1552 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1553 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1554 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1555 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1556 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1557 |
argValuePtr = &(__argValues[i].pointerVal);; |
9479 | 1558 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1559 |
} else if (typeSymbol == @symbol(pointer)) { |
9524 | 1560 |
commonPointerTypeArg: ; |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1561 |
thisType = __get_ffi_type_pointer(); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1562 |
if (arg == nil) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1563 |
__argValues[i].pointerVal = NULL; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1564 |
} else if (__isExternalAddressLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1565 |
__argValues[i].pointerVal = (void *)(__externalAddressVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1566 |
} else if (__isExternalBytesLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1567 |
__argValues[i].pointerVal = (void *)(__externalBytesVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1568 |
} else if (__isByteArrayLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1569 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1570 |
__argValues[i].pointerVal = (void *)(__byteArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1571 |
} else if (__isWordArray(arg) || __isSignedWordArray(arg) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1572 |
|| __isIntegerArray(arg) || __isSignedIntegerArray(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1573 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1574 |
__argValues[i].pointerVal = (void *)(__integerArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1575 |
} else if (__isFloatArray(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1576 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1577 |
__argValues[i].pointerVal = (void *)(__FloatArrayInstPtr(arg)->f_element); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1578 |
} else if (__isDoubleArray(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1579 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1580 |
__argValues[i].pointerVal = (void *)(__DoubleArrayInstPtr(arg)->d_element); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1581 |
} else if (__isStringLike(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1582 |
if (async == true) { |
9435 | 1583 |
badArgForAsyncCall: ; |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1584 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1585 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1586 |
printf("invalidArgument: arg%d not allowed for async call [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1587 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1588 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1589 |
__FAIL__(@symbol(BadArgForAsyncCall)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1590 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1591 |
__argValues[i].pointerVal = (void *)(__stringVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1592 |
} else if (__isBytes(arg) || __isWords(arg) || __isLongs(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1593 |
char *p = (char *)(__byteArrayVal(arg)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1594 |
int nInstBytes; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1595 |
OBJ cls; |
9483 | 1596 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1597 |
if (async == true) goto badArgForAsyncCall; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1598 |
cls = __qClass(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1599 |
nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1600 |
__argValues[i].pointerVal = p + nInstBytes; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1601 |
} else { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1602 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1603 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1604 |
printf("invalidArgument: arg%d non pointer value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1605 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1606 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1607 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1608 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1609 |
argValuePtr = &(__argValues[i].pointerVal);; |
9479 | 1610 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1611 |
} else if (typeSymbol == @symbol(bool)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1612 |
thisType = __get_ffi_type_uint(); |
9342 | 1613 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1614 |
if (arg == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1615 |
__argValues[i].iVal = 1; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1616 |
} else if (arg == false) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1617 |
__argValues[i].iVal = 0; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1618 |
} else if (__isSmallInteger(arg)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1619 |
__argValues[i].iVal = __intVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1620 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1621 |
__argValues[i].iVal = __unsignedLongIntVal(arg); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1622 |
if (__argValues[i].iVal == 0) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1623 |
# ifdef VERBOSE |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1624 |
if (@global(Verbose) == true) { |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1625 |
printf("invalidArgument: arg%d non bool value [%d]\n", i+1, __LINE__); |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1626 |
} |
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1627 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1628 |
__FAIL__(@symbol(InvalidArgument)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1629 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1630 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1631 |
argValuePtr = &(__argValues[i].iVal); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1632 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1633 |
if (__isSymbol(typeSymbol) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1634 |
&& ((argValueClass = __GLOBAL_GET(typeSymbol)) != nil)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1635 |
if (! __isBehaviorLike(argValueClass)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1636 |
__FAIL__(@symbol(NonBehaviorArgumentType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1637 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1638 |
if (! __qIsSubclassOfExternalAddress(argValueClass)) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1639 |
__FAIL__(@symbol(NonExternalAddressArgumentType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1640 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1641 |
goto commonPointerTypeArg; /* sorry */ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1642 |
} else { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1643 |
__FAIL__(@symbol(UnknownArgumentType)) |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1644 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1645 |
} |
9342 | 1646 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1647 |
__argTypes[i] = thisType; |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1648 |
__argValuePointers[i] = argValuePtr; |
9483 | 1649 |
|
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1650 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1651 |
if (@global(Verbose) == true) { |
19341
2ab29dd7ec1a
mingw 64bit fixes (xxLL in constants - sigh)
Claus Gittinger <cg@exept.de>
parents:
19334
diff
changeset
|
1652 |
printf("arg%d: %"_lx_" type:%"_lx_"\n", i+1, (INT)(__argValues[i].iVal), (INT)thisType); |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1653 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1654 |
# endif |
9342 | 1655 |
} |
9465 | 1656 |
failureInfo = nil; |
9342 | 1657 |
|
1658 |
__callType = FFI_DEFAULT_ABI; |
|
1659 |
||
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1660 |
# ifdef CALLTYPE_FFI_STDCALL |
9465 | 1661 |
if (callTypeNumber == @global(CALLTYPE_API)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1662 |
__callType = CALLTYPE_FFI_STDCALL; |
19334 | 1663 |
# ifdef VERBOSE |
1664 |
if (@global(Verbose) == true) { |
|
1665 |
printf("STDCALL\n"); |
|
1666 |
} |
|
1667 |
# endif |
|
9342 | 1668 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1669 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1670 |
# ifdef CALLTYPE_FFI_V8 |
9465 | 1671 |
if (callTypeNumber == @global(CALLTYPE_V8)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1672 |
__callType = CALLTYPE_FFI_V8; |
9342 | 1673 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1674 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1675 |
# ifdef CALLTYPE_FFI_V9 |
9465 | 1676 |
if (callTypeNumber == @global(CALLTYPE_V9)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1677 |
__callType = CALLTYPE_FFI_V9; |
9342 | 1678 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1679 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1680 |
# ifdef CALLTYPE_FFI_UNIX64 |
9465 | 1681 |
if (callTypeNumber == @global(CALLTYPE_UNIX64)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1682 |
__callType = CALLTYPE_FFI_UNIX64; |
9342 | 1683 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1684 |
# endif |
9342 | 1685 |
|
1686 |
if (ffi_prep_cif(&__cif, __callType, __numArgsIncludingThis, __returnType, __argTypesIncludingThis) != FFI_OK) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1687 |
__FAIL__(@symbol(FFIPrepareFailed)) |
9342 | 1688 |
} |
9463 | 1689 |
if (async == true) { |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1690 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1691 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1692 |
printf("async call 0x%"_lx_"\n", (INT)codeAddress); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1693 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1694 |
# endif |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1695 |
# ifdef WIN32 |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1696 |
__STX_C_CALL4( "ffi_call", ffi_call, &__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis); |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1697 |
# else |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1698 |
__BEGIN_INTERRUPTABLE__ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1699 |
ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1700 |
__END_INTERRUPTABLE__ |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1701 |
# endif |
9435 | 1702 |
} else { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1703 |
if (unlimitedStack == true) { |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1704 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1705 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1706 |
printf("UNLIMITEDSTACKCALL call 0x%"_lx_"\n", (INT)codeAddress); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1707 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1708 |
# endif |
19356 | 1709 |
__UNLIMITEDSTACKCALL4__((OBJFUNC)ffi_call, (INT)(&__cif), (INT)codeAddress, (INT)__returnValuePointer, (INT)__argValuePointersIncludingThis); |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1710 |
} else { |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1711 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1712 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1713 |
printf("call 0x%"_lx_"\n", (INT)codeAddress); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1714 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1715 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1716 |
ffi_call(&__cif, codeAddress, __returnValuePointer, __argValuePointersIncludingThis); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1717 |
} |
9435 | 1718 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1719 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1720 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1721 |
printf("retval is %"_ld_" (0x%"_lx_")\n", (INT)(__returnValue.iVal), (INT)(__returnValue.iVal)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1722 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1723 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1724 |
|
11586 | 1725 |
if ((returnTypeSymbol == @symbol(int)) |
1726 |
|| (returnTypeSymbol == @symbol(sint)) |
|
9479 | 1727 |
|| (returnTypeSymbol == @symbol(sint8)) |
1728 |
|| (returnTypeSymbol == @symbol(sint16)) |
|
1729 |
|| (returnTypeSymbol == @symbol(sint32))) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1730 |
# ifdef VERBOSE |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1731 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1732 |
printf("return int: %x\n", __returnValue.iVal); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1733 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1734 |
# endif |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1735 |
RETURN ( __MKINT(__returnValue.iVal) ); |
9342 | 1736 |
} |
1737 |
if ((returnTypeSymbol == @symbol(uint)) |
|
1738 |
|| (returnTypeSymbol == @symbol(uint8)) |
|
1739 |
|| (returnTypeSymbol == @symbol(uint16)) |
|
1740 |
|| (returnTypeSymbol == @symbol(uint32))) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1741 |
# ifdef VERBOSE |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1742 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1743 |
printf("return uint: %x\n", __returnValue.iVal); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1744 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1745 |
# endif |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1746 |
RETURN ( __MKUINT(__returnValue.iVal) ); |
9342 | 1747 |
} |
10025
053904a63549
stc-compiled ExternalLibraryFunctions
Claus Gittinger <cg@exept.de>
parents:
9981
diff
changeset
|
1748 |
if (returnTypeSymbol == @symbol(bool)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1749 |
RETURN ( __returnValue.iVal ? true : false ); |
9342 | 1750 |
} |
1751 |
if (returnTypeSymbol == @symbol(float)) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1752 |
RETURN ( __MKFLOAT(__returnValue.fVal )); |
9342 | 1753 |
} |
1754 |
if (returnTypeSymbol == @symbol(double)) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1755 |
RETURN ( __MKFLOAT(__returnValue.dVal )); |
9342 | 1756 |
} |
1757 |
if (returnTypeSymbol == @symbol(void)) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1758 |
RETURN ( nil ); |
9342 | 1759 |
} |
9463 | 1760 |
if (returnTypeSymbol == @symbol(char)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1761 |
RETURN ( __MKCHARACTER(__returnValue.iVal & 0xFF) ); |
9463 | 1762 |
} |
1763 |
if (returnTypeSymbol == @symbol(wchar)) { |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1764 |
RETURN ( __MKUCHARACTER(__returnValue.iVal & 0xFFFF) ); |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1765 |
} |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1766 |
if (returnTypeSymbol == @symbol(sint64)) { |
19356 | 1767 |
# if (__POINTER_SIZE__ == 8) |
19355 | 1768 |
|
1769 |
# ifdef VERBOSE |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1770 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1771 |
printf("return sint64: %"_lx_"\n", (INT)(__returnValue.longLongVal)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1772 |
} |
19355 | 1773 |
# endif |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1774 |
RETURN ( __MKINT(__returnValue.longLongVal) ); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1775 |
# else |
19355 | 1776 |
# ifdef VERBOSE |
1777 |
if (@global(Verbose) == true) { |
|
19357 | 1778 |
printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal)); |
19355 | 1779 |
} |
1780 |
# endif |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1781 |
RETURN ( __MKINT64(&__returnValue.longLongVal) ); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1782 |
# endif |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1783 |
} |
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1784 |
if (returnTypeSymbol == @symbol(uint64)) { |
19356 | 1785 |
# if (__POINTER_SIZE__ == 8) |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1786 |
# ifdef VERBOSE |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1787 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1788 |
printf("return uint64: %"_lx_"\n", (unsigned INT)(__returnValue.longLongVal)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1789 |
} |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1790 |
# endif |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1791 |
RETURN ( __MKUINT(__returnValue.longLongVal) ); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1792 |
# else |
19355 | 1793 |
# ifdef VERBOSE |
1794 |
if (@global(Verbose) == true) { |
|
19357 | 1795 |
printf("return sint64: %lx%08lx\n", __HI32(__returnValue.longLongVal), __LO32(__returnValue.longLongVal)); |
19355 | 1796 |
} |
1797 |
# endif |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1798 |
RETURN ( __MKUINT64(&__returnValue.longLongVal) ); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1799 |
# endif |
9463 | 1800 |
} |
11586 | 1801 |
|
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1802 |
# ifdef VERBOSE |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1803 |
if (@global(Verbose) == true) { |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1804 |
printf("return pointer: %"_lx_"\n", (INT)(__returnValue.pointerVal)); |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1805 |
} |
12504
c9987bb76eb6
untested long long return value
Claus Gittinger <cg@exept.de>
parents:
12503
diff
changeset
|
1806 |
# endif |
9346 | 1807 |
if (returnTypeSymbol == @symbol(handle)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1808 |
returnValue = __MKEXTERNALADDRESS(__returnValue.pointerVal); |
9346 | 1809 |
} else if (returnTypeSymbol == @symbol(pointer)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1810 |
returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal); |
10603 | 1811 |
} else if (returnTypeSymbol == @symbol(bytePointer)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1812 |
returnValue = __MKEXTERNALBYTES(__returnValue.pointerVal); |
9463 | 1813 |
} else if (returnTypeSymbol == @symbol(charPointer)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1814 |
returnValue = __MKSTRING(__returnValue.pointerVal); |
9463 | 1815 |
} else if (returnTypeSymbol == @symbol(wcharPointer)) { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1816 |
returnValue = __MKU16STRING(__returnValue.pointerVal); |
9342 | 1817 |
} else { |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1818 |
__FAIL__(@symbol(UnknownReturnType2)) |
9342 | 1819 |
} |
10603 | 1820 |
#else /* no FFI support */ |
10618
343d0bf4646a
Now can compile even #ifndef HAVE_FFI
Stefan Vogel <sv@exept.de>
parents:
10614
diff
changeset
|
1821 |
failureCode = @symbol(FFINotSupported); |
10603 | 1822 |
#endif /* HAVE_FFI */ |
9342 | 1823 |
getOutOfHere: ; |
1824 |
%}. |
|
1825 |
failureCode notNil ifTrue:[ |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1826 |
(failureCode == #UnknownReturnType or:[ failureCode == #UnknownArgumentType ]) ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1827 |
oldReturnType := returnType. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1828 |
oldArgumentTypes := argumentTypes. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1829 |
self adjustTypes. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1830 |
((oldReturnType ~= returnType) or:[oldArgumentTypes ~= argumentTypes]) ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1831 |
thisContext restart |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1832 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1833 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1834 |
(failureCode == #BadArgForAsyncCall) ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1835 |
^ self tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1836 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1837 |
(failureCode == #FFINotSupported) ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1838 |
self primitiveFailed:'FFI support missing in this build'. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1839 |
]. |
12579
516bba5b3e57
changed: #ffiTypeSymbolForType:
Claus Gittinger <cg@exept.de>
parents:
12504
diff
changeset
|
1840 |
|
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1841 |
self primitiveFailed. "see failureCode and failureInfo for details" |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1842 |
^ nil |
9342 | 1843 |
]. |
1844 |
||
9483 | 1845 |
returnType isSymbol ifTrue:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1846 |
returnValueClass notNil ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1847 |
self isConstReturnValue ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1848 |
returnValue changeClassTo:returnValueClass. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1849 |
^ returnValue |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1850 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1851 |
^ returnValueClass fromExternalAddress:returnValue. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1852 |
]. |
9483 | 1853 |
] ifFalse:[ |
19314
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1854 |
returnType isCPointer ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1855 |
returnType baseType isCStruct ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1856 |
stClass := Smalltalk classNamed:returnType baseType name. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1857 |
stClass notNil ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1858 |
self isConstReturnValue ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1859 |
returnValue changeClassTo:returnValueClass. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1860 |
^ returnValue |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1861 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1862 |
^ stClass fromExternalAddress:returnValue. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1863 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1864 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1865 |
returnType baseType isCChar ifTrue:[ |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1866 |
^ returnValue stringAt:1 |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1867 |
]. |
698cf296ef6d
mingw64 and debugging stuff
Claus Gittinger <cg@exept.de>
parents:
19313
diff
changeset
|
1868 |
]. |
9342 | 1869 |
]. |
1870 |
||
1871 |
^ returnValue |
|
9463 | 1872 |
|
1873 |
"Created: / 01-08-2006 / 13:56:23 / cg" |
|
10603 | 1874 |
"Modified: / 11-06-2007 / 01:50:36 / cg" |
14037 | 1875 |
! |
1876 |
||
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
1877 |
tryAgainWithAsyncSafeArguments:argumentsOrNil forCPPInstance:aReceiverOrNil |
14037 | 1878 |
"invoked by the call primitive, iff GC-unsave arguments where passed to the call. |
1879 |
Here, allocate non-movable blocks of memory and copy the arguments into them, |
|
1880 |
then try the call again, copy changed values back, and release the memeory." |
|
1881 |
||
1882 |
|saveArguments anyBadArg result originalToSaveArgMapping| |
|
1883 |
||
1884 |
argumentsOrNil isNil ifTrue:[ |
|
14625 | 1885 |
^ self primitiveFailed |
14037 | 1886 |
]. |
14506
e53548cdc24d
changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents:
14412
diff
changeset
|
1887 |
thisContext isRecursive ifTrue: [^self primitiveFailed]. |
14037 | 1888 |
|
1889 |
anyBadArg := false. |
|
1890 |
originalToSaveArgMapping := IdentityDictionary new. |
|
1891 |
||
14625 | 1892 |
saveArguments := argumentsOrNil |
1893 |
collect:[:eachArg | |
|
1894 |
|saveArg| |
|
14037 | 1895 |
|
14625 | 1896 |
(originalToSaveArgMapping includesKey:eachArg) ifTrue:[ |
1897 |
saveArg := originalToSaveArgMapping at:eachArg |
|
1898 |
] ifFalse:[ |
|
1899 |
eachArg isString ifTrue:[ |
|
1900 |
saveArg := (ExternalBytes fromString:eachArg) register. |
|
1901 |
anyBadArg := true. |
|
1902 |
originalToSaveArgMapping at:eachArg put:saveArg. |
|
1903 |
] ifFalse:[ |
|
1904 |
eachArg isByteCollection ifTrue:[ |
|
1905 |
saveArg := (ExternalBytes from:eachArg) register. |
|
1906 |
originalToSaveArgMapping at:eachArg put:saveArg. |
|
1907 |
anyBadArg := true. |
|
1908 |
] ifFalse:[ |
|
1909 |
saveArg := eachArg |
|
1910 |
] |
|
1911 |
]. |
|
1912 |
]. |
|
1913 |
saveArg |
|
1914 |
]. |
|
14037 | 1915 |
|
1916 |
anyBadArg ifFalse:[ |
|
14625 | 1917 |
"avoid recursion..." |
1918 |
^ self primitiveFailed |
|
14037 | 1919 |
]. |
1920 |
||
14659
410089913ca1
allow use of the standard (system) ffi
Claus Gittinger <cg@exept.de>
parents:
14632
diff
changeset
|
1921 |
result := self invokeFFIwithArguments:saveArguments forCPPInstance:aReceiverOrNil. |
14037 | 1922 |
|
1923 |
"/ copy back !! |
|
1924 |
originalToSaveArgMapping keysAndValuesDo:[:arg :saveArg | |
|
14625 | 1925 |
arg isSymbol ifFalse:[ |
1926 |
arg replaceFrom:1 to:(arg size) with:saveArg startingAt:1. |
|
1927 |
]. |
|
1928 |
saveArg free. |
|
14037 | 1929 |
]. |
1930 |
^ result. |
|
14506
e53548cdc24d
changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents:
14412
diff
changeset
|
1931 |
|
e53548cdc24d
changed: #tryAgainWithAsyncSafeArguments:forCPPInstance:
anwild
parents:
14412
diff
changeset
|
1932 |
"Modified (format): / 06-11-2012 / 10:52:41 / anwild" |
9342 | 1933 |
! ! |
1934 |
||
10481 | 1935 |
!ExternalLibraryFunction methodsFor:'testing'! |
1936 |
||
10603 | 1937 |
isExternalLibraryFunction |
1938 |
"return true, if the receiver is some kind of externalLibrary function; |
|
1939 |
true is returned here" |
|
1940 |
||
1941 |
^true |
|
1942 |
||
1943 |
"Created: / 07-06-2007 / 10:36:40 / cg" |
|
10481 | 1944 |
! ! |
1945 |
||
8533 | 1946 |
!ExternalLibraryFunction class methodsFor:'documentation'! |
1947 |
||
13412 | 1948 |
version_CVS |
19311 | 1949 |
^ '$Header$' |
12436 | 1950 |
! |
1951 |
||
13412 | 1952 |
version_SVN |
19311 | 1953 |
^ '$ Id: ExternalLibraryFunction.st 10643 2011-06-08 21:53:07Z vranyj1 $' |
8533 | 1954 |
! ! |
9463 | 1955 |
|
19311 | 1956 |
|
9463 | 1957 |
ExternalLibraryFunction initialize! |