Apply patch from SF bug: [ 1466086 ] PHP namespace clash - ErrorCode

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9262 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2006-09-05 16:18:01 +00:00
commit 3a5fb61abe
3 changed files with 26 additions and 14 deletions

View file

@ -1,6 +1,18 @@
Version 1.3.30 (in progress)
============================
09/05/2006: olly
[php] Rename ErrorCode and ErrorMsg #define-s to SWIG_ErrorCode
and SWIG_ErrorMsg to avoid clashes with code the user might be
wrapping (patch from Darren Warner in SF bug #1466086). Any
user typemaps which use ErrorCode and/or ErrorMsg directly will
need adjusting - you can easily fix them to work with both old
and new SWIG by changing to use SWIG_ErrorMsg and adding:
#ifndef SWIG_ErrorMsg
#define SWIG_ErrorMsg() ErrorMsg()
#endif
08/29/2006: olly
[php] Move constant initialisation from RINIT to MINIT to fix a
warning when using Apache and mod_php. We only need to create

View file

@ -46,7 +46,7 @@ static int default_error_code = E_ERROR;
#define SWIG_PHP_Arg_Error_Msg(argnum,extramsg) "Error in argument " #argnum " "#extramsg
#define SWIG_PHP_Error(code,msg) do { ErrorCode() = code; ErrorMsg() = msg; SWIG_fail; } while (0)
#define SWIG_PHP_Error(code,msg) do { SWIG_ErrorCode() = code; SWIG_ErrorMsg() = msg; SWIG_fail; } while (0)
#define SWIG_contract_assert(expr,msg) \
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else

View file

@ -661,11 +661,11 @@ public:
Printf(s_header, "ZEND_END_MODULE_GLOBALS(%s)\n", module );
Printf(s_header, "ZEND_DECLARE_MODULE_GLOBALS(%s)\n",module );
Printf(s_header, "#ifdef ZTS\n" );
Printf(s_header, "#define ErrorMsg() TSRMG(%s_globals_id, zend_%s_globals *, error_msg )\n",module,module);
Printf(s_header, "#define ErrorCode() TSRMG(%s_globals_id, zend_%s_globals *, error_code )\n",module,module);
Printf(s_header, "#define SWIG_ErrorMsg() TSRMG(%s_globals_id, zend_%s_globals *, error_msg )\n",module,module);
Printf(s_header, "#define SWIG_ErrorCode() TSRMG(%s_globals_id, zend_%s_globals *, error_code )\n",module,module);
Printf(s_header, "#else\n" );
Printf(s_header, "#define ErrorMsg() (%s_globals.error_msg)\n",module);
Printf(s_header, "#define ErrorCode() (%s_globals.error_code)\n",module);
Printf(s_header, "#define SWIG_ErrorMsg() (%s_globals.error_msg)\n",module);
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n",module);
Printf(s_header, "#endif\n\n" );
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n",module,module);
@ -678,8 +678,8 @@ public:
Printf(s_header, "\n");
Printf(s_header, "static void SWIG_ResetError() {\n");
Printf(s_header, " TSRMLS_FETCH();\n");
Printf(s_header, " ErrorMsg() = default_error_msg;\n");
Printf(s_header, " ErrorCode() = default_error_code;\n");
Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n");
Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n");
Printf(s_header, "}\n");
Printf(s_header,"#define SWIG_name \"%s\"\n", module);
@ -926,14 +926,14 @@ public:
else {
Printf(f->code,"zend_get_parameters_array_ex(argc,argv);\n");
}
Replaceall(dispatch,"$args","self,args");
Printv(f->code,dispatch,"\n",NIL);
Printf(f->code,"ErrorCode() = E_ERROR;\n");
Printf(f->code,"ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
Printv(f->code,"zend_error(ErrorCode(),ErrorMsg());\n",NIL);
Printf(f->code,"SWIG_ErrorCode() = E_ERROR;\n");
Printf(f->code,"SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
Printv(f->code,"zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\n",NIL);
Printv(f->code,"}\n",NIL);
Wrapper_print(f,s_wrappers);
@ -1285,7 +1285,7 @@ public:
if (mvr) {
if (! mvrset) {
Printf(f->code,"return _return_value;\n");
Printf(f->code,"return _return_value;\n");
}
else{
Printf(f->code,"return SUCCESS;\n");
@ -1298,9 +1298,9 @@ public:
/* Error handling code */
Printf(f->code,"fail:\n");
Printv(f->code,cleanup,NIL);
Printv(f->code,"zend_error(ErrorCode(),ErrorMsg());",NIL);
Printv(f->code,"zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());",NIL);
Printf(f->code, "}\n");
Printf(f->code, "}\n");
Replaceall(f->code,"$cleanup",cleanup);
Replaceall(f->code,"$symname",iname);