Added new iterator changes to std.
This change does not break backwards compatability with python, so all works. The python stuff, however, will still not do all that ruby can now do. Updated manual to reflect the change and improve typemap documentation on the ruby side. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9787 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6f332a6e02
commit
315bd2da6e
8 changed files with 4618 additions and 341 deletions
4112
Doc/Manual/Ruby.html
4112
Doc/Manual/Ruby.html
File diff suppressed because it is too large
Load diff
|
|
@ -159,7 +159,7 @@ namespace swig {
|
|||
%fragment("RubySequence_Cont","header",
|
||||
fragment="StdTraits",
|
||||
fragment="RubySequence_Base",
|
||||
fragment="RubySwigIterator_T")
|
||||
fragment="ConstIterator_T")
|
||||
{
|
||||
namespace swig
|
||||
{
|
||||
|
|
@ -401,47 +401,85 @@ namespace swig
|
|||
*/
|
||||
%define %swig_sequence_iterator(Sequence...)
|
||||
#if defined(SWIG_EXPORT_ITERATOR_METHODS)
|
||||
class iterator;
|
||||
class reverse_iterator;
|
||||
class const_iterator;
|
||||
class const_reverse_iterator;
|
||||
|
||||
%typemap(out,noblock=1,fragment="RubySequence_Cont")
|
||||
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
|
||||
const_iterator, const_reverse_iterator {
|
||||
$result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
|
||||
swig::RubySwigIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1,fragment="RubySequence_Cont")
|
||||
std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
|
||||
iterator, reverse_iterator {
|
||||
$result = SWIG_NewPointerObj(swig::make_inout_iterator(%static_cast($1,const $type &)),
|
||||
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1,fragment="RubySequence_Cont")
|
||||
std::pair<const_iterator, const_iterator> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
|
||||
swig::RubySwigIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second),
|
||||
swig::RubySwigIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_LEN($result) = 2;
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1,fragment="RubySequence_Cont")
|
||||
std::pair<iterator, iterator> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_inout_iterator(%static_cast($1,const $type &).first),
|
||||
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_NewPointerObj(swig::make_inout_iterator(%static_cast($1,const $type &).second),
|
||||
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_LEN($result) = 2;
|
||||
}
|
||||
|
||||
|
||||
%fragment("RubyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="RubySequence_Cont") {}
|
||||
|
||||
%typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator")
|
||||
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
|
||||
std::pair<const_iterator, bool> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
|
||||
swig::RubySwigIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
swig::ConstIterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_From(bool)(%static_cast($1,const $type &).second);
|
||||
RARRAY_LEN($result) = 2;
|
||||
}
|
||||
|
||||
%typemap(out,noblock=1,fragment="RubyPairBoolOutputIterator")
|
||||
std::pair<iterator, bool> {
|
||||
$result = rb_ary_new2(2);
|
||||
RARRAY_PTR($result)[0] = SWIG_NewPointerObj(swig::make_inout_iterator(%static_cast($1,const $type &).first),
|
||||
swig::Iterator::descriptor(),SWIG_POINTER_OWN);
|
||||
RARRAY_PTR($result)[1] = SWIG_From(bool)(%static_cast($1,const $type &).second);
|
||||
RARRAY_LEN($result) = 2;
|
||||
}
|
||||
|
||||
%typemap(in,noblock=1,fragment="RubySequence_Cont")
|
||||
iterator(swig::RubySwigIterator *iter = 0, int res),
|
||||
reverse_iterator(swig::RubySwigIterator *iter = 0, int res),
|
||||
const_iterator(swig::RubySwigIterator *iter = 0, int res),
|
||||
const_reverse_iterator(swig::RubySwigIterator *iter = 0, int res) {
|
||||
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::RubySwigIterator::descriptor(), 0);
|
||||
const_iterator(swig::ConstIterator *iter = 0, int res),
|
||||
const_reverse_iterator(swig::ConstIterator *iter = 0, int res) {
|
||||
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter),
|
||||
swig::ConstIterator::descriptor(), 0);
|
||||
if (!SWIG_IsOK(res) || !iter) {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
} else {
|
||||
swig::RubySwigIterator_T<$type > *iter_t = dynamic_cast<swig::RubySwigIterator_T<$type > *>(iter);
|
||||
swig::ConstIterator_T<$type > *iter_t = dynamic_cast<swig::ConstIterator_T<$type > *>(iter);
|
||||
if (iter_t) {
|
||||
$1 = iter_t->get_current();
|
||||
} else {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%typemap(in,noblock=1,fragment="RubySequence_Cont")
|
||||
iterator(swig::Iterator *iter = 0, int res),
|
||||
reverse_iterator(swig::Iterator *iter = 0, int res) {
|
||||
res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::Iterator::descriptor(), 0);
|
||||
if (!SWIG_IsOK(res) || !iter) {
|
||||
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
|
||||
} else {
|
||||
swig::Iterator_T<$type > *iter_t = dynamic_cast<swig::Iterator_T<$type > *>(iter);
|
||||
if (iter_t) {
|
||||
$1 = iter_t->get_current();
|
||||
} else {
|
||||
|
|
@ -451,21 +489,35 @@ namespace swig
|
|||
}
|
||||
|
||||
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont")
|
||||
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
|
||||
swig::RubySwigIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::RubySwigIterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::RubySwigIterator_T<$type > *>(iter) != 0));
|
||||
const_iterator, const_reverse_iterator {
|
||||
swig::ConstIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::ConstIterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::ConstIterator_T<$type > *>(iter) != 0));
|
||||
}
|
||||
|
||||
%typecheck(%checkcode(ITERATOR),noblock=1,fragment="RubySequence_Cont")
|
||||
iterator, reverse_iterator {
|
||||
swig::ConstIterator *iter = 0;
|
||||
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter),
|
||||
swig::Iterator::descriptor(), 0);
|
||||
$1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::Iterator_T<$type > *>(iter) != 0));
|
||||
}
|
||||
|
||||
%fragment("RubySequence_Cont");
|
||||
|
||||
%newobject iterator;
|
||||
%extend {
|
||||
swig::RubySwigIterator* iterator(VALUE* RUBY_SELF) {
|
||||
return swig::make_output_iterator($self->begin(), $self->begin(),
|
||||
$self->end(), *RUBY_SELF);
|
||||
}
|
||||
}
|
||||
// %newobject iterator;
|
||||
// %newobject const_iterator;
|
||||
// %extend {
|
||||
// swig::Iterator* iterator(VALUE* RUBY_SELF) {
|
||||
// return swig::make_inout_iterator($self->begin(), $self->begin(),
|
||||
// $self->end(), *RUBY_SELF);
|
||||
// }
|
||||
|
||||
// swig::ConstIterator* const_iterator(VALUE* RUBY_SELF) {
|
||||
// return swig::make_output_iterator($self->begin(), $self->begin(),
|
||||
// $self->end(), *RUBY_SELF);
|
||||
// }
|
||||
// }
|
||||
#endif //SWIG_EXPORT_ITERATOR_METHODS
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@
|
|||
*
|
||||
* Implement a C++ 'output' iterator for Ruby.
|
||||
*
|
||||
* Users can derive form the RubySwigIterator to implemet their
|
||||
* Users can derive form the Iterator to implemet their
|
||||
* own iterators. As an example (real one since we use it for STL/STD
|
||||
* containers), the template RubySwigIterator_T does the
|
||||
* containers), the template Iterator_T does the
|
||||
* implementation for generic C++ iterators.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -18,53 +18,48 @@
|
|||
/**
|
||||
* Abstract base class used to represent all iterators of STL containers.
|
||||
*/
|
||||
%fragment("RubySwigIterator","header") {
|
||||
%fragment("ConstIterator","header") {
|
||||
namespace swig {
|
||||
struct stop_iteration {
|
||||
};
|
||||
|
||||
struct RubySwigIterator {
|
||||
private:
|
||||
struct ConstIterator {
|
||||
protected:
|
||||
VALUE _seq;
|
||||
|
||||
protected:
|
||||
RubySwigIterator(VALUE seq) : _seq(seq)
|
||||
ConstIterator(VALUE seq) : _seq(seq)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
virtual ~RubySwigIterator() {}
|
||||
virtual ~ConstIterator() {}
|
||||
|
||||
// Access iterator method, required by Ruby
|
||||
virtual VALUE value() const = 0;
|
||||
|
||||
// Forward iterator method, required by Ruby
|
||||
virtual RubySwigIterator *incr(size_t n = 1) = 0;
|
||||
virtual ConstIterator *incr(size_t n = 1) = 0;
|
||||
|
||||
// Backward iterator method, very common in C++, but not required in Ruby
|
||||
virtual RubySwigIterator *decr(size_t n = 1)
|
||||
virtual ConstIterator *decr(size_t n = 1)
|
||||
{
|
||||
throw stop_iteration();
|
||||
}
|
||||
|
||||
// Random access iterator methods, but not required in Ruby
|
||||
virtual ptrdiff_t distance(const RubySwigIterator &x) const
|
||||
virtual ptrdiff_t distance(const ConstIterator &x) const
|
||||
{
|
||||
throw std::invalid_argument("operation not supported");
|
||||
}
|
||||
|
||||
virtual bool equal (const RubySwigIterator &x) const
|
||||
virtual bool equal (const ConstIterator &x) const
|
||||
{
|
||||
throw std::invalid_argument("operation not supported");
|
||||
}
|
||||
|
||||
// C++ common/needed methods
|
||||
virtual RubySwigIterator *copy() const = 0;
|
||||
|
||||
virtual VALUE __deref__()
|
||||
{
|
||||
return Qnil;
|
||||
}
|
||||
virtual ConstIterator *dup() const = 0;
|
||||
|
||||
VALUE next()
|
||||
{
|
||||
|
|
@ -79,42 +74,42 @@ namespace swig {
|
|||
return value();
|
||||
}
|
||||
|
||||
RubySwigIterator *advance(ptrdiff_t n)
|
||||
ConstIterator *advance(ptrdiff_t n)
|
||||
{
|
||||
return (n > 0) ? incr(n) : decr(-n);
|
||||
}
|
||||
|
||||
bool operator == (const RubySwigIterator& x) const
|
||||
bool operator == (const ConstIterator& x) const
|
||||
{
|
||||
return equal(x);
|
||||
}
|
||||
|
||||
bool operator != (const RubySwigIterator& x) const
|
||||
bool operator != (const ConstIterator& x) const
|
||||
{
|
||||
return ! operator==(x);
|
||||
}
|
||||
|
||||
RubySwigIterator& operator += (ptrdiff_t n)
|
||||
ConstIterator& operator += (ptrdiff_t n)
|
||||
{
|
||||
return *advance(n);
|
||||
}
|
||||
|
||||
RubySwigIterator& operator -= (ptrdiff_t n)
|
||||
ConstIterator& operator -= (ptrdiff_t n)
|
||||
{
|
||||
return *advance(-n);
|
||||
}
|
||||
|
||||
RubySwigIterator* operator + (ptrdiff_t n) const
|
||||
ConstIterator* operator + (ptrdiff_t n) const
|
||||
{
|
||||
return copy()->advance(n);
|
||||
return dup()->advance(n);
|
||||
}
|
||||
|
||||
RubySwigIterator* operator - (ptrdiff_t n) const
|
||||
ConstIterator* operator - (ptrdiff_t n) const
|
||||
{
|
||||
return copy()->advance(-n);
|
||||
return dup()->advance(-n);
|
||||
}
|
||||
|
||||
ptrdiff_t operator - (const RubySwigIterator& x) const
|
||||
ptrdiff_t operator - (const ConstIterator& x) const
|
||||
{
|
||||
return x.distance(*this);
|
||||
}
|
||||
|
|
@ -123,33 +118,102 @@ namespace swig {
|
|||
static int init = 0;
|
||||
static swig_type_info* desc = 0;
|
||||
if (!init) {
|
||||
desc = SWIG_TypeQuery("swig::RubySwigIterator *");
|
||||
desc = SWIG_TypeQuery("swig::ConstIterator *");
|
||||
init = 1;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
}
|
||||
|
||||
// Ruby common/needed printing methods
|
||||
virtual VALUE inspect() const = 0;
|
||||
virtual VALUE to_s() const = 0;
|
||||
};
|
||||
|
||||
struct Iterator : public ConstIterator {
|
||||
protected:
|
||||
Iterator(VALUE seq) : ConstIterator(seq)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
// Iterator setter method, required by Ruby
|
||||
virtual bool set( const VALUE& v ) = 0;
|
||||
|
||||
static swig_type_info* descriptor() {
|
||||
static int init = 0;
|
||||
static swig_type_info* desc = 0;
|
||||
if (!init) {
|
||||
desc = SWIG_TypeQuery("swig::Iterator *");
|
||||
init = 1;
|
||||
}
|
||||
return desc;
|
||||
}
|
||||
|
||||
// C++ common/needed methods
|
||||
virtual Iterator *dup() const = 0;
|
||||
|
||||
Iterator *advance(ptrdiff_t n)
|
||||
{
|
||||
return (Iterator*) ( (n > 0) ? incr(n) : decr(-n) );
|
||||
}
|
||||
|
||||
bool operator == (const ConstIterator& x) const
|
||||
{
|
||||
return equal(x);
|
||||
}
|
||||
|
||||
bool operator != (const Iterator& x) const
|
||||
{
|
||||
return ! operator==(x);
|
||||
}
|
||||
|
||||
Iterator& operator += (ptrdiff_t n)
|
||||
{
|
||||
return *advance(n);
|
||||
}
|
||||
|
||||
Iterator& operator -= (ptrdiff_t n)
|
||||
{
|
||||
return *advance(-n);
|
||||
}
|
||||
|
||||
Iterator* operator + (ptrdiff_t n) const
|
||||
{
|
||||
return dup()->advance(n);
|
||||
}
|
||||
|
||||
Iterator* operator - (ptrdiff_t n) const
|
||||
{
|
||||
return dup()->advance(-n);
|
||||
}
|
||||
|
||||
ptrdiff_t operator - (const Iterator& x) const
|
||||
{
|
||||
return x.distance(*this);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment("RubySwigIterator_T","header",fragment="RubySwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
%fragment("ConstIterator_T","header",fragment="ConstIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
|
||||
namespace swig {
|
||||
|
||||
/**
|
||||
* Abstract base classes for all custom iterators.
|
||||
* Abstract base classes for all custom const_iterators.
|
||||
*
|
||||
*/
|
||||
template<typename OutIterator>
|
||||
class RubySwigIterator_T : public RubySwigIterator
|
||||
template<typename OutConstIterator>
|
||||
class ConstIterator_T : public ConstIterator
|
||||
{
|
||||
public:
|
||||
typedef OutIterator out_iterator;
|
||||
typedef OutConstIterator out_iterator;
|
||||
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
|
||||
typedef RubySwigIterator_T<out_iterator> self_type;
|
||||
typedef ConstIterator_T<out_iterator> self_type;
|
||||
|
||||
RubySwigIterator_T(out_iterator curr, VALUE seq = Qnil)
|
||||
: RubySwigIterator(seq), current(curr)
|
||||
ConstIterator_T(out_iterator curr, VALUE seq = Qnil)
|
||||
: ConstIterator(seq), current(curr)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +223,7 @@ namespace swig {
|
|||
}
|
||||
|
||||
|
||||
bool equal (const RubySwigIterator &iter) const
|
||||
bool equal (const ConstIterator &iter) const
|
||||
{
|
||||
const self_type *iters = dynamic_cast<const self_type *>(&iter);
|
||||
if (iters) {
|
||||
|
|
@ -169,7 +233,7 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
ptrdiff_t distance(const RubySwigIterator &iter) const
|
||||
virtual ptrdiff_t distance(const ConstIterator &iter) const
|
||||
{
|
||||
const self_type *iters = dynamic_cast<const self_type *>(&iter);
|
||||
if (iters) {
|
||||
|
|
@ -179,10 +243,110 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
virtual VALUE inspect() const
|
||||
{
|
||||
VALUE ret = rb_str_new2("#<");
|
||||
ret = rb_str_cat2( ret, rb_obj_classname(_seq) );
|
||||
ret = rb_str_cat2( ret, "::const_iterator " );
|
||||
VALUE cur = value();
|
||||
ret = rb_str_concat( ret, rb_inspect(cur) );
|
||||
ret = rb_str_cat2( ret, ">" );
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual VALUE to_s() const
|
||||
{
|
||||
VALUE ret = rb_str_new2( rb_obj_classname(_seq) );
|
||||
ret = rb_str_cat2( ret, "::const_iterator " );
|
||||
VALUE cur = value();
|
||||
ret = rb_str_concat( ret, rb_obj_as_string(cur) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected:
|
||||
out_iterator current;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Abstract base classes for all custom iterators.
|
||||
*
|
||||
*/
|
||||
template<typename InOutIterator>
|
||||
class Iterator_T : public Iterator
|
||||
{
|
||||
public:
|
||||
typedef InOutIterator inout_iterator;
|
||||
typedef typename std::iterator_traits<inout_iterator>::value_type value_type;
|
||||
typedef Iterator_T<inout_iterator> self_type;
|
||||
|
||||
Iterator_T(inout_iterator curr, VALUE seq = Qnil)
|
||||
: Iterator(seq), current(curr)
|
||||
{
|
||||
}
|
||||
|
||||
const inout_iterator& get_current() const
|
||||
{
|
||||
return current;
|
||||
}
|
||||
|
||||
bool equal (const ConstIterator &iter) const
|
||||
{
|
||||
const self_type *iters = dynamic_cast<const self_type *>(&iter);
|
||||
if (iters) {
|
||||
return (current == iters->get_current());
|
||||
} else {
|
||||
throw std::invalid_argument("bad iterator type");
|
||||
}
|
||||
}
|
||||
|
||||
virtual ptrdiff_t distance(const ConstIterator &iter) const
|
||||
{
|
||||
const self_type *iters = dynamic_cast<const self_type *>(&iter);
|
||||
if (iters) {
|
||||
return std::distance(current, iters->get_current());
|
||||
} else {
|
||||
throw std::invalid_argument("bad iterator type");
|
||||
}
|
||||
}
|
||||
|
||||
virtual VALUE inspect() const
|
||||
{
|
||||
VALUE ret = rb_str_new2("#<");
|
||||
ret = rb_str_cat2( ret, rb_obj_classname(_seq) );
|
||||
ret = rb_str_cat2( ret, "::iterator " );
|
||||
VALUE cur = value();
|
||||
ret = rb_str_concat( ret, rb_inspect(cur) );
|
||||
ret = rb_str_cat2( ret, ">" );
|
||||
return ret;
|
||||
}
|
||||
|
||||
virtual VALUE to_s() const
|
||||
{
|
||||
VALUE ret = rb_str_new2( rb_obj_classname(_seq) );
|
||||
ret = rb_str_cat2( ret, "::iterator " );
|
||||
VALUE cur = value();
|
||||
ret = rb_str_concat( ret, rb_obj_as_string(cur) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
protected:
|
||||
inout_iterator current;
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <class ValueType>
|
||||
struct asval_oper
|
||||
{
|
||||
typedef ValueType value_type;
|
||||
typedef bool result_type;
|
||||
bool operator()(VALUE obj, value_type& v) const
|
||||
{
|
||||
return ( swig::asval< value_type >(obj, &v) == SWIG_OK );
|
||||
}
|
||||
};
|
||||
|
||||
template <class ValueType>
|
||||
struct from_oper
|
||||
{
|
||||
|
|
@ -196,23 +360,23 @@ namespace swig {
|
|||
|
||||
|
||||
/**
|
||||
* Iterator class for a const_iterator with no end() boundaries.
|
||||
* ConstIterator class for a const_iterator with no end() boundaries.
|
||||
*
|
||||
*/
|
||||
template<typename OutIterator,
|
||||
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
|
||||
template<typename OutConstIterator,
|
||||
typename ValueType = typename std::iterator_traits<OutConstIterator>::value_type,
|
||||
typename FromOper = from_oper<ValueType> >
|
||||
class RubySwigIteratorOpen_T : public RubySwigIterator_T<OutIterator>
|
||||
class ConstIteratorOpen_T : public ConstIterator_T<OutConstIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
typedef OutIterator out_iterator;
|
||||
typedef OutConstIterator out_iterator;
|
||||
typedef ValueType value_type;
|
||||
typedef RubySwigIterator_T<out_iterator> base;
|
||||
typedef RubySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
|
||||
typedef ConstIterator_T<out_iterator> base;
|
||||
typedef ConstIteratorOpen_T<OutConstIterator, ValueType, FromOper> self_type;
|
||||
|
||||
RubySwigIteratorOpen_T(out_iterator curr, VALUE seq = Qnil)
|
||||
: RubySwigIterator_T<OutIterator>(curr, seq)
|
||||
ConstIteratorOpen_T(out_iterator curr, VALUE seq = Qnil)
|
||||
: ConstIterator_T<OutConstIterator>(curr, seq)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -220,12 +384,12 @@ namespace swig {
|
|||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
|
||||
RubySwigIterator *copy() const
|
||||
ConstIterator *dup() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
RubySwigIterator *incr(size_t n = 1)
|
||||
ConstIterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
++base::current;
|
||||
|
|
@ -233,7 +397,7 @@ namespace swig {
|
|||
return this;
|
||||
}
|
||||
|
||||
RubySwigIterator *decr(size_t n = 1)
|
||||
ConstIterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
--base::current;
|
||||
|
|
@ -242,25 +406,80 @@ namespace swig {
|
|||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Iterator class for a const_iterator where begin() and end() boundaries are known.
|
||||
* Iterator class for an iterator with no end() boundaries.
|
||||
*
|
||||
*/
|
||||
template<typename OutIterator,
|
||||
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
|
||||
template<typename InOutIterator,
|
||||
typename ValueType = typename std::iterator_traits<InOutIterator>::value_type,
|
||||
typename FromOper = from_oper<ValueType>,
|
||||
typename AsvalOper = asval_oper<ValueType> >
|
||||
class IteratorOpen_T : public Iterator_T<InOutIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
AsvalOper asval;
|
||||
typedef InOutIterator inout_iterator;
|
||||
typedef ValueType value_type;
|
||||
typedef Iterator_T<inout_iterator> base;
|
||||
typedef IteratorOpen_T<InOutIterator, ValueType, FromOper, AsvalOper> self_type;
|
||||
|
||||
IteratorOpen_T(inout_iterator curr, VALUE seq = Qnil)
|
||||
: Iterator_T<InOutIterator>(curr, seq)
|
||||
{
|
||||
}
|
||||
|
||||
virtual VALUE value() const {
|
||||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
|
||||
virtual bool set( const VALUE& v )
|
||||
{
|
||||
value_type& dst = *base::current;
|
||||
return asval(v, dst);
|
||||
}
|
||||
|
||||
Iterator *dup() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
Iterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
++base::current;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Iterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
--base::current;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* ConstIterator class for a const_iterator where begin() and end() boundaries are known.
|
||||
*
|
||||
*/
|
||||
template<typename OutConstIterator,
|
||||
typename ValueType = typename std::iterator_traits<OutConstIterator>::value_type,
|
||||
typename FromOper = from_oper<ValueType> >
|
||||
class RubySwigIteratorClosed_T : public RubySwigIterator_T<OutIterator>
|
||||
class ConstIteratorClosed_T : public ConstIterator_T<OutConstIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
typedef OutIterator out_iterator;
|
||||
typedef OutConstIterator out_iterator;
|
||||
typedef ValueType value_type;
|
||||
typedef RubySwigIterator_T<out_iterator> base;
|
||||
typedef RubySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
|
||||
typedef ConstIterator_T<out_iterator> base;
|
||||
typedef ConstIteratorClosed_T<OutConstIterator, ValueType, FromOper> self_type;
|
||||
|
||||
RubySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, VALUE seq = Qnil)
|
||||
: RubySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
|
||||
ConstIteratorClosed_T(out_iterator curr, out_iterator first,
|
||||
out_iterator last, VALUE seq = Qnil)
|
||||
: ConstIterator_T<OutConstIterator>(curr, seq), begin(first), end(last)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -272,12 +491,13 @@ namespace swig {
|
|||
}
|
||||
}
|
||||
|
||||
RubySwigIterator *copy() const
|
||||
|
||||
ConstIterator *dup() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
RubySwigIterator *incr(size_t n = 1)
|
||||
ConstIterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == end) {
|
||||
|
|
@ -289,7 +509,7 @@ namespace swig {
|
|||
return this;
|
||||
}
|
||||
|
||||
RubySwigIterator *decr(size_t n = 1)
|
||||
ConstIterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == begin) {
|
||||
|
|
@ -306,6 +526,225 @@ namespace swig {
|
|||
out_iterator end;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterator class for a const_iterator where begin() and end() boundaries are known.
|
||||
*
|
||||
*/
|
||||
template<typename InOutIterator,
|
||||
typename ValueType = typename std::iterator_traits<InOutIterator>::value_type,
|
||||
typename FromOper = from_oper<ValueType>,
|
||||
typename AsvalOper = asval_oper<ValueType> >
|
||||
class IteratorClosed_T : public Iterator_T<InOutIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
AsvalOper asval;
|
||||
typedef InOutIterator inout_iterator;
|
||||
typedef ValueType value_type;
|
||||
typedef Iterator_T<inout_iterator> base;
|
||||
typedef IteratorClosed_T<InOutIterator, ValueType, FromOper, AsvalOper> self_type;
|
||||
|
||||
IteratorClosed_T(inout_iterator curr, inout_iterator first,
|
||||
inout_iterator last, VALUE seq = Qnil)
|
||||
: Iterator_T<InOutIterator>(curr, seq), begin(first), end(last)
|
||||
{
|
||||
}
|
||||
|
||||
virtual VALUE value() const {
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
}
|
||||
|
||||
// Iterator setter method, required by Ruby
|
||||
virtual bool set( const VALUE& v )
|
||||
{
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
value_type& dst = *base::current;
|
||||
return asval( v, dst );
|
||||
}
|
||||
}
|
||||
|
||||
Iterator *dup() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
Iterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
++base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Iterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == begin) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
--base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
inout_iterator begin;
|
||||
inout_iterator end;
|
||||
};
|
||||
|
||||
/* Partial specialization for bools which don't allow de-referencing */
|
||||
template< typename InOutIterator, typename FromOper, typename AsvalOper >
|
||||
class IteratorOpen_T< InOutIterator, bool, FromOper, AsvalOper > :
|
||||
public Iterator_T<InOutIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
AsvalOper asval;
|
||||
typedef InOutIterator inout_iterator;
|
||||
typedef bool value_type;
|
||||
typedef Iterator_T<inout_iterator> base;
|
||||
typedef IteratorOpen_T<InOutIterator, bool, FromOper, AsvalOper> self_type;
|
||||
|
||||
IteratorOpen_T(inout_iterator curr, VALUE seq = Qnil)
|
||||
: Iterator_T<InOutIterator>(curr, seq)
|
||||
{
|
||||
}
|
||||
|
||||
virtual VALUE value() const {
|
||||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
|
||||
virtual bool set( const VALUE& v )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator *dup() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
Iterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
++base::current;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Iterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
--base::current;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* Partial specialization for bools which don't allow de-referencing */
|
||||
template< typename InOutIterator, typename FromOper, typename AsvalOper >
|
||||
class IteratorClosed_T< InOutIterator, bool, FromOper, AsvalOper > :
|
||||
public Iterator_T<InOutIterator>
|
||||
{
|
||||
public:
|
||||
FromOper from;
|
||||
AsvalOper asval;
|
||||
typedef InOutIterator inout_iterator;
|
||||
typedef bool value_type;
|
||||
typedef Iterator_T<inout_iterator> base;
|
||||
typedef IteratorClosed_T<InOutIterator, bool, FromOper, AsvalOper> self_type;
|
||||
|
||||
IteratorClosed_T(inout_iterator curr, inout_iterator first,
|
||||
inout_iterator last, VALUE seq = Qnil)
|
||||
: Iterator_T<InOutIterator>(curr, seq), begin(first), end(last)
|
||||
{
|
||||
}
|
||||
|
||||
virtual VALUE value() const {
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
return from(static_cast<const value_type&>(*(base::current)));
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool set( const VALUE& v )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Iterator *dup() const
|
||||
{
|
||||
return new self_type(*this);
|
||||
}
|
||||
|
||||
Iterator *incr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == end) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
++base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Iterator *decr(size_t n = 1)
|
||||
{
|
||||
while (n--) {
|
||||
if (base::current == begin) {
|
||||
throw stop_iteration();
|
||||
} else {
|
||||
--base::current;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private:
|
||||
inout_iterator begin;
|
||||
inout_iterator end;
|
||||
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Helper function used to wrap a bounded const_iterator. This is to be used in
|
||||
* a %typemap(out), for example.
|
||||
*
|
||||
*/
|
||||
template<typename InOutIter>
|
||||
inline Iterator*
|
||||
make_inout_iterator(const InOutIter& current, const InOutIter& begin,
|
||||
const InOutIter& end, VALUE seq = Qnil)
|
||||
{
|
||||
return new IteratorClosed_T<InOutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function used to wrap an unbounded const_iterator. This is to be used in
|
||||
* a %typemap(out), for example.
|
||||
*
|
||||
*/
|
||||
template<typename InOutIter>
|
||||
inline Iterator*
|
||||
make_inout_iterator(const InOutIter& current, VALUE seq = Qnil)
|
||||
{
|
||||
return new IteratorOpen_T<InOutIter>(current, seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function used to wrap a bounded const_iterator. This is to be used in
|
||||
|
|
@ -313,10 +752,11 @@ namespace swig {
|
|||
*
|
||||
*/
|
||||
template<typename OutIter>
|
||||
inline RubySwigIterator*
|
||||
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, VALUE seq = Qnil)
|
||||
inline ConstIterator*
|
||||
make_output_iterator(const OutIter& current, const OutIter& begin,
|
||||
const OutIter& end, VALUE seq = Qnil)
|
||||
{
|
||||
return new RubySwigIteratorClosed_T<OutIter>(current, begin, end, seq);
|
||||
return new ConstIteratorClosed_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -325,16 +765,16 @@ namespace swig {
|
|||
*
|
||||
*/
|
||||
template<typename OutIter>
|
||||
inline RubySwigIterator*
|
||||
inline ConstIterator*
|
||||
make_output_iterator(const OutIter& current, VALUE seq = Qnil)
|
||||
{
|
||||
return new RubySwigIteratorOpen_T<OutIter>(current, seq);
|
||||
return new ConstIteratorOpen_T<OutIter>(current, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%fragment("RubySwigIterator");
|
||||
%fragment("ConstIterator");
|
||||
|
||||
|
||||
//
|
||||
|
|
@ -357,59 +797,80 @@ namespace swig
|
|||
/*
|
||||
Mark methods that return new objects
|
||||
*/
|
||||
%newobject RubySwigIterator::copy;
|
||||
%newobject RubySwigIterator::operator + (ptrdiff_t n) const;
|
||||
%newobject RubySwigIterator::operator - (ptrdiff_t n) const;
|
||||
%newobject ConstIterator::dup;
|
||||
%newobject ConstIterator::operator + (ptrdiff_t n) const;
|
||||
%newobject ConstIterator::operator - (ptrdiff_t n) const;
|
||||
|
||||
%nodirector RubySwigIterator;
|
||||
%nodirector ConstIterator;
|
||||
|
||||
%catches(swig::stop_iteration) RubySwigIterator::value() const;
|
||||
%catches(swig::stop_iteration) RubySwigIterator::incr(size_t n = 1);
|
||||
%catches(swig::stop_iteration) RubySwigIterator::decr(size_t n = 1);
|
||||
%catches(std::invalid_argument) RubySwigIterator::distance(const RubySwigIterator &x) const;
|
||||
%catches(std::invalid_argument) RubySwigIterator::equal (const RubySwigIterator &x) const;
|
||||
%catches(swig::stop_iteration) RubySwigIterator::next();
|
||||
%catches(swig::stop_iteration) RubySwigIterator::previous();
|
||||
%catches(swig::stop_iteration) RubySwigIterator::advance(ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) RubySwigIterator::operator += (ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) RubySwigIterator::operator -= (ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) RubySwigIterator::operator + (ptrdiff_t n) const;
|
||||
%catches(swig::stop_iteration) RubySwigIterator::operator - (ptrdiff_t n) const;
|
||||
%catches(swig::stop_iteration) ConstIterator::value() const;
|
||||
%catches(swig::stop_iteration) ConstIterator::incr(size_t n = 1);
|
||||
%catches(swig::stop_iteration) ConstIterator::decr(size_t n = 1);
|
||||
%catches(std::invalid_argument) ConstIterator::distance(const ConstIterator &x) const;
|
||||
%catches(std::invalid_argument) ConstIterator::equal (const ConstIterator &x) const;
|
||||
%catches(swig::stop_iteration) ConstIterator::next();
|
||||
%catches(swig::stop_iteration) ConstIterator::previous();
|
||||
%catches(swig::stop_iteration) ConstIterator::advance(ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) ConstIterator::operator += (ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) ConstIterator::operator -= (ptrdiff_t n);
|
||||
%catches(swig::stop_iteration) ConstIterator::operator + (ptrdiff_t n) const;
|
||||
%catches(swig::stop_iteration) ConstIterator::operator - (ptrdiff_t n) const;
|
||||
|
||||
|
||||
struct RubySwigIterator
|
||||
struct ConstIterator
|
||||
{
|
||||
protected:
|
||||
RubySwigIterator(VALUE seq);
|
||||
ConstIterator(VALUE seq);
|
||||
|
||||
public:
|
||||
virtual ~RubySwigIterator();
|
||||
virtual ~ConstIterator();
|
||||
|
||||
// Access iterator method, required by Ruby
|
||||
virtual VALUE value() const = 0;
|
||||
|
||||
// Forward iterator method, required by Ruby
|
||||
virtual RubySwigIterator *incr(size_t n = 1) = 0;
|
||||
virtual ConstIterator *incr(size_t n = 1) = 0;
|
||||
|
||||
// Backward iterator method, very common in C++, but not required in Ruby
|
||||
virtual RubySwigIterator *decr(size_t n = 1);
|
||||
virtual ConstIterator *decr(size_t n = 1);
|
||||
|
||||
// Random access iterator methods, but not required in Ruby
|
||||
virtual ptrdiff_t distance(const RubySwigIterator &x) const;
|
||||
virtual ptrdiff_t distance(const ConstIterator &x) const;
|
||||
|
||||
virtual bool equal (const RubySwigIterator &x) const;
|
||||
virtual bool equal (const ConstIterator &x) const;
|
||||
|
||||
// C++ common/needed methods
|
||||
virtual RubySwigIterator *copy() const = 0;
|
||||
virtual ConstIterator *dup() const = 0;
|
||||
|
||||
virtual VALUE inspect() const = 0;
|
||||
virtual VALUE to_s() const = 0;
|
||||
|
||||
VALUE next();
|
||||
VALUE previous();
|
||||
RubySwigIterator *advance(ptrdiff_t n);
|
||||
ConstIterator *advance(ptrdiff_t n);
|
||||
|
||||
bool operator == (const RubySwigIterator& x) const;
|
||||
RubySwigIterator* operator + (ptrdiff_t n) const;
|
||||
RubySwigIterator* operator - (ptrdiff_t n) const;
|
||||
ptrdiff_t operator - (const RubySwigIterator& x) const;
|
||||
bool operator == (const ConstIterator& x) const;
|
||||
ConstIterator* operator + (ptrdiff_t n) const;
|
||||
ConstIterator* operator - (ptrdiff_t n) const;
|
||||
ptrdiff_t operator - (const ConstIterator& x) const;
|
||||
};
|
||||
|
||||
struct Iterator : public ConstIterator
|
||||
{
|
||||
virtual bool set( const VALUE& v ) = 0;
|
||||
|
||||
// Random access iterator methods, but not required in Ruby
|
||||
virtual ptrdiff_t distance(const Iterator &x) const;
|
||||
virtual bool equal (const Iterator &x) const;
|
||||
|
||||
virtual Iterator *dup() const = 0;
|
||||
Iterator *advance(ptrdiff_t n);
|
||||
|
||||
bool operator == (const Iterator& x) const;
|
||||
Iterator* operator + (ptrdiff_t n) const;
|
||||
Iterator* operator - (ptrdiff_t n) const;
|
||||
ptrdiff_t operator - (const Iterator& x) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,11 +84,12 @@
|
|||
}
|
||||
};
|
||||
|
||||
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
|
||||
struct RubyMapIterator_T : RubySwigIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||
template<class OutIterator, class FromOper,
|
||||
class ValueType = typename OutIterator::value_type>
|
||||
struct MapIterator_T : ConstIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||
{
|
||||
RubyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq)
|
||||
: RubySwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||
MapIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq)
|
||||
: ConstIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
|
@ -96,37 +97,39 @@
|
|||
|
||||
template<class OutIterator,
|
||||
class FromOper = from_key_oper<typename OutIterator::value_type> >
|
||||
struct RubyMapKeyIterator_T : RubyMapIterator_T<OutIterator, FromOper>
|
||||
struct MapKeyIterator_T : MapIterator_T<OutIterator, FromOper>
|
||||
{
|
||||
RubyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq)
|
||||
: RubyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
MapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq)
|
||||
: MapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template<typename OutIter>
|
||||
inline RubySwigIterator*
|
||||
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = 0)
|
||||
inline ConstIterator*
|
||||
make_output_key_iterator(const OutIter& current, const OutIter& begin,
|
||||
const OutIter& end, VALUE seq = 0)
|
||||
{
|
||||
return new RubyMapKeyIterator_T<OutIter>(current, begin, end, seq);
|
||||
return new MapKeyIterator_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
|
||||
template<class OutIterator,
|
||||
class FromOper = from_value_oper<typename OutIterator::value_type> >
|
||||
struct RubyMapValueIterator_T : RubyMapIterator_T<OutIterator, FromOper>
|
||||
struct MapValueIterator_T : MapIterator_T<OutIterator, FromOper>
|
||||
{
|
||||
RubyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq)
|
||||
: RubyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
MapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, VALUE seq)
|
||||
: MapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename OutIter>
|
||||
inline RubySwigIterator*
|
||||
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, VALUE seq = 0)
|
||||
inline ConstIterator*
|
||||
make_output_value_iterator(const OutIter& current, const OutIter& begin,
|
||||
const OutIter& end, VALUE seq = 0)
|
||||
{
|
||||
return new RubyMapValueIterator_T<OutIter>(current, begin, end, seq);
|
||||
return new MapValueIterator_T<OutIter>(current, begin, end, seq);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -309,13 +312,15 @@
|
|||
}
|
||||
|
||||
%newobject key_iterator(VALUE *RUBY_SELF);
|
||||
swig::RubySwigIterator* key_iterator(VALUE *RUBY_SELF) {
|
||||
return swig::make_output_key_iterator($self->begin(), $self->begin(), $self->end(), *RUBY_SELF);
|
||||
swig::ConstIterator* key_iterator(VALUE *RUBY_SELF) {
|
||||
return swig::make_output_key_iterator($self->begin(), $self->begin(),
|
||||
$self->end(), *RUBY_SELF);
|
||||
}
|
||||
|
||||
%newobject value_iterator(VALUE *RUBY_SELF);
|
||||
swig::RubySwigIterator* value_iterator(VALUE *RUBY_SELF) {
|
||||
return swig::make_output_value_iterator($self->begin(), $self->begin(), $self->end(), *RUBY_SELF);
|
||||
swig::ConstIterator* value_iterator(VALUE *RUBY_SELF) {
|
||||
return swig::make_output_value_iterator($self->begin(), $self->begin(),
|
||||
$self->end(), *RUBY_SELF);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
%}
|
||||
|
||||
%define %swig_set_methods(set...)
|
||||
%swig_sequence_iterator(set)
|
||||
%swig_sequence_methods_common(set);
|
||||
|
||||
%extend {
|
||||
|
|
|
|||
|
|
@ -17,11 +17,8 @@
|
|||
void erase(iterator first, iterator last);
|
||||
|
||||
iterator find(const key_type& x);
|
||||
const_iterator find(const key_type& x) const;
|
||||
iterator lower_bound(const key_type& x);
|
||||
const_iterator lower_bound(const key_type& x) const;
|
||||
iterator upper_bound(const key_type& x);
|
||||
const_iterator upper_bound(const key_type& x) const;
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
|
|
|
|||
|
|
@ -7,26 +7,35 @@
|
|||
|
||||
// Set
|
||||
%define %std_set_methods_common(set...)
|
||||
%std_container_methods(set);
|
||||
class const_iterator;
|
||||
class const_reverse_iterator;
|
||||
|
||||
set();
|
||||
set( const set& );
|
||||
|
||||
const_iterator begin() const;
|
||||
const_iterator end() const;
|
||||
const_reverse_iterator rbegin();
|
||||
const_reverse_iterator rend();
|
||||
|
||||
size_type erase(const key_type& x);
|
||||
size_type count(const key_type& x) const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
void erase(iterator pos);
|
||||
void erase(iterator first, iterator last);
|
||||
void erase(const_iterator pos);
|
||||
void erase(const_iterator first, const_iterator last);
|
||||
|
||||
iterator find(const key_type& x);
|
||||
iterator lower_bound(const key_type& x);
|
||||
iterator upper_bound(const key_type& x);
|
||||
std::pair<iterator,iterator> equal_range(const key_type& x);
|
||||
const_iterator find(const key_type& x);
|
||||
const_iterator lower_bound(const key_type& x);
|
||||
const_iterator upper_bound(const key_type& x);
|
||||
std::pair<const_iterator,const_iterator> equal_range(const key_type& x);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
%define %std_set_methods(set...)
|
||||
%std_set_methods_common(set);
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
std::pair<iterator,bool> insert(const value_type& __x);
|
||||
std::pair<const_iterator,bool> insert(const value_type& __x);
|
||||
#endif
|
||||
%enddef
|
||||
|
||||
|
|
@ -99,6 +108,5 @@ namespace std {
|
|||
#endif
|
||||
|
||||
%std_set_methods(set);
|
||||
|
||||
};
|
||||
}
|
||||
|
|
|
|||
3
README
3
README
|
|
@ -27,11 +27,12 @@ Active Developers:
|
|||
Mikel Bancroft (mikel@franz.com) (Allegro CL)
|
||||
John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
|
||||
Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI)
|
||||
Charlie Savage (cfis@interserv.com) (Ruby)
|
||||
Mark Gossage (mark@gossage.cjb.net) (Lua)
|
||||
Joseph Wang (joe@gnacademy.org) (R)
|
||||
Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
|
||||
Major contributors include:
|
||||
Lyle Johnson (lyle@users.sourceforge.net) (Ruby)
|
||||
Charlie Savage (cfis@interserv.com) (Ruby)
|
||||
Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
|
||||
Richard Palmer (richard@magicality.org) (PHP)
|
||||
Sam Liddicott - Anonova Ltd (saml@liddicott.com) (PHP)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue