From fcda4004a2f68cce5ff80f8953bec2f1159e7ed8 Mon Sep 17 00:00:00 2001 From: Manuel 'Kea' Baldassarri Date: Tue, 16 Jun 2020 18:19:40 +0200 Subject: [PATCH 01/55] Fix parameters passed by reference in rect module and fix related tests (#41) --- src/rect.c | 8 ++++---- tests/006-rect.phpt | 26 ++++++++++++++++++-------- tests/007-rect-oo.phpt | 22 +++++++++++++++------- 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/src/rect.c b/src/rect.c index 4e303e8..186ffe8 100644 --- a/src/rect.c +++ b/src/rect.c @@ -270,7 +270,7 @@ PHP_FUNCTION(SDL_IntersectRect) zval *obj1, *obj2, *result; SDL_Rect rect1, rect2, rect3; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) { return; } zval_to_sdl_rect(obj1, &rect1); @@ -296,7 +296,7 @@ PHP_FUNCTION(SDL_UnionRect) zval *obj1, *obj2, *result; SDL_Rect rect1, rect2, rect3; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) { return; } zval_to_sdl_rect(obj1, &rect1); @@ -328,7 +328,7 @@ PHP_FUNCTION(SDL_EnclosePoints) SDL_Rect clip, result; SDL_Point *points; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) { return; } RETVAL_FALSE; @@ -381,7 +381,7 @@ PHP_FUNCTION(SDL_IntersectRectAndLine) SDL_Rect rect; int x1, y1, x2, y2; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzzz", &object, php_sdl_rect_ce, &z_x1, &z_y1, &z_x2, &z_y2) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/z/", &object, php_sdl_rect_ce, &z_x1, &z_y1, &z_x2, &z_y2) == FAILURE) { return; } zval_to_sdl_rect(object, &rect); diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt index 151113a..424bde8 100644 --- a/tests/006-rect.phpt +++ b/tests/006-rect.phpt @@ -3,8 +3,6 @@ rect group test, procedural mode --SKIPIF-- --FILE-- int(0) ["y"]=> @@ -76,10 +74,12 @@ object(SDL_Rect)#1 (4) { int(0) ["h"]=> int(0) + ["clip_rect"]=> + NULL } bool(true) +++ Empty (false) -object(SDL_Rect)#2 (4) { +object(SDL_Rect)#2 (5) { ["x"]=> int(1) ["y"]=> @@ -88,6 +88,8 @@ object(SDL_Rect)#2 (4) { int(3) ["h"]=> int(4) + ["clip_rect"]=> + NULL } bool(false) +++ Equal (true) @@ -99,7 +101,7 @@ bool(false) +++ Inter (true) bool(true) bool(true) -object(SDL_Rect)#6 (4) { +object(SDL_Rect)#6 (5) { ["x"]=> int(16) ["y"]=> @@ -108,6 +110,8 @@ object(SDL_Rect)#6 (4) { int(14) ["h"]=> int(13) + ["clip_rect"]=> + NULL } +++ Inter (false) bool(false) @@ -115,7 +119,7 @@ bool(false) NULL +++ Union NULL -object(SDL_Rect)#6 (4) { +object(SDL_Rect)#6 (5) { ["x"]=> int(10) ["y"]=> @@ -124,9 +128,11 @@ object(SDL_Rect)#6 (4) { int(28) ["h"]=> int(31) + ["clip_rect"]=> + NULL } NULL -object(SDL_Rect)#%d (4) { +object(SDL_Rect)#%d (5) { ["x"]=> int(10) ["y"]=> @@ -135,6 +141,8 @@ object(SDL_Rect)#%d (4) { int(110) ["h"]=> int(20) + ["clip_rect"]=> + NULL } +++ InterLine bool(true) @@ -146,7 +154,7 @@ bool(false) +++ EnclosePoints string(67) "SDL_Point(20,14) SDL_Point(13,20) SDL_Point(24,20) SDL_Point(20,28)" bool(true) -object(SDL_Rect)#%d (4) { +object(SDL_Rect)#%d (5) { ["x"]=> int(13) ["y"]=> @@ -155,6 +163,8 @@ object(SDL_Rect)#%d (4) { int(12) ["h"]=> int(15) + ["clip_rect"]=> + NULL } Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect.php on line %d diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt index 61e60b8..ad1d6cc 100644 --- a/tests/007-rect-oo.phpt +++ b/tests/007-rect-oo.phpt @@ -3,8 +3,6 @@ rect group test, object mode --SKIPIF-- --FILE-- IntersectLine($x1, $y1, $x2, $y2)); Done --EXPECTF-- +++ Empty (true) -object(SDL_Rect)#1 (4) { +object(SDL_Rect)#1 (5) { ["x"]=> int(0) ["y"]=> @@ -64,11 +62,13 @@ object(SDL_Rect)#1 (4) { int(0) ["h"]=> int(0) + ["clip_rect"]=> + NULL } string(17) "SDL_Rect(0,0,0,0)" bool(true) +++ Empty (false) -object(SDL_Rect)#2 (4) { +object(SDL_Rect)#2 (5) { ["x"]=> int(1) ["y"]=> @@ -77,6 +77,8 @@ object(SDL_Rect)#2 (4) { int(3) ["h"]=> int(4) + ["clip_rect"]=> + NULL } string(17) "SDL_Rect(1,2,3,4)" bool(false) @@ -89,7 +91,7 @@ bool(false) +++ Inter (true) bool(true) bool(true) -object(SDL_Rect)#6 (4) { +object(SDL_Rect)#6 (5) { ["x"]=> int(16) ["y"]=> @@ -98,6 +100,8 @@ object(SDL_Rect)#6 (4) { int(14) ["h"]=> int(13) + ["clip_rect"]=> + NULL } +++ Inter (false) bool(false) @@ -105,7 +109,7 @@ bool(false) NULL +++ Uninon NULL -object(SDL_Rect)#6 (4) { +object(SDL_Rect)#6 (5) { ["x"]=> int(10) ["y"]=> @@ -114,9 +118,11 @@ object(SDL_Rect)#6 (4) { int(28) ["h"]=> int(31) + ["clip_rect"]=> + NULL } NULL -object(SDL_Rect)#6 (4) { +object(SDL_Rect)#6 (5) { ["x"]=> int(10) ["y"]=> @@ -125,6 +131,8 @@ object(SDL_Rect)#6 (4) { int(110) ["h"]=> int(20) + ["clip_rect"]=> + NULL } +++ InterLine bool(true) From 413550b080521080ababceaba8ea727bd728f410 Mon Sep 17 00:00:00 2001 From: Manuel 'Kea' Baldassarri Date: Tue, 16 Jun 2020 21:52:12 +0200 Subject: [PATCH 02/55] Finish to port SDL_Palette and SDL_PixelFormat to Php7 (#42) * Fix pixel module params by ref * Re-enable and port to PHP7 read/get/write property of SDL_Palette * Re-enable and port to PHP7 read/get/write property of SDL_PixelFormat * Fix SDL_VERSION param pass by reference * Re-enable and port to PHP7 read/get/write property of SDL_Pixels * Add missing return value * Replace some spaces with tab --- src/pixels.c | 474 ++++++++++++++++++++++++++++------ src/version.c | 2 +- tests/009-color.phpt | 2 - tests/010-palette.phpt | 2 - tests/011-palette-oo.phpt | 2 - tests/012-pixelformat.phpt | 6 +- tests/013-pixelformat-oo.phpt | 6 +- tests/014-version.phpt | 4 +- tests/022-pixels.phpt | 2 - 9 files changed, 407 insertions(+), 93 deletions(-) diff --git a/src/pixels.c b/src/pixels.c index e6e0797..f954abe 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -30,9 +30,9 @@ struct php_sdl_color { static zend_class_entry *php_sdl_palette_ce; static zend_object_handlers php_sdl_palette_handlers; struct php_sdl_palette { - zend_object zo; SDL_Palette *palette; Uint32 flags; + zend_object zo; }; static zend_class_entry *php_sdl_pixelformat_ce; @@ -46,9 +46,9 @@ struct php_sdl_pixelformat { static zend_class_entry *php_sdl_pixels_ce; static zend_object_handlers php_sdl_pixels_handlers; struct php_sdl_pixels { - zend_object zo; SDL_Pixels pixels; Uint32 flags; + zend_object zo; }; zend_class_entry *get_php_sdl_color_ce(void) @@ -71,27 +71,45 @@ zend_class_entry *get_php_sdl_pixels_ce(void) return php_sdl_pixels_ce; } +static inline struct php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) { + return (struct php_sdl_palette*)((char*)(obj) - XtOffsetOf(struct php_sdl_palette, zo)); +} + #define FETCH_PALETTE(__ptr, __id, __check) \ { \ - intern = (struct php_sdl_palette *)Z_OBJ_P(__id);\ - __ptr = intern->palette; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ + intern = PHP_SDL_PALETTE_P(__id);\ + __ptr = intern->palette; \ + if (__check && !__ptr) {\ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ + RETURN_FALSE;\ + }\ +} + +#define PHP_SDL_PALETTE_P(zv) php_sdl_palette_from_obj(Z_OBJ_P((zv))) + +static inline struct php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) { + return (struct php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixelformat, zo)); } #define FETCH_PIXELFORMAT(__ptr, __id, __check) \ { \ - zend_object* zox = Z_OBJ_P(__id);\ - intern = (struct php_sdl_pixelformat *)((char*)zox - zox->handlers->offset);\ - __ptr = intern->format; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ + intern = PHP_SDL_PIXELFORMAT_P(__id);\ + __ptr = intern->format; \ + if (__check && !__ptr) {\ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ + RETURN_FALSE;\ + }\ } +#define PHP_SDL_PIXELFORMAT_P(zv) php_sdl_pixelformat_from_obj(Z_OBJ_P((zv))) + +static inline struct php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) { + return (struct php_sdl_pixels*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixels, zo)); +} + +#define PHP_SDL_PIXELS_P(zv) php_sdl_pixels_from_obj(Z_OBJ_P((zv))) + + zend_bool sdl_color_to_zval(SDL_Color *color, zval *value) { if (color) { @@ -143,7 +161,7 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags) struct php_sdl_palette *intern; object_init_ex(z_val, php_sdl_palette_ce); - intern = (struct php_sdl_palette *)Z_OBJ_P(z_val); + intern = PHP_SDL_PALETTE_P(z_val); intern->palette = palette; intern->flags = flags; @@ -162,8 +180,7 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f struct php_sdl_pixelformat *intern; object_init_ex(z_val, php_sdl_pixelformat_ce); - zend_object *zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_pixelformat *)((char*)zo - zo->handlers->offset); + intern = PHP_SDL_PIXELFORMAT_P(z_val); intern->format = format; intern->flags = flags; @@ -182,7 +199,7 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags) struct php_sdl_pixels *intern; object_init_ex(z_val, php_sdl_pixels_ce); - intern = (struct php_sdl_pixels *)Z_OBJ_P(z_val); + intern = PHP_SDL_PIXELS_P(z_val); intern->pixels = *pixels; intern->flags = flags; @@ -199,8 +216,7 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val) if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) { struct php_sdl_pixelformat *intern; - zend_object *zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_pixelformat*)((char*)zo - zo->handlers->offset); + intern = PHP_SDL_PIXELFORMAT_P(z_val); return intern->format; } return NULL; @@ -213,7 +229,7 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val) if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) { struct php_sdl_pixels *intern; - intern = (struct php_sdl_pixels *)Z_OBJ_P(z_val); + intern = PHP_SDL_PIXELS_P(z_val); return &intern->pixels; } return NULL; @@ -226,7 +242,7 @@ SDL_Palette *zval_to_sdl_palette(zval *z_val) if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) { struct php_sdl_palette *intern; - intern = (struct php_sdl_palette *)Z_OBJ_P(z_val); + intern = PHP_SDL_PALETTE_P(z_val); return intern->palette; } return NULL; @@ -234,10 +250,10 @@ SDL_Palette *zval_to_sdl_palette(zval *z_val) /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Color__construct, 0, 0, 4) - ZEND_ARG_INFO(0, r) - ZEND_ARG_INFO(0, g) - ZEND_ARG_INFO(0, b) - ZEND_ARG_INFO(0, a) + ZEND_ARG_INFO(0, r) + ZEND_ARG_INFO(0, g) + ZEND_ARG_INFO(0, b) + ZEND_ARG_INFO(0, a) ZEND_END_ARG_INFO() /* {{{ proto SDL_Color::__construct(int r, int g, int b, int a) */ @@ -319,7 +335,7 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks) int bpp; Uint32 rmask, gmask, bmask, amask; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lzzzzz", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) { RETURN_FALSE; } if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask)) { @@ -391,7 +407,7 @@ static PHP_METHOD(SDL_PixelFormat, __construct) zend_long format; zend_error_handling error_handling; - intern = (struct php_sdl_pixelformat *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELFORMAT_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format)) { @@ -420,7 +436,7 @@ static PHP_METHOD(SDL_PixelFormat, __toString) return; } - intern = (struct php_sdl_pixelformat *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELFORMAT_P(getThis()); spprintf(&buf, 100, "SDL_PixelFormat(%s)", SDL_GetPixelFormatName(intern->format->format)); RETVAL_STRING(buf); } @@ -481,7 +497,7 @@ static PHP_METHOD(SDL_Palette, __construct) zend_long ncolors; zend_error_handling error_handling; - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) { @@ -510,7 +526,7 @@ static PHP_METHOD(SDL_Palette, __toString) return; } - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); spprintf(&buf, 100, "SDL_Palette(%d)", intern->palette ? intern->palette->ncolors : 0); RETVAL_STRING(buf); } @@ -522,7 +538,7 @@ static PHP_METHOD(SDL_Palette, count) { struct php_sdl_palette *intern; - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); if (zend_parse_parameters_none() == FAILURE) { return; } @@ -532,7 +548,7 @@ static PHP_METHOD(SDL_Palette, count) /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offset, 0, 0, 1) - ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetExists(int offset) */ @@ -541,7 +557,7 @@ PHP_METHOD(SDL_Palette, offsetExists) struct php_sdl_palette *intern; zend_long offset; - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { return; } @@ -558,7 +574,7 @@ PHP_METHOD(SDL_Palette, offsetGet) struct php_sdl_palette *intern; zend_long offset; - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { return; } @@ -577,7 +593,7 @@ PHP_METHOD(SDL_Palette, offsetUnset) zend_long offset; SDL_Color color; - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { return; } @@ -591,8 +607,8 @@ PHP_METHOD(SDL_Palette, offsetUnset) /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 0, 2) - ZEND_ARG_INFO(0, offset) - ZEND_ARG_INFO(0, color) + ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */ @@ -603,7 +619,7 @@ PHP_METHOD(SDL_Palette, offsetSet) zval *z_color; SDL_Color color; - intern = (struct php_sdl_palette *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PALETTE_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE) { return; } @@ -800,7 +816,7 @@ PHP_FUNCTION(SDL_GetRGB) Uint8 r, g, b; zend_long pix; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOzzz", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b) == FAILURE) { return; } FETCH_PIXELFORMAT(format, z_format, 1); @@ -816,10 +832,10 @@ PHP_FUNCTION(SDL_GetRGB) ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PixelFormat_GetRGB, 0, 0, 4) - ZEND_ARG_INFO(0, pixel) - ZEND_ARG_INFO(1, r) - ZEND_ARG_INFO(1, g) - ZEND_ARG_INFO(1, b) + ZEND_ARG_INFO(0, pixel) + ZEND_ARG_INFO(1, r) + ZEND_ARG_INFO(1, g) + ZEND_ARG_INFO(1, b) ZEND_END_ARG_INFO() /* {{{ proto int SDL_PixelFormat::GetRGB(int pixel, int &r, int &g, int &b) @@ -834,7 +850,7 @@ PHP_METHOD(SDL_PixelFormat, GetRGB) Uint8 r, g, b; zend_long pix; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olzzz", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b) == FAILURE) { return; } FETCH_PIXELFORMAT(format, z_format, 1); @@ -866,7 +882,7 @@ PHP_FUNCTION(SDL_GetRGBA) Uint8 r, g, b, a; zend_long pix; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOzzzz", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b, &z_a) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lOz/z/z/z/", &pix, &z_format, php_sdl_pixelformat_ce, &z_r, &z_g, &z_b, &z_a) == FAILURE) { return; } FETCH_PIXELFORMAT(format, z_format, 1); @@ -895,7 +911,7 @@ PHP_METHOD(SDL_PixelFormat, GetRGBA) Uint8 r, g, b, a; zend_long pix; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olzzzz", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b, &z_a) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olz/z/z/z/", &z_format, php_sdl_pixelformat_ce, &pix, &z_r, &z_g, &z_b, &z_a) == FAILURE) { return; } FETCH_PIXELFORMAT(format, z_format, 1); @@ -924,7 +940,7 @@ PHP_FUNCTION(SDL_CalculateGammaRamp) Uint16 ramp[256]; int i; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz", &gamma, &z_ramp) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "dz/", &gamma, &z_ramp) == FAILURE) { RETURN_FALSE; } SDL_CalculateGammaRamp((float)gamma, ramp); @@ -938,8 +954,8 @@ PHP_FUNCTION(SDL_CalculateGammaRamp) ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels__construct, 0, 0, 2) - ZEND_ARG_INFO(0, pitch) - ZEND_ARG_INFO(0, h) + ZEND_ARG_INFO(0, pitch) + ZEND_ARG_INFO(0, h) ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels::__construct(int pitch, int h) */ @@ -949,7 +965,7 @@ static PHP_METHOD(SDL_Pixels, __construct) zend_long pitch, h; zend_error_handling error_handling; - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &pitch, &h)) { @@ -983,7 +999,7 @@ static PHP_METHOD(SDL_Pixels, __toString) return; } - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); spprintf(&buf, 100, "SDL_Pixels(%d,%d)", intern->pixels.pitch, intern->pixels.h); RETVAL_STRING(buf); } @@ -995,7 +1011,7 @@ static PHP_METHOD(SDL_Pixels, count) { struct php_sdl_pixels *intern; - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); if (zend_parse_parameters_none() == FAILURE) { return; } @@ -1005,7 +1021,7 @@ static PHP_METHOD(SDL_Pixels, count) /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offset, 0, 0, 1) - ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, offset) ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetExists(int offset) */ @@ -1014,7 +1030,7 @@ PHP_METHOD(SDL_Pixels, offsetExists) struct php_sdl_pixels *intern; zend_long offset; - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { return; } @@ -1031,7 +1047,7 @@ PHP_METHOD(SDL_Pixels, offsetGet) struct php_sdl_pixels *intern; zend_long offset; - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { return; } @@ -1049,7 +1065,7 @@ PHP_METHOD(SDL_Pixels, offsetUnset) struct php_sdl_pixels *intern; zend_long offset; - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { return; } @@ -1062,8 +1078,8 @@ PHP_METHOD(SDL_Pixels, offsetUnset) /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 0, 2) - ZEND_ARG_INFO(0, offset) - ZEND_ARG_INFO(0, value) + ZEND_ARG_INFO(0, offset) + ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */ @@ -1072,7 +1088,7 @@ PHP_METHOD(SDL_Pixels, offsetSet) struct php_sdl_pixels *intern; zend_long offset, value; - intern = (struct php_sdl_pixels *)Z_OBJ_P(getThis()); + intern = PHP_SDL_PIXELS_P(getThis()); if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) { return; } @@ -1086,8 +1102,8 @@ PHP_METHOD(SDL_Pixels, offsetSet) ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) ZEND_END_ARG_INFO() /* {{{ proto int SDL_Pixels::GetByte(int x, int y) */ @@ -1100,7 +1116,7 @@ PHP_METHOD(SDL_Pixels, GetByte) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) { return; } - intern = (struct php_sdl_pixels *)Z_OBJ_P(z_pixels);\ + intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); @@ -1112,9 +1128,9 @@ PHP_METHOD(SDL_Pixels, GetByte) ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) - ZEND_ARG_INFO(0, byte) + ZEND_ARG_INFO(0, x) + ZEND_ARG_INFO(0, y) + ZEND_ARG_INFO(0, byte) ZEND_END_ARG_INFO() /* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */ @@ -1127,7 +1143,7 @@ PHP_METHOD(SDL_Pixels, SetByte) if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) { return; } - intern = (struct php_sdl_pixels *)Z_OBJ_P(z_pixels);\ + intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); @@ -1144,7 +1160,7 @@ PHP_METHOD(SDL_Pixels, SetByte) */ static void php_sdl_palette_free(zend_object *object) { - struct php_sdl_palette *intern = (struct php_sdl_palette *) object; + struct php_sdl_palette *intern = php_sdl_palette_from_obj(object); if (intern->palette) { if (!(intern->flags & SDL_DONTFREE)) { @@ -1162,7 +1178,7 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type) { struct php_sdl_palette *intern; - intern = ecalloc(1, sizeof(*intern)); + intern = ecalloc(1, sizeof(struct php_sdl_palette) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -1174,11 +1190,104 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type) } /* }}} */ +/* {{{ sdl_palette_read_property*/ +zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +{ + struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); + zval *retval, tmp_member; + + if (Z_TYPE_P(member) != IS_STRING) { + zend_string *_str = zval_try_get_string_func(member); + if (UNEXPECTED(!_str)) { + return &EG(uninitialized_zval); + } + ZVAL_STR(&tmp_member, _str); + member = &tmp_member; + cache_slot = NULL; + } + + if (!intern->palette) { + return zend_std_read_property(object, member, type, cache_slot, rv); + } + + retval = rv; + + if (!strcmp(Z_STRVAL_P(member), "ncolors")) { + ZVAL_LONG(retval, intern->palette->ncolors); + + } else if (!strcmp(Z_STRVAL_P(member), "version")) { + ZVAL_LONG(retval, intern->palette->version); + + } else if (!strcmp(Z_STRVAL_P(member), "refcount")) { + ZVAL_LONG(retval, intern->palette->refcount); + + } else if (!strcmp(Z_STRVAL_P(member), "colors")) { + int i; + zval z_color; + array_init(retval); + for (i=0 ; ipalette->ncolors ; i++) { + sdl_color_to_zval(&intern->palette->colors[i], &z_color ); + add_next_index_zval(retval, &z_color); + } + + } else { + retval = zend_std_read_property(object, member, type, cache_slot, rv); + if (member == &tmp_member) { + zval_ptr_dtor_str(&tmp_member); + } + return retval; + } + + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; +} +/* }}} */ + +#define SDL_PALETTE_ADD_PROPERTY(n,f) \ + ZVAL_LONG(&zv, f); \ + zend_hash_str_update(props, n, sizeof(n)-1, &zv); + +/* {{{ sdl_palette_get_properties*/ +static HashTable *sdl_palette_get_properties(zval *object) +{ + HashTable *props; + zval zv, z_color; + int i; + struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); + + props = zend_std_get_properties(object); + + if (intern->palette) { + SDL_PALETTE_ADD_PROPERTY("ncolors", intern->palette->ncolors); + SDL_PALETTE_ADD_PROPERTY("version", intern->palette->version); + SDL_PALETTE_ADD_PROPERTY("refcount", intern->palette->refcount); + + array_init(&zv); + for (i=0 ; ipalette->ncolors ; i++) { + sdl_color_to_zval(&intern->palette->colors[i], &z_color ); + add_next_index_zval(&zv, &z_color); + } + zend_hash_str_update(props, "colors", sizeof("colors")-1, &zv); + } + return props; +} +/* }}} */ + +/* {{{ sdl_palette_write_property */ +static zval *sdl_palette_write_property(zval *object, zval *member, zval *value, void **cache_slot) +{ + php_error_docref(NULL, E_ERROR, "Not supported, use SDL_SetPaletteColors() or SDL_Palette::SetColors()"); + return value; +} +/* }}} */ + /* {{{ php_sdl_pixelformat_free */ static void php_sdl_pixelformat_free(zend_object *object) { - struct php_sdl_pixelformat *intern = (struct php_sdl_pixelformat*)((char*)object - object->handlers->offset); + struct php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object); if (intern->format) { if (!(intern->flags & SDL_DONTFREE)) { @@ -1208,11 +1317,145 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type) } /* }}} */ +/* {{{ sdl_pixelformat_read_property*/ +zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +{ + struct php_sdl_pixelformat *intern; + zval *retval, tmp_member; + + intern = PHP_SDL_PIXELFORMAT_P(object); + + if (Z_TYPE_P(member) != IS_STRING) { + zend_string *_str = zval_try_get_string_func(member); + if (UNEXPECTED(!_str)) { + return &EG(uninitialized_zval); + } + ZVAL_STR(&tmp_member, _str); + member = &tmp_member; + cache_slot = NULL; + } + + if (!intern->format) { + return zend_std_read_property(object, member, type, cache_slot, rv); + } + + retval = rv; + + if (!strcmp(Z_STRVAL_P(member), "format")) { + ZVAL_LONG(retval, intern->format->format); + + } else if (!strcmp(Z_STRVAL_P(member), "BitsPerPixel")) { + ZVAL_LONG(retval, intern->format->BitsPerPixel); + + } else if (!strcmp(Z_STRVAL_P(member), "BytesPerPixel")) { + ZVAL_LONG(retval, intern->format->BytesPerPixel); + + } else if (!strcmp(Z_STRVAL_P(member), "Rmask")) { + ZVAL_LONG(retval, intern->format->Rmask); + + } else if (!strcmp(Z_STRVAL_P(member), "Gmask")) { + ZVAL_LONG(retval, intern->format->Gmask); + + } else if (!strcmp(Z_STRVAL_P(member), "Bmask")) { + ZVAL_LONG(retval, intern->format->Bmask); + + } else if (!strcmp(Z_STRVAL_P(member), "Amask")) { + ZVAL_LONG(retval, intern->format->Amask); + + } else if (!strcmp(Z_STRVAL_P(member), "Rloss")) { + ZVAL_LONG(retval, intern->format->Rloss); + + } else if (!strcmp(Z_STRVAL_P(member), "Gloss")) { + ZVAL_LONG(retval, intern->format->Gloss); + + } else if (!strcmp(Z_STRVAL_P(member), "Bloss")) { + ZVAL_LONG(retval, intern->format->Bloss); + + } else if (!strcmp(Z_STRVAL_P(member), "Aloss")) { + ZVAL_LONG(retval, intern->format->Aloss); + + } else if (!strcmp(Z_STRVAL_P(member), "Rshift")) { + ZVAL_LONG(retval, intern->format->Rshift); + + } else if (!strcmp(Z_STRVAL_P(member), "Gshift")) { + ZVAL_LONG(retval, intern->format->Gshift); + + } else if (!strcmp(Z_STRVAL_P(member), "Bshift")) { + ZVAL_LONG(retval, intern->format->Bshift); + + } else if (!strcmp(Z_STRVAL_P(member), "Ashift")) { + ZVAL_LONG(retval, intern->format->Ashift); + + } else if (!strcmp(Z_STRVAL_P(member), "palette")) { + sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE); + + } else { + retval = zend_std_read_property(object, member, type, cache_slot, rv); + if (member == &tmp_member) { + zval_ptr_dtor_str(&tmp_member); + } + return retval; + } + + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; +} +/* }}} */ + +#define SDL_PIXELFORMAT_ADD_PROPERTY(n,f) \ + ZVAL_LONG(&zv, f); \ + zend_hash_str_update(props, n, sizeof(n)-1, &zv); + +/* {{{ sdl_pixelformat_read_property*/ +static HashTable *sdl_pixelformat_get_properties(zval *object) +{ + HashTable *props; + zval zv; + struct php_sdl_pixelformat *intern; + + intern = PHP_SDL_PIXELFORMAT_P(object); + + props = zend_std_get_properties(object); + + if (intern->format) { + SDL_PIXELFORMAT_ADD_PROPERTY("format", intern->format->format); + SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel", intern->format->BitsPerPixel); + SDL_PIXELFORMAT_ADD_PROPERTY("BytesPerPixel", intern->format->BytesPerPixel); + SDL_PIXELFORMAT_ADD_PROPERTY("Rmask", intern->format->Rmask); + SDL_PIXELFORMAT_ADD_PROPERTY("Gmask", intern->format->Gmask); + SDL_PIXELFORMAT_ADD_PROPERTY("Bmask", intern->format->Bmask); + SDL_PIXELFORMAT_ADD_PROPERTY("Amask", intern->format->Amask); + SDL_PIXELFORMAT_ADD_PROPERTY("Rloss", intern->format->Rloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Gloss", intern->format->Gloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Bloss", intern->format->Bloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Aloss", intern->format->Aloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Rshift", intern->format->Rshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Rshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Rshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Rshift); + + sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE); + zend_hash_str_update(props, "palette", sizeof("palette")-1, &zv); + } + return props; +} +/* }}} */ + +/* {{{ sdl_pixelformat_write_property */ +static zval *sdl_pixelformat_write_property(zval *object, zval *member, zval *value, void **cache_slot) +{ + php_error_docref(NULL, E_ERROR, "Not supported, SDL_PixelFormat is read-only"); + return value; +} +/* }}} */ + /* {{{ php_sdl_pixels_free */ static void php_sdl_pixels_free(zend_object *object) { - struct php_sdl_pixels *intern = (struct php_sdl_pixels *) object; + struct php_sdl_pixels *intern = php_sdl_pixels_from_obj(object); if (intern->pixels.pixels) { if (!(intern->flags & SDL_DONTFREE)) { @@ -1230,7 +1473,7 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type) { struct php_sdl_pixels *intern; - intern = ecalloc(1, sizeof(*intern)); + intern = (struct php_sdl_pixels*)ecalloc(1, sizeof(struct php_sdl_pixels) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -1241,6 +1484,82 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type) } /* }}} */ +/* {{{ sdl_pixels_read_property*/ +zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +{ + struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); + zval *retval, tmp_member; + + if (Z_TYPE_P(member) != IS_STRING) { + zend_string *_str = zval_try_get_string_func(member); + if (UNEXPECTED(!_str)) { + return &EG(uninitialized_zval); + } + ZVAL_STR(&tmp_member, _str); + member = &tmp_member; + cache_slot = NULL; + } + + if (!intern->pixels.pixels) { + return zend_std_read_property(object, member, type, cache_slot, rv); + } + + retval = rv; + + if (!strcmp(Z_STRVAL_P(member), "h")) { + ZVAL_LONG(retval, intern->pixels.h); + + } else if (!strcmp(Z_STRVAL_P(member), "pitch")) { + ZVAL_LONG(retval, intern->pixels.pitch); + + } else if (!strcmp(Z_STRVAL_P(member), "count")) { + ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h); + + } else { + retval = zend_std_read_property(object, member, type, cache_slot, rv); + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; + } + + if (member == &tmp_member) { + zval_dtor(member); + } + return retval; +} +/* }}} */ + +#define SDL_PIXELS_ADD_PROPERTY(n,f) \ + ZVAL_LONG(&zv, f); \ + zend_hash_str_update(props, n, sizeof(n)-1, &zv); + +/* {{{ sdl_pixels_read_properties */ +static HashTable *sdl_pixels_get_properties(zval *object) +{ + HashTable *props; + zval zv; + struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); + + props = zend_std_get_properties(object); + + if (intern->pixels.pixels) { + SDL_PIXELS_ADD_PROPERTY("pitch", intern->pixels.pitch); + SDL_PIXELS_ADD_PROPERTY("h", intern->pixels.h); + SDL_PIXELS_ADD_PROPERTY("count", intern->pixels.h * intern->pixels.pitch); + } + return props; +} +/* }}} */ + +/* {{{ sdl_pixels_write_property */ +static zval *sdl_pixels_write_property(zval *object, zval *member, zval *value, void **cache_slot) +{ + php_error_docref(NULL, E_ERROR, "Not supported, SDL_Pixels is read-only"); + return value; +} +/* }}} */ + /* {{{ php_sdl_color_methods[] */ static const zend_function_entry php_sdl_color_methods[] = { PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) @@ -1331,6 +1650,9 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_palette_ce->create_object = php_sdl_palette_new; zend_class_implements(php_sdl_palette_ce, 1, zend_ce_arrayaccess); memcpy(&php_sdl_palette_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + php_sdl_palette_handlers.read_property = sdl_palette_read_property; + php_sdl_palette_handlers.get_properties = sdl_palette_get_properties; + php_sdl_palette_handlers.write_property = sdl_palette_write_property; php_sdl_palette_handlers.free_obj = php_sdl_palette_free; REGISTER_PALETTE_PROP("ncolors"); @@ -1342,6 +1664,9 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_pixelformat_ce = zend_register_internal_class(&ce_pixelformat); php_sdl_pixelformat_ce->create_object = php_sdl_pixelformat_new; memcpy(&php_sdl_pixelformat_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + php_sdl_pixelformat_handlers.read_property = sdl_pixelformat_read_property; + php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties; + php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property; php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free; php_sdl_pixelformat_handlers.offset = XtOffsetOf(struct php_sdl_pixelformat, zo); @@ -1367,6 +1692,9 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_pixels_ce->create_object = php_sdl_pixels_new; zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess); memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); + php_sdl_pixels_handlers.read_property = sdl_pixels_read_property; + php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties; + php_sdl_pixels_handlers.write_property = sdl_pixels_write_property; php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free; REGISTER_PIXELS_PROP("pitch"); diff --git a/src/version.c b/src/version.c index 55e8d07..69cea57 100644 --- a/src/version.c +++ b/src/version.c @@ -144,7 +144,7 @@ PHP_FUNCTION(SDL_VERSION) SDL_version version; zval *version_array; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &version_array) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "z/", &version_array) == FAILURE) { RETURN_FALSE; } SDL_VERSION(&version); diff --git a/tests/009-color.phpt b/tests/009-color.phpt index 12f99cf..3759648 100644 --- a/tests/009-color.phpt +++ b/tests/009-color.phpt @@ -3,8 +3,6 @@ SDL_Color test --SKIPIF-- --FILE-- --FILE-- --FILE-- --FILE-- - int(303039488) ["BitsPerPixel"]=> int(4) ["BytesPerPixel"]=> @@ -266,6 +262,8 @@ object(SDL_PixelFormat)#%d (16) { } } } + ["format"]=> + int(303039488) } = RGB int(8) diff --git a/tests/013-pixelformat-oo.phpt b/tests/013-pixelformat-oo.phpt index b9c6c08..200a057 100644 --- a/tests/013-pixelformat-oo.phpt +++ b/tests/013-pixelformat-oo.phpt @@ -3,8 +3,6 @@ SDL_PixelFormat test, object mode --SKIPIF-- --FILE-- - int(303039488) ["BitsPerPixel"]=> int(4) ["BytesPerPixel"]=> @@ -269,6 +265,8 @@ object(SDL_PixelFormat)#%d (16) { } } } + ["format"]=> + int(303039488) } = RGB int(8) diff --git a/tests/014-version.phpt b/tests/014-version.phpt index f671bc2..49981f6 100644 --- a/tests/014-version.phpt +++ b/tests/014-version.phpt @@ -3,8 +3,6 @@ SDL_version test suite --SKIPIF-- --INI-- error_reporting = 32767; --FILE-- @@ -26,7 +24,7 @@ SDL_VERSION($version); var_dump(array_key_exists('major', $version) && array_key_exists('minor', $version) && array_key_exists('patch', $version)); var_dump(12030 === SDL_VERSIONNUM(10,20,30)); var_dump(SDL_VERSION_ATLEAST(2,0,0)); -var_dump(SDL_VERSION_ATLEAST(2,0,5)); +var_dump(SDL_VERSION_ATLEAST(2,0,25)); var_dump(is_string(SDL_GetRevision())); var_dump(is_integer(SDL_GetRevisionNumber())); diff --git a/tests/022-pixels.phpt b/tests/022-pixels.phpt index da36f1b..25f0a88 100644 --- a/tests/022-pixels.phpt +++ b/tests/022-pixels.phpt @@ -3,8 +3,6 @@ SDL_Pixels test --SKIPIF-- --INI-- error_reporting = 32767; --FILE-- From b4ded1ed7b5f1348c8fc52c49d1add1ede9d94b8 Mon Sep 17 00:00:00 2001 From: Manuel 'Kea' Baldassarri Date: Fri, 19 Jun 2020 20:12:50 +0200 Subject: [PATCH 03/55] Fix surface props initialization and rect extra field (#43) * Fix SDL_surface wrong properties initialization, fix SDL_Palette and SDL_Pixel offset * Fix SDL_Point conversion from and to zval * Fix SDL_GetDisplayBounds return value and fix tests * Skip 005-video.phpt if run on travis because lack of Video --- src/pixels.c | 127 +++++++++++++++++----------------- src/rect.c | 14 ++-- src/surface.c | 6 +- src/video.c | 2 +- tests/005-video.phpt | 9 ++- tests/006-rect.phpt | 24 ++----- tests/007-rect-oo.phpt | 20 ++---- tests/012-pixelformat.phpt | 4 +- tests/013-pixelformat-oo.phpt | 4 +- tests/test-functions.php | 5 ++ 10 files changed, 97 insertions(+), 118 deletions(-) diff --git a/src/pixels.c b/src/pixels.c index f954abe..58f2b11 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -20,6 +20,7 @@ #include "pixels.h" #include "zend_interfaces.h" +#include "zend_operators.h" static zend_class_entry *php_sdl_color_ce; static zend_object_handlers php_sdl_color_handlers; @@ -29,27 +30,27 @@ struct php_sdl_color { static zend_class_entry *php_sdl_palette_ce; static zend_object_handlers php_sdl_palette_handlers; -struct php_sdl_palette { +typedef struct _php_sdl_palette { SDL_Palette *palette; Uint32 flags; zend_object zo; -}; +} php_sdl_palette; static zend_class_entry *php_sdl_pixelformat_ce; static zend_object_handlers php_sdl_pixelformat_handlers; -struct php_sdl_pixelformat { +typedef struct _php_sdl_pixelformat { SDL_PixelFormat *format; Uint32 flags; zend_object zo; -}; +} php_sdl_pixelformat; static zend_class_entry *php_sdl_pixels_ce; static zend_object_handlers php_sdl_pixels_handlers; -struct php_sdl_pixels { +typedef struct _php_sdl_pixels { SDL_Pixels pixels; Uint32 flags; zend_object zo; -}; +} php_sdl_pixels; zend_class_entry *get_php_sdl_color_ce(void) { @@ -71,8 +72,8 @@ zend_class_entry *get_php_sdl_pixels_ce(void) return php_sdl_pixels_ce; } -static inline struct php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) { - return (struct php_sdl_palette*)((char*)(obj) - XtOffsetOf(struct php_sdl_palette, zo)); +static inline php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) { + return (php_sdl_palette*)((char*)(obj) - XtOffsetOf(php_sdl_palette, zo)); } #define FETCH_PALETTE(__ptr, __id, __check) \ @@ -87,8 +88,8 @@ static inline struct php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) #define PHP_SDL_PALETTE_P(zv) php_sdl_palette_from_obj(Z_OBJ_P((zv))) -static inline struct php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) { - return (struct php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixelformat, zo)); +static inline php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) { + return (php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(php_sdl_pixelformat, zo)); } #define FETCH_PIXELFORMAT(__ptr, __id, __check) \ @@ -103,8 +104,8 @@ static inline struct php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_obje #define PHP_SDL_PIXELFORMAT_P(zv) php_sdl_pixelformat_from_obj(Z_OBJ_P((zv))) -static inline struct php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) { - return (struct php_sdl_pixels*)((char*)(obj) - XtOffsetOf(struct php_sdl_pixels, zo)); +static inline php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) { + return (php_sdl_pixels*)((char*)(obj) - XtOffsetOf(php_sdl_pixels, zo)); } #define PHP_SDL_PIXELS_P(zv) php_sdl_pixels_from_obj(Z_OBJ_P((zv))) @@ -158,7 +159,7 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color) zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags) { if (palette) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; object_init_ex(z_val, php_sdl_palette_ce); intern = PHP_SDL_PALETTE_P(z_val); @@ -177,7 +178,7 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags) zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 flags) { if (format) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; object_init_ex(z_val, php_sdl_pixelformat_ce); intern = PHP_SDL_PIXELFORMAT_P(z_val); @@ -196,7 +197,7 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags) { if (pixels) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; object_init_ex(z_val, php_sdl_pixels_ce); intern = PHP_SDL_PIXELS_P(z_val); @@ -214,7 +215,7 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags) SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val) { if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; intern = PHP_SDL_PIXELFORMAT_P(z_val); return intern->format; @@ -227,7 +228,7 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val) SDL_Pixels *zval_to_sdl_pixels(zval *z_val) { if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; intern = PHP_SDL_PIXELS_P(z_val); return &intern->pixels; @@ -240,7 +241,7 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val) SDL_Palette *zval_to_sdl_palette(zval *z_val) { if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; intern = PHP_SDL_PALETTE_P(z_val); return intern->palette; @@ -403,7 +404,7 @@ PHP_FUNCTION(SDL_AllocFormat) /* {{{ proto SDL_PixelFormat::__construct(format) */ static PHP_METHOD(SDL_PixelFormat, __construct) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zend_long format; zend_error_handling error_handling; @@ -429,7 +430,7 @@ static PHP_METHOD(SDL_PixelFormat, __construct) /* {{{ proto SDL_PixelFormat::__toString() */ static PHP_METHOD(SDL_PixelFormat, __toString) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; char *buf; if (zend_parse_parameters_none() == FAILURE) { @@ -450,7 +451,7 @@ static PHP_METHOD(SDL_PixelFormat, __toString) */ PHP_FUNCTION(SDL_FreeFormat) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *object; SDL_PixelFormat *format; @@ -493,7 +494,7 @@ PHP_FUNCTION(SDL_AllocPalette) /* {{{ proto SDL_Palette::__construct(ncolors) */ static PHP_METHOD(SDL_Palette, __construct) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zend_long ncolors; zend_error_handling error_handling; @@ -519,7 +520,7 @@ static PHP_METHOD(SDL_Palette, __construct) /* {{{ proto SDL_Palette::__toString() */ static PHP_METHOD(SDL_Palette, __toString) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; char *buf; if (zend_parse_parameters_none() == FAILURE) { @@ -536,7 +537,7 @@ static PHP_METHOD(SDL_Palette, __toString) /* {{{ proto SDL_Palette, count(void) */ static PHP_METHOD(SDL_Palette, count) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; intern = PHP_SDL_PALETTE_P(getThis()); if (zend_parse_parameters_none() == FAILURE) { @@ -554,7 +555,7 @@ ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetExists(int offset) */ PHP_METHOD(SDL_Palette, offsetExists) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zend_long offset; intern = PHP_SDL_PALETTE_P(getThis()); @@ -571,7 +572,7 @@ PHP_METHOD(SDL_Palette, offsetExists) /* {{{ proto SDL_Palette, offsetGet(int offset) */ PHP_METHOD(SDL_Palette, offsetGet) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zend_long offset; intern = PHP_SDL_PALETTE_P(getThis()); @@ -589,7 +590,7 @@ PHP_METHOD(SDL_Palette, offsetGet) /* {{{ proto SDL_Palette, offsetUnset(int offset) */ PHP_METHOD(SDL_Palette, offsetUnset) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zend_long offset; SDL_Color color; @@ -614,7 +615,7 @@ ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */ PHP_METHOD(SDL_Palette, offsetSet) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zend_long offset; zval *z_color; SDL_Color color; @@ -640,7 +641,7 @@ PHP_METHOD(SDL_Palette, offsetSet) */ PHP_FUNCTION(SDL_SetPixelFormatPalette) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zval *z_format, *z_palette; SDL_Palette *palette; SDL_PixelFormat *format; @@ -672,7 +673,7 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette) */ PHP_FUNCTION(SDL_SetPaletteColors) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zval *object, *z_colors, *z_color; SDL_Palette *palette; SDL_Color *colors; @@ -732,7 +733,7 @@ PHP_FUNCTION(SDL_SetPaletteColors) */ PHP_FUNCTION(SDL_FreePalette) { - struct php_sdl_palette *intern; + php_sdl_palette *intern; zval *object; SDL_Palette *palette; @@ -758,7 +759,7 @@ PHP_FUNCTION(SDL_FreePalette) */ PHP_FUNCTION(SDL_MapRGB) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *z_format; SDL_PixelFormat *format; zend_long r, g, b; @@ -785,7 +786,7 @@ PHP_FUNCTION(SDL_MapRGB) */ PHP_FUNCTION(SDL_MapRGBA) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *z_format; SDL_PixelFormat *format; zend_long r, g, b, a; @@ -810,7 +811,7 @@ PHP_FUNCTION(SDL_MapRGBA) */ PHP_FUNCTION(SDL_GetRGB) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *z_format, *z_r, *z_g, *z_b; SDL_PixelFormat *format; Uint8 r, g, b; @@ -844,7 +845,7 @@ ZEND_END_ARG_INFO() */ PHP_METHOD(SDL_PixelFormat, GetRGB) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *z_format, *z_r, *z_g, *z_b; SDL_PixelFormat *format; Uint8 r, g, b; @@ -876,7 +877,7 @@ PHP_METHOD(SDL_PixelFormat, GetRGB) */ PHP_FUNCTION(SDL_GetRGBA) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *z_format, *z_r, *z_g, *z_b, *z_a; SDL_PixelFormat *format; Uint8 r, g, b, a; @@ -905,7 +906,7 @@ PHP_FUNCTION(SDL_GetRGBA) */ PHP_METHOD(SDL_PixelFormat, GetRGBA) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *z_format, *z_r, *z_g, *z_b, *z_a; SDL_PixelFormat *format; Uint8 r, g, b, a; @@ -961,7 +962,7 @@ ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels::__construct(int pitch, int h) */ static PHP_METHOD(SDL_Pixels, __construct) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zend_long pitch, h; zend_error_handling error_handling; @@ -992,7 +993,7 @@ static PHP_METHOD(SDL_Pixels, __construct) /* {{{ proto SDL_Pixels::__toString() */ static PHP_METHOD(SDL_Pixels, __toString) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; char *buf; if (zend_parse_parameters_none() == FAILURE) { @@ -1009,7 +1010,7 @@ static PHP_METHOD(SDL_Pixels, __toString) /* {{{ proto SDL_Pixels, count(void) */ static PHP_METHOD(SDL_Pixels, count) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; intern = PHP_SDL_PIXELS_P(getThis()); if (zend_parse_parameters_none() == FAILURE) { @@ -1027,7 +1028,7 @@ ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetExists(int offset) */ PHP_METHOD(SDL_Pixels, offsetExists) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zend_long offset; intern = PHP_SDL_PIXELS_P(getThis()); @@ -1044,7 +1045,7 @@ PHP_METHOD(SDL_Pixels, offsetExists) /* {{{ proto SDL_Pixels, offsetGet(int offset) */ PHP_METHOD(SDL_Pixels, offsetGet) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zend_long offset; intern = PHP_SDL_PIXELS_P(getThis()); @@ -1062,7 +1063,7 @@ PHP_METHOD(SDL_Pixels, offsetGet) /* {{{ proto SDL_Pixels, offsetUnset(int offset) */ PHP_METHOD(SDL_Pixels, offsetUnset) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zend_long offset; intern = PHP_SDL_PIXELS_P(getThis()); @@ -1085,7 +1086,7 @@ ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */ PHP_METHOD(SDL_Pixels, offsetSet) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zend_long offset, value; intern = PHP_SDL_PIXELS_P(getThis()); @@ -1109,7 +1110,7 @@ ZEND_END_ARG_INFO() /* {{{ proto int SDL_Pixels::GetByte(int x, int y) */ PHP_METHOD(SDL_Pixels, GetByte) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zval *z_pixels; zend_long x, y; @@ -1136,7 +1137,7 @@ ZEND_END_ARG_INFO() /* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */ PHP_METHOD(SDL_Pixels, SetByte) { - struct php_sdl_pixels *intern; + php_sdl_pixels *intern; zval *z_pixels; zend_long x, y, v; @@ -1160,7 +1161,7 @@ PHP_METHOD(SDL_Pixels, SetByte) */ static void php_sdl_palette_free(zend_object *object) { - struct php_sdl_palette *intern = php_sdl_palette_from_obj(object); + php_sdl_palette *intern = php_sdl_palette_from_obj(object); if (intern->palette) { if (!(intern->flags & SDL_DONTFREE)) { @@ -1176,9 +1177,7 @@ static void php_sdl_palette_free(zend_object *object) */ static zend_object* php_sdl_palette_new(zend_class_entry *class_type) { - struct php_sdl_palette *intern; - - intern = ecalloc(1, sizeof(struct php_sdl_palette) + zend_object_properties_size(class_type)); + php_sdl_palette *intern = zend_object_alloc(sizeof(php_sdl_palette), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -1193,7 +1192,7 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type) /* {{{ sdl_palette_read_property*/ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) { - struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); + php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); zval *retval, tmp_member; if (Z_TYPE_P(member) != IS_STRING) { @@ -1255,7 +1254,7 @@ static HashTable *sdl_palette_get_properties(zval *object) HashTable *props; zval zv, z_color; int i; - struct php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); + php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); props = zend_std_get_properties(object); @@ -1287,7 +1286,7 @@ static zval *sdl_palette_write_property(zval *object, zval *member, zval *value, */ static void php_sdl_pixelformat_free(zend_object *object) { - struct php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object); + php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object); if (intern->format) { if (!(intern->flags & SDL_DONTFREE)) { @@ -1303,9 +1302,7 @@ static void php_sdl_pixelformat_free(zend_object *object) */ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type) { - struct php_sdl_pixelformat *intern; - - intern = (struct php_sdl_pixelformat*)ecalloc(1, sizeof(struct php_sdl_pixelformat) + zend_object_properties_size(class_type)); + php_sdl_pixelformat *intern = zend_object_alloc(sizeof(php_sdl_pixelformat), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -1320,7 +1317,7 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type) /* {{{ sdl_pixelformat_read_property*/ zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) { - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; zval *retval, tmp_member; intern = PHP_SDL_PIXELFORMAT_P(object); @@ -1413,7 +1410,7 @@ static HashTable *sdl_pixelformat_get_properties(zval *object) { HashTable *props; zval zv; - struct php_sdl_pixelformat *intern; + php_sdl_pixelformat *intern; intern = PHP_SDL_PIXELFORMAT_P(object); @@ -1455,7 +1452,7 @@ static zval *sdl_pixelformat_write_property(zval *object, zval *member, zval *va */ static void php_sdl_pixels_free(zend_object *object) { - struct php_sdl_pixels *intern = php_sdl_pixels_from_obj(object); + php_sdl_pixels *intern = php_sdl_pixels_from_obj(object); if (intern->pixels.pixels) { if (!(intern->flags & SDL_DONTFREE)) { @@ -1471,9 +1468,7 @@ static void php_sdl_pixels_free(zend_object *object) */ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type) { - struct php_sdl_pixels *intern; - - intern = (struct php_sdl_pixels*)ecalloc(1, sizeof(struct php_sdl_pixels) + zend_object_properties_size(class_type)); + php_sdl_pixels *intern = zend_object_alloc(sizeof(php_sdl_pixels), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); @@ -1487,7 +1482,7 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type) /* {{{ sdl_pixels_read_property*/ zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) { - struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); + php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); zval *retval, tmp_member; if (Z_TYPE_P(member) != IS_STRING) { @@ -1539,7 +1534,7 @@ static HashTable *sdl_pixels_get_properties(zval *object) { HashTable *props; zval zv; - struct php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); + php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); props = zend_std_get_properties(object); @@ -1654,6 +1649,7 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_palette_handlers.get_properties = sdl_palette_get_properties; php_sdl_palette_handlers.write_property = sdl_palette_write_property; php_sdl_palette_handlers.free_obj = php_sdl_palette_free; + php_sdl_palette_handlers.offset = XtOffsetOf(php_sdl_palette, zo); REGISTER_PALETTE_PROP("ncolors"); REGISTER_PALETTE_PROP("version"); @@ -1668,7 +1664,7 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties; php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property; php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free; - php_sdl_pixelformat_handlers.offset = XtOffsetOf(struct php_sdl_pixelformat, zo); + php_sdl_pixelformat_handlers.offset = XtOffsetOf(php_sdl_pixelformat, zo); REGISTER_FORMAT_PROP("format"); REGISTER_FORMAT_PROP("BitsPerPixel"); @@ -1696,6 +1692,7 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties; php_sdl_pixels_handlers.write_property = sdl_pixels_write_property; php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free; + php_sdl_pixels_handlers.offset = XtOffsetOf(php_sdl_pixels, zo); REGISTER_PIXELS_PROP("pitch"); REGISTER_PIXELS_PROP("h"); diff --git a/src/rect.c b/src/rect.c index 186ffe8..d3afa41 100644 --- a/src/rect.c +++ b/src/rect.c @@ -59,9 +59,9 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value) zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) { if (pt) { - object_init_ex(value, php_sdl_rect_ce); - zend_update_property_long(php_sdl_rect_ce, value, "x", 1, pt->x); - zend_update_property_long(php_sdl_rect_ce, value, "y", 1, pt->y); + object_init_ex(value, php_sdl_point_ce); + zend_update_property_long(php_sdl_point_ce, value, "x", 1, pt->x); + zend_update_property_long(php_sdl_point_ce, value, "y", 1, pt->y); return 1; } @@ -102,11 +102,11 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_point_ce) { zval *val, rv; - val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv); + val = zend_read_property(php_sdl_point_ce, value, "x", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = pt->x = (int)Z_LVAL_P(val); - val = zend_read_property(php_sdl_rect_ce, value, "y", 1, 0, &rv); + val = zend_read_property(php_sdl_point_ce, value, "y", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = pt->y = (int)Z_LVAL_P(val); @@ -169,8 +169,8 @@ static PHP_METHOD(SDL_Point, __construct) } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_rect_ce, getThis(), "x", 1, x); - zend_update_property_long(php_sdl_rect_ce, getThis(), "y", 1, y); + zend_update_property_long(php_sdl_point_ce, getThis(), "x", 1, x); + zend_update_property_long(php_sdl_point_ce, getThis(), "y", 1, y); } /* }}} */ diff --git a/src/surface.c b/src/surface.c index 486ce7b..5357242 100644 --- a/src/surface.c +++ b/src/surface.c @@ -1356,9 +1356,9 @@ PHP_MINIT_FUNCTION(sdl_surface) REGISTER_SURFACE_PROP("w"); REGISTER_SURFACE_PROP("h"); REGISTER_SURFACE_PROP("pitch"); - zend_declare_property_null(get_php_sdl_pixelformat_ce(), ZEND_STRL("format"), ZEND_ACC_PUBLIC); - zend_declare_property_null(get_php_sdl_rect_ce(), ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC); - zend_declare_property_null(get_php_sdl_pixels_ce(), ZEND_STRL("pixels"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("format"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("pixels"), ZEND_ACC_PUBLIC); REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE", SDL_SWSURFACE); REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC", SDL_PREALLOC); diff --git a/src/video.c b/src/video.c index 9b059e5..bafef53 100644 --- a/src/video.c +++ b/src/video.c @@ -316,7 +316,7 @@ PHP_FUNCTION(SDL_GetDisplayBounds) SDL_Rect rect; zval *result; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &display, &result) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/", &display, &result) == FAILURE) { RETURN_FALSE; } err = SDL_GetDisplayBounds((int)display, &rect); diff --git a/tests/005-video.phpt b/tests/005-video.phpt index 59e378e..3d5973f 100644 --- a/tests/005-video.phpt +++ b/tests/005-video.phpt @@ -3,8 +3,7 @@ video group test --SKIPIF-- +skipIfTravis(); --FILE-- @@ -52,9 +51,9 @@ object(SDL_Rect)#1 (4) { ["y"]=> int(0) ["w"]=> - int(1680) + int(%d) ["h"]=> - int(1050) + int(%d) } SDL_GetNumDisplayModes(0):int(%d) SDL_GetDisplayMode(0,0):object(SDL_DisplayMode)#2 (4) { diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt index 424bde8..1dd5ff1 100644 --- a/tests/006-rect.phpt +++ b/tests/006-rect.phpt @@ -65,7 +65,7 @@ var_dump(SDL_EnclosePoints($pts, 6, $r4, $res2), $res2); Done --EXPECTF-- +++ Empty (true) -object(SDL_Rect)#1 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(0) ["y"]=> @@ -74,12 +74,10 @@ object(SDL_Rect)#1 (5) { int(0) ["h"]=> int(0) - ["clip_rect"]=> - NULL } bool(true) +++ Empty (false) -object(SDL_Rect)#2 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(1) ["y"]=> @@ -88,8 +86,6 @@ object(SDL_Rect)#2 (5) { int(3) ["h"]=> int(4) - ["clip_rect"]=> - NULL } bool(false) +++ Equal (true) @@ -101,7 +97,7 @@ bool(false) +++ Inter (true) bool(true) bool(true) -object(SDL_Rect)#6 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(16) ["y"]=> @@ -110,8 +106,6 @@ object(SDL_Rect)#6 (5) { int(14) ["h"]=> int(13) - ["clip_rect"]=> - NULL } +++ Inter (false) bool(false) @@ -119,7 +113,7 @@ bool(false) NULL +++ Union NULL -object(SDL_Rect)#6 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(10) ["y"]=> @@ -128,11 +122,9 @@ object(SDL_Rect)#6 (5) { int(28) ["h"]=> int(31) - ["clip_rect"]=> - NULL } NULL -object(SDL_Rect)#%d (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(10) ["y"]=> @@ -141,8 +133,6 @@ object(SDL_Rect)#%d (5) { int(110) ["h"]=> int(20) - ["clip_rect"]=> - NULL } +++ InterLine bool(true) @@ -154,7 +144,7 @@ bool(false) +++ EnclosePoints string(67) "SDL_Point(20,14) SDL_Point(13,20) SDL_Point(24,20) SDL_Point(20,28)" bool(true) -object(SDL_Rect)#%d (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(13) ["y"]=> @@ -163,8 +153,6 @@ object(SDL_Rect)#%d (5) { int(12) ["h"]=> int(15) - ["clip_rect"]=> - NULL } Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect.php on line %d diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt index ad1d6cc..176e44e 100644 --- a/tests/007-rect-oo.phpt +++ b/tests/007-rect-oo.phpt @@ -53,7 +53,7 @@ var_dump($r1->IntersectLine($x1, $y1, $x2, $y2)); Done --EXPECTF-- +++ Empty (true) -object(SDL_Rect)#1 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(0) ["y"]=> @@ -62,13 +62,11 @@ object(SDL_Rect)#1 (5) { int(0) ["h"]=> int(0) - ["clip_rect"]=> - NULL } string(17) "SDL_Rect(0,0,0,0)" bool(true) +++ Empty (false) -object(SDL_Rect)#2 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(1) ["y"]=> @@ -77,8 +75,6 @@ object(SDL_Rect)#2 (5) { int(3) ["h"]=> int(4) - ["clip_rect"]=> - NULL } string(17) "SDL_Rect(1,2,3,4)" bool(false) @@ -91,7 +87,7 @@ bool(false) +++ Inter (true) bool(true) bool(true) -object(SDL_Rect)#6 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(16) ["y"]=> @@ -100,8 +96,6 @@ object(SDL_Rect)#6 (5) { int(14) ["h"]=> int(13) - ["clip_rect"]=> - NULL } +++ Inter (false) bool(false) @@ -109,7 +103,7 @@ bool(false) NULL +++ Uninon NULL -object(SDL_Rect)#6 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(10) ["y"]=> @@ -118,11 +112,9 @@ object(SDL_Rect)#6 (5) { int(28) ["h"]=> int(31) - ["clip_rect"]=> - NULL } NULL -object(SDL_Rect)#6 (5) { +object(SDL_Rect)#%d (4) { ["x"]=> int(10) ["y"]=> @@ -131,8 +123,6 @@ object(SDL_Rect)#6 (5) { int(110) ["h"]=> int(20) - ["clip_rect"]=> - NULL } +++ InterLine bool(true) diff --git a/tests/012-pixelformat.phpt b/tests/012-pixelformat.phpt index 60ee70e..7ab0907 100644 --- a/tests/012-pixelformat.phpt +++ b/tests/012-pixelformat.phpt @@ -46,6 +46,8 @@ int(0) int(0) = Result object(SDL_PixelFormat)#%d (16) { + ["format"]=> + int(303039488) ["BitsPerPixel"]=> int(4) ["BytesPerPixel"]=> @@ -262,8 +264,6 @@ object(SDL_PixelFormat)#%d (16) { } } } - ["format"]=> - int(303039488) } = RGB int(8) diff --git a/tests/013-pixelformat-oo.phpt b/tests/013-pixelformat-oo.phpt index 200a057..baaa06d 100644 --- a/tests/013-pixelformat-oo.phpt +++ b/tests/013-pixelformat-oo.phpt @@ -49,6 +49,8 @@ string(42) "SDL_PixelFormat(SDL_PIXELFORMAT_INDEX4LSB)" int(0) = Result object(SDL_PixelFormat)#%d (16) { + ["format"]=> + int(303039488) ["BitsPerPixel"]=> int(4) ["BytesPerPixel"]=> @@ -265,8 +267,6 @@ object(SDL_PixelFormat)#%d (16) { } } } - ["format"]=> - int(303039488) } = RGB int(8) diff --git a/tests/test-functions.php b/tests/test-functions.php index bd93d90..6046469 100644 --- a/tests/test-functions.php +++ b/tests/test-functions.php @@ -3,6 +3,11 @@ function skipIncompleteTest() { exit('skip test is not complete'); } +function skipIfTravis() { + if ((bool)getenv('TRAVIS')) { + exit('skip test if run on Travis'); + } +} function assertEquals($current, $expected, $assertionMessage) { if($current === $expected) { printf('PASS: %s.' . PHP_EOL, $assertionMessage); From 3f31add0ce69b7446048b9608a1567dae98782b6 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sat, 20 Jun 2020 20:32:32 +0100 Subject: [PATCH 04/55] Do not assume there is joystick present in example file --- examples/007-input-handling.php | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php index 95cb860..d070111 100644 --- a/examples/007-input-handling.php +++ b/examples/007-input-handling.php @@ -5,6 +5,12 @@ $quit = false; SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK); +$joystick = SDL_JoystickOpen(0); +$joystickFound = !is_null($joystick); +if(!$joystickFound) { + trigger_error('A joystick could not be found.', E_USER_NOTICE); +} + $window = SDL_CreateWindow("Input handling example", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN); $renderer = SDL_CreateRenderer($window, -1, 0); @@ -19,7 +25,6 @@ SDL_SetRenderDrawColor($renderer, 255, 0, 255, 255); SDL_RenderClear($renderer); SDL_RenderPresent($renderer); -$joystick = SDL_JoystickOpen(0); $rotCenter = new SDL_Point(10, 10); $event = new SDL_Event; $destRect = new SDL_Rect; @@ -29,15 +34,17 @@ $destRect->h = 64; $update = true; while (!$quit) { - $xJoystickMotion = SDL_JoystickGetAxis($joystick, 0); - if($xJoystickMotion !== 0) { - $x += ceil($xJoystickMotion / 32767) * 5; - $update = true; - } - $yJoystickMotion = SDL_JoystickGetAxis($joystick, 1); - if($yJoystickMotion !== 0) { - $y += ceil($yJoystickMotion / 32767) * 5; - $update = true; + if($joystickFound) { + $xJoystickMotion = SDL_JoystickGetAxis($joystick, 0); + if($xJoystickMotion !== 0) { + $x += ceil($xJoystickMotion / 32767) * 5; + $update = true; + } + $yJoystickMotion = SDL_JoystickGetAxis($joystick, 1); + if($yJoystickMotion !== 0) { + $y += ceil($yJoystickMotion / 32767) * 5; + $update = true; + } } while(SDL_PollEvent($event)) { @@ -70,7 +77,9 @@ SDL_Delay(25); } -SDL_JoystickClose($joystick); +if($joystickFound) { + SDL_JoystickClose($joystick); +} SDL_DestroyTexture($texture); SDL_DestroyRenderer($renderer); From 88532a57435a72e0e824c6aa78ff515d8c7555aa Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sat, 20 Jun 2020 21:35:02 +0100 Subject: [PATCH 05/55] Create docker file to use with travis --- .dockerignore | 1 + .travis.yml | 29 ++++------------------------- Dockerfile | 21 +++++++++++++++++++++ docker-entrypoint.sh | 10 ++++++++++ 4 files changed, 36 insertions(+), 25 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100755 docker-entrypoint.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6b8710a --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +.git diff --git a/.travis.yml b/.travis.yml index 15e08d5..ad9cae6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,11 @@ language: php -php: - - 7.3 - -env: - - REPORT_EXIT_STATUS=1 +services: + - docker before_install: - - sudo add-apt-repository -y ppa:team-xbmc/ppa - - sudo apt-get update -qq - - | - travis_retry curl -L https://www.libsdl.org/release/SDL2-2.0.8.tar.gz | tar xz - pushd SDL2-2.0.8 - ./configure - make - sudo make install - popd - -install: - - sudo apt-get install libegl1-mesa-dev libgles2-mesa-dev - -before_script: - - phpize - - ./configure --quiet - - make all install - - echo "extension=sdl.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` - - chmod +x run-tests.php + - docker build -t ponup/php-sdl . script: - - ./run-tests.php -q -p $(which php) --show-diff + - docker run --rm ponup/php-sdl diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5d363a3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,21 @@ +FROM debian:10 + +RUN apt-get update +RUN apt-get install -y make build-essential wget +RUN apt-get install -y lsb-release apt-transport-https ca-certificates +RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg +RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list +RUN apt-get update +RUN apt-get install -y php7.4-dev +RUN apt-get install -y libsdl2-dev +RUN apt-get install -y xvfb +COPY . /opt/php-sdl +WORKDIR /opt/php-sdl +RUN phpize +RUN ./configure +RUN make +RUN make install +RUN echo "extension=sdl.so" >> /etc/php/7.4/cli/php.ini + +ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"] + diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh new file mode 100755 index 0000000..5c338f8 --- /dev/null +++ b/docker-entrypoint.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +Xvfb :99 -screen 0 800x600x24 -ac & + +chmod +x ./run-tests.php + +export DISPLAY=:99 +./run-tests.php -q --show-diff + +killall -9 Xvfb From 8a67461e39bd337006bb13ec9f2f631981adffc0 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sun, 21 Jun 2020 12:10:24 +0100 Subject: [PATCH 06/55] Re-format example files --- examples/001-sdl-version.php | 7 ++--- examples/002-error-messagebox.php | 3 ++- examples/003-messagebox-inputs.php | 5 ++-- examples/004-draw-points.php | 17 +++++++------ examples/005-draw-rectangle.php | 2 ++ examples/006-animated-boxes.php | 17 +++++++------ examples/007-input-handling.php | 41 +++++++++++++++--------------- examples/008-shaped-window.php | 18 ++++++------- examples/009-window-events.php | 26 +++++++++++-------- examples/010-draw-lines.php | 9 ++++--- examples/bootstrap.php | 6 +++-- 11 files changed, 83 insertions(+), 68 deletions(-) diff --git a/examples/001-sdl-version.php b/examples/001-sdl-version.php index 873de6f..f544161 100644 --- a/examples/001-sdl-version.php +++ b/examples/001-sdl-version.php @@ -1,12 +1,13 @@ Show($buttonId); echo 'Button selection: ', var_export($buttonId), PHP_EOL; - diff --git a/examples/004-draw-points.php b/examples/004-draw-points.php index c2ea513..e0eabd5 100644 --- a/examples/004-draw-points.php +++ b/examples/004-draw-points.php @@ -1,10 +1,12 @@ type == SDL_QUIT) { +while (true) { + if (SDL_PollEvent($event) && $event->type == SDL_QUIT) { break; - } + } } SDL_DestroyRenderer($renderer); SDL_DestroyWindow($window); SDL_Quit(); - diff --git a/examples/005-draw-rectangle.php b/examples/005-draw-rectangle.php index dd0ef26..a42b230 100644 --- a/examples/005-draw-rectangle.php +++ b/examples/005-draw-rectangle.php @@ -1,5 +1,7 @@ format, 0xef, 0xff, 0x87); -for($t = $time * $step; $t; $t--) { +for ($t = $time * $step; $t; $t--) { if (!($t % $step)) { - $secondsLeft = $t / $step; - SDL_SetWindowTitle($window, "Will be closed in $secondsLeft seconds"); + $secondsLeft = $t / $step; + SDL_SetWindowTitle($window, "Will be closed in $secondsLeft seconds"); } // Display 1 rect in ~red $surf->FillRect($rects[$time * $step - $t], $color); - SDL_UpdateWindowSurfaceRects($window, array($rects[$time * $step - $t])); + SDL_UpdateWindowSurfaceRects($window, array($rects[$time * $step - $t])); usleep(1000000 / $step); - while(SDL_PollEvent($event)) { - if($event->type == SDL_QUIT) break; - } + while (SDL_PollEvent($event)) { + if ($event->type == SDL_QUIT) break; + } } SDL_DestroyWindow($window); - diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php index d070111..c53884e 100644 --- a/examples/007-input-handling.php +++ b/examples/007-input-handling.php @@ -1,5 +1,7 @@ clip_rect; @@ -34,50 +36,50 @@ $destRect->h = 64; $update = true; while (!$quit) { - if($joystickFound) { + if ($joystickFound) { $xJoystickMotion = SDL_JoystickGetAxis($joystick, 0); - if($xJoystickMotion !== 0) { + if ($xJoystickMotion !== 0) { $x += ceil($xJoystickMotion / 32767) * 5; $update = true; } $yJoystickMotion = SDL_JoystickGetAxis($joystick, 1); - if($yJoystickMotion !== 0) { + if ($yJoystickMotion !== 0) { $y += ceil($yJoystickMotion / 32767) * 5; $update = true; } } - while(SDL_PollEvent($event)) { - switch ($event->type) { - case SDL_QUIT: - $quit = true; - break; - case SDL_MOUSEMOTION: - $x = $event->motion->x; - $y = $event->motion->y; + while (SDL_PollEvent($event)) { + switch ($event->type) { + case SDL_QUIT: + $quit = true; + break; + case SDL_MOUSEMOTION: + $x = $event->motion->x; + $y = $event->motion->y; $update = true; break; case SDL_JOYAXISMOTION: break; - } + } } - if($update) { + if ($update) { SDL_RenderClear($renderer); $destRect->x = $x; $destRect->y = $y; - + if (SDL_RenderCopyEx($renderer, $texture, NULL, $destRect, 90, $rotCenter, SDL_FLIP_NONE) != 0) { echo SDL_GetError(), PHP_EOL; } - SDL_RenderPresent($renderer); + SDL_RenderPresent($renderer); $update = false; } - SDL_Delay(25); + SDL_Delay(25); } -if($joystickFound) { +if ($joystickFound) { SDL_JoystickClose($joystick); } @@ -85,4 +87,3 @@ SDL_DestroyRenderer($renderer); SDL_DestroyWindow($window); SDL_Quit(); - diff --git a/examples/008-shaped-window.php b/examples/008-shaped-window.php index 7819d6c..4538c3f 100644 --- a/examples/008-shaped-window.php +++ b/examples/008-shaped-window.php @@ -1,17 +1,19 @@ type == SDL_QUIT) $quit = true; - if($event->type == SDL_MOUSEBUTTONDOWN) $quit = true; +while (!$quit) { + while (SDL_PollEvent($event)) { + $quit = in_array($event->type, [SDL_QUIT, SDL_MOUSEBUTTONDOWN]); } - SDL_Delay(20); + SDL_Delay(20); } SDL_DestroyRenderer($renderer); SDL_DestroyWindow($window); SDL_Quit(); - diff --git a/examples/009-window-events.php b/examples/009-window-events.php index 75e2d9f..38222bd 100644 --- a/examples/009-window-events.php +++ b/examples/009-window-events.php @@ -1,5 +1,7 @@ type) { - case SDL_QUIT: - $quit = true; - break; - case SDL_WINDOWEVENT: + while (SDL_PollEvent($event)) { + switch ($event->type) { + case SDL_QUIT: + $quit = true; + break; + case SDL_WINDOWEVENT: $eventText = 'unknown'; switch ($event->window->event) { case SDL_WINDOWEVENT_SHOWN: @@ -70,10 +74,10 @@ break; } $window->setTitle($eventText); - printf('Event{windowID=%d, timestamp=%s, description=%s}' . PHP_EOL, $event->window->windowID, $event->window->timestamp, $eventText); - break; - } - } + printf('Event{windowID=%d, timestamp=%s, description=%s}' . PHP_EOL, $event->window->windowID, $event->window->timestamp, $eventText); + break; + } + } SDL_Delay(5); } diff --git a/examples/010-draw-lines.php b/examples/010-draw-lines.php index 9cc48f2..e59d201 100644 --- a/examples/010-draw-lines.php +++ b/examples/010-draw-lines.php @@ -1,10 +1,12 @@ 0; ++$iteration) { $side = $iteration % 4; $sign = $side < 2 ? 1 : -1; - + $x2 = $side % 2 ? $x1 + $sign * $offset : $x1; $y2 = $side % 2 ? $y1 : $y1 + $sign * $offset; @@ -44,4 +46,3 @@ SDL_DestroyRenderer($renderer); SDL_DestroyWindow($window); SDL_Quit(); - diff --git a/examples/bootstrap.php b/examples/bootstrap.php index 4518a46..417728c 100644 --- a/examples/bootstrap.php +++ b/examples/bootstrap.php @@ -1,6 +1,8 @@ Date: Sun, 21 Jun 2020 12:39:21 +0100 Subject: [PATCH 07/55] Set color key to spaceship example --- examples/007-input-handling.php | 4 ++++ src/surface.c | 7 ++++--- tests/020-surface.phpt | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php index c53884e..cc8a01f 100644 --- a/examples/007-input-handling.php +++ b/examples/007-input-handling.php @@ -20,6 +20,10 @@ if ($image === null) { exit('Unable to load image'); } +$windowSurface = SDL_GetWindowSurface($window); +$color = SDL_MapRGB($windowSurface->format, 0xff, 0xff, 0xff); +SDL_SetColorKey($image, true, $color); + $texture = SDL_CreateTextureFromSurface($renderer, $image); $drect = $image->clip_rect; SDL_FreeSurface($image); diff --git a/src/surface.c b/src/surface.c index 5357242..2a5f0ad 100644 --- a/src/surface.c +++ b/src/surface.c @@ -806,14 +806,15 @@ PHP_FUNCTION(SDL_SetColorKey) { struct php_sdl_surface *intern; zval *z_surface; - zend_long flag, key = 0; + zend_bool flag; + zend_long key = 0; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_surface, php_sdl_surface_ce, &flag, &key)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key)) { return; } FETCH_SURFACE(surface, z_surface, 1); - RETURN_LONG(SDL_SetColorKey(surface, (int)flag, (Uint32)key)); + RETURN_LONG(SDL_SetColorKey(surface, flag ? SDL_TRUE : SDL_FALSE, (Uint32)key)); } /* }}} */ diff --git a/tests/020-surface.phpt b/tests/020-surface.phpt index 75f8504..53eaf90 100644 --- a/tests/020-surface.phpt +++ b/tests/020-surface.phpt @@ -21,9 +21,9 @@ var_dump(SDL_LockSurface($spal), $spal->locked); var_dump(SDL_UnlockSurface($spal), $spal->locked); echo "= ColorKey\n"; -var_dump(SDL_SetColorKey($spal, 1, 127)); +var_dump(SDL_SetColorKey($spal, true, 127)); var_dump(SDL_GetColorKey($spal, $key), $key); -var_dump(SDL_SetColorKey($spal, 0)); +var_dump(SDL_SetColorKey($spal, false)); var_dump(SDL_GetColorKey($spal, $key)); echo "= ColorMod\n"; From c79dcdffa47374e8fb0b1ea2c0fc1e9b7747f96d Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sun, 21 Jun 2020 13:02:13 +0100 Subject: [PATCH 08/55] Add gif example and link to readme --- README.md | 28 ++++++++++++++++------------ examples/007-input-handling.php | 5 +++-- input-handling-example.gif | Bin 0 -> 56494 bytes 3 files changed, 19 insertions(+), 14 deletions(-) create mode 100644 input-handling-example.gif diff --git a/README.md b/README.md index c8352ab..3938853 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ PHP-SDL ======= -SDL (Simple DirectMedia Layer) bindings for the PHP language. +SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allows you to create multimedia desktop applications with windows, input handling, events, and more. + +[](input-handling-example.gif) ## Installation @@ -33,7 +35,7 @@ to your _php.ini_ file. The SDL extension mimics in almost every single aspect to the official C library, so until we write our own documentation, refer to the [C counterpart](https://wiki.libsdl.org/APIByCategory). -### Example +## Examples Standard SDL2 API is available in procedural style: @@ -51,8 +53,17 @@ And is also available in object oriented style: unset($window); // will destroy the window ``` -Building -======== +Complete examples can be found in the [examples](examples) folder. + +## Projects using the extension + +* [CubeCraft](https://github.com/Ponup/cubecraft) +* [Conway's game of life](https://github.com/Ponup/conways-game-of-life) +* [PhpOkoban](https://github.com/b-viguier/PhpOkoban) +* [Inphpinity](https://github.com/b-viguier/Inphpinity) +* [PhPresent](https://github.com/b-viguier/PhPresent) + +## Building To compile your new extension, you will have to execute the following steps: @@ -66,13 +77,6 @@ $ [sudo] make install ## Support and feature requests -Please submit anything that needs our attention to [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter. - +Please submit anything that needs our attention to the [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter. -## Projects using this extension -* [CubeCraft](https://github.com/Ponup/cubecraft) -* [Conway's game of life](https://github.com/Ponup/conways-game-of-life) -* [PhpOkoban](https://github.com/b-viguier/PhpOkoban) -* [Inphpinity](https://github.com/b-viguier/Inphpinity) -* [PhPresent](https://github.com/b-viguier/PhPresent) diff --git a/examples/007-input-handling.php b/examples/007-input-handling.php index cc8a01f..45341d9 100644 --- a/examples/007-input-handling.php +++ b/examples/007-input-handling.php @@ -28,9 +28,10 @@ $drect = $image->clip_rect; SDL_FreeSurface($image); -SDL_SetRenderDrawColor($renderer, 255, 0, 255, 255); +SDL_SetRenderDrawColor($renderer, 0xbb, 0xcc, 0xdd, 0xff); SDL_RenderClear($renderer); SDL_RenderPresent($renderer); + $rotCenter = new SDL_Point(10, 10); $event = new SDL_Event; $destRect = new SDL_Rect; @@ -80,7 +81,7 @@ $update = false; } - SDL_Delay(25); + SDL_Delay(5); } if ($joystickFound) { diff --git a/input-handling-example.gif b/input-handling-example.gif new file mode 100644 index 0000000000000000000000000000000000000000..59bcb77a30edb8de46ebecba52753d121323d9d5 GIT binary patch literal 56494 zcmb@tWl)@5*EQIzyx)A! zO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`o z6^si*q4;=z<*N-xmMjBYk0pi;m7nX%au94S^D{$uvP*Ch>eZu|Y0jk-nAUtvvlZc$|mYD=grWm~E71b_uX`F0-#y;ZES$!HD=Y=0lw2ax(ECp*>f+kd_h4kP!uXVW38=YK6O^$2uud-JigjB6z9e!tM+KZA?} zh{Y2bOoaxew0>3e!Yvs)8y}2PRz3}NAr{O}J$62MDQ_vAq@4+V=cb-Tj_vVH90=^u zDKZ&*wi3t6U7roBb+927S%?dQ3cu$h&IQ^F)@RGlN?}$DHS>n22oYD;14_K$Ypd7w yie^ta`JkYJ0zcfJwd4@E`mtPT(Ub@ujGGo$Zj1c1-Qx)EXj;6i{B_Cu+5Z>5OXa)( literal 0 HcmV?d00001 From 49ecbbe9bb911832bb178534fb1d8f8bf4844be9 Mon Sep 17 00:00:00 2001 From: Manuel 'Kea' Baldassarri Date: Mon, 22 Jun 2020 20:52:08 +0200 Subject: [PATCH 09/55] Fix surface and powerinfo params by ref (#44) * Fix some surface functions params by ref and fix misplaced pointers to internal struct * Fix SDL_GetPowerInfo params by ref * 017-rwops-stream test was already working --- src/power.c | 2 +- src/surface.c | 19 +++++++++++-------- tests/017-rwops-stream.phpt | 1 - tests/018-power.phpt | 1 - tests/020-surface.phpt | 5 +++-- tests/021-surface-oo.phpt | 6 +++--- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/power.c b/src/power.c index c9a7c44..d59b4be 100644 --- a/src/power.c +++ b/src/power.c @@ -40,7 +40,7 @@ PHP_FUNCTION(SDL_GetPowerInfo) zval *z_secs = NULL, *z_pct = NULL; zend_bool has_secs, has_pct; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_secs, &z_pct) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "|z/z/", &z_secs, &z_pct) == FAILURE) { RETURN_FALSE; } diff --git a/src/surface.c b/src/surface.c index 2a5f0ad..2acb03c 100644 --- a/src/surface.c +++ b/src/surface.c @@ -186,7 +186,8 @@ static PHP_METHOD(SDL_Surface, __construct) zend_long flags, width, height, depth, rmask, gmask, bmask, amask; zend_error_handling error_handling; - intern = (struct php_sdl_surface *)Z_OBJ_P(getThis()); + zend_object* zo = Z_OBJ_P(getThis()); + intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset); zend_replace_error_handling(EH_THROW, NULL, &error_handling); if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) { @@ -217,7 +218,9 @@ static PHP_METHOD(SDL_Surface, __toString) return; } - intern = (struct php_sdl_surface *)Z_OBJ_P(getThis()); + zend_object* zo = Z_OBJ_P(getThis()); + intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset); + if (intern->surface) { buf_len = spprintf(&buf, 100, "SDL_Surface(%u,%d,%d,%u,0x%x,0x%x,0x%x,0x%x)", intern->surface->flags, intern->surface->w, intern->surface->h, @@ -839,7 +842,7 @@ PHP_FUNCTION(SDL_GetColorKey) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_key)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key)) { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -906,7 +909,7 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozzz", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -972,7 +975,7 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_a)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a)) { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -1034,7 +1037,7 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_mode)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode)) { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -1098,7 +1101,7 @@ PHP_FUNCTION(SDL_GetClipRect) SDL_Rect rect; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_surface, php_sdl_surface_ce, &z_rect)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect)) { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -1272,7 +1275,7 @@ static zend_object* php_sdl_surface_new(zend_class_entry *class_type) { struct php_sdl_surface *intern; - intern = (struct php_sdl_surface*)ecalloc(1, sizeof(struct php_sdl_surface) + zend_object_properties_size(class_type)); + intern = (struct php_sdl_surface*)zend_object_alloc(sizeof(struct php_sdl_surface), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); diff --git a/tests/017-rwops-stream.phpt b/tests/017-rwops-stream.phpt index 0d64901..acee259 100644 --- a/tests/017-rwops-stream.phpt +++ b/tests/017-rwops-stream.phpt @@ -3,7 +3,6 @@ SDL_RWops test, stream mode --SKIPIF-- --FILE-- diff --git a/tests/018-power.phpt b/tests/018-power.phpt index 97e9c25..571e426 100644 --- a/tests/018-power.phpt +++ b/tests/018-power.phpt @@ -3,7 +3,6 @@ SDL_power test suite --SKIPIF-- --FILE-- --FILE-- --FILE-- w, $spal->h, $spal->format->palette->ncolors, $spal->pixels); @@ -57,7 +57,7 @@ $scol->Free() = Done --EXPECTF-- = Create Palette -string(40) "SDL_Surface(0,150,100,8,0x0,0x0,0x0,0x0)" +string(40) "SDL_Surface(%d,150,100,8,0x0,0x0,0x0,0x0)" int(150) int(100) int(256) @@ -70,7 +70,7 @@ object(SDL_Pixels)#%d (3) { int(15200) } = Create True colors -string(57) "SDL_Surface(0,150,100,32,0xff000000,0xff0000,0xff00,0xff)" +string(57) "SDL_Surface(%d,150,100,32,0xff000000,0xff0000,0xff00,0xff)" int(150) int(100) NULL From cc2ac56ea305b4e344e7400fcb43450f7f73ce32 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Mon, 22 Jun 2020 22:53:45 +0100 Subject: [PATCH 10/55] Fix issue #31 (extending SDL_Rect) --- src/rect.c | 4 ++-- tests/007-rect-oo.phpt | 10 ++++++++-- tests/028-point.phpt | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+), 4 deletions(-) create mode 100644 tests/028-point.phpt diff --git a/src/rect.c b/src/rect.c index d3afa41..9d6bd15 100644 --- a/src/rect.c +++ b/src/rect.c @@ -71,7 +71,7 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) { - if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_rect_ce) { + if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) { zval *val, rv; val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv); @@ -99,7 +99,7 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) { - if (Z_TYPE(*value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_point_ce) { + if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) { zval *val, rv; val = zend_read_property(php_sdl_point_ce, value, "x", 1, 0, &rv); diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt index 176e44e..951f744 100644 --- a/tests/007-rect-oo.phpt +++ b/tests/007-rect-oo.phpt @@ -49,6 +49,11 @@ var_dump($r1->IntersectLine($x1, $y1, $x2, $y2)); var_dump($x1, $y1, $x2, $y2); $x1=0; $y1=2; $x2=40; $y2=6; var_dump($r1->IntersectLine($x1, $y1, $x2, $y2)); + +echo '+++ Test subclasses of SDL_Rect can be passed to SDL functions', PHP_EOL; +class CustomRect extends \SDL_Rect {} +$customRect = new CustomRect(10, 20, 30, 40); +var_dump(SDL_RectEmpty($customRect)); ?> Done --EXPECTF-- @@ -131,5 +136,6 @@ int(15) int(29) int(24) bool(false) -Done - ++++ Test subclasses of SDL_Rect can be passed to SDL functions +bool(false) +Done \ No newline at end of file diff --git a/tests/028-point.phpt b/tests/028-point.phpt new file mode 100644 index 0000000..dd3d3cb --- /dev/null +++ b/tests/028-point.phpt @@ -0,0 +1,19 @@ +--TEST-- +SDL_Point test suite +--SKIPIF-- + +SUITE: End +--EXPECTF-- +SUITE: Start +TEST: Subclasses of SDL_Point can be converted properly +SDL_Point(10,20) +SUITE: End From bc1456d253dcce0416c6a189cb1848f7676faa6a Mon Sep 17 00:00:00 2001 From: Manuel 'Kea' Baldassarri Date: Sun, 23 Aug 2020 21:54:29 +0200 Subject: [PATCH 11/55] Add SDL_QueryTexture wrapper (#46) --- src/php_sdl.c | 1 + src/render.c | 27 +++++++++++++++++++++++++++ src/render.h | 9 +++++++++ 3 files changed, 37 insertions(+) diff --git a/src/php_sdl.c b/src/php_sdl.c index cb881f1..0bd104c 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -216,6 +216,7 @@ static zend_function_entry sdl_functions[] = { ZEND_FE(SDL_RenderPresent, arginfo_SDL_RenderPresent) ZEND_FE(SDL_CreateTextureFromSurface, arginfo_SDL_CreateTextureFromSurface) ZEND_FE(SDL_CreateTexture, arginfo_SDL_CreateTexture) + ZEND_FE(SDL_QueryTexture, arginfo_SDL_QueryTexture) ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget) ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize) diff --git a/src/render.c b/src/render.c index 789f664..1e874c9 100644 --- a/src/render.c +++ b/src/render.c @@ -334,6 +334,33 @@ PHP_FUNCTION(SDL_GetRendererOutputSize) ZVAL_LONG(z_height, h); } +PHP_FUNCTION(SDL_QueryTexture) +{ + zval *z_texture, *z_format, *z_access, *z_width, *z_height; + SDL_Texture *texture; + int w, h, access, result; + Uint32 format; + + if( zend_parse_parameters(ZEND_NUM_ARGS(), "zz/z/z/z/", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) { + return; + } + + texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); + + result = SDL_QueryTexture(texture, &format, &access, &w, &h); + + zval_dtor(z_format); + ZVAL_LONG(z_format, format); + zval_dtor(z_access); + ZVAL_LONG(z_access, access); + zval_dtor(z_width); + ZVAL_LONG(z_width, (long)w); + zval_dtor(z_height); + ZVAL_LONG(z_height, (long)h); + + RETURN_LONG(result); +} + /* {{{ MINIT */ PHP_MINIT_FUNCTION(sdl_render) { diff --git a/src/render.h b/src/render.h index 85bf2c3..34b5687 100644 --- a/src/render.h +++ b/src/render.h @@ -93,6 +93,14 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5) ZEND_ARG_INFO(0, h) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 5) + ZEND_ARG_INFO(0, texture) + ZEND_ARG_INFO(1, format) + ZEND_ARG_INFO(1, access) + ZEND_ARG_INFO(1, w) + ZEND_ARG_INFO(1, h) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderTarget, 0, 0, 2) ZEND_ARG_INFO(0, renderer) ZEND_ARG_INFO(0, texture) @@ -138,6 +146,7 @@ PHP_FUNCTION(SDL_RenderPresent); PHP_FUNCTION(SDL_RenderDrawPoint); PHP_FUNCTION(SDL_CreateTextureFromSurface); PHP_FUNCTION(SDL_CreateTexture); +PHP_FUNCTION(SDL_QueryTexture); PHP_FUNCTION(SDL_SetRenderTarget); PHP_FUNCTION(SDL_CreateRenderer); PHP_FUNCTION(SDL_RenderCopy); From 8d0be8d32aa230af769bf559c46595fccfdc94b8 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sun, 23 Aug 2020 21:15:52 +0100 Subject: [PATCH 12/55] Prepare 2.4.0 release --- package.xml | 41 ++++++++++++++++++++++++++++++++++------- src/php_sdl.h | 2 +- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/package.xml b/package.xml index 02fb6a9..dd393bd 100644 --- a/package.xml +++ b/package.xml @@ -16,11 +16,12 @@ remi@php.net yes - 2019-09-08 + + 2020-08-23 - 2.3.0 - 2.3.0 + 2.4.0 + 2.4.0 devel @@ -28,9 +29,15 @@ PHP - - Fix out of bounds error (remicollet) - - Add basic joystick/gamepad support (santiagolizardo) + - Fix duplicate symbols (remicollet) + - Fix parameters passed by reference in rect module (kea) + - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea) + - Fix surface props initialisation (kea) + - Fix surface and powerinfo params by ref (kea) + - Fix SDL_Rect inheritance issue (santiagolizardo) + - Add SQL_QueryTexture binding (kea) +

@@ -98,6 +105,8 @@ + + @@ -131,6 +140,7 @@ + @@ -138,16 +148,33 @@ - 7.3.0 + 7.4.0 - 1.9.0 + 1.10.0 sdl + + 2019-09-08 + + + 2.3.0 + 2.3.0 + + + devel + devel + + PHP + + - Fix out of bounds error (remicollet) + - Add basic joystick/gamepad support (santiagolizardo) + + 2019-09-02 diff --git a/src/php_sdl.h b/src/php_sdl.h index c0cb014..c3afd94 100644 --- a/src/php_sdl.h +++ b/src/php_sdl.h @@ -32,7 +32,7 @@ extern "C" { #include #include -#define PHP_SDL_VERSION "2.3.0" +#define PHP_SDL_VERSION "2.4.0" #if defined(__APPLE__) && defined(__MACH__) #include From 3ddeb7dd02d5ee9db4347caad7c62d5399ddc13c Mon Sep 17 00:00:00 2001 From: Manuel Baldassarri Date: Fri, 18 Jun 2021 20:30:44 +0200 Subject: [PATCH 13/55] Add PHP 8 support (#50) * Add PHP 8 support * Remove PHP 7 support * Update min PHP version to 8.0 Co-authored-by: Santiago --- Dockerfile | 4 +- config.m4 | 4 +- src/event.c | 11 +-- src/messagebox.c | 36 ++++----- src/php_sdl.h | 4 - src/pixels.c | 200 ++++++++++++++++++----------------------------- src/rect.c | 36 ++++----- src/shape.c | 2 +- src/surface.c | 56 +++++++------ src/video.c | 12 +-- src/window.c | 4 +- 11 files changed, 158 insertions(+), 211 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5d363a3..a77b5b9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get install -y lsb-release apt-transport-https ca-certificates RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list RUN apt-get update -RUN apt-get install -y php7.4-dev +RUN apt-get install -y php8.0-dev RUN apt-get install -y libsdl2-dev RUN apt-get install -y xvfb COPY . /opt/php-sdl @@ -15,7 +15,7 @@ RUN phpize RUN ./configure RUN make RUN make install -RUN echo "extension=sdl.so" >> /etc/php/7.4/cli/php.ini +RUN echo "extension=sdl.so" >> /etc/php/8.0/cli/php.ini ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"] diff --git a/config.m4 b/config.m4 index 03d0d69..06963bd 100644 --- a/config.m4 +++ b/config.m4 @@ -10,8 +10,8 @@ if test "$PHP_SDL" != "no"; then export OLD_CPPFLAGS="$CPPFLAGS" export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_SDL2 -Wall -Wfatal-errors" - REQ_PHP_VERSION="7.3.0" - REQ_PHP_VERSION_ID=70300 + REQ_PHP_VERSION="8.0.0" + REQ_PHP_VERSION_ID=80000 if test -z "$PHP_VERSION_ID"; then AC_MSG_CHECKING(PHP version) AC_TRY_COMPILE([#include ], [ diff --git a/src/event.c b/src/event.c index a0760bc..027dbf3 100644 --- a/src/event.c +++ b/src/event.c @@ -43,7 +43,7 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value) object_init_ex(value, php_sdl_event_ce); - zend_update_property_long(php_sdl_event_ce, value, ZEND_STRL("type"), event->type); + zend_update_property_long(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), event->type); switch(event->type) { case SDL_MOUSEMOTION: { @@ -122,7 +122,7 @@ zend_bool zval_to_sdl_event(zval *value, SDL_Event *event) zval *val, rv; if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce) { - val = zend_read_property(php_sdl_event_ce, value, ZEND_STRL("type"), 0, &rv); + val = zend_read_property(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), 0, &rv); convert_to_long(val); Z_LVAL_P(val) = event->type = (int)Z_LVAL_P(val); @@ -163,14 +163,11 @@ static PHP_METHOD(SDL_Event, __toString) } /* }}} */ -static HashTable *sdl_event_get_properties(zval *object) +static HashTable *sdl_event_get_properties(zend_object *object) { HashTable *props; props = zend_std_get_properties(object); - zval test; - zend_string *key = zend_string_init("type", 4, 0); - ZVAL_LONG(&test, SDL_QUIT); - zend_hash_update(props, key, &test); + return props; } diff --git a/src/messagebox.c b/src/messagebox.c index dcbb361..86be6c0 100644 --- a/src/messagebox.c +++ b/src/messagebox.c @@ -66,9 +66,9 @@ zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *va { if (color) { object_init_ex(value, php_sdl_messageboxcolor_ce); - zend_update_property_long(php_sdl_messageboxcolor_ce, value, "r", 1, color->r); - zend_update_property_long(php_sdl_messageboxcolor_ce, value, "g", 1, color->g); - zend_update_property_long(php_sdl_messageboxcolor_ce, value, "b", 1, color->b); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, color->r); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, color->g); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "b", 1, color->b); return 1; } @@ -82,9 +82,9 @@ zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data, { if (data) { object_init_ex(value, php_sdl_messageboxbuttondata_ce); - zend_update_property_long(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("flags"), data->flags); - zend_update_property_long(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("buttonid"), data->buttonid); - zend_update_property_string(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("text"), data->text); + zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), data->flags); + zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), data->buttonid); + zend_update_property_string(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("text"), data->text); return 1; } @@ -119,15 +119,15 @@ zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color) /* we convert the properties, without copy: yes ! */ - val = zend_read_property(php_sdl_messageboxcolor_ce, value, "r", 1, 0, &rv); + val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->r = (Uint8)Z_LVAL_P(val); - val = zend_read_property(php_sdl_messageboxcolor_ce, value, "g", 1, 0, &rv); + val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->g = (Uint8)Z_LVAL_P(val); - val = zend_read_property(php_sdl_messageboxcolor_ce, value, "b", 1, 0, &rv); + val = zend_read_property(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "b", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->b = (Uint8)Z_LVAL_P(val); @@ -147,15 +147,15 @@ zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData /* we convert the properties, without copy: yes ! */ - val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("flags"), 0, &rv); + val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), 0, &rv); convert_to_long(val); Z_LVAL_P(val) = data->flags = (Uint32)Z_LVAL_P(val); - val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("buttonid"), 0, &rv); + val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), 0, &rv); convert_to_long(val); Z_LVAL_P(val) = data->buttonid = (int)Z_LVAL_P(val); - val = zend_read_property(php_sdl_messageboxbuttondata_ce, value, ZEND_STRL("text"), 0, &rv); + val = zend_read_property(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("text"), 0, &rv); convert_to_string(val); data->text = Z_STRVAL_P(val); @@ -250,9 +250,9 @@ static PHP_METHOD(SDL_MessageBoxColor, __construct) } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "r", 1, r&255); - zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "g", 1, g&255); - zend_update_property_long(php_sdl_messageboxcolor_ce, getThis(), "b", 1, b&255); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r&255); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g&255); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b&255); } /* }}} */ @@ -305,9 +305,9 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct) } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("flags"), flags); - zend_update_property_long(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("buttonid"), (int)id); - zend_update_property_string(php_sdl_messageboxbuttondata_ce, getThis(), ZEND_STRL("text"), text); + zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("flags"), flags); + zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("buttonid"), (int)id); + zend_update_property_string(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(getThis()), ZEND_STRL("text"), text); } /* }}} */ diff --git a/src/php_sdl.h b/src/php_sdl.h index c3afd94..ac2d6ee 100644 --- a/src/php_sdl.h +++ b/src/php_sdl.h @@ -68,10 +68,6 @@ PHP_MINFO_FUNCTION(sdl); zend_bool php_sdl_check_overflow(int a, int b, int silent); -#ifdef ZTS -#include "TSRM.h" -#endif - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/pixels.c b/src/pixels.c index 58f2b11..2e67fd0 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -115,10 +115,10 @@ zend_bool sdl_color_to_zval(SDL_Color *color, zval *value) { if (color) { object_init_ex(value, php_sdl_color_ce); - zend_update_property_long(php_sdl_color_ce, value, "r", 1, color->r); - zend_update_property_long(php_sdl_color_ce, value, "g", 1, color->g); - zend_update_property_long(php_sdl_color_ce, value, "b", 1, color->b); - zend_update_property_long(php_sdl_color_ce, value, "a", 1, color->a); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, color->r); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, color->g); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "b", 1, color->b); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "a", 1, color->a); return 1; } @@ -131,19 +131,19 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color) if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce) { zval *val, rv; - val = zend_read_property(php_sdl_color_ce, value, "r", 1, 0, &rv); + val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->r = (Uint8)Z_LVAL_P(val); - val = zend_read_property(php_sdl_color_ce, value, "g", 1, 0, &rv); + val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->g = (Uint8)Z_LVAL_P(val); - val = zend_read_property(php_sdl_color_ce, value, "b", 1, 0, &rv); + val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "b", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->b = (Uint8)Z_LVAL_P(val); - val = zend_read_property(php_sdl_color_ce, value, "a", 1, 0, &rv); + val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "a", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = color->a = (Uint8)Z_LVAL_P(val); @@ -270,10 +270,10 @@ static PHP_METHOD(SDL_Color, __construct) } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_color_ce, getThis(), "r", 1, r&255); - zend_update_property_long(php_sdl_color_ce, getThis(), "g", 1, g&255); - zend_update_property_long(php_sdl_color_ce, getThis(), "b", 1, b&255); - zend_update_property_long(php_sdl_color_ce, getThis(), "a", 1, a&255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r&255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g&255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b&255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a&255); } /* }}} */ @@ -353,7 +353,7 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks) RETURN_TRUE; } - RETURN_FALSE;; + RETURN_FALSE; } /* }}} */ @@ -486,7 +486,7 @@ PHP_FUNCTION(SDL_AllocPalette) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) { return; } - palette = SDL_AllocPalette(ncolors); + palette = SDL_AllocPalette((int)ncolors); sdl_palette_to_zval(palette, return_value, 0); } /* }}} */ @@ -690,15 +690,15 @@ PHP_FUNCTION(SDL_SetPaletteColors) if (ncolors <= 0) { ncolors = count; } else if (ncolors > count) { - php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors); + php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %lld", count, ncolors); ncolors = count; } if (first >= intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors); + php_error_docref(NULL, E_WARNING, "Invalid first color index, %lld >= %d", first, intern->palette->ncolors); RETURN_LONG(-1); } if (first+ncolors > intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors); + php_error_docref(NULL, E_WARNING, "Invalid color number, %lld > %d", first+ncolors, intern->palette->ncolors); RETURN_LONG(-1); } colors = emalloc(sizeof(SDL_Color) * ncolors); @@ -975,16 +975,16 @@ static PHP_METHOD(SDL_Pixels, __construct) } zend_restore_error_handling(&error_handling); - if (php_sdl_check_overflow(pitch, h, 1)) { + if (php_sdl_check_overflow((int)pitch, (int)h, 1)) { zend_throw_exception(zend_exception_get_default(), "Invalid size", 0); } else { if (pitch & 3) { pitch = (pitch + 3) & ~3; - php_error_docref(NULL, E_NOTICE, "Pitch set to %ld", pitch); + php_error_docref(NULL, E_NOTICE, "Pitch set to %d", (int)pitch); } - intern->pixels.pixels = ecalloc(pitch, h); - intern->pixels.pitch = pitch; - intern->pixels.h = h; + intern->pixels.pixels = ecalloc((int)pitch, (int)h); + intern->pixels.pitch = (int)pitch; + intern->pixels.h = (int)h; } } /* }}} */ @@ -1120,7 +1120,7 @@ PHP_METHOD(SDL_Pixels, GetByte) intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); + php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); @@ -1147,7 +1147,7 @@ PHP_METHOD(SDL_Pixels, SetByte) intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); + php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); @@ -1190,20 +1190,11 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type) /* }}} */ /* {{{ sdl_palette_read_property*/ -zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *sdl_palette_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) { - php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); - zval *retval, tmp_member; - - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *_str = zval_try_get_string_func(member); - if (UNEXPECTED(!_str)) { - return &EG(uninitialized_zval); - } - ZVAL_STR(&tmp_member, _str); - member = &tmp_member; - cache_slot = NULL; - } + php_sdl_palette *intern = php_sdl_palette_from_obj(object); + char *member_val = ZSTR_VAL(member); + zval *retval; if (!intern->palette) { return zend_std_read_property(object, member, type, cache_slot, rv); @@ -1211,16 +1202,16 @@ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cac retval = rv; - if (!strcmp(Z_STRVAL_P(member), "ncolors")) { + if (!strcmp(member_val, "ncolors")) { ZVAL_LONG(retval, intern->palette->ncolors); - } else if (!strcmp(Z_STRVAL_P(member), "version")) { + } else if (!strcmp(member_val, "version")) { ZVAL_LONG(retval, intern->palette->version); - } else if (!strcmp(Z_STRVAL_P(member), "refcount")) { + } else if (!strcmp(member_val, "refcount")) { ZVAL_LONG(retval, intern->palette->refcount); - } else if (!strcmp(Z_STRVAL_P(member), "colors")) { + } else if (!strcmp(member_val, "colors")) { int i; zval z_color; array_init(retval); @@ -1231,15 +1222,10 @@ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cac } else { retval = zend_std_read_property(object, member, type, cache_slot, rv); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + return retval; } - if (member == &tmp_member) { - zval_dtor(member); - } return retval; } /* }}} */ @@ -1249,12 +1235,12 @@ zval *sdl_palette_read_property(zval *object, zval *member, int type, void **cac zend_hash_str_update(props, n, sizeof(n)-1, &zv); /* {{{ sdl_palette_get_properties*/ -static HashTable *sdl_palette_get_properties(zval *object) +static HashTable *sdl_palette_get_properties(zend_object *object) { HashTable *props; zval zv, z_color; int i; - php_sdl_palette *intern = PHP_SDL_PALETTE_P(object); + php_sdl_palette *intern = php_sdl_palette_from_obj(object); props = zend_std_get_properties(object); @@ -1275,7 +1261,7 @@ static HashTable *sdl_palette_get_properties(zval *object) /* }}} */ /* {{{ sdl_palette_write_property */ -static zval *sdl_palette_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *sdl_palette_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { php_error_docref(NULL, E_ERROR, "Not supported, use SDL_SetPaletteColors() or SDL_Palette::SetColors()"); return value; @@ -1315,22 +1301,11 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type) /* }}} */ /* {{{ sdl_pixelformat_read_property*/ -zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) { - php_sdl_pixelformat *intern; - zval *retval, tmp_member; - - intern = PHP_SDL_PIXELFORMAT_P(object); - - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *_str = zval_try_get_string_func(member); - if (UNEXPECTED(!_str)) { - return &EG(uninitialized_zval); - } - ZVAL_STR(&tmp_member, _str); - member = &tmp_member; - cache_slot = NULL; - } + php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object); + char *member_val = ZSTR_VAL(member); + zval *retval; if (!intern->format) { return zend_std_read_property(object, member, type, cache_slot, rv); @@ -1338,65 +1313,60 @@ zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void * retval = rv; - if (!strcmp(Z_STRVAL_P(member), "format")) { + if (!strcmp(member_val, "format")) { ZVAL_LONG(retval, intern->format->format); - } else if (!strcmp(Z_STRVAL_P(member), "BitsPerPixel")) { + } else if (!strcmp(member_val, "BitsPerPixel")) { ZVAL_LONG(retval, intern->format->BitsPerPixel); - } else if (!strcmp(Z_STRVAL_P(member), "BytesPerPixel")) { + } else if (!strcmp(member_val, "BytesPerPixel")) { ZVAL_LONG(retval, intern->format->BytesPerPixel); - } else if (!strcmp(Z_STRVAL_P(member), "Rmask")) { + } else if (!strcmp(member_val, "Rmask")) { ZVAL_LONG(retval, intern->format->Rmask); - } else if (!strcmp(Z_STRVAL_P(member), "Gmask")) { + } else if (!strcmp(member_val, "Gmask")) { ZVAL_LONG(retval, intern->format->Gmask); - } else if (!strcmp(Z_STRVAL_P(member), "Bmask")) { + } else if (!strcmp(member_val, "Bmask")) { ZVAL_LONG(retval, intern->format->Bmask); - } else if (!strcmp(Z_STRVAL_P(member), "Amask")) { + } else if (!strcmp(member_val, "Amask")) { ZVAL_LONG(retval, intern->format->Amask); - } else if (!strcmp(Z_STRVAL_P(member), "Rloss")) { + } else if (!strcmp(member_val, "Rloss")) { ZVAL_LONG(retval, intern->format->Rloss); - } else if (!strcmp(Z_STRVAL_P(member), "Gloss")) { + } else if (!strcmp(member_val, "Gloss")) { ZVAL_LONG(retval, intern->format->Gloss); - } else if (!strcmp(Z_STRVAL_P(member), "Bloss")) { + } else if (!strcmp(member_val, "Bloss")) { ZVAL_LONG(retval, intern->format->Bloss); - } else if (!strcmp(Z_STRVAL_P(member), "Aloss")) { + } else if (!strcmp(member_val, "Aloss")) { ZVAL_LONG(retval, intern->format->Aloss); - } else if (!strcmp(Z_STRVAL_P(member), "Rshift")) { + } else if (!strcmp(member_val, "Rshift")) { ZVAL_LONG(retval, intern->format->Rshift); - } else if (!strcmp(Z_STRVAL_P(member), "Gshift")) { + } else if (!strcmp(member_val, "Gshift")) { ZVAL_LONG(retval, intern->format->Gshift); - } else if (!strcmp(Z_STRVAL_P(member), "Bshift")) { + } else if (!strcmp(member_val, "Bshift")) { ZVAL_LONG(retval, intern->format->Bshift); - } else if (!strcmp(Z_STRVAL_P(member), "Ashift")) { + } else if (!strcmp(member_val, "Ashift")) { ZVAL_LONG(retval, intern->format->Ashift); - } else if (!strcmp(Z_STRVAL_P(member), "palette")) { + } else if (!strcmp(member_val, "palette")) { sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE); } else { retval = zend_std_read_property(object, member, type, cache_slot, rv); - if (member == &tmp_member) { - zval_ptr_dtor_str(&tmp_member); - } + return retval; } - if (member == &tmp_member) { - zval_dtor(member); - } return retval; } /* }}} */ @@ -1406,14 +1376,12 @@ zval *sdl_pixelformat_read_property(zval *object, zval *member, int type, void * zend_hash_str_update(props, n, sizeof(n)-1, &zv); /* {{{ sdl_pixelformat_read_property*/ -static HashTable *sdl_pixelformat_get_properties(zval *object) +static HashTable *sdl_pixelformat_get_properties(zend_object *object) { HashTable *props; zval zv; php_sdl_pixelformat *intern; - - intern = PHP_SDL_PIXELFORMAT_P(object); - + intern = php_sdl_pixelformat_from_obj(object); props = zend_std_get_properties(object); if (intern->format) { @@ -1429,9 +1397,9 @@ static HashTable *sdl_pixelformat_get_properties(zval *object) SDL_PIXELFORMAT_ADD_PROPERTY("Bloss", intern->format->Bloss); SDL_PIXELFORMAT_ADD_PROPERTY("Aloss", intern->format->Aloss); SDL_PIXELFORMAT_ADD_PROPERTY("Rshift", intern->format->Rshift); - SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Rshift); - SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Rshift); - SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Rshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Gshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Bshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Ashift); sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE); zend_hash_str_update(props, "palette", sizeof("palette")-1, &zv); @@ -1441,7 +1409,7 @@ static HashTable *sdl_pixelformat_get_properties(zval *object) /* }}} */ /* {{{ sdl_pixelformat_write_property */ -static zval *sdl_pixelformat_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *sdl_pixelformat_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { php_error_docref(NULL, E_ERROR, "Not supported, SDL_PixelFormat is read-only"); return value; @@ -1480,20 +1448,13 @@ static zend_object* php_sdl_pixels_new(zend_class_entry *class_type) /* }}} */ /* {{{ sdl_pixels_read_property*/ -zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cache_slot, zval *rv) +zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv ) { - php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); - zval *retval, tmp_member; + php_sdl_pixels *intern; + intern = php_sdl_pixels_from_obj(object); + char *member_val = ZSTR_VAL(member); - if (Z_TYPE_P(member) != IS_STRING) { - zend_string *_str = zval_try_get_string_func(member); - if (UNEXPECTED(!_str)) { - return &EG(uninitialized_zval); - } - ZVAL_STR(&tmp_member, _str); - member = &tmp_member; - cache_slot = NULL; - } + zval *retval; if (!intern->pixels.pixels) { return zend_std_read_property(object, member, type, cache_slot, rv); @@ -1501,26 +1462,21 @@ zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cach retval = rv; - if (!strcmp(Z_STRVAL_P(member), "h")) { + if (!strcmp(member_val, "h")) { ZVAL_LONG(retval, intern->pixels.h); - } else if (!strcmp(Z_STRVAL_P(member), "pitch")) { + } else if (!strcmp(member_val, "pitch")) { ZVAL_LONG(retval, intern->pixels.pitch); - } else if (!strcmp(Z_STRVAL_P(member), "count")) { + } else if (!strcmp(member_val, "count")) { ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h); } else { retval = zend_std_read_property(object, member, type, cache_slot, rv); - if (member == &tmp_member) { - zval_dtor(member); - } + return retval; } - if (member == &tmp_member) { - zval_dtor(member); - } return retval; } /* }}} */ @@ -1530,11 +1486,11 @@ zval *sdl_pixels_read_property(zval *object, zval *member, int type, void **cach zend_hash_str_update(props, n, sizeof(n)-1, &zv); /* {{{ sdl_pixels_read_properties */ -static HashTable *sdl_pixels_get_properties(zval *object) +static HashTable *sdl_pixels_get_properties(zend_object *object) { HashTable *props; zval zv; - php_sdl_pixels *intern = PHP_SDL_PIXELS_P(object); + php_sdl_pixels *intern = php_sdl_pixels_from_obj(object); props = zend_std_get_properties(object); @@ -1548,7 +1504,7 @@ static HashTable *sdl_pixels_get_properties(zval *object) /* }}} */ /* {{{ sdl_pixels_write_property */ -static zval *sdl_pixels_write_property(zval *object, zval *member, zval *value, void **cache_slot) +static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) { php_error_docref(NULL, E_ERROR, "Not supported, SDL_Pixels is read-only"); return value; @@ -1566,7 +1522,7 @@ static const zend_function_entry php_sdl_color_methods[] = { /* {{{ php_sdl_palette_methods[] */ static const zend_function_entry php_sdl_palette_methods[] = { - PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC) PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC) @@ -1584,7 +1540,7 @@ static const zend_function_entry php_sdl_palette_methods[] = { /* {{{ php_sdl_pixelformat_methods[] */ static const zend_function_entry php_sdl_pixelformat_methods[] = { - PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC) PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC) PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC) @@ -1601,7 +1557,7 @@ static const zend_function_entry php_sdl_pixelformat_methods[] = { /* {{{ php_sdl_pixels_methods[] */ static const zend_function_entry php_sdl_pixels_methods[] = { - PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC) diff --git a/src/rect.c b/src/rect.c index 9d6bd15..38112ed 100644 --- a/src/rect.c +++ b/src/rect.c @@ -45,10 +45,10 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value) { if (rect) { object_init_ex(value, php_sdl_rect_ce); - zend_update_property_long(php_sdl_rect_ce, value, "x", 1, rect->x); - zend_update_property_long(php_sdl_rect_ce, value, "y", 1, rect->y); - zend_update_property_long(php_sdl_rect_ce, value, "w", 1, rect->w); - zend_update_property_long(php_sdl_rect_ce, value, "h", 1, rect->h); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, rect->x); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, rect->y); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "w", 1, rect->w); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "h", 1, rect->h); return 1; } @@ -60,8 +60,8 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) { if (pt) { object_init_ex(value, php_sdl_point_ce); - zend_update_property_long(php_sdl_point_ce, value, "x", 1, pt->x); - zend_update_property_long(php_sdl_point_ce, value, "y", 1, pt->y); + zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, pt->x); + zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, pt->y); return 1; } @@ -74,19 +74,19 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) { zval *val, rv; - val = zend_read_property(php_sdl_rect_ce, value, "x", 1, 0, &rv); + val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = rect->x = (int)Z_LVAL_P(val); - val = zend_read_property(php_sdl_rect_ce, value, "y", 1, 0, &rv); + val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = rect->y = (int)Z_LVAL_P(val); - val = zend_read_property(php_sdl_rect_ce, value, "w", 1, 0, &rv); + val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "w", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = rect->w = (int)Z_LVAL_P(val); - val = zend_read_property(php_sdl_rect_ce, value, "h", 1, 0, &rv); + val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "h", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = rect->h = (int)Z_LVAL_P(val); @@ -102,11 +102,11 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) { zval *val, rv; - val = zend_read_property(php_sdl_point_ce, value, "x", 1, 0, &rv); + val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = pt->x = (int)Z_LVAL_P(val); - val = zend_read_property(php_sdl_point_ce, value, "y", 1, 0, &rv); + val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, 0, &rv); convert_to_long(val); Z_LVAL_P(val) = pt->y = (int)Z_LVAL_P(val); @@ -129,10 +129,10 @@ static PHP_METHOD(SDL_Rect, __construct) return; } - zend_update_property_long(php_sdl_rect_ce, getThis(), "x", 1, x); - zend_update_property_long(php_sdl_rect_ce, getThis(), "y", 1, y); - zend_update_property_long(php_sdl_rect_ce, getThis(), "w", 1, w); - zend_update_property_long(php_sdl_rect_ce, getThis(), "h", 1, h); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "x", 1, x); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "y", 1, y); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "w", 1, w); + zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(getThis()), "h", 1, h); } /* }}} */ @@ -169,8 +169,8 @@ static PHP_METHOD(SDL_Point, __construct) } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_point_ce, getThis(), "x", 1, x); - zend_update_property_long(php_sdl_point_ce, getThis(), "y", 1, y); + zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(getThis()), "x", 1, x); + zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(getThis()), "y", 1, y); } /* }}} */ diff --git a/src/shape.c b/src/shape.c index 185e739..786b81f 100644 --- a/src/shape.c +++ b/src/shape.c @@ -189,7 +189,7 @@ static const zend_function_entry php_sdl_windowshapemode_methods[] = { #define REGISTER_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("ShapeMode" const_name, value, CONST_CS | CONST_PERSISTENT); \ - zend_declare_class_constant_long(php_sdl_windowshapemode_ce, ZEND_STRL(const_name), value); \ + zend_declare_class_constant_long(php_sdl_windowshapemode_ce, const_name, sizeof(const_name)-1, value); \ /* {{{ MINIT */ PHP_MINIT_FUNCTION(sdl_shape) diff --git a/src/surface.c b/src/surface.c index 2acb03c..b66391c 100644 --- a/src/surface.c +++ b/src/surface.c @@ -113,7 +113,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface) if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) { return; } - surface = SDL_CreateRGBSurface(flags, width, height, depth, rmask, gmask, bmask, amask); + surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask); sdl_surface_to_zval(surface, return_value); } /* }}} */ @@ -196,7 +196,7 @@ static PHP_METHOD(SDL_Surface, __construct) } zend_restore_error_handling(&error_handling); - intern->surface = SDL_CreateRGBSurface(flags, width, height, depth, rmask, gmask, bmask, amask); + intern->surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask); if (intern->surface) { /* copy flags to be able to check before access to surface */ intern->flags = intern->surface->flags; @@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels) } if (h < 0 || h > src->h || h > dst->h) { h = (src->h > dst->h ? dst->h : src->h); - php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h);\ + php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h); } if (sp != src->pitch) { sp = src->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp);\ + php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp); } if (dp != dst->pitch) { dp = dst->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp);\ + php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp); } RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp)); } @@ -1287,51 +1287,49 @@ static zend_object* php_sdl_surface_new(zend_class_entry *class_type) } /* }}} */ +static inline struct php_sdl_surface* php_sdl_surface_from_obj(zend_object *obj) { + return (struct php_sdl_surface *) ((char *) (obj) - obj->handlers->offset); +} + /* {{{ sdl_surface_read_property*/ -zval *sdl_surface_read_property(zval *object, zval *member, int type, void** cache_slot, zval *retval) +zval *sdl_surface_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *retval) { - zval tmp_member; - zend_object* zobject = Z_OBJ_P(object); - struct php_sdl_surface *intern = (struct php_sdl_surface *)((char*)zobject - zobject->handlers->offset); + struct php_sdl_surface *intern; + char *member_val; - if (!intern->surface) { - ZVAL_NULL(retval); - return retval; - } + intern = php_sdl_surface_from_obj(object); + member_val = ZSTR_VAL(member); - if (Z_TYPE_P(member) != IS_STRING) { - tmp_member = *member; - zval_copy_ctor(&tmp_member); - convert_to_string(&tmp_member); - member = &tmp_member; + if (!intern->surface) { + retval = zend_std_read_property(object, member, type, cache_slot, retval); + return retval; } - if (!strcmp(Z_STRVAL_P(member), "flags")) { + if (!strcmp(member_val, "flags")) { ZVAL_LONG(retval, intern->surface->flags); - } else if (!strcmp(Z_STRVAL_P(member), "w")) { + } else if (!strcmp(member_val, "w")) { ZVAL_LONG(retval, intern->surface->w); - } else if (!strcmp(Z_STRVAL_P(member), "h")) { + } else if (!strcmp(member_val, "h")) { ZVAL_LONG(retval, intern->surface->h); - } else if (!strcmp(Z_STRVAL_P(member), "pitch")) { + } else if (!strcmp(member_val, "pitch")) { ZVAL_LONG(retval, intern->surface->pitch); - } else if (!strcmp(Z_STRVAL_P(member), "locked")) { + } else if (!strcmp(member_val, "locked")) { ZVAL_LONG(retval, intern->surface->locked); - } else if (!strcmp(Z_STRVAL_P(member), "format")) { + } else if (!strcmp(member_val, "format")) { sdl_pixelformat_to_zval(intern->surface->format, retval, SDL_DONTFREE); - } else if (!strcmp(Z_STRVAL_P(member), "clip_rect")) { + } else if (!strcmp(member_val, "clip_rect")) { sdl_rect_to_zval(&intern->surface->clip_rect, retval); - } else if (!strcmp(Z_STRVAL_P(member), "pixels")) { + } else if (!strcmp(member_val, "pixels")) { SDL_Pixels pix; pix.pitch = intern->surface->pitch; pix.h = intern->surface->h; pix.pixels = (Uint8 *)intern->surface->pixels; sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE); } else { + retval = zend_std_read_property(object, member, type, cache_slot, retval); return retval; } - if (member == &tmp_member) { - zval_dtor(member); - } + return retval; } /* }}} */ diff --git a/src/video.c b/src/video.c index bafef53..9d571c8 100644 --- a/src/video.c +++ b/src/video.c @@ -41,7 +41,7 @@ zend_class_entry *get_php_sdl_displaymode_ce(void) } #define update_displaymode_prop(z_value, name, value) \ - zend_update_property_long(php_sdl_displaymode_ce, z_value, ZEND_STRL(name), value) + zend_update_property_long(php_sdl_displaymode_ce, Z_OBJ_P(z_value), ZEND_STRL(name), value) zend_bool sdl_displaymode_to_zval(SDL_DisplayMode *display, zval *value) { @@ -61,9 +61,9 @@ zend_bool sdl_displaymode_to_zval(SDL_DisplayMode *display, zval *value) #define read_displaymode_prop(z_value, name, value) \ { \ zval *val, rv; \ - val = zend_read_property(php_sdl_displaymode_ce, z_value, ZEND_STRL(name), 0, &rv); \ + val = zend_read_property(php_sdl_displaymode_ce, Z_OBJ_P(z_value), ZEND_STRL(name), 0, &rv); \ convert_to_long(val); \ - Z_LVAL_P(val) = value = (int)Z_LVAL_P(val); \ + Z_LVAL_P(val) = (value) = (int)Z_LVAL_P(val); \ } zend_bool zval_to_sdl_displaymode(zval *value, SDL_DisplayMode *display) @@ -526,7 +526,7 @@ PHP_FUNCTION(SDL_DisableScreenSaver) /* {{{ php_sdl_displaymode_methods[] */ static const zend_function_entry php_sdl_displaymode_methods[] = { - PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) + PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_PUBLIC) PHP_ME(SDL_DisplayMode, __toString, arginfo_video_none, ZEND_ACC_PUBLIC) PHP_FE_END @@ -543,8 +543,8 @@ PHP_MINIT_FUNCTION(sdl_video) memcpy(&php_sdl_displaymode_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("format"), 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("w"), 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("h"), 0, ZEND_ACC_PUBLIC); + zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("w"), 0, ZEND_ACC_PUBLIC); + zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("h"), 0, ZEND_ACC_PUBLIC); zend_declare_property_long(php_sdl_displaymode_ce, ZEND_STRL("refresh_rate"), 0, ZEND_ACC_PUBLIC); return SUCCESS; diff --git a/src/window.c b/src/window.c index 0cfdfc6..4522057 100644 --- a/src/window.c +++ b/src/window.c @@ -69,12 +69,12 @@ static inline void sdl_window_add_long_property(HashTable *props, const char *na } /* {{{ sdl_window_read_property*/ -static HashTable *sdl_window_get_properties(zval *object) +static HashTable *sdl_window_get_properties(zend_object *object) { HashTable *props; zend_string* z_string; zval zv; - struct php_sdl_window* intern = php_sdl_window_fetch_object(Z_OBJ_P(object)); + struct php_sdl_window* intern = php_sdl_window_fetch_object(object); props = zend_std_get_properties(object); From 9475a300e802e5e4163c973acd4d5c4b033554a8 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 18 Jun 2021 19:35:42 +0100 Subject: [PATCH 14/55] Remove EXPERIMENTAL file --- EXPERIMENTAL | 5 ----- package.xml | 1 - 2 files changed, 6 deletions(-) delete mode 100644 EXPERIMENTAL diff --git a/EXPERIMENTAL b/EXPERIMENTAL deleted file mode 100644 index 6443e99..0000000 --- a/EXPERIMENTAL +++ /dev/null @@ -1,5 +0,0 @@ -this extension is experimental, -its functions may change their names -or move to extension all together -so do not rely to much on them -you have been warned! diff --git a/package.xml b/package.xml index dd393bd..9d8528d 100644 --- a/package.xml +++ b/package.xml @@ -42,7 +42,6 @@ - From 13f7f76be5726e098afa17c5d2285d0de994a9b1 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 18 Jun 2021 19:36:45 +0100 Subject: [PATCH 15/55] Add Manuel to CREDITS file --- CREDITS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CREDITS b/CREDITS index 417db3b..19a36f5 100644 --- a/CREDITS +++ b/CREDITS @@ -1,2 +1,2 @@ SDL -Santiago Lizardo, Remi Collet +Santiago Lizardo, Remi Collet, Manuel Baldassarri From 561fd47e02d8b25b5c905661911ce895706a8626 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 18 Jun 2021 19:41:00 +0100 Subject: [PATCH 16/55] Remove php_error warnings --- src/pixels.c | 10 +++++----- src/surface.c | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pixels.c b/src/pixels.c index 2e67fd0..f9b913e 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -690,15 +690,15 @@ PHP_FUNCTION(SDL_SetPaletteColors) if (ncolors <= 0) { ncolors = count; } else if (ncolors > count) { - php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %lld", count, ncolors); + php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors); ncolors = count; } if (first >= intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid first color index, %lld >= %d", first, intern->palette->ncolors); + php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors); RETURN_LONG(-1); } if (first+ncolors > intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid color number, %lld > %d", first+ncolors, intern->palette->ncolors); + php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors); RETURN_LONG(-1); } colors = emalloc(sizeof(SDL_Color) * ncolors); @@ -1120,7 +1120,7 @@ PHP_METHOD(SDL_Pixels, GetByte) intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); + php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); @@ -1147,7 +1147,7 @@ PHP_METHOD(SDL_Pixels, SetByte) intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%lld,%lld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); + php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); diff --git a/src/surface.c b/src/surface.c index b66391c..7716fe6 100644 --- a/src/surface.c +++ b/src/surface.c @@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels) } if (h < 0 || h > src->h || h > dst->h) { h = (src->h > dst->h ? dst->h : src->h); - php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h); + php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h); } if (sp != src->pitch) { sp = src->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp); + php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp); } if (dp != dst->pitch) { dp = dst->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp); + php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp); } RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp)); } From ac8197fab469809e4dbec83027db124190e66295 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 18 Jun 2021 19:41:46 +0100 Subject: [PATCH 17/55] Make PHP8 requirement explicit --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3938853..3eadd15 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allo * C compiler * Automake tools -* PHP devel +* PHP8 devel * libSDL2 devel libraries and headers * UN*X OS (eg Linux, Macos) From 0076e48a150461edbbbf7eaf2448d15def7221a1 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 18 Jun 2021 19:53:19 +0100 Subject: [PATCH 18/55] Bump version to 2.5.0 --- package.xml | 85 +++++++++++++++++++++++++++++++-------------------- src/php_sdl.h | 2 +- 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/package.xml b/package.xml index 9d8528d..a282e0e 100644 --- a/package.xml +++ b/package.xml @@ -1,5 +1,7 @@ - + sdl pecl.php.net SDL for PHP @@ -17,11 +19,11 @@ yes - 2020-08-23 + 2021-06-18 - 2.4.0 - 2.4.0 + 2.5.0 + 2.5.0 devel @@ -29,13 +31,8 @@ PHP - - Fix duplicate symbols (remicollet) - - Fix parameters passed by reference in rect module (kea) - - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea) - - Fix surface props initialisation (kea) - - Fix surface and powerinfo params by ref (kea) - - Fix SDL_Rect inheritance issue (santiagolizardo) - - Add SQL_QueryTexture binding (kea) + - Add support for PHP8 (Manuel Baldassarri) + - Remove support for PHP7 (Manuel Baldassarri) @@ -147,7 +144,7 @@ - 7.4.0 + 8.0.0 1.10.0 @@ -157,23 +154,45 @@ sdl - - 2019-09-08 - - - 2.3.0 - 2.3.0 - - - devel - devel - - PHP - + + 2020-08-23 + + + 2.4.0 + 2.4.0 + + + devel + devel + + PHP + + - Fix duplicate symbols (remicollet) + - Fix parameters passed by reference in rect module (kea) + - Port SDL_Palette and SDL_PixelFormat to PHP7 (kea) + - Fix surface props initialisation (kea) + - Fix surface and powerinfo params by ref (kea) + - Fix SDL_Rect inheritance issue (santiagolizardo) + - Add SQL_QueryTexture binding (kea) + + + + 2019-09-08 + + + 2.3.0 + 2.3.0 + + + devel + devel + + PHP + - Fix out of bounds error (remicollet) - Add basic joystick/gamepad support (santiagolizardo) - - + + 2019-09-02 @@ -189,7 +208,7 @@ - Fix undefined symbol (sdl_window_to_zval) - Tidy up GL context creation - + 2019-08-28 @@ -204,10 +223,10 @@ PHP - - Add support for window events. (Benoit Viguier) - - Add support for the SDL_RenderCopyEx, SDL_RenderDrawLine and SDL_RenderDrawRect functions. (Benoit Viguier) - - Fix memory leak in the SDL_RenderCopy function. (Benoit Viguier) - + - Add support for window events. (Benoit Viguier) + - Add support for the SDL_RenderCopyEx, SDL_RenderDrawLine and SDL_RenderDrawRect functions. (Benoit Viguier) + - Fix memory leak in the SDL_RenderCopy function. (Benoit Viguier) + @@ -224,7 +243,7 @@ - Code updated to support PHP7. - Code that could be implemented in userland was removed from the extension. - Unit tests improvements/changes. - + diff --git a/src/php_sdl.h b/src/php_sdl.h index ac2d6ee..bd8a498 100644 --- a/src/php_sdl.h +++ b/src/php_sdl.h @@ -32,7 +32,7 @@ extern "C" { #include #include -#define PHP_SDL_VERSION "2.4.0" +#define PHP_SDL_VERSION "2.5.0" #if defined(__APPLE__) && defined(__MACH__) #include From bc9f203bfe16c93bfdf4735202df671fe79b5753 Mon Sep 17 00:00:00 2001 From: Zorobabel Date: Tue, 12 Oct 2021 14:14:31 -0500 Subject: [PATCH 19/55] Config file for Windows (#53) * Config file for Windows * Tabs removed --- config.w32 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 config.w32 diff --git a/config.w32 b/config.w32 new file mode 100644 index 0000000..5c35324 --- /dev/null +++ b/config.w32 @@ -0,0 +1,18 @@ +// vim:ft=javascript + +ARG_ENABLE('sdl', 'Whether to enable SDL2 support', 'no'); + +if(PHP_SDL != 'no') { + CHECK_LIB("SDL2.lib", "sdl", PHP_SDL); + CHECK_LIB("SDL2main.lib", "sdl", PHP_SDL); + CHECK_LIB("SDL2test.lib", "sdl", PHP_SDL); + + var sdl_sources = 'php_sdl.c blendmode.c cpuinfo.c error.c event.c filesystem.c glcontext.c joystick.c keyboard.c messagebox.c mouse.c mutex.c pixels.c platform.c power.c rect.c render.c rwops.c sdl.c shape.c surface.c timer.c version.c video.c window.c'; + + EXTENSION('sdl', sdl_sources, PHP_SDL_SHARED); + + var sdl_headers = 'php_sdl.h blendmode.h cpuinfo.h error.h event.h filesystem.h glcontext.h joystick.h keyboard.h messagebox.h mouse.h mutex.h pixels.h platform.h power.h rect.h render.h rwops.h sdl.h shape.h surface.h timer.h version.h video.h window.h'; + + PHP_INSTALL_HEADERS('ext/sdl', sdl_headers); + AC_DEFINE('HAVE_SDL', 1); +} From ca7eb21022d734a2287459612673e056803d8511 Mon Sep 17 00:00:00 2001 From: Manuel Baldassarri Date: Sun, 31 Oct 2021 22:31:02 +0100 Subject: [PATCH 20/55] Rename width parameter in SDL_Rect::__construct() (#54) fix "Duplicate parameter name $y for function SDL_Rect::__construct()" --- src/rect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rect.h b/src/rect.h index 91168d5..718c1d1 100644 --- a/src/rect.h +++ b/src/rect.h @@ -39,7 +39,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect__construct, /*unused*/0, /*ret ref*/0, / ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) ZEND_END_ARG_INFO() From 36956f39c93448172f58cd9aff64fd8a4a895118 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sat, 11 Dec 2021 22:34:10 +0000 Subject: [PATCH 21/55] Add SDL_PointInRect function --- .gitignore | 1 + examples/001-sdl-version.php | 4 +--- examples/002-error-messagebox.php | 10 +++++----- examples/003-messagebox-inputs.php | 23 +++++++++++++---------- examples/bootstrap.php | 16 ++++++++++++++-- src/messagebox.c | 2 ++ src/php_sdl.c | 1 + src/rect.c | 18 ++++++++++++++++++ src/rect.h | 6 ++++++ tests/029-point-in-rect.phpt | 17 +++++++++++++++++ 10 files changed, 78 insertions(+), 20 deletions(-) create mode 100644 tests/029-point-in-rect.phpt diff --git a/.gitignore b/.gitignore index a3f5442..e49381f 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,4 @@ php_test_results*.txt configure.ac .vscode .DS_Store +tags diff --git a/examples/001-sdl-version.php b/examples/001-sdl-version.php index f544161..8828e30 100644 --- a/examples/001-sdl-version.php +++ b/examples/001-sdl-version.php @@ -1,6 +1,4 @@ - new SDL_MessageBoxColor(0, 0, 0), @@ -21,6 +22,8 @@ SDL_MessageBoxColor::BUTTON_SELECTED => new SDL_MessageBoxColor(0, 0, 255), ]; $dialog = new SDL_MessageBoxData(SDL_MessageBoxData::INFORMATION, "Message box data", 'Select Yes or No', $buttons, $colors); -$dialog->Show($buttonId); - -echo 'Button selection: ', var_export($buttonId), PHP_EOL; +if(0 === $dialog->Show($buttonId)) { + echo 'Button selection: ', $buttonId === BUTTON_ID_YES ? 'Yes' : 'No', PHP_EOL; +} else { + printSdlErrorAndExit(); +} diff --git a/examples/bootstrap.php b/examples/bootstrap.php index 417728c..b635538 100644 --- a/examples/bootstrap.php +++ b/examples/bootstrap.php @@ -1,8 +1,20 @@ - +SUITE: End +--EXPECTF-- +SUITE: Start +bool(false) +bool(true) +SUITE: End From fcb80722e9f2060903c807d2c16cc690bc8bf122 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Tue, 18 Jan 2022 20:26:50 +0000 Subject: [PATCH 22/55] Update license --- LICENSE | 69 ++++----------------------------------------------------- 1 file changed, 4 insertions(+), 65 deletions(-) diff --git a/LICENSE b/LICENSE index 42536af..e4e776b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,68 +1,7 @@ --------------------------------------------------------------------- - The PHP License, version 3.01 -Copyright (c) 1999 - 2012 The PHP Group. All rights reserved. --------------------------------------------------------------------- +Copyright 2022 Santiago Lizardo -Redistribution and use in source and binary forms, with or without -modification, is permitted provided that the following conditions -are met: +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the - distribution. - - 3. The name "PHP" must not be used to endorse or promote products - derived from this software without prior written permission. For - written permission, please contact group@php.net. - - 4. Products derived from this software may not be called "PHP", nor - may "PHP" appear in their name, without prior written permission - from group@php.net. You may indicate that your software works in - conjunction with PHP by saying "Foo for PHP" instead of calling - it "PHP Foo" or "phpfoo" - - 5. The PHP Group may publish revised and/or new versions of the - license from time to time. Each version will be given a - distinguishing version number. - Once covered code has been published under a particular version - of the license, you may always continue to use it under the terms - of that version. You may also choose to use such covered code - under the terms of any subsequent version of the license - published by the PHP Group. No one other than the PHP Group has - the right to modify the terms applicable to covered code created - under this License. +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - 6. Redistributions of any form whatsoever must retain the following - acknowledgment: - "This product includes PHP software, freely available from - ". - -THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND -ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP -DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, -INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED -OF THE POSSIBILITY OF SUCH DAMAGE. - --------------------------------------------------------------------- - -This software consists of voluntary contributions made by many -individuals on behalf of the PHP Group. - -The PHP Group can be contacted via Email at group@php.net. - -For more information on the PHP Group and the PHP project, -please see . - -PHP includes the Zend Engine, freely available at -. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From db76b1264fb3e1e50e29803bf0584121f2f3dc10 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Tue, 18 Jan 2022 20:27:09 +0000 Subject: [PATCH 23/55] Use HTTPS in URL --- src/blendmode.c | 2 +- src/cpuinfo.c | 2 +- src/error.c | 2 +- src/event.c | 2 +- src/filesystem.c | 2 +- src/glcontext.c | 2 +- src/keyboard.c | 2 +- src/messagebox.c | 2 +- src/mouse.c | 2 +- src/mutex.c | 2 +- src/php_sdl.c | 2 +- src/pixels.c | 2 +- src/platform.c | 2 +- src/power.c | 2 +- src/rect.c | 2 +- src/render.c | 2 +- src/rwops.c | 2 +- src/sdl.c | 2 +- src/shape.c | 2 +- src/surface.c | 2 +- src/timer.c | 2 +- src/version.c | 2 +- src/video.c | 2 +- src/window.c | 2 +- 24 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/blendmode.c b/src/blendmode.c index c088e53..decb075 100644 --- a/src/blendmode.c +++ b/src/blendmode.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/cpuinfo.c b/src/cpuinfo.c index fc9d1af..eba2dae 100644 --- a/src/cpuinfo.c +++ b/src/cpuinfo.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/error.c b/src/error.c index 4b1d3ce..dc99886 100644 --- a/src/error.c +++ b/src/error.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/event.c b/src/event.c index 027dbf3..a015ed7 100644 --- a/src/event.c +++ b/src/event.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/filesystem.c b/src/filesystem.c index 3cdc93b..9bf9263 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/glcontext.c b/src/glcontext.c index 889bdab..f285047 100644 --- a/src/glcontext.c +++ b/src/glcontext.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/keyboard.c b/src/keyboard.c index 6a76c6a..cec4b62 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/messagebox.c b/src/messagebox.c index 3aadf53..8613231 100644 --- a/src/messagebox.c +++ b/src/messagebox.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/mouse.c b/src/mouse.c index aa59cd1..3f60e05 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/mutex.c b/src/mutex.c index 5bd65c7..d2825a5 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/php_sdl.c b/src/php_sdl.c index 38938f9..5356520 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/pixels.c b/src/pixels.c index f9b913e..26a5388 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/platform.c b/src/platform.c index 40d1268..81f0baf 100644 --- a/src/platform.c +++ b/src/platform.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/power.c b/src/power.c index d59b4be..8628c4e 100644 --- a/src/power.c +++ b/src/power.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/rect.c b/src/rect.c index aee9676..9e9cda1 100644 --- a/src/rect.c +++ b/src/rect.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/render.c b/src/render.c index 1e874c9..8f1d143 100644 --- a/src/render.c +++ b/src/render.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/rwops.c b/src/rwops.c index 290830d..5d0400e 100644 --- a/src/rwops.c +++ b/src/rwops.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/sdl.c b/src/sdl.c index 2f4eabf..2ab6bb3 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/shape.c b/src/shape.c index 786b81f..99c086b 100644 --- a/src/shape.c +++ b/src/shape.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/surface.c b/src/surface.c index 7716fe6..ec39c4c 100644 --- a/src/surface.c +++ b/src/surface.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/timer.c b/src/timer.c index 67c0af9..d0cd321 100644 --- a/src/timer.c +++ b/src/timer.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/version.c b/src/version.c index 69cea57..184bdfd 100644 --- a/src/version.c +++ b/src/version.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/video.c b/src/video.c index 9d571c8..5670e04 100644 --- a/src/video.c +++ b/src/video.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | diff --git a/src/window.c b/src/window.c index 4522057..71c6a16 100644 --- a/src/window.c +++ b/src/window.c @@ -7,7 +7,7 @@ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | - | http://www.php.net/license/3_01.txt | + | https://www.php.net/license/3_01.txt | | If you did not receive a copy of the PHP license and are unable to | | obtain it through the world-wide-web, please send a note to | | license@php.net so we can mail you a copy immediately. | From e70f1f41af0f29ab7616110d3418ff435c9670c2 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Tue, 18 Jan 2022 20:27:17 +0000 Subject: [PATCH 24/55] Update git ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e49381f..cf929d8 100644 --- a/.gitignore +++ b/.gitignore @@ -59,3 +59,4 @@ configure.ac .vscode .DS_Store tags +*.dep From 9a942c58b39b1e32e6ec737e1d8938b39cc44bbc Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Wed, 19 Jan 2022 21:42:02 +0000 Subject: [PATCH 25/55] Update README --- README.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 3eadd15..f8d8de8 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allo * C compiler * Automake tools -* PHP8 devel +* PHP8.1 devel * libSDL2 devel libraries and headers * UN*X OS (eg Linux, Macos) @@ -40,17 +40,17 @@ The SDL extension mimics in almost every single aspect to the official C library Standard SDL2 API is available in procedural style: ```php - $window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE); - SDL_SetWindowTitle($window, "Some new title"); - SDL_DestroyWindow($window); +$window = SDL_CreateWindow( "Foo window", 500, 50, 350, 300, SDL_WINDOW_SHOWN+SDL_WINDOW_RESIZABLE); +SDL_SetWindowTitle($window, "Some new title"); +SDL_DestroyWindow($window); ``` And is also available in object oriented style: ```php - $window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE); - $window->SetTitle("Some new title"); - unset($window); // will destroy the window +$window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE); +$window->SetTitle("Some new title"); +unset($window); // will destroy the window ``` Complete examples can be found in the [examples](examples) folder. @@ -68,15 +68,10 @@ Complete examples can be found in the [examples](examples) folder. To compile your new extension, you will have to execute the following steps: ```bash -$ phpize -$ ./configure [--enable--sdl] -$ make -$ make test -$ [sudo] make install +phpize +./configure [--enable--sdl] +make +make test +[sudo] make install ``` -## Support and feature requests - -Please submit anything that needs our attention to the [issues section](https://github.com/php-sdl/extension/issues) on Github. We are commited to attend any request in a short timespan if it's a sensible matter. - - From f765d7797b04979bfeb3fd37d95445e20c45ab4f Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Wed, 19 Jan 2022 22:35:40 +0000 Subject: [PATCH 26/55] Fix broken UTs --- README.md | 4 ++-- src/pixels.c | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f8d8de8..67b0a6b 100644 --- a/README.md +++ b/README.md @@ -69,9 +69,9 @@ To compile your new extension, you will have to execute the following steps: ```bash phpize -./configure [--enable--sdl] +./configure [--with--sdl] make make test -[sudo] make install +sudo make install ``` diff --git a/src/pixels.c b/src/pixels.c index 26a5388..04af620 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -548,9 +548,9 @@ static PHP_METHOD(SDL_Palette, count) } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offset, 0, 0, 1) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetExists, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO(); /* {{{ proto SDL_Palette, offsetExists(int offset) */ PHP_METHOD(SDL_Palette, offsetExists) @@ -569,6 +569,10 @@ PHP_METHOD(SDL_Palette, offsetExists) } /* }}} */ +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetGet, 0, 1, IS_MIXED, 1) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO(); + /* {{{ proto SDL_Palette, offsetGet(int offset) */ PHP_METHOD(SDL_Palette, offsetGet) { @@ -587,6 +591,10 @@ PHP_METHOD(SDL_Palette, offsetGet) } /* }}} */ +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetUnset, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO(); + /* {{{ proto SDL_Palette, offsetUnset(int offset) */ PHP_METHOD(SDL_Palette, offsetUnset) { @@ -607,11 +615,12 @@ PHP_METHOD(SDL_Palette, offsetUnset) } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 2, IS_VOID, 0) ZEND_ARG_INFO(0, offset) ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() + /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */ PHP_METHOD(SDL_Palette, offsetSet) { @@ -1021,9 +1030,9 @@ static PHP_METHOD(SDL_Pixels, count) } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offset, 0, 0, 1) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetExists, 0, 1, _IS_BOOL, 0) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO(); /* {{{ proto SDL_Pixels, offsetExists(int offset) */ PHP_METHOD(SDL_Pixels, offsetExists) @@ -1042,6 +1051,10 @@ PHP_METHOD(SDL_Pixels, offsetExists) } /* }}} */ +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetGet, 0, 1, IS_MIXED, 1) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO(); + /* {{{ proto SDL_Pixels, offsetGet(int offset) */ PHP_METHOD(SDL_Pixels, offsetGet) { @@ -1060,6 +1073,10 @@ PHP_METHOD(SDL_Pixels, offsetGet) } /* }}} */ +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetUnset, 0, 1, IS_VOID, 0) + ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO(); + /* {{{ proto SDL_Pixels, offsetUnset(int offset) */ PHP_METHOD(SDL_Pixels, offsetUnset) { @@ -1078,7 +1095,7 @@ PHP_METHOD(SDL_Pixels, offsetUnset) } /* }}} */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 0, 2) +ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 2, IS_VOID, 0) ZEND_ARG_INFO(0, offset) ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() @@ -1525,10 +1542,10 @@ static const zend_function_entry php_sdl_palette_methods[] = { PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC) PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists,ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC) /* non-static methods */ PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none) @@ -1560,10 +1577,10 @@ static const zend_function_entry php_sdl_pixels_methods[] = { PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC) PHP_FE_END From 719c474eb70eb83e0a152c60655c93e8d907ed2b Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Wed, 19 Jan 2022 23:04:07 +0000 Subject: [PATCH 27/55] Use github actions --- .github/workflows/build-test.yml | 16 ++++++++++++++++ .travis.yml | 11 ----------- Dockerfile | 8 +++++--- 3 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 .github/workflows/build-test.yml delete mode 100644 .travis.yml diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml new file mode 100644 index 0000000..c08e836 --- /dev/null +++ b/.github/workflows/build-test.yml @@ -0,0 +1,16 @@ +name: Build and test + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - name: Build and tag image + run: docker build -t ponup/php-sdl . + - name: Run tests + run: docker run --rm ponup/php-sdl diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index ad9cae6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -language: php - -services: - - docker - -before_install: - - docker build -t ponup/php-sdl . - -script: - - docker run --rm ponup/php-sdl - diff --git a/Dockerfile b/Dockerfile index a77b5b9..46322f9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,6 @@ -FROM debian:10 +FROM debian:11 + +ARG TARGET_PHP_VERSION=8.1 RUN apt-get update RUN apt-get install -y make build-essential wget @@ -6,7 +8,7 @@ RUN apt-get install -y lsb-release apt-transport-https ca-certificates RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list RUN apt-get update -RUN apt-get install -y php8.0-dev +RUN apt-get install -y php${TARGET_PHP_VERSION}-dev RUN apt-get install -y libsdl2-dev RUN apt-get install -y xvfb COPY . /opt/php-sdl @@ -15,7 +17,7 @@ RUN phpize RUN ./configure RUN make RUN make install -RUN echo "extension=sdl.so" >> /etc/php/8.0/cli/php.ini +RUN echo "extension=sdl.so" >> /etc/php/${TARGET_PHP_VERSION}/cli/php.ini ENTRYPOINT ["/opt/php-sdl/docker-entrypoint.sh"] From a78881cb93fc61c1332ca99e5f06b440c3a01d7d Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Wed, 19 Jan 2022 23:07:30 +0000 Subject: [PATCH 28/55] Remove travis badge --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 67b0a6b..833e7cf 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ - -[![Build Status](https://travis-ci.org/Ponup/php-sdl.svg?branch=master)](https://travis-ci.org/Ponup/php-sdl) - PHP-SDL ======= From 921984f21fcc2036fd6559a635e3405ec89e5edd Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sun, 23 Jan 2022 18:48:39 +0000 Subject: [PATCH 29/55] Show badge in readme --- .github/workflows/build-test.yml | 2 +- README.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index c08e836..2ea5cd9 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -6,7 +6,7 @@ on: - master jobs: - build: + main: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 diff --git a/README.md b/README.md index 833e7cf..5f0c28f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ +[![Build and test](https://github.com/Ponup/php-sdl/actions/workflows/build-test.yml/badge.svg)](https://github.com/Ponup/php-sdl/actions/workflows/build-test.yml) + PHP-SDL ======= From 00800c1dee42d2131caa7c7b438f73ad304d2c95 Mon Sep 17 00:00:00 2001 From: Manuel Baldassarri Date: Mon, 7 Mar 2022 20:26:35 +0100 Subject: [PATCH 30/55] Add SDL functions binding of float rect and float point render functions (#57) * Add stub for rect * Fix "wrong type" warnings * Add SDL_FRect and SDL_FPoint classes * Add SDL_FRectEmpty, SDL_HasIntersectionF and SDL_IntersectFRect Add tests and some SDL_FRect/SDL_FPoint fixes * Add SDL_RenderDrawPointF, SDL_RenderDrawLineF,SDL_RenderDrawRectF,SDL_RenderFillRectF, SDL_RenderCopyF and SDL_RenderCopyExF binding --- .gitignore | 1 + examples/011-draw-with-subpixels.php | 122 ++++++++++ src/php_sdl.c | 20 +- src/pixels.c | 10 +- src/rect.c | 346 ++++++++++++++++++++++----- src/rect.h | 81 +------ src/rect.stub.php | 76 ++++++ src/rect_arginfo.h | 321 +++++++++++++++++++++++++ src/render.c | 165 +++++++++++++ src/render.h | 50 ++++ src/surface.c | 6 +- tests/006-rect.phpt | 86 ++++++- tests/007-rect-oo.phpt | 60 ++++- tests/014-version.phpt | 2 +- tests/017-rwops-stream.phpt | 2 +- tests/028-point.phpt | 6 + 16 files changed, 1207 insertions(+), 147 deletions(-) create mode 100644 examples/011-draw-with-subpixels.php create mode 100644 src/rect.stub.php create mode 100644 src/rect_arginfo.h diff --git a/.gitignore b/.gitignore index cf929d8..4e12ae7 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.lo *.la .deps +*.dep .libs Makefile Makefile.fragments diff --git a/examples/011-draw-with-subpixels.php b/examples/011-draw-with-subpixels.php new file mode 100644 index 0000000..889d0a0 --- /dev/null +++ b/examples/011-draw-with-subpixels.php @@ -0,0 +1,122 @@ +clip_rect; +$drect->y = 500; +$dfrect = new SDL_FRect($drect->x, $drect->y, $drect->w, $drect->h); + +// Draw lines +function line($iteration, $renderer) +{ + $x1 = 40.0; + $y1 = 40.0 + $iteration; + $x2 = SQUARE; + $y2 = SQUARE - $iteration; + + SDL_RenderDrawLineF($renderer, $x1, $y1, $x2, $y2); +} + +// Draw rects +function rect($iteration, $renderer) +{ + $x1 = SQUARE + 20 + $iteration/2; + $y1 = SQUARE + $iteration/2 + 20; + $w = SQUARE - 10 - $iteration; + $h = SQUARE - 10 - $iteration; + $rect1 = new SDL_FRect($x1, $y1, $w, $h); + $rect2 = new SDL_FRect($x1 + 50, $y1 + 50, $w - 100 , $h - 100); + SDL_RenderDrawRectF($renderer, $rect1); + SDL_RenderFillRectF($renderer, $rect2); +} + +// Draw points +function points($iteration, $renderer) +{ + for ($x = SQUARE + 80; $x < WINDOW_WIDTH - 60; $x++) { + $y = sin($x*6/SQUARE + $iteration/10) * 120 + 250; + SDL_RenderDrawPointF($renderer, (float) $x, $y); + } +} + +// Draw sprites +function sprites($iteration, $renderer, $destRect, $destFRect, $texture) +{ + $destFRect->x = $iteration; + $destRect->x = (int) $destFRect->x + 100; + if (SDL_RenderCopyEx($renderer, $texture, null, $destRect, $iteration, null, SDL_FLIP_NONE) != 0) { + echo SDL_GetError(), PHP_EOL; + } + if (SDL_RenderCopyExF($renderer, $texture, null, $destFRect, $iteration, null, SDL_FLIP_NONE) != 0) { + echo SDL_GetError(), PHP_EOL; + } + + $destRect2 = clone $destRect; + $destFRect2 = clone $destFRect; + $destRect2->y += 100; + $destFRect2->y += 100; + if (SDL_RenderCopy($renderer, $texture, null, $destRect2) != 0) { + echo SDL_GetError(), PHP_EOL; + } + if (SDL_RenderCopyF($renderer, $texture, null, $destFRect2) != 0) { + echo SDL_GetError(), PHP_EOL; + } +} + +function getIncrement($i, $increment) +{ + if ($i > SQUARE) { + return -0.20; + } + + if ($i < 20.0) { + return 0.20; + } + + return $increment; +} + +// Wait for quit event +$event = new SDL_Event; +$i = .0; +$increment = 0.20; + +while (true) { + if (SDL_PollEvent($event) && $event->type == SDL_QUIT) { + break; + } + // Clear screen + SDL_SetRenderDrawColor($renderer, 47, 79, 79, 255); + SDL_RenderClear($renderer); + + SDL_SetRenderDrawColor($renderer, 230, 230, 230, 255); + $increment = getIncrement($i, $increment); + $i += $increment; + line($i, $renderer); + rect($i, $renderer); + points($i, $renderer); + sprites($i, $renderer, $drect, $dfrect, $texture); + + SDL_RenderPresent($renderer); + SDL_Delay(5); +} + +SDL_DestroyRenderer($renderer); +SDL_DestroyWindow($window); +SDL_Quit(); diff --git a/src/php_sdl.c b/src/php_sdl.c index 5356520..2785d3e 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -33,6 +33,7 @@ #include "power.h" #include "pixels.h" #include "rect.h" +#include "rect_arginfo.h" #include "render.h" #include "rwops.h" #include "sdl.h" @@ -220,6 +221,13 @@ static zend_function_entry sdl_functions[] = { ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget) ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize) + ZEND_FE(SDL_RenderDrawPointF, arginfo_SDL_RenderDrawPointF) + ZEND_FE(SDL_RenderDrawLineF, arginfo_SDL_RenderDrawLineF) + ZEND_FE(SDL_RenderDrawRectF, arginfo_SDL_RenderDrawRectF) + ZEND_FE(SDL_RenderFillRectF, arginfo_SDL_RenderFillRectF) + ZEND_FE(SDL_RenderCopyF, arginfo_SDL_RenderCopyF) + ZEND_FE(SDL_RenderCopyExF, arginfo_SDL_RenderCopyExF) + // Surface ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface) ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface) @@ -255,15 +263,19 @@ static zend_function_entry sdl_functions[] = { //PHP_FALIAS(SDL_BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) // Rect - ZEND_FE(SDL_RectEmpty, arginfo_SDL_Rect) - ZEND_FE(SDL_RectEquals, arginfo_SDL_Rect2) - ZEND_FE(SDL_HasIntersection, arginfo_SDL_Rect2) + ZEND_FE(SDL_RectEmpty, arginfo_SDL_RectEmpty) + ZEND_FE(SDL_RectEquals, arginfo_SDL_RectEquals) + ZEND_FE(SDL_HasIntersection, arginfo_SDL_HasIntersection) ZEND_FE(SDL_IntersectRect, arginfo_SDL_IntersectRect) - ZEND_FE(SDL_UnionRect, arginfo_SDL_Rect3) + ZEND_FE(SDL_UnionRect, arginfo_SDL_UnionRect) ZEND_FE(SDL_IntersectRectAndLine, arginfo_SDL_IntersectRectAndLine) ZEND_FE(SDL_EnclosePoints, arginfo_SDL_EnclosePoints) ZEND_FE(SDL_PointInRect, arginfo_SDL_PointInRect) + ZEND_FE(SDL_FRectEmpty, arginfo_SDL_FRectEmpty) + ZEND_FE(SDL_HasIntersectionF, arginfo_SDL_HasIntersectionF) + ZEND_FE(SDL_IntersectFRect, arginfo_SDL_IntersectFRect) + // Events ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent) ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent) diff --git a/src/pixels.c b/src/pixels.c index 04af620..8f8cee0 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -699,15 +699,15 @@ PHP_FUNCTION(SDL_SetPaletteColors) if (ncolors <= 0) { ncolors = count; } else if (ncolors > count) { - php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, ncolors); + php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long) ncolors); ncolors = count; } if (first >= intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", first, intern->palette->ncolors); + php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long) first, intern->palette->ncolors); RETURN_LONG(-1); } if (first+ncolors > intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", first+ncolors, intern->palette->ncolors); + php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long) (first+ncolors), intern->palette->ncolors); RETURN_LONG(-1); } colors = emalloc(sizeof(SDL_Color) * ncolors); @@ -1137,7 +1137,7 @@ PHP_METHOD(SDL_Pixels, GetByte) intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); + php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); @@ -1164,7 +1164,7 @@ PHP_METHOD(SDL_Pixels, SetByte) intern = PHP_SDL_PIXELS_P(z_pixels); if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", x, y, intern->pixels.pitch, intern->pixels.h); + php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); diff --git a/src/rect.c b/src/rect.c index 9e9cda1..11d8821 100644 --- a/src/rect.c +++ b/src/rect.c @@ -18,27 +18,50 @@ */ #include "rect.h" +#include "rect_arginfo.h" static zend_class_entry *php_sdl_rect_ce; static zend_object_handlers php_sdl_rect_handlers; struct php_sdl_rect { - zend_object zo; + zend_object zo; +}; + +static zend_class_entry *php_sdl_frect_ce; +static zend_object_handlers php_sdl_frect_handlers; +struct php_sdl_frect { + zend_object zo; }; static zend_class_entry *php_sdl_point_ce; static zend_object_handlers php_sdl_point_handlers; struct php_sdl_point { - zend_object zo; + zend_object zo; }; +static zend_class_entry *php_sdl_fpoint_ce; +static zend_object_handlers php_sdl_fpoint_handlers; +struct php_sdl_fpoint { + zend_object zo; +}; + +zend_class_entry *get_php_sdl_rect_ce(void) +{ + return php_sdl_rect_ce; +} + +zend_class_entry *get_php_sdl_frect_ce(void) +{ + return php_sdl_frect_ce; +} + zend_class_entry *get_php_sdl_point_ce(void) { return php_sdl_point_ce; } -zend_class_entry *get_php_sdl_rect_ce(void) +zend_class_entry *get_php_sdl_fpoint_ce(void) { - return php_sdl_rect_ce; + return php_sdl_fpoint_ce; } zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value) @@ -56,6 +79,21 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value) return 0; } +zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value) +{ + if (rect) { + object_init_ex(value, php_sdl_frect_ce); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, rect->x); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, rect->y); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "w", 1, rect->w); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "h", 1, rect->h); + + return 1; + } + ZVAL_NULL(value); + return 0; +} + zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) { if (pt) { @@ -69,6 +107,19 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) return 0; } +zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value) +{ + if (pt) { + object_init_ex(value, php_sdl_fpoint_ce); + zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, pt->x); + zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, pt->y); + + return 1; + } + ZVAL_NULL(value); + return 0; +} + zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) { if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) { @@ -97,6 +148,34 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) return 0; } +zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect) +{ + if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce)) { + zval *val, rv; + + val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, 0, &rv); + convert_to_double(val); + Z_DVAL_P(val) = rect->x = (float)Z_DVAL_P(val); + + val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, 0, &rv); + convert_to_double(val); + Z_DVAL_P(val) = rect->y = (float)Z_DVAL_P(val); + + val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "w", 1, 0, &rv); + convert_to_double(val); + Z_DVAL_P(val) = rect->w = (float)Z_DVAL_P(val); + + val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "h", 1, 0, &rv); + convert_to_double(val); + Z_DVAL_P(val) = rect->h = (float)Z_DVAL_P(val); + + return 1; + } + /* create an empty rect */ + memset(rect, 0, sizeof(SDL_FRect)); + return 0; +} + zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) { if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) { @@ -117,15 +196,35 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) return 0; } +zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *pt) +{ + if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce)) { + zval *val, rv; + + val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, 0, &rv); + convert_to_double(val); + Z_DVAL_P(val) = pt->x = (float)Z_DVAL_P(val); + + val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, 0, &rv); + convert_to_double(val); + Z_DVAL_P(val) = pt->y = (float)Z_DVAL_P(val); + + return 1; + } + /* create an empty point */ + memset(pt, 0, sizeof(SDL_FPoint)); + return 0; +} + /* {{{ proto SDL_Rect::__construct(, int x, int y, int w, int h) * \brief A rectangle, with the origin at the upper left. */ -static PHP_METHOD(SDL_Rect, __construct) +PHP_METHOD(SDL_Rect, __construct) { zend_long x = 0, y = 0, w = 0, h = 0; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &x, &y, &w, &h)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &x, &y, &w, &h)) { return; } @@ -136,9 +235,8 @@ static PHP_METHOD(SDL_Rect, __construct) } /* }}} */ - /* {{{ proto SDL_Rect::__toString() */ -static PHP_METHOD(SDL_Rect, __toString) +PHP_METHOD(SDL_Rect, __toString) { zend_string *buf; SDL_Rect rect; @@ -153,11 +251,42 @@ static PHP_METHOD(SDL_Rect, __toString) } /* }}} */ +PHP_METHOD(SDL_FRect, __construct) +{ + double x = 0, y = 0, w = 0, h = 0; + + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_DOUBLE(x) + Z_PARAM_DOUBLE(y) + Z_PARAM_DOUBLE(w) + Z_PARAM_DOUBLE(h) + ZEND_PARSE_PARAMETERS_END(); + + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "x", 1, x); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "y", 1, y); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "w", 1, w); + zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "h", 1, h); +} + +PHP_METHOD(SDL_FRect, __toString) +{ + zend_string *buf; + SDL_FRect rect; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zval_to_sdl_frect(getThis(), &rect); + buf = strpprintf(0, "SDL_FRect(%f,%f,%f,%f)", rect.x, rect.y, rect.w, rect.h); + RETVAL_STR(buf); +} + /* {{{ proto SDL_Point::__construct(, int x, int y) * \brief A rectangle, with the origin at the upper left. */ -static PHP_METHOD(SDL_Point, __construct) +PHP_METHOD(SDL_Point, __construct) { zend_long x, y; zend_error_handling error_handling; @@ -176,7 +305,7 @@ static PHP_METHOD(SDL_Point, __construct) /* {{{ proto SDL_Point::__toString() */ -static PHP_METHOD(SDL_Point, __toString) +PHP_METHOD(SDL_Point, __toString) { zend_string *buf; SDL_Point point; @@ -191,6 +320,32 @@ static PHP_METHOD(SDL_Point, __toString) } /* }}} */ +PHP_METHOD(SDL_FPoint, __construct) +{ + double x = 0, y = 0; + + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_DOUBLE(x) + Z_PARAM_DOUBLE(y) + ZEND_PARSE_PARAMETERS_END(); + + zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "x", 1, x); + zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "y", 1, y); +} + +PHP_METHOD(SDL_FPoint, __toString) +{ + zend_string *buf; + SDL_FPoint point; + + if (zend_parse_parameters_none() == FAILURE) { + return; + } + + zval_to_sdl_fpoint(getThis(), &point); + buf = strpprintf(0, "SDL_FPoint(%f,%f)", point.x, point.y); + RETVAL_STR(buf); +} /* {{{ proto bool SDL_RectEmpty(SDL_Rect rect) @@ -211,6 +366,18 @@ PHP_FUNCTION(SDL_RectEmpty) } /* }}} */ +PHP_FUNCTION(SDL_FRectEmpty) +{ + zval *object; + SDL_FRect rect; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE) { + return; + } + zval_to_sdl_frect(object, &rect); + + RETURN_BOOL((rect.w <= 0.0f) || (rect.h <= 0.0f)); +} /* {{{ proto bool SDL_RectEquals(SDL_Rect a, SDL_Rect b) @@ -256,6 +423,53 @@ PHP_FUNCTION(SDL_HasIntersection) } /* }}} */ +PHP_FUNCTION(SDL_HasIntersectionF) +{ + zval *obj1, *obj2; + SDL_FRect A, B; + float Amin, Amax, Bmin, Bmax; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE) { + return; + } + zval_to_sdl_frect(obj1, &A); + zval_to_sdl_frect(obj2, &B); + + /** SDL_HasIntersectionF not yet available as public API (SDL <= 2.0.20) */ + /* Horizontal intersection */ + Amin = A.x; + Amax = Amin + A.w; + Bmin = B.x; + Bmax = Bmin + B.w; + if (Bmin > Amin) { + Amin = Bmin; + } + if (Bmax < Amax) { + Amax = Bmax; + } + if (Amax <= Amin) { + RETURN_FALSE; + } + + /* Vertical intersection */ + Amin = A.y; + Amax = Amin + A.h; + Bmin = B.y; + Bmax = Bmin + B.h; + if (Bmin > Amin) { + Amin = Bmin; + } + if (Bmax < Amax) { + Amax = Bmax; + } + if (Amax <= Amin) { + RETURN_FALSE; + } + + RETURN_TRUE; +// RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2)); +} + /* {{{ proto bool SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result) * \brief Calculate the intersection of two rectangles. @@ -276,7 +490,7 @@ PHP_FUNCTION(SDL_IntersectRect) zval_to_sdl_rect(obj1, &rect1); zval_to_sdl_rect(obj2, &rect2); if (SDL_IntersectRect(&rect1, &rect2, &rect3)) { - zval_dtor(result); + zval_ptr_dtor(result); sdl_rect_to_zval(&rect3, result); RETURN_TRUE; } @@ -284,6 +498,65 @@ PHP_FUNCTION(SDL_IntersectRect) } /* }}} */ + +PHP_FUNCTION(SDL_IntersectFRect) +{ + zval *obj1, *obj2, *result; + SDL_FRect A, B, resultRect; + float Amin, Amax, Bmin, Bmax; + + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE) { + return; + } + zval_to_sdl_frect(obj1, &A); + zval_to_sdl_frect(obj2, &B); + + /** SDL_IntersectFRect does not exists (SDL <= 2.0.20) */ + /* Special cases for empty rects */ + if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f)) { + resultRect.w = 0; + resultRect.h = 0; + + zval_ptr_dtor(result); + sdl_frect_to_zval(&resultRect, result); + + RETURN_FALSE; + } + + /* Horizontal intersection */ + Amin = A.x; + Amax = Amin + A.w; + Bmin = B.x; + Bmax = Bmin + B.w; + if (Bmin > Amin) + Amin = Bmin; + resultRect.x = Amin; + if (Bmax < Amax) + Amax = Bmax; + resultRect.w = Amax - Amin; + + /* Vertical intersection */ + Amin = A.y; + Amax = Amin + A.h; + Bmin = B.y; + Bmax = Bmin + B.h; + if (Bmin > Amin) + Amin = Bmin; + resultRect.y = Amin; + if (Bmax < Amax) + Amax = Bmax; + resultRect.h = Amax - Amin; + + if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f))) { // !SDL_FRectEmpty + zval_ptr_dtor(result); + sdl_frect_to_zval(&resultRect, result); + + RETURN_TRUE; + } + + RETURN_FALSE; +} + /* {{{ proto bool SDL_UnionRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result) * \brief Calculate the union of two rectangles. @@ -302,7 +575,7 @@ PHP_FUNCTION(SDL_UnionRect) zval_to_sdl_rect(obj1, &rect1); zval_to_sdl_rect(obj2, &rect2); SDL_UnionRect(&rect1, &rect2, &rect3); - zval_dtor(result); + zval_ptr_dtor(result); sdl_rect_to_zval(&rect3, result); } /* }}} */ @@ -356,7 +629,7 @@ PHP_FUNCTION(SDL_EnclosePoints) php_error_docref(NULL, E_WARNING, "no point in provided array"); } else if (SDL_EnclosePoints(points, nb, &clip, &result)) { - zval_dtor(z_result); + zval_ptr_dtor(z_result); sdl_rect_to_zval(&result, z_result); RETVAL_TRUE; } @@ -423,55 +696,20 @@ PHP_FUNCTION(SDL_PointInRect) RETURN_FALSE; } -ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0) -ZEND_END_ARG_INFO() - -/* {{{ php_sdl_rect_methods[] */ -static const zend_function_entry php_sdl_rect_methods[] = { - PHP_ME(SDL_Rect, __construct, arginfo_SDL_Rect__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Rect, __toString, arginfo_none, ZEND_ACC_PUBLIC) - - /* non-static methods */ - PHP_FALIAS(Empty, SDL_RectEmpty, arginfo_none) - PHP_FALIAS(Equal, SDL_RectEquals, arginfo_SDL_Rect) - PHP_FALIAS(HasIntersection, SDL_HasIntersection, arginfo_SDL_Rect) - PHP_FALIAS(Intersect, SDL_IntersectRect, arginfo_SDL_Rect_Result) - PHP_FALIAS(Union, SDL_UnionRect, arginfo_SDL_Rect_Result) - PHP_FALIAS(IntersectLine, SDL_IntersectRectAndLine, arginfo_SDL_Rect_IntersectLine) - - PHP_FE_END -}; -/* }}} */ - -/* {{{ php_sdl_point_methods[] */ -static const zend_function_entry php_sdl_point_methods[] = { - PHP_ME(SDL_Point, __construct, arginfo_SDL_Point__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Point, __toString, arginfo_none, ZEND_ACC_PUBLIC) - - PHP_FE_END -}; -/* }}} */ - /* {{{ MINIT */ PHP_MINIT_FUNCTION(sdl_rect) { - zend_class_entry ce_rect, ce_point; - - INIT_CLASS_ENTRY(ce_rect, "SDL_Rect", php_sdl_rect_methods); - php_sdl_rect_ce = zend_register_internal_class(&ce_rect); + php_sdl_rect_ce = register_class_SDL_Rect(); memcpy(&php_sdl_rect_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - zend_declare_property_long(php_sdl_rect_ce, "x", 1, 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_rect_ce, "y", 1, 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_rect_ce, "w", 1, 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_rect_ce, "h", 1, 0, ZEND_ACC_PUBLIC); + php_sdl_frect_ce = register_class_SDL_FRect(); + memcpy(&php_sdl_frect_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - INIT_CLASS_ENTRY(ce_point, "SDL_Point", php_sdl_point_methods); - php_sdl_point_ce = zend_register_internal_class(&ce_point); + php_sdl_point_ce = register_class_SDL_Point(); memcpy(&php_sdl_point_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - zend_declare_property_long(php_sdl_point_ce, "x", 1, 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_point_ce, "y", 1, 0, ZEND_ACC_PUBLIC); + php_sdl_fpoint_ce = register_class_SDL_FPoint(); + memcpy(&php_sdl_fpoint_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); return SUCCESS; } diff --git a/src/rect.h b/src/rect.h index 916337d..7552dab 100644 --- a/src/rect.h +++ b/src/rect.h @@ -35,84 +35,11 @@ zend_class_entry *get_php_sdl_rect_ce(void); zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value); zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect); -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect__construct, /*unused*/0, /*ret ref*/0, /*req num args*/0) - ZEND_ARG_TYPE_INFO(0, x, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, y, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) - ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) -ZEND_END_ARG_INFO() +zend_class_entry *get_php_sdl_frect_ce(void); +zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect); - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Point__construct, 0, 0, 2) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) -ZEND_END_ARG_INFO() - - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect, 0, 0, 1) - ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0) -ZEND_END_ARG_INFO() - - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect2, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, rectA, SDL_Rect, 0) - ZEND_ARG_OBJ_INFO(0, rectB, SDL_Rect, 0) -ZEND_END_ARG_INFO() - - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect3, 0, 0, 3) - ZEND_ARG_OBJ_INFO(0, rectA, SDL_Rect, 0) - ZEND_ARG_OBJ_INFO(0, rectB, SDL_Rect, 0) - ZEND_ARG_INFO(1, result) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_IntersectRect, 0, 0, 3) - ZEND_ARG_OBJ_INFO(0, rectA, SDL_Rect, 0) - ZEND_ARG_OBJ_INFO(0, rectB, SDL_Rect, 0) - ZEND_ARG_INFO(1, result) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect_Result, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0) - ZEND_ARG_INFO(1, result) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_EnclosePoints, 0, 0, 4) - ZEND_ARG_ARRAY_INFO(0, point, 0) - ZEND_ARG_INFO(0, count) - ZEND_ARG_OBJ_INFO(0, clip, SDL_Rect, 0) - ZEND_ARG_INFO(1, rect) -ZEND_END_ARG_INFO() - - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_IntersectRectAndLine, 0, 0, 5) - ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0) - ZEND_ARG_INFO(1, X1) - ZEND_ARG_INFO(1, Y1) - ZEND_ARG_INFO(1, X2) - ZEND_ARG_INFO(1, Y2) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Rect_IntersectLine, 0, 0, 4) - ZEND_ARG_INFO(1, X1) - ZEND_ARG_INFO(1, Y1) - ZEND_ARG_INFO(1, X2) - ZEND_ARG_INFO(1, Y2) -ZEND_END_ARG_INFO() - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PointInRect, 0, 0, 2) - ZEND_ARG_OBJ_INFO(0, point, SDL_Point, 0) - ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0) -ZEND_END_ARG_INFO() - -PHP_FUNCTION(SDL_RectEmpty); -PHP_FUNCTION(SDL_RectEquals); -PHP_FUNCTION(SDL_HasIntersection); -PHP_FUNCTION(SDL_IntersectRect); -PHP_FUNCTION(SDL_UnionRect); -PHP_FUNCTION(SDL_EnclosePoints); -PHP_FUNCTION(SDL_IntersectRectAndLine); -PHP_FUNCTION(SDL_PointInRect); +zend_class_entry *get_php_sdl_fpoint_ce(void); +zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *rect); PHP_MINIT_FUNCTION(sdl_rect); diff --git a/src/rect.stub.php b/src/rect.stub.php new file mode 100644 index 0000000..00f827b --- /dev/null +++ b/src/rect.stub.php @@ -0,0 +1,76 @@ + src->h || h > dst->h) { h = (src->h > dst->h ? dst->h : src->h); - php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h); + php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h); } if (sp != src->pitch) { sp = src->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp); + php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp); } if (dp != dst->pitch) { dp = dst->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp); + php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp); } RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp)); } diff --git a/tests/006-rect.phpt b/tests/006-rect.phpt index 1dd5ff1..f44d83b 100644 --- a/tests/006-rect.phpt +++ b/tests/006-rect.phpt @@ -10,16 +10,28 @@ $r = new SDL_Rect(0,0,0,0); var_dump($r); var_dump(SDL_RectEmpty($r)); +$r = new SDL_FRect(.0,.0,.0,.0); +var_dump($r); +var_dump(SDL_FRectEmpty($r)); + echo "+++ Empty (false)\n"; $r = new SDL_Rect(1,2,3,4); var_dump($r); var_dump(SDL_RectEmpty($r)); +$r = new SDL_FRect(1.0,2.0,3.0,4.0); +var_dump($r); +var_dump(SDL_FRectEmpty($r)); + $r1 = new SDL_Rect(10,10,20,20); $r2 = new SDL_Rect(10,10,20,20); $r3 = new SDL_Rect(16,17,22,24); $r4 = new SDL_Rect(100,10,20,20); +$fr2 = new SDL_FRect(10.1, 10.1, 20.1, 20.1); +$fr3 = new SDL_FRect(16.1, 17.1, 22.1, 24.1); +$fr4 = new SDL_FRect(100.1, 10.1, 20.1, 20.1); + echo "+++ Equal (true)\n"; var_dump(SDL_RectEquals($r1, $r1)); var_dump(SDL_RectEquals($r1, $r2)); @@ -32,11 +44,19 @@ var_dump(SDL_HasIntersection($r2, $r3)); var_dump(SDL_IntersectRect($r2, $r3, $x)); var_dump($x); unset($x); +var_dump(SDL_HasIntersectionF($fr2, $fr3)); +var_dump(SDL_IntersectFRect($fr2, $fr3, $x)); +var_dump($x); unset($x); + echo "+++ Inter (false)\n"; var_dump(SDL_HasIntersection($r2, $r4)); var_dump(SDL_IntersectRect($r2, $r4, $x)); var_dump($x); unset($x); +var_dump(SDL_HasIntersectionF($fr2, $fr4)); +var_dump(SDL_IntersectFRect($fr2, $fr4, $x)); +var_dump($x); unset($x); + echo "+++ Union\n"; var_dump(SDL_UnionRect($r2, $r3, $x)); var_dump($x); unset($x); @@ -48,7 +68,7 @@ $x1=0; $y1=10; $x2=40; $y2=30; var_dump(SDL_IntersectRectAndLine($r1, $x1, $y1, $x2, $y2)); var_dump($x1, $y1, $x2, $y2); $x1=0; $y1=2; $x2=40; $y2=6; -var_dump($r1->IntersectLine($x1, $y1, $x2, $y2)); +var_dump(SDL_IntersectRectAndLine($r1, $x1, $y1, $x2, $y2)); echo "+++ EnclosePoints\n"; $pts = array( @@ -61,6 +81,15 @@ var_dump($pts[0]." ".$pts[1]." ".$pts[2]." ".$pts[3]); var_dump(SDL_EnclosePoints($pts, 0, $r1, $res1), $res1); $pts[]="foo"; var_dump(SDL_EnclosePoints($pts, 6, $r4, $res2), $res2); + +echo "+++ SDL_FRect\n"; +$r = new SDL_FRect(1.1, 2.2, 3.3, 4.4); +var_dump($r); + +echo "+++ SDL_FPoint\n"; +$r = new SDL_FPoint(1.1, 2.2); +var_dump($r); + ?> Done --EXPECTF-- @@ -76,6 +105,17 @@ object(SDL_Rect)#%d (4) { int(0) } bool(true) +object(SDL_FRect)#%d (4) { + ["x"]=> + float(0) + ["y"]=> + float(0) + ["w"]=> + float(0) + ["h"]=> + float(0) +} +bool(true) +++ Empty (false) object(SDL_Rect)#%d (4) { ["x"]=> @@ -88,6 +128,17 @@ object(SDL_Rect)#%d (4) { int(4) } bool(false) +object(SDL_FRect)#%d (4) { + ["x"]=> + float(1) + ["y"]=> + float(2) + ["w"]=> + float(3) + ["h"]=> + float(4) +} +bool(false) +++ Equal (true) bool(true) bool(true) @@ -107,10 +158,25 @@ object(SDL_Rect)#%d (4) { ["h"]=> int(13) } +bool(true) +bool(true) +object(SDL_FRect)#%d (4) { + ["x"]=> + float(16.100000381469727) + ["y"]=> + float(17.100000381469727) + ["w"]=> + float(14.100000381469727) + ["h"]=> + float(13.100000381469727) +} +++ Inter (false) bool(false) bool(false) NULL +bool(false) +bool(false) +NULL +++ Union NULL object(SDL_Rect)#%d (4) { @@ -160,5 +226,23 @@ Warning: SDL_EnclosePoints(): point #4 is not a SDL_Point object in %s/006-rect. Warning: SDL_EnclosePoints(): point #5 missing in %s/006-rect.php on line %d bool(false) NULL ++++ SDL_FRect +object(SDL_FRect)#%d (4) { + ["x"]=> + float(1.1) + ["y"]=> + float(2.2) + ["w"]=> + float(3.3) + ["h"]=> + float(4.4) +} ++++ SDL_FPoint +object(SDL_FPoint)#2 (2) { + ["x"]=> + float(1.1) + ["y"]=> + float(2.2) +} Done diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt index 951f744..8e23672 100644 --- a/tests/007-rect-oo.phpt +++ b/tests/007-rect-oo.phpt @@ -8,18 +8,30 @@ require 'test-functions.php'; echo "+++ Empty (true)\n"; $r = new SDL_Rect(0,0,0,0); var_dump($r, "$r"); -var_dump(SDL_RectEmpty($r)); +var_dump($r->Empty()); + +$r = new SDL_FRect(.0,.0,.0,.0); +var_dump($r); +var_dump($r->Empty()); echo "+++ Empty (false)\n"; $r = new SDL_Rect(1,2,3,4); var_dump($r, "$r"); var_dump($r->Empty()); +$r = new SDL_FRect(1.1, 2.2, 3.3, 4.4); +var_dump($r, "$r"); +var_dump($r->Empty()); + $r1 = new SDL_Rect(10,10,20,20); $r2 = new SDL_Rect(10,10,20,20); $r3 = new SDL_Rect(16,17,22,24); $r4 = new SDL_Rect(100,10,20,20); +$fr2 = new SDL_FRect(10.1, 10.1, 20.1, 20.1); +$fr3 = new SDL_FRect(16.1, 17.1, 22.1, 24.1); +$fr4 = new SDL_FRect(100.1, 10.1, 20.1, 20.1); + echo "+++ Equal (true)\n"; var_dump($r1->Equal($r1)); var_dump($r1->Equal($r2)); @@ -32,11 +44,19 @@ var_dump($r2->HasIntersection($r3)); var_dump($r2->Intersect($r3, $x)); var_dump($x); unset($x); +var_dump($fr2->HasIntersection($fr3)); +var_dump($fr2->Intersect($fr3, $x)); +var_dump($x); unset($x); + echo "+++ Inter (false)\n"; var_dump($r2->HasIntersection($r4)); var_dump($r2->Intersect($r4, $x)); var_dump($x); unset($x); +var_dump($fr2->HasIntersection($fr4)); +var_dump($fr2->Intersect($fr4, $x)); +var_dump($x); unset($x); + echo "+++ Uninon\n"; var_dump($r2->Union($r3, $x)); var_dump($x); unset($x); @@ -70,6 +90,17 @@ object(SDL_Rect)#%d (4) { } string(17) "SDL_Rect(0,0,0,0)" bool(true) +object(SDL_FRect)#%d (4) { + ["x"]=> + float(0) + ["y"]=> + float(0) + ["w"]=> + float(0) + ["h"]=> + float(0) +} +bool(true) +++ Empty (false) object(SDL_Rect)#%d (4) { ["x"]=> @@ -83,6 +114,18 @@ object(SDL_Rect)#%d (4) { } string(17) "SDL_Rect(1,2,3,4)" bool(false) +object(SDL_FRect)#%d (4) { + ["x"]=> + float(1.100000023841858) + ["y"]=> + float(2.200000047683716) + ["w"]=> + float(3.299999952316284) + ["h"]=> + float(4.400000095367432) +} +string(46) "SDL_FRect(1.100000,2.200000,3.300000,4.400000)" +bool(false) +++ Equal (true) bool(true) bool(true) @@ -102,10 +145,25 @@ object(SDL_Rect)#%d (4) { ["h"]=> int(13) } +bool(true) +bool(true) +object(SDL_FRect)#%d (4) { + ["x"]=> + float(16.100000381469727) + ["y"]=> + float(17.100000381469727) + ["w"]=> + float(14.100000381469727) + ["h"]=> + float(13.100000381469727) +} +++ Inter (false) bool(false) bool(false) NULL +bool(false) +bool(false) +NULL +++ Uninon NULL object(SDL_Rect)#%d (4) { diff --git a/tests/014-version.phpt b/tests/014-version.phpt index 49981f6..05889fe 100644 --- a/tests/014-version.phpt +++ b/tests/014-version.phpt @@ -4,7 +4,7 @@ SDL_version test suite size()); echo "read:"; var_dump($ro->read($buf, $size)==$size, strlen($buf)==$size); diff --git a/tests/028-point.phpt b/tests/028-point.phpt index dd3d3cb..2713cf0 100644 --- a/tests/028-point.phpt +++ b/tests/028-point.phpt @@ -10,10 +10,16 @@ echo 'TEST: Subclasses of SDL_Point can be converted properly', PHP_EOL; class CustomPoint extends \SDL_Point {} $customPoint = new CustomPoint(10, 20); echo strval($customPoint), PHP_EOL; + +echo 'TEST: SDL_FPoint to string', PHP_EOL; +$fpoint = new SDL_FPoint(22.23, 42.43); +echo (string) $fpoint, PHP_EOL; ?> SUITE: End --EXPECTF-- SUITE: Start TEST: Subclasses of SDL_Point can be converted properly SDL_Point(10,20) +TEST: SDL_FPoint to string +SDL_FPoint(22.230000,42.430000) SUITE: End From 456f57116d931406087625553469fdf12fb5d6c2 Mon Sep 17 00:00:00 2001 From: Manuel Baldassarri Date: Thu, 17 Mar 2022 20:42:52 +0100 Subject: [PATCH 31/55] Add manually the list of file to compile and add src as build dir (#59) --- config.m4 | 28 +++++++++++++++++++++++++++- package.xml | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/config.m4 b/config.m4 index 06963bd..3ebd8ee 100644 --- a/config.m4 +++ b/config.m4 @@ -55,6 +55,32 @@ if test "$PHP_SDL" != "no"; then PHP_SUBST(SDL_SHARED_LIBADD) AC_DEFINE(HAVE_SDL2, 1, [ ]) - SDL_SOURCE_FILES="`find src -name "*.c"`" + SDL_SOURCE_FILES="src/blendmode.c \ + src/cpuinfo.c \ + src/error.c \ + src/event.c \ + src/filesystem.c \ + src/glcontext.c \ + src/joystick.c \ + src/keyboard.c \ + src/messagebox.c \ + src/mouse.c \ + src/mutex.c \ + src/php_sdl.c \ + src/pixels.c \ + src/platform.c \ + src/power.c \ + src/rect.c \ + src/render.c \ + src/rwops.c \ + src/sdl.c \ + src/shape.c \ + src/surface.c \ + src/timer.c \ + src/version.c \ + src/video.c \ + src/window.c" + PHP_NEW_EXTENSION(sdl, $SDL_SOURCE_FILES, $ext_shared,, $PHP_SDL_CFLAGS) + PHP_ADD_BUILD_DIR($ext_builddir/src) fi diff --git a/package.xml b/package.xml index a282e0e..3170ffd 100644 --- a/package.xml +++ b/package.xml @@ -73,6 +73,8 @@ + + From 17950bd127fc1ccc67614c6c87190c7b787f4122 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Thu, 17 Mar 2022 21:25:33 +0000 Subject: [PATCH 32/55] Remove long long int warnings --- src/surface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/surface.c b/src/surface.c index 0ad8c2e..ec39c4c 100644 --- a/src/surface.c +++ b/src/surface.c @@ -1195,15 +1195,15 @@ PHP_FUNCTION(SDL_ConvertPixels) } if (h < 0 || h > src->h || h > dst->h) { h = (src->h > dst->h ? dst->h : src->h); - php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %lld", h); + php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h); } if (sp != src->pitch) { sp = src->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %lld", sp); + php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp); } if (dp != dst->pitch) { dp = dst->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %lld", dp); + php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp); } RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp)); } From 1c5aa8d41aa4cdf8b7ba84d5475c8f0361f8077e Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Thu, 17 Mar 2022 21:40:17 +0000 Subject: [PATCH 33/55] Increase version number. Remove PHP version 7 references. --- package.xml | 35 +++++++++++++++++++++++++++-------- src/blendmode.c | 2 -- src/blendmode.h | 2 -- src/cpuinfo.c | 2 -- src/cpuinfo.h | 2 -- src/error.c | 2 -- src/error.h | 2 -- src/event.c | 2 -- src/event.h | 2 -- src/filesystem.c | 2 -- src/filesystem.h | 2 -- src/glcontext.c | 2 -- src/glcontext.h | 2 -- src/joystick.c | 2 -- src/joystick.h | 2 -- src/keyboard.c | 2 -- src/keyboard.h | 2 -- src/messagebox.c | 2 -- src/messagebox.h | 2 -- src/mouse.c | 2 -- src/mouse.h | 2 -- src/mutex.c | 2 -- src/mutex.h | 2 -- src/php_sdl.c | 2 -- src/php_sdl.h | 4 +--- src/pixels.c | 2 -- src/pixels.h | 2 -- src/platform.c | 2 -- src/platform.h | 2 -- src/power.c | 2 -- src/power.h | 2 -- src/rect.c | 2 -- src/rect.h | 2 -- src/render.c | 2 -- src/render.h | 2 -- src/rwops.c | 2 -- src/rwops.h | 2 -- src/sdl.c | 2 -- src/sdl.h | 2 -- src/shape.c | 2 -- src/shape.h | 2 -- src/surface.c | 2 -- src/surface.h | 2 -- src/timer.c | 2 -- src/timer.h | 2 -- src/version.c | 2 -- src/version.h | 2 -- src/video.c | 2 -- src/video.h | 2 -- src/window.c | 2 -- src/window.h | 2 -- 51 files changed, 28 insertions(+), 109 deletions(-) diff --git a/package.xml b/package.xml index 3170ffd..367f667 100644 --- a/package.xml +++ b/package.xml @@ -19,20 +19,22 @@ yes - 2021-06-18 + 2022-03-17 - 2.5.0 - 2.5.0 + 2.6.0 + 2.6.0 - devel - devel + beta + beta - PHP + PHP - - Add support for PHP8 (Manuel Baldassarri) - - Remove support for PHP7 (Manuel Baldassarri) + - Add float rect and float point render functions (Manuel Baldassarri) + - Add config file for Windows (Zorobabel) + - Fix PECL build (Manuel Baldassarri) + - Rename width parameter in SDL_Rect constructor (Manuel Baldassarri) @@ -156,6 +158,23 @@ sdl + + 2021-06-18 + + + 2.5.0 + 2.5.0 + + + devel + devel + + PHP + + - Add support for PHP8 (Manuel Baldassarri) + - Remove support for PHP7 (Manuel Baldassarri) + + 2020-08-23 diff --git a/src/blendmode.c b/src/blendmode.c index decb075..9b700b6 100644 --- a/src/blendmode.c +++ b/src/blendmode.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/blendmode.h b/src/blendmode.h index 214b33c..da2443f 100644 --- a/src/blendmode.h +++ b/src/blendmode.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/cpuinfo.c b/src/cpuinfo.c index eba2dae..73a7a53 100644 --- a/src/cpuinfo.c +++ b/src/cpuinfo.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/cpuinfo.h b/src/cpuinfo.h index d4504b3..edf4e9f 100644 --- a/src/cpuinfo.h +++ b/src/cpuinfo.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/error.c b/src/error.c index dc99886..a5156d3 100644 --- a/src/error.c +++ b/src/error.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/error.h b/src/error.h index 451ee67..b43c758 100644 --- a/src/error.h +++ b/src/error.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/event.c b/src/event.c index a015ed7..f199ee4 100644 --- a/src/event.c +++ b/src/event.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/event.h b/src/event.h index 63cb54a..297fcf2 100644 --- a/src/event.h +++ b/src/event.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/filesystem.c b/src/filesystem.c index 9bf9263..a999771 100644 --- a/src/filesystem.c +++ b/src/filesystem.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/filesystem.h b/src/filesystem.h index 20ca99d..5ff1836 100644 --- a/src/filesystem.h +++ b/src/filesystem.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/glcontext.c b/src/glcontext.c index f285047..38581cd 100644 --- a/src/glcontext.c +++ b/src/glcontext.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/glcontext.h b/src/glcontext.h index 237306c..3a73554 100644 --- a/src/glcontext.h +++ b/src/glcontext.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/joystick.c b/src/joystick.c index bfa771b..7e55812 100644 --- a/src/joystick.c +++ b/src/joystick.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/joystick.h b/src/joystick.h index 47c65f5..b02ee80 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/keyboard.c b/src/keyboard.c index cec4b62..eccf18c 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/keyboard.h b/src/keyboard.h index 95ebf33..ff9a1aa 100644 --- a/src/keyboard.h +++ b/src/keyboard.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/messagebox.c b/src/messagebox.c index 8613231..6cfcd3c 100644 --- a/src/messagebox.c +++ b/src/messagebox.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/messagebox.h b/src/messagebox.h index b304b0a..c296428 100644 --- a/src/messagebox.h +++ b/src/messagebox.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/mouse.c b/src/mouse.c index 3f60e05..890b2ca 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/mouse.h b/src/mouse.h index d2468c4..391815a 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/mutex.c b/src/mutex.c index d2825a5..143a269 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/mutex.h b/src/mutex.h index 0cc85de..f7e23fe 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/php_sdl.c b/src/php_sdl.c index 2785d3e..531f842 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/php_sdl.h b/src/php_sdl.h index bd8a498..10912d1 100644 --- a/src/php_sdl.h +++ b/src/php_sdl.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ @@ -32,7 +30,7 @@ extern "C" { #include #include -#define PHP_SDL_VERSION "2.5.0" +#define PHP_SDL_VERSION "2.6.0" #if defined(__APPLE__) && defined(__MACH__) #include diff --git a/src/pixels.c b/src/pixels.c index 8f8cee0..ef1525b 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/pixels.h b/src/pixels.h index 2501cd2..8aedc44 100644 --- a/src/pixels.h +++ b/src/pixels.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/platform.c b/src/platform.c index 81f0baf..dada1e7 100644 --- a/src/platform.c +++ b/src/platform.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/platform.h b/src/platform.h index f7917a6..ee823ef 100644 --- a/src/platform.h +++ b/src/platform.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/power.c b/src/power.c index 8628c4e..42a4670 100644 --- a/src/power.c +++ b/src/power.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/power.h b/src/power.h index f889a62..c7b1e8c 100644 --- a/src/power.h +++ b/src/power.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/rect.c b/src/rect.c index 11d8821..6773f56 100644 --- a/src/rect.c +++ b/src/rect.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/rect.h b/src/rect.h index 7552dab..67ba131 100644 --- a/src/rect.h +++ b/src/rect.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/render.c b/src/render.c index 8d75b3f..f8e1f9c 100644 --- a/src/render.c +++ b/src/render.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/render.h b/src/render.h index 659bcad..0a8c0ab 100644 --- a/src/render.h +++ b/src/render.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/rwops.c b/src/rwops.c index 5d0400e..af3609b 100644 --- a/src/rwops.c +++ b/src/rwops.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/rwops.h b/src/rwops.h index 3bde6ec..f1aec7a 100644 --- a/src/rwops.h +++ b/src/rwops.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/sdl.c b/src/sdl.c index 2ab6bb3..65f0118 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/sdl.h b/src/sdl.h index 3396c11..cd6d4f3 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/shape.c b/src/shape.c index 99c086b..314ebde 100644 --- a/src/shape.c +++ b/src/shape.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/shape.h b/src/shape.h index 5f85548..9c5f85a 100644 --- a/src/shape.h +++ b/src/shape.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/surface.c b/src/surface.c index ec39c4c..8684487 100644 --- a/src/surface.c +++ b/src/surface.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/surface.h b/src/surface.h index 94f98f2..6506f0f 100644 --- a/src/surface.h +++ b/src/surface.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/timer.c b/src/timer.c index d0cd321..9a05500 100644 --- a/src/timer.c +++ b/src/timer.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/timer.h b/src/timer.h index 9babd80..4aecfed 100644 --- a/src/timer.h +++ b/src/timer.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/version.c b/src/version.c index 184bdfd..5251b6a 100644 --- a/src/version.c +++ b/src/version.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2016 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/version.h b/src/version.h index 238c4a7..b0c2980 100644 --- a/src/version.h +++ b/src/version.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/video.c b/src/video.c index 5670e04..7e8315d 100644 --- a/src/video.c +++ b/src/video.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/video.h b/src/video.h index 658f166..a158a54 100644 --- a/src/video.h +++ b/src/video.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/window.c b/src/window.c index 71c6a16..3061f41 100644 --- a/src/window.c +++ b/src/window.c @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ diff --git a/src/window.h b/src/window.h index a3d263d..95abb4c 100644 --- a/src/window.h +++ b/src/window.h @@ -1,6 +1,4 @@ /* - +----------------------------------------------------------------------+ - | PHP Version 7 | +----------------------------------------------------------------------+ | Copyright (c) 1997-2018 The PHP Group | +----------------------------------------------------------------------+ From b5b348d886295603efb10fa99b826e82a58f7eea Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Thu, 17 Mar 2022 21:47:39 +0000 Subject: [PATCH 34/55] Add list of related projects to README --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f0c28f..2877165 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ SDL (Simple DirectMedia Layer) bindings for the PHP language. The extension allo ### Via PECL ```bash -pecl install sdl-devel +pecl install sdl-beta ``` Then add @@ -54,6 +54,13 @@ unset($window); // will destroy the window Complete examples can be found in the [examples](examples) folder. +## Related projects + +* [PHP-SDL_Mixer](https://github.com/kea/php-sdl-mixer) +* [PHP-SDL_Image](https://github.com/kea/php-sdl-image) +* [PHP-OpenGL](https://github.com/ponup/php-opengl) +* [PHP-OpenAL](https://github.com/Ponup/php-openal) + ## Projects using the extension * [CubeCraft](https://github.com/Ponup/cubecraft) From 555aee64cba87f0eb740a456ce35bfb714a87d8f Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 21 Mar 2022 19:28:50 +0100 Subject: [PATCH 35/55] fix PHP 8.0 build (#60) * fix PHP 8.0 build * register rect functions in rect.c --- src/php_sdl.c | 18 +++--------------- src/pixels.c | 6 ++++++ src/rect.c | 11 +++++++++++ src/rect.h | 1 + 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/php_sdl.c b/src/php_sdl.c index 531f842..c409c6c 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -31,7 +31,6 @@ #include "power.h" #include "pixels.h" #include "rect.h" -#include "rect_arginfo.h" #include "render.h" #include "rwops.h" #include "sdl.h" @@ -68,6 +67,7 @@ zend_bool php_sdl_check_overflow(int a, int b, int silent) #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU) +#define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU) /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(sdl) @@ -107,6 +107,8 @@ PHP_MINIT_FUNCTION(sdl) /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(sdl) { + PHP_MSHUTDOWN_CALL(sdl_rect); + return SUCCESS; } /* }}} */ @@ -260,20 +262,6 @@ static zend_function_entry sdl_functions[] = { //PHP_FALIAS(SDL_BlitSurface, SDL_UpperBlit, arginfo_SDL_UpperBlit) //PHP_FALIAS(SDL_BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) - // Rect - ZEND_FE(SDL_RectEmpty, arginfo_SDL_RectEmpty) - ZEND_FE(SDL_RectEquals, arginfo_SDL_RectEquals) - ZEND_FE(SDL_HasIntersection, arginfo_SDL_HasIntersection) - ZEND_FE(SDL_IntersectRect, arginfo_SDL_IntersectRect) - ZEND_FE(SDL_UnionRect, arginfo_SDL_UnionRect) - ZEND_FE(SDL_IntersectRectAndLine, arginfo_SDL_IntersectRectAndLine) - ZEND_FE(SDL_EnclosePoints, arginfo_SDL_EnclosePoints) - ZEND_FE(SDL_PointInRect, arginfo_SDL_PointInRect) - - ZEND_FE(SDL_FRectEmpty, arginfo_SDL_FRectEmpty) - ZEND_FE(SDL_HasIntersectionF, arginfo_SDL_HasIntersectionF) - ZEND_FE(SDL_IntersectFRect, arginfo_SDL_IntersectFRect) - // Events ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent) ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent) diff --git a/src/pixels.c b/src/pixels.c index ef1525b..4594d58 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -20,6 +20,12 @@ #include "zend_interfaces.h" #include "zend_operators.h" +/* for PHP 8.0 */ +#ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX +#define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ + ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) +#endif + static zend_class_entry *php_sdl_color_ce; static zend_object_handlers php_sdl_color_handlers; struct php_sdl_color { diff --git a/src/rect.c b/src/rect.c index 6773f56..926d1b2 100644 --- a/src/rect.c +++ b/src/rect.c @@ -697,6 +697,8 @@ PHP_FUNCTION(SDL_PointInRect) /* {{{ MINIT */ PHP_MINIT_FUNCTION(sdl_rect) { + zend_register_functions(NULL, ext_functions, NULL, type); + php_sdl_rect_ce = register_class_SDL_Rect(); memcpy(&php_sdl_rect_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); @@ -712,3 +714,12 @@ PHP_MINIT_FUNCTION(sdl_rect) return SUCCESS; } /* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION */ +PHP_MSHUTDOWN_FUNCTION(sdl_rect) +{ + zend_unregister_functions(ext_functions, -1, NULL); + + return SUCCESS; +} +/* }}} */ diff --git a/src/rect.h b/src/rect.h index 67ba131..baddfd6 100644 --- a/src/rect.h +++ b/src/rect.h @@ -40,6 +40,7 @@ zend_class_entry *get_php_sdl_fpoint_ce(void); zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *rect); PHP_MINIT_FUNCTION(sdl_rect); +PHP_MSHUTDOWN_FUNCTION(sdl_rect); #ifdef __cplusplus } // extern "C" From 945cc94dbf88daacaecd6b663ffbb1687c7192e5 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 23 Mar 2022 19:13:44 +0100 Subject: [PATCH 36/55] deprecate SDL_GetRevisionNumber (#65) --- config.m4 | 4 ++++ src/php_sdl.c | 4 +++- src/version.c | 2 ++ src/version.h | 2 ++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/config.m4 b/config.m4 index 3ebd8ee..e781c23 100644 --- a/config.m4 +++ b/config.m4 @@ -55,6 +55,10 @@ if test "$PHP_SDL" != "no"; then PHP_SUBST(SDL_SHARED_LIBADD) AC_DEFINE(HAVE_SDL2, 1, [ ]) + PHP_CHECK_LIBRARY(SDL2, SDL_GetRevisionNumber, [ + AC_DEFINE(HAVE_SDL_GETREVISIONNUMBER, 1, [ ]) + ]) + SDL_SOURCE_FILES="src/blendmode.c \ src/cpuinfo.c \ src/error.c \ diff --git a/src/php_sdl.c b/src/php_sdl.c index c409c6c..7ab5d78 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -193,7 +193,9 @@ static zend_function_entry sdl_functions[] = { // Version ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none) - ZEND_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none) +#ifdef HAVE_SDL_GETREVISIONNUMBER + ZEND_DEP_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none) +#endif ZEND_FE(SDL_GetVersion, arginfo_SDL_GetVersion) ZEND_FE(SDL_VERSION, arginfo_SDL_VERSION) ZEND_FE(SDL_VERSIONNUM, arginfo_SDL_VERSIONNUM) diff --git a/src/version.c b/src/version.c index 5251b6a..a889e79 100644 --- a/src/version.c +++ b/src/version.c @@ -59,6 +59,7 @@ PHP_FUNCTION(SDL_GetRevision) } /* }}} */ +#ifdef HAVE_SDL_GETREVISIONNUMBER /* {{{ proto int SDL_GetRevisionNumber() * \brief Get the revision number of SDL that is linked against your program. @@ -76,6 +77,7 @@ PHP_FUNCTION(SDL_GetRevisionNumber) RETURN_LONG(SDL_GetRevisionNumber()); } /* }}} */ +#endif /* {{{ proto void SDL_GetVersion(array &version) diff --git a/src/version.h b/src/version.h index b0c2980..4b08737 100644 --- a/src/version.h +++ b/src/version.h @@ -49,7 +49,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_VERSION_ATLEAST, 0, 0, 3) ZEND_END_ARG_INFO() PHP_FUNCTION(SDL_GetRevision); +#ifdef HAVE_SDL_GETREVISIONNUMBER PHP_FUNCTION(SDL_GetRevisionNumber); +#endif PHP_FUNCTION(SDL_GetVersion); PHP_FUNCTION(SDL_VERSION); PHP_FUNCTION(SDL_VERSIONNUM); From 52e2a50c1f187ead639689acf4a01ef9d5880571 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Wed, 23 Mar 2022 22:35:44 +0100 Subject: [PATCH 37/55] relax test (event always initialized) (#64) --- tests/003-init-and-quit-subsystems.phpt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/003-init-and-quit-subsystems.phpt b/tests/003-init-and-quit-subsystems.phpt index 07976bd..afa0a18 100644 --- a/tests/003-init-and-quit-subsystems.phpt +++ b/tests/003-init-and-quit-subsystems.phpt @@ -9,13 +9,13 @@ require 'test-functions.php'; assertEquals(SDL_WasInit(), 0, 'before calling SDL_Init nothing is initialised'); SDL_InitSubSystem(SDL_INIT_AUDIO); -assertEquals(SDL_WasInit(), SDL_INIT_AUDIO, 'init first subsystem works'); +assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_AUDIO, 'init first subsystem works'); SDL_InitSubSystem(SDL_INIT_TIMER); -assertEquals(SDL_WasInit(), SDL_INIT_AUDIO + SDL_INIT_TIMER, 'init two subsystems works'); +assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_AUDIO + SDL_INIT_TIMER, 'init two subsystems works'); SDL_QuitSubSystem(SDL_INIT_AUDIO); -assertEquals(SDL_WasInit(), SDL_INIT_TIMER, 'quitting one subsystem works'); +assertEquals(SDL_WasInit() & ~SDL_INIT_EVENTS, SDL_INIT_TIMER, 'quitting one subsystem works'); SDL_Quit(); assertEquals(SDL_WasInit(), 0, 'quitting everything works'); From f7971f18eff999ca31989188a952989100f8016f Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Wed, 23 Mar 2022 22:07:50 +0000 Subject: [PATCH 38/55] Remove travis reference from tests --- tests/005-video.phpt | 1 - tests/test-functions.php | 7 ++----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/005-video.phpt b/tests/005-video.phpt index 3d5973f..5ed8f2e 100644 --- a/tests/005-video.phpt +++ b/tests/005-video.phpt @@ -3,7 +3,6 @@ video group test --SKIPIF-- Date: Wed, 23 Mar 2022 22:08:47 +0000 Subject: [PATCH 39/55] Add Benoit to credits --- CREDITS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CREDITS b/CREDITS index 19a36f5..ea3e033 100644 --- a/CREDITS +++ b/CREDITS @@ -1,2 +1,2 @@ SDL -Santiago Lizardo, Remi Collet, Manuel Baldassarri +Santiago Lizardo, Remi Collet, Manuel Baldassarri, Benoit Viguier From 21a983c3299673fbe0f6e8923bc5c0de705af147 Mon Sep 17 00:00:00 2001 From: sensorario Date: Sun, 15 May 2022 22:30:56 +0200 Subject: [PATCH 40/55] Update README.md (#66) Help reader to understand where the ini file is. --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2877165..9603609 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ extension=sdl.so ``` to your _php.ini_ file. +> If you have no idea about your ini file position you can run `php -i | grep ini` and see the list of you ini files. + ## Documentation The SDL extension mimics in almost every single aspect to the official C library, so until we write our own documentation, refer to the [C counterpart](https://wiki.libsdl.org/APIByCategory). From b8308ce8093e627a24e539fcf9650e80bc11d731 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 22 Jul 2022 13:40:25 +0100 Subject: [PATCH 41/55] Allow new SDL_Rect with no arguments (default to 0,0 0x0) --- src/rect.c | 201 +++++++++++++++++++++++++---------------- tests/006-rect.phpt | 6 +- tests/007-rect-oo.phpt | 6 +- 3 files changed, 129 insertions(+), 84 deletions(-) diff --git a/src/rect.c b/src/rect.c index 926d1b2..7a0a39d 100644 --- a/src/rect.c +++ b/src/rect.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -20,25 +20,29 @@ static zend_class_entry *php_sdl_rect_ce; static zend_object_handlers php_sdl_rect_handlers; -struct php_sdl_rect { +struct php_sdl_rect +{ zend_object zo; }; static zend_class_entry *php_sdl_frect_ce; static zend_object_handlers php_sdl_frect_handlers; -struct php_sdl_frect { +struct php_sdl_frect +{ zend_object zo; }; static zend_class_entry *php_sdl_point_ce; static zend_object_handlers php_sdl_point_handlers; -struct php_sdl_point { +struct php_sdl_point +{ zend_object zo; }; static zend_class_entry *php_sdl_fpoint_ce; static zend_object_handlers php_sdl_fpoint_handlers; -struct php_sdl_fpoint { +struct php_sdl_fpoint +{ zend_object zo; }; @@ -64,7 +68,8 @@ zend_class_entry *get_php_sdl_fpoint_ce(void) zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value) { - if (rect) { + if (rect) + { object_init_ex(value, php_sdl_rect_ce); zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, rect->x); zend_update_property_long(php_sdl_rect_ce, Z_OBJ_P(value), "y", 1, rect->y); @@ -79,7 +84,8 @@ zend_bool sdl_rect_to_zval(SDL_Rect *rect, zval *value) zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value) { - if (rect) { + if (rect) + { object_init_ex(value, php_sdl_frect_ce); zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, rect->x); zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(value), "y", 1, rect->y); @@ -94,7 +100,8 @@ zend_bool sdl_frect_to_zval(SDL_FRect *rect, zval *value) zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) { - if (pt) { + if (pt) + { object_init_ex(value, php_sdl_point_ce); zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, pt->x); zend_update_property_long(php_sdl_point_ce, Z_OBJ_P(value), "y", 1, pt->y); @@ -107,7 +114,8 @@ zend_bool sdl_point_to_zval(SDL_Point *pt, zval *value) zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value) { - if (pt) { + if (pt) + { object_init_ex(value, php_sdl_fpoint_ce); zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, pt->x); zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(value), "y", 1, pt->y); @@ -120,7 +128,8 @@ zend_bool sdl_fpoint_to_zval(SDL_FPoint *pt, zval *value) zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) { - if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) { + if (instanceof_function(Z_OBJCE_P(value), php_sdl_rect_ce)) + { zval *val, rv; val = zend_read_property(php_sdl_rect_ce, Z_OBJ_P(value), "x", 1, 0, &rv); @@ -148,7 +157,8 @@ zend_bool zval_to_sdl_rect(zval *value, SDL_Rect *rect) zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect) { - if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce)) { + if (instanceof_function(Z_OBJCE_P(value), php_sdl_frect_ce)) + { zval *val, rv; val = zend_read_property(php_sdl_frect_ce, Z_OBJ_P(value), "x", 1, 0, &rv); @@ -176,7 +186,8 @@ zend_bool zval_to_sdl_frect(zval *value, SDL_FRect *rect) zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) { - if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) { + if (instanceof_function(Z_OBJCE_P(value), php_sdl_point_ce)) + { zval *val, rv; val = zend_read_property(php_sdl_point_ce, Z_OBJ_P(value), "x", 1, 0, &rv); @@ -196,7 +207,8 @@ zend_bool zval_to_sdl_point(zval *value, SDL_Point *pt) zend_bool zval_to_sdl_fpoint(zval *value, SDL_FPoint *pt) { - if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce)) { + if (instanceof_function(Z_OBJCE_P(value), php_sdl_fpoint_ce)) + { zval *val, rv; val = zend_read_property(php_sdl_fpoint_ce, Z_OBJ_P(value), "x", 1, 0, &rv); @@ -222,7 +234,8 @@ PHP_METHOD(SDL_Rect, __construct) { zend_long x = 0, y = 0, w = 0, h = 0; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &x, &y, &w, &h)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|llll", &x, &y, &w, &h)) + { return; } @@ -239,7 +252,8 @@ PHP_METHOD(SDL_Rect, __toString) zend_string *buf; SDL_Rect rect; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -254,10 +268,10 @@ PHP_METHOD(SDL_FRect, __construct) double x = 0, y = 0, w = 0, h = 0; ZEND_PARSE_PARAMETERS_START(4, 4) - Z_PARAM_DOUBLE(x) - Z_PARAM_DOUBLE(y) - Z_PARAM_DOUBLE(w) - Z_PARAM_DOUBLE(h) + Z_PARAM_DOUBLE(x) + Z_PARAM_DOUBLE(y) + Z_PARAM_DOUBLE(w) + Z_PARAM_DOUBLE(h) ZEND_PARSE_PARAMETERS_END(); zend_update_property_double(php_sdl_frect_ce, Z_OBJ_P(getThis()), "x", 1, x); @@ -271,7 +285,8 @@ PHP_METHOD(SDL_FRect, __toString) zend_string *buf; SDL_FRect rect; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -290,7 +305,8 @@ PHP_METHOD(SDL_Point, __construct) zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &x, &y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &x, &y)) + { zend_restore_error_handling(&error_handling); return; } @@ -301,14 +317,14 @@ PHP_METHOD(SDL_Point, __construct) } /* }}} */ - /* {{{ proto SDL_Point::__toString() */ PHP_METHOD(SDL_Point, __toString) { zend_string *buf; SDL_Point point; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -323,8 +339,8 @@ PHP_METHOD(SDL_FPoint, __construct) double x = 0, y = 0; ZEND_PARSE_PARAMETERS_START(2, 2) - Z_PARAM_DOUBLE(x) - Z_PARAM_DOUBLE(y) + Z_PARAM_DOUBLE(x) + Z_PARAM_DOUBLE(y) ZEND_PARSE_PARAMETERS_END(); zend_update_property_double(php_sdl_fpoint_ce, Z_OBJ_P(getThis()), "x", 1, x); @@ -336,7 +352,8 @@ PHP_METHOD(SDL_FPoint, __toString) zend_string *buf; SDL_FPoint point; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -355,11 +372,12 @@ PHP_FUNCTION(SDL_RectEmpty) zval *object; SDL_Rect rect; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_rect_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_rect_ce) == FAILURE) + { return; } zval_to_sdl_rect(object, &rect); - + RETURN_BOOL(SDL_RectEmpty(&rect)); } /* }}} */ @@ -369,7 +387,8 @@ PHP_FUNCTION(SDL_FRectEmpty) zval *object; SDL_FRect rect; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_frect_ce) == FAILURE) + { return; } zval_to_sdl_frect(object, &rect); @@ -387,36 +406,37 @@ PHP_FUNCTION(SDL_RectEquals) zval *obj1, *obj2; SDL_Rect rect1, rect2; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) + { return; } zval_to_sdl_rect(obj1, &rect1); zval_to_sdl_rect(obj2, &rect2); - + RETURN_BOOL(SDL_RectEquals(&rect1, &rect2)); } /* }}} */ - /* {{{ proto bool SDL_HasIntersection(SDL_Rect a, SDL_Rect b) * \brief Determine whether two rectangles intersect. * * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. extern DECLSPEC SDL_bool SDLCALL SDL_HasIntersection(const SDL_Rect * A, - const SDL_Rect * B); + const SDL_Rect * B); */ PHP_FUNCTION(SDL_HasIntersection) { zval *obj1, *obj2; SDL_Rect rect1, rect2; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce) == FAILURE) + { return; } zval_to_sdl_rect(obj1, &rect1); zval_to_sdl_rect(obj2, &rect2); - + RETURN_BOOL(SDL_HasIntersection(&rect1, &rect2)); } /* }}} */ @@ -427,7 +447,8 @@ PHP_FUNCTION(SDL_HasIntersectionF) SDL_FRect A, B; float Amin, Amax, Bmin, Bmax; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce) == FAILURE) + { return; } zval_to_sdl_frect(obj1, &A); @@ -439,13 +460,16 @@ PHP_FUNCTION(SDL_HasIntersectionF) Amax = Amin + A.w; Bmin = B.x; Bmax = Bmin + B.w; - if (Bmin > Amin) { + if (Bmin > Amin) + { Amin = Bmin; } - if (Bmax < Amax) { + if (Bmax < Amax) + { Amax = Bmax; } - if (Amax <= Amin) { + if (Amax <= Amin) + { RETURN_FALSE; } @@ -454,18 +478,21 @@ PHP_FUNCTION(SDL_HasIntersectionF) Amax = Amin + A.h; Bmin = B.y; Bmax = Bmin + B.h; - if (Bmin > Amin) { + if (Bmin > Amin) + { Amin = Bmin; } - if (Bmax < Amax) { + if (Bmax < Amax) + { Amax = Bmax; } - if (Amax <= Amin) { + if (Amax <= Amin) + { RETURN_FALSE; } RETURN_TRUE; -// RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2)); + // RETURN_BOOL(SDL_HasIntersectionF(&rect1, &rect2)); } /* {{{ proto bool SDL_IntersectRect(SDL_Rect a, SDL_Rect b, SDL_Rect &result) @@ -474,20 +501,22 @@ PHP_FUNCTION(SDL_HasIntersectionF) * * \return SDL_TRUE if there is an intersection, SDL_FALSE otherwise. extern DECLSPEC SDL_bool SDLCALL SDL_IntersectRect(const SDL_Rect * A, - const SDL_Rect * B, - SDL_Rect * result); + const SDL_Rect * B, + SDL_Rect * result); */ PHP_FUNCTION(SDL_IntersectRect) { zval *obj1, *obj2, *result; SDL_Rect rect1, rect2, rect3; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) + { return; } zval_to_sdl_rect(obj1, &rect1); zval_to_sdl_rect(obj2, &rect2); - if (SDL_IntersectRect(&rect1, &rect2, &rect3)) { + if (SDL_IntersectRect(&rect1, &rect2, &rect3)) + { zval_ptr_dtor(result); sdl_rect_to_zval(&rect3, result); RETURN_TRUE; @@ -496,14 +525,14 @@ PHP_FUNCTION(SDL_IntersectRect) } /* }}} */ - PHP_FUNCTION(SDL_IntersectFRect) { zval *obj1, *obj2, *result; SDL_FRect A, B, resultRect; float Amin, Amax, Bmin, Bmax; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_frect_ce, &obj2, php_sdl_frect_ce, &result) == FAILURE) + { return; } zval_to_sdl_frect(obj1, &A); @@ -511,7 +540,8 @@ PHP_FUNCTION(SDL_IntersectFRect) /** SDL_IntersectFRect does not exists (SDL <= 2.0.20) */ /* Special cases for empty rects */ - if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f)) { + if ((A.w <= 0.0f) || (A.h <= 0.0f) || (B.w <= 0.0f) || (B.h <= 0.0f)) + { resultRect.w = 0; resultRect.h = 0; @@ -545,7 +575,8 @@ PHP_FUNCTION(SDL_IntersectFRect) Amax = Bmax; resultRect.h = Amax - Amin; - if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f))) { // !SDL_FRectEmpty + if (!((resultRect.w <= 0.0f) || (resultRect.h <= 0.0f))) + { // !SDL_FRectEmpty zval_ptr_dtor(result); sdl_frect_to_zval(&resultRect, result); @@ -559,15 +590,16 @@ PHP_FUNCTION(SDL_IntersectFRect) * \brief Calculate the union of two rectangles. extern DECLSPEC void SDLCALL SDL_UnionRect(const SDL_Rect * A, - const SDL_Rect * B, - SDL_Rect * result); + const SDL_Rect * B, + SDL_Rect * result); */ PHP_FUNCTION(SDL_UnionRect) { zval *obj1, *obj2, *result; SDL_Rect rect1, rect2, rect3; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOz/", &obj1, php_sdl_rect_ce, &obj2, php_sdl_rect_ce, &result) == FAILURE) + { return; } zval_to_sdl_rect(obj1, &rect1); @@ -578,17 +610,15 @@ PHP_FUNCTION(SDL_UnionRect) } /* }}} */ - - /* {{{ proto bool SDL_EnclosePoints(array points, int count, SDL_Rect clip, SDL_Rect &result) * \brief Calculate a minimal rectangle enclosing a set of points * * \return SDL_TRUE if any points were within the clipping rect extern DECLSPEC SDL_bool SDLCALL SDL_EnclosePoints(const SDL_Point * points, - int count, - const SDL_Rect * clip, - SDL_Rect * result); + int count, + const SDL_Rect * clip, + SDL_Rect * result); */ PHP_FUNCTION(SDL_EnclosePoints) { @@ -599,34 +629,42 @@ PHP_FUNCTION(SDL_EnclosePoints) SDL_Rect clip, result; SDL_Point *points; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "alOz/", &z_points, &count, &z_clip, php_sdl_rect_ce, &z_result) == FAILURE) + { return; } RETVAL_FALSE; - if (count<=0) { + if (count <= 0) + { count = zend_hash_next_free_element(Z_ARRVAL_P(z_points)); } - points = emalloc(sizeof(SDL_Point)*count); + points = emalloc(sizeof(SDL_Point) * count); zval_to_sdl_rect(z_clip, &clip); - for (i=0, nb=0 ; i int(0) @@ -238,7 +242,7 @@ object(SDL_FRect)#%d (4) { float(4.4) } +++ SDL_FPoint -object(SDL_FPoint)#2 (2) { +object(SDL_FPoint)#%d (2) { ["x"]=> float(1.1) ["y"]=> diff --git a/tests/007-rect-oo.phpt b/tests/007-rect-oo.phpt index 8e23672..3a453ee 100644 --- a/tests/007-rect-oo.phpt +++ b/tests/007-rect-oo.phpt @@ -57,7 +57,7 @@ var_dump($fr2->HasIntersection($fr4)); var_dump($fr2->Intersect($fr4, $x)); var_dump($x); unset($x); -echo "+++ Uninon\n"; +echo "+++ Union\n"; var_dump($r2->Union($r3, $x)); var_dump($x); unset($x); var_dump($r2->Union($r4, $x)); @@ -164,7 +164,7 @@ NULL bool(false) bool(false) NULL -+++ Uninon ++++ Union NULL object(SDL_Rect)#%d (4) { ["x"]=> @@ -196,4 +196,4 @@ int(24) bool(false) +++ Test subclasses of SDL_Rect can be passed to SDL functions bool(false) -Done \ No newline at end of file +Done From 4880c91330e972f1a41e11395a8c697af22af5b4 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 22 Jul 2022 15:14:30 +0100 Subject: [PATCH 42/55] Fix issue on SDL_GetKeyboardState --- examples/009-window-events.php | 11 ++++ package.xml | 31 ++++++++--- src/joystick.h | 6 --- src/keyboard.c | 98 ++++++++++++++++------------------ src/keyboard.h | 86 ++++++++++++++--------------- src/php_sdl.h | 42 ++++++++------- 6 files changed, 146 insertions(+), 128 deletions(-) diff --git a/examples/009-window-events.php b/examples/009-window-events.php index 38222bd..5cfb804 100644 --- a/examples/009-window-events.php +++ b/examples/009-window-events.php @@ -16,6 +16,17 @@ $event = new SDL_Event; while (!$quit) { + $keyboardState = SDL_GetKeyboardState($numkeys); + if($keyboardState[SDL_SCANCODE_RETURN]) { + echo 'SDL_SCANCODE_RETURN pressed', PHP_EOL; + } + if($keyboardState[SDL_SCANCODE_RIGHT]) { + echo 'SDL_SCANCODE_RIGHT pressed', PHP_EOL; + } + if($keyboardState[SDL_SCANCODE_UP]) { + echo 'SDL_SCANCODE_UP pressed', PHP_EOL; + } + while (SDL_PollEvent($event)) { switch ($event->type) { case SDL_QUIT: diff --git a/package.xml b/package.xml index 367f667..a3e3615 100644 --- a/package.xml +++ b/package.xml @@ -19,11 +19,11 @@ yes - 2022-03-17 + 2022-07-22 - 2.6.0 - 2.6.0 + 2.7.0 + 2.7.0 beta @@ -31,10 +31,7 @@ PHP - - Add float rect and float point render functions (Manuel Baldassarri) - - Add config file for Windows (Zorobabel) - - Fix PECL build (Manuel Baldassarri) - - Rename width parameter in SDL_Rect constructor (Manuel Baldassarri) + - Fix SDL_GetKeyboardState (https://github.com/Ponup/php-sdl/issues/68) @@ -158,6 +155,26 @@ sdl + + 2022-03-17 + + + 2.6.0 + 2.6.0 + + + beta + beta + + PHP + + - Add float rect and float point render functions (Manuel Baldassarri) + - Add config file for Windows (Zorobabel) + - Fix PECL build (Manuel Baldassarri) + - Rename width parameter in SDL_Rect constructor (Manuel Baldassarri) + + + 2021-06-18 diff --git a/src/joystick.h b/src/joystick.h index b02ee80..5dbb44d 100644 --- a/src/joystick.h +++ b/src/joystick.h @@ -25,12 +25,6 @@ extern "C" #include "php_sdl.h" -#define ARG_PASS_BY_REF 1 -#define ARG_NOT_PASS_BY_REF 0 - -#define ARG_ALLOW_NULL 1 -#define ARG_NOT_ALLOW_NULL 0 - ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_NumJoysticks, 0, 0, 0) ZEND_END_ARG_INFO() PHP_FUNCTION(SDL_NumJoysticks); diff --git a/src/keyboard.c b/src/keyboard.c index eccf18c..145c523 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -26,19 +26,15 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); */ PHP_FUNCTION(SDL_GetKeyboardFocus) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } sdl_window_to_zval(SDL_GetKeyboardFocus(), return_value, SDL_DONTFREE); } /* }}} */ -/* {{{ proto array SDL_GetKeyboardState([int &numkeys [, bool allkeys=true ]]) - - Standard SDL API - with allkeys=true return an array of scancode => state array - PHP Specific, (to reduce memory) - with allkeys=false return an array of scancode (which are set) +/* {{{ proto array SDL_GetKeyboardState([int &numkeys]) * \brief Get a snapshot of the current state of the keyboard. * @@ -58,32 +54,27 @@ PHP_FUNCTION(SDL_GetKeyboardFocus) PHP_FUNCTION(SDL_GetKeyboardState) { zval *z_numkeys = NULL; - int i, nb, numkeys; - zend_bool allkeys=1; + int i, numkeys; const Uint8 *state; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zb", &z_numkeys, &allkeys)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|z", &z_numkeys)) + { return; } state = SDL_GetKeyboardState(&numkeys); array_init(return_value); - for (nb=i=0 ; i #include -#define PHP_SDL_VERSION "2.6.0" +#define PHP_SDL_VERSION "2.7.0" #if defined(__APPLE__) && defined(__MACH__) #include @@ -42,14 +48,15 @@ extern "C" { #include #include #include -#ifdef __cplusplus -} // extern "C" +#ifdef __cplusplus +} // extern "C" #endif -#ifdef __cplusplus -extern "C" { +#ifdef __cplusplus +extern "C" +{ #endif -extern zend_module_entry sdl_module_entry; + extern zend_module_entry sdl_module_entry; #define phpext_sdl_ptr &sdl_module_entry #ifdef PHP_WIN32 @@ -58,21 +65,20 @@ extern zend_module_entry sdl_module_entry; #define PHP_SDL_API #endif -PHP_MINIT_FUNCTION(sdl); -PHP_MSHUTDOWN_FUNCTION(sdl); -PHP_RINIT_FUNCTION(sdl); -PHP_RSHUTDOWN_FUNCTION(sdl); -PHP_MINFO_FUNCTION(sdl); + PHP_MINIT_FUNCTION(sdl); + PHP_MSHUTDOWN_FUNCTION(sdl); + PHP_RINIT_FUNCTION(sdl); + PHP_RSHUTDOWN_FUNCTION(sdl); + PHP_MINFO_FUNCTION(sdl); -zend_bool php_sdl_check_overflow(int a, int b, int silent); + zend_bool php_sdl_check_overflow(int a, int b, int silent); -#ifdef __cplusplus -} // extern "C" +#ifdef __cplusplus +} // extern "C" #endif #endif /* PHP_PHPSDL_H */ - /* * Local variables: * tab-width: 4 From 38882fe972c0d788575848e8bc284fd12eab96be Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 22 Jul 2022 17:51:46 +0100 Subject: [PATCH 43/55] =?UTF-8?q?Remove=20extra=20=E2=80=98;=E2=80=99=20ou?= =?UTF-8?q?tside=20of=20functions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pixels.c | 957 ++++++++++++++++++++++++++++----------------------- 1 file changed, 527 insertions(+), 430 deletions(-) diff --git a/src/pixels.c b/src/pixels.c index 4594d58..3568551 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -15,7 +15,6 @@ +----------------------------------------------------------------------+ */ - #include "pixels.h" #include "zend_interfaces.h" #include "zend_operators.h" @@ -23,37 +22,41 @@ /* for PHP 8.0 */ #ifndef ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX #define ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(name, return_reference, required_num_args, type, allow_null) \ - ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) + ZEND_BEGIN_ARG_INFO_EX(name, 0, return_reference, required_num_args) #endif static zend_class_entry *php_sdl_color_ce; static zend_object_handlers php_sdl_color_handlers; -struct php_sdl_color { - zend_object zo; +struct php_sdl_color +{ + zend_object zo; }; static zend_class_entry *php_sdl_palette_ce; static zend_object_handlers php_sdl_palette_handlers; -typedef struct _php_sdl_palette { - SDL_Palette *palette; - Uint32 flags; - zend_object zo; +typedef struct _php_sdl_palette +{ + SDL_Palette *palette; + Uint32 flags; + zend_object zo; } php_sdl_palette; static zend_class_entry *php_sdl_pixelformat_ce; static zend_object_handlers php_sdl_pixelformat_handlers; -typedef struct _php_sdl_pixelformat { +typedef struct _php_sdl_pixelformat +{ SDL_PixelFormat *format; - Uint32 flags; - zend_object zo; + Uint32 flags; + zend_object zo; } php_sdl_pixelformat; static zend_class_entry *php_sdl_pixels_ce; static zend_object_handlers php_sdl_pixels_handlers; -typedef struct _php_sdl_pixels { - SDL_Pixels pixels; - Uint32 flags; - zend_object zo; +typedef struct _php_sdl_pixels +{ + SDL_Pixels pixels; + Uint32 flags; + zend_object zo; } php_sdl_pixels; zend_class_entry *get_php_sdl_color_ce(void) @@ -76,48 +79,53 @@ zend_class_entry *get_php_sdl_pixels_ce(void) return php_sdl_pixels_ce; } -static inline php_sdl_palette* php_sdl_palette_from_obj(zend_object *obj) { - return (php_sdl_palette*)((char*)(obj) - XtOffsetOf(php_sdl_palette, zo)); +static inline php_sdl_palette *php_sdl_palette_from_obj(zend_object *obj) +{ + return (php_sdl_palette *)((char *)(obj)-XtOffsetOf(php_sdl_palette, zo)); } -#define FETCH_PALETTE(__ptr, __id, __check) \ -{ \ - intern = PHP_SDL_PALETTE_P(__id);\ - __ptr = intern->palette; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ -} +#define FETCH_PALETTE(__ptr, __id, __check) \ + { \ + intern = PHP_SDL_PALETTE_P(__id); \ + __ptr = intern->palette; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } -#define PHP_SDL_PALETTE_P(zv) php_sdl_palette_from_obj(Z_OBJ_P((zv))) +#define PHP_SDL_PALETTE_P(zv) php_sdl_palette_from_obj(Z_OBJ_P((zv))) -static inline php_sdl_pixelformat* php_sdl_pixelformat_from_obj(zend_object *obj) { - return (php_sdl_pixelformat*)((char*)(obj) - XtOffsetOf(php_sdl_pixelformat, zo)); +static inline php_sdl_pixelformat *php_sdl_pixelformat_from_obj(zend_object *obj) +{ + return (php_sdl_pixelformat *)((char *)(obj)-XtOffsetOf(php_sdl_pixelformat, zo)); } -#define FETCH_PIXELFORMAT(__ptr, __id, __check) \ -{ \ - intern = PHP_SDL_PIXELFORMAT_P(__id);\ - __ptr = intern->format; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ -} +#define FETCH_PIXELFORMAT(__ptr, __id, __check) \ + { \ + intern = PHP_SDL_PIXELFORMAT_P(__id); \ + __ptr = intern->format; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } -#define PHP_SDL_PIXELFORMAT_P(zv) php_sdl_pixelformat_from_obj(Z_OBJ_P((zv))) +#define PHP_SDL_PIXELFORMAT_P(zv) php_sdl_pixelformat_from_obj(Z_OBJ_P((zv))) -static inline php_sdl_pixels* php_sdl_pixels_from_obj(zend_object *obj) { - return (php_sdl_pixels*)((char*)(obj) - XtOffsetOf(php_sdl_pixels, zo)); +static inline php_sdl_pixels *php_sdl_pixels_from_obj(zend_object *obj) +{ + return (php_sdl_pixels *)((char *)(obj)-XtOffsetOf(php_sdl_pixels, zo)); } -#define PHP_SDL_PIXELS_P(zv) php_sdl_pixels_from_obj(Z_OBJ_P((zv))) - +#define PHP_SDL_PIXELS_P(zv) php_sdl_pixels_from_obj(Z_OBJ_P((zv))) zend_bool sdl_color_to_zval(SDL_Color *color, zval *value) { - if (color) { + if (color) + { object_init_ex(value, php_sdl_color_ce); zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, color->r); zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(value), "g", 1, color->g); @@ -132,7 +140,8 @@ zend_bool sdl_color_to_zval(SDL_Color *color, zval *value) zend_bool zval_to_sdl_color(zval *value, SDL_Color *color) { - if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce) { + if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_color_ce) + { zval *val, rv; val = zend_read_property(php_sdl_color_ce, Z_OBJ_P(value), "r", 1, 0, &rv); @@ -158,11 +167,11 @@ zend_bool zval_to_sdl_color(zval *value, SDL_Color *color) return 0; } - /* {{{ sdl_palette_to_zval */ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags) { - if (palette) { + if (palette) + { php_sdl_palette *intern; object_init_ex(z_val, php_sdl_palette_ce); @@ -177,11 +186,11 @@ zend_bool sdl_palette_to_zval(SDL_Palette *palette, zval *z_val, Uint32 flags) } /* }}} */ - /* {{{ sdl_pixelformat_to_zval */ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 flags) { - if (format) { + if (format) + { php_sdl_pixelformat *intern; object_init_ex(z_val, php_sdl_pixelformat_ce); @@ -200,13 +209,14 @@ zend_bool sdl_pixelformat_to_zval(SDL_PixelFormat *format, zval *z_val, Uint32 f /* {{{ sdl_pixels_to_zval */ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags) { - if (pixels) { + if (pixels) + { php_sdl_pixels *intern; object_init_ex(z_val, php_sdl_pixels_ce); intern = PHP_SDL_PIXELS_P(z_val); intern->pixels = *pixels; - intern->flags = flags; + intern->flags = flags; return 1; } @@ -218,12 +228,13 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags) /* {{{ zval_to_sdl_pixelformat */ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val) { - if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) { + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixelformat_ce) + { php_sdl_pixelformat *intern; intern = PHP_SDL_PIXELFORMAT_P(z_val); return intern->format; - } + } return NULL; } /* }}} */ @@ -231,12 +242,13 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val) /* {{{ zval_to_sdl_pixels */ SDL_Pixels *zval_to_sdl_pixels(zval *z_val) { - if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) { + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) + { php_sdl_pixels *intern; intern = PHP_SDL_PIXELS_P(z_val); return &intern->pixels; - } + } return NULL; } /* }}} */ @@ -244,21 +256,22 @@ SDL_Pixels *zval_to_sdl_pixels(zval *z_val) /* {{{ zval_to_sdl_palette */ SDL_Palette *zval_to_sdl_palette(zval *z_val) { - if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) { + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_palette_ce) + { php_sdl_palette *intern; intern = PHP_SDL_PALETTE_P(z_val); return intern->palette; - } + } return NULL; } /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Color__construct, 0, 0, 4) - ZEND_ARG_INFO(0, r) - ZEND_ARG_INFO(0, g) - ZEND_ARG_INFO(0, b) - ZEND_ARG_INFO(0, a) +ZEND_ARG_INFO(0, r) +ZEND_ARG_INFO(0, g) +ZEND_ARG_INFO(0, b) +ZEND_ARG_INFO(0, a) ZEND_END_ARG_INFO() /* {{{ proto SDL_Color::__construct(int r, int g, int b, int a) */ @@ -268,27 +281,28 @@ static PHP_METHOD(SDL_Color, __construct) zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &r, &g, &b, &a)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llll", &r, &g, &b, &a)) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r&255); - zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g&255); - zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b&255); - zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a&255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "r", 1, r & 255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "g", 1, g & 255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "b", 1, b & 255); + zend_update_property_long(php_sdl_color_ce, Z_OBJ_P(getThis()), "a", 1, a & 255); } /* }}} */ - /* {{{ proto SDL_Color::__toString() */ static PHP_METHOD(SDL_Color, __toString) { char *buf; SDL_Color color; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -308,11 +322,13 @@ PHP_FUNCTION(SDL_GetPixelFormatName) zend_long format; const char *name; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format) == FAILURE) + { RETURN_FALSE; } name = SDL_GetPixelFormatName((Uint32)format); - if (!name) { + if (!name) + { RETURN_FALSE; } RETURN_STRING(name); @@ -327,11 +343,11 @@ PHP_FUNCTION(SDL_GetPixelFormatName) * * \sa SDL_MasksToPixelFormatEnum() extern DECLSPEC SDL_bool SDLCALL SDL_PixelFormatEnumToMasks(Uint32 format, - int *bpp, - Uint32 * Rmask, - Uint32 * Gmask, - Uint32 * Bmask, - Uint32 * Amask); + int *bpp, + Uint32 * Rmask, + Uint32 * Gmask, + Uint32 * Bmask, + Uint32 * Amask); */ PHP_FUNCTION(SDL_PixelFormatEnumToMasks) { @@ -340,10 +356,12 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks) int bpp; Uint32 rmask, gmask, bmask, amask; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lz/z/z/z/z/", &format, &z_bpp, &z_rmask, &z_gmask, &z_bmask, &z_amask) == FAILURE) + { RETURN_FALSE; } - if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask)) { + if (SDL_PixelFormatEnumToMasks((Uint32)format, &bpp, &rmask, &gmask, &bmask, &amask)) + { zval_dtor(z_bpp); ZVAL_LONG(z_bpp, bpp); zval_dtor(z_rmask); @@ -361,7 +379,6 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks) } /* }}} */ - /* {{{ proto bool SDL_MasksToPixelFormatEnum(int format, int bpp, int Rmask, int Gmask, int Bmask, int Amask) * \brief Convert a bpp and RGBA masks to an enumerated pixel format. * @@ -370,16 +387,17 @@ PHP_FUNCTION(SDL_PixelFormatEnumToMasks) * * \sa SDL_PixelFormatEnumToMasks() extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, - Uint32 Rmask, - Uint32 Gmask, - Uint32 Bmask, - Uint32 Amask); + Uint32 Rmask, + Uint32 Gmask, + Uint32 Bmask, + Uint32 Amask); */ PHP_FUNCTION(SDL_MasksToPixelFormatEnum) { zend_long bpp, rmask, gmask, bmask, amask; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll", &bpp, &rmask, &gmask, &bmask, &amask) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lllll", &bpp, &rmask, &gmask, &bmask, &amask) == FAILURE) + { RETURN_FALSE; } @@ -397,7 +415,8 @@ PHP_FUNCTION(SDL_AllocFormat) zend_long index; SDL_PixelFormat *format; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &index)) + { return; } format = SDL_AllocFormat((Uint32)index); @@ -415,29 +434,33 @@ static PHP_METHOD(SDL_PixelFormat, __construct) intern = PHP_SDL_PIXELFORMAT_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &format)) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); intern->format = SDL_AllocFormat((Uint32)format); - if (intern->format) { + if (intern->format) + { intern->flags = 0; - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); } } /* }}} */ - /* {{{ proto SDL_PixelFormat::__toString() */ static PHP_METHOD(SDL_PixelFormat, __toString) { php_sdl_pixelformat *intern; char *buf; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -447,7 +470,6 @@ static PHP_METHOD(SDL_PixelFormat, __toString) } /* }}} */ - /* {{{ proto void SDL_FreeFormat(SDL_PixelFormat format) * \brief Free an SDL_PixelFormat structure. @@ -459,7 +481,8 @@ PHP_FUNCTION(SDL_FreeFormat) zval *object; SDL_PixelFormat *format; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_pixelformat_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_pixelformat_ce) == FAILURE) + { return; } FETCH_PIXELFORMAT(format, object, 1); @@ -469,7 +492,6 @@ PHP_FUNCTION(SDL_FreeFormat) } /* }}} */ - /* {{{ proto SDL_Palette SDL_AllocPalette(int ncolors) * \brief Create a palette structure with the specified number of color @@ -487,7 +509,8 @@ PHP_FUNCTION(SDL_AllocPalette) zend_long ncolors; SDL_Palette *palette; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) + { return; } palette = SDL_AllocPalette((int)ncolors); @@ -505,29 +528,33 @@ static PHP_METHOD(SDL_Palette, __construct) intern = PHP_SDL_PALETTE_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &ncolors)) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); intern->palette = SDL_AllocPalette(ncolors); - if (intern->palette) { + if (intern->palette) + { intern->flags = 0; - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); } } /* }}} */ - /* {{{ proto SDL_Palette::__toString() */ static PHP_METHOD(SDL_Palette, __toString) { php_sdl_palette *intern; char *buf; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -537,14 +564,14 @@ static PHP_METHOD(SDL_Palette, __toString) } /* }}} */ - /* {{{ proto SDL_Palette, count(void) */ static PHP_METHOD(SDL_Palette, count) { php_sdl_palette *intern; intern = PHP_SDL_PALETTE_P(getThis()); - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -553,8 +580,8 @@ static PHP_METHOD(SDL_Palette, count) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetExists, 0, 1, _IS_BOOL, 0) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO(); +ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetExists(int offset) */ PHP_METHOD(SDL_Palette, offsetExists) @@ -563,10 +590,12 @@ PHP_METHOD(SDL_Palette, offsetExists) zend_long offset; intern = PHP_SDL_PALETTE_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) + { return; } - if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { + if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) + { RETURN_FALSE; } RETURN_TRUE; @@ -574,8 +603,8 @@ PHP_METHOD(SDL_Palette, offsetExists) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetGet, 0, 1, IS_MIXED, 1) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO(); +ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetGet(int offset) */ PHP_METHOD(SDL_Palette, offsetGet) @@ -584,20 +613,22 @@ PHP_METHOD(SDL_Palette, offsetGet) zend_long offset; intern = PHP_SDL_PALETTE_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) + { return; } - if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { + if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) + { zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } - sdl_color_to_zval(intern->palette->colors+offset, return_value); + sdl_color_to_zval(intern->palette->colors + offset, return_value); } /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetUnset, 0, 1, IS_VOID, 0) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO(); +ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() /* {{{ proto SDL_Palette, offsetUnset(int offset) */ PHP_METHOD(SDL_Palette, offsetUnset) @@ -607,10 +638,12 @@ PHP_METHOD(SDL_Palette, offsetUnset) SDL_Color color; intern = PHP_SDL_PALETTE_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) + { return; } - if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { + if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) + { zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } @@ -620,11 +653,10 @@ PHP_METHOD(SDL_Palette, offsetUnset) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Palette_offsetSet, 0, 2, IS_VOID, 0) - ZEND_ARG_INFO(0, offset) - ZEND_ARG_INFO(0, color) +ZEND_ARG_INFO(0, offset) +ZEND_ARG_INFO(0, color) ZEND_END_ARG_INFO() - /* {{{ proto SDL_Palette, offsetSet(int offset, int value) */ PHP_METHOD(SDL_Palette, offsetSet) { @@ -634,10 +666,12 @@ PHP_METHOD(SDL_Palette, offsetSet) SDL_Color color; intern = PHP_SDL_PALETTE_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "lO", &offset, &z_color, php_sdl_color_ce) == FAILURE) + { return; } - if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { + if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) + { zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } @@ -650,7 +684,7 @@ PHP_METHOD(SDL_Palette, offsetSet) * \brief Set the palette for a pixel format structure. extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, - SDL_Palette *palette); + SDL_Palette *palette); */ PHP_FUNCTION(SDL_SetPixelFormatPalette) { @@ -659,7 +693,8 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette) SDL_Palette *palette; SDL_PixelFormat *format; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_format, php_sdl_pixelformat_ce, &z_palette, php_sdl_palette_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_format, php_sdl_pixelformat_ce, &z_palette, php_sdl_palette_ce) == FAILURE) + { return; } FETCH_PALETTE(palette, z_palette, 1); @@ -669,7 +704,6 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette) } /* }}} */ - /* {{{ proto int SDL_SetPaletteColors(SDL_Palette palette, array colors, int first, int ncolors) * \brief Set a range of colors in a palette. @@ -681,8 +715,8 @@ PHP_FUNCTION(SDL_SetPixelFormatPalette) * * \return 0 on success, or -1 if not all of the colors could be set. extern DECLSPEC int SDLCALL SDL_SetPaletteColors(SDL_Palette * palette, - const SDL_Color * colors, - int firstcolor, int ncolors); + const SDL_Color * colors, + int firstcolor, int ncolors); */ PHP_FUNCTION(SDL_SetPaletteColors) { @@ -691,44 +725,58 @@ PHP_FUNCTION(SDL_SetPaletteColors) SDL_Palette *palette; SDL_Color *colors; int i, nb; - zend_long first=0, ncolors=0; + zend_long first = 0, ncolors = 0; long count; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|ll", &object, php_sdl_palette_ce, &z_colors, &first, &ncolors) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|ll", &object, php_sdl_palette_ce, &z_colors, &first, &ncolors) == FAILURE) + { return; } FETCH_PALETTE(palette, object, 1); count = zend_hash_next_free_element(Z_ARRVAL_P(z_colors)); - if (ncolors <= 0) { + if (ncolors <= 0) + { ncolors = count; - } else if (ncolors > count) { - php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long) ncolors); + } + else if (ncolors > count) + { + php_error_docref(NULL, E_NOTICE, "Invalid color number, %ld will be used instead of %ld", count, (long)ncolors); ncolors = count; } - if (first >= intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long) first, intern->palette->ncolors); + if (first >= intern->palette->ncolors) + { + php_error_docref(NULL, E_WARNING, "Invalid first color index, %ld >= %d", (long)first, intern->palette->ncolors); RETURN_LONG(-1); } - if (first+ncolors > intern->palette->ncolors) { - php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long) (first+ncolors), intern->palette->ncolors); + if (first + ncolors > intern->palette->ncolors) + { + php_error_docref(NULL, E_WARNING, "Invalid color number, %ld > %d", (long)(first + ncolors), intern->palette->ncolors); RETURN_LONG(-1); } colors = emalloc(sizeof(SDL_Color) * ncolors); - for (nb=i=0 ; ipixels.pixels = ecalloc((int)pitch, (int)h); - intern->pixels.pitch = (int)pitch; - intern->pixels.h = (int)h; + intern->pixels.pitch = (int)pitch; + intern->pixels.h = (int)h; } } /* }}} */ - /* {{{ proto SDL_Pixels::__toString() */ static PHP_METHOD(SDL_Pixels, __toString) { php_sdl_pixels *intern; char *buf; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -1019,14 +1072,14 @@ static PHP_METHOD(SDL_Pixels, __toString) } /* }}} */ - /* {{{ proto SDL_Pixels, count(void) */ static PHP_METHOD(SDL_Pixels, count) { php_sdl_pixels *intern; intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -1035,8 +1088,8 @@ static PHP_METHOD(SDL_Pixels, count) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetExists, 0, 1, _IS_BOOL, 0) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO(); +ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetExists(int offset) */ PHP_METHOD(SDL_Pixels, offsetExists) @@ -1045,10 +1098,12 @@ PHP_METHOD(SDL_Pixels, offsetExists) zend_long offset; intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) + { return; } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) { + if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) + { RETURN_FALSE; } RETURN_TRUE; @@ -1056,8 +1111,8 @@ PHP_METHOD(SDL_Pixels, offsetExists) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetGet, 0, 1, IS_MIXED, 1) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO(); +ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetGet(int offset) */ PHP_METHOD(SDL_Pixels, offsetGet) @@ -1066,10 +1121,12 @@ PHP_METHOD(SDL_Pixels, offsetGet) zend_long offset; intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) + { return; } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) { + if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) + { zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } @@ -1078,8 +1135,8 @@ PHP_METHOD(SDL_Pixels, offsetGet) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetUnset, 0, 1, IS_VOID, 0) - ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO(); +ZEND_ARG_INFO(0, offset) +ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetUnset(int offset) */ PHP_METHOD(SDL_Pixels, offsetUnset) @@ -1088,10 +1145,12 @@ PHP_METHOD(SDL_Pixels, offsetUnset) zend_long offset; intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) + { return; } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) { + if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) + { zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } @@ -1100,8 +1159,8 @@ PHP_METHOD(SDL_Pixels, offsetUnset) /* }}} */ ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 2, IS_VOID, 0) - ZEND_ARG_INFO(0, offset) - ZEND_ARG_INFO(0, value) +ZEND_ARG_INFO(0, offset) +ZEND_ARG_INFO(0, value) ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */ @@ -1111,10 +1170,12 @@ PHP_METHOD(SDL_Pixels, offsetSet) zend_long offset, value; intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) + { return; } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) { + if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) + { zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } @@ -1122,10 +1183,9 @@ PHP_METHOD(SDL_Pixels, offsetSet) } /* }}} */ - ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) +ZEND_ARG_INFO(0, x) +ZEND_ARG_INFO(0, y) ZEND_END_ARG_INFO() /* {{{ proto int SDL_Pixels::GetByte(int x, int y) */ @@ -1135,24 +1195,25 @@ PHP_METHOD(SDL_Pixels, GetByte) zval *z_pixels; zend_long x, y; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) + { return; } intern = PHP_SDL_PIXELS_P(z_pixels); - if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h); + if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) + { + php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } - RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); + RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]); } /* }}} */ - ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3) - ZEND_ARG_INFO(0, x) - ZEND_ARG_INFO(0, y) - ZEND_ARG_INFO(0, byte) +ZEND_ARG_INFO(0, x) +ZEND_ARG_INFO(0, y) +ZEND_ARG_INFO(0, byte) ZEND_END_ARG_INFO() /* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */ @@ -1162,30 +1223,32 @@ PHP_METHOD(SDL_Pixels, SetByte) zval *z_pixels; zend_long x, y, v; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) + { return; } intern = PHP_SDL_PIXELS_P(z_pixels); - if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long) x, (long) y, intern->pixels.pitch, intern->pixels.h); + if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) + { + php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h); RETURN_FALSE; } - RETVAL_LONG(intern->pixels.pixels[y*intern->pixels.pitch+x]); - intern->pixels.pixels[y*intern->pixels.pitch+x] = (Uint8)v; + RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]); + intern->pixels.pixels[y * intern->pixels.pitch + x] = (Uint8)v; } /* }}} */ - - /* {{{ php_sdl_palette_free - */ + */ static void php_sdl_palette_free(zend_object *object) { php_sdl_palette *intern = php_sdl_palette_from_obj(object); - if (intern->palette) { - if (!(intern->flags & SDL_DONTFREE)) { + if (intern->palette) + { + if (!(intern->flags & SDL_DONTFREE)) + { SDL_FreePalette(intern->palette); } } @@ -1196,7 +1259,7 @@ static void php_sdl_palette_free(zend_object *object) /* {{{ php_sdl_palette_new */ -static zend_object* php_sdl_palette_new(zend_class_entry *class_type) +static zend_object *php_sdl_palette_new(zend_class_entry *class_type) { php_sdl_palette *intern = zend_object_alloc(sizeof(php_sdl_palette), class_type); @@ -1204,7 +1267,7 @@ static zend_object* php_sdl_palette_new(zend_class_entry *class_type) object_properties_init(&intern->zo, class_type); intern->palette = NULL; - intern->zo.handlers = (zend_object_handlers *) &php_sdl_palette_handlers; + intern->zo.handlers = (zend_object_handlers *)&php_sdl_palette_handlers; return &intern->zo; } @@ -1217,31 +1280,38 @@ zval *sdl_palette_read_property(zend_object *object, zend_string *member, int ty char *member_val = ZSTR_VAL(member); zval *retval; - if (!intern->palette) { + if (!intern->palette) + { return zend_std_read_property(object, member, type, cache_slot, rv); } retval = rv; - if (!strcmp(member_val, "ncolors")) { + if (!strcmp(member_val, "ncolors")) + { ZVAL_LONG(retval, intern->palette->ncolors); - - } else if (!strcmp(member_val, "version")) { + } + else if (!strcmp(member_val, "version")) + { ZVAL_LONG(retval, intern->palette->version); - - } else if (!strcmp(member_val, "refcount")) { + } + else if (!strcmp(member_val, "refcount")) + { ZVAL_LONG(retval, intern->palette->refcount); - - } else if (!strcmp(member_val, "colors")) { + } + else if (!strcmp(member_val, "colors")) + { int i; zval z_color; array_init(retval); - for (i=0 ; ipalette->ncolors ; i++) { - sdl_color_to_zval(&intern->palette->colors[i], &z_color ); + for (i = 0; i < intern->palette->ncolors; i++) + { + sdl_color_to_zval(&intern->palette->colors[i], &z_color); add_next_index_zval(retval, &z_color); } - - } else { + } + else + { retval = zend_std_read_property(object, member, type, cache_slot, rv); return retval; @@ -1251,9 +1321,9 @@ zval *sdl_palette_read_property(zend_object *object, zend_string *member, int ty } /* }}} */ -#define SDL_PALETTE_ADD_PROPERTY(n,f) \ - ZVAL_LONG(&zv, f); \ - zend_hash_str_update(props, n, sizeof(n)-1, &zv); +#define SDL_PALETTE_ADD_PROPERTY(n, f) \ + ZVAL_LONG(&zv, f); \ + zend_hash_str_update(props, n, sizeof(n) - 1, &zv); /* {{{ sdl_palette_get_properties*/ static HashTable *sdl_palette_get_properties(zend_object *object) @@ -1265,17 +1335,19 @@ static HashTable *sdl_palette_get_properties(zend_object *object) props = zend_std_get_properties(object); - if (intern->palette) { - SDL_PALETTE_ADD_PROPERTY("ncolors", intern->palette->ncolors); - SDL_PALETTE_ADD_PROPERTY("version", intern->palette->version); + if (intern->palette) + { + SDL_PALETTE_ADD_PROPERTY("ncolors", intern->palette->ncolors); + SDL_PALETTE_ADD_PROPERTY("version", intern->palette->version); SDL_PALETTE_ADD_PROPERTY("refcount", intern->palette->refcount); array_init(&zv); - for (i=0 ; ipalette->ncolors ; i++) { - sdl_color_to_zval(&intern->palette->colors[i], &z_color ); + for (i = 0; i < intern->palette->ncolors; i++) + { + sdl_color_to_zval(&intern->palette->colors[i], &z_color); add_next_index_zval(&zv, &z_color); } - zend_hash_str_update(props, "colors", sizeof("colors")-1, &zv); + zend_hash_str_update(props, "colors", sizeof("colors") - 1, &zv); } return props; } @@ -1290,13 +1362,15 @@ static zval *sdl_palette_write_property(zend_object *object, zend_string *name, /* }}} */ /* {{{ php_sdl_pixelformat_free - */ + */ static void php_sdl_pixelformat_free(zend_object *object) { php_sdl_pixelformat *intern = php_sdl_pixelformat_from_obj(object); - if (intern->format) { - if (!(intern->flags & SDL_DONTFREE)) { + if (intern->format) + { + if (!(intern->flags & SDL_DONTFREE)) + { SDL_FreeFormat(intern->format); } } @@ -1307,7 +1381,7 @@ static void php_sdl_pixelformat_free(zend_object *object) /* {{{ php_sdl_pixelformat_new */ -static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type) +static zend_object *php_sdl_pixelformat_new(zend_class_entry *class_type) { php_sdl_pixelformat *intern = zend_object_alloc(sizeof(php_sdl_pixelformat), class_type); @@ -1315,7 +1389,7 @@ static zend_object* php_sdl_pixelformat_new(zend_class_entry *class_type) object_properties_init(&intern->zo, class_type); intern->format = NULL; - intern->zo.handlers = (zend_object_handlers *) &php_sdl_pixelformat_handlers; + intern->zo.handlers = (zend_object_handlers *)&php_sdl_pixelformat_handlers; return &intern->zo; } @@ -1328,61 +1402,79 @@ zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, in char *member_val = ZSTR_VAL(member); zval *retval; - if (!intern->format) { + if (!intern->format) + { return zend_std_read_property(object, member, type, cache_slot, rv); } retval = rv; - if (!strcmp(member_val, "format")) { + if (!strcmp(member_val, "format")) + { ZVAL_LONG(retval, intern->format->format); - - } else if (!strcmp(member_val, "BitsPerPixel")) { + } + else if (!strcmp(member_val, "BitsPerPixel")) + { ZVAL_LONG(retval, intern->format->BitsPerPixel); - - } else if (!strcmp(member_val, "BytesPerPixel")) { + } + else if (!strcmp(member_val, "BytesPerPixel")) + { ZVAL_LONG(retval, intern->format->BytesPerPixel); - - } else if (!strcmp(member_val, "Rmask")) { + } + else if (!strcmp(member_val, "Rmask")) + { ZVAL_LONG(retval, intern->format->Rmask); - - } else if (!strcmp(member_val, "Gmask")) { + } + else if (!strcmp(member_val, "Gmask")) + { ZVAL_LONG(retval, intern->format->Gmask); - - } else if (!strcmp(member_val, "Bmask")) { + } + else if (!strcmp(member_val, "Bmask")) + { ZVAL_LONG(retval, intern->format->Bmask); - - } else if (!strcmp(member_val, "Amask")) { + } + else if (!strcmp(member_val, "Amask")) + { ZVAL_LONG(retval, intern->format->Amask); - - } else if (!strcmp(member_val, "Rloss")) { + } + else if (!strcmp(member_val, "Rloss")) + { ZVAL_LONG(retval, intern->format->Rloss); - - } else if (!strcmp(member_val, "Gloss")) { + } + else if (!strcmp(member_val, "Gloss")) + { ZVAL_LONG(retval, intern->format->Gloss); - - } else if (!strcmp(member_val, "Bloss")) { + } + else if (!strcmp(member_val, "Bloss")) + { ZVAL_LONG(retval, intern->format->Bloss); - - } else if (!strcmp(member_val, "Aloss")) { + } + else if (!strcmp(member_val, "Aloss")) + { ZVAL_LONG(retval, intern->format->Aloss); - - } else if (!strcmp(member_val, "Rshift")) { + } + else if (!strcmp(member_val, "Rshift")) + { ZVAL_LONG(retval, intern->format->Rshift); - - } else if (!strcmp(member_val, "Gshift")) { + } + else if (!strcmp(member_val, "Gshift")) + { ZVAL_LONG(retval, intern->format->Gshift); - - } else if (!strcmp(member_val, "Bshift")) { + } + else if (!strcmp(member_val, "Bshift")) + { ZVAL_LONG(retval, intern->format->Bshift); - - } else if (!strcmp(member_val, "Ashift")) { + } + else if (!strcmp(member_val, "Ashift")) + { ZVAL_LONG(retval, intern->format->Ashift); - - } else if (!strcmp(member_val, "palette")) { + } + else if (!strcmp(member_val, "palette")) + { sdl_palette_to_zval(intern->format->palette, retval, SDL_DONTFREE); - - } else { + } + else + { retval = zend_std_read_property(object, member, type, cache_slot, rv); return retval; @@ -1392,9 +1484,9 @@ zval *sdl_pixelformat_read_property(zend_object *object, zend_string *member, in } /* }}} */ -#define SDL_PIXELFORMAT_ADD_PROPERTY(n,f) \ - ZVAL_LONG(&zv, f); \ - zend_hash_str_update(props, n, sizeof(n)-1, &zv); +#define SDL_PIXELFORMAT_ADD_PROPERTY(n, f) \ + ZVAL_LONG(&zv, f); \ + zend_hash_str_update(props, n, sizeof(n) - 1, &zv); /* {{{ sdl_pixelformat_read_property*/ static HashTable *sdl_pixelformat_get_properties(zend_object *object) @@ -1405,25 +1497,26 @@ static HashTable *sdl_pixelformat_get_properties(zend_object *object) intern = php_sdl_pixelformat_from_obj(object); props = zend_std_get_properties(object); - if (intern->format) { - SDL_PIXELFORMAT_ADD_PROPERTY("format", intern->format->format); - SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel", intern->format->BitsPerPixel); + if (intern->format) + { + SDL_PIXELFORMAT_ADD_PROPERTY("format", intern->format->format); + SDL_PIXELFORMAT_ADD_PROPERTY("BitsPerPixel", intern->format->BitsPerPixel); SDL_PIXELFORMAT_ADD_PROPERTY("BytesPerPixel", intern->format->BytesPerPixel); - SDL_PIXELFORMAT_ADD_PROPERTY("Rmask", intern->format->Rmask); - SDL_PIXELFORMAT_ADD_PROPERTY("Gmask", intern->format->Gmask); - SDL_PIXELFORMAT_ADD_PROPERTY("Bmask", intern->format->Bmask); - SDL_PIXELFORMAT_ADD_PROPERTY("Amask", intern->format->Amask); - SDL_PIXELFORMAT_ADD_PROPERTY("Rloss", intern->format->Rloss); - SDL_PIXELFORMAT_ADD_PROPERTY("Gloss", intern->format->Gloss); - SDL_PIXELFORMAT_ADD_PROPERTY("Bloss", intern->format->Bloss); - SDL_PIXELFORMAT_ADD_PROPERTY("Aloss", intern->format->Aloss); - SDL_PIXELFORMAT_ADD_PROPERTY("Rshift", intern->format->Rshift); - SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Gshift); - SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Bshift); - SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Ashift); + SDL_PIXELFORMAT_ADD_PROPERTY("Rmask", intern->format->Rmask); + SDL_PIXELFORMAT_ADD_PROPERTY("Gmask", intern->format->Gmask); + SDL_PIXELFORMAT_ADD_PROPERTY("Bmask", intern->format->Bmask); + SDL_PIXELFORMAT_ADD_PROPERTY("Amask", intern->format->Amask); + SDL_PIXELFORMAT_ADD_PROPERTY("Rloss", intern->format->Rloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Gloss", intern->format->Gloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Bloss", intern->format->Bloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Aloss", intern->format->Aloss); + SDL_PIXELFORMAT_ADD_PROPERTY("Rshift", intern->format->Rshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Gshift", intern->format->Gshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Bshift", intern->format->Bshift); + SDL_PIXELFORMAT_ADD_PROPERTY("Ashift", intern->format->Ashift); sdl_palette_to_zval(intern->format->palette, &zv, SDL_DONTFREE); - zend_hash_str_update(props, "palette", sizeof("palette")-1, &zv); + zend_hash_str_update(props, "palette", sizeof("palette") - 1, &zv); } return props; } @@ -1438,13 +1531,15 @@ static zval *sdl_pixelformat_write_property(zend_object *object, zend_string *na /* }}} */ /* {{{ php_sdl_pixels_free - */ + */ static void php_sdl_pixels_free(zend_object *object) { php_sdl_pixels *intern = php_sdl_pixels_from_obj(object); - if (intern->pixels.pixels) { - if (!(intern->flags & SDL_DONTFREE)) { + if (intern->pixels.pixels) + { + if (!(intern->flags & SDL_DONTFREE)) + { efree(intern->pixels.pixels); } } @@ -1455,21 +1550,21 @@ static void php_sdl_pixels_free(zend_object *object) /* {{{ php_sdl_pixels_new */ -static zend_object* php_sdl_pixels_new(zend_class_entry *class_type) +static zend_object *php_sdl_pixels_new(zend_class_entry *class_type) { php_sdl_pixels *intern = zend_object_alloc(sizeof(php_sdl_pixels), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); - intern->zo.handlers = (zend_object_handlers *) &php_sdl_pixels_handlers; + intern->zo.handlers = (zend_object_handlers *)&php_sdl_pixels_handlers; return &intern->zo; } /* }}} */ /* {{{ sdl_pixels_read_property*/ -zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv ) +zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int type, void **cache_slot, zval *rv) { php_sdl_pixels *intern; intern = php_sdl_pixels_from_obj(object); @@ -1477,22 +1572,27 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ zval *retval; - if (!intern->pixels.pixels) { + if (!intern->pixels.pixels) + { return zend_std_read_property(object, member, type, cache_slot, rv); } retval = rv; - if (!strcmp(member_val, "h")) { + if (!strcmp(member_val, "h")) + { ZVAL_LONG(retval, intern->pixels.h); - - } else if (!strcmp(member_val, "pitch")) { + } + else if (!strcmp(member_val, "pitch")) + { ZVAL_LONG(retval, intern->pixels.pitch); - - } else if (!strcmp(member_val, "count")) { + } + else if (!strcmp(member_val, "count")) + { ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h); - - } else { + } + else + { retval = zend_std_read_property(object, member, type, cache_slot, rv); return retval; @@ -1502,9 +1602,9 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ } /* }}} */ -#define SDL_PIXELS_ADD_PROPERTY(n,f) \ - ZVAL_LONG(&zv, f); \ - zend_hash_str_update(props, n, sizeof(n)-1, &zv); +#define SDL_PIXELS_ADD_PROPERTY(n, f) \ + ZVAL_LONG(&zv, f); \ + zend_hash_str_update(props, n, sizeof(n) - 1, &zv); /* {{{ sdl_pixels_read_properties */ static HashTable *sdl_pixels_get_properties(zend_object *object) @@ -1515,10 +1615,11 @@ static HashTable *sdl_pixels_get_properties(zend_object *object) props = zend_std_get_properties(object); - if (intern->pixels.pixels) { - SDL_PIXELS_ADD_PROPERTY("pitch", intern->pixels.pitch); - SDL_PIXELS_ADD_PROPERTY("h", intern->pixels.h); - SDL_PIXELS_ADD_PROPERTY("count", intern->pixels.h * intern->pixels.pitch); + if (intern->pixels.pixels) + { + SDL_PIXELS_ADD_PROPERTY("pitch", intern->pixels.pitch); + SDL_PIXELS_ADD_PROPERTY("h", intern->pixels.h); + SDL_PIXELS_ADD_PROPERTY("count", intern->pixels.h * intern->pixels.pitch); } return props; } @@ -1534,61 +1635,57 @@ static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, z /* {{{ php_sdl_color_methods[] */ static const zend_function_entry php_sdl_color_methods[] = { - PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Color, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_Color, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_FE_END -}; + PHP_FE_END}; /* }}} */ /* {{{ php_sdl_palette_methods[] */ static const zend_function_entry php_sdl_palette_methods[] = { - PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists,ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC) /* non-static methods */ - PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none) - PHP_FALIAS(SetColors, SDL_SetPaletteColors, arginfo_SDL_Palette_SetColors) + PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none) + PHP_FALIAS(SetColors, SDL_SetPaletteColors, arginfo_SDL_Palette_SetColors) - PHP_FE_END -}; + PHP_FE_END}; /* }}} */ /* {{{ php_sdl_pixelformat_methods[] */ static const zend_function_entry php_sdl_pixelformat_methods[] = { - PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC) - PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC) - PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC) /* non-static methods */ - PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none) - PHP_FALIAS(SetPalette, SDL_SetPixelFormatPalette, arginfo_SDL_PixelFormat_SetPalette) - PHP_FALIAS(MapRGB, SDL_MapRGB, arginfo_SDL_PixelFormat_MapRGB) - PHP_FALIAS(MapRGBA, SDL_MapRGBA, arginfo_SDL_PixelFormat_MapRGBA) + PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none) + PHP_FALIAS(SetPalette, SDL_SetPixelFormatPalette, arginfo_SDL_PixelFormat_SetPalette) + PHP_FALIAS(MapRGB, SDL_MapRGB, arginfo_SDL_PixelFormat_MapRGB) + PHP_FALIAS(MapRGBA, SDL_MapRGBA, arginfo_SDL_PixelFormat_MapRGBA) - PHP_FE_END -}; + PHP_FE_END}; /* }}} */ /* {{{ php_sdl_pixels_methods[] */ static const zend_function_entry php_sdl_pixels_methods[] = { - PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC) - PHP_FE_END -}; + PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC) + PHP_FE_END}; /* }}} */ #define REGISTER_COLOR_PROP(name) \ @@ -1622,7 +1719,7 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_palette_ce->create_object = php_sdl_palette_new; zend_class_implements(php_sdl_palette_ce, 1, zend_ce_arrayaccess); memcpy(&php_sdl_palette_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - php_sdl_palette_handlers.read_property = sdl_palette_read_property; + php_sdl_palette_handlers.read_property = sdl_palette_read_property; php_sdl_palette_handlers.get_properties = sdl_palette_get_properties; php_sdl_palette_handlers.write_property = sdl_palette_write_property; php_sdl_palette_handlers.free_obj = php_sdl_palette_free; @@ -1637,7 +1734,7 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_pixelformat_ce = zend_register_internal_class(&ce_pixelformat); php_sdl_pixelformat_ce->create_object = php_sdl_pixelformat_new; memcpy(&php_sdl_pixelformat_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - php_sdl_pixelformat_handlers.read_property = sdl_pixelformat_read_property; + php_sdl_pixelformat_handlers.read_property = sdl_pixelformat_read_property; php_sdl_pixelformat_handlers.get_properties = sdl_pixelformat_get_properties; php_sdl_pixelformat_handlers.write_property = sdl_pixelformat_write_property; php_sdl_pixelformat_handlers.free_obj = php_sdl_pixelformat_free; @@ -1665,7 +1762,7 @@ PHP_MINIT_FUNCTION(sdl_pixels) php_sdl_pixels_ce->create_object = php_sdl_pixels_new; zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess); memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - php_sdl_pixels_handlers.read_property = sdl_pixels_read_property; + php_sdl_pixels_handlers.read_property = sdl_pixels_read_property; php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties; php_sdl_pixels_handlers.write_property = sdl_pixels_write_property; php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free; @@ -1676,83 +1773,83 @@ PHP_MINIT_FUNCTION(sdl_pixels) REGISTER_PIXELS_PROP("count"); /* Pixel type. */ - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX4", SDL_PIXELTYPE_INDEX4, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX8", SDL_PIXELTYPE_INDEX8, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED8", SDL_PIXELTYPE_PACKED8, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED16", SDL_PIXELTYPE_PACKED16, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED32", SDL_PIXELTYPE_PACKED32, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU8", SDL_PIXELTYPE_ARRAYU8, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU16", SDL_PIXELTYPE_ARRAYU16, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU32", SDL_PIXELTYPE_ARRAYU32, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF16", SDL_PIXELTYPE_ARRAYF16, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF32", SDL_PIXELTYPE_ARRAYF32, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX4", SDL_PIXELTYPE_INDEX4, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX8", SDL_PIXELTYPE_INDEX8, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED8", SDL_PIXELTYPE_PACKED8, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED16", SDL_PIXELTYPE_PACKED16, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_PACKED32", SDL_PIXELTYPE_PACKED32, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU8", SDL_PIXELTYPE_ARRAYU8, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU16", SDL_PIXELTYPE_ARRAYU16, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYU32", SDL_PIXELTYPE_ARRAYU32, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF16", SDL_PIXELTYPE_ARRAYF16, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_ARRAYF32", SDL_PIXELTYPE_ARRAYF32, CONST_CS | CONST_PERSISTENT); /* Bitmap pixel order, high bit -> low bit. */ - REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_NONE", SDL_BITMAPORDER_NONE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_4321", SDL_BITMAPORDER_4321, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_1234", SDL_BITMAPORDER_1234, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_NONE", SDL_BITMAPORDER_NONE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_4321", SDL_BITMAPORDER_4321, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BITMAPORDER_1234", SDL_BITMAPORDER_1234, CONST_CS | CONST_PERSISTENT); /* Packed component order, high bit -> low bit. */ - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_NONE", SDL_PACKEDORDER_NONE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XRGB", SDL_PACKEDORDER_XRGB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBX", SDL_PACKEDORDER_RGBX, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ARGB", SDL_PACKEDORDER_ARGB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBA", SDL_PACKEDORDER_RGBA, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XBGR", SDL_PACKEDORDER_XBGR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRX", SDL_PACKEDORDER_BGRX, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ABGR", SDL_PACKEDORDER_ABGR, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRA", SDL_PACKEDORDER_BGRA, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_NONE", SDL_PACKEDORDER_NONE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XRGB", SDL_PACKEDORDER_XRGB, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBX", SDL_PACKEDORDER_RGBX, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ARGB", SDL_PACKEDORDER_ARGB, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_RGBA", SDL_PACKEDORDER_RGBA, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_XBGR", SDL_PACKEDORDER_XBGR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRX", SDL_PACKEDORDER_BGRX, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_ABGR", SDL_PACKEDORDER_ABGR, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDORDER_BGRA", SDL_PACKEDORDER_BGRA, CONST_CS | CONST_PERSISTENT); /* Packed component layout. */ - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_NONE", SDL_PACKEDLAYOUT_NONE, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_332", SDL_PACKEDLAYOUT_332, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_4444", SDL_PACKEDLAYOUT_4444, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1555", SDL_PACKEDLAYOUT_1555, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_5551", SDL_PACKEDLAYOUT_5551, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_565", SDL_PACKEDLAYOUT_565, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_8888", SDL_PACKEDLAYOUT_8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_2101010", SDL_PACKEDLAYOUT_2101010, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1010102", SDL_PACKEDLAYOUT_1010102, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_NONE", SDL_PACKEDLAYOUT_NONE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_332", SDL_PACKEDLAYOUT_332, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_4444", SDL_PACKEDLAYOUT_4444, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1555", SDL_PACKEDLAYOUT_1555, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_5551", SDL_PACKEDLAYOUT_5551, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_565", SDL_PACKEDLAYOUT_565, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_8888", SDL_PACKEDLAYOUT_8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_2101010", SDL_PACKEDLAYOUT_2101010, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PACKEDLAYOUT_1010102", SDL_PACKEDLAYOUT_1010102, CONST_CS | CONST_PERSISTENT); /* Pixel format */ - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UNKNOWN", SDL_PIXELFORMAT_UNKNOWN, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1LSB", SDL_PIXELFORMAT_INDEX1LSB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1MSB", SDL_PIXELFORMAT_INDEX1MSB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4LSB", SDL_PIXELFORMAT_INDEX4LSB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4MSB", SDL_PIXELFORMAT_INDEX4MSB, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX8", SDL_PIXELFORMAT_INDEX8, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB332", SDL_PIXELFORMAT_RGB332, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB444", SDL_PIXELFORMAT_RGB444, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB555", SDL_PIXELFORMAT_RGB555, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR555", SDL_PIXELFORMAT_BGR555, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB4444", SDL_PIXELFORMAT_ARGB4444, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA4444", SDL_PIXELFORMAT_RGBA4444, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR4444", SDL_PIXELFORMAT_ABGR4444, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA4444", SDL_PIXELFORMAT_BGRA4444, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB1555", SDL_PIXELFORMAT_ARGB1555, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA5551", SDL_PIXELFORMAT_RGBA5551, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR1555", SDL_PIXELFORMAT_ABGR1555, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA5551", SDL_PIXELFORMAT_BGRA5551, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB565", SDL_PIXELFORMAT_RGB565, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR565", SDL_PIXELFORMAT_BGR565, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB24", SDL_PIXELFORMAT_RGB24, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR24", SDL_PIXELFORMAT_BGR24, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB888", SDL_PIXELFORMAT_RGB888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBX8888", SDL_PIXELFORMAT_RGBX8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR888", SDL_PIXELFORMAT_BGR888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRX8888", SDL_PIXELFORMAT_BGRX8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB8888", SDL_PIXELFORMAT_ARGB8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA8888", SDL_PIXELFORMAT_RGBA8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR8888", SDL_PIXELFORMAT_ABGR8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA8888", SDL_PIXELFORMAT_BGRA8888, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB2101010", SDL_PIXELFORMAT_ARGB2101010, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YV12", SDL_PIXELFORMAT_YV12, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_IYUV", SDL_PIXELFORMAT_IYUV, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YUY2", SDL_PIXELFORMAT_YUY2, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UYVY", SDL_PIXELFORMAT_UYVY, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YVYU", SDL_PIXELFORMAT_YVYU, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UNKNOWN", SDL_PIXELFORMAT_UNKNOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1LSB", SDL_PIXELFORMAT_INDEX1LSB, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX1MSB", SDL_PIXELFORMAT_INDEX1MSB, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4LSB", SDL_PIXELFORMAT_INDEX4LSB, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX4MSB", SDL_PIXELFORMAT_INDEX4MSB, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_INDEX8", SDL_PIXELFORMAT_INDEX8, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB332", SDL_PIXELFORMAT_RGB332, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB444", SDL_PIXELFORMAT_RGB444, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB555", SDL_PIXELFORMAT_RGB555, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR555", SDL_PIXELFORMAT_BGR555, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB4444", SDL_PIXELFORMAT_ARGB4444, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA4444", SDL_PIXELFORMAT_RGBA4444, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR4444", SDL_PIXELFORMAT_ABGR4444, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA4444", SDL_PIXELFORMAT_BGRA4444, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB1555", SDL_PIXELFORMAT_ARGB1555, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA5551", SDL_PIXELFORMAT_RGBA5551, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR1555", SDL_PIXELFORMAT_ABGR1555, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA5551", SDL_PIXELFORMAT_BGRA5551, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB565", SDL_PIXELFORMAT_RGB565, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR565", SDL_PIXELFORMAT_BGR565, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB24", SDL_PIXELFORMAT_RGB24, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR24", SDL_PIXELFORMAT_BGR24, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGB888", SDL_PIXELFORMAT_RGB888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBX8888", SDL_PIXELFORMAT_RGBX8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGR888", SDL_PIXELFORMAT_BGR888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRX8888", SDL_PIXELFORMAT_BGRX8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB8888", SDL_PIXELFORMAT_ARGB8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_RGBA8888", SDL_PIXELFORMAT_RGBA8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ABGR8888", SDL_PIXELFORMAT_ABGR8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_BGRA8888", SDL_PIXELFORMAT_BGRA8888, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_ARGB2101010", SDL_PIXELFORMAT_ARGB2101010, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YV12", SDL_PIXELFORMAT_YV12, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_IYUV", SDL_PIXELFORMAT_IYUV, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YUY2", SDL_PIXELFORMAT_YUY2, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_UYVY", SDL_PIXELFORMAT_UYVY, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_PIXELFORMAT_YVYU", SDL_PIXELFORMAT_YVYU, CONST_CS | CONST_PERSISTENT); return SUCCESS; } From 09a795cbbb4247c855fc6e3ab0a655998988e86e Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 22 Jul 2022 19:07:04 +0100 Subject: [PATCH 44/55] Use bool instead of zend_bool --- src/mouse.c | 268 +++++++++++---------- src/surface.c | 642 ++++++++++++++++++++++++++++---------------------- src/window.c | 564 ++++++++++++++++++++++++-------------------- 3 files changed, 813 insertions(+), 661 deletions(-) diff --git a/src/mouse.c b/src/mouse.c index 890b2ca..88d4e0b 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -21,10 +21,11 @@ static zend_class_entry *php_sdl_cursor_ce; static zend_object_handlers php_sdl_cursor_handlers; -struct php_sdl_cursor { - SDL_Cursor *cursor; - Uint32 flags; - zend_object zo; +struct php_sdl_cursor +{ + SDL_Cursor *cursor; + Uint32 flags; + zend_object zo; }; /* {{{ get_php_sdl_cursor_ce */ @@ -34,28 +35,30 @@ zend_class_entry *get_php_sdl_cursor_ce(void) } /* }}} */ -#define FETCH_CURSOR(__ptr, __id, __check) \ -{ \ - zend_object* zo = Z_OBJ_P(__id);\ - intern = (struct php_sdl_cursor *)((char*)zo - zo->handlers->offset);\ - __ptr = intern->cursor; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ -} +#define FETCH_CURSOR(__ptr, __id, __check) \ + { \ + zend_object *zo = Z_OBJ_P(__id); \ + intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset); \ + __ptr = intern->cursor; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } /* {{{ sdl_cursor_to_zval */ zend_bool sdl_cursor_to_zval(SDL_Cursor *cursor, zval *z_val, Uint32 flags) { - if (cursor) { + if (cursor) + { struct php_sdl_cursor *intern; object_init_ex(z_val, php_sdl_cursor_ce); - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_cursor *)((char*)zo - zo->handlers->offset); + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset); intern->cursor = cursor; - intern->flags = flags; + intern->flags = flags; return 1; } @@ -64,28 +67,28 @@ zend_bool sdl_cursor_to_zval(SDL_Cursor *cursor, zval *z_val, Uint32 flags) } /* }}} */ - /* {{{ zval_to_sdl_cursor */ SDL_GLContext zval_to_sdl_cursor(zval *z_val) { struct php_sdl_cursor *intern; - if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_cursor_ce) { - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_cursor*)((char*)zo - zo->handlers->offset); + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_cursor_ce) + { + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_cursor *)((char *)zo - zo->handlers->offset); return intern->cursor; } return NULL; } /* }}} */ - /* {{{ php_sdl_cursor_free */ static void php_sdl_cursor_free(zend_object *object) { - struct php_sdl_cursor *intern = (struct php_sdl_cursor *)((char*)object - object->handlers->offset); + struct php_sdl_cursor *intern = (struct php_sdl_cursor *)((char *)object - object->handlers->offset); - if (intern->cursor && !(intern->flags & SDL_DONTFREE)) { + if (intern->cursor && !(intern->flags & SDL_DONTFREE)) + { SDL_FreeCursor(intern->cursor); } @@ -93,10 +96,9 @@ static void php_sdl_cursor_free(zend_object *object) } /* }}} */ - /* {{{ php_sdl_cursor_new */ -static zend_object* php_sdl_cursor_new(zend_class_entry *class_type) +static zend_object *php_sdl_cursor_new(zend_class_entry *class_type) { struct php_sdl_cursor *intern; @@ -126,44 +128,48 @@ static PHP_METHOD(SDL_Cursor, __construct) intern = (struct php_sdl_cursor *)Z_OBJ_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); - if (w<=0 || w&7 || h<=0) { + if (w <= 0 || w & 7 || h <= 0) + { zend_throw_exception(zend_exception_get_default(), "Invalid cursor size", 0); return; } - size = w/8 * h; - if (data_len!=size || mask_len!=size) { + size = w / 8 * h; + if (data_len != size || mask_len != size) + { zend_throw_exception_ex(zend_exception_get_default(), 0, "Invalid data or mask, size must be %ld", size); return; } intern->cursor = SDL_CreateCursor((Uint8 *)data, (Uint8 *)mask, (int)w, (int)h, (int)x, (int)y); - if (intern->cursor) { + if (intern->cursor) + { intern->flags = 0; - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); } } /* }}} */ - /* {{{ proto SDL_Cursor::__toString() -*/ + */ static PHP_METHOD(SDL_Cursor, __toString) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } RETVAL_STRING("SDL_Cursor()"); } /* }}} */ - - /* {{{ proto SDL_Cursor SDL_CreateCursor(string data, string mask, int w, int h, int hot_x, int hot_y) * \brief Create a cursor, using the specified bitmap data and @@ -183,9 +189,9 @@ static PHP_METHOD(SDL_Cursor, __toString) * * \sa SDL_FreeCursor() extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, - const Uint8 * mask, - int w, int h, int hot_x, - int hot_y); + const Uint8 * mask, + int w, int h, int hot_x, + int hot_y); */ PHP_FUNCTION(SDL_CreateCursor) { @@ -195,15 +201,18 @@ PHP_FUNCTION(SDL_CreateCursor) long size; SDL_Cursor *cursor; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ssllll", &data, &data_len, &mask, &mask_len, &w, &h, &x, &y)) + { return; } - if (w<=0 || w&7 || h<=0) { + if (w <= 0 || w & 7 || h <= 0) + { php_error_docref(NULL, E_WARNING, "Invalid cursor size"); return; } - size = w/8 * h; - if (data_len!=size || mask_len!=size) { + size = w / 8 * h; + if (data_len != size || mask_len != size) + { php_error_docref(NULL, E_WARNING, "Invalid data or mask, size must be %ld", size); return; } @@ -212,8 +221,6 @@ PHP_FUNCTION(SDL_CreateCursor) } /* }}} */ - - /* {{{ proto SDL_Cursor SDL_CreateSystemCursor(int id) * \brief Create a system cursor. @@ -226,7 +233,8 @@ PHP_FUNCTION(SDL_CreateSystemCursor) zend_long id; SDL_Cursor *cursor; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &id)) + { return; } cursor = SDL_CreateSystemCursor(id); @@ -234,15 +242,14 @@ PHP_FUNCTION(SDL_CreateSystemCursor) } /* }}} */ - /* {{{ proto SDL_Cursor SDL_CreateSystemCursor(int id) * \brief Create a color cursor. * * \sa SDL_FreeCursor() extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, - int hot_x, - int hot_y); + int hot_x, + int hot_y); */ PHP_FUNCTION(SDL_CreateColorCursor) { @@ -251,20 +258,23 @@ PHP_FUNCTION(SDL_CreateColorCursor) SDL_Surface *surface; SDL_Cursor *cursor; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_surface, get_php_sdl_surface_ce(), &x, &y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_surface, get_php_sdl_surface_ce(), &x, &y)) + { return; } surface = zval_to_sdl_surface(z_surface); - if (surface) { + if (surface) + { cursor = SDL_CreateColorCursor(surface, (int)x, (int)y); sdl_cursor_to_zval(cursor, return_value, 0); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object"); } } /* }}} */ - /* {{{ proto void SDL_FreeCursor(SDL_Cursor cursor) * \brief Frees a cursor created with SDL_CreateCursor(). @@ -278,7 +288,8 @@ PHP_FUNCTION(SDL_FreeCursor) zval *z_cursor; SDL_Cursor *cursor; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) + { return; } FETCH_CURSOR(cursor, z_cursor, 1); @@ -299,7 +310,8 @@ PHP_FUNCTION(SDL_SetCursor) zval *z_cursor; SDL_Cursor *cursor; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_cursor, php_sdl_cursor_ce) == FAILURE) + { return; } FETCH_CURSOR(cursor, z_cursor, 1); @@ -308,7 +320,6 @@ PHP_FUNCTION(SDL_SetCursor) } /* }}} */ - /* {{{ proto SDL_Cursor SDL_GetCursor(void) * \brief Return the active cursor. @@ -318,7 +329,8 @@ PHP_FUNCTION(SDL_GetCursor) { SDL_Cursor *cursor; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } cursor = SDL_GetCursor(); @@ -326,7 +338,6 @@ PHP_FUNCTION(SDL_GetCursor) } /* }}} */ - /* {{{ proto SDL_Cursor SDL_GetDefaultCursor(void) * \brief Return the default cursor. @@ -336,7 +347,8 @@ PHP_FUNCTION(SDL_GetDefaultCursor) { SDL_Cursor *cursor; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } cursor = SDL_GetDefaultCursor(); @@ -344,7 +356,6 @@ PHP_FUNCTION(SDL_GetDefaultCursor) } /* }}} */ - /* {{{ proto int SDL_ShowCursor(bool toogle) * \brief Toggle whether or not the cursor is shown. @@ -357,16 +368,16 @@ PHP_FUNCTION(SDL_GetDefaultCursor) */ PHP_FUNCTION(SDL_ShowCursor) { - zend_bool toggle; + bool toggle; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &toggle)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &toggle)) + { return; } RETVAL_BOOL(SDL_ShowCursor(toggle)); } /* }}} */ - /* {{{ proto SDL_Window SDL_GetMouseFocus(void) * \brief Get the window which currently has mouse focus. @@ -374,13 +385,13 @@ PHP_FUNCTION(SDL_ShowCursor) */ PHP_FUNCTION(SDL_GetMouseFocus) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } sdl_window_to_zval(SDL_GetMouseFocus(), return_value, SDL_DONTFREE); } - /* {{{ proto int SDL_GetMouseState(int &x, int &y) * \brief Retrieve the current state of the mouse. @@ -393,19 +404,22 @@ PHP_FUNCTION(SDL_GetMouseFocus) */ PHP_FUNCTION(SDL_GetMouseState) { - zval *z_x=NULL, *z_y=NULL; + zval *z_x = NULL, *z_y = NULL; int x, y; Uint32 state; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) + { return; } state = SDL_GetMouseState(&x, &y); - if (z_x) { + if (z_x) + { zval_dtor(z_x); ZVAL_LONG(z_x, x); } - if (z_y) { + if (z_y) + { zval_dtor(z_y); ZVAL_LONG(z_y, y); } @@ -413,7 +427,6 @@ PHP_FUNCTION(SDL_GetMouseState) } /* }}} */ - /* {{{ proto int SDL_GetRelativeMouseState(int &x, int &y) * \brief Retrieve the relative state of the mouse. @@ -425,19 +438,22 @@ PHP_FUNCTION(SDL_GetMouseState) */ PHP_FUNCTION(SDL_GetRelativeMouseState) { - zval *z_x=NULL, *z_y=NULL; + zval *z_x = NULL, *z_y = NULL; int x, y; Uint32 state; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "|zz", &z_x, &z_y)) + { return; } state = SDL_GetRelativeMouseState(&x, &y); - if (z_x) { + if (z_x) + { zval_dtor(z_x); ZVAL_LONG(z_x, x); } - if (z_y) { + if (z_y) + { zval_dtor(z_y); ZVAL_LONG(z_y, y); } @@ -445,7 +461,6 @@ PHP_FUNCTION(SDL_GetRelativeMouseState) } /* }}} */ - /* {{{ proto void SDL_WarpMouseInWindow(SDL_Window window, int x, int y) * \brief Moves the mouse to the given position within the window. @@ -456,7 +471,7 @@ PHP_FUNCTION(SDL_GetRelativeMouseState) * * \note This function generates a mouse motion event extern DECLSPEC void SDLCALL SDL_WarpMouseInWindow(SDL_Window * window, - int x, int y); + int x, int y); */ PHP_FUNCTION(SDL_WarpMouseInWindow) { @@ -464,19 +479,22 @@ PHP_FUNCTION(SDL_WarpMouseInWindow) SDL_Window *window; zend_long x, y; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_window, get_php_sdl_window_ce(), &x, &y)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Oll", &z_window, get_php_sdl_window_ce(), &x, &y)) + { return; } window = zval_to_sdl_window(z_window); - if (window) { + if (window) + { SDL_WarpMouseInWindow(window, (int)x, (int)y); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object"); } } /* }}} */ - /* {{{ proto int SDL_SetRelativeMouseMode(bool enabled) * \brief Set relative mouse mode. @@ -497,16 +515,16 @@ PHP_FUNCTION(SDL_WarpMouseInWindow) */ PHP_FUNCTION(SDL_SetRelativeMouseMode) { - zend_bool enabled; + bool enabled; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enabled)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "b", &enabled)) + { return; } RETVAL_LONG(SDL_SetRelativeMouseMode(enabled)); } /* }}} */ - /* {{{ proto bool SDL_GetRelativeMouseMode(void) * \brief Query whether relative mouse mode is enabled. @@ -516,39 +534,37 @@ extern DECLSPEC SDL_bool SDLCALL SDL_GetRelativeMouseMode(void); */ PHP_FUNCTION(SDL_GetRelativeMouseMode) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } RETVAL_BOOL(SDL_GetRelativeMouseMode()); } - ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0) ZEND_END_ARG_INFO() - /* {{{ sdl_cursor_methods[] */ static const zend_function_entry php_sdl_cursor_methods[] = { - PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Cursor, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_Cursor, __toString, arginfo_none, ZEND_ACC_PUBLIC) /* non-static methods */ - PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none) - PHP_FALIAS(Set, SDL_SetCursor, arginfo_none) + PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none) + PHP_FALIAS(Set, SDL_SetCursor, arginfo_none) /* static methods */ - ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(CreateSystem, ZEND_FN(SDL_CreateSystemCursor), arginfo_SDL_CreateSystemCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(CreateColor, ZEND_FN(SDL_CreateColorCursor), arginfo_SDL_CreateColorCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(Get, ZEND_FN(SDL_GetCursor), arginfo_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(GetDefault, ZEND_FN(SDL_GetDefaultCursor), arginfo_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(Show, ZEND_FN(SDL_ShowCursor), arginfo_SDL_ShowCursor, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - - ZEND_FE_END -}; + ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(CreateSystem, ZEND_FN(SDL_CreateSystemCursor), arginfo_SDL_CreateSystemCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(CreateColor, ZEND_FN(SDL_CreateColorCursor), arginfo_SDL_CreateColorCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(Get, ZEND_FN(SDL_GetCursor), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(GetDefault, ZEND_FN(SDL_GetDefaultCursor), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(Show, ZEND_FN(SDL_ShowCursor), arginfo_SDL_ShowCursor, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + + ZEND_FE_END}; /* }}} */ -#define REGISTER_CURSOR_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_CURSOR_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("SDL_SYSTEM_CURSOR_" const_name, value, CONST_CS | CONST_PERSISTENT); \ zend_declare_class_constant_long(php_sdl_cursor_ce, ZEND_STRL(const_name), value) @@ -561,25 +577,25 @@ PHP_MINIT_FUNCTION(sdl_mouse) php_sdl_cursor_ce = zend_register_internal_class(&ce); php_sdl_cursor_ce->create_object = php_sdl_cursor_new; memcpy(&php_sdl_cursor_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); - php_sdl_cursor_handlers.free_obj = php_sdl_cursor_free; + php_sdl_cursor_handlers.free_obj = php_sdl_cursor_free; php_sdl_cursor_handlers.offset = XtOffsetOf(struct php_sdl_cursor, zo); /* Cursor types for SDL_CreateSystemCursor. typedef enum SDL_SystemCursor; */ - REGISTER_CURSOR_CLASS_CONST_LONG("ARROW", SDL_SYSTEM_CURSOR_ARROW); - REGISTER_CURSOR_CLASS_CONST_LONG("IBEAM", SDL_SYSTEM_CURSOR_IBEAM); - REGISTER_CURSOR_CLASS_CONST_LONG("WAIT", SDL_SYSTEM_CURSOR_WAIT); + REGISTER_CURSOR_CLASS_CONST_LONG("ARROW", SDL_SYSTEM_CURSOR_ARROW); + REGISTER_CURSOR_CLASS_CONST_LONG("IBEAM", SDL_SYSTEM_CURSOR_IBEAM); + REGISTER_CURSOR_CLASS_CONST_LONG("WAIT", SDL_SYSTEM_CURSOR_WAIT); REGISTER_CURSOR_CLASS_CONST_LONG("CROSSHAIR", SDL_SYSTEM_CURSOR_CROSSHAIR); REGISTER_CURSOR_CLASS_CONST_LONG("WAITARROW", SDL_SYSTEM_CURSOR_WAITARROW); - REGISTER_CURSOR_CLASS_CONST_LONG("SIZENWSE", SDL_SYSTEM_CURSOR_SIZENWSE); - REGISTER_CURSOR_CLASS_CONST_LONG("SIZENESW", SDL_SYSTEM_CURSOR_SIZENESW); - REGISTER_CURSOR_CLASS_CONST_LONG("SIZEWE", SDL_SYSTEM_CURSOR_SIZEWE); - REGISTER_CURSOR_CLASS_CONST_LONG("SIZENS", SDL_SYSTEM_CURSOR_SIZENS); - REGISTER_CURSOR_CLASS_CONST_LONG("SIZEALL", SDL_SYSTEM_CURSOR_SIZEALL); - REGISTER_CURSOR_CLASS_CONST_LONG("NO", SDL_SYSTEM_CURSOR_NO); - REGISTER_CURSOR_CLASS_CONST_LONG("HAND", SDL_SYSTEM_CURSOR_HAND); - - REGISTER_LONG_CONSTANT("SDL_NUM_SYSTEM_CURSORS", SDL_NUM_SYSTEM_CURSORS, CONST_CS | CONST_PERSISTENT); + REGISTER_CURSOR_CLASS_CONST_LONG("SIZENWSE", SDL_SYSTEM_CURSOR_SIZENWSE); + REGISTER_CURSOR_CLASS_CONST_LONG("SIZENESW", SDL_SYSTEM_CURSOR_SIZENESW); + REGISTER_CURSOR_CLASS_CONST_LONG("SIZEWE", SDL_SYSTEM_CURSOR_SIZEWE); + REGISTER_CURSOR_CLASS_CONST_LONG("SIZENS", SDL_SYSTEM_CURSOR_SIZENS); + REGISTER_CURSOR_CLASS_CONST_LONG("SIZEALL", SDL_SYSTEM_CURSOR_SIZEALL); + REGISTER_CURSOR_CLASS_CONST_LONG("NO", SDL_SYSTEM_CURSOR_NO); + REGISTER_CURSOR_CLASS_CONST_LONG("HAND", SDL_SYSTEM_CURSOR_HAND); + + REGISTER_LONG_CONSTANT("SDL_NUM_SYSTEM_CURSORS", SDL_NUM_SYSTEM_CURSORS, CONST_CS | CONST_PERSISTENT); zend_declare_class_constant_long(php_sdl_cursor_ce, ZEND_STRL("NUM_SYSTEM"), SDL_NUM_SYSTEM_CURSORS); /* @@ -588,16 +604,16 @@ PHP_MINIT_FUNCTION(sdl_mouse) * - Button 2: Middle mouse button * - Button 3: Right mouse button */ - REGISTER_LONG_CONSTANT("SDL_BUTTON_LEFT", SDL_BUTTON_LEFT, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_MIDDLE", SDL_BUTTON_MIDDLE, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_RIGHT", SDL_BUTTON_RIGHT, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_X1", SDL_BUTTON_X1, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_X2", SDL_BUTTON_X2, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_LMASK", SDL_BUTTON_LMASK, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_MMASK", SDL_BUTTON_MMASK, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_RMASK", SDL_BUTTON_RMASK, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_X1MASK", SDL_BUTTON_X1MASK, CONST_CS | CONST_PERSISTENT); \ - REGISTER_LONG_CONSTANT("SDL_BUTTON_X2MASK", SDL_BUTTON_X2MASK, CONST_CS | CONST_PERSISTENT); \ + REGISTER_LONG_CONSTANT("SDL_BUTTON_LEFT", SDL_BUTTON_LEFT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_MIDDLE", SDL_BUTTON_MIDDLE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_RIGHT", SDL_BUTTON_RIGHT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_X1", SDL_BUTTON_X1, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_X2", SDL_BUTTON_X2, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_LMASK", SDL_BUTTON_LMASK, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_MMASK", SDL_BUTTON_MMASK, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_RMASK", SDL_BUTTON_RMASK, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_X1MASK", SDL_BUTTON_X1MASK, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_BUTTON_X2MASK", SDL_BUTTON_X2MASK, CONST_CS | CONST_PERSISTENT); return SUCCESS; } diff --git a/src/surface.c b/src/surface.c index 8684487..76a17f6 100644 --- a/src/surface.c +++ b/src/surface.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -23,10 +23,11 @@ static zend_class_entry *php_sdl_surface_ce; static zend_object_handlers php_sdl_surface_handlers; -struct php_sdl_surface { - SDL_Surface *surface; - Uint32 flags; - zend_object zo; +struct php_sdl_surface +{ + SDL_Surface *surface; + Uint32 flags; + zend_object zo; }; zend_class_entry *get_php_sdl_surface_ce(void) @@ -34,26 +35,28 @@ zend_class_entry *get_php_sdl_surface_ce(void) return php_sdl_surface_ce; } -#define FETCH_SURFACE(__ptr, __id, __check) \ -{ \ - zend_object* zox = Z_OBJ_P(__id);\ - intern = (struct php_sdl_surface*)((char*)zox - zox->handlers->offset);\ - __ptr = intern->surface; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ -} +#define FETCH_SURFACE(__ptr, __id, __check) \ + { \ + zend_object *zox = Z_OBJ_P(__id); \ + intern = (struct php_sdl_surface *)((char *)zox - zox->handlers->offset); \ + __ptr = intern->surface; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } /* {{{ sdl_surface_to_zval */ zend_bool sdl_surface_to_zval(SDL_Surface *surface, zval *z_val) { - if (surface) { + if (surface) + { struct php_sdl_surface *intern; object_init_ex(z_val, php_sdl_surface_ce); - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset); + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset); intern->surface = surface; /* copy flags to be able to check before access to surface */ intern->flags = surface->flags; @@ -70,17 +73,16 @@ SDL_Surface *zval_to_sdl_surface(zval *z_val) { struct php_sdl_surface *intern; - if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_surface_ce) { - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset); + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_surface_ce) + { + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset); return intern->surface; - } + } return NULL; } /* }}} */ - - /* {{{ proto SDL_Surface SDL_CreateRGBSurface(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask) * Allocate and free an RGB surface. @@ -100,15 +102,16 @@ SDL_Surface *zval_to_sdl_surface(zval *z_val) * \param Bmask The blue mask of the surface to create. * \param Amask The alpha mask of the surface to create. extern DECLSPEC SDL_Surface *SDLCALL SDL_CreateRGBSurface - (Uint32 flags, int width, int height, int depth, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); + (Uint32 flags, int width, int height, int depth, + Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); */ PHP_FUNCTION(SDL_CreateRGBSurface) { zend_long flags, width, height, depth, rmask, gmask, bmask, amask; SDL_Surface *surface; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) + { return; } surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask); @@ -126,7 +129,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface) * * \return the new surface, or NULL if there was an error. extern DECLSPEC SDL_Surface *SDLCALL SDL_LoadBMP_RW(SDL_RWops * src, - int freesrc); + int freesrc); */ PHP_FUNCTION(SDL_LoadBMP_RW) { @@ -135,12 +138,14 @@ PHP_FUNCTION(SDL_LoadBMP_RW) SDL_Surface *surface; SDL_RWops *rwops; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &z_rwops, get_php_sdl_rwops_ce(), &freesrc)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "Ol", &z_rwops, get_php_sdl_rwops_ce(), &freesrc)) + { return; } rwops = zval_to_sdl_rwops(z_rwops); surface = SDL_LoadBMP_RW(rwops, 0); - if (freesrc) { + if (freesrc) + { /* we close the SDL_RWops ourself, to free the PHP object */ zval_dtor(z_rwops); ZVAL_NULL(z_rwops); @@ -149,8 +154,6 @@ PHP_FUNCTION(SDL_LoadBMP_RW) } /* }}} */ - - /* {{{ proto SDL_Surface SDL_LoadBMP(string file) PHP note: stream are supported @@ -166,7 +169,8 @@ PHP_FUNCTION(SDL_LoadBMP) size_t path_len; SDL_Surface *surface = NULL; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &path, &path_len)) + { return; } @@ -176,7 +180,6 @@ PHP_FUNCTION(SDL_LoadBMP) } /* }}} */ - /* {{{ proto SDL_Surface::__construct(int flags, int width, int height, int depth, int Rmask, int Gmask, int Bmask, int Amask) */ static PHP_METHOD(SDL_Surface, __construct) { @@ -184,56 +187,61 @@ static PHP_METHOD(SDL_Surface, __construct) zend_long flags, width, height, depth, rmask, gmask, bmask, amask; zend_error_handling error_handling; - zend_object* zo = Z_OBJ_P(getThis()); - intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset); + zend_object *zo = Z_OBJ_P(getThis()); + intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "llllllll", &flags, &width, &height, &depth, &rmask, &gmask, &bmask, &amask)) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); intern->surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask); - if (intern->surface) { + if (intern->surface) + { /* copy flags to be able to check before access to surface */ intern->flags = intern->surface->flags; - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); } } /* }}} */ - /* {{{ proto SDL_Surface::__toString() */ static PHP_METHOD(SDL_Surface, __toString) { struct php_sdl_surface *intern; char *buf; - size_t buf_len; + size_t buf_len; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } - zend_object* zo = Z_OBJ_P(getThis()); - intern = (struct php_sdl_surface*)((char*)zo - zo->handlers->offset); + zend_object *zo = Z_OBJ_P(getThis()); + intern = (struct php_sdl_surface *)((char *)zo - zo->handlers->offset); - if (intern->surface) { + if (intern->surface) + { buf_len = spprintf(&buf, 100, "SDL_Surface(%u,%d,%d,%u,0x%x,0x%x,0x%x,0x%x)", - intern->surface->flags, intern->surface->w, intern->surface->h, - intern->surface->format->BitsPerPixel, intern->surface->format->Rmask, - intern->surface->format->Gmask, intern->surface->format->Bmask, intern->surface->format->Amask); + intern->surface->flags, intern->surface->w, intern->surface->h, + intern->surface->format->BitsPerPixel, intern->surface->format->Rmask, + intern->surface->format->Gmask, intern->surface->format->Bmask, intern->surface->format->Amask); RETVAL_STRINGL(buf, buf_len); - efree(buf); - } else { + efree(buf); + } + else + { RETVAL_STRING("SDL_Surface()"); } } /* }}} */ - - /* {{{ proto int SDL_SaveBMP_RW(SDL_Surface surface, SDL_RWops &dst, int freedst) * Save a surface to a seekable SDL data stream (memory or file). @@ -242,7 +250,7 @@ static PHP_METHOD(SDL_Surface, __toString) * * \return 0 if successful or -1 if there was an error. extern DECLSPEC int SDLCALL SDL_SaveBMP_RW - (SDL_Surface * surface, SDL_RWops * dst, int freedst); + (SDL_Surface * surface, SDL_RWops * dst, int freedst); */ PHP_FUNCTION(SDL_SaveBMP_RW) { @@ -253,20 +261,23 @@ PHP_FUNCTION(SDL_SaveBMP_RW) SDL_RWops *rwops; int result; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_surface, php_sdl_surface_ce, &z_rwops, get_php_sdl_rwops_ce(), &freedst) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_surface, php_sdl_surface_ce, &z_rwops, get_php_sdl_rwops_ce(), &freedst) == FAILURE) + { return; } FETCH_SURFACE(surface, z_surface, 1); rwops = zval_to_sdl_rwops(z_rwops); - if (!rwops) { + if (!rwops) + { php_error_docref(NULL, E_WARNING, "Invalid SDL_RWops object"); RETURN_LONG(-1); } result = SDLCALL SDL_SaveBMP_RW(surface, rwops, 0); - if (freedst) { + if (freedst) + { /* we close the SDL_RWops ourself, to free the PHP object */ zval_dtor(z_rwops); ZVAL_NULL(z_rwops); @@ -275,14 +286,12 @@ PHP_FUNCTION(SDL_SaveBMP_RW) } /* }}} */ - - /* {{{ proto int SDL_SaveBMP(SDL_Surface surface, string path) PHP note: stream are "partially" supported (only when PHP_STREAM_AS_STDIO) define SDL_SaveBMP(surface, file) \ - SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) + SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1) */ PHP_FUNCTION(SDL_SaveBMP) @@ -296,7 +305,8 @@ PHP_FUNCTION(SDL_SaveBMP) int result = -1; php_stream *stream; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_surface, php_sdl_surface_ce, &path, &path_len) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_surface, php_sdl_surface_ce, &path, &path_len) == FAILURE) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -305,7 +315,8 @@ PHP_FUNCTION(SDL_SaveBMP) php_stream_to_zval_rwops(stream, &z_rwops, 0); rwops = zval_to_sdl_rwops(&z_rwops); - if (rwops) { + if (rwops) + { result = SDLCALL SDL_SaveBMP_RW(surface, rwops, 0); } zval_dtor(&z_rwops); @@ -314,7 +325,6 @@ PHP_FUNCTION(SDL_SaveBMP) } /* }}} */ - /* {{{ proto void SDL_FreeSurface(SDL_Surface surface) * \brief Destroy a window. @@ -326,7 +336,8 @@ PHP_FUNCTION(SDL_FreeSurface) zval *object; SDL_Surface *surface; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_surface_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_surface_ce) == FAILURE) + { return; } FETCH_SURFACE(surface, object, 1); @@ -336,8 +347,6 @@ PHP_FUNCTION(SDL_FreeSurface) } /* }}} */ - - /* {{{ proto SDL_FillRect(SDL_Surface surface, SDL_Rect rect, int color) * Performs a fast fill of the given rectangle with \c color. @@ -349,7 +358,7 @@ PHP_FUNCTION(SDL_FreeSurface) * * \return 0 on success, or -1 on error. extern DECLSPEC int SDLCALL SDL_FillRect - (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); + (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); */ PHP_FUNCTION(SDL_FillRect) { @@ -359,7 +368,8 @@ PHP_FUNCTION(SDL_FillRect) SDL_Rect rect; SDL_Surface *surface; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOl", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce(), &color) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOl", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce(), &color) == FAILURE) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -369,11 +379,10 @@ PHP_FUNCTION(SDL_FillRect) } /* }}} */ - /* {{{ proto int SDL_FillRects(SDL_Surface surface, SDL_Rect rect, int count, int color) extern DECLSPEC int SDLCALL SDL_FillRects - (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); + (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); */ PHP_FUNCTION(SDL_FillRects) { @@ -384,32 +393,40 @@ PHP_FUNCTION(SDL_FillRects) SDL_Rect *rects; SDL_Surface *surface; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oall", &z_surface, php_sdl_surface_ce, &z_rects, &count, &color) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oall", &z_surface, php_sdl_surface_ce, &z_rects, &count, &color) == FAILURE) + { return; } FETCH_SURFACE(surface, z_surface, 1); - if (count<=0) { + if (count <= 0) + { count = zend_hash_next_free_element(Z_ARRVAL_P(z_rects)); } - rects = emalloc(sizeof(SDL_Rect)*count); + rects = emalloc(sizeof(SDL_Rect) * count); - for (i=nb=0 ; iRGB: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source alpha-channel and per-surface alpha) - SDL_SRCCOLORKEY ignored. - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy RGB. - if SDL_SRCCOLORKEY set, only copy the pixels matching the - RGB values of the source color key, ignoring alpha in the - comparison. - - RGB->RGBA: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source per-surface alpha) - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy RGB, set destination alpha to source per-surface alpha value. - both: - if SDL_SRCCOLORKEY set, only copy the pixels matching the - source color key. - - RGBA->RGBA: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source alpha-channel and per-surface alpha) - SDL_SRCCOLORKEY ignored. - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy all of RGBA to the destination. - if SDL_SRCCOLORKEY set, only copy the pixels matching the - RGB values of the source color key, ignoring alpha in the - comparison. - - RGB->RGB: - Source surface blend mode set to SDL_BLENDMODE_BLEND: - alpha-blend (using the source per-surface alpha) - Source surface blend mode set to SDL_BLENDMODE_NONE: - copy RGB. - both: - if SDL_SRCCOLORKEY set, only copy the pixels matching the - source color key. - \endverbatim + RGBA->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB, set destination alpha to source per-surface alpha value. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + + RGBA->RGBA: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source alpha-channel and per-surface alpha) + SDL_SRCCOLORKEY ignored. + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy all of RGBA to the destination. + if SDL_SRCCOLORKEY set, only copy the pixels matching the + RGB values of the source color key, ignoring alpha in the + comparison. + + RGB->RGB: + Source surface blend mode set to SDL_BLENDMODE_BLEND: + alpha-blend (using the source per-surface alpha) + Source surface blend mode set to SDL_BLENDMODE_NONE: + copy RGB. + both: + if SDL_SRCCOLORKEY set, only copy the pixels matching the + source color key. + \endverbatim * * You should call SDL_BlitSurface() unless you know exactly how SDL @@ -559,8 +575,8 @@ PHP_FUNCTION(SDL_UnlockSurface) * This is the public blit function, SDL_BlitSurface(), and it performs * rectangle validation and clipping before passing it to SDL_LowerBlit() extern DECLSPEC int SDLCALL SDL_UpperBlit - (SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); */ PHP_FUNCTION(SDL_UpperBlit) { @@ -570,42 +586,44 @@ PHP_FUNCTION(SDL_UpperBlit) SDL_Rect srect, drect; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) + { return; } FETCH_SURFACE(src, z_src, 1); FETCH_SURFACE(dst, z_dst, 1); - if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) { + if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect))) + { php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object"); return; } - /* - if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) { - php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object"); - return; - } else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) { - php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored"); - } - * */ + /* +if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) { + php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object"); + return; +} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) { + php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored"); +} + * */ - result = SDL_UpperBlit(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect), - dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect)); + result = SDL_UpperBlit(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect), + dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect)); - if (result==0 && z_drect && Z_TYPE_P(z_drect)==IS_OBJECT) { + if (result == 0 && z_drect && Z_TYPE_P(z_drect) == IS_OBJECT) + { sdl_rect_to_zval(&drect, z_drect); } RETURN_LONG(result); } /* }}} */ - /* {{{ proto void SDL_LowerBlit(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst , SDL_rect &dstrect) * This is a semi-private blit function and it performs low-level surface * blitting only. extern DECLSPEC int SDLCALL SDL_LowerBlit - (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); */ PHP_FUNCTION(SDL_LowerBlit) { @@ -615,7 +633,8 @@ PHP_FUNCTION(SDL_LowerBlit) SDL_Rect srect, drect; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) + { return; } FETCH_SURFACE(src, z_src, 1); @@ -625,7 +644,8 @@ PHP_FUNCTION(SDL_LowerBlit) result = SDL_LowerBlit(src, &srect, dst, &drect); - if (result==0) { + if (result == 0) + { zval_dtor(z_srect); sdl_rect_to_zval(&srect, z_srect); zval_dtor(z_drect); @@ -635,14 +655,13 @@ PHP_FUNCTION(SDL_LowerBlit) } /* }}} */ - /* {{{ proto void SDL_UpperBlitScaled(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst [, SDL_rect &dstrect]) * This is the public scaled blit function, SDL_BlitScaled(), and it performs * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() extern DECLSPEC int SDLCALL SDL_UpperBlitScaled - (SDL_Surface * src, const SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); define SDL_BlitScaled SDL_UpperBlitScaled */ PHP_FUNCTION(SDL_UpperBlitScaled) @@ -653,42 +672,44 @@ PHP_FUNCTION(SDL_UpperBlitScaled) SDL_Rect srect, drect; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) + { return; } FETCH_SURFACE(src, z_src, 1); FETCH_SURFACE(dst, z_dst, 1); - if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) { + if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect))) + { php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object"); return; } - /* - if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) { - php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object"); - return; - } else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) { - php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored"); - } - * */ + /* +if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) { + php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object"); + return; +} else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) { + php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored"); +} + * */ - result = SDL_UpperBlitScaled(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect), - dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect)); + result = SDL_UpperBlitScaled(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect), + dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect)); - if (result==0 && z_drect && Z_TYPE_P(z_drect)==IS_OBJECT) { + if (result == 0 && z_drect && Z_TYPE_P(z_drect) == IS_OBJECT) + { sdl_rect_to_zval(&drect, z_drect); } RETURN_LONG(result); } /* }}} */ - /* {{{ proto void SDL_LowerBlitScaled(SDL_Surface src, SDL_rect &srcrect, SDL_Surface dst , SDL_rect &dstrect) * This is a semi-private blit function and it performs low-level surface * scaled blitting only. extern DECLSPEC int SDLCALL SDL_LowerBlitScaled - (SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect); + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); */ PHP_FUNCTION(SDL_LowerBlitScaled) { @@ -698,7 +719,8 @@ PHP_FUNCTION(SDL_LowerBlitScaled) SDL_Rect srect, drect; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOOO", &z_src, php_sdl_surface_ce, &z_srect, get_php_sdl_rect_ce(), &z_dst, php_sdl_surface_ce, &z_drect, get_php_sdl_rect_ce())) + { return; } FETCH_SURFACE(src, z_src, 1); @@ -708,7 +730,8 @@ PHP_FUNCTION(SDL_LowerBlitScaled) result = SDL_LowerBlitScaled(src, &srect, dst, &drect); - if (result==0) { + if (result == 0) + { zval_dtor(z_srect); sdl_rect_to_zval(&srect, z_srect); zval_dtor(z_drect); @@ -718,7 +741,6 @@ PHP_FUNCTION(SDL_LowerBlitScaled) } /* }}} */ - /* {{{ proto void SDL_SoftStretch(SDL_Surface src, SDL_rect srcrect, SDL_Surface dst [, SDL_rect dstrect]) * \brief Perform a fast, low quality, stretch blit between two surfaces of the @@ -726,9 +748,9 @@ PHP_FUNCTION(SDL_LowerBlitScaled) * * \note This function uses a static buffer, and is not thread-safe. extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, - const SDL_Rect * srcrect, - SDL_Surface * dst, - const SDL_Rect * dstrect); + const SDL_Rect * srcrect, + SDL_Surface * dst, + const SDL_Rect * dstrect); */ PHP_FUNCTION(SDL_SoftStretch) @@ -739,30 +761,34 @@ PHP_FUNCTION(SDL_SoftStretch) SDL_Rect srect, drect; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OzO|z", &z_src, php_sdl_surface_ce, &z_srect, &z_dst, php_sdl_surface_ce, &z_drect)) + { return; } FETCH_SURFACE(src, z_src, 1); FETCH_SURFACE(dst, z_dst, 1); - if (!(Z_TYPE_P(z_srect)==IS_NULL || zval_to_sdl_rect(z_srect, &srect))) { + if (!(Z_TYPE_P(z_srect) == IS_NULL || zval_to_sdl_rect(z_srect, &srect))) + { php_error_docref(NULL, E_ERROR, "srcrect is not a SDL_Rect object"); return; } - if (z_drect && !(Z_TYPE_P(z_drect)==IS_NULL || zval_to_sdl_rect(z_drect, &drect))) { + if (z_drect && !(Z_TYPE_P(z_drect) == IS_NULL || zval_to_sdl_rect(z_drect, &drect))) + { php_error_docref(NULL, E_ERROR, "dstrect is not a SDL_Rect object"); return; - } else if (z_drect && Z_TYPE_P(z_drect)==IS_NULL) { + } + else if (z_drect && Z_TYPE_P(z_drect) == IS_NULL) + { php_error_docref(NULL, E_NOTICE, "dstrect is not a SDL_Rect object, so is ignored"); } - result = SDL_SoftStretch(src, (Z_TYPE_P(z_srect)==IS_NULL ? NULL : &srect), - dst, (z_drect==NULL || Z_TYPE_P(z_drect)==IS_NULL ? NULL : &drect)); + result = SDL_SoftStretch(src, (Z_TYPE_P(z_srect) == IS_NULL ? NULL : &srect), + dst, (z_drect == NULL || Z_TYPE_P(z_drect) == IS_NULL ? NULL : &drect)); RETURN_LONG(result); } /* }}} */ - /* {{{ proto void SDL_SetSurfaceRLE(SDL_Surface src, int flag) * \brief Sets the RLE acceleration hint for a surface. @@ -772,7 +798,7 @@ PHP_FUNCTION(SDL_SoftStretch) * \note If RLE is enabled, colorkey and alpha blending blits are much faster, * but the surface must be locked before directly accessing the pixels. extern DECLSPEC int SDLCALL SDL_SetSurfaceRLE(SDL_Surface * surface, - int flag); + int flag); */ PHP_FUNCTION(SDL_SetSurfaceRLE) { @@ -781,7 +807,8 @@ PHP_FUNCTION(SDL_SetSurfaceRLE) zend_long flag; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &flag)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &flag)) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -801,17 +828,18 @@ PHP_FUNCTION(SDL_SetSurfaceRLE) * * You can pass SDL_RLEACCEL to enable RLE accelerated blits. extern DECLSPEC int SDLCALL SDL_SetColorKey(SDL_Surface * surface, - int flag, Uint32 key); + int flag, Uint32 key); */ PHP_FUNCTION(SDL_SetColorKey) { struct php_sdl_surface *intern; zval *z_surface; - zend_bool flag; + bool flag; zend_long key = 0; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob|l", &z_surface, php_sdl_surface_ce, &flag, &key)) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -830,7 +858,7 @@ PHP_FUNCTION(SDL_SetColorKey) * \return 0 on success, or -1 if the surface is not valid or colorkey is not * enabled. extern DECLSPEC int SDLCALL SDL_GetColorKey(SDL_Surface * surface, - Uint32 * key); + Uint32 * key); */ PHP_FUNCTION(SDL_GetColorKey) { @@ -840,12 +868,14 @@ PHP_FUNCTION(SDL_GetColorKey) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_key)) + { return; } FETCH_SURFACE(surface, z_surface, 1); result = SDL_GetColorKey(surface, &key); - if (result == 0) { + if (result == 0) + { zval_dtor(z_key); ZVAL_LONG(z_key, (long)key); } @@ -866,7 +896,7 @@ PHP_FUNCTION(SDL_GetColorKey) * * \sa SDL_GetSurfaceColorMod() extern DECLSPEC int SDLCALL SDL_SetSurfaceColorMod(SDL_Surface * surface, - Uint8 r, Uint8 g, Uint8 b); + Uint8 r, Uint8 g, Uint8 b); */ PHP_FUNCTION(SDL_SetSurfaceColorMod) { @@ -875,7 +905,8 @@ PHP_FUNCTION(SDL_SetSurfaceColorMod) zend_long r, g, b; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_surface, php_sdl_surface_ce, &r, &g, &b)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_surface, php_sdl_surface_ce, &r, &g, &b)) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -896,8 +927,8 @@ PHP_FUNCTION(SDL_SetSurfaceColorMod) * * \sa SDL_SetSurfaceColorMod() extern DECLSPEC int SDLCALL SDL_GetSurfaceColorMod(SDL_Surface * surface, - Uint8 * r, Uint8 * g, - Uint8 * b); + Uint8 * r, Uint8 * g, + Uint8 * b); */ PHP_FUNCTION(SDL_GetSurfaceColorMod) { @@ -907,12 +938,14 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/z/", &z_surface, php_sdl_surface_ce, &z_r, &z_g, &z_b)) + { return; } FETCH_SURFACE(surface, z_surface, 1); result = SDL_GetSurfaceColorMod(surface, &r, &g, &b); - if (result == 0) { + if (result == 0) + { zval_dtor(z_r); ZVAL_LONG(z_r, (long)r); zval_dtor(z_g); @@ -935,7 +968,7 @@ PHP_FUNCTION(SDL_GetSurfaceColorMod) * * \sa SDL_GetSurfaceAlphaMod() extern DECLSPEC int SDLCALL SDL_SetSurfaceAlphaMod(SDL_Surface * surface, - Uint8 alpha); + Uint8 alpha); */ PHP_FUNCTION(SDL_SetSurfaceAlphaMod) { @@ -944,7 +977,8 @@ PHP_FUNCTION(SDL_SetSurfaceAlphaMod) zend_long a; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &a)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &a)) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -963,7 +997,7 @@ PHP_FUNCTION(SDL_SetSurfaceAlphaMod) * * \sa SDL_SetSurfaceAlphaMod() extern DECLSPEC int SDLCALL SDL_GetSurfaceAlphaMod(SDL_Surface * surface, - Uint8 * alpha); + Uint8 * alpha); */ PHP_FUNCTION(SDL_GetSurfaceAlphaMod) { @@ -973,12 +1007,14 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_a)) + { return; } FETCH_SURFACE(surface, z_surface, 1); result = SDL_GetSurfaceAlphaMod(surface, &a); - if (result == 0) { + if (result == 0) + { zval_dtor(z_a); ZVAL_LONG(z_a, (long)a); } @@ -986,7 +1022,6 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod) } /* }}} */ - /* {{{ proto int SDL_SetSurfaceBlendMode(SDL_Surface src, int blendmode) * \brief Set the blend mode used for blit operations. * @@ -997,7 +1032,7 @@ PHP_FUNCTION(SDL_GetSurfaceAlphaMod) * * \sa SDL_GetSurfaceBlendMode() extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, - SDL_BlendMode blendMode); + SDL_BlendMode blendMode); */ PHP_FUNCTION(SDL_SetSurfaceBlendMode) { @@ -1006,7 +1041,8 @@ PHP_FUNCTION(SDL_SetSurfaceBlendMode) zend_long mode; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &mode)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &z_surface, php_sdl_surface_ce, &mode)) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -1025,7 +1061,7 @@ PHP_FUNCTION(SDL_SetSurfaceBlendMode) * * \sa SDL_SetSurfaceBlendMode() extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, - SDL_BlendMode *blendMode); + SDL_BlendMode *blendMode); */ PHP_FUNCTION(SDL_GetSurfaceBlendMode) { @@ -1035,12 +1071,14 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode) SDL_Surface *surface; int result; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_mode)) + { return; } FETCH_SURFACE(surface, z_surface, 1); result = SDL_GetSurfaceBlendMode(surface, &mode); - if (result == 0) { + if (result == 0) + { zval_dtor(z_mode); ZVAL_LONG(z_mode, (long)mode); } @@ -1062,7 +1100,7 @@ PHP_FUNCTION(SDL_GetSurfaceBlendMode) * Note that blits are automatically clipped to the edges of the source * and destination surfaces. extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface * surface, - const SDL_Rect * rect); + const SDL_Rect * rect); */ PHP_FUNCTION(SDL_SetClipRect) { @@ -1071,11 +1109,13 @@ PHP_FUNCTION(SDL_SetClipRect) SDL_Rect rect; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce())) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_surface, php_sdl_surface_ce, &z_rect, get_php_sdl_rect_ce())) + { return; } FETCH_SURFACE(surface, z_surface, 1); - if (zval_to_sdl_rect(z_rect, &rect)) { + if (zval_to_sdl_rect(z_rect, &rect)) + { RETURN_BOOL(SDL_SetClipRect(surface, &rect)); } php_error_docref(NULL, E_WARNING, "Invalid SDL_Rect object"); @@ -1090,7 +1130,7 @@ PHP_FUNCTION(SDL_SetClipRect) * \c rect must be a pointer to a valid rectangle which will be filled * with the correct values. extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, - SDL_Rect * rect); + SDL_Rect * rect); */ PHP_FUNCTION(SDL_GetClipRect) { @@ -1099,7 +1139,8 @@ PHP_FUNCTION(SDL_GetClipRect) SDL_Rect rect; SDL_Surface *surface; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_surface, php_sdl_surface_ce, &z_rect)) + { return; } FETCH_SURFACE(surface, z_surface, 1); @@ -1120,7 +1161,7 @@ PHP_FUNCTION(SDL_GetClipRect) * SDL will try to RLE accelerate colorkey and alpha blits in the resulting * surface. extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface - (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); + (SDL_Surface * src, const SDL_PixelFormat * fmt, Uint32 flags); */ PHP_FUNCTION(SDL_ConvertSurface) { @@ -1130,15 +1171,19 @@ PHP_FUNCTION(SDL_ConvertSurface) SDL_Surface *src, *dst; SDL_PixelFormat *format; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_src, php_sdl_surface_ce, &z_format, get_php_sdl_pixelformat_ce(), &flags)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO|l", &z_src, php_sdl_surface_ce, &z_format, get_php_sdl_pixelformat_ce(), &flags)) + { return; } FETCH_SURFACE(src, z_src, 1); format = zval_to_sdl_pixelformat(z_format); - if (format) { + if (format) + { dst = SDL_ConvertSurface(src, format, (Uint32)flags); sdl_surface_to_zval(dst, return_value); - } else { + } + else + { RETVAL_NULL(); } } @@ -1147,7 +1192,7 @@ PHP_FUNCTION(SDL_ConvertSurface) /* {{{ proto void SDL_ConvertSurfaceFormat(SDL_Surface src, int format [, int flags]) extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat - (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); + (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); */ PHP_FUNCTION(SDL_ConvertSurfaceFormat) { @@ -1156,7 +1201,8 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat) zend_long format, flags = 0; SDL_Surface *src, *dst; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_src, php_sdl_surface_ce, &format, &flags)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol|l", &z_src, php_sdl_surface_ce, &format, &flags)) + { return; } FETCH_SURFACE(src, z_src, 1); @@ -1171,10 +1217,10 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat) * * \return 0 on success, or -1 if there was an error extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, - Uint32 src_format, - const void * src, int src_pitch, - Uint32 dst_format, - void * dst, int dst_pitch); + Uint32 src_format, + const void * src, int src_pitch, + Uint32 dst_format, + void * dst, int dst_pitch); */ PHP_FUNCTION(SDL_ConvertPixels) { @@ -1182,24 +1228,30 @@ PHP_FUNCTION(SDL_ConvertPixels) zend_long w, h, sf, sp, df, dp; SDL_Pixels *src, *dst; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp)) + { return; } - if (!(src = zval_to_sdl_pixels(z_src))) { + if (!(src = zval_to_sdl_pixels(z_src))) + { php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object"); } - if (!(dst = zval_to_sdl_pixels(z_dst))) { + if (!(dst = zval_to_sdl_pixels(z_dst))) + { php_error_docref(NULL, E_WARNING, "Invalid destination SDL_Pixels object"); } - if (h < 0 || h > src->h || h > dst->h) { + if (h < 0 || h > src->h || h > dst->h) + { h = (src->h > dst->h ? dst->h : src->h); php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h); } - if (sp != src->pitch) { + if (sp != src->pitch) + { sp = src->pitch; php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp); } - if (dp != dst->pitch) { + if (dp != dst->pitch) + { dp = dst->pitch; php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp); } @@ -1212,53 +1264,54 @@ PHP_FUNCTION(SDL_ConvertPixels) #undef SDL_BlitScaled static const zend_function_entry php_sdl_surface_methods[] = { - PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Surface, __toString, arginfo_surface_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_Surface, __toString, arginfo_surface_none, ZEND_ACC_PUBLIC) /* non-static methods */ - PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none) - PHP_FALIAS(FillRect, SDL_FillRect, arginfo_SDL_Surface_FillRect) - PHP_FALIAS(FillRects, SDL_FillRects, arginfo_SDL_Surface_FillRects) - PHP_FALIAS(MustLock, SDL_MUSTLOCK, arginfo_surface_none) - PHP_FALIAS(Lock, SDL_LockSurface, arginfo_surface_none) - PHP_FALIAS(Unlock, SDL_UnlockSurface, arginfo_surface_none) - PHP_FALIAS(Blit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit) - PHP_FALIAS(UpperBlit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit) - PHP_FALIAS(LowerBlit, SDL_LowerBlit, arginfo_SDL_Surface_LowerBlit) - PHP_FALIAS(BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit) - PHP_FALIAS(UpperBlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit) - PHP_FALIAS(LowerBlitScaled, SDL_LowerBlitScaled, arginfo_SDL_Surface_LowerBlit) - PHP_FALIAS(SoftStretch, SDL_SoftStretch, arginfo_SDL_Surface_UpperBlit) - PHP_FALIAS(SaveBMP_RW, SDL_SaveBMP_RW, arginfo_SDL_Surface_SaveBMP_RW) - PHP_FALIAS(SaveBMP, SDL_SaveBMP, arginfo_SDL_Surface_SaveBMP) - PHP_FALIAS(SetRLE, SDL_SetSurfaceRLE, arginfo_SDL_Surface_SetRLE) - PHP_FALIAS(SetColorKey, SDL_SetColorKey, arginfo_SDL_Surface_SetColorKey) - PHP_FALIAS(GetColorKey, SDL_GetColorKey, arginfo_SDL_Surface_GetColorKey) - PHP_FALIAS(SetColorMod, SDL_SetSurfaceColorMod, arginfo_SDL_Surface_SetColorMod) - PHP_FALIAS(GetColorMod, SDL_GetSurfaceColorMod, arginfo_SDL_Surface_GetColorMod) - PHP_FALIAS(SetAlphaMod, SDL_SetSurfaceAlphaMod, arginfo_SDL_Surface_SetAlphaMod) - PHP_FALIAS(GetAlphaMod, SDL_GetSurfaceAlphaMod, arginfo_SDL_Surface_GetAlphaMod) - PHP_FALIAS(SetBlendMode, SDL_SetSurfaceBlendMode, arginfo_SDL_Surface_SetBlendMode) - PHP_FALIAS(GetBlendMode, SDL_GetSurfaceBlendMode, arginfo_SDL_Surface_GetBlendMode) - PHP_FALIAS(SetClipRect, SDL_SetClipRect, arginfo_SDL_Surface_SetClipRect) - PHP_FALIAS(GetClipRect, SDL_GetClipRect, arginfo_SDL_Surface_GetClipRect) - PHP_FALIAS(Convert, SDL_ConvertSurface, arginfo_SDL_Surface_Convert) - PHP_FALIAS(ConvertFormat, SDL_ConvertSurfaceFormat, arginfo_SDL_Surface_ConvertFormat) + PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none) + PHP_FALIAS(FillRect, SDL_FillRect, arginfo_SDL_Surface_FillRect) + PHP_FALIAS(FillRects, SDL_FillRects, arginfo_SDL_Surface_FillRects) + PHP_FALIAS(MustLock, SDL_MUSTLOCK, arginfo_surface_none) + PHP_FALIAS(Lock, SDL_LockSurface, arginfo_surface_none) + PHP_FALIAS(Unlock, SDL_UnlockSurface, arginfo_surface_none) + PHP_FALIAS(Blit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit) + PHP_FALIAS(UpperBlit, SDL_UpperBlit, arginfo_SDL_Surface_UpperBlit) + PHP_FALIAS(LowerBlit, SDL_LowerBlit, arginfo_SDL_Surface_LowerBlit) + PHP_FALIAS(BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit) + PHP_FALIAS(UpperBlitScaled, SDL_UpperBlitScaled, arginfo_SDL_Surface_UpperBlit) + PHP_FALIAS(LowerBlitScaled, SDL_LowerBlitScaled, arginfo_SDL_Surface_LowerBlit) + PHP_FALIAS(SoftStretch, SDL_SoftStretch, arginfo_SDL_Surface_UpperBlit) + PHP_FALIAS(SaveBMP_RW, SDL_SaveBMP_RW, arginfo_SDL_Surface_SaveBMP_RW) + PHP_FALIAS(SaveBMP, SDL_SaveBMP, arginfo_SDL_Surface_SaveBMP) + PHP_FALIAS(SetRLE, SDL_SetSurfaceRLE, arginfo_SDL_Surface_SetRLE) + PHP_FALIAS(SetColorKey, SDL_SetColorKey, arginfo_SDL_Surface_SetColorKey) + PHP_FALIAS(GetColorKey, SDL_GetColorKey, arginfo_SDL_Surface_GetColorKey) + PHP_FALIAS(SetColorMod, SDL_SetSurfaceColorMod, arginfo_SDL_Surface_SetColorMod) + PHP_FALIAS(GetColorMod, SDL_GetSurfaceColorMod, arginfo_SDL_Surface_GetColorMod) + PHP_FALIAS(SetAlphaMod, SDL_SetSurfaceAlphaMod, arginfo_SDL_Surface_SetAlphaMod) + PHP_FALIAS(GetAlphaMod, SDL_GetSurfaceAlphaMod, arginfo_SDL_Surface_GetAlphaMod) + PHP_FALIAS(SetBlendMode, SDL_SetSurfaceBlendMode, arginfo_SDL_Surface_SetBlendMode) + PHP_FALIAS(GetBlendMode, SDL_GetSurfaceBlendMode, arginfo_SDL_Surface_GetBlendMode) + PHP_FALIAS(SetClipRect, SDL_SetClipRect, arginfo_SDL_Surface_SetClipRect) + PHP_FALIAS(GetClipRect, SDL_GetClipRect, arginfo_SDL_Surface_GetClipRect) + PHP_FALIAS(Convert, SDL_ConvertSurface, arginfo_SDL_Surface_Convert) + PHP_FALIAS(ConvertFormat, SDL_ConvertSurfaceFormat, arginfo_SDL_Surface_ConvertFormat) /* static methods */ - ZEND_FENTRY(LoadRW, ZEND_FN(SDL_LoadBMP_RW), arginfo_SDL_LoadBMP_RW, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(LoadBMP, ZEND_FN(SDL_LoadBMP), arginfo_SDL_LoadBMP, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_FENTRY(LoadRW, ZEND_FN(SDL_LoadBMP_RW), arginfo_SDL_LoadBMP_RW, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(LoadBMP, ZEND_FN(SDL_LoadBMP), arginfo_SDL_LoadBMP, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_FE_END -}; + PHP_FE_END}; /* {{{ php_sdl_surface_free - */ + */ static void php_sdl_surface_free(zend_object *object) { - struct php_sdl_surface *intern = (struct php_sdl_surface*)((char*)object - object->handlers->offset); - if (intern->surface) { - if (!(intern->flags & SDL_DONTFREE)) { + struct php_sdl_surface *intern = (struct php_sdl_surface *)((char *)object - object->handlers->offset); + if (intern->surface) + { + if (!(intern->flags & SDL_DONTFREE)) + { SDL_FreeSurface(intern->surface); } } @@ -1269,24 +1322,25 @@ static void php_sdl_surface_free(zend_object *object) /* {{{ php_sdl_surface_new */ -static zend_object* php_sdl_surface_new(zend_class_entry *class_type) +static zend_object *php_sdl_surface_new(zend_class_entry *class_type) { struct php_sdl_surface *intern; - intern = (struct php_sdl_surface*)zend_object_alloc(sizeof(struct php_sdl_surface), class_type); + intern = (struct php_sdl_surface *)zend_object_alloc(sizeof(struct php_sdl_surface), class_type); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); intern->surface = NULL; - intern->zo.handlers = (zend_object_handlers *) &php_sdl_surface_handlers; + intern->zo.handlers = (zend_object_handlers *)&php_sdl_surface_handlers; return &intern->zo; } /* }}} */ -static inline struct php_sdl_surface* php_sdl_surface_from_obj(zend_object *obj) { - return (struct php_sdl_surface *) ((char *) (obj) - obj->handlers->offset); +static inline struct php_sdl_surface *php_sdl_surface_from_obj(zend_object *obj) +{ + return (struct php_sdl_surface *)((char *)(obj)-obj->handlers->offset); } /* {{{ sdl_surface_read_property*/ @@ -1298,32 +1352,50 @@ zval *sdl_surface_read_property(zend_object *object, zend_string *member, int ty intern = php_sdl_surface_from_obj(object); member_val = ZSTR_VAL(member); - if (!intern->surface) { + if (!intern->surface) + { retval = zend_std_read_property(object, member, type, cache_slot, retval); return retval; } - if (!strcmp(member_val, "flags")) { + if (!strcmp(member_val, "flags")) + { ZVAL_LONG(retval, intern->surface->flags); - } else if (!strcmp(member_val, "w")) { + } + else if (!strcmp(member_val, "w")) + { ZVAL_LONG(retval, intern->surface->w); - } else if (!strcmp(member_val, "h")) { + } + else if (!strcmp(member_val, "h")) + { ZVAL_LONG(retval, intern->surface->h); - } else if (!strcmp(member_val, "pitch")) { + } + else if (!strcmp(member_val, "pitch")) + { ZVAL_LONG(retval, intern->surface->pitch); - } else if (!strcmp(member_val, "locked")) { + } + else if (!strcmp(member_val, "locked")) + { ZVAL_LONG(retval, intern->surface->locked); - } else if (!strcmp(member_val, "format")) { + } + else if (!strcmp(member_val, "format")) + { sdl_pixelformat_to_zval(intern->surface->format, retval, SDL_DONTFREE); - } else if (!strcmp(member_val, "clip_rect")) { + } + else if (!strcmp(member_val, "clip_rect")) + { sdl_rect_to_zval(&intern->surface->clip_rect, retval); - } else if (!strcmp(member_val, "pixels")) { + } + else if (!strcmp(member_val, "pixels")) + { SDL_Pixels pix; - pix.pitch = intern->surface->pitch; - pix.h = intern->surface->h; + pix.pitch = intern->surface->pitch; + pix.h = intern->surface->h; pix.pixels = (Uint8 *)intern->surface->pixels; sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE); - } else { + } + else + { retval = zend_std_read_property(object, member, type, cache_slot, retval); return retval; } @@ -1332,7 +1404,7 @@ zval *sdl_surface_read_property(zend_object *object, zend_string *member, int ty } /* }}} */ -#define REGISTER_SURFACE_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_SURFACE_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("SDL_" const_name, value, CONST_CS | CONST_PERSISTENT); \ zend_declare_class_constant_long(php_sdl_surface_ce, ZEND_STRL(const_name), value) @@ -1360,10 +1432,10 @@ PHP_MINIT_FUNCTION(sdl_surface) zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("clip_rect"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_surface_ce, ZEND_STRL("pixels"), ZEND_ACC_PUBLIC); - REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE", SDL_SWSURFACE); - REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC", SDL_PREALLOC); - REGISTER_SURFACE_CLASS_CONST_LONG("RLEACCEL", SDL_RLEACCEL); - REGISTER_SURFACE_CLASS_CONST_LONG("DONTFREE", SDL_DONTFREE); + REGISTER_SURFACE_CLASS_CONST_LONG("SWSURFACE", SDL_SWSURFACE); + REGISTER_SURFACE_CLASS_CONST_LONG("PREALLOC", SDL_PREALLOC); + REGISTER_SURFACE_CLASS_CONST_LONG("RLEACCEL", SDL_RLEACCEL); + REGISTER_SURFACE_CLASS_CONST_LONG("DONTFREE", SDL_DONTFREE); return SUCCESS; } diff --git a/src/window.c b/src/window.c index 3061f41..83d28b1 100644 --- a/src/window.c +++ b/src/window.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -28,15 +28,16 @@ static zend_class_entry *php_sdl_window_ce; static zend_object_handlers php_sdl_window_handlers; -struct php_sdl_window { - SDL_Window *window; +struct php_sdl_window +{ + SDL_Window *window; int flags; - zend_object zo; + zend_object zo; }; typedef struct php_sdl_window php_sdl_window_t; -static inline php_sdl_window_t* php_sdl_window_fetch_object(zend_object* obj); +static inline php_sdl_window_t *php_sdl_window_fetch_object(zend_object *obj); zend_class_entry *get_php_sdl_window_ce(void) { @@ -46,11 +47,12 @@ zend_class_entry *get_php_sdl_window_ce(void) /* {{{ zval_to_sdl_window */ SDL_Window *zval_to_sdl_window(zval *z_val) { - if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_window_ce) { - zend_object* zo = Z_OBJ_P(z_val); + if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_window_ce) + { + zend_object *zo = Z_OBJ_P(z_val); struct php_sdl_window *intern; - intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset); + intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset); return intern->window; } return NULL; @@ -60,7 +62,7 @@ SDL_Window *zval_to_sdl_window(zval *z_val) static inline void sdl_window_add_long_property(HashTable *props, const char *name, zend_long value) { zval zvalue; - zend_string *zname = zend_string_init(name, strlen(name), 0); + zend_string *zname = zend_string_init(name, strlen(name), 0); ZVAL_LONG(&zvalue, value); zend_hash_update(props, zname, &zvalue); zend_string_release(zname); @@ -70,13 +72,14 @@ static inline void sdl_window_add_long_property(HashTable *props, const char *na static HashTable *sdl_window_get_properties(zend_object *object) { HashTable *props; - zend_string* z_string; + zend_string *z_string; zval zv; - struct php_sdl_window* intern = php_sdl_window_fetch_object(object); + struct php_sdl_window *intern = php_sdl_window_fetch_object(object); props = zend_std_get_properties(object); - if (intern->window) { + if (intern->window) + { int w, h, x, y; SDL_GetWindowSize(intern->window, &w, &h); @@ -88,7 +91,7 @@ static HashTable *sdl_window_get_properties(zend_object *object) sdl_window_add_long_property(props, "w", w); sdl_window_add_long_property(props, "h", h); ZVAL_STRING(&zv, SDL_GetWindowTitle(intern->window)); - z_string = zend_string_init("title", 6, 0); + z_string = zend_string_init("title", 6, 0); zend_hash_update(props, z_string, &zv); zend_string_release(z_string); } @@ -96,22 +99,22 @@ static HashTable *sdl_window_get_properties(zend_object *object) } /* }}} */ -static inline php_sdl_window_t* php_sdl_window_fetch_object(zend_object* obj) +static inline php_sdl_window_t *php_sdl_window_fetch_object(zend_object *obj) { - return (php_sdl_window_t*) ((char*) obj - XtOffsetOf(php_sdl_window_t, zo)); -} - -#define FETCH_WINDOW(__ptr, __id, __check) \ -{ \ - zend_object* zox = Z_OBJ_P(__id);\ - intern = (struct php_sdl_window*)((char*)zox - zox->handlers->offset);\ - __ptr = intern->window; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ + return (php_sdl_window_t *)((char *)obj - XtOffsetOf(php_sdl_window_t, zo)); } +#define FETCH_WINDOW(__ptr, __id, __check) \ + { \ + zend_object *zox = Z_OBJ_P(__id); \ + intern = (struct php_sdl_window *)((char *)zox - zox->handlers->offset); \ + __ptr = intern->window; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } /* {{{ proto void SDL_GetWindowDisplayIndex(SDL_Window window) @@ -127,7 +130,8 @@ PHP_FUNCTION(SDL_GetWindowDisplayIndex) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -151,8 +155,8 @@ PHP_FUNCTION(SDL_GetWindowDisplayIndex) * \sa SDL_GetWindowDisplayMode() * \sa SDL_SetWindowFullscreen() extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, - const SDL_DisplayMode - * mode); + const SDL_DisplayMode + * mode); */ PHP_FUNCTION(SDL_SetWindowDisplayMode) { @@ -161,11 +165,13 @@ PHP_FUNCTION(SDL_SetWindowDisplayMode) SDL_Window *window; SDL_DisplayMode mode; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_mode, get_php_sdl_displaymode_ce()) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_mode, get_php_sdl_displaymode_ce()) == FAILURE) + { return; } FETCH_WINDOW(window, z_window, 1); - if (zval_to_sdl_displaymode(z_mode, &mode)) { + if (zval_to_sdl_displaymode(z_mode, &mode)) + { RETVAL_LONG(SDL_SetWindowDisplayMode(window, &mode)); } } @@ -179,7 +185,7 @@ PHP_FUNCTION(SDL_SetWindowDisplayMode) * \sa SDL_SetWindowDisplayMode() * \sa SDL_SetWindowFullscreen() extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, - SDL_DisplayMode * mode); + SDL_DisplayMode * mode); */ PHP_FUNCTION(SDL_GetWindowDisplayMode) { @@ -189,12 +195,14 @@ PHP_FUNCTION(SDL_GetWindowDisplayMode) SDL_DisplayMode mode; int res; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) + { return; } FETCH_WINDOW(window, z_window, 1); res = SDL_GetWindowDisplayMode(window, &mode); - if (0==res) { + if (0 == res) + { zval_dtor(z_mode); sdl_displaymode_to_zval(&mode, z_mode); } @@ -202,7 +210,6 @@ PHP_FUNCTION(SDL_GetWindowDisplayMode) } /* }}} */ - /* {{{ proto int SDL_GetWindowPixelFormat(SDL_Window window) * \brief Get the pixel format associated with the window. @@ -214,7 +221,8 @@ PHP_FUNCTION(SDL_GetWindowPixelFormat) zval *z_window; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -222,7 +230,6 @@ PHP_FUNCTION(SDL_GetWindowPixelFormat) } /* }}} */ - /* {{{ proto int SDL_GetWindowID(SDL_Window window) * \brief Get the numeric ID of a window, for logging purposes. @@ -234,7 +241,8 @@ PHP_FUNCTION(SDL_GetWindowID) zval *z_window; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -253,7 +261,8 @@ PHP_FUNCTION(SDL_GetWindowFlags) zval *z_window; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -268,7 +277,7 @@ PHP_FUNCTION(SDL_GetWindowFlags) * \param window The window for which the icon should be set. * \param icon The icon for the window. extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, - SDL_Surface * icon); + SDL_Surface * icon); */ PHP_FUNCTION(SDL_SetWindowIcon) { @@ -277,15 +286,19 @@ PHP_FUNCTION(SDL_SetWindowIcon) SDL_Window *window; SDL_Surface *icon; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_icon, get_php_sdl_surface_ce())) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, php_sdl_window_ce, &z_icon, get_php_sdl_surface_ce())) + { return; } FETCH_WINDOW(window, z_window, 1); icon = zval_to_sdl_surface(z_icon); - if (icon) { + if (icon) + { SDL_SetWindowIcon(window, icon); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Surface object"); } } @@ -297,15 +310,15 @@ PHP_FUNCTION(SDL_SetWindowIcon) * * \param window The window to reposition. * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or - ::SDL_WINDOWPOS_UNDEFINED. + ::SDL_WINDOWPOS_UNDEFINED. * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or - ::SDL_WINDOWPOS_UNDEFINED. + ::SDL_WINDOWPOS_UNDEFINED. * * \note The window coordinate origin is the upper left of the display. * * \sa SDL_GetWindowPosition() extern DECLSPEC void SDLCALL SDL_SetWindowPosition(SDL_Window * window, - int x, int y); + int x, int y); */ PHP_FUNCTION(SDL_SetWindowPosition) { @@ -314,7 +327,8 @@ PHP_FUNCTION(SDL_SetWindowPosition) zend_long x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -330,14 +344,14 @@ PHP_FUNCTION(SDL_WINDOWPOS_CENTERED_DISPLAY) { zend_long display; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) + { return; } RETVAL_LONG(SDL_WINDOWPOS_CENTERED_DISPLAY(display)); } /* }}} */ - /* {{{ proto int SDL_WINDOWPOS_UNDEFINED_DISPLAY(int) define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) @@ -346,7 +360,8 @@ PHP_FUNCTION(SDL_WINDOWPOS_UNDEFINED_DISPLAY) { zend_long display; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "l", &display)) + { return; } RETVAL_LONG(SDL_WINDOWPOS_UNDEFINED_DISPLAY(display)); @@ -363,32 +378,34 @@ PHP_FUNCTION(SDL_WINDOWPOS_UNDEFINED_DISPLAY) * * \sa SDL_SetWindowPosition() extern DECLSPEC void SDLCALL SDL_GetWindowPosition(SDL_Window * window, - int *x, int *y); + int *x, int *y); */ PHP_FUNCTION(SDL_GetWindowPosition) { struct php_sdl_window *intern; - zval *z_window, *z_x=NULL, *z_y=NULL; + zval *z_window, *z_x = NULL, *z_y = NULL; int x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) + { return; } FETCH_WINDOW(window, z_window, 1); SDL_GetWindowPosition(window, &x, &y); - if (z_x) { + if (z_x) + { zval_dtor(z_x); ZVAL_LONG(z_x, x); } - if (z_y) { + if (z_y) + { zval_dtor(z_y); ZVAL_LONG(z_y, y); } } /* }}} */ - /* {{{ proto void SDL_SetWindowSize(SDL Window window, int x, int y) * \brief Set the size of a window's client area. @@ -402,7 +419,7 @@ PHP_FUNCTION(SDL_GetWindowPosition) * * \sa SDL_GetWindowSize() extern DECLSPEC void SDLCALL SDL_SetWindowSize(SDL_Window * window, int w, - int h); + int h); */ PHP_FUNCTION(SDL_SetWindowSize) { @@ -411,7 +428,8 @@ PHP_FUNCTION(SDL_SetWindowSize) zend_long x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -429,32 +447,34 @@ PHP_FUNCTION(SDL_SetWindowSize) * * \sa SDL_SetWindowSize() extern DECLSPEC void SDLCALL SDL_GetWindowSize(SDL_Window * window, int *w, - int *h); + int *h); */ PHP_FUNCTION(SDL_GetWindowSize) { struct php_sdl_window *intern; - zval *z_window, *z_x=NULL, *z_y=NULL; + zval *z_window, *z_x = NULL, *z_y = NULL; int x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/z/", &z_window, php_sdl_window_ce, &z_x, &z_y)) + { return; } FETCH_WINDOW(window, z_window, 1); SDL_GetWindowSize(window, &x, &y); - if (z_x) { + if (z_x) + { zval_dtor(z_x); ZVAL_LONG(z_x, x); } - if (z_y) { + if (z_y) + { zval_dtor(z_y); ZVAL_LONG(z_y, y); } } /* }}} */ - /* {{{ proto void SDL_SetWindowMinimumSize(SDL Window window, int x, int y) * \brief Set the minimum size of a window's client area. @@ -469,7 +489,7 @@ PHP_FUNCTION(SDL_GetWindowSize) * \sa SDL_GetWindowMinimumSize() * \sa SDL_SetWindowMaximumSize() extern DECLSPEC void SDLCALL SDL_SetWindowMinimumSize(SDL_Window * window, - int min_w, int min_h); + int min_w, int min_h); */ PHP_FUNCTION(SDL_SetWindowMinimumSize) { @@ -478,7 +498,8 @@ PHP_FUNCTION(SDL_SetWindowMinimumSize) zend_long x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -497,32 +518,34 @@ PHP_FUNCTION(SDL_SetWindowMinimumSize) * \sa SDL_GetWindowMaximumSize() * \sa SDL_SetWindowMinimumSize() extern DECLSPEC void SDLCALL SDL_GetWindowMinimumSize(SDL_Window * window, - int *w, int *h); + int *w, int *h); */ PHP_FUNCTION(SDL_GetWindowMinimumSize) { struct php_sdl_window *intern; - zval *z_window, *z_x=NULL, *z_y=NULL; + zval *z_window, *z_x = NULL, *z_y = NULL; int x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) + { return; } FETCH_WINDOW(window, z_window, 1); SDL_GetWindowMinimumSize(window, &x, &y); - if (z_x) { + if (z_x) + { zval_dtor(z_x); ZVAL_LONG(z_x, x); } - if (z_y) { + if (z_y) + { zval_dtor(z_y); ZVAL_LONG(z_y, y); } } /* }}} */ - /* {{{ proto void SDL_SetWindowMaximumSize(SDL Window window, int x, int y) * \brief Set the maximum size of a window's client area. @@ -537,7 +560,7 @@ PHP_FUNCTION(SDL_GetWindowMinimumSize) * \sa SDL_GetWindowMaximumSize() * \sa SDL_SetWindowMinimumSize() extern DECLSPEC void SDLCALL SDL_SetWindowMaximumSize(SDL_Window * window, - int max_w, int max_h); + int max_w, int max_h); */ PHP_FUNCTION(SDL_SetWindowMaximumSize) { @@ -546,7 +569,8 @@ PHP_FUNCTION(SDL_SetWindowMaximumSize) zend_long x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_window, php_sdl_window_ce, &x, &y)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -565,25 +589,28 @@ PHP_FUNCTION(SDL_SetWindowMaximumSize) * \sa SDL_GetWindowMinimumSize() * \sa SDL_SetWindowMaximumSize() extern DECLSPEC void SDLCALL SDL_GetWindowMaximumSize(SDL_Window * window, - int *w, int *h); + int *w, int *h); */ PHP_FUNCTION(SDL_GetWindowMaximumSize) { struct php_sdl_window *intern; - zval *z_window, *z_x=NULL, *z_y=NULL; + zval *z_window, *z_x = NULL, *z_y = NULL; int x, y; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O|zz", &z_window, php_sdl_window_ce, &z_x, &z_y)) + { return; } FETCH_WINDOW(window, z_window, 1); SDL_GetWindowMaximumSize(window, &x, &y); - if (z_x) { + if (z_x) + { zval_dtor(z_x); ZVAL_LONG(z_x, x); } - if (z_y) { + if (z_y) + { zval_dtor(z_y); ZVAL_LONG(z_y, y); } @@ -605,16 +632,17 @@ PHP_FUNCTION(SDL_GetWindowMaximumSize) * * \sa SDL_GetWindowFlags() extern DECLSPEC void SDLCALL SDL_SetWindowBordered(SDL_Window * window, - SDL_bool bordered); + SDL_bool bordered); */ PHP_FUNCTION(SDL_SetWindowBordered) { struct php_sdl_window *intern; zval *z_window; - zend_bool bordered; + bool bordered; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &bordered)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ob", &z_window, php_sdl_window_ce, &bordered)) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -622,7 +650,6 @@ PHP_FUNCTION(SDL_SetWindowBordered) } /* }}} */ - /* {{{ proto void SDL_ShowWindow(SDL_Window window) * \brief Show a window. @@ -636,7 +663,8 @@ PHP_FUNCTION(SDL_ShowWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -645,7 +673,6 @@ PHP_FUNCTION(SDL_ShowWindow) } /* }}} */ - /* {{{ proto void SDL_HideWindow(SDL_Window window) * \brief Hide a window. @@ -659,7 +686,8 @@ PHP_FUNCTION(SDL_HideWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -668,7 +696,6 @@ PHP_FUNCTION(SDL_HideWindow) } /* }}} */ - /* {{{ proto void SDL_RaiseWindow(SDL_Window window) * \brief Raise a window above other windows and set the input focus. @@ -680,7 +707,8 @@ PHP_FUNCTION(SDL_RaiseWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -689,7 +717,6 @@ PHP_FUNCTION(SDL_RaiseWindow) } /* }}} */ - /* {{{ proto void SDL_MaximizeWindow(SDL_Window window) * \brief Make a window as large as possible. @@ -703,7 +730,8 @@ PHP_FUNCTION(SDL_MaximizeWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -712,7 +740,6 @@ PHP_FUNCTION(SDL_MaximizeWindow) } /* }}} */ - /* {{{ proto void SDL_MinimizeWindow(SDL_Window window) * \brief Minimize a window to an iconic representation. @@ -726,7 +753,8 @@ PHP_FUNCTION(SDL_MinimizeWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -735,7 +763,6 @@ PHP_FUNCTION(SDL_MinimizeWindow) } /* }}} */ - /* {{{ proto void SDL_RestoreWindow(SDL_Window window) * \brief Restore the size and position of a minimized or maximized window. @@ -750,7 +777,8 @@ PHP_FUNCTION(SDL_RestoreWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -768,7 +796,7 @@ PHP_FUNCTION(SDL_RestoreWindow) * \sa SDL_SetWindowDisplayMode() * \sa SDL_GetWindowDisplayMode() extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, - Uint32 flags); + Uint32 flags); */ PHP_FUNCTION(SDL_SetWindowFullscreen) { @@ -777,7 +805,8 @@ PHP_FUNCTION(SDL_SetWindowFullscreen) SDL_Window *window; zend_long flags; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, php_sdl_window_ce, &flags) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ol", &object, php_sdl_window_ce, &flags) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -786,7 +815,6 @@ PHP_FUNCTION(SDL_SetWindowFullscreen) } /* }}} */ - /* {{{ proto void SDL_GetWindowSurface(SDL_Window window) * \brief Get the SDL surface associated with the window. @@ -809,7 +837,8 @@ PHP_FUNCTION(SDL_GetWindowSurface) SDL_Window *window = NULL; SDL_Surface *surface = NULL; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -828,8 +857,8 @@ PHP_FUNCTION(SDL_GetWindowSurface) * \sa SDL_GetWindowSurface() * \sa SDL_UpdateWindowSurfaceRect() extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, - const SDL_Rect * rects, - int numrects); + const SDL_Rect * rects, + int numrects); */ PHP_FUNCTION(SDL_UpdateWindowSurfaceRects) { @@ -840,35 +869,46 @@ PHP_FUNCTION(SDL_UpdateWindowSurfaceRects) SDL_Window *window; SDL_Rect *rects; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|l", &z_window, php_sdl_window_ce, &z_array, &num)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oa|l", &z_window, php_sdl_window_ce, &z_array, &num)) + { return; } FETCH_WINDOW(window, z_window, 1); - nb = 0; + nb = 0; max = (int)(num ? num : zend_hash_num_elements(Z_ARRVAL_P(z_array))); - if (max) { + if (max) + { zval *ppzval; rects = emalloc(max * sizeof(SDL_Rect)); - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_array), ppzval) { - if (zval_to_sdl_rect(ppzval, rects+nb)) { - nb++; - } else { - php_error_docref(NULL, E_NOTICE, "Ignore rect, not a SDL_Rect object"); - } + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_array), ppzval) + { + if (zval_to_sdl_rect(ppzval, rects + nb)) + { + nb++; + } + else + { + php_error_docref(NULL, E_NOTICE, "Ignore rect, not a SDL_Rect object"); + } } ZEND_HASH_FOREACH_END(); } - if (!nb) { + if (!nb) + { php_error_docref(NULL, E_WARNING, "No SDL_Rect provided"); - } else { - if (num && nbwindow = window; @@ -1101,8 +1149,8 @@ PHP_FUNCTION(SDL_CreateShapedWindow) * * \sa SDL_DestroyWindow() extern DECLSPEC SDL_Window * SDLCALL SDL_CreateWindow(const char *title, - int x, int y, int w, - int h, Uint32 flags); + int x, int y, int w, + int h, Uint32 flags); */ PHP_FUNCTION(SDL_CreateWindow) { @@ -1122,7 +1170,8 @@ static PHP_METHOD(SDL_Window, __construct) intern = php_sdl_window_fetch_object(Z_OBJ_P(getThis())); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "slllll", &title, &title_len, &x, &y, &w, &h, &flags)) + { zend_restore_error_handling(&error_handling); return; } @@ -1130,41 +1179,46 @@ static PHP_METHOD(SDL_Window, __construct) intern->window = SDL_CreateWindow(title, x, y, w, h, flags); intern->flags = 0; - if (intern->window) { + if (intern->window) + { SDL_SetWindowData(intern->window, PHP_SDL_MAGICDATA, (void *)(unsigned long)Z_OBJ_HANDLE_P(getThis())); - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), "Can't create window", 0); } } /* }}} */ - /* {{{ proto SDL_Window::__toString() */ static PHP_METHOD(SDL_Window, __toString) { struct php_sdl_window *intern; char *buf = NULL; - int buf_len; + int buf_len; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } intern = php_sdl_window_fetch_object(Z_OBJ_P(getThis())); - if (0 && intern->window) { + if (0 && intern->window) + { int x, y, w, h; SDL_GetWindowPosition(intern->window, &x, &y); SDL_GetWindowSize(intern->window, &w, &h); buf_len = spprintf(&buf, 0, "SDL_Window(\"%s\",%d,%d,%d,%d,%u)", SDL_GetWindowTitle(intern->window), x, y, w, h, SDL_GetWindowFlags(intern->window)); RETURN_STRINGL(buf, buf_len); - } else { + } + else + { RETURN_STRING("SDL_Window()"); } } /* }}} */ - /* {{{ proto SDL_UpdateWindowSurface(SDL_Window window) * \brief Copy the window surface to the screen. @@ -1181,7 +1235,8 @@ PHP_FUNCTION(SDL_UpdateWindowSurface) zval *z_window; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, z_window, 1); @@ -1189,7 +1244,6 @@ PHP_FUNCTION(SDL_UpdateWindowSurface) } /* }}} */ - /* {{{ proto SDL_DestroyWindow(SDL_Window window) * \brief Destroy a window. @@ -1201,7 +1255,8 @@ PHP_FUNCTION(SDL_DestroyWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -1211,7 +1266,6 @@ PHP_FUNCTION(SDL_DestroyWindow) } /* }}} */ - /* {{{ proto string SDL_GetWindowTitle(SDL_Window window) * \brief Get the title of a window, in UTF-8 format. @@ -1225,7 +1279,8 @@ PHP_FUNCTION(SDL_GetWindowTitle) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -1240,7 +1295,7 @@ PHP_FUNCTION(SDL_GetWindowTitle) * * \sa SDL_GetWindowTitle() extern DECLSPEC void SDLCALL SDL_SetWindowTitle(SDL_Window * window, - const char *title); + const char *title); */ PHP_FUNCTION(SDL_SetWindowTitle) { @@ -1250,7 +1305,8 @@ PHP_FUNCTION(SDL_SetWindowTitle) char *title; size_t title_len; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, php_sdl_window_ce, &title, &title_len) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &object, php_sdl_window_ce, &title, &title_len) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -1259,7 +1315,6 @@ PHP_FUNCTION(SDL_SetWindowTitle) } /* }}} */ - /* {{{ proto bool SDL_IsShapedWindow(SDL_Window window) * \brief Return whether the given window is a shaped window. @@ -1276,7 +1331,8 @@ PHP_FUNCTION(SDL_IsShapedWindow) zval *object; SDL_Window *window; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &object, php_sdl_window_ce) == FAILURE) + { return; } FETCH_WINDOW(window, object, 1); @@ -1308,20 +1364,24 @@ PHP_FUNCTION(SDL_SetWindowShape) SDL_WindowShapeMode *mode; if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OOO", &z_window, php_sdl_window_ce, - &z_surface, get_php_sdl_surface_ce(), &z_mode, get_php_sdl_windowshapemode_ce()) == FAILURE) { + &z_surface, get_php_sdl_surface_ce(), &z_mode, get_php_sdl_windowshapemode_ce()) == FAILURE) + { return; } FETCH_WINDOW(window, z_window, 1); surface = zval_to_sdl_surface(z_surface); - mode = zval_to_sdl_windowshapemode(z_mode); - if (!surface) { + mode = zval_to_sdl_windowshapemode(z_mode); + if (!surface) + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Surface object"); - - } else if (!mode) { + } + else if (!mode) + { php_error_docref(NULL, E_WARNING, "Invalid SDL_WindowShapeMode object"); - - } else { - RETVAL_LONG(SDL_SetWindowShape(window, surface, mode)); + } + else + { + RETVAL_LONG(SDL_SetWindowShape(window, surface, mode)); } } /* }}} */ @@ -1349,12 +1409,14 @@ PHP_FUNCTION(SDL_GetShapedWindowMode) SDL_WindowShapeMode mode; int ret; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, php_sdl_window_ce, &z_mode) == FAILURE) + { return; } FETCH_WINDOW(window, z_window, 1); ret = SDL_GetShapedWindowMode(window, &mode); - if (ret==0) { + if (ret == 0) + { zval_dtor(z_mode); sdl_windowshapemode_to_zval(&mode, z_mode); } @@ -1363,69 +1425,70 @@ PHP_FUNCTION(SDL_GetShapedWindowMode) /* }}} */ static const zend_function_entry php_sdl_window_methods[] = { - PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Window, __toString, arginfo_window_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_Window, __toString, arginfo_window_none, ZEND_ACC_PUBLIC) /* non-static functions */ - PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none) - PHP_FALIAS(Destroy, SDL_DestroyWindow, arginfo_window_none) - PHP_FALIAS(GetTitle, SDL_GetWindowTitle, arginfo_window_none) - PHP_FALIAS(SetTitle, SDL_SetWindowTitle, arginfo_SDL_Window_SetTitle) - PHP_FALIAS(GetDisplayIndex, SDL_GetWindowDisplayIndex, arginfo_window_none) - PHP_FALIAS(Show, SDL_ShowWindow, arginfo_window_none) - PHP_FALIAS(Hide, SDL_HideWindow, arginfo_window_none) - PHP_FALIAS(Raise, SDL_RaiseWindow, arginfo_window_none) - PHP_FALIAS(Maximize, SDL_MaximizeWindow, arginfo_window_none) - PHP_FALIAS(Minimize, SDL_MinimizeWindow, arginfo_window_none) - PHP_FALIAS(Restore, SDL_RestoreWindow, arginfo_window_none) - PHP_FALIAS(GetSurface, SDL_GetWindowSurface, arginfo_window_none) - PHP_FALIAS(SetDisplayMode, SDL_SetWindowDisplayMode, arginfo_SDL_Window_SetDisplayMode) - PHP_FALIAS(GetDisplayMode, SDL_GetWindowDisplayMode, arginfo_SDL_Window_GetDisplayMode) - PHP_FALIAS(GetPixelFormat, SDL_GetWindowPixelFormat, arginfo_window_none) - PHP_FALIAS(GetID, SDL_GetWindowID, arginfo_window_none) - PHP_FALIAS(GetFlags, SDL_GetWindowFlags, arginfo_window_none) - PHP_FALIAS(SetIcon, SDL_SetWindowIcon, arginfo_SDL_Window_SetIcon) - PHP_FALIAS(SetPosition, SDL_SetWindowPosition, arginfo_SDL_Window_SetPosition) - PHP_FALIAS(GetPosition, SDL_GetWindowPosition, arginfo_SDL_Window_GetPosition) - PHP_FALIAS(SetSize, SDL_SetWindowSize, arginfo_SDL_Window_SetSize) - PHP_FALIAS(GetSize, SDL_GetWindowSize, arginfo_SDL_Window_GetSize) - PHP_FALIAS(SetMinimumSize, SDL_SetWindowMinimumSize, arginfo_SDL_Window_SetPosition) - PHP_FALIAS(GetMinimumSize, SDL_GetWindowMinimumSize, arginfo_SDL_Window_GetPosition) - PHP_FALIAS(SetMaximumSize, SDL_SetWindowMaximumSize, arginfo_SDL_Window_SetPosition) - PHP_FALIAS(GetMaximumSize, SDL_GetWindowMaximumSize, arginfo_SDL_Window_GetPosition) - PHP_FALIAS(SetBordered, SDL_SetWindowBordered, arginfo_SDL_Window_SetBordered) - PHP_FALIAS(SetFullscreen, SDL_SetWindowFullscreen, arginfo_SDL_Window_SetFullscreen) - PHP_FALIAS(UpdateSurfaceRects, SDL_UpdateWindowSurfaceRects, arginfo_SDL_Window_UpdateSurfaceRects) - PHP_FALIAS(SetGrab, SDL_SetWindowGrab, arginfo_SDL_Window_SetGrab) - PHP_FALIAS(GetGrab, SDL_GetWindowGrab, arginfo_window_none) - PHP_FALIAS(SetBrightness, SDL_SetWindowBrightness, arginfo_SDL_Window_SetBrightness) - PHP_FALIAS(GetBrightness, SDL_GetWindowBrightness, arginfo_window_none) - PHP_FALIAS(GetGammaRamp, SDL_GetWindowGammaRamp, arginfo_SDL_Window_GetGammaRamp) - PHP_FALIAS(GL_CreateContext, SDL_GL_CreateContext, arginfo_window_none) - PHP_FALIAS(GL_MakeCurrent, SDL_GL_MakeCurrent, arginfo_SDL_GLContext) -#if SDL_VERSION_ATLEAST(2,0,1) - PHP_FALIAS(GL_GetDrawableSize, SDL_GL_GetDrawableSize, arginfo_SDL_Window_GetPosition) + PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none) + PHP_FALIAS(Destroy, SDL_DestroyWindow, arginfo_window_none) + PHP_FALIAS(GetTitle, SDL_GetWindowTitle, arginfo_window_none) + PHP_FALIAS(SetTitle, SDL_SetWindowTitle, arginfo_SDL_Window_SetTitle) + PHP_FALIAS(GetDisplayIndex, SDL_GetWindowDisplayIndex, arginfo_window_none) + PHP_FALIAS(Show, SDL_ShowWindow, arginfo_window_none) + PHP_FALIAS(Hide, SDL_HideWindow, arginfo_window_none) + PHP_FALIAS(Raise, SDL_RaiseWindow, arginfo_window_none) + PHP_FALIAS(Maximize, SDL_MaximizeWindow, arginfo_window_none) + PHP_FALIAS(Minimize, SDL_MinimizeWindow, arginfo_window_none) + PHP_FALIAS(Restore, SDL_RestoreWindow, arginfo_window_none) + PHP_FALIAS(GetSurface, SDL_GetWindowSurface, arginfo_window_none) + PHP_FALIAS(SetDisplayMode, SDL_SetWindowDisplayMode, arginfo_SDL_Window_SetDisplayMode) + PHP_FALIAS(GetDisplayMode, SDL_GetWindowDisplayMode, arginfo_SDL_Window_GetDisplayMode) + PHP_FALIAS(GetPixelFormat, SDL_GetWindowPixelFormat, arginfo_window_none) + PHP_FALIAS(GetID, SDL_GetWindowID, arginfo_window_none) + PHP_FALIAS(GetFlags, SDL_GetWindowFlags, arginfo_window_none) + PHP_FALIAS(SetIcon, SDL_SetWindowIcon, arginfo_SDL_Window_SetIcon) + PHP_FALIAS(SetPosition, SDL_SetWindowPosition, arginfo_SDL_Window_SetPosition) + PHP_FALIAS(GetPosition, SDL_GetWindowPosition, arginfo_SDL_Window_GetPosition) + PHP_FALIAS(SetSize, SDL_SetWindowSize, arginfo_SDL_Window_SetSize) + PHP_FALIAS(GetSize, SDL_GetWindowSize, arginfo_SDL_Window_GetSize) + PHP_FALIAS(SetMinimumSize, SDL_SetWindowMinimumSize, arginfo_SDL_Window_SetPosition) + PHP_FALIAS(GetMinimumSize, SDL_GetWindowMinimumSize, arginfo_SDL_Window_GetPosition) + PHP_FALIAS(SetMaximumSize, SDL_SetWindowMaximumSize, arginfo_SDL_Window_SetPosition) + PHP_FALIAS(GetMaximumSize, SDL_GetWindowMaximumSize, arginfo_SDL_Window_GetPosition) + PHP_FALIAS(SetBordered, SDL_SetWindowBordered, arginfo_SDL_Window_SetBordered) + PHP_FALIAS(SetFullscreen, SDL_SetWindowFullscreen, arginfo_SDL_Window_SetFullscreen) + PHP_FALIAS(UpdateSurfaceRects, SDL_UpdateWindowSurfaceRects, arginfo_SDL_Window_UpdateSurfaceRects) + PHP_FALIAS(SetGrab, SDL_SetWindowGrab, arginfo_SDL_Window_SetGrab) + PHP_FALIAS(GetGrab, SDL_GetWindowGrab, arginfo_window_none) + PHP_FALIAS(SetBrightness, SDL_SetWindowBrightness, arginfo_SDL_Window_SetBrightness) + PHP_FALIAS(GetBrightness, SDL_GetWindowBrightness, arginfo_window_none) + PHP_FALIAS(GetGammaRamp, SDL_GetWindowGammaRamp, arginfo_SDL_Window_GetGammaRamp) + PHP_FALIAS(GL_CreateContext, SDL_GL_CreateContext, arginfo_window_none) + PHP_FALIAS(GL_MakeCurrent, SDL_GL_MakeCurrent, arginfo_SDL_GLContext) +#if SDL_VERSION_ATLEAST(2, 0, 1) + PHP_FALIAS(GL_GetDrawableSize, SDL_GL_GetDrawableSize, arginfo_SDL_Window_GetPosition) #endif - PHP_FALIAS(GL_Swap, SDL_GL_SwapWindow, arginfo_window_none) - PHP_FALIAS(WarpMouse, SDL_WarpMouseInWindow, arginfo_SDL_Window_SetPosition) - PHP_FALIAS(IsShaped, SDL_IsShapedWindow, arginfo_window_none) - PHP_FALIAS(SetShape, SDL_SetWindowShape, arginfo_SDL_Window_SetShape) - PHP_FALIAS(GetShapedMode, SDL_GetShapedWindowMode, arginfo_SDL_Window_GetShapedMode) + PHP_FALIAS(GL_Swap, SDL_GL_SwapWindow, arginfo_window_none) + PHP_FALIAS(WarpMouse, SDL_WarpMouseInWindow, arginfo_SDL_Window_SetPosition) + PHP_FALIAS(IsShaped, SDL_IsShapedWindow, arginfo_window_none) + PHP_FALIAS(SetShape, SDL_SetWindowShape, arginfo_SDL_Window_SetShape) + PHP_FALIAS(GetShapedMode, SDL_GetShapedWindowMode, arginfo_SDL_Window_GetShapedMode) /* static methods */ - ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentWindow), arginfo_window_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) - ZEND_FENTRY(GetMouseFocus, ZEND_FN(SDL_GetMouseFocus), arginfo_window_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentWindow), arginfo_window_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) + ZEND_FENTRY(GetMouseFocus, ZEND_FN(SDL_GetMouseFocus), arginfo_window_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - PHP_FE_END -}; + PHP_FE_END}; /* {{{ php_sdl_window_free - */ -static void php_sdl_window_free(zend_object* zo) + */ +static void php_sdl_window_free(zend_object *zo) { - struct php_sdl_window *intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset); - if (intern->window) { - if(!(intern->flags & SDL_DONTFREE)) { + struct php_sdl_window *intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset); + if (intern->window) + { + if (!(intern->flags & SDL_DONTFREE)) + { SDL_DestroyWindow(intern->window); } } @@ -1436,19 +1499,19 @@ static void php_sdl_window_free(zend_object* zo) /* {{{ php_sdl_window_new */ -static zend_object* php_sdl_window_new(zend_class_entry *class_type) +static zend_object *php_sdl_window_new(zend_class_entry *class_type) { struct php_sdl_window *intern; - intern = (struct php_sdl_window*)ecalloc(1, sizeof(struct php_sdl_window) + zend_object_properties_size(class_type)); + intern = (struct php_sdl_window *)ecalloc(1, sizeof(struct php_sdl_window) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); - intern->window = NULL; + intern->window = NULL; php_sdl_window_handlers.offset = XtOffsetOf(struct php_sdl_window, zo); - php_sdl_window_handlers.free_obj = php_sdl_window_free; + php_sdl_window_handlers.free_obj = php_sdl_window_free; intern->zo.handlers = &php_sdl_window_handlers; return &intern->zo; @@ -1458,12 +1521,13 @@ static zend_object* php_sdl_window_new(zend_class_entry *class_type) /* {{{ sdl_window_to_zval */ zend_bool sdl_window_to_zval(SDL_Window *window, zval *z_val, int flags) { - if (window) { + if (window) + { struct php_sdl_window *intern; object_init_ex(z_val, php_sdl_window_ce); - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_window*)((char*)zo - zo->handlers->offset); + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_window *)((char *)zo - zo->handlers->offset); intern->window = window; intern->flags = flags; @@ -1474,13 +1538,13 @@ zend_bool sdl_window_to_zval(SDL_Window *window, zval *z_val, int flags) } /* }}} */ -#define REGISTER_WINDOW_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_WINDOW_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("SDL_WINDOW_" const_name, value, CONST_CS | CONST_PERSISTENT); \ - zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL(const_name), value); \ + zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL(const_name), value); -#define REGISTER_WINDOWPOS_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_WINDOWPOS_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("SDL_WINDOWPOS_" const_name, value, CONST_CS | CONST_PERSISTENT); \ - zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL("POS_" const_name), value); \ + zend_declare_class_constant_long(php_sdl_window_ce, ZEND_STRL("POS_" const_name), value); #define REGISTER_WINDOW_PROP(name) \ zend_declare_property_long(php_sdl_window_ce, ZEND_STRL(name), 0, ZEND_ACC_PUBLIC) @@ -1505,28 +1569,28 @@ PHP_MINIT_FUNCTION(sdl_window) REGISTER_WINDOW_PROP("w"); REGISTER_WINDOW_PROP("h"); - zend_declare_property_null(php_sdl_window_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC); - - REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN", SDL_WINDOW_FULLSCREEN); - REGISTER_WINDOW_CLASS_CONST_LONG("OPENGL", SDL_WINDOW_OPENGL); - REGISTER_WINDOW_CLASS_CONST_LONG("SHOWN", SDL_WINDOW_SHOWN); - REGISTER_WINDOW_CLASS_CONST_LONG("HIDDEN", SDL_WINDOW_HIDDEN); - REGISTER_WINDOW_CLASS_CONST_LONG("BORDERLESS", SDL_WINDOW_BORDERLESS); - REGISTER_WINDOW_CLASS_CONST_LONG("RESIZABLE", SDL_WINDOW_RESIZABLE); - REGISTER_WINDOW_CLASS_CONST_LONG("MINIMIZED", SDL_WINDOW_MINIMIZED); - REGISTER_WINDOW_CLASS_CONST_LONG("MAXIMIZED", SDL_WINDOW_MAXIMIZED); - REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_GRABBED", SDL_WINDOW_INPUT_GRABBED); - REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_FOCUS", SDL_WINDOW_INPUT_FOCUS); - REGISTER_WINDOW_CLASS_CONST_LONG("MOUSE_FOCUS", SDL_WINDOW_MOUSE_FOCUS); + zend_declare_property_null(php_sdl_window_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC); + + REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN", SDL_WINDOW_FULLSCREEN); + REGISTER_WINDOW_CLASS_CONST_LONG("OPENGL", SDL_WINDOW_OPENGL); + REGISTER_WINDOW_CLASS_CONST_LONG("SHOWN", SDL_WINDOW_SHOWN); + REGISTER_WINDOW_CLASS_CONST_LONG("HIDDEN", SDL_WINDOW_HIDDEN); + REGISTER_WINDOW_CLASS_CONST_LONG("BORDERLESS", SDL_WINDOW_BORDERLESS); + REGISTER_WINDOW_CLASS_CONST_LONG("RESIZABLE", SDL_WINDOW_RESIZABLE); + REGISTER_WINDOW_CLASS_CONST_LONG("MINIMIZED", SDL_WINDOW_MINIMIZED); + REGISTER_WINDOW_CLASS_CONST_LONG("MAXIMIZED", SDL_WINDOW_MAXIMIZED); + REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_GRABBED", SDL_WINDOW_INPUT_GRABBED); + REGISTER_WINDOW_CLASS_CONST_LONG("INPUT_FOCUS", SDL_WINDOW_INPUT_FOCUS); + REGISTER_WINDOW_CLASS_CONST_LONG("MOUSE_FOCUS", SDL_WINDOW_MOUSE_FOCUS); REGISTER_WINDOW_CLASS_CONST_LONG("FULLSCREEN_DESKTOP", SDL_WINDOW_FULLSCREEN_DESKTOP); - REGISTER_WINDOW_CLASS_CONST_LONG("FOREIGN", SDL_WINDOW_FOREIGN); + REGISTER_WINDOW_CLASS_CONST_LONG("FOREIGN", SDL_WINDOW_FOREIGN); #if SDL_COMPILEDVERSION > 2000 - REGISTER_WINDOW_CLASS_CONST_LONG("ALLOW_HIGHDPI", SDL_WINDOW_ALLOW_HIGHDPI); + REGISTER_WINDOW_CLASS_CONST_LONG("ALLOW_HIGHDPI", SDL_WINDOW_ALLOW_HIGHDPI); #endif - REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED_MASK", SDL_WINDOWPOS_UNDEFINED_MASK); - REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED", SDL_WINDOWPOS_UNDEFINED); - REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED_MASK", SDL_WINDOWPOS_CENTERED_MASK); - REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED", SDL_WINDOWPOS_CENTERED); + REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED_MASK", SDL_WINDOWPOS_UNDEFINED_MASK); + REGISTER_WINDOWPOS_CLASS_CONST_LONG("UNDEFINED", SDL_WINDOWPOS_UNDEFINED); + REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED_MASK", SDL_WINDOWPOS_CENTERED_MASK); + REGISTER_WINDOWPOS_CLASS_CONST_LONG("CENTERED", SDL_WINDOWPOS_CENTERED); return SUCCESS; } From e63ec0543ca5486990b93fe088748ab3ef8553cc Mon Sep 17 00:00:00 2001 From: Santiago Date: Sat, 23 Jul 2022 11:26:03 +0100 Subject: [PATCH 45/55] Update README.md --- README.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/README.md b/README.md index 9603609..c60690b 100644 --- a/README.md +++ b/README.md @@ -46,18 +46,11 @@ SDL_SetWindowTitle($window, "Some new title"); SDL_DestroyWindow($window); ``` -And is also available in object oriented style: - -```php -$window = new SDL_Window( "Foo window", 100, 50, 350, 300, SDL_Window::SHOWN|SDL_Window::RESIZABLE); -$window->SetTitle("Some new title"); -unset($window); // will destroy the window -``` - Complete examples can be found in the [examples](examples) folder. ## Related projects +* [PHP-SDL_TTF](https://github.com/Ponup/php-sdl-ttf) * [PHP-SDL_Mixer](https://github.com/kea/php-sdl-mixer) * [PHP-SDL_Image](https://github.com/kea/php-sdl-image) * [PHP-OpenGL](https://github.com/ponup/php-opengl) From 4d0e9c30163278d4c3dd1cf556cf682cca370f79 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 2 Dec 2022 11:42:41 +0000 Subject: [PATCH 46/55] Update QueryTexture function --- src/php_sdl.c | 2 +- src/render.c | 22 ++++++++++------------ src/render.h | 28 ++++++++-------------------- src/shape.c | 2 +- 4 files changed, 20 insertions(+), 34 deletions(-) diff --git a/src/php_sdl.c b/src/php_sdl.c index 7ab5d78..6c39112 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | diff --git a/src/render.c b/src/render.c index f8e1f9c..54f7b9a 100644 --- a/src/render.c +++ b/src/render.c @@ -334,12 +334,12 @@ PHP_FUNCTION(SDL_GetRendererOutputSize) PHP_FUNCTION(SDL_QueryTexture) { - zval *z_texture, *z_format, *z_access, *z_width, *z_height; + zval *z_texture, *z_format = NULL, *z_access = NULL, *z_width = NULL, *z_height = NULL; SDL_Texture *texture; int w, h, access, result; Uint32 format; - if( zend_parse_parameters(ZEND_NUM_ARGS(), "zz/z/z/z/", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) { + if( zend_parse_parameters(ZEND_NUM_ARGS(), "z|zzzz", &z_texture, &z_format, &z_access, &z_width, &z_height) == FAILURE ) { return; } @@ -347,14 +347,14 @@ PHP_FUNCTION(SDL_QueryTexture) result = SDL_QueryTexture(texture, &format, &access, &w, &h); - zval_dtor(z_format); - ZVAL_LONG(z_format, format); - zval_dtor(z_access); - ZVAL_LONG(z_access, access); - zval_dtor(z_width); - ZVAL_LONG(z_width, (long)w); - zval_dtor(z_height); - ZVAL_LONG(z_height, (long)h); + if(z_format) + ZEND_TRY_ASSIGN_REF_LONG(z_format, format); + if(z_access) + ZEND_TRY_ASSIGN_REF_LONG(z_access, access); + if(z_width) + ZEND_TRY_ASSIGN_REF_LONG(z_width, w); + if(z_height) + ZEND_TRY_ASSIGN_REF_LONG(z_height, h); RETURN_LONG(result); } @@ -366,12 +366,10 @@ PHP_FUNCTION(SDL_RenderDrawPointF) double x, y; ZEND_PARSE_PARAMETERS_START(3, 3); - //Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce) Z_PARAM_ZVAL(RENDERER) Z_PARAM_DOUBLE(x) Z_PARAM_DOUBLE(y) ZEND_PARSE_PARAMETERS_END(); -// renderer = php_sdl_renderer_from_zval_p(RENDERER); renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer); int result = SDL_RenderDrawPointF(renderer, (float) x, (float) y); diff --git a/src/render.h b/src/render.h index 0a8c0ab..10ef166 100644 --- a/src/render.h +++ b/src/render.h @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -25,7 +25,6 @@ extern "C" { #include "php_sdl.h" ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderDrawColor, 0, 0, 5) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_INFO(0, r) ZEND_ARG_INFO(0, g) @@ -34,12 +33,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderDrawColor, 0, 0, 5) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderClear, 0, 0, 1) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_DestroyRenderer, 0, 0, 1) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_END_ARG_INFO() @@ -48,10 +45,8 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_DestroyTexture, 0, 0, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderFillRect, 0, 0, 2) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 0) - //ZEND_ARG_INFO(0, rect) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawRect, 0, 0, 2) @@ -68,7 +63,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawLine, 0, 0, 4) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderPresent, 0, 0, 1) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_END_ARG_INFO() @@ -79,7 +73,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderDrawPoint, 0, 0, 3) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTextureFromSurface, 0, 0, 2) - ZEND_ARG_INFO(0, renderer)//ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) + ZEND_ARG_INFO(0, renderer) ZEND_ARG_OBJ_INFO(0, surface, SDL_Surface, 0) ZEND_END_ARG_INFO() @@ -91,12 +85,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5) ZEND_ARG_INFO(0, h) ZEND_END_ARG_INFO() -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 5) - ZEND_ARG_INFO(0, texture) - ZEND_ARG_INFO(1, format) - ZEND_ARG_INFO(1, access) - ZEND_ARG_INFO(1, w) - ZEND_ARG_INFO(1, h) +ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0) + ZEND_ARG_TYPE_INFO(1, format, IS_LONG, 1) + ZEND_ARG_TYPE_INFO(1, access, IS_LONG, 1) + ZEND_ARG_TYPE_INFO(1, w, IS_LONG, 1) + ZEND_ARG_TYPE_INFO(1, h, IS_LONG, 1) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetRenderTarget, 0, 0, 2) @@ -134,14 +128,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawPointF, 0, 3, IS_LONG, 0) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_TYPE_INFO(0, x, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, y, IS_DOUBLE, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawLineF, 0, 5, IS_LONG, 0) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_TYPE_INFO(0, x1, IS_DOUBLE, 0) ZEND_ARG_TYPE_INFO(0, y1, IS_DOUBLE, 0) @@ -150,7 +142,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawLineF, 0, 5, IS_LO ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderDrawRectF, 0, 2, IS_LONG, 0) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_OBJ_INFO(0, rect, SDL_FRect, 0) ZEND_END_ARG_INFO() @@ -158,7 +149,6 @@ ZEND_END_ARG_INFO() #define arginfo_SDL_RenderFillRectF arginfo_SDL_RenderDrawRectF ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyF, 0, 4, IS_LONG, 0) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0) ZEND_ARG_OBJ_INFO(0, srcrect, SDL_Rect, 1) @@ -166,7 +156,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyF, 0, 4, IS_LONG, ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyExF, 0, 7, IS_LONG, 0) - //ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) ZEND_ARG_INFO(0, renderer) ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0) ZEND_ARG_OBJ_INFO_WITH_DEFAULT_VALUE(0, srcrect, SDL_Rect, 1, "null") @@ -176,7 +165,6 @@ ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_SDL_RenderCopyExF, 0, 7, IS_LONG ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, flip, IS_LONG, 0, "SDL_FLIP_NONE") ZEND_END_ARG_INFO() - PHP_FUNCTION(SDL_SetRenderDrawColor); PHP_FUNCTION(SDL_RenderClear); PHP_FUNCTION(SDL_DestroyRenderer); diff --git a/src/shape.c b/src/shape.c index 314ebde..2bdf8ec 100644 --- a/src/shape.c +++ b/src/shape.c @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ - | Copyright (c) 1997-2018 The PHP Group | + | Copyright (c) 1997-2022 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | From 4b4da68dec71fd8c3980787654e181fec25b4b0c Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Tue, 27 Dec 2022 22:54:24 +0000 Subject: [PATCH 47/55] Remove warnings on __toString class methods --- src/event.c | 271 +++++++++++++------------ src/glcontext.c | 269 +++++++++++++------------ src/messagebox.c | 331 +++++++++++++++++------------- src/mouse.c | 7 +- src/mutex.c | 12 +- src/php_sdl.c | 510 ++++++++++++++++++++++------------------------- src/pixels.c | 50 +++-- src/rwops.c | 5 +- src/shape.c | 8 +- src/surface.c | 5 +- src/video.c | 5 +- src/window.c | 5 +- 12 files changed, 785 insertions(+), 693 deletions(-) diff --git a/src/event.c b/src/event.c index f199ee4..25da33e 100644 --- a/src/event.c +++ b/src/event.c @@ -20,7 +20,8 @@ static zend_class_entry *php_sdl_event_ce; static zend_object_handlers php_sdl_event_handlers; -struct php_sdl_event { +struct php_sdl_event +{ zend_object zo; }; @@ -31,11 +32,13 @@ zend_class_entry *get_php_sdl_event_ce(void) zend_bool sdl_event_to_zval(SDL_Event *event, zval *value) { - if(NULL == event) { + if (NULL == event) + { ZVAL_NULL(value); return 0; } - if(value != NULL) { + if (value != NULL) + { zval_ptr_dtor(value); } @@ -43,73 +46,86 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value) zend_update_property_long(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), event->type); - switch(event->type) { - case SDL_MOUSEMOTION: { - zval motion; - object_init(&motion); - add_property_long(&motion, "state", event->motion.state); - add_property_long(&motion, "x", event->motion.x); - add_property_long(&motion, "y", event->motion.y); - add_property_zval(value, "motion", &motion); - zval_ptr_dtor(&motion); - } break; - case SDL_MOUSEBUTTONDOWN: { - zval button; - object_init(&button); - add_property_long(&button, "button", event->button.button); - add_property_long(&button, "x", event->button.x); - add_property_long(&button, "y", event->button.y); - add_property_zval(value, "button", &button); - zval_ptr_dtor(&button); - } break; - case SDL_KEYDOWN: - case SDL_KEYUP: { - zval keysym; - object_init(&keysym); - add_property_long(&keysym, "sym", event->key.keysym.sym); - - zval key; - object_init(&key); - add_property_zval(&key, "keysym", &keysym); - - add_property_zval(value, "key", &key); - zval_ptr_dtor(&key); - zval_ptr_dtor(&keysym); - } break; - case SDL_WINDOWEVENT: { - zval window; - object_init(&window); - add_property_long(&window, "event", event->window.event); - add_property_long(&window, "timestamp", event->window.timestamp); - add_property_long(&window, "windowID", event->window.windowID); - add_property_long(&window, "data1", event->window.data1); - add_property_long(&window, "data2", event->window.data2); - add_property_zval(value, "window", &window); - zval_ptr_dtor(&window); - } break; - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: { - zval joybutton; - object_init(&joybutton); - add_property_long(&joybutton, "type", event->jbutton.type); - add_property_long(&joybutton, "timestamp", event->jbutton.timestamp); - add_property_long(&joybutton, "which", event->jbutton.which); - add_property_long(&joybutton, "button", event->jbutton.button); - add_property_long(&joybutton, "state", event->jbutton.state); - add_property_zval(value, "jbutton", &joybutton); - zval_ptr_dtor(&joybutton); - } break; - case SDL_JOYAXISMOTION: { - zval jaxis; - object_init(&jaxis); - add_property_long(&jaxis, "type", event->jaxis.type); - add_property_long(&jaxis, "timestamp", event->jaxis.timestamp); - add_property_long(&jaxis, "which", event->jaxis.which); - add_property_long(&jaxis, "axis", event->jaxis.axis); - add_property_long(&jaxis, "value", event->jaxis.value); - add_property_zval(value, "jaxis", &jaxis); - zval_ptr_dtor(&jaxis); - } break; + switch (event->type) + { + case SDL_MOUSEMOTION: + { + zval motion; + object_init(&motion); + add_property_long(&motion, "state", event->motion.state); + add_property_long(&motion, "x", event->motion.x); + add_property_long(&motion, "y", event->motion.y); + add_property_zval(value, "motion", &motion); + zval_ptr_dtor(&motion); + } + break; + case SDL_MOUSEBUTTONDOWN: + { + zval button; + object_init(&button); + add_property_long(&button, "button", event->button.button); + add_property_long(&button, "x", event->button.x); + add_property_long(&button, "y", event->button.y); + add_property_zval(value, "button", &button); + zval_ptr_dtor(&button); + } + break; + case SDL_KEYDOWN: + case SDL_KEYUP: + { + zval keysym; + object_init(&keysym); + add_property_long(&keysym, "sym", event->key.keysym.sym); + + zval key; + object_init(&key); + add_property_zval(&key, "keysym", &keysym); + + add_property_zval(value, "key", &key); + zval_ptr_dtor(&key); + zval_ptr_dtor(&keysym); + } + break; + case SDL_WINDOWEVENT: + { + zval window; + object_init(&window); + add_property_long(&window, "event", event->window.event); + add_property_long(&window, "timestamp", event->window.timestamp); + add_property_long(&window, "windowID", event->window.windowID); + add_property_long(&window, "data1", event->window.data1); + add_property_long(&window, "data2", event->window.data2); + add_property_zval(value, "window", &window); + zval_ptr_dtor(&window); + } + break; + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: + { + zval joybutton; + object_init(&joybutton); + add_property_long(&joybutton, "type", event->jbutton.type); + add_property_long(&joybutton, "timestamp", event->jbutton.timestamp); + add_property_long(&joybutton, "which", event->jbutton.which); + add_property_long(&joybutton, "button", event->jbutton.button); + add_property_long(&joybutton, "state", event->jbutton.state); + add_property_zval(value, "jbutton", &joybutton); + zval_ptr_dtor(&joybutton); + } + break; + case SDL_JOYAXISMOTION: + { + zval jaxis; + object_init(&jaxis); + add_property_long(&jaxis, "type", event->jaxis.type); + add_property_long(&jaxis, "timestamp", event->jaxis.timestamp); + add_property_long(&jaxis, "which", event->jaxis.which); + add_property_long(&jaxis, "axis", event->jaxis.axis); + add_property_long(&jaxis, "value", event->jaxis.value); + add_property_zval(value, "jaxis", &jaxis); + zval_ptr_dtor(&jaxis); + } + break; } return 1; @@ -118,8 +134,9 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value) zend_bool zval_to_sdl_event(zval *value, SDL_Event *event) { zval *val, rv; - - if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce) { + + if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_event_ce) + { val = zend_read_property(php_sdl_event_ce, Z_OBJ_P(value), ZEND_STRL("type"), 0, &rv); convert_to_long(val); Z_LVAL_P(val) = event->type = (int)Z_LVAL_P(val); @@ -136,7 +153,8 @@ static PHP_METHOD(SDL_Event, __construct) zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters_none()) { + if (FAILURE == zend_parse_parameters_none()) + { zend_restore_error_handling(&error_handling); return; } @@ -147,23 +165,27 @@ static PHP_METHOD(SDL_Event, __construct) static PHP_METHOD(SDL_Event, __toString) { char *buf; - size_t buf_len; + size_t buf_len; SDL_Event event; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } zval_to_sdl_event(getThis(), &event); buf_len = spprintf(&buf, 100, "SDL_Event(type=%d)", event.type); RETVAL_STRINGL(buf, buf_len); - efree(buf); + efree(buf); } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Event___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + static HashTable *sdl_event_get_properties(zend_object *object) { - HashTable *props; + HashTable *props; props = zend_std_get_properties(object); return props; @@ -175,7 +197,8 @@ PHP_FUNCTION(SDL_PollEvent) SDL_Event event; int ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) + { return; } @@ -191,13 +214,14 @@ PHP_FUNCTION(SDL_WaitEvent) SDL_Event event; int ret; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) { + if (zend_parse_parameters(ZEND_NUM_ARGS(), "O/", &object, get_php_sdl_event_ce()) == FAILURE) + { return; } ret = SDL_WaitEvent(&event); sdl_event_to_zval(&event, object); - + RETURN_LONG(ret); } @@ -205,13 +229,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0) ZEND_END_ARG_INFO() static const zend_function_entry php_sdl_event_methods[] = { - PHP_ME(SDL_Event, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_Event, __toString, arginfo_none, ZEND_ACC_PUBLIC) - - /* non-static methods */ -// PHP_FALIAS(Empty, SDL_RectEmpty, arginfo_none) - PHP_FE_END -}; + PHP_ME(SDL_Event, __construct, arginfo_none, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_Event, __toString, arginfo_class_SDL_Event___toString, ZEND_ACC_PUBLIC) + PHP_FE_END}; /* {{{ MINIT */ PHP_MINIT_FUNCTION(sdl_event) @@ -220,50 +240,50 @@ PHP_MINIT_FUNCTION(sdl_event) REGISTER_LONG_CONSTANT("SDL_QUIT", SDL_QUIT, CONST_CS | CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERBACKGROUND", SDL_APP_DIDENTERBACKGROUND, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERFOREGROUND", SDL_APP_WILLENTERFOREGROUND, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERFOREGROUND", SDL_APP_DIDENTERFOREGROUND, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT", SDL_WINDOWEVENT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_SYSWMEVENT", SDL_SYSWMEVENT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_KEYDOWN", SDL_KEYDOWN, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_KEYUP", SDL_KEYUP, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_TEXTEDITING", SDL_TEXTEDITING, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_TEXTINPUT", SDL_TEXTINPUT, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_MOUSEMOTION", SDL_MOUSEMOTION, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONDOWN", SDL_MOUSEBUTTONDOWN, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONUP", SDL_MOUSEBUTTONUP, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_MOUSEWHEEL", SDL_MOUSEWHEEL, CONST_CS|CONST_PERSISTENT); - + REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERBACKGROUND", SDL_APP_DIDENTERBACKGROUND, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERFOREGROUND", SDL_APP_WILLENTERFOREGROUND, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_APP_DIDENTERFOREGROUND", SDL_APP_DIDENTERFOREGROUND, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT", SDL_WINDOWEVENT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_SYSWMEVENT", SDL_SYSWMEVENT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_KEYDOWN", SDL_KEYDOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_KEYUP", SDL_KEYUP, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_TEXTEDITING", SDL_TEXTEDITING, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_TEXTINPUT", SDL_TEXTINPUT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_MOUSEMOTION", SDL_MOUSEMOTION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONDOWN", SDL_MOUSEBUTTONDOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_MOUSEBUTTONUP", SDL_MOUSEBUTTONUP, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_MOUSEWHEEL", SDL_MOUSEWHEEL, CONST_CS | CONST_PERSISTENT); + // Joystick - REGISTER_LONG_CONSTANT("SDL_JOYAXISMOTION", SDL_JOYAXISMOTION, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_JOYBUTTONDOWN", SDL_JOYBUTTONDOWN, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_JOYBUTTONUP", SDL_JOYBUTTONUP, CONST_CS|CONST_PERSISTENT); - - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SHOWN", SDL_WINDOWEVENT_SHOWN, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIDDEN", SDL_WINDOWEVENT_HIDDEN, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_EXPOSED", SDL_WINDOWEVENT_EXPOSED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MOVED", SDL_WINDOWEVENT_MOVED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESIZED", SDL_WINDOWEVENT_RESIZED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SIZE_CHANGED", SDL_WINDOWEVENT_SIZE_CHANGED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MINIMIZED", SDL_WINDOWEVENT_MINIMIZED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MAXIMIZED", SDL_WINDOWEVENT_MAXIMIZED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESTORED", SDL_WINDOWEVENT_RESTORED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_ENTER", SDL_WINDOWEVENT_ENTER, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_LEAVE", SDL_WINDOWEVENT_LEAVE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_GAINED", SDL_WINDOWEVENT_FOCUS_GAINED, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_LOST", SDL_WINDOWEVENT_FOCUS_LOST, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_CLOSE", SDL_WINDOWEVENT_CLOSE, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_TAKE_FOCUS", SDL_WINDOWEVENT_TAKE_FOCUS, CONST_CS|CONST_PERSISTENT); - REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIT_TEST", SDL_WINDOWEVENT_HIT_TEST, CONST_CS|CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_JOYAXISMOTION", SDL_JOYAXISMOTION, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_JOYBUTTONDOWN", SDL_JOYBUTTONDOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_JOYBUTTONUP", SDL_JOYBUTTONUP, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SHOWN", SDL_WINDOWEVENT_SHOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIDDEN", SDL_WINDOWEVENT_HIDDEN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_EXPOSED", SDL_WINDOWEVENT_EXPOSED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MOVED", SDL_WINDOWEVENT_MOVED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESIZED", SDL_WINDOWEVENT_RESIZED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_SIZE_CHANGED", SDL_WINDOWEVENT_SIZE_CHANGED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MINIMIZED", SDL_WINDOWEVENT_MINIMIZED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_MAXIMIZED", SDL_WINDOWEVENT_MAXIMIZED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_RESTORED", SDL_WINDOWEVENT_RESTORED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_ENTER", SDL_WINDOWEVENT_ENTER, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_LEAVE", SDL_WINDOWEVENT_LEAVE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_GAINED", SDL_WINDOWEVENT_FOCUS_GAINED, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_FOCUS_LOST", SDL_WINDOWEVENT_FOCUS_LOST, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_CLOSE", SDL_WINDOWEVENT_CLOSE, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_TAKE_FOCUS", SDL_WINDOWEVENT_TAKE_FOCUS, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_WINDOWEVENT_HIT_TEST", SDL_WINDOWEVENT_HIT_TEST, CONST_CS | CONST_PERSISTENT); INIT_CLASS_ENTRY(ce_event, "SDL_Event", php_sdl_event_methods); php_sdl_event_ce = zend_register_internal_class(&ce_event); memcpy(&php_sdl_event_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_sdl_event_handlers.get_properties = sdl_event_get_properties; - php_sdl_event_handlers.offset = XtOffsetOf(struct php_sdl_event, zo); + php_sdl_event_handlers.offset = XtOffsetOf(struct php_sdl_event, zo); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("type"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC); @@ -272,4 +292,3 @@ PHP_MINIT_FUNCTION(sdl_event) return SUCCESS; } /* }}} */ - diff --git a/src/glcontext.c b/src/glcontext.c index 38581cd..0392c37 100644 --- a/src/glcontext.c +++ b/src/glcontext.c @@ -15,7 +15,6 @@ +----------------------------------------------------------------------+ */ - /* +----------------------------------------------------------------------+ | wrapper for SDL2/SDL_video.h (only SDL_GLContext) | @@ -37,13 +36,13 @@ static zend_class_entry *php_sdl_glcontext_ce; static zend_object_handlers php_sdl_glcontext_handlers; -struct php_sdl_glcontext { +struct php_sdl_glcontext +{ SDL_GLContext glcontext; - Uint32 flags; - zend_object zo; + Uint32 flags; + zend_object zo; }; - /* {{{ get_php_sdl_glcontext_ce */ zend_class_entry *get_php_sdl_glcontext_ce(void) { @@ -51,27 +50,28 @@ zend_class_entry *get_php_sdl_glcontext_ce(void) } /* }}} */ - -#define FETCH_GLCONTEXT(__ptr, __id, __check) \ -{ \ - zend_object* zox = Z_OBJ_P(__id);\ - intern = (struct php_sdl_glcontext*)((char*)zox - zox->handlers->offset);\ - __ptr = intern->glcontext; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ -} +#define FETCH_GLCONTEXT(__ptr, __id, __check) \ + { \ + zend_object *zox = Z_OBJ_P(__id); \ + intern = (struct php_sdl_glcontext *)((char *)zox - zox->handlers->offset); \ + __ptr = intern->glcontext; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } /* {{{ sdl_glcontext_to_zval */ zend_bool sdl_glcontext_to_zval(SDL_GLContext glcontext, zval *z_val, Uint32 flags) { - if (glcontext) { + if (glcontext) + { struct php_sdl_glcontext *intern; object_init_ex(z_val, php_sdl_glcontext_ce); - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset); + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset); intern->glcontext = glcontext; intern->flags = flags; @@ -82,30 +82,31 @@ zend_bool sdl_glcontext_to_zval(SDL_GLContext glcontext, zval *z_val, Uint32 fla } /* }}} */ - /* {{{ zval_to_sdl_glcontext */ SDL_GLContext zval_to_sdl_glcontext(zval *z_val) { struct php_sdl_glcontext *intern; - if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_glcontext_ce) { - zend_object* zo = Z_OBJ_P(z_val); - intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset); + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_glcontext_ce) + { + zend_object *zo = Z_OBJ_P(z_val); + intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset); return intern->glcontext; } return NULL; } /* }}} */ - /* {{{ php_sdl_glcontext_free - */ + */ static void php_sdl_glcontext_free(zend_object *zo) { - struct php_sdl_glcontext* intern = (struct php_sdl_glcontext*)((char*)zo - zo->handlers->offset); + struct php_sdl_glcontext *intern = (struct php_sdl_glcontext *)((char *)zo - zo->handlers->offset); - if (intern->glcontext) { - if (!(intern->flags & SDL_DONTFREE)) { + if (intern->glcontext) + { + if (!(intern->flags & SDL_DONTFREE)) + { SDL_GL_DeleteContext(intern->glcontext); } } @@ -114,40 +115,39 @@ static void php_sdl_glcontext_free(zend_object *zo) } /* }}} */ - /* {{{ php_sdl_glcontext_new */ -static zend_object* php_sdl_glcontext_new(zend_class_entry *class_type) +static zend_object *php_sdl_glcontext_new(zend_class_entry *class_type) { struct php_sdl_glcontext *intern; - intern = (struct php_sdl_glcontext*)ecalloc(1, sizeof(struct php_sdl_glcontext) + zend_object_properties_size(class_type)); + intern = (struct php_sdl_glcontext *)ecalloc(1, sizeof(struct php_sdl_glcontext) + zend_object_properties_size(class_type)); zend_object_std_init(&intern->zo, class_type); object_properties_init(&intern->zo, class_type); intern->glcontext = NULL; - - intern->zo.handlers = (zend_object_handlers*)&php_sdl_glcontext_handlers; - return &intern->zo; + intern->zo.handlers = (zend_object_handlers *)&php_sdl_glcontext_handlers; + + return &intern->zo; } /* }}} */ - /* {{{ proto bool SDL_GL_ExtensionSupported(string extension) * \brief Return true if an OpenGL extension is supported for the current * context. extern DECLSPEC SDL_bool SDLCALL SDL_GL_ExtensionSupported(const char - *extension); + *extension); */ PHP_FUNCTION(SDL_GL_ExtensionSupported) { char *ext; size_t ext_len; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ext, &ext_len)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "s", &ext, &ext_len)) + { return; } RETVAL_BOOL(SDL_GL_ExtensionSupported(ext) == SDL_TRUE); @@ -163,14 +163,14 @@ PHP_FUNCTION(SDL_GL_SetAttribute) { zend_long attr, value; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &attr, &value)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &attr, &value)) + { return; } RETVAL_LONG(SDL_GL_SetAttribute((SDL_GLattr)attr, (int)value)); } /* }}} */ - /* {{{ proto int SDL_GL_GetAttribute(int attr, int &value) * \brief Get the actual value for an attribute from the current context. @@ -182,11 +182,13 @@ PHP_FUNCTION(SDL_GL_GetAttribute) zval *z_value; int ret, value; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &attr, &z_value)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lz", &attr, &z_value)) + { return; } ret = SDL_GL_GetAttribute((SDL_GLattr)attr, &value); - if (ret == 0) { + if (ret == 0) + { zval_dtor(z_value); ZVAL_LONG(z_value, value); } @@ -194,7 +196,6 @@ PHP_FUNCTION(SDL_GL_GetAttribute) } /* }}} */ - /* {{{ proto SDL_GLContext::__construct(void) */ PHP_METHOD(SDL_GLContext, __construct) { @@ -206,47 +207,59 @@ PHP_METHOD(SDL_GLContext, __construct) intern = (struct php_sdl_glcontext *)Z_OBJ_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); window = zval_to_sdl_window(z_window); - if (window) { + if (window) + { intern->glcontext = SDL_GL_CreateContext(window); - if (intern->glcontext) { + if (intern->glcontext) + { intern->flags = 0; - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); } - } else { + } + else + { zend_throw_exception(zend_exception_get_default(), "Invalid SDL_Window object", 0); } } /* }}} */ - /* {{{ proto SDL_GLContext::__toString() */ PHP_METHOD(SDL_GLContext, __toString) { struct php_sdl_glcontext *intern; char *buf; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } intern = (struct php_sdl_glcontext *)Z_OBJ_P(getThis()); - if (intern->glcontext) { + if (intern->glcontext) + { spprintf(&buf, 100, "SDL_GLContext(%lx)", (long)intern->glcontext); RETVAL_STRING(buf); - } else { + } + else + { RETVAL_STRING("SDL_GLContext()"); } } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_GLContext__toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_GLContext SDL_GL_CreateContext(SDL_Window window) @@ -255,7 +268,7 @@ PHP_METHOD(SDL_GLContext, __toString) * * \sa SDL_GL_DeleteContext() extern DECLSPEC SDL_GLContext SDLCALL SDL_GL_CreateContext(SDL_Window * - window); + window); */ PHP_FUNCTION(SDL_GL_CreateContext) { @@ -263,20 +276,23 @@ PHP_FUNCTION(SDL_GL_CreateContext) zval *z_window; SDL_Window *window; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_window, get_php_sdl_window_ce())) + { return; } window = zval_to_sdl_window(z_window); - if (window) { + if (window) + { context = SDL_GL_CreateContext(window); sdl_glcontext_to_zval(context, return_value, SDL_DONTFREE); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object"); } } /* }}} */ - /* {{{ proto void SDL_GL_DeleteContext(SDL_GLContext context) * \brief Delete an OpenGL context. @@ -290,7 +306,8 @@ PHP_FUNCTION(SDL_GL_DeleteContext) zval *z_context; SDL_GLContext context; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_context, php_sdl_glcontext_ce) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_context, php_sdl_glcontext_ce) == FAILURE) + { return; } FETCH_GLCONTEXT(context, z_context, 1); @@ -300,15 +317,14 @@ PHP_FUNCTION(SDL_GL_DeleteContext) } /* }}} */ - -#if SDL_VERSION_ATLEAST(2,0,1) +#if SDL_VERSION_ATLEAST(2, 0, 1) /* {{{ proto int SDL_GL_MakeCurrent(SDL_Window window, SDL_GLContext context) * \brief Set up an OpenGL context for rendering into an OpenGL window. * * \note The context must have been created with a compatible window. extern DECLSPEC int SDLCALL SDL_GL_MakeCurrent(SDL_Window * window, - SDL_GLContext context); + SDL_GLContext context); */ PHP_FUNCTION(SDL_GL_MakeCurrent) { @@ -317,20 +333,23 @@ PHP_FUNCTION(SDL_GL_MakeCurrent) SDL_GLContext context; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, get_php_sdl_window_ce(), &z_context, php_sdl_glcontext_ce)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "OO", &z_window, get_php_sdl_window_ce(), &z_context, php_sdl_glcontext_ce)) + { return; } FETCH_GLCONTEXT(context, z_context, 1); window = zval_to_sdl_window(z_window); - if (window) { + if (window) + { RETVAL_LONG(SDL_GL_MakeCurrent(window, context)); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object"); } } /* }}} */ - /* {{{ proto SDL_Window SDL_GL_GetCurrentWindow(void) * \brief Get the currently active OpenGL window. @@ -338,13 +357,13 @@ PHP_FUNCTION(SDL_GL_MakeCurrent) */ PHP_FUNCTION(SDL_GL_GetCurrentWindow) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } sdl_window_to_zval(SDL_GL_GetCurrentWindow(), return_value, SDL_DONTFREE); } - /* {{{ proto SDL_GLContext SDL_GL_GetCurrentContext(void) * \brief Get the currently active OpenGL context. @@ -352,7 +371,8 @@ PHP_FUNCTION(SDL_GL_GetCurrentWindow) */ PHP_FUNCTION(SDL_GL_GetCurrentContext) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } sdl_glcontext_to_zval(SDL_GL_GetCurrentContext(), return_value, SDL_DONTFREE); @@ -374,7 +394,7 @@ PHP_FUNCTION(SDL_GL_GetCurrentContext) * \sa SDL_GetWindowSize() * \sa SDL_CreateWindow() extern DECLSPEC void SDLCALL SDL_GL_GetDrawableSize(SDL_Window * window, int *w, - int *h); + int *h); */ PHP_FUNCTION(SDL_GL_GetDrawableSize) { @@ -382,17 +402,21 @@ PHP_FUNCTION(SDL_GL_GetDrawableSize) SDL_Window *window; int w, h; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz", &z_window, get_php_sdl_window_ce(), &z_w, &z_h)) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Ozz", &z_window, get_php_sdl_window_ce(), &z_w, &z_h)) + { return; } window = zval_to_sdl_window(z_window); - if (window) { + if (window) + { SDL_GL_GetDrawableSize(window, &w, &h); zval_dtor(z_w); ZVAL_LONG(z_w, w); zval_dtor(z_h); ZVAL_LONG(z_h, h); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object"); } } @@ -410,19 +434,22 @@ PHP_FUNCTION(SDL_GL_SwapWindow) zval *z_window; SDL_Window *window; - if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, get_php_sdl_window_ce())) { + if (FAILURE == zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "O", &z_window, get_php_sdl_window_ce())) + { return; } window = zval_to_sdl_window(z_window); - if (window) { + if (window) + { SDL_GL_SwapWindow(window); - } else { + } + else + { php_error_docref(NULL, E_WARNING, "Invalid SDL_Window object"); } } /* }}} */ - /* {{{ proto int SDL_GL_SetSwapInterval(int interval) * \brief Set the swap interval for the current OpenGL context. @@ -441,14 +468,14 @@ PHP_FUNCTION(SDL_GL_SetSwapInterval) { zend_long value; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "l", &value)) + { return; } RETVAL_LONG(SDL_GL_SetSwapInterval((int)value)); } /* }}} */ - /* {{{ proto int SDL_GL_GetSwapInterval() * \brief Get the swap interval for the current OpenGL context. @@ -464,37 +491,35 @@ PHP_FUNCTION(SDL_GL_SetSwapInterval) */ PHP_FUNCTION(SDL_GL_GetSwapInterval) { - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } RETVAL_LONG(SDL_GL_GetSwapInterval()); } /* }}} */ - /* {{{ sdl_glcontext_methods[] */ static const zend_function_entry php_sdl_glcontext_methods[] = { - PHP_ME(SDL_GLContext, __construct, arginfo_SDL_GLContext__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_GLContext, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_GLContext, __construct, arginfo_SDL_GLContext__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_GLContext, __toString, arginfo_class_SDL_GLContext__toString, ZEND_ACC_PUBLIC) /* non-static method */ - PHP_FALIAS(Delete, SDL_GL_DeleteContext, arginfo_none) + PHP_FALIAS(Delete, SDL_GL_DeleteContext, arginfo_none) /* static functions */ - ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentContext), arginfo_none, ZEND_ACC_PUBLIC|ZEND_ACC_STATIC) + ZEND_FENTRY(GL_GetCurrent, ZEND_FN(SDL_GL_GetCurrentContext), arginfo_none, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) - ZEND_FE_END -}; + ZEND_FE_END}; /* }}} */ -#define REGISTER_GL_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_GL_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("SDL_GL_" const_name, value, CONST_CS | CONST_PERSISTENT); \ - zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name)-1, value) + zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name) - 1, value) -#define REGISTER_GLCONTEXT_CLASS_CONST_LONG(const_name, value) \ +#define REGISTER_GLCONTEXT_CLASS_CONST_LONG(const_name, value) \ REGISTER_LONG_CONSTANT("SDL_GL_CONTEXT_" const_name, value, CONST_CS | CONST_PERSISTENT); \ - zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name)-1, value) - + zend_declare_class_constant_long(php_sdl_glcontext_ce, const_name, sizeof(const_name) - 1, value) /* {{{ MINIT */ PHP_MINIT_FUNCTION(sdl_glcontext) @@ -509,44 +534,44 @@ PHP_MINIT_FUNCTION(sdl_glcontext) php_sdl_glcontext_handlers.offset = XtOffsetOf(struct php_sdl_glcontext, zo); /* typedef enum SDL_GLattr; */ - REGISTER_GL_CLASS_CONST_LONG("RED_SIZE", SDL_GL_RED_SIZE); - REGISTER_GL_CLASS_CONST_LONG("GREEN_SIZE", SDL_GL_GREEN_SIZE); - REGISTER_GL_CLASS_CONST_LONG("BLUE_SIZE", SDL_GL_BLUE_SIZE); - REGISTER_GL_CLASS_CONST_LONG("ALPHA_SIZE", SDL_GL_ALPHA_SIZE); - REGISTER_GL_CLASS_CONST_LONG("BUFFER_SIZE", SDL_GL_BUFFER_SIZE), - REGISTER_GL_CLASS_CONST_LONG("DOUBLEBUFFER", SDL_GL_DOUBLEBUFFER); - REGISTER_GL_CLASS_CONST_LONG("DEPTH_SIZE", SDL_GL_DEPTH_SIZE); - REGISTER_GL_CLASS_CONST_LONG("STENCIL_SIZE", SDL_GL_STENCIL_SIZE); - REGISTER_GL_CLASS_CONST_LONG("ACCUM_RED_SIZE", SDL_GL_ACCUM_RED_SIZE); - REGISTER_GL_CLASS_CONST_LONG("ACCUM_GREEN_SIZE", SDL_GL_ACCUM_GREEN_SIZE); - REGISTER_GL_CLASS_CONST_LONG("ACCUM_BLUE_SIZE", SDL_GL_ACCUM_BLUE_SIZE); - REGISTER_GL_CLASS_CONST_LONG("ACCUM_ALPHA_SIZE", SDL_GL_ACCUM_ALPHA_SIZE); - REGISTER_GL_CLASS_CONST_LONG("STEREO", SDL_GL_STEREO); - REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLEBUFFERS", SDL_GL_MULTISAMPLEBUFFERS); - REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLESAMPLES", SDL_GL_MULTISAMPLESAMPLES), - REGISTER_GL_CLASS_CONST_LONG("ACCELERATED_VISUAL", SDL_GL_ACCELERATED_VISUAL); - REGISTER_GL_CLASS_CONST_LONG("RETAINED_BACKING", SDL_GL_RETAINED_BACKING); - REGISTER_GL_CLASS_CONST_LONG("SHARE_WITH_CURRENT_CONTEXT", SDL_GL_SHARE_WITH_CURRENT_CONTEXT); - -#if SDL_VERSION_ATLEAST(2,0,1) - REGISTER_GL_CLASS_CONST_LONG("FRAMEBUFFER_SRGB_CAPABLE", SDL_GL_FRAMEBUFFER_SRGB_CAPABLE); + REGISTER_GL_CLASS_CONST_LONG("RED_SIZE", SDL_GL_RED_SIZE); + REGISTER_GL_CLASS_CONST_LONG("GREEN_SIZE", SDL_GL_GREEN_SIZE); + REGISTER_GL_CLASS_CONST_LONG("BLUE_SIZE", SDL_GL_BLUE_SIZE); + REGISTER_GL_CLASS_CONST_LONG("ALPHA_SIZE", SDL_GL_ALPHA_SIZE); + REGISTER_GL_CLASS_CONST_LONG("BUFFER_SIZE", SDL_GL_BUFFER_SIZE), + REGISTER_GL_CLASS_CONST_LONG("DOUBLEBUFFER", SDL_GL_DOUBLEBUFFER); + REGISTER_GL_CLASS_CONST_LONG("DEPTH_SIZE", SDL_GL_DEPTH_SIZE); + REGISTER_GL_CLASS_CONST_LONG("STENCIL_SIZE", SDL_GL_STENCIL_SIZE); + REGISTER_GL_CLASS_CONST_LONG("ACCUM_RED_SIZE", SDL_GL_ACCUM_RED_SIZE); + REGISTER_GL_CLASS_CONST_LONG("ACCUM_GREEN_SIZE", SDL_GL_ACCUM_GREEN_SIZE); + REGISTER_GL_CLASS_CONST_LONG("ACCUM_BLUE_SIZE", SDL_GL_ACCUM_BLUE_SIZE); + REGISTER_GL_CLASS_CONST_LONG("ACCUM_ALPHA_SIZE", SDL_GL_ACCUM_ALPHA_SIZE); + REGISTER_GL_CLASS_CONST_LONG("STEREO", SDL_GL_STEREO); + REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLEBUFFERS", SDL_GL_MULTISAMPLEBUFFERS); + REGISTER_GL_CLASS_CONST_LONG("MULTISAMPLESAMPLES", SDL_GL_MULTISAMPLESAMPLES), + REGISTER_GL_CLASS_CONST_LONG("ACCELERATED_VISUAL", SDL_GL_ACCELERATED_VISUAL); + REGISTER_GL_CLASS_CONST_LONG("RETAINED_BACKING", SDL_GL_RETAINED_BACKING); + REGISTER_GL_CLASS_CONST_LONG("SHARE_WITH_CURRENT_CONTEXT", SDL_GL_SHARE_WITH_CURRENT_CONTEXT); + +#if SDL_VERSION_ATLEAST(2, 0, 1) + REGISTER_GL_CLASS_CONST_LONG("FRAMEBUFFER_SRGB_CAPABLE", SDL_GL_FRAMEBUFFER_SRGB_CAPABLE); #endif - REGISTER_GLCONTEXT_CLASS_CONST_LONG("MAJOR_VERSION", SDL_GL_CONTEXT_MAJOR_VERSION); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("MINOR_VERSION", SDL_GL_CONTEXT_MINOR_VERSION); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("EGL", SDL_GL_CONTEXT_EGL); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("FLAGS", SDL_GL_CONTEXT_FLAGS); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_MASK", SDL_GL_CONTEXT_PROFILE_MASK); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("MAJOR_VERSION", SDL_GL_CONTEXT_MAJOR_VERSION); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("MINOR_VERSION", SDL_GL_CONTEXT_MINOR_VERSION); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("EGL", SDL_GL_CONTEXT_EGL); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("FLAGS", SDL_GL_CONTEXT_FLAGS); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_MASK", SDL_GL_CONTEXT_PROFILE_MASK); /* typedef enum SDL_GLprofile; */ - REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_CORE", SDL_GL_CONTEXT_PROFILE_CORE); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_COMPATIBILITY", SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_ES", SDL_GL_CONTEXT_PROFILE_ES); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_CORE", SDL_GL_CONTEXT_PROFILE_CORE); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_COMPATIBILITY", SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("PROFILE_ES", SDL_GL_CONTEXT_PROFILE_ES); /* typedef enum SDL_GLcontextFlag; */ - REGISTER_GLCONTEXT_CLASS_CONST_LONG("DEBUG_FLAG", SDL_GL_CONTEXT_DEBUG_FLAG); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("DEBUG_FLAG", SDL_GL_CONTEXT_DEBUG_FLAG); REGISTER_GLCONTEXT_CLASS_CONST_LONG("FORWARD_COMPATIBLE_FLAG", SDL_GL_CONTEXT_FORWARD_COMPATIBLE_FLAG); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("ROBUST_ACCESS_FLAG", SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG); - REGISTER_GLCONTEXT_CLASS_CONST_LONG("RESET_ISOLATION_FLAG", SDL_GL_CONTEXT_RESET_ISOLATION_FLAG); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("ROBUST_ACCESS_FLAG", SDL_GL_CONTEXT_ROBUST_ACCESS_FLAG); + REGISTER_GLCONTEXT_CLASS_CONST_LONG("RESET_ISOLATION_FLAG", SDL_GL_CONTEXT_RESET_ISOLATION_FLAG); return SUCCESS; } diff --git a/src/messagebox.c b/src/messagebox.c index 6cfcd3c..a3dfae2 100644 --- a/src/messagebox.c +++ b/src/messagebox.c @@ -20,22 +20,25 @@ static zend_class_entry *php_sdl_messageboxcolor_ce; static zend_object_handlers php_sdl_messageboxcolor_handlers; -struct php_sdl_messageboxcolor { - zend_object zo; +struct php_sdl_messageboxcolor +{ + zend_object zo; }; static zend_class_entry *php_sdl_messageboxbuttondata_ce; static zend_object_handlers php_sdl_messageboxbuttondata_handlers; -struct php_sdl_messageboxbuttondata { - zend_object zo; +struct php_sdl_messageboxbuttondata +{ + zend_object zo; }; static zend_class_entry *php_sdl_messageboxdata_ce; static zend_object_handlers php_sdl_messageboxdata_handlers; -struct php_sdl_messageboxdata { - zend_object zo; - SDL_MessageBoxData *data; - Uint32 flags; +struct php_sdl_messageboxdata +{ + zend_object zo; + SDL_MessageBoxData *data; + Uint32 flags; }; /* {{{ get_php_sdl_messageboxcolor_ce */ @@ -62,7 +65,8 @@ zend_class_entry *get_php_sdl_messageboxdata_ce(void) /* {{{ sdl_messageboxcolor_to_zval */ zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *value) { - if (color) { + if (color) + { object_init_ex(value, php_sdl_messageboxcolor_ce); zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "r", 1, color->r); zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(value), "g", 1, color->g); @@ -78,7 +82,8 @@ zend_bool sdl_messageboxcolor_to_zval(const SDL_MessageBoxColor *color, zval *va /* {{{ sdl_messageboxbuttondata_to_zval */ zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data, zval *value) { - if (data) { + if (data) + { object_init_ex(value, php_sdl_messageboxbuttondata_ce); zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("flags"), data->flags); zend_update_property_long(php_sdl_messageboxbuttondata_ce, Z_OBJ_P(value), ZEND_STRL("buttonid"), data->buttonid); @@ -94,13 +99,14 @@ zend_bool sdl_messageboxbuttondata_to_zval(const SDL_MessageBoxButtonData *data, /* {{{ sdl_messageboxdata_to_zval */ zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint32 flags) { - if (data) { + if (data) + { struct php_sdl_messageboxdata *intern; object_init_ex(z_val, php_sdl_messageboxdata_ce); intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(z_val); - intern->data = data; - intern->flags = flags; + intern->data = data; + intern->flags = flags; return 1; } @@ -112,7 +118,8 @@ zend_bool sdl_messageboxdata_to_zval(SDL_MessageBoxData *data, zval *z_val, Uint /* {{{ zval_to_sdl_messageboxcolor( */ zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color) { - if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxcolor_ce) { + if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxcolor_ce) + { zval *val, rv; /* we convert the properties, without copy: yes ! */ @@ -140,7 +147,8 @@ zend_bool zval_to_sdl_messageboxcolor(zval *value, SDL_MessageBoxColor *color) /* {{{ zval_to_sdl_messageboxcolor( */ zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData *data) { - if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxbuttondata_ce) { + if (Z_TYPE_P(value) == IS_OBJECT && Z_OBJCE_P(value) == php_sdl_messageboxbuttondata_ce) + { zval *val, rv; /* we convert the properties, without copy: yes ! */ @@ -168,30 +176,35 @@ zend_bool zval_to_sdl_messageboxbuttondata(zval *value, SDL_MessageBoxButtonData /* {{{ zval_to_sdl_messageboxdata */ SDL_MessageBoxData *zval_to_sdl_messageboxdata(zval *z_val) { - if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_messageboxdata_ce) { + if (z_val && Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_messageboxdata_ce) + { struct php_sdl_messageboxdata *intern; intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(z_val); return intern->data; - } + } return NULL; } /* }}} */ /* {{{ php_sdl_messageboxdata_free - */ + */ static void php_sdl_messageboxdata_free(zend_object *object) { - struct php_sdl_messageboxdata *intern = (struct php_sdl_messageboxdata *) object; + struct php_sdl_messageboxdata *intern = (struct php_sdl_messageboxdata *)object; - if (intern->data) { - if (!(intern->flags & SDL_DONTFREE)) { + if (intern->data) + { + if (!(intern->flags & SDL_DONTFREE)) + { efree((void *)intern->data->title); efree((void *)intern->data->message); - if (intern->data->buttons) { + if (intern->data->buttons) + { efree((void *)intern->data->buttons); } - if (intern->data->colorScheme) { + if (intern->data->colorScheme) + { efree((void *)intern->data->colorScheme); } efree(intern->data); @@ -204,7 +217,7 @@ static void php_sdl_messageboxdata_free(zend_object *object) /* {{{ php_sdl_messageboxdata_new */ -static zend_object* php_sdl_messageboxdata_new(zend_class_entry *class_type) +static zend_object *php_sdl_messageboxdata_new(zend_class_entry *class_type) { struct php_sdl_messageboxdata *intern; @@ -221,11 +234,10 @@ static zend_object* php_sdl_messageboxdata_new(zend_class_entry *class_type) } /* }}} */ - ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxColor__construct, 0, 0, 3) - ZEND_ARG_INFO(0, r) - ZEND_ARG_INFO(0, g) - ZEND_ARG_INFO(0, b) +ZEND_ARG_INFO(0, r) +ZEND_ARG_INFO(0, g) +ZEND_ARG_INFO(0, b) ZEND_END_ARG_INFO() /* {{{ proto SDL_MessageBoxColor::__construct(int r, int g, int b, int a) @@ -233,7 +245,7 @@ ZEND_END_ARG_INFO() * \brief RGB value used in a message box color scheme typedef struct { - Uint8 r, g, b; + Uint8 r, g, b; } SDL_MessageBoxColor; */ static PHP_METHOD(SDL_MessageBoxColor, __construct) @@ -242,18 +254,21 @@ static PHP_METHOD(SDL_MessageBoxColor, __construct) zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lll", &r, &g, &b)) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); - zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r&255); - zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g&255); - zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b&255); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "r", 1, r & 255); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "g", 1, g & 255); + zend_update_property_long(php_sdl_messageboxcolor_ce, Z_OBJ_P(getThis()), "b", 1, b & 255); } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxColor__toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_MessageBoxColor::__toString() */ static PHP_METHOD(SDL_MessageBoxColor, __toString) @@ -261,8 +276,9 @@ static PHP_METHOD(SDL_MessageBoxColor, __toString) char *buf; SDL_MessageBoxColor color; - //intern = (struct php_sdl_pixelformat *)Z_OBJ_P(__id); - if (zend_parse_parameters_none() == FAILURE) { + // intern = (struct php_sdl_pixelformat *)Z_OBJ_P(__id); + if (zend_parse_parameters_none() == FAILURE) + { return; } @@ -272,11 +288,10 @@ static PHP_METHOD(SDL_MessageBoxColor, __toString) } /* }}} */ - ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxButtonData__construct, 0, 0, 3) - ZEND_ARG_INFO(0, flags) - ZEND_ARG_INFO(0, buttonid) - ZEND_ARG_INFO(0, text) +ZEND_ARG_INFO(0, flags) +ZEND_ARG_INFO(0, buttonid) +ZEND_ARG_INFO(0, text) ZEND_END_ARG_INFO() /* {{{ proto SDL_MessageBoxButtonData::__construct(int r, int g, int b, int a) @@ -284,9 +299,9 @@ ZEND_END_ARG_INFO() * \brief Individual button data. typedef struct { - Uint32 flags; *< ::SDL_MessageBoxButtonFlags * - int buttonid; *< User defined button id (value returned via SDL_ShowMessageBox) * - const char * text; *< The UTF-8 button text * + Uint32 flags; *< ::SDL_MessageBoxButtonFlags * + int buttonid; *< User defined button id (value returned via SDL_ShowMessageBox) * + const char * text; *< The UTF-8 button text * } SDL_MessageBoxButtonData; */ static PHP_METHOD(SDL_MessageBoxButtonData, __construct) @@ -297,7 +312,8 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct) zend_error_handling error_handling; zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lls", &flags, &id, &text, &text_len)) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lls", &flags, &id, &text, &text_len)) + { zend_restore_error_handling(&error_handling); return; } @@ -309,15 +325,18 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxButtonData___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_MessageBoxButtonData::__toString() -*/ + */ static PHP_METHOD(SDL_MessageBoxButtonData, __toString) { char *buf; SDL_MessageBoxButtonData data; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } zval_to_sdl_messageboxbuttondata(getThis(), &data); @@ -326,14 +345,13 @@ static PHP_METHOD(SDL_MessageBoxButtonData, __toString) } /* }}} */ - ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxData__construct, 0, 0, 3) - ZEND_ARG_INFO(0, flags) - ZEND_ARG_INFO(0, title) - ZEND_ARG_INFO(0, message) - ZEND_ARG_ARRAY_INFO(0, buttons, 0) - ZEND_ARG_ARRAY_INFO(0, colors, 0) - ZEND_ARG_OBJ_INFO(0, parentwindow, SDL_Window, 0) +ZEND_ARG_INFO(0, flags) +ZEND_ARG_INFO(0, title) +ZEND_ARG_INFO(0, message) +ZEND_ARG_ARRAY_INFO(0, buttons, 0) +ZEND_ARG_ARRAY_INFO(0, colors, 0) +ZEND_ARG_OBJ_INFO(0, parentwindow, SDL_Window, 0) ZEND_END_ARG_INFO() /* {{{ proto SDL_MessageBoxData::__construct(int flags, string title, string text [, array buttons [, array colors [, SDL_Window window ]]]) @@ -341,103 +359,126 @@ ZEND_END_ARG_INFO() * \brief MessageBox structure containing title, text, window, etc. typedef struct { - Uint32 flags; **< ::SDL_MessageBoxFlags * - SDL_Window *window; **< Parent window, can be NULL * - const char *title; **< UTF-8 title * - const char *message; **< UTF-8 message text * + Uint32 flags; **< ::SDL_MessageBoxFlags * + SDL_Window *window; **< Parent window, can be NULL * + const char *title; **< UTF-8 title * + const char *message; **< UTF-8 message text * - int numbuttons; - const SDL_MessageBoxButtonData *buttons; + int numbuttons; + const SDL_MessageBoxButtonData *buttons; - const SDL_MessageBoxColorScheme *colorScheme; **< ::SDL_MessageBoxColorScheme, can be NULL to use system settings * + const SDL_MessageBoxColorScheme *colorScheme; **< ::SDL_MessageBoxColorScheme, can be NULL to use system settings * } SDL_MessageBoxData; */ static PHP_METHOD(SDL_MessageBoxData, __construct) { struct php_sdl_messageboxdata *intern; - zval *z_window=NULL, *z_buttons=NULL, *z_colors=NULL; + zval *z_window = NULL, *z_buttons = NULL, *z_colors = NULL; zend_long flags; char *title, *text; size_t title_len, text_len; - int n, nb; + int n, nb; zend_error_handling error_handling; intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(getThis()); zend_replace_error_handling(EH_THROW, NULL, &error_handling); - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|aaO", &flags, &title, &title_len, &text, &text_len, &z_buttons, &z_colors, &z_window, get_php_sdl_window_ce())) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|aaO", &flags, &title, &title_len, &text, &text_len, &z_buttons, &z_colors, &z_window, get_php_sdl_window_ce())) + { zend_restore_error_handling(&error_handling); return; } zend_restore_error_handling(&error_handling); - intern->flags = 0; + intern->flags = 0; intern->data = emalloc(sizeof(SDL_MessageBoxData)); - intern->data->title = estrdup(title); - intern->data->message = estrdup(text); - intern->data->flags = (Uint32)flags; - intern->data->window = zval_to_sdl_window(z_window); - intern->data->numbuttons = 0; - intern->data->buttons = NULL; + intern->data->title = estrdup(title); + intern->data->message = estrdup(text); + intern->data->flags = (Uint32)flags; + intern->data->window = zval_to_sdl_window(z_window); + intern->data->numbuttons = 0; + intern->data->buttons = NULL; intern->data->colorScheme = NULL; - if (z_buttons) { + if (z_buttons) + { zval *ppzval; SDL_MessageBoxButtonData *buttons; - n = 0; + n = 0; nb = zend_hash_num_elements(Z_ARRVAL_P(z_buttons)); - if (nb) { + if (nb) + { buttons = emalloc(nb * sizeof(SDL_MessageBoxButtonData)); - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_buttons), ppzval) { - if (zval_to_sdl_messageboxbuttondata(ppzval, buttons+n)) { - n++; - } else { - php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxButtonData object"); - } + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_buttons), ppzval) + { + if (zval_to_sdl_messageboxbuttondata(ppzval, buttons + n)) + { + n++; + } + else + { + php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxButtonData object"); + } } ZEND_HASH_FOREACH_END(); - if (n) { + if (n) + { intern->data->numbuttons = n; - intern->data->buttons = buttons; - } else { + intern->data->buttons = buttons; + } + else + { efree(buttons); } } } - if (z_colors) { + if (z_colors) + { zval *ppzval = NULL; SDL_MessageBoxColorScheme *colors; colors = emalloc(sizeof(SDL_MessageBoxColorScheme)); memset(colors, 0, sizeof(*colors)); - n = 0; - ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_colors), ppzval) { - if (SDL_MESSAGEBOX_COLOR_MAX == n) { - php_error_docref(NULL, E_NOTICE, "Ignore button, only %d accepted", SDL_MESSAGEBOX_COLOR_MAX); - } else if (zval_to_sdl_messageboxcolor(ppzval, &colors->colors[n])) { - n++; - } else { - php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxColor object"); - } + n = 0; + ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(z_colors), ppzval) + { + if (SDL_MESSAGEBOX_COLOR_MAX == n) + { + php_error_docref(NULL, E_NOTICE, "Ignore button, only %d accepted", SDL_MESSAGEBOX_COLOR_MAX); + } + else if (zval_to_sdl_messageboxcolor(ppzval, &colors->colors[n])) + { + n++; + } + else + { + php_error_docref(NULL, E_NOTICE, "Ignore button, not a SDL_MessageBoxColor object"); + } } ZEND_HASH_FOREACH_END(); - if (n) { - if (SDL_MESSAGEBOX_COLOR_MAX != n) { + if (n) + { + if (SDL_MESSAGEBOX_COLOR_MAX != n) + { php_error_docref(NULL, E_NOTICE, "%d SDL_MessageBoxColors expected", SDL_MESSAGEBOX_COLOR_MAX); } intern->data->colorScheme = colors; - } else { + } + else + { efree(colors); } } } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_MessageBoxData___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_MessageBoxData::__toString() */ static PHP_METHOD(SDL_MessageBoxData, __toString) @@ -445,33 +486,38 @@ static PHP_METHOD(SDL_MessageBoxData, __toString) struct php_sdl_messageboxdata *intern; char *buf; - if (zend_parse_parameters_none() == FAILURE) { + if (zend_parse_parameters_none() == FAILURE) + { return; } intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(getThis()); - if (intern->data) { + if (intern->data) + { spprintf(&buf, 100, "SDL_MessageBoxData(\"%s\")", intern->data->title); RETVAL_STRING(buf); - } else { + } + else + { RETVAL_STRING("SDL_MessageBoxData()"); } } /* }}} */ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_MessageBoxData_Show, 0, 0, 1) - ZEND_ARG_INFO(1, buttonid) +ZEND_ARG_INFO(1, buttonid) ZEND_END_ARG_INFO() -#define FETCH_DATA(__ptr, __id, __check) \ -{ \ - intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(__id);\ - __ptr = intern->data; \ - if (__check && !__ptr) {\ - php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name));\ - RETURN_FALSE;\ - }\ -} +#define FETCH_DATA(__ptr, __id, __check) \ + { \ + intern = (struct php_sdl_messageboxdata *)Z_OBJ_P(__id); \ + __ptr = intern->data; \ + if (__check && !__ptr) \ + { \ + php_error_docref(NULL, E_WARNING, "Invalid %s object", ZSTR_VAL(intern->zo.ce->name)); \ + RETURN_FALSE; \ + } \ + } /* {{{ proto int SDL_ShowMessageBox(SDL_MessageBoxData messageboxdata, int &buttonid) @@ -496,13 +542,15 @@ PHP_FUNCTION(SDL_ShowMessageBox) SDL_MessageBoxData *data; int id, res; - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_data, php_sdl_messageboxdata_ce, &z_id) == FAILURE) { + if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oz/", &z_data, php_sdl_messageboxdata_ce, &z_id) == FAILURE) + { return; } FETCH_DATA(data, z_data, 1); res = SDL_ShowMessageBox(data, &id); - if (res==0) { + if (res == 0) + { zval_dtor(z_id); ZVAL_LONG(z_id, (long)id); } @@ -533,54 +581,49 @@ PHP_FUNCTION(SDL_ShowSimpleMessageBox) zval *z_window = NULL; SDL_Window *window = NULL; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|O!", &flags, &title, &title_len, &msg, &msg_len, &z_window, get_php_sdl_window_ce())) { + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lss|O!", &flags, &title, &title_len, &msg, &msg_len, &z_window, get_php_sdl_window_ce())) + { return; } - if( z_window != NULL ) { + if (z_window != NULL) + { window = zval_to_sdl_window(z_window); } RETVAL_LONG(SDL_ShowSimpleMessageBox(flags, title, msg, window)); } /* }}} */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_messagebox_none, 0, 0, 0) -ZEND_END_ARG_INFO() - /* {{{ php_sdl_messageboxcolor_methods[] */ static const zend_function_entry php_sdl_messageboxcolor_methods[] = { - PHP_ME(SDL_MessageBoxColor, __construct, arginfo_SDL_MessageBoxColor__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_MessageBoxColor, __toString, arginfo_messagebox_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_MessageBoxColor, __construct, arginfo_SDL_MessageBoxColor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_MessageBoxColor, __toString, arginfo_class_SDL_MessageBoxColor__toString, ZEND_ACC_PUBLIC) - PHP_FE_END -}; + PHP_FE_END}; /* }}} */ /* {{{ php_sdl_messageboxbuttondata_methods[] */ static const zend_function_entry php_sdl_messageboxbuttondata_methods[] = { - PHP_ME(SDL_MessageBoxButtonData, __construct, arginfo_SDL_MessageBoxButtonData__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_MessageBoxButtonData, __toString, arginfo_messagebox_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_MessageBoxButtonData, __construct, arginfo_SDL_MessageBoxButtonData__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_MessageBoxButtonData, __toString, arginfo_class_SDL_MessageBoxButtonData___toString, ZEND_ACC_PUBLIC) - PHP_FE_END -}; + PHP_FE_END}; /* }}} */ /* {{{ php_sdl_messageboxdata_methods[] */ static const zend_function_entry php_sdl_messageboxdata_methods[] = { - PHP_ME(SDL_MessageBoxData, __construct, arginfo_SDL_MessageBoxData__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_MessageBoxData, __toString, arginfo_messagebox_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_MessageBoxData, __construct, arginfo_SDL_MessageBoxData__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) + PHP_ME(SDL_MessageBoxData, __toString, arginfo_class_SDL_MessageBoxData___toString, ZEND_ACC_PUBLIC) /* non-static methods */ - PHP_FALIAS(Show, SDL_ShowMessageBox, arginfo_SDL_MessageBoxData_Show) + PHP_FALIAS(Show, SDL_ShowMessageBox, arginfo_SDL_MessageBoxData_Show) - PHP_FE_END -}; + PHP_FE_END}; /* }}} */ -#define REGISTER_MESSAGEBOX_CLASS_CONST_LONG(prefix, const_name, value, ce) \ +#define REGISTER_MESSAGEBOX_CLASS_CONST_LONG(prefix, const_name, value, ce) \ REGISTER_LONG_CONSTANT("SDL_MESSAGEBOX_" prefix const_name, value, CONST_CS | CONST_PERSISTENT); \ - zend_declare_class_constant_long(ce, ZEND_STRL(const_name), value); \ + zend_declare_class_constant_long(ce, ZEND_STRL(const_name), value); #define REGISTER_MESSAGEBOXCOLOR_PROP(name) \ zend_declare_property_long(php_sdl_messageboxcolor_ce, ZEND_STRL(name), 0, ZEND_ACC_PUBLIC) @@ -615,17 +658,17 @@ PHP_MINIT_FUNCTION(sdl_messagebox) memcpy(&php_sdl_messageboxdata_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_sdl_messageboxdata_handlers.free_obj = php_sdl_messageboxdata_free; - zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("flags"), 0, ZEND_ACC_PUBLIC); - zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC); - zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("message"), ZEND_ACC_PUBLIC); - zend_declare_property_bool(php_sdl_messageboxdata_ce, ZEND_STRL("window"), 0, ZEND_ACC_PUBLIC); - zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("numbuttons"), 0, ZEND_ACC_PUBLIC); - zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("buttons"), ZEND_ACC_PUBLIC); - zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("colors"), ZEND_ACC_PUBLIC); + zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("flags"), 0, ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("title"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("message"), ZEND_ACC_PUBLIC); + zend_declare_property_bool(php_sdl_messageboxdata_ce, ZEND_STRL("window"), 0, ZEND_ACC_PUBLIC); + zend_declare_property_long(php_sdl_messageboxdata_ce, ZEND_STRL("numbuttons"), 0, ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("buttons"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_messageboxdata_ce, ZEND_STRL("colors"), ZEND_ACC_PUBLIC); /* enum SDL_MessageBoxFlags: If supported will display warning icon, etc. */ - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "ERROR", SDL_MESSAGEBOX_ERROR, php_sdl_messageboxdata_ce); - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "WARNING", SDL_MESSAGEBOX_WARNING, php_sdl_messageboxdata_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "ERROR", SDL_MESSAGEBOX_ERROR, php_sdl_messageboxdata_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "WARNING", SDL_MESSAGEBOX_WARNING, php_sdl_messageboxdata_ce); REGISTER_MESSAGEBOX_CLASS_CONST_LONG("", "INFORMATION", SDL_MESSAGEBOX_INFORMATION, php_sdl_messageboxdata_ce); /* enum SDL_MessageBoxButtonFlags: Flags for SDL_MessageBoxButtonData. */ @@ -633,12 +676,12 @@ PHP_MINIT_FUNCTION(sdl_messagebox) REGISTER_MESSAGEBOX_CLASS_CONST_LONG("BUTTON_", "ESCAPEKEY_DEFAULT", SDL_MESSAGEBOX_BUTTON_ESCAPEKEY_DEFAULT, php_sdl_messageboxbuttondata_ce); /* enum SDL_MessageBoxColorType */ - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BACKGROUND", SDL_MESSAGEBOX_COLOR_BACKGROUND, php_sdl_messageboxcolor_ce); - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "TEXT", SDL_MESSAGEBOX_COLOR_TEXT, php_sdl_messageboxcolor_ce); - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BORDER", SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, php_sdl_messageboxcolor_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BACKGROUND", SDL_MESSAGEBOX_COLOR_BACKGROUND, php_sdl_messageboxcolor_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "TEXT", SDL_MESSAGEBOX_COLOR_TEXT, php_sdl_messageboxcolor_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BORDER", SDL_MESSAGEBOX_COLOR_BUTTON_BORDER, php_sdl_messageboxcolor_ce); REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_BACKGROUND", SDL_MESSAGEBOX_COLOR_BUTTON_BACKGROUND, php_sdl_messageboxcolor_ce); - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_SELECTED", SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, php_sdl_messageboxcolor_ce); - REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "MAX", SDL_MESSAGEBOX_COLOR_MAX, php_sdl_messageboxcolor_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "BUTTON_SELECTED", SDL_MESSAGEBOX_COLOR_BUTTON_SELECTED, php_sdl_messageboxcolor_ce); + REGISTER_MESSAGEBOX_CLASS_CONST_LONG("COLOR_", "MAX", SDL_MESSAGEBOX_COLOR_MAX, php_sdl_messageboxcolor_ce); return SUCCESS; } diff --git a/src/mouse.c b/src/mouse.c index 88d4e0b..ce4ed62 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -158,6 +158,9 @@ static PHP_METHOD(SDL_Cursor, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Cursor___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_Cursor::__toString() */ static PHP_METHOD(SDL_Cursor, __toString) @@ -547,11 +550,11 @@ ZEND_END_ARG_INFO() /* {{{ sdl_cursor_methods[] */ static const zend_function_entry php_sdl_cursor_methods[] = { PHP_ME(SDL_Cursor, __construct, arginfo_SDL_Cursor__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) - PHP_ME(SDL_Cursor, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Cursor, __toString, arginfo_class_SDL_Cursor___toString, ZEND_ACC_PUBLIC) /* non-static methods */ PHP_FALIAS(Free, SDL_FreeCursor, arginfo_none) - PHP_FALIAS(Set, SDL_SetCursor, arginfo_none) + PHP_FALIAS(Set, SDL_SetCursor, arginfo_none) /* static methods */ ZEND_FENTRY(Create, ZEND_FN(SDL_CreateCursor), arginfo_SDL_Cursor__construct, ZEND_ACC_PUBLIC | ZEND_ACC_STATIC) diff --git a/src/mutex.c b/src/mutex.c index 143a269..72aba04 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -331,6 +331,8 @@ static PHP_METHOD(SDL_mutex, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Mutex___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_mutex::__toString() */ static PHP_METHOD(SDL_mutex, __toString) @@ -492,6 +494,8 @@ static PHP_METHOD(SDL_sem, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Sem___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_sem::__toString() */ static PHP_METHOD(SDL_sem, __toString) @@ -696,6 +700,8 @@ static PHP_METHOD(SDL_cond, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_cond___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_cond::__toString() */ static PHP_METHOD(SDL_cond, __toString) @@ -896,7 +902,7 @@ PHP_FUNCTION(SDL_DestroyCond) /* {{{ sdl_mutex_methods[] */ static const zend_function_entry php_sdl_mutex_methods[] = { PHP_ME(SDL_mutex, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_mutex, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_mutex, __toString, arginfo_class_SDL_Mutex___toString, ZEND_ACC_PUBLIC) /* non-static method */ PHP_FALIAS(Lock, SDL_LockMutex, arginfo_none) @@ -912,7 +918,7 @@ static const zend_function_entry php_sdl_mutex_methods[] = { /* {{{ sdl_sem_methods[] */ static const zend_function_entry php_sdl_sem_methods[] = { PHP_ME(SDL_sem, __construct, arginfo_SDL_sem__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_sem, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_sem, __toString, arginfo_class_SDL_Sem___toString, ZEND_ACC_PUBLIC) /* non-static method */ PHP_FALIAS(Wait, SDL_SemWait, arginfo_none) @@ -930,7 +936,7 @@ static const zend_function_entry php_sdl_sem_methods[] = { /* {{{ sdl_cond_methods[] */ static const zend_function_entry php_sdl_cond_methods[] = { PHP_ME(SDL_cond, __construct, arginfo_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_cond, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_cond, __toString, arginfo_class_SDL_cond___toString, ZEND_ACC_PUBLIC) /* non-static method */ PHP_FALIAS(Wait, SDL_CondWait, arginfo_SDL_Cond_Wait) diff --git a/src/php_sdl.c b/src/php_sdl.c index 6c39112..c902860 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -49,14 +49,18 @@ ZEND_GET_MODULE(sdl) /* {{{ php_sdl_check_overflow */ zend_bool php_sdl_check_overflow(int a, int b, int silent) { - if(a <= 0 || b <= 0) { - if (!silent) { + if (a <= 0 || b <= 0) + { + if (!silent) + { php_error_docref(NULL, E_WARNING, "one parameter to a memory allocation multiplication is negative or zero, failing operation gracefully"); } return 1; } - if(a > INT_MAX / b) { - if (!silent) { + if (a > INT_MAX / b) + { + if (!silent) + { php_error_docref(NULL, E_WARNING, "product of memory allocation multiplication would exceed INT_MAX, failing operation gracefully"); } return 1; @@ -65,45 +69,20 @@ zend_bool php_sdl_check_overflow(int a, int b, int silent) } /* }}} */ - #define PHP_MINIT_CALL(func) PHP_MINIT(func)(INIT_FUNC_ARGS_PASSTHRU) #define PHP_MSHUTDOWN_CALL(func) PHP_MSHUTDOWN(func)(SHUTDOWN_FUNC_ARGS_PASSTHRU) /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(sdl) { - if ( SUCCESS == PHP_MINIT_CALL(sdl_blendmode) - && SUCCESS == PHP_MINIT_CALL(sdl_cpuinfo) - && SUCCESS == PHP_MINIT_CALL(sdl_error) - && SUCCESS == PHP_MINIT_CALL(sdl_event) - && SUCCESS == PHP_MINIT_CALL(sdl_glcontext) - && SUCCESS == PHP_MINIT_CALL(sdl_keyboard) - && SUCCESS == PHP_MINIT_CALL(sdl_messagebox) - && SUCCESS == PHP_MINIT_CALL(sdl_mouse) - && SUCCESS == PHP_MINIT_CALL(sdl_mutex) - && SUCCESS == PHP_MINIT_CALL(sdl_platform) - && SUCCESS == PHP_MINIT_CALL(sdl_power) - && SUCCESS == PHP_MINIT_CALL(sdl_filesystem) - && SUCCESS == PHP_MINIT_CALL(sdl_pixels) - && SUCCESS == PHP_MINIT_CALL(sdl_rect) - && SUCCESS == PHP_MINIT_CALL(sdl_render) - && SUCCESS == PHP_MINIT_CALL(sdl_rwops) - && SUCCESS == PHP_MINIT_CALL(sdl_sdl) - && SUCCESS == PHP_MINIT_CALL(sdl_shape) - && SUCCESS == PHP_MINIT_CALL(sdl_surface) - && SUCCESS == PHP_MINIT_CALL(sdl_timer) - && SUCCESS == PHP_MINIT_CALL(sdl_version) - && SUCCESS == PHP_MINIT_CALL(sdl_video) - && SUCCESS == PHP_MINIT_CALL(sdl_window) - && SUCCESS == PHP_MINIT_CALL(sdl_joystick) - ) { + if (SUCCESS == PHP_MINIT_CALL(sdl_blendmode) && SUCCESS == PHP_MINIT_CALL(sdl_cpuinfo) && SUCCESS == PHP_MINIT_CALL(sdl_error) && SUCCESS == PHP_MINIT_CALL(sdl_event) && SUCCESS == PHP_MINIT_CALL(sdl_glcontext) && SUCCESS == PHP_MINIT_CALL(sdl_keyboard) && SUCCESS == PHP_MINIT_CALL(sdl_messagebox) && SUCCESS == PHP_MINIT_CALL(sdl_mouse) && SUCCESS == PHP_MINIT_CALL(sdl_mutex) && SUCCESS == PHP_MINIT_CALL(sdl_platform) && SUCCESS == PHP_MINIT_CALL(sdl_power) && SUCCESS == PHP_MINIT_CALL(sdl_filesystem) && SUCCESS == PHP_MINIT_CALL(sdl_pixels) && SUCCESS == PHP_MINIT_CALL(sdl_rect) && SUCCESS == PHP_MINIT_CALL(sdl_render) && SUCCESS == PHP_MINIT_CALL(sdl_rwops) && SUCCESS == PHP_MINIT_CALL(sdl_sdl) && SUCCESS == PHP_MINIT_CALL(sdl_shape) && SUCCESS == PHP_MINIT_CALL(sdl_surface) && SUCCESS == PHP_MINIT_CALL(sdl_timer) && SUCCESS == PHP_MINIT_CALL(sdl_version) && SUCCESS == PHP_MINIT_CALL(sdl_video) && SUCCESS == PHP_MINIT_CALL(sdl_window) && SUCCESS == PHP_MINIT_CALL(sdl_joystick)) + { return SUCCESS; } return FAILURE; } /* }}} */ - /* {{{ PHP_MSHUTDOWN_FUNCTION */ PHP_MSHUTDOWN_FUNCTION(sdl) { @@ -148,58 +127,58 @@ static zend_function_entry sdl_functions[] = { ZEND_FE(SDL_WasInit, arginfo_SDL_WasInit) // Window - ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow) - ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow) - ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window) - ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle) - ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window) - ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window) - ZEND_FE(SDL_HideWindow, arginfo_SDL_Window) - ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window) - ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window) - ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window) - ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode) - ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode) - ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon) - ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered) - ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen) - ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects) - ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab) - ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness) - ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp) - ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape) - ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode) - - ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) - ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) + ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow) + ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow) + ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window) + ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle) + ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window) + ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window) + ZEND_FE(SDL_HideWindow, arginfo_SDL_Window) + ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window) + ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window) + ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window) + ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode) + ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode) + ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon) + ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered) + ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen) + ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects) + ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab) + ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness) + ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp) + ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape) + ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode) + + ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) + ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) // Version - ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none) + ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none) #ifdef HAVE_SDL_GETREVISIONNUMBER - ZEND_DEP_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none) + ZEND_DEP_FE(SDL_GetRevisionNumber, arginfo_sdl_version_none) #endif - ZEND_FE(SDL_GetVersion, arginfo_SDL_GetVersion) - ZEND_FE(SDL_VERSION, arginfo_SDL_VERSION) - ZEND_FE(SDL_VERSIONNUM, arginfo_SDL_VERSIONNUM) - ZEND_FE(SDL_VERSION_ATLEAST, arginfo_SDL_VERSION_ATLEAST) + ZEND_FE(SDL_GetVersion, arginfo_SDL_GetVersion) + ZEND_FE(SDL_VERSION, arginfo_SDL_VERSION) + ZEND_FE(SDL_VERSIONNUM, arginfo_SDL_VERSIONNUM) + ZEND_FE(SDL_VERSION_ATLEAST, arginfo_SDL_VERSION_ATLEAST) // Timer ZEND_FE(SDL_Delay, arginfo_SDL_Delay) @@ -231,237 +210,233 @@ static zend_function_entry sdl_functions[] = { ZEND_FE(SDL_RenderCopyExF, arginfo_SDL_RenderCopyExF) // Surface - ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface) - ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface) - ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect) - ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects) - ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface) - ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface) - ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface) - ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW) - ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP) - ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit) - ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit) - ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) - ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit) - ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit) - ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW) - ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP) - ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE) - ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey) - ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey) - ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod) - ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod) - ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod) - ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod) - ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode) - ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode) - ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect) - ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect) - ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface) - ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat) - ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels) - //PHP_FALIAS(SDL_BlitSurface, SDL_UpperBlit, arginfo_SDL_UpperBlit) - //PHP_FALIAS(SDL_BlitScaled, SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface) + ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface) + ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect) + ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects) + ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface) + ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface) + ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface) + ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW) + ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP) + ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit) + ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit) + ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW) + ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP) + ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE) + ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey) + ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey) + ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod) + ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod) + ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod) + ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod) + ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode) + ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode) + ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect) + ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect) + ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface) + ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat) + ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels) // Events ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent) - ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent) + ZEND_FE(SDL_PollEvent, arginfo_SDL_PollEvent) // Message box - ZEND_FE(SDL_ShowSimpleMessageBox, arginfo_SDL_ShowSimpleMessageBox) - ZEND_FE(SDL_ShowMessageBox, arginfo_SDL_ShowMessageBox) + ZEND_FE(SDL_ShowSimpleMessageBox, arginfo_SDL_ShowSimpleMessageBox) + ZEND_FE(SDL_ShowMessageBox, arginfo_SDL_ShowMessageBox) // Pixels - ZEND_FE(SDL_GetPixelFormatName, arginfo_SDL_GetPixelFormatName) - ZEND_FE(SDL_PixelFormatEnumToMasks, arginfo_SDL_PixelFormatEnumToMasks) - ZEND_FE(SDL_MasksToPixelFormatEnum, arginfo_SDL_MasksToPixelFormatEnum) - - ZEND_FE(SDL_AllocPalette, arginfo_SDL_AllocPalette) - ZEND_FE(SDL_FreePalette, arginfo_SDL_Palette) - ZEND_FE(SDL_SetPaletteColors, arginfo_SDL_SetPaletteColors) - - ZEND_FE(SDL_AllocFormat, arginfo_SDL_AllocFormat) - ZEND_FE(SDL_FreeFormat, arginfo_SDL_PixelFormat) - ZEND_FE(SDL_SetPixelFormatPalette, arginfo_SDL_SetPixelFormatPalette) - ZEND_FE(SDL_MapRGB, arginfo_SDL_MapRGB) - ZEND_FE(SDL_MapRGBA, arginfo_SDL_MapRGBA) - ZEND_FE(SDL_GetRGB, arginfo_SDL_GetRGB) - ZEND_FE(SDL_GetRGBA, arginfo_SDL_GetRGBA) - ZEND_FE(SDL_CalculateGammaRamp, arginfo_SDL_CalculateGammaRamp) + ZEND_FE(SDL_GetPixelFormatName, arginfo_SDL_GetPixelFormatName) + ZEND_FE(SDL_PixelFormatEnumToMasks, arginfo_SDL_PixelFormatEnumToMasks) + ZEND_FE(SDL_MasksToPixelFormatEnum, arginfo_SDL_MasksToPixelFormatEnum) + + ZEND_FE(SDL_AllocPalette, arginfo_SDL_AllocPalette) + ZEND_FE(SDL_FreePalette, arginfo_SDL_Palette) + ZEND_FE(SDL_SetPaletteColors, arginfo_SDL_SetPaletteColors) + + ZEND_FE(SDL_AllocFormat, arginfo_SDL_AllocFormat) + ZEND_FE(SDL_FreeFormat, arginfo_SDL_PixelFormat) + ZEND_FE(SDL_SetPixelFormatPalette, arginfo_SDL_SetPixelFormatPalette) + ZEND_FE(SDL_MapRGB, arginfo_SDL_MapRGB) + ZEND_FE(SDL_MapRGBA, arginfo_SDL_MapRGBA) + ZEND_FE(SDL_GetRGB, arginfo_SDL_GetRGB) + ZEND_FE(SDL_GetRGBA, arginfo_SDL_GetRGBA) + ZEND_FE(SDL_CalculateGammaRamp, arginfo_SDL_CalculateGammaRamp) // Filesystem ZEND_FE(SDL_GetBasePath, arginfo_SDL_GetBasePath) - ZEND_FE(SDL_GetPrefPath, arginfo_SDL_GetPrefPath) + ZEND_FE(SDL_GetPrefPath, arginfo_SDL_GetPrefPath) // GL - ZEND_FE(SDL_GL_ExtensionSupported, arginfo_SDL_GL_ExtensionSupported) - ZEND_FE(SDL_GL_SetAttribute, arginfo_SDL_GL_SetAttribute) - ZEND_FE(SDL_GL_GetAttribute, arginfo_SDL_GL_GetAttribute) - ZEND_FE(SDL_GL_CreateContext, arginfo_SDL_GLContext__construct) - ZEND_FE(SDL_GL_DeleteContext, arginfo_SDL_GL_DeleteContext) - ZEND_FE(SDL_GL_MakeCurrent, arginfo_SDL_GL_MakeCurrent) - ZEND_FE(SDL_GL_GetCurrentWindow, arginfo_none) - ZEND_FE(SDL_GL_GetCurrentContext, arginfo_none) -#if SDL_VERSION_ATLEAST(2,0,1) - ZEND_FE(SDL_GL_GetDrawableSize, arginfo_SDL_GL_GetDrawableSize) + ZEND_FE(SDL_GL_ExtensionSupported, arginfo_SDL_GL_ExtensionSupported) + ZEND_FE(SDL_GL_SetAttribute, arginfo_SDL_GL_SetAttribute) + ZEND_FE(SDL_GL_GetAttribute, arginfo_SDL_GL_GetAttribute) + ZEND_FE(SDL_GL_CreateContext, arginfo_SDL_GLContext__construct) + ZEND_FE(SDL_GL_DeleteContext, arginfo_SDL_GL_DeleteContext) + ZEND_FE(SDL_GL_MakeCurrent, arginfo_SDL_GL_MakeCurrent) + ZEND_FE(SDL_GL_GetCurrentWindow, arginfo_none) + ZEND_FE(SDL_GL_GetCurrentContext, arginfo_none) +#if SDL_VERSION_ATLEAST(2, 0, 1) + ZEND_FE(SDL_GL_GetDrawableSize, arginfo_SDL_GL_GetDrawableSize) #endif - ZEND_FE(SDL_GL_SwapWindow, arginfo_SDL_Window) - ZEND_FE(SDL_GL_SetSwapInterval, arginfo_SDL_GL_SetSwapInterval) - ZEND_FE(SDL_GL_GetSwapInterval, arginfo_none) + ZEND_FE(SDL_GL_SwapWindow, arginfo_SDL_Window) + ZEND_FE(SDL_GL_SetSwapInterval, arginfo_SDL_GL_SetSwapInterval) + ZEND_FE(SDL_GL_GetSwapInterval, arginfo_none) // CPU info - ZEND_FE(SDL_GetCPUCount, arginfo_cpuinfo_none) - ZEND_FE(SDL_GetCPUCacheLineSize, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasRDTSC, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasAltiVec, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasMMX, arginfo_cpuinfo_none) - ZEND_FE(SDL_Has3DNow, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasSSE, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasSSE2, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasSSE3, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasSSE41, arginfo_cpuinfo_none) - ZEND_FE(SDL_HasSSE42, arginfo_cpuinfo_none) + ZEND_FE(SDL_GetCPUCount, arginfo_cpuinfo_none) + ZEND_FE(SDL_GetCPUCacheLineSize, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasRDTSC, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasAltiVec, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasMMX, arginfo_cpuinfo_none) + ZEND_FE(SDL_Has3DNow, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasSSE, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasSSE2, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasSSE3, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasSSE41, arginfo_cpuinfo_none) + ZEND_FE(SDL_HasSSE42, arginfo_cpuinfo_none) #if SDL_COMPILEDVERSION > 2000 - ZEND_FE(SDL_GetSystemRAM, arginfo_cpuinfo_none) + ZEND_FE(SDL_GetSystemRAM, arginfo_cpuinfo_none) #endif // Error handling - ZEND_FE(SDL_SetError, arginfo_SDL_SetError) - ZEND_FE(SDL_GetError, arginfo_error_none) - ZEND_FE(SDL_ClearError, arginfo_error_none) + ZEND_FE(SDL_SetError, arginfo_SDL_SetError) + ZEND_FE(SDL_GetError, arginfo_error_none) + ZEND_FE(SDL_ClearError, arginfo_error_none) // Video - ZEND_FE(SDL_GetNumVideoDrivers, arginfo_video_none) - ZEND_FE(SDL_GetVideoDriver, arginfo_SDL_GetVideoDriver) - ZEND_FE(SDL_VideoInit, arginfo_SDL_VideoInit) - ZEND_FE(SDL_VideoQuit, arginfo_video_none) - ZEND_FE(SDL_GetCurrentVideoDriver, arginfo_video_none) - ZEND_FE(SDL_GetNumVideoDisplays, arginfo_video_none) - ZEND_FE(SDL_GetDisplayName, arginfo_SDL_dysplayindex) - ZEND_FE(SDL_GetDisplayBounds, arginfo_SDL_GetDisplayBounds) - ZEND_FE(SDL_GetNumDisplayModes, arginfo_SDL_dysplayindex) - ZEND_FE(SDL_GetDisplayMode, arginfo_SDL_GetDisplayMode) - ZEND_FE(SDL_GetDesktopDisplayMode, arginfo_SDL_dysplayindex) - ZEND_FE(SDL_GetCurrentDisplayMode, arginfo_SDL_dysplayindex) - ZEND_FE(SDL_GetClosestDisplayMode, arginfo_SDL_GetClosestDisplayMode) - ZEND_FE(SDL_IsScreenSaverEnabled, arginfo_video_none) - ZEND_FE(SDL_EnableScreenSaver, arginfo_video_none) - ZEND_FE(SDL_DisableScreenSaver, arginfo_video_none) + ZEND_FE(SDL_GetNumVideoDrivers, arginfo_video_none) + ZEND_FE(SDL_GetVideoDriver, arginfo_SDL_GetVideoDriver) + ZEND_FE(SDL_VideoInit, arginfo_SDL_VideoInit) + ZEND_FE(SDL_VideoQuit, arginfo_video_none) + ZEND_FE(SDL_GetCurrentVideoDriver, arginfo_video_none) + ZEND_FE(SDL_GetNumVideoDisplays, arginfo_video_none) + ZEND_FE(SDL_GetDisplayName, arginfo_SDL_dysplayindex) + ZEND_FE(SDL_GetDisplayBounds, arginfo_SDL_GetDisplayBounds) + ZEND_FE(SDL_GetNumDisplayModes, arginfo_SDL_dysplayindex) + ZEND_FE(SDL_GetDisplayMode, arginfo_SDL_GetDisplayMode) + ZEND_FE(SDL_GetDesktopDisplayMode, arginfo_SDL_dysplayindex) + ZEND_FE(SDL_GetCurrentDisplayMode, arginfo_SDL_dysplayindex) + ZEND_FE(SDL_GetClosestDisplayMode, arginfo_SDL_GetClosestDisplayMode) + ZEND_FE(SDL_IsScreenSaverEnabled, arginfo_video_none) + ZEND_FE(SDL_EnableScreenSaver, arginfo_video_none) + ZEND_FE(SDL_DisableScreenSaver, arginfo_video_none) // Power - ZEND_FE(SDL_GetPowerInfo, arginfo_SDL_GetPowerInfo) + ZEND_FE(SDL_GetPowerInfo, arginfo_SDL_GetPowerInfo) // Platform - ZEND_FE(SDL_GetPlatform, arginfo_SDL_GetPlatform) + ZEND_FE(SDL_GetPlatform, arginfo_SDL_GetPlatform) // Keyboard - ZEND_FE(SDL_GetKeyboardFocus, arginfo_none) - ZEND_FE(SDL_GetKeyboardState, arginfo_SDL_GetKeyboardState) - ZEND_FE(SDL_GetModState, arginfo_none) - ZEND_FE(SDL_SetModState, arginfo_SDL_SetModState) - ZEND_FE(SDL_GetKeyFromScancode, arginfo_scancode) - ZEND_FE(SDL_GetScancodeFromKey, arginfo_key) - ZEND_FE(SDL_GetScancodeName, arginfo_scancode) - ZEND_FE(SDL_GetScancodeFromName, arginfo_name) - ZEND_FE(SDL_GetKeyName, arginfo_key) - ZEND_FE(SDL_GetKeyFromName, arginfo_name) - ZEND_FE(SDL_StartTextInput, arginfo_none) - ZEND_FE(SDL_IsTextInputActive, arginfo_none) - ZEND_FE(SDL_StopTextInput, arginfo_none) - ZEND_FE(SDL_SetTextInputRect, arginfo_SDL_SetTextInputRect) - ZEND_FE(SDL_HasScreenKeyboardSupport, arginfo_none) - ZEND_FE(SDL_IsScreenKeyboardShown, arginfo_SDL_IsScreenKeyboardShown) + ZEND_FE(SDL_GetKeyboardFocus, arginfo_none) + ZEND_FE(SDL_GetKeyboardState, arginfo_SDL_GetKeyboardState) + ZEND_FE(SDL_GetModState, arginfo_none) + ZEND_FE(SDL_SetModState, arginfo_SDL_SetModState) + ZEND_FE(SDL_GetKeyFromScancode, arginfo_scancode) + ZEND_FE(SDL_GetScancodeFromKey, arginfo_key) + ZEND_FE(SDL_GetScancodeName, arginfo_scancode) + ZEND_FE(SDL_GetScancodeFromName, arginfo_name) + ZEND_FE(SDL_GetKeyName, arginfo_key) + ZEND_FE(SDL_GetKeyFromName, arginfo_name) + ZEND_FE(SDL_StartTextInput, arginfo_none) + ZEND_FE(SDL_IsTextInputActive, arginfo_none) + ZEND_FE(SDL_StopTextInput, arginfo_none) + ZEND_FE(SDL_SetTextInputRect, arginfo_SDL_SetTextInputRect) + ZEND_FE(SDL_HasScreenKeyboardSupport, arginfo_none) + ZEND_FE(SDL_IsScreenKeyboardShown, arginfo_SDL_IsScreenKeyboardShown) // Mouse/Cursor - ZEND_FE(SDL_CreateCursor, arginfo_SDL_Cursor__construct) - ZEND_FE(SDL_CreateSystemCursor, arginfo_SDL_CreateSystemCursor) - ZEND_FE(SDL_CreateColorCursor, arginfo_SDL_CreateColorCursor) - ZEND_FE(SDL_FreeCursor, arginfo_SDL_Cursor) - ZEND_FE(SDL_SetCursor, arginfo_SDL_Cursor) - ZEND_FE(SDL_GetCursor, arginfo_none) - ZEND_FE(SDL_GetDefaultCursor, arginfo_none) - ZEND_FE(SDL_ShowCursor, arginfo_SDL_ShowCursor) - ZEND_FE(SDL_GetMouseFocus, arginfo_none) - ZEND_FE(SDL_GetMouseState, arginfo_SDL_GetMouseState) - ZEND_FE(SDL_GetRelativeMouseState, arginfo_SDL_GetMouseState) - ZEND_FE(SDL_WarpMouseInWindow, arginfo_SDL_WarpMouseInWindow) - ZEND_FE(SDL_SetRelativeMouseMode, arginfo_SDL_SetRelativeMouseMode) - ZEND_FE(SDL_GetRelativeMouseMode, arginfo_none) + ZEND_FE(SDL_CreateCursor, arginfo_SDL_Cursor__construct) + ZEND_FE(SDL_CreateSystemCursor, arginfo_SDL_CreateSystemCursor) + ZEND_FE(SDL_CreateColorCursor, arginfo_SDL_CreateColorCursor) + ZEND_FE(SDL_FreeCursor, arginfo_SDL_Cursor) + ZEND_FE(SDL_SetCursor, arginfo_SDL_Cursor) + ZEND_FE(SDL_GetCursor, arginfo_none) + ZEND_FE(SDL_GetDefaultCursor, arginfo_none) + ZEND_FE(SDL_ShowCursor, arginfo_SDL_ShowCursor) + ZEND_FE(SDL_GetMouseFocus, arginfo_none) + ZEND_FE(SDL_GetMouseState, arginfo_SDL_GetMouseState) + ZEND_FE(SDL_GetRelativeMouseState, arginfo_SDL_GetMouseState) + ZEND_FE(SDL_WarpMouseInWindow, arginfo_SDL_WarpMouseInWindow) + ZEND_FE(SDL_SetRelativeMouseMode, arginfo_SDL_SetRelativeMouseMode) + ZEND_FE(SDL_GetRelativeMouseMode, arginfo_none) // Mutex - ZEND_FE(SDL_CreateMutex, arginfo_none) - ZEND_FE(SDL_LockMutex, arginfo_SDL_mutex) - ZEND_FE(SDL_TryLockMutex, arginfo_SDL_mutex) - ZEND_FE(SDL_UnlockMutex, arginfo_SDL_mutex) - ZEND_FE(SDL_DestroyMutex, arginfo_SDL_mutex) + ZEND_FE(SDL_CreateMutex, arginfo_none) + ZEND_FE(SDL_LockMutex, arginfo_SDL_mutex) + ZEND_FE(SDL_TryLockMutex, arginfo_SDL_mutex) + ZEND_FE(SDL_UnlockMutex, arginfo_SDL_mutex) + ZEND_FE(SDL_DestroyMutex, arginfo_SDL_mutex) /* mutex aliases */ - PHP_FALIAS(SDL_mutexP, SDL_LockMutex, arginfo_SDL_mutex) - PHP_FALIAS(SDL_mutexV, SDL_UnlockMutex, arginfo_SDL_mutex) + PHP_FALIAS(SDL_mutexP, SDL_LockMutex, arginfo_SDL_mutex) + PHP_FALIAS(SDL_mutexV, SDL_UnlockMutex, arginfo_SDL_mutex) /* semaphore functions */ - ZEND_FE(SDL_CreateSemaphore, arginfo_SDL_sem__construct) - ZEND_FE(SDL_SemWait, arginfo_SDL_sem) - ZEND_FE(SDL_SemTryWait, arginfo_SDL_sem) - ZEND_FE(SDL_SemPost, arginfo_SDL_sem) - ZEND_FE(SDL_SemValue, arginfo_SDL_sem) - ZEND_FE(SDL_SemWaitTimeout, arginfo_SDL_SemWaitTimeout) - ZEND_FE(SDL_DestroySemaphore, arginfo_SDL_sem) + ZEND_FE(SDL_CreateSemaphore, arginfo_SDL_sem__construct) + ZEND_FE(SDL_SemWait, arginfo_SDL_sem) + ZEND_FE(SDL_SemTryWait, arginfo_SDL_sem) + ZEND_FE(SDL_SemPost, arginfo_SDL_sem) + ZEND_FE(SDL_SemValue, arginfo_SDL_sem) + ZEND_FE(SDL_SemWaitTimeout, arginfo_SDL_SemWaitTimeout) + ZEND_FE(SDL_DestroySemaphore, arginfo_SDL_sem) /* condition functions */ - ZEND_FE(SDL_CreateCond, arginfo_none) - ZEND_FE(SDL_CondWait, arginfo_SDL_CondWait) - ZEND_FE(SDL_CondSignal, arginfo_SDL_cond) - ZEND_FE(SDL_CondBroadcast, arginfo_SDL_cond) - ZEND_FE(SDL_CondWaitTimeout, arginfo_SDL_CondWaitTimeout) - ZEND_FE(SDL_DestroyCond, arginfo_SDL_cond) + ZEND_FE(SDL_CreateCond, arginfo_none) + ZEND_FE(SDL_CondWait, arginfo_SDL_CondWait) + ZEND_FE(SDL_CondSignal, arginfo_SDL_cond) + ZEND_FE(SDL_CondBroadcast, arginfo_SDL_cond) + ZEND_FE(SDL_CondWaitTimeout, arginfo_SDL_CondWaitTimeout) + ZEND_FE(SDL_DestroyCond, arginfo_SDL_cond) // Joystick ZEND_FE(SDL_NumJoysticks, arginfo_SDL_NumJoysticks) - ZEND_FE(SDL_JoystickOpen, arginfo_SDL_JoystickOpen) - ZEND_FE(SDL_JoystickClose, arginfo_SDL_JoystickClose) - ZEND_FE(SDL_JoystickNumButtons, arginfo_SDL_JoystickNumButtons) - ZEND_FE(SDL_JoystickName, arginfo_SDL_JoystickName) - ZEND_FE(SDL_JoystickGetAxis, arginfo_SDL_JoystickGetAxis) - ZEND_FE(SDL_JoystickNameForIndex, arginfo_SDL_JoystickNameForIndex) - ZEND_FE(SDL_IsGameController, arginfo_SDL_IsGameController) + ZEND_FE(SDL_JoystickOpen, arginfo_SDL_JoystickOpen) + ZEND_FE(SDL_JoystickClose, arginfo_SDL_JoystickClose) + ZEND_FE(SDL_JoystickNumButtons, arginfo_SDL_JoystickNumButtons) + ZEND_FE(SDL_JoystickName, arginfo_SDL_JoystickName) + ZEND_FE(SDL_JoystickGetAxis, arginfo_SDL_JoystickGetAxis) + ZEND_FE(SDL_JoystickNameForIndex, arginfo_SDL_JoystickNameForIndex) + ZEND_FE(SDL_IsGameController, arginfo_SDL_IsGameController) // Rwops - ZEND_FE(SDL_AllocRW, arginfo_none) - ZEND_FE(SDL_FreeRW, arginfo_SDL_RWops) - ZEND_FE(SDL_RWFromFile, arginfo_SDL_RWFromFile) - ZEND_FE(SDL_RWFromFP, arginfo_SDL_RWFromFP) - ZEND_FE(SDL_RWFromMem, arginfo_SDL_RWFromMem) - ZEND_FE(SDL_RWFromConstMem, arginfo_SDL_RWFromConstMem) - ZEND_FE(SDL_RWsize, arginfo_SDL_RWops) - ZEND_FE(SDL_RWseek, arginfo_SDL_RWseek) - ZEND_FE(SDL_RWtell, arginfo_SDL_RWops) - ZEND_FE(SDL_RWread, arginfo_SDL_RWread) - ZEND_FE(SDL_RWwrite, arginfo_SDL_RWwrite) - ZEND_FE(SDL_RWclose, arginfo_SDL_RWops) - ZEND_FE(SDL_ReadU8, arginfo_SDL_RWops) - ZEND_FE(SDL_ReadLE16, arginfo_SDL_RWops) - ZEND_FE(SDL_ReadBE16, arginfo_SDL_RWops) - ZEND_FE(SDL_ReadLE32, arginfo_SDL_RWops) - ZEND_FE(SDL_ReadBE32, arginfo_SDL_RWops) + ZEND_FE(SDL_AllocRW, arginfo_none) + ZEND_FE(SDL_FreeRW, arginfo_SDL_RWops) + ZEND_FE(SDL_RWFromFile, arginfo_SDL_RWFromFile) + ZEND_FE(SDL_RWFromFP, arginfo_SDL_RWFromFP) + ZEND_FE(SDL_RWFromMem, arginfo_SDL_RWFromMem) + ZEND_FE(SDL_RWFromConstMem, arginfo_SDL_RWFromConstMem) + ZEND_FE(SDL_RWsize, arginfo_SDL_RWops) + ZEND_FE(SDL_RWseek, arginfo_SDL_RWseek) + ZEND_FE(SDL_RWtell, arginfo_SDL_RWops) + ZEND_FE(SDL_RWread, arginfo_SDL_RWread) + ZEND_FE(SDL_RWwrite, arginfo_SDL_RWwrite) + ZEND_FE(SDL_RWclose, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadU8, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadLE16, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadBE16, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadLE32, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadBE32, arginfo_SDL_RWops) #if SIZEOF_LONG > 4 - ZEND_FE(SDL_ReadLE64, arginfo_SDL_RWops) - ZEND_FE(SDL_ReadBE64, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadLE64, arginfo_SDL_RWops) + ZEND_FE(SDL_ReadBE64, arginfo_SDL_RWops) #endif - ZEND_FE(SDL_WriteU8, arginfo_SDL_write) - ZEND_FE(SDL_WriteLE16, arginfo_SDL_write) - ZEND_FE(SDL_WriteBE16, arginfo_SDL_write) - ZEND_FE(SDL_WriteLE32, arginfo_SDL_write) - ZEND_FE(SDL_WriteBE32, arginfo_SDL_write) + ZEND_FE(SDL_WriteU8, arginfo_SDL_write) + ZEND_FE(SDL_WriteLE16, arginfo_SDL_write) + ZEND_FE(SDL_WriteBE16, arginfo_SDL_write) + ZEND_FE(SDL_WriteLE32, arginfo_SDL_write) + ZEND_FE(SDL_WriteBE32, arginfo_SDL_write) #if SIZEOF_LONG > 4 - ZEND_FE(SDL_WriteLE64, arginfo_SDL_write) - ZEND_FE(SDL_WriteBE64, arginfo_SDL_write) + ZEND_FE(SDL_WriteLE64, arginfo_SDL_write) + ZEND_FE(SDL_WriteBE64, arginfo_SDL_write) #endif - - ZEND_FE_END -}; + ZEND_FE_END}; /* }}} */ /* {{{ sdl_module_entry @@ -472,14 +447,13 @@ zend_module_entry sdl_module_entry = { NULL, "SDL", sdl_functions, - PHP_MINIT(sdl), /* Replace with NULL if there is nothing to do at php startup */ + PHP_MINIT(sdl), /* Replace with NULL if there is nothing to do at php startup */ PHP_MSHUTDOWN(sdl), /* Replace with NULL if there is nothing to do at php shutdown */ - NULL, /* RINIT */ - NULL, /* RSHUTDOWN */ + NULL, /* RINIT */ + NULL, /* RSHUTDOWN */ PHP_MINFO(sdl), PHP_SDL_VERSION, - STANDARD_MODULE_PROPERTIES -}; + STANDARD_MODULE_PROPERTIES}; /* }}} */ /* diff --git a/src/pixels.c b/src/pixels.c index 3568551..9f49dd7 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -295,6 +295,9 @@ static PHP_METHOD(SDL_Color, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Color___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_Color::__toString() */ static PHP_METHOD(SDL_Color, __toString) { @@ -453,6 +456,9 @@ static PHP_METHOD(SDL_PixelFormat, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_PixelFormat___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_PixelFormat::__toString() */ static PHP_METHOD(SDL_PixelFormat, __toString) { @@ -547,6 +553,9 @@ static PHP_METHOD(SDL_Palette, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Palette___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_Palette::__toString() */ static PHP_METHOD(SDL_Palette, __toString) { @@ -1055,6 +1064,9 @@ static PHP_METHOD(SDL_Pixels, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Pixels___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_Pixels::__toString() */ static PHP_METHOD(SDL_Pixels, __toString) { @@ -1636,7 +1648,7 @@ static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, z /* {{{ php_sdl_color_methods[] */ static const zend_function_entry php_sdl_color_methods[] = { PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) - PHP_ME(SDL_Color, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Color, __toString, arginfo_class_SDL_Color___toString, ZEND_ACC_PUBLIC) PHP_FE_END}; /* }}} */ @@ -1644,12 +1656,12 @@ static const zend_function_entry php_sdl_color_methods[] = { /* {{{ php_sdl_palette_methods[] */ static const zend_function_entry php_sdl_palette_methods[] = { PHP_ME(SDL_Palette, __construct, arginfo_SDL_AllocPalette, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, __toString, arginfo_class_SDL_Palette___toString, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, count, arginfo_palette_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetExists, arginfo_SDL_Palette_offsetExists, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetGet, arginfo_SDL_Palette_offsetGet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetSet, arginfo_SDL_Palette_offsetSet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Palette, offsetUnset, arginfo_SDL_Palette_offsetUnset, ZEND_ACC_PUBLIC) /* non-static methods */ PHP_FALIAS(Free, SDL_FreePalette, arginfo_palette_none) @@ -1661,9 +1673,9 @@ static const zend_function_entry php_sdl_palette_methods[] = { /* {{{ php_sdl_pixelformat_methods[] */ static const zend_function_entry php_sdl_pixelformat_methods[] = { PHP_ME(SDL_PixelFormat, __construct, arginfo_SDL_AllocFormat, ZEND_ACC_PUBLIC) - PHP_ME(SDL_PixelFormat, __toString, arginfo_palette_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC) - PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, __toString, arginfo_class_SDL_PixelFormat___toString, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, GetRGB, arginfo_SDL_PixelFormat_GetRGB, ZEND_ACC_PUBLIC) + PHP_ME(SDL_PixelFormat, GetRGBA, arginfo_SDL_PixelFormat_GetRGBA, ZEND_ACC_PUBLIC) /* non-static methods */ PHP_FALIAS(Free, SDL_FreeFormat, arginfo_format_none) @@ -1677,15 +1689,15 @@ static const zend_function_entry php_sdl_pixelformat_methods[] = { /* {{{ php_sdl_pixels_methods[] */ static const zend_function_entry php_sdl_pixels_methods[] = { PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, __toString, arginfo_format_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC) - PHP_FE_END}; + PHP_ME(SDL_Pixels, __toString, arginfo_class_SDL_Pixels___toString, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC) + PHP_FE_END}; /* }}} */ #define REGISTER_COLOR_PROP(name) \ diff --git a/src/rwops.c b/src/rwops.c index af3609b..87485cb 100644 --- a/src/rwops.c +++ b/src/rwops.c @@ -142,6 +142,9 @@ static PHP_METHOD(SDL_RWops, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_RWops___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_RWops::__toString() */ static PHP_METHOD(SDL_RWops, __toString) { @@ -812,7 +815,7 @@ ZEND_END_ARG_INFO() /* {{{ sdl_rwops_methods[] */ static const zend_function_entry php_sdl_rwops_methods[] = { PHP_ME(SDL_RWops, __construct, arginfo_rwops_none, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_RWops, __toString, arginfo_rwops_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_RWops, __toString, arginfo_class_SDL_RWops___toString, ZEND_ACC_PUBLIC) /* non-static methods */ PHP_FALIAS(Free, SDL_FreeRW, arginfo_rwops_none) diff --git a/src/shape.c b/src/shape.c index 2bdf8ec..58c6bd5 100644 --- a/src/shape.c +++ b/src/shape.c @@ -138,6 +138,8 @@ static PHP_METHOD(SDL_WindowShapeMode, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_WindowShapeMode___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() /* {{{ proto SDL_WindowShapeMode::__toString() */ static PHP_METHOD(SDL_WindowShapeMode, __toString) @@ -172,14 +174,10 @@ static PHP_METHOD(SDL_WindowShapeMode, __toString) } /* }}} */ -/* generic arginfo */ -ZEND_BEGIN_ARG_INFO_EX(arginfo_none, 0, 0, 0) -ZEND_END_ARG_INFO() - /* {{{ php_sdl_windowshapemode_methods[] */ static const zend_function_entry php_sdl_windowshapemode_methods[] = { PHP_ME(SDL_WindowShapeMode, __construct, arginfo_SDL_WindowShapeMode__construct, ZEND_ACC_CTOR|ZEND_ACC_PUBLIC) - PHP_ME(SDL_WindowShapeMode, __toString, arginfo_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_WindowShapeMode, __toString, arginfo_class_SDL_WindowShapeMode___toString, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/src/surface.c b/src/surface.c index 76a17f6..ce6f8bb 100644 --- a/src/surface.c +++ b/src/surface.c @@ -211,6 +211,9 @@ static PHP_METHOD(SDL_Surface, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Surface___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_Surface::__toString() */ static PHP_METHOD(SDL_Surface, __toString) { @@ -1265,7 +1268,7 @@ PHP_FUNCTION(SDL_ConvertPixels) static const zend_function_entry php_sdl_surface_methods[] = { PHP_ME(SDL_Surface, __construct, arginfo_SDL_CreateRGBSurface, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) - PHP_ME(SDL_Surface, __toString, arginfo_surface_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Surface, __toString, arginfo_class_SDL_Surface___toString, ZEND_ACC_PUBLIC) /* non-static methods */ PHP_FALIAS(Free, SDL_FreeSurface, arginfo_surface_none) diff --git a/src/video.c b/src/video.c index 7e8315d..c77e508 100644 --- a/src/video.c +++ b/src/video.c @@ -109,6 +109,9 @@ static PHP_METHOD(SDL_DisplayMode, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_DisplayMode___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_DisplayMode::__toString() */ static PHP_METHOD(SDL_DisplayMode, __toString) { @@ -525,7 +528,7 @@ PHP_FUNCTION(SDL_DisableScreenSaver) /* {{{ php_sdl_displaymode_methods[] */ static const zend_function_entry php_sdl_displaymode_methods[] = { PHP_ME(SDL_DisplayMode, __construct, arginfo_SDL_DisplayMode__construct, ZEND_ACC_PUBLIC) - PHP_ME(SDL_DisplayMode, __toString, arginfo_video_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_DisplayMode, __toString, arginfo_class_SDL_DisplayMode___toString, ZEND_ACC_PUBLIC) PHP_FE_END }; diff --git a/src/window.c b/src/window.c index 83d28b1..8ea9c11 100644 --- a/src/window.c +++ b/src/window.c @@ -1190,6 +1190,9 @@ static PHP_METHOD(SDL_Window, __construct) } /* }}} */ +ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_class_SDL_Window___toString, 0, 0, IS_STRING, 0) +ZEND_END_ARG_INFO() + /* {{{ proto SDL_Window::__toString() */ static PHP_METHOD(SDL_Window, __toString) { @@ -1426,7 +1429,7 @@ PHP_FUNCTION(SDL_GetShapedWindowMode) static const zend_function_entry php_sdl_window_methods[] = { PHP_ME(SDL_Window, __construct, arginfo_SDL_CreateWindow, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) - PHP_ME(SDL_Window, __toString, arginfo_window_none, ZEND_ACC_PUBLIC) + PHP_ME(SDL_Window, __toString, arginfo_class_SDL_Window___toString, ZEND_ACC_PUBLIC) /* non-static functions */ PHP_FALIAS(UpdateSurface, SDL_UpdateWindowSurface, arginfo_window_none) From ee620e64e12265bc523784b2e278dc9e6bd2b30a Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 27 Dec 2022 23:25:54 +0000 Subject: [PATCH 48/55] Add some functions (#69) * SDL_SetHint + SDL_HINT_RENDER_SCALE_QUALITY * SDL_RenderSetLogicalSize * SDL_CreateSoftwareRenderer * SDL_UpdateTexture Co-authored-by: Santiago Lizardo --- examples/005-draw-rectangle.php | 2 + src/php_sdl.c | 144 ++++++++++++++++---------------- src/render.c | 75 +++++++++++++++-- src/render.h | 20 +++++ src/sdl.c | 20 +++++ src/sdl.h | 7 ++ 6 files changed, 189 insertions(+), 79 deletions(-) diff --git a/examples/005-draw-rectangle.php b/examples/005-draw-rectangle.php index a42b230..3fa7611 100644 --- a/examples/005-draw-rectangle.php +++ b/examples/005-draw-rectangle.php @@ -6,6 +6,8 @@ $window = SDL_CreateWindow('Primitive drawing example', SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 480, SDL_WINDOW_SHOWN); $renderer = SDL_CreateRenderer($window, 0, SDL_RENDERER_SOFTWARE); +SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest"); +SDL_RenderSetLogicalSize($renderer, 640, 480); SDL_SetRenderDrawColor($renderer, 255, 0, 0, 255); SDL_RenderClear($renderer); diff --git a/src/php_sdl.c b/src/php_sdl.c index c902860..cadb867 100644 --- a/src/php_sdl.c +++ b/src/php_sdl.c @@ -125,50 +125,51 @@ static zend_function_entry sdl_functions[] = { ZEND_FE(SDL_Quit, arginfo_SDL_Quit) ZEND_FE(SDL_QuitSubSystem, arginfo_SDL_QuitSubSystem) ZEND_FE(SDL_WasInit, arginfo_SDL_WasInit) + ZEND_FE(SDL_SetHint, arginfo_SDL_SetHint) // Window ZEND_FE(SDL_CreateWindow, arginfo_SDL_CreateWindow) - ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow) - ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window) - ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle) - ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window) - ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window) - ZEND_FE(SDL_HideWindow, arginfo_SDL_Window) - ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window) - ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window) - ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window) - ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode) - ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode) - ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon) - ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition) - ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition) - ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered) - ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen) - ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects) - ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab) - ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness) - ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window) - ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp) - ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window) - ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape) - ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode) - - ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) - ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) + ZEND_FE(SDL_CreateShapedWindow, arginfo_SDL_CreateWindow) + ZEND_FE(SDL_DestroyWindow, arginfo_SDL_Window) + ZEND_FE(SDL_UpdateWindowSurface, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowTitle, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowTitle, arginfo_SDL_SetWindowTitle) + ZEND_FE(SDL_GetWindowDisplayIndex, arginfo_SDL_Window) + ZEND_FE(SDL_ShowWindow, arginfo_SDL_Window) + ZEND_FE(SDL_HideWindow, arginfo_SDL_Window) + ZEND_FE(SDL_RaiseWindow, arginfo_SDL_Window) + ZEND_FE(SDL_MaximizeWindow, arginfo_SDL_Window) + ZEND_FE(SDL_MinimizeWindow, arginfo_SDL_Window) + ZEND_FE(SDL_RestoreWindow, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowSurface, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowDisplayMode, arginfo_SDL_SetWindowDisplayMode) + ZEND_FE(SDL_GetWindowDisplayMode, arginfo_SDL_GetWindowDisplayMode) + ZEND_FE(SDL_GetWindowPixelFormat, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowID, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowFlags, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowIcon, arginfo_SDL_SetWindowIcon) + ZEND_FE(SDL_SetWindowPosition, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowPosition, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowSize, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowSize, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowMinimumSize, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowMinimumSize, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowMaximumSize, arginfo_SDL_SetWindowPosition) + ZEND_FE(SDL_GetWindowMaximumSize, arginfo_SDL_GetWindowPosition) + ZEND_FE(SDL_SetWindowBordered, arginfo_SDL_SetWindowBordered) + ZEND_FE(SDL_SetWindowFullscreen, arginfo_SDL_SetWindowFullscreen) + ZEND_FE(SDL_UpdateWindowSurfaceRects, arginfo_SDL_UpdateWindowSurfaceRects) + ZEND_FE(SDL_SetWindowGrab, arginfo_SDL_SetWindowGrab) + ZEND_FE(SDL_GetWindowGrab, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowBrightness, arginfo_SDL_SetWindowBrightness) + ZEND_FE(SDL_GetWindowBrightness, arginfo_SDL_Window) + ZEND_FE(SDL_GetWindowGammaRamp, arginfo_SDL_GetWindowGammaRamp) + ZEND_FE(SDL_IsShapedWindow, arginfo_SDL_Window) + ZEND_FE(SDL_SetWindowShape, arginfo_SDL_SetWindowShape) + ZEND_FE(SDL_GetShapedWindowMode, arginfo_SDL_GetShapedWindowMode) + + ZEND_FE(SDL_WINDOWPOS_UNDEFINED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) + ZEND_FE(SDL_WINDOWPOS_CENTERED_DISPLAY, arginfo_SDL_WINDOWPOS_DISPLAY) // Version ZEND_FE(SDL_GetRevision, arginfo_sdl_version_none) @@ -185,6 +186,7 @@ static zend_function_entry sdl_functions[] = { // Render ZEND_FE(SDL_CreateRenderer, arginfo_SDL_CreateRenderer) + ZEND_FE(SDL_CreateSoftwareRenderer, arginfo_SDL_CreateSoftwareRenderer) ZEND_FE(SDL_DestroyRenderer, arginfo_SDL_DestroyRenderer) ZEND_FE(SDL_DestroyTexture, arginfo_SDL_DestroyTexture) ZEND_FE(SDL_SetRenderDrawColor, arginfo_SDL_SetRenderDrawColor) @@ -198,8 +200,10 @@ static zend_function_entry sdl_functions[] = { ZEND_FE(SDL_RenderPresent, arginfo_SDL_RenderPresent) ZEND_FE(SDL_CreateTextureFromSurface, arginfo_SDL_CreateTextureFromSurface) ZEND_FE(SDL_CreateTexture, arginfo_SDL_CreateTexture) + ZEND_FE(SDL_UpdateTexture, arginfo_SDL_UpdateTexture) ZEND_FE(SDL_QueryTexture, arginfo_SDL_QueryTexture) ZEND_FE(SDL_SetRenderTarget, arginfo_SDL_SetRenderTarget) + ZEND_FE(SDL_RenderSetLogicalSize, arginfo_SDL_RenderSetLogicalSize) ZEND_FE(SDL_GetRendererOutputSize, arginfo_SDL_GetRendererOutputSize) ZEND_FE(SDL_RenderDrawPointF, arginfo_SDL_RenderDrawPointF) @@ -211,35 +215,35 @@ static zend_function_entry sdl_functions[] = { // Surface ZEND_FE(SDL_CreateRGBSurface, arginfo_SDL_CreateRGBSurface) - ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface) - ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect) - ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects) - ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface) - ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface) - ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface) - ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW) - ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP) - ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit) - ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit) - ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) - ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit) - ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit) - ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW) - ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP) - ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE) - ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey) - ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey) - ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod) - ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod) - ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod) - ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod) - ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode) - ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode) - ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect) - ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect) - ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface) - ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat) - ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels) + ZEND_FE(SDL_FreeSurface, arginfo_SDL_Surface) + ZEND_FE(SDL_FillRect, arginfo_SDL_FillRect) + ZEND_FE(SDL_FillRects, arginfo_SDL_FillRects) + ZEND_FE(SDL_MUSTLOCK, arginfo_SDL_Surface) + ZEND_FE(SDL_LockSurface, arginfo_SDL_Surface) + ZEND_FE(SDL_UnlockSurface, arginfo_SDL_Surface) + ZEND_FE(SDL_LoadBMP_RW, arginfo_SDL_LoadBMP_RW) + ZEND_FE(SDL_LoadBMP, arginfo_SDL_LoadBMP) + ZEND_FE(SDL_UpperBlit, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_LowerBlit, arginfo_SDL_LowerBlit) + ZEND_FE(SDL_UpperBlitScaled, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_LowerBlitScaled, arginfo_SDL_LowerBlit) + ZEND_FE(SDL_SoftStretch, arginfo_SDL_UpperBlit) + ZEND_FE(SDL_SaveBMP_RW, arginfo_SDL_SaveBMP_RW) + ZEND_FE(SDL_SaveBMP, arginfo_SDL_SaveBMP) + ZEND_FE(SDL_SetSurfaceRLE, arginfo_SDL_SetSurfaceRLE) + ZEND_FE(SDL_SetColorKey, arginfo_SDL_SetColorKey) + ZEND_FE(SDL_GetColorKey, arginfo_SDL_GetColorKey) + ZEND_FE(SDL_SetSurfaceColorMod, arginfo_SDL_SetSurfaceColorMod) + ZEND_FE(SDL_GetSurfaceColorMod, arginfo_SDL_GetSurfaceColorMod) + ZEND_FE(SDL_SetSurfaceAlphaMod, arginfo_SDL_SetSurfaceAlphaMod) + ZEND_FE(SDL_GetSurfaceAlphaMod, arginfo_SDL_GetSurfaceAlphaMod) + ZEND_FE(SDL_SetSurfaceBlendMode, arginfo_SDL_SetSurfaceBlendMode) + ZEND_FE(SDL_GetSurfaceBlendMode, arginfo_SDL_GetSurfaceBlendMode) + ZEND_FE(SDL_SetClipRect, arginfo_SDL_SetClipRect) + ZEND_FE(SDL_GetClipRect, arginfo_SDL_GetClipRect) + ZEND_FE(SDL_ConvertSurface, arginfo_SDL_ConvertSurface) + ZEND_FE(SDL_ConvertSurfaceFormat, arginfo_SDL_ConvertSurfaceFormat) + ZEND_FE(SDL_ConvertPixels, arginfo_SDL_ConvertPixels) // Events ZEND_FE(SDL_WaitEvent, arginfo_SDL_WaitEvent) diff --git a/src/render.c b/src/render.c index 54f7b9a..3a31ca4 100644 --- a/src/render.c +++ b/src/render.c @@ -18,6 +18,7 @@ #include "render.h" #include "window.h" #include "surface.h" +#include "pixels.h" #include "rect.h" #define SDL_RENDERER_RES_NAME "SDL Renderer" @@ -210,6 +211,35 @@ PHP_FUNCTION(SDL_CreateTexture) } } +PHP_FUNCTION(SDL_UpdateTexture) +{ + zval *z_texture, *z_rect, *z_pixels; + zend_long pitch; + + SDL_Rect def_rect; + SDL_Rect *rect = NULL; + SDL_Texture *texture = NULL; + SDL_Pixels *pixels; + + if( zend_parse_parameters(ZEND_NUM_ARGS(), "zO!Ol", &z_texture, &z_rect, get_php_sdl_rect_ce(), &z_pixels, get_php_sdl_pixels_ce(), &pitch ) == FAILURE ) { + WRONG_PARAM_COUNT; + } + if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) { + rect = &def_rect; + zval_to_sdl_rect(z_rect, rect); + } + + if (!(pixels = zval_to_sdl_pixels(z_pixels))) + { + php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object"); + } + texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); + + if( texture ) { + RETURN_LONG(SDL_UpdateTexture(texture, rect, pixels, pitch)); + } +} + PHP_FUNCTION(SDL_SetRenderTarget) { zval *z_renderer, *z_texture; @@ -247,6 +277,24 @@ PHP_FUNCTION(SDL_CreateRenderer) RETURN_RES(zend_register_resource(renderer, le_sdl_renderer)); } +PHP_FUNCTION(SDL_CreateSoftwareRenderer) +{ + zval *z_surface; + SDL_Surface *surface = NULL; + SDL_Renderer *renderer = NULL; + + if( zend_parse_parameters(ZEND_NUM_ARGS(), "O", &z_surface, get_php_sdl_surface_ce()) == FAILURE ) { + WRONG_PARAM_COUNT; + } + + if( z_surface != NULL ) { + surface = zval_to_sdl_surface(z_surface); + } + + renderer = SDL_CreateSoftwareRenderer(surface); + RETURN_RES(zend_register_resource(renderer, le_sdl_renderer)); +} + PHP_FUNCTION(SDL_RenderCopy) { zval *z_renderer, *z_texture; @@ -312,6 +360,21 @@ PHP_FUNCTION(SDL_RenderCopyEx) RETURN_LONG(SDL_RenderCopyEx(renderer, texture, srcrect, dstrect, angle, center, (Uint32)flip)); } +PHP_FUNCTION(SDL_RenderSetLogicalSize) +{ + zval *z_renderer; + zend_long w, h; + SDL_Renderer *renderer; + + if( zend_parse_parameters(ZEND_NUM_ARGS(), "zll", &z_renderer, &w, &h) == FAILURE ) { + WRONG_PARAM_COUNT; + } + + renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer); + + RETURN_LONG(SDL_RenderSetLogicalSize(renderer, w, h)); +} + PHP_FUNCTION(SDL_GetRendererOutputSize) { zval *z_renderer, *z_width=NULL, *z_height=NULL; @@ -384,14 +447,13 @@ PHP_FUNCTION(SDL_RenderDrawLineF) double x1, y1, x2, y2; ZEND_PARSE_PARAMETERS_START(5, 5); - //Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce) Z_PARAM_ZVAL(RENDERER) Z_PARAM_DOUBLE(x1) Z_PARAM_DOUBLE(y1) Z_PARAM_DOUBLE(x2) Z_PARAM_DOUBLE(y2) ZEND_PARSE_PARAMETERS_END(); - //renderer = php_sdl_renderer_from_zval_p(RENDERER); + renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer); int result = SDL_RenderDrawLineF(renderer, (float) x1, (float) y1, (float) x2, (float) y2); @@ -407,11 +469,10 @@ PHP_FUNCTION(SDL_RenderDrawRectF) SDL_FRect rect; ZEND_PARSE_PARAMETERS_START(2, 2); - //Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce) Z_PARAM_ZVAL(RENDERER) Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce()) ZEND_PARSE_PARAMETERS_END(); - //renderer = php_sdl_renderer_from_zval_p(RENDERER); + renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer); zval_to_sdl_frect(RECT, &rect); int result = SDL_RenderDrawRectF(renderer, (const SDL_FRect*) &rect); @@ -426,11 +487,9 @@ PHP_FUNCTION(SDL_RenderFillRectF) SDL_FRect rect; ZEND_PARSE_PARAMETERS_START(2, 2); - //Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce) Z_PARAM_ZVAL(RENDERER) Z_PARAM_OBJECT_OF_CLASS(RECT, get_php_sdl_frect_ce()) ZEND_PARSE_PARAMETERS_END(); - //renderer = php_sdl_renderer_from_zval_p(RENDERER); renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer); zval_to_sdl_frect(RECT, &rect); int result = SDL_RenderFillRectF(renderer, (const SDL_FRect*) &rect); @@ -449,14 +508,12 @@ PHP_FUNCTION(SDL_RenderCopyF) SDL_FRect def_dstrect; ZEND_PARSE_PARAMETERS_START(4, 4); - //Z_PARAM_OBJECT_OF_CLASS(RENDERER, sdl_renderer_ce) Z_PARAM_ZVAL(RENDERER) - // Z_PARAM_OBJECT_OF_CLASS(TEXTURE, sdl_texture_ce) Z_PARAM_ZVAL(TEXTURE) Z_PARAM_OBJECT_OF_CLASS_OR_NULL(SRCRECT, get_php_sdl_rect_ce()) Z_PARAM_OBJECT_OF_CLASS_OR_NULL(DSTRECT, get_php_sdl_frect_ce()) ZEND_PARSE_PARAMETERS_END(); - //renderer = php_sdl_renderer_from_zval_p(RENDERER); + renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(RENDERER), SDL_RENDERER_RES_NAME, le_sdl_renderer); texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(TEXTURE), SDL_TEXTURE_RES_NAME, le_sdl_texture); diff --git a/src/render.h b/src/render.h index 10ef166..11da7f8 100644 --- a/src/render.h +++ b/src/render.h @@ -85,6 +85,13 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateTexture, 0, 0, 5) ZEND_ARG_INFO(0, h) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_UpdateTexture, 0, 0, 4) + ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0) + ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 1) + ZEND_ARG_OBJ_INFO(0, pixels, SDL_Pixels, 0) + ZEND_ARG_INFO(0, pitch) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1) ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0) ZEND_ARG_TYPE_INFO(1, format, IS_LONG, 1) @@ -104,6 +111,10 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateRenderer, 0, 0, 3) ZEND_ARG_INFO(0, flags) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_CreateSoftwareRenderer, 0, 0, 1) + ZEND_ARG_OBJ_INFO(0, surface, SDL_Surface, 0) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopy, 0, 0, 4) ZEND_ARG_INFO(0, renderer) ZEND_ARG_INFO(0, texture) @@ -121,6 +132,12 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopyEx, 0, 0, 7) ZEND_ARG_INFO(0, flip) ZEND_END_ARG_INFO() +ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderSetLogicalSize, 0, 0, 3) + ZEND_ARG_INFO(0, renderer) + ZEND_ARG_INFO(0, w) + ZEND_ARG_INFO(0, h) +ZEND_END_ARG_INFO() + ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3) ZEND_ARG_INFO(0, renderer) ZEND_ARG_INFO(1, w) @@ -176,11 +193,14 @@ PHP_FUNCTION(SDL_RenderPresent); PHP_FUNCTION(SDL_RenderDrawPoint); PHP_FUNCTION(SDL_CreateTextureFromSurface); PHP_FUNCTION(SDL_CreateTexture); +PHP_FUNCTION(SDL_UpdateTexture); PHP_FUNCTION(SDL_QueryTexture); PHP_FUNCTION(SDL_SetRenderTarget); PHP_FUNCTION(SDL_CreateRenderer); +PHP_FUNCTION(SDL_CreateSoftwareRenderer); PHP_FUNCTION(SDL_RenderCopy); PHP_FUNCTION(SDL_RenderCopyEx); +PHP_FUNCTION(SDL_RenderSetLogicalSize); PHP_FUNCTION(SDL_GetRendererOutputSize); ZEND_FUNCTION(SDL_RenderDrawPointF); ZEND_FUNCTION(SDL_RenderDrawLineF); diff --git a/src/sdl.c b/src/sdl.c index 65f0118..5270028 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -112,6 +112,24 @@ PHP_FUNCTION(SDL_WasInit) { } /* }}} */ +/* {{{ proto int SDL_SetHint(string hint, string value) + +extern DECLSPEC Uint32 SDLCALL SDL_SetHint(char *hint, char *value); +*/ +PHP_FUNCTION(SDL_SetHint) { + char *hint; + size_t hint_len; + char *value; + size_t value_len; + + if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &hint, &hint_len, &value, &value_len) == FAILURE) { + RETURN_FALSE; + } + + RETURN_LONG(SDL_SetHint(hint, value)); +} +/* }}} */ + /* {{{ PHP_MINIT_FUNCTION */ PHP_MINIT_FUNCTION(sdl_sdl) { @@ -129,6 +147,8 @@ PHP_MINIT_FUNCTION(sdl_sdl) REGISTER_LONG_CONSTANT("SDL_INIT_NOPARACHUTE", SDL_INIT_NOPARACHUTE, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SDL_INIT_EVERYTHING", SDL_INIT_EVERYTHING, CONST_CS | CONST_PERSISTENT); + REGISTER_STRING_CONSTANT("SDL_HINT_RENDER_SCALE_QUALITY", SDL_HINT_RENDER_SCALE_QUALITY, CONST_CS | CONST_PERSISTENT); + return SUCCESS; } /* }}} */ diff --git a/src/sdl.h b/src/sdl.h index cd6d4f3..25df540 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -54,6 +54,13 @@ ZEND_END_ARG_INFO() PHP_FUNCTION(SDL_Quit); +ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetHint, 0, 0, 2) + ZEND_ARG_INFO(0, flags) +ZEND_END_ARG_INFO() + +PHP_FUNCTION(SDL_SetHint); + + PHP_MINIT_FUNCTION(sdl_sdl); #ifdef __cplusplus From 932b0a1b1d50affa2fcf04e7c366cc39dc1b85ac Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Fri, 30 Dec 2022 19:11:05 +0000 Subject: [PATCH 49/55] Declare window property on SDL_Event class --- src/event.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/event.c b/src/event.c index 25da33e..c6440d4 100644 --- a/src/event.c +++ b/src/event.c @@ -288,6 +288,7 @@ PHP_MINIT_FUNCTION(sdl_event) zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("type"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("motion"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC); return SUCCESS; } From 3206f3cffc91aafe31e813996f02ec6be1b8d2b3 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sat, 31 Dec 2022 00:01:07 +0000 Subject: [PATCH 50/55] Fix SDL_UpdateTexture function --- src/event.c | 1 + src/pixels.c | 246 +++----------------------------------------------- src/pixels.h | 2 - src/render.c | 4 +- src/render.h | 8 +- src/sdl.c | 9 +- src/sdl.h | 3 +- src/surface.c | 26 +----- 8 files changed, 32 insertions(+), 267 deletions(-) diff --git a/src/event.c b/src/event.c index c6440d4..45942ee 100644 --- a/src/event.c +++ b/src/event.c @@ -289,6 +289,7 @@ PHP_MINIT_FUNCTION(sdl_event) zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("key"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("motion"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC); + zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("button"), ZEND_ACC_PUBLIC); return SUCCESS; } diff --git a/src/pixels.c b/src/pixels.c index 9f49dd7..50c87a5 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -214,7 +214,8 @@ zend_bool sdl_pixels_to_zval(SDL_Pixels *pixels, zval *z_val, Uint32 flags) php_sdl_pixels *intern; object_init_ex(z_val, php_sdl_pixels_ce); - intern = PHP_SDL_PIXELS_P(z_val); + zend_object *zo = Z_OBJ_P(z_val); + intern = (php_sdl_pixels*)((char *)zo - zo->handlers->offset); intern->pixels = *pixels; intern->flags = flags; @@ -242,11 +243,12 @@ SDL_PixelFormat *zval_to_sdl_pixelformat(zval *z_val) /* {{{ zval_to_sdl_pixels */ SDL_Pixels *zval_to_sdl_pixels(zval *z_val) { + php_sdl_pixels *intern; + if (Z_TYPE_P(z_val) == IS_OBJECT && Z_OBJCE_P(z_val) == php_sdl_pixels_ce) { - php_sdl_pixels *intern; - - intern = PHP_SDL_PIXELS_P(z_val); + zend_object *zo = Z_OBJ_P(z_val); + intern = (php_sdl_pixels*)((char *)zo - zo->handlers->offset); return &intern->pixels; } return NULL; @@ -1058,8 +1060,6 @@ static PHP_METHOD(SDL_Pixels, __construct) php_error_docref(NULL, E_NOTICE, "Pitch set to %d", (int)pitch); } intern->pixels.pixels = ecalloc((int)pitch, (int)h); - intern->pixels.pitch = (int)pitch; - intern->pixels.h = (int)h; } } /* }}} */ @@ -1070,7 +1070,6 @@ ZEND_END_ARG_INFO() /* {{{ proto SDL_Pixels::__toString() */ static PHP_METHOD(SDL_Pixels, __toString) { - php_sdl_pixels *intern; char *buf; if (zend_parse_parameters_none() == FAILURE) @@ -1078,179 +1077,11 @@ static PHP_METHOD(SDL_Pixels, __toString) return; } - intern = PHP_SDL_PIXELS_P(getThis()); - spprintf(&buf, 100, "SDL_Pixels(%d,%d)", intern->pixels.pitch, intern->pixels.h); + spprintf(&buf, 100, "SDL_Pixels"); RETVAL_STRING(buf); } /* }}} */ -/* {{{ proto SDL_Pixels, count(void) */ -static PHP_METHOD(SDL_Pixels, count) -{ - php_sdl_pixels *intern; - - intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters_none() == FAILURE) - { - return; - } - - RETURN_LONG(intern->pixels.h * intern->pixels.pitch); -} -/* }}} */ - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetExists, 0, 1, _IS_BOOL, 0) -ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -/* {{{ proto SDL_Pixels, offsetExists(int offset) */ -PHP_METHOD(SDL_Pixels, offsetExists) -{ - php_sdl_pixels *intern; - zend_long offset; - - intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) - { - return; - } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) - { - RETURN_FALSE; - } - RETURN_TRUE; -} -/* }}} */ - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetGet, 0, 1, IS_MIXED, 1) -ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -/* {{{ proto SDL_Pixels, offsetGet(int offset) */ -PHP_METHOD(SDL_Pixels, offsetGet) -{ - php_sdl_pixels *intern; - zend_long offset; - - intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) - { - return; - } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) - { - zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); - RETURN_FALSE; - } - RETVAL_LONG(intern->pixels.pixels[offset]); -} -/* }}} */ - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetUnset, 0, 1, IS_VOID, 0) -ZEND_ARG_INFO(0, offset) -ZEND_END_ARG_INFO() - -/* {{{ proto SDL_Pixels, offsetUnset(int offset) */ -PHP_METHOD(SDL_Pixels, offsetUnset) -{ - php_sdl_pixels *intern; - zend_long offset; - - intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &offset) == FAILURE) - { - return; - } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) - { - zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); - RETURN_FALSE; - } - intern->pixels.pixels[offset] = 0; -} -/* }}} */ - -ZEND_BEGIN_ARG_WITH_TENTATIVE_RETURN_TYPE_INFO_EX(arginfo_SDL_Pixels_offsetSet, 0, 2, IS_VOID, 0) -ZEND_ARG_INFO(0, offset) -ZEND_ARG_INFO(0, value) -ZEND_END_ARG_INFO() - -/* {{{ proto SDL_Pixels, offsetSet(int offset, int value) */ -PHP_METHOD(SDL_Pixels, offsetSet) -{ - php_sdl_pixels *intern; - zend_long offset, value; - - intern = PHP_SDL_PIXELS_P(getThis()); - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ll", &offset, &value) == FAILURE) - { - return; - } - if (offset < 0 || offset >= (intern->pixels.h * intern->pixels.pitch)) - { - zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); - RETURN_FALSE; - } - intern->pixels.pixels[offset] = (Uint8)value; -} -/* }}} */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_GetByte, 0, 0, 2) -ZEND_ARG_INFO(0, x) -ZEND_ARG_INFO(0, y) -ZEND_END_ARG_INFO() - -/* {{{ proto int SDL_Pixels::GetByte(int x, int y) */ -PHP_METHOD(SDL_Pixels, GetByte) -{ - php_sdl_pixels *intern; - zval *z_pixels; - zend_long x, y; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Oll", &z_pixels, php_sdl_pixels_ce, &x, &y) == FAILURE) - { - return; - } - intern = PHP_SDL_PIXELS_P(z_pixels); - - if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) - { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h); - RETURN_FALSE; - } - RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]); -} -/* }}} */ - -ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_Pixels_SetByte, 0, 0, 3) -ZEND_ARG_INFO(0, x) -ZEND_ARG_INFO(0, y) -ZEND_ARG_INFO(0, byte) -ZEND_END_ARG_INFO() - -/* {{{ proto int SDL_Pixels::SetByte(int x, int y, int byte) */ -PHP_METHOD(SDL_Pixels, SetByte) -{ - php_sdl_pixels *intern; - zval *z_pixels; - zend_long x, y, v; - - if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Olll", &z_pixels, php_sdl_pixels_ce, &x, &y, &v) == FAILURE) - { - return; - } - intern = PHP_SDL_PIXELS_P(z_pixels); - - if (x < 0 || x >= intern->pixels.pitch || y < 0 || y >= intern->pixels.h) - { - php_error_docref(NULL, E_NOTICE, "Invalid position (%ld,%ld) in SDL_Pixels (%d,%d)", (long)x, (long)y, intern->pixels.pitch, intern->pixels.h); - RETURN_FALSE; - } - RETVAL_LONG(intern->pixels.pixels[y * intern->pixels.pitch + x]); - intern->pixels.pixels[y * intern->pixels.pitch + x] = (Uint8)v; -} -/* }}} */ - /* {{{ php_sdl_palette_free */ static void php_sdl_palette_free(zend_object *object) @@ -1584,30 +1415,18 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ zval *retval; - if (!intern->pixels.pixels) - { - return zend_std_read_property(object, member, type, cache_slot, rv); - } - retval = rv; - if (!strcmp(member_val, "h")) + if (!strcmp(member_val, "pixels")) { - ZVAL_LONG(retval, intern->pixels.h); - } - else if (!strcmp(member_val, "pitch")) - { - ZVAL_LONG(retval, intern->pixels.pitch); - } - else if (!strcmp(member_val, "count")) - { - ZVAL_LONG(retval, intern->pixels.pitch * intern->pixels.h); + if (!intern->pixels.pixels) + { + return zend_std_read_property(object, member, type, cache_slot, rv); + } } else { retval = zend_std_read_property(object, member, type, cache_slot, rv); - - return retval; } return retval; @@ -1618,33 +1437,6 @@ zval *sdl_pixels_read_property(zend_object *object, zend_string *member, int typ ZVAL_LONG(&zv, f); \ zend_hash_str_update(props, n, sizeof(n) - 1, &zv); -/* {{{ sdl_pixels_read_properties */ -static HashTable *sdl_pixels_get_properties(zend_object *object) -{ - HashTable *props; - zval zv; - php_sdl_pixels *intern = php_sdl_pixels_from_obj(object); - - props = zend_std_get_properties(object); - - if (intern->pixels.pixels) - { - SDL_PIXELS_ADD_PROPERTY("pitch", intern->pixels.pitch); - SDL_PIXELS_ADD_PROPERTY("h", intern->pixels.h); - SDL_PIXELS_ADD_PROPERTY("count", intern->pixels.h * intern->pixels.pitch); - } - return props; -} -/* }}} */ - -/* {{{ sdl_pixels_write_property */ -static zval *sdl_pixels_write_property(zend_object *object, zend_string *name, zval *value, void **cache_slot) -{ - php_error_docref(NULL, E_ERROR, "Not supported, SDL_Pixels is read-only"); - return value; -} -/* }}} */ - /* {{{ php_sdl_color_methods[] */ static const zend_function_entry php_sdl_color_methods[] = { PHP_ME(SDL_Color, __construct, arginfo_SDL_Color__construct, ZEND_ACC_CTOR | ZEND_ACC_PUBLIC) @@ -1690,13 +1482,6 @@ static const zend_function_entry php_sdl_pixelformat_methods[] = { static const zend_function_entry php_sdl_pixels_methods[] = { PHP_ME(SDL_Pixels, __construct, arginfo_SDL_Pixels__construct, ZEND_ACC_PUBLIC) PHP_ME(SDL_Pixels, __toString, arginfo_class_SDL_Pixels___toString, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, count, arginfo_format_none, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetExists, arginfo_SDL_Pixels_offsetExists, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetGet, arginfo_SDL_Pixels_offsetGet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetSet, arginfo_SDL_Pixels_offsetSet, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, offsetUnset, arginfo_SDL_Pixels_offsetUnset, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, GetByte, arginfo_SDL_Pixels_GetByte, ZEND_ACC_PUBLIC) - PHP_ME(SDL_Pixels, SetByte, arginfo_SDL_Pixels_SetByte, ZEND_ACC_PUBLIC) PHP_FE_END}; /* }}} */ @@ -1772,18 +1557,11 @@ PHP_MINIT_FUNCTION(sdl_pixels) INIT_CLASS_ENTRY(ce_pixels, "SDL_Pixels", php_sdl_pixels_methods); php_sdl_pixels_ce = zend_register_internal_class(&ce_pixels); php_sdl_pixels_ce->create_object = php_sdl_pixels_new; - zend_class_implements(php_sdl_pixels_ce, 1, zend_ce_arrayaccess); memcpy(&php_sdl_pixels_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); php_sdl_pixels_handlers.read_property = sdl_pixels_read_property; - php_sdl_pixels_handlers.get_properties = sdl_pixels_get_properties; - php_sdl_pixels_handlers.write_property = sdl_pixels_write_property; php_sdl_pixels_handlers.free_obj = php_sdl_pixels_free; php_sdl_pixels_handlers.offset = XtOffsetOf(php_sdl_pixels, zo); - REGISTER_PIXELS_PROP("pitch"); - REGISTER_PIXELS_PROP("h"); - REGISTER_PIXELS_PROP("count"); - /* Pixel type. */ REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_UNKNOWN", SDL_PIXELTYPE_UNKNOWN, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SDL_PIXELTYPE_INDEX1", SDL_PIXELTYPE_INDEX1, CONST_CS | CONST_PERSISTENT); diff --git a/src/pixels.h b/src/pixels.h index 8aedc44..d6b32af 100644 --- a/src/pixels.h +++ b/src/pixels.h @@ -28,8 +28,6 @@ extern "C" { /* PHP specific struct to manage memory access */ typedef struct SDL_Pixels { - int h; - int pitch; Uint8 *pixels; } SDL_Pixels; diff --git a/src/render.c b/src/render.c index 3a31ca4..a48d5ae 100644 --- a/src/render.c +++ b/src/render.c @@ -227,16 +227,18 @@ PHP_FUNCTION(SDL_UpdateTexture) if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) { rect = &def_rect; zval_to_sdl_rect(z_rect, rect); + rect = NULL; } if (!(pixels = zval_to_sdl_pixels(z_pixels))) { php_error_docref(NULL, E_WARNING, "Invalid source SDL_Pixels object"); } + texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); if( texture ) { - RETURN_LONG(SDL_UpdateTexture(texture, rect, pixels, pitch)); + RETURN_LONG(SDL_UpdateTexture(texture, rect, pixels->pixels, pitch)); } } diff --git a/src/render.h b/src/render.h index 11da7f8..a67673f 100644 --- a/src/render.h +++ b/src/render.h @@ -89,7 +89,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_UpdateTexture, 0, 0, 4) ZEND_ARG_OBJ_INFO(0, texture, SDL_Texture, 0) ZEND_ARG_OBJ_INFO(0, rect, SDL_Rect, 1) ZEND_ARG_OBJ_INFO(0, pixels, SDL_Pixels, 0) - ZEND_ARG_INFO(0, pitch) + ZEND_ARG_TYPE_INFO(0, pitch, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_QueryTexture, 0, 0, 1) @@ -133,9 +133,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderCopyEx, 0, 0, 7) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_RenderSetLogicalSize, 0, 0, 3) - ZEND_ARG_INFO(0, renderer) - ZEND_ARG_INFO(0, w) - ZEND_ARG_INFO(0, h) + ZEND_ARG_OBJ_INFO(0, renderer, SDL_Renderer, 0) + ZEND_ARG_TYPE_INFO(0, w, IS_LONG, 0) + ZEND_ARG_TYPE_INFO(0, h, IS_LONG, 0) ZEND_END_ARG_INFO() ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_GetRendererOutputSize, 0, 0, 3) diff --git a/src/sdl.c b/src/sdl.c index 5270028..cde630a 100644 --- a/src/sdl.c +++ b/src/sdl.c @@ -122,11 +122,12 @@ PHP_FUNCTION(SDL_SetHint) { char *value; size_t value_len; - if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &hint, &hint_len, &value, &value_len) == FAILURE) { - RETURN_FALSE; - } + ZEND_PARSE_PARAMETERS_START(2, 2) + Z_PARAM_STRING(hint, hint_len) + Z_PARAM_STRING(value, value_len) + ZEND_PARSE_PARAMETERS_END(); - RETURN_LONG(SDL_SetHint(hint, value)); + RETURN_LONG(SDL_SetHint(hint, value) == SDL_TRUE); } /* }}} */ diff --git a/src/sdl.h b/src/sdl.h index 25df540..93e51ae 100644 --- a/src/sdl.h +++ b/src/sdl.h @@ -55,7 +55,8 @@ ZEND_END_ARG_INFO() PHP_FUNCTION(SDL_Quit); ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetHint, 0, 0, 2) - ZEND_ARG_INFO(0, flags) + ZEND_ARG_TYPE_INFO(0, name, IS_STRING, 0) + ZEND_ARG_TYPE_INFO(0, value, IS_STRING, 0) ZEND_END_ARG_INFO() PHP_FUNCTION(SDL_SetHint); diff --git a/src/surface.c b/src/surface.c index ce6f8bb..330ef51 100644 --- a/src/surface.c +++ b/src/surface.c @@ -114,7 +114,7 @@ PHP_FUNCTION(SDL_CreateRGBSurface) { return; } - surface = SDL_CreateRGBSurface(flags, (int)width, (int)height, (int)depth, rmask, gmask, bmask, amask); + surface = SDL_CreateRGBSurface((Uint32)flags, (int)width, (int)height, (int)depth, (Uint32)rmask, (Uint32)gmask, (Uint32)bmask, (Uint32)amask); sdl_surface_to_zval(surface, return_value); } /* }}} */ @@ -1228,10 +1228,10 @@ PHP_FUNCTION(SDL_ConvertSurfaceFormat) PHP_FUNCTION(SDL_ConvertPixels) { zval *z_src, *z_dst; - zend_long w, h, sf, sp, df, dp; + zend_long w, h, src_format, src_pitch, dst_format, dst_pitch; SDL_Pixels *src, *dst; - if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &sf, &z_src, get_php_sdl_pixels_ce(), &sp, &df, &z_dst, get_php_sdl_pixels_ce(), &dp)) + if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS(), "lllOllOl", &w, &h, &src_format, &z_src, get_php_sdl_pixels_ce(), &src_pitch, &dst_format, &z_dst, get_php_sdl_pixels_ce(), &dst_pitch)) { return; } @@ -1243,22 +1243,8 @@ PHP_FUNCTION(SDL_ConvertPixels) { php_error_docref(NULL, E_WARNING, "Invalid destination SDL_Pixels object"); } - if (h < 0 || h > src->h || h > dst->h) - { - h = (src->h > dst->h ? dst->h : src->h); - php_error_docref(NULL, E_NOTICE, "Bad value for height, will use %ld", h); - } - if (sp != src->pitch) - { - sp = src->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for source pitch, will use %ld", sp); - } - if (dp != dst->pitch) - { - dp = dst->pitch; - php_error_docref(NULL, E_NOTICE, "Bad value for destination pitch, will use %ld", dp); - } - RETVAL_LONG(SDL_ConvertPixels(w, h, sf, src->pixels, sp, df, src->pixels, dp)); + + RETVAL_LONG(SDL_ConvertPixels(w, h, src_format, src->pixels, src_pitch, dst_format, dst->pixels, dst_pitch)); } /* }}} */ @@ -1392,8 +1378,6 @@ zval *sdl_surface_read_property(zend_object *object, zend_string *member, int ty else if (!strcmp(member_val, "pixels")) { SDL_Pixels pix; - pix.pitch = intern->surface->pitch; - pix.h = intern->surface->h; pix.pixels = (Uint8 *)intern->surface->pixels; sdl_pixels_to_zval(&pix, retval, SDL_DONTFREE); } From 655e403b8a9681c418702a74833c68c1a4ae1bd5 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sat, 31 Dec 2022 15:35:11 +0000 Subject: [PATCH 51/55] Use new parameter parsing method --- src/render.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/src/render.c b/src/render.c index a48d5ae..9314a00 100644 --- a/src/render.c +++ b/src/render.c @@ -33,9 +33,13 @@ PHP_FUNCTION(SDL_SetRenderDrawColor) zend_long r, g, b, a; SDL_Renderer *renderer; - if( zend_parse_parameters(ZEND_NUM_ARGS(), "zllll", &z_renderer, &r, &g, &b, &a) == FAILURE ) { - WRONG_PARAM_COUNT; - } + ZEND_PARSE_PARAMETERS_START(5, 5) + Z_PARAM_ZVAL(z_renderer) + Z_PARAM_LONG(r) + Z_PARAM_LONG(g) + Z_PARAM_LONG(b) + Z_PARAM_LONG(a) + ZEND_PARSE_PARAMETERS_END(); renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer); @@ -144,9 +148,9 @@ PHP_FUNCTION(SDL_RenderPresent) zval *z_renderer; SDL_Renderer *renderer; - if( zend_parse_parameters(ZEND_NUM_ARGS(), "z", &z_renderer) == FAILURE ) { - WRONG_PARAM_COUNT; - } + ZEND_PARSE_PARAMETERS_START(1, 1) + Z_PARAM_ZVAL(z_renderer) + ZEND_PARSE_PARAMETERS_END(); renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer); @@ -221,9 +225,13 @@ PHP_FUNCTION(SDL_UpdateTexture) SDL_Texture *texture = NULL; SDL_Pixels *pixels; - if( zend_parse_parameters(ZEND_NUM_ARGS(), "zO!Ol", &z_texture, &z_rect, get_php_sdl_rect_ce(), &z_pixels, get_php_sdl_pixels_ce(), &pitch ) == FAILURE ) { - WRONG_PARAM_COUNT; - } + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_ZVAL(z_texture) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_rect, get_php_sdl_rect_ce()) + Z_PARAM_OBJECT_OF_CLASS(z_pixels, get_php_sdl_pixels_ce()) + Z_PARAM_LONG(pitch) + ZEND_PARSE_PARAMETERS_END(); + if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) { rect = &def_rect; zval_to_sdl_rect(z_rect, rect); @@ -306,9 +314,12 @@ PHP_FUNCTION(SDL_RenderCopy) SDL_Rect *srcrect = NULL, *dstrect = NULL; SDL_Rect def_srcrect, def_dstrect; - if( zend_parse_parameters(ZEND_NUM_ARGS(), "zzO!O!", &z_renderer, &z_texture, &z_srcrect, get_php_sdl_rect_ce(), &z_dstrect, get_php_sdl_rect_ce()) == FAILURE ) { - WRONG_PARAM_COUNT; - } + ZEND_PARSE_PARAMETERS_START(4, 4) + Z_PARAM_ZVAL(z_renderer) + Z_PARAM_ZVAL(z_texture) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_srcrect, get_php_sdl_rect_ce()) + Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_dstrect, get_php_sdl_rect_ce()) + ZEND_PARSE_PARAMETERS_END(); renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer); texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); From 107999a668cff872b8cae58682ff47f4b18cebd9 Mon Sep 17 00:00:00 2001 From: Manuel Baldassarri Date: Sun, 6 Aug 2023 22:43:26 +0200 Subject: [PATCH 52/55] Remove invalid tests for SDL_Pixels array access (#73) --- tests/014-version.phpt | 3 ++- tests/021-surface-oo.phpt | 16 ++-------------- tests/022-pixels.phpt | 38 ++------------------------------------ 3 files changed, 6 insertions(+), 51 deletions(-) diff --git a/tests/014-version.phpt b/tests/014-version.phpt index 05889fe..52d45fa 100644 --- a/tests/014-version.phpt +++ b/tests/014-version.phpt @@ -26,7 +26,8 @@ var_dump(12030 === SDL_VERSIONNUM(10,20,30)); var_dump(SDL_VERSION_ATLEAST(2,0,0)); var_dump(SDL_VERSION_ATLEAST(2,0,25)); var_dump(is_string(SDL_GetRevision())); -var_dump(is_integer(SDL_GetRevisionNumber())); +SDL_GetVersion($linkedVersion); +var_dump(array_key_exists('major', $linkedVersion) && array_key_exists('minor', $linkedVersion) && array_key_exists('patch', $linkedVersion)); echo '= Done', PHP_EOL; ?> diff --git a/tests/021-surface-oo.phpt b/tests/021-surface-oo.phpt index f107820..f2b74e6 100644 --- a/tests/021-surface-oo.phpt +++ b/tests/021-surface-oo.phpt @@ -61,26 +61,14 @@ string(40) "SDL_Surface(%d,150,100,8,0x0,0x0,0x0,0x0)" int(150) int(100) int(256) -object(SDL_Pixels)#%d (3) { - ["pitch"]=> - int(152) - ["h"]=> - int(100) - ["count"]=> - int(15200) +object(SDL_Pixels)#%d (0) { } = Create True colors string(57) "SDL_Surface(%d,150,100,32,0xff000000,0xff0000,0xff00,0xff)" int(150) int(100) NULL -object(SDL_Pixels)#%d (3) { - ["pitch"]=> - int(600) - ["h"]=> - int(100) - ["count"]=> - int(60000) +object(SDL_Pixels)#%d (0) { } = Lock bool(false) diff --git a/tests/022-pixels.phpt b/tests/022-pixels.phpt index 25f0a88..fd0aa8e 100644 --- a/tests/022-pixels.phpt +++ b/tests/022-pixels.phpt @@ -14,19 +14,6 @@ try { echo "Exception: " . $e->getMessage() . "\n"; } var_dump($pix = new SDL_Pixels(10, 10), "$pix"); -echo "= Get/Set\n"; -var_dump($pix->GetByte(15,15)); -var_dump($pix->SetByte(0,0,1)); -var_dump($pix->GetByte(0,0)); -var_dump($pix->SetByte(1,1,255)); -var_dump($pix->GetByte(1,1)); - -echo "= Array\n"; -var_dump($pix[20], isset($pix[20]), isset($pix[1000])); -var_dump($pix[20]=127); -var_dump($pix[20]); -unset($pix[20]); -var_dump($pix[20]); ?> = Done --EXPECTF-- @@ -34,28 +21,7 @@ var_dump($pix[20]); Exception: Invalid size Notice: SDL_Pixels::__construct(): Pitch set to 12 in %s%e022-pixels.php on line 8 -object(SDL_Pixels)#%d (3) { - ["pitch"]=> - int(12) - ["h"]=> - int(10) - ["count"]=> - int(120) +object(SDL_Pixels)#%d (0) { } -string(17) "SDL_Pixels(12,10)" -= Get/Set - -Notice: SDL_Pixels::GetByte(): Invalid position (15,15) in SDL_Pixels (12,10) in %s%e022-pixels.php on line 10 -bool(false) -int(0) -int(1) -int(0) -int(255) -= Array -int(0) -bool(true) -bool(false) -int(127) -int(127) -int(0) +string(10) "SDL_Pixels" = Done From 96a6c7f9a95d1ff8b868656dbc30e08c520541b4 Mon Sep 17 00:00:00 2001 From: Santiago Lizardo Date: Sun, 6 Aug 2023 22:14:12 +0100 Subject: [PATCH 53/55] Fix version test --- tests/014-version.phpt | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/014-version.phpt b/tests/014-version.phpt index 52d45fa..31cc82b 100644 --- a/tests/014-version.phpt +++ b/tests/014-version.phpt @@ -23,7 +23,6 @@ echo '= Functions', PHP_EOL; SDL_VERSION($version); var_dump(array_key_exists('major', $version) && array_key_exists('minor', $version) && array_key_exists('patch', $version)); var_dump(12030 === SDL_VERSIONNUM(10,20,30)); -var_dump(SDL_VERSION_ATLEAST(2,0,0)); var_dump(SDL_VERSION_ATLEAST(2,0,25)); var_dump(is_string(SDL_GetRevision())); SDL_GetVersion($linkedVersion); @@ -47,7 +46,6 @@ bool(true) bool(true) bool(true) bool(true) -bool(false) bool(true) bool(true) = Done From 04c9014b9d76e45f3cff4e00d0f5a4650685fb23 Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 8 Dec 2025 23:43:57 +0100 Subject: [PATCH 54/55] use zend_ce_exception instead of zend_exception_get_default() for 8.5 (#78) --- src/glcontext.c | 4 ++-- src/mouse.c | 6 +++--- src/mutex.c | 6 +++--- src/pixels.c | 12 ++++++------ src/rwops.c | 2 +- src/shape.c | 4 ++-- src/surface.c | 2 +- src/window.c | 2 +- 8 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/glcontext.c b/src/glcontext.c index 0392c37..7cb49fe 100644 --- a/src/glcontext.c +++ b/src/glcontext.c @@ -224,12 +224,12 @@ PHP_METHOD(SDL_GLContext, __construct) } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } else { - zend_throw_exception(zend_exception_get_default(), "Invalid SDL_Window object", 0); + zend_throw_exception(zend_ce_exception, "Invalid SDL_Window object", 0); } } /* }}} */ diff --git a/src/mouse.c b/src/mouse.c index ce4ed62..23af147 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -137,13 +137,13 @@ static PHP_METHOD(SDL_Cursor, __construct) if (w <= 0 || w & 7 || h <= 0) { - zend_throw_exception(zend_exception_get_default(), "Invalid cursor size", 0); + zend_throw_exception(zend_ce_exception, "Invalid cursor size", 0); return; } size = w / 8 * h; if (data_len != size || mask_len != size) { - zend_throw_exception_ex(zend_exception_get_default(), 0, "Invalid data or mask, size must be %ld", size); + zend_throw_exception_ex(zend_ce_exception, 0, "Invalid data or mask, size must be %ld", size); return; } intern->cursor = SDL_CreateCursor((Uint8 *)data, (Uint8 *)mask, (int)w, (int)h, (int)x, (int)y); @@ -153,7 +153,7 @@ static PHP_METHOD(SDL_Cursor, __construct) } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ diff --git a/src/mutex.c b/src/mutex.c index 72aba04..f9781d0 100644 --- a/src/mutex.c +++ b/src/mutex.c @@ -326,7 +326,7 @@ static PHP_METHOD(SDL_mutex, __construct) if (intern->mutex) { intern->flags = 0; } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ @@ -489,7 +489,7 @@ static PHP_METHOD(SDL_sem, __construct) if (intern->sem) { intern->flags = 0; } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ @@ -695,7 +695,7 @@ static PHP_METHOD(SDL_cond, __construct) if (intern->cond) { intern->flags = 0; } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ diff --git a/src/pixels.c b/src/pixels.c index 50c87a5..7951cb8 100644 --- a/src/pixels.c +++ b/src/pixels.c @@ -453,7 +453,7 @@ static PHP_METHOD(SDL_PixelFormat, __construct) } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ @@ -550,7 +550,7 @@ static PHP_METHOD(SDL_Palette, __construct) } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ @@ -630,7 +630,7 @@ PHP_METHOD(SDL_Palette, offsetGet) } if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { - zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); + zend_throw_exception(zend_ce_exception, "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } sdl_color_to_zval(intern->palette->colors + offset, return_value); @@ -655,7 +655,7 @@ PHP_METHOD(SDL_Palette, offsetUnset) } if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { - zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); + zend_throw_exception(zend_ce_exception, "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } memset(&color, 0, sizeof(color)); @@ -683,7 +683,7 @@ PHP_METHOD(SDL_Palette, offsetSet) } if (!intern->palette || offset < 0 || offset >= (intern->palette->ncolors)) { - zend_throw_exception(zend_exception_get_default(), "Invalid offset in SDL_Pixels", 0); + zend_throw_exception(zend_ce_exception, "Invalid offset in SDL_Pixels", 0); RETURN_FALSE; } zval_to_sdl_color(z_color, &color); @@ -1050,7 +1050,7 @@ static PHP_METHOD(SDL_Pixels, __construct) if (php_sdl_check_overflow((int)pitch, (int)h, 1)) { - zend_throw_exception(zend_exception_get_default(), "Invalid size", 0); + zend_throw_exception(zend_ce_exception, "Invalid size", 0); } else { diff --git a/src/rwops.c b/src/rwops.c index 87485cb..1a1a3a0 100644 --- a/src/rwops.c +++ b/src/rwops.c @@ -137,7 +137,7 @@ static PHP_METHOD(SDL_RWops, __construct) if (intern->rwops) { intern->flags = 0; } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ diff --git a/src/shape.c b/src/shape.c index 58c6bd5..756bc19 100644 --- a/src/shape.c +++ b/src/shape.c @@ -128,12 +128,12 @@ static PHP_METHOD(SDL_WindowShapeMode, __construct) intern->mode.mode = ShapeModeColorKey; zval_to_sdl_color(z_param, &intern->mode.parameters.colorKey); } else { - zend_throw_exception(zend_exception_get_default(), "Invalid parameter for mode=ShapeModeColorKey, SDL_Color object expected", 0); + zend_throw_exception(zend_ce_exception, "Invalid parameter for mode=ShapeModeColorKey, SDL_Color object expected", 0); } } else { - zend_throw_exception(zend_exception_get_default(), "Invalid mode for SDL_WindowShapeMode", 0); + zend_throw_exception(zend_ce_exception, "Invalid mode for SDL_WindowShapeMode", 0); } } /* }}} */ diff --git a/src/surface.c b/src/surface.c index 330ef51..3215f4d 100644 --- a/src/surface.c +++ b/src/surface.c @@ -206,7 +206,7 @@ static PHP_METHOD(SDL_Surface, __construct) } else { - zend_throw_exception(zend_exception_get_default(), SDL_GetError(), 0); + zend_throw_exception(zend_ce_exception, SDL_GetError(), 0); } } /* }}} */ diff --git a/src/window.c b/src/window.c index 8ea9c11..61edf2b 100644 --- a/src/window.c +++ b/src/window.c @@ -1185,7 +1185,7 @@ static PHP_METHOD(SDL_Window, __construct) } else { - zend_throw_exception(zend_exception_get_default(), "Can't create window", 0); + zend_throw_exception(zend_ce_exception, "Can't create window", 0); } } /* }}} */ From 419eb9d759e8d56b106455c5a84d25fe67526c63 Mon Sep 17 00:00:00 2001 From: davidnurdin <50957749+davidnurdin@users.noreply.github.com> Date: Mon, 8 Dec 2025 23:45:12 +0100 Subject: [PATCH 55/55] add touchscreen (#77) * add touchscreen * deprecated dynamic properties * properties dynamic * bug render target null --- src/event.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/event.h | 5 +++-- src/render.c | 19 +++++++++++++---- 3 files changed, 77 insertions(+), 6 deletions(-) diff --git a/src/event.c b/src/event.c index 45942ee..29fa842 100644 --- a/src/event.c +++ b/src/event.c @@ -48,6 +48,16 @@ zend_bool sdl_event_to_zval(SDL_Event *event, zval *value) switch (event->type) { + case SDL_FINGERDOWN: + case SDL_FINGERUP: + case SDL_FINGERMOTION: + { + zval tfinger; + php_sdl_touchfingerevent_to_zval(&event->tfinger, &tfinger); + add_property_zval(value, "tfinger", &tfinger); + + } + break; case SDL_MOUSEMOTION: { zval motion; @@ -240,6 +250,11 @@ PHP_MINIT_FUNCTION(sdl_event) REGISTER_LONG_CONSTANT("SDL_QUIT", SDL_QUIT, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_FINGERDOWN", SDL_FINGERDOWN, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_FINGERUP", SDL_FINGERUP, CONST_CS | CONST_PERSISTENT); + REGISTER_LONG_CONSTANT("SDL_FINGERMOTION", SDL_FINGERMOTION, CONST_CS | CONST_PERSISTENT); + + REGISTER_LONG_CONSTANT("SDL_APP_TERMINATING", SDL_APP_TERMINATING, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SDL_APP_LOWMEMORY", SDL_APP_LOWMEMORY, CONST_CS | CONST_PERSISTENT); REGISTER_LONG_CONSTANT("SDL_APP_WILLENTERBACKGROUND", SDL_APP_WILLENTERBACKGROUND, CONST_CS | CONST_PERSISTENT); @@ -291,6 +306,50 @@ PHP_MINIT_FUNCTION(sdl_event) zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("window"), ZEND_ACC_PUBLIC); zend_declare_property_null(php_sdl_event_ce, ZEND_STRL("button"), ZEND_ACC_PUBLIC); + + // touchpad + zend_declare_property_null(php_sdl_event_ce, "tfinger", sizeof("tfinger") - 1, ZEND_ACC_PUBLIC); + + zend_class_entry ce; + INIT_CLASS_ENTRY(ce, "SDL_TouchFingerEvent", NULL); + sdlTouchFingerEvent_ce = zend_register_internal_class(&ce); + + + // Déclaration explicite des propriétés publiques + zend_declare_property_null(sdlTouchFingerEvent_ce, "type", sizeof("type") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "timestamp", sizeof("timestamp") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "x", sizeof("x") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "y", sizeof("y") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "dx", sizeof("dx") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "dy", sizeof("dy") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "pressure", sizeof("pressure") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "fingerId", sizeof("fingerId") - 1, ZEND_ACC_PUBLIC); + zend_declare_property_null(sdlTouchFingerEvent_ce, "touchId", sizeof("touchId") - 1, ZEND_ACC_PUBLIC); + + return SUCCESS; } /* }}} */ + +zend_class_entry *sdlTouchFingerEvent_ce; + +zend_object* php_sdl_touchfingerevent_new(zend_class_entry *class_type) { + zend_object *obj = zend_objects_new(class_type); + object_properties_init(obj, class_type); + obj->handlers = &std_object_handlers; + return obj; +} + +void php_sdl_touchfingerevent_to_zval(SDL_TouchFingerEvent *event, zval *value) { + object_init_ex(value, sdlTouchFingerEvent_ce); + + add_property_long(value, "type", event->type); + add_property_long(value, "timestamp", event->timestamp); + add_property_double(value, "x", event->x); + add_property_double(value, "y", event->y); + add_property_double(value, "dx", event->dx); + add_property_double(value, "dy", event->dy); + add_property_double(value, "pressure", event->pressure); + add_property_long(value, "fingerId", (zend_long)event->fingerId); + add_property_long(value, "touchId", (zend_long)event->touchId); +} diff --git a/src/event.h b/src/event.h index 297fcf2..ba0be5c 100644 --- a/src/event.h +++ b/src/event.h @@ -27,7 +27,8 @@ extern "C" { zend_class_entry *get_php_sdl_event_ce(void); zend_bool sdl_event_to_zval(SDL_Event *event, zval *value); zend_bool zval_to_sdl_event(zval *value, SDL_Event *event); - +void php_sdl_touchfingerevent_to_zval(SDL_TouchFingerEvent *event, zval *value); +extern zend_class_entry *sdlTouchFingerEvent_ce; // déclaration externe ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_PollEvent, 0, 0, 1) ZEND_ARG_OBJ_INFO(1, event, SDL_Event, 0) ZEND_END_ARG_INFO() @@ -42,7 +43,7 @@ PHP_FUNCTION(SDL_WaitEvent); PHP_MINIT_FUNCTION(sdl_event); #ifdef __cplusplus -} // extern "C" +} // extern "C" #endif #endif /* PHP_SDL_EVENT_H */ diff --git a/src/render.c b/src/render.c index 9314a00..49412c7 100644 --- a/src/render.c +++ b/src/render.c @@ -235,7 +235,7 @@ PHP_FUNCTION(SDL_UpdateTexture) if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) { rect = &def_rect; zval_to_sdl_rect(z_rect, rect); - rect = NULL; + rect = NULL; } if (!(pixels = zval_to_sdl_pixels(z_pixels))) @@ -261,9 +261,20 @@ PHP_FUNCTION(SDL_SetRenderTarget) } renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer); - texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); - - if( renderer && texture ) { + // texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); + if (Z_TYPE_P(z_texture) == IS_NULL) { + // SDL accepte NULL pour reset la target vers le default render target + texture = NULL; + } else { + texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture); + if (!texture) { + php_error_docref(NULL, E_WARNING, "Invalid SDL_Texture resource"); + RETURN_FALSE; + } + } + + if (renderer) + { RETURN_LONG(SDL_SetRenderTarget(renderer, texture)); } }