Merged from branches/szager-python-builtin

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12596 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-04-03 08:33:41 +00:00
commit bc9a32a658
53 changed files with 3413 additions and 563 deletions

View file

@ -0,0 +1,35 @@
ifeq (,$(PY3))
PYSCRIPT = runme.py
else
PYSCRIPT = runme3.py
endif
default : all
include ../../Makefile
SUBDIRS := constructor func hierarchy operator hierarchy_operator
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)