add back support for specialize_std_vector/list/etc
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6741 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
edb5a6669f
commit
0d9df55066
1 changed files with 36 additions and 0 deletions
|
|
@ -228,3 +228,39 @@ std::string SwigString_AsString(PyObject* o) {
|
|||
#endif
|
||||
|
||||
|
||||
%define %specialize_std_container(Type,Check,As,From)
|
||||
%{
|
||||
namespace swig {
|
||||
template <> struct traits_asval<Type > {
|
||||
typedef Type value_type;
|
||||
static int asval(PyObject *obj, value_type *val) {
|
||||
if (Check(obj)) {
|
||||
*val = As(obj);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
template <> struct traits_from<Type > {
|
||||
typedef Type value_type;
|
||||
static PyObject *from(const value_type& val) {
|
||||
return From(val);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct traits_check<Type, value_category> {
|
||||
static bool check(PyObject *obj) {
|
||||
return obj && Check(obj);
|
||||
}
|
||||
};
|
||||
}
|
||||
%}
|
||||
%enddef
|
||||
|
||||
|
||||
#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_list(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_set(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(SWIG_arg(Type),Check,As,From)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue