Merge branch 'master' of github.com:/swig/swig

* 'master' of github.com:/swig/swig:
  Eliminate unused parameter from SWIG_Php_GetModule()
  Fix comment typo
  Fix compiler warnings in generated Lua code
  [PHP] Pass the ZTS context we already have to avoid needing to call TSRMLS_FETCH, which is relatively expensive.
  [PHP] Pass ZTS context through to t_output_helper() so it works with a ZTS-enabled build of PHP.  Reported by Pierre Labastie in github PR#155.
This commit is contained in:
William S Fulton 2014-04-02 22:10:47 +01:00
commit 4928eaf662
6 changed files with 33 additions and 25 deletions

View file

@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.1 (in progress)
===========================
2014-04-02: olly
[PHP] Pass the ZTS context we already have to avoid needing to
call TSRMLS_FETCH, which is relatively expensive.
2014-04-02: olly
[PHP] Pass ZTS context through to t_output_helper() so it works
with a ZTS-enabled build of PHP. Reported by Pierre Labastie in
github PR#155.
2014-03-28: wsfulton
[Java C# D Go] Fixes for C enums used in an API and the definition of the enum
has not been parsed. For D, this fixes a segfault in SWIG. The other languages

View file

@ -703,6 +703,7 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
/* Macros for iteration among class bases */
#if (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
(void)swig_type;\
SWIG_Lua_get_table(L,".bases");\
assert(lua_istable(L,-1));\
bases_count = lua_rawlen(L,-1);\
@ -716,7 +717,7 @@ SWIGINTERN void SWIG_Lua_get_class_metatable(lua_State *L,const char *cname);
} else\
valid = 1;
#else /* en elua .bases table doesn't exist. Use table from swig_lua_class */
#else /* In elua .bases table doesn't exist. Use table from swig_lua_class */
#define SWIG_LUA_INIT_BASE_SEARCH(bases_count)\
assert(swig_type!=0);\
@ -748,7 +749,7 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info *swig_type, i
int last_arg = lua_gettop(L);/* position of last argument */
lua_getmetatable(L,first_arg);
int original_metatable = last_arg + 1;
int bases_count;
size_t bases_count;
SWIG_LUA_INIT_BASE_SEARCH(bases_count);
int result = SWIG_ERROR;
if(ret)
@ -1169,7 +1170,7 @@ SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L,swig_lua_class
/* Add bases to .bases table */
SWIG_Lua_get_table(L,".bases");
assert(lua_istable(L,-1)); /* just in case */
int bases_count = 0;
size_t bases_count = 0;
for(i=0;clss->bases[i];i++)
{
SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname);

View file

@ -79,7 +79,7 @@ static int default_error_code = E_ERROR;
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else
/* Standard SWIG API */
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule(clientdata)
#define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
/* used to wrap returned objects in so we know whether they are newobject
@ -252,7 +252,7 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC
}
static char const_name[] = "swig_runtime_data_type_pointer";
static swig_module_info *SWIG_Php_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
static swig_module_info *SWIG_Php_GetModule() {
zval *pointer;
swig_module_info *ret = 0;
TSRMLS_FETCH();

View file

@ -38,7 +38,7 @@
zval *o;
MAKE_STD_ZVAL(o);
ZVAL_BOOL(o,temp$argnum);
t_output_helper( &$result, o );
t_output_helper( &$result, o TSRMLS_CC );
}
%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
%{
@ -67,7 +67,7 @@
zval *o;
MAKE_STD_ZVAL(o);
ZVAL_DOUBLE(o,temp$argnum);
t_output_helper( &$result, o );
t_output_helper( &$result, o TSRMLS_CC );
}
%typemap(in) TYPE *REFERENCE (TYPE dvalue), TYPE &REFERENCE (TYPE dvalue)
%{
@ -96,7 +96,7 @@
zval *o;
MAKE_STD_ZVAL(o);
ZVAL_LONG(o,temp$argnum);
t_output_helper( &$result, o );
t_output_helper( &$result, o TSRMLS_CC );
}
%typemap(in) TYPE *REFERENCE (TYPE lvalue), TYPE &REFERENCE (TYPE lvalue)
%{
@ -137,7 +137,7 @@ INT_TYPEMAP(long long);
sprintf(temp, "%lld", (long long)temp$argnum);
ZVAL_STRING(o, temp, 1);
}
t_output_helper( &$result, o );
t_output_helper( &$result, o TSRMLS_CC );
}
%typemap(in) TYPE *REFERENCE (long long lvalue)
%{
@ -178,7 +178,7 @@ INT_TYPEMAP(unsigned long long);
sprintf(temp, "%llu", (unsigned long long)temp$argnum);
ZVAL_STRING(o, temp, 1);
}
t_output_helper( &$result, o );
t_output_helper( &$result, o TSRMLS_CC );
}
%typemap(in) TYPE *REFERENCE (unsigned long long lvalue)
%{
@ -276,12 +276,12 @@ INT_TYPEMAP(unsigned long long);
%}
%typemap(in,numinputs=0) char OUTPUT[ANY] ( char temp[$1_dim0] )
"$1 = temp;";
%typemap(argout) char OUTPUT[ANY]
%typemap(argout,fragment="t_output_helper") char OUTPUT[ANY]
{
zval *o;
MAKE_STD_ZVAL(o);
ZVAL_STRINGL(o,temp$argnum,$1_dim0);
t_output_helper( &$result, o );
t_output_helper( &$result, o TSRMLS_CC );
}
%typemap(in,numinputs=0) void **OUTPUT (int force),

View file

@ -91,7 +91,7 @@
%fragment("t_output_helper","header") %{
static void
t_output_helper( zval **target, zval *o) {
t_output_helper(zval **target, zval *o TSRMLS_DC) {
if ( (*target)->type == IS_ARRAY ) {
/* it's already an array, just append */
add_next_index_zval( *target, o );

