Source

cpython / Mac / Modules / qdoffs / _Qdoffsmodule.c

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722

/* ========================= Module _Qdoffs ========================= */

#include "Python.h"


#include <Carbon/Carbon.h>
#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)

#include "pymactoolbox.h"

/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL )  {\
    PyErr_SetString(PyExc_NotImplementedError, \
    "Not available in this shared library/OS version"); \
    return NULL; \
    }} while(0)



#ifdef USE_TOOLBOX_OBJECT_GLUE
extern PyObject *_GWorldObj_New(GWorldPtr);
extern int _GWorldObj_Convert(PyObject *, GWorldPtr *);

#define GWorldObj_New _GWorldObj_New
#define GWorldObj_Convert _GWorldObj_Convert
#endif

#define as_GrafPtr(gworld) ((GrafPtr)(gworld))


static PyObject *Qdoffs_Error;

/* ----------------------- Object type GWorld ----------------------- */

PyTypeObject GWorld_Type;

#define GWorldObj_Check(x) ((x)->ob_type == &GWorld_Type || PyObject_TypeCheck((x), &GWorld_Type))

typedef struct GWorldObject {
    PyObject_HEAD
    GWorldPtr ob_itself;
} GWorldObject;

PyObject *GWorldObj_New(GWorldPtr itself)
{
    GWorldObject *it;
    if (itself == NULL) return PyMac_Error(resNotFound);
    it = PyObject_NEW(GWorldObject, &GWorld_Type);
    if (it == NULL) return NULL;
    it->ob_itself = itself;
    return (PyObject *)it;
}

int GWorldObj_Convert(PyObject *v, GWorldPtr *p_itself)
{
    if (!GWorldObj_Check(v))
    {
        PyErr_SetString(PyExc_TypeError, "GWorld required");
        return 0;
    }
    *p_itself = ((GWorldObject *)v)->ob_itself;
    return 1;
}

static void GWorldObj_dealloc(GWorldObject *self)
{
    DisposeGWorld(self->ob_itself);
    self->ob_type->tp_free((PyObject *)self);
}

static PyObject *GWorldObj_GetGWorldDevice(GWorldObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    GDHandle _rv;
#ifndef GetGWorldDevice
    PyMac_PRECHECK(GetGWorldDevice);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = GetGWorldDevice(_self->ob_itself);
    _res = Py_BuildValue("O&",
                         ResObj_New, _rv);
    return _res;
}

static PyObject *GWorldObj_GetGWorldPixMap(GWorldObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixMapHandle _rv;
#ifndef GetGWorldPixMap
    PyMac_PRECHECK(GetGWorldPixMap);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = GetGWorldPixMap(_self->ob_itself);
    _res = Py_BuildValue("O&",
                         ResObj_New, _rv);
    return _res;
}

static PyObject *GWorldObj_as_GrafPtr(GWorldObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    GrafPtr _rv;
#ifndef as_GrafPtr
    PyMac_PRECHECK(as_GrafPtr);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = as_GrafPtr(_self->ob_itself);
    _res = Py_BuildValue("O&",
                         GrafObj_New, _rv);
    return _res;
}

static PyMethodDef GWorldObj_methods[] = {
    {"GetGWorldDevice", (PyCFunction)GWorldObj_GetGWorldDevice, 1,
     PyDoc_STR("() -> (GDHandle _rv)")},
    {"GetGWorldPixMap", (PyCFunction)GWorldObj_GetGWorldPixMap, 1,
     PyDoc_STR("() -> (PixMapHandle _rv)")},
    {"as_GrafPtr", (PyCFunction)GWorldObj_as_GrafPtr, 1,
     PyDoc_STR("() -> (GrafPtr _rv)")},
    {NULL, NULL, 0}
};

#define GWorldObj_getsetlist NULL


#define GWorldObj_compare NULL

#define GWorldObj_repr NULL

#define GWorldObj_hash NULL
#define GWorldObj_tp_init 0

#define GWorldObj_tp_alloc PyType_GenericAlloc

static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds)
{
    PyObject *_self;
    GWorldPtr itself;
    char *kw[] = {"itself", 0};

    if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, GWorldObj_Convert, &itself)) return NULL;
    if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL;
    ((GWorldObject *)_self)->ob_itself = itself;
    return _self;
}

#define GWorldObj_tp_free PyObject_Del


PyTypeObject GWorld_Type = {
    PyObject_HEAD_INIT(NULL)
    0, /*ob_size*/
    "_Qdoffs.GWorld", /*tp_name*/
    sizeof(GWorldObject), /*tp_basicsize*/
    0, /*tp_itemsize*/
    /* methods */
    (destructor) GWorldObj_dealloc, /*tp_dealloc*/
    0, /*tp_print*/
    (getattrfunc)0, /*tp_getattr*/
    (setattrfunc)0, /*tp_setattr*/
    (cmpfunc) GWorldObj_compare, /*tp_compare*/
    (reprfunc) GWorldObj_repr, /*tp_repr*/
    (PyNumberMethods *)0, /* tp_as_number */
    (PySequenceMethods *)0, /* tp_as_sequence */
    (PyMappingMethods *)0, /* tp_as_mapping */
    (hashfunc) GWorldObj_hash, /*tp_hash*/
    0, /*tp_call*/
    0, /*tp_str*/
    PyObject_GenericGetAttr, /*tp_getattro*/
    PyObject_GenericSetAttr, /*tp_setattro */
    0, /*tp_as_buffer*/
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, /* tp_flags */
    0, /*tp_doc*/
    0, /*tp_traverse*/
    0, /*tp_clear*/
    0, /*tp_richcompare*/
    0, /*tp_weaklistoffset*/
    0, /*tp_iter*/
    0, /*tp_iternext*/
    GWorldObj_methods, /* tp_methods */
    0, /*tp_members*/
    GWorldObj_getsetlist, /*tp_getset*/
    0, /*tp_base*/
    0, /*tp_dict*/
    0, /*tp_descr_get*/
    0, /*tp_descr_set*/
    0, /*tp_dictoffset*/
    GWorldObj_tp_init, /* tp_init */
    GWorldObj_tp_alloc, /* tp_alloc */
    GWorldObj_tp_new, /* tp_new */
    GWorldObj_tp_free, /* tp_free */
};

/* --------------------- End object type GWorld --------------------- */


static PyObject *Qdoffs_NewGWorld(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    QDErr _err;
    GWorldPtr offscreenGWorld;
    short PixelDepth;
    Rect boundsRect;
    CTabHandle cTable;
    GDHandle aGDevice;
    GWorldFlags flags;
#ifndef NewGWorld
    PyMac_PRECHECK(NewGWorld);
#endif
    if (!PyArg_ParseTuple(_args, "hO&O&O&l",
                          &PixelDepth,
                          PyMac_GetRect, &boundsRect,
                          OptResObj_Convert, &cTable,
                          OptResObj_Convert, &aGDevice,
                          &flags))
        return NULL;
    _err = NewGWorld(&offscreenGWorld,
                     PixelDepth,
                     &boundsRect,
                     cTable,
                     aGDevice,
                     flags);
    if (_err != noErr) return PyMac_Error(_err);
    _res = Py_BuildValue("O&",
                         GWorldObj_New, offscreenGWorld);
    return _res;
}

static PyObject *Qdoffs_LockPixels(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    Boolean _rv;
    PixMapHandle pm;
#ifndef LockPixels
    PyMac_PRECHECK(LockPixels);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pm))
        return NULL;
    _rv = LockPixels(pm);
    _res = Py_BuildValue("b",
                         _rv);
    return _res;
}

static PyObject *Qdoffs_UnlockPixels(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixMapHandle pm;
#ifndef UnlockPixels
    PyMac_PRECHECK(UnlockPixels);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pm))
        return NULL;
    UnlockPixels(pm);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_UpdateGWorld(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    GWorldFlags _rv;
    GWorldPtr offscreenGWorld;
    short pixelDepth;
    Rect boundsRect;
    CTabHandle cTable;
    GDHandle aGDevice;
    GWorldFlags flags;
#ifndef UpdateGWorld
    PyMac_PRECHECK(UpdateGWorld);
#endif
    if (!PyArg_ParseTuple(_args, "hO&O&O&l",
                          &pixelDepth,
                          PyMac_GetRect, &boundsRect,
                          OptResObj_Convert, &cTable,
                          OptResObj_Convert, &aGDevice,
                          &flags))
        return NULL;
    _rv = UpdateGWorld(&offscreenGWorld,
                       pixelDepth,
                       &boundsRect,
                       cTable,
                       aGDevice,
                       flags);
    _res = Py_BuildValue("lO&",
                         _rv,
                         GWorldObj_New, offscreenGWorld);
    return _res;
}

