Remove unnecessary vector of constant pointer specialization since the improved default typemap matching rules were introduced
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11961 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b6c4ea90b6
commit
482c06c28c
2 changed files with 18 additions and 30 deletions
|
|
@ -74,12 +74,6 @@ const std::vector<Struct *> & vecstructptr(const std::vector<Struct *> & vec) {
|
||||||
const std::vector<const Struct *> & vecstructconstptr(const std::vector<const Struct *> & vec) { return vec; }
|
const std::vector<const Struct *> & vecstructconstptr(const std::vector<const Struct *> & vec) { return vec; }
|
||||||
%}
|
%}
|
||||||
|
|
||||||
#if defined(SWIGCSHARP)
|
|
||||||
// Also test const and non-const pointers, but not strictly necessary since std::vector was enhanced in swig-1.3.40
|
|
||||||
%template(StructurePtrVector) std::vector<Structure *>;
|
|
||||||
%template(StructureConstPtrVector) std::vector<const Structure *>;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if !defined(SWIGR)
|
#if !defined(SWIGR)
|
||||||
%template(IntPtrVector) std::vector<int *>;
|
%template(IntPtrVector) std::vector<int *>;
|
||||||
%template(IntConstPtrVector) std::vector<const int *>;
|
%template(IntConstPtrVector) std::vector<const int *>;
|
||||||
|
|
@ -88,7 +82,6 @@ const std::vector<const Struct *> & vecstructconstptr(const std::vector<const St
|
||||||
%template(StructPtrVector) std::vector<Struct *>;
|
%template(StructPtrVector) std::vector<Struct *>;
|
||||||
%template(StructConstPtrVector) std::vector<const Struct *>;
|
%template(StructConstPtrVector) std::vector<const Struct *>;
|
||||||
|
|
||||||
#if !defined(SWIGTCL)
|
|
||||||
%inline {
|
%inline {
|
||||||
struct MyClass {};
|
struct MyClass {};
|
||||||
typedef MyClass *MyClassPtr;
|
typedef MyClass *MyClassPtr;
|
||||||
|
|
@ -106,7 +99,6 @@ const std::vector<const Struct *> & vecstructconstptr(const std::vector<const St
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(SWIGRUBY)
|
#if defined(SWIGRUBY)
|
||||||
%template(LanguageVector) std::vector< swig::LANGUAGE_OBJ >;
|
%template(LanguageVector) std::vector< swig::LANGUAGE_OBJ >;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
%include <std_common.i>
|
%include <std_common.i>
|
||||||
|
|
||||||
// MACRO for use within the std::vector class body
|
// MACRO for use within the std::vector class body
|
||||||
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CTYPE...)
|
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...)
|
||||||
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
|
%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n#endif\n";
|
||||||
%typemap(cscode) std::vector<CTYPE > %{
|
%typemap(cscode) std::vector<CTYPE > %{
|
||||||
public $csclassname(System.Collections.ICollection c) : this() {
|
public $csclassname(System.Collections.ICollection c) : this() {
|
||||||
|
|
@ -208,16 +208,16 @@
|
||||||
public:
|
public:
|
||||||
typedef size_t size_type;
|
typedef size_t size_type;
|
||||||
typedef CTYPE value_type;
|
typedef CTYPE value_type;
|
||||||
typedef CONST_REFERENCE_TYPE const_reference;
|
typedef CONST_REFERENCE const_reference;
|
||||||
%rename(Clear) clear;
|
%rename(Clear) clear;
|
||||||
void clear();
|
void clear();
|
||||||
%rename(Add) push_back;
|
%rename(Add) push_back;
|
||||||
void push_back(const value_type& x);
|
void push_back(CTYPE const& x);
|
||||||
size_type size() const;
|
size_type size() const;
|
||||||
size_type capacity() const;
|
size_type capacity() const;
|
||||||
void reserve(size_type n);
|
void reserve(size_type n);
|
||||||
%newobject GetRange(int index, int count);
|
%newobject GetRange(int index, int count);
|
||||||
%newobject Repeat(const value_type& value, int count);
|
%newobject Repeat(CTYPE const& value, int count);
|
||||||
vector();
|
vector();
|
||||||
vector(const vector &other);
|
vector(const vector &other);
|
||||||
%extend {
|
%extend {
|
||||||
|
|
@ -243,7 +243,7 @@
|
||||||
else
|
else
|
||||||
throw std::out_of_range("index");
|
throw std::out_of_range("index");
|
||||||
}
|
}
|
||||||
void setitem(int index, const value_type& val) throw (std::out_of_range) {
|
void setitem(int index, CTYPE const& val) throw (std::out_of_range) {
|
||||||
if (index>=0 && index<(int)$self->size())
|
if (index>=0 && index<(int)$self->size())
|
||||||
(*$self)[index] = val;
|
(*$self)[index] = val;
|
||||||
else
|
else
|
||||||
|
|
@ -263,7 +263,7 @@
|
||||||
throw std::invalid_argument("invalid range");
|
throw std::invalid_argument("invalid range");
|
||||||
return new std::vector<CTYPE >($self->begin()+index, $self->begin()+index+count);
|
return new std::vector<CTYPE >($self->begin()+index, $self->begin()+index+count);
|
||||||
}
|
}
|
||||||
void Insert(int index, const value_type& x) throw (std::out_of_range) {
|
void Insert(int index, CTYPE const& x) throw (std::out_of_range) {
|
||||||
if (index>=0 && index<(int)$self->size()+1)
|
if (index>=0 && index<(int)$self->size()+1)
|
||||||
$self->insert($self->begin()+index, x);
|
$self->insert($self->begin()+index, x);
|
||||||
else
|
else
|
||||||
|
|
@ -291,7 +291,7 @@
|
||||||
throw std::invalid_argument("invalid range");
|
throw std::invalid_argument("invalid range");
|
||||||
$self->erase($self->begin()+index, $self->begin()+index+count);
|
$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) {
|
static std::vector<CTYPE > *Repeat(CTYPE const& value, int count) throw (std::out_of_range) {
|
||||||
if (count < 0)
|
if (count < 0)
|
||||||
throw std::out_of_range("count");
|
throw std::out_of_range("count");
|
||||||
return new std::vector<CTYPE >(count, value);
|
return new std::vector<CTYPE >(count, value);
|
||||||
|
|
@ -320,31 +320,31 @@
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
%define SWIG_STD_VECTOR_MINIMUM(CTYPE...)
|
%define SWIG_STD_VECTOR_MINIMUM(CTYPE...)
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, CTYPE const&, CTYPE)
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
// Extra methods added to the collection class if operator== is defined for the class being wrapped
|
||||||
// The class will then implement IList<>, which adds extra functionality
|
// The class will then implement IList<>, which adds extra functionality
|
||||||
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
|
||||||
%extend {
|
%extend {
|
||||||
bool Contains(const value_type& value) {
|
bool Contains(CTYPE const& value) {
|
||||||
return std::find($self->begin(), $self->end(), value) != $self->end();
|
return std::find($self->begin(), $self->end(), value) != $self->end();
|
||||||
}
|
}
|
||||||
int IndexOf(const value_type& value) {
|
int IndexOf(CTYPE const& value) {
|
||||||
int index = -1;
|
int index = -1;
|
||||||
std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||||
if (it != $self->end())
|
if (it != $self->end())
|
||||||
index = (int)(it - $self->begin());
|
index = (int)(it - $self->begin());
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
int LastIndexOf(const value_type& value) {
|
int LastIndexOf(CTYPE const& value) {
|
||||||
int index = -1;
|
int index = -1;
|
||||||
std::vector<CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value);
|
std::vector<CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value);
|
||||||
if (rit != $self->rend())
|
if (rit != $self->rend())
|
||||||
index = (int)($self->rend() - 1 - rit);
|
index = (int)($self->rend() - 1 - rit);
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
bool Remove(const value_type& value) {
|
bool Remove(CTYPE const& value) {
|
||||||
std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
|
||||||
if (it != $self->end()) {
|
if (it != $self->end()) {
|
||||||
$self->erase(it);
|
$self->erase(it);
|
||||||
|
|
@ -359,7 +359,7 @@ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CTYPE)
|
||||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||||
namespace std {
|
namespace std {
|
||||||
template<> class vector<CTYPE > {
|
template<> class vector<CTYPE > {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CTYPE)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, CTYPE const&, CTYPE)
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -394,16 +394,12 @@ namespace std {
|
||||||
template<class T> class vector {
|
template<class T> class vector {
|
||||||
SWIG_STD_VECTOR_MINIMUM(T)
|
SWIG_STD_VECTOR_MINIMUM(T)
|
||||||
};
|
};
|
||||||
// specializations for pointers
|
// specialization for pointers
|
||||||
template<class T> class vector<T*> {
|
template<class T> class vector<T *> {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T*)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *)
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T*)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||||
};
|
};
|
||||||
template<class T> class vector<const T*> {
|
// bool is specialized in the C++ standard - const_reference in particular
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, const T*)
|
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(const T*)
|
|
||||||
};
|
|
||||||
// bool is a bit different in the C++ standard
|
|
||||||
template<> class vector<bool> {
|
template<> class vector<bool> {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool)
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue