Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid throwing exceptions with normal usage of iterators.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12231 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
40e64b14f1
commit
8a05a23612
2 changed files with 17 additions and 11 deletions
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.1 (in progress)
|
Version 2.0.1 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2010-09-28: wsfulton
|
||||||
|
[C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
|
||||||
|
throwing exceptions with normal usage of iterators.
|
||||||
|
|
||||||
2010-09-25: wsfulton
|
2010-09-25: wsfulton
|
||||||
Apply SF patch #3075150 - Java directors using static variables in
|
Apply SF patch #3075150 - Java directors using static variables in
|
||||||
named namespace.
|
named namespace.
|
||||||
|
|
|
||||||
|
|
@ -67,12 +67,13 @@
|
||||||
public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
|
public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
|
||||||
get {
|
get {
|
||||||
System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>();
|
System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>();
|
||||||
|
int size = this.Count;
|
||||||
|
if (size > 0) {
|
||||||
IntPtr iter = create_iterator_begin();
|
IntPtr iter = create_iterator_begin();
|
||||||
try {
|
for (int i = 0; i < size; i++) {
|
||||||
while (true) {
|
|
||||||
keys.Add(get_next_key(iter));
|
keys.Add(get_next_key(iter));
|
||||||
}
|
}
|
||||||
} catch (ArgumentOutOfRangeException) {
|
destroy_iterator(iter);
|
||||||
}
|
}
|
||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
@ -258,7 +259,7 @@
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create_iterator_begin() and get_next_key() work together to provide a collection of keys to C#
|
// create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C#
|
||||||
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
|
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
|
||||||
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
|
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
|
||||||
|
|
||||||
|
|
@ -266,15 +267,15 @@
|
||||||
return new std::map< K, T >::iterator($self->begin());
|
return new std::map< K, T >::iterator($self->begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) throw (std::out_of_range) {
|
const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
|
||||||
std::map< K, T >::iterator iter = *swigiterator;
|
std::map< K, T >::iterator iter = *swigiterator;
|
||||||
if (iter == $self->end()) {
|
swigiterator++;
|
||||||
delete swigiterator;
|
|
||||||
throw std::out_of_range("no more map elements");
|
|
||||||
}
|
|
||||||
(*swigiterator)++;
|
|
||||||
return (*iter).first;
|
return (*iter).first;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void destroy_iterator(std::map< K, T >::iterator *swigiterator) {
|
||||||
|
delete swigiterator;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -285,6 +286,7 @@
|
||||||
%csmethodmodifiers std::map::setitem "private"
|
%csmethodmodifiers std::map::setitem "private"
|
||||||
%csmethodmodifiers std::map::create_iterator_begin "private"
|
%csmethodmodifiers std::map::create_iterator_begin "private"
|
||||||
%csmethodmodifiers std::map::get_next_key "private"
|
%csmethodmodifiers std::map::get_next_key "private"
|
||||||
|
%csmethodmodifiers std::map::destroy_iterator "private"
|
||||||
|
|
||||||
// Default implementation
|
// Default implementation
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue