From: William F. <wsf...@us...> - 2005-12-26 23:24:06
|
Update of /cvsroot/swig/SWIG/Lib/csharp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30097/Lib/csharp Modified Files: std_vector.i Log Message: Use value_type to to more closely match the STL declarations and work around some bugs in some compilers for pointer references (when the type is a pointer) Index: std_vector.i =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/csharp/std_vector.i,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** std_vector.i 26 Nov 2005 09:28:18 -0000 1.9 --- std_vector.i 26 Dec 2005 23:23:58 -0000 1.10 *************** *** 7,10 **** --- 7,16 ---- * All the methods in IList are defined, but we don't derive from IList as this is a typesafe collection. * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents! + * + * Very often the C# generated code will not compile as the C++ template type is not the same as the C# + * proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg + * + * SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass) + * %template(VectKlass) std::vector<SomeNamespace::Klass>; */ *************** *** 164,176 **** public: typedef size_t size_type; %rename(Clear) clear; void clear(); %rename(Add) push_back; ! void push_back(const CTYPE& value); size_type size() const; size_type capacity() const; void reserve(size_type n); %newobject GetRange(int index, int count); ! %newobject Repeat(const CTYPE& value, int count); vector(); %extend { --- 170,183 ---- public: typedef size_t size_type; + typedef CTYPE value_type; %rename(Clear) clear; void clear(); %rename(Add) push_back; ! void push_back(const value_type& value); size_type size() const; size_type capacity() const; void reserve(size_type n); %newobject GetRange(int index, int count); ! %newobject Repeat(const value_type& value, int count); vector(); %extend { *************** *** 191,195 **** throw std::out_of_range("index"); } ! const CTYPE& getitem(int index) throw (std::out_of_range) { if (index>=0 && index<(int)self->size()) return (*self)[index]; --- 198,202 ---- throw std::out_of_range("index"); } ! const value_type& getitem(int index) throw (std::out_of_range) { if (index>=0 && index<(int)self->size()) return (*self)[index]; *************** *** 197,201 **** throw std::out_of_range("index"); } ! void setitem(int index, const CTYPE& value) throw (std::out_of_range) { if (index>=0 && index<(int)self->size()) (*self)[index] = value; --- 204,208 ---- throw std::out_of_range("index"); } ! void setitem(int index, const value_type& value) throw (std::out_of_range) { if (index>=0 && index<(int)self->size()) (*self)[index] = value; *************** *** 217,221 **** return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count); } ! void Insert(int index, const CTYPE& value) throw (std::out_of_range) { if (index>=0 && index<(int)self->size()+1) self->insert(self->begin()+index, value); --- 224,228 ---- return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count); } ! void Insert(int index, const value_type& value) throw (std::out_of_range) { if (index>=0 && index<(int)self->size()+1) self->insert(self->begin()+index, value); *************** *** 245,249 **** self->erase(self->begin()+index, self->begin()+index+count); } ! static std::vector<CTYPE > *Repeat(const CTYPE& value, int count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("count"); --- 252,256 ---- self->erase(self->begin()+index, self->begin()+index+count); } ! static std::vector<CTYPE > *Repeat(const value_type& value, int count) throw (std::out_of_range) { if (count < 0) throw std::out_of_range("count"); *************** *** 277,284 **** %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) %extend { ! bool Contains(const CTYPE& value) { return std::find(self->begin(), self->end(), value) != self->end(); } ! int IndexOf(const CTYPE& value) { int index = -1; std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); --- 284,291 ---- %define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...) %extend { ! bool Contains(const value_type& value) { return std::find(self->begin(), self->end(), value) != self->end(); } ! int IndexOf(const value_type& value) { int index = -1; std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); *************** *** 287,291 **** return index; } ! int LastIndexOf(const CTYPE& value) { int index = -1; std::vector<CTYPE >::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value); --- 294,298 ---- return index; } ! int LastIndexOf(const value_type& value) { int index = -1; std::vector<CTYPE >::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value); *************** *** 294,298 **** return index; } ! void Remove(const CTYPE& value) { std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); if (it != self->end()) --- 301,305 ---- return index; } ! void Remove(const value_type& value) { std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value); if (it != self->end()) |