Fix compilation error

This commit is contained in:
Simon Marchetto 2013-05-30 14:29:53 +02:00
commit f48e95cb47

View file

@ -9,7 +9,7 @@
%include <std_common.i> %include <std_common.i>
%fragment("SciSwigIterator","header",fragment="<stddef.h>") { %fragment("SciSwigIterator","header",fragment="<stddef.h>") {
namespace swig { namespace swig {
struct stop_iteration { struct stop_iteration {
}; };
@ -22,7 +22,7 @@ namespace swig {
SciSwigIterator(SciObject seq) : _seq(seq) SciSwigIterator(SciObject seq) : _seq(seq)
{ {
} }
public: public:
virtual ~SciSwigIterator() {} virtual ~SciSwigIterator() {}
@ -44,7 +44,7 @@ namespace swig {
{ {
throw std::invalid_argument("operation not supported"); throw std::invalid_argument("operation not supported");
} }
virtual SciSwigIterator *copy() const = 0; virtual SciSwigIterator *copy() const = 0;
SciObject next() SciObject next()
@ -64,12 +64,12 @@ namespace swig {
{ {
return (n > 0) ? incr(n) : decr(-n); return (n > 0) ? incr(n) : decr(-n);
} }
bool operator == (const SciSwigIterator& x) const bool operator == (const SciSwigIterator& x) const
{ {
return equal(x); return equal(x);
} }
bool operator != (const SciSwigIterator& x) const bool operator != (const SciSwigIterator& x) const
{ {
return ! operator==(x); return ! operator==(x);
@ -84,7 +84,7 @@ namespace swig {
decr(); decr();
return this; return this;
} }
SciSwigIterator* operator + (ptrdiff_t n) const SciSwigIterator* operator + (ptrdiff_t n) const
{ {
return copy()->advance(n); return copy()->advance(n);
@ -94,21 +94,21 @@ namespace swig {
{ {
return copy()->advance(-n); return copy()->advance(-n);
} }
ptrdiff_t operator - (const SciSwigIterator& x) const ptrdiff_t operator - (const SciSwigIterator& x) const
{ {
return x.distance(*this); return x.distance(*this);
} }
static swig_type_info* descriptor() { static swig_type_info* descriptor() {
static int init = 0; static int init = 0;
static swig_type_info* desc = 0; static swig_type_info* desc = 0;
if (!init) { if (!init) {
desc = SWIG_TypeQuery("swig::SciSwigIterator *"); desc = SWIG_TypeQuery("swig::SciSwigIterator *");
init = 1; init = 1;
} }
return desc; return desc;
} }
}; };
} }
} }
@ -120,7 +120,7 @@ namespace swig {
{ {
public: public:
typedef OutIterator out_iterator; typedef OutIterator out_iterator;
typedef typename std::iterator_traits<out_iterator>::value_type value_type; typedef typename std::iterator_traits<out_iterator>::value_type value_type;
typedef SciSwigIterator_T<out_iterator> self_type; typedef SciSwigIterator_T<out_iterator> self_type;
SciSwigIterator_T(out_iterator curr, SciObject seq) SciSwigIterator_T(out_iterator curr, SciObject seq)
@ -133,7 +133,7 @@ namespace swig {
return current; return current;
} }
bool equal (const SciSwigIterator &iter) const bool equal (const SciSwigIterator &iter) const
{ {
const self_type *iters = dynamic_cast<const self_type *>(&iter); const self_type *iters = dynamic_cast<const self_type *>(&iter);
@ -143,7 +143,7 @@ namespace swig {
throw std::invalid_argument("bad iterator type"); throw std::invalid_argument("bad iterator type");
} }
} }
ptrdiff_t distance(const SciSwigIterator &iter) const ptrdiff_t distance(const SciSwigIterator &iter) const
{ {
const self_type *iters = dynamic_cast<const self_type *>(&iter); const self_type *iters = dynamic_cast<const self_type *>(&iter);
@ -152,14 +152,14 @@ namespace swig {
} else { } else {
throw std::invalid_argument("bad iterator type"); throw std::invalid_argument("bad iterator type");
} }
} }
protected: protected:
out_iterator current; out_iterator current;
}; };
template <class ValueType> template <class ValueType>
struct from_oper struct from_oper
{ {
typedef const ValueType& argument_type; typedef const ValueType& argument_type;
typedef SciObject result_type; typedef SciObject result_type;
@ -169,7 +169,7 @@ namespace swig {
} }
}; };
template<typename OutIterator, template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type, typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> > typename FromOper = from_oper<ValueType> >
class SciSwigIteratorOpen_T : public SciSwigIterator_T<OutIterator> class SciSwigIteratorOpen_T : public SciSwigIterator_T<OutIterator>
@ -180,16 +180,16 @@ namespace swig {
typedef ValueType value_type; typedef ValueType value_type;
typedef SciSwigIterator_T<out_iterator> base; typedef SciSwigIterator_T<out_iterator> base;
typedef SciSwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type; typedef SciSwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
SciSwigIteratorOpen_T(out_iterator curr, SciObject seq) SciSwigIteratorOpen_T(out_iterator curr, SciObject seq)
: SciSwigIterator_T<OutIterator>(curr, seq) : SciSwigIterator_T<OutIterator>(curr, seq)
{ {
} }
SciObject value() const { SciObject value() const {
return from(static_cast<const value_type&>(*(base::current))); return from(static_cast<const value_type&>(*(base::current)));
} }
SciSwigIterator *copy() const SciSwigIterator *copy() const
{ {
return new self_type(*this); return new self_type(*this);
@ -212,7 +212,7 @@ namespace swig {
} }
}; };
template<typename OutIterator, template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type, typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> > typename FromOper = from_oper<ValueType> >
class SciSwigIteratorClosed_T : public SciSwigIterator_T<OutIterator> class SciSwigIteratorClosed_T : public SciSwigIterator_T<OutIterator>
@ -221,14 +221,14 @@ namespace swig {
FromOper from; FromOper from;
typedef OutIterator out_iterator; typedef OutIterator out_iterator;
typedef ValueType value_type; typedef ValueType value_type;
typedef SciSwigIterator_T<out_iterator> base; typedef SciSwigIterator_T<out_iterator> base;
typedef SciSwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type; typedef SciSwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
SciSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, SciObject seq) SciSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, SciObject seq)
: SciSwigIterator_T<OutIterator>(curr, seq), begin(first), end(last) : SciSwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
{ {
} }
SciObject value() const { SciObject value() const {
if (base::current == end) { if (base::current == end) {
throw stop_iteration(); throw stop_iteration();
@ -236,7 +236,7 @@ namespace swig {
return from(static_cast<const value_type&>(*(base::current))); return from(static_cast<const value_type&>(*(base::current)));
} }
} }
SciSwigIterator *copy() const SciSwigIterator *copy() const
{ {
return new self_type(*this); return new self_type(*this);
@ -289,14 +289,15 @@ namespace swig {
%fragment("SciSwigIterator"); %fragment("SciSwigIterator");
namespace swig namespace swig
{ {
// Throw a StopIteration exception // Throw a StopIteration exception
%ignore stop_iteration; %ignore stop_iteration;
struct stop_iteration {}; struct stop_iteration {};
%typemap(throws) stop_iteration { %typemap(throws) stop_iteration
error("stop_iteration exception"); {
Scierror(999, "%s: stop_iteration exception", SWIG_Scilab_GetFname());
SWIG_fail; SWIG_fail;
} }
@ -332,13 +333,13 @@ namespace swig
virtual SciObject value() const = 0; virtual SciObject value() const = 0;
virtual SciSwigIterator *incr(size_t n = 1) = 0; virtual SciSwigIterator *incr(size_t n = 1) = 0;
virtual SciSwigIterator *decr(size_t n = 1); virtual SciSwigIterator *decr(size_t n = 1);
virtual ptrdiff_t distance(const SciSwigIterator &x) const; virtual ptrdiff_t distance(const SciSwigIterator &x) const;
virtual bool equal (const SciSwigIterator &x) const; virtual bool equal (const SciSwigIterator &x) const;
virtual SciSwigIterator *copy() const = 0; virtual SciSwigIterator *copy() const = 0;
SciObject next(); SciObject next();