From 39d8882a8234296fe94b55e070c9599c94d1789b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Apr 2012 06:18:21 +0000 Subject: [PATCH 01/43] Apply #3513569 which adds a catchlist to the xml output git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12977 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Source/Modules/xml.cxx | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index aaadbad7c..24319515e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-04-13: wsfulton + [Xml] Apply #3513569 which adds a catchlist to the xml output. + 2012-04-05: olly [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx index bcfac1acc..438205f68 100644 --- a/Source/Modules/xml.cxx +++ b/Source/Modules/xml.cxx @@ -144,6 +144,8 @@ public: Xml_print_kwargs(Getattr(obj, k)); } else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) { Xml_print_parmlist(Getattr(obj, k)); + } else if (Cmp(k, "catchlist") == 0) { + Xml_print_parmlist(Getattr(obj, k), "catchlist"); } else { DOH *o; print_indent(0); @@ -198,10 +200,10 @@ public: } - void Xml_print_parmlist(ParmList *p) { + void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") { print_indent(0); - Printf(out, "\n", ++id, p); + Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p); indent_level += 4; while (p) { print_indent(0); @@ -213,7 +215,7 @@ public: } indent_level -= 4; print_indent(0); - Printf(out, "\n"); + Printf(out, "\n", markup); } void Xml_print_baselist(List *p) { From 5c8e5542efc17030007175a1aff162d0eb24766a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Apr 2012 18:28:37 +0000 Subject: [PATCH 02/43] Apply #3219676 from Shane Liesegang which adds: - support for %factory - a __tostring method - a __disown method git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12978 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 6 ++++ Examples/test-suite/disown.i | 6 ++++ Examples/test-suite/lua/disown_runme.lua | 6 ++++ Lib/lua/luarun.swg | 37 ++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/CHANGES.current b/CHANGES.current index 24319515e..01944f978 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-04-13: wsfulton + [Lua] Apply #3219676 from Shane Liesegang which adds: + - support for %factory + - a __tostring method + - a __disown method + 2012-04-13: wsfulton [Xml] Apply #3513569 which adds a catchlist to the xml output. diff --git a/Examples/test-suite/disown.i b/Examples/test-suite/disown.i index 8b3aeb0ec..884fdaa74 100644 --- a/Examples/test-suite/disown.i +++ b/Examples/test-suite/disown.i @@ -42,6 +42,12 @@ _a = disown; return 5; } + + int remove(A *remove) + { + delete remove; + return 5; + } }; } diff --git a/Examples/test-suite/lua/disown_runme.lua b/Examples/test-suite/lua/disown_runme.lua index 72115bbc7..79c3df3c4 100644 --- a/Examples/test-suite/lua/disown_runme.lua +++ b/Examples/test-suite/lua/disown_runme.lua @@ -12,3 +12,9 @@ for x=0,100 do b:acquire(a) end collectgarbage() -- this will double delete unless the memory is managed properly + +a=disown.A() +a:__disown() +b:remove(a) +a=nil +collectgarbage() -- this will double delete unless the manual disown call worked diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 6fe0bccce..31808e82b 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -469,6 +469,39 @@ SWIGINTERN int SWIG_Lua_class_destruct(lua_State* L) return 0; } +/* the class.__tostring method called by the interpreter and print */ +SWIGINTERN int SWIG_Lua_class_tostring(lua_State* L) +{ +/* there should be 1 param passed in + (1) userdata (not the metatable) */ + assert(lua_isuserdata(L,1)); /* just in case */ + unsigned long userData = (unsigned long)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); + + char output[256]; + sprintf(output, "<%s userdata: %lX>", className, userData); + + lua_pushstring(L, (const char*)output); + return 1; +} + +/* to manually disown some userdata */ +SWIGINTERN int SWIG_Lua_class_disown(lua_State* L) +{ +/* there should be 1 params passed in + (1) userdata (not the meta table) */ + swig_lua_userdata* usr; + assert(lua_isuserdata(L,-1)); /* just in case */ + usr=(swig_lua_userdata*)lua_touserdata(L,-1); /* get it */ + + usr->own = 0; /* clear our ownership */ + return 0; +} + /* gets the swig class registry (or creates it) */ SWIGINTERN void SWIG_Lua_get_class_registry(lua_State* L) { @@ -594,11 +627,15 @@ SWIGINTERN void SWIG_Lua_class_register(lua_State* L,swig_lua_class* clss) /* add a table called ".fn" */ lua_pushstring(L,".fn"); lua_newtable(L); + /* add manual disown method */ + SWIG_Lua_add_function(L,"__disown",SWIG_Lua_class_disown); lua_rawset(L,-3); /* add accessor fns for using the .get,.set&.fn */ SWIG_Lua_add_function(L,"__index",SWIG_Lua_class_get); SWIG_Lua_add_function(L,"__newindex",SWIG_Lua_class_set); SWIG_Lua_add_function(L,"__gc",SWIG_Lua_class_destruct); + /* add tostring method for better output */ + SWIG_Lua_add_function(L,"__tostring",SWIG_Lua_class_tostring); /* add it */ lua_rawset(L,-3); /* metatable into registry */ lua_pop(L,1); /* tidy stack (remove registry) */ From 478496bcae15324aa68c48ebb605f9f9b9de5358 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 13 Apr 2012 19:29:33 +0000 Subject: [PATCH 03/43] Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12979 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/swig.swg | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 01944f978..1b5cbe4de 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-04-13: wsfulton + Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. + 2012-04-13: wsfulton [Lua] Apply #3219676 from Shane Liesegang which adds: - support for %factory diff --git a/Lib/swig.swg b/Lib/swig.swg index b47d4ff2c..fdcd4e5de 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -359,7 +359,7 @@ namespace std { #ifdef __cplusplus %typemap(memberin) char * { - if ($1) delete [] $1; + delete [] $1; if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); @@ -376,7 +376,7 @@ namespace std { } } %typemap(globalin) char * { - if ($1) delete [] $1; + delete [] $1; if ($input) { $1 = ($1_type) (new char[strlen((const char *)$input)+1]); strcpy((char *)$1, (const char *)$input); @@ -394,11 +394,11 @@ namespace std { } #else %typemap(memberin) char * { - if ($1) free((char *)$1); if ($input) { - $1 = ($1_type) malloc(strlen((const char *)$input)+1); + $1 = ($1_type) realloc($1, strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { + free($1); $1 = 0; } } @@ -411,11 +411,11 @@ namespace std { } } %typemap(globalin) char * { - if ($1) free((char *)$1); if ($input) { - $1 = ($1_type) malloc(strlen((const char *)$input)+1); + $1 = ($1_type) realloc($1, strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { + free ($1); $1 = 0; } } From 5effbc386cc6f028aa63aec4a4cd309c4267f588 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 16:18:04 +0000 Subject: [PATCH 04/43] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12980 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/ruby/rubyrun.swg | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 1b5cbe4de..390c2b50f 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-04-14: wsfulton + [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. + 2012-04-13: wsfulton Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. diff --git a/Lib/ruby/rubyrun.swg b/Lib/ruby/rubyrun.swg index a8afc6a10..a2d246e97 100644 --- a/Lib/ruby/rubyrun.swg +++ b/Lib/ruby/rubyrun.swg @@ -189,7 +189,7 @@ SWIG_Ruby_NewPointerObj(void *ptr, swig_type_info *type, int flags) downcast methods. */ if (obj != Qnil) { VALUE value = rb_iv_get(obj, "@__swigtype__"); - char* type_name = RSTRING_PTR(value); + const char* type_name = RSTRING_PTR(value); if (strcmp(type->name, type_name) == 0) { return obj; From 449599c8f30fd9c9122db955a2581466685968a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 16:26:45 +0000 Subject: [PATCH 05/43] nspace tests result in a warning if %nspace not supported where before it sometimes resulted in an error in the testsuite git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12981 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 1 - Examples/test-suite/director_nspace.i | 5 +++++ Examples/test-suite/nspace.i | 2 ++ Examples/test-suite/nspace_extend.i | 2 ++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 390c2b50f..6f805126e 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -57,7 +57,6 @@ Version 2.0.5 (in progress) [Octave] Use -globals . to load global variables in module namespace [Octave] Comment declaration of unimplemented function swig_register_director [Octave] Fix OCTAVE_PATH in octave Makefiles - [Octave] Add support for nspace feature - fix director_nspace test [Octave] Add support for std::list - fix li_std_containers_int test [Octave] Fix imports test diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i index 9861d9596..6814a43a3 100644 --- a/Examples/test-suite/director_nspace.i +++ b/Examples/test-suite/director_nspace.i @@ -36,8 +36,13 @@ namespace Bar %include +// nspace feature only supported by these languages +#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) %nspace Bar::Foo; %nspace Bar::FooBar; +#else +#warning nspace feature not yet supported in this target language +#endif %feature("director") Bar::Foo; diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i index 65c6aafa1..2e10542d3 100644 --- a/Examples/test-suite/nspace.i +++ b/Examples/test-suite/nspace.i @@ -103,5 +103,7 @@ struct GlobalClass { void test_classes(Outer::SomeClass c, Outer::Inner2::Color cc) {} %} +#else +#warning nspace feature not yet supported in this target language #endif diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i index 96e97a4ff..1965ef8f6 100644 --- a/Examples/test-suite/nspace_extend.i +++ b/Examples/test-suite/nspace_extend.i @@ -49,5 +49,7 @@ namespace Outer { const Outer::Inner2::Color& col2c) {} } +#else +#warning nspace feature not yet supported in this target language #endif From e8aab00b6d0df6f2d0253f84803c7ff58423b271 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 17:01:39 +0000 Subject: [PATCH 06/43] Remove run tests which should have been done in rev 12953 (reverting %shared_ptr fixes with typedef) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12982 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../python/li_boost_shared_ptr_template_runme.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py index 20e7a8060..c10627f36 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_template_runme.py @@ -8,8 +8,9 @@ if d.bar() != 2: raise RuntimeError if bar_getter(b) != 1: raise RuntimeError -if bar_getter(d) != 2: - raise RuntimeError +# Fix reverted in rev 12953 +#if bar_getter(d) != 2: +# raise RuntimeError b = BaseDefaultInt() d = DerivedDefaultInt() @@ -22,7 +23,8 @@ if d2.bar2() != 4: raise RuntimeError if bar2_getter(b) != 3: raise RuntimeError -if bar2_getter(d) != 4: - raise RuntimeError -if bar2_getter(d2) != 4: - raise RuntimeError +# Fix reverted in rev 12953 +#if bar2_getter(d) != 4: +# raise RuntimeError +#if bar2_getter(d2) != 4: +# raise RuntimeError From 68a135860d0da197639ea707e802b425df93fa76 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 17:30:03 +0000 Subject: [PATCH 07/43] Revert rev 12835 as it introduces a failure in the test-suite (primitive_types test) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12983 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 --- Lib/python/pyhead.swg | 1 - Lib/python/pyprimtypes.swg | 7 ++++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 6f805126e..b6bc01ac8 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -219,9 +219,6 @@ Version 2.0.5 (in progress) 2011-11-11: wsfulton Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. -2011-11-04: szager - [python] Bug 3429388: python unsigned integer handling on 32-bit architectures. - 2011-11-03: wsfulton Expand special variables in typemap warnings, eg: diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg index 206b81a37..803cd0745 100644 --- a/Lib/python/pyhead.swg +++ b/Lib/python/pyhead.swg @@ -4,7 +4,6 @@ #define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) #define PyInt_Check(x) PyLong_Check(x) #define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_AsUnsignedLongMask(x) PyLong_AsUnsignedLongMask(x) #define PyInt_FromLong(x) PyLong_FromLong(x) #define PyString_Check(name) PyBytes_Check(name) #define PyString_FromString(x) PyUnicode_FromString(x) diff --git a/Lib/python/pyprimtypes.swg b/Lib/python/pyprimtypes.swg index 43a3375b7..aa5ddaf62 100644 --- a/Lib/python/pyprimtypes.swg +++ b/Lib/python/pyprimtypes.swg @@ -100,12 +100,13 @@ SWIGINTERN int SWIG_AsVal_dec(unsigned long)(PyObject *obj, unsigned long *val) { if (PyInt_Check(obj)) { - unsigned long v = PyInt_AsUnsignedLongMask(obj); - if (!PyErr_Occurred()) { + long v = PyInt_AsLong(obj); + if (v >= 0) { if (val) *val = v; return SWIG_OK; + } else { + return SWIG_OverflowError; } - PyErr_Clear(); } else if (PyLong_Check(obj)) { unsigned long v = PyLong_AsUnsignedLong(obj); if (!PyErr_Occurred()) { From df4f9adf0a2f47b9aaa2993b8494a00d694b4fba Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 20:29:22 +0000 Subject: [PATCH 08/43] Diagnostics for erratically failing test case git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12984 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/threads_exception_runme.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py index f9b0fddc0..12202e3d3 100644 --- a/Examples/test-suite/python/threads_exception_runme.py +++ b/Examples/test-suite/python/threads_exception_runme.py @@ -26,7 +26,7 @@ except threads_exception.Exc,e: if e.code != 42: raise RuntimeError if e.msg != "Hosed": - raise RuntimeError + raise RuntimeError, "bad... msg: %s" % e.msg for i in range(1,4): try: From ac688f9ccbbbaff5ff6d2bd9efb8bd183875f157 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 20:37:39 +0000 Subject: [PATCH 09/43] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12985 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/lua/luarun.swg | 9 +++++++++ Lib/lua/luaruntime.swg | 6 +----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index b6bc01ac8..c12f9f6d9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.5 (in progress) =========================== +2012-04-14: wsfulton + [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable + 2012-04-14: wsfulton [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg index 31808e82b..af3e7a3af 100644 --- a/Lib/lua/luarun.swg +++ b/Lib/lua/luarun.swg @@ -33,6 +33,15 @@ extern "C" { # define lua_rawlen lua_objlen #endif + +/* lua_pushglobaltable is the recommended "future-proof" way to get + the global table for Lua 5.2 and later. Here we define + lua_pushglobaltable ourselves for Lua versions before 5.2. */ +#if !defined(LUA_VERSION_NUM) || LUA_VERSION_NUM < 502 +# define lua_pushglobaltable(L) lua_pushvalue(L, LUA_GLOBALSINDEX) +#endif + + /* ----------------------------------------------------------------------------- * global swig types * ----------------------------------------------------------------------------- */ diff --git a/Lib/lua/luaruntime.swg b/Lib/lua/luaruntime.swg index 9cf6a14a4..0f59b0476 100644 --- a/Lib/lua/luaruntime.swg +++ b/Lib/lua/luaruntime.swg @@ -30,11 +30,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; /* start with global table */ -#ifdef LUA_RIDX_GLOBALS - lua_rawgeti(L, LUA_REGISTRYINDEX, LUA_RIDX_GLOBALS); -#else - lua_pushvalue(L,LUA_GLOBALSINDEX); -#endif + lua_pushglobaltable (L); /* SWIG's internal initalisation */ SWIG_InitializeModule((void*)L); SWIG_PropagateClientData(); From f00a41093c4feb33ceb3c614a87cae24d9cd9241 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 21:11:19 +0000 Subject: [PATCH 10/43] As std_list.i is not available in many language, put this python specific test just in Python makefile git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12986 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 - Examples/test-suite/python/Makefile.in | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 0b79706cc..301df98b9 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -466,7 +466,6 @@ CPP_STD_TEST_CASES += \ director_string \ ignore_template_constructor \ li_std_combinations \ - li_std_containers_int \ li_std_deque \ li_std_except \ li_std_map \ diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index e5d92626e..43ba2717e 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -46,6 +46,7 @@ CPP_TEST_CASES += \ li_cwstring \ li_factory \ li_implicit \ + li_std_containers_int \ li_std_map_member \ li_std_multimap \ li_std_pair_extra \ From 442422fee0681954be262033a46760e6be588dd4 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 22:57:48 +0000 Subject: [PATCH 11/43] Remove annoying echo of compiler invocation by R CMD SHLIB git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12987 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/Makefile.in | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 700b7fcd3..e6c0d2f33 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1142,20 +1142,21 @@ R_CFLAGS=-fPIC # need to compile .cxx files outside of R build system to make sure that # we get -fPIC +# CMD SHLIB stdout is piped to /dev/null to prevent echo of compiler command r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) ifneq ($(SRCS),) $(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) endif - +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) ) + +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) ifneq ($(CXXSRCS),) $(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(CXXSRCS) $(INCLUDES) endif - +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) ) + +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) r_clean: rm -f *_wrap* *~ .~* From c3fdc9fc5eea327e807c58e2c872fe9200213a21 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 14 Apr 2012 23:30:22 +0000 Subject: [PATCH 12/43] Add back in %traits_enum removed in rev 12961 and probably fix iterating through std::vector wrappers of enumerations for R git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12988 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 2 +- Lib/r/std_common.i | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index c12f9f6d9..1cffb5ce9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -54,7 +54,7 @@ Version 2.0.5 (in progress) Apply patch #3468362 from Karl Wette to fix %include inside %define. 2012-03-13: wsfulton - [Python, Ruby, Octave] Fix #3475492 - iterating through std::vector wrappers of enumerations. + [Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations. 2012-02-27: xavier98 (patches from Karl Wette) [Octave] Use -globals . to load global variables in module namespace diff --git a/Lib/r/std_common.i b/Lib/r/std_common.i index fab7f54d0..8e97521b0 100644 --- a/Lib/r/std_common.i +++ b/Lib/r/std_common.i @@ -1,11 +1,16 @@ %include -%include + + +/* + Generate the traits for a 'primitive' type, such as 'double', + for which the SWIG_AsVal and SWIG_From methods are already defined. +*/ %define %traits_ptypen(Type...) %fragment(SWIG_Traits_frag(Type),"header", - fragment=SWIG_AsVal_frag(Type), - fragment=SWIG_From_frag(Type), - fragment="StdTraits") { + fragment=SWIG_AsVal_frag(Type), + fragment=SWIG_From_frag(Type), + fragment="StdTraits") { namespace swig { template <> struct traits { typedef value_category category; @@ -27,6 +32,39 @@ namespace swig { } %enddef +/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums + is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit + instantiations required using %template). The STL containers define the 'front' method and the typemap + below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the + standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from + required in the generated code for enums. */ + +%define %traits_enum(Type...) + %fragment("SWIG_Traits_enum_"{Type},"header", + fragment=SWIG_AsVal_frag(int), + fragment=SWIG_From_frag(int), + fragment="StdTraits") { +namespace swig { + template <> struct traits_asval { + typedef Type value_type; + static int asval(SEXP obj, value_type *val) { + return SWIG_AsVal(int)(obj, (int *)val); + } + }; + template <> struct traits_from { + typedef Type value_type; + static SEXP from(const value_type& val) { + return SWIG_From(int)((int)val); + } + }; +} +} +%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%} +%enddef + + +%include + // // Generates the traits for all the known primitive // C++ types (int, double, ...) From 068358da2fd1039d697e09c31d1947fc3434f740 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 15 Apr 2012 12:25:50 +0000 Subject: [PATCH 13/43] remove spurtious printf git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12989 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/r/std_vector.i | 1 - 1 file changed, 1 deletion(-) diff --git a/Lib/r/std_vector.i b/Lib/r/std_vector.i index 2d66cdcd4..9fb95c597 100644 --- a/Lib/r/std_vector.i +++ b/Lib/r/std_vector.i @@ -192,7 +192,6 @@ struct traits_asptr < std::vector > { static int asptr(SEXP obj, std::vector **val) { std::vector *p; - Rprintf("my asptr\n"); int res = SWIG_R_ConvertPtr(obj, (void**)&p, type_info< std::vector >(), 0); if (SWIG_IsOK(res)) { if (val) *val = p; From d12e7ecd9ed30f70f15bf8cf631f07a4063fab15 Mon Sep 17 00:00:00 2001 From: Joseph Wang Date: Sun, 15 Apr 2012 12:54:42 +0000 Subject: [PATCH 14/43] add test to confirm fix to sourceforge 3478922 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12990 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/r/Makefile.in | 2 +- Examples/test-suite/r/r_base_test_runme.R | 13 +++++++++++++ Examples/test-suite/r_base_test.i | 20 ++++++++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Examples/test-suite/r/r_base_test_runme.R create mode 100644 Examples/test-suite/r_base_test.i diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 86b19e142..d6e9d6cfa 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -11,7 +11,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ C_TEST_CASES = r_copy_struct r_legacy -CPP_TEST_CASES = r_double_delete r_overload_array +CPP_TEST_CASES = r_double_delete r_overload_array r_base_test include $(srcdir)/../common.mk diff --git a/Examples/test-suite/r/r_base_test_runme.R b/Examples/test-suite/r/r_base_test_runme.R new file mode 100644 index 000000000..af05f99a9 --- /dev/null +++ b/Examples/test-suite/r/r_base_test_runme.R @@ -0,0 +1,13 @@ +source("unittest.R") +dyn.load(paste("r_base_test", .Platform$dynlib.ext, sep="")) +source("r_base_test.R") +cacheMetaData(1) + +b <- Base() +Base_method(b) +Base_overloaded_method(b) +Base_overloaded_method(b, 43) +Base_overloaded_method(b) +b$method() + +b$overloaded_method() diff --git a/Examples/test-suite/r_base_test.i b/Examples/test-suite/r_base_test.i new file mode 100644 index 000000000..d971417bf --- /dev/null +++ b/Examples/test-suite/r_base_test.i @@ -0,0 +1,20 @@ +/* This test confirms the fix to sourceforge bug #3478922 */ + +%module r_base_test +%inline %{ +class Base + { + public: + + Base() : x(42) {} + + int method() const { return x; } + + void overloaded_method(int aArg) { x = aArg; } + int overloaded_method() const { return x; } + + private: + + int x; + }; +%} From 4e3428ff66599b9e93502deb0d1f4040fb32b2c2 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Apr 2012 17:44:09 +0000 Subject: [PATCH 15/43] One test per line in Makefile git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12991 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/r/Makefile.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index d6e9d6cfa..5a09864ae 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -10,8 +10,14 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -C_TEST_CASES = r_copy_struct r_legacy -CPP_TEST_CASES = r_double_delete r_overload_array r_base_test +C_TEST_CASES += \ + r_copy_struct \ + r_legacy + +CPP_TEST_CASES += \ + r_double_delete \ + r_overload_array \ + r_base_test include $(srcdir)/../common.mk From bee885dfe00e774b661992d14b94b8cd6a966a01 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Apr 2012 18:10:58 +0000 Subject: [PATCH 16/43] Rename r_base_test to overload_method as it is a useful test for all languages git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12992 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/common.mk | 1 + Examples/test-suite/{r_base_test.i => overload_method.i} | 4 ++-- Examples/test-suite/r/Makefile.in | 3 +-- .../r/{r_base_test_runme.R => overload_method_runme.R} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename Examples/test-suite/{r_base_test.i => overload_method.i} (71%) rename Examples/test-suite/r/{r_base_test_runme.R => overload_method_runme.R} (66%) diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 301df98b9..7cc410e7a 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -277,6 +277,7 @@ CPP_TEST_CASES += \ operbool \ ordering \ overload_copy \ + overload_method \ overload_extend \ overload_rename \ overload_return_type \ diff --git a/Examples/test-suite/r_base_test.i b/Examples/test-suite/overload_method.i similarity index 71% rename from Examples/test-suite/r_base_test.i rename to Examples/test-suite/overload_method.i index d971417bf..8b44b8172 100644 --- a/Examples/test-suite/r_base_test.i +++ b/Examples/test-suite/overload_method.i @@ -1,6 +1,6 @@ -/* This test confirms the fix to sourceforge bug #3478922 */ +/* This test confirms the fix to sourceforge bug #3478922 for R */ -%module r_base_test +%module overload_method %inline %{ class Base { diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 5a09864ae..bece71c2f 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -16,8 +16,7 @@ C_TEST_CASES += \ CPP_TEST_CASES += \ r_double_delete \ - r_overload_array \ - r_base_test + r_overload_array include $(srcdir)/../common.mk diff --git a/Examples/test-suite/r/r_base_test_runme.R b/Examples/test-suite/r/overload_method_runme.R similarity index 66% rename from Examples/test-suite/r/r_base_test_runme.R rename to Examples/test-suite/r/overload_method_runme.R index af05f99a9..afb590a74 100644 --- a/Examples/test-suite/r/r_base_test_runme.R +++ b/Examples/test-suite/r/overload_method_runme.R @@ -1,6 +1,6 @@ source("unittest.R") -dyn.load(paste("r_base_test", .Platform$dynlib.ext, sep="")) -source("r_base_test.R") +dyn.load(paste("overload_method", .Platform$dynlib.ext, sep="")) +source("overload_method.R") cacheMetaData(1) b <- Base() From 117cb9b74aac9c4246c3beac4d77d0e3f29d3903 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 15 Apr 2012 21:56:38 +0000 Subject: [PATCH 17/43] Fix a few warnings/errors in the test-suite using Solaris compiler git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12993 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/python/autodoc_runme.py | 2 +- Examples/test-suite/template_typedef_class_template.i | 4 ++-- Examples/test-suite/template_typemaps.i | 2 ++ Examples/test-suite/typedef_struct.i | 8 ++++++++ Examples/test-suite/typemap_various.i | 10 +++++----- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py index c65ebba24..dc843ae96 100644 --- a/Examples/test-suite/python/autodoc_runme.py +++ b/Examples/test-suite/python/autodoc_runme.py @@ -2,7 +2,7 @@ from autodoc import * def check(got, expected): if expected != got: - raise RuntimeError("\n" + "Expected: [" + expected + "]\n" + "Got : [" + got + "]") + raise RuntimeError("\n" + "Expected: [" + str(expected) + "]\n" + "Got : [" + str(got) + "]") check(A.__doc__, "Proxy of C++ A class") check(A.funk.__doc__, "just a string") diff --git a/Examples/test-suite/template_typedef_class_template.i b/Examples/test-suite/template_typedef_class_template.i index 498f83ec5..fc8151ff0 100644 --- a/Examples/test-suite/template_typedef_class_template.i +++ b/Examples/test-suite/template_typedef_class_template.i @@ -24,8 +24,8 @@ template class Multimap { class const_iterator {}; // test usage of a typedef of a nested class in a template - Standard::Pair equal_range_1(const key_type& kt1) {} - Standard::Pair equal_range_2(const key_type& kt2) const {} + Standard::Pair equal_range_1(const key_type& kt1) { return Standard::Pair(); } + Standard::Pair equal_range_2(const key_type& kt2) const { return Standard::Pair(); } }; } %} diff --git a/Examples/test-suite/template_typemaps.i b/Examples/test-suite/template_typemaps.i index deaf8351a..c68eba730 100644 --- a/Examples/test-suite/template_typemaps.i +++ b/Examples/test-suite/template_typemaps.i @@ -3,6 +3,7 @@ %typemap(in) Integer1 { + $1 = 0; /* do nothing */ } @@ -13,6 +14,7 @@ %typemap(in) Integer2 { + $1 = 0; /* do nothing */ } diff --git a/Examples/test-suite/typedef_struct.i b/Examples/test-suite/typedef_struct.i index 4380156d1..97456d9a6 100644 --- a/Examples/test-suite/typedef_struct.i +++ b/Examples/test-suite/typedef_struct.i @@ -45,10 +45,18 @@ B_t make_b() { %inline %{ +#ifdef __cplusplus +extern "C" { +#endif + typedef struct _Foo { enum { NONAME1, NONAME2 } enumvar; int foovar; void (*fptr)(int); } Foo; +#ifdef __cplusplus +} +#endif + %} diff --git a/Examples/test-suite/typemap_various.i b/Examples/test-suite/typemap_various.i index 58dbe6667..5fc9fbcc2 100644 --- a/Examples/test-suite/typemap_various.i +++ b/Examples/test-suite/typemap_various.i @@ -65,10 +65,10 @@ void foo2(Foo f, const Foo& ff) {} %typemap(out) double ABC::_3 "$1 = 0.0;" %inline %{ struct ABC { - double meth() {} - double m1() {} - double _x2() {} - double y_() {} - double _3() {} + double meth() { return 0.0; } + double m1() { return 0.0; } + double _x2() { return 0.0; } + double y_() { return 0.0; } + double _3() { return 0.0; } }; %} From 70e0cf60f7c8496e2e37266e0aa436ad8534fa64 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 15 Apr 2012 22:47:19 +0000 Subject: [PATCH 18/43] Fixed segfault-on-exit in octave 3.2.4 - see SourceForge #3516652 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12994 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/octave/octruntime.swg | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg index b6c8537bd..650298d5c 100644 --- a/Lib/octave/octruntime.swg +++ b/Lib/octave/octruntime.swg @@ -171,7 +171,9 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) { // exiting without explicitly clearing the variable causes octave to segfault. #if OCTAVE_API_VERSION_NUMBER>=37 octave_value_list SWIG_atexit_func(const octave_value_list &args, int nargout) { - symbol_table::clear_global_pattern("*"); + string_vector vars = symbol_table::global_variable_names(); + for (int i = 0; i < vars.length(); i++) + symbol_table::clear_global(vars[i]); symbol_table::clear_functions(); return octave_value(); } From 35b2270f84a292181bf6004115076640f3c56801 Mon Sep 17 00:00:00 2001 From: Karl Wette Date: Sun, 15 Apr 2012 22:47:38 +0000 Subject: [PATCH 19/43] Make octave_dim tests pass for octave version != 3.2.4 - see SourceForge #3516652 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12995 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/octave_dim.i | 4 ++-- Lib/octave/octrun.swg | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Examples/test-suite/octave_dim.i b/Examples/test-suite/octave_dim.i index c74285808..f0d05852a 100644 --- a/Examples/test-suite/octave_dim.i +++ b/Examples/test-suite/octave_dim.i @@ -127,7 +127,7 @@ public: class Baz5 { public: Array __dims__() const { - Array c(2,1); + Array c(dim_vector(2,1)); c(0) = 3; c(1) = 4; return c; @@ -137,7 +137,7 @@ public: class Baz6 { public: Array __dims__() const { - Array c(1,2); + Array c(dim_vector(1,2)); c(0) = 3; c(1) = 4; return c; diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg index 5f1c18af4..b006bfabe 100644 --- a/Lib/octave/octrun.swg +++ b/Lib/octave/octrun.swg @@ -424,7 +424,8 @@ namespace Swig { if (ndim==1 && c.columns()!=1) ndim = c.columns(); dim_vector d; - d.resize(ndim); + d.resize(ndim < 2 ? 2 : ndim); + d(0) = d(1) = 1; // Fill in dim_vector for (int k=0;k a = out.int_vector_value(); if (error_state) return dim_vector(1,1); dim_vector d; - d.resize(a.numel()); + d.resize(a.numel() < 2 ? 2 : a.numel()); + d(0) = d(1) = 1; for (int k=0;k Date: Mon, 16 Apr 2012 18:45:33 +0000 Subject: [PATCH 20/43] Some test-suite fixes for visual studio git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12996 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/director_binary_string.i | 4 ++-- Examples/test-suite/operator_pointer_ref.i | 6 ++++++ Examples/test-suite/refcount.i | 2 +- Examples/test-suite/special_variable_macros.i | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Examples/test-suite/director_binary_string.i b/Examples/test-suite/director_binary_string.i index ec64bc4b4..96c835959 100644 --- a/Examples/test-suite/director_binary_string.i +++ b/Examples/test-suite/director_binary_string.i @@ -29,12 +29,12 @@ public: void delCallback() { delete _callback; _callback = 0; } void setCallback(Callback *cb) { delCallback(); _callback = cb; } int call() { + int sum = 0; if (_callback) { char* aa = (char*)malloc(BUFFER_SIZE_AA); memset(aa, 9, BUFFER_SIZE_AA); char* bb = (char*)malloc(BUFFER_SIZE_BB); memset(bb, 13, BUFFER_SIZE_BB); - int sum = 0; _callback->run(aa, BUFFER_SIZE_AA, bb, BUFFER_SIZE_BB); for (int i = 0; i < BUFFER_SIZE_AA; i++) sum += aa[i]; @@ -42,8 +42,8 @@ public: sum += bb[i]; free(aa); free(bb); - return sum; } + return sum; } }; diff --git a/Examples/test-suite/operator_pointer_ref.i b/Examples/test-suite/operator_pointer_ref.i index 1541adbcf..84182da0d 100644 --- a/Examples/test-suite/operator_pointer_ref.i +++ b/Examples/test-suite/operator_pointer_ref.i @@ -1,5 +1,11 @@ %module operator_pointer_ref +%{ +#if defined(_MSC_VER) + #pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. +#endif +%} + %rename(AsCharStarRef) operator char*&; %inline %{ diff --git a/Examples/test-suite/refcount.i b/Examples/test-suite/refcount.i index 28b55545b..d47323482 100644 --- a/Examples/test-suite/refcount.i +++ b/Examples/test-suite/refcount.i @@ -97,7 +97,7 @@ RCPtr _a; }; -class B* global_create(A* a) +struct B* global_create(A* a) { return new B(a); } diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i index ba9889d7a..65f5496eb 100644 --- a/Examples/test-suite/special_variable_macros.i +++ b/Examples/test-suite/special_variable_macros.i @@ -5,6 +5,12 @@ %warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'NewName' due to Go name ('NewName') conflict with 'Name' */ +%{ +#if defined(_MSC_VER) + #pragma warning(disable: 4996) // 'strdup': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _strdup. See online help for details. +#endif +%} + %ignore Name::operator=; %inline %{ From a6219a855ef1ed5dcc88abb1a6e55ea0828eb297 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Mon, 16 Apr 2012 19:55:33 +0000 Subject: [PATCH 21/43] signed unsigned fix git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12997 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pycontainer.swg | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 43dd19537..779816059 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -272,7 +272,7 @@ namespace swig { typename Sequence::const_iterator it = sb; while (it!=se) { sequence->push_back(*it); - for (typename Sequence::size_type c=0; cpush_back(*it); - for (typename Sequence::size_type c=0; c<-step && it!=se; ++c) + for (Py_ssize_t c=0; c<-step && it!=se; ++c) it++; } } @@ -337,7 +337,7 @@ namespace swig { std::advance(it,ii); for (size_t rc=0; rcerase(it); if (it==self->end()) break; - for (typename Sequence::size_type c=0; c<(step-1); ++c) + for (Py_ssize_t c=0; c<(step-1); ++c) it++; delcount--; } @@ -399,7 +399,7 @@ namespace swig { self->erase((++it).base()); if (it==self->rend()) break; - for (typename Sequence::size_type c=0; c<(-step-1); ++c) + for (Py_ssize_t c=0; c<(-step-1); ++c) it++; delcount--; } From cc5b232021b6ffebe81e666587af68b246cbc13a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Apr 2012 05:52:25 +0000 Subject: [PATCH 22/43] testcase fix for vc++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12998 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../template_default_class_parms_typedef.i | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Examples/test-suite/template_default_class_parms_typedef.i b/Examples/test-suite/template_default_class_parms_typedef.i index fb64659ba..0767498bf 100644 --- a/Examples/test-suite/template_default_class_parms_typedef.i +++ b/Examples/test-suite/template_default_class_parms_typedef.i @@ -21,16 +21,16 @@ namespace Space { C method(C c, D d, E e) { return c; } // Use typedef with classname qualifiers - Bar(bool, Bar::C c, Bar::D d, Bar::E e) {} - Bar::C method_1(Bar::C c, Bar::D d, Bar::E e) { return c; } + Bar(bool, typename Bar::C c, typename Bar::D d, typename Bar::E e) {} + typename Bar::C method_1(typename Bar::C c, typename Bar::D d, typename Bar::E e) { return c; } // Use typedef with classname and full template parameter qualifiers - Bar(bool, bool, Bar::C c, Bar::D d, Bar::E e) {} - Bar::C method_2(Bar::C c, Bar::D d, Bar::E e) { return c; } + Bar(bool, bool, typename Bar::C c, typename Bar::D d, typename Bar::E e) {} + typename Bar::C method_2(typename Bar::C c, typename Bar::D d, typename Bar::E e) { return c; } // Use typedef with namespace and classname and full template parameter qualifiers - Bar(bool, bool, bool, Space::Bar::C c, Space::Bar::D d, Space::Bar::E e) {} - Space::Bar::C method_3(Space::Bar::C c, Space::Bar::D d, Space::Bar::E e) { return c; } + Bar(bool, bool, bool, typename Space::Bar::C c, typename Space::Bar::D d, typename Space::Bar::E e) {} + typename Space::Bar::C method_3(typename Space::Bar::C c, typename Space::Bar::D d, typename Space::Bar::E e) { return c; } }; template class Foo { public: @@ -43,15 +43,15 @@ namespace Space { // Use typedef with classname qualifiers Foo(const T &, T t) {} - Foo::T method_A(Foo::T t) { return t; } + typename Foo::T method_A(typename Foo::T t) { return t; } // Use typedef with classname and full template parameter qualifiers - Foo(const Foo::T &, const Foo::T &, Foo::T t) {} - Foo::T method_B(Foo::T t) { return t; } + Foo(const typename Foo::T &, const typename Foo::T &, typename Foo::T t) {} + typename Foo::T method_B(typename Foo::T t) { return t; } // Use typedef with namespace and classname and full template parameter qualifiers - Foo(const Foo::T &, const Foo::T &, const Foo::T &, Foo::T t) {} - Foo::T method_C(Foo::T t) { return t; } + Foo(const typename Foo::T &, const typename Foo::T &, const typename Foo::T &, typename Foo::T t) {} + typename Foo::T method_C(typename Foo::T t) { return t; } }; template class ATemplate {}; From 1fbcafc0ea5b38e091fff7582b48f72037790400 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Apr 2012 07:02:15 +0000 Subject: [PATCH 23/43] Go back to using free/malloc rather than realloc as may be slower git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12999 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/swig.swg | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lib/swig.swg b/Lib/swig.swg index fdcd4e5de..97e7c80a4 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -394,11 +394,11 @@ namespace std { } #else %typemap(memberin) char * { + free($1); if ($input) { - $1 = ($1_type) realloc($1, strlen((const char *)$input)+1); + $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { - free($1); $1 = 0; } } @@ -411,11 +411,11 @@ namespace std { } } %typemap(globalin) char * { + free($1); if ($input) { - $1 = ($1_type) realloc($1, strlen((const char *)$input)+1); + $1 = ($1_type) malloc(strlen((const char *)$input)+1); strcpy((char *)$1, (const char *)$input); } else { - free ($1); $1 = 0; } } From 7615b099d1281f06aecd9092eef93948a0057e5a Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Tue, 17 Apr 2012 12:17:42 +0000 Subject: [PATCH 24/43] [D] Reverted part of #3502431 mistakenly applied in r12948. (The changes only concerned D2, and were already present in trunk.) git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13000 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +-- Lib/d/dhead.swg | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 1cffb5ce9..ba9b723ba 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -31,8 +31,7 @@ Version 2.0.5 (in progress) [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types 2012-03-24: wsfulton - [D] Apply #3502431 to fix duplicate symbols in multiple modules and compiler errors due to lack - of const in some methods taking char*. + [D] Apply #3502431 to fix duplicate symbols in multiple modules. 2012-03-21: wsfulton Fix #3494791 - %$isglobal for %rename matching. diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg index 9b3ec3470..7a2f4fddc 100644 --- a/Lib/d/dhead.swg +++ b/Lib/d/dhead.swg @@ -91,31 +91,31 @@ private class SwigExceptionHelper { &setNoSuchElementException); } - static void setException(const char* message) { + static void setException(char* message) { auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } - static void setIllegalArgumentException(const char* message) { + static void setIllegalArgumentException(char* message) { auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } - static void setIllegalElementException(const char* message) { + static void setIllegalElementException(char* message) { auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } - static void setIOException(const char* message) { + static void setIOException(char* message) { auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); } - static void setNoSuchElementException(const char* message) { + static void setNoSuchElementException(char* message) { auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup); exception.next = SwigPendingException.retrieve(); SwigPendingException.set(exception); @@ -174,7 +174,7 @@ private: alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData; static ThreadLocalData m_sPendingException; } -alias void function(const char* message) SwigExceptionCallback; +alias void function(char* message) SwigExceptionCallback; %} #else %pragma(d) imdmoduleimports=%{ From 4b1fdf5c55e1112922e8a0191e00b6782f036360 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 17 Apr 2012 22:11:38 +0000 Subject: [PATCH 25/43] Add release notes summary for 2.0.5 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13001 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- RELEASENOTES | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RELEASENOTES b/RELEASENOTES index f517b9db2..5b542d4da 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,19 @@ and CHANGES files. Release Notes ============= +SWIG-2.0.5 summary: +- Official Android support added including documentation and examples. +- Improvements involving templates: + 1) Various fixes with templates and typedef types. + 2) Some template lookup problems fixed. + 3) Templated type fixes to use correct typemaps. +- Autodoc documentation generation improvements. +- Python STL container wrappers improvements including addition of + stepped slicing. +- Approximately 70 fixes and minor enhancements for the following + target languages: AllegroCL, C#, D, Go, Java, Lua, Ocaml, Octave, + Perl, PHP, Python, R, Ruby, Tcl, Xml. + SWIG-2.0.4 summary: - This is mainly a Python oriented release including support for Python built-in types for superior performance with the new -builtin option. From 121086fb77bdde585c5e80becb049ded680bdce0 Mon Sep 17 00:00:00 2001 From: Robert Stone Date: Wed, 18 Apr 2012 21:49:32 +0000 Subject: [PATCH 26/43] * revert perl5 li_typemaps run tests due to Windows regressions. * stricter casting to sidestep compiler warnings on Windows. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13002 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- .../test-suite/perl5/li_typemaps_runme.pl | 142 ++++++++---------- Lib/perl5/perlprimtypes.swg | 6 +- 2 files changed, 62 insertions(+), 86 deletions(-) diff --git a/Examples/test-suite/perl5/li_typemaps_runme.pl b/Examples/test-suite/perl5/li_typemaps_runme.pl index 194c98ca3..c182cdbb1 100644 --- a/Examples/test-suite/perl5/li_typemaps_runme.pl +++ b/Examples/test-suite/perl5/li_typemaps_runme.pl @@ -1,99 +1,74 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 631; +use Test::More tests => 415; BEGIN { use_ok('li_typemaps') } require_ok('li_typemaps'); -my @tests = qw( - in inr - out outr - inout inoutr -); - -sub should_pass { my($type, @values) = @_; - # verify that each value passes cleanly - for my $test (@tests) { - my $name = "${test}_${type}"; - my $func = li_typemaps->can($name); - for my $val (@values) { - my $rv = eval { $func->($val) }; - is($rv, $val, "$name $val"); +sub batch { my($type, @values) = @_; + # this is a little ugly because I'm trying to be clever and save my + # wrists from hammering out all these tests. + for my $val (@values) { + for my $tst (qw( + in inr + out outr + inout inoutr + )) { + my $func = $tst . '_' . $type; + is(eval { li_typemaps->can($func)->($val) }, $val, "$func $val"); + if($@) { + my $err = $@; + $err =~ s/^/#\$\@# /mg; + print $err; + } } } } -sub should_fail { my($type, @values) = @_; - # verify that all values trigger runtime errors - for my $test (@tests) { - my $name = "${test}_${type}"; - my $func = li_typemaps->can($name); - for my $val (@values) { - my $rv = eval { $func->($val) }; - like($@, qr/\b(?:Overflow|Type)Error\b/, "overflow $name $val"); - } - } -} +batch('bool', '', 1); +# let's assume we're at least on a 32 bit machine +batch('int', -0x80000000, -1, 0, 1, 12, 0x7fffffff); +# long could be bigger, but it's at least this big +batch('long', -0x80000000, -1, 0, 1, 12, 0x7fffffff); +batch('short', -0x8000, -1, 0, 1, 12, 0x7fff); +batch('uint', 0, 1, 12, 0xffffffff); +batch('ushort', 0, 1, 12, 0xffff); +batch('ulong', 0, 1, 12, 0xffffffff); +batch('uchar', 0, 1, 12, 0xff); +batch('schar', -0x80, 0, 1, 12, 0x7f); -sub pad { my($t, $s, $f) = @_; - my $nbytes = length pack $t, 0; - return unpack $t, $s . ($f x ($nbytes - 1)); +{ + use Math::BigInt qw(); + # the pack dance is to get plain old NVs out of the + # Math::BigInt objects. + my $inf = unpack 'd', pack 'd', Math::BigInt->binf(); + my $nan = unpack 'd', pack 'd', Math::BigInt->bnan(); + batch('float', + -(2 - 2 ** -23) * 2 ** 127, + -1, -2 ** -149, 0, 2 ** -149, 1, + (2 - 2 ** -23) * 2 ** 127, + $nan); + { local $TODO = "float typemaps don't pass infinity"; + # it seems as though SWIG is unwilling to pass infinity around + # because that value always fails bounds checking. I think that + # is a bug. + batch('float', $inf); + } + batch('double', + -(2 - 2 ** -53) ** 1023, + -1, -2 ** -1074, 0, 2 ** 1074, + (2 - 2 ** -53) ** 1023, + $nan, $inf); } - -# some edge case values: -my $nan = unpack 'f>', "\x7f\xc0\x00\x00"; -my $inf = unpack 'f>', "\x7f\x80\x00\x00"; -my $char_min = pad 'c', "\x80"; -my $char_max = pad 'c', "\x7f"; -my $char_umax = pad 'C', "\xff"; -my $short_min = pad 's!>', "\x80", "\x00"; -my $short_max = pad 's!>', "\x7f", "\xff"; -my $short_umax = pad 'S!>', "\xff", "\xff"; -my $int_min = pad 'i!>', "\x80", "\x00"; -my $int_max = pad 'i!>', "\x7f", "\xff"; -my $int_umax = pad 'I!>', "\xff", "\xff"; -my $long_min = pad 'l!>', "\x80", "\x00"; -my $long_max = pad 'l!>', "\x7f", "\xff"; -my $long_umax = pad 'L!>', "\xff", "\xff"; - -should_pass('bool', '', 1); -should_pass('int', $int_min, -1, 0, 1, 12, $int_max); -should_fail('int', $int_min - 1000, $int_max + 1000, $inf, $nan); -should_pass('long', $long_min, -1, 0, 1, 12, $long_max); -should_fail('long', $long_min - 8000, $long_max + 8000, $inf, $nan); -should_pass('short', $short_min, -1, 0, 1, 12, $short_max); -should_fail('short', $short_min - 1, $short_max + 1, $inf, $nan); -should_pass('uint', 0, 1, 12, $int_umax); -should_fail('uint', -1, $int_umax + 1000, $inf, $nan); -should_pass('ushort', 0, 1, 12, $short_umax); -should_fail('ushort', -1, $short_umax + 1, $inf, $nan); -should_pass('ulong', 0, 1, 12, $long_umax); -should_fail('ulong', -1, $long_umax + 8000, $inf, $nan); -should_pass('uchar', 0, 1, 12, $char_umax); -should_fail('uchar', -1, $char_umax + 1, $inf, $nan); -should_pass('schar', $char_min, -1, 0, 1, 12, $char_max); -should_fail('schar', $char_min - 1, $char_max + 1, $inf, $nan); -should_pass('float', -1, 0, 1, $nan); -TODO: { - local $TODO = "typemaps don't allow float infinity"; - should_pass('float', -$inf, $inf); -} -should_pass('double', -$inf, -1, 0, 1, $inf, $nan); -should_pass('longlong', -1, 0, 1, 12); -should_fail('longlong', $inf, $nan); -should_pass('ulonglong', 0, 1, 12); -should_fail('ulonglong', -1, $inf, $nan); +batch('longlong', -1, 0, 1, 12); +batch('ulonglong', 0, 1, 12); SKIP: { - my $llong_min = eval { pad 'q>', "\x80", "\x00" }; - my $llong_max = eval { pad 'q>', "\x7f", "\xff" }; - my $llong_umax = eval { pad 'Q>', "\xff", "\xff" }; - - skip 'not a 64 bit perl', 6 * 6 unless defined $llong_min; - - should_pass('longlong', $llong_min, $llong_max); - should_fail('longlong', $llong_min - 8000, $llong_max + 8000); - should_pass('ulonglong', $llong_umax); - should_fail('ulonglong', $llong_umax + 8000); + my $a = "8000000000000000"; + my $b = "7fffffffffffffff"; + my $c = "ffffffffffffffff"; + skip "not a 64bit Perl", 18 unless eval { pack 'q', 1 }; + batch('longlong', -hex($a), hex($b)); + batch('ulonglong', hex($c)); } my($foo, $int) = li_typemaps::out_foo(10); @@ -104,3 +79,4 @@ is($int, 20); my($a, $b) = li_typemaps::inoutr_int2(13, 31); is($a, 13); is($b, 31); + diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index 9420a2f41..15e8feef3 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -23,7 +23,7 @@ SWIG_AsVal_dec(bool)(SV *obj, bool* val) if (val) *val = false; return SWIG_OK; } else { - if (val) *val = SvTRUE(obj); + if (val) *val = (bool)(SvTRUE(obj)); return SWIG_AddCast(SWIG_OK); } } @@ -171,7 +171,7 @@ SWIG_From_dec(long long)(long long value) { SV *sv; if (value >= IV_MIN && value <= IV_MAX) - sv = newSViv(value); + sv = newSViv((IV)(value)); else { //sv = newSVpvf("%lld", value); doesn't work in non 64bit Perl char temp[256]; @@ -248,7 +248,7 @@ SWIG_From_dec(unsigned long long)(unsigned long long value) { SV *sv; if (value <= UV_MAX) - sv = newSVuv(value); + sv = newSVuv((UV)(value)); else { //sv = newSVpvf("%llu", value); doesn't work in non 64bit Perl char temp[256]; From 40c6b36614e8ccc6ab23336311bd660a8e3a4517 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Apr 2012 06:16:07 +0000 Subject: [PATCH 27/43] Add 2.0.5 release date git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13003 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 4 ++-- Doc/Manual/Sections.html | 2 +- README | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 6f0247f56..f277c63ba 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.5 (in progress) *** +*** ANNOUNCE: SWIG 2.0.5 (19 April 2012) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index ba9b723ba..07dbad9ad 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,8 +2,8 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.5 (in progress) -=========================== +Version 2.0.5 (19 April 2012) +============================= 2012-04-14: wsfulton [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index ebe6fa476..1fb0d1312 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@ -Last update : SWIG-2.0.5 (in progress) +Last update : SWIG-2.0.5 (19 April 2012)

