From 05c8c972cc32c11bc4adbbfd45e73cd7bf97495f Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Thu, 18 Apr 2019 23:24:43 +0100 Subject: Improve backwards compatibility in Java std::vector wrappers For users who have typemaps for the parameters in the add and set methods (now called doAdd and doSet). Also for users who have typemaps for the get method - revert the return type for get (now called doGet) back to the same return type as std::vector::at. Correct definitions of const_reference to match the those in the (C++11) standard. --- Lib/java/std_vector.i | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'Lib/java') diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i index 88de46f46..e33270238 100644 --- a/Lib/java/std_vector.i +++ b/Lib/java/std_vector.i @@ -105,14 +105,14 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { return SWIG_VectorSize(self->size()); } - void doAdd(const value_type& value) { - self->push_back(value); + void doAdd(const value_type& x) { + self->push_back(x); } - void doAdd(jint index, const value_type& value) throw (std::out_of_range) { + void doAdd(jint index, const value_type& x) throw (std::out_of_range) { jint size = static_cast(self->size()); if (0 <= index && index <= size) { - self->insert(self->begin() + index, value); + self->insert(self->begin() + index, x); } else { throw std::out_of_range("vector index out of range"); } @@ -129,7 +129,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { } } - CONST_REFERENCE doGet(jint index) throw (std::out_of_range) { + const_reference doGet(jint index) throw (std::out_of_range) { jint size = static_cast(self->size()); if (index >= 0 && index < size) return (*self)[index]; @@ -137,11 +137,11 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { throw std::out_of_range("vector index out of range"); } - value_type doSet(jint index, const value_type& value) throw (std::out_of_range) { + value_type doSet(jint index, const value_type& val) throw (std::out_of_range) { jint size = static_cast(self->size()); if (index >= 0 && index < size) { CTYPE const old_value = (*self)[index]; - (*self)[index] = value; + (*self)[index] = val; return old_value; } else @@ -169,7 +169,7 @@ SWIGINTERN jint SWIG_VectorSize(size_t size) { namespace std { template class vector { - SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const T&) + SWIG_STD_VECTOR_MINIMUM_INTERNAL(T, const value_type&) }; // bool specialization -- cgit v1.2.1