modifying build system not to rely on the -I path to find the input files avoiding warning 125: merge .i files that are common between python and the main version
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10954 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b266e1f68c
commit
3041db155d
9 changed files with 15 additions and 424 deletions
|
|
@ -1,58 +0,0 @@
|
|||
%module("templatereduce") 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(pairAA) pair<int, A>;
|
||||
%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*> >;
|
||||
|
||||
|
||||
%template() pair<swig::PyObject_ptr, swig::PyObject_ptr>;
|
||||
%template(pymap) map<swig::PyObject_ptr, swig::PyObject_ptr>;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
%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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
%template(mapii) map<int,int>;
|
||||
}
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
%module li_std_set
|
||||
|
||||
%include <std_string.i>
|
||||
%include <std_set.i>
|
||||
%include <std_multiset.i>
|
||||
%include <std_vector.i>
|
||||
|
||||
%template(set_string) std::set<std::string>;
|
||||
%template(set_int) std::multiset<int>;
|
||||
|
||||
|
||||
%template(v_int) std::vector<int>;
|
||||
|
||||
|
||||
|
||||
|
||||
%template(pyset) std::set<swig::PyObject_ptr>;
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
%module li_std_stream
|
||||
|
||||
%inline %{
|
||||
struct A;
|
||||
%}
|
||||
|
||||
%include <std_iostream.i>
|
||||
%include <std_sstream.i>
|
||||
|
||||
|
||||
|
||||
%callback(1) A::bar;
|
||||
|
||||
%inline %{
|
||||
|
||||
struct B {
|
||||
virtual ~B()
|
||||
{
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct A : B
|
||||
{
|
||||
void __add__(int a)
|
||||
{
|
||||
}
|
||||
|
||||
void __add__(double a)
|
||||
{
|
||||
}
|
||||
|
||||
static int bar(int a){
|
||||
return a;
|
||||
}
|
||||
|
||||
static int foo(int a, int (*pf)(int a))
|
||||
{
|
||||
return pf(a);
|
||||
}
|
||||
|
||||
|
||||
std::ostream& __rlshift__(std::ostream& out)
|
||||
{
|
||||
out << "A class";
|
||||
return out;
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
%extend std::basic_ostream<char>{
|
||||
std::basic_ostream<char>&
|
||||
operator<<(const A& a)
|
||||
{
|
||||
*self << "A class";
|
||||
return *self;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,141 +0,0 @@
|
|||
%module li_std_vector
|
||||
|
||||
%warnfilter(509) overloaded1;
|
||||
%warnfilter(509) overloaded2;
|
||||
|
||||
%include "std_string.i"
|
||||
%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() vector<string>;
|
||||
}
|
||||
|
||||
%template(DoubleVector) std::vector<double>;
|
||||
|
||||
|
||||
%template(sizeVector) std::vector<size_t>;
|
||||
%{
|
||||
template <class T>
|
||||
struct Param
|
||||
{
|
||||
T val;
|
||||
|
||||
Param(T v = 0): val(v) {
|
||||
}
|
||||
|
||||
operator T() const { return val; }
|
||||
};
|
||||
%}
|
||||
specialize_std_vector(Param<int>,PyInt_Check,PyInt_AsLong,PyInt_FromLong);
|
||||
%template(PIntVector) std::vector<Param<int> >;
|
||||
|
||||
%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;
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> vecStr(std::vector<std::string> v) {
|
||||
v[0] += v[1];
|
||||
return v;
|
||||
}
|
||||
|
||||
%}
|
||||
%template(VecB) std::vector<Test::B>;
|
||||
%template(VecA) std::vector<Test::A*>;
|
||||
|
||||
%pointer_class(int,PtrInt)
|
||||
%array_functions(int,ArrInt)
|
||||
|
||||
|
||||
%template(pyvector) std::vector<swig::PyObject_ptr>;
|
||||
|
||||
namespace std {
|
||||
%template(ConstIntVector) vector<const int *>;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
std::string overloaded1(std::vector<double> vi) { return "vector<double>"; }
|
||||
std::string overloaded1(std::vector<int> vi) { return "vector<int>"; }
|
||||
std::string overloaded2(std::vector<int> vi) { return "vector<int>"; }
|
||||
std::string overloaded2(std::vector<double> vi) { return "vector<double>"; }
|
||||
std::string overloaded3(std::vector<int> *vi) { return "vector<int> *"; }
|
||||
std::string overloaded3(int i) { return "int"; }
|
||||
%}
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
from li_std_vector import *
|
||||
from li_std_vector_extra import *
|
||||
|
||||
iv = IntVector(4)
|
||||
for i in range(0,4):
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
%module li_std_wstring
|
||||
%include <std_basic_string.i>
|
||||
%include <std_wstring.i>
|
||||
|
||||
|
||||
%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;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
|
||||
void test_throw() throw(std::wstring){
|
||||
static std::wstring x = L"x";
|
||||
|
||||
throw x;
|
||||
}
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
|
||||
#endif
|
||||
|
||||
%}
|
||||
|
||||
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
%module std_containers
|
||||
|
||||
%{
|
||||
#include <set>
|
||||
%}
|
||||
%include std_vector.i
|
||||
%include std_string.i
|
||||
%include std_deque.i
|
||||
%include std_list.i
|
||||
%include std_set.i
|
||||
%include std_multiset.i
|
||||
%include std_pair.i
|
||||
%include std_map.i
|
||||
%include std_multimap.i
|
||||
%include std_complex.i
|
||||
|
||||
%template() std::vector<double>;
|
||||
%template() std::pair<std::string, int>;
|
||||
%template() std::pair<int,double>;
|
||||
|
||||
%template() std::vector< std::vector<double > > ;
|
||||
%template(ccube) std::vector< std::vector< std::vector<double > > >;
|
||||
|
||||
%inline
|
||||
{
|
||||
typedef
|
||||
std::vector<std::vector<std::vector<double > > >
|
||||
ccube;
|
||||
|
||||
ccube cident(const ccube& c)
|
||||
{
|
||||
return c;
|
||||
}
|
||||
|
||||
struct C
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
%template(map_si) std::map<std::string, int>;
|
||||
%template(pair_iC) std::pair<int, C*>;
|
||||
%template(map_iC) std::map<int, C*>;
|
||||
%template(mmap_si) std::multimap<std::string, int>;
|
||||
%template(set_i) std::set<int>;
|
||||
%template(multiset_i) std::multiset<int>;
|
||||
%template(list_i) std::list<int>;
|
||||
%template(deque_i) std::deque<int>;
|
||||
|
||||
%template(vector_b) std::vector<bool>;
|
||||
%template(vector_i) std::vector<int>;
|
||||
%template(vector_c) std::vector<std::complex<double> >;
|
||||
%template(vector_ui) std::vector<unsigned int>;
|
||||
|
||||
%template(bmatrix) std::vector<std::vector<bool> >;
|
||||
%template(imatrix) std::vector<std::vector<int> >;
|
||||
%template(cmatrix) std::vector<std::vector<std::complex<double> > >;
|
||||
|
||||
%apply std::vector<int> *INOUT {std::vector<int> *INOUT2};
|
||||
|
||||
%inline
|
||||
{
|
||||
typedef std::vector<std::vector<int> > imatrix;
|
||||
imatrix midenti(const imatrix& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
typedef std::vector<std::vector<bool> > bmatrix;
|
||||
bmatrix midentb(const bmatrix& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::map<int,C*> mapidentc(const std::map<int,C*>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::map<int,int> mapidenti(const std::map<int,int>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::map<std::string,int> mapident(const std::map<std::string,int>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::vector<int> vident(const std::vector<int>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::set<int> sident(const std::set<int>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> videntu(const std::vector<unsigned int>& v)
|
||||
{
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
int get_elem(const std::vector<int>& v, int index)
|
||||
{
|
||||
return v[index];
|
||||
}
|
||||
|
||||
std::pair<int,double> pident(const std::pair<int,double>& p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
void
|
||||
v_inout(std::vector<int> *INOUT) {
|
||||
*INOUT = *INOUT;
|
||||
}
|
||||
|
||||
void
|
||||
v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) {
|
||||
std::swap(*INOUT, *INOUT2);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
%{
|
||||
|
||||
template <class C> struct Param
|
||||
{
|
||||
};
|
||||
%}
|
||||
|
||||
|
||||
template <class C> struct Param
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
%template(Param_c) Param<std::complex<double> >;
|
||||
%inline
|
||||
{
|
||||
int hello(Param<std::complex<double> > c)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
%inline
|
||||
{
|
||||
struct A
|
||||
{
|
||||
A(int aa = 0) : a(aa)
|
||||
{
|
||||
}
|
||||
int a;
|
||||
};
|
||||
}
|
||||
|
||||
%template() std::pair<A,int>;
|
||||
%template(pair_iA) std::pair<int,A>;
|
||||
%template(vector_piA) std::vector<std::pair<int,A> >;
|
||||
|
||||
|
||||
%inline {
|
||||
std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b)
|
||||
{
|
||||
return std::pair<A,int>();
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a )
|
||||
{
|
||||
return a;
|
||||
}
|
||||
|
||||
struct Foo
|
||||
{
|
||||
Foo(int i) {
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
%std_nodefconst_type(Foo);
|
||||
|
||||
%template(vector_Foo) std::vector<Foo>;
|
||||
%template(deque_Foo) std::deque<Foo>;
|
||||
%template(list_Foo) std::list<Foo>;
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue