Mercurial > cpython-lru_cache-weakref
annotate Modules/cstubs @ 4566:6403c94de50d legacy-trunk
Added safeguard against failure in __del__.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Wed, 27 Nov 1996 19:39:58 +0000 |
| parents | 65d2d8e67da3 |
| children | 94ce3e01c30c |
| rev | line source |
|---|---|
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
1 /*********************************************************** |
|
2061
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
3 The Netherlands. |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
4 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
5 All Rights Reserved |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
6 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
15 permission. |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
29 |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
30 ******************************************************************/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1443
diff
changeset
|
31 |
| 6 | 32 /* |
| 33 Input used to generate the Python module "glmodule.c". | |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
34 The stub generator is a Python script called "cgen.py". |
| 6 | 35 |
| 36 Each definition must be contained on one line: | |
| 37 | |
| 38 <returntype> <name> <type> <arg> <type> <arg> | |
| 39 | |
| 40 <returntype> can be: void, short, long (XXX maybe others?) | |
| 41 | |
| 42 <type> can be: char, string, short, float, long, or double | |
| 43 string indicates a null terminated string; | |
| 44 if <type> is char and <arg> begins with a *, the * is stripped | |
| 45 and <type> is changed into string | |
| 46 | |
| 47 <arg> has the form <mode> or <mode>[<subscript>] | |
| 48 where <mode> can be | |
| 49 s: arg is sent | |
| 50 r: arg is received (arg is a pointer) | |
| 51 and <subscript> can be (N and I are numbers): | |
| 52 N | |
| 53 argI | |
| 54 retval | |
| 55 N*argI | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
56 N*I |
| 6 | 57 N*retval |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
58 In the case where the subscript consists of two parts |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
59 separated by *, the first part is the width of the matrix, and |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
60 the second part is the length of the matrix. This order is |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
61 opposite from the order used in C to declare a two-dimensional |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
62 matrix. |
| 6 | 63 */ |
| 64 | |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
65 /* |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
66 * An attempt has been made to make this module switch threads on qread |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
67 * calls. It is far from safe, though. |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
68 */ |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
69 |
| 6 | 70 #include <gl.h> |
| 71 #include <device.h> | |
| 86 | 72 |
| 73 #include "allobjects.h" | |
| 6 | 74 #include "import.h" |
| 75 #include "modsupport.h" | |
| 76 #include "cgensupport.h" | |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
77 #include "ceval.h" |
| 6 | 78 |
| 79 /* | |
| 80 Some stubs are too complicated for the stub generator. | |
| 81 We can include manually written versions of them here. | |
| 82 A line starting with '%' gives the name of the function so the stub | |
| 83 generator can include it in the table of functions. | |
| 84 */ | |
| 85 | |
|
947
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
86 % qread |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
87 |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
88 static object * |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
89 gl_qread(self, args) |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
90 object *self; |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
91 object *args; |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
92 { |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
93 long retval; |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
94 short arg1 ; |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
95 BGN_SAVE |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
96 retval = qread( & arg1 ); |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
97 END_SAVE |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
98 { object *v = newtupleobject( 2 ); |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
99 if (v == NULL) return NULL; |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
100 settupleitem(v, 0, mknewlongobject(retval)); |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
101 settupleitem(v, 1, mknewshortobject(arg1)); |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
102 return v; |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
103 } |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
104 } |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
105 |
|
260d96db112f
Modified to allow other threads to run in a multithreaded environment.
Jack Jansen <jack.jansen@cwi.nl>
parents:
906
diff
changeset
|
106 |
| 6 | 107 /* |
| 108 varray -- an array of v.. calls. | |
| 109 The argument is an array (maybe list or tuple) of points. | |
| 110 Each point must be a tuple or list of coordinates (x, y, z). | |
| 111 The points may be 2- or 3-dimensional but must all have the | |
| 112 same dimension. Float and int values may be mixed however. | |
| 113 The points are always converted to 3D double precision points | |
| 114 by assuming z=0.0 if necessary (as indicated in the man page), | |
| 115 and for each point v3d() is called. | |
| 116 */ | |
| 117 | |
| 118 % varray | |
| 119 | |
| 120 static object * | |
| 121 gl_varray(self, args) | |
| 122 object *self; | |
| 123 object *args; | |
| 124 { | |
| 125 object *v, *w; | |
| 126 int i, n, width; | |
| 127 double vec[3]; | |
| 128 object * (*getitem) FPROTO((object *, int)); | |
| 129 | |
| 130 if (!getiobjectarg(args, 1, 0, &v)) | |
| 131 return NULL; | |
| 132 | |
| 133 if (is_listobject(v)) { | |
| 134 n = getlistsize(v); | |
| 135 getitem = getlistitem; | |
| 136 } | |
| 137 else if (is_tupleobject(v)) { | |
| 138 n = gettuplesize(v); | |
| 139 getitem = gettupleitem; | |
| 140 } | |
| 141 else { | |
| 142 err_badarg(); | |
| 143 return NULL; | |
| 144 } | |
| 145 | |
| 146 if (n == 0) { | |
| 147 INCREF(None); | |
| 148 return None; | |
| 149 } | |
| 150 if (n > 0) | |
| 151 w = (*getitem)(v, 0); | |
| 152 | |
| 153 width = 0; | |
| 154 if (w == NULL) { | |
| 155 } | |
| 156 else if (is_listobject(w)) { | |
| 157 width = getlistsize(w); | |
| 158 } | |
| 159 else if (is_tupleobject(w)) { | |
| 160 width = gettuplesize(w); | |
| 161 } | |
| 162 | |
| 163 switch (width) { | |
| 164 case 2: | |
| 165 vec[2] = 0.0; | |
| 166 /* Fall through */ | |
| 167 case 3: | |
| 168 break; | |
| 169 default: | |
| 170 err_badarg(); | |
| 171 return NULL; | |
| 172 } | |
| 173 | |
| 174 for (i = 0; i < n; i++) { | |
| 175 w = (*getitem)(v, i); | |
| 176 if (!getidoublearray(w, 1, 0, width, vec)) | |
| 177 return NULL; | |
| 178 v3d(vec); | |
| 179 } | |
| 180 | |
| 181 INCREF(None); | |
| 182 return None; | |
| 183 } | |
| 184 | |
| 185 /* | |
| 186 vnarray, nvarray -- an array of n3f and v3f calls. | |
| 187 The argument is an array (list or tuple) of pairs of points and normals. | |
| 188 Each pair is a tuple (NOT a list) of a point and a normal for that point. | |
| 189 Each point or normal must be a tuple (NOT a list) of coordinates (x, y, z). | |
| 190 Three coordinates must be given. Float and int values may be mixed. | |
| 191 For each pair, n3f() is called for the normal, and then v3f() is called | |
| 192 for the vector. | |
| 193 | |
| 194 vnarray and nvarray differ only in the order of the vector and normal in | |
| 195 the pair: vnarray expects (v, n) while nvarray expects (n, v). | |
| 196 */ | |
| 197 | |
| 198 static object *gen_nvarray(); /* Forward */ | |
| 199 | |
| 200 % nvarray | |
| 201 | |
| 202 static object * | |
| 203 gl_nvarray(self, args) | |
| 204 object *self; | |
| 205 object *args; | |
| 206 { | |
| 207 return gen_nvarray(args, 0); | |
| 208 } | |
| 209 | |
| 210 % vnarray | |
| 211 | |
| 212 static object * | |
| 213 gl_vnarray(self, args) | |
| 214 object *self; | |
| 215 object *args; | |
| 216 { | |
| 217 return gen_nvarray(args, 1); | |
| 218 } | |
| 219 | |
| 220 /* Generic, internal version of {nv,nv}array: inorm indicates the | |
| 221 argument order, 0: normal first, 1: vector first. */ | |
| 222 | |
| 223 static object * | |
| 224 gen_nvarray(args, inorm) | |
| 225 object *args; | |
| 226 int inorm; | |
| 227 { | |
| 228 object *v, *w, *wnorm, *wvec; | |
| 229 int i, n; | |
| 230 float norm[3], vec[3]; | |
| 231 object * (*getitem) FPROTO((object *, int)); | |
| 232 | |
| 233 if (!getiobjectarg(args, 1, 0, &v)) | |
| 234 return NULL; | |
| 235 | |
| 236 if (is_listobject(v)) { | |
| 237 n = getlistsize(v); | |
| 238 getitem = getlistitem; | |
| 239 } | |
| 240 else if (is_tupleobject(v)) { | |
| 241 n = gettuplesize(v); | |
| 242 getitem = gettupleitem; | |
| 243 } | |
| 244 else { | |
| 245 err_badarg(); | |
| 246 return NULL; | |
| 247 } | |
| 248 | |
| 249 for (i = 0; i < n; i++) { | |
| 250 w = (*getitem)(v, i); | |
| 251 if (!is_tupleobject(w) || gettuplesize(w) != 2) { | |
| 252 err_badarg(); | |
| 253 return NULL; | |
| 254 } | |
| 255 wnorm = gettupleitem(w, inorm); | |
| 256 wvec = gettupleitem(w, 1 - inorm); | |
| 257 if (!getifloatarray(wnorm, 1, 0, 3, norm) || | |
| 258 !getifloatarray(wvec, 1, 0, 3, vec)) | |
| 259 return NULL; | |
| 260 n3f(norm); | |
| 261 v3f(vec); | |
| 262 } | |
| 263 | |
| 264 INCREF(None); | |
| 265 return None; | |
| 266 } | |
| 267 | |
| 268 /* nurbssurface(s_knots[], t_knots[], ctl[][], s_order, t_order, type). | |
| 269 The dimensions of ctl[] are computed as follows: | |
| 270 [len(s_knots) - s_order], [len(t_knots) - t_order] | |
| 271 */ | |
| 272 | |
| 273 % nurbssurface | |
| 274 | |
| 275 static object * | |
| 276 gl_nurbssurface(self, args) | |
| 277 object *self; | |
| 278 object *args; | |
| 279 { | |
| 280 long arg1 ; | |
| 281 double * arg2 ; | |
| 282 long arg3 ; | |
| 283 double * arg4 ; | |
| 284 double *arg5 ; | |
| 285 long arg6 ; | |
| 286 long arg7 ; | |
| 287 long arg8 ; | |
| 288 long ncoords; | |
| 289 long s_byte_stride, t_byte_stride; | |
| 290 long s_nctl, t_nctl; | |
| 291 long s, t; | |
| 292 object *v, *w, *pt; | |
| 293 double *pnext; | |
| 294 if (!getilongarraysize(args, 6, 0, &arg1)) | |
| 295 return NULL; | |
| 296 if ((arg2 = NEW(double, arg1 )) == NULL) { | |
| 297 return err_nomem(); | |
| 298 } | |
| 299 if (!getidoublearray(args, 6, 0, arg1 , arg2)) | |
| 300 return NULL; | |
| 301 if (!getilongarraysize(args, 6, 1, &arg3)) | |
| 302 return NULL; | |
| 303 if ((arg4 = NEW(double, arg3 )) == NULL) { | |
| 304 return err_nomem(); | |
| 305 } | |
| 306 if (!getidoublearray(args, 6, 1, arg3 , arg4)) | |
| 307 return NULL; | |
| 308 if (!getilongarg(args, 6, 3, &arg6)) | |
| 309 return NULL; | |
| 310 if (!getilongarg(args, 6, 4, &arg7)) | |
| 311 return NULL; | |
| 312 if (!getilongarg(args, 6, 5, &arg8)) | |
| 313 return NULL; | |
| 314 if (arg8 == N_XYZ) | |
| 315 ncoords = 3; | |
| 316 else if (arg8 == N_XYZW) | |
| 317 ncoords = 4; | |
| 318 else { | |
| 319 err_badarg(); | |
| 320 return NULL; | |
| 321 } | |
| 322 s_nctl = arg1 - arg6; | |
| 323 t_nctl = arg3 - arg7; | |
| 324 if (!getiobjectarg(args, 6, 2, &v)) | |
| 325 return NULL; | |
| 326 if (!is_listobject(v) || getlistsize(v) != s_nctl) { | |
| 327 err_badarg(); | |
| 328 return NULL; | |
| 329 } | |
| 330 if ((arg5 = NEW(double, s_nctl*t_nctl*ncoords )) == NULL) { | |
| 331 return err_nomem(); | |
| 332 } | |
| 333 pnext = arg5; | |
| 334 for (s = 0; s < s_nctl; s++) { | |
| 335 w = getlistitem(v, s); | |
| 336 if (w == NULL || !is_listobject(w) || | |
| 337 getlistsize(w) != t_nctl) { | |
| 338 err_badarg(); | |
| 339 return NULL; | |
| 340 } | |
| 341 for (t = 0; t < t_nctl; t++) { | |
| 342 pt = getlistitem(w, t); | |
| 343 if (!getidoublearray(pt, 1, 0, ncoords, pnext)) | |
| 344 return NULL; | |
| 345 pnext += ncoords; | |
| 346 } | |
| 347 } | |
| 348 s_byte_stride = sizeof(double) * ncoords; | |
| 349 t_byte_stride = s_byte_stride * s_nctl; | |
| 350 nurbssurface( arg1 , arg2 , arg3 , arg4 , | |
| 351 s_byte_stride , t_byte_stride , arg5 , arg6 , arg7 , arg8 ); | |
| 352 DEL(arg2); | |
| 353 DEL(arg4); | |
| 354 DEL(arg5); | |
| 355 INCREF(None); | |
| 356 return None; | |
| 357 } | |
| 358 | |
| 359 /* nurbscurve(knots, ctlpoints, order, type). | |
| 360 The length of ctlpoints is len(knots)-order. */ | |
| 361 | |
| 362 %nurbscurve | |
| 363 | |
| 364 static object * | |
| 365 gl_nurbscurve(self, args) | |
| 366 object *self; | |
| 367 object *args; | |
| 368 { | |
| 369 long arg1 ; | |
| 370 double * arg2 ; | |
| 371 long arg3 ; | |
| 372 double * arg4 ; | |
| 373 long arg5 ; | |
| 374 long arg6 ; | |
| 375 int ncoords, npoints; | |
| 376 int i; | |
| 377 object *v; | |
| 378 double *pnext; | |
| 379 if (!getilongarraysize(args, 4, 0, &arg1)) | |
| 380 return NULL; | |
| 381 if ((arg2 = NEW(double, arg1 )) == NULL) { | |
| 382 return err_nomem(); | |
| 383 } | |
| 384 if (!getidoublearray(args, 4, 0, arg1 , arg2)) | |
| 385 return NULL; | |
| 386 if (!getilongarg(args, 4, 2, &arg5)) | |
| 387 return NULL; | |
| 388 if (!getilongarg(args, 4, 3, &arg6)) | |
| 389 return NULL; | |
| 390 if (arg6 == N_ST) | |
| 391 ncoords = 2; | |
| 392 else if (arg6 == N_STW) | |
| 393 ncoords = 3; | |
| 394 else { | |
| 395 err_badarg(); | |
| 396 return NULL; | |
| 397 } | |
| 398 npoints = arg1 - arg5; | |
| 399 if (!getiobjectarg(args, 4, 1, &v)) | |
| 400 return NULL; | |
| 401 if (!is_listobject(v) || getlistsize(v) != npoints) { | |
| 402 err_badarg(); | |
| 403 return NULL; | |
| 404 } | |
| 405 if ((arg4 = NEW(double, npoints*ncoords )) == NULL) { | |
| 406 return err_nomem(); | |
| 407 } | |
| 408 pnext = arg4; | |
| 409 for (i = 0; i < npoints; i++) { | |
| 410 if (!getidoublearray(getlistitem(v, i), 1, 0, ncoords, pnext)) | |
| 411 return NULL; | |
| 412 pnext += ncoords; | |
| 413 } | |
| 414 arg3 = (sizeof(double)) * ncoords; | |
| 415 nurbscurve( arg1 , arg2 , arg3 , arg4 , arg5 , arg6 ); | |
| 416 DEL(arg2); | |
| 417 DEL(arg4); | |
| 418 INCREF(None); | |
| 419 return None; | |
| 420 } | |
| 421 | |
| 422 /* pwlcurve(points, type). | |
| 423 Points is a list of points. Type must be N_ST. */ | |
| 424 | |
| 425 %pwlcurve | |
| 426 | |
| 427 static object * | |
| 428 gl_pwlcurve(self, args) | |
| 429 object *self; | |
| 430 object *args; | |
| 431 { | |
| 432 object *v; | |
| 433 long type; | |
| 434 double *data, *pnext; | |
| 435 long npoints, ncoords; | |
| 436 int i; | |
| 437 if (!getiobjectarg(args, 2, 0, &v)) | |
| 438 return NULL; | |
| 439 if (!getilongarg(args, 2, 1, &type)) | |
| 440 return NULL; | |
| 441 if (!is_listobject(v)) { | |
| 442 err_badarg(); | |
| 443 return NULL; | |
| 444 } | |
| 445 npoints = getlistsize(v); | |
| 446 if (type == N_ST) | |
| 447 ncoords = 2; | |
| 448 else { | |
| 449 err_badarg(); | |
| 450 return NULL; | |
| 451 } | |
| 452 if ((data = NEW(double, npoints*ncoords)) == NULL) { | |
| 453 return err_nomem(); | |
| 454 } | |
| 455 pnext = data; | |
| 456 for (i = 0; i < npoints; i++) { | |
| 457 if (!getidoublearray(getlistitem(v, i), 1, 0, ncoords, pnext)) | |
| 458 return NULL; | |
| 459 pnext += ncoords; | |
| 460 } | |
| 461 pwlcurve(npoints, data, sizeof(double)*ncoords, type); | |
| 462 DEL(data); | |
| 463 INCREF(None); | |
| 464 return None; | |
| 465 } | |
| 466 | |
| 467 | |
| 468 /* Picking and Selecting */ | |
| 469 | |
| 470 static short *pickbuffer = NULL; | |
| 471 static long pickbuffersize; | |
| 472 | |
| 473 static object * | |
| 474 pick_select(args, func) | |
| 475 object *args; | |
| 476 void (*func)(); | |
| 477 { | |
| 478 if (!getilongarg(args, 1, 0, &pickbuffersize)) | |
| 479 return NULL; | |
| 480 if (pickbuffer != NULL) { | |
| 481 err_setstr(RuntimeError, | |
| 482 "pick/gselect: already picking/selecting"); | |
| 483 return NULL; | |
| 484 } | |
| 485 if ((pickbuffer = NEW(short, pickbuffersize)) == NULL) { | |
| 486 return err_nomem(); | |
| 487 } | |
| 488 (*func)(pickbuffer, pickbuffersize); | |
| 489 INCREF(None); | |
| 490 return None; | |
| 491 } | |
| 492 | |
| 493 static object * | |
| 494 endpick_select(args, func) | |
| 495 object *args; | |
| 496 long (*func)(); | |
| 497 { | |
| 498 object *v, *w; | |
| 499 int i, nhits, n; | |
| 500 if (!getnoarg(args)) | |
| 501 return NULL; | |
| 502 if (pickbuffer == NULL) { | |
| 503 err_setstr(RuntimeError, | |
| 504 "endpick/endselect: not in pick/select mode"); | |
| 505 return NULL; | |
| 506 } | |
| 507 nhits = (*func)(pickbuffer); | |
| 508 if (nhits < 0) { | |
| 509 nhits = -nhits; /* How to report buffer overflow otherwise? */ | |
| 510 } | |
| 511 /* Scan the buffer to see how many integers */ | |
| 512 n = 0; | |
| 513 for (; nhits > 0; nhits--) { | |
| 514 n += 1 + pickbuffer[n]; | |
| 515 } | |
| 516 v = newlistobject(n); | |
| 517 if (v == NULL) | |
| 518 return NULL; | |
| 519 /* XXX Could do it nicer and interpret the data structure here, | |
| 520 returning a list of lists. But this can be done in Python... */ | |
| 521 for (i = 0; i < n; i++) { | |
| 522 w = newintobject((long)pickbuffer[i]); | |
| 523 if (w == NULL) { | |
| 524 DECREF(v); | |
| 525 return NULL; | |
| 526 } | |
| 527 setlistitem(v, i, w); | |
| 528 } | |
| 529 DEL(pickbuffer); | |
| 530 pickbuffer = NULL; | |
| 531 return v; | |
| 532 } | |
| 533 | |
| 534 extern void pick(), gselect(); | |
| 535 extern long endpick(), endselect(); | |
| 536 | |
| 537 %pick | |
| 538 static object *gl_pick(self, args) object *self, *args; { | |
| 539 return pick_select(args, pick); | |
| 540 } | |
| 541 | |
| 542 %endpick | |
| 543 static object *gl_endpick(self, args) object *self, *args; { | |
| 544 return endpick_select(args, endpick); | |
| 545 } | |
| 546 | |
| 547 %gselect | |
| 548 static object *gl_gselect(self, args) object *self, *args; { | |
| 549 return pick_select(args, gselect); | |
| 550 } | |
| 551 | |
| 552 %endselect | |
| 553 static object *gl_endselect(self, args) object *self, *args; { | |
| 554 return endpick_select(args, endselect); | |
| 555 } | |
| 556 | |
| 557 | |
| 558 /* XXX The generator botches this one. Here's a quick hack to fix it. */ | |
| 559 | |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
560 /* XXX The generator botches this one. Here's a quick hack to fix it. */ |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
561 |
| 6 | 562 % getmatrix float r[16] |
| 563 | |
| 564 static object * | |
| 565 gl_getmatrix(self, args) | |
| 566 object *self; | |
| 567 object *args; | |
| 568 { | |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
569 Matrix arg1; |
| 6 | 570 object *v, *w; |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
571 int i, j; |
| 6 | 572 getmatrix( arg1 ); |
| 573 v = newlistobject(16); | |
| 574 if (v == NULL) { | |
| 575 return err_nomem(); | |
| 576 } | |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
577 for (i = 0; i < 4; i++) for (j = 0; j < 4; j++) { |
|
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
578 w = mknewfloatobject(arg1[i][j]); |
| 6 | 579 if (w == NULL) { |
| 580 DECREF(v); | |
| 581 return NULL; | |
| 582 } | |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
583 setlistitem(v, i*4+j, w); |
| 6 | 584 } |
| 585 return v; | |
| 586 } | |
| 587 | |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
588 /* Here's an alternate version that returns a 4x4 matrix instead of |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
589 a vector. Unfortunately it is incompatible with loadmatrix and |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
590 multmatrix... */ |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
591 |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
592 % altgetmatrix float r[4][4] |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
593 |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
594 static object * |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
595 gl_altgetmatrix(self, args) |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
596 object *self; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
597 object *args; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
598 { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
599 Matrix arg1; |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
600 object *v, *w; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
601 int i, j; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
602 getmatrix( arg1 ); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
603 v = newlistobject(4); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
604 if (v == NULL) { |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
605 return NULL; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
606 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
607 for (i = 0; i < 4; i++) { |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
608 w = newlistobject(4); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
609 if (w == NULL) { |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
610 DECREF(v); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
611 return NULL; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
612 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
613 setlistitem(v, i, w); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
614 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
615 for (i = 0; i < 4; i++) { |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
616 for (j = 0; j < 4; j++) { |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
617 w = mknewfloatobject(arg1[i][j]); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
618 if (w == NULL) { |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
619 DECREF(v); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
620 return NULL; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
621 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
622 setlistitem(getlistitem(v, i), j, w); |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
623 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
624 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
625 return v; |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
626 } |
|
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
627 |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
628 % lrectwrite |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
629 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
630 static object * |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
631 gl_lrectwrite(self, args) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
632 object *self; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
633 object *args; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
634 { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
635 short x1 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
636 short y1 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
637 short x2 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
638 short y2 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
639 string parray ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
640 object *s; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
641 int pixcount; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
642 if (!getishortarg(args, 5, 0, &x1)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
643 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
644 if (!getishortarg(args, 5, 1, &y1)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
645 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
646 if (!getishortarg(args, 5, 2, &x2)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
647 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
648 if (!getishortarg(args, 5, 3, &y2)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
649 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
650 if (!getistringarg(args, 5, 4, &parray)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
651 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
652 if (!getiobjectarg(args, 5, 4, &s)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
653 return NULL; |
|
434
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
654 #if 0 |
|
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
655 /* Don't check this, it breaks experiments with pixmode(PM_SIZE, ...) */ |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
656 pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
657 if (!is_stringobject(s) || getstringsize(s) != pixcount*sizeof(long)) { |
|
434
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
658 err_setstr(RuntimeError, |
|
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
659 "string arg to lrectwrite has wrong size"); |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
660 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
661 } |
|
434
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
662 #endif |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
663 lrectwrite( x1 , y1 , x2 , y2 , (unsigned long *) parray ); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
664 INCREF(None); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
665 return None; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
666 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
667 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
668 % lrectread |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
669 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
670 static object * |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
671 gl_lrectread(self, args) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
672 object *self; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
673 object *args; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
674 { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
675 short x1 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
676 short y1 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
677 short x2 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
678 short y2 ; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
679 object *parray; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
680 int pixcount; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
681 if (!getishortarg(args, 4, 0, &x1)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
682 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
683 if (!getishortarg(args, 4, 1, &y1)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
684 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
685 if (!getishortarg(args, 4, 2, &x2)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
686 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
687 if (!getishortarg(args, 4, 3, &y2)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
688 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
689 pixcount = (long)(x2+1-x1) * (long)(y2+1-y1); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
690 parray = newsizedstringobject((char *)NULL, pixcount*sizeof(long)); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
691 if (parray == NULL) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
692 return NULL; /* No memory */ |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
693 lrectread(x1, y1, x2, y2, (unsigned long *) getstringvalue(parray)); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
694 return parray; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
695 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
696 |
|
1218
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
697 % readdisplay |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
698 |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
699 static object * |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
700 gl_readdisplay(self, args) |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
701 object *self; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
702 object *args; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
703 { |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
704 short x1, y1, x2, y2; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
705 unsigned long *parray, hints; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
706 long size, size_ret; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
707 object *rv; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
708 |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
709 if ( !getargs(args, "hhhhl", &x1, &y1, &x2, &y2, &hints) ) |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
710 return 0; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
711 size = (long)(x2+1-x1) * (long)(y2+1-y1); |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
712 rv = newsizedstringobject((char *)NULL, size*sizeof(long)); |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
713 if ( rv == NULL ) |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
714 return NULL; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
715 parray = (unsigned long *)getstringvalue(rv); |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
716 size_ret = readdisplay(x1, y1, x2, y2, parray, hints); |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
717 if ( size_ret != size ) { |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
718 printf("gl_readdisplay: got %d pixels, expected %d\n", |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
719 size_ret, size); |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
720 err_setstr(RuntimeError, "readdisplay returned unexpected length"); |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
721 return NULL; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
722 } |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
723 return rv; |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
724 } |
|
51223ce95a61
Added readdisplay() routine
Jack Jansen <jack.jansen@cwi.nl>
parents:
1039
diff
changeset
|
725 |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
726 /* Desperately needed, here are tools to compress and decompress |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
727 the data manipulated by lrectread/lrectwrite. |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
728 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
729 gl.packrect(width, height, packfactor, bigdata) --> smalldata |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
730 makes 'bigdata' 4*(packfactor**2) times smaller by: |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
731 - turning it into B/W (a factor 4) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
732 - replacing squares of size pacfactor by one |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
733 representative |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
734 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
735 gl.unpackrect(width, height, packfactor, smalldata) --> bigdata |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
736 is the inverse; the numeric arguments must be *the same*. |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
737 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
738 Both work best if width and height are multiples of packfactor |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
739 (in fact unpackrect will leave garbage bytes). |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
740 */ |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
741 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
742 % packrect |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
743 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
744 static object * |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
745 gl_packrect(self, args) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
746 object *self; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
747 object *args; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
748 { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
749 long width, height, packfactor; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
750 char *s; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
751 object *unpacked, *packed; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
752 int pixcount, packedcount, x, y, r, g, b; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
753 unsigned long pixel; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
754 unsigned char *p; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
755 unsigned long *parray; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
756 if (!getilongarg(args, 4, 0, &width)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
757 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
758 if (!getilongarg(args, 4, 1, &height)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
759 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
760 if (!getilongarg(args, 4, 2, &packfactor)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
761 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
762 if (!getistringarg(args, 4, 3, &s)) /* For type checking only */ |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
763 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
764 if (!getiobjectarg(args, 4, 3, &unpacked)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
765 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
766 if (width <= 0 || height <= 0 || packfactor <= 0) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
767 err_setstr(RuntimeError, "packrect args must be > 0"); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
768 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
769 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
770 pixcount = width*height; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
771 packedcount = ((width+packfactor-1)/packfactor) * |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
772 ((height+packfactor-1)/packfactor); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
773 if (getstringsize(unpacked) != pixcount*sizeof(long)) { |
|
434
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
774 err_setstr(RuntimeError, |
|
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
775 "string arg to packrect has wrong size"); |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
776 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
777 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
778 packed = newsizedstringobject((char *)NULL, packedcount); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
779 if (packed == NULL) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
780 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
781 parray = (unsigned long *) getstringvalue(unpacked); |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1232
diff
changeset
|
782 p = (unsigned char *) getstringvalue(packed); |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
783 for (y = 0; y < height; y += packfactor, parray += packfactor*width) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
784 for (x = 0; x < width; x += packfactor) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
785 pixel = parray[x]; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
786 r = pixel & 0xff; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
787 g = (pixel >> 8) & 0xff; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
788 b = (pixel >> 16) & 0xff; |
|
434
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
789 *p++ = (30*r+59*g+11*b) / 100; |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
790 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
791 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
792 return packed; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
793 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
794 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
795 % unpackrect |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
796 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
797 static unsigned long unpacktab[256]; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
798 static int unpacktab_inited = 0; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
799 |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
800 static object * |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
801 gl_unpackrect(self, args) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
802 object *self; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
803 object *args; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
804 { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
805 long width, height, packfactor; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
806 char *s; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
807 object *unpacked, *packed; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
808 int pixcount, packedcount, y; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
809 register unsigned char *p; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
810 register unsigned long *parray; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
811 if (!unpacktab_inited) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
812 register int white; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
813 for (white = 256; --white >= 0; ) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
814 unpacktab[white] = white * 0x010101L; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
815 unpacktab_inited++; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
816 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
817 if (!getilongarg(args, 4, 0, &width)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
818 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
819 if (!getilongarg(args, 4, 1, &height)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
820 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
821 if (!getilongarg(args, 4, 2, &packfactor)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
822 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
823 if (!getistringarg(args, 4, 3, &s)) /* For type checking only */ |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
824 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
825 if (!getiobjectarg(args, 4, 3, &packed)) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
826 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
827 if (width <= 0 || height <= 0 || packfactor <= 0) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
828 err_setstr(RuntimeError, "packrect args must be > 0"); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
829 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
830 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
831 pixcount = width*height; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
832 packedcount = ((width+packfactor-1)/packfactor) * |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
833 ((height+packfactor-1)/packfactor); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
834 if (getstringsize(packed) != packedcount) { |
|
434
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
835 err_setstr(RuntimeError, |
|
487b7c62ae77
Improved RGB --> grayscale conversion.
Guido van Rossum <guido@python.org>
parents:
389
diff
changeset
|
836 "string arg to unpackrect has wrong size"); |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
837 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
838 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
839 unpacked = newsizedstringobject((char *)NULL, pixcount*sizeof(long)); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
840 if (unpacked == NULL) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
841 return NULL; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
842 parray = (unsigned long *) getstringvalue(unpacked); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
843 p = (unsigned char *) getstringvalue(packed); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
844 if (packfactor == 1 && width*height > 0) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
845 /* Just expand bytes to longs */ |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
846 register int x = width * height; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
847 do { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
848 *parray++ = unpacktab[*p++]; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
849 } while (--x >= 0); |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
850 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
851 else { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
852 register int y; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
853 for (y = 0; y < height-packfactor+1; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
854 y += packfactor, parray += packfactor*width) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
855 register int x; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
856 for (x = 0; x < width-packfactor+1; x += packfactor) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
857 register unsigned long pixel = unpacktab[*p++]; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
858 register int i; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
859 for (i = packfactor*width; (i-=width) >= 0;) { |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
860 register int j; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
861 for (j = packfactor; --j >= 0; ) |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
862 parray[i+x+j] = pixel; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
863 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
864 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
865 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
866 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
867 return unpacked; |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
868 } |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
869 |
|
1039
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
870 % gversion |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
871 static object * |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
872 gl_gversion(self, args) |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
873 object *self; |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
874 object *args; |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
875 { |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
876 char buf[20]; |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
877 gversion(buf); |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
878 return newstringobject(buf); |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
879 } |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
880 |
|
6aa0ee14ac2e
Made struct a standard built-in module; added string args to {set,get}sockopt;
Guido van Rossum <guido@python.org>
parents:
948
diff
changeset
|
881 |
| 6 | 882 /* End of manually written stubs */ |
| 883 | |
| 884 %% | |
| 885 | |
| 886 long getshade | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
887 if !solaris void devport short s long s |
| 6 | 888 void rdr2i long s long s |
| 889 void rectfs short s short s short s short s | |
| 890 void rects short s short s short s short s | |
| 891 void rmv2i long s long s | |
| 892 void noport | |
| 893 void popviewport | |
| 894 void clear | |
| 895 void clearhitcode | |
| 896 void closeobj | |
| 897 void cursoff | |
| 898 void curson | |
| 899 void doublebuffer | |
| 900 void finish | |
| 901 void gconfig | |
| 902 void ginit | |
| 903 void greset | |
| 904 void multimap | |
| 905 void onemap | |
| 906 void popattributes | |
| 907 void popmatrix | |
| 908 void pushattributes | |
| 909 void pushmatrix | |
| 910 void pushviewport | |
| 911 void qreset | |
| 912 void RGBmode | |
| 913 void singlebuffer | |
| 914 void swapbuffers | |
| 915 void gsync | |
| 677 | 916 void gflush |
| 6 | 917 void tpon |
| 918 void tpoff | |
| 919 void clkon | |
| 920 void clkoff | |
| 921 void ringbell | |
| 922 #void callfunc | |
| 923 void gbegin | |
| 924 void textinit | |
| 925 void initnames | |
| 926 void pclos | |
| 927 void popname | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
928 if !solaris void spclos |
| 6 | 929 void zclear |
| 930 void screenspace | |
| 931 void reshapeviewport | |
| 932 void winpush | |
| 933 void winpop | |
| 934 void foreground | |
| 935 void endfullscrn | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
936 if !solaris void endpupmode |
| 6 | 937 void fullscrn |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
938 if !solaris void pupmode |
| 6 | 939 void winconstraints |
| 940 void pagecolor short s | |
| 941 void textcolor short s | |
| 942 void color short s | |
| 943 void curveit short s | |
| 944 void font short s | |
| 945 void linewidth short s | |
| 946 void setlinestyle short s | |
| 947 void setmap short s | |
| 948 void swapinterval short s | |
| 949 void writemask short s | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
950 if !solaris void textwritemask short s |
| 6 | 951 void qdevice short s |
| 952 void unqdevice short s | |
| 953 void curvebasis short s | |
| 954 void curveprecision short s | |
| 955 void loadname short s | |
| 956 void passthrough short s | |
| 957 void pushname short s | |
| 958 void setmonitor short s | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
959 if !solaris void setshade short s |
| 6 | 960 void setpattern short s |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
961 if !solaris void pagewritemask short s |
| 6 | 962 # |
| 963 void callobj long s | |
| 964 void delobj long s | |
| 965 void editobj long s | |
| 966 void makeobj long s | |
| 967 void maketag long s | |
| 968 void chunksize long s | |
| 969 void compactify long s | |
| 970 void deltag long s | |
| 971 void lsrepeat long s | |
| 972 void objinsert long s | |
| 973 void objreplace long s | |
| 974 void winclose long s | |
| 975 void blanktime long s | |
| 976 void freepup long s | |
| 977 # This is not in the library!? | |
| 978 ###void pupcolor long s | |
| 979 # | |
| 980 void backbuffer long s | |
| 981 void frontbuffer long s | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
982 if !solaris void lsbackup long s |
| 6 | 983 void resetls long s |
| 984 void lampon long s | |
| 985 void lampoff long s | |
| 986 void setbell long s | |
| 987 void blankscreen long s | |
| 988 void depthcue long s | |
| 989 void zbuffer long s | |
| 990 void backface long s | |
| 991 # | |
| 992 void cmov2i long s long s | |
| 993 void draw2i long s long s | |
| 994 void move2i long s long s | |
| 995 void pnt2i long s long s | |
| 996 void patchbasis long s long s | |
| 997 void patchprecision long s long s | |
| 998 void pdr2i long s long s | |
| 999 void pmv2i long s long s | |
| 1000 void rpdr2i long s long s | |
| 1001 void rpmv2i long s long s | |
| 1002 void xfpt2i long s long s | |
| 1003 void objdelete long s long s | |
| 1004 void patchcurves long s long s | |
| 1005 void minsize long s long s | |
| 1006 void maxsize long s long s | |
| 1007 void keepaspect long s long s | |
| 1008 void prefsize long s long s | |
| 1009 void stepunit long s long s | |
| 1010 void fudge long s long s | |
| 1011 void winmove long s long s | |
| 1012 # | |
| 1013 void attachcursor short s short s | |
| 1014 void deflinestyle short s short s | |
| 1015 void noise short s short s | |
| 1016 void picksize short s short s | |
| 1017 void qenter short s short s | |
| 1018 void setdepth short s short s | |
| 1019 void cmov2s short s short s | |
| 1020 void draw2s short s short s | |
| 1021 void move2s short s short s | |
| 1022 void pdr2s short s short s | |
| 1023 void pmv2s short s short s | |
| 1024 void pnt2s short s short s | |
| 1025 void rdr2s short s short s | |
| 1026 void rmv2s short s short s | |
| 1027 void rpdr2s short s short s | |
| 1028 void rpmv2s short s short s | |
| 1029 void xfpt2s short s short s | |
| 1030 # | |
| 1031 void cmov2 float s float s | |
| 1032 void draw2 float s float s | |
| 1033 void move2 float s float s | |
| 1034 void pnt2 float s float s | |
| 1035 void pdr2 float s float s | |
| 1036 void pmv2 float s float s | |
| 1037 void rdr2 float s float s | |
| 1038 void rmv2 float s float s | |
| 1039 void rpdr2 float s float s | |
| 1040 void rpmv2 float s float s | |
| 1041 void xfpt2 float s float s | |
| 1042 # | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1043 void loadmatrix float s[4*4] |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1044 # Really [4][4] |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1045 void multmatrix float s[4*4] |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1046 # Really [4][4] |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1047 void crv float s[3*4] |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1048 # Really [4][3] |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1049 void rcrv float s[4*4] |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1050 # Really [4][4] |
| 6 | 1051 # |
| 1052 # Methods that have strings. | |
| 1053 # | |
| 1054 void addtopup long s char *s long s | |
| 1055 void charstr char *s | |
| 1056 void getport char *s | |
| 1057 long strwidth char *s | |
| 1058 long winopen char *s | |
| 1059 void wintitle char *s | |
| 1060 # | |
| 1061 # Methods that have 1 long (# of elements) and an array | |
| 1062 # | |
| 1063 void polf long s float s[3*arg1] | |
| 1064 void polf2 long s float s[2*arg1] | |
| 1065 void poly long s float s[3*arg1] | |
| 1066 void poly2 long s float s[2*arg1] | |
| 1067 void crvn long s float s[3*arg1] | |
| 1068 void rcrvn long s float s[4*arg1] | |
| 1069 # | |
| 1070 void polf2i long s long s[2*arg1] | |
| 1071 void polfi long s long s[3*arg1] | |
| 1072 void poly2i long s long s[2*arg1] | |
| 1073 void polyi long s long s[3*arg1] | |
| 1074 # | |
| 1075 void polf2s long s short s[2*arg1] | |
| 1076 void polfs long s short s[3*arg1] | |
| 1077 void polys long s short s[3*arg1] | |
| 1078 void poly2s long s short s[2*arg1] | |
| 1079 # | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1080 void defcursor short s u_short s[128] |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1081 # Is this useful? |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1082 void writepixels short s u_short s[arg1] |
|
338
794cfd455dc6
Changed some interfaces after error reports from Liberte.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
1083 # Should be unsigned short... |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1084 void defbasis long s float s[4*4] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1085 if !solaris void gewrite short s short s[arg1] |
| 6 | 1086 # |
| 1087 void rotate short s char s | |
| 1088 # This is not in the library!? | |
| 1089 ###void setbutton short s char s | |
| 1090 void rot float s char s | |
| 1091 # | |
| 1092 void circfi long s long s long s | |
| 1093 void circi long s long s long s | |
| 1094 void cmovi long s long s long s | |
| 1095 void drawi long s long s long s | |
| 1096 void movei long s long s long s | |
| 1097 void pnti long s long s long s | |
| 1098 void newtag long s long s long s | |
| 1099 void pdri long s long s long s | |
| 1100 void pmvi long s long s long s | |
| 1101 void rdri long s long s long s | |
| 1102 void rmvi long s long s long s | |
| 1103 void rpdri long s long s long s | |
| 1104 void rpmvi long s long s long s | |
| 1105 void xfpti long s long s long s | |
| 1106 # | |
| 1107 void circ float s float s float s | |
| 1108 void circf float s float s float s | |
| 1109 void cmov float s float s float s | |
| 1110 void draw float s float s float s | |
| 1111 void move float s float s float s | |
| 1112 void pnt float s float s float s | |
| 1113 void scale float s float s float s | |
| 1114 void translate float s float s float s | |
| 1115 void pdr float s float s float s | |
| 1116 void pmv float s float s float s | |
| 1117 void rdr float s float s float s | |
| 1118 void rmv float s float s float s | |
| 1119 void rpdr float s float s float s | |
| 1120 void rpmv float s float s float s | |
| 1121 void xfpt float s float s float s | |
| 1122 # | |
| 1123 void RGBcolor short s short s short s | |
| 1124 void RGBwritemask short s short s short s | |
| 1125 void setcursor short s short s short s | |
| 1126 void tie short s short s short s | |
| 1127 void circfs short s short s short s | |
| 1128 void circs short s short s short s | |
| 1129 void cmovs short s short s short s | |
| 1130 void draws short s short s short s | |
| 1131 void moves short s short s short s | |
| 1132 void pdrs short s short s short s | |
| 1133 void pmvs short s short s short s | |
| 1134 void pnts short s short s short s | |
| 1135 void rdrs short s short s short s | |
| 1136 void rmvs short s short s short s | |
| 1137 void rpdrs short s short s short s | |
| 1138 void rpmvs short s short s short s | |
| 1139 void xfpts short s short s short s | |
| 1140 void curorigin short s short s short s | |
| 1141 void cyclemap short s short s short s | |
| 1142 # | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1143 void patch float s[4*4] float s[4*4] float s[4*4] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1144 void splf long s float s[3*arg1] u_short s[arg1] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1145 void splf2 long s float s[2*arg1] u_short s[arg1] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1146 void splfi long s long s[3*arg1] u_short s[arg1] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1147 void splf2i long s long s[2*arg1] u_short s[arg1] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1148 void splfs long s short s[3*arg1] u_short s[arg1] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1149 void splf2s long s short s[2*arg1] u_short s[arg1] |
|
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1150 ###void defpattern short s short s u_short s[arg2*arg2/16] |
| 6 | 1151 # |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1152 void rpatch float s[4*4] float s[4*4] float s[4*4] float s[4*4] |
| 6 | 1153 # |
| 1154 # routines that send 4 floats | |
| 1155 # | |
| 1156 void ortho2 float s float s float s float s | |
| 1157 void rect float s float s float s float s | |
| 1158 void rectf float s float s float s float s | |
| 1159 void xfpt4 float s float s float s float s | |
| 1160 # | |
| 1161 void textport short s short s short s short s | |
| 1162 void mapcolor short s short s short s short s | |
| 1163 void scrmask short s short s short s short s | |
| 1164 void setvaluator short s short s short s short s | |
| 1165 void viewport short s short s short s short s | |
| 1166 void shaderange short s short s short s short s | |
| 1167 void xfpt4s short s short s short s short s | |
| 1168 void rectfi long s long s long s long s | |
| 1169 void recti long s long s long s long s | |
| 1170 void xfpt4i long s long s long s long s | |
| 1171 void prefposition long s long s long s long s | |
| 1172 # | |
| 1173 void arc float s float s float s short s short s | |
| 1174 void arcf float s float s float s short s short s | |
| 1175 void arcfi long s long s long s short s short s | |
| 1176 void arci long s long s long s short s short s | |
| 1177 # | |
| 1178 void bbox2 short s short s float s float s float s float s | |
| 1179 void bbox2i short s short s long s long s long s long s | |
| 1180 void bbox2s short s short s short s short s short s short s | |
| 1181 void blink short s short s short s short s short s | |
| 1182 void ortho float s float s float s float s float s float s | |
| 1183 void window float s float s float s float s float s float s | |
| 1184 void lookat float s float s float s float s float s float s short s | |
| 1185 # | |
| 1186 void perspective short s float s float s float s | |
| 1187 void polarview float s short s short s short s | |
| 1188 # XXX getichararray not supported | |
| 1189 #void writeRGB short s char s[arg1] char s[arg1] char s[arg1] | |
| 1190 # | |
| 1191 void arcfs short s short s short s short s short s | |
| 1192 void arcs short s short s short s short s short s | |
| 1193 void rectcopy short s short s short s short s short s short s | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1194 if !solaris void RGBcursor short s short s short s short s short s short s short s |
| 6 | 1195 # |
| 1196 long getbutton short s | |
| 1197 long getcmmode | |
| 1198 long getlsbackup | |
| 1199 long getresetls | |
| 1200 long getdcm | |
| 1201 long getzbuffer | |
| 1202 long ismex | |
| 1203 long isobj long s | |
| 1204 long isqueued short s | |
| 1205 long istag long s | |
| 1206 # | |
| 1207 long genobj | |
| 1208 long gentag | |
| 1209 long getbuffer | |
| 1210 long getcolor | |
| 1211 long getdisplaymode | |
| 1212 long getfont | |
| 1213 long getheight | |
| 1214 long gethitcode | |
| 1215 long getlstyle | |
| 1216 long getlwidth | |
| 1217 long getmap | |
| 1218 long getplanes | |
| 1219 long getwritemask | |
| 1220 long qtest | |
| 1221 long getlsrepeat | |
| 1222 long getmonitor | |
| 1223 long getopenobj | |
| 1224 long getpattern | |
| 1225 long winget | |
| 1226 long winattach | |
| 1227 long getothermonitor | |
| 1228 long newpup | |
| 1229 # | |
| 1230 long getvaluator short s | |
| 1231 void winset long s | |
| 1232 long dopup long s | |
| 1233 void getdepth short r short r | |
| 1234 void getcpos short r short r | |
| 1235 void getsize long r long r | |
| 1236 void getorigin long r long r | |
| 1237 void getviewport short r short r short r short r | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1238 if !solaris void gettp short r short r short r short r |
| 6 | 1239 void getgpos float r float r float r float r |
| 1240 void winposition long s long s long s long s | |
| 1241 void gRGBcolor short r short r short r | |
| 1242 void gRGBmask short r short r short r | |
| 1243 void getscrmask short r short r short r short r | |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1244 ###void gRGBcursor short r short r short r short r short r short r short r short r |
| 6 | 1245 void getmcolor short s short r short r short r |
| 1246 void mapw long s short s short s float r float r float r float r float r float r | |
| 1247 void mapw2 long s short s short s float r float r | |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1248 ###void defrasterfont short s short s short s Fontchar s[arg3] short s short s[4*arg5] |
|
948
e5ae42ffd9a0
Fix bug introduced by Jack (duplicate def of qread)
Guido van Rossum <guido@python.org>
parents:
947
diff
changeset
|
1249 ###long qread short r |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1250 void getcursor short r u_short r u_short r long r |
| 6 | 1251 # |
| 1252 # For these we receive arrays of stuff | |
| 1253 # | |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1254 ###void getdev long s short s[arg1] short r[arg1] |
| 6 | 1255 #XXX not generated correctly yet |
| 1256 #void getmatrix float r[16] | |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1257 ###long readpixels short s short r[retval] |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1258 ###long readRGB short s char r[retval] char r[retval] char r[retval] |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1259 ###long blkqread short s short r[arg1] |
| 6 | 1260 # |
| 1261 # New 4D routines | |
| 1262 # | |
| 1263 void cmode | |
| 1264 void concave long s | |
| 1265 void curstype long s | |
| 1266 void drawmode long s | |
| 1267 void gammaramp short s[256] short s[256] short s[256] | |
| 1268 long getbackface | |
| 1269 long getdescender | |
| 1270 long getdrawmode | |
| 1271 long getmmode | |
| 1272 long getsm | |
| 1273 long getvideo long s | |
| 1274 void imakebackground | |
| 1275 void lmbind short s short s | |
| 1276 void lmdef long s long s long s float s[arg3] | |
| 1277 void mmode long s | |
| 1278 void normal float s[3] | |
| 1279 void overlay long s | |
| 1280 void RGBrange short s short s short s short s short s short s short s short s | |
|
1443
2ec08a9d0325
rgbimgmodule.c, Makefile, config.c: new module to read RGB image files.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1356
diff
changeset
|
1281 if !solaris void setvideo long s long s |
| 6 | 1282 void shademodel long s |
| 1283 void underlay long s | |
| 1284 # | |
| 1285 # New Personal Iris/GT Routines | |
| 1286 # | |
| 1287 void bgnclosedline | |
| 1288 void bgnline | |
| 1289 void bgnpoint | |
| 1290 void bgnpolygon | |
| 1291 void bgnsurface | |
| 1292 void bgntmesh | |
| 1293 void bgntrim | |
| 1294 void endclosedline | |
| 1295 void endline | |
| 1296 void endpoint | |
| 1297 void endpolygon | |
| 1298 void endsurface | |
| 1299 void endtmesh | |
| 1300 void endtrim | |
| 1301 void blendfunction long s long s | |
| 1302 void c3f float s[3] | |
| 1303 void c3i long s[3] | |
| 1304 void c3s short s[3] | |
| 1305 void c4f float s[4] | |
| 1306 void c4i long s[4] | |
| 1307 void c4s short s[4] | |
| 1308 void colorf float s | |
| 1309 void cpack long s | |
| 1310 void czclear long s long s | |
| 1311 void dglclose long s | |
| 1312 long dglopen char *s long s | |
| 1313 long getgdesc long s | |
| 1314 void getnurbsproperty long s float r | |
| 1315 void glcompat long s long s | |
| 1316 void iconsize long s long s | |
| 1317 void icontitle char *s | |
| 1318 void lRGBrange short s short s short s short s short s short s long s long s | |
| 1319 void linesmooth long s | |
| 1320 void lmcolor long s | |
| 1321 void logicop long s | |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1322 ###long lrectread short s short s short s short s long r[retval] |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1323 ###void lrectwrite short s short s short s short s long s[(arg2-arg1+1)*(arg4-arg3+1)] |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1324 ### Now manual, with string last arg |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1325 ###long rectread short s short s short s short s short r[retval] |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1326 ###void rectwrite short s short s short s short s short s[(arg2-arg1+1)*(arg4-arg3+1)] |
| 6 | 1327 void lsetdepth long s long s |
| 1328 void lshaderange short s short s long s long s | |
| 1329 void n3f float s[3] | |
| 1330 void noborder | |
| 1331 void pntsmooth long s | |
| 1332 void readsource long s | |
| 1333 void rectzoom float s float s | |
| 1334 void sbox float s float s float s float s | |
| 1335 void sboxi long s long s long s long s | |
| 1336 void sboxs short s short s short s short s | |
| 1337 void sboxf float s float s float s float s | |
| 1338 void sboxfi long s long s long s long s | |
| 1339 void sboxfs short s short s short s short s | |
| 1340 void setnurbsproperty long s float s | |
| 1341 void setpup long s long s long s | |
| 1342 void smoothline long s | |
| 1343 void subpixel long s | |
| 1344 void swaptmesh | |
| 1345 long swinopen long s | |
| 1346 void v2f float s[2] | |
| 1347 void v2i long s[2] | |
| 1348 void v2s short s[2] | |
| 1349 void v3f float s[3] | |
| 1350 void v3i long s[3] | |
| 1351 void v3s short s[3] | |
| 1352 void v4f float s[4] | |
| 1353 void v4i long s[4] | |
| 1354 void v4s short s[4] | |
| 1355 void videocmd long s | |
| 1356 long windepth long s | |
| 1357 void wmpack long s | |
| 1358 void zdraw long s | |
| 1359 void zfunction long s | |
| 1360 void zsource long s | |
| 1361 void zwritemask long s | |
| 1362 # | |
| 1363 # uses doubles | |
| 1364 # | |
| 1365 void v2d double s[2] | |
| 1366 void v3d double s[3] | |
| 1367 void v4d double s[4] | |
|
389
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1368 # |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1369 # Why isn't this here? |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1370 # |
|
55bf66445c85
Added lrect{read,write} and pixmode().
Guido van Rossum <guido@python.org>
parents:
338
diff
changeset
|
1371 void pixmode long s long s |
|
906
63798cde582c
Added qgetfd() to cstubs for GL.
Guido van Rossum <guido@python.org>
parents:
677
diff
changeset
|
1372 # |
|
63798cde582c
Added qgetfd() to cstubs for GL.
Guido van Rossum <guido@python.org>
parents:
677
diff
changeset
|
1373 # New in IRIX 4.0 |
|
63798cde582c
Added qgetfd() to cstubs for GL.
Guido van Rossum <guido@python.org>
parents:
677
diff
changeset
|
1374 # |
|
63798cde582c
Added qgetfd() to cstubs for GL.
Guido van Rossum <guido@python.org>
parents:
677
diff
changeset
|
1375 long qgetfd |
| 1232 | 1376 void dither long s |
