acc: work around a Swig 4.2.1 bug
Pierre Ganty wrote that he could not compile Spot with Swig 4.2.1 anymore, and when I upgraded from 4.2.0 to 4.2.1 I could not either. It seems that declaring operator<< as friends in subclasses is confusing Swig 4.2.1. See https://github.com/swig/swig/issues/2845 * spot/twa/acc.cc, spot/twa/acc.hh: Declare operator<< for acc_cond::mark_t and acc_cond::acc_code outside the class, so that we do not need friend declarations.
This commit is contained in:
parent
cb15840c56
commit
03a4f01184
2 changed files with 43 additions and 27 deletions
|
|
@ -48,7 +48,7 @@ namespace spot
|
|||
" <spot@lrde.epita.fr>.");
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, spot::acc_cond::mark_t m)
|
||||
std::ostream& operator<<(std::ostream& os, acc_cond::mark_t m)
|
||||
{
|
||||
auto a = m;
|
||||
os << '{';
|
||||
|
|
@ -68,6 +68,31 @@ namespace spot
|
|||
return os;
|
||||
}
|
||||
|
||||
std::string acc_cond::mark_t::as_string() const
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << *this;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
// Deprecated since Spot 2.8
|
||||
std::ostream& acc_cond::format(std::ostream& os,
|
||||
acc_cond::mark_t m) const
|
||||
{
|
||||
if (!m)
|
||||
return os;
|
||||
return os << m;
|
||||
}
|
||||
|
||||
// Deprecated since Spot 2.8
|
||||
std::string acc_cond::format(acc_cond::mark_t m) const
|
||||
{
|
||||
std::ostringstream os;
|
||||
if (m)
|
||||
os << m;
|
||||
return os.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const acc_cond& acc)
|
||||
{
|
||||
return os << '(' << acc.num_sets() << ", " << acc.get_acceptance() << ')';
|
||||
|
|
@ -1922,7 +1947,7 @@ namespace spot
|
|||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const spot::acc_cond::acc_code& code)
|
||||
const acc_cond::acc_code& code)
|
||||
{
|
||||
return code.to_text(os);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -430,15 +430,7 @@ namespace spot
|
|||
/// Returns some iterable object that contains the used sets.
|
||||
spot::internal::mark_container sets() const;
|
||||
|
||||
SPOT_API
|
||||
friend std::ostream& operator<<(std::ostream& os, mark_t m);
|
||||
|
||||
std::string as_string() const
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << *this;
|
||||
return os.str();
|
||||
}
|
||||
std::string as_string() const;
|
||||
};
|
||||
|
||||
/// \brief Operators for acceptance formulas.
|
||||
|
|
@ -1491,9 +1483,6 @@ namespace spot
|
|||
{
|
||||
}
|
||||
|
||||
/// \brief prints the acceptance formula as text
|
||||
SPOT_API
|
||||
friend std::ostream& operator<<(std::ostream& os, const acc_code& code);
|
||||
};
|
||||
|
||||
/// \brief Build an acceptance condition
|
||||
|
|
@ -2036,22 +2025,11 @@ namespace spot
|
|||
|
||||
// Deprecated since Spot 2.8
|
||||
SPOT_DEPRECATED("Use operator<< instead.")
|
||||
std::ostream& format(std::ostream& os, mark_t m) const
|
||||
{
|
||||
if (!m)
|
||||
return os;
|
||||
return os << m;
|
||||
}
|
||||
std::ostream& format(std::ostream& os, mark_t m) const;
|
||||
|
||||
// Deprecated since Spot 2.8
|
||||
SPOT_DEPRECATED("Use operator<< or mark_t::as_string() instead.")
|
||||
std::string format(mark_t m) const
|
||||
{
|
||||
std::ostringstream os;
|
||||
if (m)
|
||||
os << m;
|
||||
return os.str();
|
||||
}
|
||||
std::string format(mark_t m) const;
|
||||
|
||||
/// \brief The number of sets used in the acceptance condition.
|
||||
unsigned num_sets() const
|
||||
|
|
@ -2380,6 +2358,19 @@ namespace spot
|
|||
SPOT_API
|
||||
std::ostream& operator<<(std::ostream& os, const acc_cond& acc);
|
||||
|
||||
// The next two operators used to be declared as friend inside the
|
||||
// acc_cond::mark_t and acc_cond::acc_code, but Swig 4.2.1
|
||||
// introduced a bug with friend operators. See
|
||||
// https://github.com/swig/swig/issues/2845
|
||||
|
||||
SPOT_API
|
||||
std::ostream& operator<<(std::ostream& os, acc_cond::mark_t m);
|
||||
|
||||
/// \brief prints the acceptance formula as text
|
||||
SPOT_API
|
||||
std::ostream& operator<<(std::ostream& os,
|
||||
const acc_cond::acc_code& code);
|
||||
|
||||
/// @}
|
||||
|
||||
namespace internal
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue