Fix incorrect implicit constructor and destructor names in the symbol tables. Fix some feature matching issues for implicit destructors and implicit constructors and impliciti copy constructors added with %copyctor. Also improves consistency in named typemap lookup rules.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@13882 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-11-13 22:19:47 +00:00
commit aeebd394f3
4 changed files with 56 additions and 23 deletions

View file

@ -8,6 +8,30 @@ Version 2.0.9 (in progress)
2012-11-09: vzeitlin
[Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type.
2012-11-09: wsfulton
Fix some feature matching issues for implicit destructors and implicit constructors and implicit
copy constructors added with %copyctor. Previously a feature for these had to be fully qualified
in order to match. Now the following will also match:
%feature("xyz") ~XXX();
struct XXX {};
2012-11-09: wsfulton
Further consistency in named output typemap lookups for implicit constructors and destructors and
implicit copy constructors added with %copyctor. Previously only the fully qualified name was being
used, now the unqualified name will also be used. For example, previously:
example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More
Looking for: void Space::More::~More
Looking for: void
Now the unqualified name is also used:
example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More
Looking for: void Space::More::~More
Looking for: void ~More
Looking for: void
2012-11-02: wsfulton
Fix some subtle named output typemap lookup misses, the fully qualified name was not always being
used for variables, for example:

View file

@ -2170,8 +2170,7 @@ static void addCopyConstructor(Node *n) {
String *cname = Getattr(n, "name");
SwigType *type = Copy(cname);
String *last = Swig_scopename_last(cname);
String *name = NewStringf("%s::%s", cname, last);
String *name = Swig_scopename_last(cname);
String *cc = NewStringf("r.q(const).%s", type);
String *decl = NewStringf("f(%s).", cc);
String *csymname = Getattr(n, "sym:name");
@ -2196,7 +2195,7 @@ static void addCopyConstructor(Node *n) {
}
}
String *symname = Swig_name_make(cn, cname, last, decl, oldname);
String *symname = Swig_name_make(cn, cname, name, decl, oldname);
if (Strcmp(symname, "$ignore") != 0) {
if (!symname) {
symname = Copy(csymname);
@ -2213,8 +2212,8 @@ static void addCopyConstructor(Node *n) {
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
Node *on = Swig_symbol_add(symname, cn);
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
Swig_symbol_setscope(oldscope);
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
if (on == cn) {
Node *access = NewHash();
@ -2229,7 +2228,6 @@ static void addCopyConstructor(Node *n) {
}
}
Delete(cn);
Delete(last);
Delete(name);
Delete(decl);
Delete(symname);
@ -2243,12 +2241,11 @@ static void addDefaultConstructor(Node *n) {
Setline(cn, Getline(n));
String *cname = Getattr(n, "name");
String *last = Swig_scopename_last(cname);
String *name = NewStringf("%s::%s", cname, last);
String *name = Swig_scopename_last(cname);
String *decl = NewString("f().");
String *csymname = Getattr(n, "sym:name");
String *oldname = csymname;
String *symname = Swig_name_make(cn, cname, last, decl, oldname);
String *symname = Swig_name_make(cn, cname, name, decl, oldname);
if (Strcmp(symname, "$ignore") != 0) {
if (!symname) {
symname = Copy(csymname);
@ -2260,11 +2257,10 @@ static void addDefaultConstructor(Node *n) {
Setattr(cn, "decl", decl);
Setattr(cn, "parentNode", n);
Setattr(cn, "default_constructor", "1");
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
Node *on = Swig_symbol_add(symname, cn);
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
Swig_symbol_setscope(oldscope);
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
if (on == cn) {
Node *access = NewHash();
@ -2278,7 +2274,6 @@ static void addDefaultConstructor(Node *n) {
}
}
Delete(cn);
Delete(last);
Delete(name);
Delete(decl);
Delete(symname);
@ -2292,11 +2287,10 @@ static void addDestructor(Node *n) {
Setline(cn, Getline(n));
String *cname = Getattr(n, "name");
String *last = Swig_scopename_last(cname);
Insert(last, 0, "~");
String *name = NewStringf("%s::%s", cname, last);
String *name = Swig_scopename_last(cname);
Insert(name, 0, "~");
String *decl = NewString("f().");
String *symname = Swig_name_make(cn, cname, last, decl, 0);
String *symname = Swig_name_make(cn, cname, name, decl, 0);
if (Strcmp(symname, "$ignore") != 0) {
String *possible_nonstandard_symname = NewStringf("~%s", Getattr(n, "sym:name"));
@ -2308,8 +2302,8 @@ static void addDestructor(Node *n) {
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
Node *nonstandard_destructor = Equal(possible_nonstandard_symname, symname) ? 0 : Swig_symbol_clookup(possible_nonstandard_symname, 0);
Node *on = Swig_symbol_add(symname, cn);
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
Swig_symbol_setscope(oldscope);
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
if (on == cn) {
// SWIG accepts a non-standard named destructor in %extend that uses a typedef for the destructor name
@ -2329,7 +2323,6 @@ static void addDestructor(Node *n) {
Delete(possible_nonstandard_symname);
}
Delete(cn);
Delete(last);
Delete(name);
Delete(decl);
Delete(symname);

View file

@ -1549,6 +1549,7 @@ static int symbol_no_constructor(Node *n) {
* Swig_symbol_type_qualify()
*
* Create a fully qualified type name
* Note: Does not resolve a constructor if passed in as the 'type'.
* ----------------------------------------------------------------------------- */
SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {

View file

@ -1306,6 +1306,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
SwigType *mtype = 0;
String *pname;
String *qpname = 0;
String *noscope_pname = 0;
Hash *tm = 0;
String *s = 0;
String *sdef = 0;
@ -1338,20 +1339,32 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
}
pname = Getattr(node, "name");
noscope_pname = Copy(pname);
if (pname && node && Getattr(node, "sym:symtab")) {
/* Add on a qualified name search for any symbol, for example:
/* Add on a qualified name search for any symbol in the symbol table, for example:
* struct Foo {
* int *foo(int bar) -> Foo::foo
* };
* Note that if node is a parameter (Parm *) then there will be no symbol table attached to the Parm *.
*/
Symtab *st = Getattr(node, "sym:symtab");
String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;
if (qsn && Len(qsn) && !Equal(qsn, pname))
qpname = qsn;
String *qsn;
if (Swig_scopename_check(pname)) {
/* sometimes pname is qualified, so we remove all the scope for the lookup */
Delete(noscope_pname);
noscope_pname = Swig_scopename_last(pname);
/*
Printf(stdout, "Removed scope: %s => %s\n", pname, noscope_pname);
*/
}
qsn = Swig_symbol_qualified(node);
if (qsn && Len(qsn)) {
qpname = NewStringf("%s::%s", qsn, noscope_pname);
Delete(qsn);
}
}
tm = typemap_search(tmap_method, type, pname, qpname, &mtype, node);
tm = typemap_search(tmap_method, type, noscope_pname, qpname, &mtype, node);
if (typemap_search_debug)
debug_search_result_display(tm);
if (typemaps_used_debug && tm) {
@ -1364,6 +1377,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
Delete(qpname);
qpname = 0;
Delete(noscope_pname);
noscope_pname = 0;
if (!tm)
return sdef;