mirror of https://github.com/swig/swig
more fixes for template + def args
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6833 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
1c382fe97b
commit
6b499410dd
|
@ -1,5 +1,5 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../swig
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS =
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
|
|
|
@ -44,10 +44,12 @@
|
|||
%template(list_i) std::list<int>;
|
||||
%template(deque_i) std::deque<int>;
|
||||
|
||||
%template(vector_b) std::vector<bool>;
|
||||
%template(vector_i) std::vector<int>;
|
||||
%template(vector_c) std::vector<std::complex<double> >;
|
||||
%template(vector_ui) std::vector<unsigned int>;
|
||||
|
||||
%template(bmatrix) std::vector<std::vector<bool> >;
|
||||
%template(imatrix) std::vector<std::vector<int> >;
|
||||
%template(cmatrix) std::vector<std::vector<std::complex<double> > >;
|
||||
|
||||
|
@ -56,7 +58,13 @@
|
|||
%inline
|
||||
{
|
||||
typedef std::vector<std::vector<int> > imatrix;
|
||||
imatrix mident(const imatrix& v)
|
||||
imatrix midenti(const imatrix& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
typedef std::vector<std::vector<bool> > bmatrix;
|
||||
bmatrix midentb(const bmatrix& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
|
|
@ -33,9 +33,13 @@ if v[0:3][1] != vu[0:3][1]:
|
|||
|
||||
|
||||
m = ((1,2,3),(2,3),(3,4))
|
||||
if m != std_containers.mident(m):
|
||||
if m != std_containers.midenti(m):
|
||||
raise RuntimeError, "bad getslice"
|
||||
|
||||
|
||||
mb = ((1,0,1),(1,1),(1,1))
|
||||
if mb != std_containers.midentb(mb):
|
||||
raise RuntimeError, "bad getslice"
|
||||
|
||||
|
||||
mi = std_containers.imatrix(m)
|
||||
mc = std_containers.cmatrix(m)
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
}
|
||||
%}
|
||||
|
||||
%define %swig_set_methods(set)
|
||||
%define %swig_set_methods(set...)
|
||||
%swig_container_methods(set);
|
||||
|
||||
%extend {
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace std {
|
|||
typedef _CharT value_type;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
static const size_type npos;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
%include <std_common.i>
|
||||
%include <exception.i>
|
||||
%include <std_alloc.i>
|
||||
|
||||
%{
|
||||
#include <algorithm>
|
||||
|
@ -7,7 +8,7 @@
|
|||
|
||||
// Common container methods
|
||||
|
||||
%define %std_container_methods(container)
|
||||
%define %std_container_methods(container...)
|
||||
container();
|
||||
container(const container&);
|
||||
|
||||
|
@ -17,6 +18,8 @@
|
|||
|
||||
void swap(container& v);
|
||||
|
||||
allocator_type get_allocator() const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator begin();
|
||||
const_iterator begin() const;
|
||||
|
@ -34,7 +37,7 @@
|
|||
|
||||
%define %std_sequence_methods_common(sequence)
|
||||
|
||||
%std_container_methods(SWIG_arg(sequence));
|
||||
%std_container_methods(SWIG_arg(sequence));
|
||||
|
||||
sequence(size_type size);
|
||||
void pop_back();
|
||||
|
@ -71,7 +74,7 @@
|
|||
|
||||
%enddef
|
||||
|
||||
%define %std_sequence_methods_val(sequence)
|
||||
%define %std_sequence_methods_val(sequence...)
|
||||
|
||||
%std_sequence_methods_common(SWIG_arg(sequence));
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
|
||||
// Deque
|
||||
|
||||
%define %std_deque_methods(deque)
|
||||
%define %std_deque_methods(deque...)
|
||||
%std_sequence_methods(deque)
|
||||
|
||||
void pop_front();
|
||||
void push_front(const value_type& x);
|
||||
%enddef
|
||||
|
||||
%define %std_deque_methods_val(deque)
|
||||
%define %std_deque_methods_val(deque...)
|
||||
%std_sequence_methods_val(deque)
|
||||
|
||||
void pop_front();
|
||||
|
@ -49,73 +49,77 @@
|
|||
|
||||
namespace std {
|
||||
|
||||
template<class T > class deque {
|
||||
template<class _Tp, class _Alloc = std::allocator<_Tp> >
|
||||
class deque {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::deque<T >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::deque<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdDequeTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::deque<T > > {
|
||||
template <> struct traits<std::deque<_Tp, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::deque<" #T " >";
|
||||
return "std::deque<" #_Tp " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp, _Alloc >);
|
||||
|
||||
%std_deque_methods(deque);
|
||||
|
||||
#ifdef %swig_deque_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_deque_methods(std::deque<T >);
|
||||
%swig_deque_methods(std::deque<_Tp, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T > class deque<T*> {
|
||||
template<class _Tp, class _Alloc >
|
||||
class deque<_Tp*, _Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* value_type;
|
||||
typedef _Tp* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::deque<T* >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::deque<_Tp*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdDequeTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::deque<T* > > {
|
||||
template <> struct traits<std::deque<_Tp*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::deque<" #T " * >";
|
||||
return "std::deque<" #_Tp " * >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<T* >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_DEQUE, std::deque<_Tp*, _Alloc >);
|
||||
|
||||
%std_deque_methods_val(std::deque<T* >);
|
||||
%std_deque_methods_val(std::deque<_Tp*, _Alloc >);
|
||||
|
||||
#ifdef %swig_deque_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_deque_methods_val(std::deque<T* >);
|
||||
%swig_deque_methods_val(std::deque<_Tp*, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -61,73 +61,77 @@
|
|||
|
||||
namespace std {
|
||||
|
||||
template<class T > class list {
|
||||
template<class _Tp, class _Alloc = std::allocator<_Tp> >
|
||||
class list {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::list<T >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::list<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdListTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::list<T > > {
|
||||
template <> struct traits<std::list<_Tp, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::list<" #T " >";
|
||||
return "std::list<" #_Tp ", " #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp, _Alloc >);
|
||||
|
||||
%std_list_methods(list);
|
||||
|
||||
#ifdef %swig_list_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_list_methods(std::list<T >);
|
||||
%swig_list_methods(std::list<_Tp, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
template<class T > class list<T*> {
|
||||
template<class _Tp, class _Alloc >
|
||||
class list<_Tp*, _Alloc> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* value_type;
|
||||
typedef _Tp* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::list<T* >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::list<_Tp*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdListTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::list<T* > > {
|
||||
template <> struct traits<std::list<_Tp*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::list<" #T " * >";
|
||||
return "std::list<" #_Tp " *," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<T* >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_LIST, std::list<_Tp*, _Alloc >);
|
||||
|
||||
%std_list_methods_val(list);
|
||||
|
||||
#ifdef %swig_list_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_list_methods_val(std::list<T* >);
|
||||
%swig_list_methods_val(std::list<_Tp*, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -80,42 +80,45 @@
|
|||
|
||||
namespace std {
|
||||
|
||||
template<class K, class T> class map {
|
||||
template<class _Key, class _Tp, class _Compare = std::less<_Key >,
|
||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp > > >
|
||||
class map {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair<const K, T> value_type;
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef std::pair<const _Key, _Tp> value_type;
|
||||
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(K);
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Key);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::map<K, T >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<K, T >),
|
||||
%fragment(SWIG_Traits_frag(std::map<_Key, _Tp, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
|
||||
fragment="StdMapTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::map<K, T > > {
|
||||
template <> struct traits<std::map<_Key, _Tp, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::map<" #K "," #T " >";
|
||||
return "std::map<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<K, T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MAP, std::map<_Key, _Tp, _Compare, _Alloc >);
|
||||
|
||||
%std_map_methods(map);
|
||||
|
||||
#ifdef %swig_map_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_map_methods(std::map<K, T >);
|
||||
%swig_map_methods(std::map<_Key, _Tp, _Compare, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -42,43 +42,45 @@
|
|||
|
||||
|
||||
namespace std {
|
||||
template<class K, class T> class multimap {
|
||||
template<class _Key, class _Tp, class _Compare = std::less<_Key >,
|
||||
class _Alloc = std::allocator<std::pair<const _Key, _Tp > > >
|
||||
class multimap {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef K key_type;
|
||||
typedef T mapped_type;
|
||||
typedef std::pair<const K, T> value_type;
|
||||
typedef _Key key_type;
|
||||
typedef _Tp mapped_type;
|
||||
typedef std::pair<const _Key, _Tp> value_type;
|
||||
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(K);
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Key);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::multimap<K, T >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<K, T >),
|
||||
fragment="StdMultimapTraits") {
|
||||
%fragment(SWIG_Traits_frag(std::multimap<_Key, _Tp, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(std::pair<_Key, _Tp >),
|
||||
fragment="StdMultiapTraits") {
|
||||
namespace swig {
|
||||
|
||||
template <> struct traits<std::multimap<K, T > > {
|
||||
typedef value_category category;
|
||||
template <> struct traits<std::multimap<_Key, _Tp, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::multimap<" #K "," #T " >";
|
||||
return "std::multimap<" #_Key "," #_Tp "," #_Compare "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<K, T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MULTIMAP, std::multimap<_Key, _Tp, _Compare, _Alloc >);
|
||||
|
||||
%std_multimap_methods(multimap);
|
||||
|
||||
#ifdef %swig_multimap_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_multimap_methods(std::multimap<K, T >);
|
||||
%swig_multimap_methods(std::multimap<_Key, _Tp, _Compare, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
// Multiset
|
||||
|
||||
%define %std_multiset_methods(multiset)
|
||||
%define %std_multiset_methods(multiset...)
|
||||
%std_set_methods_common(multiset);
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
pair<iterator,bool> insert(iterator pos);
|
||||
|
@ -43,40 +43,42 @@ namespace std {
|
|||
|
||||
//multiset
|
||||
|
||||
template<class T > class multiset {
|
||||
template <class _Key, class _Compare = less<_Key>,
|
||||
class _Alloc = allocator<_Key> >
|
||||
class multiset {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Key key_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Key);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::multiset<T >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::multiset<_Key, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Key),
|
||||
fragment="StdMultisetTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::multiset<T > > {
|
||||
template <> struct traits<std::multiset<_Key, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::multiset<" #T " >";
|
||||
return "std::multiset<" #_Key "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_MULTISET, std::multiset<_Key, _Compare, _Alloc >);
|
||||
|
||||
%std_multiset_methods(multiset);
|
||||
|
||||
#ifdef %swig_multiset_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_multiset_methods(std::multiset<T >);
|
||||
%swig_multiset_methods(std::multiset<_Key, _Compare, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
%include <std_container.i>
|
||||
|
||||
// Set
|
||||
%define %std_set_methods_common(set)
|
||||
%define %std_set_methods_common(set...)
|
||||
%std_container_methods(set);
|
||||
|
||||
size_type erase(const key_type& x);
|
||||
|
@ -26,7 +26,7 @@
|
|||
#endif
|
||||
%enddef
|
||||
|
||||
%define %std_set_methods(set)
|
||||
%define %std_set_methods(set...)
|
||||
%std_set_methods_common(set);
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
pair<iterator,bool> insert(const value_type& __x);
|
||||
|
@ -64,39 +64,42 @@
|
|||
|
||||
namespace std {
|
||||
|
||||
template<class T > class set {
|
||||
template <class _Key, class _Compare = less<_Key>,
|
||||
class _Alloc = allocator<_Key> >
|
||||
class set {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef T key_type;
|
||||
typedef _Key value_type;
|
||||
typedef _Key key_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type& reference;
|
||||
typedef const value_type& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Key);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::set<T >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::set<_Key, _Compare, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Key),
|
||||
fragment="StdSetTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::set<T > > {
|
||||
template <> struct traits<std::set<_Key, _Compare, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::set<" #T " >";
|
||||
return "std::set<" #_Key "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_SET, std::set<_Key, _Compare, _Alloc >);
|
||||
|
||||
%std_set_methods(set);
|
||||
|
||||
#ifdef %swig_set_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_set_methods(std::set<T >);
|
||||
%swig_set_methods(std::set<_Key, _Compare, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
// Vector
|
||||
|
||||
%define %std_vector_methods(vector)
|
||||
%define %std_vector_methods(vector...)
|
||||
%std_sequence_methods(vector)
|
||||
|
||||
void reserve(size_type n);
|
||||
|
@ -14,7 +14,7 @@
|
|||
%enddef
|
||||
|
||||
|
||||
%define %std_vector_methods_val(vector)
|
||||
%define %std_vector_methods_val(vector...)
|
||||
%std_sequence_methods_val(vector)
|
||||
|
||||
void reserve(size_type n);
|
||||
|
@ -53,44 +53,43 @@
|
|||
|
||||
// exported classes
|
||||
|
||||
#if !defined(SWIG_STD_MODERN_STL) || defined(SWIG_STD_NOMODERN_STL)
|
||||
%ignore std::vector<bool>::flip();
|
||||
#endif
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T > class vector {
|
||||
template<class _Tp, class _Alloc = std::allocator< _Tp > >
|
||||
class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef _Tp value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef _Tp& reference;
|
||||
typedef const _Tp& const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<T >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::vector<_Tp, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<T > > {
|
||||
template <> struct traits<std::vector<_Tp, _Alloc > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<" #T " >";
|
||||
return "std::vector<" #_Tp "," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<T >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp, _Alloc >);
|
||||
|
||||
%std_vector_methods(vector);
|
||||
|
||||
#ifdef %swig_vector_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods(std::vector<T >);
|
||||
%swig_vector_methods(std::vector<_Tp, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -98,52 +97,49 @@ namespace std {
|
|||
// This specialization should dissapear or get simplified when
|
||||
// a 'const SWIGTYPE*&' can be defined
|
||||
// ***
|
||||
template<class T > class vector<T*> {
|
||||
template<class _Tp, class _Alloc >
|
||||
class vector<_Tp*, _Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* value_type;
|
||||
typedef _Tp* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(T);
|
||||
%traits_swigtype(_Tp);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<T* >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
%fragment(SWIG_Traits_frag(std::vector<_Tp*, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(_Tp),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<T* > > {
|
||||
template <> struct traits<std::vector<_Tp*, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<" #T " * >";
|
||||
return "std::vector<" #_Tp " *," #_Alloc " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<T* >);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<_Tp*, _Alloc >);
|
||||
|
||||
%std_vector_methods_val(vector);
|
||||
|
||||
#ifdef %swig_vector_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods_val(std::vector<T* >);
|
||||
%swig_vector_methods_val(std::vector<_Tp*, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
// ***
|
||||
// ***
|
||||
// bool specialization
|
||||
%extend vector<bool> {
|
||||
void flip()
|
||||
{
|
||||
self->flip();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T > class vector<bool> {
|
||||
template<class _Alloc >
|
||||
class vector<bool,_Alloc > {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
|
@ -152,29 +148,34 @@ namespace std {
|
|||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
typedef _Alloc allocator_type;
|
||||
|
||||
%traits_swigtype(bool);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<bool>), "header",
|
||||
%fragment(SWIG_Traits_frag(std::vector<bool, _Alloc >), "header",
|
||||
fragment=SWIG_Traits_frag(bool),
|
||||
fragment="StdVectorTraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<bool> > {
|
||||
template <> struct traits<std::vector<bool, _Alloc > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<bool>";
|
||||
return "std::vector<bool, _Alloc >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool>);
|
||||
%typemap_traits_ptr(SWIG_TYPECHECK_VECTOR, std::vector<bool, _Alloc >);
|
||||
|
||||
%std_vector_methods_val(vector<bool>);
|
||||
%std_vector_methods_val(vector);
|
||||
|
||||
#if defined(SWIG_STD_MODERN_STL) && !defined(SWIG_STD_NOMODERN_STL)
|
||||
void flip();
|
||||
#endif
|
||||
|
||||
#ifdef %swig_vector_methods_val
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods_val(std::vector<bool>);
|
||||
%swig_vector_methods_val(std::vector<bool, _Alloc >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -1,145 +1,7 @@
|
|||
//
|
||||
// std::vector<T,A>
|
||||
//
|
||||
//
|
||||
// First attemp to add allocators. Still, the plain version
|
||||
// works much better. So, if tyou don't need allocators, use
|
||||
// std_vector.i instead.
|
||||
// We keep this file only for backward compatibility, since std_vector.i
|
||||
// now uses the std::allocator parameter.
|
||||
//
|
||||
|
||||
%include <std_container.i>
|
||||
|
||||
// Vector
|
||||
|
||||
%define %std_vector_methods(vector...)
|
||||
%std_sequence_methods(SWIG_arg(vector))
|
||||
|
||||
void reserve(size_type n);
|
||||
size_type capacity() const;
|
||||
%enddef
|
||||
|
||||
|
||||
%define %std_vector_methods_val(vector...)
|
||||
%std_sequence_methods_val(SWIG_arg(vector))
|
||||
|
||||
void reserve(size_type n);
|
||||
size_type capacity() const;
|
||||
%enddef
|
||||
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// std::vector
|
||||
//
|
||||
// const declarations are used to guess the intent of the function being
|
||||
// exported; therefore, the following rationale is applied:
|
||||
//
|
||||
// -- f(std::vector<T,A>), f(const std::vector<T,A>&):
|
||||
// the parameter being read-only, either a sequence or a
|
||||
// previously wrapped std::vector<T,A> can be passed.
|
||||
// -- f(std::vector<T,A>&), f(std::vector<T,A>*):
|
||||
// the parameter may be modified; therefore, only a wrapped std::vector
|
||||
// can be passed.
|
||||
// -- std::vector<T,A> f(), const std::vector<T,A>& f():
|
||||
// the vector is returned by copy; therefore, a sequence of T:s
|
||||
// is returned which is most easily used in other functions
|
||||
// -- std::vector<T,A>& f(), std::vector<T,A>* f():
|
||||
// the vector is returned by reference; therefore, a wrapped std::vector
|
||||
// is returned
|
||||
// -- const std::vector<T,A>* f(), f(const std::vector<T,A>*):
|
||||
// for consistency, they expect and return a plain vector pointer.
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
%{
|
||||
#include <vector>
|
||||
%}
|
||||
|
||||
// exported classes
|
||||
|
||||
namespace std {
|
||||
|
||||
template<class T, class A = std::allocator<T > >
|
||||
class vector {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
|
||||
%traits_swigtype(T);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<T,A >), "header",
|
||||
fragment=SWIG_Traits_frag(T),
|
||||
fragment="StdVectorATraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<T,A > > {
|
||||
typedef pointer_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<" #T "," #A " >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits(SWIG_TYPECHECK_VECTOR, std::vector<T,A >);
|
||||
|
||||
%std_vector_methods(vector<T,A >);
|
||||
|
||||
#ifdef %swig_vector_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods(std::vector<T,A >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// ***
|
||||
// This pointer especialization should dissapears or get
|
||||
// simplified when a 'const SWIGTYPE*&' can be be defined.
|
||||
// ***
|
||||
template<class T, class A = std::allocator<T*> >
|
||||
class vector<T*,A> {
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef const value_type* const_pointer;
|
||||
typedef value_type reference;
|
||||
typedef value_type const_reference;
|
||||
|
||||
%traits_swigtype(T);
|
||||
|
||||
%fragment(SWIG_Traits_frag(std::vector<T*,A >), "header",
|
||||
fragment="StdVectorATraits") {
|
||||
namespace swig {
|
||||
template <> struct traits<std::vector<T*,A > > {
|
||||
typedef value_category category;
|
||||
static const char* type_name() {
|
||||
return "std::vector<" #T " *,"#A" >";
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%typemap_traits(SWIG_TYPECHECK_VECTOR, std::vector<T*,A >);
|
||||
|
||||
%std_vector_methods_val(vector);
|
||||
|
||||
#ifdef %swig_vector_methods
|
||||
// Add swig/language extra methods
|
||||
%swig_vector_methods_val(std::vector<T*,A >);
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
// bool specialization
|
||||
%extend vector<bool,std::allocator<bool> > {
|
||||
void flip()
|
||||
{
|
||||
self->flip();
|
||||
}
|
||||
}
|
||||
}
|
||||
%include <std_vector.i>
|
||||
|
||||
|
|
|
@ -2324,6 +2324,9 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
} else {
|
||||
int def_supplied = 0;
|
||||
/* Expand the template */
|
||||
Node *templ = Swig_symbol_clookup($5,0);
|
||||
Parm *targs = templ ? Getattr(templ,"templateparms") : 0;
|
||||
|
||||
ParmList *temparms;
|
||||
if (specialized) temparms = CopyParmList($7);
|
||||
else temparms = CopyParmList(tparms);
|
||||
|
@ -2345,6 +2348,21 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
}
|
||||
Delattr(tp,"value");
|
||||
}
|
||||
/* fix default arg values */
|
||||
if (targs) {
|
||||
Parm *pi = temparms;
|
||||
Parm *ti = targs;
|
||||
String *tv = Getattr(tp,"value");
|
||||
if (!tv) tv = Getattr(tp,"type");
|
||||
while(pi != tp) {
|
||||
String *name = Getattr(ti,"name");
|
||||
String *value = Getattr(pi,"value");
|
||||
if (!value) value = Getattr(pi,"type");
|
||||
Replaceid(tv, name, value);
|
||||
pi = nextSibling(pi);
|
||||
ti = nextSibling(ti);
|
||||
}
|
||||
}
|
||||
p = nextSibling(p);
|
||||
tp = nextSibling(tp);
|
||||
if (!p && tp) {
|
||||
|
|
|
@ -297,12 +297,12 @@ Swig_cparse_template_expand(Node *n, String *rname, ParmList *tparms, Symtab *ts
|
|||
tydef = Getattr(p,"typedef");
|
||||
|
||||
if (name) {
|
||||
if (!value) {
|
||||
value = Getattr(p,"type");
|
||||
valuestr = SwigType_str(value,0);
|
||||
} else {
|
||||
valuestr = SwigType_namestr(value);
|
||||
if (!value) value = Getattr(p,"type");
|
||||
if (SwigType_istemplate(value)) {
|
||||
value = Swig_cparse_template_deftype(value, 0);
|
||||
}
|
||||
|
||||
valuestr = SwigType_str(value,0);
|
||||
assert(value);
|
||||
/* Need to patch default arguments */
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
char cvsroot_stype_c[] = "$Header$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
@ -902,11 +903,14 @@ String *SwigType_manglestr_default(SwigType *s) {
|
|||
char *c;
|
||||
String *result,*base;
|
||||
SwigType *lt;
|
||||
SwigType *ss = 0;
|
||||
SwigType *ss = SwigType_typedef_resolve_all(s);
|
||||
s = ss;
|
||||
|
||||
if (SwigType_istemplate(s)) {
|
||||
ss = SwigType_typedef_resolve_all(s);
|
||||
String *st = ss;
|
||||
ss = Swig_cparse_template_deftype(st, 0);
|
||||
s = ss;
|
||||
Delete(st);
|
||||
}
|
||||
lt = SwigType_ltype(s);
|
||||
result = SwigType_prefix(lt);
|
||||
|
|
Loading…
Reference in New Issue