diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2010-07-20 21:58:41 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2010-07-20 21:58:41 +0000 |
commit | ab1cd039793dd2ef4cf69320bf3f5fe6ca36f028 (patch) | |
tree | a21cfd0ca421c33faaa0d3d96ff11fc905935072 /Lib/std | |
parent | d8cc75946b236f08f9561a82867997e1021f96ab (diff) | |
parent | cb64f65bae17ed4eeaa257556f15e18f4742a993 (diff) | |
download | swig-ab1cd039793dd2ef4cf69320bf3f5fe6ca36f028.tar.gz |
merge revisions 11243-11872 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12162 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/std')
-rw-r--r-- | Lib/std/_std_deque.i | 25 | ||||
-rw-r--r-- | Lib/std/std_vector.i | 40 |
2 files changed, 58 insertions, 7 deletions
diff --git a/Lib/std/_std_deque.i b/Lib/std/_std_deque.i index c30523c0d..4234789a8 100644 --- a/Lib/std/_std_deque.i +++ b/Lib/std/_std_deque.i @@ -24,7 +24,7 @@ }; */ -%define %std_deque_methods(T) +%define %std_deque_methods_noempty(T) typedef T &reference; typedef const T& const_reference; @@ -38,7 +38,6 @@ unsigned int size() const; unsigned int max_size() const; void resize(unsigned int n, T c = T()); - bool empty() const; const_reference front(); const_reference back(); void push_front(const T& x); @@ -66,7 +65,7 @@ throw std::out_of_range("deque index out of range"); } void delitem(int i) throw (std::out_of_range) { - int size = int(self->size()); + int size = int(self->size()); if (i<0) i+= size; if (i>=0 && i<size) { self->erase(self->begin()+i); @@ -74,7 +73,7 @@ throw std::out_of_range("deque index out of range"); } } - std::deque<T> getslice(int i, int j) { + std::deque<T> getslice(int i, int j) { int size = int(self->size()); if (i<0) i = size+i; if (j<0) j = size+j; @@ -109,8 +108,23 @@ self->erase(self->begin()+i,self->begin()+j); } }; +%enddef +#ifdef SWIGPHP +%define %std_deque_methods(T) + %extend { + bool is_empty() const { + return self->empty(); + } + }; + %std_deque_methods_noempty(T) %enddef +#else +%define %std_deque_methods(T) + bool empty() const; + %std_deque_methods_noempty(T) +%enddef +#endif namespace std { template<class T> class deque { @@ -118,6 +132,3 @@ namespace std { %std_deque_methods(T); }; } - - - diff --git a/Lib/std/std_vector.i b/Lib/std/std_vector.i index ab1435b31..b0bb714d4 100644 --- a/Lib/std/std_vector.i +++ b/Lib/std/std_vector.i @@ -135,6 +135,46 @@ namespace std { }; // *** + // const pointer specialization + // *** + template<class _Tp, class _Alloc > + class vector<const _Tp *, _Alloc > { + public: + typedef size_t size_type; + typedef ptrdiff_t difference_type; + typedef const _Tp * value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + typedef value_type reference; + typedef value_type const_reference; + typedef _Alloc allocator_type; + + %traits_swigtype(_Tp); + + %fragment(SWIG_Traits_frag(std::vector<const _Tp *, _Alloc >), "header", + fragment=SWIG_Traits_frag(_Tp), + fragment="StdVectorTraits") { + namespace swig { + template <> struct traits<std::vector<const _Tp *, _Alloc > > { + typedef value_category category; + static const char* type_name() { + return "std::vector<const " #_Tp " *," #_Alloc " >"; + } + }; + } + } + + %typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<const _Tp *, _Alloc >); + +#ifdef %swig_vector_methods_val + // Add swig/language extra methods + %swig_vector_methods_val(std::vector<const _Tp *, _Alloc >); +#endif + + %std_vector_methods_val(vector); + }; + + // *** // *** // bool specialization |