Sections

diff --git a/README b/README index 9eb3bc90c..3d8181ab9 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.5 (in progress) +Version: 2.0.5 (19 April 2012) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, From 56965adb057bb6b7ba2de0dca5635b32b0fe71bc Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Apr 2012 06:35:00 +0000 Subject: [PATCH 28/43] warning fix using vc++ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13004 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/perl5/perlprimtypes.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index 15e8feef3..d7ac6f94e 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -23,7 +23,7 @@ SWIG_AsVal_dec(bool)(SV *obj, bool* val) if (val) *val = false; return SWIG_OK; } else { - if (val) *val = (bool)(SvTRUE(obj)); + if (val) *val = SvTRUE(obj) ? true : false; return SWIG_AddCast(SWIG_OK); } } From 63a6a0e21438cf1b037f778864f19e682d4d70a8 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Apr 2012 07:13:55 +0000 Subject: [PATCH 29/43] Fix symbol name clash under windows in testcase git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13005 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/typemap_various.i | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Examples/test-suite/typemap_various.i b/Examples/test-suite/typemap_various.i index 5fc9fbcc2..2a1777ea8 100644 --- a/Examples/test-suite/typemap_various.i +++ b/Examples/test-suite/typemap_various.i @@ -58,13 +58,13 @@ void foo2(Foo f, const Foo& ff) {} // Test obscure bug where named typemaps where not being applied when symbol name contained a number %typemap(out) double "_typemap_for_double_no_compile_" -%typemap(out) double ABC::meth "$1 = 0.0;" -%typemap(out) double ABC::m1 "$1 = 0.0;" -%typemap(out) double ABC::_x2 "$1 = 0.0;" -%typemap(out) double ABC::y_ "$1 = 0.0;" -%typemap(out) double ABC::_3 "$1 = 0.0;" +%typemap(out) double ABCD::meth "$1 = 0.0;" +%typemap(out) double ABCD::m1 "$1 = 0.0;" +%typemap(out) double ABCD::_x2 "$1 = 0.0;" +%typemap(out) double ABCD::y_ "$1 = 0.0;" +%typemap(out) double ABCD::_3 "$1 = 0.0;" %inline %{ -struct ABC { +struct ABCD { double meth() { return 0.0; } double m1() { return 0.0; } double _x2() { return 0.0; } From 399b4e120bc91b42985c9f81495f875f01f59a0b Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Apr 2012 18:31:46 +0000 Subject: [PATCH 30/43] html corrections git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13006 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Go.html | 4 ++-- Doc/Manual/Lua.html | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index a420b2864..8abeada81 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -102,8 +102,8 @@ swig -go -help -gccgo-46 Generate code for gccgo 4.6. The default is set by the configure - script. This generates code that does not use some facilities - that are only available in gccgo 4.7 and later. + script. This generates code that does not use some facilities + that are only available in gccgo 4.7 and later. diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 8523f8119..699be2bb7 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -75,12 +75,14 @@ eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers t

