Fix typemap method hiding regression introduced in swig-2.0.5 - rev 12764

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13071 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-05-11 21:23:37 +00:00
commit ef7a8a8253
5 changed files with 73 additions and 12 deletions

View file

@ -362,7 +362,7 @@ Version 2.0.5 (19 April 2012)
namespace std {
template<class Key, class T> struct map {
class iterator;
}
};
}
iterator was scoped as std::iterator, but now it is correctly std::map<Key, T>::iterator;
@ -374,10 +374,10 @@ Version 2.0.5 (19 April 2012)
template<class Key, class T, class C = int> struct Map {
typedef Key key_type;
typedef T mapped_type;
}
};
}
tyepdef double DOUBLE;
%typemap(MM) Std::Map<int, DOUBLE>;
typedef double DOUBLE;
%template(MM) Std::Map<int, DOUBLE>;
All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the
wrapped code uses Std::Map<int, double> or std::Map<int, DOUBLE> or Std::Map<int, double, int>

View file

@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.7 (in progress)
===========================
2012-05-11: wsfulton
SF bug #3525050 - Fix regression introduced in swig-2.0.5 whereby defining one typemap
method such as an 'out' typemap may hide another typemap method such as an 'in' typemap -
only occurs when the type is a template type where the template parameters are the same
via a typedef.
2012-05-10: olly
[PHP] Fix the constant typemaps for SWIGTYPE, etc - previously
these used the wrong name for renamed constants. Add

View file

@ -430,6 +430,7 @@ CPP_TEST_CASES += \
typemap_ns_using \
typemap_numinputs \
typemap_template \
typemap_template_parm_typedef \
typemap_out_optimal \
typemap_qualifier_strip \
typemap_variables \

View file

@ -0,0 +1,48 @@
%module typemap_template_parm_typedef
%typemap(in) SWIGTYPE " _in_will_not_compile_ "
%typemap(in) SWIGTYPE * " _in_will_not_compile_ "
%typemap(out) SWIGTYPE " _out_will_not_compile_ "
%typemap(out) SWIGTYPE * " _out_will_not_compile_ "
%{
#include <vector>
#include <list>
#include <deque>
namespace jada {
typedef unsigned int uint;
void test_no_typedef(std::list<unsigned int> bada) {}
void test_typedef(std::vector<uint> bada) {}
std::deque<unsigned int> no_typedef_out() {}
}
%}
%typemap(in) std::list<unsigned int> (std::list<unsigned int> tmp) {
$1 = tmp;
}
%typemap(in) std::vector<unsigned int> (std::vector<unsigned int> tmp) {
$1 = tmp;
}
%typemap(out) std::list<unsigned int> {
}
// The presennce of this 'out' typemap was hiding the std::vector<unsigned int> 'in' typemap in swig-2.0.5 and swig-2.0.6
%typemap(out) std::vector<jada::uint> {
}
// This typemap was not used for no_typedef_out in 2.0.4 and earlier
%typemap(out) std::deque<jada::uint> {
$result = 0;
}
namespace jada {
typedef unsigned int uint;
void test_no_typedef(std::list<uint> bada);
void test_typedef(std::vector<uint> bada);
std::deque<unsigned int> no_typedef_out();
}

View file

@ -89,13 +89,16 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) {
return tm;
}
static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) {
static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) {
SwigType *hashtype = 0;
Hash *new_tm = 0;
assert(*tmhash == 0);
if (SwigType_istemplate(type)) {
SwigType *rty = SwigType_typedef_resolve_all(type);
String *ty = Swig_symbol_template_deftype(rty, 0);
String *tyq = Swig_symbol_type_qualify(ty, 0);
hashtype = SwigType_remove_global_scope_prefix(tyq);
*tmhash = Getattr(typemaps[tm_scope], hashtype);
Delete(rty);
Delete(tyq);
Delete(ty);
@ -103,10 +106,17 @@ static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) {
hashtype = SwigType_remove_global_scope_prefix(type);
}
if (!*tmhash) {
/* this type has not been seen before even after resolving template parameter types */
new_tm = NewHash();
*tmhash = new_tm;
}
/* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */
Setattr(typemaps[tm_scope], hashtype, tm);
Setattr(typemaps[tm_scope], hashtype, *tmhash);
Delete(hashtype);
Delete(new_tm);
}
@ -210,9 +220,7 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
/* See if this type has been seen before */
tm = get_typemap(tm_scope, type);
if (!tm) {
tm = NewHash();
set_typemap(tm_scope, type, tm);
Delete(tm);
set_typemap(tm_scope, type, &tm);
}
if (pname) {
/* See if parameter has been seen before */
@ -476,9 +484,7 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
type = Getattr(lastdp, "type");
tm = get_typemap(tm_scope, type);
if (!tm) {
tm = NewHash();
set_typemap(tm_scope, type, tm);
Delete(tm);
set_typemap(tm_scope, type, &tm);
}
name = Getattr(lastdp, "name");
if (name) {