summaryrefslogtreecommitdiff
path: root/Lib/guile
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2018-10-09 19:44:00 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2018-10-09 19:44:00 +0100
commitca287ae13b069ab0f8c914a81a615de77c34dbcc (patch)
tree80ac86edbdd77ad21c6dc6d27fc009ac4f3f280c /Lib/guile
parent220a735ec5797df0750ffc20998383fcbd22f828 (diff)
downloadswig-ca287ae13b069ab0f8c914a81a615de77c34dbcc.tar.gz
Add support for non-default compare template argument in std::map wrappers
Diffstat (limited to 'Lib/guile')
-rw-r--r--Lib/guile/std_map.i176
1 files changed, 88 insertions, 88 deletions
diff --git a/Lib/guile/std_map.i b/Lib/guile/std_map.i
index 489acc187..e945afd86 100644
--- a/Lib/guile/std_map.i
+++ b/Lib/guile/std_map.i
@@ -40,12 +40,12 @@
namespace std {
- template<class K, class T> class map {
- %typemap(in) map<K,T> {
+ template<class K, class T, class C = std::less<K> > class map {
+ %typemap(in) map< K, T, C > {
if (scm_is_null($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
} else if (scm_is_pair($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
SCM alist = $input;
while (!scm_is_null(alist)) {
K* k;
@@ -72,13 +72,13 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp),
- const map<K,T>* (std::map<K,T> temp) {
+ %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp),
+ const map< K, T, C >* (std::map< K, T, C > temp) {
if (scm_is_null($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
} else if (scm_is_pair($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
SCM alist = $input;
while (!scm_is_null(alist)) {
@@ -105,9 +105,9 @@ namespace std {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
- %typemap(out) map<K,T> {
+ %typemap(out) map< K, T, C > {
SCM alist = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=$i.rbegin(); i!=$i.rend(); ++i) {
K* key = new K(i->first);
T* val = new T(i->second);
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
@@ -117,7 +117,7 @@ namespace std {
}
$result = alist;
}
- %typecheck(SWIG_TYPECHECK_MAP) map<K,T> {
+ %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > {
/* native sequence? */
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -153,7 +153,7 @@ namespace std {
}
} else {
/* wrapped map? */
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
@@ -161,8 +161,8 @@ namespace std {
$1 = 0;
}
}
- %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&,
- const map<K,T>* {
+ %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&,
+ const map< K, T, C >* {
/* native sequence? */
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -198,7 +198,7 @@ namespace std {
}
} else {
/* wrapped map? */
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
@@ -219,14 +219,14 @@ namespace std {
typedef K key_type;
typedef T mapped_type;
map();
- map(const map< K, T> &);
+ map(const map< K, T, C> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& __getitem__(const K& key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
@@ -236,19 +236,19 @@ namespace std {
(*self)[key] = x;
}
void __delitem__(const K& key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
return i != self->end();
}
SCM keys() {
SCM result = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
K* key = new K(i->first);
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
result = scm_cons(k,result);
@@ -263,12 +263,12 @@ namespace std {
%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
- template<class T> class map<K,T> {
- %typemap(in) map<K,T> {
+ template<class T> class map< K, T, C > {
+ %typemap(in) map< K, T, C > {
if (scm_is_null($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
} else if (scm_is_pair($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
SCM alist = $input;
while (!scm_is_null(alist)) {
T* x;
@@ -280,7 +280,7 @@ namespace std {
val = SCM_CDR(entry);
if (!CHECK(key))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) != 0) {
if (!scm_is_pair(val))
@@ -296,13 +296,13 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp),
- const map<K,T>* (std::map<K,T> temp) {
+ %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp),
+ const map< K, T, C >* (std::map< K, T, C > temp) {
if (scm_is_null($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
} else if (scm_is_pair($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
SCM alist = $input;
while (!scm_is_null(alist)) {
@@ -315,7 +315,7 @@ namespace std {
val = SCM_CDR(entry);
if (!CHECK(key))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
if (SWIG_ConvertPtr(val,(void**) &x,
$descriptor(T *), 0) != 0) {
if (!scm_is_pair(val))
@@ -330,9 +330,9 @@ namespace std {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
- %typemap(out) map<K,T> {
+ %typemap(out) map< K, T, C > {
SCM alist = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) {
T* val = new T(i->second);
SCM k = CONVERT_TO(i->first);
SCM x = SWIG_NewPointerObj(val,$descriptor(T *), 1);
@@ -341,7 +341,7 @@ namespace std {
}
$result = alist;
}
- %typecheck(SWIG_TYPECHECK_MAP) map<K,T> {
+ %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > {
// native sequence?
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -375,7 +375,7 @@ namespace std {
}
} else {
// wrapped map?
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
@@ -383,8 +383,8 @@ namespace std {
$1 = 0;
}
}
- %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&,
- const map<K,T>* {
+ %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&,
+ const map< K, T, C >* {
// native sequence?
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -418,7 +418,7 @@ namespace std {
}
} else {
// wrapped map?
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
@@ -435,14 +435,14 @@ namespace std {
%rename("has-key?") has_key;
public:
map();
- map(const map< K, T > &);
+ map(const map< K, T, C > &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
T& __getitem__(K key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
@@ -452,19 +452,19 @@ namespace std {
(*self)[key] = x;
}
void __delitem__(K key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(K key) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
return i != self->end();
}
SCM keys() {
SCM result = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
SCM k = CONVERT_TO(i->first);
result = scm_cons(k,result);
}
@@ -475,12 +475,12 @@ namespace std {
%enddef
%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
- template<class K> class map<K,T> {
- %typemap(in) map<K,T> {
+ template<class K> class map< K, T, C > {
+ %typemap(in) map< K, T, C > {
if (scm_is_null($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
} else if (scm_is_pair($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
SCM alist = $input;
while (!scm_is_null(alist)) {
K* k;
@@ -497,7 +497,7 @@ namespace std {
val = SCM_CAR(val);
if (!CHECK(val))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
}
(($1_type &)$1)[*k] = CONVERT_FROM(val);
alist = SCM_CDR(alist);
@@ -507,13 +507,13 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp),
- const map<K,T>* (std::map<K,T> temp) {
+ %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp),
+ const map< K, T, C >* (std::map< K, T, C > temp) {
if (scm_is_null($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
} else if (scm_is_pair($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
SCM alist = $input;
while (!scm_is_null(alist)) {
@@ -531,7 +531,7 @@ namespace std {
val = SCM_CAR(val);
if (!CHECK(val))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
}
temp[*k] = CONVERT_FROM(val);
alist = SCM_CDR(alist);
@@ -540,9 +540,9 @@ namespace std {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
- %typemap(out) map<K,T> {
+ %typemap(out) map< K, T, C > {
SCM alist = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) {
K* key = new K(i->first);
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
SCM x = CONVERT_TO(i->second);
@@ -551,7 +551,7 @@ namespace std {
}
$result = alist;
}
- %typecheck(SWIG_TYPECHECK_MAP) map<K,T> {
+ %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > {
// native sequence?
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -583,7 +583,7 @@ namespace std {
}
} else {
// wrapped map?
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
@@ -591,8 +591,8 @@ namespace std {
$1 = 0;
}
}
- %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&,
- const map<K,T>* {
+ %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&,
+ const map< K, T, C >* {
// native sequence?
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -624,7 +624,7 @@ namespace std {
}
} else {
// wrapped map?
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
@@ -641,14 +641,14 @@ namespace std {
%rename("has-key?") has_key;
public:
map();
- map(const map< K, T > &);
+ map(const map< K, T, C > &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
T __getitem__(const K& key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
@@ -658,19 +658,19 @@ namespace std {
(*self)[key] = x;
}
void __delitem__(const K& key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
return i != self->end();
}
SCM keys() {
SCM result = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
K* key = new K(i->first);
SCM k = SWIG_NewPointerObj(key,$descriptor(K *), 1);
result = scm_cons(k,result);
@@ -683,12 +683,12 @@ namespace std {
%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
- template<> class map<K,T> {
- %typemap(in) map<K,T> {
+ template<> class map< K, T, C > {
+ %typemap(in) map< K, T, C > {
if (scm_is_null($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
} else if (scm_is_pair($input)) {
- $1 = std::map< K, T >();
+ $1 = std::map< K, T, C >();
SCM alist = $input;
while (!scm_is_null(alist)) {
SCM entry, key, val;
@@ -699,14 +699,14 @@ namespace std {
val = SCM_CDR(entry);
if (!CHECK_K(key))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
if (!CHECK_T(val)) {
if (!scm_is_pair(val))
SWIG_exception(SWIG_TypeError,"alist expected");
val = SCM_CAR(val);
if (!CHECK_T(val))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
}
(($1_type &)$1)[CONVERT_K_FROM(key)] =
CONVERT_T_FROM(val);
@@ -717,13 +717,13 @@ namespace std {
SWIG_MustGetPtr($input,$&1_descriptor,$argnum, 0));
}
}
- %typemap(in) const map<K,T>& (std::map<K,T> temp),
- const map<K,T>* (std::map<K,T> temp) {
+ %typemap(in) const map< K, T, C >& (std::map< K, T, C > temp),
+ const map< K, T, C >* (std::map< K, T, C > temp) {
if (scm_is_null($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
} else if (scm_is_pair($input)) {
- temp = std::map< K, T >();
+ temp = std::map< K, T, C >();
$1 = &temp;
SCM alist = $input;
while (!scm_is_null(alist)) {
@@ -735,14 +735,14 @@ namespace std {
val = SCM_CDR(entry);
if (!CHECK_K(key))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
if (!CHECK_T(val)) {
if (!scm_is_pair(val))
SWIG_exception(SWIG_TypeError,"alist expected");
val = SCM_CAR(val);
if (!CHECK_T(val))
SWIG_exception(SWIG_TypeError,
- "map<" #K "," #T "> expected");
+ "map<" #K "," #T "," #C "> expected");
}
temp[CONVERT_K_FROM(key)] = CONVERT_T_FROM(val);
alist = SCM_CDR(alist);
@@ -751,9 +751,9 @@ namespace std {
$1 = ($1_ltype) SWIG_MustGetPtr($input,$1_descriptor,$argnum, 0);
}
}
- %typemap(out) map<K,T> {
+ %typemap(out) map< K, T, C > {
SCM alist = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=$1.rbegin(); i!=$1.rend(); ++i) {
SCM k = CONVERT_K_TO(i->first);
SCM x = CONVERT_T_TO(i->second);
SCM entry = scm_cons(k,x);
@@ -761,7 +761,7 @@ namespace std {
}
$result = alist;
}
- %typecheck(SWIG_TYPECHECK_MAP) map<K,T> {
+ %typecheck(SWIG_TYPECHECK_MAP) map< K, T, C > {
// native sequence?
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -792,7 +792,7 @@ namespace std {
}
} else {
// wrapped map?
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$&1_descriptor, 0) == 0)
$1 = 1;
@@ -800,8 +800,8 @@ namespace std {
$1 = 0;
}
}
- %typecheck(SWIG_TYPECHECK_MAP) const map<K,T>&,
- const map<K,T>* {
+ %typecheck(SWIG_TYPECHECK_MAP) const map< K, T, C >&,
+ const map< K, T, C >* {
// native sequence?
if (scm_is_null($input)) {
/* an empty sequence can be of any type */
@@ -832,7 +832,7 @@ namespace std {
}
} else {
// wrapped map?
- std::map< K, T >* m;
+ std::map< K, T, C >* m;
if (SWIG_ConvertPtr($input,(void **) &m,
$1_descriptor, 0) == 0)
$1 = 1;
@@ -849,14 +849,14 @@ namespace std {
%rename("has-key?") has_key;
public:
map();
- map(const map< K, T> &);
+ map(const map< K, T, C> &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
T __getitem__(K key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
@@ -866,19 +866,19 @@ namespace std {
(*self)[key] = x;
}
void __delitem__(K key) throw (std::out_of_range) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(K key) {
- std::map< K, T >::iterator i = self->find(key);
+ std::map< K, T, C >::iterator i = self->find(key);
return i != self->end();
}
SCM keys() {
SCM result = SCM_EOL;
- for (std::map< K, T >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
+ for (std::map< K, T, C >::reverse_iterator i=self->rbegin(); i!=self->rend(); ++i) {
SCM k = CONVERT_K_TO(i->first);
result = scm_cons(k,result);
}