26.1 Preliminaries

+

The current SWIG implementation is designed to work with Lua 5.0.x, 5.1.x and 5.2.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.

26.2 Running SWIG

+

Suppose that you defined a SWIG module such as the following:

From e464aa021b456425cd6c568cb7407fc0349919a5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 19 Apr 2012 21:30:06 +0000 Subject: [PATCH 31/43] Bump version to 2.0.6 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13009 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 8 +- CHANGES | 440 ++++++++++++++++++++++++++++++++++++++ CHANGES.current | 441 +-------------------------------------- Doc/Manual/Sections.html | 2 +- README | 2 +- configure.in | 2 +- 6 files changed, 449 insertions(+), 446 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index f277c63ba..61f2a70bf 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,8 +1,8 @@ -*** ANNOUNCE: SWIG 2.0.5 (19 April 2012) *** +*** ANNOUNCE: SWIG 2.0.6 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-2.0.5, the latest SWIG release. +We're pleased to announce SWIG-2.0.6, the latest SWIG release. What is SWIG? ============= @@ -21,11 +21,11 @@ Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.5.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.6.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.5.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.6.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CHANGES b/CHANGES index 185d57d45..70af78333 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,446 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. +Version 2.0.5 (19 April 2012) +============================= + +2012-04-14: wsfulton + [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable + +2012-04-14: wsfulton + [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. + +2012-04-13: wsfulton + Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. + +2012-04-13: wsfulton + [Lua] Apply #3219676 from Shane Liesegang which adds: + - support for %factory + - a __tostring method + - a __disown method + +2012-04-13: wsfulton + [Xml] Apply #3513569 which adds a catchlist to the xml output. + +2012-04-05: olly + [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) + +2012-03-26: xavier98 + [octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1) + [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types + +2012-03-24: wsfulton + [D] Apply #3502431 to fix duplicate symbols in multiple modules. + +2012-03-21: wsfulton + Fix #3494791 - %$isglobal for %rename matching. + +2012-03-20: wsfulton + Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import + for STL containers and compiling with g++-4.6. An include of stddef.h is now only + generated when SWIG generates STL helper templates which require ptrdiff_t. If you + were previously relying on "#include " always being generated when using a + %include of an STL header, you may now need to add this in manually. + +2012-03-16: wsfulton + Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment. + +2012-03-16: wsfulton + Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages. + +2012-03-13: wsfulton + Apply patch #3468362 from Karl Wette to fix %include inside %define. + +2012-03-13: wsfulton + [Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations. + +2012-02-27: xavier98 (patches from Karl Wette) + [Octave] Use -globals . to load global variables in module namespace + [Octave] Comment declaration of unimplemented function swig_register_director + [Octave] Fix OCTAVE_PATH in octave Makefiles + [Octave] Add support for std::list - fix li_std_containers_int test + [Octave] Fix imports test + +2012-02-16: wsfulton + [Java] Make generated support functions in arrays_java.i static so that generated code + from multiple instances of SWIG can be compiled and linked together - problem reported by + Evan Krause. + +2012-01-24: wsfulton + Fix crash with bad regex - bug #3474250. + +2012-01-24: wsfulton + [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list). + Assigning to a slice, reading a slice and deleting a slice with steps now work. + For example: + + %template(vector_i) std::vector + + vi = vector_i(range(10)) + print list(vi) + vi[1:4:2] = [111, 333] + print list(vi) + del vi[3:10:3] + print list(vi) + print list(vi[::-1]) + + gives (same behaviour as native Python sequences such as list): + + [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + [0, 111, 2, 333, 4, 5, 6, 7, 8, 9] + [0, 111, 2, 4, 5, 7, 8] + [8, 7, 5, 4, 2, 111, 0] + +2012-01-23: klickverbot + [D] Correctly annotate function pointers with C linkage. + [D] Exception and Error have become blessed names; removed d_exception_name test case. + +2012-01-20: wsfulton + [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg: + + %template(vector_i) std::vector + + iv=vector_i([0,1,2,3,4,5]) + iv[-7:] + + now returns [0, 1, 2, 3, 4, 5] instead of [5]. + + vv[7:9] = [22,33] + + now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error. + + Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper: + + il[0:2] = [11] + +2012-01-17: wsfulton + [Go] Fix forward class declaration within a class when used as a base. + +2012-01-07: wsfulton + [C#] Add support for %nspace when using directors. + +2012-01-06: wsfulton + [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. + +2011-12-21: wsfulton + The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - + $1_name, $2_name etc. + +2011-12-20: wsfulton + [Java] Add (char *STRING, size_t LENGTH) director typemaps. + +2011-12-20: wsfulton + [C#, Go, Java, D] Add support for the 'directorargout' typemap. + +2011-12-20: wsfulton + [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. + This change will break any 'directorargout' typemaps you may have written. Please change: + $result to $1 + $input to $result + + Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't + previously compile and add in $1, $2 etc expansion. + + *** POTENTIAL INCOMPATIBILITY *** + +2011-12-10: talby + [perl5] SWIG_error() now gets decorated with perl source file/line number. + [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). + +2011-12-10: wsfulton + [Android/Java] Fix directors to compile on Android. + + Added documentation and examples for Android. + +2011-12-08: vadz + Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes + (they could be sometimes mysteriously not renamed or ignored there before). + +2011-12-03: klickverbot + [D] Fix exception glue code for newer DMD 2 versions. + [D] Do not default to 32 bit glue code for DMD anymore. + [D] Use stdc.config.c_long/c_ulong to represent C long types. + +2011-12-01: szager + [python] Fixed bug 3447426: memory leak in vector.__getitem__. + +2011-11-30: wsfulton + [R] Remove C++ comments from generated C code. + +2011-11-27: olly + [Python] Fix some warnings when compiling generated wrappers with + certain GCC warning options (Debian bug #650246). + +2011-11-28: wsfulton + Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. + +2011-11-28: olly + [Perl] Fix warnings when compiling generated wrappers with certain + GCC warning options (Debian bug #436711). + +2011-11-28: olly + [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. + +2011-11-25: wsfulton + [C#] Provide an easy way to override the default visibility for the proxy class pointer + constructors and getCPtr() method. The visibility is 'internal' by default and if multiple + SWIG modules are being used and compiled into different assemblies, then they need to be + 'public' in order to use the constructor or getCPtr() method from a different assembly. + Use the following macros to change the visibilities in the proxy and type wrapper class: + + SWIG_CSBODY_PROXY(public, public, SWIGTYPE) + SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) + + [Java] Provide an easy way to override the default visibility for the proxy class pointer + constructors and getCPtr() method. The visibility is 'protected' by default and if multiple + SWIG modules are being used and compiled into different packages, then they need to be + 'public' in order to use the constructor or getCPtr() method from a different package. + Use the following macros to change the visibilities in the proxy and type wrapper class: + + SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) + SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) + + The default for Java has changed from public to protected for the proxy classes. Use the + SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. + + *** POTENTIAL INCOMPATIBILITY *** + +2011-11-22: szager + [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin + isn't being used, to avoid unnecessary binary incompatibilities between + python installations. + +2011-11-17: wsfulton + Bug fix: Remove root directory from directory search list in Windows. + +2011-11-13: wsfulton + [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in + different namespaces confusion when using multiple modules. + +2011-11-11: wsfulton + Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. + +2011-11-03: wsfulton + Expand special variables in typemap warnings, eg: + + %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." + +2011-11-01: wsfulton + Fix named output typemaps not being used when the symbol uses a qualifier and contains + a number, eg: + + %typemap(out) double ABC::m1 "..." + +2011-10-24: talby + [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research + is needed on a stable path for tail calls in XS. + + Also, fix for large long longs in 32 bit perl. + +2011-10-13: xavier98 + [octave] Allow Octave modules to be re-loaded after a "clear all". + +2011-09-19: wsfulton + Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code + when using typedef and function pointer references, for example: + + typedef int FN(const int &a, int b); + void *typedef_call1(FN *& precallback, FN * postcallback); + +2011-09-14: wsfulton + [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) + including options for targeting Lua Tiny RAM (LTR). + +2011-09-14: wsfulton + [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. + +2011-09-13: wsfulton + Add warnings for badly named destructors, eg: + + struct KStruct { + ~NOT_KStruct() {} + }; + + cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. + +2011-09-13: wsfulton + Fix %extend and destructors for templates. The destructor in %extend was not always wrapped, + for example: + + %extend FooT { + ~FooT() { delete $self; } // was not wrapped as expected + }; + template class FooT {}; + %template(FooTi) FooT; + +2011-09-13: wsfulton + Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character. + +2011-09-10: talby + [perl5] SF bug #1481958 - Improve range checking for integer types. + Enhance li_typemaps_runme.pl + +2011-09-08: wsfulton + Fix %extend on typedef classes in a namespace using the typedef name, for example: + namespace Space { + %extend CStruct { + ... + } + typedef struct tagCStruct { ... } CStruct; + } + +2011-08-31: xavier98 + [octave] patches from Karl Wette: improvements to module loading behavior; + added example of friend operator to operator example; fixed octave panic/crash in 3.0.5; + documentation improvements + +2011-08-30: szager + [python] Bug 3400486, fix error signalling for built-in constructors. + +2011-08-26: wsfulton + [Go] Fix file/line number display for "gotype" when using typemap debugging options + -tmsearch and -tmused. + +2011-08-26: wsfulton + [C#, D] Fix %callback which was generating uncompileable code. + +2011-08-25: wsfulton + Fix constructors in named typedef class declarations as reported by Gregory Bronner: + + typedef struct A { + A(){} // Constructor which was not accepted by SWIG + B(){} // NOT a constructor --illegal, but was accepted by SWIG + } B; + + For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in + the generated code when wrapping members in A, but ultimately this does not matter, as + they are the same thing. + +2011-08-23: wsfulton + Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The + code from the "ref" feature was not always being generated for the function specified by %newobject. + Documentation for "ref" and "unref" moved from Python to the C++ chapter. + +2011-08-22: szager + [python] Fixed memory leak with --builtin option (bug 3385089). + +2011-08-22: wsfulton + [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing + the module table into the global namespace. Require call also returns the module table instead + of a string. + +2011-08-09: xavier98 + Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) + +2011-08-04: wsfulton + Add in $symname expansion for director methods. + +2011-07-29: olly + [PHP] Don't generate "return $r;" in cases where $r hasn't been set. + This was basically harmless, except it generated a PHP E_NOTICE if + the calling code had enabled them. + +2011-07-26: wsfulton + Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol + was incorrectly put into the outer namespace, eg + + namespace std { + template struct map { + class iterator; + } + } + + iterator was scoped as std::iterator, but now it is correctly std::map::iterator; + + Also fixed is %template and template parameters that are a typedef when the template contains + default template parameters, eg: + + namespace Std { + template struct Map { + typedef Key key_type; + typedef T mapped_type; + } + } + tyepdef double DOUBLE; + %typemap(MM) Std::Map; + + All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the + wrapped code uses Std::Map or std::Map or Std::Map + + Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. + +2011-07-20 szager + [python] Fix closure for tp_call slot. + +2011-07-16: wsfulton + [python] Fix director typemap using PyObject *. + +2011-07-13: szager + [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i + +2011-07-13: szager + [python] Fix for bug 3324753: %rename member variables with -builtin. + +2011-07-01: wsfulton + Fix some scope and symbol lookup problems when template default parameters are being + used with typedef. For example: + + template struct Foo { + typedef XX X; + typedef TT T; + }; + template struct UsesFoo { + void x(typename Foo::T, typename Foo::X); + }; + + Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. + +2011-06-23: olly + [PHP] Fix director code to work when PHP is built with ZTS enabled, + which is the standard configuration on Microsoft Windows. + +2011-06-21: mutandiz + [allegrocl] + - various small tweaks and bug fixes. + - Avoid name conflicts between smart pointer wrappers and the wrappers for + the actual class. + - Fix default typemaps for C bindings, which were incorrectly attempting to + call non-existent destructors on user-defined types. + - New feature, feature:aclmixins, for adding superclass to the foreign class + wrappers. + - Improve longlong typemaps. + +2011-06-19: wsfulton + Fix incorrect typemaps being used for a symbol within a templated type, eg: + A::value_type would incorrectly use a typemap for type A. + +2011-06-18: olly + [Tcl] Fix variable declarations in middle of blocks which isn't + permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). + Reported by Paul Obermeier in SF#3288586. + +2011-06-17: wsfulton + [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] + using arrays_java.i. + +2011-06-13: wsfulton + [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. + +2011-06-10: wsfulton + [Python] Few subtle bugfixes in autodoc documentation generation, + - Unnamed argument names fix for autodoc levels > 0. + - Display of template types fixed for autodoc levels > 1. + - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. + - Add missing type for self for autodoc levels 1 and 3. + - autodoc levels 2 and 3 documented. + - Minor tweaks to autodoc style to conform with PEP8. + +2011-05-30: olly + [PHP] Fix handling of directors when -prefix is used. + +2011-05-24: olly + [PHP] Fix handling of methods of classes with a virtual base class (SF#3124665). + Version 2.0.4 (21 May 2011) =========================== diff --git a/CHANGES.current b/CHANGES.current index 07dbad9ad..0b7de2539 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,443 +2,6 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.5 (19 April 2012) -============================= - -2012-04-14: wsfulton - [Lua] Apply patch #3517435 from Miles Bader - prefer to use Lua_pushglobaltable - -2012-04-14: wsfulton - [Ruby] Apply patch #3517769 from Robin Stocker to fix compile error on MacRuby using RSTRING_PTR. - -2012-04-13: wsfulton - Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers. - -2012-04-13: wsfulton - [Lua] Apply #3219676 from Shane Liesegang which adds: - - support for %factory - - a __tostring method - - a __disown method - -2012-04-13: wsfulton - [Xml] Apply #3513569 which adds a catchlist to the xml output. - -2012-04-05: olly - [Lua] Add support for Lua 5.2 (patch SF#3514593 from Miles Bader) - -2012-03-26: xavier98 - [octave] Apply patch #3425993 from jgillis: add extra logic to the octave_swig_type::dims(void) method: it checks if the user has defined a __dims__ method and uses this in stead of returning (1,1) - [octave] Apply patch #3424833 from jgillis: make is_object return true for swig types - -2012-03-24: wsfulton - [D] Apply #3502431 to fix duplicate symbols in multiple modules. - -2012-03-21: wsfulton - Fix #3494791 - %$isglobal for %rename matching. - -2012-03-20: wsfulton - Fix #3487706 and #3391906 - missing stddef.h include for ptrdiff_t when using %import - for STL containers and compiling with g++-4.6. An include of stddef.h is now only - generated when SWIG generates STL helper templates which require ptrdiff_t. If you - were previously relying on "#include " always being generated when using a - %include of an STL header, you may now need to add this in manually. - -2012-03-16: wsfulton - Apply patch #3392264 from Sebastien Bine to parse (unsigned) long long types in enum value assignment. - -2012-03-16: wsfulton - Apply patch #3505530 from Karl Wette to allow custom allocators in STL string classes for the UTL languages. - -2012-03-13: wsfulton - Apply patch #3468362 from Karl Wette to fix %include inside %define. - -2012-03-13: wsfulton - [Python, Ruby, Octave, R] Fix #3475492 - iterating through std::vector wrappers of enumerations. - -2012-02-27: xavier98 (patches from Karl Wette) - [Octave] Use -globals . to load global variables in module namespace - [Octave] Comment declaration of unimplemented function swig_register_director - [Octave] Fix OCTAVE_PATH in octave Makefiles - [Octave] Add support for std::list - fix li_std_containers_int test - [Octave] Fix imports test - -2012-02-16: wsfulton - [Java] Make generated support functions in arrays_java.i static so that generated code - from multiple instances of SWIG can be compiled and linked together - problem reported by - Evan Krause. - -2012-01-24: wsfulton - Fix crash with bad regex - bug #3474250. - -2012-01-24: wsfulton - [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list). - Assigning to a slice, reading a slice and deleting a slice with steps now work. - For example: - - %template(vector_i) std::vector - - vi = vector_i(range(10)) - print list(vi) - vi[1:4:2] = [111, 333] - print list(vi) - del vi[3:10:3] - print list(vi) - print list(vi[::-1]) - - gives (same behaviour as native Python sequences such as list): - - [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] - [0, 111, 2, 333, 4, 5, 6, 7, 8, 9] - [0, 111, 2, 4, 5, 7, 8] - [8, 7, 5, 4, 2, 111, 0] - -2012-01-23: klickverbot - [D] Correctly annotate function pointers with C linkage. - [D] Exception and Error have become blessed names; removed d_exception_name test case. - -2012-01-20: wsfulton - [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg: - - %template(vector_i) std::vector - - iv=vector_i([0,1,2,3,4,5]) - iv[-7:] - - now returns [0, 1, 2, 3, 4, 5] instead of [5]. - - vv[7:9] = [22,33] - - now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error. - - Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper: - - il[0:2] = [11] - -2012-01-17: wsfulton - [Go] Fix forward class declaration within a class when used as a base. - -2012-01-07: wsfulton - [C#] Add support for %nspace when using directors. - -2012-01-06: wsfulton - [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors. - -2011-12-21: wsfulton - The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds - - $1_name, $2_name etc. - -2011-12-20: wsfulton - [Java] Add (char *STRING, size_t LENGTH) director typemaps. - -2011-12-20: wsfulton - [C#, Go, Java, D] Add support for the 'directorargout' typemap. - -2011-12-20: wsfulton - [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap. - This change will break any 'directorargout' typemaps you may have written. Please change: - $result to $1 - $input to $result - - Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't - previously compile and add in $1, $2 etc expansion. - - *** POTENTIAL INCOMPATIBILITY *** - -2011-12-10: talby - [perl5] SWIG_error() now gets decorated with perl source file/line number. - [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue). - -2011-12-10: wsfulton - [Android/Java] Fix directors to compile on Android. - - Added documentation and examples for Android. - -2011-12-08: vadz - Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes - (they could be sometimes mysteriously not renamed or ignored there before). - -2011-12-03: klickverbot - [D] Fix exception glue code for newer DMD 2 versions. - [D] Do not default to 32 bit glue code for DMD anymore. - [D] Use stdc.config.c_long/c_ulong to represent C long types. - -2011-12-01: szager - [python] Fixed bug 3447426: memory leak in vector.__getitem__. - -2011-11-30: wsfulton - [R] Remove C++ comments from generated C code. - -2011-11-27: olly - [Python] Fix some warnings when compiling generated wrappers with - certain GCC warning options (Debian bug #650246). - -2011-11-28: wsfulton - Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments. - -2011-11-28: olly - [Perl] Fix warnings when compiling generated wrappers with certain - GCC warning options (Debian bug #436711). - -2011-11-28: olly - [PHP] Update keyword list to include keywords added in PHP releases up to 5.3. - -2011-11-25: wsfulton - [C#] Provide an easy way to override the default visibility for the proxy class pointer - constructors and getCPtr() method. The visibility is 'internal' by default and if multiple - SWIG modules are being used and compiled into different assemblies, then they need to be - 'public' in order to use the constructor or getCPtr() method from a different assembly. - Use the following macros to change the visibilities in the proxy and type wrapper class: - - SWIG_CSBODY_PROXY(public, public, SWIGTYPE) - SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE) - - [Java] Provide an easy way to override the default visibility for the proxy class pointer - constructors and getCPtr() method. The visibility is 'protected' by default and if multiple - SWIG modules are being used and compiled into different packages, then they need to be - 'public' in order to use the constructor or getCPtr() method from a different package. - Use the following macros to change the visibilities in the proxy and type wrapper class: - - SWIG_JAVABODY_PROXY(public, public, SWIGTYPE) - SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE) - - The default for Java has changed from public to protected for the proxy classes. Use the - SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities. - - *** POTENTIAL INCOMPATIBILITY *** - -2011-11-22: szager - [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin - isn't being used, to avoid unnecessary binary incompatibilities between - python installations. - -2011-11-17: wsfulton - Bug fix: Remove root directory from directory search list in Windows. - -2011-11-13: wsfulton - [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in - different namespaces confusion when using multiple modules. - -2011-11-11: wsfulton - Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely. - -2011-11-03: wsfulton - Expand special variables in typemap warnings, eg: - - %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..." - -2011-11-01: wsfulton - Fix named output typemaps not being used when the symbol uses a qualifier and contains - a number, eg: - - %typemap(out) double ABC::m1 "..." - -2011-10-24: talby - [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research - is needed on a stable path for tail calls in XS. - - Also, fix for large long longs in 32 bit perl. - -2011-10-13: xavier98 - [octave] Allow Octave modules to be re-loaded after a "clear all". - -2011-09-19: wsfulton - Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code - when using typedef and function pointer references, for example: - - typedef int FN(const int &a, int b); - void *typedef_call1(FN *& precallback, FN * postcallback); - -2011-09-14: wsfulton - [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua) - including options for targeting Lua Tiny RAM (LTR). - -2011-09-14: wsfulton - [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571. - -2011-09-13: wsfulton - Add warnings for badly named destructors, eg: - - struct KStruct { - ~NOT_KStruct() {} - }; - - cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored. - -2011-09-13: wsfulton - Fix %extend and destructors for templates. The destructor in %extend was not always wrapped, - for example: - - %extend FooT { - ~FooT() { delete $self; } // was not wrapped as expected - }; - template class FooT {}; - %template(FooTi) FooT; - -2011-09-13: wsfulton - Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character. - -2011-09-10: talby - [perl5] SF bug #1481958 - Improve range checking for integer types. - Enhance li_typemaps_runme.pl - -2011-09-08: wsfulton - Fix %extend on typedef classes in a namespace using the typedef name, for example: - namespace Space { - %extend CStruct { - ... - } - typedef struct tagCStruct { ... } CStruct; - } - -2011-08-31: xavier98 - [octave] patches from Karl Wette: improvements to module loading behavior; - added example of friend operator to operator example; fixed octave panic/crash in 3.0.5; - documentation improvements - -2011-08-30: szager - [python] Bug 3400486, fix error signalling for built-in constructors. - -2011-08-26: wsfulton - [Go] Fix file/line number display for "gotype" when using typemap debugging options - -tmsearch and -tmused. - -2011-08-26: wsfulton - [C#, D] Fix %callback which was generating uncompileable code. - -2011-08-25: wsfulton - Fix constructors in named typedef class declarations as reported by Gregory Bronner: - - typedef struct A { - A(){} // Constructor which was not accepted by SWIG - B(){} // NOT a constructor --illegal, but was accepted by SWIG - } B; - - For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in - the generated code when wrapping members in A, but ultimately this does not matter, as - they are the same thing. - -2011-08-23: wsfulton - Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The - code from the "ref" feature was not always being generated for the function specified by %newobject. - Documentation for "ref" and "unref" moved from Python to the C++ chapter. - -2011-08-22: szager - [python] Fixed memory leak with --builtin option (bug 3385089). - -2011-08-22: wsfulton - [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing - the module table into the global namespace. Require call also returns the module table instead - of a string. - -2011-08-09: xavier98 - Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette) - -2011-08-04: wsfulton - Add in $symname expansion for director methods. - -2011-07-29: olly - [PHP] Don't generate "return $r;" in cases where $r hasn't been set. - This was basically harmless, except it generated a PHP E_NOTICE if - the calling code had enabled them. - -2011-07-26: wsfulton - Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol - was incorrectly put into the outer namespace, eg - - namespace std { - template struct map { - class iterator; - } - } - - iterator was scoped as std::iterator, but now it is correctly std::map::iterator; - - Also fixed is %template and template parameters that are a typedef when the template contains - default template parameters, eg: - - namespace Std { - template struct Map { - typedef Key key_type; - typedef T mapped_type; - } - } - tyepdef double DOUBLE; - %typemap(MM) Std::Map; - - All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the - wrapped code uses Std::Map or std::Map or Std::Map - - Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits. - -2011-07-20 szager - [python] Fix closure for tp_call slot. - -2011-07-16: wsfulton - [python] Fix director typemap using PyObject *. - -2011-07-13: szager - [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i - -2011-07-13: szager - [python] Fix for bug 3324753: %rename member variables with -builtin. - -2011-07-01: wsfulton - Fix some scope and symbol lookup problems when template default parameters are being - used with typedef. For example: - - template struct Foo { - typedef XX X; - typedef TT T; - }; - template struct UsesFoo { - void x(typename Foo::T, typename Foo::X); - }; - - Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard. - -2011-06-23: olly - [PHP] Fix director code to work when PHP is built with ZTS enabled, - which is the standard configuration on Microsoft Windows. - -2011-06-21: mutandiz - [allegrocl] - - various small tweaks and bug fixes. - - Avoid name conflicts between smart pointer wrappers and the wrappers for - the actual class. - - Fix default typemaps for C bindings, which were incorrectly attempting to - call non-existent destructors on user-defined types. - - New feature, feature:aclmixins, for adding superclass to the foreign class - wrappers. - - Improve longlong typemaps. - -2011-06-19: wsfulton - Fix incorrect typemaps being used for a symbol within a templated type, eg: - A::value_type would incorrectly use a typemap for type A. - -2011-06-18: olly - [Tcl] Fix variable declarations in middle of blocks which isn't - permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663). - Reported by Paul Obermeier in SF#3288586. - -2011-06-17: wsfulton - [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[] - using arrays_java.i. - -2011-06-13: wsfulton - [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python. - -2011-06-10: wsfulton - [Python] Few subtle bugfixes in autodoc documentation generation, - - Unnamed argument names fix for autodoc levels > 0. - - Display of template types fixed for autodoc levels > 1. - - Fix SF #3310528 - display of typedef structs for autodoc levels > 1. - - Add missing type for self for autodoc levels 1 and 3. - - autodoc levels 2 and 3 documented. - - Minor tweaks to autodoc style to conform with PEP8. - -2011-05-30: olly - [PHP] Fix handling of directors when -prefix is used. - -2011-05-24: olly - [PHP] Fix handling of methods of classes with a virtual base class (SF#3124665). +Version 2.0.6 (in progress) +=========================== diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 1fb0d1312..c6651349b 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

SWIG-2.0 Documentation

-Last update : SWIG-2.0.5 (19 April 2012) +Last update : SWIG-2.0.6 (in progress)

Sections

diff --git a/README b/README index 3d8181ab9..bd5f8ae4b 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.5 (19 April 2012) +Version: 2.0.6 (in progress) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, diff --git a/configure.in b/configure.in index 67c3bc982..77791bd02 100644 --- a/configure.in +++ b/configure.in @@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script. dnl The macros which aren't shipped with the autotools are stored in the dnl Tools/config directory in .m4 files. -AC_INIT([swig],[2.0.5],[http://www.swig.org]) +AC_INIT([swig],[2.0.6],[http://www.swig.org]) dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl definition below can be removed From 2f5fc8dd2dc4e86d5b75574734177eb4ee6d8bfc Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 20 Apr 2012 23:32:48 +0000 Subject: [PATCH 32/43] Fix typos git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13011 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Lua.html | 60 ++++++++++++++++++++++----------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index 699be2bb7..cccb5d889 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -67,7 +67,7 @@

-Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org +Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). It's also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org

eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net @@ -110,7 +110,7 @@ $ swig -c++ -lua example.i This creates a C/C++ source file example_wrap.c or example_wrap.cxx. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.

-The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module. +The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrapped module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.

To build an eLua module, run SWIG using -lua and add either -elua or -eluac. @@ -185,7 +185,7 @@ int main(int argc,char* argv[]) } L=lua_open(); luaopen_base(L); // load basic libs (eg. print) - luaopen_example(L); // load the wrappered module + luaopen_example(L); // load the wrapped module if (luaL_loadfile(L,argv[1])==0) // load and run the file lua_pcall(L,0,0,0); else @@ -278,10 +278,10 @@ print(a,b,c)

Note: for Lua 5.0:
-The loadlib() function is in the global namespace, not in package. So its just loadlib(). +The loadlib() function is in the global namespace, not in a package. So it's just loadlib().

-if 'a' is a function, this its all working fine, all you need to do is call it +if 'a' is a function, this is all working fine, all you need to do is call it

   a()
@@ -290,7 +290,7 @@ if 'a' is a function, this its all working fine, all you need to do is call it
 to load your library which will add a table 'example' with all the functions added.
 

-If it doesn't work, look at the error messages, in particular mesage 'b'
+If it doesn't work, look at the error messages, in particular message 'b'
The specified module could not be found.
Means that is cannot find the module, check your the location and spelling of the module.
The specified procedure could not be found.
@@ -395,7 +395,7 @@ SWIG will effectively generate two functions example.Foo_set() and 4 5

