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