lib_xxxx tests renamed to li_xxxx as a workaround in glib which Mono C# uses - libraries wont be loaded if they start with lib
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6588 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cf415b0c64
commit
00bc9d8ee6
12 changed files with 0 additions and 0 deletions
58
Examples/test-suite/li_std_vector.i
Normal file
58
Examples/test-suite/li_std_vector.i
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
%module lib_std_vector
|
||||
|
||||
%include "std_vector.i"
|
||||
|
||||
%{
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%template(IntVector) vector<int>;
|
||||
}
|
||||
|
||||
%template(DoubleVector) std::vector<double>;
|
||||
|
||||
%inline %{
|
||||
typedef float Real;
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%template(RealVector) vector<Real>;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
double average(std::vector<int> v) {
|
||||
return std::accumulate(v.begin(),v.end(),0.0)/v.size();
|
||||
}
|
||||
|
||||
std::vector<Real> half(const std::vector<Real>& v) {
|
||||
std::vector<Real> w(v);
|
||||
for (std::vector<Real>::size_type i=0; i<w.size(); i++)
|
||||
w[i] /= 2.0;
|
||||
return w;
|
||||
}
|
||||
|
||||
void halve_in_place(std::vector<double>& v) {
|
||||
std::transform(v.begin(),v.end(),v.begin(),
|
||||
std::bind2nd(std::divides<double>(),2.0));
|
||||
}
|
||||
|
||||
struct Struct {
|
||||
double num;
|
||||
Struct() : num(0.0) {}
|
||||
Struct(double d) : num(d) {}
|
||||
// bool operator==(const Struct &other) { return (num == other.num); }
|
||||
};
|
||||
%}
|
||||
|
||||
#ifndef SWIGCSHARP
|
||||
// Can't do vectors of pointers yet
|
||||
%template(IntPtrVector) std::vector<int *>;
|
||||
#endif
|
||||
|
||||
%template(StructVector) std::vector<Struct>;
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue