1
2 /* ========================= Module _Qdoffs ========================= */
3
4 #include "Python.h"
5
6
7 #include <Carbon/Carbon.h>
8 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
9
10 #include "pymactoolbox.h"
11
12 /* Macro to test whether a weak-loaded CFM function exists */
13 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
14 PyErr_SetString(PyExc_NotImplementedError, \
15 "Not available in this shared library/OS version"); \
16 return NULL; \
17 }} while(0)
18
19
20
21 #ifdef USE_TOOLBOX_OBJECT_GLUE
22 extern PyObject *_GWorldObj_New(GWorldPtr);
23 extern int _GWorldObj_Convert(PyObject *, GWorldPtr *);
24
25 #define GWorldObj_New _GWorldObj_New
26 #define GWorldObj_Convert _GWorldObj_Convert
27 #endif
28
29 #define as_GrafPtr(gworld) ((GrafPtr)(gworld))
30
31
32 static PyObject *Qdoffs_Error;
33
34 /* ----------------------- Object type GWorld ----------------------- */
35
36 PyTypeObject GWorld_Type;
37
38 #define GWorldObj_Check(x) ((x)->ob_type == &GWorld_Type || PyObject_TypeCheck((x), &GWorld_Type))
39
40 typedef struct GWorldObject {
41 PyObject_HEAD
42 GWorldPtr ob_itself;
43 } GWorldObject;
44
GWorldObj_New(GWorldPtr itself)45 PyObject *GWorldObj_New(GWorldPtr itself)
46 {
47 GWorldObject *it;
48 if (itself == NULL) return PyMac_Error(resNotFound);
49 it = PyObject_NEW(GWorldObject, &GWorld_Type);
50 if (it == NULL) return NULL;
51 it->ob_itself = itself;
52 return (PyObject *)it;
53 }
54
GWorldObj_Convert(PyObject * v,GWorldPtr * p_itself)55 int GWorldObj_Convert(PyObject *v, GWorldPtr *p_itself)
56 {
57 if (!GWorldObj_Check(v))
58 {
59 PyErr_SetString(PyExc_TypeError, "GWorld required");
60 return 0;
61 }
62 *p_itself = ((GWorldObject *)v)->ob_itself;
63 return 1;
64 }
65
GWorldObj_dealloc(GWorldObject * self)66 static void GWorldObj_dealloc(GWorldObject *self)
67 {
68 DisposeGWorld(self->ob_itself);
69 self->ob_type->tp_free((PyObject *)self);
70 }
71
GWorldObj_GetGWorldDevice(GWorldObject * _self,PyObject * _args)72 static PyObject *GWorldObj_GetGWorldDevice(GWorldObject *_self, PyObject *_args)
73 {
74 PyObject *_res = NULL;
75 GDHandle _rv;
76 #ifndef GetGWorldDevice
77 PyMac_PRECHECK(GetGWorldDevice);
78 #endif
79 if (!PyArg_ParseTuple(_args, ""))
80 return NULL;
81 _rv = GetGWorldDevice(_self->ob_itself);
82 _res = Py_BuildValue("O&",
83 ResObj_New, _rv);
84 return _res;
85 }
86
GWorldObj_GetGWorldPixMap(GWorldObject * _self,PyObject * _args)87 static PyObject *GWorldObj_GetGWorldPixMap(GWorldObject *_self, PyObject *_args)
88 {
89 PyObject *_res = NULL;
90 PixMapHandle _rv;
91 #ifndef GetGWorldPixMap
92 PyMac_PRECHECK(GetGWorldPixMap);
93 #endif
94 if (!PyArg_ParseTuple(_args, ""))
95 return NULL;
96 _rv = GetGWorldPixMap(_self->ob_itself);
97 _res = Py_BuildValue("O&",
98 ResObj_New, _rv);
99 return _res;
100 }
101
GWorldObj_as_GrafPtr(GWorldObject * _self,PyObject * _args)102 static PyObject *GWorldObj_as_GrafPtr(GWorldObject *_self, PyObject *_args)
103 {
104 PyObject *_res = NULL;
105 GrafPtr _rv;
106 #ifndef as_GrafPtr
107 PyMac_PRECHECK(as_GrafPtr);
108 #endif
109 if (!PyArg_ParseTuple(_args, ""))
110 return NULL;
111 _rv = as_GrafPtr(_self->ob_itself);
112 _res = Py_BuildValue("O&",
113 GrafObj_New, _rv);
114 return _res;
115 }
116
117 static PyMethodDef GWorldObj_methods[] = {
118 {"GetGWorldDevice", (PyCFunction)GWorldObj_GetGWorldDevice, 1,
119 PyDoc_STR("() -> (GDHandle _rv)")},
120 {"GetGWorldPixMap", (PyCFunction)GWorldObj_GetGWorldPixMap, 1,
121 PyDoc_STR("() -> (PixMapHandle _rv)")},
122 {"as_GrafPtr", (PyCFunction)GWorldObj_as_GrafPtr, 1,
123 PyDoc_STR("() -> (GrafPtr _rv)")},
124 {NULL, NULL, 0}
125 };
126
127 #define GWorldObj_getsetlist NULL
128
129
130 #define GWorldObj_compare NULL
131
132 #define GWorldObj_repr NULL
133
134 #define GWorldObj_hash NULL
135 #define GWorldObj_tp_init 0
136
137 #define GWorldObj_tp_alloc PyType_GenericAlloc
138
GWorldObj_tp_new(PyTypeObject * type,PyObject * _args,PyObject * _kwds)139 static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
140 {
141 PyObject *_self;
142 GWorldPtr itself;
143 char *kw[] = {"itself", 0};
144
145 if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, GWorldObj_Convert, &itself)) return NULL;
146 if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
147 ((GWorldObject *)_self)->ob_itself = itself;
148 return _self;
149 }
150
151 #define GWorldObj_tp_free PyObject_Del
152
153
154 PyTypeObject GWorld_Type = {
155 PyObject_HEAD_INIT(NULL)
156 0, /*ob_size*/
157 "_Qdoffs.GWorld", /*tp_name*/
158 sizeof(GWorldObject), /*tp_basicsize*/
159 0, /*tp_itemsize*/
160 /* methods */
161 (destructor) GWorldObj_dealloc, /*tp_dealloc*/
162 0, /*tp_print*/
163 (getattrfunc)0, /*tp_getattr*/
164 (setattrfunc)0, /*tp_setattr*/
165 (cmpfunc) GWorldObj_compare, /*tp_compare*/
166 (reprfunc) GWorldObj_repr, /*tp_repr*/
167 (PyNumberMethods *)0, /* tp_as_number */
168 (PySequenceMethods *)0, /* tp_as_sequence */
169 (PyMappingMethods *)0, /* tp_as_mapping */
170 (hashfunc) GWorldObj_hash, /*tp_hash*/
171 0, /*tp_call*/
172 0, /*tp_str*/
173 PyObject_GenericGetAttr, /*tp_getattro*/
174 PyObject_GenericSetAttr, /*tp_setattro */
175 0, /*tp_as_buffer*/
176 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
177 0, /*tp_doc*/
178 0, /*tp_traverse*/
179 0, /*tp_clear*/
180 0, /*tp_richcompare*/
181 0, /*tp_weaklistoffset*/
182 0, /*tp_iter*/
183 0, /*tp_iternext*/
184 GWorldObj_methods, /* tp_methods */
185 0, /*tp_members*/
186 GWorldObj_getsetlist, /*tp_getset*/
187 0, /*tp_base*/
188 0, /*tp_dict*/
189 0, /*tp_descr_get*/
190 0, /*tp_descr_set*/
191 0, /*tp_dictoffset*/
192 GWorldObj_tp_init, /* tp_init */
193 GWorldObj_tp_alloc, /* tp_alloc */
194 GWorldObj_tp_new, /* tp_new */
195 GWorldObj_tp_free, /* tp_free */
196 };
197
198 /* --------------------- End object type GWorld --------------------- */
199
200
Qdoffs_NewGWorld(PyObject * _self,PyObject * _args)201 static PyObject *Qdoffs_NewGWorld(PyObject *_self, PyObject *_args)
202 {
203 PyObject *_res = NULL;
204 QDErr _err;
205 GWorldPtr offscreenGWorld;
206 short PixelDepth;
207 Rect boundsRect;
208 CTabHandle cTable;
209 GDHandle aGDevice;
210 GWorldFlags flags;
211 #ifndef NewGWorld
212 PyMac_PRECHECK(NewGWorld);
213 #endif
214 if (!PyArg_ParseTuple(_args, "hO&O&O&l",
215 &PixelDepth,
216 PyMac_GetRect, &boundsRect,
217 OptResObj_Convert, &cTable,
218 OptResObj_Convert, &aGDevice,
219 &flags))
220 return NULL;
221 _err = NewGWorld(&offscreenGWorld,
222 PixelDepth,
223 &boundsRect,
224 cTable,
225 aGDevice,
226 flags);
227 if (_err != noErr) return PyMac_Error(_err);
228 _res = Py_BuildValue("O&",
229 GWorldObj_New, offscreenGWorld);
230 return _res;
231 }
232
Qdoffs_LockPixels(PyObject * _self,PyObject * _args)233 static PyObject *Qdoffs_LockPixels(PyObject *_self, PyObject *_args)
234 {
235 PyObject *_res = NULL;
236 Boolean _rv;
237 PixMapHandle pm;
238 #ifndef LockPixels
239 PyMac_PRECHECK(LockPixels);
240 #endif
241 if (!PyArg_ParseTuple(_args, "O&",
242 ResObj_Convert, &pm))
243 return NULL;
244 _rv = LockPixels(pm);
245 _res = Py_BuildValue("b",
246 _rv);
247 return _res;
248 }
249
Qdoffs_UnlockPixels(PyObject * _self,PyObject * _args)250 static PyObject *Qdoffs_UnlockPixels(PyObject *_self, PyObject *_args)
251 {
252 PyObject *_res = NULL;
253 PixMapHandle pm;
254 #ifndef UnlockPixels
255 PyMac_PRECHECK(UnlockPixels);
256 #endif
257 if (!PyArg_ParseTuple(_args, "O&",
258 ResObj_Convert, &pm))
259 return NULL;
260 UnlockPixels(pm);
261 Py_INCREF(Py_None);
262 _res = Py_None;
263 return _res;
264 }
265
Qdoffs_UpdateGWorld(PyObject * _self,PyObject * _args)266 static PyObject *Qdoffs_UpdateGWorld(PyObject *_self, PyObject *_args)
267 {
268 PyObject *_res = NULL;
269 GWorldFlags _rv;
270 GWorldPtr offscreenGWorld;
271 short pixelDepth;
272 Rect boundsRect;
273 CTabHandle cTable;
274 GDHandle aGDevice;
275 GWorldFlags flags;
276 #ifndef UpdateGWorld
277 PyMac_PRECHECK(UpdateGWorld);
278 #endif
279 if (!PyArg_ParseTuple(_args, "hO&O&O&l",
280 &pixelDepth,
281 PyMac_GetRect, &boundsRect,
282 OptResObj_Convert, &cTable,
283 OptResObj_Convert, &aGDevice,
284 &flags))
285 return NULL;
286 _rv = UpdateGWorld(&offscreenGWorld,
287 pixelDepth,
288 &boundsRect,
289 cTable,
290 aGDevice,
291 flags);
292 _res = Py_BuildValue("lO&",
293 _rv,
294 GWorldObj_New, offscreenGWorld);
295 return _res;
296 }
297
Qdoffs_GetGWorld(PyObject * _self,PyObject * _args)298 static PyObject *Qdoffs_GetGWorld(PyObject *_self, PyObject *_args)
299 {
300 PyObject *_res = NULL;
301 CGrafPtr port;
302 GDHandle gdh;
303 #ifndef GetGWorld
304 PyMac_PRECHECK(GetGWorld);
305 #endif
306 if (!PyArg_ParseTuple(_args, ""))
307 return NULL;
308 GetGWorld(&port,
309 &gdh);
310 _res = Py_BuildValue("O&O&",
311 GrafObj_New, port,
312 ResObj_New, gdh);
313 return _res;
314 }
315
Qdoffs_SetGWorld(PyObject * _self,PyObject * _args)316 static PyObject *Qdoffs_SetGWorld(PyObject *_self, PyObject *_args)
317 {
318 PyObject *_res = NULL;
319 CGrafPtr port;
320 GDHandle gdh;
321 #ifndef SetGWorld
322 PyMac_PRECHECK(SetGWorld);
323 #endif
324 if (!PyArg_ParseTuple(_args, "O&O&",
325 GrafObj_Convert, &port,
326 OptResObj_Convert, &gdh))
327 return NULL;
328 SetGWorld(port,
329 gdh);
330 Py_INCREF(Py_None);
331 _res = Py_None;
332 return _res;
333 }
334
Qdoffs_CTabChanged(PyObject * _self,PyObject * _args)335 static PyObject *Qdoffs_CTabChanged(PyObject *_self, PyObject *_args)
336 {
337 PyObject *_res = NULL;
338 CTabHandle ctab;
339 #ifndef CTabChanged
340 PyMac_PRECHECK(CTabChanged);
341 #endif
342 if (!PyArg_ParseTuple(_args, "O&",
343 OptResObj_Convert, &ctab))
344 return NULL;
345 CTabChanged(ctab);
346 Py_INCREF(Py_None);
347 _res = Py_None;
348 return _res;
349 }
350
Qdoffs_PixPatChanged(PyObject * _self,PyObject * _args)351 static PyObject *Qdoffs_PixPatChanged(PyObject *_self, PyObject *_args)
352 {
353 PyObject *_res = NULL;
354 PixPatHandle ppat;
355 #ifndef PixPatChanged
356 PyMac_PRECHECK(PixPatChanged);
357 #endif
358 if (!PyArg_ParseTuple(_args, "O&",
359 ResObj_Convert, &ppat))
360 return NULL;
361 PixPatChanged(ppat);
362 Py_INCREF(Py_None);
363 _res = Py_None;
364 return _res;
365 }
366
Qdoffs_PortChanged(PyObject * _self,PyObject * _args)367 static PyObject *Qdoffs_PortChanged(PyObject *_self, PyObject *_args)
368 {
369 PyObject *_res = NULL;
370 GrafPtr port;
371 #ifndef PortChanged
372 PyMac_PRECHECK(PortChanged);
373 #endif
374 if (!PyArg_ParseTuple(_args, "O&",
375 GrafObj_Convert, &port))
376 return NULL;
377 PortChanged(port);
378 Py_INCREF(Py_None);
379 _res = Py_None;
380 return _res;
381 }
382
Qdoffs_GDeviceChanged(PyObject * _self,PyObject * _args)383 static PyObject *Qdoffs_GDeviceChanged(PyObject *_self, PyObject *_args)
384 {
385 PyObject *_res = NULL;
386 GDHandle gdh;
387 #ifndef GDeviceChanged
388 PyMac_PRECHECK(GDeviceChanged);
389 #endif
390 if (!PyArg_ParseTuple(_args, "O&",
391 OptResObj_Convert, &gdh))
392 return NULL;
393 GDeviceChanged(gdh);
394 Py_INCREF(Py_None);
395 _res = Py_None;
396 return _res;
397 }
398
Qdoffs_AllowPurgePixels(PyObject * _self,PyObject * _args)399 static PyObject *Qdoffs_AllowPurgePixels(PyObject *_self, PyObject *_args)
400 {
401 PyObject *_res = NULL;
402 PixMapHandle pm;
403 #ifndef AllowPurgePixels
404 PyMac_PRECHECK(AllowPurgePixels);
405 #endif
406 if (!PyArg_ParseTuple(_args, "O&",
407 ResObj_Convert, &pm))
408 return NULL;
409 AllowPurgePixels(pm);
410 Py_INCREF(Py_None);
411 _res = Py_None;
412 return _res;
413 }
414
Qdoffs_NoPurgePixels(PyObject * _self,PyObject * _args)415 static PyObject *Qdoffs_NoPurgePixels(PyObject *_self, PyObject *_args)
416 {
417 PyObject *_res = NULL;
418 PixMapHandle pm;
419 #ifndef NoPurgePixels
420 PyMac_PRECHECK(NoPurgePixels);
421 #endif
422 if (!PyArg_ParseTuple(_args, "O&",
423 ResObj_Convert, &pm))
424 return NULL;
425 NoPurgePixels(pm);
426 Py_INCREF(Py_None);
427 _res = Py_None;
428 return _res;
429 }
430
Qdoffs_GetPixelsState(PyObject * _self,PyObject * _args)431 static PyObject *Qdoffs_GetPixelsState(PyObject *_self, PyObject *_args)
432 {
433 PyObject *_res = NULL;
434 GWorldFlags _rv;
435 PixMapHandle pm;
436 #ifndef GetPixelsState
437 PyMac_PRECHECK(GetPixelsState);
438 #endif
439 if (!PyArg_ParseTuple(_args, "O&",
440 ResObj_Convert, &pm))
441 return NULL;
442 _rv = GetPixelsState(pm);
443 _res = Py_BuildValue("l",
444 _rv);
445 return _res;
446 }
447
Qdoffs_SetPixelsState(PyObject * _self,PyObject * _args)448 static PyObject *Qdoffs_SetPixelsState(PyObject *_self, PyObject *_args)
449 {
450 PyObject *_res = NULL;
451 PixMapHandle pm;
452 GWorldFlags state;
453 #ifndef SetPixelsState
454 PyMac_PRECHECK(SetPixelsState);
455 #endif
456 if (!PyArg_ParseTuple(_args, "O&l",
457 ResObj_Convert, &pm,
458 &state))
459 return NULL;
460 SetPixelsState(pm,
461 state);
462 Py_INCREF(Py_None);
463 _res = Py_None;
464 return _res;
465 }
466
Qdoffs_GetPixRowBytes(PyObject * _self,PyObject * _args)467 static PyObject *Qdoffs_GetPixRowBytes(PyObject *_self, PyObject *_args)
468 {
469 PyObject *_res = NULL;
470 long _rv;
471 PixMapHandle pm;
472 #ifndef GetPixRowBytes
473 PyMac_PRECHECK(GetPixRowBytes);
474 #endif
475 if (!PyArg_ParseTuple(_args, "O&",
476 ResObj_Convert, &pm))
477 return NULL;
478 _rv = GetPixRowBytes(pm);
479 _res = Py_BuildValue("l",
480 _rv);
481 return _res;
482 }
483
Qdoffs_NewScreenBuffer(PyObject * _self,PyObject * _args)484 static PyObject *Qdoffs_NewScreenBuffer(PyObject *_self, PyObject *_args)
485 {
486 PyObject *_res = NULL;
487 QDErr _err;
488 Rect globalRect;
489 Boolean purgeable;
490 GDHandle gdh;
491 PixMapHandle offscreenPixMap;
492 #ifndef NewScreenBuffer
493 PyMac_PRECHECK(NewScreenBuffer);
494 #endif
495 if (!PyArg_ParseTuple(_args, "O&b",
496 PyMac_GetRect, &globalRect,
497 &purgeable))
498 return NULL;
499 _err = NewScreenBuffer(&globalRect,
500 purgeable,
501 &gdh,
502 &offscreenPixMap);
503 if (_err != noErr) return PyMac_Error(_err);
504 _res = Py_BuildValue("O&O&",
505 ResObj_New, gdh,
506 ResObj_New, offscreenPixMap);
507 return _res;
508 }
509
Qdoffs_DisposeScreenBuffer(PyObject * _self,PyObject * _args)510 static PyObject *Qdoffs_DisposeScreenBuffer(PyObject *_self, PyObject *_args)
511 {
512 PyObject *_res = NULL;
513 PixMapHandle offscreenPixMap;
514 #ifndef DisposeScreenBuffer
515 PyMac_PRECHECK(DisposeScreenBuffer);
516 #endif
517 if (!PyArg_ParseTuple(_args, "O&",
518 ResObj_Convert, &offscreenPixMap))
519 return NULL;
520 DisposeScreenBuffer(offscreenPixMap);
521 Py_INCREF(Py_None);
522 _res = Py_None;
523 return _res;
524 }
525
Qdoffs_QDDone(PyObject * _self,PyObject * _args)526 static PyObject *Qdoffs_QDDone(PyObject *_self, PyObject *_args)
527 {
528 PyObject *_res = NULL;
529 Boolean _rv;
530 GrafPtr port;
531 #ifndef QDDone
532 PyMac_PRECHECK(QDDone);
533 #endif
534 if (!PyArg_ParseTuple(_args, "O&",
535 GrafObj_Convert, &port))
536 return NULL;
537 _rv = QDDone(port);
538 _res = Py_BuildValue("b",
539 _rv);
540 return _res;
541 }
542
Qdoffs_OffscreenVersion(PyObject * _self,PyObject * _args)543 static PyObject *Qdoffs_OffscreenVersion(PyObject *_self, PyObject *_args)
544 {
545 PyObject *_res = NULL;
546 long _rv;
547 #ifndef OffscreenVersion
548 PyMac_PRECHECK(OffscreenVersion);
549 #endif
550 if (!PyArg_ParseTuple(_args, ""))
551 return NULL;
552 _rv = OffscreenVersion();
553 _res = Py_BuildValue("l",
554 _rv);
555 return _res;
556 }
557
Qdoffs_NewTempScreenBuffer(PyObject * _self,PyObject * _args)558 static PyObject *Qdoffs_NewTempScreenBuffer(PyObject *_self, PyObject *_args)
559 {
560 PyObject *_res = NULL;
561 QDErr _err;
562 Rect globalRect;
563 Boolean purgeable;
564 GDHandle gdh;
565 PixMapHandle offscreenPixMap;
566 #ifndef NewTempScreenBuffer
567 PyMac_PRECHECK(NewTempScreenBuffer);
568 #endif
569 if (!PyArg_ParseTuple(_args, "O&b",
570 PyMac_GetRect, &globalRect,
571 &purgeable))
572 return NULL;
573 _err = NewTempScreenBuffer(&globalRect,
574 purgeable,
575 &gdh,
576 &offscreenPixMap);
577 if (_err != noErr) return PyMac_Error(_err);
578 _res = Py_BuildValue("O&O&",
579 ResObj_New, gdh,
580 ResObj_New, offscreenPixMap);
581 return _res;
582 }
583
Qdoffs_PixMap32Bit(PyObject * _self,PyObject * _args)584 static PyObject *Qdoffs_PixMap32Bit(PyObject *_self, PyObject *_args)
585 {
586 PyObject *_res = NULL;
587 Boolean _rv;
588 PixMapHandle pmHandle;
589 #ifndef PixMap32Bit
590 PyMac_PRECHECK(PixMap32Bit);
591 #endif
592 if (!PyArg_ParseTuple(_args, "O&",
593 ResObj_Convert, &pmHandle))
594 return NULL;
595 _rv = PixMap32Bit(pmHandle);
596 _res = Py_BuildValue("b",
597 _rv);
598 return _res;
599 }
600
Qdoffs_GetPixMapBytes(PyObject * _self,PyObject * _args)601 static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args)
602 {
603 PyObject *_res = NULL;
604
605 PixMapHandle pm;
606 int from, length;
607 char *cp;
608
609 if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
610 return NULL;
611 cp = GetPixBaseAddr(pm)+from;
612 _res = PyString_FromStringAndSize(cp, length);
613 return _res;
614
615 }
616
Qdoffs_PutPixMapBytes(PyObject * _self,PyObject * _args)617 static PyObject *Qdoffs_PutPixMapBytes(PyObject *_self, PyObject *_args)
618 {
619 PyObject *_res = NULL;
620
621 PixMapHandle pm;
622 int from, length;
623 char *cp, *icp;
624
625 if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
626 return NULL;
627 cp = GetPixBaseAddr(pm)+from;
628 memcpy(cp, icp, length);
629 Py_INCREF(Py_None);
630 _res = Py_None;
631 return _res;
632
633 }
634 #endif /* __LP64__ */
635
636 static PyMethodDef Qdoffs_methods[] = {
637 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
638 {"NewGWorld", (PyCFunction)Qdoffs_NewGWorld, 1,
639 PyDoc_STR("(short PixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldPtr offscreenGWorld)")},
640 {"LockPixels", (PyCFunction)Qdoffs_LockPixels, 1,
641 PyDoc_STR("(PixMapHandle pm) -> (Boolean _rv)")},
642 {"UnlockPixels", (PyCFunction)Qdoffs_UnlockPixels, 1,
643 PyDoc_STR("(PixMapHandle pm) -> None")},
644 {"UpdateGWorld", (PyCFunction)Qdoffs_UpdateGWorld, 1,
645 PyDoc_STR("(short pixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldFlags _rv, GWorldPtr offscreenGWorld)")},
646 {"GetGWorld", (PyCFunction)Qdoffs_GetGWorld, 1,
647 PyDoc_STR("() -> (CGrafPtr port, GDHandle gdh)")},
648 {"SetGWorld", (PyCFunction)Qdoffs_SetGWorld, 1,
649 PyDoc_STR("(CGrafPtr port, GDHandle gdh) -> None")},
650 {"CTabChanged", (PyCFunction)Qdoffs_CTabChanged, 1,
651 PyDoc_STR("(CTabHandle ctab) -> None")},
652 {"PixPatChanged", (PyCFunction)Qdoffs_PixPatChanged, 1,
653 PyDoc_STR("(PixPatHandle ppat) -> None")},
654 {"PortChanged", (PyCFunction)Qdoffs_PortChanged, 1,
655 PyDoc_STR("(GrafPtr port) -> None")},
656 {"GDeviceChanged", (PyCFunction)Qdoffs_GDeviceChanged, 1,
657 PyDoc_STR("(GDHandle gdh) -> None")},
658 {"AllowPurgePixels", (PyCFunction)Qdoffs_AllowPurgePixels, 1,
659 PyDoc_STR("(PixMapHandle pm) -> None")},
660 {"NoPurgePixels", (PyCFunction)Qdoffs_NoPurgePixels, 1,
661 PyDoc_STR("(PixMapHandle pm) -> None")},
662 {"GetPixelsState", (PyCFunction)Qdoffs_GetPixelsState, 1,
663 PyDoc_STR("(PixMapHandle pm) -> (GWorldFlags _rv)")},
664 {"SetPixelsState", (PyCFunction)Qdoffs_SetPixelsState, 1,
665 PyDoc_STR("(PixMapHandle pm, GWorldFlags state) -> None")},
666 {"GetPixRowBytes", (PyCFunction)Qdoffs_GetPixRowBytes, 1,
667 PyDoc_STR("(PixMapHandle pm) -> (long _rv)")},
668 {"NewScreenBuffer", (PyCFunction)Qdoffs_NewScreenBuffer, 1,
669 PyDoc_STR("(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)")},
670 {"DisposeScreenBuffer", (PyCFunction)Qdoffs_DisposeScreenBuffer, 1,
671 PyDoc_STR("(PixMapHandle offscreenPixMap) -> None")},
672 {"QDDone", (PyCFunction)Qdoffs_QDDone, 1,
673 PyDoc_STR("(GrafPtr port) -> (Boolean _rv)")},
674 {"OffscreenVersion", (PyCFunction)Qdoffs_OffscreenVersion, 1,
675 PyDoc_STR("() -> (long _rv)")},
676 {"NewTempScreenBuffer", (PyCFunction)Qdoffs_NewTempScreenBuffer, 1,
677 PyDoc_STR("(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)")},
678 {"PixMap32Bit", (PyCFunction)Qdoffs_PixMap32Bit, 1,
679 PyDoc_STR("(PixMapHandle pmHandle) -> (Boolean _rv)")},
680 {"GetPixMapBytes", (PyCFunction)Qdoffs_GetPixMapBytes, 1,
681 PyDoc_STR("(pixmap, int start, int size) -> string. Return bytes from the pixmap")},
682 {"PutPixMapBytes", (PyCFunction)Qdoffs_PutPixMapBytes, 1,
683 PyDoc_STR("(pixmap, int start, string data). Store bytes into the pixmap")},
684 #endif /* __LP64__ */
685 {NULL, NULL, 0}
686 };
687
688
689
690
init_Qdoffs(void)691 void init_Qdoffs(void)
692 {
693 PyObject *m;
694 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
695 PyObject *d;
696
697
698
699 PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);
700 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);
701
702 #endif /* __LP64__ */
703
704 m = Py_InitModule("_Qdoffs", Qdoffs_methods);
705 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
706 d = PyModule_GetDict(m);
707 Qdoffs_Error = PyMac_GetOSErrException();
708 if (Qdoffs_Error == NULL ||
709 PyDict_SetItemString(d, "Error", Qdoffs_Error) != 0)
710 return;
711 GWorld_Type.ob_type = &PyType_Type;
712 if (PyType_Ready(&GWorld_Type) < 0) return;
713 Py_INCREF(&GWorld_Type);
714 PyModule_AddObject(m, "GWorld", (PyObject *)&GWorld_Type);
715 /* Backward-compatible name */
716 Py_INCREF(&GWorld_Type);
717 PyModule_AddObject(m, "GWorldType", (PyObject *)&GWorld_Type);
718 #endif /* __LP64__ */
719 }
720
721 /* ======================= End module _Qdoffs ======================= */
722
723