modifying build system not to rely on the -I path to find the input files avoiding warning 125: move python .i files up one directory, some files have been renamed - prepended with python

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10953 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2008-11-26 22:50:35 +00:00
commit b266e1f68c
29 changed files with 19 additions and 72 deletions

View file

@ -64,9 +64,10 @@ CPP_TEST_CASES += \
std_containers \
swigobject \
template_matrix \
simutry \
vector
simutry
# li_std_carray
# director_profile
C_TEST_CASES += \
file_test \

View file

@ -1,18 +0,0 @@
%module abstractbase
%include <pyabc.i>
%include <std_map.i>
%include <std_multimap.i>
%include <std_set.i>
%include <std_multiset.i>
%include <std_list.i>
%include <std_vector.i>
namespace std
{
%template(Mapii) map<int, int>;
%template(Multimapii) multimap<int, int>;
%template(IntSet) set<int>;
%template(IntMultiset) multiset<int>;
%template(IntVector) vector<int>;
%template(IntList) list<int>;
}

View file

@ -1,23 +0,0 @@
%module argcargvtest
%include <argcargv.i>
%apply (int ARGC, char **ARGV) { (size_t argc, const char **argv) }
%inline %{
int mainc(size_t argc, const char **argv)
{
return (int)argc;
}
const char* mainv(size_t argc, const char **argv, int idx)
{
return argv[idx];
}
void initializeApp(size_t argc, const char **argv, bool setPGid = true, bool isMakeline = false)
{
}
%}

View file

@ -1,95 +0,0 @@
%module(docstring="hello") autodoc
%feature("autodoc");
// especial typemap and its docs
%typemap(in) (int c, int d) "$1 =0; $2 = 0;";
%typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
// testing for different documentation levels
%feature("autodoc","0") A::func0; // names
%feature("autodoc","1") A::func1; // names + types
%feature("autodoc","2") A::func2; // extended
%feature("autodoc","3") A::func3; // extended + types
%feature("autodoc","just a string") A::func; // names
%inline {
enum Hola {
hi, hello
};
struct A
{
A(int a, short b, Hola h)
{
}
int func(int a)
{
return a;
}
int func0(int c, int d)
{
return c;
}
int func1(int c, int d)
{
return c;
}
int func2(A* c, double d = 2)
{
return 2;
}
int func3(A* c, double d = 2)
{
return 2;
}
};
}
// deleting typemaps and docs
%typemap(in) (int c, int d) ;
%typemap(doc) (int c, int d);
// docs for some parameters
%typemap(doc) int a "a: special comment for parameter a";
%typemap(doc) int b "b: another special comment for parameter b";
%callback(1) func_cb;
%inline {
struct B
{
B(int a, int b, Hola h)
{
}
int func(int c, int d)
{
return c;
}
};
int func(int c, int d) {
return c;
}
int funcio(int *INOUT) {
return 1;
}
int func_cb(int c, int d) {
return c;
}
}

View file

@ -1,72 +0,0 @@
%module callback
%callback(1) foo;
%callback(1) foof;
%callback(1) A::bar;
%callback(1) A::foom;
%callback("%s_Cb_Ptr") foo_T; // old style, still works.
%inline %{
int foo(int a) {
return a;
}
int foof(int a) {
return 3*a;
}
struct A
{
static int bar(int a) {
return 2*a;
}
int foom(int a)
{
return -a;
}
//friend int foof(int a);
};
extern "C" int foobar(int a, int (*pf)(int a)) {
return pf(a);
}
extern "C" int foobarm(int a, A ap, int (A::*pf)(int a)) {
return (ap.*pf)(a);
}
template <class T>
T foo_T(T a)
{
return a;
}
template <class T>
T foo_T(T a, T b)
{
return a + b;
}
template <class T>
T foobar_T(T a, T (*pf)(T a)) {
return pf(a);
}
template <class T>
const T& ident(const T& x) {
return x;
}
%}
%template(foo_i) foo_T<int>;
%template(foobar_i) foobar_T<int>;
%template(foo_d) foo_T<double>;
%template(foobar_d) foobar_T<double>;
%template(ident_d) ident<double>;

View file

@ -1,61 +0,0 @@
%module complextest
%include <complex.i>
#ifdef __cplusplus
%{
#include <algorithm>
#include <functional>
#include <numeric>
%}
%include <std_vector.i>
#if 1
%template(VectorStdCplx) std::vector<std::complex<double> >;
#endif
%inline
{
std::complex<double> Conj(const std::complex<double>& a)
{
return std::conj(a);
}
std::complex<float> Conjf(const std::complex<float>& a)
{
return std::conj(a);
}
#if 1
std::vector<std::complex<double> > Copy_h(const std::vector<std::complex<double> >& a)
{
std::vector<std::complex<double> > b(a.size()/2);
std::copy(a.begin(), a.begin()+a.size()/2, b.begin());
return b;
}
#endif
}
#else
%{
%}
%inline
{
complex Conj(complex a)
{
return conj(a);
}
complex float Conjf(float complex a)
{
return conj(a);
}
}
#endif

View file

@ -1,64 +0,0 @@
%module(directors="1") director_profile
%include std_string.i
%feature("director") B;
%inline %{
class A {
public:
A() {}
};
class B
{
A aa;
public:
B() {}
virtual A fn(const A* a) {
return *a;
}
virtual int vfi(int a) {
return a + 1;
}
int fi(int a) {
return vfi(a);
}
int fj(const A* a) {
return 10;
}
B* fk(int i) {
return this;
}
const char* fl(int i) {
return "hello";
}
virtual ~B()
{
}
static B* get_self(B *b)
{
return b;
}
virtual std::string vfs(const std::string& a) {
return a;
}
std::string fs(const std::string& a) {
return vfs(a);
}
};
%}

View file

@ -1,76 +0,0 @@
%module(directors="1") director_stl
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
%include "std_string.i"
%include "std_pair.i"
%include "std_vector.i"
#ifndef SWIG_STD_DEFAULT_INSTANTIATION
%template() std::vector<double>;
%template() std::vector<int>;
%template() std::vector<std::string>;
%template() std::pair<std::string, int>;
%template() std::pair<int,double>;
%template() std::pair<double,int>;
#endif
%feature("director") Foo;
%feature("director:except") {
if ($error != NULL) {
throw Swig::DirectorMethodException();
}
}
%exception {
try { $action }
catch (...) { SWIG_fail; }
}
%inline
{
class Foo {
public:
virtual ~Foo() {}
virtual std::string& bar(std::string& s)
{
return s;
}
virtual std::string ping(std::string s) = 0;
virtual std::string pong(const std::string& s)
{ return std::string("Foo::pong:") + s + ":" + ping(s); }
std::string tping(std::string s) { return ping(s); }
std::string tpong(const std::string& s) { return pong(s); }
virtual std::pair<double, int>
pident(const std::pair<double, int>& p) { return p; }
virtual std::vector<int>
vident(const std::vector<int>& p) { return p; }
virtual std::vector<int>
vsecond(const std::vector<int>& p, const std::vector<int>& s) { return s; }
std::pair<double, int>
tpident(const std::pair<double, int>& p) { return pident(p); }
std::vector<int>
tvident(const std::vector<int>& p) { return vident(p); }
virtual std::vector<int>
tvsecond(const std::vector<int>& p, const std::vector<int>& s) { return vsecond(p,s); }
virtual std::vector<std::string>
vidents(const std::vector<std::string>& p) { return p; }
std::vector<std::string>
tvidents(const std::vector<std::string>& p) { return vidents(p); }
};
}

View file

@ -1,12 +0,0 @@
%module iadd
%include attribute.i
%{
#include "iadd.h"
%}
class Foo;
%attribute_ref(test::Foo, test::A& , AsA);
%attribute_ref(test::Foo, long, AsLong);
%include "iadd.h"

View file

@ -1,48 +0,0 @@
%module inout
%include "typemaps.i"
%include "std_pair.i"
%{
inline void AddOne3(double* a, double* b, double* c) {
*a += 1;
*b += 1;
*c += 1;
}
inline void AddOne1(double* a) {
*a += 1;
}
inline void AddOne1p(std::pair<double, double>* p) {
p->first += 1;
p->second += 1;
}
inline void AddOne2p(std::pair<double, double>* p,double* a) {
*a += 1;
p->first += 1;
p->second += 1;
}
inline void AddOne3p(double* a, std::pair<double, double>* p,double* b) {
*a += 1;
*b += 1;
p->first += 1;
p->second += 1;
}
inline void AddOne1r(double& a) {
a += 1;
}
%}
%template() std::pair<double, double>;
void AddOne1(double* INOUT);
void AddOne3(double* INOUT, double* INOUT, double* INOUT);
void AddOne1p(std::pair<double, double>* INOUT);
void AddOne2p(std::pair<double, double>* INOUT, double* INOUT);
void AddOne3p(double* INOUT, std::pair<double, double>* INOUT, double* INOUT);
void AddOne1r(double& INOUT);

View file

@ -1,40 +0,0 @@
%module inplaceadd
%{
#include <iostream>
%}
%inline %{
struct A
{
int val;
A(int v): val(v)
{
}
A& operator+=(int v)
{
val += v;
return *this;
}
A& operator+=(const A& a)
{
val += a.val;
return *this;
}
A& operator-=(int v)
{
val -= v;
return *this;
}
A& operator*=(int v)
{
val *= v;
return *this;
}
};
%}

View file

@ -1,41 +0,0 @@
%module input
%apply int *INPUT {int *bar};
%typemap(out, fragment=SWIG_From_frag(int)) int *foo {
if ($1) {
$result = SWIG_From(int)(*$1);
} else {
$result = SWIG_Py_Void();
}
}
%inline
{
struct Foo {
int *foo(int *bar = 0) {
if (bar) {
*bar *= 2;
}
return (bar) ? bar : 0;
}
};
}
%include std_string.i
%apply std::string *INPUT {std::string *bar};
%typemap(out, fragment=SWIG_From_frag(std::string)) std::string *sfoo {
if ($1) {
$result = SWIG_From(std::string)(*$1);
} else {
$result = SWIG_Py_Void();
}
}
%inline %{
std::string *sfoo(std::string *bar = 0) {
if (bar) *bar += " world";
return (bar) ? bar : 0;
}
%}

View file

@ -1,112 +0,0 @@
%module kwargs
%nocopyctor;
%kwargs;
%rename(myDel) del;
%inline
{
struct s { int del; };
}
// Simple class
%extend Foo
{
int efoo(int a = 1, int b = 0) {return a + b; }
static int sfoo(int a = 1, int b = 0) { return a + b; }
}
%newobject Foo::create;
%inline %{
struct Foo
{
Foo(int a, int b = 0) {}
virtual int foo(int a = 1, int b = 0) {return a + b; }
static int statfoo(int a = 1, int b = 0) {return a + b; }
static Foo *create(int a = 1, int b = 0)
{
return new Foo(a, b);
}
virtual ~Foo() {
}
};
%}
// Templated class
%extend Bar
{
T ebar(T a = 1, T b = 0) {return a + b; }
static T sbar(T a = 1, T b = 0) { return a + b; }
}
%inline %{
template <typename T> struct Bar
{
Bar(T a, T b = 0){}
T bar(T a = 1, T b = 0) {return a + b; }
static T statbar(T a = 1, T b = 0) {return a + b; }
};
%}
%template(BarInt) Bar<int>;
// Functions
%inline %{
int foo(int a = 1, int b = 0) {return a + b; }
template<typename T> T templatedfunction(T a = 1, T b = 0) { return a + b; }
%}
%template(templatedfunction) templatedfunction<int>;
// Deafult args with references
%inline
%{
typedef int size_type;
struct Hello
{
static const size_type hello = 3;
};
int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
{
return x;
}
%}
%{
const int Hello::hello;
%}
// Functions with keywords
%warnfilter(SWIGWARN_PARSE_KEYWORD);
%inline %{
/* silently rename the parameter names in python */
int foo_kw(int from = 1, int except = 2) {return from + except; }
int foo_nu(int from = 1, int = 0) {return from; }
int foo_mm(int min = 1, int max = 2) {return min + max; }
%}

