2
// Use the following macro with modern STL implementations
4
//#define SWIG_STD_MODERN_STL
6
// Use this to deactive the previous definition, when using gcc-2.95
7
// or similar old compilers.
9
//#define SWIG_STD_NOMODERN_STL
11
// Here, we identify compilers we now have problems with STL.
14
#if defined(__SUNPRO_CC)
15
#define SWIG_STD_NOASSIGN_STL
16
#define SWIG_STD_NOINSERT_TEMPLATE_STL
22
// Common code for supporting the STD C++ namespace
32
%fragment("StdTraitsCommon","header")
36
struct noconst_traits {
37
typedef Type noconst_type;
41
struct noconst_traits<const Type> {
42
typedef Type noconst_type;
48
struct pointer_category { };
49
struct value_category { };
52
General traits that provides type_name and type_info
54
template <class Type> struct traits { };
57
inline const char* type_name() {
58
return traits<typename noconst_traits<Type >::noconst_type >::type_name();
63
static swig_type_info *type_query(std::string name) {
65
return SWIG_TypeQuery(name.c_str());
67
static swig_type_info *type_info() {
68
static swig_type_info *info = type_query(type_name<Type>());
74
inline swig_type_info *type_info() {
75
return traits_info<Type>::type_info();
79
Partial specialization for pointers
81
template <class Type> struct traits <Type *> {
82
typedef pointer_category category;
83
static std::string make_ptr_name(const char* name) {
84
std::string ptrname = name;
88
static const char* type_name() {
89
static std::string name = make_ptr_name(swig::type_name<Type>());
94
template <class Type, class Category>
97
template <class Type, class Category>
98
struct traits_check { };
104
Generate the traits for a swigtype
107
%define %traits_swigtype(Type...)
108
%fragment(SWIG_Traits_frag(Type),"header",fragment="StdTraits") {
110
template <> struct traits<Type > {
111
typedef pointer_category category;
112
static const char* type_name() { return #Type; }
120
Generate the traits for a 'primitive' type, such as 'double',
121
for which the SWIG_AsVal and SWIG_From methods are already defined.
124
%define %traits_ptypen(Type...)
125
%fragment(SWIG_Traits_frag(Type),"header",
126
fragment=SWIG_AsVal_frag(Type),
127
fragment=SWIG_From_frag(Type),
128
fragment="StdTraits") {
130
template <> struct traits<Type > {
131
typedef value_category category;
132
static const char* type_name() { return #Type; }
134
template <> struct traits_asval<Type > {
135
typedef Type value_type;
136
static int asval(PyObject *obj, value_type *val) {
137
return SWIG_AsVal(Type)(obj, val);
140
template <> struct traits_from<Type > {
141
typedef Type value_type;
142
static PyObject *from(const value_type& val) {
143
return SWIG_From(Type)(val);
151
Generate the typemaps for a class that has 'value' traits
154
%define %typemap_traits(Code,Type...)
155
%typemap_ascheckfrom(SWIG_arg(Code),
156
SWIG_arg(swig::as<Type >),
157
SWIG_arg(swig::check<Type >),
158
SWIG_arg(swig::from),
159
SWIG_arg(SWIG_Traits_frag(Type)),
160
SWIG_arg(SWIG_Traits_frag(Type)),
161
SWIG_arg(SWIG_Traits_frag(Type)),
166
Generate the typemaps for a class that behaves more like a 'pointer' or
167
plain wrapped Swigtype.
170
%define %typemap_traits_ptr(Code,Type...)
171
%typemap_asptrfrom(SWIG_arg(Code),
172
SWIG_arg(swig::asptr),
173
SWIG_arg(swig::from),
174
SWIG_arg(SWIG_Traits_frag(Type)),
175
SWIG_arg(SWIG_Traits_frag(Type)),
183
%define %std_equal_methods(Type...)
185
bool operator == (const Type& v) {
189
bool operator != (const Type& v) {
200
%define %std_order_methods(Type...)
202
bool operator > (const Type& v) {
206
bool operator < (const Type& v) {
210
bool operator >= (const Type& v) {
214
bool operator <= (const Type& v) {
224
%define %std_comp_methods(Type...)
225
%std_equal_methods(Type )
226
%std_order_methods(Type )