659
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1998 by eXept Software AG
|
|
3 |
All Rights Reserved
|
|
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 |
"
|
|
12 |
|
|
13 |
|
|
14 |
ExternalFunction subclass:#WinAPIFunction
|
|
15 |
instanceVariableNames:''
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'OS-Windows'
|
|
19 |
!
|
|
20 |
|
|
21 |
!WinAPIFunction primitiveDefinitions!
|
|
22 |
%{
|
|
23 |
typedef WINAPI INT (*WINAPI_INTFUNC)();
|
|
24 |
%}
|
|
25 |
|
|
26 |
! !
|
|
27 |
|
|
28 |
!WinAPIFunction class methodsFor:'documentation'!
|
|
29 |
|
|
30 |
copyright
|
|
31 |
"
|
|
32 |
COPYRIGHT (c) 1998 by eXept Software AG
|
|
33 |
All Rights Reserved
|
|
34 |
|
|
35 |
This software is furnished under a license and may be used
|
|
36 |
only in accordance with the terms of that license and with the
|
|
37 |
inclusion of the above copyright notice. This software may not
|
|
38 |
be provided or otherwise made available to, or used by, any
|
|
39 |
other person. No title to or ownership of the software is
|
|
40 |
hereby transferred.
|
|
41 |
"
|
|
42 |
|
|
43 |
!
|
|
44 |
|
|
45 |
documentation
|
|
46 |
"
|
|
47 |
WIN32 only:
|
|
48 |
|
|
49 |
Experimental class representing external (non-Smalltalk) WINAPI functions.
|
|
50 |
These will provide the same functionality and protocol as
|
|
51 |
regular externalFunctions, but use a different calling convention.
|
|
52 |
|
|
53 |
Warning: under construction.
|
|
54 |
|
|
55 |
[author:]
|
|
56 |
Claus Gittinger
|
|
57 |
|
|
58 |
[see also:]
|
|
59 |
ExternalAddress ExternalBytes
|
|
60 |
"
|
|
61 |
|
|
62 |
|
|
63 |
! !
|
|
64 |
|
|
65 |
!WinAPIFunction methodsFor:'function calling'!
|
|
66 |
|
|
67 |
call
|
|
68 |
"call the underlying C function, passing no argument.
|
|
69 |
The return value is interpreted as an integer
|
|
70 |
(and must be converted to an externalBytes object,
|
|
71 |
if it is a pointer to something).
|
|
72 |
|
|
73 |
DANGER alert: This is an unprotected low-level entry.
|
|
74 |
Not for normal application usage.
|
|
75 |
"
|
|
76 |
%{
|
|
77 |
WINAPI_INTFUNC func;
|
|
78 |
INT retVal;
|
|
79 |
|
660
|
80 |
func = (WINAPI_INTFUNC) __INST(code_);
|
659
|
81 |
if (func) {
|
|
82 |
retVal = (*func)();
|
|
83 |
RETURN (__MKINT(retVal));
|
|
84 |
}
|
|
85 |
%}.
|
|
86 |
self primitiveFailed
|
|
87 |
|
|
88 |
"Created: / 18.6.1998 / 18:01:28 / cg"
|
660
|
89 |
"Modified: / 18.6.1998 / 18:04:48 / cg"
|
|
90 |
!
|
|
91 |
|
|
92 |
callWith:arg
|
|
93 |
"call the underlying C function, passing a single argument.
|
|
94 |
The argument arg is converted to a corresponding C data type,
|
|
95 |
as defined in the convertST_to_C() function.
|
|
96 |
The return value is interpreted as an integer
|
|
97 |
(and must be converted to an externalBytes object,
|
|
98 |
if it is a pointer to something).
|
|
99 |
|
|
100 |
DANGER alert: This is an unprotected low-level entry.
|
|
101 |
Not for normal application usage.
|
|
102 |
"
|
|
103 |
%{
|
|
104 |
WINAPI_INTFUNC func;
|
|
105 |
INT retVal;
|
|
106 |
|
|
107 |
func = (WINAPI_INTFUNC) __INST(code_);
|
|
108 |
if (func) {
|
|
109 |
retVal = (*func)(convertST_to_C(arg));
|
|
110 |
RETURN (__MKINT(retVal));
|
|
111 |
}
|
|
112 |
%}.
|
|
113 |
self primitiveFailed
|
|
114 |
|
|
115 |
"Created: / 18.6.1998 / 18:04:30 / cg"
|
|
116 |
"Modified: / 18.6.1998 / 18:04:53 / cg"
|
|
117 |
!
|
|
118 |
|
|
119 |
callWith:arg1 with:arg2
|
|
120 |
"call the underlying C function, passing two args.
|
|
121 |
The arguments are converted to a corresponding C data type,
|
|
122 |
as defined in the convertST_to_C() function.
|
|
123 |
The return value is interpreted as an integer
|
|
124 |
(and must be converted to an externalBytes object,
|
|
125 |
if it is a pointer to something).
|
|
126 |
|
|
127 |
DANGER alert: This is an unprotected low-level entry.
|
|
128 |
Not for normal application usage.
|
|
129 |
"
|
|
130 |
%{
|
|
131 |
WINAPI_INTFUNC func;
|
|
132 |
INT retVal;
|
|
133 |
|
|
134 |
func = (WINAPI_INTFUNC) __INST(code_);
|
|
135 |
if (func) {
|
|
136 |
retVal = (*func)(convertST_to_C(arg1), convertST_to_C(arg2));
|
|
137 |
RETURN (__MKINT(retVal));
|
|
138 |
}
|
|
139 |
%}.
|
|
140 |
self primitiveFailed
|
|
141 |
|
|
142 |
"Created: / 18.6.1998 / 18:05:07 / cg"
|
|
143 |
!
|
|
144 |
|
|
145 |
callWith:arg1 with:arg2 with:arg3
|
|
146 |
"call the underlying C function, passing three args.
|
|
147 |
The arguments are converted to a corresponding C data type,
|
|
148 |
as defined in the convertST_to_C() function.
|
|
149 |
The return value is interpreted as an integer
|
|
150 |
(and must be converted to an externalBytes object,
|
|
151 |
if it is a pointer to something).
|
|
152 |
|
|
153 |
DANGER alert: This is an unprotected low-level entry.
|
|
154 |
Not for normal application usage.
|
|
155 |
"
|
|
156 |
%{
|
|
157 |
WINAPI_INTFUNC func;
|
|
158 |
INT retVal;
|
|
159 |
|
|
160 |
func = (WINAPI_INTFUNC) __INST(code_);
|
|
161 |
if (func) {
|
|
162 |
retVal = (*func)(convertST_to_C(arg1), convertST_to_C(arg2), convertST_to_C(arg3));
|
|
163 |
RETURN (__MKINT(retVal));
|
|
164 |
}
|
|
165 |
%}.
|
|
166 |
self primitiveFailed
|
|
167 |
|
|
168 |
"Created: / 18.6.1998 / 18:05:18 / cg"
|
|
169 |
!
|
|
170 |
|
|
171 |
callWithArguments:argArray
|
|
172 |
"call the underlying C function, passing up to 10 arguments.
|
|
173 |
The arguments are converted to a corresponding C data type,
|
|
174 |
as defined in the convertST_to_C() function.
|
|
175 |
The return value is interpreted as an integer
|
|
176 |
(and must be converted to an externalBytes object,
|
|
177 |
if it is a pointer to something).
|
|
178 |
|
|
179 |
DANGER alert: This is an unprotected low-level entry.
|
|
180 |
Not for normal application usage.
|
|
181 |
"
|
|
182 |
%{
|
|
183 |
WINAPI_INTFUNC func;
|
|
184 |
# define NUMARGS 10
|
|
185 |
INT args[NUMARGS];
|
|
186 |
INT retVal;
|
|
187 |
OBJ *ap;
|
|
188 |
INT convertST_to_C();
|
|
189 |
|
|
190 |
func = (WINAPI_INTFUNC) __INST(code_);
|
1566
|
191 |
if (func && __isArrayLike(argArray)) {
|
660
|
192 |
int n = __arraySize(argArray);
|
|
193 |
int i;
|
|
194 |
|
|
195 |
if (n <= 10) {
|
|
196 |
ap = __ArrayInstPtr(argArray)->a_element;
|
|
197 |
for (i=0; i<NUMARGS; i++) {
|
|
198 |
args[i] = convertST_to_C(*ap++);
|
|
199 |
}
|
|
200 |
}
|
|
201 |
switch (n) {
|
|
202 |
case 0:
|
|
203 |
retVal = (*func)();
|
|
204 |
break;
|
|
205 |
case 1:
|
|
206 |
retVal = (*func)(args[0]);
|
|
207 |
break;
|
|
208 |
case 2:
|
|
209 |
retVal = (*func)(args[0], args[1]);
|
|
210 |
break;
|
|
211 |
case 3:
|
|
212 |
retVal = (*func)(args[0], args[1], args[2]);
|
|
213 |
break;
|
|
214 |
case 4:
|
|
215 |
retVal = (*func)(args[0], args[1], args[2], args[3]);
|
|
216 |
break;
|
|
217 |
case 5:
|
|
218 |
retVal = (*func)(args[0], args[1], args[2], args[3],
|
|
219 |
args[4]);
|
|
220 |
break;
|
|
221 |
case 6:
|
|
222 |
retVal = (*func)(args[0], args[1], args[2], args[3],
|
|
223 |
args[4], args[5]);
|
|
224 |
break;
|
|
225 |
case 7:
|
|
226 |
retVal = (*func)(args[0], args[1], args[2], args[3],
|
|
227 |
args[4], args[5], args[6]);
|
|
228 |
break;
|
|
229 |
case 8:
|
|
230 |
retVal = (*func)(args[0], args[1], args[2], args[3],
|
|
231 |
args[4], args[5], args[6], args[7]);
|
|
232 |
break;
|
|
233 |
case 9:
|
|
234 |
retVal = (*func)(args[0], args[1], args[2], args[3],
|
|
235 |
args[4], args[5], args[6], args[7],
|
|
236 |
args[8]);
|
|
237 |
break;
|
|
238 |
case 10:
|
|
239 |
retVal = (*func)(args[0], args[1], args[2], args[3],
|
|
240 |
args[4], args[5], args[6], args[7],
|
|
241 |
args[8], args[9]);
|
|
242 |
break;
|
|
243 |
default:
|
|
244 |
goto err;
|
|
245 |
}
|
|
246 |
RETURN (__MKINT(retVal));
|
|
247 |
}
|
|
248 |
err: ;
|
|
249 |
%}.
|
|
250 |
self primitiveFailed
|
|
251 |
|
|
252 |
"Created: / 18.6.1998 / 18:05:46 / cg"
|
659
|
253 |
! !
|
|
254 |
|
|
255 |
!WinAPIFunction class methodsFor:'documentation'!
|
|
256 |
|
|
257 |
version
|
1566
|
258 |
^ '$Header: /cvs/stx/stx/libbasic2/WinAPIFunction.st,v 1.3 2005-07-13 14:22:19 cg Exp $'
|
659
|
259 |
! !
|