diff options
Diffstat (limited to 'Examples')
462 files changed, 4824 insertions, 2069 deletions
diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README index f536864de..93463ea30 100644 --- a/Examples/GIFPlot/Java/full/README +++ b/Examples/GIFPlot/Java/full/README @@ -1,8 +1,8 @@ This example runs the entire gifplot.h header file through SWIG without -any changes. The program 'main.java' does something a little more -interesting. After doing a make, run it using 'java main'. You'll have to go +any changes. The program 'runme.java' does something a little more +interesting. After doing a make, run it using 'java runme'. You'll have to go look at the header file to get a complete listing of the functions. -Note the differences in the main.java files between this example and the +Note the differences in the runme.java files between this example and the 'full' example. This example does not use shadow classes. diff --git a/Examples/GIFPlot/Java/full/main.java b/Examples/GIFPlot/Java/full/runme.java index 8fb65c86d..c47c1e672 100644 --- a/Examples/GIFPlot/Java/full/main.java +++ b/Examples/GIFPlot/Java/full/runme.java @@ -1,7 +1,7 @@ // Plot a 3D function import java.lang.Math; -public class main { +public class runme { static { try { diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile index e513b9b5a..8062c2700 100644 --- a/Examples/GIFPlot/Java/shadow/Makefile +++ b/Examples/GIFPlot/Java/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -10,7 +11,7 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' java javac *.java clean:: diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README index 4adbde306..b06c5a8f1 100644 --- a/Examples/GIFPlot/Java/shadow/README +++ b/Examples/GIFPlot/Java/shadow/README @@ -1,5 +1,5 @@ This example uses the file in ../../Interface/gifplot.i to build -an interface with shadow classes. After doing a make, run the program main, ie: 'java main'. +an interface with shadow classes. After doing a make, run the program runme, ie: 'java runme'. -Note the differences in the main.java files between this example and the +Note the differences in the runme.java files between this example and the 'full' example. This example uses the shadow classes. diff --git a/Examples/GIFPlot/Java/shadow/main.java b/Examples/GIFPlot/Java/shadow/runme.java index fbcf6e792..91db03898 100644 --- a/Examples/GIFPlot/Java/shadow/main.java +++ b/Examples/GIFPlot/Java/shadow/runme.java @@ -2,7 +2,7 @@ import java.lang.Math; -public class main { +public class runme { static { try { diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README index 1fb8453f0..13ff49611 100644 --- a/Examples/GIFPlot/Java/simple/README +++ b/Examples/GIFPlot/Java/simple/README @@ -1,5 +1,5 @@ This is a very minimalistic example in which just a few functions and constants from library are wrapped and used to draw some simple -shapes. After doing a make, run the java program, ie 'java main'. +shapes. After doing a make, run the java program, ie 'java runme'. diff --git a/Examples/GIFPlot/Java/simple/main.java b/Examples/GIFPlot/Java/simple/runme.java index b165a4baa..2d8d2bb48 100644 --- a/Examples/GIFPlot/Java/simple/main.java +++ b/Examples/GIFPlot/Java/simple/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c index a4eaf285e..7d79baca9 100644 --- a/Examples/GIFPlot/Lib/color.c +++ b/Examples/GIFPlot/Lib/color.c @@ -132,7 +132,10 @@ int ColorMap_write(ColorMap *cm, char *filename) { f = fopen(filename,"w"); - fwrite(cm->cmap,768,1,f); + if (fwrite(cm->cmap,768,1,f) != 1) { + fclose(f); + return -1; + } fclose(f); return 0; } diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c index a0cfca1d5..7953e5ce9 100644 --- a/Examples/GIFPlot/Lib/gif.c +++ b/Examples/GIFPlot/Lib/gif.c @@ -268,7 +268,7 @@ static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */ static count_int *htab; static unsigned short *codetab; -static GIFOutBufSize; +static int GIFOutBufSize; /* static count_int htab [HSIZE]; static unsigned short codetab [HSIZE]; */ @@ -656,7 +656,11 @@ int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) { fclose(file); return -1; } - fwrite(buffer,nbytes,1,file); + if (fwrite(buffer,nbytes,1,file) != 1) { + free(buffer); + fclose(file); + return -1; + } fclose(file); free(buffer); return 0; diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile index c5cb7aec4..c39eac52c 100644 --- a/Examples/GIFPlot/Perl5/shadow/Makefile +++ b/Examples/GIFPlot/Perl5/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot -lm INCLUDES = -I../../Include @@ -10,12 +11,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5 static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static + TARGET='myperl' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5_static clean:: $(MAKE) -f $(TOP)/Makefile perl5_clean diff --git a/Examples/GIFPlot/Php4/check.list b/Examples/GIFPlot/Php/check.list index e75ee586a..e75ee586a 100644 --- a/Examples/GIFPlot/Php4/check.list +++ b/Examples/GIFPlot/Php/check.list diff --git a/Examples/GIFPlot/Php4/full/Makefile b/Examples/GIFPlot/Php/full/Makefile index 3aa632b99..e33e7a730 100644 --- a/Examples/GIFPlot/Php4/full/Makefile +++ b/Examples/GIFPlot/Php/full/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f *.gif rm -f php_gifplot.h diff --git a/Examples/GIFPlot/Php4/full/README b/Examples/GIFPlot/Php/full/README index f8d38d9af..f8d38d9af 100644 --- a/Examples/GIFPlot/Php4/full/README +++ b/Examples/GIFPlot/Php/full/README diff --git a/Examples/GIFPlot/Php4/full/cmap b/Examples/GIFPlot/Php/full/cmap Binary files differindex a20c331a9..a20c331a9 100644 --- a/Examples/GIFPlot/Php4/full/cmap +++ b/Examples/GIFPlot/Php/full/cmap diff --git a/Examples/GIFPlot/Php4/full/gifplot.i b/Examples/GIFPlot/Php/full/gifplot.i index 5a7f5008f..5a7f5008f 100644 --- a/Examples/GIFPlot/Php4/full/gifplot.i +++ b/Examples/GIFPlot/Php/full/gifplot.i diff --git a/Examples/GIFPlot/Php4/full/runme.php4 b/Examples/GIFPlot/Php/full/runme.php index de5371ee8..de5371ee8 100644 --- a/Examples/GIFPlot/Php4/full/runme.php4 +++ b/Examples/GIFPlot/Php/full/runme.php diff --git a/Examples/GIFPlot/Php4/shadow/Makefile b/Examples/GIFPlot/Php/shadow/Makefile index 5627e53a0..df8ee30c0 100644 --- a/Examples/GIFPlot/Php4/shadow/Makefile +++ b/Examples/GIFPlot/Php/shadow/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f *.gif check: all diff --git a/Examples/GIFPlot/Php4/shadow/README b/Examples/GIFPlot/Php/shadow/README index 3e91f7d59..3e91f7d59 100644 --- a/Examples/GIFPlot/Php4/shadow/README +++ b/Examples/GIFPlot/Php/shadow/README diff --git a/Examples/GIFPlot/Php4/shadow/cmap b/Examples/GIFPlot/Php/shadow/cmap Binary files differindex a20c331a9..a20c331a9 100644 --- a/Examples/GIFPlot/Php4/shadow/cmap +++ b/Examples/GIFPlot/Php/shadow/cmap diff --git a/Examples/GIFPlot/Php4/shadow/runme.php4 b/Examples/GIFPlot/Php/shadow/runme.php index 3dffba050..3dffba050 100644 --- a/Examples/GIFPlot/Php4/shadow/runme.php4 +++ b/Examples/GIFPlot/Php/shadow/runme.php diff --git a/Examples/GIFPlot/Php4/simple/Makefile b/Examples/GIFPlot/Php/simple/Makefile index 6903bec0b..e60b641fa 100644 --- a/Examples/GIFPlot/Php4/simple/Makefile +++ b/Examples/GIFPlot/Php/simple/Makefile @@ -10,10 +10,10 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4 + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f *.gif rm -f php_simple.h diff --git a/Examples/GIFPlot/Php4/simple/README b/Examples/GIFPlot/Php/simple/README index c2c799a70..c2c799a70 100644 --- a/Examples/GIFPlot/Php4/simple/README +++ b/Examples/GIFPlot/Php/simple/README diff --git a/Examples/GIFPlot/Php4/simple/runme.php4 b/Examples/GIFPlot/Php/simple/runme.php index cf21a0927..cf21a0927 100644 --- a/Examples/GIFPlot/Php4/simple/runme.php4 +++ b/Examples/GIFPlot/Php/simple/runme.php diff --git a/Examples/GIFPlot/Php4/simple/simple.i b/Examples/GIFPlot/Php/simple/simple.i index 457bc4c09..457bc4c09 100644 --- a/Examples/GIFPlot/Php4/simple/simple.i +++ b/Examples/GIFPlot/Php/simple/simple.i diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile index ae927b72b..83a7c864b 100644 --- a/Examples/GIFPlot/Python/full/Makefile +++ b/Examples/GIFPlot/Python/full/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = -I../../Include SRCS = TARGET = gifplot @@ -23,3 +23,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile index 1f5014895..3ae9a9897 100644 --- a/Examples/GIFPlot/Python/shadow/Makefile +++ b/Examples/GIFPlot/Python/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. -SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIG = $(TOP)/../preinst-swig +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -10,12 +11,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='mypython' INTERFACE='$(INTERFACE)' python_static + TARGET='mypython' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python_static clean:: $(MAKE) -f $(TOP)/Makefile python_clean @@ -23,3 +24,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile index 5eb0344e8..9fc9a6c72 100644 --- a/Examples/GIFPlot/Python/simple/Makefile +++ b/Examples/GIFPlot/Python/simple/Makefile @@ -1,5 +1,5 @@ TOP = ../../.. -SWIG = $(TOP)/../swig +SWIG = $(TOP)/../preinst-swig SWIGOPT = SRCS = TARGET = simple @@ -23,3 +23,4 @@ clean:: rm -f *.gif check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile index ea382ea88..8cbea2a57 100644 --- a/Examples/GIFPlot/Ruby/shadow/Makefile +++ b/Examples/GIFPlot/Ruby/shadow/Makefile @@ -1,8 +1,9 @@ TOP = ../../.. SWIG = $(TOP)/../swig -SWIGOPT = -I../../Interface +SWIGOPT = -outcurrentdir SRCS = TARGET = gifplot +INTERFACEDIR = ../../Interface/ INTERFACE = gifplot.i LIBS = -L../.. -lgifplot INCLUDES = -I../../Include @@ -10,12 +11,12 @@ INCLUDES = -I../../Include all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \ - TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static + TARGET='myruby' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby_static clean:: $(MAKE) -f $(TOP)/Makefile ruby_clean diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 317d2ffff..e3f05b7b8 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -12,11 +12,11 @@ # certain packages have been installed. Set the prefixes # accordingly. # -# 2. To use this makefile, simply set SRCS, INTERFACE, INCLUDES, LIBS, -# TARGET, and do a +# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE, +# INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a # $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \ # INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \ -# TARGET='$(TARGET)' method +# INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method # # 'method' describes what is being built. #--------------------------------------------------------------- @@ -31,6 +31,8 @@ SRCS = INCLUDES = LIBS = INTERFACE = +INTERFACEDIR = +INTERFACEPATH = $(INTERFACEDIR)$(INTERFACE) SWIGOPT = SWIG = swig @@ -105,12 +107,12 @@ TCLCXXSHARED = @TCLCXXSHARED@ tclsh: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) tclsh_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET) @@ -119,13 +121,13 @@ tclsh_cpp: $(SRCS) # ----------------------------------------------------------- wish: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) wish_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \ $(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET) @@ -134,7 +136,7 @@ wish_cpp: $(SRCS) # ----------------------------------------------------------- tcl: $(SRCS) - $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) + $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) @@ -143,7 +145,7 @@ tcl: $(SRCS) # ----------------------------------------------------------- tcl_cpp: $(SRCS) - $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE) + $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) @@ -175,7 +177,7 @@ PERL5_CCFLAGS = @PERL5CCFLAGS@ # ---------------------------------------------------------------- perl5: $(SRCS) - $(SWIG) -perl5 $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH) $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -184,7 +186,7 @@ perl5: $(SRCS) # ---------------------------------------------------------------- perl5_cpp: $(SRCS) - $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -202,11 +204,11 @@ perl5_xs: $(SRCS) PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) perl5_static: $(SRCS) - $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) perl5_static_cpp: $(SRCS) - $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- @@ -223,19 +225,39 @@ perl5_clean: ################################################################## # Make sure these locate your Python installation -PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ -PYTHON_LIB = @PYLIB@ - -# Extra Python specific dynamic linking options -PYTHON_DLNK = @PYTHONDYNAMICLINKING@ +ifeq (,$(PY3)) + PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@ + PYTHON_LIB = @PYLIB@ + PYTHON = @PYTHON@ +else + PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@ + PYTHON_LIB = @PY3LIB@ + PYTHON = @PYTHON3@ +endif + +# Extra Python specific linking options +ifeq (,$(PY3)) + PYTHON_DLNK = @PYTHONDYNAMICLINKING@ + PYTHON_LINK = @PYLINK@ +else + PYTHON_DLNK = @PYTHON3DYNAMICLINKING@ + PYTHON_LINK = @PY3LINK@ +endif PYTHON_SO = @PYTHON_SO@ +# SWIG option for Python +ifeq (,$(PY3)) + SWIGPYTHON = $(SWIG) -python +else + SWIGPYTHON = $(SWIG) -python -py3 +endif + # ---------------------------------------------------------------- # Build a C dynamically loadable module # ---------------------------------------------------------------- python: $(SRCS) - $(SWIG) -python $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -244,7 +266,7 @@ python: $(SRCS) # ----------------------------------------------------------------- python_cpp: $(SRCS) - $(SWIG) -c++ -python $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO) @@ -257,18 +279,37 @@ python_cpp: $(SRCS) #TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11 TKINTER = -PYTHON_LIBOPTS = @PYLINK@ @LIBS@ $(TKINTER) $(SYSLIBS) +PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS) python_static: $(SRCS) - $(SWIG) -python -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) python_static_cpp: $(SRCS) - $(SWIG) -c++ -python -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Running a Python example +# ----------------------------------------------------------------- + +ifeq (,$(PY3)) + PYSCRIPT = runme.py +else + PYSCRIPT = runme3.py +endif + +PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'` + +python_run: $(PYSCRIPT) + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null + +runme3.py: runme.py + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- @@ -277,6 +318,8 @@ python_clean: rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@ + if [ -f runme.py ]; then (rm -f runme3.py runme3.py.bak;) fi; + ################################################################## ##### OCTAVE ###### @@ -295,7 +338,7 @@ OCTAVE_SO = @OCTAVE_SO@ # ---------------------------------------------------------------- octave: $(SRCS) - $(SWIG) -octave $(SWIGOPT) $(INTERFACE) + $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(OCTAVE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -305,7 +348,7 @@ octave: $(SRCS) # ----------------------------------------------------------------- octave_cpp: $(SRCS) - $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -332,12 +375,12 @@ GUILE_LIBPREFIX = lib # Build a dynamically loaded module with passive linkage and the scm interface #------------------------------------------------------------------ guile: $(SRCS) - $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_cpp: $(SRCS) - $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -348,12 +391,12 @@ guile_externalhdr: # Build a dynamically loaded module with passive linkage and the gh interface #------------------------------------------------------------------ guile_gh: $(SRCS) - $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_gh_cpp: $(SRCS) - $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -362,12 +405,12 @@ guile_gh_cpp: $(SRCS) # ----------------------------------------------------------------- guile_passive: $(SRCS) - $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) guile_passive_cpp: $(SRCS) - $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) @@ -378,24 +421,24 @@ guile_passive_cpp: $(SRCS) GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) guile_static: $(SRCS) - $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) - $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ -DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) - $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE) + $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) - $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile @@ -430,7 +473,7 @@ JAVACFLAGS = @JAVACFLAGS@ # ---------------------------------------------------------------- java: $(SRCS) - $(SWIG) -java $(SWIGOPT) $(INTERFACE) + $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) @@ -439,7 +482,7 @@ java: $(SRCS) # ---------------------------------------------------------------- java_cpp: $(SRCS) - $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE) $(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO) @@ -448,7 +491,7 @@ java_cpp: $(SRCS) # ----------------------------------------------------------------- java_clean: - rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v main.java` + rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ @@ -463,12 +506,12 @@ MODULA3_INCLUDE= @MODULA3INC@ # ---------------------------------------------------------------- modula3: $(SRCS) - $(SWIG) -modula3 $(SWIGOPT) $(INTERFACE) + $(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \ # $(OBJS) $(IOBJS) $(LIBS) modula3_cpp: $(SRCS) - $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) # ----------------------------------------------------------------- # Cleaning the modula3 examples @@ -483,7 +526,7 @@ modula3_clean: ##### MZSCHEME ###### ################################################################## -MZC = test -n "@MZC@" && @MZC@ +MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ @@ -492,13 +535,13 @@ MZSCHEME_SO = @MZSCHEME_SO@ # ---------------------------------------------------------------- mzscheme: $(SRCS) - $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACE) - $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) - $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) + $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH) + $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS) + $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) mzscheme_cpp: $(SRCS) - $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE) - $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH) + $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS) # ----------------------------------------------------------------- @@ -520,6 +563,7 @@ OCAMLFIND=@OCAMLFIND@ OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE) NOLINK ?= false OCAMLPP= -pp "camlp4o ./swigp4.cmo" +OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where` OCAMLCORE=\ rm -rf swig.mli swig.ml swigp4.ml && \ $(SWIG) -ocaml -co swig.mli 2>/dev/null && \ @@ -527,12 +571,12 @@ OCAMLCORE=\ $(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \ $(OCC) -c swig.mli && \ $(OCC) -c swig.ml && \ - $(OCC) -I `camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ + $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \ -c swigp4.ml ocaml_static: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) @@ -546,7 +590,7 @@ ocaml_static: $(SRCS) ocaml_dynamic: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS) @@ -565,7 +609,7 @@ ocaml_dynamic: $(SRCS) ocaml_static_toplevel: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH) $(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS) $(OCC) -g -c $(INTERFACE:%.i=%.mli) $(OCC) -g -c $(INTERFACE:%.i=%.ml) @@ -573,14 +617,14 @@ ocaml_static_toplevel: $(SRCS) $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ - -I `camlp4 -where` camlp4o.cma swigp4.cmo \ + -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)" ocaml_static_cpp: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) @@ -597,7 +641,7 @@ ocaml_static_cpp: $(SRCS) ocaml_static_cpp_toplevel: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) @@ -607,7 +651,7 @@ ocaml_static_cpp_toplevel: $(SRCS) $(OCC) $(OCAMLPP) -c $(PROGFILE) $(NOLINK) || $(OCAMLMKTOP) \ swig.cmo \ - -I `camlp4 -where` camlp4o.cma swigp4.cmo \ + -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \ -g -ccopt -g -cclib -g -custom -o $(TARGET)_top \ $(INTERFACE:%.i=%.cmo) \ $(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \ @@ -615,7 +659,7 @@ ocaml_static_cpp_toplevel: $(SRCS) ocaml_dynamic_cpp: $(SRCS) $(OCAMLCORE) - $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH) cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c) $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \ $(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC @@ -656,7 +700,7 @@ RUBY_DLNK = @RUBYDYNAMICLINKING@ # ---------------------------------------------------------------- ruby: $(SRCS) - $(SWIG) -ruby $(SWIGOPT) $(INTERFACE) + $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -665,7 +709,7 @@ ruby: $(SRCS) # ----------------------------------------------------------------- ruby_cpp: $(SRCS) - $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -679,12 +723,12 @@ ruby_cpp: $(SRCS) RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) ruby_static: $(SRCS) - $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) ruby_cpp_static: $(SRCS) - $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) @@ -703,41 +747,41 @@ ruby_clean: ################################################################## # ------------------------------------------------------------------- -# Build a PHP4 dynamically loadable module (C) +# Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- -PHP4_INCLUDE = @PHP4INC@ -PHP4_SO = @PHP4_SO@ +PHP_INCLUDE = @PHPINC@ +PHP_SO = @PHP_SO@ -php4: $(SRCS) - $(SWIG) -php5 $(SWIGOPT) $(INTERFACE) - $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP4_INCLUDE) - $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) +php: $(SRCS) + $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # -------------------------------------------------------------------- -# Build a PHP4 dynamically loadable module (C++) +# Build a PHP dynamically loadable module (C++) # -------------------------------------------------------------------- -php4_cpp: $(SRCS) - $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) $(INTERFACE) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP4_INCLUDE) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO) +php_cpp: $(SRCS) + $(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO) # ----------------------------------------------------------------- -# Running a PHP4 example +# Running a PHP example # ----------------------------------------------------------------- -PHP4=@PHP4@ -SCRIPT ?= runme.php4 +PHP=@PHP@ +PHPSCRIPT ?= runme.php -php4_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP4) -n -q -d extension_dir=. $(SCRIPT) +php_run: + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) # ----------------------------------------------------------------- -# Cleaning the PHP4 examples +# Cleaning the PHP examples # ----------------------------------------------------------------- -php4_clean: +php_clean: rm -f *_wrap* *~ .~* example.php php_example.h rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ @@ -757,7 +801,7 @@ PIKE_DLNK = @PIKEDYNAMICLINKING@ # ---------------------------------------------------------------- pike: $(SRCS) - $(SWIG) -pike $(SWIGOPT) $(INTERFACE) + $(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -766,7 +810,7 @@ pike: $(SRCS) # ----------------------------------------------------------------- pike_cpp: $(SRCS) - $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -780,12 +824,12 @@ pike_cpp: $(SRCS) PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) pike_static: $(SRCS) - $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) pike_cpp_static: $(SRCS) - $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) @@ -827,7 +871,7 @@ CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@) # This is the old way to build chicken, but it does not work correctly with exceptions chicken_direct: $(SRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) @@ -837,7 +881,7 @@ chicken_direct: $(SRCS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO) chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -dynamic -feature chicken-compile-shared \ -output-file $(CHICKEN_COMPILED_SCHEME) @@ -852,7 +896,7 @@ chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS) # The following two targets are also used by the test suite chicken_static: $(SRCS) $(CHICKSRCS) - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ @@ -864,7 +908,7 @@ chicken_static: $(SRCS) $(CHICKSRCS) $(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET) chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \ -output-file $(CHICKEN_COMPILED_SCHEME) $(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \ @@ -880,11 +924,11 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS) # ---------------------------------------------------------------- chicken: - $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO) chicken_cpp: - $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE) + $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH) $(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO) chicken_externalhdr: @@ -912,7 +956,7 @@ CSHARPSO = @CSHARPSO@ # ---------------------------------------------------------------- csharp: $(SRCS) - $(SWIG) -csharp $(SWIGOPT) $(INTERFACE) + $(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) @@ -921,7 +965,7 @@ csharp: $(SRCS) # ---------------------------------------------------------------- csharp_cpp: $(SRCS) - $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACE) + $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO) @@ -961,7 +1005,7 @@ LUA_INTERP = ../lua.c # ---------------------------------------------------------------- lua: $(SRCS) - $(SWIG) -lua $(SWIGOPT) $(INTERFACE) + $(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) @@ -970,7 +1014,7 @@ lua: $(SRCS) # ----------------------------------------------------------------- lua_cpp: $(SRCS) - $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO) @@ -979,12 +1023,12 @@ lua_cpp: $(SRCS) # ----------------------------------------------------------------- lua_static: $(SRCS) - $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACE) + $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) lua_static_cpp: $(SRCS) - $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) @@ -1002,12 +1046,12 @@ lua_clean: ################################################################## allegrocl: $(SRCS) - $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACE) + $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) allegrocl_cpp: $(SRCS) - $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1021,10 +1065,10 @@ allegrocl_clean: ################################################################## clisp: $(SRCS) - $(SWIG) -clisp $(SWIGOPT) $(INTERFACE) + $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_cpp: $(SRCS) - $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_clean: rm -f *_wrap* *~ .~* @@ -1036,12 +1080,12 @@ clisp_clean: ################################################################## cffi: $(SRCS) - $(SWIG) -cffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) cffi_cpp: $(SRCS) - $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1055,12 +1099,12 @@ cffi_clean: ################################################################## uffi: $(SRCS) - $(SWIG) -uffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) # $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) uffi_cpp: $(SRCS) - $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACE) + $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) @@ -1078,11 +1122,11 @@ RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system a RRSRC = $(INTERFACE:.i=.R) r: $(SRCS) - $(SWIG) -r $(SWIGOPT) $(INTERFACE) + $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) +( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) ) r_cpp: $(CXXSRCS) - $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACE) + $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) +( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) ) r_clean: diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile new file mode 100644 index 000000000..b3446d895 --- /dev/null +++ b/Examples/csharp/arrays/Makefile @@ -0,0 +1,20 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +SWIGOPT = +CSHARPSRCS = *.cs +CSHARPFLAGS= -nologo -unsafe -out:runme.exe + +all:: csharp + +csharp:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp + $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile + +clean:: + $(MAKE) -f $(TOP)/Makefile csharp_clean + +check: all diff --git a/Examples/csharp/arrays/example.c b/Examples/csharp/arrays/example.c new file mode 100644 index 000000000..2498e1f4e --- /dev/null +++ b/Examples/csharp/arrays/example.c @@ -0,0 +1,22 @@ +/* File : example.c */ + +#include "example.h" + +/* copy the contents of the first array to the second */ +void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { + int i; + for ( i = 0; i < nitems; i++ ) { + targetArray[ i ] = sourceArray[ i ]; + } +} + +/* swap the contents of the two arrays */ +void myArraySwap( int* array1, int* array2, int nitems ) { + int i, temp; + for ( i = 0; i < nitems; i++ ) { + temp = array1[ i ]; + array1[ i ] = array2[ i ]; + array2[ i ] = temp; + } +} + diff --git a/Examples/csharp/arrays/example.h b/Examples/csharp/arrays/example.h new file mode 100644 index 000000000..113b92c1b --- /dev/null +++ b/Examples/csharp/arrays/example.h @@ -0,0 +1,4 @@ + +void myArrayCopy( int *sourceArray, int* targetArray, int nitems ); +void myArraySwap( int* array1, int* array2, int nitems ); + diff --git a/Examples/csharp/arrays/example.i b/Examples/csharp/arrays/example.i new file mode 100644 index 000000000..488565a74 --- /dev/null +++ b/Examples/csharp/arrays/example.i @@ -0,0 +1,45 @@ +/* File : example.i */ +%module example + +%{ +#include "example.h" +%} +%include "arrays_csharp.i" + +%apply int INPUT[] { int* sourceArray } +%apply int OUTPUT[] { int* targetArray } + +%apply int INOUT[] { int* array1 } +%apply int INOUT[] { int* array2 } + +%include "example.h" + +%clear int* sourceArray; +%clear int* targetArray; + +%clear int* array1; +%clear int* array2; + + +// Below replicates the above array handling but this time using the pinned (fixed) array typemaps +%csmethodmodifiers "public unsafe"; + +%apply int FIXED[] { int* sourceArray } +%apply int FIXED[] { int* targetArray } + +%inline %{ +void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { + myArrayCopy(sourceArray, targetArray, nitems); +} +%} + +%apply int FIXED[] { int* array1 } +%apply int FIXED[] { int* array2 } + +%inline %{ +void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { + myArraySwap(array1, array2, nitems); +} +%} + + diff --git a/Examples/csharp/arrays/runme.cs b/Examples/csharp/arrays/runme.cs new file mode 100644 index 000000000..c2b8a6bdd --- /dev/null +++ b/Examples/csharp/arrays/runme.cs @@ -0,0 +1,43 @@ +using System; + +public class runme +{ + static void Main() + { + int[] source = { 1, 2, 3 }; + int[] target = new int[ source.Length ]; + + example.myArrayCopy( source, target, target.Length ); + + Console.WriteLine( "Contents of copy target array using default marshaling" ); + PrintArray( target ); + + target = new int[ source.Length ]; + + example.myArrayCopyUsingFixedArrays( source, target, target.Length ); + Console.WriteLine( "Contents of copy target array using fixed arrays" ); + PrintArray( target ); + + target = new int[] { 4, 5, 6 }; + example.myArraySwap( source, target, target.Length ); + Console.WriteLine( "Contents of arrays after swapping using default marshaling" ); + PrintArray( source ); + PrintArray( target ); + + source = new int[] { 1, 2, 3 }; + target = new int[] { 4, 5, 6 }; + + example.myArraySwapUsingFixedArrays( source, target, target.Length ); + Console.WriteLine( "Contents of arrays after swapping using fixed arrays" ); + PrintArray( source ); + PrintArray( target ); + } + + static void PrintArray( int[] a ) + { + foreach ( int i in a ) + Console.Write( "{0} ", i ); + Console.WriteLine(); + } +} + diff --git a/Examples/csharp/check.list b/Examples/csharp/check.list index c4d92402b..5454d8531 100644 --- a/Examples/csharp/check.list +++ b/Examples/csharp/check.list @@ -1,4 +1,5 @@ # see top-level Makefile.in +arrays callback class enum diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/matrix.scm index 18e52842d..18e52842d 100755..100644 --- a/Examples/guile/matrix/matrix.scm +++ b/Examples/guile/matrix/matrix.scm diff --git a/Examples/java/callback/main.java b/Examples/java/callback/runme.java index 4800f8cc9..4090f0ac3 100644 --- a/Examples/java/callback/main.java +++ b/Examples/java/callback/runme.java @@ -1,4 +1,4 @@ -public class main +public class runme { static { try { diff --git a/Examples/java/class/index.html b/Examples/java/class/index.html index e9db7e94a..cf9130c62 100644 --- a/Examples/java/class/index.html +++ b/Examples/java/class/index.html @@ -88,7 +88,7 @@ Note: when creating a C++ extension, you must run SWIG with the <tt>-c++</tt> op <h2>A sample Java program</h2> -Click <a href="main.java">here</a> to see a Java program that calls the C++ functions from Java. +Click <a href="runme.java">here</a> to see a Java program that calls the C++ functions from Java. <h2>Key points</h2> diff --git a/Examples/java/class/main.java b/Examples/java/class/runme.java index 8ef35db6d..e1ea0d71c 100644 --- a/Examples/java/class/main.java +++ b/Examples/java/class/runme.java @@ -1,7 +1,7 @@ // This example illustrates how C++ classes can be used from Java using SWIG. // The Java class gets mapped onto the C++ class and behaves as if it is a Java class. -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/constants/index.html b/Examples/java/constants/index.html index 8367d0571..9f1e95a03 100644 --- a/Examples/java/constants/index.html +++ b/Examples/java/constants/index.html @@ -20,7 +20,7 @@ to see a SWIG interface with some constant declarations in it. Click <a href="../../../Doc/Manual/Java.html#constants">here</a> for the section on constants in the SWIG and Java documentation. <p> -Click <a href="main.java">here</a> to see a Java program that prints out the values +Click <a href="runme.java">here</a> to see a Java program that prints out the values of the constants contained in the above file.</p> <h2>Key points</h2> <ul> diff --git a/Examples/java/constants/main.java b/Examples/java/constants/runme.java index 7130c3d70..2c67d86aa 100644 --- a/Examples/java/constants/main.java +++ b/Examples/java/constants/runme.java @@ -1,6 +1,6 @@ import java.lang.reflect.*; -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/enum/index.html b/Examples/java/enum/index.html index 52c06c5d1..20daf2691 100644 --- a/Examples/java/enum/index.html +++ b/Examples/java/enum/index.html @@ -21,7 +21,7 @@ See the documentation for the other approaches for wrapping enums. <ul> <li><a href="example.h">example.h</a>. Header file containing some enums. <li><a href="example.i">example.i</a>. Interface file. -<li><a href="main.java">main.java</a>. Sample Java program. +<li><a href="runme.java">runme.java</a>. Sample Java program. </ul> <hr> diff --git a/Examples/java/enum/main.java b/Examples/java/enum/runme.java index 8646e0087..56e49af91 100644 --- a/Examples/java/enum/main.java +++ b/Examples/java/enum/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/extend/main.java b/Examples/java/extend/runme.java index ee3a94ed0..629bb14a6 100644 --- a/Examples/java/extend/main.java +++ b/Examples/java/extend/runme.java @@ -17,7 +17,7 @@ class CEO extends Manager { } -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/funcptr/index.html b/Examples/java/funcptr/index.html index 0ad2be1cf..56d3baa18 100644 --- a/Examples/java/funcptr/index.html +++ b/Examples/java/funcptr/index.html @@ -66,7 +66,7 @@ Here are some files that illustrate this with a simple example: <li><a href="example.c">example.c</a> <li><a href="example.h">example.h</a> <li><a href="example.i">example.i</a> (SWIG interface) -<li><a href="main.java">main.java</a> (Sample program) +<li><a href="runme.java">runme.java</a> (Sample program) </ul> <h2>Notes</h2> diff --git a/Examples/java/funcptr/main.java b/Examples/java/funcptr/runme.java index cf81f92b4..cd34c1b65 100644 --- a/Examples/java/funcptr/main.java +++ b/Examples/java/funcptr/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/index.html b/Examples/java/index.html index d98f9a393..007e14dbc 100644 --- a/Examples/java/index.html +++ b/Examples/java/index.html @@ -30,7 +30,7 @@ certain C declarations are turned into constants. <h2>Running the examples</h2> Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p> -On Unix most of the examples work by making the Makefile before executing the program main.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac. +On Unix most of the examples work by making the Makefile before executing the program runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac. <p> Ensure that the dynamic link library file is in the appropriate path before executing the Java program. For example in Unix, libexample.so must be in the LD_LIBRARY_PATH. <p> @@ -39,7 +39,7 @@ A Unix example: <pre> $ make $ export LD_LIBRARY_PATH=. #ksh -$ java main +$ java runme </pre> </blockquote> <p> diff --git a/Examples/java/multimap/main.java b/Examples/java/multimap/runme.java index 331ac6b89..738330e77 100644 --- a/Examples/java/multimap/main.java +++ b/Examples/java/multimap/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/native/index.html b/Examples/java/native/index.html index 7ecf129ce..1ca51c1e9 100644 --- a/Examples/java/native/index.html +++ b/Examples/java/native/index.html @@ -18,7 +18,7 @@ This example compares wrapping a c global function using the manual way and the <ul> <li><a href="example.i">example.i</a>. Interface file comparing code wrapped by SWIG and wrapped manually. -<li><a href="main.java">main.java</a>. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions. +<li><a href="runme.java">runme.java</a>. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions. </ul> <h2>Notes</h2> diff --git a/Examples/java/native/main.java b/Examples/java/native/runme.java index f4760bb3d..e9a18b21a 100644 --- a/Examples/java/native/main.java +++ b/Examples/java/native/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html index c30d549e6..e20fe3328 100644 --- a/Examples/java/pointer/index.html +++ b/Examples/java/pointer/index.html @@ -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="main.java">main.java</a> (Java program) +<li> <a href="runme.java">runme.java</a> (Java program) </ul> <h2>Notes</h2> diff --git a/Examples/java/pointer/main.java b/Examples/java/pointer/runme.java index e96e02eaa..f32f980f9 100644 --- a/Examples/java/pointer/main.java +++ b/Examples/java/pointer/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/reference/index.html b/Examples/java/reference/index.html index 64b129cbb..33c80c50f 100644 --- a/Examples/java/reference/index.html +++ b/Examples/java/reference/index.html @@ -121,7 +121,7 @@ Click <a href="example.i">here</a> to see a SWIG interface file with these addit <h2>Sample Java program</h2> -Click <a href="main.java">here</a> to see a Java program that manipulates some C++ references. +Click <a href="runme.java">here</a> to see a Java program that manipulates some C++ references. <h2>Notes:</h2> diff --git a/Examples/java/reference/main.java b/Examples/java/reference/runme.java index 4fd354761..6a2d9bf70 100644 --- a/Examples/java/reference/main.java +++ b/Examples/java/reference/runme.java @@ -1,6 +1,6 @@ // This example illustrates the manipulation of C++ references in Java. -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/simple/index.html b/Examples/java/simple/index.html index a363327fe..9729e6dd8 100644 --- a/Examples/java/simple/index.html +++ b/Examples/java/simple/index.html @@ -65,15 +65,15 @@ to create the extension <tt>libexample.so (unix)</tt>. <h2>Using the extension</h2> -Click <a href="main.java">here</a> to see a program that calls our C functions from Java. +Click <a href="runme.java">here</a> to see a program that calls our C functions from Java. <p> -Compile the java files <tt><a href="example.java">example.java</a></tt> and <tt><a href="main.java">main.java</a></tt> -to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example: +Compile the java files <tt><a href="example.java">example.java</a></tt> and <tt><a href="runme.java">runme.java</a></tt> +to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example: <blockquote> <pre> export LD_LIBRARY_PATH=. #ksh javac *.java -java main +java runme </pre> </blockquote> diff --git a/Examples/java/simple/main.java b/Examples/java/simple/runme.java index 6d224a4dc..92880e8f9 100644 --- a/Examples/java/simple/main.java +++ b/Examples/java/simple/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html index 1aebd4c2a..f4408e568 100644 --- a/Examples/java/template/index.html +++ b/Examples/java/template/index.html @@ -85,7 +85,7 @@ Note that SWIG parses the templated function <tt>max</tt> and templated class <t <h2>A sample Java program</h2> -Click <a href="main.java">here</a> to see a Java program that calls the C++ functions from Java. +Click <a href="runme.java">here</a> to see a Java program that calls the C++ functions from Java. <h2>Notes</h2> Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive. diff --git a/Examples/java/template/main.java b/Examples/java/template/runme.java index 9129fcf2a..5d1097bba 100644 --- a/Examples/java/template/main.java +++ b/Examples/java/template/runme.java @@ -1,6 +1,6 @@ // This example illustrates how C++ templates can be used from Java. -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html index 486aa8e79..5dd591941 100644 --- a/Examples/java/typemap/index.html +++ b/Examples/java/typemap/index.html @@ -16,7 +16,7 @@ This example shows how typemaps can be used to modify the default behaviour of t <ul> <li><a href="example.i">example.i</a>. Interface file. -<li><a href="main.java">main.java</a>. Sample Java program. +<li><a href="runme.java">runme.java</a>. Sample Java program. </ul> <h2>Notes</h2> diff --git a/Examples/java/typemap/main.java b/Examples/java/typemap/runme.java index bd9a4e1b6..fcbcc3067 100644 --- a/Examples/java/typemap/main.java +++ b/Examples/java/typemap/runme.java @@ -1,5 +1,5 @@ -public class main { +public class runme { static { try { diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html index 05aaa2d6e..07b19d4e7 100644 --- a/Examples/java/variables/index.html +++ b/Examples/java/variables/index.html @@ -38,7 +38,7 @@ example.set_foo(12.3); </pre> </blockquote> -Click <a href="main.java">here</a> to see the example program that updates and prints +Click <a href="runme.java">here</a> to see the example program that updates and prints out the values of the variables using this technique. <h2>Key points</h2> diff --git a/Examples/java/variables/main.java b/Examples/java/variables/runme.java index 92745db99..361a30fa6 100644 --- a/Examples/java/variables/main.java +++ b/Examples/java/variables/runme.java @@ -2,7 +2,7 @@ import java.lang.reflect.*; -public class main { +public class runme { static { try { System.loadLibrary("example"); diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp index c2424f9af..e5e0e0a7d 100644 --- a/Examples/lua/embed3/embed3.cpp +++ b/Examples/lua/embed3/embed3.cpp @@ -26,7 +26,12 @@ extern "C" { #include <lauxlib.h> #include <lualib.h> } - +
+/* The SWIG external runtime is generated by using.
+swig -lua -externalruntime swigluarun.h
+It contains useful function used by SWIG in its wrappering
+SWIG_TypeQuery() SWIG_NewPointerObj()
+*/ #include "swigluarun.h" // the SWIG external runtime /* the SWIG wrappered library */ diff --git a/Examples/perl5/class/example.dsp b/Examples/perl5/class/example.dsp index bbdedc094..b5ccd1928 100644 --- a/Examples/perl5/class/example.dsp +++ b/Examples/perl5/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/bar.dsp b/Examples/perl5/import/bar.dsp index 682c21757..64786b8f6 100644 --- a/Examples/perl5/import/bar.dsp +++ b/Examples/perl5/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/base.dsp b/Examples/perl5/import/base.dsp index 7a0ea8027..920891cbf 100644 --- a/Examples/perl5/import/base.dsp +++ b/Examples/perl5/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/foo.dsp b/Examples/perl5/import/foo.dsp index 755560165..d519a5316 100644 --- a/Examples/perl5/import/foo.dsp +++ b/Examples/perl5/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/spam.dsp b/Examples/perl5/import/spam.dsp index ed41de36b..e5c8046eb 100644 --- a/Examples/perl5/import/spam.dsp +++ b/Examples/perl5/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/multimap/example.dsp b/Examples/perl5/multimap/example.dsp index 2d295763b..be8a0070e 100644 --- a/Examples/perl5/multimap/example.dsp +++ b/Examples/perl5/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/simple/example.dsp b/Examples/perl5/simple/example.dsp index 2d295763b..be8a0070e 100644 --- a/Examples/perl5/simple/example.dsp +++ b/Examples/perl5/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/php4/check.list b/Examples/php/check.list index 9daad455b..9daad455b 100644 --- a/Examples/php4/check.list +++ b/Examples/php/check.list diff --git a/Examples/php4/enum/Makefile b/Examples/php/class/Makefile index 39c4d2f23..252a72660 100644 --- a/Examples/php4/enum/Makefile +++ b/Examples/php/class/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/class/example.cxx b/Examples/php/class/example.cxx index f171f10e9..f171f10e9 100644 --- a/Examples/php4/class/example.cxx +++ b/Examples/php/class/example.cxx diff --git a/Examples/php4/class/example.h b/Examples/php/class/example.h index 02eaf7232..02eaf7232 100644 --- a/Examples/php4/class/example.h +++ b/Examples/php/class/example.h diff --git a/Examples/php4/class/example.i b/Examples/php/class/example.i index 75700b305..75700b305 100644 --- a/Examples/php4/class/example.i +++ b/Examples/php/class/example.i diff --git a/Examples/php4/class/runme.php4 b/Examples/php/class/runme.php index a9ca657dc..a9ca657dc 100644 --- a/Examples/php4/class/runme.php4 +++ b/Examples/php/class/runme.php diff --git a/Examples/php4/constants/Makefile b/Examples/php/constants/Makefile index aed110eb2..23e2675d7 100644 --- a/Examples/php4/constants/Makefile +++ b/Examples/php/constants/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/constants/example.i b/Examples/php/constants/example.i index 0098a893a..0098a893a 100644 --- a/Examples/php4/constants/example.i +++ b/Examples/php/constants/example.i diff --git a/Examples/php4/constants/runme.php4 b/Examples/php/constants/runme.php index cea06485f..cea06485f 100644 --- a/Examples/php4/constants/runme.php4 +++ b/Examples/php/constants/runme.php diff --git a/Examples/php4/simple/Makefile b/Examples/php/cpointer/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php4/simple/Makefile +++ b/Examples/php/cpointer/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/cpointer/example.c b/Examples/php/cpointer/example.c index 3326dec3e..3326dec3e 100644 --- a/Examples/php4/cpointer/example.c +++ b/Examples/php/cpointer/example.c diff --git a/Examples/php4/cpointer/example.i b/Examples/php/cpointer/example.i index 52e6df190..52e6df190 100644 --- a/Examples/php4/cpointer/example.i +++ b/Examples/php/cpointer/example.i diff --git a/Examples/php4/cpointer/runme.php4 b/Examples/php/cpointer/runme.php index f5ef08a3c..f5ef08a3c 100644 --- a/Examples/php4/cpointer/runme.php4 +++ b/Examples/php/cpointer/runme.php diff --git a/Examples/php4/proxy/Makefile b/Examples/php/disown/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php4/proxy/Makefile +++ b/Examples/php/disown/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/disown/example.cxx b/Examples/php/disown/example.cxx index 6393735e9..6393735e9 100644 --- a/Examples/php4/disown/example.cxx +++ b/Examples/php/disown/example.cxx diff --git a/Examples/php4/disown/example.h b/Examples/php/disown/example.h index 985bc333d..985bc333d 100644 --- a/Examples/php4/disown/example.h +++ b/Examples/php/disown/example.h diff --git a/Examples/php4/disown/example.i b/Examples/php/disown/example.i index 599f162c5..599f162c5 100644 --- a/Examples/php4/disown/example.i +++ b/Examples/php/disown/example.i diff --git a/Examples/php4/disown/runme.php4 b/Examples/php/disown/runme.php index 73d50786b..73d50786b 100644 --- a/Examples/php4/disown/runme.php4 +++ b/Examples/php/disown/runme.php diff --git a/Examples/php4/class/Makefile b/Examples/php/enum/Makefile index 39c4d2f23..252a72660 100644 --- a/Examples/php4/class/Makefile +++ b/Examples/php/enum/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/enum/example.cxx b/Examples/php/enum/example.cxx index df7bb6328..df7bb6328 100644 --- a/Examples/php4/enum/example.cxx +++ b/Examples/php/enum/example.cxx diff --git a/Examples/php4/enum/example.h b/Examples/php/enum/example.h index 525d62afc..525d62afc 100644 --- a/Examples/php4/enum/example.h +++ b/Examples/php/enum/example.h diff --git a/Examples/php4/enum/example.i b/Examples/php/enum/example.i index abf254731..abf254731 100644 --- a/Examples/php4/enum/example.i +++ b/Examples/php/enum/example.i diff --git a/Examples/php4/enum/runme.php4 b/Examples/php/enum/runme.php index 55b0bc4c3..55b0bc4c3 100644 --- a/Examples/php4/enum/runme.php4 +++ b/Examples/php/enum/runme.php diff --git a/Examples/php4/funcptr/Makefile b/Examples/php/funcptr/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php4/funcptr/Makefile +++ b/Examples/php/funcptr/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/funcptr/example.c b/Examples/php/funcptr/example.c index 99583b72e..99583b72e 100644 --- a/Examples/php4/funcptr/example.c +++ b/Examples/php/funcptr/example.c diff --git a/Examples/php4/funcptr/example.h b/Examples/php/funcptr/example.h index 58989db79..58989db79 100644 --- a/Examples/php4/funcptr/example.h +++ b/Examples/php/funcptr/example.h diff --git a/Examples/php4/funcptr/example.i b/Examples/php/funcptr/example.i index 39390da27..39390da27 100644 --- a/Examples/php4/funcptr/example.i +++ b/Examples/php/funcptr/example.i diff --git a/Examples/php4/funcptr/runme.php4 b/Examples/php/funcptr/runme.php index 712d4147c..712d4147c 100644 --- a/Examples/php4/funcptr/runme.php4 +++ b/Examples/php/funcptr/runme.php diff --git a/Examples/php4/sync/Makefile b/Examples/php/overloading/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php4/sync/Makefile +++ b/Examples/php/overloading/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/overloading/example.cxx b/Examples/php/overloading/example.cxx index fc7aff195..2f684f05c 100644 --- a/Examples/php4/overloading/example.cxx +++ b/Examples/php/overloading/example.cxx @@ -34,22 +34,22 @@ double Square::perimeter(void) { return 4*width; } -char *overloaded(int i) { +const char *overloaded(int i) { return "Overloaded with int"; } -char *overloaded(double d) { +const char *overloaded(double d) { return "Overloaded with double"; } -char *overloaded(const char * str) { +const char *overloaded(const char * str) { return "Overloaded with char *"; } -char *overloaded( const Circle& ) { +const char *overloaded( const Circle& ) { return "Overloaded with Circle"; } -char *overloaded( const Shape& ) { +const char *overloaded( const Shape& ) { return "Overloaded with Shape"; } diff --git a/Examples/php4/overloading/example.h b/Examples/php/overloading/example.h index 39ccc1cb1..01d71dd70 100644 --- a/Examples/php4/overloading/example.h +++ b/Examples/php/overloading/example.h @@ -38,9 +38,9 @@ public: virtual double perimeter(void); }; -char *overloaded( int i ); -char *overloaded( double d ); -char *overloaded( const char * str ); -char *overloaded( const Circle& ); -char *overloaded( const Shape& ); +const char *overloaded( int i ); +const char *overloaded( double d ); +const char *overloaded( const char * str ); +const char *overloaded( const Circle& ); +const char *overloaded( const Shape& ); diff --git a/Examples/php4/overloading/example.i b/Examples/php/overloading/example.i index 950d2549d..950d2549d 100644 --- a/Examples/php4/overloading/example.i +++ b/Examples/php/overloading/example.i diff --git a/Examples/php4/overloading/runme.php4 b/Examples/php/overloading/runme.php index 5aa69048d..5aa69048d 100644 --- a/Examples/php4/overloading/runme.php4 +++ b/Examples/php/overloading/runme.php diff --git a/Examples/php4/cpointer/Makefile b/Examples/php/pointer/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php4/cpointer/Makefile +++ b/Examples/php/pointer/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/pointer/example.c b/Examples/php/pointer/example.c index 3326dec3e..3326dec3e 100644 --- a/Examples/php4/pointer/example.c +++ b/Examples/php/pointer/example.c diff --git a/Examples/php4/pointer/example.i b/Examples/php/pointer/example.i index c14b94189..c14b94189 100644 --- a/Examples/php4/pointer/example.i +++ b/Examples/php/pointer/example.i diff --git a/Examples/php4/pointer/runme.php4 b/Examples/php/pointer/runme.php index 5e86de6a2..5e86de6a2 100644 --- a/Examples/php4/pointer/runme.php4 +++ b/Examples/php/pointer/runme.php diff --git a/Examples/php4/pragmas/Makefile b/Examples/php/pragmas/Makefile index aed110eb2..23e2675d7 100644 --- a/Examples/php4/pragmas/Makefile +++ b/Examples/php/pragmas/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/pragmas/example.i b/Examples/php/pragmas/example.i index 289d4ec99..c7e8bf303 100644 --- a/Examples/php4/pragmas/example.i +++ b/Examples/php/pragmas/example.i @@ -21,11 +21,11 @@ zend_printf("This was %%rshutdown\n"); } -%pragma(php4) include="include.php"; +%pragma(php) include="include.php"; -%pragma(php4) code=" +%pragma(php) code=" # This code is inserted into example.php -echo \"this was php4 code\\n\"; +echo \"this was php code\\n\"; " -%pragma(php4) phpinfo="php_info_print_table_start();" +%pragma(php) phpinfo="php_info_print_table_start();" diff --git a/Examples/php4/pragmas/include.php b/Examples/php/pragmas/include.php index e19880a06..e19880a06 100644 --- a/Examples/php4/pragmas/include.php +++ b/Examples/php/pragmas/include.php diff --git a/Examples/php4/pragmas/runme.php4 b/Examples/php/pragmas/runme.php index 538548b6f..538548b6f 100755 --- a/Examples/php4/pragmas/runme.php4 +++ b/Examples/php/pragmas/runme.php diff --git a/Examples/php4/overloading/Makefile b/Examples/php/proxy/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php4/overloading/Makefile +++ b/Examples/php/proxy/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/proxy/example.cxx b/Examples/php/proxy/example.cxx index 94e4a7888..94e4a7888 100644 --- a/Examples/php4/proxy/example.cxx +++ b/Examples/php/proxy/example.cxx diff --git a/Examples/php4/proxy/example.h b/Examples/php/proxy/example.h index 361dff898..361dff898 100644 --- a/Examples/php4/proxy/example.h +++ b/Examples/php/proxy/example.h diff --git a/Examples/php4/proxy/example.i b/Examples/php/proxy/example.i index ce73746d0..ce73746d0 100644 --- a/Examples/php4/proxy/example.i +++ b/Examples/php/proxy/example.i diff --git a/Examples/php4/proxy/runme.php4 b/Examples/php/proxy/runme.php index dea80e358..dea80e358 100644 --- a/Examples/php4/proxy/runme.php4 +++ b/Examples/php/proxy/runme.php diff --git a/Examples/php4/reference/Makefile b/Examples/php/reference/Makefile index 39c4d2f23..252a72660 100644 --- a/Examples/php4/reference/Makefile +++ b/Examples/php/reference/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/reference/example.cxx b/Examples/php/reference/example.cxx index 3e13841d2..3e13841d2 100644 --- a/Examples/php4/reference/example.cxx +++ b/Examples/php/reference/example.cxx diff --git a/Examples/php4/reference/example.h b/Examples/php/reference/example.h index 4915adb1b..4915adb1b 100644 --- a/Examples/php4/reference/example.h +++ b/Examples/php/reference/example.h diff --git a/Examples/php4/reference/example.i b/Examples/php/reference/example.i index 55d1828a8..55d1828a8 100644 --- a/Examples/php4/reference/example.i +++ b/Examples/php/reference/example.i diff --git a/Examples/php4/reference/runme-proxy.php4 b/Examples/php/reference/runme-proxy.php4 index 9d216f78b..9d216f78b 100644 --- a/Examples/php4/reference/runme-proxy.php4 +++ b/Examples/php/reference/runme-proxy.php4 diff --git a/Examples/php4/reference/runme.php4 b/Examples/php/reference/runme.php index 00aaa5298..00aaa5298 100644 --- a/Examples/php4/reference/runme.php4 +++ b/Examples/php/reference/runme.php diff --git a/Examples/php4/pointer/Makefile b/Examples/php/simple/Makefile index caeec2d73..0862ce5ec 100644 --- a/Examples/php4/pointer/Makefile +++ b/Examples/php/simple/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/simple/example.c b/Examples/php/simple/example.c index 2fe275632..2fe275632 100644 --- a/Examples/php4/simple/example.c +++ b/Examples/php/simple/example.c diff --git a/Examples/php4/simple/example.i b/Examples/php/simple/example.i index af4ff08a7..af4ff08a7 100644 --- a/Examples/php4/simple/example.i +++ b/Examples/php/simple/example.i diff --git a/Examples/php4/simple/runme.php4 b/Examples/php/simple/runme.php index 0e96fe800..0e96fe800 100755 --- a/Examples/php4/simple/runme.php4 +++ b/Examples/php/simple/runme.php diff --git a/Examples/php4/disown/Makefile b/Examples/php/sync/Makefile index ef3acc773..1bc0beaab 100644 --- a/Examples/php4/disown/Makefile +++ b/Examples/php/sync/Makefile @@ -9,16 +9,16 @@ SWIGOPT = all:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4_cpp + php_cpp static:: $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_cpp_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_cpp_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/sync/example.cxx b/Examples/php/sync/example.cxx index 47378924b..31ed2021b 100644 --- a/Examples/php4/sync/example.cxx +++ b/Examples/php/sync/example.cxx @@ -2,7 +2,7 @@ #include <stdio.h> int x = 42; -char *s = "Test"; +char *s = (char *)"Test"; void Sync::printer(void) { diff --git a/Examples/php4/sync/example.h b/Examples/php/sync/example.h index d67ec21dc..d67ec21dc 100644 --- a/Examples/php4/sync/example.h +++ b/Examples/php/sync/example.h diff --git a/Examples/php4/sync/example.i b/Examples/php/sync/example.i index 17ff87cf3..17ff87cf3 100644 --- a/Examples/php4/sync/example.i +++ b/Examples/php/sync/example.i diff --git a/Examples/php4/sync/runme.php4 b/Examples/php/sync/runme.php index a7c43474f..a7c43474f 100644 --- a/Examples/php4/sync/runme.php4 +++ b/Examples/php/sync/runme.php diff --git a/Examples/php4/value/Makefile b/Examples/php/value/Makefile index cc383ea3f..9e69d00a4 100644 --- a/Examples/php4/value/Makefile +++ b/Examples/php/value/Makefile @@ -9,16 +9,16 @@ SWIGOPT = -noproxy all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 + php static:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean + $(MAKE) -f $(TOP)/Makefile php_clean rm -f $(TARGET).php check: all - $(MAKE) -f $(TOP)/Makefile php4_run + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/value/example.c b/Examples/php/value/example.c index 3c402a214..3c402a214 100644 --- a/Examples/php4/value/example.c +++ b/Examples/php/value/example.c diff --git a/Examples/php4/value/example.h b/Examples/php/value/example.h index f55752a5f..f55752a5f 100644 --- a/Examples/php4/value/example.h +++ b/Examples/php/value/example.h diff --git a/Examples/php4/value/example.i b/Examples/php/value/example.i index 386fa3b84..386fa3b84 100644 --- a/Examples/php4/value/example.i +++ b/Examples/php/value/example.i diff --git a/Examples/php4/value/runme.php4 b/Examples/php/value/runme.php index 49115376c..49115376c 100644 --- a/Examples/php4/value/runme.php4 +++ b/Examples/php/value/runme.php diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile new file mode 100644 index 000000000..0862ce5ec --- /dev/null +++ b/Examples/php/variables/Makefile @@ -0,0 +1,24 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +SRCS = example.c +TARGET = example +INTERFACE = example.i +LIBS = +SWIGOPT = + +all:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ + php + +static:: + $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ + SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \ + php_static + +clean:: + $(MAKE) -f $(TOP)/Makefile php_clean + rm -f $(TARGET).php + +check: all + $(MAKE) -f $(TOP)/Makefile php_run diff --git a/Examples/php4/variables/example.c b/Examples/php/variables/example.c index 3114c7c5f..3114c7c5f 100644 --- a/Examples/php4/variables/example.c +++ b/Examples/php/variables/example.c diff --git a/Examples/php4/variables/example.h b/Examples/php/variables/example.h index 3b3659ce5..3b3659ce5 100644 --- a/Examples/php4/variables/example.h +++ b/Examples/php/variables/example.h diff --git a/Examples/php4/variables/example.i b/Examples/php/variables/example.i index 3edbb72d7..3edbb72d7 100644 --- a/Examples/php4/variables/example.i +++ b/Examples/php/variables/example.i diff --git a/Examples/php4/variables/runme.php4 b/Examples/php/variables/runme.php index bbfeb610b..bbfeb610b 100644 --- a/Examples/php4/variables/runme.php4 +++ b/Examples/php/variables/runme.php diff --git a/Examples/php4/variables/runme.php4.old b/Examples/php/variables/runme.php4.old index 9a6bfb386..9a6bfb386 100644 --- a/Examples/php4/variables/runme.php4.old +++ b/Examples/php/variables/runme.php4.old diff --git a/Examples/php4/variables/Makefile b/Examples/php4/variables/Makefile deleted file mode 100644 index caeec2d73..000000000 --- a/Examples/php4/variables/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -TOP = ../.. -SWIG = $(TOP)/../preinst-swig -SRCS = example.c -TARGET = example -INTERFACE = example.i -LIBS = -SWIGOPT = - -all:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \ - php4 - -static:: - $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ - SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \ - php4_static - -clean:: - $(MAKE) -f $(TOP)/Makefile php4_clean - rm -f $(TARGET).php - -check: all - $(MAKE) -f $(TOP)/Makefile php4_run diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile index 981ccef6f..981ccef6f 100755..100644 --- a/Examples/pike/class/Makefile +++ b/Examples/pike/class/Makefile diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx index c7a3194a4..c7a3194a4 100755..100644 --- a/Examples/pike/class/example.cxx +++ b/Examples/pike/class/example.cxx diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h index f74a4fefc..f74a4fefc 100755..100644 --- a/Examples/pike/class/example.h +++ b/Examples/pike/class/example.h diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i index 75700b305..75700b305 100755..100644 --- a/Examples/pike/class/example.i +++ b/Examples/pike/class/example.i diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile index 7fa493851..7fa493851 100755..100644 --- a/Examples/pike/constants/Makefile +++ b/Examples/pike/constants/Makefile diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i index 4f7b1a4d7..4f7b1a4d7 100755..100644 --- a/Examples/pike/constants/example.i +++ b/Examples/pike/constants/example.i diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx index 3760fdd49..3760fdd49 100755..100644 --- a/Examples/pike/overload/example.cxx +++ b/Examples/pike/overload/example.cxx diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h index e47a122ee..e47a122ee 100755..100644 --- a/Examples/pike/overload/example.h +++ b/Examples/pike/overload/example.h diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile index b3f012927..b3f012927 100755..100644 --- a/Examples/pike/template/Makefile +++ b/Examples/pike/template/Makefile diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h index 7401df650..7401df650 100755..100644 --- a/Examples/pike/template/example.h +++ b/Examples/pike/template/example.h diff --git a/Examples/pike/template/example.i b/Examples/pike/template/example.i index 8f94c4da1..8f94c4da1 100755..100644 --- a/Examples/pike/template/example.i +++ b/Examples/pike/template/example.i diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile index ad36d7d7e..a29276e58 100644 --- a/Examples/python/callback/Makefile +++ b/Examples/python/callback/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/callback/runme.py b/Examples/python/callback/runme.py index 5d93e8223..026e9520b 100644 --- a/Examples/python/callback/runme.py +++ b/Examples/python/callback/runme.py @@ -5,8 +5,6 @@ import example -# CEO class, which overrides Employee::getPosition(). - class PyCallback(example.Callback): def __init__(self): example.Callback.__init__(self) diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile index f331b8203..74625b992 100644 --- a/Examples/python/class/Makefile +++ b/Examples/python/class/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp index dccba46b0..fd7bf8c06 100644 --- a/Examples/python/class/example.dsp +++ b/Examples/python/class/example.dsp @@ -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
diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile index 01d0f943a..1420b4e0b 100644 --- a/Examples/python/constants/Makefile +++ b/Examples/python/constants/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile index c7b476995..77fe94b1a 100644 --- a/Examples/python/contract/Makefile +++ b/Examples/python/contract/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp index 7a32f4dc1..32845e0e8 100644 --- a/Examples/python/contract/example.dsp +++ b/Examples/python/contract/example.dsp @@ -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
diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile index 74ab112a1..f25450cac 100644 --- a/Examples/python/docstrings/Makefile +++ b/Examples/python/docstrings/Makefile @@ -21,3 +21,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile index f331b8203..74625b992 100644 --- a/Examples/python/enum/Makefile +++ b/Examples/python/enum/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile index 17c4f30b7..7dbdde944 100644 --- a/Examples/python/exception/Makefile +++ b/Examples/python/exception/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/exceptproxy/Makefile +++ b/Examples/python/exceptproxy/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile index ad36d7d7e..a29276e58 100644 --- a/Examples/python/extend/Makefile +++ b/Examples/python/extend/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/funcptr/Makefile +++ b/Examples/python/funcptr/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/funcptr2/Makefile +++ b/Examples/python/funcptr2/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile index c45536529..fe389757a 100644 --- a/Examples/python/functor/Makefile +++ b/Examples/python/functor/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile index e00e81864..74d4f88cf 100644 --- a/Examples/python/import/Makefile +++ b/Examples/python/import/Makefile @@ -19,3 +19,4 @@ clean:: @rm -f foo.py bar.py spam.py base.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp index edb45811b..17b05cc39 100644 --- a/Examples/python/import/bar.dsp +++ b/Examples/python/import/bar.dsp @@ -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
diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp index 0ddb65157..2bc9736d1 100644 --- a/Examples/python/import/base.dsp +++ b/Examples/python/import/base.dsp @@ -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
diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp index 86e11699f..9a92c4b85 100644 --- a/Examples/python/import/foo.dsp +++ b/Examples/python/import/foo.dsp @@ -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
diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp index 7245f7a7c..0a6595bfe 100644 --- a/Examples/python/import/spam.dsp +++ b/Examples/python/import/spam.dsp @@ -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
diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile index fa49f3145..ee47e994d 100644 --- a/Examples/python/import_template/Makefile +++ b/Examples/python/import_template/Makefile @@ -19,3 +19,4 @@ clean:: @rm -f foo.py bar.py spam.py base.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile index 8c7edfa65..fafb7de09 100644 --- a/Examples/python/libffi/Makefile +++ b/Examples/python/libffi/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/multimap/Makefile +++ b/Examples/python/multimap/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp index 7a32f4dc1..32845e0e8 100644 --- a/Examples/python/multimap/example.dsp +++ b/Examples/python/multimap/example.dsp @@ -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
diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i index 163d7cc8e..f1c4d9990 100644 --- a/Examples/python/multimap/example.i +++ b/Examples/python/multimap/example.i @@ -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); } diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile index c45536529..fe389757a 100644 --- a/Examples/python/operator/Makefile +++ b/Examples/python/operator/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/pointer/Makefile +++ b/Examples/python/pointer/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile index f331b8203..74625b992 100644 --- a/Examples/python/reference/Makefile +++ b/Examples/python/reference/Makefile @@ -18,3 +18,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/simple/Makefile +++ b/Examples/python/simple/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp index 7a32f4dc1..32845e0e8 100644 --- a/Examples/python/simple/example.dsp +++ b/Examples/python/simple/example.dsp @@ -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
diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile index 58d139643..f73802a6b 100644 --- a/Examples/python/smartptr/Makefile +++ b/Examples/python/smartptr/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile index 2d4c1b4a3..5d13da764 100644 --- a/Examples/python/std_map/Makefile +++ b/Examples/python/std_map/Makefile @@ -22,3 +22,4 @@ run: python runme.py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/std_map/example.i b/Examples/python/std_map/example.i index 36354a882..6a7af7108 100644 --- a/Examples/python/std_map/example.i +++ b/Examples/python/std_map/example.i @@ -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>; diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/std_vector/Makefile +++ b/Examples/python/std_vector/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile index 53bf701c9..2142be5bb 100644 --- a/Examples/python/swigrun/Makefile +++ b/Examples/python/swigrun/Makefile @@ -22,3 +22,4 @@ clean:: check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile index a4f334311..ba5c79827 100644 --- a/Examples/python/template/Makefile +++ b/Examples/python/template/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile index 01d0f943a..1420b4e0b 100644 --- a/Examples/python/varargs/Makefile +++ b/Examples/python/varargs/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile index 4a1e1bb71..0f4a1e077 100644 --- a/Examples/python/variables/Makefile +++ b/Examples/python/variables/Makefile @@ -17,3 +17,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/python/weave/Makefile b/Examples/python/weave/Makefile index 822779bd1..88f95c095 100644 --- a/Examples/python/weave/Makefile +++ b/Examples/python/weave/Makefile @@ -19,3 +19,4 @@ clean:: rm -f $(TARGET).py check: all + $(MAKE) -f $(TOP)/Makefile python_run diff --git a/Examples/r/class/example.dsp b/Examples/r/class/example.dsp index 682b156fb..b831989cc 100644 --- a/Examples/r/class/example.dsp +++ b/Examples/r/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath)
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath)
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
# End Custom Build
diff --git a/Examples/r/simple/example.dsp b/Examples/r/simple/example.dsp index aaa5ef8e0..356815d19 100644 --- a/Examples/r/simple/example.dsp +++ b/Examples/r/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -r $(InputPath)
+ ..\..\..\swig.exe -r $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -r $(InputPath)
+ ..\..\..\swig.exe -r $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp index 9a26322ec..2adab787a 100644 --- a/Examples/ruby/class/example.dsp +++ b/Examples/ruby/class/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp index 9a26322ec..2adab787a 100644 --- a/Examples/ruby/free_function/example.dsp +++ b/Examples/ruby/free_function/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/free_function/example.i b/Examples/ruby/free_function/example.i index 5ab29bd58..a446b3f99 100644 --- a/Examples/ruby/free_function/example.i +++ b/Examples/ruby/free_function/example.i @@ -20,7 +20,7 @@ static void free_Zoo(void* ptr) { Zoo* zoo = (Zoo*) ptr; - /* Loop over each object and call SWIG_RemoveMapping */ + /* Loop over each object and call SWIG_RubyRemoveTracking */ int count = zoo->get_num_animals(); for(int i = 0; i < count; ++i) { @@ -32,7 +32,7 @@ SWIG_RubyRemoveTracking(animal); } - /* Now call SWIG_RemoveMapping for the zoo */ + /* Now call SWIG_RubyRemoveTracking for the zoo */ SWIG_RubyRemoveTracking(ptr); /* Now free the zoo which will free the animals it contains */ diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile index a2fbbd397..a2fbbd397 100755..100644 --- a/Examples/ruby/hashargs/Makefile +++ b/Examples/ruby/hashargs/Makefile diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i index 159bbd32a..159bbd32a 100755..100644 --- a/Examples/ruby/hashargs/example.i +++ b/Examples/ruby/hashargs/example.i diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp index dd09ca021..29d9abf2f 100644 --- a/Examples/ruby/import/bar.dsp +++ b/Examples/ruby/import/bar.dsp @@ -120,7 +120,7 @@ InputName=bar echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=bar echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp index 2bd4fa243..174afef3e 100644 --- a/Examples/ruby/import/base.dsp +++ b/Examples/ruby/import/base.dsp @@ -120,7 +120,7 @@ InputName=base echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=base echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp index 2a764bbd7..7f4754915 100644 --- a/Examples/ruby/import/foo.dsp +++ b/Examples/ruby/import/foo.dsp @@ -120,7 +120,7 @@ InputName=foo echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=foo echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp index d2d7158bb..72729f290 100644 --- a/Examples/ruby/import/spam.dsp +++ b/Examples/ruby/import/spam.dsp @@ -120,7 +120,7 @@ InputName=spam echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=spam echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp index 9a26322ec..2adab787a 100644 --- a/Examples/ruby/mark_function/example.dsp +++ b/Examples/ruby/mark_function/example.dsp @@ -128,7 +128,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/multimap/example.dsp b/Examples/ruby/multimap/example.dsp index ccb99d44d..4888299f5 100644 --- a/Examples/ruby/multimap/example.dsp +++ b/Examples/ruby/multimap/example.dsp @@ -124,7 +124,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
@@ -139,7 +139,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/simple/example.dsp b/Examples/ruby/simple/example.dsp index ccb99d44d..4888299f5 100644 --- a/Examples/ruby/simple/example.dsp +++ b/Examples/ruby/simple/example.dsp @@ -124,7 +124,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
@@ -139,7 +139,7 @@ InputName=example echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb index 1529d38c6..851190536 100644 --- a/Examples/ruby/std_vector/runme.rb +++ b/Examples/ruby/std_vector/runme.rb @@ -9,7 +9,7 @@ puts Example::average([1,2,3,4]) # ... or a wrapped std::vector<int> v = Example::IntVector.new(4) -0.upto(v.length-1) { |i| v[i] = i+1 } +0.upto(v.size-1) { |i| v[i] = i+1 } puts Example::average(v) @@ -17,7 +17,7 @@ puts Example::average(v) # Call it with a Ruby array... w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0]) -0.upto(w.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # ... or a wrapped std::vector<double> @@ -25,12 +25,12 @@ puts v = Example::DoubleVector.new [1,2,3,4].each { |i| v.push(i) } w = Example::half(v) -0.upto(w.length-1) { |i| print w[i],"; " } +0.upto(w.size-1) { |i| print w[i],"; " } puts # now halve a wrapped std::vector<double> in place Example::halve_in_place(v) -0.upto(v.length-1) { |i| print v[i],"; " } +0.upto(v.size-1) { |i| print v[i],"; " } puts diff --git a/Examples/tcl/class/example.dsp b/Examples/tcl/class/example.dsp index bf6149407..0ff54829f 100644 --- a/Examples/tcl/class/example.dsp +++ b/Examples/tcl/class/example.dsp @@ -126,7 +126,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/contract/example.dsp b/Examples/tcl/contract/example.dsp index 296cb313b..c1568f2c5 100644 --- a/Examples/tcl/contract/example.dsp +++ b/Examples/tcl/contract/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/bar.dsp b/Examples/tcl/import/bar.dsp index 35b4e608b..d22b6a6fa 100644 --- a/Examples/tcl/import/bar.dsp +++ b/Examples/tcl/import/bar.dsp @@ -118,7 +118,7 @@ InputName=bar echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/base.dsp b/Examples/tcl/import/base.dsp index 74870ccb0..b27bbfdb6 100644 --- a/Examples/tcl/import/base.dsp +++ b/Examples/tcl/import/base.dsp @@ -118,7 +118,7 @@ InputName=base echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/foo.dsp b/Examples/tcl/import/foo.dsp index ac7f09f06..4d3765bd7 100644 --- a/Examples/tcl/import/foo.dsp +++ b/Examples/tcl/import/foo.dsp @@ -118,7 +118,7 @@ InputName=foo echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/spam.dsp b/Examples/tcl/import/spam.dsp index db9ade0a3..5674c4373 100644 --- a/Examples/tcl/import/spam.dsp +++ b/Examples/tcl/import/spam.dsp @@ -118,7 +118,7 @@ InputName=spam echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/multimap/example.dsp b/Examples/tcl/multimap/example.dsp index 296cb313b..c1568f2c5 100644 --- a/Examples/tcl/multimap/example.dsp +++ b/Examples/tcl/multimap/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/simple/example.dsp b/Examples/tcl/simple/example.dsp index 296cb313b..c1568f2c5 100644 --- a/Examples/tcl/simple/example.dsp +++ b/Examples/tcl/simple/example.dsp @@ -122,7 +122,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in index 394d2d524..df7193389 100644 --- a/Examples/test-suite/allegrocl/Makefile.in +++ b/Examples/test-suite/allegrocl/Makefile.in @@ -9,116 +9,75 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ + +# these cpp tests generate warnings/errors when compiling +# the wrapper .cxx file. +CPP_TEST_BROKEN_CXX = +# the error is wrap:action code generated by swig. \ +# error: can't convert [std::string] 'b' to 'bool' \ +# might just need a bool overload op for std::string. \ + global_vars \ +# same as w/ global_vars but with more errors in cxx file \ + naturalvar \ + # these cpp tests aren't working. Fix 'em # need to further separate these into tests requiring # std libraries, or the $ldestructor problem. CPP_TEST_BROKEN_ACL = \ - array_member \ - char_strings \ - class_ignore \ - constant_pointers \ contract \ + allprotected \ +# 'throws' typemap entries. \ cplusplus_throw \ - cpp_basic \ - cpp_enum \ - cpp_typedef \ - default_constructor \ +# 'throws' typemap entries. \ default_args \ +# missing typemaps. suspect module support needed \ dynamic_cast \ - enum_thorough \ extend_variable \ - global_vars \ - import_nomodule \ - kind \ - li_carrays \ +# cdata.i support needed \ li_cdata \ - li_windows \ - namespace_class \ - namespace_spaces \ - naturalvar \ +# warning generated. otherwise all good. \ operator_overload \ - overload_simple \ - register_par \ +# std_common.i support \ sizet \ - smart_pointer_extend \ - smart_pointer_namespace \ - template \ - template_classes \ +# std_vector.i support. \ template_default \ - template_default_inherit \ - template_enum \ - template_explicit \ - template_extend_overload \ - template_ns \ - template_ns4 \ - template_ns_enum \ - template_rename \ - template_retvalue \ - template_static \ - template_tbase_template \ - template_typedef \ - template_typedef_cplx \ - template_typedef_cplx2 \ - template_typedef_cplx3 \ - template_typedef_cplx4 \ - template_typedef_cplx5 \ - template_typedef_ns \ - template_typedef_rec \ - threads \ - typedef_array_member \ - typedef_sizet \ +# *** line 31. can't copy typemap?? \ typemap_namespace \ - union_scope \ - using_pointers \ - valuewrapper_opaque \ - varargs \ - virtual_poly \ - voidtest \ - wrapmacro # these aren't working due to longlong support. (low hanging fruit) CPP_TEST_BROKEN_LONGLONG = \ arrays_dimensionless \ arrays_global \ arrays_global_twodim \ - li_stdint \ li_typemaps \ + li_windows \ long_long_apply \ - mixed_types \ primitive_ref \ reference_global_vars \ template_default_arg # These are currently unsupported. CPP_TEST_CASES_ACL_UNSUPPORTED = \ +# contract support \ aggregate \ +# directors support \ + apply_signed_char \ +# contract support \ contract \ - director_abstract \ - director_basic \ - director_constructor \ - director_detect \ - director_default \ - director_enum \ director_exception \ - director_frob \ - director_finalizer \ - director_nested \ director_protected \ - director_redefined \ - director_unroll \ - director_using \ - director_wombat \ exception_order \ +# 'throws' typemap support \ extern_throws \ - throw_exception + throw_exception \ + using_pointers \ C_TEST_CASES_ACL_BROKEN = \ - arrays \ - enums \ - extern_declaration \ - immutable \ - integers \ +# 'cdate.i' module support \ li_cdata \ +# adding an existing type defnition... \ + typedef_struct \ +# swigrun.swg support. \ typemap_subst C_TEST_BROKEN_LONGLONG = \ @@ -128,12 +87,10 @@ C_TEST_BROKEN_LONGLONG = \ # std lib support hasn't been done yet. SKIP_CPP_STD_CASES = Yes -C_TEST_CASES = - -CPP_TEST_CASES = - include $(srcdir)/../common.mk +# SWIGOPT += -debug-module 4 + # Rules for the different types of tests %.cpptest: $(setup) @@ -157,9 +114,8 @@ run_testcase = \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ fi; -# Clean: (does nothing, we dont generate extra allegrocl code) %.clean: - + @rm -f $*.cl clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean diff --git a/Examples/test-suite/python/argcargvtest.i b/Examples/test-suite/argcargvtest.i index ed5aa0985..ed5aa0985 100644 --- a/Examples/test-suite/python/argcargvtest.i +++ b/Examples/test-suite/argcargvtest.i diff --git a/Examples/test-suite/python/callback.i b/Examples/test-suite/callback.i index c4d50d3fe..c4d50d3fe 100644 --- a/Examples/test-suite/python/callback.i +++ b/Examples/test-suite/callback.i diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i index 126a58215..12e4b5aa2 100644 --- a/Examples/test-suite/char_strings.i +++ b/Examples/test-suite/char_strings.i @@ -9,8 +9,13 @@ below. %warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[] %warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory. +#ifdef SWIG_ALLEGRO_CL %{ #include <stdio.h> +%} +#endif + +%{ #define OTHERLAND_MSG "Little message from the safe world." #define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible." static char *global_str = NULL; diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in index ef6d7056c..764518880 100644 --- a/Examples/test-suite/chicken/Makefile.in +++ b/Examples/test-suite/chicken/Makefile.in @@ -19,7 +19,7 @@ SKIP_CPP_STD_CASES = Yes CPP_TEST_CASES += li_std_string -EXTRA_TEST_CASES += ext_test.externaltest +EXTRA_TEST_CASES += chicken_ext_test.externaltest include $(srcdir)/../common.mk diff --git a/Examples/test-suite/chicken/ext_test_runme.ss b/Examples/test-suite/chicken/chicken_ext_test_runme.ss index ea3eaa487..65fa4e085 100644 --- a/Examples/test-suite/chicken/ext_test_runme.ss +++ b/Examples/test-suite/chicken/chicken_ext_test_runme.ss @@ -1,4 +1,4 @@ -(load "ext_test.so") +(load "chicken_ext_test.so") (define a (test-create)) diff --git a/Examples/test-suite/chicken/ext_test.i b/Examples/test-suite/chicken_ext_test.i index e8f5930df..b4f726cc7 100644 --- a/Examples/test-suite/chicken/ext_test.i +++ b/Examples/test-suite/chicken_ext_test.i @@ -1,4 +1,4 @@ -%module ext_test +%module chicken_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 7bf8474a3..7afb55bb2 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -59,11 +59,12 @@ CXXSRCS = CSRCS = TARGETPREFIX = TARGETSUFFIX = -SWIGOPT = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -DSWIG_NOEXTRA_QUALIFICATION -INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) +INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) LIBS = -L. LIBPREFIX = lib ACTION = check +INTERFACEDIR = $(if $(wildcard $*.i), ./, ../) # # Please keep test cases in alphabetical order. @@ -76,8 +77,9 @@ CPP_TEST_BROKEN += \ cpp_broken \ exception_partial_info \ extend_variable \ + li_std_vector_ptr \ namespace_union \ - nested_comment \ + nested_struct \ overload_complicated \ template_default_pointer \ template_expr @@ -164,6 +166,7 @@ CPP_TEST_CASES += \ director_overload \ director_primitives \ director_protected \ + director_protected_overloaded \ director_redefined \ director_thread \ director_unroll \ @@ -191,6 +194,7 @@ CPP_TEST_CASES += \ fragments \ friends \ fvirtual \ + global_namespace \ global_ns_arg \ global_vars \ grouping \ @@ -205,6 +209,7 @@ CPP_TEST_CASES += \ inherit_target_language \ inherit_void_arg \ inline_initializer \ + insert_directive \ keyword_rename \ kind \ langobj \ @@ -236,10 +241,12 @@ CPP_TEST_CASES += \ namespace_typemap \ namespace_virtual_method \ naturalvar \ + nested_comment \ newobject1 \ null_pointer \ operator_overload \ operator_overload_break \ + operbool \ ordering \ overload_copy \ overload_extend \ @@ -262,6 +269,7 @@ CPP_TEST_CASES += \ rename3 \ rename4 \ rename_scope \ + rename_strip_encoder \ restrict_cplusplus \ return_const_value \ return_value_scope \ @@ -366,6 +374,7 @@ CPP_TEST_CASES += \ typemap_namespace \ typemap_ns_using \ typemap_numinputs \ + typemap_out_optimal \ typemap_variables \ typemap_various \ typename \ @@ -406,6 +415,7 @@ CPP_STD_TEST_CASES += \ template_typedef_fnc \ template_type_namespace \ template_opaque +# li_std_list ifndef SKIP_CPP_STD_CASES @@ -442,11 +452,13 @@ C_TEST_CASES += \ overload_extendc \ preproc \ ret_by_value \ + simple_array \ sizeof_pointer \ sneaky1 \ struct_rename \ typedef_struct \ typemap_subst \ + union_parameter \ unions @@ -492,14 +504,14 @@ swig_and_compile_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_c = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT) swig_and_compile_multi_cpp = \ @@ -507,7 +519,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done @@ -519,7 +531,7 @@ swig_and_compile_external = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \ - TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \ + TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \ $(LANGUAGE)$(VARIANT)_cpp swig_and_compile_runtime = \ diff --git a/Examples/test-suite/python/complextest.i b/Examples/test-suite/complextest.i index 64c751a82..64c751a82 100644 --- a/Examples/test-suite/python/complextest.i +++ b/Examples/test-suite/complextest.i diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i index 760f8e994..174808c1e 100644 --- a/Examples/test-suite/contract.i +++ b/Examples/test-suite/contract.i @@ -202,3 +202,33 @@ struct E { }; %} + +// Namespace + +%{ +namespace myNames { + +class myClass +{ + public: + myClass(int i) {} +}; + +} +%} + +namespace myNames { + +%contract myClass::myClass( int i ) { +require: + i > 0; +} + +class myClass +{ + public: + myClass(int i) {} +}; + +} + diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in index 5fd576ed8..5fb547f3f 100644 --- a/Examples/test-suite/csharp/Makefile.in +++ b/Examples/test-suite/csharp/Makefile.in @@ -21,12 +21,17 @@ CPP_TEST_CASES = \ enum_thorough_typesafe \ exception_partial_info -CUSTOM_TEST_CASES = intermediary_classname +CUSTOM_TEST_CASES = \ + csharp_lib_arrays \ + intermediary_classname include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) +INTERFACEDIR = ../../ + +CSHARPFLAGSSPECIAL = # Rules for the different types of tests %.cpptest: @@ -47,6 +52,8 @@ SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL) # Rules for custom tests intermediary_classname.customtest: $(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname" +csharp_lib_arrays.customtest: + $(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe" # Makes a directory for the testcase if it does not exist setup = \ @@ -65,14 +72,14 @@ setup = \ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ - CSHARPFLAGS='-nologo -out:$*_runme.exe' \ + CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \ $*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \ else ( \ cd $* && \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ - CSHARPFLAGS='-nologo -t:module -out:$*.netmodule' \ + CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ CSHARPSRCS='*.cs' csharp_compile; ); \ fi; diff --git a/Examples/test-suite/csharp/bools_runme.cs b/Examples/test-suite/csharp/bools_runme.cs index 70620fcef..70620fcef 100755..100644 --- a/Examples/test-suite/csharp/bools_runme.cs +++ b/Examples/test-suite/csharp/bools_runme.cs diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs new file mode 100644 index 000000000..9f3ea6b88 --- /dev/null +++ b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs @@ -0,0 +1,70 @@ +using System; +using csharp_lib_arraysNamespace; + +public class runme +{ + static void Main() + { + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[ source.Length ]; + + csharp_lib_arrays.myArrayCopy( source, target, target.Length ); + CompareArrays(source, target); + } + + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[ source.Length ]; + + csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length ); + CompareArrays(source, target); + } + + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[] { 6, 7, 8, 9, 10 }; + + csharp_lib_arrays.myArraySwap( source, target, target.Length ); + + for (int i=0; i<target.Length; ++i) + target[i] += 5; + CompareArrays(source, target); + } + + { + int[] source = { 1, 2, 3, 4, 5 }; + int[] target = new int[] { 6, 7, 8, 9, 10 }; + + csharp_lib_arrays.myArraySwapUsingFixedArrays( source, target, target.Length ); + + for (int i=0; i<target.Length; ++i) + target[i] += 5; + CompareArrays(source, target); + } + } + + static void CompareArrays( int[] a, int[] b ) + { + if (a.Length != b.Length) + throw new Exception("size mismatch"); + + for(int i=0; i<a.Length; ++i) { + if (a[i] != b[i]) { + Console.Error.WriteLine("a:"); + PrintArray(a); + Console.Error.WriteLine("b:"); + PrintArray(b); + throw new Exception("element mismatch"); + } + } + } + + static void PrintArray( int[] a ) + { + foreach ( int i in a ) + Console.Error.Write( "{0} ", i ); + Console.Error.WriteLine(); + } +} + diff --git a/Examples/test-suite/csharp/director_classic_runme.cs b/Examples/test-suite/csharp/director_classic_runme.cs index 7220437d5..7220437d5 100755..100644 --- a/Examples/test-suite/csharp/director_classic_runme.cs +++ b/Examples/test-suite/csharp/director_classic_runme.cs diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs index 765347e4b..144736f2b 100755..100644 --- a/Examples/test-suite/csharp/enum_thorough_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_runme.cs @@ -358,12 +358,51 @@ public class runme { i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed"); + if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed"); + } + { + if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed"); + if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed"); + if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed"); + if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed"); + if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed"); + if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed"); + } + { + if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed"); + if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed"); + if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed"); + if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed"); + if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed"); + if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed"); + } + { + if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed"); + if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed"); + } + { + if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed"); + if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed"); + if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed"); + } + // ignore enum item tests end { if ((int)enum_thorough.repeatTest(repeat.one) != 1) throw new Exception("repeatTest 1 failed"); if ((int)enum_thorough.repeatTest(repeat.initial) != 1) throw new Exception("repeatTest 2 failed"); if ((int)enum_thorough.repeatTest(repeat.two) != 2) throw new Exception("repeatTest 3 failed"); if ((int)enum_thorough.repeatTest(repeat.three) != 3) throw new Exception("repeatTest 4 failed"); - if ((int)enum_thorough.repeatTest(repeat.last) != 3) throw new Exception("repeatTest 5 failed"); + if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed"); if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs index f8556ff37..d5bba1b7d 100644 --- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs @@ -358,12 +358,51 @@ public class runme { i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed"); + } + { + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed"); + } + { + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed"); + } + { + if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed"); + if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed"); + } + { + if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed"); + if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed"); + if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed"); + } + // ignore enum item tests end { if (enum_thorough_simple.repeatTest(enum_thorough_simple.one) != 1) throw new Exception("repeatTest 1 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.initial) != 1) throw new Exception("repeatTest 2 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.two) != 2) throw new Exception("repeatTest 3 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.three) != 3) throw new Exception("repeatTest 4 failed"); - if (enum_thorough_simple.repeatTest(enum_thorough_simple.last) != 3) throw new Exception("repeatTest 5 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs index dc2a981de..3606d1137 100644 --- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs +++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs @@ -358,12 +358,51 @@ public class runme { i.MemberInstance = Instances.memberinstance3; if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue != 0) throw new Exception("ignoreATest 0 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue != 3) throw new Exception("ignoreATest 3 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue != 10) throw new Exception("ignoreATest 10 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue != 11) throw new Exception("ignoreATest 11 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue != 13) throw new Exception("ignoreATest 13 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue != 14) throw new Exception("ignoreATest 14 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue != 20) throw new Exception("ignoreATest 20 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue != 30) throw new Exception("ignoreATest 30 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue != 32) throw new Exception("ignoreATest 32 failed"); + if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue != 33) throw new Exception("ignoreATest 33 failed"); + } + { + if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue != 11) throw new Exception("ignoreBTest 11 failed"); + if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue != 12) throw new Exception("ignoreBTest 12 failed"); + if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue != 31) throw new Exception("ignoreBTest 31 failed"); + if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue != 32) throw new Exception("ignoreBTest 32 failed"); + if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue != 41) throw new Exception("ignoreBTest 41 failed"); + if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue != 42) throw new Exception("ignoreBTest 42 failed"); + } + { + if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue != 10) throw new Exception("ignoreCTest 10 failed"); + if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue != 12) throw new Exception("ignoreCTest 12 failed"); + if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue != 30) throw new Exception("ignoreCTest 30 failed"); + if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue != 32) throw new Exception("ignoreCTest 32 failed"); + if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue != 40) throw new Exception("ignoreCTest 40 failed"); + if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue != 42) throw new Exception("ignoreCTest 42 failed"); + } + { + if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue != 21) throw new Exception("ignoreDTest 21 failed"); + if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue != 22) throw new Exception("ignoreDTest 22 failed"); + } + { + if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue != 0) throw new Exception("ignoreETest 0 failed"); + if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue != 21) throw new Exception("ignoreETest 21 failed"); + if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue != 22) throw new Exception("ignoreETest 22 failed"); + } + // ignore enum item tests end { if (enum_thorough_typesafe.repeatTest(repeat.one).swigValue != 1) throw new Exception("repeatTest 1 failed"); if (enum_thorough_typesafe.repeatTest(repeat.initial).swigValue != 1) throw new Exception("repeatTest 2 failed"); if (enum_thorough_typesafe.repeatTest(repeat.two).swigValue != 2) throw new Exception("repeatTest 3 failed"); if (enum_thorough_typesafe.repeatTest(repeat.three).swigValue != 3) throw new Exception("repeatTest 4 failed"); - if (enum_thorough_typesafe.repeatTest(repeat.last).swigValue != 3) throw new Exception("repeatTest 5 failed"); + if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/csharp/inherit_target_language_runme.cs b/Examples/test-suite/csharp/inherit_target_language_runme.cs new file mode 100644 index 000000000..2f9e2a75d --- /dev/null +++ b/Examples/test-suite/csharp/inherit_target_language_runme.cs @@ -0,0 +1,24 @@ +using System; +using inherit_target_languageNamespace; + +public class inherit_target_language_runme { + public static void Main() { + new Derived1().targetLanguageBaseMethod(); + new Derived2().targetLanguageBaseMethod(); + + new MultipleDerived1().targetLanguageBaseMethod(); + new MultipleDerived2().targetLanguageBaseMethod(); + new MultipleDerived3().f(); + new MultipleDerived4().g(); + + BaseX baseX = new BaseX(); + baseX.basex(); + baseX.targetLanguageBase2Method(); + + DerivedX derivedX = new DerivedX(); + derivedX.basex(); + derivedX.derivedx(); + derivedX.targetLanguageBase2Method(); + } +} + diff --git a/Examples/test-suite/csharp/li_attribute_runme.cs b/Examples/test-suite/csharp/li_attribute_runme.cs new file mode 100644 index 000000000..46f982637 --- /dev/null +++ b/Examples/test-suite/csharp/li_attribute_runme.cs @@ -0,0 +1,78 @@ +// Ported from Python li_attribute_runme.py + +using System; +using li_attributeNamespace; + +public class li_attribute_runme { + + public static void Main() { + A aa = new A(1,2,3); + + if (aa.a != 1) + throw new ApplicationException("error"); + aa.a = 3; + if (aa.a != 3) + throw new ApplicationException("error"); + + if (aa.b != 2) + throw new ApplicationException("error"); + aa.b = 5; + if (aa.b != 5) + throw new ApplicationException("error"); + + if (aa.d != aa.b) + throw new ApplicationException("error"); + + if (aa.c != 3) + throw new ApplicationException("error"); + //aa.c = 5; + //if (aa.c != 3) + // throw new ApplicationException("error"); + + Param_i pi = new Param_i(7); + if (pi.value != 7) + throw new ApplicationException("error"); + + pi.value=3; + if (pi.value != 3) + throw new ApplicationException("error"); + + B b = new B(aa); + + if (b.a.c != 3) + throw new ApplicationException("error"); + + // class/struct attribute with get/set methods using return/pass by reference + MyFoo myFoo = new MyFoo(); + myFoo.x = 8; + MyClass myClass = new MyClass(); + myClass.Foo = myFoo; + if (myClass.Foo.x != 8) + throw new ApplicationException("error"); + + // class/struct attribute with get/set methods using return/pass by value + MyClassVal myClassVal = new MyClassVal(); + if (myClassVal.ReadWriteFoo.x != -1) + throw new ApplicationException("error"); + if (myClassVal.ReadOnlyFoo.x != -1) + throw new ApplicationException("error"); + myClassVal.ReadWriteFoo = myFoo; + if (myClassVal.ReadWriteFoo.x != 8) + throw new ApplicationException("error"); + if (myClassVal.ReadOnlyFoo.x != 8) + throw new ApplicationException("error"); + + // string attribute with get/set methods using return/pass by value + MyStringyClass myStringClass = new MyStringyClass("initial string"); + if (myStringClass.ReadWriteString != "initial string") + throw new ApplicationException("error"); + if (myStringClass.ReadOnlyString != "initial string") + throw new ApplicationException("error"); + myStringClass.ReadWriteString = "changed string"; + if (myStringClass.ReadWriteString != "changed string") + throw new ApplicationException("error"); + if (myStringClass.ReadOnlyString != "changed string") + throw new ApplicationException("error"); + } +} + diff --git a/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs b/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs index 27bc4628f..6ded989b5 100644 --- a/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs +++ b/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs @@ -345,6 +345,16 @@ public class runme verifyCount(1, kret); } + // 3rd derived class + { + Klass k = new Klass3rdDerived("me oh my"); + String val = k.getValue(); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values + val = li_boost_shared_ptr.test3rdupcast(k); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); + } ////////////////////////////////// Member variables //////////////////////////////////////// // smart pointer by value diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs new file mode 100644 index 000000000..685b20e47 --- /dev/null +++ b/Examples/test-suite/csharp/li_std_map_runme.cs @@ -0,0 +1,243 @@ +/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * li_std_map_runme.cs
+ *
+ * SWIG C# tester for std_map.i
+ * Implementation by Yuval Baror (http://yuval.bar-or.org)
+ *
+ * This class tests all the functionality of the std_map.i wrapper.
+ * Upon successful testing, the main function doesn't print out anything.
+ * If any error is found - it will be printed on the screen.
+ * ----------------------------------------------------------------------------- */
+
+using System;
+using System.Collections.Generic;
+using li_std_mapNamespace;
+
+public class li_std_map_runme {
+
+ private static readonly int collectionSize = 20;
+ private static readonly int midCollection = collectionSize / 2;
+
+ public static void Main()
+ {
+ // Set up an int int map
+ StringIntMap simap = new StringIntMap();
+ for (int i = 0; i < collectionSize; i++)
+ {
+ int val = i * 18;
+ simap.Add(i.ToString(), val);
+ }
+
+ // Count property test
+ if (simap.Count != collectionSize)
+ throw new Exception("Count test failed");
+
+ // IsReadOnly property test
+ if (simap.IsReadOnly)
+ throw new Exception("IsReadOnly test failed");
+
+ // Item indexing test
+ simap["0"] = 200;
+ if (simap["0"] != 200)
+ throw new Exception("Item property test failed");
+ simap["0"] = 0 * 18;
+
+ // ContainsKey() test
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!simap.ContainsKey(i.ToString()))
+ throw new Exception("ContainsKey test " + i + " failed");
+ }
+
+ // ContainsKey() test
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!simap.Contains(new KeyValuePair<string, int>(i.ToString(), i * 18)))
+ throw new Exception("Contains test " + i + " failed");
+ }
+
+ // TryGetValue() test
+ int value;
+ bool rc = simap.TryGetValue("3", out value);
+ if (rc != true || value != (3 * 18))
+ throw new Exception("TryGetValue test 1 failed");
+
+ rc = simap.TryGetValue("-1", out value);
+ if (rc != false)
+ throw new Exception("TryGetValue test 2 failed");
+
+ // Keys and Values test
+ {
+ IList<string> keys = new List<string>(simap.Keys);
+ IList<int> values = new List<int>(simap.Values);
+ if (keys.Count != collectionSize)
+ throw new Exception("Keys count test failed");
+
+ if (values.Count != collectionSize)
+ throw new Exception("Values count test failed");
+
+ for (int i = 0; i < keys.Count; i++)
+ {
+ if (simap[keys[i]] != values[i])
+ throw new Exception("Keys and values test failed for index " + i);
+ }
+ }
+
+ // Add and Remove test
+ for (int i = 100; i < 103; i++)
+ {
+ simap.Add(i.ToString(), i * 18);
+ if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
+ throw new Exception("Add test failed for index " + i);
+
+ simap.Remove(i.ToString());
+ if (simap.ContainsKey(i.ToString()))
+ throw new Exception("Remove test failed for index " + i);
+ }
+
+ for (int i = 200; i < 203; i++)
+ {
+ simap.Add(new KeyValuePair<string, int>(i.ToString(), i * 18));
+ if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
+ throw new Exception("Add explicit test failed for index " + i);
+
+ simap.Remove(new KeyValuePair<string, int>(i.ToString(), i * 18));
+ if (simap.ContainsKey(i.ToString()))
+ throw new Exception("Remove explicit test failed for index " + i);
+ }
+
+ // Duplicate key test
+ try
+ {
+ simap.Add("3", 0);
+ throw new Exception("Adding duplicate key test failed");
+ }
+ catch (ArgumentException)
+ {
+ }
+
+ // CopyTo() test
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize];
+ simap.CopyTo(outputarray);
+ foreach (KeyValuePair<string, int> val in outputarray)
+ {
+ if (simap[val.Key] != val.Value)
+ throw new Exception("CopyTo (1) test failed, index:" + val.Key);
+ }
+ }
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[midCollection + collectionSize];
+ simap.CopyTo(outputarray, midCollection);
+ for (int i = midCollection; i < midCollection + collectionSize; i++)
+ {
+ KeyValuePair<string, int> val = outputarray[i];
+ if (simap[val.Key] != val.Value)
+ throw new Exception("CopyTo (2) test failed, index:" + val.Key);
+ }
+ }
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize - 1];
+ try
+ {
+ simap.CopyTo(outputarray);
+ throw new Exception("CopyTo (4) test failed");
+ }
+ catch (ArgumentException)
+ {
+ }
+ }
+
+ // Clear test
+ simap.Clear();
+ if (simap.Count != 0)
+ throw new Exception("Clear test failed");
+
+ // Test wrapped methods
+ for (int i = 1; i <= 5; i++)
+ {
+ simap[i.ToString()] = i;
+ }
+ double avg = li_std_map.valueAverage(simap);
+ if (avg != 3.0)
+ throw new Exception("Wrapped method valueAverage test failed. Got " + avg);
+
+ string keyStringified = li_std_map.stringifyKeys(simap);
+ if (keyStringified != " 1 2 3 4 5")
+ throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
+
+ // Test a map with a new specialized type (Struct)
+ {
+ IntStructMap ismap = new IntStructMap();
+ for (int i = 0; i < 10; i++)
+ {
+ ismap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (ismap.Count != 10)
+ throw new Exception("Count test on specialized map failed");
+
+ foreach (KeyValuePair<int, Struct> p in ismap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on specialized map failed for index " + p.Key);
+ }
+ }
+
+ // Test a map of pointers
+ {
+ IntStructPtrMap ispmap = new IntStructPtrMap();
+ for (int i = 0; i < 10; i++)
+ {
+ ispmap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (ispmap.Count != 10)
+ throw new Exception("Count test on specialized pointer map failed");
+
+ foreach (KeyValuePair<int, Struct> p in ispmap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on specialized pointer map failed for index " + p.Key);
+ }
+ }
+ {
+ IntStructConstPtrMap iscpmap = new IntStructConstPtrMap();
+ for (int i = 0; i < 10; i++)
+ {
+ iscpmap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (iscpmap.Count != 10)
+ throw new Exception("Count test on specialized const pointer map failed");
+
+ foreach (KeyValuePair<int, Struct> p in iscpmap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on specialized const pointer map failed for index " + p.Key);
+ }
+ }
+
+ // Test non-specialized map
+ {
+ StructIntMap limap = new StructIntMap();
+ Struct s7 = new Struct(7);
+ Struct s8 = new Struct(8);
+ limap.setitem(s7 , 8);
+ if (limap.getitem(s7) != 8)
+ throw new Exception("Assignment test on non-specialized map failed");
+
+ if (!limap.ContainsKey(s7))
+ throw new Exception("Key test (1) on non-specialized map failed");
+
+ if (limap.ContainsKey(s8))
+ throw new Exception("Key test (2) on non-specialized map failed");
+ }
+
+ // All done
+ }
+}
+
diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs index 718087336..a2da91e15 100644 --- a/Examples/test-suite/csharp/li_std_vector_runme.cs +++ b/Examples/test-suite/csharp/li_std_vector_runme.cs @@ -82,14 +82,17 @@ public class li_std_vector_runme { } catch (ArgumentException) { } } +#if SWIG_DOTNET_1 { + // runtime check that 2D arrays fail double[,] outputarray = new double[collectionSize,collectionSize]; try { vect.CopyTo(outputarray); - throw new Exception("CopyTo (5) test failed"); + throw new Exception("CopyTo (5a) test failed"); } catch (ArgumentException) { } } +#endif { StructVector inputvector = new StructVector(); int arrayLen = 10; @@ -150,10 +153,13 @@ public class li_std_vector_runme { } } try { - new DoubleVector(null); + new DoubleVector((System.Collections.ICollection)null); throw new Exception("ICollection constructor null test failed"); } catch (ArgumentNullException) { } + { + myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 }; + } // IndexOf() test for (int i=0; i<collectionSize; i++) { @@ -174,6 +180,13 @@ public class li_std_vector_runme { throw new Exception("LastIndexOf non-existent test failed"); if (dv.LastIndexOf(33.3) != 6) throw new Exception("LastIndexOf position test failed"); + + // Copy constructor test + DoubleVector dvCopy = new DoubleVector(dv); + for (int i=0; i<doubleArray.Length; i++) { + if (doubleArray[i] != dvCopy[i]) + throw new Exception("Copy constructor failed, index:" + i); + } } { // Repeat() test @@ -187,11 +200,22 @@ public class li_std_vector_runme { throw new Exception("Repeat count test failed"); // Also tests enumerator - System.Collections.IEnumerator myEnumerator = dv.GetEnumerator(); - while ( myEnumerator.MoveNext() ) { - if ((double)myEnumerator.Current != 77.7) - throw new Exception("Repeat test failed"); + { + System.Collections.IEnumerator myEnumerator = dv.GetEnumerator(); + while ( myEnumerator.MoveNext() ) { + if ((double)myEnumerator.Current != 77.7) + throw new Exception("Repeat (1) test failed"); + } } +#if !SWIG_DOTNET_1 + { + System.Collections.Generic.IEnumerator<double> myEnumerator = dv.GetEnumerator(); + while ( myEnumerator.MoveNext() ) { + if (myEnumerator.Current != 77.7) + throw new Exception("Repeat (2) test failed"); + } + } +#endif } { @@ -516,6 +540,13 @@ public class li_std_vector_runme { li_std_vector.halve_in_place(dvec); } + // Dispose() + { + using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } ) + using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) { + } + } + // More wrapped methods { RealVector v0 = li_std_vector.vecreal(new RealVector()); diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs index fe663a3e0..fe663a3e0 100755..100644 --- a/Examples/test-suite/csharp/li_std_wstring_runme.cs +++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs diff --git a/Examples/test-suite/csharp/overload_complicated_runme.cs b/Examples/test-suite/csharp/overload_complicated_runme.cs index 13741827e..13741827e 100755..100644 --- a/Examples/test-suite/csharp/overload_complicated_runme.cs +++ b/Examples/test-suite/csharp/overload_complicated_runme.cs diff --git a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs new file mode 100644 index 000000000..5bc1d14be --- /dev/null +++ b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs @@ -0,0 +1,13 @@ +using System; +using typemap_out_optimalNamespace; + +public class typemap_out_optimal_runme { + + public static XX x = null; + public static void Main() { + XX.debug = false; + x = XX.create(); + } + +} + diff --git a/Examples/test-suite/csharp_lib_arrays.i b/Examples/test-suite/csharp_lib_arrays.i new file mode 100644 index 000000000..d07d43737 --- /dev/null +++ b/Examples/test-suite/csharp_lib_arrays.i @@ -0,0 +1,61 @@ +%module csharp_lib_arrays + +%include "arrays_csharp.i" + +%apply int INPUT[] { int* sourceArray } +%apply int OUTPUT[] { int* targetArray } + +%apply int INOUT[] { int* array1 } +%apply int INOUT[] { int* array2 } + +%inline %{ +/* copy the contents of the first array to the second */ +void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) { + int i; + for ( i = 0; i < nitems; i++ ) { + targetArray[ i ] = sourceArray[ i ]; + } +} + +/* swap the contents of the two arrays */ +void myArraySwap( int* array1, int* array2, int nitems ) { + int i, temp; + for ( i = 0; i < nitems; i++ ) { + temp = array1[ i ]; + array1[ i ] = array2[ i ]; + array2[ i ] = temp; + } +} +%} + + +%clear int* sourceArray; +%clear int* targetArray; + +%clear int* array1; +%clear int* array2; + + +// Below replicates the above array handling but this time using the pinned (fixed) array typemaps +%csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe"; +%csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe"; + +%apply int FIXED[] { int* sourceArray } +%apply int FIXED[] { int* targetArray } + +%inline %{ +void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) { + myArrayCopy(sourceArray, targetArray, nitems); +} +%} + +%apply int FIXED[] { int* array1 } +%apply int FIXED[] { int* array2 } + +%inline %{ +void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) { + myArraySwap(array1, array2, nitems); +} +%} + + diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i index 9c2cedc83..0c35c1833 100644 --- a/Examples/test-suite/csharp_prepost.i +++ b/Examples/test-suite/csharp_prepost.i @@ -1,6 +1,6 @@ %module csharp_prepost -// Test the pre, post and cshin attributes for csin typemaps +// Test the pre, post, terminate and cshin attributes for csin typemaps %include "std_vector.i" @@ -88,3 +88,102 @@ public: }; %} + + +// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html) +%typemap(cstype) const CDate& "System.DateTime" +%typemap(csin, + pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);" + ) const CDate & + "$csclassname.getCPtr(temp$csinput)" + +%typemap(cstype) CDate& "out System.DateTime" +%typemap(csin, + pre=" CDate temp$csinput = new CDate();", + post=" $csinput = new System.DateTime(temp$csinput.getYear()," + " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", + cshin="out $csinput" + ) CDate & + "$csclassname.getCPtr(temp$csinput)" + + +%inline %{ +class CDate { +public: + CDate(); + CDate(int year, int month, int day); + int getYear(); + int getMonth(); + int getDay(); +private: + int m_year; + int m_month; + int m_day; +}; +struct Action { + int doSomething(const CDate &dateIn, CDate &dateOut); + Action(const CDate &dateIn, CDate& dateOut); +}; +%} + +%{ +Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;} +int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; } +CDate::CDate() : m_year(0), m_month(0), m_day(0) {} +CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {} +int CDate::getYear() { return m_year; } +int CDate::getMonth() { return m_month; } +int CDate::getDay() { return m_day; } +%} + +%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime" + +%typemap(csin, + pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);", + post=" $csinput = new System.DateTime(temp$csinput.getYear()," + " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", + cshin="ref $csinput" + ) CDate * + "$csclassname.getCPtr(temp$csinput)" + +%inline %{ +void addYears(CDate *pDate, int years) { + *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay()); +} +%} + +%typemap(csin, + pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {", + post=" $csinput = new System.DateTime(temp$csinput.getYear()," + " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);", + terminator=" } // terminate temp$csinput using block", + cshin="ref $csinput" + ) CDate * + "$csclassname.getCPtr(temp$csinput)" + +%inline %{ +void subtractYears(CDate *pDate, int years) { + *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay()); +} +%} + +%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{ + /* csvarin typemap code */ + set { + CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day); + $imcall;$excode + } %} + +%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{ + /* csvarout typemap code */ + get { + IntPtr cPtr = $imcall; + CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode + return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(), + 0, 0, 0); + } %} + +%inline %{ +CDate ImportantDate = CDate(1999, 12, 31); +%} + diff --git a/Examples/test-suite/director_classic.i b/Examples/test-suite/director_classic.i index f22de4c98..f22de4c98 100755..100644 --- a/Examples/test-suite/director_classic.i +++ b/Examples/test-suite/director_classic.i diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i index 51317fbe0..51317fbe0 100755..100644 --- a/Examples/test-suite/director_ignore.i +++ b/Examples/test-suite/director_ignore.i diff --git a/Examples/test-suite/python/director_profile.i b/Examples/test-suite/director_profile.i index 25ed895b5..25ed895b5 100644 --- a/Examples/test-suite/python/director_profile.i +++ b/Examples/test-suite/director_profile.i diff --git a/Examples/test-suite/director_protected_overloaded.i b/Examples/test-suite/director_protected_overloaded.i new file mode 100644 index 000000000..a9f786fc7 --- /dev/null +++ b/Examples/test-suite/director_protected_overloaded.i @@ -0,0 +1,21 @@ +%module(directors="1",dirprot="1") director_protected_overloaded + +%director IDataObserver; +%director DerivedDataObserver; + +// protected overloaded methods +%inline %{ + class IDataObserver + { + public: + virtual ~IDataObserver(){} + + protected: + virtual void notoverloaded() = 0; + virtual void isoverloaded() = 0; + virtual void isoverloaded(int i) = 0; + virtual void isoverloaded(int i, double d) = 0; + }; + class DerivedDataObserver : public IDataObserver { + }; +%} diff --git a/Examples/test-suite/python/director_stl.i b/Examples/test-suite/director_stl.i index cbcb4ba85..cbcb4ba85 100644 --- a/Examples/test-suite/python/director_stl.i +++ b/Examples/test-suite/director_stl.i diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i index 4f4e55cfe..2732eb907 100644 --- a/Examples/test-suite/director_thread.i +++ b/Examples/test-suite/director_thread.i @@ -13,6 +13,7 @@ #include <process.h> #else #include <pthread.h> +#include <signal.h> #include <unistd.h> #endif @@ -27,6 +28,8 @@ extern "C" { void* working(void* t); pthread_t thread; #endif + static int thread_terminate = 0; + } %} @@ -51,6 +54,15 @@ extern "C" { virtual ~Foo() { } + void stop() { + thread_terminate = 1; + %#ifdef _WIN32 + /*TODO(bhy) what to do for win32? */ + %#else + pthread_join(thread, NULL); + %#endif + } + void run() { %#ifdef _WIN32 _beginthreadex(NULL,0,working,this,0,&thread_id); @@ -75,10 +87,15 @@ extern "C" { #endif { Foo* f = static_cast<Foo*>(t); - while (1) { + while ( ! thread_terminate ) { MilliSecondSleep(50); f->do_foo(); } +#ifdef _WIN32 + /* TODO(bhy) what's the corresponding of pthread_exit in win32? */ +#else + pthread_exit(0); +#endif return 0; } } diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i index 31e3e2105..974227a01 100644 --- a/Examples/test-suite/enum_thorough.i +++ b/Examples/test-suite/enum_thorough.i @@ -487,29 +487,53 @@ struct Instances { // Repeated values #if defined(SWIGJAVA) %javaconst(1); +// needed for typesafe and proper enums only +%javaconst(0) ignoreA_three; +%javaconst(0) ignoreA_thirteen; #elif defined(SWIGCSHARP) +// needed for typesafe enums only +#ifdef SWIG_TEST_NOCSCONST + %csconst(0) ignoreA_three; + %csconst(0) ignoreA_thirteen; +#endif %csconst(1); #endif -#if defined(SWIGPERL) -%inline %{ +%ignore ignoreA_one; +%ignore ignoreA_two; +%ignore ignoreA_twelve; +%ignore ignoreA_thirty_one; -namespace RepeatSpace { -typedef enum -{ - one = 1, - initial = one, - two, - three, - llast = three, - end = llast -} repeat; -repeat repeatTest(repeat e) { return e; } -} +%ignore ignoreB_ten; +%ignore ignoreB_twenty; +%ignore ignoreB_thirty; +%ignore ignoreB_forty; + +%ignore ignoreC_eleven; +%ignore ignoreC_thirty_one; +%ignore ignoreC_forty_one; + +%ignore ignoreD_ten; +%ignore ignoreD_twenty; + +%ignore ignoreE_twenty; + +%inline %{ +struct IgnoreTest { + enum IgnoreA { ignoreA_zero, ignoreA_one, ignoreA_two, ignoreA_three, ignoreA_ten=10, ignoreA_eleven, ignoreA_twelve, ignoreA_thirteen, ignoreA_fourteen, ignoreA_twenty=20, ignoreA_thirty=30, ignoreA_thirty_one, ignoreA_thirty_two, ignoreA_thirty_three }; + enum IgnoreB { ignoreB_ten=10, ignoreB_eleven, ignoreB_twelve, ignoreB_twenty=20, ignoreB_thirty=30, ignoreB_thirty_one, ignoreB_thirty_two, ignoreB_forty=40, ignoreB_forty_one, ignoreB_forty_two }; + enum IgnoreC { ignoreC_ten=10, ignoreC_eleven, ignoreC_twelve, ignoreC_twenty=20, ignoreC_thirty=30, ignoreC_thirty_one, ignoreC_thirty_two, ignoreC_forty=40, ignoreC_forty_one, ignoreC_forty_two }; + enum IgnoreD { ignoreD_ten=10, ignoreD_twenty=20, ignoreD_twenty_one, ignoreD_twenty_two }; + enum IgnoreE { ignoreE_zero, ignoreE_twenty=20, ignoreE_twenty_one, ignoreE_twenty_two }; +}; +IgnoreTest::IgnoreA ignoreATest(IgnoreTest::IgnoreA n) { return n; } +IgnoreTest::IgnoreB ignoreBTest(IgnoreTest::IgnoreB n) { return n; } +IgnoreTest::IgnoreC ignoreCTest(IgnoreTest::IgnoreC n) { return n; } +IgnoreTest::IgnoreD ignoreDTest(IgnoreTest::IgnoreD n) { return n; } +IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; } %} -#else %inline %{ namespace RepeatSpace { @@ -519,14 +543,11 @@ typedef enum initial = one, two, three, - last = three, - end = last + llast = three, + end = llast } repeat; repeat repeatTest(repeat e) { return e; } } %} - -#endif - diff --git a/Examples/test-suite/enum_thorough_typesafe.i b/Examples/test-suite/enum_thorough_typesafe.i index 8bae5b07a..e205e8ad1 100644 --- a/Examples/test-suite/enum_thorough_typesafe.i +++ b/Examples/test-suite/enum_thorough_typesafe.i @@ -3,5 +3,7 @@ // Test enum wrapping using the typesafe enum pattern in the target language %include "enumtypesafe.swg" +#define SWIG_TEST_NOCSCONST // For C# typesafe enums + %include "enum_thorough.i" diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i index 2db51ae6b..2ccbe725a 100644 --- a/Examples/test-suite/features.i +++ b/Examples/test-suite/features.i @@ -162,3 +162,20 @@ namespace Space { } %} +// Test 8 conversion operators +%rename(opbool) operator bool; +%rename(opuint) operator unsigned int; + +%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */"; +%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */"; +%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */"; +%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/"; + +%inline %{ + class ConversionOperators { + public: + operator bool() { return false; } + operator unsigned int() { return 0; } + }; +%} + diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i new file mode 100644 index 000000000..02139f6c4 --- /dev/null +++ b/Examples/test-suite/global_namespace.i @@ -0,0 +1,60 @@ +%module global_namespace + +// classes +%inline %{ +class Klass1 {}; +class Klass2 {}; +class Klass3 {}; +class Klass4 {}; +class Klass5 {}; +class Klass6 {}; +class Klass7 {}; + +struct KlassMethods { + static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {} + static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {} +}; +%} + +%inline %{ +namespace Space { +class XYZ1 {}; +class XYZ2 {}; +class XYZ3 {}; +class XYZ4 {}; +class XYZ5 {}; +class XYZ6 {}; +class XYZ7 {}; +} + +struct XYZMethods { + static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {} + static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {} +}; +%} + +//enums +%inline %{ +enum AnEnum1 { anenum1 }; +enum AnEnum2 { anenum2 }; +enum AnEnum3 { anenum3 }; + +struct AnEnumMethods { + static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {} + static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {} +}; +%} + +%inline %{ +namespace Space { +enum TheEnum1 { theenum1 }; +enum TheEnum2 { theenum2 }; +enum TheEnum3 { theenum3 }; + +struct TheEnumMethods { + static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {} + static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {} +}; +} +%} + diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in index 97f30e3b2..25d40674d 100644 --- a/Examples/test-suite/guile/Makefile.in +++ b/Examples/test-suite/guile/Makefile.in @@ -36,7 +36,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ SWIGOPT=" -noruntime "; \ done diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in index 04de236db..eb53f020e 100644 --- a/Examples/test-suite/guilescm/Makefile.in +++ b/Examples/test-suite/guilescm/Makefile.in @@ -2,7 +2,7 @@ # Makefile for guile test-suite (with SCM API) ####################################################################### -EXTRA_TEST_CASES += ext_test.externaltest +EXTRA_TEST_CASES += guilescm_ext_test.externaltest include ../guile/Makefile @@ -31,7 +31,7 @@ swig_and_compile_multi_cpp = \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \ SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \ INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \ - TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \ + TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \ $(LANGUAGE)$(VARIANT)_cpp; \ done diff --git a/Examples/test-suite/guilescm/ext_test_runme.scm b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm index 67add849e..ff3df064b 100644 --- a/Examples/test-suite/guilescm/ext_test_runme.scm +++ b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm @@ -1,4 +1,4 @@ -(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so")) +(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so")) ; This is a test for SF Bug 1573892 ; If IsPointer is called before TypeQuery, the test-is-pointer will fail diff --git a/Examples/test-suite/guilescm/ext_test.i b/Examples/test-suite/guilescm_ext_test.i index 8b117bb5a..fd5655d4f 100644 --- a/Examples/test-suite/guilescm/ext_test.i +++ b/Examples/test-suite/guilescm_ext_test.i @@ -1,4 +1,4 @@ -%module ext_test +%module guilescm_ext_test /* just use the imports_a.h header... for this test we only need a class */ %{ diff --git a/Examples/test-suite/python/iadd.h b/Examples/test-suite/iadd.i index 367eda26f..514bd3e4f 100644 --- a/Examples/test-suite/python/iadd.h +++ b/Examples/test-suite/iadd.i @@ -1,3 +1,12 @@ +%module iadd + +%include attribute.i +class Foo; +%attribute_ref(test::Foo, test::A& , AsA); +%attribute_ref(test::Foo, long, AsLong); + + +%inline %{ struct B { int x; B(const int x) : x(x) {} @@ -45,3 +54,5 @@ private: long *_n; }; } + +%} diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i index 5225d5183..ffd541986 100644 --- a/Examples/test-suite/ignore_template_constructor.i +++ b/Examples/test-suite/ignore_template_constructor.i @@ -37,3 +37,9 @@ public: #endif %template(VectFlow) std::vector<Flow>; + +%inline %{ +std::vector<Flow> inandout(std::vector<Flow> v) { + return v; +} +%} diff --git a/Examples/test-suite/octave/implicittest.i b/Examples/test-suite/implicittest.i index 91205aafa..91205aafa 100644 --- a/Examples/test-suite/octave/implicittest.i +++ b/Examples/test-suite/implicittest.i diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i index b06f14001..3cf511032 100644 --- a/Examples/test-suite/import_nomodule.i +++ b/Examples/test-suite/import_nomodule.i @@ -3,6 +3,9 @@ #include "import_nomodule.h" %} +// For Python +%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive. + %import "import_nomodule.h" #if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGCOM) diff --git a/Examples/test-suite/imports_b.i b/Examples/test-suite/imports_b.i index afc573a39..81e84cddd 100644 --- a/Examples/test-suite/imports_b.i +++ b/Examples/test-suite/imports_b.i @@ -34,9 +34,14 @@ */ #if 0 -%import "imports_a.i" + %import "imports_a.i" #else -%import(module="imports_a") "imports_a.h" +# if 0 + // Test Warning 401 (Python only) + %import "imports_a.h" +# else + %import(module="imports_a") "imports_a.h" +# endif #endif %include "imports_b.h" diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i index 770e11d36..20fb93fda 100644 --- a/Examples/test-suite/inherit_target_language.i +++ b/Examples/test-suite/inherit_target_language.i @@ -12,10 +12,12 @@ using System; using System.Runtime.InteropServices; public class TargetLanguageBase { public virtual void targetLanguageBaseMethod() {} }; +public class TargetLanguageBase2 { public virtual void targetLanguageBase2Method() {} }; %} %pragma(java) moduleimports=%{ class TargetLanguageBase { public void targetLanguageBaseMethod() {} }; +class TargetLanguageBase2 { public void targetLanguageBase2Method() {} }; %} @@ -61,3 +63,11 @@ struct MultipleDerived3 : MBase3a, MBase3b {}; struct MultipleDerived4 : MBase4a, MBase4b {}; %} +// Replace a C++ base, but only classes that do not have a C++ base +%typemap(csbase, notderived="1") SWIGTYPE "TargetLanguageBase2" + +%inline %{ +struct BaseX { virtual ~BaseX() {}; void basex() {} }; +struct DerivedX : BaseX { void derivedx() {} }; +%} + diff --git a/Examples/test-suite/python/inout.i b/Examples/test-suite/inout.i index dc6db0ecb..dc6db0ecb 100644 --- a/Examples/test-suite/python/inout.i +++ b/Examples/test-suite/inout.i diff --git a/Examples/test-suite/python/inplaceadd.i b/Examples/test-suite/inplaceadd.i index 91ef84bd2..91ef84bd2 100644 --- a/Examples/test-suite/python/inplaceadd.i +++ b/Examples/test-suite/inplaceadd.i diff --git a/Examples/test-suite/python/input.i b/Examples/test-suite/input.i index 6cef3f9f5..6cef3f9f5 100644 --- a/Examples/test-suite/python/input.i +++ b/Examples/test-suite/input.i diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i new file mode 100644 index 000000000..8ad966a99 --- /dev/null +++ b/Examples/test-suite/insert_directive.i @@ -0,0 +1,38 @@ +%module insert_directive + +// check %insert and the order of each insert section is correct + +%begin %{ +// %inserted code %begin +int inserted_begin(int i) { return i; } +%} + +%runtime %{ +// %inserted code %runtime +int inserted_runtime(int i) { return inserted_begin(i); } +%} + +%{ +// %inserted code %header +int inserted_header1(int i) { return inserted_runtime(i); } +%} + +%header %{ +// %inserted code %header +int inserted_header2(int i) { return inserted_header1(i); } +%} + +%{ +// %inserted code %header +int inserted_header3(int i) { return inserted_header2(i); } +%} + +%wrapper %{ +// %inserted code %wrapper +int inserted_wrapper(int i) { return inserted_header3(i); } +%} + +%init %{ +// %inserted code %init +int inserted_init_value = inserted_wrapper(0); +%} diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i index 0f90f9cdd..94858a5fb 100644 --- a/Examples/test-suite/intermediary_classname.i +++ b/Examples/test-suite/intermediary_classname.i @@ -18,6 +18,7 @@ "new $javaclassname($jniinput, false)/*javadirectorin*/" %typemap(out, throws="IllegalAccessException/*out Base&*/") Base& { // XYZ& typemap out + $result = 0; // remove unused variable warning } %inline %{ diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in index ace8dee86..03c10d498 100644 --- a/Examples/test-suite/java/Makefile.in +++ b/Examples/test-suite/java/Makefile.in @@ -32,11 +32,13 @@ CPP_TEST_CASES = \ java_throws \ java_typemaps_proxy \ java_typemaps_typewrapper +# li_boost_intrusive_ptr include $(srcdir)/../common.mk # Overridden variables here SWIGOPT += -package $* +INTERFACEDIR = ../../ # Rules for the different types of tests %.cpptest: @@ -72,7 +74,7 @@ run_testcase = \ (cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \ - env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*\_runme;) \ + env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \ fi; # Clean: remove testcase directories diff --git a/Examples/test-suite/java/allprotected_runme.java b/Examples/test-suite/java/allprotected_runme.java index aa5413a95..aa5413a95 100755..100644 --- a/Examples/test-suite/java/allprotected_runme.java +++ b/Examples/test-suite/java/allprotected_runme.java diff --git a/Examples/test-suite/java/director_classic_runme.java b/Examples/test-suite/java/director_classic_runme.java index 50ea2b8d3..50ea2b8d3 100755..100644 --- a/Examples/test-suite/java/director_classic_runme.java +++ b/Examples/test-suite/java/director_classic_runme.java diff --git a/Examples/test-suite/java/director_ignore_runme.java b/Examples/test-suite/java/director_ignore_runme.java index 9b98ee4cf..9b98ee4cf 100755..100644 --- a/Examples/test-suite/java/director_ignore_runme.java +++ b/Examples/test-suite/java/director_ignore_runme.java diff --git a/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java index 243d3bddd..66968060d 100644 --- a/Examples/test-suite/java/enum_thorough_proper_runme.java +++ b/Examples/test-suite/java/enum_thorough_proper_runme.java @@ -369,12 +369,51 @@ public class enum_thorough_proper_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue() != 0) throw new RuntimeException("ignoreATest 0 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue() != 3) throw new RuntimeException("ignoreATest 3 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue() != 10) throw new RuntimeException("ignoreATest 10 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue() != 11) throw new RuntimeException("ignoreATest 11 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue() != 13) throw new RuntimeException("ignoreATest 13 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue() != 14) throw new RuntimeException("ignoreATest 14 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue() != 20) throw new RuntimeException("ignoreATest 20 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue() != 30) throw new RuntimeException("ignoreATest 30 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreATest 32 failed"); + if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue() != 33) throw new RuntimeException("ignoreATest 33 failed"); + } + { + if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue() != 11) throw new RuntimeException("ignoreBTest 11 failed"); + if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue() != 12) throw new RuntimeException("ignoreBTest 12 failed"); + if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue() != 31) throw new RuntimeException("ignoreBTest 31 failed"); + if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreBTest 32 failed"); + if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue() != 41) throw new RuntimeException("ignoreBTest 41 failed"); + if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue() != 42) throw new RuntimeException("ignoreBTest 42 failed"); + } + { + if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue() != 10) throw new RuntimeException("ignoreCTest 10 failed"); + if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue() != 12) throw new RuntimeException("ignoreCTest 12 failed"); + if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue() != 30) throw new RuntimeException("ignoreCTest 30 failed"); + if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreCTest 32 failed"); + if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue() != 40) throw new RuntimeException("ignoreCTest 40 failed"); + if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue() != 42) throw new RuntimeException("ignoreCTest 42 failed"); + } + { + if (enum_thorough_proper.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreDTest 21 failed"); + if (enum_thorough_proper.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreDTest 22 failed"); + } + { + if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue() != 0) throw new RuntimeException("ignoreETest 0 failed"); + if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreETest 21 failed"); + if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreETest 22 failed"); + } + // ignore enum item tests end { if (enum_thorough_proper.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed"); if (enum_thorough_proper.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed"); if (enum_thorough_proper.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed"); if (enum_thorough_proper.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed"); - if (enum_thorough_proper.repeatTest(repeat.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java index 1cd02d38d..79c902ccf 100644 --- a/Examples/test-suite/java/enum_thorough_runme.java +++ b/Examples/test-suite/java/enum_thorough_runme.java @@ -369,12 +369,51 @@ public class enum_thorough_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue() != 0) throw new RuntimeException("ignoreATest 0 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue() != 3) throw new RuntimeException("ignoreATest 3 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue() != 10) throw new RuntimeException("ignoreATest 10 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue() != 11) throw new RuntimeException("ignoreATest 11 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue() != 13) throw new RuntimeException("ignoreATest 13 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue() != 14) throw new RuntimeException("ignoreATest 14 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue() != 20) throw new RuntimeException("ignoreATest 20 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue() != 30) throw new RuntimeException("ignoreATest 30 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreATest 32 failed"); + if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue() != 33) throw new RuntimeException("ignoreATest 33 failed"); + } + { + if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue() != 11) throw new RuntimeException("ignoreBTest 11 failed"); + if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue() != 12) throw new RuntimeException("ignoreBTest 12 failed"); + if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue() != 31) throw new RuntimeException("ignoreBTest 31 failed"); + if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreBTest 32 failed"); + if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue() != 41) throw new RuntimeException("ignoreBTest 41 failed"); + if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue() != 42) throw new RuntimeException("ignoreBTest 42 failed"); + } + { + if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue() != 10) throw new RuntimeException("ignoreCTest 10 failed"); + if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue() != 12) throw new RuntimeException("ignoreCTest 12 failed"); + if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue() != 30) throw new RuntimeException("ignoreCTest 30 failed"); + if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreCTest 32 failed"); + if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue() != 40) throw new RuntimeException("ignoreCTest 40 failed"); + if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue() != 42) throw new RuntimeException("ignoreCTest 42 failed"); + } + { + if (enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreDTest 21 failed"); + if (enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreDTest 22 failed"); + } + { + if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue() != 0) throw new RuntimeException("ignoreETest 0 failed"); + if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreETest 21 failed"); + if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreETest 22 failed"); + } + // ignore enum item tests end { if (enum_thorough.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed"); if (enum_thorough.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed"); if (enum_thorough.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed"); if (enum_thorough.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed"); - if (enum_thorough.repeatTest(repeat.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java index 9bd56273e..e54acda70 100644 --- a/Examples/test-suite/java/enum_thorough_simple_runme.java +++ b/Examples/test-suite/java/enum_thorough_simple_runme.java @@ -369,12 +369,51 @@ public class enum_thorough_simple_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed"); + if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed"); + } + { + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed"); + if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed"); + } + { + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed"); + if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed"); + } + { + if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed"); + if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed"); + } + { + if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed"); + if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed"); + if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed"); + } + // ignore enum item tests end { if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.one) != 1) throw new RuntimeException("repeatTest 1 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.initial) != 1) throw new RuntimeException("repeatTest 2 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.two) != 2) throw new RuntimeException("repeatTest 3 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.three) != 3) throw new RuntimeException("repeatTest 4 failed"); - if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.last) != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java index 35d1a1937..b00788911 100644 --- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java +++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java @@ -369,12 +369,51 @@ public class enum_thorough_typeunsafe_runme { i.setMemberInstance(Instances.memberinstance3); if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed"); } + // ignore enum item tests start + { + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed"); + if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed"); + } + { + if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed"); + if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed"); + if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed"); + if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed"); + if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed"); + if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed"); + } + { + if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed"); + if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed"); + if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed"); + if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed"); + if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed"); + if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed"); + } + { + if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed"); + if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed"); + } + { + if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed"); + if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed"); + if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed"); + } + // ignore enum item tests end { if (enum_thorough_typeunsafe.repeatTest(repeat.one) != 1) throw new RuntimeException("repeatTest 1 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.initial) != 1) throw new RuntimeException("repeatTest 2 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.two) != 2) throw new RuntimeException("repeatTest 3 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.three) != 3) throw new RuntimeException("repeatTest 4 failed"); - if (enum_thorough_typeunsafe.repeatTest(repeat.last) != 3) throw new RuntimeException("repeatTest 5 failed"); + if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed"); } } diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java new file mode 100644 index 000000000..faab7d4ba --- /dev/null +++ b/Examples/test-suite/java/global_namespace_runme.java @@ -0,0 +1,25 @@ +import global_namespace.*; + +public class global_namespace_runme { + + static { + try { + System.loadLibrary("global_namespace"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static void main(String argv[]) { + + KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); + KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7()); + + XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); + XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7()); + + TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3); + TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3); + } +} diff --git a/Examples/test-suite/java/inherit_target_language_runme.java b/Examples/test-suite/java/inherit_target_language_runme.java index 6c7c1bf33..184272fe2 100644 --- a/Examples/test-suite/java/inherit_target_language_runme.java +++ b/Examples/test-suite/java/inherit_target_language_runme.java @@ -21,6 +21,15 @@ public class inherit_target_language_runme { new MultipleDerived2().targetLanguageBaseMethod(); new MultipleDerived3().f(); new MultipleDerived4().g(); + + BaseX baseX = new BaseX(); + baseX.basex(); + baseX.targetLanguageBase2Method(); + + DerivedX derivedX = new DerivedX(); + derivedX.basex(); + derivedX.derivedx(); + derivedX.targetLanguageBase2Method(); } } diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java index 3538aa6d4..6a73ea563 100644 --- a/Examples/test-suite/java/java_throws_runme.java +++ b/Examples/test-suite/java/java_throws_runme.java @@ -94,5 +94,20 @@ public class java_throws_runme { if (!pass) throw new RuntimeException("Test 7 failed"); + + // Test %nojavaexception + NoExceptTest net = new NoExceptTest(); + + pass = false; + try { + net.exceptionPlease(); + pass = true; + } + catch (MyException e) {} + + if (!pass) + throw new RuntimeException("Test 8 failed"); + + net.noExceptionPlease(); } } diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java new file mode 100644 index 000000000..f40c28e9e --- /dev/null +++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java @@ -0,0 +1,701 @@ +import li_boost_intrusive_ptr.*;
+
+public class li_boost_intrusive_ptr_runme {
+ static {
+ try {
+ System.loadLibrary("li_boost_intrusive_ptr");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ // Debugging flag
+ public final static boolean debug = false;
+
+ public static void main(String argv[])
+ {
+ if (debug)
+ System.out.println("Started");
+
+ li_boost_intrusive_ptr.setDebug_shared(debug);
+
+ // Change loop count to run for a long time to monitor memory
+ final int loopCount = 5000; //5000;
+ for (int i=0; i<loopCount; i++) {
+ new li_boost_intrusive_ptr_runme().runtest();
+ System.gc();
+ System.runFinalization();
+ try {
+ if (i%100 == 0) {
+ java.lang.Thread.sleep(1); // give some time to the lower priority finalizer thread
+ }
+ } catch (java.lang.InterruptedException e) {
+ }
+ }
+
+ if (debug)
+ System.out.println("Nearly finished");
+
+ int countdown = 50;
+ while (true) {
+ System.gc();
+ System.runFinalization();
+ try {
+ java.lang.Thread.sleep(100);
+ } catch (java.lang.InterruptedException e) {
+ }
+ if (--countdown == 0)
+ break;
+ if (Klass.getTotal_count() == 1 && KlassWithoutRefCount.getTotal_count() == 0 &&
+ li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() == 0 &&
+ KlassDerived.getTotal_count() == 0 && KlassDerivedDerived.getTotal_count() == 1)
+ // Expect 1 Klass instance - the one global variable (GlobalValue)
+ break;
+ };
+ if (Klass.getTotal_count() != 1)
+ throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
+ if (KlassWithoutRefCount.getTotal_count() != 0)
+ throw new RuntimeException("KlassWithoutRefCount.total_count=" + KlassWithoutRefCount.getTotal_count());
+ if (li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() != 0)
+ throw new RuntimeException("IgnoredRefCountingBase.total_count=" + li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count());
+ if (KlassDerived.getTotal_count() != 0)
+ throw new RuntimeException("KlassDerived.total_count=" + KlassDerived.getTotal_count());
+ if (KlassDerivedDerived.getTotal_count() != 0)
+ throw new RuntimeException("KlassDerivedDerived.total_count=" + KlassDerivedDerived.getTotal_count());
+
+ int wrapper_count = li_boost_intrusive_ptr.intrusive_ptr_wrapper_count();
+ if (wrapper_count != li_boost_intrusive_ptr.getNOT_COUNTING())
+ if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
+ throw new RuntimeException("shared_ptr wrapper count=" + wrapper_count);
+
+ if (debug)
+ System.out.println("Finished");
+ }
+
+ private void runtest() {
+ // simple shared_ptr usage - created in C++
+ {
+ Klass k = new Klass("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ Klass k = li_boost_intrusive_ptr.factorycreate();
+ String val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by value
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.pointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ if (li_boost_intrusive_ptr.smartpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (!li_boost_intrusive_ptr.nullsmartpointerpointertest(null).equals("null pointer"))
+ throw new RuntimeException("not null smartpointer pointer");
+
+ try { li_boost_intrusive_ptr.valuetest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+
+ if (li_boost_intrusive_ptr.pointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ try { li_boost_intrusive_ptr.reftest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ // $owner
+ {
+ Klass k = li_boost_intrusive_ptr.pointerownertest();
+ String val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ Klass k = li_boost_intrusive_ptr.smartpointerpointerownertest();
+ String val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived access to base class which cannot be wrapped in an intrusive_ptr
+ {
+ KlassWithoutRefCount k = new KlassDerived("me oh my");
+ verifyValue("this class cannot be wrapped by intrusive_ptrs but we can still use it", k.getSpecialValueFromUnwrappableClass());
+ }
+ // derived pass by shared_ptr
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // derived pass by shared_ptr pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
+ verifyCount(2, kret);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
+ verifyCount(2, kret);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedvaluetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedvaluetest-Derived", val); // note slicing
+ verifyIntrusiveCount(1, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-DerivedDerived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-DerivedDerived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member value");
+ m.setSmartMemberValue(k);
+ String val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ verifyCount(1, kmember);
+
+ m.delete();
+ verifyIntrusiveCount(2, kmember);
+ verifyIntrusiveCount(2, k);
+ }
+
+ // smart pointer by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member pointer");
+ m.setSmartMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+
+ Klass kmember = m.getSmartMemberPointer();
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyIntrusiveCount(2, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+ }
+ // smart pointer by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member reference");
+ m.setSmartMemberReference(k);
+ String val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberReference();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ m.setSmartMemberValue(k);
+ Klass kmemberVal = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(5, kmemberVal);
+ verifyCount(1, kmemberVal);
+ verifyIntrusiveCount(5, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(5, k);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyIntrusiveCount(3, kmemberVal);
+ verifyCount(1, kmemberVal);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ }
+
+ //plain by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member value");
+ m.setMemberValue(k);
+ String val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberValue();
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //plain by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member pointer");
+ m.setMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberPointer();
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //plain by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member reference");
+ m.setMemberReference(k);
+ String val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberReference();
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //null member variables
+ {
+ MemberVariables m = new MemberVariables();
+
+ // shared_ptr by value
+ Klass k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ m.setSmartMemberValue(null);
+ k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+}
+private void toIgnore() {
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ Klass kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("smart global value");
+ li_boost_intrusive_ptr.setGlobalSmartValue(k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
+ String val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyIntrusiveCount(3, kglobal);
+ verifyCount(1, kglobal);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ verifyValue("smart global value", li_boost_intrusive_ptr.getGlobalSmartValue().getValue());
+ li_boost_intrusive_ptr.setGlobalSmartValue(null);
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global value");
+ li_boost_intrusive_ptr.setGlobalValue(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalValue();
+ String val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", li_boost_intrusive_ptr.getGlobalValue().getValue());
+
+ try { li_boost_intrusive_ptr.setGlobalValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+ //plain pointer
+ {
+ Klass kglobal = li_boost_intrusive_ptr.getGlobalPointer();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("global pointer");
+ li_boost_intrusive_ptr.setGlobalPointer(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalPointer();
+ String val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ li_boost_intrusive_ptr.setGlobalPointer(null);
+ }
+
+ // plain reference
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global reference");
+ li_boost_intrusive_ptr.setGlobalReference(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalReference();
+ String val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { li_boost_intrusive_ptr.setGlobalReference(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
+ throw new RuntimeException("Base values wrong");
+ if (pid.getVal1() != 10 || pid.getVal2() != 20.2)
+ throw new RuntimeException("Derived Values wrong");
+ }
+ }
+ private void verifyValue(String expected, String got) {
+ if (!expected.equals(got))
+ throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, Klass k) {
+ int got = li_boost_intrusive_ptr.use_count(k);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, KlassDerived kd) {
+ int got = li_boost_intrusive_ptr.use_count(kd);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, KlassDerivedDerived kdd) {
+ int got = li_boost_intrusive_ptr.use_count(kdd);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, Klass k) {
+ int got = k.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, KlassDerived kd) {
+ int got = kd.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, KlassDerivedDerived kdd) {
+ int got = kdd.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+}
diff --git a/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_runme.java index a699222e5..02d6d6502 100644 --- a/Examples/test-suite/java/li_boost_shared_ptr_runme.java +++ b/Examples/test-suite/java/li_boost_shared_ptr_runme.java @@ -357,6 +357,16 @@ public class li_boost_shared_ptr_runme { verifyCount(1, kret); } + // 3rd derived class + { + Klass k = new Klass3rdDerived("me oh my"); + String val = k.getValue(); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values + val = li_boost_shared_ptr.test3rdupcast(k); + verifyValue("me oh my-3rdDerived", val); + verifyCount(3, k); + } ////////////////////////////////// Member variables //////////////////////////////////////// // smart pointer by value diff --git a/Examples/test-suite/java/overload_complicated_runme.java b/Examples/test-suite/java/overload_complicated_runme.java index ac8523d75..ac8523d75 100755..100644 --- a/Examples/test-suite/java/overload_complicated_runme.java +++ b/Examples/test-suite/java/overload_complicated_runme.java diff --git a/Examples/test-suite/java/typemap_out_optimal_runme.java b/Examples/test-suite/java/typemap_out_optimal_runme.java new file mode 100644 index 000000000..8a87f0c4b --- /dev/null +++ b/Examples/test-suite/java/typemap_out_optimal_runme.java @@ -0,0 +1,21 @@ + +import typemap_out_optimal.*; + +public class typemap_out_optimal_runme { + + static { + try { + System.loadLibrary("typemap_out_optimal"); + } catch (UnsatisfiedLinkError e) { + System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e); + System.exit(1); + } + } + + public static XX x = null; + public static void main(String argv[]) { + XX.setDebug(false); + x = XX.create(); + } +} + diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i index 3aa11defb..b020fefcb 100644 --- a/Examples/test-suite/java_throws.i +++ b/Examples/test-suite/java_throws.i @@ -143,3 +143,41 @@ try { } %} +// Test %nojavaexception +%javaexception("MyException") %{ +/* global exception handler */ +try { + $action +} catch (MyException) { + jclass excep = jenv->FindClass("java_throws/MyException"); + if (excep) + jenv->ThrowNew(excep, "exception message"); + return $null; +} +%} + +%nojavaexception *::noExceptionPlease(); +%nojavaexception NoExceptTest::NoExceptTest(); + +// Need to handle the checked exception in NoExceptTest.delete() +%typemap(javafinalize) SWIGTYPE %{ + protected void finalize() { + try { + delete(); + } catch (MyException e) { + throw new RuntimeException(e); + } + } +%} + +%inline %{ +struct NoExceptTest { + unsigned int noExceptionPlease() { return 123; } + unsigned int exceptionPlease() { return 456; } + ~NoExceptTest() {} +}; +%} + +// Turn global exceptions off (for the implicit destructors/constructors) +%nojavaexception; + diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i index 5b4379ebf..4f9497afb 100644 --- a/Examples/test-suite/li_attribute.i +++ b/Examples/test-suite/li_attribute.i @@ -93,9 +93,11 @@ struct MyFoo; // %attribute2 does not work with templates %template(Param_i) Param<int>; +// class/struct attribute with get/set methods using return/pass by reference %attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo); %inline %{ struct MyFoo { + MyFoo() : x(-1) {} int x; }; class MyClass { @@ -106,3 +108,32 @@ struct MyFoo; // %attribute2 does not work with templates }; %} + +// class/struct attribute with get/set methods using return/pass by value +%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo); +%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo); +%inline %{ + class MyClassVal { + MyFoo foo; + public: + MyFoo GetFoo() { return foo; } + void SetFoo(MyFoo other) { foo = other; } + }; +%} + + +// string attribute with get/set methods using return/pass by value +%include <std_string.i> +%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString); +%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString); +%inline %{ + class MyStringyClass { + std::string str; + public: + MyStringyClass(const std::string &val) : str(val) {} + std::string GetString() { return str; } + void SetString(std::string other) { str = other; } + }; +%} + + diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i new file mode 100644 index 000000000..7c37e6843 --- /dev/null +++ b/Examples/test-suite/li_boost_intrusive_ptr.i @@ -0,0 +1,494 @@ +// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
+// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
+// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
+// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
+//
+// Also note the debug_shared flag which can be set from the target language.
+
+%module li_boost_intrusive_ptr
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+
+%inline %{
+#include "boost/shared_ptr.hpp"
+#include "boost/intrusive_ptr.hpp"
+#include <boost/detail/atomic_count.hpp>
+
+// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
+//#define INTRUSIVE_PTR_WRAPPER
+
+#ifdef INTRUSIVE_PTR_WRAPPER
+# include "intrusive_ptr_wrapper.h"
+# include "shared_ptr_wrapper.h"
+#endif
+%}
+
+%{
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SwigBoost boost
+#endif
+%}
+
+%include "std_string.i"
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
+# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+%include <boost_intrusive_ptr.i>
+SWIG_INTRUSIVE_PTR(Klass, Space::Klass)
+SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount)
+SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived)
+SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived)
+
+//For the use_count shared_ptr functions
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
+
+#endif
+
+// TODO:
+// const intrusive_ptr
+// std::vector
+// Add in generic %extend for the Upcast function for derived classes
+// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
+
+%exception {
+ if (debug_shared) {
+ cout << "++++++" << endl << flush;
+ cout << "calling $name" << endl << flush;
+ }
+ $action
+ if (debug_shared) {
+ cout << "------" << endl << flush;
+ }
+}
+
+%ignore IgnoredRefCountingBase;
+%ignore *::operator=;
+%ignore intrusive_ptr_add_ref;
+%ignore intrusive_ptr_release;
+%newobject pointerownertest();
+%newobject smartpointerpointerownertest();
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+static bool debug_shared = false;
+
+namespace Space {
+
+struct Klass {
+ Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
+
+ Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
+
+ Klass &operator=(const Klass &other) { value = other.value; return *this; }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+ mutable boost::detail::atomic_count count;
+};
+
+struct KlassWithoutRefCount {
+ KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
+
+ KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
+ std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
+ KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+};
+
+struct IgnoredRefCountingBase {
+ IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
+ return *this;
+ }
+
+ virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ double d;
+ double e;
+ mutable boost::detail::atomic_count count;
+};
+
+long getTotal_IgnoredRefCountingBase_count() {
+ return IgnoredRefCountingBase::getTotal_count();
+}
+
+// For most compilers, this use of multiple inheritance results in different derived and base class
+// pointer values ... for some more challenging tests :)
+struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
+ KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
+ KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
+ int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+struct KlassDerivedDerived : KlassDerived {
+ KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
+ KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+KlassDerived* derivedpointertest(KlassDerived* kd) {
+ if (kd)
+ kd->append(" derivedpointertest");
+ return kd;
+}
+KlassDerived derivedvaluetest(KlassDerived kd) {
+ kd.append(" derivedvaluetest");
+ return kd;
+}
+KlassDerived& derivedreftest(KlassDerived& kd) {
+ kd.append(" derivedreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::intrusive_ptr<KlassDerived> kd) {
+ if (kd)
+ kd->append(" derivedsmartptrtest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointertest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr<KlassDerived>*& kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointerreftest");
+ return kd;
+}
+
+SwigBoost::intrusive_ptr<Klass> factorycreate() {
+ return SwigBoost::intrusive_ptr<Klass>(new Klass("factorycreate"));
+}
+// smart pointer
+SwigBoost::intrusive_ptr<Klass> smartpointertest(SwigBoost::intrusive_ptr<Klass> k) {
+ if (k)
+ k->append(" smartpointertest");
+ return SwigBoost::intrusive_ptr<Klass>(k);
+}
+SwigBoost::intrusive_ptr<Klass>* smartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointertest");
+ return k;
+}
+SwigBoost::intrusive_ptr<Klass>& smartpointerreftest(SwigBoost::intrusive_ptr<Klass>& k) {
+ if (k)
+ k->append(" smartpointerreftest");
+ return k;
+}
+SwigBoost::intrusive_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::intrusive_ptr<Klass>*& k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointerreftest");
+ return k;
+}
+// const
+SwigBoost::intrusive_ptr<const Klass> constsmartpointertest(SwigBoost::intrusive_ptr<const Klass> k) {
+ return SwigBoost::intrusive_ptr<const Klass>(k);
+}
+SwigBoost::intrusive_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::intrusive_ptr<const Klass>* k) {
+ return k;
+}
+SwigBoost::intrusive_ptr<const Klass>& constsmartpointerreftest(SwigBoost::intrusive_ptr<const Klass>& k) {
+ return k;
+}
+// plain pointer
+Klass valuetest(Klass k) {
+ k.append(" valuetest");
+ return k;
+}
+Klass *pointertest(Klass *k) {
+ if (k)
+ k->append(" pointertest");
+ return k;
+}
+Klass& reftest(Klass& k) {
+ k.append(" reftest");
+ return k;
+}
+Klass*& pointerreftest(Klass*& k) {
+ k->append(" pointerreftest");
+ return k;
+}
+// null
+std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
+ if (k && *k)
+ return "not null";
+ else if (!k)
+ return "null smartpointer pointer";
+ else if (!*k)
+ return "null pointer";
+ else
+ return "also not null";
+}
+// $owner
+Klass *pointerownertest() {
+ return new Klass("pointerownertest");
+}
+SwigBoost::intrusive_ptr<Klass>* smartpointerpointerownertest() {
+ return new SwigBoost::intrusive_ptr<Klass>(new Klass("smartpointerpointerownertest"));
+}
+
+const SwigBoost::intrusive_ptr<Klass>& ref_1() {
+ static SwigBoost::intrusive_ptr<Klass> sptr;
+ return sptr;
+}
+
+// overloading tests
+std::string overload_rawbyval(int i) { return "int"; }
+std::string overload_rawbyval(Klass k) { return "rawbyval"; }
+
+std::string overload_rawbyref(int i) { return "int"; }
+std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
+
+std::string overload_rawbyptr(int i) { return "int"; }
+std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
+
+std::string overload_rawbyptrref(int i) { return "int"; }
+std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; }
+
+
+
+std::string overload_smartbyval(int i) { return "int"; }
+std::string overload_smartbyval(SwigBoost::intrusive_ptr<Klass> k) { return "smartbyval"; }
+
+std::string overload_smartbyref(int i) { return "int"; }
+std::string overload_smartbyref(SwigBoost::intrusive_ptr<Klass> &k) { return "smartbyref"; }
+
+std::string overload_smartbyptr(int i) { return "int"; }
+std::string overload_smartbyptr(SwigBoost::intrusive_ptr<Klass> *k) { return "smartbyptr"; }
+
+std::string overload_smartbyptrref(int i) { return "int"; }
+std::string overload_smartbyptrref(SwigBoost::intrusive_ptr<Klass> *&k) { return "smartbyptrref"; }
+
+} // namespace Space
+
+%}
+%{
+ boost::detail::atomic_count Space::Klass::total_count(0);
+ boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
+ boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
+ boost::detail::atomic_count Space::KlassDerived::total_count(0);
+ boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
+%}
+
+// Member variables
+
+%inline %{
+struct MemberVariables {
+ MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr<Space::Klass>()), SmartMemberReference(*(new SwigBoost::intrusive_ptr<Space::Klass>())), MemberPointer(0), MemberReference(MemberValue) {}
+ virtual ~MemberVariables() {
+ delete SmartMemberPointer;
+ delete &SmartMemberReference;
+ }
+ SwigBoost::intrusive_ptr<Space::Klass> SmartMemberValue;
+ SwigBoost::intrusive_ptr<Space::Klass> * SmartMemberPointer;
+ SwigBoost::intrusive_ptr<Space::Klass> & SmartMemberReference;
+ Space::Klass MemberValue;
+ Space::Klass * MemberPointer;
+ Space::Klass & MemberReference;
+};
+
+// Global variables
+SwigBoost::intrusive_ptr<Space::Klass> GlobalSmartValue;
+Space::Klass GlobalValue;
+Space::Klass * GlobalPointer = 0;
+Space::Klass & GlobalReference = GlobalValue;
+
+%}
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+// Note: %template after the intrusive_ptr typemaps
+SWIG_INTRUSIVE_PTR(BaseIntDouble, Base<int, double>)
+// Note: cannot use Base<int, double> in the macro below because of the comma in the type,
+// so we use a typedef instead. Alternatively use %arg(Base<int, double>). %arg is defined in swigmacros.swg.
+SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair<int, double>)
+
+#endif
+
+// Templates
+%inline %{
+template <class T1, class T2> struct Base {
+ Space::Klass klassBase;
+ T1 baseVal1;
+ T2 baseVal2;
+ Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
+ virtual std::string getValue() const { return "Base<>"; };
+ mutable int count;
+ void addref(void) const { count++; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+};
+typedef Base<int, double> BaseIntDouble_t;
+%}
+
+%template(BaseIntDouble) Base<int, double>;
+
+%inline %{
+template <class T1, class T2> struct Pair : Base<T1, T2> {
+ Space::Klass klassPair;
+ T1 val1;
+ T2 val2;
+ Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
+ virtual std::string getValue() const { return "Pair<>"; };
+};
+
+Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
+SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
+
+template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
+
+template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
+
+long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Space::KlassDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Space::KlassDerivedDerived>& sptr) {
+ return sptr.use_count();
+}
+%}
+
+%template(PairIntDouble) Pair<int, double>;
+
+// For counting the instances of intrusive_ptr (all of which are created on the heap)
+// intrusive_ptr_wrapper_count() gives overall count
+%inline %{
+namespace SwigBoost {
+ const int NOT_COUNTING = -123456;
+ int intrusive_ptr_wrapper_count() {
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ return SwigBoost::IntrusivePtrWrapper::getTotalCount();
+ #else
+ return NOT_COUNTING;
+ #endif
+ }
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ template<> std::string show_message(boost::intrusive_ptr<Space::Klass >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<const Space::Klass >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<Space::KlassDerived >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<const Space::KlassDerived >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ #endif
+}
+%}
+
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i index a6225410b..f992a3c08 100644 --- a/Examples/test-suite/li_boost_shared_ptr.i +++ b/Examples/test-suite/li_boost_shared_ptr.i @@ -43,6 +43,14 @@ %include <boost_shared_ptr.i> SWIG_SHARED_PTR(Klass, Space::Klass) SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived) +SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived) +SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived) + +// TEMP for python +%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) { + *newmemory = SWIG_CAST_NEW_MEMORY; + return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from); +} #endif @@ -101,7 +109,13 @@ private: }; SwigExamples::CriticalSection Space::Klass::critical_section; -struct IgnoredMultipleInheritBase { virtual ~IgnoredMultipleInheritBase() {} double d; double e;}; +struct IgnoredMultipleInheritBase { + IgnoredMultipleInheritBase() : d(0.0), e(0.0) {} + virtual ~IgnoredMultipleInheritBase() {} + double d; + double e; + virtual void AVirtualMethod() {} +}; // For most compilers, this use of multiple inheritance results in different derived and base class // pointer values ... for some more challenging tests :) @@ -142,7 +156,21 @@ SwigBoost::shared_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::s return kd; } +// 3 classes in inheritance chain test +struct Klass2ndDerived : Klass { + Klass2ndDerived() : Klass() {} + Klass2ndDerived(const std::string &val) : Klass(val) {} +}; +struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived { + Klass3rdDerived() : Klass2ndDerived() {} + Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {} + virtual ~Klass3rdDerived() {} + virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; } +}; +std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) { + return k->getValue(); +} @@ -217,8 +245,14 @@ SwigBoost::shared_ptr<Klass>* smartpointerpointerownertest() { return new SwigBoost::shared_ptr<Klass>(new Klass("smartpointerpointerownertest")); } -// Provide overloads for Klass and KlassDerived as some language modules, eg Python, create an extra reference in +// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in // the marshalling if an upcast to a base class is required. +long use_count(const SwigBoost::shared_ptr<Klass3rdDerived>& sptr) { + return sptr.use_count(); +} +long use_count(const SwigBoost::shared_ptr<Klass2ndDerived>& sptr) { + return sptr.use_count(); +} long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) { return sptr.use_count(); } diff --git a/Examples/test-suite/li_cstring.i b/Examples/test-suite/li_cstring.i index fd92ac7d3..28e8049e8 100644 --- a/Examples/test-suite/li_cstring.i +++ b/Examples/test-suite/li_cstring.i @@ -4,7 +4,7 @@ #ifndef SWIG_CSTRING_UNIMPL -%cstring_input_binary(char *in, int n); +%cstring_input_binary(char *str_in, int n); %cstring_bounded_output(char *out1, 512); %cstring_chunk_output(char *out2, 64); %cstring_bounded_mutable(char *out3, 512); @@ -22,13 +22,13 @@ %inline %{ -int count(char *in, int n, char c) { +int count(char *str_in, int n, char c) { int r = 0; while (n > 0) { - if (*in == c) { + if (*str_in == c) { r++; } - in++; + str_in++; --n; } return r; diff --git a/Examples/test-suite/li_cwstring.i b/Examples/test-suite/li_cwstring.i index dc9a1c4b9..769dcce12 100644 --- a/Examples/test-suite/li_cwstring.i +++ b/Examples/test-suite/li_cwstring.i @@ -4,7 +4,7 @@ #ifndef SWIG_CWSTRING_UNIMPL -%cwstring_input_binary(wchar_t *in, int n); +%cwstring_input_binary(wchar_t *str_in, int n); %cwstring_bounded_output(wchar_t *out1, 512); %cwstring_chunk_output(wchar_t *out2, 64); %cwstring_bounded_mutable(wchar_t *out3, 512); @@ -22,13 +22,13 @@ %inline %{ -int count(wchar_t *in, int n, wchar_t c) { +int count(wchar_t *str_in, int n, wchar_t c) { int r = 0; while (n > 0) { - if (*in == c) { + if (*str_in == c) { r++; } - in++; + str_in++; --n; } return r; diff --git a/Examples/test-suite/python/li_std_carray.i b/Examples/test-suite/li_std_carray.i index b38e0e441..b38e0e441 100644 --- a/Examples/test-suite/python/li_std_carray.i +++ b/Examples/test-suite/li_std_carray.i diff --git a/Examples/test-suite/ruby/li_std_functors.i b/Examples/test-suite/li_std_functors.i index 067bb1002..067bb1002 100644 --- a/Examples/test-suite/ruby/li_std_functors.i +++ b/Examples/test-suite/li_std_functors.i diff --git a/Examples/test-suite/perl5/li_std_list.i b/Examples/test-suite/li_std_list.i index bae475eea..bae475eea 100644 --- a/Examples/test-suite/perl5/li_std_list.i +++ b/Examples/test-suite/li_std_list.i diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i index edcb05641..356e86df3 100644 --- a/Examples/test-suite/li_std_map.i +++ b/Examples/test-suite/li_std_map.i @@ -1,45 +1,96 @@ -/** - * @file li_std_map.i - * @author gga - * @date Mon Apr 30 15:03:58 2007 - * - * @brief a test of map containers. - * Languages should define swig::LANGUAGE_OBJ to be - * an entity of their native pointer type which can be - * included in a STL container. - * - * For example: - * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is PyObject_ptr in python - * - * - */ - %module("templatereduce") li_std_map %feature("trackobjects"); -%include std_pair.i -%include std_map.i -%include std_multimap.i +%include "std_pair.i" +%include "std_map.i" +%include "std_string.i" + +// Declare some maps to play around with +%template(IntIntMap) std::map<int, int>; +%template(StringIntMap) std::map<std::string, int>; + +%ignore Struct::operator<; +%ignore Struct::operator==; +// Add an inline function to test %inline %{ -struct A{ - int val; + +double valueAverage(std::map<std::string, int> m) { + if (m.size() == 0) { + return 0.0; + } - A(int v = 0): val(v) - { - } + double a = 0.0; + for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) { + a += i->second; + } + + return a / m.size(); +} + +std::string stringifyKeys(std::map<std::string, int> m) { + std::string a; + for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) { + a += " " + i->first; + } + return a; +} +struct Struct { + double num; + Struct() : num(0.0) {} + Struct(double d) : num(d) {} + bool operator<(const Struct &other) const { return num < other.num; } + bool operator==(const Struct &other) const { return num == other.num; } }; + +%} + +#if defined(SWIGCSHARP) + +// Specialize some more non-default map types +SWIG_STD_MAP_SPECIALIZED(int, int *, int, SWIGTYPE_p_int) +SWIG_STD_MAP_SPECIALIZED(int, const int *, int, SWIGTYPE_p_int) +SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, Struct) +SWIG_STD_MAP_SPECIALIZED(int, Struct *, int, Struct) +SWIG_STD_MAP_SPECIALIZED(int, const Struct *, int, Struct) +SWIG_STD_MAP_SPECIALIZED(Struct *, int, Struct, int) + +#endif + +//#if !defined(SWIGR) + +// Test out some maps with pointer types +%template(IntIntPtrMap) std::map<int, int *>; +%template(IntConstIntPtrMap) std::map<int, const int *>; + +//#endif + + +// Test out some maps with non-basic types and non-basic pointer types +%template(IntStructMap) std::map<int, Struct>; +%template(IntStructPtrMap) std::map<int, Struct *>; +%template(IntStructConstPtrMap) std::map<int, const Struct *>; +%template(StructPtrIntMap) std::map<Struct *, int>; + +// Test out a non-specialized map +%template(StructIntMap) std::map<Struct, int>; + +// Additional map definitions for Ruby, Python and Octave tests +%inline %{ + struct A{ + int val; + + A(int v = 0): val(v) { + } + }; %} -namespace std -{ +namespace std { %template(pairii) pair<int, int>; %template(pairAA) pair<int, A>; %template(pairA) pair<int, A*>; %template(mapA) map<int, A*>; - %template(mmapA) multimap<int, A*>; %template(paircA1) pair<const int, A*>; %template(paircA2) pair<const int, const A*>; @@ -47,30 +98,26 @@ namespace std %template(pairiiAc) pair<int,const pair<int, A*> >; +#ifdef SWIGRUBY %template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; %template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >; - -} - - +#endif -%inline -{ -std::pair<int, A*> -p_identa(std::pair<int, A*> p) { - return p; +#ifdef SWIGPYTHON + %template() pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>; + %template(pymap) map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>; +#endif + } -std::map<int,A*> m_identa(const std::map<int,A*>& v) -{ - return v; -} +%inline { + std::pair<int, A*> p_identa(std::pair<int, A*> p) { + return p; + } + std::map<int, A*> m_identa(const std::map<int,A*>& v) { + return v; + } } - -namespace std -{ -%template(mapii) map<int,int>; -} diff --git a/Examples/test-suite/li_std_multimap.i b/Examples/test-suite/li_std_multimap.i new file mode 100644 index 000000000..a29417919 --- /dev/null +++ b/Examples/test-suite/li_std_multimap.i @@ -0,0 +1,25 @@ +%module("templatereduce") li_std_multimap + +%feature("trackobjects"); + +%include std_pair.i +%include std_map.i +%include std_multimap.i + +%inline %{ +struct A{ + int val; + + A(int v = 0): val(v) + { + } + +}; +%} + +namespace std +{ + %template(pairA) pair<int, A*>; + %template(mapA) map<int, A*>; + %template(multimapA) multimap<int, A*>; +} diff --git a/Examples/test-suite/octave/li_std_pair.i b/Examples/test-suite/li_std_pair_extra.i index 886bf1a4b..4e3b3a571 100644 --- a/Examples/test-suite/octave/li_std_pair.i +++ b/Examples/test-suite/li_std_pair_extra.i @@ -1,4 +1,4 @@ -%module li_std_pair +%module li_std_pair_extra // // activate the automatic comparison methods generation (==,!=,...) diff --git a/Examples/test-suite/ruby/li_std_pair_lang_object.i b/Examples/test-suite/li_std_pair_lang_object.i index a830af728..a830af728 100644 --- a/Examples/test-suite/ruby/li_std_pair_lang_object.i +++ b/Examples/test-suite/li_std_pair_lang_object.i diff --git a/Examples/test-suite/ruby/li_std_queue.i b/Examples/test-suite/li_std_queue.i index 2d322b4d9..2d322b4d9 100644 --- a/Examples/test-suite/ruby/li_std_queue.i +++ b/Examples/test-suite/li_std_queue.i diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i index c2cdc2ebe..8c335b24c 100644 --- a/Examples/test-suite/li_std_set.i +++ b/Examples/test-suite/li_std_set.i @@ -10,7 +10,7 @@ * * For example: * swig::LANGUAGE_OBJ is GC_VALUE in Ruby - * swig::LANGUAGE_OBJ is PyObject_ptr in python + * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python * * */ @@ -31,4 +31,10 @@ +#if defined(SWIGRUBY) %template(LanguageSet) std::set<swig::LANGUAGE_OBJ>; +#endif + +#if defined(SWIGPYTHON) +%template(pyset) std::set<swig::SwigPtr_PyObject>; +#endif diff --git a/Examples/test-suite/ruby/li_std_stack.i b/Examples/test-suite/li_std_stack.i index d29254089..d29254089 100644 --- a/Examples/test-suite/ruby/li_std_stack.i +++ b/Examples/test-suite/li_std_stack.i diff --git a/Examples/test-suite/octave/li_std_string.i b/Examples/test-suite/li_std_string_extra.i index 822d713c4..aa758532a 100644 --- a/Examples/test-suite/octave/li_std_string.i +++ b/Examples/test-suite/li_std_string_extra.i @@ -1,4 +1,4 @@ -%module li_std_string +%module li_std_string_extra %naturalvar A; @@ -51,5 +51,5 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_ %} -%include ../li_std_string.i +%include "li_std_string.i" diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i index 587ea2217..c6e2ea9ad 100644 --- a/Examples/test-suite/li_std_vector.i +++ b/Examples/test-suite/li_std_vector.i @@ -85,8 +85,10 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *) %template(StructureConstPtrVector) std::vector<const Structure *>; #endif +#if !defined(SWIGR) %template(IntPtrVector) std::vector<int *>; %template(IntConstPtrVector) std::vector<const int *>; +#endif %template(StructVector) std::vector<Struct>; %template(StructPtrVector) std::vector<Struct *>; %template(StructConstPtrVector) std::vector<const Struct *>; diff --git a/Examples/test-suite/python/li_std_vector.i b/Examples/test-suite/li_std_vector_extra.i index 06dafce59..9c2497f7c 100644 --- a/Examples/test-suite/python/li_std_vector.i +++ b/Examples/test-suite/li_std_vector_extra.i @@ -1,4 +1,4 @@ -%module li_std_vector +%module li_std_vector_extra %warnfilter(509) overloaded1; %warnfilter(509) overloaded2; @@ -123,11 +123,17 @@ std::vector<std::string> vecStr(std::vector<std::string> v) { %pointer_class(int,PtrInt) %array_functions(int,ArrInt) +%inline %{ + int *makeIntPtr(int v) { return new int(v); } + double *makeDoublePtr(double v) { return new double(v); } + int extractInt(int *p) { return *p; } +%} -%template(pyvector) std::vector<swig::PyObject_ptr>; +%template(pyvector) std::vector<swig::SwigPtr_PyObject>; namespace std { - %template(ConstIntVector) vector<const int *>; + %template(ConstShortVector) vector<const short *>; +// %template(ConstIntVector) vector<const int *>; // interferes with vector<int *>... see new testcase li_std_vector_ptr } %inline %{ diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i new file mode 100644 index 000000000..688cbdd54 --- /dev/null +++ b/Examples/test-suite/li_std_vector_ptr.i @@ -0,0 +1,29 @@ +%module li_std_vector_ptr + +%include "std_vector.i" + +%template(IntPtrVector) std::vector<int *>; + +%inline %{ +#include <iostream> +using namespace std; +int* makeIntPtr(int v) { + return new int(v); +} +double* makeDoublePtr(double v) { + return new double(v); +} + +#if 1 +int** makeIntPtrPtr(int* v) { + return new int*(v); +} +#endif + +void displayVector(std::vector<int *> vpi) { + cout << "displayVector..." << endl; + for (int i=0; i<vpi.size(); ++i) + cout << *vpi[i] << endl; +} +%} + diff --git a/Examples/test-suite/python/li_std_vectora.i b/Examples/test-suite/li_std_vectora.i index d95fdf648..d95fdf648 100644 --- a/Examples/test-suite/python/li_std_vectora.i +++ b/Examples/test-suite/li_std_vectora.i diff --git a/Examples/test-suite/python/li_std_wstream.i b/Examples/test-suite/li_std_wstream.i index e4d725f10..e4d725f10 100644 --- a/Examples/test-suite/python/li_std_wstream.i +++ b/Examples/test-suite/li_std_wstream.i diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i index a9cb35686..527dbcfaa 100644 --- a/Examples/test-suite/name_warnings.i +++ b/Examples/test-suite/name_warnings.i @@ -58,13 +58,12 @@ namespace std %template(max_i) max<int>; - %inline { /* silently rename the parameter names in csharp/java */ #ifdef SWIGR double foo(double inparam, double out) { return 1.0; } #else - double foo(double in, double out) { return 1.0; } + double foo(double abstract, double out) { return 1.0; } #endif double bar(double native, bool boolean) { return 1.0; } } diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i index e4e0af905..984b93a6f 100644 --- a/Examples/test-suite/namespace_typemap.i +++ b/Examples/test-suite/namespace_typemap.i @@ -75,7 +75,7 @@ namespace test { class string_class; #ifdef SWIGPYTHON %typemap(in) string_class * { - $1 = new string_class(PyString_AsString($input)); + $1 = new string_class(SWIG_Python_str_AsChar($input)); } %typemap(freearg) string_class * { delete $1; diff --git a/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i index 16f1b7af2..ea365a6fe 100644 --- a/Examples/test-suite/nested_comment.i +++ b/Examples/test-suite/nested_comment.i @@ -18,24 +18,17 @@ in rlgc models */ char *name; } n ; } s2; - -%} - -// bug #491476 -%inline %{ -struct { -struct { -int a; -} a, b; -} a; - %} -// bug #909387 +// comment in nested struct %inline %{ -struct foo { - struct happy; // no warning - struct sad { int x; }; // warning - happy *good(); // produces good code - sad *bad(); // produces bad code +struct a +{ + struct { + /*struct*/ + struct { + int b; + } c; + } d; }; +%} diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i new file mode 100644 index 000000000..4b13ff69d --- /dev/null +++ b/Examples/test-suite/nested_structs.i @@ -0,0 +1,22 @@ +%module nested_structs + +// bug #491476 +%inline %{ +struct { +struct { +int a; +} a, b; +} a; + +%} + +// bug #909387 +%inline %{ +struct foo { + struct happy; // no warning + struct sad { int x; }; // warning + happy *good(); // produces good code + sad *bad(); // produces bad code +}; +%} + diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in index 6f0b65489..0e6235f94 100644 --- a/Examples/test-suite/ocaml/Makefile.in +++ b/Examples/test-suite/ocaml/Makefile.in @@ -16,7 +16,7 @@ run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \ -f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ - $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& ./runme) ; \ + $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme) ; \ elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ $(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \ diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in index 534da55c4..b12cf500a 100644 --- a/Examples/test-suite/octave/Makefile.in +++ b/Examples/test-suite/octave/Makefile.in @@ -10,7 +10,9 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ - cell_deref + li_std_pair_extra \ + li_std_string_extra \ + octave_cell_deref CPP_TEST_BROKEN += \ implicittest \ diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m index c66e27c5b..548e733ed 100644 --- a/Examples/test-suite/octave/li_attribute_runme.m +++ b/Examples/test-suite/octave/li_attribute_runme.m @@ -10,7 +10,6 @@ if (aa.a != 3) error("aa.a = %i",aa.a) endif - if (aa.b != 2) error(aa.b) endif @@ -19,8 +18,6 @@ if (aa.b != 5) error endif - - if (aa.d != aa.b) error endif @@ -39,14 +36,13 @@ if (pi.value != 3) error endif - b = li_attribute.B(aa); if (b.a.c != 3) error endif - +# class/struct attribute with get/set methods using return/pass by reference myFoo = li_attribute.MyFoo(); myFoo.x = 8; myClass = li_attribute.MyClass(); @@ -55,3 +51,35 @@ if (myClass.Foo.x != 8) error endif +# class/struct attribute with get/set methods using return/pass by value +myClassVal = li_attribute.MyClassVal(); +if (myClassVal.ReadWriteFoo.x != -1) + error +endif +if (myClassVal.ReadOnlyFoo.x != -1) + error +endif +myClassVal.ReadWriteFoo = myFoo; +if (myClassVal.ReadWriteFoo.x != 8) + error +endif +if (myClassVal.ReadOnlyFoo.x != 8) + error +endif + +# string attribute with get/set methods using return/pass by value +myStringyClass = li_attribute.MyStringyClass("initial string"); +if (myStringyClass.ReadWriteString != "initial string") + error +endif +if (myStringyClass.ReadOnlyString != "initial string") + error +endif +myStringyClass.ReadWriteString = "changed string"; +if (myStringyClass.ReadWriteString != "changed string") + error +endif +if (myStringyClass.ReadOnlyString != "changed string") + error +endif + diff --git a/Examples/test-suite/octave/li_std_map_runme.m b/Examples/test-suite/octave/li_std_map_runme.m index e74fc79fc..f37c78012 100644 --- a/Examples/test-suite/octave/li_std_map_runme.m +++ b/Examples/test-suite/octave/li_std_map_runme.m @@ -49,7 +49,7 @@ for k in pm, endif endfor -mii = li_std_map.mapii(); +mii = li_std_map.IntIntMap(); mii{1} = 1; mii{1} = 2; diff --git a/Examples/test-suite/octave/li_std_pair_extra_runme.m b/Examples/test-suite/octave/li_std_pair_extra_runme.m new file mode 100644 index 000000000..0f9e9a23d --- /dev/null +++ b/Examples/test-suite/octave/li_std_pair_extra_runme.m @@ -0,0 +1,69 @@ +li_std_pair_extra + +p = {1,2}; +p1 = li_std_pair_extra.p_inout(p); +assert(all(cell2mat(p1)==[2,1])); +p2 = li_std_pair_extra.p_inoutd(p1); +assert(all(cell2mat(p2)==[1,2])); + +d1 = li_std_pair_extra.d_inout(2); +assert(d1==4); + +[i,d2] = li_std_pair_extra.d_inout2(2); +assert(all([i,d2]==[1,4])); + +[i,p] = li_std_pair_extra.p_inout2(p); +assert(i==1&&all([cell2mat(p)]==[2,1])); +[p3,p4] = li_std_pair_extra.p_inout3(p1,p1); +assert(all(cell2mat(p3)==[2,1])); +assert(all(cell2mat(p4)==[2,1])); + +psi = li_std_pair_extra.SIPair("hello",1); +assert(psi=={"hello",1}); +pci = li_std_pair_extra.CIPair(complex(1,2),1); +assert(pci.first==complex(1,2)&&pci.second==1); + + +psi = li_std_pair_extra.SIPair("hi",1); +assert(psi.first=="hi"&&psi.second==1); + +psii = li_std_pair_extra.SIIPair(psi,1); +assert(psii.first.first=="hi"); +assert(psii.first.second==1); +assert(psii.second==1); + +a = li_std_pair_extra.A(); +b = li_std_pair_extra.B(); + +pab = li_std_pair_extra.ABPair(a,b); + +pab.first = a; +pab.first.val = 2; + +assert(pab.first.val == 2); + +pci = li_std_pair_extra.CIntPair(1,0); +assert(pci.first==1&&pci.second==0); + +a = li_std_pair_extra.A(5); +p1 = li_std_pair_extra.pairP1(1,a); +p2 = li_std_pair_extra.pairP2(a,1); +p3 = li_std_pair_extra.pairP3(a,a); + +assert(a.val == li_std_pair_extra.p_identa(p1){2}.val); + +p = li_std_pair_extra.IntPair(1,10); +assert(p.first==1&&p.second==10); +p.first = 1; +assert(p.first==1); + +p = li_std_pair_extra.paircA1(1,a); +assert(p.first==1); +assert(swig_this(p.second)==swig_this(a)); + +p = li_std_pair_extra.paircA2(1,a); +assert(p.first==1); +assert(swig_this(p.second)==swig_this(a)); +#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2 +pp = li_std_pair_extra.pairiiA(1,{1,A()}); + diff --git a/Examples/test-suite/octave/li_std_pair_runme.m b/Examples/test-suite/octave/li_std_pair_runme.m deleted file mode 100644 index 83e9fe5b5..000000000 --- a/Examples/test-suite/octave/li_std_pair_runme.m +++ /dev/null @@ -1,69 +0,0 @@ -li_std_pair - -p = {1,2}; -p1 = li_std_pair.p_inout(p); -assert(all(cell2mat(p1)==[2,1])); -p2 = li_std_pair.p_inoutd(p1); -assert(all(cell2mat(p2)==[1,2])); - -d1 = li_std_pair.d_inout(2); -assert(d1==4); - -[i,d2] = li_std_pair.d_inout2(2); -assert(all([i,d2]==[1,4])); - -[i,p] = li_std_pair.p_inout2(p); -assert(i==1&&all([cell2mat(p)]==[2,1])); -[p3,p4] = li_std_pair.p_inout3(p1,p1); -assert(all(cell2mat(p3)==[2,1])); -assert(all(cell2mat(p4)==[2,1])); - -psi = li_std_pair.SIPair("hello",1); -assert(psi=={"hello",1}); -pci = li_std_pair.CIPair(complex(1,2),1); -assert(pci.first==complex(1,2)&&pci.second==1); - - -psi = li_std_pair.SIPair("hi",1); -assert(psi.first=="hi"&&psi.second==1); - -psii = li_std_pair.SIIPair(psi,1); -assert(psii.first.first=="hi"); -assert(psii.first.second==1); -assert(psii.second==1); - -a = li_std_pair.A(); -b = li_std_pair.B(); - -pab = li_std_pair.ABPair(a,b); - -pab.first = a; -pab.first.val = 2; - -assert(pab.first.val == 2); - -pci = li_std_pair.CIntPair(1,0); -assert(pci.first==1&&pci.second==0); - -a = li_std_pair.A(5); -p1 = li_std_pair.pairP1(1,a); -p2 = li_std_pair.pairP2(a,1); -p3 = li_std_pair.pairP3(a,a); - -assert(a.val == li_std_pair.p_identa(p1){2}.val); - -p = li_std_pair.IntPair(1,10); -assert(p.first==1&&p.second==10); -p.first = 1; -assert(p.first==1); - -p = li_std_pair.paircA1(1,a); -assert(p.first==1); -assert(swig_this(p.second)==swig_this(a)); - -p = li_std_pair.paircA2(1,a); -assert(p.first==1); -assert(swig_this(p.second)==swig_this(a)); -#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2 -pp = li_std_pair.pairiiA(1,{1,A()}); - diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m new file mode 100644 index 000000000..8d506af8a --- /dev/null +++ b/Examples/test-suite/octave/li_std_string_extra_runme.m @@ -0,0 +1,162 @@ +li_std_string_extra + +x="hello"; + + + +if (li_std_string_extra.test_ccvalue(x) != x) + error("bad string mapping") +endif + +if (li_std_string_extra.test_cvalue(x) != x) + error("bad string mapping") +endif + +if (li_std_string_extra.test_value(x) != x) + error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x)) +endif + +if (li_std_string_extra.test_const_reference(x) != x) + error("bad string mapping") +endif + + +s = li_std_string_extra.string("he"); +#s += "ll" +#s.append("ll") +s = s + "llo"; + +if (s != x) + error("bad string mapping: %s, %s", s, x); +endif + +#if (s(1:4) != x(1:4)) +# error("bad string mapping") +#endif + +if (li_std_string_extra.test_value(s) != x) + error("bad string mapping") +endif + +if (li_std_string_extra.test_const_reference(s) != x) + error("bad string mapping") +endif + +a = li_std_string_extra.A(s); + +if (li_std_string_extra.test_value(a) != x) + error("bad string mapping") +endif + +if (li_std_string_extra.test_const_reference(a) != x) + error("bad string mapping") +endif + +b = li_std_string_extra.string(" world"); + +s = a + b; +if (a + b != "hello world") + error("bad string mapping: %s", a + b) +endif + +if (a + " world" != "hello world") + error("bad string mapping") +endif + +#if ("hello" + b != "hello world") +# error("bad string mapping") +#endif + +c = (li_std_string_extra.string("hello") + b); +if (c.find_last_of("l") != 9) + error("bad string mapping") +endif + +s = "hello world"; + +b = li_std_string_extra.B("hi"); + +b.name = li_std_string_extra.string("hello"); +if (b.name != "hello") + error("bad string mapping") +endif + + +b.a = li_std_string_extra.A("hello"); +if (b.a != "hello") + error("bad string mapping") +endif + + +if (li_std_string_extra.test_value_basic1(x) != x) + error("bad string mapping") +endif + +if (li_std_string_extra.test_value_basic2(x) != x) + error("bad string mapping") +endif + + +if (li_std_string_extra.test_value_basic3(x) != x) + error("bad string mapping") +endif + +# Global variables +s = "initial string"; +if (li_std_string_extra.cvar.GlobalString2 != "global string 2") + error("GlobalString2 test 1") +endif +li_std_string_extra.cvar.GlobalString2 = s; +if (li_std_string_extra.cvar.GlobalString2 != s) + error("GlobalString2 test 2") +endif +if (li_std_string_extra.cvar.ConstGlobalString != "const global string") + error("ConstGlobalString test") +endif + +# Member variables +myStructure = li_std_string_extra.Structure(); +if (myStructure.MemberString2 != "member string 2") + error("MemberString2 test 1") +endif +myStructure.MemberString2 = s; +if (myStructure.MemberString2 != s) + error("MemberString2 test 2") +endif +if (myStructure.ConstMemberString != "const member string") + error("ConstMemberString test") +endif + +if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2") + error("StaticMemberString2 test 1") +endif +li_std_string_extra.cvar.Structure_StaticMemberString2 = s; +if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s) + error("StaticMemberString2 test 2") +endif +if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string") + error("ConstStaticMemberString test") +endif + + +if (li_std_string_extra.test_reference_input("hello") != "hello") + error +endif +s = li_std_string_extra.test_reference_inout("hello"); +if (s != "hellohello") + error +endif + + +if (li_std_string_extra.stdstring_empty() != "") + error +endif + + +if (li_std_string_extra.c_empty() != "") + error +endif + +#if (li_std_string_extra.c_null() != None) +# error +#endif diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_runme.m deleted file mode 100644 index fa0e260e0..000000000 --- a/Examples/test-suite/octave/li_std_string_runme.m +++ /dev/null @@ -1,162 +0,0 @@ -li_std_string - -x="hello"; - - - -if (li_std_string.test_ccvalue(x) != x) - error("bad string mapping") -endif - -if (li_std_string.test_cvalue(x) != x) - error("bad string mapping") -endif - -if (li_std_string.test_value(x) != x) - error("bad string mapping: %s, %s", x, li_std_string.test_value(x)) -endif - -if (li_std_string.test_const_reference(x) != x) - error("bad string mapping") -endif - - -s = li_std_string.string("he"); -#s += "ll" -#s.append('o') -s = s + "llo"; - -if (s != x) - error("bad string mapping: %s, %s", s, x); -endif - -if (s[1:4] != x[1:4]) - error("bad string mapping") -endif - -if (li_std_string.test_value(s) != x) - error("bad string mapping") -endif - -if (li_std_string.test_const_reference(s) != x) - error("bad string mapping") -endif - -a = li_std_string.A(s); - -if (li_std_string.test_value(a) != x) - error("bad string mapping") -endif - -if (li_std_string.test_const_reference(a) != x) - error("bad string mapping") -endif - -b = li_std_string.string(" world"); - -s = a + b; -if (a + b != "hello world") - error("bad string mapping: %s", a + b) -endif - -if (a + " world" != "hello world") - error("bad string mapping") -endif - -if ("hello" + b != "hello world") - error("bad string mapping") -endif - -c = ("hello" + b) -if (c.find_last_of("l") != 9) - error("bad string mapping") -endif - -s = "hello world"; - -b = li_std_string.B("hi"); - -b.name = li_std_string.string("hello"); -if (b.name != "hello") - error("bad string mapping") -endif - - -b.a = li_std_string.A("hello"); -if (b.a != "hello") - error("bad string mapping") -endif - - -if (li_std_string.test_value_basic1(x) != x) - error("bad string mapping") -endif - -if (li_std_string.test_value_basic2(x) != x) - error("bad string mapping") -endif - - -if (li_std_string.test_value_basic3(x) != x) - error("bad string mapping") -endif - -# Global variables -s = "initial string"; -if (li_std_string.cvar.GlobalString2 != "global string 2") - error("GlobalString2 test 1") -endif -li_std_string.cvar.GlobalString2 = s; -if (li_std_string.cvar.GlobalString2 != s) - error("GlobalString2 test 2") -endif -if (li_std_string.cvar.ConstGlobalString != "const global string") - error("ConstGlobalString test") -endif - -# Member variables -myStructure = li_std_string.Structure(); -if (myStructure.MemberString2 != "member string 2") - error("MemberString2 test 1") -endif -myStructure.MemberString2 = s; -if (myStructure.MemberString2 != s) - error("MemberString2 test 2") -endif -if (myStructure.ConstMemberString != "const member string") - error("ConstMemberString test") -endif - -if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2") - error("StaticMemberString2 test 1") -endif -li_std_string.cvar.Structure_StaticMemberString2 = s; -if (li_std_string.cvar.Structure_StaticMemberString2 != s) - error("StaticMemberString2 test 2") -endif -if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string") - error("ConstStaticMemberString test") -endif - - -if (li_std_string.test_reference_input("hello") != "hello") - error -endif -s = li_std_string.test_reference_inout("hello"); -if (s != "hellohello") - error -endif - - -if (li_std_string.stdstring_empty() != "") - error -endif - - -if (li_std_string.c_empty() != "") - error -endif - -if (li_std_string.c_null() != None) - error -endif diff --git a/Examples/test-suite/octave/cell_deref_runme.m b/Examples/test-suite/octave/octave_cell_deref_runme.m index 1c370fe85..5a98c0a3b 100644 --- a/Examples/test-suite/octave/cell_deref_runme.m +++ b/Examples/test-suite/octave/octave_cell_deref_runme.m @@ -1,4 +1,4 @@ -cell_deref; +octave_cell_deref; assert(func("hello")); assert(func({"hello"})); diff --git a/Examples/test-suite/octave/cell_deref.i b/Examples/test-suite/octave_cell_deref.i index fddcd80ec..2e92ec4de 100644 --- a/Examples/test-suite/octave/cell_deref.i +++ b/Examples/test-suite/octave_cell_deref.i @@ -1,4 +1,4 @@ -%module cell_deref +%module octave_cell_deref %inline { bool func(const char* s) { diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i index 775818e83..b2537c669 100644 --- a/Examples/test-suite/operator_overload.i +++ b/Examples/test-suite/operator_overload.i @@ -71,6 +71,12 @@ see bottom for a set of possible tests %rename(OrOperator) operator ||; #endif +#ifdef SWIG_ALLEGRO_CL +%{ +#include <stdio.h> +%} +#endif + %rename(IntCast) operator int(); %rename(DoubleCast) operator double(); diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i new file mode 100644 index 000000000..793c0174e --- /dev/null +++ b/Examples/test-suite/operbool.i @@ -0,0 +1,12 @@ +%module operbool + +%rename(operbool) operator bool(); + +%inline %{ + class Test { + public: + operator bool() { + return false; + } + }; +%} diff --git a/Examples/test-suite/packageoption.h b/Examples/test-suite/packageoption.h index a7ef499aa..82f29d1c7 100644 --- a/Examples/test-suite/packageoption.h +++ b/Examples/test-suite/packageoption.h @@ -1,5 +1,6 @@ -class A -{ - public: - int testInt() { return 2;} +struct Base { + virtual int vmethod() { return 1; } + int basemethod() { return 1; } + virtual ~Base() {} }; + diff --git a/Examples/test-suite/packageoption.list b/Examples/test-suite/packageoption.list index 4bdabeccf..da125c2a3 100644 --- a/Examples/test-suite/packageoption.list +++ b/Examples/test-suite/packageoption.list @@ -1,2 +1,3 @@ packageoption_a packageoption_b +packageoption_c diff --git a/Examples/test-suite/packageoption_a.i b/Examples/test-suite/packageoption_a.i index e95091b0d..b28278282 100644 --- a/Examples/test-suite/packageoption_a.i +++ b/Examples/test-suite/packageoption_a.i @@ -1,4 +1,4 @@ -%module(package="C") "packageoption_a"; +%module(package="CommonPackage") "packageoption_a"; %inline %{ class A @@ -6,5 +6,11 @@ class A public: int testInt() { return 2;} }; +%} +%{ +#include "packageoption.h" %} + +%include "packageoption.h" + diff --git a/Examples/test-suite/packageoption_b.i b/Examples/test-suite/packageoption_b.i index 466853cc0..40a44be14 100644 --- a/Examples/test-suite/packageoption_b.i +++ b/Examples/test-suite/packageoption_b.i @@ -1,4 +1,4 @@ -%module(package="C") "packageoption_b"; +%module(package="CommonPackage") "packageoption_b"; %inline %{ class B diff --git a/Examples/test-suite/packageoption_c.i b/Examples/test-suite/packageoption_c.i new file mode 100644 index 000000000..f43e47002 --- /dev/null +++ b/Examples/test-suite/packageoption_c.i @@ -0,0 +1,13 @@ +%module(package="PackageC") "packageoption_c"; + +%import "packageoption_a.i" + +%inline %{ +#include "packageoption.h" + +struct Derived : Base { + virtual int vmethod() { return 2; } + virtual ~Derived() {} +}; + +%} diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in index 3fee35bcb..518d341b2 100644 --- a/Examples/test-suite/perl5/Makefile.in +++ b/Examples/test-suite/perl5/Makefile.in @@ -15,6 +15,7 @@ CPP_TEST_CASES += \ li_cdata \ li_cstring \ li_cdata_carrays \ + byreference \ C_TEST_CASES += \ li_cdata \ diff --git a/Examples/test-suite/perl5/byreference.i b/Examples/test-suite/perl5/byreference.i new file mode 100644 index 000000000..43215f1cc --- /dev/null +++ b/Examples/test-suite/perl5/byreference.i @@ -0,0 +1,52 @@ +%module byreference + +%include "reference.i" + +%inline %{ + double FrVal; + double ToVal; + void PDouble(double *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RDouble(double &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PFloat(float *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RFloat(float &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PInt(int *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RInt(int &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PShort(short *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RShort(short &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PLong(long *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RLong(long &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PUInt(unsigned int *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RUInt(unsigned int &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PUShort(unsigned short *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RUShort(unsigned short &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PULong(unsigned long *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RULong(unsigned long &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PUChar(unsigned char *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RUChar(unsigned char &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PChar(signed char *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RChar(signed char &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } + void PBool(bool *REFERENCE, int t = 0) + { ToVal = *REFERENCE; *REFERENCE = FrVal + t; } + void RBool(bool &REFERENCE, int t = 0) + { ToVal = REFERENCE; REFERENCE = FrVal + t; } +%} diff --git a/Examples/test-suite/perl5/byreference_runme.pl b/Examples/test-suite/perl5/byreference_runme.pl new file mode 100644 index 000000000..845d870cd --- /dev/null +++ b/Examples/test-suite/perl5/byreference_runme.pl @@ -0,0 +1,36 @@ +use strict; +use warnings; +use Test::More tests => 68; +BEGIN { use_ok('byreference') } +require_ok('byreference'); + +sub chk { my($type, $call, $v1, $v2) = @_; + $byreference::FrVal = $v1; + my $v = $v2; + eval { $call->(\$v) }; + is($@, '', "$type check"); + is($byreference::ToVal, $v2, "$type out"); + is($v, $v1, "$type in"); +} +chk("double*", \&byreference::PDouble, 12.2, 18.6); +chk("double&", \&byreference::RDouble, 32.5, 64.8); +chk("float*", \&byreference::PFloat, 64.5, 96.0); +chk("float&", \&byreference::RFloat, 98.5, 6.25); +chk("int*", \&byreference::PInt, 1887, 3356); +chk("int&", \&byreference::RInt, 2622, 9867); +chk("short*", \&byreference::PShort, 4752, 3254); +chk("short&", \&byreference::RShort, 1898, 5757); +chk("long*", \&byreference::PLong, 6687, 7132); +chk("long&", \&byreference::RLong, 8346, 4398); +chk("uint*", \&byreference::PUInt, 6853, 5529); +chk("uint&", \&byreference::RUInt, 5483, 7135); +chk("ushort*", \&byreference::PUShort, 9960, 9930); +chk("ushort&", \&byreference::RUShort, 1193, 4178); +chk("ulong*", \&byreference::PULong, 7960, 4788); +chk("ulong&", \&byreference::RULong, 8829, 1603); +chk("uchar*", \&byreference::PUChar, 110, 239); +chk("uchar&", \&byreference::RUChar, 15, 97); +chk("char*", \&byreference::PChar, -7, 118); +chk("char&", \&byreference::RChar, -3, -107); +chk("bool*", \&byreference::PBool, 0, 1); +chk("bool&", \&byreference::RBool, 1, 0); diff --git a/Examples/test-suite/perl5/char_strings_runme.pl b/Examples/test-suite/perl5/char_strings_runme.pl index 51c227bb9..c4573737e 100644 --- a/Examples/test-suite/perl5/char_strings_runme.pl +++ b/Examples/test-suite/perl5/char_strings_runme.pl @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 5; BEGIN { use_ok('char_strings') } require_ok('char_strings'); @@ -10,3 +10,6 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1'); my $val2 = "greetings"; is(char_strings::CharPingPong($val2), "greetings", 'cstr2'); +# SF#2564192 +"this is a test" =~ /(\w+)$/; +is(char_strings::CharPingPong($1), "test", "handles Magical"); diff --git a/Examples/test-suite/perl5/enum_thorough_runme.pl b/Examples/test-suite/perl5/enum_thorough_runme.pl index 80a2ccae9..66e719275 100644 --- a/Examples/test-suite/perl5/enum_thorough_runme.pl +++ b/Examples/test-suite/perl5/enum_thorough_runme.pl @@ -1,7 +1,7 @@ # an adaptation of ../java/enum_thorough_runme.java use strict; use warnings; -use Test::More tests => 272; +use Test::More tests => 298; BEGIN { use_ok('enum_thorough') } require_ok('enum_thorough'); @@ -348,17 +348,51 @@ SKIP: { $i->{MemberInstance} = $enum_thorough::Instances::memberinstance3; is($i->{MemberInstance}, $enum_thorough::Instances::memberinstance3, "MemberInstance 1"); } +# ignore enum item tests start +{ + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_zero), 0, "ignoreATest 0"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_three), 3, "ignoreATest 3"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_ten), 10, "ignoreATest 10"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_eleven), 11, "ignoreATest 11"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirteen), 13, "ignoreATest 13"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_fourteen), 14, "ignoreATest 14"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_twenty), 20, "ignoreATest 20"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty), 30, "ignoreATest 30"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_two), 32, "ignoreATest 32"); + is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_three), 33, "ignoreATest 33"); +} +{ + is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_eleven), 11, "ignoreBTest 11"); + is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_twelve), 12, "ignoreBTest 12"); + is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_one), 31, "ignoreBTest 31"); + is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_two), 32, "ignoreBTest 32"); + is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_one), 41, "ignoreBTest 41"); + is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_two), 42, "ignoreBTest 42"); +} +{ + is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_ten), 10, "ignoreCTest 10"); + is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_twelve), 12, "ignoreCTest 12"); + is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty), 30, "ignoreCTest 30"); + is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty_two), 32, "ignoreCTest 32"); + is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty), 40, "ignoreCTest 40"); + is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty_two), 42, "ignoreCTest 42"); +} +{ + is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_one), 21, "ignoreDTest 21"); + is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_two), 22, "ignoreDTest 22"); +} +{ + is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_zero), 0, "ignoreETest 0"); + is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_one), 21, "ignoreETest 21"); + is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_two), 22, "ignoreETest 22"); +} +# ignore enum item tests end { is(enum_thorough::repeatTest($enum_thorough::one), 1, "repeatTest 1"); is(enum_thorough::repeatTest($enum_thorough::initial), 1, "repeatTest 2"); is(enum_thorough::repeatTest($enum_thorough::two), 2, "repeatTest 3"); is(enum_thorough::repeatTest($enum_thorough::three), 3, "repeatTest 4"); -{ local $TODO = "overzealous keyword guarding"; - ok(defined($enum_thorough::last), "found enum value"); -SKIP: { - skip "enum value not in expected package", 1 unless defined $enum_thorough::last; - is(enum_thorough::repeatTest($enum_thorough::last), 3, "repeatTest 5"); -}} + is(enum_thorough::repeatTest($enum_thorough::llast), 3, "repeatTest 5"); is(enum_thorough::repeatTest($enum_thorough::end), 3, "repeatTest 6"); } @@ -368,8 +402,8 @@ SKIP: { is(enum_thorough::speedTest4($enum_thorough::SpeedClass::slow), $enum_thorough::SpeedClass::slow, "speedTest Global 4"); is(enum_thorough::speedTest5($enum_thorough::SpeedClass::slow), - $enum_thorough::SpeedClass::slow, "speedTest Global 5 failed"); + $enum_thorough::SpeedClass::slow, "speedTest Global 5"); is(enum_thorough::speedTest4($enum_thorough::SpeedClass::fast), - $enum_thorough::SpeedClass::fast, "speedTest Global 4 failed"); + $enum_thorough::SpeedClass::fast, "speedTest Global 4"); is(enum_thorough::speedTest5($enum_thorough::SpeedClass::fast), - $enum_thorough::SpeedClass::fast, "speedTest Global 5 failed"); + $enum_thorough::SpeedClass::fast, "speedTest Global 5"); diff --git a/Examples/test-suite/perl5/imports_runme.pl b/Examples/test-suite/perl5/imports_runme.pl index 13ca08a1c..fd730fedf 100644 --- a/Examples/test-suite/perl5/imports_runme.pl +++ b/Examples/test-suite/perl5/imports_runme.pl @@ -1,5 +1,5 @@ use imports_b; use imports_a; -$x = imports_b::B->new(); +$x = imports_bc::new_B(); imports_ac::A_hello($x); diff --git a/Examples/test-suite/perl5/packageoption_runme.pl b/Examples/test-suite/perl5/packageoption_runme.pl index debea78e1..d94a7a1fd 100644 --- a/Examples/test-suite/perl5/packageoption_runme.pl +++ b/Examples/test-suite/perl5/packageoption_runme.pl @@ -14,11 +14,11 @@ sub ok_not ($;$) { ok($test, $name); } -my $a = C::A->new(); +my $a = CommonPackage::A->new(); -isa_ok($a, 'C::A'); +isa_ok($a, 'CommonPackage::A'); -my $b = C::B->new(); +my $b = CommonPackage::B->new(); -isa_ok($b, 'C::B'); +isa_ok($b, 'CommonPackage::B'); diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in new file mode 100644 index 000000000..d48f37e8a --- /dev/null +++ b/Examples/test-suite/php/Makefile.in @@ -0,0 +1,56 @@ +####################################################################### +# Makefile for php test-suite +####################################################################### + +LANGUAGE = php +SCRIPTSUFFIX = _runme.php +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ + +#CPP_TEST_CASES += \ +# php_namewarn_rename \ + +include $(srcdir)/../common.mk + +# Overridden variables here +TARGETPREFIX =# Should be php_ for Windows, empty otherwise + +# write out tests without a _runme.php +missingcpptests: + for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done + +missingctests: + for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done + +missingtests: missingcpptests missingctests + +# Rules for the different types of tests +%.cpptest: + $(setup) + +$(swig_and_compile_cpp) + +$(run_testcase) + +%.ctest: + $(setup) + +$(swig_and_compile_c) + +$(run_testcase) + +%.multicpptest: + $(setup) + +$(swig_and_compile_multi_cpp) + +$(run_testcase) + +# Runs the testcase. A testcase is only run if +# a file is found which has _runme.php appended after the testcase name. +run_testcase = \ + if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \ + fi; + +# Clean: remove the generated .php file +%.clean: + @rm -f $*.php; + +clean: + $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean diff --git a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 b/Examples/test-suite/php/abstract_inherit_ok_runme.php index 1182e4cec..c2d86499b 100644 --- a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 +++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "abstract_inherit_ok.php"; check::classes(array(Foo,Spam)); diff --git a/Examples/test-suite/php4/abstract_inherit_runme.php4 b/Examples/test-suite/php/abstract_inherit_runme.php index fbc971711..3554e6fd8 100644 --- a/Examples/test-suite/php4/abstract_inherit_runme.php4 +++ b/Examples/test-suite/php/abstract_inherit_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "abstract_inherit.php"; check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i)); diff --git a/Examples/test-suite/php4/add_link_runme.php4 b/Examples/test-suite/php/add_link_runme.php index b9d5334dd..4d8c31d5e 100644 --- a/Examples/test-suite/php4/add_link_runme.php4 +++ b/Examples/test-suite/php/add_link_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "add_link.php"; // No new functions, except the flat functions diff --git a/Examples/test-suite/php4/argout_runme.php4 b/Examples/test-suite/php/argout_runme.php index 1328b0926..1c9026b6c 100644 --- a/Examples/test-suite/php4/argout_runme.php4 +++ b/Examples/test-suite/php/argout_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "argout.php"; check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle)); diff --git a/Examples/test-suite/php4/arrayptr_runme.php4 b/Examples/test-suite/php/arrayptr_runme.php index c057a6772..717c870d9 100644 --- a/Examples/test-suite/php4/arrayptr_runme.php4 +++ b/Examples/test-suite/php/arrayptr_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "arrayptr.php"; // No new functions diff --git a/Examples/test-suite/php4/arrays_global_runme.php4 b/Examples/test-suite/php/arrays_global_runme.php index d6a3955e1..baa5521ed 100644 --- a/Examples/test-suite/php4/arrays_global_runme.php4 +++ b/Examples/test-suite/php/arrays_global_runme.php @@ -1,14 +1,20 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "arrays_global.php"; check::functions(array(test_a,test_b,new_simplestruct,new_material)); check::classes(array(arrays_global,SimpleStruct,Material)); check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat)); -check::set(array_c,"hac"); -check::equal("ha",check::get(array_c,"ha"),"set array_c"); +// The size of array_c is 2, but the last byte is \0, so we can only store a +// single byte string in it. +check::set(array_c,"Z"); +check::equal("Z",check::get(array_c),"set array_c"); +check::set(array_c,"xy"); +check::equal("x",check::get(array_c),"set array_c"); +check::set(array_c,"h"); +check::equal("h",check::get(array_c),"set array_c"); check::done(); ?> diff --git a/Examples/test-suite/php4/arrays_global_twodim_runme.php4 b/Examples/test-suite/php/arrays_global_twodim_runme.php index 352ad2568..d9b62de0d 100644 --- a/Examples/test-suite/php4/arrays_global_twodim_runme.php4 +++ b/Examples/test-suite/php/arrays_global_twodim_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "arrays_global_twodim.php"; check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material)); diff --git a/Examples/test-suite/php4/arrays_runme.php4 b/Examples/test-suite/php/arrays_runme.php index 407c32c31..97ee6bbbf 100644 --- a/Examples/test-suite/php4/arrays_runme.php4 +++ b/Examples/test-suite/php/arrays_runme.php @@ -1,6 +1,6 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "arrays.php"; check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func)); diff --git a/Examples/test-suite/php4/arrays_scope_runme.php4 b/Examples/test-suite/php/arrays_scope_runme.php index 75c7ccf27..92de96920 100644 --- a/Examples/test-suite/php4/arrays_scope_runme.php4 +++ b/Examples/test-suite/php/arrays_scope_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "arrays_scope.php"; // No new functions diff --git a/Examples/test-suite/php4/casts_runme.php4 b/Examples/test-suite/php/casts_runme.php index c3d19e29e..03ee6829c 100644 --- a/Examples/test-suite/php4/casts_runme.php4 +++ b/Examples/test-suite/php/casts_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "casts.php"; // No new functions diff --git a/Examples/test-suite/php4/class_ignore_runme.php4 b/Examples/test-suite/php/class_ignore_runme.php index 5da23e502..861576026 100644 --- a/Examples/test-suite/php4/class_ignore_runme.php4 +++ b/Examples/test-suite/php/class_ignore_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "class_ignore.php"; check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo)); diff --git a/Examples/test-suite/php4/conversion_namespace_runme.php4 b/Examples/test-suite/php/conversion_namespace_runme.php index ae49d2002..e6866f871 100644 --- a/Examples/test-suite/php4/conversion_namespace_runme.php4 +++ b/Examples/test-suite/php/conversion_namespace_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "conversion_namespace.php"; check::classes(array("Foo","Bar")); diff --git a/Examples/test-suite/php4/conversion_ns_template_runme.php4 b/Examples/test-suite/php/conversion_ns_template_runme.php index e799cdd48..9702eedb7 100644 --- a/Examples/test-suite/php4/conversion_ns_template_runme.php4 +++ b/Examples/test-suite/php/conversion_ns_template_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "conversion_ns_template.php"; check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi")); diff --git a/Examples/test-suite/php4/conversion_runme.php4 b/Examples/test-suite/php/conversion_runme.php index 7941a7bbe..69ade46db 100644 --- a/Examples/test-suite/php4/conversion_runme.php4 +++ b/Examples/test-suite/php/conversion_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "conversion.php"; check::classes(array("Foo","Bar")); diff --git a/Examples/test-suite/php4/cpp_static_runme.php4 b/Examples/test-suite/php/cpp_static_runme.php index b7f987505..54dbfc7d8 100644 --- a/Examples/test-suite/php4/cpp_static_runme.php4 +++ b/Examples/test-suite/php/cpp_static_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "cpp_static.php"; // No new functions diff --git a/Examples/test-suite/php4/enum_scope_template_runme.php4 b/Examples/test-suite/php/enum_scope_template_runme.php index 40efc5743..7cea23911 100644 --- a/Examples/test-suite/php4/enum_scope_template_runme.php4 +++ b/Examples/test-suite/php/enum_scope_template_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "enum_scope_template.php"; check::classes(array("enum_scope_template", "TreeInt")); diff --git a/Examples/test-suite/php4/evil_diamond_ns_runme.php4 b/Examples/test-suite/php/evil_diamond_ns_runme.php index 29e8cd520..b76d1443f 100644 --- a/Examples/test-suite/php4/evil_diamond_ns_runme.php4 +++ b/Examples/test-suite/php/evil_diamond_ns_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "evil_diamond_ns.php"; check::classes(array("evil_diamond_ns","foo","bar","baz","spam")); diff --git a/Examples/test-suite/php4/evil_diamond_prop_runme.php4 b/Examples/test-suite/php/evil_diamond_prop_runme.php index c0b157fca..6f66d01c5 100644 --- a/Examples/test-suite/php4/evil_diamond_prop_runme.php4 +++ b/Examples/test-suite/php/evil_diamond_prop_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "evil_diamond_prop.php"; check::classes(array("evil_diamond_prop","foo","bar","baz","spam")); diff --git a/Examples/test-suite/php4/evil_diamond_runme.php4 b/Examples/test-suite/php/evil_diamond_runme.php index 677813bfa..a6ef211b1 100644 --- a/Examples/test-suite/php4/evil_diamond_runme.php4 +++ b/Examples/test-suite/php/evil_diamond_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "evil_diamond.php"; check::classes(array("evil_diamond","foo","bar","baz","spam")); diff --git a/Examples/test-suite/php4/extend_template_ns_runme.php4 b/Examples/test-suite/php/extend_template_ns_runme.php index 16a6434bf..604e0470e 100644 --- a/Examples/test-suite/php4/extend_template_ns_runme.php4 +++ b/Examples/test-suite/php/extend_template_ns_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "extend_template_ns.php"; check::classes(array("extend_template_ns","Foo_One")); diff --git a/Examples/test-suite/php4/extend_template_runme.php4 b/Examples/test-suite/php/extend_template_runme.php index c12f330a5..bf77e9b1c 100644 --- a/Examples/test-suite/php4/extend_template_runme.php4 +++ b/Examples/test-suite/php/extend_template_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "extend_template.php"; check::classes(array("Foo_0")); diff --git a/Examples/test-suite/php4/grouping_runme.php4 b/Examples/test-suite/php/grouping_runme.php index 45e321fd3..8a2a88fa9 100644 --- a/Examples/test-suite/php4/grouping_runme.php4 +++ b/Examples/test-suite/php/grouping_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "grouping.php"; check::functions(array("test1","test2","do_unary","negate")); diff --git a/Examples/test-suite/php4/ignore_parameter_runme.php4 b/Examples/test-suite/php/ignore_parameter_runme.php index 8a2bf899e..745720c3c 100644 --- a/Examples/test-suite/php4/ignore_parameter_runme.php4 +++ b/Examples/test-suite/php/ignore_parameter_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "ignore_parameter.php"; // No new functions diff --git a/Examples/test-suite/php4/li_carrays_runme.php4 b/Examples/test-suite/php/li_carrays_runme.php index b0b93dafe..babf8443b 100644 --- a/Examples/test-suite/php4/li_carrays_runme.php4 +++ b/Examples/test-suite/php/li_carrays_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "li_carrays.php"; // No new functions diff --git a/Examples/test-suite/php4/li_std_string_runme.php4 b/Examples/test-suite/php/li_std_string_runme.php index fb3da3598..c7270df3d 100644 --- a/Examples/test-suite/php4/li_std_string_runme.php4 +++ b/Examples/test-suite/php/li_std_string_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "li_std_string.php"; // Global variables diff --git a/Examples/test-suite/php4/rename_scope_runme.php4 b/Examples/test-suite/php/rename_scope_runme.php index ad86321d3..33925a6db 100644 --- a/Examples/test-suite/php4/rename_scope_runme.php4 +++ b/Examples/test-suite/php/rename_scope_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "rename_scope.php"; check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket")); diff --git a/Examples/test-suite/php4/skel.php4 b/Examples/test-suite/php/skel.php index d6f33758d..780a999ed 100644 --- a/Examples/test-suite/php4/skel.php4 +++ b/Examples/test-suite/php/skel.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "____.php"; // No new functions diff --git a/Examples/test-suite/php4/smart_pointer_rename_runme.php4 b/Examples/test-suite/php/smart_pointer_rename_runme.php index 5f21b6dda..a1759cb95 100644 --- a/Examples/test-suite/php4/smart_pointer_rename_runme.php4 +++ b/Examples/test-suite/php/smart_pointer_rename_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "smart_pointer_rename.php"; check::classes(array("Foo","Bar")); diff --git a/Examples/test-suite/php4/sym_runme.php4 b/Examples/test-suite/php/sym_runme.php index ce89ea4b2..a6d2a6c74 100644 --- a/Examples/test-suite/php4/sym_runme.php4 +++ b/Examples/test-suite/php/sym_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "sym.php"; // No new functions diff --git a/Examples/test-suite/php4/template_arg_typename_runme.php4 b/Examples/test-suite/php/template_arg_typename_runme.php index 7062c674e..58835eafe 100644 --- a/Examples/test-suite/php4/template_arg_typename_runme.php4 +++ b/Examples/test-suite/php/template_arg_typename_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "template_arg_typename.php"; // No new functions diff --git a/Examples/test-suite/php4/template_construct_runme.php4 b/Examples/test-suite/php/template_construct_runme.php index d0fbc9bb7..3a3986f7e 100644 --- a/Examples/test-suite/php4/template_construct_runme.php4 +++ b/Examples/test-suite/php/template_construct_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "template_construct.php"; check::classes(array(Foo_int)); diff --git a/Examples/test-suite/php4/tests.php4 b/Examples/test-suite/php/tests.php index 36e9f4163..b62e878fc 100644 --- a/Examples/test-suite/php4/tests.php4 +++ b/Examples/test-suite/php/tests.php @@ -185,7 +185,7 @@ class check { } function equal($a,$b,$message) { - if (! ($a===$b)) return check::fail($message); + if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'"); return TRUE; } diff --git a/Examples/test-suite/php4/typedef_reference_runme.php4 b/Examples/test-suite/php/typedef_reference_runme.php index 2c64efce6..88a70f8d3 100644 --- a/Examples/test-suite/php4/typedef_reference_runme.php4 +++ b/Examples/test-suite/php/typedef_reference_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "typedef_reference.php"; check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value)); diff --git a/Examples/test-suite/php4/typemap_ns_using_runme.php4 b/Examples/test-suite/php/typemap_ns_using_runme.php index 44403d138..6a599f008 100644 --- a/Examples/test-suite/php4/typemap_ns_using_runme.php4 +++ b/Examples/test-suite/php/typemap_ns_using_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "typemap_ns_using.php"; if (! class_exists("_fooimpl")) die("_fooimpl class not found\n"); if (! 3==spam(3)) die("spam function not working right\n"); diff --git a/Examples/test-suite/php4/using1_runme.php4 b/Examples/test-suite/php/using1_runme.php index ed7e32b06..51841bc78 100644 --- a/Examples/test-suite/php4/using1_runme.php4 +++ b/Examples/test-suite/php/using1_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "using1.php"; if (! class_exists("_fooimpl")) die("_fooimpl class not found\n"); if (! 3==spam(3)) die("spam function not working right\n"); diff --git a/Examples/test-suite/php4/using2_runme.php4 b/Examples/test-suite/php/using2_runme.php index e57f0ce9a..391a98f52 100644 --- a/Examples/test-suite/php4/using2_runme.php4 +++ b/Examples/test-suite/php/using2_runme.php @@ -1,6 +1,6 @@ <?php -require "tests.php4"; +require "tests.php"; require "using2.php"; if (! class_exists("_fooimpl")) die("_fooimpl class not found\n"); if (! 3==spam(3)) die("spam function not working right\n"); diff --git a/Examples/test-suite/php4/valuewrapper_base_runme.php4 b/Examples/test-suite/php/valuewrapper_base_runme.php index 355bb41c5..aff88486e 100644 --- a/Examples/test-suite/php4/valuewrapper_base_runme.php4 +++ b/Examples/test-suite/php/valuewrapper_base_runme.php @@ -1,7 +1,7 @@ <?php // Sample test file -require "tests.php4"; +require "tests.php"; require "valuewrapper_base.php"; check::classes(array("valuewrapper_base","Base","Interface_BP")); diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php4/Makefile.in deleted file mode 100644 index 2e14ef9a2..000000000 --- a/Examples/test-suite/php4/Makefile.in +++ /dev/null @@ -1,69 +0,0 @@ -####################################################################### -# Makefile for php4 test-suite -####################################################################### - -LANGUAGE = php4 -SCRIPTSUFFIX = _runme.php4 -srcdir = @srcdir@ -top_srcdir = @top_srcdir@ -top_builddir = @top_builddir@ - -include $(srcdir)/../common.mk - -# Overridden variables here -TARGETPREFIX =# Should be php_ for Windows, empty otherwise - -makecpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do $(MAKE) clean && $(MAKE) $${test}.cpptest; done' - -maketests: makecpptests makectests - -makectests: - @bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done' - -runcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done' - -runctests: - @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done' - -runtests: runcpptests runctests - -# write out tests without a _runme.php4 -missingcpptests: - @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done' - -missingctests: - @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done' - -missingtests: missingcpptests missingctests - -# Rules for the different types of tests -%.cpptest: - $(setup) - +$(swig_and_compile_cpp) - +$(run_testcase) - -%.ctest: - $(setup) - +$(swig_and_compile_c) - +$(run_testcase) - -%.multicpptest: - $(setup) - +$(swig_and_compile_multi_cpp) - +$(run_testcase) - -# Runs the testcase. A testcase is only run if -# a file is found which has _runme.php4 appended after the testcase name. -run_testcase = \ - if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \ - fi; - -# Clean: remove the generated .php file -%.clean: - @rm -f $*.php; - -clean: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php4_clean diff --git a/Examples/test-suite/php4/namewarn_rename.i b/Examples/test-suite/php_namewarn_rename.i index 98de311b9..87877c4f0 100644 --- a/Examples/test-suite/php4/namewarn_rename.i +++ b/Examples/test-suite/php_namewarn_rename.i @@ -1,4 +1,4 @@ -%module namewarn_rename +%module php_namewarn_rename %inline %{ diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i index 9491fc1d2..b9f357b90 100644 --- a/Examples/test-suite/preproc.i +++ b/Examples/test-suite/preproc.i @@ -313,6 +313,11 @@ int test(int defined) #define MASK(shift, size) (((1 << (size)) - 1) <<(shift)) #define SOME_MASK_DEF (80*MASK(8, 10)) +/* some constants */ +#define BOLTZMANN (1.380658e-23) +#define AVOGADRO (6.0221367e23) +#define RGAS (BOLTZMANN*AVOGADRO) +#define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN) %{ #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \ diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i index f8189a502..27a90bc72 100644 --- a/Examples/test-suite/pure_virtual.i +++ b/Examples/test-suite/pure_virtual.i @@ -63,16 +63,18 @@ class E : public C, public AA { public: virtual void something() { }; }; +%} /* Fill in method from AA. This class should be constructable */ #ifdef SWIGCSHARP %ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored. #endif + +%inline %{ class F : public E { public: virtual void method2() { } }; - %} %{ diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in index 7f11cd495..b8bd8944c 100644 --- a/Examples/test-suite/python/Makefile.in +++ b/Examples/test-suite/python/Makefile.in @@ -2,16 +2,37 @@ # Makefile for python test-suite ####################################################################### +ifeq (,$(PY3)) + PYBIN = @PYTHON@ +else + PYBIN = @PYTHON3@ +endif + LANGUAGE = python -PYTHON = @PYTHON@ -SCRIPTSUFFIX = _runme.py +PYTHON = $(PYBIN) + +#*_runme.py for Python 2.x, *_runme3.py for Python 3.x +PY2SCRIPTSUFFIX = _runme.py +PY3SCRIPTSUFFIX = _runme3.py + +ifeq (,$(PY3)) + SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX) +else + SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX) +endif + srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ + +PY2TO3 = 2to3 -x import + + CPP_TEST_CASES += \ argcargvtest \ - autodoc \ + python_autodoc \ + python_append \ callback \ complextest \ director_stl \ @@ -22,32 +43,39 @@ CPP_TEST_CASES += \ input \ inplaceadd \ implicittest \ - kwargs \ li_cstring \ li_cwstring \ li_factory \ li_implicit \ li_std_vectora \ + li_std_vector_extra \ li_std_map \ + li_std_multimap \ + li_std_pair_extra \ li_std_set \ li_std_stream \ + li_std_string_extra \ li_std_wstream \ li_std_wstring \ - nondynamic \ - overload_simple_cast \ primitive_types \ + python_abstractbase \ + python_kwargs \ + python_nondynamic \ + python_overload_simple_cast \ std_containers \ swigobject \ template_matrix \ - simutry \ - vector + simutry +# li_std_carray +# director_profile +# python_pybuf C_TEST_CASES += \ file_test \ li_cstring \ li_cwstring \ - nondynamic + python_nondynamic # # This test only works with modern C compilers @@ -77,17 +105,42 @@ VALGRIND_OPT += --suppressions=pythonswig.supp +$(swig_and_compile_multi_cpp) $(run_testcase) + +# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file +%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX) + cp $< $@ + $(PY2TO3) -w $@ >/dev/null 2>&1 + + # Runs the testcase. A testcase is only run if -# a file is found which has _runme.py appended after the testcase name. +# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name. + +run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) + +py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX) +py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX) + +ifeq (,$(PY3)) run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \ + $(run_python);)\ + fi; +else +run_testcase = \ + if [ -f $(py2_runme) ]; then ( \ + $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \ + $(run_python);) \ + elif [ -f $(py3_runme) ]; then ( \ + $(run_python);) \ fi; +endif # Clean: remove the generated .py file %.clean: @rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @rm -f $*.py; + @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py. + @if [ -f $(py2_runme) ]; then (rm -f $(py3_runme) $(py3_runme).bak;) fi; clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean @@ -101,14 +154,15 @@ cvsignore: @echo clientdata_prop_b.py @echo imports_a.py @echo imports_b.py - @echo mod_a.py mod_b.py + @echo mod_a.py mod_b.py @echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py @echo template_typedef_import.py +hugemod_runme = hugemod$(SCRIPTPREFIX) hugemod: - perl hugemod.pl + perl hugemod.pl $(hugemod_runme) $(MAKE) hugemod_a.cpptest $(MAKE) hugemod_b.cpptest - time $(PYTHON) hugemod_runme.py - time $(PYTHON) hugemod_runme.py + sh -c "time $(PYTHON) $(hugemod_runme)" + sh -c "time $(PYTHON) $(hugemod_runme)" diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README index b86ec5289..71db759b5 100644 --- a/Examples/test-suite/python/README +++ b/Examples/test-suite/python/README @@ -1,4 +1,8 @@ See ../README for common README file. -Any testcases which have _runme.py appended after the testcase name will be detected and run. +Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run. +If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test. + +You can run make with PY3=y to run test case with Python 3.x, eg. + $ make voidtest.cpptest PY3=y diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py index 9ded5bb5b..905bf1196 100644 --- a/Examples/test-suite/python/contract_runme.py +++ b/Examples/test-suite/python/contract_runme.py @@ -133,3 +133,11 @@ try: except: pass +#Namespace +my = contract.myClass(1) +try: + my = contract.myClass(0) + print "Failed! constructor preassertion" +except: + pass + diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py index 3108b4f47..a454774f5 100644 --- a/Examples/test-suite/python/cpp_namespace_runme.py +++ b/Examples/test-suite/python/cpp_namespace_runme.py @@ -3,20 +3,20 @@ import cpp_namespace n = cpp_namespace.fact(4) if n != 24: - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.cvar.Foo != 42: - raise "Bad variable value!" + raise RuntimeError("Bad variable value!") t = cpp_namespace.Test() if t.method() != "Test::method": - raise "Bad method return value!" + raise RuntimeError("Bad method return value!") if cpp_namespace.do_method(t) != "Test::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method2(t) != "Test::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") cpp_namespace.weird("hello", 4) @@ -28,18 +28,18 @@ t4 = cpp_namespace.Test4() t5 = cpp_namespace.Test5() if cpp_namespace.foo3(42) != 42: - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t2,40) != "Test2::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t3,40) != "Test3::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t4,40) != "Test4::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") if cpp_namespace.do_method3(t5,40) != "Test5::method": - raise "Bad return value!" + raise RuntimeError("Bad return value!") diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py new file mode 100644 index 000000000..ef8623359 --- /dev/null +++ b/Examples/test-suite/python/cpp_static_runme.py @@ -0,0 +1,7 @@ +#!/usr/bin/evn python +from cpp_static import * +StaticFunctionTest.static_func() +StaticFunctionTest.static_func_2(1) +StaticFunctionTest.static_func_3(1,2) +StaticMemberTest.static_int = 10 +assert StaticMemberTest.static_int == 10 diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py index 878905679..7e18a9a61 100644 --- a/Examples/test-suite/python/director_classic_runme.py +++ b/Examples/test-suite/python/director_classic_runme.py @@ -1,56 +1,56 @@ from director_classic import * class TargetLangPerson(Person): - def __init__(self): - Person.__init__(self) - def id(self): - identifier = "TargetLangPerson" - return identifier + def __init__(self): + Person.__init__(self) + def id(self): + identifier = "TargetLangPerson" + return identifier class TargetLangChild(Child): - def __init__(self): - Child.__init__(self) - def id(self): - identifier = "TargetLangChild" - return identifier + def __init__(self): + Child.__init__(self) + def id(self): + identifier = "TargetLangChild" + return identifier class TargetLangGrandChild(GrandChild): - def __init__(self): - GrandChild.__init__(self) - def id(self): - identifier = "TargetLangGrandChild" - return identifier + def __init__(self): + GrandChild.__init__(self) + def id(self): + identifier = "TargetLangGrandChild" + return identifier # Semis - don't override id() in target language class TargetLangSemiPerson(Person): - def __init__(self): - Person.__init__(self) + def __init__(self): + Person.__init__(self) # No id() override class TargetLangSemiChild(Child): - def __init__(self): - Child.__init__(self) + def __init__(self): + Child.__init__(self) # No id() override class TargetLangSemiGrandChild(GrandChild): - def __init__(self): - GrandChild.__init__(self) + def __init__(self): + GrandChild.__init__(self) # No id() override # Orphans - don't override id() in C++ class TargetLangOrphanPerson(OrphanPerson): - def __init__(self): - OrphanPerson.__init__(self) - def id(self): - identifier = "TargetLangOrphanPerson" - return identifier + def __init__(self): + OrphanPerson.__init__(self) + def id(self): + identifier = "TargetLangOrphanPerson" + return identifier class TargetLangOrphanChild(OrphanChild): - def __init__(self): - Child.__init__(self) - def id(self): - identifier = "TargetLangOrphanChild" - return identifier + def __init__(self): + Child.__init__(self) + def id(self): + identifier = "TargetLangOrphanChild" + return identifier def check(person, expected): @@ -61,7 +61,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) # Polymorphic call from C++ caller = Caller() @@ -70,7 +70,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected) # Polymorphic call of object created in target language and passed to C++ and back again baseclass = caller.baseClass() @@ -78,7 +78,7 @@ def check(person, expected): if (debug): print(ret) if (ret != expected): - raise ("Failed. Received: " + ret + " Expected: " + expected) + raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected) caller.resetCallback() if (debug): diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py index 7c9e69250..ef7a044f1 100644 --- a/Examples/test-suite/python/director_exception_runme.py +++ b/Examples/test-suite/python/director_exception_runme.py @@ -1,5 +1,8 @@ from director_exception import * -from exceptions import * + +class MyException(Exception): + def __init__(self, a, b): + self.msg = a + b class MyFoo(Foo): def ping(self): @@ -7,39 +10,62 @@ class MyFoo(Foo): class MyFoo2(Foo): def ping(self): - return true + return True pass # error: should return a string -ok = 0 +class MyFoo3(Foo): + def ping(self): + raise MyException("foo", "bar") +# Check that the NotImplementedError raised by MyFoo.ping() is returned by +# MyFoo.pong(). +ok = 0 a = MyFoo() b = launder(a) - try: b.pong() except NotImplementedError, e: - ok = 1 + if str(e) == "MyFoo::ping() EXCEPTION": + ok = 1 + else: + print "Unexpected error message: %s" % str(e) except: pass - if not ok: raise RuntimeError -ok = 0 +# Check that the director returns the appropriate TypeError if the return type +# is wrong. +ok = 0 a = MyFoo2() b = launder(a) - try: b.pong() -except: - ok = 1 +except TypeError, e: + if str(e) == "Swig director type mismatch in output value of type 'std::string'": + ok = 1 + else: + print "Unexpected error message: %s" % str(e) +if not ok: + raise RuntimeError +# Check that the director can return an exception which requires two arguments +# to the constructor, without mangling it. +ok = 0 +a = MyFoo3() +b = launder(a) +try: + b.pong() +except MyException, e: + if e.msg == 'foobar': + ok = 1 + else: + print "Unexpected error message: %s" % str(e) if not ok: raise RuntimeError - try: raise Exception2() except Exception2: diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py index e66817e17..15a12ab80 100644 --- a/Examples/test-suite/python/director_thread_runme.py +++ b/Examples/test-suite/python/director_thread_runme.py @@ -14,3 +14,5 @@ d.run() if d.val >= 0: print d.val raise RuntimeError + +d.stop() diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py index 64154c619..de4e2669e 100644 --- a/Examples/test-suite/python/file_test_runme.py +++ b/Examples/test-suite/python/file_test_runme.py @@ -1,7 +1,8 @@ import sys import file_test -file_test.nfile(sys.stdout) +if sys.version_info < (3,0): + file_test.nfile(sys.stdout) cstdout = file_test.GetStdOut() diff --git a/Examples/test-suite/python/hugemod.pl b/Examples/test-suite/python/hugemod.pl index 15c4ce41b..5420926e4 100644 --- a/Examples/test-suite/python/hugemod.pl +++ b/Examples/test-suite/python/hugemod.pl @@ -2,8 +2,12 @@ use strict; +my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod + +my $runme = shift @ARGV; + open HEADER, ">hugemod.h" or die "error"; -open TEST, ">hugemod_runme.py" or die "error"; +open TEST, ">$runme" or die "error"; open I1, ">hugemod_a.i" or die "error"; open I2, ">hugemod_b.i" or die "error"; @@ -21,7 +25,7 @@ print I2 "\%inline \%{\n"; my $i; -for ($i = 0; $i < 6000; $i++) { +for ($i = 0; $i < $modsize; $i++) { my $t = $i * 4; print HEADER "class type$i { public: int a; };\n"; print I2 "class dtype$i : public type$i { public: int b; };\n"; diff --git a/Examples/test-suite/python/iadd.i b/Examples/test-suite/python/iadd.i deleted file mode 100644 index 76604c027..000000000 --- a/Examples/test-suite/python/iadd.i +++ /dev/null @@ -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" diff --git a/Examples/test-suite/python/implicittest.i b/Examples/test-suite/python/implicittest.i deleted file mode 100644 index 91205aafa..000000000 --- a/Examples/test-suite/python/implicittest.i +++ /dev/null @@ -1,68 +0,0 @@ -%module(naturalvar="1") implicittest - -%implicitconv; - -%inline -{ - struct B { }; -} - -%inline -{ - struct A - { - int ii; - A(int i) { ii = 1; } - A(double d) { ii = 2; } - A(const B& b) { ii = 3; } - explicit A(char *s) { ii = 4; } - - int get() const { return ii; } - - }; - - int get(const A& a) { return a.ii; } - - template <class T> - struct A_T - { - int ii; - A_T(int i) { ii = 1; } - A_T(double d) { ii = 2; } - A_T(const B& b) { ii = 3; } - explicit A_T(char *s) { ii = 4; } - - int get() const { return ii; } - - }; -} - -%inline -{ - struct Foo - { - int ii; - Foo(){ ii = 0;} - Foo(int){ ii = 1;} - Foo(double){ ii = 2;} - explicit Foo(char *s){ii = 3;} - Foo(const Foo& f){ ii = f.ii;} - - }; - - struct Bar - { - int ii; - Foo f; - Bar() {ii = -1;} - Bar(const Foo& ff){ ii = ff.ii;} - }; - - - int get_b(const Bar&b) { return b.ii; } - - Foo foo; - -} - -%template(A_int) A_T<int>; diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py index 5eeec299b..db40b9b2a 100644 --- a/Examples/test-suite/python/li_attribute_runme.py +++ b/Examples/test-suite/python/li_attribute_runme.py @@ -1,3 +1,5 @@ +# Ported to C# li_attribute_runme.cs + import li_attribute aa = li_attribute.A(1,2,3) @@ -9,7 +11,6 @@ if aa.a != 3: print aa.a raise RuntimeError - if aa.b != 2: print aa.b raise RuntimeError @@ -17,8 +18,6 @@ aa.b = 5 if aa.b != 5: raise RuntimeError - - if aa.d != aa.b: raise RuntimeError @@ -36,17 +35,40 @@ pi.value=3 if pi.value != 3: raise RuntimeError - b = li_attribute.B(aa) if b.a.c != 3: raise RuntimeError - -myFoo = li_attribute.MyFoo +# class/struct attribute with get/set methods using return/pass by reference +myFoo = li_attribute.MyFoo() myFoo.x = 8 -myClass = li_attribute.MyClass +myClass = li_attribute.MyClass() myClass.Foo = myFoo if myClass.Foo.x != 8: raise RuntimeError +# class/struct attribute with get/set methods using return/pass by value +myClassVal = li_attribute.MyClassVal() +if myClassVal.ReadWriteFoo.x != -1: + raise RuntimeError +if myClassVal.ReadOnlyFoo.x != -1: + raise RuntimeError +myClassVal.ReadWriteFoo = myFoo +if myClassVal.ReadWriteFoo.x != 8: + raise RuntimeError +if myClassVal.ReadOnlyFoo.x != 8: + raise RuntimeError + +# string attribute with get/set methods using return/pass by value +myStringyClass = li_attribute.MyStringyClass("initial string") +if myStringyClass.ReadWriteString != "initial string": + raise RuntimeError +if myStringyClass.ReadOnlyString != "initial string": + raise RuntimeError +myStringyClass.ReadWriteString = "changed string" +if myStringyClass.ReadWriteString != "changed string": + raise RuntimeError +if myStringyClass.ReadOnlyString != "changed string": + raise RuntimeError + diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py index 5f6cbd211..f967def14 100644 --- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py +++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py @@ -304,6 +304,15 @@ class li_boost_shared_ptr_runme: self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr") self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref") + # 3rd derived class + k = li_boost_shared_ptr.Klass3rdDerived("me oh my") + val = k.getValue() + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + val = li_boost_shared_ptr.test3rdupcast(k) + self.verifyValue("me oh my-3rdDerived", val) + self.verifyCount(1, k) + # //////////////////////////////// Member variables //////////////////////////////////////// # smart pointer by value m = li_boost_shared_ptr.MemberVariables() diff --git a/Examples/test-suite/python/li_std_map.i b/Examples/test-suite/python/li_std_map.i deleted file mode 100644 index a8ba4f2e2..000000000 --- a/Examples/test-suite/python/li_std_map.i +++ /dev/null @@ -1,58 +0,0 @@ -%module("templatereduce") li_std_map - -%include std_pair.i -%include std_map.i -%include std_multimap.i - -%inline %{ -struct A{ - int val; - - A(int v = 0): val(v) - { - } - -}; -%} - -namespace std -{ - %template(pairii) pair<int, int>; - %template(pairAA) pair<int, A>; - %template(pairA) pair<int, A*>; - %template(mapA) map<int, A*>; - %template(mmapA) multimap<int, A*>; - - %template(paircA1) pair<const int, A*>; - %template(paircA2) pair<const int, const A*>; - %template(pairiiA) pair<int,pair<int, A*> >; - %template(pairiiAc) pair<int,const pair<int, A*> >; - - - %template() pair<swig::PyObject_ptr, swig::PyObject_ptr>; - %template(pymap) map<swig::PyObject_ptr, swig::PyObject_ptr>; - -} - - - -%inline -{ -std::pair<int, A*> -p_identa(std::pair<int, A*> p) { - return p; -} - -std::map<int,A*> m_identa(const std::map<int,A*>& v) -{ - return v; -} - -} - - - -namespace std -{ -%template(mapii) map<int,int>; -} diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py index 461421a54..ae75bdda0 100644 --- a/Examples/test-suite/python/li_std_map_runme.py +++ b/Examples/test-suite/python/li_std_map_runme.py @@ -48,7 +48,7 @@ for k in pm: -mii = li_std_map.mapii() +mii = li_std_map.IntIntMap() mii[1] = 1 mii[1] = 2 diff --git a/Examples/test-suite/python/li_std_pair.i b/Examples/test-suite/python/li_std_pair.i deleted file mode 100644 index 886bf1a4b..000000000 --- a/Examples/test-suite/python/li_std_pair.i +++ /dev/null @@ -1,210 +0,0 @@ -%module li_std_pair - -// -// activate the automatic comparison methods generation (==,!=,...) -// - -%{ -#include <algorithm> // for std::swap -%} - - -%include std_pair.i -%include std_string.i -%include std_complex.i - -%inline -%{ - struct A - { - int val; - - A(int v = 0): val(v) - { - } - - }; - struct B - { - }; -%} - -%std_comp_methods(std::pair<std::string, int>); - -namespace std { - %template(CIntPair) pair<const int, const int>; - %template() pair<double, double>; - %template(ShortPair) pair<short, short>; - - %template(IntPair) pair<int, int>; - %extend pair<int, int> - { - %template(pair) pair<short,short>; - } - - - - %template(SIPair) pair<std::string, int>; - %template(CIPair) pair<std::complex<double>, int>; - %template(SIIPair) pair<std::pair<std::string, int>, int>; - %template(AIntPair) pair<A, int>; - - %template(CCIntPair) pair<const A, const pair<int, int> >; - - %template(ABPair) pair<A, B>; - %template(IntAPair) pair<int, A>; - - %template(pairP1) pair<int, A*>; - %template(pairP2) pair<A*, int>; - %template(pairP3) pair<A*, A*>; - %template(pairP4) pair<int, int*>; - %template(pairP5) pair<int*, int>; - %template(pairP6) pair<int*, int*>; - -} -%std_comp_methods(std::pair<std::pair<std::string, int>, int>); - -%apply std::pair<int,int> *INOUT {std::pair<int,int> *INOUT2}; - -%inline %{ - -/* Test the "out" typemap for pair<T, U> */ -std::pair<int, int> makeIntPair(int a, int b) { - return std::make_pair(a, b); -} - -/** - * There is no "out" typemap for a pointer to a pair, so - * this should return a wrapped instance of a std::pair - * instead of the native "array" type for the target language. - */ -std::pair<int, int> * makeIntPairPtr(int a, int b) { - static std::pair<int, int> p = std::make_pair(a, b); - return &p; -} - -/** - * There is no "out" typemap for a non-const reference to a pair, so - * this should return a wrapped instance of a std::pair instead of - * the native "array" type for the target language. - */ -std::pair<int, int>& makeIntPairRef(int a, int b) { - static std::pair<int, int> p = std::make_pair(a, b); - return p; -} - -/** - * There is no "out" typemap for a const reference to a pair, so - * this should return a wrapped instance of a std::pair - * instead of the native "array" type for the target language. - */ -const std::pair<int, int> & makeIntPairConstRef(int a, int b) { - static std::pair<int, int> p = std::make_pair(a, b); - return p; -} - -/* Test the "in" typemap for pair<T, U> */ -int product1(std::pair<int, int> p) { - return p.first*p.second; -} - -/* Test the "in" typemap for const pair<T, U>& */ -int product2(const std::pair<int, int>& p) { - return p.first*p.second; -} - -std::pair<int, int> - p_ident(std::pair<int, int> p, const std::pair<int, int>& q) { - return p; -} - - -std::pair<int, A*> -p_identa(const std::pair<int, A*>& p) { - return p; -} - -void -d_inout(double *INOUT) { - *INOUT += *INOUT; -} - -void -d_inout(int *INOUT) { - *INOUT += *INOUT; -} - -int -d_inout2(double *INOUT) { - *INOUT += *INOUT; - return 1; -} - -void -p_inout(std::pair<int, int> *INOUT) { - std::swap(INOUT->first, INOUT->second); -} - -int -p_inout2(std::pair<int, int> *INOUT) { - std::swap(INOUT->first, INOUT->second); - return 1; -} - -void - p_inout3(std::pair<int,int> *INOUT, std::pair<int,int> *INOUT2) { - std::swap(*INOUT, *INOUT2); -} - -void -p_inoutd(std::pair<double, double> *INOUT) { - std::swap(INOUT->first, INOUT->second); -} - -std::string - s_ident(const std::string& s) { - return s; -} - -#if 0 -std::pair<char, char> - p_ident(std::pair<char, char> p, const std::pair<char, char>& q) { - return p; -} - -/* Test the "in" typemap for const pair<T, U>* */ -std::pair<A, B> - p_ident(std::pair<A, B> p, const std::pair<A, B>& q) { - return q; -} - -/* Test the "in" typemap for const pair<T, U>* */ -std::pair<int, A> - p_ident(std::pair<int, A> p, const std::pair<int, A>& q) { - return p; -} - - -std::pair<int, int> - p_ident(std::pair<int, int> p, const std::pair<A, int>& q) { - return p; -} - -std::pair<int, int> - p_ident(std::pair<int, int> p, const std::pair<A, B>& q) { - return p; -} - - - -#endif -%} - - -namespace std -{ - %template(paircA1) pair<const int, A*>; - %template(paircA2) pair<const int, const A*>; - %template(pairiiA) pair<int,pair<int, A*> >; -} - diff --git a/Examples/test-suite/python/li_std_pair_extra_runme.py b/Examples/test-suite/python/li_std_pair_extra_runme.py new file mode 100644 index 000000000..dc6e31b76 --- /dev/null +++ b/Examples/test-suite/python/li_std_pair_extra_runme.py @@ -0,0 +1,59 @@ +import li_std_pair_extra + +p = (1,2) +p1 = li_std_pair_extra.p_inout(p) +p2 = li_std_pair_extra.p_inoutd(p1) + +d1 = li_std_pair_extra.d_inout(2) + +i,d2 = li_std_pair_extra.d_inout2(2) + +i,p = li_std_pair_extra.p_inout2(p) +p3,p4 = li_std_pair_extra.p_inout3(p1,p1) + +psi = li_std_pair_extra.SIPair("hello",1) +pci = li_std_pair_extra.CIPair(1,1) + + +#psi.first = "hi" + + +psi = li_std_pair_extra.SIPair("hi",1) +if psi != ("hi",1): + raise RuntimeError + +psii = li_std_pair_extra.SIIPair(psi,1) + +a = li_std_pair_extra.A() +b = li_std_pair_extra.B() + +pab = li_std_pair_extra.ABPair(a,b); + +pab.first = a +pab.first.val = 2 + +if pab.first.val != 2: + raise RuntimeError + + +pci = li_std_pair_extra.CIntPair(1,0) + +a = li_std_pair_extra.A(5) +p1 = li_std_pair_extra.pairP1(1,a.this) +p2 = li_std_pair_extra.pairP2(a,1) +p3 = li_std_pair_extra.pairP3(a,a) + + +if a.val != li_std_pair_extra.p_identa(p1.this)[1].val: + raise RuntimeError + +p = li_std_pair_extra.IntPair(1,10) +p.first = 1 + +p = li_std_pair_extra.paircA1(1,a) +p.first +p.second + +p = li_std_pair_extra.paircA2(1,a) +pp = li_std_pair_extra.pairiiA(1,p) + diff --git a/Examples/test-suite/python/li_std_pair_runme.py b/Examples/test-suite/python/li_std_pair_runme.py deleted file mode 100644 index b301f0d24..000000000 --- a/Examples/test-suite/python/li_std_pair_runme.py +++ /dev/null @@ -1,59 +0,0 @@ -import li_std_pair - -p = (1,2) -p1 = li_std_pair.p_inout(p) -p2 = li_std_pair.p_inoutd(p1) - -d1 = li_std_pair.d_inout(2) - -i,d2 = li_std_pair.d_inout2(2) - -i,p = li_std_pair.p_inout2(p) -p3,p4 = li_std_pair.p_inout3(p1,p1) - -psi = li_std_pair.SIPair("hello",1) -pci = li_std_pair.CIPair(1,1) - - -#psi.first = "hi" - - -psi = li_std_pair.SIPair("hi",1) -if psi != ("hi",1): - raise RuntimeError - -psii = li_std_pair.SIIPair(psi,1) - -a = li_std_pair.A() -b = li_std_pair.B() - -pab = li_std_pair.ABPair(a,b); - -pab.first = a -pab.first.val = 2 - -if pab.first.val != 2: - raise RuntimeError - - -pci = li_std_pair.CIntPair(1,0) - -a = li_std_pair.A(5) -p1 = li_std_pair.pairP1(1,a.this) -p2 = li_std_pair.pairP2(a,1) -p3 = li_std_pair.pairP3(a,a) - - -if a.val != li_std_pair.p_identa(p1.this)[1].val: - raise RuntimeError - -p = li_std_pair.IntPair(1,10) -p.first = 1 - -p = li_std_pair.paircA1(1,a) -p.first -p.second - -p = li_std_pair.paircA2(1,a) -pp = li_std_pair.pairiiA(1,p) - diff --git a/Examples/test-suite/python/li_std_set.i b/Examples/test-suite/python/li_std_set.i deleted file mode 100644 index f0fddb058..000000000 --- a/Examples/test-suite/python/li_std_set.i +++ /dev/null @@ -1,17 +0,0 @@ -%module li_std_set - -%include <std_string.i> -%include <std_set.i> -%include <std_multiset.i> -%include <std_vector.i> - -%template(set_string) std::set<std::string>; -%template(set_int) std::multiset<int>; - - -%template(v_int) std::vector<int>; - - - - -%template(pyset) std::set<swig::PyObject_ptr>; diff --git a/Examples/test-suite/python/li_std_stream.i b/Examples/test-suite/python/li_std_stream.i deleted file mode 100644 index 0a999ddbf..000000000 --- a/Examples/test-suite/python/li_std_stream.i +++ /dev/null @@ -1,59 +0,0 @@ -%module li_std_stream - -%inline %{ - struct A; -%} - -%include <std_iostream.i> -%include <std_sstream.i> - - - -%callback(1) A::bar; - -%inline %{ - - struct B { - virtual ~B() - { - } - - }; - - struct A : B - { - void __add__(int a) - { - } - - void __add__(double a) - { - } - - static int bar(int a){ - return a; - } - - static int foo(int a, int (*pf)(int a)) - { - return pf(a); - } - - - std::ostream& __rlshift__(std::ostream& out) - { - out << "A class"; - return out; - } - }; -%} - -%extend std::basic_ostream<char>{ - std::basic_ostream<char>& - operator<<(const A& a) - { - *self << "A class"; - return *self; - } -} - diff --git a/Examples/test-suite/python/li_std_string.i b/Examples/test-suite/python/li_std_string.i deleted file mode 100644 index 822d713c4..000000000 --- a/Examples/test-suite/python/li_std_string.i +++ /dev/null @@ -1,55 +0,0 @@ -%module li_std_string - -%naturalvar A; - - -%include <std_basic_string.i> -%include <std_string.i> - - -%inline %{ - -struct A : std::string -{ - A(const std::string& s) : std::string(s) - { - } -}; - -struct B -{ - B(const std::string& s) : cname(0), name(s), a(s) - { - } - - char *cname; - std::string name; - A a; - -}; - - -const char* test_ccvalue(const char* x) { - return x; -} - -char* test_cvalue(char* x) { - return x; -} - -std::basic_string<char> test_value_basic1(std::basic_string<char> x) { - return x; -} - -std::basic_string<char,std::char_traits<char> > test_value_basic2(std::basic_string<char,std::char_traits<char> > x) { - return x; -} - -std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic3(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) { - return x; -} - -%} - -%include ../li_std_string.i - diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py index c0dae1e25..cef5921b0 100644 --- a/Examples/test-suite/python/li_std_string_runme.py +++ b/Examples/test-suite/python/li_std_string_extra_runme.py @@ -1,24 +1,24 @@ -import li_std_string +import li_std_string_extra x="hello" -if li_std_string.test_ccvalue(x) != x: +if li_std_string_extra.test_ccvalue(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_cvalue(x) != x: +if li_std_string_extra.test_cvalue(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_value(x) != x: - print x, li_std_string.test_value(x) +if li_std_string_extra.test_value(x) != x: + print x, li_std_string_extra.test_value(x) raise RuntimeError, "bad string mapping" -if li_std_string.test_const_reference(x) != x: +if li_std_string_extra.test_const_reference(x) != x: raise RuntimeError, "bad string mapping" -s = li_std_string.string("he") +s = li_std_string_extra.string("he") #s += "ll" #s.append('o') s = s + "llo" @@ -30,21 +30,21 @@ if s != x: if s[1:4] != x[1:4]: raise RuntimeError, "bad string mapping" -if li_std_string.test_value(s) != x: +if li_std_string_extra.test_value(s) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_const_reference(s) != x: +if li_std_string_extra.test_const_reference(s) != x: raise RuntimeError, "bad string mapping" -a = li_std_string.A(s) +a = li_std_string_extra.A(s) -if li_std_string.test_value(a) != x: +if li_std_string_extra.test_value(a) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_const_reference(a) != x: +if li_std_string_extra.test_const_reference(a) != x: raise RuntimeError, "bad string mapping" -b = li_std_string.string(" world") +b = li_std_string_extra.string(" world") s = a + b if a + b != "hello world": @@ -63,40 +63,40 @@ if c.find_last_of("l") != 9: s = "hello world" -b = li_std_string.B("hi") +b = li_std_string_extra.B("hi") -b.name = li_std_string.string("hello") +b.name = li_std_string_extra.string("hello") if b.name != "hello": raise RuntimeError, "bad string mapping" -b.a = li_std_string.A("hello") +b.a = li_std_string_extra.A("hello") if b.a != "hello": raise RuntimeError, "bad string mapping" -if li_std_string.test_value_basic1(x) != x: +if li_std_string_extra.test_value_basic1(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_value_basic2(x) != x: +if li_std_string_extra.test_value_basic2(x) != x: raise RuntimeError, "bad string mapping" -if li_std_string.test_value_basic3(x) != x: +if li_std_string_extra.test_value_basic3(x) != x: raise RuntimeError, "bad string mapping" # Global variables s = "initial string" -if li_std_string.cvar.GlobalString2 != "global string 2": +if li_std_string_extra.cvar.GlobalString2 != "global string 2": raise RuntimeError, "GlobalString2 test 1" -li_std_string.cvar.GlobalString2 = s -if li_std_string.cvar.GlobalString2 != s: +li_std_string_extra.cvar.GlobalString2 = s +if li_std_string_extra.cvar.GlobalString2 != s: raise RuntimeError, "GlobalString2 test 2" -if li_std_string.cvar.ConstGlobalString != "const global string": +if li_std_string_extra.cvar.ConstGlobalString != "const global string": raise RuntimeError, "ConstGlobalString test" # Member variables -myStructure = li_std_string.Structure() +myStructure = li_std_string_extra.Structure() if myStructure.MemberString2 != "member string 2": raise RuntimeError, "MemberString2 test 1" myStructure.MemberString2 = s @@ -105,28 +105,28 @@ if myStructure.MemberString2 != s: if myStructure.ConstMemberString != "const member string": raise RuntimeError, "ConstMemberString test" -if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2": +if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2": raise RuntimeError, "StaticMemberString2 test 1" -li_std_string.cvar.Structure_StaticMemberString2 = s -if li_std_string.cvar.Structure_StaticMemberString2 != s: +li_std_string_extra.cvar.Structure_StaticMemberString2 = s +if li_std_string_extra.cvar.Structure_StaticMemberString2 != s: raise RuntimeError, "StaticMemberString2 test 2" -if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string": +if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string": raise RuntimeError, "ConstStaticMemberString test" -if li_std_string.test_reference_input("hello") != "hello": +if li_std_string_extra.test_reference_input("hello") != "hello": raise RuntimeError -s = li_std_string.test_reference_inout("hello") +s = li_std_string_extra.test_reference_inout("hello") if s != "hellohello": raise RuntimeError -if li_std_string.stdstring_empty() != "": +if li_std_string_extra.stdstring_empty() != "": raise RuntimeError -if li_std_string.c_empty() != "": +if li_std_string_extra.c_empty() != "": raise RuntimeError -if li_std_string.c_null() != None: +if li_std_string_extra.c_null() != None: raise RuntimeError diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py index a0d96d4aa..776eacfb3 100644 --- a/Examples/test-suite/python/li_std_vector_runme.py +++ b/Examples/test-suite/python/li_std_vector_extra_runme.py @@ -1,4 +1,4 @@ -from li_std_vector import * +from li_std_vector_extra import * iv = IntVector(4) for i in range(0,4): @@ -133,3 +133,24 @@ if overloaded3(None) != "vector<int> *": if overloaded3(100) != "int": raise RuntimeError + +# vector pointer checks +ip = makeIntPtr(11) +dp = makeDoublePtr(33.3) +error = 0 +try: + vi = IntPtrVector((ip, dp)) # check vector<int *> does not accept double * element + error = 1 +except: + pass + +if error: + raise RuntimeError + +vi = IntPtrVector((ip, makeIntPtr(22))) +if extractInt(vi[0]) != 11: + raise RuntimeError + +if extractInt(vi[1]) != 22: + raise RuntimeError + diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py new file mode 100644 index 000000000..c5f72fde4 --- /dev/null +++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py @@ -0,0 +1,8 @@ +from li_std_vector_ptr import * + +ip1 = makeIntPtr(11) +ip2 = makeIntPtr(22) + +vi = IntPtrVector((ip1, ip2)) +displayVector(vi) + diff --git a/Examples/test-suite/python/li_std_wstring.i b/Examples/test-suite/python/li_std_wstring.i deleted file mode 100644 index c809e11ec..000000000 --- a/Examples/test-suite/python/li_std_wstring.i +++ /dev/null @@ -1,89 +0,0 @@ -%module li_std_wstring -%include <std_basic_string.i> -%include <std_wstring.i> - - -%inline %{ - -struct A : std::wstring -{ - A(const std::wstring& s) : std::wstring(s) - { - } -}; - -struct B -{ - B(const std::wstring& s) : cname(0), name(s), a(s) - { - } - - char *cname; - std::wstring name; - A a; - -}; - - -wchar_t test_wcvalue(wchar_t x) { - return x; -} - -const wchar_t* test_ccvalue(const wchar_t* x) { - return x; -} - -wchar_t* test_cvalue(wchar_t* x) { - return x; -} - - -std::wstring test_value(std::wstring x) { - return x; -} - -const std::wstring& test_const_reference(const std::wstring &x) { - return x; -} - -void test_pointer(std::wstring *x) { -} - -std::wstring *test_pointer_out() { - static std::wstring x = L"x"; - return &x; -} - -void test_const_pointer(const std::wstring *x) { -} - -const std::wstring *test_const_pointer_out() { - static std::wstring x = L"x"; - return &x; -} - -void test_reference(std::wstring &x) { -} - -std::wstring& test_reference_out() { - static std::wstring x = L"x"; - return x; -} - -#if defined(_MSC_VER) - #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif - -void test_throw() throw(std::wstring){ - static std::wstring x = L"x"; - - throw x; -} - -#if defined(_MSC_VER) - #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow) -#endif - -%} - - diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py new file mode 100644 index 000000000..4218b5dd4 --- /dev/null +++ b/Examples/test-suite/python/operbool_runme.py @@ -0,0 +1,4 @@ +#!/usr/bin/env python +import operbool +assert not operbool.Test() + diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py new file mode 100644 index 000000000..e34777558 --- /dev/null +++ b/Examples/test-suite/python/python_abstractbase_runme3.py @@ -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) diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py new file mode 100644 index 000000000..c8e6b2640 --- /dev/null +++ b/Examples/test-suite/python/python_append_runme.py @@ -0,0 +1,4 @@ +from python_append import * +t=Test() +t.func() +t.static_func() diff --git a/Examples/test-suite/python/kwargs_runme.py b/Examples/test-suite/python/python_kwargs_runme.py index 91812929d..fb6e191dd 100644 --- a/Examples/test-suite/python/kwargs_runme.py +++ b/Examples/test-suite/python/python_kwargs_runme.py @@ -1,4 +1,4 @@ -from kwargs import * +from python_kwargs import * class MyFoo(Foo): def __init__(self, a , b = 0): diff --git a/Examples/test-suite/python/nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py index 18230616d..27755db9c 100644 --- a/Examples/test-suite/python/nondynamic_runme.py +++ b/Examples/test-suite/python/python_nondynamic_runme.py @@ -1,6 +1,6 @@ -import nondynamic +import python_nondynamic -aa = nondynamic.A() +aa = python_nondynamic.A() aa.a = 1 aa.b = 2 @@ -14,10 +14,10 @@ if not err: raise RuntimeError, "A is not static" -class B(nondynamic.A): +class B(python_nondynamic.A): c = 4 def __init__(self): - nondynamic.A.__init__(self) + python_nondynamic.A.__init__(self) pass pass @@ -35,5 +35,5 @@ if not err: raise RuntimeError, "B is not static" -cc = nondynamic.C() +cc = python_nondynamic.C() cc.d = 3 diff --git a/Examples/test-suite/python/overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py index 87e6e5d43..1b3a5482c 100644 --- a/Examples/test-suite/python/overload_simple_cast_runme.py +++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py @@ -1,4 +1,4 @@ -from overload_simple_cast import * +from python_overload_simple_cast import * class Ai: def __init__(self,x): diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py new file mode 100644 index 000000000..152aecdc0 --- /dev/null +++ b/Examples/test-suite/python/python_pybuf_runme3.py @@ -0,0 +1,42 @@ +#run: +# python python_pybuf_runme3.py benchmark +#for the benchmark, other wise the test case will be run +import python_pybuf +import sys +if len(sys.argv)>=2 and sys.argv[1]=="benchmark": + #run the benchmark + import time + k=1000000 #number of times to excute the functions + + t=time.time() + a = bytearray(b'hello world') + for i in range(k): + pybuf.title1(a) + print("Time used by bytearray:",time.time()-t) + + t=time.time() + b = 'hello world' + for i in range(k): + pybuf.title2(b) + print("Time used by string:",time.time()-t) +else: + #run the test case + buf1 = bytearray(10) + buf2 = bytearray(50) + + pybuf.func1(buf1) + assert buf1 == b'a'*10 + + pybuf.func2(buf2) + assert buf2.startswith(b"Hello world!\x00") + + count = pybuf.func3(buf2) + assert count==10 #number of alpha and number in 'Hello world!' + + length = pybuf.func4(buf2) + assert length==12 + + buf3 = bytearray(b"hello") + pybuf.title1(buf3) + assert buf3==b'Hello' + diff --git a/Examples/test-suite/python/rename_strip_encoder_runme.py b/Examples/test-suite/python/rename_strip_encoder_runme.py new file mode 100644 index 000000000..64be611d6 --- /dev/null +++ b/Examples/test-suite/python/rename_strip_encoder_runme.py @@ -0,0 +1,6 @@ +from rename_strip_encoder import * + +s = SomeWidget() +a = AnotherWidget() +a.DoSomething() + diff --git a/Examples/test-suite/python/std_containers.i b/Examples/test-suite/python/std_containers.i deleted file mode 100644 index a1d39e7ab..000000000 --- a/Examples/test-suite/python/std_containers.i +++ /dev/null @@ -1,199 +0,0 @@ -%module std_containers - -%{ -#include <set> -%} -%include std_vector.i -%include std_string.i -%include std_deque.i -%include std_list.i -%include std_set.i -%include std_multiset.i -%include std_pair.i -%include std_map.i -%include std_multimap.i -%include std_complex.i - -%template() std::vector<double>; -%template() std::pair<std::string, int>; -%template() std::pair<int,double>; - -%template() std::vector< std::vector<double > > ; -%template(ccube) std::vector< std::vector< std::vector<double > > >; - -%inline -{ - typedef - std::vector<std::vector<std::vector<double > > > - ccube; - - ccube cident(const ccube& c) - { - return c; - } - - struct C - { - }; -} - - -%template(map_si) std::map<std::string, int>; -%template(pair_iC) std::pair<int, C*>; -%template(map_iC) std::map<int, C*>; -%template(mmap_si) std::multimap<std::string, int>; -%template(set_i) std::set<int>; -%template(multiset_i) std::multiset<int>; -%template(list_i) std::list<int>; -%template(deque_i) std::deque<int>; - -%template(vector_b) std::vector<bool>; -%template(vector_i) std::vector<int>; -%template(vector_c) std::vector<std::complex<double> >; -%template(vector_ui) std::vector<unsigned int>; - -%template(bmatrix) std::vector<std::vector<bool> >; -%template(imatrix) std::vector<std::vector<int> >; -%template(cmatrix) std::vector<std::vector<std::complex<double> > >; - -%apply std::vector<int> *INOUT {std::vector<int> *INOUT2}; - -%inline -{ - typedef std::vector<std::vector<int> > imatrix; - imatrix midenti(const imatrix& v) - { - return v; - } - - typedef std::vector<std::vector<bool> > bmatrix; - bmatrix midentb(const bmatrix& v) - { - return v; - } - - std::map<int,C*> mapidentc(const std::map<int,C*>& v) - { - return v; - } - - std::map<int,int> mapidenti(const std::map<int,int>& v) - { - return v; - } - - std::map<std::string,int> mapident(const std::map<std::string,int>& v) - { - return v; - } - - std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v) - { - return v; - } - - std::vector<int> vident(const std::vector<int>& v) - { - return v; - } - - std::set<int> sident(const std::set<int>& v) - { - return v; - } - - std::vector<unsigned int> videntu(const std::vector<unsigned int>& v) - { - return v; - } - - - int get_elem(const std::vector<int>& v, int index) - { - return v[index]; - } - - std::pair<int,double> pident(const std::pair<int,double>& p) - { - return p; - } - - void - v_inout(std::vector<int> *INOUT) { - *INOUT = *INOUT; - } - - void - v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) { - std::swap(*INOUT, *INOUT2); - } - -} - - -%{ - - template <class C> struct Param - { - }; -%} - - -template <class C> struct Param -{ -}; - - -%template(Param_c) Param<std::complex<double> >; -%inline -{ - int hello(Param<std::complex<double> > c) - { - return 0; - } -} - -%inline -{ - struct A - { - A(int aa = 0) : a(aa) - { - } - int a; - }; -} - -%template() std::pair<A,int>; -%template(pair_iA) std::pair<int,A>; -%template(vector_piA) std::vector<std::pair<int,A> >; - - -%inline { - std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b) - { - return std::pair<A,int>(); - } - - - std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a ) - { - return a; - } - - struct Foo - { - Foo(int i) { - } - }; - -} - - -%std_nodefconst_type(Foo); - -%template(vector_Foo) std::vector<Foo>; -%template(deque_Foo) std::deque<Foo>; -%template(list_Foo) std::list<Foo>; - - diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py index 7f629e1d5..a906108e3 100644 --- a/Examples/test-suite/python/swigobject_runme.py +++ b/Examples/test-suite/python/swigobject_runme.py @@ -12,11 +12,17 @@ if a1.this != a2.this: lthis = long(a.this) -xstr1 = "0x%x" % (lthis,) +# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p +xstr1 = "%016X" % (lthis,) +xstr1 = str.lstrip(xstr1, '0') xstr2 = pointer_str(a) +xstr2 = str.replace(xstr2, "0x", "") +xstr2 = str.replace(xstr2, "0X", "") +xstr2 = str.lstrip(xstr2, '0') +xstr2 = str.upper(xstr2) if xstr1 != xstr2: - print xstr1, xstr2 + print xstr1, xstr2 raise RuntimeError s = str(a.this) diff --git a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i b/Examples/test-suite/python/tag_no_clash_with_variable_runme.i deleted file mode 100644 index 0f8fdafed..000000000 --- a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i +++ /dev/null @@ -1,3 +0,0 @@ -import enum_tag_no_clash_with_variable - -error_action = error_action diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py index 030fe02d8..04c599329 100644 --- a/Examples/test-suite/python/template_typedef_cplx2_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx2 import * # @@ -13,7 +12,7 @@ except: raise RuntimeError s = '%s' % d -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -25,7 +24,7 @@ except: raise RuntimeError s = '%s' % e -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -42,7 +41,7 @@ except: raise RuntimeError s = '%s' % c -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -54,7 +53,7 @@ except: raise RuntimeError s = '%s' % f -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -70,7 +69,7 @@ except: raise RuntimeError s = '%s' % g -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -83,7 +82,7 @@ except: raise RuntimeError s = '%s' % h -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py index 99ffcb9aa..2cd9c8348 100644 --- a/Examples/test-suite/python/template_typedef_cplx_runme.py +++ b/Examples/test-suite/python/template_typedef_cplx_runme.py @@ -1,4 +1,3 @@ -import string from template_typedef_cplx import * # @@ -13,7 +12,7 @@ except: raise RuntimeError s = '%s' % d -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print d, "is not an ArithUnaryFunction" raise RuntimeError @@ -25,7 +24,7 @@ except: raise RuntimeError s = '%s' % e -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print e, "is not an ArithUnaryFunction" raise RuntimeError @@ -42,7 +41,7 @@ except: raise RuntimeError s = '%s' % c -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print c, "is not an ArithUnaryFunction" raise RuntimeError @@ -54,7 +53,7 @@ except: raise RuntimeError s = '%s' % f -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print f, "is not an ArithUnaryFunction" raise RuntimeError @@ -70,7 +69,7 @@ except: raise RuntimeError s = '%s' % g -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print g, "is not an ArithUnaryFunction" raise RuntimeError @@ -83,6 +82,6 @@ except: raise RuntimeError s = '%s' % h -if string.find(s, 'ArithUnaryFunction') == -1: +if str.find(s, 'ArithUnaryFunction') == -1: print h, "is not an ArithUnaryFunction" raise RuntimeError diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py new file mode 100644 index 000000000..b148f2d06 --- /dev/null +++ b/Examples/test-suite/python/typemap_out_optimal_runme.py @@ -0,0 +1,5 @@ +from typemap_out_optimal import * + +cvar.XX_debug = False +x = XX.create() + diff --git a/Examples/test-suite/python/vector.i b/Examples/test-suite/python/vector.i deleted file mode 100644 index 04c961cda..000000000 --- a/Examples/test-suite/python/vector.i +++ /dev/null @@ -1,51 +0,0 @@ -%module vector -%{ -#include <vector> -%} - -%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...) - public: - typedef size_t size_type; - typedef CTYPE value_type; - size_type size() const; - vector(); - %extend { - static std::vector<CTYPE > *Repeat(const value_type& value, int count) /*throw (std::out_of_range)*/ { -// if (count < 0) -// throw std::out_of_range("count"); - return new std::vector<CTYPE >(count, value); - } - } -%enddef - -namespace std { - // primary (unspecialized) class template for std::vector - // does not require operator== to be defined - template<class T> class vector { - SWIG_STD_VECTOR_MINIMUM(T, T) - }; -} - -%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...) -namespace std { - template<> class vector<CTYPE > { - SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE) - }; -} -%enddef - -SWIG_STD_VECTOR_SPECIALIZE(float, float) - -%inline %{ -typedef float Real; -%} - -#if 1 -//fails -namespace std { - %template(RealVector) vector<Real>; -} -#else -//works -%template(RealVector) std::vector<Real>; -#endif diff --git a/Examples/test-suite/python_abstractbase.i b/Examples/test-suite/python_abstractbase.i new file mode 100644 index 000000000..f72688237 --- /dev/null +++ b/Examples/test-suite/python_abstractbase.i @@ -0,0 +1,18 @@ +%module python_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>; +} diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i new file mode 100644 index 000000000..2dc9cb970 --- /dev/null +++ b/Examples/test-suite/python_append.i @@ -0,0 +1,32 @@ +/* +Testcase to test %pythonprepend and %pythonappend +*/ + +%module python_append + +%pythonappend Test::func %{ + pass +%} + +%pythonprepend Test::func %{ + pass +%} + +%pythonappend Test::static_func %{ +pass +%} + +%pythonprepend Test::static_func { + pass +} + +%inline %{ + +class Test { +public: + static void static_func() {}; + void func() {}; +}; + +%} + diff --git a/Examples/test-suite/python/autodoc.i b/Examples/test-suite/python_autodoc.i index c22cc02f0..c363e4384 100644 --- a/Examples/test-suite/python/autodoc.i +++ b/Examples/test-suite/python_autodoc.i @@ -1,4 +1,4 @@ -%module(docstring="hello") autodoc +%module(docstring="hello") python_autodoc %feature("autodoc"); diff --git a/Examples/test-suite/python/kwargs.i b/Examples/test-suite/python_kwargs.i index 83713d8c2..28089bbf1 100644 --- a/Examples/test-suite/python/kwargs.i +++ b/Examples/test-suite/python_kwargs.i @@ -1,4 +1,4 @@ -%module kwargs +%module python_kwargs %nocopyctor; %kwargs; diff --git a/Examples/test-suite/python/nondynamic.i b/Examples/test-suite/python_nondynamic.i index 2acc9bf8b..26c69644d 100644 --- a/Examples/test-suite/python/nondynamic.i +++ b/Examples/test-suite/python_nondynamic.i @@ -1,4 +1,4 @@ -%module nondynamic +%module python_nondynamic /* Use the %pythonnondynamic directuve to make the wrapped class a diff --git a/Examples/test-suite/python/overload_simple_cast.i b/Examples/test-suite/python_overload_simple_cast.i index d274722c0..e7f58d788 100644 --- a/Examples/test-suite/python/overload_simple_cast.i +++ b/Examples/test-suite/python_overload_simple_cast.i @@ -1,4 +1,4 @@ // Simple tests of overloaded functions -%module("castmode") overload_simple_cast +%module("castmode") python_overload_simple_cast %include overload_simple.i diff --git a/Examples/test-suite/python_pybuf.i b/Examples/test-suite/python_pybuf.i new file mode 100644 index 000000000..8e1302582 --- /dev/null +++ b/Examples/test-suite/python_pybuf.i @@ -0,0 +1,64 @@ +%module python_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); +} +%} diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in index 70dd62ec5..98d1f9571 100644 --- a/Examples/test-suite/r/Makefile.in +++ b/Examples/test-suite/r/Makefile.in @@ -10,8 +10,8 @@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -C_TEST_CASES = copy_struct simple_array legacy -CPP_TEST_CASES = double_delete +C_TEST_CASES = r_copy_struct r_legacy +CPP_TEST_CASES = r_double_delete include $(srcdir)/../common.mk diff --git a/Examples/test-suite/r/arrays_dimensionless_runme.R b/Examples/test-suite/r/arrays_dimensionless_runme.R new file mode 100644 index 000000000..9b97de2d8 --- /dev/null +++ b/Examples/test-suite/r/arrays_dimensionless_runme.R @@ -0,0 +1,20 @@ +source("unittest.R") +dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep="")) +source("arrays_dimensionless.R") +cacheMetaData(1) + +unittest(arr_short(1:4, 3), 6) +unittest(arr_ushort(1:4, 3), 6) +unittest(arr_int(1:4, 3), 6) +unittest(arr_uint(1:4, 3), 6) +unittest(arr_long(1:4, 3), 6) +unittest(arr_ulong(1:4, 3), 6) +unittest(arr_ll(1:4, 3), 6) +unittest(arr_ull(1:4, 3), 6) +unittest(arr_float(as.numeric(1:4), 3), 6) +unittest(arr_double(as.numeric(1:4), 3), 6) + +q(save="no") + + + diff --git a/Examples/test-suite/r/double_delete_runme.R b/Examples/test-suite/r/double_delete_runme.R deleted file mode 100644 index 8ac6b4344..000000000 --- a/Examples/test-suite/r/double_delete_runme.R +++ /dev/null @@ -1,12 +0,0 @@ -# This file illustrates the proxy class C++ interface generated -# by SWIG. - -dyn.load(paste("double_delete", .Platform$dynlib.ext, sep="")) -source("double_delete.R") -cacheMetaData(1) - -# ----- Object creation ----- - -f <- Foo(2.0) -delete(f); -delete(f); diff --git a/Examples/test-suite/r/integers_runme.R b/Examples/test-suite/r/integers_runme.R new file mode 100644 index 000000000..e31099a3b --- /dev/null +++ b/Examples/test-suite/r/integers_runme.R @@ -0,0 +1,20 @@ +source("unittest.R") +dyn.load(paste("integers", .Platform$dynlib.ext, sep="")) +source("integers.R") +cacheMetaData(1) + +unittest(signed_char_identity(1), 1) +unittest(unsigned_char_identity(1), 1) +unittest(signed_short_identity(1), 1) +unittest(unsigned_short_identity(1), 1) +unittest(signed_int_identity(1), 1) +unittest(unsigned_int_identity(1), 1) +unittest(signed_long_identity(1), 1) +unittest(unsigned_long_identity(1), 1) +unittest(signed_long_long_identity(1), 1) +unittest(unsigned_long_long_identity(1), 1) + +q(save="no") + + + diff --git a/Examples/test-suite/r/copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R index 523f1d680..21bd93b64 100644 --- a/Examples/test-suite/r/copy_struct_runme.R +++ b/Examples/test-suite/r/r_copy_struct_runme.R @@ -1,6 +1,6 @@ source("unittest.R") -dyn.load(paste("copy_struct", .Platform$dynlib.ext, sep="")) -source("copy_struct.R") +dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep="")) +source("r_copy_struct.R") cacheMetaData(1) a <- getA() @@ -41,7 +41,7 @@ unittest(d$u, 0) la <- new("A"); -la@ui <- 5 +la@ui <- as.integer(5) # Removing the next line makes this fail in R 2.4 la@str <- "" @@ -49,9 +49,10 @@ other = A() foo <- copyToC(la, other) aa = A() -aa$i = 201 +aa$i = as.integer(201) aa$d = pi aa$str = "foo" +aa$ui = as.integer(0) copyToR(aa) diff --git a/Examples/test-suite/r/r_double_delete_runme.R b/Examples/test-suite/r/r_double_delete_runme.R new file mode 100644 index 000000000..7b6fdb77f --- /dev/null +++ b/Examples/test-suite/r/r_double_delete_runme.R @@ -0,0 +1,9 @@ +dyn.load(paste("r_double_delete", .Platform$dynlib.ext, sep="")) +source("r_double_delete.R") +cacheMetaData(1) + +# ----- Object creation ----- + +f <- Foo(2.0) +delete(f); +delete(f); diff --git a/Examples/test-suite/r/legacy_runme.R b/Examples/test-suite/r/r_legacy_runme.R index a1466e4ce..7e5ade87f 100644 --- a/Examples/test-suite/r/legacy_runme.R +++ b/Examples/test-suite/r/r_legacy_runme.R @@ -1,6 +1,6 @@ source("unittest.R") -dyn.load(paste("legacy", .Platform$dynlib.ext, sep="")) -source("legacy.R") +dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep="")) +source("r_legacy.R") cacheMetaData(1) obj <- getObject(1,3) diff --git a/Examples/test-suite/r/copy_struct.i b/Examples/test-suite/r_copy_struct.i index db6223303..fda321afb 100644 --- a/Examples/test-suite/r/copy_struct.i +++ b/Examples/test-suite/r_copy_struct.i @@ -1,4 +1,4 @@ -%module copy_struct +%module r_copy_struct %feature("opaque", "yes") B; %feature("opaque", "yes") C; diff --git a/Examples/test-suite/r/double_delete.i b/Examples/test-suite/r_double_delete.i index 4f2d1e0a2..9743d0454 100644 --- a/Examples/test-suite/r/double_delete.i +++ b/Examples/test-suite/r_double_delete.i @@ -1,5 +1,4 @@ -/* File : example.i */ -%module double_delete +%module r_double_delete %inline %{ diff --git a/Examples/test-suite/r/legacy.i b/Examples/test-suite/r_legacy.i index 4e2080262..c89263082 100644 --- a/Examples/test-suite/r/legacy.i +++ b/Examples/test-suite/r_legacy.i @@ -1,4 +1,4 @@ -%module legacy +%module r_legacy %inline %{ typedef char *String; diff --git a/Examples/test-suite/rename_strip_encoder.i b/Examples/test-suite/rename_strip_encoder.i new file mode 100644 index 000000000..691173b02 --- /dev/null +++ b/Examples/test-suite/rename_strip_encoder.i @@ -0,0 +1,16 @@ +%module rename_strip_encoder + +// strip the wx prefix from all identifiers +%rename("%(strip:[wx])s") ""; + +%inline %{ + +class wxSomeWidget { +}; + +struct wxAnotherWidget { + void wxDoSomething() {} +}; + + +%} diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in index 7339373fb..d50b478be 100644 --- a/Examples/test-suite/ruby/Makefile.in +++ b/Examples/test-suite/ruby/Makefile.in @@ -10,21 +10,24 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ CPP_TEST_CASES = \ - keywords \ li_cdata \ li_cstring \ li_factory \ li_std_functors \ li_std_map \ + li_std_multimap \ li_std_pair_lang_object \ li_std_queue \ li_std_set \ li_std_stack \ - naming \ primitive_types \ - std_containers \ - track_objects \ - track_objects_directors + ruby_keywords \ + ruby_naming \ + ruby_track_objects \ + ruby_track_objects_directors \ + std_containers +# ruby_li_std_speed +# stl_new C_TEST_CASES += \ li_cdata \ @@ -39,7 +42,7 @@ SWIGOPT += -w801 -noautorename -features autodoc=4 # Rules for the different types of tests # make sure -autorename is true for the naming test -naming.cpptest: SWIGOPT = -autorename +ruby_naming.cpptest: SWIGOPT += -autorename %.cpptest: $(setup) diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb index 319fdec52..0ec8cac84 100755 --- a/Examples/test-suite/ruby/li_std_map_runme.rb +++ b/Examples/test-suite/ruby/li_std_map_runme.rb @@ -1,6 +1,6 @@ #!/usr/bin/env ruby # -# Tests for std::map and std::multimap +# Tests for std::map # # # @@ -41,18 +41,9 @@ m["foo"] = "hello" pm = Li_std_map::LanguageMap.new m.each_key { |k| pm[k] = m[k] } m.each_key { |k| swig_assert_equal("pm[#{k.inspect}]", "m[#{k.inspect}]", binding) } - -m = Li_std_map::MmapA.new -m[0] = a1 -m[0] = a2 -m[0].size == 2 -m.respond_to?(:each) == true -m.respond_to?(:each_key) == true -m.respond_to?(:each_value) == true -m.values_at(0)[0] == m[0] EOF -mii = Li_std_map::Mapii.new +mii = Li_std_map::IntIntMap.new mii[1] = 1 mii[1] = 2 diff --git a/Examples/test-suite/ruby/li_std_multimap_runme.rb b/Examples/test-suite/ruby/li_std_multimap_runme.rb new file mode 100755 index 000000000..b0c2bb359 --- /dev/null +++ b/Examples/test-suite/ruby/li_std_multimap_runme.rb @@ -0,0 +1,27 @@ +#!/usr/bin/env ruby +# +# Tests for std::multimap +# +# +# +# +# + +require 'swig_assert' +require 'li_std_multimap' + +swig_assert_each_line(<<'EOF', binding) + +a1 = Li_std_multimap::A.new(3) +a2 = Li_std_multimap::A.new(7) + +m = Li_std_multimap::MultimapA.new +m[0] = a1 +m[0] = a2 +m[0].size == 2 +m.respond_to?(:each) == true +m.respond_to?(:each_key) == true +m.respond_to?(:each_value) == true +m.values_at(0)[0] == m[0] +EOF + diff --git a/Examples/test-suite/ruby/keywords_runme.rb b/Examples/test-suite/ruby/ruby_keywords_runme.rb index cb8bd38bf..9b06ecf1d 100644 --- a/Examples/test-suite/ruby/keywords_runme.rb +++ b/Examples/test-suite/ruby/ruby_keywords_runme.rb @@ -9,9 +9,9 @@ require 'swig_assert' -require 'keywords' +require 'ruby_keywords' -kw = Keywords::Keywords.new +kw = Ruby_keywords::Keywords.new if kw.alias != 'alias' then raise RuntimeError, 'Keyword method did not work: alias' diff --git a/Examples/test-suite/ruby/li_std_speed_runme.rb b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb index a67e618a3..825f3c593 100755 --- a/Examples/test-suite/ruby/li_std_speed_runme.rb +++ b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb @@ -10,8 +10,8 @@ require 'benchmark' require 'mathn' -require 'li_std_speed' -include Li_std_speed +require 'ruby_li_std_speed' +include Ruby_li_std_speed def benchmark(f, phigh, sequences) diff --git a/Examples/test-suite/ruby/naming_runme.rb b/Examples/test-suite/ruby/ruby_naming_runme.rb index dab3a50b6..8ea5f13d3 100644 --- a/Examples/test-suite/ruby/naming_runme.rb +++ b/Examples/test-suite/ruby/ruby_naming_runme.rb @@ -9,86 +9,86 @@ require 'swig_assert' -require 'naming' +require 'ruby_naming' # Check class names -if not Naming - raise RuntimeError, 'Invalid module name for Naming' +if not Ruby_naming + raise RuntimeError, 'Invalid module name for Ruby_naming' end -if not Naming::MyClass +if not Ruby_naming::MyClass raise RuntimeError, 'Invalid class name for MyClass' end # Check constant names / values -if Naming::CONSTANT1 != 1 +if Ruby_naming::CONSTANT1 != 1 raise RuntimeError, "Incorrect value for CONSTANT1" end -if Naming::CONSTANT2 != 2 +if Ruby_naming::CONSTANT2 != 2 raise RuntimeError, "Incorrect value for CONSTANT2" end # Check constant names / values -if Naming::CONSTANT3 != 3 +if Ruby_naming::CONSTANT3 != 3 raise RuntimeError, "Incorrect value for CONSTANT3" end -if not Naming::methods.include?("constant4") +if not Ruby_naming::methods.include?("constant4") raise RuntimeError, "Incorrect mapping for constant4" end -if not Naming::methods.include?("constant5") +if not Ruby_naming::methods.include?("constant5") raise RuntimeError, "Incorrect mapping for constant5" end -if not Naming::methods.include?("constant6") +if not Ruby_naming::methods.include?("constant6") raise RuntimeError, "Incorrect mapping for constant6" end -if not Naming::TestConstants.instance_methods.include?("constant7") +if not Ruby_naming::TestConstants.instance_methods.include?("constant7") raise RuntimeError, "Incorrect mapping for constant7" end -if not Naming::TestConstants.methods.include?("constant8") +if not Ruby_naming::TestConstants.methods.include?("constant8") raise RuntimeError, "Incorrect mapping for constant8" end # There is no constant9 because it is illegal C++ -#if not Naming::TestConstants.instance_methods.include?("constant9") +#if not Ruby_naming::TestConstants.instance_methods.include?("constant9") # raise RuntimeError, "Incorrect mapping for constant9" #end -if Naming::TestConstants::CONSTANT10 != 10 +if Ruby_naming::TestConstants::CONSTANT10 != 10 raise RuntimeError, "Incorrect value for CONSTANT10" end -if not Naming::methods.include?("constant11") +if not Ruby_naming::methods.include?("constant11") raise RuntimeError, "Incorrect mapping for constant11" end # Check enums -if Naming::constants.include?("Color") +if Ruby_naming::constants.include?("Color") raise RuntimeError, "Color enum should not be exposed to Ruby" end -if Naming::Red != 0 +if Ruby_naming::Red != 0 raise RuntimeError, "Incorrect value for enum RED" end -if Naming::Green != 1 +if Ruby_naming::Green != 1 raise RuntimeError, "Incorrect value for enum GREEN" end -if Naming::Blue != 2 +if Ruby_naming::Blue != 2 raise RuntimeError, "Incorrect value for enum BLUE" end # Check method names -my_class = Naming::MyClass.new() +my_class = Ruby_naming::MyClass.new() if my_class.method_one != 1 raise RuntimeError, "Incorrect value for method_one" diff --git a/Examples/test-suite/ruby/track_objects_directors_runme.rb b/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb index 247d3e98b..fb55323a8 100644 --- a/Examples/test-suite/ruby/track_objects_directors_runme.rb +++ b/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb @@ -9,9 +9,9 @@ require 'swig_assert' -require 'track_objects_directors' +require 'ruby_track_objects_directors' -class MyFoo < Track_objects_directors::Foo +class MyFoo < Ruby_track_objects_directors::Foo def ping "MyFoo::ping()" end @@ -22,12 +22,12 @@ a = MyFoo.new raise RuntimeError if a.ping != "MyFoo::ping()" raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()" -b = Track_objects_directors::Foo.new +b = Ruby_track_objects_directors::Foo.new raise RuntimeError if b.ping != "Foo::ping()" raise RuntimeError if b.pong != "Foo::pong();Foo::ping()" -container = Track_objects_directors::Container.new +container = Ruby_track_objects_directors::Container.new foo = MyFoo.new container.set_foo(foo) diff --git a/Examples/test-suite/ruby/track_objects_runme.rb b/Examples/test-suite/ruby/ruby_track_objects_runme.rb index 27d8f6da7..7bc67a478 100644 --- a/Examples/test-suite/ruby/track_objects_runme.rb +++ b/Examples/test-suite/ruby/ruby_track_objects_runme.rb @@ -9,7 +9,7 @@ require 'swig_assert' -require 'track_objects' +require 'ruby_track_objects' def test_same_ruby_object(foo1, foo2) if not foo1.equal?(foo2) @@ -23,12 +23,12 @@ def test_same_cpp_object(foo1, foo2) end end -bar = Track_objects::Bar.new -foo1 = Track_objects::Foo.new() +bar = Ruby_track_objects::Bar.new +foo1 = Ruby_track_objects::Foo.new() bar.set_unowned_foo(foo1) # test_simple_identity -foo2 = Track_objects::Foo.new() +foo2 = Ruby_track_objects::Foo.new() foo3 = foo2 test_same_ruby_object(foo2, foo3) @@ -48,8 +48,8 @@ test_same_ruby_object(foo5, foo6) test_same_cpp_object(foo5, foo6) # test_new_foo_identity -foo7 = Track_objects::Bar.get_new_foo() -foo8 = Track_objects::Bar.get_new_foo() +foo7 = Ruby_track_objects::Bar.get_new_foo() +foo8 = Ruby_track_objects::Bar.get_new_foo() if foo7.equal?(foo8) raise "Ruby objects should be different." @@ -60,7 +60,7 @@ if foo7.cpp_equal(foo8) end # test_set_owned_identity -foo9 = Track_objects::Foo.new +foo9 = Ruby_track_objects::Foo.new bar.set_owned_foo(foo9) foo10 = bar.get_owned_foo() @@ -69,7 +69,7 @@ test_same_cpp_object(foo9, foo10) # test_set_owned_identity2 begin - foo11 = Track_objects::Foo.new + foo11 = Ruby_track_objects::Foo.new bar.set_owned_foo(foo11) foo11 = nil end @@ -90,20 +90,20 @@ test_same_ruby_object(foo13, foo14) test_same_cpp_object(foo13, foo14) # Now create the factory -factory = Track_objects::Factory.new +factory = Ruby_track_objects::Factory.new # Create itemA which is really an itemB itemA = factory.createItem # Check class -if itemA.class != Track_objects::ItemA +if itemA.class != Ruby_track_objects::ItemA raise RuntimeError, 'Item should have an ItemA class' end # Now downcast -itemB = Track_objects.downcast(itemA) +itemB = Ruby_track_objects.downcast(itemA) -if itemB.class != Track_objects::ItemB +if itemB.class != Ruby_track_objects::ItemB raise RuntimeError, 'Item should have an ItemB class' end diff --git a/Examples/test-suite/ruby/keywords.i b/Examples/test-suite/ruby_keywords.i index eb91b4ffa..c87efab33 100644 --- a/Examples/test-suite/ruby/keywords.i +++ b/Examples/test-suite/ruby_keywords.i @@ -1,4 +1,4 @@ -%module keywords +%module ruby_keywords // fix up conflicts with C++ keywords %rename("and") Keywords::and_; diff --git a/Examples/test-suite/ruby/li_std_speed.i b/Examples/test-suite/ruby_li_std_speed.i index 0dad81690..3c8e60643 100644 --- a/Examples/test-suite/ruby/li_std_speed.i +++ b/Examples/test-suite/ruby_li_std_speed.i @@ -1,5 +1,5 @@ /** - * @file li_std_speed.i + * @file ruby_li_std_speed.i * @author gga * @date Fri May 18 18:03:15 2007 * @@ -8,7 +8,7 @@ * */ -%module li_std_speed +%module ruby_li_std_speed %include <std_list.i> %include <std_vector.i> diff --git a/Examples/test-suite/ruby/naming.i b/Examples/test-suite/ruby_naming.i index 75500ae34..d8ef50ad3 100644 --- a/Examples/test-suite/ruby/naming.i +++ b/Examples/test-suite/ruby_naming.i @@ -1,4 +1,4 @@ -%module naming +%module ruby_naming %predicate predicateMethod(); %bang bangMethod(); diff --git a/Examples/test-suite/ruby/track_objects.i b/Examples/test-suite/ruby_track_objects.i index 0a50e1fad..f4bbb37e7 100644 --- a/Examples/test-suite/ruby/track_objects.i +++ b/Examples/test-suite/ruby_track_objects.i @@ -1,4 +1,4 @@ -%module track_objects +%module ruby_track_objects %include typemaps.i diff --git a/Examples/test-suite/ruby/track_objects_directors.i b/Examples/test-suite/ruby_track_objects_directors.i index adac8ae4d..131209828 100644 --- a/Examples/test-suite/ruby/track_objects_directors.i +++ b/Examples/test-suite/ruby_track_objects_directors.i @@ -1,4 +1,4 @@ -%module(directors="1") track_objects_directors +%module(directors="1") ruby_track_objects_directors %{ #include <string> diff --git a/Examples/test-suite/r/simple_array.i b/Examples/test-suite/simple_array.i index 6ddc43678..6ddc43678 100644 --- a/Examples/test-suite/r/simple_array.i +++ b/Examples/test-suite/simple_array.i diff --git a/Examples/test-suite/python/simutry.i b/Examples/test-suite/simutry.i index addea14db..addea14db 100644 --- a/Examples/test-suite/python/simutry.i +++ b/Examples/test-suite/simutry.i diff --git a/Examples/test-suite/ruby/stl_new.i b/Examples/test-suite/stl_new.i index 690a1672b..690a1672b 100644 --- a/Examples/test-suite/ruby/stl_new.i +++ b/Examples/test-suite/stl_new.i diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h index 7710f9361..feef26d0f 100644 --- a/Examples/test-suite/swig_examples_lock.h +++ b/Examples/test-suite/swig_examples_lock.h @@ -1,10 +1,10 @@ -namespace SwigExamples { - # if defined(_WIN32) || defined(__WIN32__) #include <windows.h> +namespace SwigExamples { + class CriticalSection { public: CriticalSection() { @@ -27,9 +27,18 @@ private: CriticalSection &critical_section; }; +} + #else #include <pthread.h> +#ifndef PTHREAD_MUTEX_RECURSIVE_NP + // For Cygwin and possibly other OSs: _NP is "non-portable" + #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE +#endif + +namespace SwigExamples { + class CriticalSection { public: CriticalSection() { @@ -55,7 +64,7 @@ private: CriticalSection &critical_section; }; -#endif - } +#endif + diff --git a/Examples/test-suite/python/swigobject.i b/Examples/test-suite/swigobject.i index 2e77969b9..2ec064509 100644 --- a/Examples/test-suite/python/swigobject.i +++ b/Examples/test-suite/swigobject.i @@ -10,7 +10,7 @@ const char* pointer_str(A *a){ static char result[1024]; - sprintf(result,"0x%lx", (unsigned long)(void *)a); + sprintf(result,"%p", a); return result; } diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in index e26d77582..7c4b7ed61 100644 --- a/Examples/test-suite/tcl/Makefile.in +++ b/Examples/test-suite/tcl/Makefile.in @@ -11,15 +11,12 @@ top_builddir = @top_builddir@ CPP_TEST_CASES += \ primitive_types \ - li_cdata \ li_cstring \ li_cwstring C_TEST_CASES += \ - li_cdata \ li_cstring \ - li_cwstring \ - union + li_cwstring include $(srcdir)/../common.mk diff --git a/Examples/test-suite/tcl/union_runme.tcl b/Examples/test-suite/tcl/union_parameter_runme.tcl index 2c47ecef3..fb3e092b8 100755..100644 --- a/Examples/test-suite/tcl/union_runme.tcl +++ b/Examples/test-suite/tcl/union_parameter_runme.tcl @@ -1,4 +1,4 @@ -if [ catch { load ./union[info sharedlibextension] unions} err_msg ] { +if [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] { puts stderr "Could not load shared object:\n$err_msg" } diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i index 61743f9a5..b2d29c943 100644 --- a/Examples/test-suite/template_inherit_abstract.i +++ b/Examples/test-suite/template_inherit_abstract.i @@ -57,7 +57,7 @@ namespace oss %inline %{ namespace oss { -#ifdef SWIGCSHARP +#if defined(SWIG) && defined(SWIGCSHARP) %ignore HModule<B>::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored. #endif struct test : HModule<B> diff --git a/Examples/test-suite/python/template_matrix.i b/Examples/test-suite/template_matrix.i index 27696542a..27696542a 100644 --- a/Examples/test-suite/python/template_matrix.i +++ b/Examples/test-suite/template_matrix.i diff --git a/Examples/test-suite/template_typedef_funcptr.i b/Examples/test-suite/template_typedef_funcptr.i index 0175c7516..cec43e7c8 100644 --- a/Examples/test-suite/template_typedef_funcptr.i +++ b/Examples/test-suite/template_typedef_funcptr.i @@ -2,6 +2,10 @@ //Bug #1832613 +#if !defined(SWIGR) +// R Swig fails on this test. Because it tries to return a nil SEXP in +// an error + %include <std_string.i> %inline %{ @@ -46,3 +50,4 @@ typedef MCContractPtr* ContractPtrPtr; // Plain pointers were also causing problems... %template(MCContractFactory2) ContractFactory<MCContract, std::string, ContractPtrPtr>; +#endif diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i index 5375c43b6..b3fa1a733 100644 --- a/Examples/test-suite/typemap_namespace.i +++ b/Examples/test-suite/typemap_namespace.i @@ -27,7 +27,7 @@ namespace Foo { %typemap(javaout) Str1 * = char *; #endif %typemap(in) Str1 * = char *; -#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP)) +#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML)) %typemap(freearg) Str1 * = char *; #endif %typemap(typecheck) Str1 * = char *; diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i new file mode 100644 index 000000000..8bac2fa89 --- /dev/null +++ b/Examples/test-suite/typemap_out_optimal.i @@ -0,0 +1,38 @@ +// Test the optimal attribute in the out typemap +%module typemap_out_optimal + +// Just the following languages tested +#if defined (SWIGCSHARP) +%typemap(out, optimal="1") SWIGTYPE %{ + $result = new $1_ltype((const $1_ltype &)$1); +%} +#elif defined (SWIGJAVA) +%typemap(out, optimal="1") SWIGTYPE %{ + *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1); +%} +#elif defined (SWIGUTL) +%typemap(out,noblock="1", optimal="1") SWIGTYPE { + %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags)); +} +#endif + +%ignore XX::operator=; + +%inline %{ +#include <iostream> +using namespace std; + +struct XX { + XX() { cout << "XX()" << endl; } + XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; } + XX(const XX &other) { cout << "XX(const XX &)" << endl; } + XX& operator =(const XX &other) { cout << "operator=(const XX &)" << endl; return *this; } + ~XX() { if (debug) cout << "~XX()" << endl; } + static XX create() { + return XX(123); + } + static bool debug; +}; +bool XX::debug = true; +%} + diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i index 67d412442..d5a8416db 100644 --- a/Examples/test-suite/typemap_subst.i +++ b/Examples/test-suite/typemap_subst.i @@ -50,6 +50,14 @@ (void)stardesc; (void)ampdesc; } + { /* Test descriptor macro */ + void *desc = $descriptor(const struct xyzzy **); + void *stardesc = $descriptor(const struct xyzzy *); + void *ampdesc = $descriptor(const struct xyzzy ***); + (void)desc; + (void)stardesc; + (void)ampdesc; + } $1 = ($ltype) temp; } diff --git a/Examples/test-suite/types_directive.i b/Examples/test-suite/types_directive.i index 44312263d..26cb6aeeb 100644 --- a/Examples/test-suite/types_directive.i +++ b/Examples/test-suite/types_directive.i @@ -1,5 +1,13 @@ %module types_directive +#if defined(SWIGR) +// Avoid conflict with Date class in R +#define Date DateSwig +%inline %{ +#define Date DateSwig +%} +#endif + %ignore Time2::operator Date *; %inline %{ diff --git a/Examples/test-suite/tcl/union.i b/Examples/test-suite/union_parameter.i index d8ac62bfb..bb010d3fa 100644 --- a/Examples/test-suite/tcl/union.i +++ b/Examples/test-suite/union_parameter.i @@ -1,4 +1,4 @@ -%module unions +%module union_parameter %inline %{ |