renamed lib_xxxx to li_xxxx
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6598 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d035ab0fa3
commit
9af665a99a
6 changed files with 6 additions and 6 deletions
96
SWIG/Examples/test-suite/python/li_std_vector.i
Normal file
96
SWIG/Examples/test-suite/python/li_std_vector.i
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
%module li_std_vector
|
||||
|
||||
%include "std_vector.i"
|
||||
%include "cpointer.i"
|
||||
%include "carrays.i"
|
||||
|
||||
%{
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%template() vector<short>;
|
||||
%template(IntVector) vector<int>;
|
||||
%template(BoolVector) vector<bool>;
|
||||
}
|
||||
|
||||
%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));
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(IntPtrVector) std::vector<int *>;
|
||||
|
||||
|
||||
|
||||
//
|
||||
//
|
||||
%{
|
||||
#include <iostream>
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace Test {
|
||||
struct A {
|
||||
virtual ~A() {}
|
||||
virtual int f(const int i) const = 0;
|
||||
};
|
||||
|
||||
struct B : public A {
|
||||
int val;
|
||||
|
||||
B(int i = 0) : val(i)
|
||||
{
|
||||
}
|
||||
|
||||
int f(const int i) const { return i + val; }
|
||||
};
|
||||
|
||||
|
||||
int vecAptr(const std::vector<A*>& v) {
|
||||
return v[0]->f(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
std::vector<short> halfs(const std::vector<short>& v) {
|
||||
std::vector<short> w(v);
|
||||
for (std::vector<short>::size_type i=0; i<w.size(); i++)
|
||||
w[i] /= 2;
|
||||
return w;
|
||||
}
|
||||
|
||||
%}
|
||||
%template(VecB) std::vector<Test::B>;
|
||||
%template(VecA) std::vector<Test::A*>;
|
||||
|
||||
%pointer_class(int,PtrInt)
|
||||
%array_functions(int,ArrInt)
|
||||
Loading…
Add table
Add a link
Reference in a new issue