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