-Its is therefore not possible to 'move' the global variable into the global namespace as it is with functions. It is however, possible to rename the module with an assignment, to make it more convenient. +It is therefore not possible to 'move' the global variable into the global namespace as it is with functions. It is however, possible to rename the module with an assignment, to make it more convenient.

 > e=example
@@ -406,7 +406,7 @@ Its is therefore not possible to 'move' the global variable into the global name
 4
 

-If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Lua error. Given a global variable: +If a variable is marked with the %immutable directive then any attempts to set this variable will cause a Lua error. Given a global variable:

%module example
@@ -512,13 +512,13 @@ When wrapped, you will be able to use the functions in a natural way from Lua. F
 > example.fclose(f)
 

-Unlike many scripting languages, Lua has had support for pointers to C/C++ object built in for a long time. They are called 'userdata'. Unlike many other SWIG versions which use some kind of encoded character string, all objects will be represented as a userdata. The SWIG-Lua bindings provides a special function swig_type(), which if given a userdata object will return the type of object pointed to as a string (assuming it was a SWIG wrappered object). +Unlike many scripting languages, Lua has had support for pointers to C/C++ object built in for a long time. They are called 'userdata'. Unlike many other SWIG versions which use some kind of encoded character string, all objects will be represented as a userdata. The SWIG-Lua bindings provides a special function swig_type(), which if given a userdata object will return the type of object pointed to as a string (assuming it was a SWIG wrapped object).

 > print(f)
 userdata: 003FDA80
 > print(swig_type(f))
