Fix for missing C++ code in std::multimap wrappers.
%template for a std::multimap generated uncompilable code unless a
%template for a std::map of the same template types was also coded up.
This patch is needed in conjunction with previous commit - 5f1fff1849
Closes #64
Closes #65
This commit is contained in:
parent
5f1fff1849
commit
80f8d1d922
7 changed files with 214 additions and 197 deletions
|
|
@ -4,6 +4,11 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
|
|
||||||
Version 2.0.11 (in progress)
|
Version 2.0.11 (in progress)
|
||||||
============================
|
============================
|
||||||
|
2013-07-30: wsfulton
|
||||||
|
[Python, Ruby] Fix #64 #65: Missing code in std::multimap wrappers. Previously an instantiation
|
||||||
|
of a std::map was erroneously required in addition to an instantiation of std::multimap with the
|
||||||
|
same template parameters to prevent compilation errors for the wrappers of a std::multimap.
|
||||||
|
|
||||||
2013-07-14: joequant
|
2013-07-14: joequant
|
||||||
[R] Change types file to allow for SEXP return values
|
[R] Change types file to allow for SEXP return values
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@
|
||||||
%feature("trackobjects");
|
%feature("trackobjects");
|
||||||
|
|
||||||
%include std_pair.i
|
%include std_pair.i
|
||||||
%include std_map.i
|
|
||||||
%include std_multimap.i
|
%include std_multimap.i
|
||||||
|
|
||||||
%inline %{
|
%inline %{
|
||||||
|
|
@ -20,6 +19,5 @@ struct A{
|
||||||
namespace std
|
namespace std
|
||||||
{
|
{
|
||||||
%template(pairA) pair<int, A*>;
|
%template(pairA) pair<int, A*>;
|
||||||
%template(mapA) map<int, A*>;
|
|
||||||
%template(multimapA) multimap<int, A*>;
|
%template(multimapA) multimap<int, A*>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,73 +2,9 @@
|
||||||
|
|
||||||
%include <octcontainer.swg>
|
%include <octcontainer.swg>
|
||||||
|
|
||||||
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class OctSeq, class K, class T >
|
|
||||||
inline void
|
|
||||||
assign(const OctSeq& octseq, std::map<K,T > *map) {
|
|
||||||
typedef typename std::map<K,T>::value_type value_type;
|
|
||||||
typename OctSeq::const_iterator it = octseq.begin();
|
|
||||||
for (;it != octseq.end(); ++it) {
|
|
||||||
map->insert(value_type(it->first, it->second));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class K, class T>
|
|
||||||
struct traits_asptr<std::map<K,T> > {
|
|
||||||
typedef std::map<K,T> map_type;
|
|
||||||
static int asptr(octave_value obj, map_type **val) {
|
|
||||||
/*
|
|
||||||
int res = SWIG_ERROR;
|
|
||||||
if (PyDict_Check(obj)) {
|
|
||||||
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
|
|
||||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
|
||||||
} else {
|
|
||||||
map_type *p;
|
|
||||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
|
||||||
if (SWIG_IsOK(res) && val) *val = p;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
*/
|
|
||||||
return SWIG_ERROR;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class K, class T >
|
|
||||||
struct traits_from<std::map<K,T> > {
|
|
||||||
typedef std::map<K,T> map_type;
|
|
||||||
typedef typename map_type::const_iterator const_iterator;
|
|
||||||
typedef typename map_type::size_type size_type;
|
|
||||||
|
|
||||||
static octave_value from(const map_type& map) {
|
|
||||||
/*
|
|
||||||
swig_type_info *desc = swig::type_info<map_type>();
|
|
||||||
if (desc && desc->clientdata) {
|
|
||||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
|
||||||
} else {
|
|
||||||
size_type size = map.size();
|
|
||||||
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
|
||||||
if (pysize < 0) {
|
|
||||||
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
|
||||||
"map size not valid in python");
|
|
||||||
SWIG_PYTHON_THREAD_END_BLOCK;
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
PyObject *obj = PyDict_New();
|
|
||||||
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
|
||||||
swig::SwigVar_PyObject key = swig::from(i->first);
|
|
||||||
swig::SwigVar_PyObject val = swig::from(i->second);
|
|
||||||
PyDict_SetItem(obj, key, val);
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return octave_value();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class ValueType>
|
template <class ValueType>
|
||||||
struct from_key_oper
|
struct from_key_oper
|
||||||
{
|
{
|
||||||
|
|
@ -138,6 +74,75 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
|
||||||
|
{
|
||||||
|
namespace swig {
|
||||||
|
template <class OctSeq, class K, class T >
|
||||||
|
inline void
|
||||||
|
assign(const OctSeq& octseq, std::map<K,T > *map) {
|
||||||
|
typedef typename std::map<K,T>::value_type value_type;
|
||||||
|
typename OctSeq::const_iterator it = octseq.begin();
|
||||||
|
for (;it != octseq.end(); ++it) {
|
||||||
|
map->insert(value_type(it->first, it->second));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class K, class T>
|
||||||
|
struct traits_asptr<std::map<K,T> > {
|
||||||
|
typedef std::map<K,T> map_type;
|
||||||
|
static int asptr(octave_value obj, map_type **val) {
|
||||||
|
/*
|
||||||
|
int res = SWIG_ERROR;
|
||||||
|
if (PyDict_Check(obj)) {
|
||||||
|
SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
|
||||||
|
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||||
|
} else {
|
||||||
|
map_type *p;
|
||||||
|
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||||
|
if (SWIG_IsOK(res) && val) *val = p;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
*/
|
||||||
|
return SWIG_ERROR;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class K, class T >
|
||||||
|
struct traits_from<std::map<K,T> > {
|
||||||
|
typedef std::map<K,T> map_type;
|
||||||
|
typedef typename map_type::const_iterator const_iterator;
|
||||||
|
typedef typename map_type::size_type size_type;
|
||||||
|
|
||||||
|
static octave_value from(const map_type& map) {
|
||||||
|
/*
|
||||||
|
swig_type_info *desc = swig::type_info<map_type>();
|
||||||
|
if (desc && desc->clientdata) {
|
||||||
|
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||||
|
} else {
|
||||||
|
size_type size = map.size();
|
||||||
|
int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
if (pysize < 0) {
|
||||||
|
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
|
||||||
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
|
"map size not valid in python");
|
||||||
|
SWIG_PYTHON_THREAD_END_BLOCK;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
PyObject *obj = PyDict_New();
|
||||||
|
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
||||||
|
swig::SwigVar_PyObject key = swig::from(i->first);
|
||||||
|
swig::SwigVar_PyObject val = swig::from(i->second);
|
||||||
|
PyDict_SetItem(obj, key, val);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
return octave_value();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%define %swig_map_common(Map...)
|
%define %swig_map_common(Map...)
|
||||||
%swig_sequence_iterator(Map);
|
%swig_sequence_iterator(Map);
|
||||||
%swig_container_methods(Map);
|
%swig_container_methods(Map);
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,79 @@
|
||||||
Maps
|
Maps
|
||||||
*/
|
*/
|
||||||
|
|
||||||
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
|
||||||
|
{
|
||||||
|
namespace swig {
|
||||||
|
template <class ValueType>
|
||||||
|
struct from_key_oper
|
||||||
|
{
|
||||||
|
typedef const ValueType& argument_type;
|
||||||
|
typedef PyObject *result_type;
|
||||||
|
result_type operator()(argument_type v) const
|
||||||
|
{
|
||||||
|
return swig::from(v.first);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class ValueType>
|
||||||
|
struct from_value_oper
|
||||||
|
{
|
||||||
|
typedef const ValueType& argument_type;
|
||||||
|
typedef PyObject *result_type;
|
||||||
|
result_type operator()(argument_type v) const
|
||||||
|
{
|
||||||
|
return swig::from(v.second);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
|
||||||
|
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
|
||||||
|
{
|
||||||
|
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||||
|
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<class OutIterator,
|
||||||
|
class FromOper = from_key_oper<typename OutIterator::value_type> >
|
||||||
|
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
||||||
|
{
|
||||||
|
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||||
|
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<typename OutIter>
|
||||||
|
inline SwigPyIterator*
|
||||||
|
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
||||||
|
{
|
||||||
|
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class OutIterator,
|
||||||
|
class FromOper = from_value_oper<typename OutIterator::value_type> >
|
||||||
|
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
||||||
|
{
|
||||||
|
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
||||||
|
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
template<typename OutIter>
|
||||||
|
inline SwigPyIterator*
|
||||||
|
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
||||||
|
{
|
||||||
|
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class SwigPySeq, class K, class T, class Compare, class Alloc >
|
template <class SwigPySeq, class K, class T, class Compare, class Alloc >
|
||||||
|
|
@ -73,74 +145,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class ValueType>
|
|
||||||
struct from_key_oper
|
|
||||||
{
|
|
||||||
typedef const ValueType& argument_type;
|
|
||||||
typedef PyObject *result_type;
|
|
||||||
result_type operator()(argument_type v) const
|
|
||||||
{
|
|
||||||
return swig::from(v.first);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class ValueType>
|
|
||||||
struct from_value_oper
|
|
||||||
{
|
|
||||||
typedef const ValueType& argument_type;
|
|
||||||
typedef PyObject *result_type;
|
|
||||||
result_type operator()(argument_type v) const
|
|
||||||
{
|
|
||||||
return swig::from(v.second);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
|
|
||||||
struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
|
|
||||||
{
|
|
||||||
SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
|
||||||
: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template<class OutIterator,
|
|
||||||
class FromOper = from_key_oper<typename OutIterator::value_type> >
|
|
||||||
struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
|
||||||
{
|
|
||||||
SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
|
||||||
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename OutIter>
|
|
||||||
inline SwigPyIterator*
|
|
||||||
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
|
||||||
{
|
|
||||||
return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class OutIterator,
|
|
||||||
class FromOper = from_value_oper<typename OutIterator::value_type> >
|
|
||||||
struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
|
|
||||||
{
|
|
||||||
SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
|
|
||||||
: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
template<typename OutIter>
|
|
||||||
inline SwigPyIterator*
|
|
||||||
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
|
|
||||||
{
|
|
||||||
return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
%include <std_map.i>
|
%include <std_map.i>
|
||||||
|
|
||||||
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class SwigPySeq, class K, class T >
|
template <class SwigPySeq, class K, class T >
|
||||||
|
|
|
||||||
|
|
@ -1,67 +1,9 @@
|
||||||
//
|
//
|
||||||
// Maps
|
// Maps
|
||||||
//
|
//
|
||||||
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdMapCommonTraits","header",fragment="StdSequenceTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class RubySeq, class K, class T >
|
|
||||||
inline void
|
|
||||||
assign(const RubySeq& rubyseq, std::map<K,T > *map) {
|
|
||||||
typedef typename std::map<K,T>::value_type value_type;
|
|
||||||
typename RubySeq::const_iterator it = rubyseq.begin();
|
|
||||||
for (;it != rubyseq.end(); ++it) {
|
|
||||||
map->insert(value_type(it->first, it->second));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class K, class T>
|
|
||||||
struct traits_asptr<std::map<K,T> > {
|
|
||||||
typedef std::map<K,T> map_type;
|
|
||||||
static int asptr(VALUE obj, map_type **val) {
|
|
||||||
int res = SWIG_ERROR;
|
|
||||||
if ( TYPE(obj) == T_HASH ) {
|
|
||||||
static ID id_to_a = rb_intern("to_a");
|
|
||||||
VALUE items = rb_funcall(obj, id_to_a, 0);
|
|
||||||
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
|
||||||
} else {
|
|
||||||
map_type *p;
|
|
||||||
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
|
||||||
if (SWIG_IsOK(res) && val) *val = p;
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class K, class T >
|
|
||||||
struct traits_from<std::map<K,T> > {
|
|
||||||
typedef std::map<K,T> map_type;
|
|
||||||
typedef typename map_type::const_iterator const_iterator;
|
|
||||||
typedef typename map_type::size_type size_type;
|
|
||||||
|
|
||||||
static VALUE from(const map_type& map) {
|
|
||||||
swig_type_info *desc = swig::type_info<map_type>();
|
|
||||||
if (desc && desc->clientdata) {
|
|
||||||
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
|
||||||
} else {
|
|
||||||
size_type size = map.size();
|
|
||||||
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
|
||||||
if (rubysize < 0) {
|
|
||||||
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
|
||||||
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
|
|
||||||
SWIG_RUBY_THREAD_END_BLOCK;
|
|
||||||
return Qnil;
|
|
||||||
}
|
|
||||||
VALUE obj = rb_hash_new();
|
|
||||||
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
|
||||||
VALUE key = swig::from(i->first);
|
|
||||||
VALUE val = swig::from(i->second);
|
|
||||||
rb_hash_aset(obj, key, val);
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <class ValueType>
|
template <class ValueType>
|
||||||
struct from_key_oper
|
struct from_key_oper
|
||||||
{
|
{
|
||||||
|
|
@ -134,6 +76,69 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%fragment("StdMapTraits","header",fragment="StdMapCommonTraits")
|
||||||
|
{
|
||||||
|
namespace swig {
|
||||||
|
template <class RubySeq, class K, class T >
|
||||||
|
inline void
|
||||||
|
assign(const RubySeq& rubyseq, std::map<K,T > *map) {
|
||||||
|
typedef typename std::map<K,T>::value_type value_type;
|
||||||
|
typename RubySeq::const_iterator it = rubyseq.begin();
|
||||||
|
for (;it != rubyseq.end(); ++it) {
|
||||||
|
map->insert(value_type(it->first, it->second));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class K, class T>
|
||||||
|
struct traits_asptr<std::map<K,T> > {
|
||||||
|
typedef std::map<K,T> map_type;
|
||||||
|
static int asptr(VALUE obj, map_type **val) {
|
||||||
|
int res = SWIG_ERROR;
|
||||||
|
if ( TYPE(obj) == T_HASH ) {
|
||||||
|
static ID id_to_a = rb_intern("to_a");
|
||||||
|
VALUE items = rb_funcall(obj, id_to_a, 0);
|
||||||
|
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
|
||||||
|
} else {
|
||||||
|
map_type *p;
|
||||||
|
res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
|
||||||
|
if (SWIG_IsOK(res) && val) *val = p;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class K, class T >
|
||||||
|
struct traits_from<std::map<K,T> > {
|
||||||
|
typedef std::map<K,T> map_type;
|
||||||
|
typedef typename map_type::const_iterator const_iterator;
|
||||||
|
typedef typename map_type::size_type size_type;
|
||||||
|
|
||||||
|
static VALUE from(const map_type& map) {
|
||||||
|
swig_type_info *desc = swig::type_info<map_type>();
|
||||||
|
if (desc && desc->clientdata) {
|
||||||
|
return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
|
||||||
|
} else {
|
||||||
|
size_type size = map.size();
|
||||||
|
int rubysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
|
||||||
|
if (rubysize < 0) {
|
||||||
|
SWIG_RUBY_THREAD_BEGIN_BLOCK;
|
||||||
|
rb_raise( rb_eRuntimeError, "map size not valid in Ruby");
|
||||||
|
SWIG_RUBY_THREAD_END_BLOCK;
|
||||||
|
return Qnil;
|
||||||
|
}
|
||||||
|
VALUE obj = rb_hash_new();
|
||||||
|
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
|
||||||
|
VALUE key = swig::from(i->first);
|
||||||
|
VALUE val = swig::from(i->second);
|
||||||
|
rb_hash_aset(obj, key, val);
|
||||||
|
}
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
%define %swig_map_common(Map...)
|
%define %swig_map_common(Map...)
|
||||||
%swig_container_methods(%arg(Map));
|
%swig_container_methods(%arg(Map));
|
||||||
// %swig_sequence_iterator(%arg(Map));
|
// %swig_sequence_iterator(%arg(Map));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
*/
|
*/
|
||||||
%include <std_map.i>
|
%include <std_map.i>
|
||||||
|
|
||||||
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
|
%fragment("StdMultimapTraits","header",fragment="StdMapCommonTraits")
|
||||||
{
|
{
|
||||||
namespace swig {
|
namespace swig {
|
||||||
template <class RubySeq, class K, class T >
|
template <class RubySeq, class K, class T >
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue