-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SDL_SetError(), SDL_GetError(), SDL_ClearError
- Loading branch information
1 parent
d3e67e0
commit f1ae804
Showing
10 changed files
with
191 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,6 @@ Release_TS | |
Release_TSDbg | ||
Release_TS_inline | ||
Debug_TS | ||
sdl2*.tgz | ||
sdl-*.tgz | ||
tmp-php.ini | ||
run-tests.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
SDL2 | ||
Remi Collet | ||
SDL | ||
Santiago Lizardo, Remi Collet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,7 @@ if test "$PHP_SDL" != "no"; then | |
|
||
sources=" | ||
cpuinfo.c | ||
error.c | ||
rect.c | ||
surface.c | ||
video.c | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| PHP Version 5 | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1997-2013 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 | | ||
| available through the world-wide-web at the following url: | | ||
| http://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. | | ||
+----------------------------------------------------------------------+ | ||
| Authors: Santiago Lizardo <santiagolizardo@php.net> | | ||
| Remi Collet <remi@php.net> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
/* $ Id: $ */ | ||
|
||
#include "php_sdl.h" | ||
|
||
ZEND_BEGIN_ARG_INFO_EX(arginfo_SDL_SetError, 0, 0, 1) | ||
ZEND_ARG_INFO(0, error_message) | ||
ZEND_END_ARG_INFO() | ||
|
||
/* {{{ proto int SDL_SetError(string error) | ||
* SDL_SetError() unconditionally returns -1. | ||
extern DECLSPEC int SDLCALL SDL_SetError(const char *fmt, ...); | ||
*/ | ||
PHP_FUNCTION(SDL_SetError) { | ||
char *error; | ||
int *error_len; | ||
|
||
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &error, &error_len) == FAILURE) { | ||
RETURN_FALSE; | ||
} | ||
|
||
RETURN_LONG(SDL_SetError(error)); | ||
} | ||
/* }}} */ | ||
|
||
ZEND_BEGIN_ARG_INFO_EX(arginfo_error_none, 0, 0, 0) | ||
ZEND_END_ARG_INFO() | ||
|
||
/* {{{ proto string SDL_GetError(void) | ||
extern DECLSPEC const char *SDLCALL SDL_GetError(void); | ||
*/ | ||
PHP_FUNCTION(SDL_GetError) { | ||
const char *error; | ||
|
||
if (zend_parse_parameters_none() == FAILURE) { | ||
RETURN_FALSE; | ||
} | ||
|
||
error = SDL_GetError(); | ||
if (error) { | ||
RETURN_STRING(error, 1); | ||
} | ||
} | ||
/* }}} */ | ||
|
||
|
||
/* {{{ proto string SDL_ClearError(void) | ||
extern DECLSPEC void SDLCALL SDL_ClearError(void); | ||
*/ | ||
PHP_FUNCTION(SDL_ClearError) { | ||
|
||
if (zend_parse_parameters_none() == FAILURE) { | ||
RETURN_FALSE; | ||
} | ||
|
||
SDL_ClearError(); | ||
} | ||
/* }}} */ | ||
|
||
|
||
/* {{{ sdl_error_functions[] */ | ||
zend_function_entry sdl_error_functions[] = { | ||
ZEND_FE(SDL_SetError, arginfo_SDL_SetError) | ||
ZEND_FE(SDL_GetError, arginfo_error_none) | ||
ZEND_FE(SDL_ClearError, arginfo_error_none) | ||
ZEND_FE_END | ||
}; | ||
/* }}} */ | ||
|
||
|
||
/* {{{ MINIT */ | ||
PHP_MINIT_FUNCTION(sdl_error) | ||
{ | ||
return (zend_register_functions(NULL, sdl_error_functions, NULL, MODULE_PERSISTENT TSRMLS_CC)); | ||
} | ||
/* }}} */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
+----------------------------------------------------------------------+ | ||
| PHP Version 5 | | ||
+----------------------------------------------------------------------+ | ||
| Copyright (c) 1997-2013 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 | | ||
| available through the world-wide-web at the following url: | | ||
| http://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. | | ||
+----------------------------------------------------------------------+ | ||
| Authors: Santiago Lizardo <santiagolizardo@php.net> | | ||
| Remi Collet <remi@php.net> | | ||
+----------------------------------------------------------------------+ | ||
*/ | ||
|
||
/* $ Id: $ */ | ||
|
||
#ifndef PHP_SDL_ERROR_H | ||
#define PHP_SDL_ERROR_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
PHP_MINIT_FUNCTION(sdl_error); | ||
|
||
#ifdef __cplusplus | ||
} // extern "C" | ||
#endif | ||
|
||
#endif /* PHP_SDL_ERROR_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--TEST-- | ||
error group test | ||
--SKIPIF-- | ||
<?php | ||
if (!extension_loaded("sdl")) die("skip: SDL extension not loaded"); | ||
?> | ||
--FILE-- | ||
<?php | ||
echo "+ start\n"; | ||
var_dump(SDL_GetError()); | ||
echo "+ set\n"; | ||
var_dump(SDL_SetError("Foo")); | ||
var_dump(SDL_GetError()); | ||
echo "+ clear\n"; | ||
var_dump(SDL_ClearError()); | ||
var_dump(SDL_GetError()); | ||
?> | ||
Done | ||
--EXPECTF-- | ||
+ start | ||
string(0) "" | ||
+ set | ||
int(-1) | ||
string(3) "Foo" | ||
+ clear | ||
NULL | ||
string(0) "" | ||
Done | ||
|