Include all template parameters for std_unordered_multimap and std_unordered_map
This commit is contained in:
parent
cfdf65eb34
commit
30f59ffe22
5 changed files with 42 additions and 38 deletions
|
|
@ -5,3 +5,7 @@
|
||||||
|
|
||||||
%template(UnorderedMapIntInt) std::unordered_map<int, int>;
|
%template(UnorderedMapIntInt) std::unordered_map<int, int>;
|
||||||
%template(UnorderedMapStringInt) std::unordered_map<std::string, int>;
|
%template(UnorderedMapStringInt) std::unordered_map<std::string, int>;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
std::unordered_map<std::string, int, std::hash< std::string >,std::equal_to< std::string >,std::allocator< std::pair< std::string const,int > > > inout(std::unordered_map<std::string, int> m) { return m; }
|
||||||
|
%}
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,9 @@
|
||||||
%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits")
|
%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class SwigPySeq, class K, class T, class Hash, class Compare, class Alloc >
|
template <class SwigPySeq, class K, class T, class Hash, class Compare, class Alloc>
|
||||||
inline void
|
inline void
|
||||||
assign(const SwigPySeq& swigpyseq, std::unordered_map<K,T,Hash,Compare,Alloc > *unordered_map) {
|
assign(const SwigPySeq& swigpyseq, std::unordered_map<K,T,Hash,Compare,Alloc> *unordered_map) {
|
||||||
typedef typename std::unordered_map<K,T,Hash,Compare,Alloc>::value_type value_type;
|
typedef typename std::unordered_map<K,T,Hash,Compare,Alloc>::value_type value_type;
|
||||||
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
||||||
for (;it != swigpyseq.end(); ++it) {
|
for (;it != swigpyseq.end(); ++it) {
|
||||||
|
|
@ -97,7 +97,7 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class T, class Hash, class Compare, class Alloc >
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_from<std::unordered_map<K,T,Hash,Compare,Alloc> > {
|
struct traits_from<std::unordered_map<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_map<K,T,Hash,Compare,Alloc> unordered_map_type;
|
typedef std::unordered_map<K,T,Hash,Compare,Alloc> unordered_map_type;
|
||||||
typedef typename unordered_map_type::const_iterator const_iterator;
|
typedef typename unordered_map_type::const_iterator const_iterator;
|
||||||
|
|
|
||||||
|
|
@ -6,27 +6,27 @@
|
||||||
%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits")
|
%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits",fragment="StdUnorderedMapForwardIteratorTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class SwigPySeq, class K, class T >
|
template <class SwigPySeq, class K, class T, class Hash, class Compare, class Alloc>
|
||||||
inline void
|
inline void
|
||||||
assign(const SwigPySeq& swigpyseq, std::unordered_multimap<K,T > *unordered_multimap) {
|
assign(const SwigPySeq& swigpyseq, std::unordered_multimap<K,T,Hash,Compare,Alloc> *unordered_multimap) {
|
||||||
typedef typename std::unordered_multimap<K,T>::value_type value_type;
|
typedef typename std::unordered_multimap<K,T,Hash,Compare,Alloc>::value_type value_type;
|
||||||
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
typename SwigPySeq::const_iterator it = swigpyseq.begin();
|
||||||
for (;it != swigpyseq.end(); ++it) {
|
for (;it != swigpyseq.end(); ++it) {
|
||||||
unordered_multimap->insert(value_type(it->first, it->second));
|
unordered_multimap->insert(value_type(it->first, it->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T>
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_reserve<std::unordered_multimap<K,T> > {
|
struct traits_reserve<std::unordered_multimap<K,T,Hash,Compare,Alloc> > {
|
||||||
static void reserve(std::unordered_multimap<K,T> &seq, typename std::unordered_multimap<K,T>::size_type n) {
|
static void reserve(std::unordered_multimap<K,T,Hash,Compare,Alloc> &seq, typename std::unordered_multimap<K,T,Hash,Compare,Alloc>::size_type n) {
|
||||||
seq.reserve(n);
|
seq.reserve(n);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class T>
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_asptr<std::unordered_multimap<K,T> > {
|
struct traits_asptr<std::unordered_multimap<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_multimap<K,T> unordered_multimap_type;
|
typedef std::unordered_multimap<K,T,Hash,Compare,Alloc> unordered_multimap_type;
|
||||||
static int asptr(PyObject *obj, std::unordered_multimap<K,T> **val) {
|
static int asptr(PyObject *obj, std::unordered_multimap<K,T,Hash,Compare,Alloc> **val) {
|
||||||
int res = SWIG_ERROR;
|
int res = SWIG_ERROR;
|
||||||
if (PyDict_Check(obj)) {
|
if (PyDict_Check(obj)) {
|
||||||
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
|
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
/* In Python 3.x the ".items()" method returns a dict_items object */
|
/* In Python 3.x the ".items()" method returns a dict_items object */
|
||||||
items = PySequence_Fast(items, ".items() didn't return a sequence!");
|
items = PySequence_Fast(items, ".items() didn't return a sequence!");
|
||||||
%#endif
|
%#endif
|
||||||
res = traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
|
res = traits_asptr_stdseq<std::unordered_multimap<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val);
|
||||||
} else {
|
} else {
|
||||||
unordered_multimap_type *p;
|
unordered_multimap_type *p;
|
||||||
swig_type_info *descriptor = swig::type_info<unordered_multimap_type>();
|
swig_type_info *descriptor = swig::type_info<unordered_multimap_type>();
|
||||||
|
|
@ -45,9 +45,9 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class T >
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_from<std::unordered_multimap<K,T> > {
|
struct traits_from<std::unordered_multimap<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_multimap<K,T> unordered_multimap_type;
|
typedef std::unordered_multimap<K,T,Hash,Compare,Alloc> unordered_multimap_type;
|
||||||
typedef typename unordered_multimap_type::const_iterator const_iterator;
|
typedef typename unordered_multimap_type::const_iterator const_iterator;
|
||||||
typedef typename unordered_multimap_type::size_type size_type;
|
typedef typename unordered_multimap_type::size_type size_type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,25 @@
|
||||||
%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits")
|
%fragment("StdUnorderedMapTraits","header",fragment="StdMapCommonTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class RubySeq, class K, class T >
|
template <class RubySeq, class K, class T, class Hash, class Compare, class Alloc>
|
||||||
inline void
|
inline void
|
||||||
assign(const RubySeq& rubyseq, std::unordered_map<K,T > *map) {
|
assign(const RubySeq& rubyseq, std::unordered_map<K,T,Hash,Compare,Alloc> *map) {
|
||||||
typedef typename std::unordered_map<K,T>::value_type value_type;
|
typedef typename std::unordered_map<K,T,Hash,Compare,Alloc>::value_type value_type;
|
||||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||||
for (;it != rubyseq.end(); ++it) {
|
for (;it != rubyseq.end(); ++it) {
|
||||||
map->insert(value_type(it->first, it->second));
|
map->insert(value_type(it->first, it->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T>
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_asptr<std::unordered_map<K,T> > {
|
struct traits_asptr<std::unordered_map<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_map<K,T> map_type;
|
typedef std::unordered_map<K,T,Hash,Compare,Alloc> map_type;
|
||||||
static int asptr(VALUE obj, map_type **val) {
|
static int asptr(VALUE obj, map_type **val) {
|
||||||
int res = SWIG_ERROR;
|
int res = SWIG_ERROR;
|
||||||
if (TYPE(obj) == T_HASH) {
|
if (TYPE(obj) == T_HASH) {
|
||||||
static ID id_to_a = rb_intern("to_a");
|
static ID id_to_a = rb_intern("to_a");
|
||||||
VALUE items = rb_funcall(obj, id_to_a, 0);
|
VALUE items = rb_funcall(obj, id_to_a, 0);
|
||||||
res = traits_asptr_stdseq<std::unordered_map<K,T>, std::pair<K, T> >::asptr(items, val);
|
res = traits_asptr_stdseq<std::unordered_map<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val);
|
||||||
} else {
|
} else {
|
||||||
map_type *p;
|
map_type *p;
|
||||||
swig_type_info *descriptor = swig::type_info<map_type>();
|
swig_type_info *descriptor = swig::type_info<map_type>();
|
||||||
|
|
@ -35,9 +35,9 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class T >
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_from<std::unordered_map<K,T> > {
|
struct traits_from<std::unordered_map<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_map<K,T> map_type;
|
typedef std::unordered_map<K,T,Hash,Compare,Alloc> map_type;
|
||||||
typedef typename map_type::const_iterator const_iterator;
|
typedef typename map_type::const_iterator const_iterator;
|
||||||
typedef typename map_type::size_type size_type;
|
typedef typename map_type::size_type size_type;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,25 +6,25 @@
|
||||||
%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits")
|
%fragment("StdUnorderedMultimapTraits","header",fragment="StdMapCommonTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class RubySeq, class K, class T >
|
template <class RubySeq, class K, class T, class Hash, class Compare, class Alloc>
|
||||||
inline void
|
inline void
|
||||||
assign(const RubySeq& rubyseq, std::unordered_multimap<K,T > *multimap) {
|
assign(const RubySeq& rubyseq, std::unordered_multimap<K,T,Hash,Compare,Alloc> *multimap) {
|
||||||
typedef typename std::unordered_multimap<K,T>::value_type value_type;
|
typedef typename std::unordered_multimap<K,T,Hash,Compare,Alloc>::value_type value_type;
|
||||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||||
for (;it != rubyseq.end(); ++it) {
|
for (;it != rubyseq.end(); ++it) {
|
||||||
multimap->insert(value_type(it->first, it->second));
|
multimap->insert(value_type(it->first, it->second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class K, class T>
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_asptr<std::unordered_multimap<K,T> > {
|
struct traits_asptr<std::unordered_multimap<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_multimap<K,T> multimap_type;
|
typedef std::unordered_multimap<K,T,Hash,Compare,Alloc> multimap_type;
|
||||||
static int asptr(VALUE obj, std::unordered_multimap<K,T> **val) {
|
static int asptr(VALUE obj, std::unordered_multimap<K,T,Hash,Compare,Alloc> **val) {
|
||||||
int res = SWIG_ERROR;
|
int res = SWIG_ERROR;
|
||||||
if ( TYPE(obj) == T_HASH ) {
|
if ( TYPE(obj) == T_HASH ) {
|
||||||
static ID id_to_a = rb_intern("to_a");
|
static ID id_to_a = rb_intern("to_a");
|
||||||
VALUE items = rb_funcall(obj, id_to_a, 0);
|
VALUE items = rb_funcall(obj, id_to_a, 0);
|
||||||
return traits_asptr_stdseq<std::unordered_multimap<K,T>, std::pair<K, T> >::asptr(items, val);
|
return traits_asptr_stdseq<std::unordered_multimap<K,T,Hash,Compare,Alloc>, std::pair<K, T> >::asptr(items, val);
|
||||||
} else {
|
} else {
|
||||||
multimap_type *p;
|
multimap_type *p;
|
||||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0);
|
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<multimap_type>(),0);
|
||||||
|
|
@ -34,9 +34,9 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class K, class T >
|
template <class K, class T, class Hash, class Compare, class Alloc>
|
||||||
struct traits_from<std::unordered_multimap<K,T> > {
|
struct traits_from<std::unordered_multimap<K,T,Hash,Compare,Alloc> > {
|
||||||
typedef std::unordered_multimap<K,T> multimap_type;
|
typedef std::unordered_multimap<K,T,Hash,Compare,Alloc> multimap_type;
|
||||||
typedef typename multimap_type::const_iterator const_iterator;
|
typedef typename multimap_type::const_iterator const_iterator;
|
||||||
typedef typename multimap_type::size_type size_type;
|
typedef typename multimap_type::size_type size_type;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue