Updated Ruby's STL to new framework.
Still need to add new tests for multimap, multiset, list, etc. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9719 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c1119d264a
commit
a0b74a907e
23 changed files with 1330 additions and 2739 deletions
60
Lib/ruby/std_set.i
Normal file
60
Lib/ruby/std_set.i
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
Sets
|
||||
*/
|
||||
|
||||
%fragment("StdSetTraits","header",fragment="StdSequenceTraits")
|
||||
%{
|
||||
namespace swig {
|
||||
template <class RubySeq, class T>
|
||||
inline void
|
||||
assign(const RubySeq& rubyseq, std::set<T>* seq) {
|
||||
#ifdef SWIG_STD_NOINSERT_TEMPLATE_STL
|
||||
typedef typename RubySeq::value_type value_type;
|
||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||
for (;it != rubyseq.end(); ++it) {
|
||||
seq->insert(seq->end(),(value_type)(*it));
|
||||
}
|
||||
#else
|
||||
seq->insert(rubyseq.begin(), rubyseq.end());
|
||||
#endif
|
||||
}
|
||||
|
||||
template <class T>
|
||||
struct traits_asptr<std::set<T> > {
|
||||
static int asptr(VALUE obj, std::set<T> **s) {
|
||||
return traits_asptr_stdseq<std::set<T> >::asptr(obj, s);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct traits_from<std::set<T> > {
|
||||
static VALUE from(const std::set<T>& vec) {
|
||||
return traits_from_stdseq<std::set<T> >::from(vec);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%define %swig_set_methods(set...)
|
||||
%swig_sequence_iterator(set);
|
||||
%swig_container_methods(set);
|
||||
|
||||
%extend {
|
||||
const value_type& push(value_type x) {
|
||||
self->insert(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
%rename("include?") __contains__;
|
||||
bool __contains__(value_type x) {
|
||||
return self->find(x) != self->end();
|
||||
}
|
||||
|
||||
value_type __getitem__(difference_type i) const throw (std::out_of_range) {
|
||||
return *(swig::cgetpos(self, i));
|
||||
}
|
||||
|
||||
};
|
||||
%enddef
|
||||
|
||||
%include <std/std_set.i>
|
||||
Loading…
Add table
Add a link
Reference in a new issue