From: SourceForge.net <no...@so...> - 2008-11-03 12:03:19
|
Bugs item #2218834, was opened at 2008-11-03 12:03 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2218834&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: python Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Andy Buckley (andybuckley) Assigned to: Nobody/Anonymous (nobody) Summary: Namespace breaks %ignore with unbound C++ operator<< Initial Comment: NB. This may be in the C++ parser rather than anything Python-specific, but I've only tested in Python. I've been trying to hide a C++ operator<< function (2 args unbound, i.e. not a class method) using the SWIG %ignore directive. It seems that if this stream function is declared as a friend in the class to be streamed, inside a namespace, then the %ignore matching fails, even in the case of an exact textual match. Here's an example hepmc.i file, with the C++ code to be mapped represented inline: ----- %module hepmc // These don't work: namespace HepMC { %ignore operator<<; %ignore operator<<(std::ostream&, const GenParticle&); } %ignore HepMC::operator<<; %ignore HepMC::operator<<(std::ostream&, const GenParticle&); // This works: //%ignore operator<<; //%ignore operator<<(std::ostream&, const GenParticle&); ///////////////////////////////////////// // Equiv to: %include "HepMC/GenParticle.h" namespace HepMC { class GenParticle { // [...] friend std::ostream& operator<<( std::ostream&, const GenParticle& ); }; std::ostream& operator<<( std::ostream& os, const GenParticle& gp) { os << gp.foo(); return os; } } ///////////////////////////////////////// ----- The above results in an error " Warning(503): Can't wrap 'operator <<' unless renamed to a valid identifier." referring specifically to the friend statement, unless the "coarse match" %ignores under the "This works" comment are included. The equivalent %ignores which are specific, one way or another, about the namespace don't match the operator<< referred to in the friend statement. Note that this bug seems to be specific to the friend statement --- if you remove the friend declaration in GenParticle, the %ignore works properly. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=2218834&group_id=1645 |