-FILE * -- its a FILE*
+FILE * -- it's a FILE*
 

Lua enforces the integrity of its userdata, so it is virtually impossible to corrupt the data. But as the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes & structs (see below). One final note: if a function returns a NULL pointer, this is not encoded as a userdata, but as a Lua nil. @@ -562,10 +562,10 @@ If you print out the value of p in the above example, you will see something lik userdata: 003FA320

-Like the pointer in the previous section, this is held as a userdata. However, additional features have been added to make this more usable. SWIG effectivly creates some accessor/mutator functions to get and set the data. These functions will be added to the userdata's metatable. This provides the natural access to the member variables that were shown above (see end of the document for full details). +Like the pointer in the previous section, this is held as a userdata. However, additional features have been added to make this more usable. SWIG effectively creates some accessor/mutator functions to get and set the data. These functions will be added to the userdata's metatable. This provides the natural access to the member variables that were shown above (see end of the document for full details).

-const members of a structure are read-only. Data members can also be forced to be read-only using the immutable directive. As with other immutable's, setting attempts will be cause an error. For example: +const members of a structure are read-only. Data members can also be forced to be read-only using the immutable directive. As with other immutables, setting attempts will be cause an error. For example:

struct Foo {
    ...
@@ -688,7 +688,7 @@ In Lua, the static members can be accessed as follows:
 It is not (currently) possible to access static members of an instance:
 

-> s=example.Spam()      -- s is a Spam instance
+> s=example.Spam()              -- s is a Spam instance
 > s.foo()                       -- Spam::foo() via an instance
                                 -- does NOT work
 
@@ -1185,7 +1185,7 @@ void throw_A() throw(A*) { }

-SWIG will just convert it (poorly) to a string and use that as its error. (This is not that useful, but it always works). +SWIG will just convert it (poorly) to a string and use that as its error. (This is not that useful, but it always works).

@@ -1261,7 +1261,7 @@ add exception specification to functions or globally (respectively).
 

26.4 Typemaps

-

This section explains what typemaps are and the usage of them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect

+

This section explains what typemaps are and how to use them. The default wrapping behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrapping. This section will be explaining how to use typemaps to best effect

26.4.1 What is a typemap?

@@ -1357,8 +1357,8 @@ extern void sort_double(double* arr, int len);

There are basically two ways that SWIG can deal with this. The first way, uses the <carrays.i> library -to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious. -More details can be found in the carrays.i documention.

+to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but it's a bit tedious. +More details can be found in the carrays.i documentation.

The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

@@ -1378,7 +1378,7 @@ extern void sort_int(int* arr, int len); // the function to wrap extern void sort_double(double* arr, int len); // the function to wrap -

Once wrappered, the functions can both be called, though with different ease of use:

+

Once wrapped, the functions can both be called, though with different ease of use:

require "example"
 ARRAY_SIZE=10
@@ -1430,7 +1430,7 @@ free(ptr); // dispose of iMath
 

SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrapping as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:

%include <typemaps.i>
-%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
+%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG it's an output
 
