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