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:
parent
d4b7275f51
commit
aeebd394f3
4 changed files with 56 additions and 23 deletions
|
|
@ -8,6 +8,30 @@ Version 2.0.9 (in progress)
|
||||||
2012-11-09: vzeitlin
|
2012-11-09: vzeitlin
|
||||||
[Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type.
|
[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
|
2012-11-02: wsfulton
|
||||||
Fix some subtle named output typemap lookup misses, the fully qualified name was not always being
|
Fix some subtle named output typemap lookup misses, the fully qualified name was not always being
|
||||||
used for variables, for example:
|
used for variables, for example:
|
||||||
|
|
|
||||||
|
|
@ -2170,8 +2170,7 @@ static void addCopyConstructor(Node *n) {
|
||||||
|
|
||||||
String *cname = Getattr(n, "name");
|
String *cname = Getattr(n, "name");
|
||||||
SwigType *type = Copy(cname);
|
SwigType *type = Copy(cname);
|
||||||
String *last = Swig_scopename_last(cname);
|
String *name = Swig_scopename_last(cname);
|
||||||
String *name = NewStringf("%s::%s", cname, last);
|
|
||||||
String *cc = NewStringf("r.q(const).%s", type);
|
String *cc = NewStringf("r.q(const).%s", type);
|
||||||
String *decl = NewStringf("f(%s).", cc);
|
String *decl = NewStringf("f(%s).", cc);
|
||||||
String *csymname = Getattr(n, "sym:name");
|
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 (Strcmp(symname, "$ignore") != 0) {
|
||||||
if (!symname) {
|
if (!symname) {
|
||||||
symname = Copy(csymname);
|
symname = Copy(csymname);
|
||||||
|
|
@ -2213,8 +2212,8 @@ static void addCopyConstructor(Node *n) {
|
||||||
|
|
||||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||||
Node *on = Swig_symbol_add(symname, cn);
|
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_symbol_setscope(oldscope);
|
||||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
|
||||||
|
|
||||||
if (on == cn) {
|
if (on == cn) {
|
||||||
Node *access = NewHash();
|
Node *access = NewHash();
|
||||||
|
|
@ -2229,7 +2228,6 @@ static void addCopyConstructor(Node *n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Delete(cn);
|
Delete(cn);
|
||||||
Delete(last);
|
|
||||||
Delete(name);
|
Delete(name);
|
||||||
Delete(decl);
|
Delete(decl);
|
||||||
Delete(symname);
|
Delete(symname);
|
||||||
|
|
@ -2243,12 +2241,11 @@ static void addDefaultConstructor(Node *n) {
|
||||||
Setline(cn, Getline(n));
|
Setline(cn, Getline(n));
|
||||||
|
|
||||||
String *cname = Getattr(n, "name");
|
String *cname = Getattr(n, "name");
|
||||||
String *last = Swig_scopename_last(cname);
|
String *name = Swig_scopename_last(cname);
|
||||||
String *name = NewStringf("%s::%s", cname, last);
|
|
||||||
String *decl = NewString("f().");
|
String *decl = NewString("f().");
|
||||||
String *csymname = Getattr(n, "sym:name");
|
String *csymname = Getattr(n, "sym:name");
|
||||||
String *oldname = csymname;
|
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 (Strcmp(symname, "$ignore") != 0) {
|
||||||
if (!symname) {
|
if (!symname) {
|
||||||
symname = Copy(csymname);
|
symname = Copy(csymname);
|
||||||
|
|
@ -2260,11 +2257,10 @@ static void addDefaultConstructor(Node *n) {
|
||||||
Setattr(cn, "decl", decl);
|
Setattr(cn, "decl", decl);
|
||||||
Setattr(cn, "parentNode", n);
|
Setattr(cn, "parentNode", n);
|
||||||
Setattr(cn, "default_constructor", "1");
|
Setattr(cn, "default_constructor", "1");
|
||||||
|
|
||||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||||
Node *on = Swig_symbol_add(symname, cn);
|
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_symbol_setscope(oldscope);
|
||||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
|
||||||
|
|
||||||
if (on == cn) {
|
if (on == cn) {
|
||||||
Node *access = NewHash();
|
Node *access = NewHash();
|
||||||
|
|
@ -2278,7 +2274,6 @@ static void addDefaultConstructor(Node *n) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Delete(cn);
|
Delete(cn);
|
||||||
Delete(last);
|
|
||||||
Delete(name);
|
Delete(name);
|
||||||
Delete(decl);
|
Delete(decl);
|
||||||
Delete(symname);
|
Delete(symname);
|
||||||
|
|
@ -2292,11 +2287,10 @@ static void addDestructor(Node *n) {
|
||||||
Setline(cn, Getline(n));
|
Setline(cn, Getline(n));
|
||||||
|
|
||||||
String *cname = Getattr(n, "name");
|
String *cname = Getattr(n, "name");
|
||||||
String *last = Swig_scopename_last(cname);
|
String *name = Swig_scopename_last(cname);
|
||||||
Insert(last, 0, "~");
|
Insert(name, 0, "~");
|
||||||
String *name = NewStringf("%s::%s", cname, last);
|
|
||||||
String *decl = NewString("f().");
|
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) {
|
if (Strcmp(symname, "$ignore") != 0) {
|
||||||
String *possible_nonstandard_symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
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"));
|
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 *nonstandard_destructor = Equal(possible_nonstandard_symname, symname) ? 0 : Swig_symbol_clookup(possible_nonstandard_symname, 0);
|
||||||
Node *on = Swig_symbol_add(symname, cn);
|
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_symbol_setscope(oldscope);
|
||||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
|
||||||
|
|
||||||
if (on == cn) {
|
if (on == cn) {
|
||||||
// SWIG accepts a non-standard named destructor in %extend that uses a typedef for the destructor name
|
// 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(possible_nonstandard_symname);
|
||||||
}
|
}
|
||||||
Delete(cn);
|
Delete(cn);
|
||||||
Delete(last);
|
|
||||||
Delete(name);
|
Delete(name);
|
||||||
Delete(decl);
|
Delete(decl);
|
||||||
Delete(symname);
|
Delete(symname);
|
||||||
|
|
|
||||||
|
|
@ -1549,6 +1549,7 @@ static int symbol_no_constructor(Node *n) {
|
||||||
* Swig_symbol_type_qualify()
|
* Swig_symbol_type_qualify()
|
||||||
*
|
*
|
||||||
* Create a fully qualified type name
|
* 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) {
|
SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
||||||
|
|
|
||||||
|
|
@ -1306,6 +1306,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
||||||
SwigType *mtype = 0;
|
SwigType *mtype = 0;
|
||||||
String *pname;
|
String *pname;
|
||||||
String *qpname = 0;
|
String *qpname = 0;
|
||||||
|
String *noscope_pname = 0;
|
||||||
Hash *tm = 0;
|
Hash *tm = 0;
|
||||||
String *s = 0;
|
String *s = 0;
|
||||||
String *sdef = 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");
|
pname = Getattr(node, "name");
|
||||||
|
noscope_pname = Copy(pname);
|
||||||
|
|
||||||
if (pname && node && Getattr(node, "sym:symtab")) {
|
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 {
|
* struct Foo {
|
||||||
* int *foo(int bar) -> Foo::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;
|
||||||
String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;
|
if (Swig_scopename_check(pname)) {
|
||||||
if (qsn && Len(qsn) && !Equal(qsn, pname))
|
/* sometimes pname is qualified, so we remove all the scope for the lookup */
|
||||||
qpname = qsn;
|
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)
|
if (typemap_search_debug)
|
||||||
debug_search_result_display(tm);
|
debug_search_result_display(tm);
|
||||||
if (typemaps_used_debug && 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);
|
Delete(qpname);
|
||||||
qpname = 0;
|
qpname = 0;
|
||||||
|
Delete(noscope_pname);
|
||||||
|
noscope_pname = 0;
|
||||||
|
|
||||||
if (!tm)
|
if (!tm)
|
||||||
return sdef;
|
return sdef;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue