fix Lib/std/std unordered containers

This commit is contained in:
Takashi Tamura 2017-01-26 11:42:07 +09:00
commit 9cb90982ee
5 changed files with 30 additions and 39 deletions

View file

@ -26,19 +26,17 @@
class const_iterator;
iterator begin();
iterator end();
#endif
%enddef
%define %std_container_methods_reverse_iterators(container...)
#ifdef SWIG_EXPORT_ITERATOR_METHODS
#if !defined(SWIG_NO_REVERSE_ITERATOR_METHODS)
class reverse_iterator;
class const_reverse_iterator;
reverse_iterator rbegin();
reverse_iterator rend();
#endif
#endif
%enddef
// Common container methods

View file

@ -4,7 +4,7 @@
// operator--() and constructor(compare function) not available for unordered_
// types
//
#define SWIG_NO_REVERSE_ITERATOR_METHODS
%include <std_pair.i>
%include <std_container.i>
@ -22,8 +22,6 @@
}
iterator find(const key_type& x);
iterator lower_bound(const key_type& x);
iterator upper_bound(const key_type& x);
#endif
%enddef
@ -68,7 +66,7 @@
namespace std {
template<class _Key, class _Tp, class _Compare = std::less< _Key >,
template<class _Key, class _Tp, class _Hash = std::hash< _Key >, class _Pred = std::equal_to< _Key >,
class _Alloc = allocator<std::pair< const _Key, _Tp > > >
class unordered_map {
public:
@ -101,29 +99,28 @@ namespace std {
}
}
%fragment(SWIG_Traits_frag(std::unordered_map< _Key, _Tp, _Compare, _Alloc >), "header",
%fragment(SWIG_Traits_frag(std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >), "header",
fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >),
fragment="StdMapTraits") {
fragment="StdUnorderedMapTraits") {
namespace swig {
template <> struct traits<std::unordered_map< _Key, _Tp, _Compare, _Alloc > > {
template <> struct traits<std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc > > {
typedef pointer_category category;
static const char* type_name() {
return "std::unordered_map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
return "std::unordered_map<" #_Key "," #_Tp "," #_Hash "," #_Pred "," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map< _Key, _Tp, _Compare, _Alloc >);
unordered_map( const _Compare& );
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >);
#ifdef %swig_unordered_map_methods
// Add swig/language extra methods
%swig_unordered_map_methods(std::unordered_map< _Key, _Tp, _Compare, _Alloc >);
%swig_unordered_map_methods(std::unordered_map< _Key, _Tp, _Hash, _Pred, _Alloc >);
#endif
%std_unordered_map_methods(unordered_map);
};
}
#undef SWIG_NO_REVERSE_ITERATOR_METHODS

View file

@ -6,10 +6,10 @@
//
%include <std_unordered_map.i>
#define SWIG_NO_REVERSE_ITERATOR_METHODS
%define %std_unordered_multimap_methods(mmap...)
%std_map_methods_common(mmap);
%std_unordered_map_methods_common(mmap);
#ifdef SWIG_EXPORT_ITERATOR_METHODS
std::pair<iterator,iterator> equal_range(const key_type& x);
@ -44,7 +44,7 @@
namespace std {
template<class _Key, class _Tp, class _Compare = std::less< _Key >,
template<class _Key, class _Tp, class _Hash = std::hash< _Key >, class _Pred = std::equal_to< _Key >,
class _Alloc = allocator<std::pair< const _Key, _Tp > > >
class unordered_multimap {
public:
@ -63,28 +63,27 @@ namespace std {
%traits_swigtype(_Key);
%traits_swigtype(_Tp);
%fragment(SWIG_Traits_frag(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >), "header",
%fragment(SWIG_Traits_frag(std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >), "header",
fragment=SWIG_Traits_frag(std::pair< _Key, _Tp >),
fragment="StdMultimapTraits") {
fragment="StdUnorderedMultimapTraits") {
namespace swig {
template <> struct traits<std::unordered_multimap< _Key, _Tp, _Compare, _Alloc > > {
template <> struct traits<std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc > > {
typedef pointer_category category;
static const char* type_name() {
return "std::unordered_multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
return "std::unordered_multimap<" #_Key "," #_Tp "," #_Hash "," #_Pred "," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >);
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >);
unordered_multimap( const _Compare& );
#ifdef %swig_unordered_multimap_methods
// Add swig/language extra methods
%swig_unordered_multimap_methods(std::unordered_multimap< _Key, _Tp, _Compare, _Alloc >);
%swig_unordered_multimap_methods(std::unordered_multimap< _Key, _Tp, _Hash, _Pred, _Alloc >);
#endif
%std_unordered_multimap_methods(unordered_multimap);
};
}
#undef SWIG_NO_REVERSE_ITERATOR_METHODS

View file

@ -43,7 +43,8 @@ namespace std {
//unordered_multiset
template <class _Key, class _Compare = std::less< _Key >,
template <class _Key, class _Hash = std::hash< _Key >,
class _Compare = std::equal_to< _Key >,
class _Alloc = allocator< _Key > >
class unordered_multiset {
public:
@ -59,26 +60,24 @@ namespace std {
%traits_swigtype(_Key);
%fragment(SWIG_Traits_frag(std::unordered_multiset< _Key, _Compare, _Alloc >), "header",
%fragment(SWIG_Traits_frag(std::unordered_multiset< _Key, _Hash, _Compare, _Alloc >), "header",
fragment=SWIG_Traits_frag(_Key),
fragment="StdMultisetTraits") {
namespace swig {
template <> struct traits<std::unordered_multiset< _Key, _Compare, _Alloc > > {
template <> struct traits<std::unordered_multiset< _Key, _Hash, _Compare, _Alloc > > {
typedef pointer_category category;
static const char* type_name() {
return "std::unordered_multiset<" #_Key "," #_Compare "," #_Alloc " >";
return "std::unordered_multiset<" #_Key "," #_Hash "," #_Compare "," #_Alloc " >";
}
};
}
}
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset< _Key, _Compare, _Alloc >);
unordered_multiset( const _Compare& );
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::unordered_multiset< _Key, _Hash, _Compare, _Alloc >);
#ifdef %swig_unordered_multiset_methods
// Add swig/language extra methods
%swig_unordered_multiset_methods(std::unordered_multiset< _Key, _Compare, _Alloc >);
%swig_unordered_multiset_methods(std::unordered_multiset< _Key, _Hash, _Compare, _Alloc >);
#endif
%std_unordered_multiset_methods(unordered_multiset);

View file

@ -110,8 +110,6 @@ namespace std {
%typemap_traits_ptr(SWIG_TYPECHECK_SET, std::unordered_set< _Key, _Hash, _Compare, _Alloc >);
unordered_set( const _Compare& );
#ifdef %swig_unordered_set_methods
// Add swig/language extra methods
%swig_unordered_set_methods(std::unordered_set< _Key, _Hash, _Compare, _Alloc >);