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