View file

@ -414,10 +414,9 @@ public:
* which has to be dynamically generated as it depends on the module name.
*/
Append(s_header, "#ifdef __GNUC__\n");
Append(s_header, "static void SWIG_FAIL() __attribute__ ((__noreturn__));\n");
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) __attribute__ ((__noreturn__));\n");
Append(s_header, "#endif\n\n");
Append(s_header, "static void SWIG_FAIL() {\n");
Append(s_header, " TSRMLS_FETCH();\n");
Append(s_header, "static void SWIG_FAIL(TSRMLS_D) {\n");
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
// zend_error() should never return with the parameters we pass, but if it
// does, we really don't want to let SWIG_FAIL() return. This also avoids
@ -433,8 +432,7 @@ public:
Printf(s_header, "static void %s_destroy_globals(zend_%s_globals * globals) { (void)globals; }\n", module, module);
Printf(s_header, "\n");
Printf(s_header, "static void SWIG_ResetError() {\n");
Printf(s_header, " TSRMLS_FETCH();\n");
Printf(s_header, "static void SWIG_ResetError(TSRMLS_D) {\n");
Printf(s_header, " SWIG_ErrorMsg() = default_error_msg;\n");
Printf(s_header, " SWIG_ErrorCode() = default_error_code;\n");
Printf(s_header, "}\n");
@ -445,7 +443,7 @@ public:
Append(s_header, " swig_object_wrapper *value;\n");
Append(s_header, " int type;\n");
Append(s_header, "\n");
Append(s_header, " SWIG_ResetError();\n");
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
Append(s_header, " if(ZEND_NUM_ARGS() != 2 || zend_get_parameters_array_ex(2, args) != SUCCESS) {\n");
Append(s_header, " WRONG_PARAM_COUNT;\n");
Append(s_header, " }\n");
@ -460,7 +458,7 @@ public:
Append(s_header, " swig_object_wrapper *value;\n");
Append(s_header, " int type;\n");
Append(s_header, "\n");
Append(s_header, " SWIG_ResetError();\n");
Append(s_header, " SWIG_ResetError(TSRMLS_C);\n");
Append(s_header, " if(ZEND_NUM_ARGS() != 1 || zend_get_parameters_array_ex(1, args) != SUCCESS) {\n");
Append(s_header, " WRONG_PARAM_COUNT;\n");
Append(s_header, " }\n");
@ -736,7 +734,7 @@ public:
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
Printv(f->code, "SWIG_FAIL();\n", NIL);
Printv(f->code, "SWIG_FAIL(TSRMLS_C);\n", NIL);
Printv(f->code, "}\n", NIL);
Wrapper_print(f, s_wrappers);
@ -854,7 +852,7 @@ public:
// NOTE: possible we ignore this_ptr as a param for native constructor
Printf(f->code, "SWIG_ResetError();\n");
Printf(f->code, "SWIG_ResetError(TSRMLS_C);\n");
if (numopt > 0) { // membervariable wrappers do not have optional args
Wrapper_add_local(f, "arg_count", "int arg_count");
@ -1019,7 +1017,7 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
Append(f->code, "SWIG_FAIL();\n");
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
Printf(f->code, "}\n");
@ -2336,7 +2334,7 @@ done:
Append(f->code, "return;\n");
Append(f->code, "fail:\n");
Append(f->code, "SWIG_FAIL();\n");
Append(f->code, "SWIG_FAIL(TSRMLS_C);\n");
Printf(f->code, "}\n");
Wrapper_print(f, s_wrappers);
@ -2700,7 +2698,7 @@ done:
}
Append(w->code, "fail:\n");
Append(w->code, "SWIG_FAIL();\n");
Append(w->code, "SWIG_FAIL(TSRMLS_C);\n");
Append(w->code, "}\n");
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method