1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
%module li_boost_array
#if defined(SWIGPYTHON) || defined(SWIGRUBY)
// Hack to use the std::array support for boost::array.
// Is limited as it currently exposes some 'using' bugs in SWIG though.
// For example, the type system fails to see that pointers to std::array
// and pointers to boost::array are the same.
%{
#if __cplusplus >= 201103 || (defined(_MSC_VER) && _MSC_VER >= 1900)
// Use C++11 array as this is unfortunately sometimes included by <algorithm>
#include <array>
namespace boost {
using std::array;
}
#else
#include <boost/array.hpp>
namespace std {
using boost::array;
}
#endif
%}
namespace boost {
using std::array;
}
%include <std_array.i>
%template(ArrayInt6) std::array<int, 6>;
%inline %{
boost::array<int, 6> arrayOutVal() {
const signed char carray[] = { -2, -1, 0, 0, 1, 2 };
boost::array<int, 6> myarray;
for (size_t i=0; i<6; ++i) {
myarray[i] = carray[i];
}
return myarray;
}
boost::array<int, 6> & arrayOutRef() {
static boost::array<int, 6> a = { -2, -1, 0, 0, 1, 2 };
return a;
}
const boost::array<int, 6> & arrayOutConstRef() {
static boost::array<int, 6> a = { -2, -1, 0, 0, 1, 2 };
return a;
}
boost::array<int, 6> * arrayOutPtr() {
static boost::array<int, 6> a = { -2, -1, 0, 0, 1, 2 };
return &a;
}
boost::array<int, 6> arrayInVal(boost::array<int, 6> myarray) {
for (boost::array<int, 6>::iterator it = myarray.begin(); it!=myarray.end(); ++it) {
*it *= 10;
}
return myarray;
}
const boost::array<int, 6> & arrayInConstRef(const boost::array<int, 6> & myarray) {
static boost::array<int, 6> a = myarray;
for (boost::array<int, 6>::iterator it = a.begin(); it!=a.end(); ++it) {
*it *= 10;
}
return a;
}
void arrayInRef(boost::array<int, 6> & myarray) {
for (boost::array<int, 6>::iterator it = myarray.begin(); it!=myarray.end(); ++it) {
*it *= 10;
}
}
void arrayInPtr(boost::array<int, 6> * myarray) {
for (boost::array<int, 6>::iterator it = myarray->begin(); it!=myarray->end(); ++it) {
*it *= 10;
}
}
%}
#endif
|