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
21
SWIG/Examples/test-suite/python/li_std_except.i
Normal file
21
SWIG/Examples/test-suite/python/li_std_except.i
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
%module li_std_except
|
||||
|
||||
%include <std_except.i>
|
||||
|
||||
|
||||
%inline %{
|
||||
struct E1 : public std::exception
|
||||
{
|
||||
};
|
||||
|
||||
struct E2
|
||||
{
|
||||
};
|
||||
|
||||
struct Test {
|
||||
int foo1() throw(std::bad_exception) { return 0; }
|
||||
int foo2() throw(std::logic_error) { return 0; }
|
||||
int foo3() throw(E1) { return 0; }
|
||||
int foo4() throw(E2) { return 0; }
|
||||
};
|
||||
%}
|
||||
49
SWIG/Examples/test-suite/python/li_std_map.i
Normal file
49
SWIG/Examples/test-suite/python/li_std_map.i
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
%module li_std_map
|
||||
|
||||
%include std_pair.i
|
||||
%include std_map.i
|
||||
%include std_multimap.i
|
||||
|
||||
%inline %{
|
||||
struct A{
|
||||
int val;
|
||||
|
||||
A(int v = 0): val(v)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
%}
|
||||
|
||||
namespace std
|
||||
{
|
||||
%template(pairii) pair<int, int>;
|
||||
%template(pairA) pair<int, A*>;
|
||||
%template(mapA) map<int, A*>;
|
||||
%template(mmapA) multimap<int, A*>;
|
||||
|
||||
%template(paircA1) pair<const int, A*>;
|
||||
%template(paircA2) pair<const int, const A*>;
|
||||
%template(pairiiA) pair<int,pair<int, A*> >;
|
||||
%template(pairiiAc) pair<int,const pair<int, A*> >;
|
||||
}
|
||||
|
||||
|
||||
|
||||
%inline
|
||||
{
|
||||
std::pair<int, A*>
|
||||
p_identa(std::pair<int, A*> p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
std::map<int,A*> m_identa(const std::map<int,A*>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
188
SWIG/Examples/test-suite/python/li_std_pair.i
Normal file
188
SWIG/Examples/test-suite/python/li_std_pair.i
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
%module li_std_pair
|
||||
|
||||
//
|
||||
// activate the automatic comparison methods generation (==,!=,...)
|
||||
//
|
||||
|
||||
%include std_pair.i
|
||||
%include std_string.i
|
||||
%include std_complex.i
|
||||
|
||||
%inline
|
||||
%{
|
||||
struct A
|
||||
{
|
||||
int val;
|
||||
|
||||
A(int v = 0): val(v)
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
struct B
|
||||
{
|
||||
};
|
||||
%}
|
||||
|
||||
%std_comp_methods(std::pair<std::string, int>);
|
||||
|
||||
namespace std {
|
||||
%template(CIntPair) pair<const int, const int>;
|
||||
%template() pair<double, double>;
|
||||
%template(IntPair) pair<int, int>;
|
||||
%template(SIPair) pair<std::string, int>;
|
||||
%template(CIPair) pair<std::complex<double>, int>;
|
||||
%template(SIIPair) pair<std::pair<std::string, int>, int>;
|
||||
%template(AIntPair) pair<A, int>;
|
||||
|
||||
%template(CCIntPair) pair<const A, const pair<int, int> >;
|
||||
|
||||
%template(ABPair) pair<A, B>;
|
||||
%template(IntAPair) pair<int, A>;
|
||||
|
||||
%template(pairP1) pair<int, A*>;
|
||||
%template(pairP2) pair<A*, int>;
|
||||
%template(pairP3) pair<A*, A*>;
|
||||
%template(pairP4) pair<int, int*>;
|
||||
%template(pairP5) pair<int*, int>;
|
||||
%template(pairP6) pair<int*, int*>;
|
||||
|
||||
}
|
||||
%std_comp_methods(std::pair<std::pair<std::string, int>, int>);
|
||||
|
||||
%apply std::pair<int,int> *INOUT {std::pair<int,int> *INOUT2};
|
||||
|
||||
%inline %{
|
||||
|
||||
/* Test the "out" typemap for pair<T, U> */
|
||||
std::pair<int, int> makeIntPair(int a, int b) {
|
||||
return std::make_pair(a, b);
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no "out" typemap for a pointer to a pair, so
|
||||
* this should return a wrapped instance of a std::pair
|
||||
* instead of the native "array" type for the target language.
|
||||
*/
|
||||
std::pair<int, int> * makeIntPairPtr(int a, int b) {
|
||||
static std::pair<int, int> p = std::make_pair(a, b);
|
||||
return &p;
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no "out" typemap for a non-const reference to a pair, so
|
||||
* this should return a wrapped instance of a std::pair instead of
|
||||
* the native "array" type for the target language.
|
||||
*/
|
||||
std::pair<int, int>& makeIntPairRef(int a, int b) {
|
||||
static std::pair<int, int> p = std::make_pair(a, b);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
* There is no "out" typemap for a const reference to a pair, so
|
||||
* this should return a wrapped instance of a std::pair
|
||||
* instead of the native "array" type for the target language.
|
||||
*/
|
||||
const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
|
||||
static std::pair<int, int> p = std::make_pair(a, b);
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Test the "in" typemap for pair<T, U> */
|
||||
int product1(std::pair<int, int> p) {
|
||||
return p.first*p.second;
|
||||
}
|
||||
|
||||
/* Test the "in" typemap for const pair<T, U>& */
|
||||
int product2(const std::pair<int, int>& p) {
|
||||
return p.first*p.second;
|
||||
}
|
||||
|
||||
std::pair<int, int>
|
||||
p_ident(std::pair<int, int> p, const std::pair<int, int>& q) {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, A*>
|
||||
p_identa(const std::pair<int, A*>& p) {
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
d_inout(double *INOUT) {
|
||||
*INOUT += *INOUT;
|
||||
}
|
||||
|
||||
void
|
||||
d_inout(int *INOUT) {
|
||||
*INOUT += *INOUT;
|
||||
}
|
||||
|
||||
int
|
||||
d_inout2(double *INOUT) {
|
||||
*INOUT += *INOUT;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
p_inout(std::pair<int, int> *INOUT) {
|
||||
std::swap(INOUT->first, INOUT->second);
|
||||
}
|
||||
|
||||
int
|
||||
p_inout2(std::pair<int, int> *INOUT) {
|
||||
std::swap(INOUT->first, INOUT->second);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void
|
||||
p_inout3(std::pair<int,int> *INOUT, std::pair<int,int> *INOUT2) {
|
||||
std::swap(*INOUT, *INOUT2);
|
||||
}
|
||||
|
||||
void
|
||||
p_inoutd(std::pair<double, double> *INOUT) {
|
||||
std::swap(INOUT->first, INOUT->second);
|
||||
}
|
||||
|
||||
std::string
|
||||
s_ident(const std::string& s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
#if 0
|
||||
std::pair<char, char>
|
||||
p_ident(std::pair<char, char> p, const std::pair<char, char>& q) {
|
||||
return p;
|
||||
}
|
||||
|
||||
/* Test the "in" typemap for const pair<T, U>* */
|
||||
std::pair<A, B>
|
||||
p_ident(std::pair<A, B> p, const std::pair<A, B>& q) {
|
||||
return q;
|
||||
}
|
||||
|
||||
/* Test the "in" typemap for const pair<T, U>* */
|
||||
std::pair<int, A>
|
||||
p_ident(std::pair<int, A> p, const std::pair<int, A>& q) {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
std::pair<int, int>
|
||||
p_ident(std::pair<int, int> p, const std::pair<A, int>& q) {
|
||||
return p;
|
||||
}
|
||||
|
||||
std::pair<int, int>
|
||||
p_ident(std::pair<int, int> p, const std::pair<A, B>& q) {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
%}
|
||||
|
||||
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)
|
||||
65
SWIG/Examples/test-suite/python/li_std_vectora.i
Normal file
65
SWIG/Examples/test-suite/python/li_std_vectora.i
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
%module li_std_vectora
|
||||
|
||||
%include std_vectora.i
|
||||
|
||||
|
||||
%{
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <numeric>
|
||||
%}
|
||||
|
||||
|
||||
%template(vector_i) std::vector<int, std::allocator<int> >;
|
||||
|
||||
%template(matrix_i) std::vector<std::vector<int,std::allocator<int> >,std::allocator<std::vector<int,std::allocator<int> > > >;
|
||||
|
||||
%inline
|
||||
{
|
||||
typedef
|
||||
std::vector<std::vector<int,std::allocator<int> >,
|
||||
std::allocator<std::vector<int,std::allocator<int> > > >
|
||||
imatrix;
|
||||
|
||||
std::vector<int> vident(const std::vector<int,std::allocator<int> >& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
imatrix mident(const imatrix& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
%template(DoubleVector) std::vector<double, std::allocator<double> >;
|
||||
|
||||
%inline %{
|
||||
typedef float Real;
|
||||
%}
|
||||
|
||||
namespace std {
|
||||
%template(RealVector) vector<Real, std::allocator<Real> >;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
|
||||
double average(std::vector<int, std::allocator<int> > v) {
|
||||
return std::accumulate(v.begin(),v.end(),0.0)/v.size();
|
||||
}
|
||||
|
||||
std::vector<Real,std::allocator<Real> >
|
||||
half(const std::vector<Real,std::allocator<Real> >& v) {
|
||||
std::vector<Real> w(v);
|
||||
for (unsigned int i=0; i<w.size(); i++)
|
||||
w[i] /= 2.0;
|
||||
return w;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%template(IntPtrVector) std::vector<int *,std::allocator<int *> >;
|
||||
|
||||
|
||||
|
||||
82
SWIG/Examples/test-suite/python/li_std_wstring.i
Normal file
82
SWIG/Examples/test-suite/python/li_std_wstring.i
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
%module li_std_wstring
|
||||
%include <std_basic_string.i>
|
||||
%include <std_wstring.i>
|
||||
|
||||
|
||||
%template(wstring) std::basic_string<wchar_t>;
|
||||
%inline %{
|
||||
|
||||
struct A : std::wstring
|
||||
{
|
||||
A(const std::wstring& s) : std::wstring(s)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
B(const std::wstring& s) : cname(0), name(s), a(s)
|
||||
{
|
||||
}
|
||||
|
||||
char *cname;
|
||||
std::wstring name;
|
||||
A a;
|
||||
|
||||
};
|
||||
|
||||
|
||||
wchar_t test_wcvalue(wchar_t x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const wchar_t* test_ccvalue(const wchar_t* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
wchar_t* test_cvalue(wchar_t* x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
std::wstring test_value(std::wstring x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
const std::wstring& test_const_reference(const std::wstring &x) {
|
||||
return x;
|
||||
}
|
||||
|
||||
void test_pointer(std::wstring *x) {
|
||||
}
|
||||
|
||||
std::wstring *test_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_const_pointer(const std::wstring *x) {
|
||||
}
|
||||
|
||||
const std::wstring *test_const_pointer_out() {
|
||||
static std::wstring x = L"x";
|
||||
return &x;
|
||||
}
|
||||
|
||||
void test_reference(std::wstring &x) {
|
||||
}
|
||||
|
||||
std::wstring& test_reference_out() {
|
||||
static std::wstring x = L"x";
|
||||
return x;
|
||||
}
|
||||
|
||||
void test_throw() throw(std::wstring){
|
||||
static std::wstring x = L"x";
|
||||
|
||||
throw x;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
|
||||
Loading…
Reference in a new issue