1 /* 2 pygame - Python Game Library 3 Copyright (C) 2000-2001 Pete Shinners 4 5 This library is free software; you can redistribute it and/or 6 modify it under the terms of the GNU Library General Public 7 License as published by the Free Software Foundation; either 8 version 2 of the License, or (at your option) any later version. 9 10 This library is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 Library General Public License for more details. 14 15 You should have received a copy of the GNU Library General Public 16 License along with this library; if not, write to the Free 17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 19 Pete Shinners 20 pete@shinners.org 21 */ 22 23 #ifndef _PYGAME_H 24 #define _PYGAME_H 25 26 /** This header file includes all the definitions for the 27 ** base pygame extensions. This header only requires 28 ** Python includes (and SDL.h for functions that use SDL types). 29 ** The reason for functions prototyped with #define's is 30 ** to allow for maximum Python portability. It also uses 31 ** Python as the runtime linker, which allows for late binding. 32 '' For more information on this style of development, read 33 ** the Python docs on this subject. 34 ** http://www.python.org/doc/current/ext/using-cobjects.html 35 ** 36 ** If using this to build your own derived extensions, 37 ** you'll see that the functions available here are mainly 38 ** used to help convert between python objects and SDL objects. 39 ** Since this library doesn't add a lot of functionality to 40 ** the SDL library, it doesn't need to offer a lot either. 41 ** 42 ** When initializing your extension module, you must manually 43 ** import the modules you want to use. (this is the part about 44 ** using python as the runtime linker). Each module has its 45 ** own import_xxx() routine. You need to perform this import 46 ** after you have initialized your own module, and before 47 ** you call any routines from that module. Since every module 48 ** in pygame does this, there are plenty of examples. 49 ** 50 ** The base module does include some useful conversion routines 51 ** that you are free to use in your own extension. 52 **/ 53 54 #include "pgplatform.h" 55 #include <Python.h> 56 57 58 /* version macros (defined since version 1.9.5) */ 59 #define PG_MAJOR_VERSION 2 60 #define PG_MINOR_VERSION 1 61 #define PG_PATCH_VERSION 0 62 #define PG_VERSIONNUM(MAJOR, MINOR, PATCH) (1000*(MAJOR) + 100*(MINOR) + (PATCH)) 63 #define PG_VERSION_ATLEAST(MAJOR, MINOR, PATCH) \ 64 (PG_VERSIONNUM(PG_MAJOR_VERSION, PG_MINOR_VERSION, PG_PATCH_VERSION) >= \ 65 PG_VERSIONNUM(MAJOR, MINOR, PATCH)) 66 67 /* SDL 1.x/2.x and pygame 1.x/2.x 68 */ 69 #if defined(SDL_VERSION_ATLEAST) 70 #if (SDL_VERSION_ATLEAST(2, 0, 0)) 71 #define PG_API_VERSION 2 72 #else /* SDL 1 */ 73 /* for now: allow pygame 2 to be compiled with SDL 1. */ 74 #define PG_API_VERSION 1 75 #endif /* SDL 1 */ 76 #else /* NO SDL */ 77 #define PG_API_VERSION ((PG_MAJOR_VERSION == 1) ? 1 : 2) 78 #endif /* NO SDL */ 79 80 #include "pgcompat.h" 81 82 83 /* Flag indicating a pg_buffer; used for assertions within callbacks */ 84 #ifndef NDEBUG 85 #define PyBUF_PYGAME 0x4000 86 #endif 87 #define PyBUF_HAS_FLAG(f, F) (((f) & (F)) == (F)) 88 89 /* Array information exchange struct C type; inherits from Py_buffer 90 * 91 * Pygame uses its own Py_buffer derived C struct as an internal representation 92 * of an imported array buffer. The extended Py_buffer allows for a 93 * per-instance release callback, 94 */ 95 typedef void (*pybuffer_releaseproc)(Py_buffer *); 96 97 typedef struct pg_bufferinfo_s { 98 Py_buffer view; 99 PyObject *consumer; /* Input: Borrowed reference */ 100 pybuffer_releaseproc release_buffer; 101 } pg_buffer; 102 103 #include "pgimport.h" 104 105 /* 106 * BASE module 107 */ 108 #ifndef PYGAMEAPI_BASE_INTERNAL 109 #define pgExc_SDLError \ 110 ((PyObject *) \ 111 PYGAMEAPI_GET_SLOT(base, 0)) 112 113 #define pg_RegisterQuit \ 114 (*(void (*)(void (*)(void))) \ 115 PYGAMEAPI_GET_SLOT(base, 1)) 116 117 #define pg_IntFromObj \ 118 (*(int (*)(PyObject *, int *)) \ 119 PYGAMEAPI_GET_SLOT(base, 2)) 120 121 #define pg_IntFromObjIndex \ 122 (*(int (*)(PyObject *, int, int *)) \ 123 PYGAMEAPI_GET_SLOT(base, 3)) 124 125 #define pg_TwoIntsFromObj \ 126 (*(int (*)(PyObject *, int *, int *)) \ 127 PYGAMEAPI_GET_SLOT(base, 4)) 128 129 #define pg_FloatFromObj \ 130 (*(int (*)(PyObject *, float *)) \ 131 PYGAMEAPI_GET_SLOT(base, 5)) 132 133 #define pg_FloatFromObjIndex \ 134 (*(int (*)(PyObject *, int, float *)) \ 135 PYGAMEAPI_GET_SLOT(base, 6)) 136 137 #define pg_TwoFloatsFromObj \ 138 (*(int (*)(PyObject *, float *, float *)) \ 139 PYGAMEAPI_GET_SLOT(base, 7)) 140 141 #define pg_UintFromObj \ 142 (*(int (*)(PyObject *, Uint32 *)) \ 143 PYGAMEAPI_GET_SLOT(base, 8)) 144 145 #define pg_UintFromObjIndex \ 146 (*(int (*)(PyObject *, int, Uint32 *)) \ 147 PYGAMEAPI_GET_SLOT(base, 9)) 148 149 #define pg_mod_autoinit \ 150 (*(int (*)(const char *)) \ 151 PYGAMEAPI_GET_SLOT(base, 10)) 152 153 #define pg_mod_autoquit \ 154 (*(void (*)(const char *)) \ 155 PYGAMEAPI_GET_SLOT(base, 11)) 156 157 #define pg_RGBAFromObj \ 158 (*(int (*)(PyObject *, Uint8 *)) \ 159 PYGAMEAPI_GET_SLOT(base, 12)) 160 161 #define pgBuffer_AsArrayInterface \ 162 (*(PyObject * (*)(Py_buffer *)) \ 163 PYGAMEAPI_GET_SLOT(base, 13)) 164 165 #define pgBuffer_AsArrayStruct \ 166 (*(PyObject * (*)(Py_buffer *)) \ 167 PYGAMEAPI_GET_SLOT(base, 14)) 168 169 #define pgObject_GetBuffer \ 170 (*(int (*)(PyObject *, pg_buffer *, int)) \ 171 PYGAMEAPI_GET_SLOT(base, 15)) 172 173 #define pgBuffer_Release \ 174 (*(void (*)(pg_buffer *)) \ 175 PYGAMEAPI_GET_SLOT(base, 16)) 176 177 #define pgDict_AsBuffer \ 178 (*(int (*)(pg_buffer *, PyObject *, int)) \ 179 PYGAMEAPI_GET_SLOT(base, 17)) 180 181 #define pgExc_BufferError \ 182 ((PyObject *) \ 183 PYGAMEAPI_GET_SLOT(base, 18)) 184 185 #if PG_API_VERSION == 2 186 #define pg_GetDefaultWindow \ 187 (*(SDL_Window * (*)(void)) \ 188 PYGAMEAPI_GET_SLOT(base, 19)) 189 190 #define pg_SetDefaultWindow \ 191 (*(void (*)(SDL_Window *)) \ 192 PYGAMEAPI_GET_SLOT(base, 20)) 193 194 #define pg_GetDefaultWindowSurface \ 195 (*(pgSurfaceObject * (*)(void)) \ 196 PYGAMEAPI_GET_SLOT(base, 21)) 197 198 #define pg_SetDefaultWindowSurface \ 199 (*(void (*)(pgSurfaceObject *)) \ 200 PYGAMEAPI_GET_SLOT(base, 22)) 201 202 #define pg_EnvShouldBlendAlphaSDL2 \ 203 (*(char * (*)(void)) \ 204 PYGAMEAPI_GET_SLOT(base, 23)) 205 206 #endif /* PG_API_VERSION == 2 */ 207 208 #define import_pygame_base() IMPORT_PYGAME_MODULE(base) 209 #endif /* ~PYGAMEAPI_BASE_INTERNAL */ 210 211 /* 212 * RECT module 213 */ 214 #if !defined(SDL_VERSION_ATLEAST) || PG_API_VERSION == 1 215 typedef struct { 216 int x, y; 217 int w, h; 218 } GAME_Rect; 219 #else /* SDL 2+ */ 220 typedef SDL_Rect GAME_Rect; 221 #endif /* SDL 2+ */ 222 223 typedef struct { 224 PyObject_HEAD GAME_Rect r; 225 PyObject *weakreflist; 226 } pgRectObject; 227 228 #define pgRect_AsRect(x) (((pgRectObject *)x)->r) 229 #ifndef PYGAMEAPI_RECT_INTERNAL 230 #define pgRect_Type \ 231 (*(PyTypeObject *) \ 232 PYGAMEAPI_GET_SLOT(rect, 0)) 233 234 #define pgRect_Check(x) \ 235 ((x)->ob_type == &pgRect_Type) 236 #define pgRect_New \ 237 (*(PyObject * (*)(SDL_Rect *)) \ 238 PYGAMEAPI_GET_SLOT(rect, 1)) 239 240 #define pgRect_New4 \ 241 (*(PyObject * (*)(int, int, int, int)) \ 242 PYGAMEAPI_GET_SLOT(rect, 2)) 243 244 #define pgRect_FromObject \ 245 (*(GAME_Rect * (*)(PyObject *, GAME_Rect *)) \ 246 PYGAMEAPI_GET_SLOT(rect, 3)) 247 248 #define pgRect_Normalize (*(void (*)(GAME_Rect *)) PYGAMEAPI_GET_SLOT(rect, 4)) 249 250 #define import_pygame_rect() IMPORT_PYGAME_MODULE(rect) 251 #endif /* ~PYGAMEAPI_RECT_INTERNAL */ 252 253 /* 254 * CDROM module 255 */ 256 257 typedef struct { 258 PyObject_HEAD int id; 259 } pgCDObject; 260 261 #define pgCD_AsID(x) (((pgCDObject *)x)->id) 262 #ifndef PYGAMEAPI_CDROM_INTERNAL 263 #define pgCD_Type \ 264 (*(PyTypeObject *) \ 265 PYGAMEAPI_GET_SLOT(cdrom, 0)) 266 267 #define pgCD_Check(x) \ 268 ((x)->ob_type == &pgCD_Type) 269 #define pgCD_New \ 270 (*(PyObject * (*)(int)) \ 271 PYGAMEAPI_GET_SLOT(cdrom, 1)) 272 273 #define import_pygame_cd() IMPORT_PYGAME_MODULE(cdrom) 274 #endif 275 276 /* 277 * JOYSTICK module 278 */ 279 typedef struct pgJoystickObject { 280 PyObject_HEAD 281 int id; 282 SDL_Joystick *joy; 283 284 /* Joysticks form an intrusive linked list. 285 * 286 * Note that we don't maintain refcounts for these so they are weakrefs from 287 * the Python side. 288 */ 289 struct pgJoystickObject *next; 290 struct pgJoystickObject *prev; 291 } pgJoystickObject; 292 293 #define pgJoystick_AsID(x) (((pgJoystickObject *)x)->id) 294 #define pgJoystick_AsSDL(x) (((pgJoystickObject *)x)->joy) 295 296 #ifndef PYGAMEAPI_JOYSTICK_INTERNAL 297 #define pgJoystick_Type \ 298 (*(PyTypeObject *) \ 299 PYGAMEAPI_GET_SLOT(joystick, 0)) 300 301 #define pgJoystick_Check(x) \ 302 ((x)->ob_type == &pgJoystick_Type) 303 #define pgJoystick_New \ 304 (*(PyObject * (*)(int)) \ 305 PYGAMEAPI_GET_SLOT(joystick, 1)) 306 307 #define import_pygame_joystick() IMPORT_PYGAME_MODULE(joystick) 308 #endif 309 310 /* 311 * DISPLAY module 312 */ 313 314 #if defined(SDL_VERSION_ATLEAST) 315 316 #if PG_API_VERSION == 2 317 typedef struct { 318 Uint32 hw_available:1; 319 Uint32 wm_available:1; 320 Uint32 blit_hw:1; 321 Uint32 blit_hw_CC:1; 322 Uint32 blit_hw_A:1; 323 Uint32 blit_sw:1; 324 Uint32 blit_sw_CC:1; 325 Uint32 blit_sw_A:1; 326 Uint32 blit_fill:1; 327 Uint32 video_mem; 328 SDL_PixelFormat *vfmt; 329 SDL_PixelFormat vfmt_data; 330 int current_w; 331 int current_h; 332 } pg_VideoInfo; 333 #endif /* PG_API_VERSION == 2 */ 334 335 typedef struct { 336 #if PG_API_VERSION == 1 337 PyObject_HEAD SDL_VideoInfo info; 338 #else 339 PyObject_HEAD pg_VideoInfo info; 340 #endif 341 } pgVidInfoObject; 342 343 #define pgVidInfo_AsVidInfo(x) (((pgVidInfoObject *)x)->info) 344 #endif /* defined(SDL_VERSION_ATLEAST) */ 345 346 #ifndef PYGAMEAPI_DISPLAY_INTERNAL 347 #define pgVidInfo_Type \ 348 (*(PyTypeObject *) \ 349 PYGAMEAPI_GET_SLOT(display, 0)) 350 351 #define pgVidInfo_Check(x) \ 352 ((x)->ob_type == &pgVidInfo_Type) 353 354 #if PG_API_VERSION == 1 355 #define pgVidInfo_New \ 356 (*(PyObject * (*)(SDL_VideoInfo *)) \ 357 PYGAMEAPI_GET_SLOT(display, 1)) 358 #else 359 #define pgVidInfo_New \ 360 (*(PyObject * (*)(pg_VideoInfo *)) \ 361 PYGAMEAPI_GET_SLOT(display, 1)) 362 #endif 363 364 #define import_pygame_display() IMPORT_PYGAME_MODULE(display) 365 #endif /* ~PYGAMEAPI_DISPLAY_INTERNAL */ 366 367 /* 368 * SURFACE module 369 */ 370 struct pgSubSurface_Data; 371 struct SDL_Surface; 372 373 typedef struct { 374 PyObject_HEAD struct SDL_Surface *surf; 375 #if PG_API_VERSION == 2 376 int owner; 377 #endif /* PG_API_VERSION == 2 */ 378 struct pgSubSurface_Data *subsurface; /* ptr to subsurface data (if a 379 * subsurface)*/ 380 PyObject *weakreflist; 381 PyObject *locklist; 382 PyObject *dependency; 383 } pgSurfaceObject; 384 #define pgSurface_AsSurface(x) (((pgSurfaceObject *)x)->surf) 385 386 #ifndef PYGAMEAPI_SURFACE_INTERNAL 387 #define pgSurface_Type \ 388 (*(PyTypeObject *) \ 389 PYGAMEAPI_GET_SLOT(surface, 0)) 390 391 #define pgSurface_Check(x) \ 392 (PyObject_IsInstance((x), (PyObject *) &pgSurface_Type)) 393 #if PG_API_VERSION == 1 394 #define pgSurface_New \ 395 (*(pgSurfaceObject * (*)(SDL_Surface *)) \ 396 PYGAMEAPI_GET_SLOT(surface, 1)) 397 398 #define pgSurface_SetSurface \ 399 (*(int (*)(pgSurfaceObject *, SDL_Surface *)) \ 400 PYGAMEAPI_GET_SLOT(surface, 3)) 401 402 #else /* PG_API_VERSION == 2 */ 403 #define pgSurface_New2 \ 404 (*(pgSurfaceObject * (*)(SDL_Surface *, int)) \ 405 PYGAMEAPI_GET_SLOT(surface, 1)) 406 407 #define pgSurface_SetSurface \ 408 (*(int (*)(pgSurfaceObject *, SDL_Surface *, int)) \ 409 PYGAMEAPI_GET_SLOT(surface, 3)) 410 411 #endif /* PG_API_VERSION == 2 */ 412 #define pgSurface_Blit \ 413 (*(int (*)(pgSurfaceObject *, pgSurfaceObject *, GAME_Rect *, GAME_Rect *, int)) \ 414 PYGAMEAPI_GET_SLOT(surface, 2)) 415 416 #define import_pygame_surface() \ 417 do { \ 418 IMPORT_PYGAME_MODULE(surface); \ 419 if (PyErr_Occurred() != NULL) \ 420 break; \ 421 IMPORT_PYGAME_MODULE(surflock); \ 422 } while (0) 423 424 #if PG_API_VERSION == 2 425 #define pgSurface_New(surface) pgSurface_New2((surface), 1) 426 #define pgSurface_NewNoOwn(surface) pgSurface_New2((surface), 0) 427 #endif /* PG_API_VERSION == 2 */ 428 429 #endif /* ~PYGAMEAPI_SURFACE_INTERNAL */ 430 431 /* 432 * SURFLOCK module 433 * auto imported/initialized by surface 434 */ 435 #ifndef PYGAMEAPI_SURFLOCK_INTERNAL 436 #define pgLifetimeLock_Type \ 437 (*(PyTypeObject *) \ 438 PYGAMEAPI_GET_SLOT(surflock, 0)) 439 440 #define pgLifetimeLock_Check(x) \ 441 ((x)->ob_type == &pgLifetimeLock_Type) 442 443 #define pgSurface_Prep(x) \ 444 if ((x)->subsurface) \ 445 (*(*(void (*)(pgSurfaceObject *)) \ 446 PYGAMEAPI_GET_SLOT(surflock, 1)))(x) 447 448 #define pgSurface_Unprep(x) \ 449 if ((x)->subsurface) \ 450 (*(*(void (*)(pgSurfaceObject *)) \ 451 PYGAMEAPI_GET_SLOT(surflock, 2)))(x) 452 453 #define pgSurface_Lock \ 454 (*(int (*)(pgSurfaceObject *)) \ 455 PYGAMEAPI_GET_SLOT(surflock, 3)) 456 457 #define pgSurface_Unlock \ 458 (*(int (*)(pgSurfaceObject *)) \ 459 PYGAMEAPI_GET_SLOT(surflock, 4)) 460 461 #define pgSurface_LockBy \ 462 (*(int (*)(pgSurfaceObject *, PyObject *)) \ 463 PYGAMEAPI_GET_SLOT(surflock, 5)) 464 465 #define pgSurface_UnlockBy \ 466 (*(int (*)(pgSurfaceObject *, PyObject *)) \ 467 PYGAMEAPI_GET_SLOT(surflock, 6)) 468 469 #define pgSurface_LockLifetime \ 470 (*(PyObject * (*)(PyObject *, PyObject *)) \ 471 PYGAMEAPI_GET_SLOT(surflock, 7)) 472 #endif 473 474 /* 475 * EVENT module 476 */ 477 typedef struct pgEventObject pgEventObject; 478 479 #ifndef PYGAMEAPI_EVENT_INTERNAL 480 #define pgEvent_Type \ 481 (*(PyTypeObject *) \ 482 PYGAMEAPI_GET_SLOT(event, 0)) 483 484 #define pgEvent_Check(x) \ 485 ((x)->ob_type == &pgEvent_Type) 486 487 #define pgEvent_New \ 488 (*(PyObject * (*)(SDL_Event *)) \ 489 PYGAMEAPI_GET_SLOT(event, 1)) 490 491 #define pgEvent_New2 \ 492 (*(PyObject * (*)(int, PyObject *)) \ 493 PYGAMEAPI_GET_SLOT(event, 2)) 494 495 #define pgEvent_FillUserEvent \ 496 (*(int (*)(pgEventObject *, SDL_Event *)) \ 497 PYGAMEAPI_GET_SLOT(event, 3)) 498 499 #if PG_API_VERSION == 2 500 #define pg_EnableKeyRepeat \ 501 (*(int (*)(int, int)) \ 502 PYGAMEAPI_GET_SLOT(event, 4)) 503 504 #define pg_GetKeyRepeat \ 505 (*(void (*)(int *, int *)) \ 506 PYGAMEAPI_GET_SLOT(event, 5)) 507 #endif /* PG_API_VERSION == 2 */ 508 509 #define import_pygame_event() IMPORT_PYGAME_MODULE(event) 510 #endif 511 512 /* 513 * RWOBJECT module 514 * the rwobject are only needed for C side work, not accessable from python. 515 */ 516 #ifndef PYGAMEAPI_RWOBJECT_INTERNAL 517 #define pgRWops_FromObject \ 518 (*(SDL_RWops * (*)(PyObject *)) \ 519 PYGAMEAPI_GET_SLOT(rwobject, 0)) 520 521 #define pgRWops_IsFileObject \ 522 (*(int (*)(SDL_RWops *)) \ 523 PYGAMEAPI_GET_SLOT(rwobject, 1)) 524 525 #define pg_EncodeFilePath \ 526 (*(PyObject * (*)(PyObject *, PyObject *)) \ 527 PYGAMEAPI_GET_SLOT(rwobject, 2)) 528 529 #define pg_EncodeString \ 530 (*(PyObject * (*)(PyObject *, const char *, const char *, PyObject *)) \ 531 PYGAMEAPI_GET_SLOT(rwobject, 3)) 532 533 #define pgRWops_FromFileObject \ 534 (*(SDL_RWops * (*)(PyObject *)) \ 535 PYGAMEAPI_GET_SLOT(rwobject, 4)) 536 537 #define pgRWops_ReleaseObject \ 538 (*(int (*)(SDL_RWops *)) \ 539 PYGAMEAPI_GET_SLOT(rwobject, 5)) 540 541 #define pgRWops_GetFileExtension \ 542 (*(char * (*)(SDL_RWops *)) \ 543 PYGAMEAPI_GET_SLOT(rwobject, 6)) 544 545 #define import_pygame_rwobject() IMPORT_PYGAME_MODULE(rwobject) 546 547 #endif 548 549 /* 550 * PixelArray module 551 */ 552 #ifndef PYGAMEAPI_PIXELARRAY_INTERNAL 553 #define PyPixelArray_Type \ 554 ((PyTypeObject *) \ 555 PYGAMEAPI_GET_SLOT(pixelarray, 0)) 556 557 #define PyPixelArray_Check(x) \ 558 ((x)->ob_type == &PyPixelArray_Type) 559 #define PyPixelArray_New \ 560 (*(PyObject * (*)) \ 561 PYGAMEAPI_GET_SLOT(pixelarray, 1)) 562 563 #define import_pygame_pixelarray() IMPORT_PYGAME_MODULE(pixelarray) 564 #endif /* PYGAMEAPI_PIXELARRAY_INTERNAL */ 565 566 /* 567 * Color module 568 */ 569 typedef struct pgColorObject pgColorObject; 570 571 #ifndef PYGAMEAPI_COLOR_INTERNAL 572 #define pgColor_Type (*(PyObject *) \ 573 PYGAMEAPI_GET_SLOT(color, 0)) 574 575 #define pgColor_Check(x) \ 576 ((x)->ob_type == &pgColor_Type) 577 #define pgColor_New \ 578 (*(PyObject * (*)(Uint8 *)) \ 579 PYGAMEAPI_GET_SLOT(color, 1)) 580 581 #define pgColor_NewLength \ 582 (*(PyObject * (*)(Uint8 *, Uint8)) \ 583 PYGAMEAPI_GET_SLOT(color, 3)) 584 585 #define pg_RGBAFromColorObj \ 586 (*(int (*)(PyObject *, Uint8 *)) \ 587 PYGAMEAPI_GET_SLOT(color, 2)) 588 589 #define pg_RGBAFromFuzzyColorObj \ 590 (*(int (*)(PyObject *, Uint8 *)) \ 591 PYGAMEAPI_GET_SLOT(color, 4)) 592 593 #define pgColor_AsArray(x) (((pgColorObject *)x)->data) 594 #define pgColor_NumComponents(x) (((pgColorObject *)x)->len) 595 596 597 #define import_pygame_color() IMPORT_PYGAME_MODULE(color) 598 #endif /* PYGAMEAPI_COLOR_INTERNAL */ 599 600 /* 601 * Math module 602 */ 603 #ifndef PYGAMEAPI_MATH_INTERNAL 604 #define pgVector2_Check(x) \ 605 ((x)->ob_type == (PyTypeObject *) \ 606 PYGAMEAPI_GET_SLOT(math, 0)) 607 608 #define pgVector3_Check(x) \ 609 ((x)->ob_type == (PyTypeObject *) \ 610 PYGAMEAPI_GET_SLOT(math, 1)) 611 /* 612 #define pgVector2_New \ 613 (*(PyObject*(*)) \ 614 PYGAMEAPI_GET_SLOT(PyGAME_C_API, 1)) 615 */ 616 #define import_pygame_math() IMPORT_PYGAME_MODULE(math) 617 #endif /* PYGAMEAPI_MATH_INTERNAL */ 618 619 #define IMPORT_PYGAME_MODULE _IMPORT_PYGAME_MODULE 620 621 /* 622 * base pygame API slots 623 * disable slots with NO_PYGAME_C_API 624 */ 625 #ifdef PYGAME_H 626 PYGAMEAPI_DEFINE_SLOTS(base); 627 PYGAMEAPI_DEFINE_SLOTS(rect); 628 PYGAMEAPI_DEFINE_SLOTS(cdrom); 629 PYGAMEAPI_DEFINE_SLOTS(joystick); 630 PYGAMEAPI_DEFINE_SLOTS(display); 631 PYGAMEAPI_DEFINE_SLOTS(surface); 632 PYGAMEAPI_DEFINE_SLOTS(surflock); 633 PYGAMEAPI_DEFINE_SLOTS(event); 634 PYGAMEAPI_DEFINE_SLOTS(rwobject); 635 PYGAMEAPI_DEFINE_SLOTS(pixelarray); 636 PYGAMEAPI_DEFINE_SLOTS(color); 637 PYGAMEAPI_DEFINE_SLOTS(math); 638 #else /* ~PYGAME_H */ 639 PYGAMEAPI_EXTERN_SLOTS(base); 640 PYGAMEAPI_EXTERN_SLOTS(rect); 641 PYGAMEAPI_EXTERN_SLOTS(cdrom); 642 PYGAMEAPI_EXTERN_SLOTS(joystick); 643 PYGAMEAPI_EXTERN_SLOTS(display); 644 PYGAMEAPI_EXTERN_SLOTS(surface); 645 PYGAMEAPI_EXTERN_SLOTS(surflock); 646 PYGAMEAPI_EXTERN_SLOTS(event); 647 PYGAMEAPI_EXTERN_SLOTS(rwobject); 648 PYGAMEAPI_EXTERN_SLOTS(pixelarray); 649 PYGAMEAPI_EXTERN_SLOTS(color); 650 PYGAMEAPI_EXTERN_SLOTS(math); 651 #endif /* ~PYGAME_H */ 652 653 #endif /* PYGAME_H */ 654