From 3191473523de629d75181b134c75a83f7fd7297b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 24 May 2014 00:14:18 +0100 Subject: [PATCH] Fix compiler warnings in generated code when using -std=c++98 -std=gnu89 -pedantic -Wreturn-type --- Lib/guile/guile_scm_run.swg | 3 +- Lib/javascript/v8/javascriptinit.swg | 2 +- Lib/lua/lua_fnptr.i | 1 - Lib/lua/luarun.swg | 122 ++++++++++++++++----------- Lib/lua/luaruntime.swg | 2 +- Lib/lua/typemaps.i | 2 +- Lib/php/const.i | 4 +- Lib/php/utils.i | 2 +- Lib/ruby/file.i | 2 +- 9 files changed, 80 insertions(+), 60 deletions(-) diff --git a/Lib/guile/guile_scm_run.swg b/Lib/guile/guile_scm_run.swg index 322d660c5..94cf4d101 100644 --- a/Lib/guile/guile_scm_run.swg +++ b/Lib/guile/guile_scm_run.swg @@ -27,8 +27,7 @@ scm_module_variable (SCM module, SCM sym) #endif #if SCM_MAJOR_VERSION >= 2 -// scm_c_define_gsubr takes a different parameter type -// depending on the guile version +/* scm_c_define_gsubr takes a different parameter type depending on the guile version */ typedef scm_t_subr swig_guile_proc; #else diff --git a/Lib/javascript/v8/javascriptinit.swg b/Lib/javascript/v8/javascriptinit.swg index de1fe91f4..b428d4af9 100644 --- a/Lib/javascript/v8/javascriptinit.swg +++ b/Lib/javascript/v8/javascriptinit.swg @@ -113,6 +113,6 @@ void SWIGV8_INIT (v8::Handle exports, v8::Handle /*modul } #if defined(BUILDING_NODE_EXTENSION) -NODE_MODULE($jsname, $jsname_initialize); +NODE_MODULE($jsname, $jsname_initialize) #endif %} diff --git a/Lib/lua/lua_fnptr.i b/Lib/lua/lua_fnptr.i index 4e2c8dc6a..481cfafa6 100644 --- a/Lib/lua/lua_fnptr.i +++ b/Lib/lua/lua_fnptr.i @@ -103,7 +103,6 @@ void swiglua_ref_clear(SWIGLUA_REF* pref){ } void swiglua_ref_set(SWIGLUA_REF* pref,lua_State* L,int idx){ -// swiglua_ref_clear(pref); /* just in case */ pref->L=L; lua_pushvalue(L,idx); /* copy obj to top */ pref->ref=luaL_ref(L,LUA_REGISTRYINDEX); /* remove obj from top & put into registry */ diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 7cfcff212..1dd3b9f09 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -630,10 +630,12 @@ SWIGINTERN int SWIG_Lua_add_namespace_details(lua_State *L, swig_lua_namespace * /* Register all classes in the namespace */ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace *ns) { + swig_lua_class **classes; + /* There must be a module/namespace table at the top of the stack */ assert(lua_istable(L,-1)); - swig_lua_class **classes = ns->ns_classes; + classes = ns->ns_classes; if( classes != 0 ) { while(*classes != 0) { @@ -650,6 +652,7 @@ SWIGINTERN void SWIG_Lua_add_namespace_classes(lua_State *L, swig_lua_namespace */ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns, int reg) { + swig_lua_namespace **sub_namespace; /* 1 argument - table on the top of the stack */ const int SWIGUNUSED begin = lua_gettop(L); assert(lua_istable(L,-1)); /* just in case. This is supposed to be module table or parent namespace table */ @@ -681,7 +684,7 @@ SWIGINTERN void SWIG_Lua_namespace_register(lua_State *L, swig_lua_namespace *ns /* Register classes */ SWIG_Lua_add_namespace_classes(L,ns); - swig_lua_namespace **sub_namespace = ns->ns_namespaces; + sub_namespace = ns->ns_namespaces; if( sub_namespace != 0) { while(*sub_namespace != 0) { SWIG_Lua_namespace_register(L, *sub_namespace, 1); @@ -753,22 +756,21 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED /* first_arg - position of the object in stack. Everything that is above are arguments * and is passed to every evocation of the func */ int last_arg = lua_gettop(L);/* position of last argument */ - int original_metatable; + int original_metatable = last_arg + 1; size_t bases_count; - int result; + int result = SWIG_ERROR; lua_getmetatable(L,first_arg); - original_metatable = last_arg + 1; SWIG_LUA_INIT_BASE_SEARCH(bases_count); - result = SWIG_ERROR; if(ret) *ret = 0; if(bases_count>0) { + int to_remove; size_t i; int j; + int subcall_last_arg; int subcall_first_arg = lua_gettop(L) + 1;/* Here a copy of first_arg and arguments begin */ int valid = 1; - int subcall_last_arg; swig_type_info *base_swig_type = 0; for(j=first_arg;j<=last_arg;j++) lua_pushvalue(L,j); @@ -792,7 +794,7 @@ SWIGINTERN int SWIG_Lua_iterate_bases(lua_State *L, swig_type_info * SWIGUNUSED lua_pushvalue(L,original_metatable); lua_setmetatable(L,first_arg); /* Clear - remove everything between last_arg and subcall_last_arg including */ - const int to_remove = subcall_last_arg - last_arg; + to_remove = subcall_last_arg - last_arg; for(j=0;jtype; + int result; + swig_lua_userdata *usr; + swig_type_info *type; int ret = 0; - int result = SWIG_Lua_class_do_get(L,type,1,&ret); + assert(lua_isuserdata(L,1)); + usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + type = usr->type; + result = SWIG_Lua_class_do_get(L,type,1,&ret); if(result == SWIG_OK) return ret; @@ -902,6 +905,7 @@ SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int fi (3) any for the new value */ + int bases_search_result; int substack_start = lua_gettop(L) - 3; lua_checkstack(L,5); assert(lua_isuserdata(L,substack_start+1)); /* just in case */ @@ -944,14 +948,12 @@ SWIGINTERN int SWIG_Lua_class_do_set(lua_State *L, swig_type_info *type, int fi lua_pop(L,1); /* remove value */ lua_pop(L,1); /* remove metatable */ - { - /* Search among bases */ - int bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret); - if(ret) - assert(*ret == 0); - assert(lua_gettop(L) == substack_start + 3); - return bases_search_result; - } + /* Search among bases */ + bases_search_result = SWIG_Lua_iterate_bases(L,type,first_arg,SWIG_Lua_class_do_set,ret); + if(ret) + assert(*ret == 0); + assert(lua_gettop(L) == substack_start + 3); + return bases_search_result; } /* This is the actual method exported to Lua. It calls SWIG_Lua_class_do_set and correctly @@ -964,11 +966,14 @@ SWIGINTERN int SWIG_Lua_class_set(lua_State *L) (2) string name of the attribute (3) any for the new value */ - assert(lua_isuserdata(L,1)); - swig_lua_userdata *usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ - swig_type_info *type = usr->type; int ret = 0; - int result = SWIG_Lua_class_do_set(L,type,1,&ret); + int result; + swig_lua_userdata *usr; + swig_type_info *type; + assert(lua_isuserdata(L,1)); + usr=(swig_lua_userdata*)lua_touserdata(L,1); /* get data */ + type = usr->type; + result = SWIG_Lua_class_do_set(L,type,1,&ret); if(result != SWIG_OK) { SWIG_Lua_pushferrstring(L,"Assignment not possible. No setter/member with this name. For custom assignments implement __setitem method."); lua_error(L); @@ -1004,13 +1009,15 @@ SWIGINTERN int SWIG_Lua_class_tostring(lua_State *L) { /* there should be 1 param passed in (1) userdata (not the metatable) */ + const char *className; + void* userData; assert(lua_isuserdata(L,1)); /* just in case */ - void* userData = lua_touserdata(L,1); /* get the userdata address for later */ + userData = lua_touserdata(L,1); /* get the userdata address for later */ lua_getmetatable(L,1); /* get the meta table */ assert(lua_istable(L,-1)); /* just in case */ lua_getfield(L, -1, ".type"); - const char *className = lua_tostring(L, -1); + className = lua_tostring(L, -1); lua_pushfstring(L, "<%s userdata: %p>", className, userData); return 1; @@ -1238,10 +1245,10 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class SWIGINTERN void SWIG_Lua_add_class_instance_details(lua_State *L, swig_lua_class *clss) { int i; + size_t bases_count = 0; /* Add bases to .bases table */ SWIG_Lua_get_table(L,".bases"); assert(lua_istable(L,-1)); /* just in case */ - size_t bases_count = 0; for(i=0;clss->bases[i];i++) { SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); @@ -1296,7 +1303,7 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L); /*forward declaration /* The real function that resolves a metamethod. * Function searches given class and all it's bases(recursively) for first instance of something that is - * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actuall metamethod implementation + * not equal to SWIG_Lua_resolve_metatmethod. (Almost always this 'something' is actual metamethod implementation * and it is a SWIG-generated C function.). It returns value on the top of the L and there is no garbage below the * answer. * Returns 1 if found, 0 otherwise. @@ -1310,6 +1317,9 @@ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class int skip_check) { /* This function is called recursively */ + int result = 0; + int i = 0; + if (!skip_check) { SWIG_Lua_get_class_metatable(L, clss->fqname); lua_pushvalue(L, metamethod_name_idx); @@ -1326,8 +1336,6 @@ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class } /* Forwarding calls to bases */ - int result = 0; - int i = 0; for(i=0;clss->bases[i];i++) { result = SWIG_Lua_do_resolve_metamethod(L, clss->bases[i], metamethod_name_idx, 0); @@ -1342,21 +1350,26 @@ SWIGINTERN int SWIG_Lua_do_resolve_metamethod(lua_State *L, const swig_lua_class * and calls it */ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) { + int numargs; + int metamethod_name_idx; + const swig_lua_class* clss; + int result; + lua_checkstack(L,5); - const int numargs = lua_gettop(L); /* number of arguments to pass to actuall metamethod */ + numargs = lua_gettop(L); /* number of arguments to pass to actual metamethod */ /* Get upvalues from closure */ lua_pushvalue(L, lua_upvalueindex(1)); /*Get function name*/ - const int metamethod_name_idx = lua_gettop(L); + metamethod_name_idx = lua_gettop(L); lua_pushvalue(L, lua_upvalueindex(2)); - const swig_lua_class* clss = (const swig_lua_class*)(lua_touserdata(L,-1)); + clss = (const swig_lua_class*)(lua_touserdata(L,-1)); lua_pop(L,1); /* remove lightuserdata with clss from stack */ - /* Actuall work */ - const int result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); + /* Actual work */ + result = SWIG_Lua_do_resolve_metamethod(L, clss, metamethod_name_idx, 1); if (!result) { - SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actuall metamethod. Memory corruption is most likely explanation."); + SWIG_Lua_pushferrstring(L,"The metamethod proxy is set, but it failed to find actual metamethod. Memory corruption is most likely explanation."); lua_error(L); return 0; } @@ -1374,10 +1387,14 @@ SWIGRUNTIME int SWIG_Lua_resolve_metamethod(lua_State *L) */ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class *clss, const int metatable_index) { + int key_index; + int success = 0; + int i = 0; + /* metamethod name - on the top of the stack */ assert(lua_isstring(L,-1)); - const int key_index = lua_gettop(L); + key_index = lua_gettop(L); /* Check whether method is already defined in metatable */ lua_pushvalue(L,key_index); /* copy of the key */ @@ -1389,8 +1406,6 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * lua_pop(L,1); /* Iterating over immediate bases */ - int success = 0; - int i = 0; for(i=0;clss->bases[i];i++) { const swig_lua_class *base = clss->bases[i]; @@ -1420,11 +1435,15 @@ SWIGINTERN int SWIG_Lua_add_class_user_metamethod(lua_State *L, swig_lua_class * SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class *clss) { + int metatable_index; + int metamethods_info_index; + int tostring_undefined; + SWIG_Lua_get_class_metatable(L, clss->fqname); - const int metatable_index = lua_gettop(L); + metatable_index = lua_gettop(L); SWIG_Lua_get_inheritable_metamethods(L); assert(lua_istable(L,-1)); - const int metamethods_info_index = lua_gettop(L); + metamethods_info_index = lua_gettop(L); lua_pushnil(L); /* first key */ while(lua_next(L, metamethods_info_index) != 0 ) { /* key at index -2, value at index -1 */ @@ -1442,7 +1461,7 @@ SWIGINTERN void SWIG_Lua_add_class_user_metamethods(lua_State *L, swig_lua_class lua_pushstring(L, "__tostring"); lua_pushvalue(L,-1); lua_rawget(L,metatable_index); - const int tostring_undefined = lua_isnil(L,-1); + tostring_undefined = lua_isnil(L,-1); lua_pop(L,1); if( tostring_undefined ) { lua_pushcfunction(L, SWIG_Lua_class_tostring); @@ -1494,6 +1513,7 @@ SWIGINTERN void SWIG_Lua_class_register_static(lua_State *L, swig_lua_class *cls */ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *clss) { + int new_metatable_index; const int SWIGUNUSED begin = lua_gettop(L); int i; /* if name already there (class is already registered) then do nothing */ @@ -1520,11 +1540,12 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c * It would get us all special methods: __getitem, __add etc. * This would set .fn, .type, and other .xxx incorrectly, but we will overwrite it right away */ - const int new_metatable_index = lua_absindex(L,-1); + new_metatable_index = lua_absindex(L,-1); for(i=0;clss->bases[i];i++) { + int base_metatable; SWIG_Lua_get_class_metatable(L,clss->bases[i]->fqname); - const int base_metatable = lua_absindex(L,-1); + base_metatable = lua_absindex(L,-1); SWIG_Lua_merge_tables_by_index(L,new_metatable_index, base_metatable); lua_pop(L,1); } @@ -1573,6 +1594,7 @@ SWIGINTERN void SWIG_Lua_class_register_instance(lua_State *L,swig_lua_class *c SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss) { + int SWIGUNUSED begin; assert(lua_istable(L,-1)); /* This is a table (module or namespace) where classes will be added */ SWIG_Lua_class_register_instance(L,clss); SWIG_Lua_class_register_static(L,clss); @@ -1587,7 +1609,7 @@ SWIGINTERN void SWIG_Lua_class_register(lua_State *L,swig_lua_class *clss) * | ".set" --> .... * |=============================== ".instance" */ - const int SWIGUNUSED begin = lua_gettop(L); + begin = lua_gettop(L); lua_pushstring(L,clss->cls_static->name); lua_rawget(L,-2); /* get class static table */ assert(lua_istable(L,-1)); diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index 26dab93f6..89908044b 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -29,6 +29,7 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ { #if (SWIG_LUA_TARGET != SWIG_LUA_FLAVOR_ELUAC) /* valid for both Lua and eLua */ int i; + int globalRegister = 0; /* start with global table */ lua_pushglobaltable (L); /* SWIG's internal initialisation */ @@ -49,7 +50,6 @@ SWIGEXPORT int SWIG_init(lua_State* L) /* default Lua action */ SWIG_Lua_init_base_class(L,(swig_lua_class*)(swig_types[i]->clientdata)); } } - int globalRegister = 0; #ifdef SWIG_LUA_MODULE_GLOBAL globalRegister = 1; #endif diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index 7a095a1e0..c662cd31e 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -296,7 +296,7 @@ This is one giant macro to define the typemaps & the helpers for array handling */ %define SWIG_TYPEMAP_NUM_ARR(NAME,TYPE) -%{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE);%} +%{SWIG_DECLARE_TYPEMAP_ARR_FN(NAME,TYPE)%} // fixed size array's %typemap(in) TYPE INPUT[ANY] diff --git a/Lib/php/const.i b/Lib/php/const.i index 82c48022b..329b0cf07 100644 --- a/Lib/php/const.i +++ b/Lib/php/const.i @@ -34,12 +34,12 @@ SWIGTYPE &&, SWIGTYPE [] { zval *z_var; + zend_constant c; + size_t len = sizeof("$symname") - 1; MAKE_STD_ZVAL(z_var); SWIG_SetPointerZval(z_var, (void*)$value, $1_descriptor, 0); - zend_constant c; c.value = *z_var; zval_copy_ctor(&c.value); - size_t len = sizeof("$symname") - 1; c.name = zend_strndup("$symname", len); c.name_len = len+1; c.flags = CONST_CS | CONST_PERSISTENT; diff --git a/Lib/php/utils.i b/Lib/php/utils.i index 4e53e25a7..408a3b366 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -92,6 +92,7 @@ %fragment("t_output_helper","header") %{ static void t_output_helper(zval **target, zval *o TSRMLS_DC) { + zval *tmp; if ( (*target)->type == IS_ARRAY ) { /* it's already an array, just append */ add_next_index_zval( *target, o ); @@ -102,7 +103,6 @@ t_output_helper(zval **target, zval *o TSRMLS_DC) { FREE_ZVAL(o); return; } - zval *tmp; ALLOC_INIT_ZVAL(tmp); *tmp = **target; zval_copy_ctor(tmp); diff --git a/Lib/ruby/file.i b/Lib/ruby/file.i index d64937ed1..f9aaa2754 100644 --- a/Lib/ruby/file.i +++ b/Lib/ruby/file.i @@ -4,7 +4,7 @@ extern "C" { #endif -// Ruby 1.9 changed the file name of this header +/* Ruby 1.9 changed the file name of this header */ #ifdef HAVE_RUBY_IO_H #include "ruby/io.h" #else