Merge trunk rev 13025 (swig-2.0.6) into gsoc2008-maciekd

Conflicts:
	Doc/Manual/chapters
	Examples/Makefile.in
	Examples/test-suite/dynamic_cast.i
	Lib/exception.i
	Makefile.in
	Source/Include/swigwarn.h
	Source/Modules/swigmain.cxx
	Source/Swig/swig.h
	Tools/config/config.guess
	Tools/config/config.sub
	configure.in

From: William S Fulton <wsf@fultondesigns.co.uk>

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-maciekd@13036 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2012-05-07 16:59:38 +00:00
commit e0067ea998
2152 changed files with 99389 additions and 53536 deletions

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -1,6 +1,5 @@
/* File : example.h */
#include <cstdio>
#include <iostream>
class Callback {

View file

@ -5,8 +5,6 @@
import example
# CEO class, which overrides Employee::getPosition().
class PyCallback(example.Callback):
def __init__(self):
example.Callback.__init__(self)

View file

@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -126,7 +126,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@ -141,7 +141,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -python $(InputPath)
..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -python $(InputPath)
..\..\..\swig.exe -python $(InputPath)
# End Custom Build

View file

@ -21,3 +21,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -19,3 +19,4 @@ clean::
@rm -f foo.py bar.py spam.py base.py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -118,7 +118,7 @@ InputName=bar
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@ -133,7 +133,7 @@ InputName=bar
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build

View file

@ -118,7 +118,7 @@ InputName=base
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@ -133,7 +133,7 @@ InputName=base
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build

View file

@ -118,7 +118,7 @@ InputName=foo
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@ -133,7 +133,7 @@ InputName=foo
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build

View file

@ -118,7 +118,7 @@ InputName=spam
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@ -133,7 +133,7 @@ InputName=spam
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -c++ -python $(InputPath)
..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build

View file

@ -19,3 +19,4 @@ clean::
@rm -f foo.py bar.py spam.py base.py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -python $(InputPath)
..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -python $(InputPath)
..\..\..\swig.exe -python $(InputPath)
# End Custom Build

View file

@ -27,11 +27,24 @@ extern int gcd(int x, int y);
$2 = (char **) malloc(($1+1)*sizeof(char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem($input,i);
if (!PyString_Check(s)) {
%#if PY_VERSION_HEX >= 0x03000000
if (!PyUnicode_Check(s))
%#else
if (!PyString_Check(s))
%#endif
{
free($2);
SWIG_exception(SWIG_ValueError, "List items must be strings");
}
%#if PY_VERSION_HEX >= 0x03000000
{
int l;
$2[i] = PyUnicode_AsStringAndSize(s, &l);
}
%#else
$2[i] = PyString_AsString(s);
%#endif
}
$2[i] = 0;
}
@ -39,12 +52,21 @@ extern int gcd(int x, int y);
extern int gcdmain(int argc, char *argv[]);
%typemap(in) (char *bytes, int len) {
%#if PY_VERSION_HEX >= 0x03000000
if (!PyUnicode_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a string");
return NULL;
}
$1 = PyUnicode_AsStringAndSize($input, &$2);
%#else
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a string");
return NULL;
}
$1 = PyString_AsString($input);
$2 = PyString_Size($input);
%#endif
}
extern int count(char *bytes, int len, char c);
@ -56,9 +78,15 @@ extern int count(char *bytes, int len, char c);
so that we don't violate it's mutability */
%typemap(in) (char *str, int len) {
%#if PY_VERSION_HEX >= 0x03000000
$2 = PyUnicode_GetSize($input);
$1 = (char *) malloc($2+1);
memmove($1,PyUnicode_AsString($input),$2);
%#else
$2 = PyString_Size($input);
$1 = (char *) malloc($2+1);
memmove($1,PyString_AsString($input),$2);
%#endif
}
/* Return the mutated string as a new object. The t_output_helper
@ -67,7 +95,11 @@ extern int count(char *bytes, int len, char c);
%typemap(argout) (char *str, int len) {
PyObject *o;
%#if PY_VERSION_HEX >= 0x03000000
o = PyUnicode_FromStringAndSize($1,$2);
%#else
o = PyString_FromStringAndSize($1,$2);
%#endif
$result = t_output_helper($result,o);
free($1);
}

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -0,0 +1,37 @@
ifeq (,$(PY3))
PYSCRIPT = runme.py
else
PYSCRIPT = runme3.py
endif
default : all
include ../../Makefile
SUBDIRS := constructor func hierarchy operator hierarchy_operator
.PHONY : all $(SUBDIRS)
all : $(SUBDIRS:%=%-build)
@for subdir in $(SUBDIRS); do \
echo Running $$subdir test... ; \
echo -------------------------------------------------------------------------------- ; \
cd $$subdir; \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT); \
cd ..; \
done
$(SUBDIRS) :
$(MAKE) -C $@
@echo Running $$subdir test...
@echo --------------------------------------------------------------------------------
cd $@ && env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT)
%-build :
$(MAKE) -C $*
%-clean :
$(MAKE) -s -C $* clean
clean : $(SUBDIRS:%=%-clean)
rm -f *.pyc

View file

@ -0,0 +1,21 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
TARGET = Simple
INTERFACE = Simple.i
all :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
static :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean :
$(MAKE) -f $(TOP)/Makefile python_clean
rm -f $(TARGET).py

View file

@ -0,0 +1,8 @@
%inline %{
class MyClass {
public:
MyClass () {}
~MyClass () {}
void func () {}
};
%}

View file

@ -0,0 +1,11 @@
#!/usr/bin/env
import sys
sys.path.append('..')
import harness
def proc (mod) :
for i in range(1000000) :
x = mod.MyClass()
harness.run(proc)

View file

@ -0,0 +1,23 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
TARGET = Simple
INTERFACE = Simple.i
default : all
all :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
static :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean :
$(MAKE) -f $(TOP)/Makefile python_clean
rm -f $(TARGET).py

View file

@ -0,0 +1,8 @@
%inline %{
class MyClass {
public:
MyClass () {}
~MyClass () {}
void func () {}
};
%}

View file

@ -0,0 +1,12 @@
#!/usr/bin/env
import sys
sys.path.append('..')
import harness
def proc (mod) :
x = mod.MyClass()
for i in range(10000000) :
x.func()
harness.run(proc)

View file

@ -0,0 +1,30 @@
#!/usr/bin/env
import sys
import time
import imp
from subprocess import *
def run (proc) :
try :
mod = imp.find_module(sys.argv[1])
mod = imp.load_module(sys.argv[1], *mod)
t1 = time.clock()
proc(mod)
t2 = time.clock()
print "%s took %f seconds" % (mod.__name__, t2 - t1)
except IndexError :
proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
(stdout, stderr) = proc.communicate()
print stdout
proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
(stdout, stderr) = proc.communicate()
print stdout
proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
(stdout, stderr) = proc.communicate()
print stdout

View file

@ -0,0 +1,23 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
TARGET = Simple
INTERFACE = Simple.i
default : all
all :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
static :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean :
$(MAKE) -f $(TOP)/Makefile python_clean
rm -f $(TARGET).py

View file

@ -0,0 +1,52 @@
%inline %{
class A {
public:
A () {}
~A () {}
void func () {}
};
class B : public A {
public:
B () {}
~B () {}
};
class C : public B {
public:
C () {}
~C () {}
};
class D : public C {
public:
D () {}
~D () {}
};
class E : public D {
public:
E () {}
~E () {}
};
class F : public E {
public:
F () {}
~F () {}
};
class G : public F {
public:
G () {}
~G () {}
};
class H : public G {
public:
H () {}
~H () {}
};
%}

View file

@ -0,0 +1,12 @@
#!/usr/bin/env
import sys
sys.path.append('..')
import harness
def proc (mod) :
x = mod.H()
for i in range(10000000) :
x.func()
harness.run(proc)

View file

@ -0,0 +1,23 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
TARGET = Simple
INTERFACE = Simple.i
default : all
all :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
static :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean :
$(MAKE) -f $(TOP)/Makefile python_clean
rm -f $(TARGET).py

View file

@ -0,0 +1,53 @@
%inline %{
class A {
public:
A () {}
~A () {}
void func () {}
A& operator+= (int i) { return *this; }
};
class B : public A {
public:
B () {}
~B () {}
};
class C : public B {
public:
C () {}
~C () {}
};
class D : public C {
public:
D () {}
~D () {}
};
class E : public D {
public:
E () {}
~E () {}
};
class F : public E {
public:
F () {}
~F () {}
};
class G : public F {
public:
G () {}
~G () {}
};
class H : public G {
public:
H () {}
~H () {}
};
%}

View file

@ -0,0 +1,12 @@
#!/usr/bin/env
import sys
sys.path.append('..')
import harness
def proc (mod) :
x = mod.H()
for i in range(10000000) :
x += i
harness.run(proc)

View file

@ -0,0 +1,23 @@
TOP = ../../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
TARGET = Simple
INTERFACE = Simple.i
default : all
all :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
static :
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean :
$(MAKE) -f $(TOP)/Makefile python_clean
rm -f $(TARGET).py

View file

@ -0,0 +1,8 @@
%inline %{
class MyClass {
public:
MyClass () {}
~MyClass () {}
MyClass& operator+ (int i) { return *this; }
};
%}

View file

@ -0,0 +1,12 @@
#!/usr/bin/env
import sys
sys.path.append('..')
import harness
def proc (mod) :
x = mod.MyClass()
for i in range(10000000) :
x = x + i
harness.run(proc)

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -144,7 +144,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
<li> <a href="example.i">example.i</a> (SWIG interface)
<li> <a href="example.py">example.py</a> (Python Script)
</ul>

View file

@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -python $(InputPath)
..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
..\..\..\swig -python $(InputPath)
..\..\..\swig.exe -python $(InputPath)
# End Custom Build

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -22,3 +22,4 @@ run:
python runme.py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -23,5 +23,5 @@ namespace std {
%template(halfi) half_map<std::string,int>;
%template() std::pair<swig::PyObject_ptr, swig::PyObject_ptr>;
%template(pymap) std::map<swig::PyObject_ptr, swig::PyObject_ptr>;
%template() std::pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
%template(pymap) std::map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -22,3 +22,4 @@ clean::
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
$(MAKE) -f $(TOP)/Makefile python_run

View file

@ -1,21 +0,0 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
CXXSRCS =
TARGET = example
INTERFACE = example.i
LIBS = -lm
SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
static::
$(MAKE) -f $(TOP)/Makefile $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
clean::
$(MAKE) -f $(TOP)/Makefile python_clean
rm -f $(TARGET).py
check: all

View file

@ -1,25 +0,0 @@
This directory contains a simple example to test weave support for
SWIG wrapped objects.
The weave package provides tools for including C/C++ code in Python
code. This offers both another level of optimization to those who need
it, and an easy way to modify and extend any supported extension
libraries. Weave automatically builds an extension module from the
given C/C++ code and runs that. This can result in very significant
speedups (of upto 500x) depending on the problem. Weave also supports
inlining SWIG-1.3.x wrapped objects.
The example in this directory requires that weave be installed. Weave
is distributed as part of SciPy (http://www.scipy.org). More
information on Weave may be had from here:
http://www.scipy.org/documentation/weave
As of November 22, 2004, this example only works with weave from CVS.
If there is a more recent release of SciPy after this date, it should
work fine.
Also, you need to replace the weave file swigptr2.py by the one
provided here.

View file

@ -1,18 +0,0 @@
#ifndef _EXAMPLE_H
#define _EXAMPLE_H
class Foo {
public:
int x;
};
class Bar {
public:
int y;
};
class FooBar : public Foo, public Bar {
public:
int z;
};
#endif

View file

@ -1,15 +0,0 @@
%module(directors="1") example
%{
#include "example.h"
%}
%include "std_vector.i"
%director Foo;
%director Bar;
%include "example.h"
%template(VectorBar) std::vector<Bar*>;
%template(VectorFoo) std::vector<Foo*>;

View file

@ -1,72 +0,0 @@
"""
Test weave support for SWIG wrapped objects.
This example requires that one has weave installed. Weave is
distributed as part of SciPy (http://www.scipy.org). More information
on Weave may be had from here:
http://www.scipy.org/documentation/weave
As of November 22, 2004, this only works with weave from CVS. If
there is a more recent release of SciPy after this date, it should
work fine.
"""
import example
import weave
from weave import converters
from weave import swig2_spec
# Weave does not support swig2 by default (yet). So add this to the
# list of default converters to test.
converters.default.insert(0, swig2_spec.swig2_converter())
def test():
""" A simple test case for weave."""
a = example.Foo()
a.x = 1
b = example.Bar()
b.y = 2
c = example.FooBar()
c.x = 1
c.y = 2
c.z = 3
v = example.VectorBar()
v.append(b)
v.append(c)
d = v[0]
e = v[1]
v = example.VectorFoo()
v.append(a)
v.append(c)
f = v[0]
g = v[1]
code = """
std::cout << a->x << std::endl;
assert(a->x == 1);
std::cout << b->y << std::endl;
assert(b->y == 2);
std::cout << c->x << std::endl;
std::cout << c->y << std::endl;
std::cout << c->z << std::endl;
assert(c->x == 1);
assert(c->y == 2);
assert(c->z == 3);
std::cout << d->y << std::endl;
assert(d->y == 2);
std::cout << e->y << std::endl;
assert(e->y == 2);
std::cout << f->x << std::endl;
assert(f->x == 1);
std::cout << g->x << std::endl;
assert(g->x == 1);
"""
weave.inline(code, ['a', 'b', 'c', 'd', 'e', 'f', 'g'],
include_dirs=['.'],
headers=['"example.h"'],
verbose=2)
if __name__ == "__main__":
test()

File diff suppressed because it is too large Load diff