 struct iMath;    // some structure
 int Create_Math(iMath** pptr); // its creator (assume it mallocs)
@@ -1438,7 +1438,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
 
 

The usage is as follows:

-
ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int (ok)
+
ok,ptr=Create_Math() -- ptr is an iMath* which is returned with the int (ok)
 ptr=nil -- the iMath* will be GC'ed as normal
 
@@ -1449,7 +1449,7 @@ ptr=nil -- the iMath* will be GC'ed as normal

Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrapping, or to achieve an effect which in not available with the default bindings.

-

Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).

+

Before proceeding, you should read the previous section on using typemaps, and look at the existing typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you an idea to base your work on).

26.5.1 Typemaps you can write

@@ -1545,7 +1545,7 @@ The %native directive in the above example, tells SWIG that there is a

-As well as adding additional C/C++ code, its also possible to add your own Lua code to the module as well. +As well as adding additional C/C++ code, it's also possible to add your own Lua code to the module as well. This code is executed once all other initialisation, including the %init code has been called.

@@ -1570,7 +1570,7 @@ module name added.

Should there be an error in the Lua code, this will not stop loading of the module. -The default behaviour of SWIG is to print a error message to stderr and then continue. +The default behaviour of SWIG is to print an error message to stderr and then continue. It is possible to change this behaviour by using a #define SWIG_DOSTRING_FAIL(STR) to define a different behaviour should the code fail.

@@ -1657,7 +1657,7 @@ That way when you call 'a=example.Foo', the interpreter looks at the ta As mentioned earlier, classes and structures, are all held as pointer, using the Lua 'userdata' structure. This structure is actually a pointer to a C structure 'swig_lua_userdata', which contains the pointer to the data, a pointer to the swig_type_info (an internal SWIG struct) and a flag which marks if the object is to be disposed of when the interpreter no longer needs it. The actual accessing of the object is done via the metatable attached to this userdata.

-The metatable is a Lua 5.0 feature (which is also why SWIG cannot wrap Lua 4.0). Its a table which holds a list of functions, operators and attributes. This is what gives the userdata the feeling that it is a real object and not just a hunk of memory. +The metatable is a Lua 5.0 feature (which is also why SWIG cannot wrap Lua 4.0). It's a table which holds a list of functions, operators and attributes. This is what gives the userdata the feeling that it is a real object and not just a hunk of memory.

Given a class @@ -1674,10 +1674,10 @@ public: };

-SWIG will create a module excpp, with all the various function inside. However to allow the intuitive use of the userdata is also creates up a set of metatables. As seen in the above section on global variables, use of the metatables allows for wrappers to be used intuitively. To save effort, the code creates one metatable per class and stores it inside Lua's registry. Then when an new object is instantiated, the metatable is found in the registry and the userdata associated to the metatable. Currently derived classes make a complete copy of the base classes table and then add on their own additional function. +SWIG will create a module excpp, with all the various functions inside. However to allow the intuitive use of the userdata, SWIG also creates up a set of metatables. As seen in the above section on global variables, use of the metatables allows for wrappers to be used intuitively. To save effort, the code creates one metatable per class and stores it inside Lua's registry. Then when a new object is instantiated, the metatable is found in the registry and the userdata associated with the metatable. Currently, derived classes make a complete copy of the base class' table and then add on their own additional functions.

-Some of the internals can be seen by looking at a classes metatable. +Some of the internals can be seen by looking at the metatable of a class:

 > p=excpp.Point()
@@ -1694,7 +1694,7 @@ __index function: 003FB698
 .fn     table: 003FB528
 

