Skip to content

Commit 655e403

Browse files
Use new parameter parsing method
1 parent 3206f3c commit 655e403

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/render.c

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ PHP_FUNCTION(SDL_SetRenderDrawColor)
3333
zend_long r, g, b, a;
3434
SDL_Renderer *renderer;
3535

36-
if( zend_parse_parameters(ZEND_NUM_ARGS(), "zllll", &z_renderer, &r, &g, &b, &a) == FAILURE ) {
37-
WRONG_PARAM_COUNT;
38-
}
36+
ZEND_PARSE_PARAMETERS_START(5, 5)
37+
Z_PARAM_ZVAL(z_renderer)
38+
Z_PARAM_LONG(r)
39+
Z_PARAM_LONG(g)
40+
Z_PARAM_LONG(b)
41+
Z_PARAM_LONG(a)
42+
ZEND_PARSE_PARAMETERS_END();
3943

4044
renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
4145

@@ -144,9 +148,9 @@ PHP_FUNCTION(SDL_RenderPresent)
144148
zval *z_renderer;
145149
SDL_Renderer *renderer;
146150

147-
if( zend_parse_parameters(ZEND_NUM_ARGS(), "z", &z_renderer) == FAILURE ) {
148-
WRONG_PARAM_COUNT;
149-
}
151+
ZEND_PARSE_PARAMETERS_START(1, 1)
152+
Z_PARAM_ZVAL(z_renderer)
153+
ZEND_PARSE_PARAMETERS_END();
150154

151155
renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
152156

@@ -221,9 +225,13 @@ PHP_FUNCTION(SDL_UpdateTexture)
221225
SDL_Texture *texture = NULL;
222226
SDL_Pixels *pixels;
223227

224-
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 ) {
225-
WRONG_PARAM_COUNT;
226-
}
228+
ZEND_PARSE_PARAMETERS_START(4, 4)
229+
Z_PARAM_ZVAL(z_texture)
230+
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_rect, get_php_sdl_rect_ce())
231+
Z_PARAM_OBJECT_OF_CLASS(z_pixels, get_php_sdl_pixels_ce())
232+
Z_PARAM_LONG(pitch)
233+
ZEND_PARSE_PARAMETERS_END();
234+
227235
if(z_rect != NULL && Z_TYPE_P(z_rect) != IS_NULL) {
228236
rect = &def_rect;
229237
zval_to_sdl_rect(z_rect, rect);
@@ -306,9 +314,12 @@ PHP_FUNCTION(SDL_RenderCopy)
306314
SDL_Rect *srcrect = NULL, *dstrect = NULL;
307315
SDL_Rect def_srcrect, def_dstrect;
308316

309-
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 ) {
310-
WRONG_PARAM_COUNT;
311-
}
317+
ZEND_PARSE_PARAMETERS_START(4, 4)
318+
Z_PARAM_ZVAL(z_renderer)
319+
Z_PARAM_ZVAL(z_texture)
320+
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_srcrect, get_php_sdl_rect_ce())
321+
Z_PARAM_OBJECT_OF_CLASS_OR_NULL(z_dstrect, get_php_sdl_rect_ce())
322+
ZEND_PARSE_PARAMETERS_END();
312323

313324
renderer = (SDL_Renderer*)zend_fetch_resource(Z_RES_P(z_renderer), SDL_RENDERER_RES_NAME, le_sdl_renderer);
314325
texture = (SDL_Texture*)zend_fetch_resource(Z_RES_P(z_texture), SDL_TEXTURE_RES_NAME, le_sdl_texture);

0 commit comments

Comments
 (0)