/src/Core/objects/Rect.xs

http://github.com/PerlGameDev/SDL · Unknown · 83 lines · 69 code · 14 blank · 0 comment · 0 complexity · 60894e7b1e54859b67e7b27a90655dac MD5 · raw file

  1. #include "EXTERN.h"
  2. #include "perl.h"
  3. #include "XSUB.h"
  4. #include "ppport.h"
  5. #include "helper.h"
  6. #ifndef aTHX_
  7. #define aTHX_
  8. #endif
  9. #include <SDL.h>
  10. MODULE = SDL::Rect PACKAGE = SDL::Rect PREFIX = rect_
  11. =for documentation
  12. SDL_Rect -- Defines a rectangular area
  13. typedef struct{
  14. Sint16 x, y;
  15. Uint16 w, h;
  16. } SDL_Rect;
  17. =cut
  18. SDL_Rect *
  19. rect_new (CLASS, x, y, w, h)
  20. char* CLASS
  21. Sint16 x
  22. Sint16 y
  23. Uint16 w
  24. Uint16 h
  25. CODE:
  26. RETVAL = (SDL_Rect *) safemalloc (sizeof(SDL_Rect));
  27. RETVAL->x = x;
  28. RETVAL->y = y;
  29. RETVAL->w = w;
  30. RETVAL->h = h;
  31. OUTPUT:
  32. RETVAL
  33. Sint16
  34. rect_x ( rect, ... )
  35. SDL_Rect *rect
  36. CODE:
  37. if (items > 1 ) rect->x = SvIV(ST(1));
  38. RETVAL = rect->x;
  39. OUTPUT:
  40. RETVAL
  41. Sint16
  42. rect_y ( rect, ... )
  43. SDL_Rect *rect
  44. CODE:
  45. if (items > 1 ) rect->y = SvIV(ST(1));
  46. RETVAL = rect->y;
  47. OUTPUT:
  48. RETVAL
  49. Uint16
  50. rect_w ( rect, ... )
  51. SDL_Rect *rect
  52. CODE:
  53. if (items > 1 ) rect->w = SvIV(ST(1));
  54. RETVAL = rect->w;
  55. OUTPUT:
  56. RETVAL
  57. Uint16
  58. rect_h ( rect, ... )
  59. SDL_Rect *rect
  60. CODE:
  61. if (items > 1 ) rect->h = SvIV(ST(1));
  62. RETVAL = rect->h;
  63. OUTPUT:
  64. RETVAL
  65. void
  66. rect_DESTROY(bag)
  67. SV *bag
  68. CODE:
  69. objDESTROY(bag, safefree);