-The '.type' attribute is the name of the class. The '.get' and '.set' tables work in a similar manner to the modules, the main difference is the '.fn' table which also holds all the member functions. (The '__gc' function is the classes destructor function) +The '.type' attribute is the name of the class. The '.get' and '.set' tables work in a similar manner to the modules, the main difference is the '.fn' table which also holds all the member functions. (The '__gc' function is the class' destructor function)

The Lua equivalent of the code for enabling functions looks a little like this @@ -1708,7 +1708,7 @@ function __index(obj,name) local f=g[name] -- looks for the get_attribute function -- calls it & returns the value if type(f)=="function" then return f() end - -- ok, so it not an attribute, maybe its a function + -- ok, so it not an attribute, maybe it's a function local fn=m['.fn'] -- gets the function table if not fn then return nil end local f=fn[name] -- looks for the function @@ -1728,7 +1728,7 @@ In theory, you can play with this usertable & add new features, but remember Note: Both the opaque structures (like the FILE*) and normal wrapped classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them.

-Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload. +Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the class' metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.

26.7.3 Memory management

@@ -1740,7 +1740,7 @@ Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully It is currently not recommended to edit this field or add some user code, to change the behaviour. Though for those who wish to try, here is where to look.

-It is also currently not possible to change the ownership flag on the data (unlike most other scripting languages, Lua does not permit access to the data from within the interpreter) +It is also currently not possible to change the ownership flag on the data (unlike most other scripting languages, Lua does not permit access to the data from within the interpreter).

From dc7818db818fe049af451eb2dadd1c362edacf13 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Apr 2012 18:37:53 +0000 Subject: [PATCH 33/43] Add missing Lua factory.i for patch #3219676 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13014 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/lua/factory.i | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Lib/lua/factory.i diff --git a/Lib/lua/factory.i b/Lib/lua/factory.i new file mode 100644 index 000000000..7e605c5d5 --- /dev/null +++ b/Lib/lua/factory.i @@ -0,0 +1,23 @@ +/* + A modification of factory.swg from the generic UTL library. +*/ + +%include + +%define %_factory_dispatch(Type) +if (!dcast) { + Type *dobj = dynamic_cast($1); + if (dobj) { + dcast = 1; + SWIG_NewPointerObj(L, dobj, $descriptor(Type *), $owner); SWIG_arg++; + } +}%enddef + +%define %factory(Method,Types...) +%typemap(out) Method { + int dcast = 0; + %formacro(%_factory_dispatch, Types) + if (!dcast) { + SWIG_NewPointerObj(L, $1, $descriptor, $owner); SWIG_arg++; + } +}%enddef From 1bc105bd724e54c93b3d8c1050994f91595370f5 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Tue, 24 Apr 2012 18:56:16 +0000 Subject: [PATCH 34/43] Add missing Lua factory.i test for patch #3219676 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13015 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Examples/test-suite/lua/li_factory_runme.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Examples/test-suite/lua/li_factory_runme.lua diff --git a/Examples/test-suite/lua/li_factory_runme.lua b/Examples/test-suite/lua/li_factory_runme.lua new file mode 100644 index 000000000..794959eb6 --- /dev/null +++ b/Examples/test-suite/lua/li_factory_runme.lua @@ -0,0 +1,16 @@ +require("import") -- the import fn +import("li_factory") -- import code + +-- moving to global +for k,v in pairs(li_factory) do _G[k]=v end + +-- catch "undefined" global variables +setmetatable(getfenv(),{__index=function (t,i) error("undefined global variable `"..i.."'",2) end}) + +circle = Geometry_create(Geometry_CIRCLE) +r = circle:radius() +assert(r == 1.5) + +point = Geometry_create(Geometry_POINT) +w = point:width() +assert(w == 1.0) From 60b9635c79e752243857961c3b4b95e1fe4570c6 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 25 Apr 2012 05:53:14 +0000 Subject: [PATCH 35/43] Fix uninitialised variable in Lua SWIGTYPE **OUTPUT typemaps git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13016 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 +++ Lib/lua/typemaps.i | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.current b/CHANGES.current index 0b7de2539..df57de6e7 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,3 +5,6 @@ See the RELEASENOTES file for a summary of changes in each release. Version 2.0.6 (in progress) =========================== +2012-04-25: wsfulton + [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. + diff --git a/Lib/lua/typemaps.i b/Lib/lua/typemaps.i index 180d17fd6..63cb49a0d 100644 --- a/Lib/lua/typemaps.i +++ b/Lib/lua/typemaps.i @@ -557,7 +557,8 @@ ptr=nil -- the iMath* will be GC'ed as normal */ %typemap(in,numinputs=0) SWIGTYPE** OUTPUT ($*ltype temp) -%{ $1 = &temp; %} +%{ temp = ($*ltype)0; + $1 = &temp; %} %typemap(argout) SWIGTYPE** OUTPUT %{SWIG_NewPointerObj(L,*$1,$*descriptor,1); SWIG_arg++; %} From e39322cd01b3edbaf2b01891f5ad7af3ae78503c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Apr 2012 11:18:10 +0000 Subject: [PATCH 36/43] Fix STL wrapper compilation errors on Mac OSX 64bit git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13018 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 3 ++ Lib/python/pycontainer.swg | 58 +++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index df57de6e7..a2ebf35f9 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -8,3 +8,6 @@ Version 2.0.6 (in progress) 2012-04-25: wsfulton [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. +2012-04-28: wsfulton + [Python] Fix compilation errors when wrapping STL containers on Mac OSX 64 bit. + diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 779816059..4a2a2f66e 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -188,8 +188,9 @@ namespace swig { } namespace swig { + template inline size_t - check_index(ptrdiff_t i, size_t size, bool insert = false) { + check_index(Difference i, size_t size, bool insert = false) { if ( i < 0 ) { if ((size_t) (-i) <= size) return (size_t) (i + size); @@ -201,37 +202,38 @@ namespace swig { throw std::out_of_range("index out of range"); } + template void - slice_adjust(ptrdiff_t i, ptrdiff_t j, ptrdiff_t step, size_t size, ptrdiff_t &ii, ptrdiff_t &jj, bool insert = false) { + slice_adjust(Difference i, Difference j, Difference step, size_t size, Difference &ii, Difference &jj, bool insert = false) { if (step == 0) { throw std::invalid_argument("slice step cannot be zero"); } else if (step > 0) { // Required range: 0 <= i < size, 0 <= j < size if (i < 0) { ii = 0; - } else if (i < (ptrdiff_t)size) { + } else if (i < (Difference)size) { ii = i; - } else if (insert && (i >= (ptrdiff_t)size)) { - ii = (ptrdiff_t)size; + } else if (insert && (i >= (Difference)size)) { + ii = (Difference)size; } if ( j < 0 ) { jj = 0; } else { - jj = (j < (ptrdiff_t)size) ? j : (ptrdiff_t)size; + jj = (j < (Difference)size) ? j : (Difference)size; } } else { // Required range: -1 <= i < size-1, -1 <= j < size-1 if (i < -1) { ii = -1; - } else if (i < (ptrdiff_t) size) { + } else if (i < (Difference) size) { ii = i; - } else if (i >= (ptrdiff_t)(size-1)) { - ii = (ptrdiff_t)(size-1); + } else if (i >= (Difference)(size-1)) { + ii = (Difference)(size-1); } if (j < -1) { jj = -1; } else { - jj = (j < (ptrdiff_t)size ) ? j : (ptrdiff_t)(size-1); + jj = (j < (Difference)size ) ? j : (Difference)(size-1); } } } @@ -797,8 +799,7 @@ namespace swig return swig::getslice(self, i, j, 1); } - void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) - throw (std::out_of_range, std::invalid_argument) { + void __setslice__(difference_type i, difference_type j, const Sequence& v = Sequence()) throw (std::out_of_range, std::invalid_argument) { swig::setslice(self, i, j, 1, v); } @@ -821,41 +822,46 @@ namespace swig SWIG_Error(SWIG_TypeError, "Slice object expected."); return NULL; } - PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step); - return swig::getslice(self, i, j, step); + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + return swig::getslice(self, id, jd, step); } - void __setitem__(PySliceObject *slice, const Sequence& v) - throw (std::out_of_range, std::invalid_argument) { + void __setitem__(PySliceObject *slice, const Sequence& v) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } - PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step); - swig::setslice(self, i, j, step, v); + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + swig::setslice(self, id, jd, step, v); } - void __setitem__(PySliceObject *slice) - throw (std::out_of_range, std::invalid_argument) { + void __setitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } - PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step); - swig::delslice(self, i, j, step); + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + swig::delslice(self, id, jd, step); } - void __delitem__(PySliceObject *slice) - throw (std::out_of_range, std::invalid_argument) { + void __delitem__(PySliceObject *slice) throw (std::out_of_range, std::invalid_argument) { Py_ssize_t i, j, step; if( !PySlice_Check(slice) ) { SWIG_Error(SWIG_TypeError, "Slice object expected."); return; } - PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), self->size(), &i, &j, &step); - swig::delslice(self, i, j, step); + PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step); + Sequence::difference_type id = i; + Sequence::difference_type jd = j; + swig::delslice(self, id, jd, step); } } From c13131986ec75ed2e17f3607a7c4ddf463c20317 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Apr 2012 11:39:13 +0000 Subject: [PATCH 37/43] Warning fix in python STL wrappers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13019 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pycontainer.swg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 4a2a2f66e..a9862cc73 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -331,7 +331,7 @@ namespace swig { size_t replacecount = (jj - ii + step - 1) / step; if (is.size() != replacecount) { char msg[1024]; - sprintf(msg, "attempt to assign sequence of size %d to extended slice of size %d", is.size(), replacecount); + sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); throw std::invalid_argument(msg); } typename Sequence::const_iterator isit = is.begin(); @@ -349,7 +349,7 @@ namespace swig { size_t replacecount = (ii - jj - step - 1) / -step; if (is.size() != replacecount) { char msg[1024]; - sprintf(msg, "attempt to assign sequence of size %d to extended slice of size %d", is.size(), replacecount); + sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount); throw std::invalid_argument(msg); } typename Sequence::const_iterator isit = is.begin(); From 52fe61820abbde9d0457c4ae7b85e1b432c69752 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Apr 2012 14:27:55 +0000 Subject: [PATCH 38/43] More for Mac OSX STL fixes git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13020 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Lib/python/pycontainer.swg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index a9862cc73..eb089e98e 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -204,7 +204,7 @@ namespace swig { template void - slice_adjust(Difference i, Difference j, Difference step, size_t size, Difference &ii, Difference &jj, bool insert = false) { + slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) { if (step == 0) { throw std::invalid_argument("slice step cannot be zero"); } else if (step > 0) { From a0e21e82ca112624ed2ab588424dec022e1e6a5a Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sat, 28 Apr 2012 14:29:23 +0000 Subject: [PATCH 39/43] char **STRING_ARRAY typemaps fixed to handle null pointers git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13021 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- CHANGES.current | 4 ++ .../java/java_lib_various_runme.java | 5 ++ Lib/java/various.i | 48 +++++++++++-------- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index a2ebf35f9..f3cb1de21 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -11,3 +11,7 @@ Version 2.0.6 (in progress) 2012-04-28: wsfulton [Python] Fix compilation errors when wrapping STL containers on Mac OSX 64 bit. +2012-04-28: wsfulton + [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle + null pointers. + diff --git a/Examples/test-suite/java/java_lib_various_runme.java b/Examples/test-suite/java/java_lib_various_runme.java index ab54aced8..203a30ec2 100644 --- a/Examples/test-suite/java/java_lib_various_runme.java +++ b/Examples/test-suite/java/java_lib_various_runme.java @@ -45,6 +45,11 @@ public class java_lib_various_runme { if ( !langs[i].equals(newLangs[i]) ) throw new RuntimeException("Languages verify failed " + i + " " + langs[i] + "|" + newLangs[i]); + // STRING_ARRAY null + java_lib_various.setLanguages(null); + if (java_lib_various.getLanguages() != null) + throw new RuntimeException("languages should be null"); + // STRING_RET test { String stringOutArray[] = { "" }; diff --git a/Lib/java/various.i b/Lib/java/various.i index 9e7cf29ca..71569ca32 100644 --- a/Lib/java/various.i +++ b/Lib/java/various.i @@ -23,7 +23,8 @@ %typemap(jtype) char **STRING_ARRAY "String[]" %typemap(jstype) char **STRING_ARRAY "String[]" %typemap(in) char **STRING_ARRAY (jint size) { - int i = 0; + int i = 0; + if ($input) { size = JCALL1(GetArrayLength, jenv, $input); #ifdef __cplusplus $1 = new char*[size+1]; @@ -31,51 +32,56 @@ $1 = (char **)calloc(size+1, sizeof(char *)); #endif for (i = 0; i Date: Sat, 28 Apr 2012 15:30:19 +0000 Subject: [PATCH 40/43] Fix %fragment error in docs and improve preprocessing and delimiters section - SF bug 3519394 git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13022 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Doc/Manual/Preprocessor.html | 10 ++++++++-- Doc/Manual/Typemaps.html | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html index 8d41efccf..332d2a576 100644 --- a/Doc/Manual/Preprocessor.html +++ b/Doc/Manual/Preprocessor.html @@ -306,7 +306,13 @@ interface building. However, they are used internally to implement a number of SWIG directives and are provided to make SWIG more compatible with C99 code.

-

7.7 Preprocessing and %{ ... %} & " ... " delimiters

+

7.7 Preprocessing and delimiters

+ +

+The preprocessor handles { }, " " and %{ %} delimiters differently. +

+ +

7.7 Preprocessing and %{ ... %} & " ... " delimiters

@@ -331,7 +337,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

-

7.8 Preprocessing and { ... } delimiters

+

7.8 Preprocessing and { ... } delimiters

diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index b6e8cf3ce..b3b0bc7a9 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -3673,17 +3673,21 @@ generated into the wrapper code before any typemap code that calls it.

To define a fragment you need a fragment name, a section name for generating the fragment code into, and the code itself. See Code insertion blocks for a full list of section names. -Usually the section name used is "header". Both string and curly braces can be used: +Usually the section name used is "header". Different delimiters can be used:

+%fragment("my_name", "header") %{ ... %}
 %fragment("my_name", "header") { ... }
 %fragment("my_name", "header") " ... "
 

+and these follow the usual preprocessing rules mentioned in the +Preprocessing delimiters +section. The following are some rules and guidelines for using fragments:

@@ -3761,8 +3765,8 @@ A fragment can use one or more additional fragments, for example:
-%fragment("<limits.h>", "header")  {
-  #include <limits.h>
+%fragment("<limits.h>", "header") {
+  %#include <limits.h>
 }
 
 

From 127e772693ab4096b88081f4c35e7f6adec9a99f Mon Sep 17 00:00:00 2001
From: William S Fulton 
Date: Sat, 28 Apr 2012 15:33:58 +0000
Subject: [PATCH 41/43] HTML doc section update

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13023 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
 Doc/Manual/Contents.html     |  3 +++
 Doc/Manual/Lua.html          |  3 +--
 Doc/Manual/Preprocessor.html | 14 +++++++++-----
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 105bbcf7e..4af66298c 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -263,8 +263,11 @@
 
  • Macro Expansion
  • SWIG Macros
  • C99 and GNU Extensions +
  • Preprocessing and delimiters +
  • Preprocessor and Typemaps
  • Viewing preprocessor output
  • The #error and #warning directives diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index cccb5d889..ec32c4449 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -218,8 +218,7 @@ For eLua, the source must be built along with the wrappers generated by SWIG. Ma _ROM( AUXLIB_MOD, luaopen_mod, mod_map )\ ....
  • -

    -

    +
     /* Sample auxmods.h */
     #define AUXLIB_PIO       "pio"
    diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
    index 332d2a576..8fcbe9206 100644
    --- a/Doc/Manual/Preprocessor.html
    +++ b/Doc/Manual/Preprocessor.html
    @@ -16,8 +16,11 @@
     
  • Macro Expansion
  • SWIG Macros
  • C99 and GNU Extensions +
  • Preprocessing and delimiters +
  • Preprocessor and Typemaps
  • Viewing preprocessor output
  • The #error and #warning directives @@ -308,11 +311,12 @@ SWIG directives and are provided to make SWIG more compatible with C99 code.

    7.7 Preprocessing and delimiters

    +

    The preprocessor handles { }, " " and %{ %} delimiters differently.

    -

    7.7 Preprocessing and %{ ... %} & " ... " delimiters

    +

    7.7.1 Preprocessing and %{ ... %} & " ... " delimiters

    @@ -337,7 +341,7 @@ the contents of the %{ ... %} block are copied without modification to the output (including all preprocessor directives).

    -

    7.8 Preprocessing and { ... } delimiters

    +

    7.7.2 Preprocessing and { ... } delimiters

    @@ -379,7 +383,7 @@ to actually go into the wrapper file, prefix the preprocessor directives with % and leave the preprocessor directive in the code.

    -

    7.9 Preprocessor and Typemaps

    +

    7.8 Preprocessor and Typemaps

    @@ -450,7 +454,7 @@ would generate

  • -

    7.10 Viewing preprocessor output

    +

    7.9 Viewing preprocessor output

    @@ -460,7 +464,7 @@ Instead the results after the preprocessor has run are displayed. This might be useful as an aid to debugging and viewing the results of macro expansions.

    -

    7.11 The #error and #warning directives

    +

    7.10 The #error and #warning directives

    From 8bf13473544fc3aee0b42ebf8038d0ceea712d25 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Apr 2012 21:51:18 +0000 Subject: [PATCH 42/43] Warning fixes using clang git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13024 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- Source/DOH/base.c | 2 +- Source/Modules/d.cxx | 2 +- Source/Preprocessor/expr.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/DOH/base.c b/Source/DOH/base.c index cfbd2bdc4..db37e147b 100644 --- a/Source/DOH/base.c +++ b/Source/DOH/base.c @@ -259,7 +259,7 @@ int DohEqual(const DOH *obj1, const DOH *obj2) { if (!b1info) { return obj1 == obj2; - } else if ((b1info == b2info)) { + } else if (b1info == b2info) { return b1info->doh_equal ? (b1info->doh_equal) (b1, b2) : (b1info->doh_cmp ? (b1info->doh_cmp) (b1, b2) == 0 : (b1 == b2)); } else { return 0; diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx index bf4d15987..bc51cf5ed 100644 --- a/Source/Modules/d.cxx +++ b/Source/Modules/d.cxx @@ -4602,7 +4602,7 @@ private: co = c + Len(nspace); while (*c && (c != co)) { - if ((*c == '.')) { + if (*c == '.') { break; } c++; diff --git a/Source/Preprocessor/expr.c b/Source/Preprocessor/expr.c index 3e3f39480..e7470378d 100644 --- a/Source/Preprocessor/expr.c +++ b/Source/Preprocessor/expr.c @@ -298,16 +298,16 @@ int Preprocessor_expr(DOH *s, int *error) { stack[sp++].op = EXPR_OP; stack[sp].op = EXPR_TOP; stack[sp].svalue = 0; - } else if ((token == SWIG_TOKEN_LPAREN)) { + } else if (token == SWIG_TOKEN_LPAREN) { stack[sp++].op = EXPR_GROUP; stack[sp].op = EXPR_TOP; stack[sp].value = 0; stack[sp].svalue = 0; } else if (token == SWIG_TOKEN_ENDLINE) { - } else if ((token == SWIG_TOKEN_STRING)) { + } else if (token == SWIG_TOKEN_STRING) { stack[sp].svalue = NewString(Scanner_text(scan)); stack[sp].op = EXPR_VALUE; - } else if ((token == SWIG_TOKEN_ID)) { + } else if (token == SWIG_TOKEN_ID) { stack[sp].value = 0; stack[sp].svalue = 0; stack[sp].op = EXPR_VALUE; From 8aeb72ef3b287c534f7c8e48ddb4301f4b3c99fb Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 29 Apr 2012 21:52:27 +0000 Subject: [PATCH 43/43] swig-2.0.6 release date and summary git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13025 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- ANNOUNCE | 2 +- CHANGES.current | 6 +++--- Doc/Manual/Sections.html | 2 +- README | 2 +- RELEASENOTES | 3 +++ 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 61f2a70bf..825837614 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,4 +1,4 @@ -*** ANNOUNCE: SWIG 2.0.6 (in progress) *** +*** ANNOUNCE: SWIG 2.0.6 (30 April 2012) *** http://www.swig.org diff --git a/CHANGES.current b/CHANGES.current index f3cb1de21..cb64a7937 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,14 +2,14 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.6 (in progress) -=========================== +Version 2.0.6 (30 April 2012) +============================= 2012-04-25: wsfulton [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. 2012-04-28: wsfulton - [Python] Fix compilation errors when wrapping STL containers on Mac OSX 64 bit. + [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems. 2012-04-28: wsfulton [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index c6651349b..1151de1d5 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

    SWIG-2.0 Documentation

    -Last update : SWIG-2.0.6 (in progress) +Last update : SWIG-2.0.6 (30 April 2012)

    Sections

    diff --git a/README b/README index bd5f8ae4b..d846665e3 100644 --- a/README +++ b/README @@ -1,6 +1,6 @@ SWIG (Simplified Wrapper and Interface Generator) -Version: 2.0.6 (in progress) +Version: 2.0.6 (30 April 2012) Tagline: SWIG is a compiler that integrates C and C++ with languages including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, diff --git a/RELEASENOTES b/RELEASENOTES index 5b542d4da..faa57bf63 100644 --- a/RELEASENOTES +++ b/RELEASENOTES @@ -4,6 +4,9 @@ and CHANGES files. Release Notes ============= +SWIG-2.0.6 summary: +- Regression fix for Python STL wrappers on some systems. + SWIG-2.0.5 summary: - Official Android support added including documentation and examples. - Improvements involving templates:

    SWIG-2.0 Documentation