static PyObject *Qdoffs_GetGWorld(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    CGrafPtr port;
    GDHandle gdh;
#ifndef GetGWorld
    PyMac_PRECHECK(GetGWorld);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    GetGWorld(&port,
              &gdh);
    _res = Py_BuildValue("O&O&",
                         GrafObj_New, port,
                         ResObj_New, gdh);
    return _res;
}

static PyObject *Qdoffs_SetGWorld(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    CGrafPtr port;
    GDHandle gdh;
#ifndef SetGWorld
    PyMac_PRECHECK(SetGWorld);
#endif
    if (!PyArg_ParseTuple(_args, "O&O&",
                          GrafObj_Convert, &port,
                          OptResObj_Convert, &gdh))
        return NULL;
    SetGWorld(port,
              gdh);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_CTabChanged(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    CTabHandle ctab;
#ifndef CTabChanged
    PyMac_PRECHECK(CTabChanged);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          OptResObj_Convert, &ctab))
        return NULL;
    CTabChanged(ctab);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_PixPatChanged(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixPatHandle ppat;
#ifndef PixPatChanged
    PyMac_PRECHECK(PixPatChanged);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &ppat))
        return NULL;
    PixPatChanged(ppat);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_PortChanged(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    GrafPtr port;
#ifndef PortChanged
    PyMac_PRECHECK(PortChanged);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          GrafObj_Convert, &port))
        return NULL;
    PortChanged(port);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_GDeviceChanged(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    GDHandle gdh;
#ifndef GDeviceChanged
    PyMac_PRECHECK(GDeviceChanged);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          OptResObj_Convert, &gdh))
        return NULL;
    GDeviceChanged(gdh);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_AllowPurgePixels(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixMapHandle pm;
#ifndef AllowPurgePixels
    PyMac_PRECHECK(AllowPurgePixels);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pm))
        return NULL;
    AllowPurgePixels(pm);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_NoPurgePixels(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixMapHandle pm;
#ifndef NoPurgePixels
    PyMac_PRECHECK(NoPurgePixels);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pm))
        return NULL;
    NoPurgePixels(pm);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_GetPixelsState(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    GWorldFlags _rv;
    PixMapHandle pm;
#ifndef GetPixelsState
    PyMac_PRECHECK(GetPixelsState);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pm))
        return NULL;
    _rv = GetPixelsState(pm);
    _res = Py_BuildValue("l",
                         _rv);
    return _res;
}

static PyObject *Qdoffs_SetPixelsState(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixMapHandle pm;
    GWorldFlags state;
#ifndef SetPixelsState
    PyMac_PRECHECK(SetPixelsState);
#endif
    if (!PyArg_ParseTuple(_args, "O&l",
                          ResObj_Convert, &pm,
                          &state))
        return NULL;
    SetPixelsState(pm,
                   state);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_GetPixRowBytes(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    long _rv;
    PixMapHandle pm;
#ifndef GetPixRowBytes
    PyMac_PRECHECK(GetPixRowBytes);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pm))
        return NULL;
    _rv = GetPixRowBytes(pm);
    _res = Py_BuildValue("l",
                         _rv);
    return _res;
}

static PyObject *Qdoffs_NewScreenBuffer(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    QDErr _err;
    Rect globalRect;
    Boolean purgeable;
    GDHandle gdh;
    PixMapHandle offscreenPixMap;
#ifndef NewScreenBuffer
    PyMac_PRECHECK(NewScreenBuffer);
#endif
    if (!PyArg_ParseTuple(_args, "O&b",
                          PyMac_GetRect, &globalRect,
                          &purgeable))
        return NULL;
    _err = NewScreenBuffer(&globalRect,
                           purgeable,
                           &gdh,
                           &offscreenPixMap);
    if (_err != noErr) return PyMac_Error(_err);
    _res = Py_BuildValue("O&O&",
                         ResObj_New, gdh,
                         ResObj_New, offscreenPixMap);
    return _res;
}

static PyObject *Qdoffs_DisposeScreenBuffer(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    PixMapHandle offscreenPixMap;
#ifndef DisposeScreenBuffer
    PyMac_PRECHECK(DisposeScreenBuffer);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &offscreenPixMap))
        return NULL;
    DisposeScreenBuffer(offscreenPixMap);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;
}

static PyObject *Qdoffs_QDDone(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    Boolean _rv;
    GrafPtr port;
#ifndef QDDone
    PyMac_PRECHECK(QDDone);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          GrafObj_Convert, &port))
        return NULL;
    _rv = QDDone(port);
    _res = Py_BuildValue("b",
                         _rv);
    return _res;
}

static PyObject *Qdoffs_OffscreenVersion(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    long _rv;
#ifndef OffscreenVersion
    PyMac_PRECHECK(OffscreenVersion);
#endif
    if (!PyArg_ParseTuple(_args, ""))
        return NULL;
    _rv = OffscreenVersion();
    _res = Py_BuildValue("l",
                         _rv);
    return _res;
}

static PyObject *Qdoffs_NewTempScreenBuffer(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    QDErr _err;
    Rect globalRect;
    Boolean purgeable;
    GDHandle gdh;
    PixMapHandle offscreenPixMap;
#ifndef NewTempScreenBuffer
    PyMac_PRECHECK(NewTempScreenBuffer);
#endif
    if (!PyArg_ParseTuple(_args, "O&b",
                          PyMac_GetRect, &globalRect,
                          &purgeable))
        return NULL;
    _err = NewTempScreenBuffer(&globalRect,
                               purgeable,
                               &gdh,
                               &offscreenPixMap);
    if (_err != noErr) return PyMac_Error(_err);
    _res = Py_BuildValue("O&O&",
                         ResObj_New, gdh,
                         ResObj_New, offscreenPixMap);
    return _res;
}

static PyObject *Qdoffs_PixMap32Bit(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;
    Boolean _rv;
    PixMapHandle pmHandle;
#ifndef PixMap32Bit
    PyMac_PRECHECK(PixMap32Bit);
#endif
    if (!PyArg_ParseTuple(_args, "O&",
                          ResObj_Convert, &pmHandle))
        return NULL;
    _rv = PixMap32Bit(pmHandle);
    _res = Py_BuildValue("b",
                         _rv);
    return _res;
}

static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;

    PixMapHandle pm;
    int from, length;
    char *cp;

    if ( !PyArg_ParseTuple(_args, "O&ii", ResObj_Convert, &pm, &from, &length) )
        return NULL;
    cp = GetPixBaseAddr(pm)+from;
    _res = PyString_FromStringAndSize(cp, length);
    return _res;

}

static PyObject *Qdoffs_PutPixMapBytes(PyObject *_self, PyObject *_args)
{
    PyObject *_res = NULL;

    PixMapHandle pm;
    int from, length;
    char *cp, *icp;

    if ( !PyArg_ParseTuple(_args, "O&is#", ResObj_Convert, &pm, &from, &icp, &length) )
        return NULL;
    cp = GetPixBaseAddr(pm)+from;
    memcpy(cp, icp, length);
    Py_INCREF(Py_None);
    _res = Py_None;
    return _res;

}
#endif /* __LP64__ */

static PyMethodDef Qdoffs_methods[] = {
#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
    {"NewGWorld", (PyCFunction)Qdoffs_NewGWorld, 1,
     PyDoc_STR("(short PixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldPtr offscreenGWorld)")},
    {"LockPixels", (PyCFunction)Qdoffs_LockPixels, 1,
     PyDoc_STR("(PixMapHandle pm) -> (Boolean _rv)")},
    {"UnlockPixels", (PyCFunction)Qdoffs_UnlockPixels, 1,
     PyDoc_STR("(PixMapHandle pm) -> None")},
    {"UpdateGWorld", (PyCFunction)Qdoffs_UpdateGWorld, 1,
     PyDoc_STR("(short pixelDepth, Rect boundsRect, CTabHandle cTable, GDHandle aGDevice, GWorldFlags flags) -> (GWorldFlags _rv, GWorldPtr offscreenGWorld)")},
    {"GetGWorld", (PyCFunction)Qdoffs_GetGWorld, 1,
     PyDoc_STR("() -> (CGrafPtr port, GDHandle gdh)")},
    {"SetGWorld", (PyCFunction)Qdoffs_SetGWorld, 1,
     PyDoc_STR("(CGrafPtr port, GDHandle gdh) -> None")},
    {"CTabChanged", (PyCFunction)Qdoffs_CTabChanged, 1,
     PyDoc_STR("(CTabHandle ctab) -> None")},
    {"PixPatChanged", (PyCFunction)Qdoffs_PixPatChanged, 1,
     PyDoc_STR("(PixPatHandle ppat) -> None")},
    {"PortChanged", (PyCFunction)Qdoffs_PortChanged, 1,
     PyDoc_STR("(GrafPtr port) -> None")},
    {"GDeviceChanged", (PyCFunction)Qdoffs_GDeviceChanged, 1,
     PyDoc_STR("(GDHandle gdh) -> None")},
    {"AllowPurgePixels", (PyCFunction)Qdoffs_AllowPurgePixels, 1,
     PyDoc_STR("(PixMapHandle pm) -> None")},
    {"NoPurgePixels", (PyCFunction)Qdoffs_NoPurgePixels, 1,
     PyDoc_STR("(PixMapHandle pm) -> None")},
    {"GetPixelsState", (PyCFunction)Qdoffs_GetPixelsState, 1,
     PyDoc_STR("(PixMapHandle pm) -> (GWorldFlags _rv)")},
    {"SetPixelsState", (PyCFunction)Qdoffs_SetPixelsState, 1,
     PyDoc_STR("(PixMapHandle pm, GWorldFlags state) -> None")},
    {"GetPixRowBytes", (PyCFunction)Qdoffs_GetPixRowBytes, 1,
     PyDoc_STR("(PixMapHandle pm) -> (long _rv)")},
    {"NewScreenBuffer", (PyCFunction)Qdoffs_NewScreenBuffer, 1,
     PyDoc_STR("(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)")},
    {"DisposeScreenBuffer", (PyCFunction)Qdoffs_DisposeScreenBuffer, 1,
     PyDoc_STR("(PixMapHandle offscreenPixMap) -> None")},
    {"QDDone", (PyCFunction)Qdoffs_QDDone, 1,
     PyDoc_STR("(GrafPtr port) -> (Boolean _rv)")},
    {"OffscreenVersion", (PyCFunction)Qdoffs_OffscreenVersion, 1,
     PyDoc_STR("() -> (long _rv)")},
    {"NewTempScreenBuffer", (PyCFunction)Qdoffs_NewTempScreenBuffer, 1,
     PyDoc_STR("(Rect globalRect, Boolean purgeable) -> (GDHandle gdh, PixMapHandle offscreenPixMap)")},
    {"PixMap32Bit", (PyCFunction)Qdoffs_PixMap32Bit, 1,
     PyDoc_STR("(PixMapHandle pmHandle) -> (Boolean _rv)")},
    {"GetPixMapBytes", (PyCFunction)Qdoffs_GetPixMapBytes, 1,
     PyDoc_STR("(pixmap, int start, int size) -> string. Return bytes from the pixmap")},
    {"PutPixMapBytes", (PyCFunction)Qdoffs_PutPixMapBytes, 1,
     PyDoc_STR("(pixmap, int start, string data). Store bytes into the pixmap")},
#endif /* __LP64__ */
    {NULL, NULL, 0}
};




void init_Qdoffs(void)
{
    PyObject *m;
#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
    PyObject *d;



        PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);
        PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);

#endif /* __LP64__ */

    m = Py_InitModule("_Qdoffs", Qdoffs_methods);
#if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7)
    d = PyModule_GetDict(m);
    Qdoffs_Error = PyMac_GetOSErrException();
    if (Qdoffs_Error == NULL ||
        PyDict_SetItemString(d, "Error", Qdoffs_Error) != 0)
        return;
    GWorld_Type.ob_type = &PyType_Type;
    if (PyType_Ready(&GWorld_Type) < 0) return;
    Py_INCREF(&GWorld_Type);
    PyModule_AddObject(m, "GWorld", (PyObject *)&GWorld_Type);
    /* Backward-compatible name */
    Py_INCREF(&GWorld_Type);
    PyModule_AddObject(m, "GWorldType", (PyObject *)&GWorld_Type);
#endif /* __LP64__ */
}

/* ======================= End module _Qdoffs ======================= */