View file

@ -1,8 +0,0 @@
%module li_std_carray
%include <std_carray.i>
%template(Vector3) std::carray<double, 3>;
%template(Matrix3) std::carray<std::carray<double, 3>, 3>;

View file

@ -1,65 +0,0 @@
%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 *> >;

View file

@ -1,59 +0,0 @@
%module li_std_wstream
%inline %{
struct A;
%}
%include <std_wiostream.i>
%include <std_wsstream.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::wostream& __rlshift__(std::wostream& out)
{
out << "A class";
return out;
}
};
%}
%extend std::basic_ostream<wchar_t>{
std::basic_ostream<wchar_t>&
operator<<(const A& a)
{
*self << "A class";
return *self;
}
}

View file

@ -1,58 +0,0 @@
%module nondynamic
/*
Use the %pythonnondynamic directuve to make the wrapped class a
nondynamic one, ie, a python class that doesn't dynamically add new
attributes. Hence, for the class
%pythonnondynamic A;
struct A
{
int a;
int b;
};
you will get:
aa = A()
aa.a = 1 # Ok
aa.b = 1 # Ok
aa.c = 3 # error
Since "nondynamic" is a feature, if you use
%pythonnondynamic;
it will make all the wrapped class nondynamic ones.
The implementation is based on the recipe:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252158
and works for modern (-modern) and plain python.
*/
%pythonnondynamic A;
%pythondynamic C;
%inline %{
struct A
{
int a;
int b;
};
struct C
{
int a;
int b;
};
%}

View file

@ -1,4 +0,0 @@
// Simple tests of overloaded functions
%module("castmode") overload_simple_cast
%include overload_simple.i

View file

@ -1,64 +0,0 @@
%module pybuf
%include<pybuffer.i>
%include<cstring.i>
/*functions for the test case*/
%pybuffer_mutable_binary(char *buf1, int len);
%pybuffer_mutable_string(char *buf2);
%pybuffer_binary(const char *buf3, int len);
%pybuffer_string(const char *buf4);
%inline %{
void func1(char *buf1, int len)
{
int i;
for (i=0; i<len; ++i)
buf1[i] = 'a';
return;
}
void func2(char *buf2)
{
strcpy(buf2, "Hello world!");
}
int func3(const char *buf3, int len)
{
int count = 0;
int i;
for(i=0; i<len; ++i)
if (isalnum(buf3[i]))
++count;
return count;
}
int func4(const char *buf4)
{
return strlen(buf4);
}
%}
/*functions for the benchmark*/
%pybuffer_mutable_string(char *str1);
%cstring_mutable(char *str2);
%inline %{
void title(char *str) {
int outword = 1;
while(*str) {
if (isalnum(*str)) {
if (outword) {
outword = 0;
*str = toupper(*str);
}
}
else {
outword = 0;
}
str++;
}
}
void title1(char *str1) {
title(str1);
}
void title2(char *str2) {
title(str2);
}
%}

View file

@ -0,0 +1,8 @@
from python_abstractbase import *
from collections import *
assert issubclass(Mapii, MutableMapping)
assert issubclass(Multimapii, MutableMapping)
assert issubclass(IntSet, MutableSet)
assert issubclass(IntMultiset, MutableSet)
assert issubclass(IntVector, MutableSequence)
assert issubclass(IntList, MutableSequence)

Some files were not shown because too many files have changed in this diff Show more