Merge remote-tracking branch 'origin/master' into gsoc2012-scilab
Conflicts: .gitignore .travis.yml configure.ac
This commit is contained in:
commit
adc4b788df
352 changed files with 8897 additions and 2812 deletions
|
|
@ -130,6 +130,7 @@ OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@)
|
|||
|
||||
distclean:
|
||||
rm -f Makefile
|
||||
rm -f d/example.mk
|
||||
rm -f xml/Makefile
|
||||
|
||||
##################################################################
|
||||
|
|
@ -595,7 +596,7 @@ java_cpp: $(SRCDIR_SRCS)
|
|||
# ----------------------------------------------------------------
|
||||
|
||||
java_compile: $(SRCDIR_SRCS)
|
||||
$(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(addprefix $(SRCDIR),$(JAVASRCS))
|
||||
$(COMPILETOOL) $(JAVAC) $(addprefix $(SRCDIR),$(JAVASRCS))
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Run java example
|
||||
|
|
@ -632,9 +633,6 @@ java_clean:
|
|||
ROOT_DIR = @ROOT_DIR@
|
||||
JSINCLUDES = @JSCOREINC@ @JSV8INC@
|
||||
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
|
||||
JSSO =@JSSO@
|
||||
JSLDSHARED = @JSLDSHARED@
|
||||
JSCXXSHARED = @JSCXXSHARED@
|
||||
NODEJS = @NODEJS@
|
||||
NODEGYP = @NODEGYP@
|
||||
|
||||
|
|
@ -730,7 +728,7 @@ javascript_clean:
|
|||
rm -rf build
|
||||
rm -f *_wrap* $(RUNME)
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
|
||||
rm -f *.@OBJEXT@ *@SO@
|
||||
rm -f binding.gyp example-gypcopy.cxx
|
||||
cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean
|
||||
|
||||
|
|
@ -738,10 +736,10 @@ javascript_clean:
|
|||
##### ANDROID ######
|
||||
##################################################################
|
||||
|
||||
ANDROID = android
|
||||
ANDROID_NDK_BUILD = ndk-build
|
||||
ANDROID_ADB = adb
|
||||
ANT = ant
|
||||
ANDROID = @ANDROID@
|
||||
ANDROID_NDK_BUILD = @NDKBUILD@
|
||||
ANDROID_ADB = @ADB@
|
||||
ANT = @ANT@
|
||||
TARGETID = 1
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
|
@ -784,7 +782,7 @@ android_version:
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
android_clean:
|
||||
test -n "$(SRCDIR)" && cd $(SRCDIR) ; ant -q -logfile /dev/null clean
|
||||
test -n "$(SRCDIR)" && cd $(SRCDIR) ; $(ANT) -q -logfile /dev/null clean
|
||||
rm -f $(INTERFACEDIR)$(TARGET)_wrap.*
|
||||
rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java`
|
||||
rm -rf obj
|
||||
|
|
@ -1095,7 +1093,7 @@ ruby_version:
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
ruby_clean:
|
||||
rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm
|
||||
rm -f *_wrap* *~ .~* myruby@EXEEXT@
|
||||
rm -f core @EXTRA_CLEAN@
|
||||
rm -f *.@OBJEXT@ *$(RUBY_SO)
|
||||
|
||||
|
|
@ -1396,6 +1394,7 @@ csharp_run:
|
|||
# Version check below also works with MS csc.exe which does not understand --version
|
||||
csharp_version:
|
||||
$(CSHARPCOMPILER) --version | head -n 1
|
||||
if test -n "$(CSHARPCILINTERPRETER)" ; then "$(CSHARPCILINTERPRETER)" --version ; fi
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Cleaning the CSharp examples
|
||||
|
|
@ -1924,7 +1923,7 @@ d_compile: $(SRCDIR_SRCS)
|
|||
# -----------------------------------------------------------------
|
||||
|
||||
d_run:
|
||||
$(RUNTOOL) $(D_RUNME) $(RUNPIPE)
|
||||
env LD_LIBRARY_PATH=$$PWD $(RUNTOOL) $(D_RUNME) $(RUNPIPE)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
# Version display
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ public:
|
|||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
}
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
|
|
@ -19,7 +19,7 @@ class Circle : public Shape {
|
|||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
Circle(double r) : radius(r) { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
|
@ -28,7 +28,7 @@ class Square : public Shape {
|
|||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { };
|
||||
Square(double w) : width(w) { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
@ -40,7 +40,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ example_wrap.c
|
||||
EXTRA_LDFLAGS = example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
/* ----------------------------------------------------------------------------
|
||||
* This file was automatically generated by SWIG (http://www.swig.org).
|
||||
* Version 1.3.41
|
||||
*
|
||||
* Do not make changes to this file unless you know what you are doing--modify
|
||||
* the SWIG interface file instead.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
module example;
|
||||
|
||||
static import example_wrap;
|
||||
|
||||
static import tango.stdc.stringz;
|
||||
|
||||
public const int ICONST = 42;
|
||||
public const double FCONST = 2.1828;
|
||||
public const char CCONST = 'x';
|
||||
public const char CCONST2 = '\n';
|
||||
public const char[] SCONST = "Hello World";
|
||||
public const char[] SCONST2 = "\"Hello World\"";
|
||||
public const double EXPR = 42+3*(2.1828);
|
||||
public const int iconst = 37;
|
||||
public const double fconst = 3.14;
|
||||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
59
Examples/d/example.mk.in
Normal file
59
Examples/d/example.mk.in
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#
|
||||
# Common Makefile code for building D examples.
|
||||
#
|
||||
# We actually need to configure this to gain access to the default D version to
|
||||
# use when D_VERSION is not set. Using Examples/Makefile.in is not enough, as
|
||||
# the location of the source files (d1/ or d2/) depends on it. The alternative
|
||||
# would be to add the functionality specific to Examples/d (as opposed to the
|
||||
# test suite) directly to Examples/Makefile.in.
|
||||
#
|
||||
# This file is supposed to be included from a Makefile in the subdirectory
|
||||
# corresponding to a specific example.
|
||||
#
|
||||
|
||||
ifeq (,$(D_VERSION))
|
||||
D_VERSION = @DDEFAULTVERSION@
|
||||
endif
|
||||
|
||||
ifeq (1,$(D_VERSION))
|
||||
VERSION_DIR = d1/
|
||||
else
|
||||
VERSION_DIR = d2/
|
||||
endif
|
||||
|
||||
EXAMPLES_TOP = ../../..
|
||||
SWIG_TOP = ../../../..
|
||||
SWIG = $(SWIG_TOP)/preinst-swig
|
||||
EXTRA_CFLAGS =
|
||||
EXTRA_CXXFLAGS =
|
||||
EXTRA_LDFLAGS =
|
||||
TARGET = example_wrap
|
||||
SWIGOPT = -outcurrentdir
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
ifeq (,$(SRCDIR))
|
||||
DSRCS = *.d
|
||||
else
|
||||
DSRCS = *.d $(addprefix ../$(SRCDIR)$(VERSION_DIR),runme.d)
|
||||
endif
|
||||
|
||||
|
||||
check: build
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
mkdir -p $(VERSION_DIR)
|
||||
if [ -f $(SRCDIR)example.cxx ]; then \
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CXXFLAGS='$(EXTRA_CXXFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' CXXSRCS='example.cxx' d_cpp; \
|
||||
elif [ -f $(SRCDIR)example.c ]; then \
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='example.c' d; \
|
||||
else \
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
|
||||
fi
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
if [ -d $(VERSION_DIR) ]; then \
|
||||
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \
|
||||
fi
|
||||
test -f $(VERSION_DIR)runme.d || rm -rf $(VERSION_DIR) # Only delete dir if out of source
|
||||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -1,27 +1 @@
|
|||
ifeq (2,$(D_VERSION))
|
||||
WORKING_DIR = d2/
|
||||
else
|
||||
WORKING_DIR = d1/
|
||||
endif
|
||||
|
||||
TOP = ../../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
|
||||
EXTRA_LDFLAGS = example.o example_wrap.o
|
||||
TARGET = example_wrap
|
||||
SWIGOPT =
|
||||
DSRCS = *.d
|
||||
DFLAGS = -ofrunme
|
||||
|
||||
check: build
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_run
|
||||
|
||||
build:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
|
||||
|
||||
clean:
|
||||
cd $(WORKING_DIR); \
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' d_clean
|
||||
include ../example.mk
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
@ -40,7 +40,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,18 @@ else
|
|||
JSENGINE=node
|
||||
endif
|
||||
|
||||
ifneq (, $(V8_VERSION))
|
||||
JSV8_VERSION=$(V8_VERSION)
|
||||
else
|
||||
JSV8_VERSION=0x031110
|
||||
endif
|
||||
|
||||
EXAMPLES_TOP=../..
|
||||
SWIG_TOP=../../..
|
||||
SWIG = $(SWIG_TOP)/preinst-swig
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
SWIGOPT=-$(JSENGINE)
|
||||
SWIGOPT=-$(JSENGINE) -DV8_VERSION=$(JSV8_VERSION)
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(EXAMPLES_TOP)/Makefile SRCDIR='$(SRCDIR)' JSENGINE='$(JSENGINE)' TARGET='$(TARGET)' javascript_run
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
|
|||
|
|
@ -9,20 +9,20 @@ console.log(example.maxdouble(3.14,2.18));
|
|||
iv = new example.vecint(100);
|
||||
dv = new example.vecdouble(1000);
|
||||
|
||||
for(i=0;i<=100;i++)
|
||||
for(i=0;i<100;i++)
|
||||
iv.setitem(i,2*i);
|
||||
|
||||
for(i=0;i<=1000;i++)
|
||||
for(i=0;i<1000;i++)
|
||||
dv.setitem(i, 1.0/(i+1));
|
||||
|
||||
sum = 0;
|
||||
for(i=0;i<=100;i++)
|
||||
for(i=0;i<100;i++)
|
||||
sum = sum + iv.getitem(i);
|
||||
|
||||
console.log(sum);
|
||||
|
||||
sum = 0.0;
|
||||
for(i=0;i<=1000;i++)
|
||||
for(i=0;i<1000;i++)
|
||||
sum = sum + dv.getitem(i);
|
||||
console.log(sum);
|
||||
|
||||
|
|
|
|||
|
|
@ -3,25 +3,25 @@ print "[lua] This is runme.lua"
|
|||
-- we do not need to load the library, as it was already in the interpreter
|
||||
-- but let's check anyway
|
||||
assert(type(example)=='table',"Don't appear to have loaded the example module")
|
||||
|
||||
-- note: we will copy the functions from example table into global
|
||||
-- this will help us later
|
||||
for k,v in pairs(example) do _G[k]=v end
|
||||
|
||||
-- our add function
|
||||
-- note: we will copy the functions from example table into global
|
||||
-- this will help us later
|
||||
for k,v in pairs(example) do _G[k]=v end
|
||||
|
||||
-- our add function
|
||||
-- we will be calling this from C
|
||||
function add(a,b)
|
||||
print("[lua] this is function add(",a,b,")")
|
||||
c=a+b
|
||||
print("[lua] returning",c)
|
||||
return c
|
||||
function add(a,b)
|
||||
print("[lua] this is function add(",a,b,")")
|
||||
c=a+b
|
||||
print("[lua] returning",c)
|
||||
return c
|
||||
end
|
||||
|
||||
function append(a,b)
|
||||
print("[lua] this is function append(",a,b,")")
|
||||
c=a..b
|
||||
print("[lua] returning",c)
|
||||
return c
|
||||
function append(a,b)
|
||||
print("[lua] this is function append(",a,b,")")
|
||||
c=a..b
|
||||
print("[lua] returning",c)
|
||||
return c
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
class Base {
|
||||
public:
|
||||
Base() { };
|
||||
virtual ~Base() { };
|
||||
Base() { }
|
||||
virtual ~Base() { }
|
||||
virtual const char * A() const {
|
||||
return "Base::A";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public:
|
|||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
}
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
|
|
@ -20,7 +20,7 @@ class Circle : public Shape {
|
|||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
Circle(double r) : radius(r) { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
|
@ -29,7 +29,7 @@ class Square : public Shape {
|
|||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { };
|
||||
Square(double w) : width(w) { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ struct Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
Vector operator+(const Vector &b) const;
|
||||
char *print();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module(directors="1") swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
/* A few preprocessor macros */
|
||||
|
||||
#define ICONST 42
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%contract gcd(int x, int y) {
|
||||
require:
|
||||
x >= 0;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module(directors="1") swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%inline %{
|
||||
// From B. Strousjoup, "The C++ Programming Language, Third Edition", p. 514
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* File : example.i */
|
||||
/* module name given on cmdline */
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
#pragma SWIG nowarn=SWIGWARN_IGNORE_OPERATOR_EQ
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
extern void add(int *, int *, int *);
|
||||
extern void sub(int *, int *, int *);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%inline %{
|
||||
extern int gcd(int x, int y);
|
||||
extern double Foo;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
/* File : example.i */
|
||||
%module swigexample
|
||||
|
||||
%feature("autodoc", 1);
|
||||
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
class Base {
|
||||
public:
|
||||
Base() { };
|
||||
virtual ~Base() { };
|
||||
Base() { }
|
||||
virtual ~Base() { }
|
||||
virtual void A() {
|
||||
printf("I'm Base::A\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
@ -40,7 +40,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public:
|
|||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
}
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
|
|
@ -22,8 +22,8 @@ class Circle : public Shape {
|
|||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
~Circle() { };
|
||||
Circle(double r) : radius(r) { }
|
||||
~Circle() { }
|
||||
void set_radius( double r );
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
|
|
@ -33,7 +33,7 @@ class Square : public Shape {
|
|||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { };
|
||||
Square(double w) : width(w) { }
|
||||
~Square() { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
|
|
@ -44,7 +44,7 @@ private:
|
|||
typedef std::vector<Shape*>::iterator iterator;
|
||||
std::vector<Shape*> shapes;
|
||||
public:
|
||||
ShapeContainer() : shapes() {};
|
||||
ShapeContainer() : shapes() {}
|
||||
~ShapeContainer();
|
||||
void addShape( Shape *s );
|
||||
};
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ public:
|
|||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
}
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area(void) = 0;
|
||||
|
|
@ -22,8 +22,8 @@ class Circle : public Shape {
|
|||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
~Circle() { };
|
||||
Circle(double r) : radius(r) { }
|
||||
~Circle() { }
|
||||
void set_radius( double r );
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
|
|
@ -33,7 +33,7 @@ class Square : public Shape {
|
|||
private:
|
||||
double width;
|
||||
public:
|
||||
Square(double w) : width(w) { };
|
||||
Square(double w) : width(w) { }
|
||||
~Square() { }
|
||||
virtual double area(void);
|
||||
virtual double perimeter(void);
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *as_string();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
/* File : example.i */
|
||||
|
||||
/* This example has nothing to do with references but the name is used by all
|
||||
* the other languages so it's hard to rename to something more meaningful.
|
||||
*
|
||||
* Mostly it shows how to use %extend.
|
||||
*/
|
||||
/* This file has a few "typical" uses of C++ references. */
|
||||
|
||||
%module example
|
||||
|
||||
|
|
@ -33,8 +29,8 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
printf("VectorArray extended get: %p %d\n", (void *)$self, index);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ simple
|
|||
smartptr
|
||||
std_vector
|
||||
std_map
|
||||
swigrun
|
||||
template
|
||||
varargs
|
||||
variables
|
||||
|
|
|
|||
|
|
@ -10,3 +10,12 @@
|
|||
/* Let's just grab the original header file here */
|
||||
%include "example.h"
|
||||
|
||||
%inline %{
|
||||
// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,10 +20,17 @@ try:
|
|||
except RuntimeError,e:
|
||||
print e.args[0]
|
||||
|
||||
try:
|
||||
t.hosed()
|
||||
except example.Exc,e:
|
||||
print e.code, e.msg
|
||||
if not example.is_python_builtin():
|
||||
try:
|
||||
t.hosed()
|
||||
except example.Exc,e:
|
||||
print e.code, e.msg
|
||||
else:
|
||||
try:
|
||||
t.hosed()
|
||||
except BaseException,e:
|
||||
# Throwing builtin classes as exceptions not supported (-builtin option)
|
||||
print e
|
||||
|
||||
for i in range(1,4):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -109,6 +109,12 @@
|
|||
%template(doubleQueue) Queue<double>;
|
||||
|
||||
|
||||
|
||||
|
||||
%inline %{
|
||||
// The -builtin SWIG option results in SWIGPYTHON_BUILTIN being defined
|
||||
#ifdef SWIGPYTHON_BUILTIN
|
||||
bool is_python_builtin() { return true; }
|
||||
#else
|
||||
bool is_python_builtin() { return false; }
|
||||
#endif
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
# file: runme.py
|
||||
import example
|
||||
|
||||
if example.is_python_builtin():
|
||||
print "Skipping example: -builtin option does not support %exceptionclass"
|
||||
exit(0)
|
||||
|
||||
q = example.intQueue(10)
|
||||
|
||||
print "Inserting items into intQueue"
|
||||
|
||||
print type(example.FullError)
|
||||
|
||||
try:
|
||||
for i in range(0,100):
|
||||
q.enqueue(i)
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
class Base {
|
||||
public:
|
||||
Base() { };
|
||||
virtual ~Base() { };
|
||||
Base() { }
|
||||
virtual ~Base() { }
|
||||
virtual void A() {
|
||||
printf("I'm Base::A\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,8 @@ import_packages_subdirs = \
|
|||
from_init2 \
|
||||
from_init3 \
|
||||
relativeimport1 \
|
||||
relativeimport1
|
||||
relativeimport2 \
|
||||
relativeimport3
|
||||
|
||||
check: build
|
||||
if test "x$(SRCDIR)" != x; then \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
# Test import of modules content from within __init__.py
|
||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
# Test import of modules content from within __init__.py
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
# Test import of modules content from within __init__.py
|
||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
# Test import of modules content from within __init__.py
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
# Test import of modules content from within __init__.py
|
||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
# Test import of modules content from within __init__.py
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2
|
||||
print " Finished importing py2.pkg2"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
# Test import of modules content from within __init__.py
|
||||
print "Testing %module(package=...) with -relativeimport"
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
# Test import of modules content from within __init__.py
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) with -relativeimport"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
# Test import of modules content from within __init__.py
|
||||
print "Testing %module(package=...) + python 'import' in __init__.py"
|
||||
import sys
|
||||
import os.path
|
||||
|
||||
# Test import of modules content from within __init__.py
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
|
|
|
|||
|
|
@ -1,9 +0,0 @@
|
|||
# Test import of modules content from within __init__.py
|
||||
print("Testing %module(package=...) + python 'import' in __init__.py")
|
||||
import sys
|
||||
if sys.version_info < (3, 0):
|
||||
import py2.pkg2.bar
|
||||
print(" Finished importing py2.pkg2.bar")
|
||||
else:
|
||||
import py3.pkg2.bar
|
||||
print(" Finished importing py3.pkg2.bar")
|
||||
25
Examples/python/import_packages/relativeimport3/Makefile
Normal file
25
Examples/python/import_packages/relativeimport3/Makefile
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
TOP = ../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
PY3 =
|
||||
|
||||
ifeq (,$(PY3))
|
||||
PKG1DIR = "py2"
|
||||
else
|
||||
PKG1DIR = "py3"
|
||||
endif
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
|
||||
|
||||
build:
|
||||
cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' build
|
||||
|
||||
static:
|
||||
cd $(PKG1DIR) && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -relativeimport' LIBS='$(LIBS)' static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
cd py2 && $(MAKE) clean
|
||||
cd py3 && $(MAKE) clean
|
||||
22
Examples/python/import_packages/relativeimport3/README
Normal file
22
Examples/python/import_packages/relativeimport3/README
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
This example tests the %import directive and -relativeimport swig option.
|
||||
|
||||
Use 'python runme.py' to run a test.
|
||||
|
||||
Overview:
|
||||
---------
|
||||
|
||||
The example defines 2 different extension modules--each wrapping a separate C++
|
||||
class.
|
||||
|
||||
pyX/pkg2/pkg3/foo.i - Pkg3_Foo class
|
||||
pyX/pkg2/bar.i - Pkg2_Bar class derived from Pkg3_Foo
|
||||
|
||||
The code is processed by swig with -relativeimport flag. The runtime test
|
||||
imports pyX.pkg2.bar module.
|
||||
|
||||
If everything works well, the module pyX.pkg2.bar shall load properly.
|
||||
|
||||
Unix:
|
||||
-----
|
||||
- Run make
|
||||
- Run the test as described above
|
||||
14
Examples/python/import_packages/relativeimport3/py2/Makefile
Normal file
14
Examples/python/import_packages/relativeimport3/py2/Makefile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
TOP = ../../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
|
||||
build:
|
||||
cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
|
||||
|
||||
static:
|
||||
cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
cd pkg2 && $(MAKE) clean
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
TOP = ../../../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
|
||||
cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
|
||||
cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
|
||||
cd pkg3 && $(MAKE) clean
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef PY2_PKG2_BAR_HPP
|
||||
#define PY2_PKG2_BAR_HPP
|
||||
#include "../../py2/pkg2/pkg3/foo.hpp"
|
||||
struct Pkg2_Bar : Pkg3_Foo {};
|
||||
#endif /* PY2_PKG2_BAR_HPP */
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
%module(package="py2.pkg2") bar
|
||||
%{
|
||||
#include "../../py2/pkg2/bar.hpp"
|
||||
%}
|
||||
%import (module="foo", package="py2.pkg2.pkg3") "../../py2/pkg2/pkg3/foo.hpp"
|
||||
%include "../../py2/pkg2/bar.hpp"
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
TOP = ../../../../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef PY2_PKG2_PKG3_FOO_HPP
|
||||
#define PY2_PKG2_PKG3_FOO_HPP
|
||||
struct Pkg3_Foo {};
|
||||
#endif /* PY2_PKG2_PKG3_FOO_HPP */
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
%module(package="py2.pkg2.pkg3") foo
|
||||
%{
|
||||
#include "../../../py2/pkg2/pkg3/foo.hpp"
|
||||
%}
|
||||
%include "../../../py2/pkg2/pkg3/foo.hpp"
|
||||
14
Examples/python/import_packages/relativeimport3/py3/Makefile
Normal file
14
Examples/python/import_packages/relativeimport3/py3/Makefile
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
TOP = ../../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
|
||||
build:
|
||||
cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
|
||||
|
||||
static:
|
||||
cd pkg2 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_clean
|
||||
cd pkg2 && $(MAKE) clean
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
TOP = ../../../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
|
||||
cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' build
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='bar' INTERFACE='bar.i' python_cpp
|
||||
cd pkg3 && $(MAKE) SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='bar' python_clean
|
||||
cd pkg3 && $(MAKE) clean
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
#ifndef PY3_PKG2_BAR_HPP
|
||||
#define PY3_PKG2_BAR_HPP
|
||||
#include "../../py3/pkg2/pkg3/foo.hpp"
|
||||
struct Pkg2_Bar : Pkg3_Foo {};
|
||||
#endif /* PY3_PKG2_BAR_HPP */
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
%module(package="py3.pkg2") bar
|
||||
%{
|
||||
#include "../../py3/pkg2/bar.hpp"
|
||||
%}
|
||||
%import (module="foo", package="py3.pkg2.pkg3") "../../py3/pkg2/pkg3/foo.hpp"
|
||||
%include "../../py3/pkg2/bar.hpp"
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
TOP = ../../../../../..
|
||||
SWIG = $(realpath $(TOP)/../preinst-swig)
|
||||
SWIGOPT =
|
||||
LIBS =
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \
|
||||
LIBS='$(LIBS)' TARGET='foo' INTERFACE='foo.i' python_cpp_static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='foo' python_clean
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#ifndef PY3_PKG2_PKG3_FOO_HPP
|
||||
#define PY3_PKG2_PKG3_FOO_HPP
|
||||
struct Pkg3_Foo {};
|
||||
#endif /* PY3_PKG2_PKG3_FOO_HPP */
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
%module(package="py3.pkg2.pkg3") foo
|
||||
%{
|
||||
#include "../../../py3/pkg2/pkg3/foo.hpp"
|
||||
%}
|
||||
%include "../../../py3/pkg2/pkg3/foo.hpp"
|
||||
13
Examples/python/import_packages/relativeimport3/runme.py
Normal file
13
Examples/python/import_packages/relativeimport3/runme.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
import sys
|
||||
import os.path
|
||||
|
||||
# Test import of modules content from within __init__.py
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) with -relativeimport"
|
||||
|
||||
if sys.version_info < (3,0):
|
||||
import py2.pkg2.bar
|
||||
print " Finished importing py2.pkg2.bar"
|
||||
else:
|
||||
import py3.pkg2.bar
|
||||
print " Finished importing py3.pkg2.bar"
|
||||
|
|
@ -1,5 +1,9 @@
|
|||
import os.path
|
||||
|
||||
# Test import of same modules from different packages
|
||||
print "Testing %module(package=...) + %import + same modules in different packages"
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
import pkg2.foo
|
||||
print " Finished importing pkg2.foo"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,8 @@
|
|||
import os.path
|
||||
|
||||
testname = os.path.basename(os.path.dirname(os.path.abspath(__file__)))
|
||||
print "Testing " + testname + " - %module(package=...) + python 'import' in __init__.py"
|
||||
|
||||
import pkg1.pkg2.foo
|
||||
print " Finished importing pkg1.pkg2.foo"
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
template<class T> class Base {
|
||||
public:
|
||||
Base() { };
|
||||
virtual ~Base() { };
|
||||
Base() { }
|
||||
virtual ~Base() { }
|
||||
virtual void A() {
|
||||
printf("I'm Base::A\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
@ -42,7 +42,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ public:
|
|||
}
|
||||
virtual ~Shape() {
|
||||
nshapes--;
|
||||
};
|
||||
}
|
||||
double x, y;
|
||||
void move(double dx, double dy);
|
||||
virtual double area() = 0;
|
||||
|
|
@ -19,7 +19,7 @@ class Circle : public Shape {
|
|||
private:
|
||||
double radius;
|
||||
public:
|
||||
Circle(double r) : radius(r) { };
|
||||
Circle(double r) : radius(r) { }
|
||||
virtual double area();
|
||||
virtual double perimeter();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
CXXSRCS = example.cxx
|
||||
TARGET = example
|
||||
INTERFACE = example.i
|
||||
LIBS = -lm
|
||||
SWIGOPT =
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' python_run
|
||||
|
||||
build:
|
||||
$(SWIG) -python -external-runtime
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python_cpp
|
||||
|
||||
static:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' $(SWIGLIB) CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
|
||||
SWIGOPT='$(SWIGOPT)' TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' python_clean
|
||||
rm -f swigpyrun.h
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
/* File : example.cxx */
|
||||
|
||||
#include <Python.h>
|
||||
#include "swigpyrun.h"
|
||||
#include "example.h"
|
||||
|
||||
|
||||
Manager* convert_to_Manager(PyObject *py_obj)
|
||||
{
|
||||
Manager* c_ptr;
|
||||
swig_type_info *ty = SWIG_TypeQuery("Manager *");
|
||||
printf("manager ty %p \n", (void *)ty);
|
||||
if (SWIG_ConvertPtr(py_obj, (void **) &c_ptr, ty, 0) == -1) {
|
||||
c_ptr = 0;
|
||||
} else {
|
||||
Py_XINCREF(py_obj);
|
||||
}
|
||||
return c_ptr;
|
||||
}
|
||||
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/* File : example.h */
|
||||
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <cmath>
|
||||
|
||||
class Employee {
|
||||
private:
|
||||
std::string name;
|
||||
public:
|
||||
Employee(const char* n): name(n) {}
|
||||
virtual std::string getTitle() { return getPosition() + " " + getName(); }
|
||||
virtual std::string getName() { return name; }
|
||||
virtual std::string getPosition() const { return "Employee"; }
|
||||
virtual ~Employee() { printf("~Employee() @ %p\n", (void *)this); }
|
||||
};
|
||||
|
||||
|
||||
class Manager: public Employee {
|
||||
public:
|
||||
Manager(const char* n): Employee(n) {}
|
||||
virtual std::string getPosition() const { return "Manager"; }
|
||||
};
|
||||
|
||||
|
||||
class EmployeeList {
|
||||
std::vector<Employee*> list;
|
||||
public:
|
||||
EmployeeList() {
|
||||
list.push_back(new Employee("Bob"));
|
||||
list.push_back(new Employee("Jane"));
|
||||
list.push_back(new Manager("Ted"));
|
||||
}
|
||||
void addEmployee(Employee *p) {
|
||||
list.push_back(p);
|
||||
std::cout << "New employee added. Current employees are:" << std::endl;
|
||||
std::vector<Employee*>::iterator i;
|
||||
for (i=list.begin(); i!=list.end(); i++) {
|
||||
std::cout << " " << (*i)->getTitle() << std::endl;
|
||||
}
|
||||
}
|
||||
const Employee *get_item(int i) {
|
||||
return list[i];
|
||||
}
|
||||
~EmployeeList() {
|
||||
std::vector<Employee*>::iterator i;
|
||||
std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
|
||||
for (i=list.begin(); i!=list.end(); i++) {
|
||||
delete *i;
|
||||
}
|
||||
std::cout << "~EmployeeList empty." << std::endl;
|
||||
}
|
||||
};
|
||||
|
||||
Manager* convert_to_Manager(PyObject *obj);
|
||||
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module(directors="1") example
|
||||
%{
|
||||
#include "example.h"
|
||||
%}
|
||||
|
||||
%include "std_vector.i"
|
||||
%include "std_string.i"
|
||||
|
||||
/* turn on director wrapping for Manager */
|
||||
%feature("director") Employee;
|
||||
%feature("director") Manager;
|
||||
|
||||
%include "example.h"
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# file: runme.py
|
||||
|
||||
# This file illustrates the cross language polymorphism using directors.
|
||||
|
||||
import example
|
||||
|
||||
|
||||
# CEO class, which overrides Employee::getPosition().
|
||||
|
||||
class CEO(example.Manager):
|
||||
def __init__(self, name):
|
||||
example.Manager.__init__(self, name)
|
||||
def getPosition(self):
|
||||
return "CEO"
|
||||
def __del__(self):
|
||||
print "CEO.__del__(),", self.getName()
|
||||
# for proxy class extensions that are not "disowned" and
|
||||
# define a __del__ method, it is very important to call the
|
||||
# base class __del__. otherwise the c++ objects will never
|
||||
# be deleted.
|
||||
example.Manager.__del__(self)
|
||||
|
||||
|
||||
|
||||
|
||||
e = CEO("Alice")
|
||||
m = example.convert_to_Manager(e)
|
||||
print m
|
||||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public:
|
|||
VectorArray(int maxsize);
|
||||
~VectorArray();
|
||||
int size();
|
||||
|
||||
|
||||
/* This wrapper provides an alternative to the [] operator */
|
||||
%extend {
|
||||
Vector &get(int index) {
|
||||
|
|
@ -40,7 +40,3 @@ public:
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ class Vector {
|
|||
private:
|
||||
double x,y,z;
|
||||
public:
|
||||
Vector() : x(0), y(0), z(0) { };
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { };
|
||||
Vector() : x(0), y(0), z(0) { }
|
||||
Vector(double x, double y, double z) : x(x), y(y), z(z) { }
|
||||
friend Vector operator+(const Vector &a, const Vector &b);
|
||||
char *print();
|
||||
};
|
||||
|
|
@ -20,7 +20,3 @@ public:
|
|||
Vector &operator[](int);
|
||||
int size();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue