Changeset 391 for python/trunk/Mac/Modules/qdoffs
- Timestamp:
- Mar 19, 2014, 11:31:01 PM (12 years ago)
- Location:
- python/trunk
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
Mac/Modules/qdoffs/_Qdoffsmodule.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
python/trunk
-
Property svn:mergeinfo
set to
/python/vendor/Python-2.7.6 merged eligible /python/vendor/current merged eligible
-
Property svn:mergeinfo
set to
-
python/trunk/Mac/Modules/qdoffs/_Qdoffsmodule.c
r2 r391 5 5 6 6 7 #ifndef __LP64__ 7 #include <Carbon/Carbon.h> 8 #if !defined(__LP64__) && !defined(MAC_OS_X_VERSION_10_7) 8 9 9 10 #include "pymactoolbox.h" … … 11 12 /* Macro to test whether a weak-loaded CFM function exists */ 12 13 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ 13 PyErr_SetString(PyExc_NotImplementedError, \14 "Not available in this shared library/OS version"); \15 return NULL; \14 PyErr_SetString(PyExc_NotImplementedError, \ 15 "Not available in this shared library/OS version"); \ 16 return NULL; \ 16 17 }} while(0) 17 18 18 19 19 #include <Carbon/Carbon.h>20 20 21 21 #ifdef USE_TOOLBOX_OBJECT_GLUE … … 39 39 40 40 typedef struct GWorldObject { 41 PyObject_HEAD42 GWorldPtr ob_itself;41 PyObject_HEAD 42 GWorldPtr ob_itself; 43 43 } GWorldObject; 44 44 45 45 PyObject *GWorldObj_New(GWorldPtr itself) 46 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;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 53 } 54 54 55 55 int GWorldObj_Convert(PyObject *v, GWorldPtr *p_itself) 56 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;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 64 } 65 65 66 66 static void GWorldObj_dealloc(GWorldObject *self) 67 67 { 68 DisposeGWorld(self->ob_itself);69 self->ob_type->tp_free((PyObject *)self);68 DisposeGWorld(self->ob_itself); 69 self->ob_type->tp_free((PyObject *)self); 70 70 } 71 71 72 72 static PyObject *GWorldObj_GetGWorldDevice(GWorldObject *_self, PyObject *_args) 73 73 { 74 PyObject *_res = NULL;75 GDHandle _rv;74 PyObject *_res = NULL; 75 GDHandle _rv; 76 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;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 85 } 86 86 87 87 static PyObject *GWorldObj_GetGWorldPixMap(GWorldObject *_self, PyObject *_args) 88 88 { 89 PyObject *_res = NULL;90 PixMapHandle _rv;89 PyObject *_res = NULL; 90 PixMapHandle _rv; 91 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;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 100 } 101 101 102 102 static PyObject *GWorldObj_as_GrafPtr(GWorldObject *_self, PyObject *_args) 103 103 { 104 PyObject *_res = NULL;105 GrafPtr _rv;104 PyObject *_res = NULL; 105 GrafPtr _rv; 106 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;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 115 } 116 116 117 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}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 125 }; 126 126 … … 139 139 static PyObject *GWorldObj_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) 140 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;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 149 } 150 150 … … 153 153 154 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 */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 196 }; 197 197 … … 201 201 static PyObject *Qdoffs_NewGWorld(PyObject *_self, PyObject *_args) 202 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;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 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;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 231 } 232 232 233 233 static PyObject *Qdoffs_LockPixels(PyObject *_self, PyObject *_args) 234 234 { 235 PyObject *_res = NULL;236 Boolean _rv;237 PixMapHandle pm;235 PyObject *_res = NULL; 236 Boolean _rv; 237 PixMapHandle pm; 238 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;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 248 } 249 249 250 250 static PyObject *Qdoffs_UnlockPixels(PyObject *_self, PyObject *_args) 251 251 { 252 PyObject *_res = NULL;253 PixMapHandle pm;252 PyObject *_res = NULL; 253 PixMapHandle pm; 254 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;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 264 } 265 265 266 266 static PyObject *Qdoffs_UpdateGWorld(PyObject *_self, PyObject *_args) 267 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;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 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;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 296 } 297 297 298 298 static PyObject *Qdoffs_GetGWorld(PyObject *_self, PyObject *_args) 299 299 { 300 PyObject *_res = NULL;301 CGrafPtr port;302 GDHandle gdh;300 PyObject *_res = NULL; 301 CGrafPtr port; 302 GDHandle gdh; 303 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;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 314 } 315 315 316 316 static PyObject *Qdoffs_SetGWorld(PyObject *_self, PyObject *_args) 317 317 { 318 PyObject *_res = NULL;319 CGrafPtr port;320 GDHandle gdh;318 PyObject *_res = NULL; 319 CGrafPtr port; 320 GDHandle gdh; 321 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;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 333 } 334 334 335 335 static PyObject *Qdoffs_CTabChanged(PyObject *_self, PyObject *_args) 336 336 { 337 PyObject *_res = NULL;338 CTabHandle ctab;337 PyObject *_res = NULL; 338 CTabHandle ctab; 339 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;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 349 } 350 350 351 351 static PyObject *Qdoffs_PixPatChanged(PyObject *_self, PyObject *_args) 352 352 { 353 PyObject *_res = NULL;354 PixPatHandle ppat;353 PyObject *_res = NULL; 354 PixPatHandle ppat; 355 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;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 365 } 366 366 367 367 static PyObject *Qdoffs_PortChanged(PyObject *_self, PyObject *_args) 368 368 { 369 PyObject *_res = NULL;370 GrafPtr port;369 PyObject *_res = NULL; 370 GrafPtr port; 371 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;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 381 } 382 382 383 383 static PyObject *Qdoffs_GDeviceChanged(PyObject *_self, PyObject *_args) 384 384 { 385 PyObject *_res = NULL;386 GDHandle gdh;385 PyObject *_res = NULL; 386 GDHandle gdh; 387 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;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 397 } 398 398 399 399 static PyObject *Qdoffs_AllowPurgePixels(PyObject *_self, PyObject *_args) 400 400 { 401 PyObject *_res = NULL;402 PixMapHandle pm;401 PyObject *_res = NULL; 402 PixMapHandle pm; 403 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;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 413 } 414 414 415 415 static PyObject *Qdoffs_NoPurgePixels(PyObject *_self, PyObject *_args) 416 416 { 417 PyObject *_res = NULL;418 PixMapHandle pm;417 PyObject *_res = NULL; 418 PixMapHandle pm; 419 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;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 429 } 430 430 431 431 static PyObject *Qdoffs_GetPixelsState(PyObject *_self, PyObject *_args) 432 432 { 433 PyObject *_res = NULL;434 GWorldFlags _rv;435 PixMapHandle pm;433 PyObject *_res = NULL; 434 GWorldFlags _rv; 435 PixMapHandle pm; 436 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;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 446 } 447 447 448 448 static PyObject *Qdoffs_SetPixelsState(PyObject *_self, PyObject *_args) 449 449 { 450 PyObject *_res = NULL;451 PixMapHandle pm;452 GWorldFlags state;450 PyObject *_res = NULL; 451 PixMapHandle pm; 452 GWorldFlags state; 453 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;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 465 } 466 466 467 467 static PyObject *Qdoffs_GetPixRowBytes(PyObject *_self, PyObject *_args) 468 468 { 469 PyObject *_res = NULL;470 long _rv;471 PixMapHandle pm;469 PyObject *_res = NULL; 470 long _rv; 471 PixMapHandle pm; 472 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;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 482 } 483 483 484 484 static PyObject *Qdoffs_NewScreenBuffer(PyObject *_self, PyObject *_args) 485 485 { 486 PyObject *_res = NULL;487 QDErr _err;488 Rect globalRect;489 Boolean purgeable;490 GDHandle gdh;491 PixMapHandle offscreenPixMap;486 PyObject *_res = NULL; 487 QDErr _err; 488 Rect globalRect; 489 Boolean purgeable; 490 GDHandle gdh; 491 PixMapHandle offscreenPixMap; 492 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;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 508 } 509 509 510 510 static PyObject *Qdoffs_DisposeScreenBuffer(PyObject *_self, PyObject *_args) 511 511 { 512 PyObject *_res = NULL;513 PixMapHandle offscreenPixMap;512 PyObject *_res = NULL; 513 PixMapHandle offscreenPixMap; 514 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;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 524 } 525 525 526 526 static PyObject *Qdoffs_QDDone(PyObject *_self, PyObject *_args) 527 527 { 528 PyObject *_res = NULL;529 Boolean _rv;530 GrafPtr port;528 PyObject *_res = NULL; 529 Boolean _rv; 530 GrafPtr port; 531 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;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 541 } 542 542 543 543 static PyObject *Qdoffs_OffscreenVersion(PyObject *_self, PyObject *_args) 544 544 { 545 PyObject *_res = NULL;546 long _rv;545 PyObject *_res = NULL; 546 long _rv; 547 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;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 556 } 557 557 558 558 static PyObject *Qdoffs_NewTempScreenBuffer(PyObject *_self, PyObject *_args) 559 559 { 560 PyObject *_res = NULL;561 QDErr _err;562 Rect globalRect;563 Boolean purgeable;564 GDHandle gdh;565 PixMapHandle offscreenPixMap;560 PyObject *_res = NULL; 561 QDErr _err; 562 Rect globalRect; 563 Boolean purgeable; 564 GDHandle gdh; 565 PixMapHandle offscreenPixMap; 566 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;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 582 } 583 583 584 584 static PyObject *Qdoffs_PixMap32Bit(PyObject *_self, PyObject *_args) 585 585 { 586 PyObject *_res = NULL;587 Boolean _rv;588 PixMapHandle pmHandle;586 PyObject *_res = NULL; 587 Boolean _rv; 588 PixMapHandle pmHandle; 589 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;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 599 } 600 600 601 601 static PyObject *Qdoffs_GetPixMapBytes(PyObject *_self, PyObject *_args) 602 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;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 614 615 615 } … … 617 617 static PyObject *Qdoffs_PutPixMapBytes(PyObject *_self, PyObject *_args) 618 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;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 632 633 633 } … … 635 635 636 636 static PyMethodDef Qdoffs_methods[] = { 637 #if ndef __LP64__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")},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 684 #endif /* __LP64__ */ 685 {NULL, NULL, 0}685 {NULL, NULL, 0} 686 686 }; 687 687 … … 691 691 void init_Qdoffs(void) 692 692 { 693 PyObject *m;694 #if ndef __LP64__695 PyObject *d;696 697 698 699 PyMac_INIT_TOOLBOX_OBJECT_NEW(GWorldPtr, GWorldObj_New);700 PyMac_INIT_TOOLBOX_OBJECT_CONVERT(GWorldPtr, GWorldObj_Convert);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 701 702 702 #endif /* __LP64__ */ 703 703 704 m = Py_InitModule("_Qdoffs", Qdoffs_methods);705 #if ndef __LP64__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);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 718 #endif /* __LP64__ */ 719 719 }
Note:
See TracChangeset
for help on using the changeset viewer.
