mirror of https://github.com/swig/swig
Fix symbol table entry for friend operators
Now unqualified friend declarations/definitions can be ignored or renamed as expected. Note: previous commit regressed this for friends that were not operators but now the symbol tables are correct for operators and non-operators alike.
This commit is contained in:
parent
d572432773
commit
a6ab914511
|
@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.2.1 (in progress)
|
||||
===========================
|
||||
|
||||
2024-01-15: wsfulton
|
||||
https://sourceforge.net/p/swig/bugs/960/
|
||||
Fix so that friend operators within a namespace can be correctly ignored
|
||||
or renamed.
|
||||
|
||||
2024-01-15: wsfulton
|
||||
https://sourceforge.net/p/swig/bugs/807/
|
||||
Wrap friend functions that are defined or declared within a namespace.
|
||||
|
|
|
@ -48,9 +48,16 @@ namespace oss
|
|||
}
|
||||
}
|
||||
|
||||
%rename("equals") operator==;
|
||||
// Note not: Utilities::Bucket::operator==
|
||||
%rename("equals") Utilities::operator==;
|
||||
|
||||
%ignore Utilities::operator<<;
|
||||
namespace Utilities {
|
||||
%ignore operator>>;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
#include <iostream>
|
||||
|
||||
namespace Utilities {
|
||||
class Bucket
|
||||
|
@ -60,6 +67,8 @@ namespace oss
|
|||
friend bool operator==(const Bucket& lhs, const Bucket& rhs){
|
||||
return ( rhs.m_left == lhs.m_left );
|
||||
}
|
||||
friend std::ostream& operator<<(std::ostream&, const Bucket &);
|
||||
friend std::ostream& operator>>(std::ostream&, const Bucket &);
|
||||
private:
|
||||
int m_left;
|
||||
};
|
||||
|
|
|
@ -426,13 +426,18 @@ static void add_symbols(Node *n) {
|
|||
old_scope = Swig_symbol_popscope();
|
||||
Namespaceprefix = Swig_symbol_qualifiedscopename(0);
|
||||
if (!prefix) {
|
||||
/* To check - this should probably apply to operators too */
|
||||
if (name && !is_operator(name) && Namespaceprefix) {
|
||||
String *friendusing = NewStringf("using namespace %s;", Namespaceprefix);
|
||||
Setattr(n, "friendusing", friendusing);
|
||||
Delete(friendusing);
|
||||
}
|
||||
} else {
|
||||
/* Qualified friend declarations should not be possible as they are ignored in the parse tree */
|
||||
/* TODO: uncomment out for swig-4.3.0
|
||||
assert(0);
|
||||
*/
|
||||
}
|
||||
Namespaceprefix = 0;
|
||||
} else if (Equal(nodeType(n), "using")) {
|
||||
String *uname = Getattr(n, "uname");
|
||||
Node *cls = current_class ? current_class : currentOuterClass; /* Current class seems to vary depending on whether it is a template class or a plain class */
|
||||
|
|
Loading…
Reference in New Issue