diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..596615322 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +.gitattributes export-ignore +.gitignore export-ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..eb3aa012c --- /dev/null +++ b/.gitignore @@ -0,0 +1,130 @@ +# Compiled Source +*.o +*.class + +# Editor files and various other junk +*.sw? +*.bak + +# Local PCRE +pcre +*.gz + +# C/C++ object files, based on: +# https://github.com/github/gitignore/blob/master/C.gitignore +# https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore +*.slo +*.lo + +# C/C++ dynamic libraries, based on: +# https://github.com/github/gitignore/blob/master/C.gitignore +# https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore +*.dll +*.so +*.so.* +*.dylib + +# C/C++ static libraries, based on: +# https://github.com/github/gitignore/blob/master/C.gitignore +# https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore +*.lib +*.lai +*.la +*.a + +# C/C++ executables, based on: +# https://github.com/github/gitignore/blob/master/C.gitignore +# https://github.com/github/gitignore/blob/master/C%2B%2B.gitignore +*.exe +*.out +*.app + +# Generated by autogen.sh +CCache/autom4te.cache/ +CCache/config.h.in +CCache/configure +Source/Include/swigconfig.h.in +Source/Include/swigconfig.h.in~ +Source/Makefile.in +Tools/config/compile +Tools/config/config.guess +Tools/config/config.sub +Tools/config/depcomp +Tools/config/install-sh +Tools/config/missing +Tools/config/ylwrap +aclocal.m4 +autom4te.cache/ +configure + +# Generated by ./configure +CCache/Makefile +CCache/ccache_swig_config.h +CCache/config.h +CCache/config.log +CCache/config.status +Examples/Makefile +Examples/guile/Makefile +Examples/test-suite/*/Makefile +Examples/xml/Makefile +Lib/ocaml/swigp4.ml +/Makefile +Source/Include/stamp-h1 +Source/Include/swigconfig.h +Source/Makefile +.deps +config.log +config.status +preinst-swig +swig.spec + +# Build Artifacts +.dirstamp +CCache/ccache-swig +CCache/ccache-swig.1 +Source/CParse/parser.c +Source/CParse/parser.h +Source/eswig +swig + +# Generated documentation +Doc/Manual/CCache.html +Doc/Manual/SWIGDocumentation.html +Doc/Manual/SWIGDocumentation.pdf +Doc/Manual/*.book + +# Test Suite Generated Files +Examples/test-suite/allegrocl/*/ +Examples/test-suite/cffi/*/ +Examples/test-suite/chicken/*/ +Examples/test-suite/clisp/*/ +Examples/test-suite/csharp/*/ +Examples/test-suite/d/*/ +Examples/test-suite/go/*/ +Examples/test-suite/guile/*/ +Examples/test-suite/java/*/ +Examples/test-suite/lua/*/ +Examples/test-suite/mzscheme/*/ +Examples/test-suite/ocaml/*/ +Examples/test-suite/octave/*/ +Examples/test-suite/perl5/*/ +Examples/test-suite/php/*/ +Examples/test-suite/pike/*/ +Examples/test-suite/python/*/ +Examples/test-suite/r/*/ +Examples/test-suite/ruby/*/ +Examples/test-suite/tcl/*/ +Examples/test-suite/uffi/*/ + +# Python generated files, based on: +# https://github.com/github/gitignore/blob/master/Python.gitignore +*.py[cod] +*/__pycache__/ +/__pycache__/ + +# C# generated files +*_runme.exe.mdb +*_runme.exe + +# Scratch directories +Examples/scratch diff --git a/.project b/.project deleted file mode 100644 index 86af75213..000000000 --- a/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - SWIG - - - - - - - - diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..13502de0b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,57 @@ +language: cpp +compiler: + - clang + - gcc +env: + - SWIGLANG= +matrix: + include: + - compiler: gcc + env: SWIGLANG=csharp + - compiler: gcc + env: SWIGLANG=go + - compiler: gcc + env: SWIGLANG=guile + - compiler: gcc + env: SWIGLANG=java + - compiler: gcc + env: SWIGLANG=lua + - compiler: gcc + env: SWIGLANG=octave SWIGJOBS=-j4 + - compiler: gcc + env: SWIGLANG=perl5 + - compiler: gcc + env: SWIGLANG=php + - compiler: gcc + env: SWIGLANG=python + - compiler: gcc + env: SWIGLANG=python PY3=1 + - compiler: gcc + env: SWIGLANG=ruby + - compiler: gcc + env: SWIGLANG=tcl + allow_failures: + # None +before_install: + - lsb_release -a + - uname -a + - time sudo apt-get -qq install libboost-dev + - if test "$SWIGLANG" = "csharp"; then sudo apt-get -qq install mono-devel; fi + - if test "$SWIGLANG" = "go"; then go env | sed -e 's/^/export /' > goenvsetup && source goenvsetup && rm -f goenvsetup; fi # Until configure.ac is fixed + - if test "$SWIGLANG" = "guile"; then sudo apt-get -qq install guile-2.0-dev; fi + - if test "$SWIGLANG" = "lua"; then sudo apt-get -qq install lua5.1 liblua5.1-dev; fi + - if test "$SWIGLANG" = "octave"; then sudo apt-get -qq install octave3.2 octave3.2-headers; fi + - if test "$SWIGLANG" = "php"; then sudo apt-get install php5-cli php5-dev; fi + - if test "$SWIGLANG" = "python" -a "$PY3"; then sudo apt-get install python3-dev; fi + - if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi +script: + - ./autogen.sh && ./configure + - make -s $SWIGJOBS + - if test -z "$SWIGLANG"; then make -s check-ccache; fi + - ./swig -version + - if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi + - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples; fi + - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi +branches: + only: + - master diff --git a/ANNOUNCE b/ANNOUNCE index 825837614..1c3297a5c 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,31 +1,31 @@ -*** ANNOUNCE: SWIG 2.0.6 (30 April 2012) *** +*** ANNOUNCE: SWIG 2.0.10 (in progress) *** http://www.swig.org -We're pleased to announce SWIG-2.0.6, the latest SWIG release. +We're pleased to announce SWIG-2.0.10, the latest SWIG release. What is SWIG? ============= SWIG is a software development tool that reads C/C++ header files and generates the wrapper code needed to make C and C++ code accessible -from other languages including Perl, Python, Tcl, Ruby, PHP, Java, -Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, Lua, Pike, C#, Modula-3, -Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also -export its parse tree in the form of XML and Lisp s-expressions. Major -applications of SWIG include generation of scripting language extension -modules, rapid prototyping, testing, and user interface development for -large C/C++ systems. +from other programming languages including Perl, Python, Tcl, Ruby, +PHP, C#, Go, Java, Lua, Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, +Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). +SWIG can also export its parse tree in the form of XML and Lisp +s-expressions. Major applications of SWIG include generation of +scripting language extension modules, rapid prototyping, testing, +and user interface development for large C/C++ systems. Availability ============ The release is available for download on Sourceforge at - http://prdownloads.sourceforge.net/swig/swig-2.0.6.tar.gz + http://prdownloads.sourceforge.net/swig/swig-2.0.10.tar.gz A Windows version is also available at - http://prdownloads.sourceforge.net/swig/swigwin-2.0.6.zip + http://prdownloads.sourceforge.net/swig/swigwin-2.0.10.zip Please report problems with this release to the swig-devel mailing list, details at http://www.swig.org/mail.html. diff --git a/CCache/ccache.c b/CCache/ccache.c index d1696da88..e7dd1d30a 100644 --- a/CCache/ccache.c +++ b/CCache/ccache.c @@ -712,12 +712,13 @@ static void from_cache(int first) passfail = retrieve_from_cache(hashname, output_file, hardlink); } - free(stderr_file); if (passfail == -1) { close(fd_stderr); unlink(stderr_file); + free(stderr_file); return; } + free(stderr_file); } /* get rid of the intermediate preprocessor file */ diff --git a/CCache/ccache.h b/CCache/ccache.h index 668ce8288..3c3e22311 100644 --- a/CCache/ccache.h +++ b/CCache/ccache.h @@ -159,7 +159,7 @@ int asprintf(char **ptr, const char *format, ...); int snprintf(char *,size_t ,const char *, ...); #endif -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize); +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles); void cleanup_all(const char *dir); void wipe_all(const char *dir); diff --git a/CCache/cleanup.c b/CCache/cleanup.c index 99312283e..f54ee54d9 100644 --- a/CCache/cleanup.c +++ b/CCache/cleanup.c @@ -75,21 +75,40 @@ static void traverse_fn(const char *fname, struct stat *st) /* sort the files we've found and delete the oldest ones until we are below the thresholds */ -static void sort_and_clean(void) +static void sort_and_clean(size_t minfiles) { unsigned i; + size_t adjusted_minfiles = minfiles; if (num_files > 1) { /* sort in ascending data order */ qsort(files, num_files, sizeof(struct files *), (COMPAR_FN_T)files_compare); } + /* ensure newly cached files (minfiles) are kept - instead of matching + the filenames of those newly cached, a faster and simpler approach + assumes these are the most recent in the cache and if any other + cached files have an identical time stamp, they will also be kept - + this approach would not be needed if the cleanup was done at exit. */ + if (minfiles != 0 && minfiles < num_files) { + unsigned minfiles_index = num_files - minfiles; + time_t minfiles_time = files[minfiles_index]->mtime; + for (i=1; i<=minfiles_index; i++) { + if (files[minfiles_index-i]->mtime == minfiles_time) + adjusted_minfiles++; + else + break; + } + } /* delete enough files to bring us below the threshold */ for (i=0;ifname) != 0 && errno != ENOENT) { fprintf(stderr, "unlink %s - %s\n", files[i]->fname, strerror(errno)); @@ -103,7 +122,7 @@ static void sort_and_clean(void) } /* cleanup in one cache subdir */ -void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) +void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize, size_t minfiles) { unsigned i; @@ -117,7 +136,7 @@ void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize) traverse(dir, traverse_fn); /* clean the cache */ - sort_and_clean(); + sort_and_clean(minfiles); stats_set_sizes(dir, total_files, total_size); @@ -151,7 +170,8 @@ void cleanup_all(const char *dir) cleanup_dir(dname, counters[STATS_MAXFILES], - counters[STATS_MAXSIZE]); + counters[STATS_MAXSIZE], + 0); free(dname); free(sfile); } diff --git a/CCache/configure.in b/CCache/configure.ac similarity index 100% rename from CCache/configure.in rename to CCache/configure.ac diff --git a/CCache/stats.c b/CCache/stats.c index 92bc4a835..d2122bcd3 100644 --- a/CCache/stats.c +++ b/CCache/stats.c @@ -168,7 +168,8 @@ static void stats_update_size(enum stats stat, size_t size, size_t numfiles) if (need_cleanup) { char *p = dirname(stats_file); - cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]); + cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE], + numfiles); free(p); } } diff --git a/CCache/test.sh b/CCache/test.sh index 9581c85e3..f64c3e3de 100755 --- a/CCache/test.sh +++ b/CCache/test.sh @@ -142,7 +142,7 @@ basetests() { testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1 - rmdir testd + rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" @@ -315,7 +315,7 @@ swigtests() { testname="non-regular" mkdir testd $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1 - rmdir testd + rm -rf testd checkstat 'output to a non-regular file' 1 testname="no-input" diff --git a/CHANGES b/CHANGES index 70af78333..488bf7286 100644 --- a/CHANGES +++ b/CHANGES @@ -3,6 +3,659 @@ SWIG (Simplified Wrapper and Interface Generator) See the CHANGES.current file for changes in the current version. See the RELEASENOTES file for a summary of changes in each release. +Version 2.0.10 (27 May 2013) +============================ + +2013-05-25: wsfulton + [Python] Fix Python 3 inconsistency when negative numbers are passed + where a parameter expects an unsigned C type. An OverFlow error is + now consistently thrown instead of a TypeError. + +2013-05-25: Artem Serebriyskiy + SVN Patch ticket #338 - fixes to %attribute macros for template usage + with %arg. + +2013-05-19: wsfulton + Fix ccache-swig internal error bug due to premature file cleanup. + + Fixes SF bug 1319 which shows up as a failure in the ccache tests on + Debian 64 bit Wheezy, possibly because ENABLE_ZLIB is defined. + + This is a corner case which will be hit when the maximum number of files + in the cache is set to be quite low (-F option), resulting in a cache miss. + +2013-05-09: kwwette + [Octave] Fix bugs in Octave module loading: + - fix a memory leak in setting of global variables + - install functions only once, to speed up module loads + +2013-04-28: gjanssens + [Guile] Updates in guile module: + - Add support for guile 2.0 + - Drop support for guile 1.6 + - Drop support for generating wrappers using guile's gh interface. + All generated wrappers will use the scm interface from now on. + - Deprecate -gh and -scm options. They are no longer needed. + A warning will be issued when these options are still used. + - Fix all tests and examples to have a successful travis test + +2013-04-18: wsfulton + Apply Patch #36 from Jesus Lopez to add support for $descriptor() special variable macro expansion + in fragments. For example: + + %fragment("nameDescriptor", "header") + %{ + static const char *nameDescriptor = "$descriptor(Name)"; + %} + + which will generate into the wrapper if the fragment is used: + + static const char *nameDescriptor = "SWIGTYPE_Name"; + +2013-04-18: wsfulton + Fix SF Bug #428 - Syntax error when preprocessor macros are defined inside of enum lists, such as: + + typedef enum { + eZero = 0 + #define ONE 1 + } EFoo; + + The macros are silently ignored. + +2013-04-17: wsfulton + [C#] Pull patch #34 from BrantKyser to fix smart pointers in conjuction with directors. + +2013-04-15: kwwette + [Octave] Fix bugs in output of cleanup code. + - Cleanup code is now written also after the "fail:" label, so it will be called if + a SWIG_exception is raised by the wrapping function, consistent with other modules. + - Octave module now also recognises the "$cleanup" special variable, if needed. + +2013-04-08: kwwette + Add -MP option to SWIG for generating phony targets for all dependencies. + - Prevents make from complaining if header files have been deleted before + the dependency file has been updated. + - Modelled on similar option in GCC. + +2013-04-09: olly + [PHP] Add missing directorin typemap for char* and char[] which + fixes director_string testcase failure. + +2013-04-05: wsfulton + [Ruby] SF Bug #1292 - Runtime fixes for Proc changes in ruby-1.9 when using STL + wrappers that override the default predicate, such as: + + %template(Map) std::map >; + +2013-04-05: wsfulton + [Ruby] SF Bug #1159 - Correctly check rb_respond_to call return values to fix some + further 1.9 problems with functors and use of Complex wrappers. + +2013-04-02: wsfulton + [Ruby] Runtime fixes for std::complex wrappers for ruby-1.9 - new native Ruby complex numbers are used. + +2013-03-30: wsfulton + [Ruby] Fix seg fault when using STL containers of generic Ruby types, GC_VALUE or LANGUAGE_OBJECT, + on exit of the Ruby interpreter. More frequently observed in ruby-1.9. + +2013-03-29: wsfulton + [Ruby] Fix delete_if (reject!) for the STL container wrappers which previously would + sometimes seg fault or not work. + +2013-03-25: wsfulton + [Python] Fix some undefined behaviour deleting slices in the STL containers. + +2013-03-19: wsfulton + [C#, Java, D] Fix seg fault in SWIG using directors when class and virtual method names are + the same except being in different namespaces when the %nspace feature is not being used. + +2013-02-19: kwwette + Fix bug in SWIG's handling of qualified (e.g. const) variables of array type. Given the typedef + a(7).q(volatile).double myarray // typedef volatile double[7] myarray; + the type + q(const).myarray // const myarray + becomes + a(7).q(const volatile).double // const volatile double[7] + Previously, SwigType_typedef_resolve() produces the type + q(const).a(7).q(volatile).double // non-sensical type + which would never match %typemap declarations, whose types were parsed correctly. + Add typemap_array_qualifiers.i to the test suite which checks for the correct behaviour. + +2013-02-18: wsfulton + Deprecate typedef names used as constructor and destructor names in %extend. The real + class/struct name should be used. + + typedef struct tagEStruct { + int ivar; + } EStruct; + + %extend tagEStruct { + EStruct() // illegal name, should be tagEStruct() + { + EStruct *s = new EStruct(); + s->ivar = ivar0; + return s; + } + ~EStruct() // illegal name, should be ~tagEStruct() + { + delete $self; + } + } + + For now these trigger a warning: + + extend_constructor_destructor.i:107: Warning 522: Use of an illegal constructor name 'EStruct' in + %extend is deprecated, the constructor name should be 'tagEStruct'. + extend_constructor_destructor.i:111: Warning 523: Use of an illegal destructor name 'EStruct' in + %extend is deprecated, the destructor name should be 'tagEStruct'. + + These %extend destructor and constructor names were valid up to swig-2.0.4, however swig-2.0.5 ignored + them altogether for C code as reported in SF bug #1306. The old behaviour of using them has been + restored for now, but is officially deprecated. This does not apply to anonymously defined typedef + classes/structs such as: + + typedef struct {...} X; + +2013-02-17: kwwette + When generating functions provided by %extend, use "(void)" for no-argument functions + instead of "()". This prevents warnings when compiling with "gcc -Wstrict-prototypes". + +2013-02-17: kwwette + [Octave] Minor fix to autodoc generation: get the right type for functions returning structs. + +2013-02-15: wsfulton + Deprecate typedef names used in %extend that are not the real class/struct name. For example: + + typedef struct StructBName { + int myint; + } StructB; + + %extend StructB { + void method() {} + } + + will now trigger a warning: + + swig_extend.i:19: Warning 326: Deprecated %extend name used - the struct name StructBName + should be used instead of the typedef name StructB. + + This is only partially working anyway (the %extend only worked if placed after the class + definition). + +2013-02-09: wsfulton + [CFFI] Apply patch #22 - Fix missing package before &body + +2013-01-29: wsfulton + [Java] Ensure 'javapackage' typemap is used as it stopped working from version 2.0.5. + +2013-01-28: wsfulton + [Python] Apply patch SF #334 - Fix default value conversions "TRUE"->True, "FALSE"->False. + +2013-01-28: wsfulton + [Java] Apply patch SF #335 - Truly ignore constructors in directors with %ignore. + +2013-01-18: Brant Kyser + [Java] Patch #15 - Allow the use of the nspace feature without the -package commandline option. + This works as long and the new jniclasspackage pragma is used to place the JNI intermediate class + into a package and the nspace feature is used to place all exposed types into a package. + +2013-01-15: wsfulton + Fix Visual Studio examples to work when SWIG is unzipped into a directory containing spaces. + +2013-01-15: wsfulton + [C#] Fix cstype typemap lookup for member variables so that a fully qualified variable name + matches. For example: + %typemap(cstype) bool MVar::mvar "MyBool" + struct MVar { + bool mvar; + }; + +2013-01-11: Brant Kyser + [Java, C#, D] SF Bug #1299 - Fix generated names for when %nspace is used on + classes with the same name in two different namespaces. + +2013-01-11: Vladimir Kalinin + [C#] Add support for csdirectorin 'pre', 'post' and 'terminator' attributes. + +2013-01-08: olly + [PHP] Fix to work with a ZTS build of PHP (broken in 2.0.7). + +2013-01-07: olly + Fix bashism in configure, introduced in 2.0.9. + +2013-01-06: wsfulton + Pull patch #4 from ptomulik to fix SF Bug #1296 - Fix incorrect warning for virtual destructors + in templates, such as: + Warning 521: Illegal destructor name B< A >::~B(). Ignored. + +2013-01-05: wsfulton + [Python] Pull patch #3 from ptomulik to fix SF Bug #1295 - standard exceptions as + classes using the SWIG_STD_EXCEPTIONS_AS_CLASSES macro. + +2013-01-04: wsfulton + [Java] Pull patch #2 from BrantKyser to fix SF Bug #1283 - fix smart pointers in conjuction + with directors. + +2013-01-03: wsfulton + [Java] Pull patch #1 from BrantKyser to fix SF Bug #1278 - fix directors and nspace feature when + multilevel namespaces are used. + +Version 2.0.9 (16 December 2012) +================================ + +2012-12-16: wsfulton + Fix garbage line number / empty file name reporting for some missing + '}' or ')' error messages. + +2012-12-15: kkaempf + [Ruby] Apply patch 3530444, Class#methods and Class#constants returns array of + symbols in Ruby 1.9+ + +2012-12-14: kkaempf + [Ruby] Apply patch 3530439 and finally replace all occurrences of the STR2CSTR() macro + with StringValuePtr(). STR2CSTR was deprecated since years and got removed in Ruby 1.9 + +2012-12-14: kkaempf + [Ruby] Applied patches #3530442 and 3530443 to adapt compile and runtime include + paths to match Ruby 1.9+ + +2012-12-14: wsfulton + [CFFI] Fix #3161614 - Some string constants are incorrect + +2012-12-13: wsfulton + [CFFI] Fix #3529690 - Fix incorrect constant names. + +2012-12-12: drjoe + [R] add fix to finalizer that was missed earlier + +2012-12-11: wsfulton + [Python] Apply patch #3590522 - fully qualified package paths for Python 3 even if a module is in the + same package. + +2012-12-08: wsfulton + [Python] Bug #3563647 - PyInt_FromSize_t unavailable prior to Python 2.5 for unsigned int types. + +2012-12-08: wsfulton + [Perl] Fix bug #3571361 - C++ comment in C wrappers. + +2012-12-07: wsfulton + [C#] Apply patch #3571029 which adds missing director support for const unsigned long long &. + +2012-11-28: kwwette + [Octave] Simplified module loading: now just the syntax + $ example; + is accepted, which loads functions globally but constants and variables relative to the current scope. + This make module loading behaviour reliably consistent, and reduces problems when loading modules which + depend on other modules which may not have been previously loaded. + +2012-11-27: wsfulton + [cffi] Fix junk output when wrapping single character literal constants. + +2012-11-17: wsfulton + [Tcl, Modula3] Add missing support for -outdir. + +2012-11-17: wsfulton + Fix segfaults when using filename paths greater than 1024 characters in length. + +2012-11-14: wsfulton + [ccache-swig] Apply patch #3586392 from Frederik Deweerdt to fix some error cases - incorrectly using + memory after it has been deleted. + +2012-11-09: vzeitlin + [Python] Fix overflow when passing values greater than LONG_MAX from Python 3 for parameters with unsigned long C type. + +2012-11-09: wsfulton + Fix some feature matching issues for implicit destructors and implicit constructors and implicit + copy constructors added with %copyctor. Previously a feature for these had to be fully qualified + in order to match. Now the following will also match: + + %feature("xyz") ~XXX(); + struct XXX {}; + +2012-11-09: wsfulton + Further consistency in named output typemap lookups for implicit constructors and destructors and + implicit copy constructors added with %copyctor. Previously only the fully qualified name was being + used, now the unqualified name will also be used. For example, previously: + + example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More + Looking for: void Space::More::~More + Looking for: void + + Now the unqualified name is also used: + + example.i:38: Searching for a suitable 'out' typemap for: void Space::More::~More + Looking for: void Space::More::~More + Looking for: void ~More + Looking for: void + +2012-11-02: wsfulton + Fix some subtle named output typemap lookup misses, the fully qualified name was not always being + used for variables, for example: + + struct Glob { + int MyVar; + }; + + Previously the search rules (as shown by -debug-tmsearch) for the getter wrapper were: + + example.i:44: Searching for a suitable 'out' typemap for: int MyVar + Looking for: int MyVar + Looking for: int + + Now the scope is named correctly: + + example.i:44: Searching for a suitable 'out' typemap for: int Glob::MyVar + Looking for: int Glob::MyVar + Looking for: int MyVar + Looking for: int + +2012-10-26: wsfulton + Fix director typemap searching so that a typemap specified with a name will be correctly matched. Previously + the name was ignored during the typemap search. Applies to the following list of typemaps: + directorout, csdirectorout, cstype, imtype, ctype, ddirectorout, dtype, gotype, jtype, jni, javadirectorout. + +2012-10-11: wsfulton + Most of the special variables available for use in %exception are now also available for expansion in + %extend blocks. These are: $name $symname $overname $decl $fulldecl $parentname $parentsymname, see docs + on "Class extension" in SWIGPlus.html. Patch based on submission from Kris Thielemans. + +2012-10-10: wsfulton + Additional new special variables in %exception are expanded as follows: + $parentname - The parent class name (if any) for a method. + $parentsymname - The target language parent class name (if any) for a method. + +2012-10-08: iant + [Go] Generating Go code now requires using the -intgosize option to + indicate the size of the 'int' type in Go. This is because the + size of the type is changing from Go 1.0 to Go 1.1 for x86_64. + +2012-09-14: wsfulton + Add new warning if the empty template instantiation is used as a base class, for example: + + template class Base {}; + %template() Base; + class Derived : public Base {}; + + gives the following warning instead of silently ignoring the base: + + cpp_inherit.i:52: Warning 401: Base class 'Base< int >' has no name as it is an empty template instantiated with '%template()'. Ignored. + cpp_inherit.i:51: Warning 401: The %template directive must be written before 'Base< int >' is used as a base class and be declared with a name. + + +2012-09-11: wsfulton + [Java] Fix #3535304 - Direct use of a weak global reference in directors + sometimes causing seg faults especially on Android. + +2012-09-06: wsfulton + [Java] Fix (char *STRING, size_t LENGTH) typemaps to accept NULL string. + +2012-08-26: drjoe + [R] make ExternalReference slot ref to contain reference + +2012-08-26: drjoe + [R] fix Examples/Makefile to use C in $(CC) rather than $(CXX) + +Version 2.0.8 (20 August 2012) +============================== + +2012-08-15: wsfulton + [Perl] Add size_type, value_type, const_reference to the STL containers. + +2012-08-15: wsfulton + [Python] Add discard and add methods to std::set wrappers so that pyabc.i can be used ensuring + MutableSet is a valid abstract base class for std::set. As reported by Alexey Sokolov. + Similarly for std::multiset. + +2012-08-15: wsfulton + [Python] Fix #3541744 - Missing PyInt_FromSize_t calls for Python 3. + +2012-08-13: wsfulton + [Java] Patch from David Baum to add the assumeoverride feature for Java directors to + improve performance when all overridden methods can be assumed to be overridden. + +2012-08-05: wsfulton + [Python] #3530021 Fix unused variable warning. + +2012-08-05: wsfulton + [C#] Fix #3536360 - Invalid code sometimes being generated for director methods + with many arguments. + +2012-08-05: wsfulton + [Perl] #3545877 - Don't undefine bool if defined by C99 stdbool.h - problem using + Perl 5.16 and later. + +2012-08-04: wsfulton + Remove incorrect warning (314) about target language keywords which were triggered + by using declarations and using directives. For example 'string' is a keyword in C#: + namespace std { class string; } + using std::string; + +2012-07-21: wsfulton + Fix display of pointers in various places on 64 bit systems - only 32 bits were being shown. + +2012-07-21: wsfulton + Fix gdb debugger functions 'swigprint' and 'locswigprint' to display to the gdb output window + rather than stdout. This fixes display problems in gdbtui and the ensures the output + appears where expected in other gdb based debuggers such as Eclipse CDT. + +2012-07-20: kwwette + [Octave] segfault-on-exit prevention hack now preserves exit status, and uses C99 _Exit(). + +2012-07-02: wsfulton + Fix Debian bug http://bugs.debian.org/672035, typemap copy failure - regression introduced + in swig-2.0.5: + %include + using std::pair; + %template(StrPair) pair; + +2012-07-02: wsfulton + Fix using declarations combined with using directives with forward class declarations so that + types are correctly found in scope for templates. Example: + + namespace Outer2 { + namespace Space2 { + template class Thing2; + } + } + using namespace Outer2; + using Space2::Thing2; + template class Thing2 {}; + // STILL BROKEN void useit2(Thing2 t) {} + void useit2a(Outer2::Space2::Thing2 t) {} + void useit2b(::Outer2::Space2::Thing2 t) {} + void useit2c(Space2::Thing2 t) {} + namespace Outer2 { + void useit2d(Space2::Thing2 t) {} + } + + %template(Thing2Int) Thing2; + + +2012-06-30: wsfulton + Fix template namespace problems for symbols declared with a forward class declarations, such as: + + namespace Space1 { + namespace Space2 { + template struct YYY; + } + template struct Space2::YYY { + T yyy(T h) { + return h; + } + }; + void testYYY1(Space1::Space2::YYY yy) {} + void testYYY2(Space2::YYY yy) {} + void testYYY3(::Space1::Space2::YYY yy) {} + } + + %template(YYYInt) Space1::Space2::YYY; + +2012-06-30: wsfulton + Fix namespace problems for symbols declared with a forward class declarations, such as: + + namespace Space1 { + namespace Space2 { + struct XXX; + struct YYY; + } + + struct Space2::YYY {}; + struct Space1::Space2::XXX {}; + + void testXXX2(Space2::XXX xx) {} + void testYYY2(Space2::YYY yy) {} + } + + where xx and yy were not recognised as the proxy classes XXX and YYY. + +2012-06-30: wsfulton + Fix using declarations combined with using directives with forward class declarations so that + types are correctly found in scope. + + namespace Outer2 { + namespace Space2 { + class Thing2; + } + } + using namespace Outer2; + using Space2::Thing2; + class Thing2 {}; + // None of the methods below correctly used the Thing2 proxy class + void useit2(Thing2 t) {} + void useit2a(Outer2::Space2::Thing2 t) {} + void useit2b(::Outer2::Space2::Thing2 t) {} + void useit2c(Space2::Thing2 t) {} + namespace Outer2 { + void useit2d(Space2::Thing2 t) {} + } + +2012-06-25: wsfulton + Fix using declarations combined with using directives so that types are correctly found in scope. + Example: + + namespace Outer2 { + namespace Space2 { + class Thing2 {}; + } + } + using namespace Outer2; // using directive + using Space2::Thing2; // using declaration + void useit2(Thing2 t) {} + + Similarly for templated classes. + +2012-05-29: wsfulton + Fix #3529601 - seg fault when a protected method has the "director" + feature but the parent class does not. Also fix similar problems with + the allprotected feature. + +2012-05-28: wsfulton + Fix seg fault when attempting to warn about an illegal destructor - #3530055, 3530078 and #3530118. + +Version 2.0.7 (26 May 2012) +=========================== +2012-05-26: wsfulton + std::string typemap modifications so they can be used with %apply for other string + classes. + +2012-05-25: wsfulton + [Lua] Fixes for -external-runtime to work again. + +2012-05-22: szager + [python] Disambiguate SWIG_From_unsigned_SS_int and SWIG_From_unsigned_SS_long. + +2012-05-18: olly + [PHP] Fix getters for template members. (SF#3428833, SF#3528035) + +2012-05-14: wsfulton + Fix some language's std::map wrappers to recognise difference_type, size_type, key_type + and mapped_type. + +2012-05-14: kwwette (signed off by xavier98) + [Octave] Prevent Octave from seg-faulting at exit when SWIG + modules are loaded, due to bugs in Octave's cleanup code: + * Wrapping functions now declared with Octave DEFUN_DLD macro, + and loaded through Octave's dynamic module loader + * Global variables of swigref type are now assigned a new() + copy of the swigref class, to prevent double-free errors + * SWIG module at-exit cleanup function now created in Octave + through eval(), so not dependent on loaded .oct library + * For Octave versions 3.1.* to 3.3.*, register C-level at-exit + function which terminates Octave immediately (with correct + status code) without performing memory cleanup. This function + can be controlled with macros in Lib/octave/octruntime.swg + + [Octave] New syntax for determing whether SWIG module should be + loaded globally or non-globally. To load module "example" globally, + type the module name + $ example; + as before; to load module non-globally, assign it to a variable: + $ example = example; + or + $ ex = example; + for a shorter (local) module name. -global/-noglobal command-line + options and module command line are deprecated. Added usage info + to module, so typing + $ help example + or incorrect usage should display proper usage, with examples. + + *** POTENTIAL INCOMPATIBILITY *** + +2012-05-12: olly + [PHP] Fix memory leak in code generated for a callback. Patch from + SF bug #3510806. + +2012-05-12: olly + [PHP] Avoid using zend_error_noreturn() as it doesn't work with all + builds of PHP (SF bug #3166423). Instead we now wrap it in a + SWIG_FAIL() function which we annotate as "noreturn" for GCC to + avoids warnings. This also reduces the size of the compiled + wrapper (e.g. the stripped size is reduced by 6% for Xapian's PHP + bindings). + +2012-05-11: wsfulton + [Java] SF patch #3522855 Fix unintended uninitialised memory access in OUTPUT typemaps. + +2012-05-11: wsfulton + [Java] SF patch #3522674 Fix possible uninitialised memory access in char **STRING_OUT + typemap. + +2012-05-11: wsfulton + [Java] SF patch #3522611 Fix uninitialised size regression in char **STRING_ARRAY + introduced in swig-2.0.6. + +2012-05-11: wsfulton + SF bug #3525050 - Fix regression introduced in swig-2.0.5 whereby defining one typemap + method such as an 'out' typemap may hide another typemap method such as an 'in' typemap - + only occurs when the type is a template type where the template parameters are the same + via a typedef. + +2012-05-10: olly + [PHP] Fix the constant typemaps for SWIGTYPE, etc - previously + these used the wrong name for renamed constants. Add + autodoc_runme.php to the testsuite as a regression test for this. + +2012-05-02: ianlancetaylor + [Go] Remove compatibility support for gccgo 4.6. Using + SWIG with gccgo will now require gccgo 4.7. Using SWIG + with the more commonly used gc compiler is unaffected. + +2012-05-01: wsfulton + Fix generated code for C forward enum declarations in some languages. + +Version 2.0.6 (30 April 2012) +============================= + +2012-04-25: wsfulton + [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. + +2012-04-28: wsfulton + [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems. + +2012-04-28: wsfulton + [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle + null pointers. + Version 2.0.5 (19 April 2012) ============================= @@ -349,7 +1002,7 @@ Version 2.0.5 (19 April 2012) namespace std { template struct map { class iterator; - } + }; } iterator was scoped as std::iterator, but now it is correctly std::map::iterator; @@ -361,10 +1014,10 @@ Version 2.0.5 (19 April 2012) template struct Map { typedef Key key_type; typedef T mapped_type; - } + }; } - tyepdef double DOUBLE; - %typemap(MM) Std::Map; + typedef double DOUBLE; + %template(MM) Std::Map; All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the wrapped code uses Std::Map or std::Map or Std::Map @@ -3199,7 +3852,7 @@ Version 1.3.32 (November 15, 2007) [C#] Added missing support for C++ class member pointers. 08/09/2007: wsfulton - [C#, Java] Add support for $owner in the "out" typemaps like in the the scripting + [C#, Java] Add support for $owner in the "out" typemaps like in the scripting language modules. Note that $owner has always been supported in the "javaout" / "csout" typemaps. @@ -3899,7 +4552,7 @@ Version 1.3.30 (November 13, 2006) 10/12/2006: wsfulton [Java] Remove potential race condition on the proxy class' delete() method (it is now a synchronized method, but is now customisable by changing the - methodmodifiers attribute in the the javadestruct or javadestruct_derived typemap) + methodmodifiers attribute in the javadestruct or javadestruct_derived typemap) [C#] Remove potential race condition on the proxy class' Dispose() method, similar to Java's delete() above. @@ -4707,7 +5360,7 @@ Version 1.3.28 (February 12, 2006) %naturalvar std::string; %include - that will tell swig to use the the 'natural' wrapping + that will tell swig to use the 'natural' wrapping mechanism to all std::string global and member variables. @@ -8214,7 +8867,7 @@ Version 1.3.23 (November 11, 2004) b = B() b.bar(1) - note the the methods are emitted inside the classes, + note the methods are emitted inside the classes, and hence, the %template name refers to the 'member' method name, not a global namespace name. @@ -11728,7 +12381,7 @@ Version 1.3.20 (December 17, 2003) 06/25/2003: mrose (Mark Rose) [Python] Director typemap marshalling checks for null pointers when walking the parameter list instead of relying soley on the parameter - count. Cures a segfault that occured for multiple argument inv typemaps. + count. Cures a segfault that occurred for multiple argument inv typemaps. Someone with more Swig experience should probably review this code. 06/24/2003: mkoeppe (Matthias Koeppe) @@ -16162,7 +16815,7 @@ Version 1.3.12 (June 2, 2002) %feature, %rename, %ignore, %exception, and related directives: - Namespaces are fully integrated into the the renaming and declaration + Namespaces are fully integrated into the renaming and declaration matcher. For example: %rename(display) Foo::print; // Rename in namespace Foo @@ -17203,7 +17856,7 @@ Version 1.3.10 (December 10, 2001) shadow classes. In early implementations, shadow classes were merely Python wrappers around typed pointer objects. However, some users actually wanted to receive the shadow class object in C. - To accomodate this, the dereferencing of the "this" pointer in + To accommodate this, the dereferencing of the "this" pointer in a shadow class was moved to C as described in CHANGES [8/8/99]. However, the process of returning pointers to Python was still somewhat problematic. Specifically, shadow classes never worked @@ -19117,7 +19770,7 @@ Version 1.3.6 (July 9, 2001) [Java] destructor (_delete()) was not aware of %name renaming [Java] extends baseclass did not know about %name renaming [Java] extends baseclass did extend even when the baseclass was not known to swig - [Java] sometimes enum-declarations occured before the Java class declaration + [Java] sometimes enum-declarations occurred before the Java class declaration [Java] unrelated enum initialisations no longer appear in Java class [Java] if module ends in '_' correct JNI names are now produced @@ -20270,7 +20923,7 @@ Version 1.3 Alpha 1 (February 11, 2000) names or use %apply to map typemaps to alternate names. 8/8/99 : Handling of the 'this' pointer has been changed in Python shadow - classes. Previously, dereferencing of '.this' occured in the + classes. Previously, dereferencing of '.this' occurred in the Python shadow class itself. Now, this step occurs in the C wrappers using the following function: @@ -20827,7 +21480,7 @@ Version 1.1 Patch 1 (August 27, 1997) Would generate completely bogus code with garbage replacing the '%d'. Caused by one faulty use of printf (wasn't able to find - any other occurences). + any other occurrences). 7/7/97 : Fixed bug in Python shadow class generation with non-member functions that are returning more than one value. @@ -20943,7 +21596,7 @@ Version 1.1 (June 24, 1997) .... later ... int OldName(int); - Unlike %name, %rename will rename any occurence of the old name. + Unlike %name, %rename will rename any occurrence of the old name. This applies to functions, variables, class members and so forth. There is no way to disable %rename once set, but you can change the name by redeclaring it to something else. diff --git a/CHANGES.current b/CHANGES.current index cb64a7937..98166efca 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -2,16 +2,6 @@ Below are the changes for the current release. See the CHANGES file for changes in older releases. See the RELEASENOTES file for a summary of changes in each release. -Version 2.0.6 (30 April 2012) -============================= - -2012-04-25: wsfulton - [Lua] Fix uninitialised variable in SWIGTYPE **OUTPUT typemaps as reported by Jim Anderson. - -2012-04-28: wsfulton - [Python] Fix compilation errors when wrapping STL containers on Mac OSX and possibly other systems. - -2012-04-28: wsfulton - [Java] Patch 3521811 from Leo Davis - char **STRING_ARRAY typemaps fixed to handle - null pointers. +Version 2.0.11 (in progress) +============================ diff --git a/COPYRIGHT b/COPYRIGHT index e86a994fa..d0954a3eb 100644 --- a/COPYRIGHT +++ b/COPYRIGHT @@ -66,7 +66,7 @@ Past contributors include: James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran Kovuk, Oleg Tolmatcev, Tal Shalif, Lluis Padro, Chris Seatory, Igor Bely, Robin Dunn, Edward Zimmermann, David Ascher, Dominique Dumont, Pier Giorgio Esposito, Hasan Baran Kovuk, - Klaus Wiederänders + Klaus Wiederänders, Richard Beare, Hans Oesterholt. (See CHANGES and CHANGES.current and the bug tracker for a more complete list). Past students: diff --git a/Doc/Devel/engineering.html b/Doc/Devel/engineering.html index 2e78fbe35..c12eb1328 100644 --- a/Doc/Devel/engineering.html +++ b/Doc/Devel/engineering.html @@ -25,7 +25,7 @@
  • 8. Naming Conventions
  • 9. Visibility
  • 10. Miscellaneous Coding Guidelines -
  • 11. SVN Tagging Conventions +
  • 11. Git Tagging Conventions @@ -119,8 +119,8 @@ are case-insensitive on Windows so this convention will prevent you from inadver creating two files that differ in case-only.

    -Each file should include a short abstract, license information and -a SVN revision tag like this: +Each file should include a short abstract and license information +like this:

    @@ -137,8 +137,6 @@ a SVN revision tag like this:
      * This file defines ...
      * ----------------------------------------------------------------------------- */
     
    -static char cvs[] = "$Id$";
    -
     #include "swig.h"
     
     /* Declarations */
    @@ -159,12 +157,6 @@ static int  avariable;
     
    -The SVN revision tag should be placed into a static string as shown -above mangled with the name of the file. -This adds the revision information to the SWIG executable and -makes it possible to extract version information from a raw binary -(sometimes useful in debugging). -

    As a general rule, files start to get unmanageable once they exceed about 2000 lines. Files larger than this should be broken up into @@ -379,10 +371,10 @@ making your changes. These are largely covered in the main documentation in the Extending.html file. -

    11. SVN Tagging Conventions

    +

    11. Git Tagging Conventions

    -Use svn tag to declare some set of file revisions as related in some +Use git tag to declare some set of file revisions as related in some symbolic way. This eases reference, retrieval and manipulation of these files later. At the moment (2001/01/16 14:02:53), the conventions are very simple; let's hope they stay that way! @@ -390,10 +382,10 @@ let's hope they stay that way!

    There are two types of tags, internal (aka personal) and external. Internal tags are used by SWIG developers primarily, whereas external -tags are used when communicating with people w/ anonymous svn access. +tags are used when communicating with people w/ anonymous git access.

    • Internal tags should start with the developer name and a hyphen. -
    • External tags should start with "v-". +
    • External tags should start with "rel-".
    That's all there is to it. Some example tags: @@ -402,10 +394,8 @@ That's all there is to it. Some example tags:
  • ttn-pre-xml-patch
  • ttn-post-xml-patch
  • ttn-going-on-vacation-so-dutifully-tagging-now -
  • v-1-3-a37-fixes-bug-2432 -
  • v-1-3-a37-fixes-bug-2433 -
  • v-1-3-a37-fixes-bug-2432-again -
  • v-1-3-a37-release +
  • rel-1.3.40 +
  • rel-2.0.9
    diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html index d24869d10..94a82519d 100644 --- a/Doc/Devel/internals.html +++ b/Doc/Devel/internals.html @@ -42,6 +42,7 @@
  • 7. Debugging SWIG @@ -1179,6 +1180,34 @@ Either
    + +

    7.2 Debugging DOH memory allocation problems

    +
    + +

    +The DOH objects are reference counted and use pools for memory allocation. +The implementation is in memory.c. When there are memory corruption problems, +various memory allocator tools are normally used to diagnose problems. These can be used +on SWIG and can be very useful. However, they won't necessarily find use of stale DOH objects, +that is, DOH objects +that are used after they have been deleted. This is because the DOH memory allocator +grabs a chunk of memory from the C memory allocator and manages the usage internally. +Stale DOH object usage can be checked for by defining DOH_DEBUG_MEMORY_POOLS in +memory.c. If an attempt to use an object is made after the reference count is +zero, an assertion is triggered instead of quietly re-using the stale object... +

    + +
    +
    +swig: DOH/memory.c:91: DohCheck: Assertion `!DOH_object_already_deleted' failed.
    +
    +
    + +

    +This can be memory intensive as previously used memory in the pool is not re-used so is +only recommended for diagnosing memory corruption problems. +

    +
    Copyright (C) 1999-2010 SWIG Development Team. diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html index 5d00c4cd0..12b915ee2 100644 --- a/Doc/Manual/Allegrocl.html +++ b/Doc/Manual/Allegrocl.html @@ -1118,7 +1118,7 @@ namespace BAR { function that returns an object (or pointer/reference) of C/C++ type X, the wrapping defun (or defmethod) on the Lisp side will automatically wrap the pointer returned in an instance - of the apropriate class. This makes it much easier to write and + of the appropriate class. This makes it much easier to write and debug code than if pointers were passed around as a jumble of integer values.

    @@ -1613,7 +1613,7 @@ opoverload>

    Variable length argument lists are not supported, by default. If such a function is encountered, a warning will generated to - stderr. Varargs are supported via the SWIG %vararg + stderr. Varargs are supported via the SWIG %varargs directive. This directive allows you to specify a (finite) argument list which will be inserted into the wrapper in place of the variable length argument indicator. As an example, @@ -1624,7 +1624,7 @@ opoverload>

    See the following section on Variable Length arguments - provides examples on how %vararg can be used, along + provides examples on how %varargs can be used, along with other ways such functions can be wrapped.

    diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html index 443d77691..4d1be3944 100644 --- a/Doc/Manual/Android.html +++ b/Doc/Manual/Android.html @@ -15,7 +15,9 @@
  • Examples introduction
  • Simple C example
  • C++ class example +
  • Other examples +
  • C++ STL @@ -45,7 +47,7 @@ This chapter contains a few Android specific notes and examples.

    -The examples require the the Android SDK and Android NDK which can be installed as per instructions in the links. +The examples require the Android SDK and Android NDK which can be installed as per instructions in the links. The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places). Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):

    @@ -744,6 +746,36 @@ Run the app to see the result of calling the C++ code from Java:
    Android screenshot of SwigClass example
    +

    18.2.4 Other examples

    + + +

    +The Examples/android directory contains further examples which can be run and installed in a similar manner to the previous two examples. +

    + +

    +Note that the 'extend' example is demonstrates the directors feature. +Normally C++ exception handling and the STL is not available by default in the version of g++ shipped with Android, but this example turns these features on as described in the next section. +

    + +

    18.3 C++ STL

    + + +

    +Should the C++ Standard Template Library (STL) be required, an Application.mk file needs to be created +in the same directory as the Android.mk directory containing information about the STL to use. +See the NDK documentation in the $NDKROOT/docs folder especially CPLUSPLUS-SUPPORT.html. +Below is an example of the Application.mk file to make the STLport static library available for use: +

    + +
    +
    +# File: Application.mk
    +APP_STL := gnustl_static
    +
    +
    + + diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html index b511dc126..6df2594c4 100644 --- a/Doc/Manual/CSharp.html +++ b/Doc/Manual/CSharp.html @@ -38,6 +38,7 @@
  • Memory management for objects passed to the C++ layer
  • Date marshalling using the csin typemap and associated attributes
  • A date example demonstrating marshalling of C# properties +
  • Date example demonstrating the 'pre' and 'post' typemap attributes for directors
  • Turning wrapped classes into partial classes
  • Extending proxy classes with additional C# code
  • Underlying type for enums @@ -190,6 +191,20 @@ csattributes C# attributes for attaching to proxy classes/enums
  • +
  • +

    Additional typemap attributes:

    + +

    +The "null" attribute in the "out" typemap can be specified to provide a value for $null to expand into for wrapped functions that return non-void. Normally the default value of 0 is used. +For example this is needed if you change the return type to void: +

    +
    +%typemap(ctype) Status "void"
    +%typemap(out, null="") Status { ... }
    +
    + +
  • +
  • Feature equivalent names:

    @@ -227,10 +242,12 @@ $jnicall                    -> $imcall
     

    Unlike the "javain" typemap, the "csin" typemap does not support the 'pgcpp' attribute as the C# module does not have a premature garbage collection prevention parameter. The "csin" typemap supports additional optional attributes called 'cshin' and 'terminator'. +The "csdirectorin" typemap supports additional optional attributes called 'terminator'. The 'cshin' attribute should contain the parameter type and name whenever a constructor helper function is generated due to the 'pre' or 'post' attributes. The 'terminator' attribute normally just contains a closing brace for when the 'pre' attribute contains an opening brace, such as when a C# using or fixed block is started. Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set. Please see the Date marshalling example and Date marshalling of properties example for further understanding of these "csin" applicable attributes. +Please see the Date marshalling director example for further understanding of the "csdirectorin" attributes.

  • @@ -2040,13 +2057,13 @@ The typemaps to achieve this are shown below.
    -%typemap(cstype) const CDate& "System.DateTime"
    +%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(cstype) CDate & "out System.DateTime"
     %typemap(csin, 
              pre="    CDate temp$csinput = new CDate();", 
              post="      $csinput = new System.DateTime(temp$csinput.getYear(),"
    @@ -2257,7 +2274,7 @@ Console.WriteLine("Important date: " + importantDate);
     

    -When SWIG wraps a variable that is a class/struct/union, it is wrapped using a pointer to the type for the reasons given in Stucture data members. +When SWIG wraps a variable that is a class/struct/union, it is wrapped using a pointer to the type for the reasons given in Structure data members. The typemap type required is thus CDate *. Given that the previous section already designed CDate * typemaps, we'll use those same typemaps plus the 'csvarin' and 'csvarout' typemaps.

    @@ -2329,8 +2346,69 @@ Some points to note:
  • The 'csin' typemap has 'pre', 'post' and 'cshin' attributes, and these are all ignored in the property set. The code in these attributes must instead be replicated within the 'csvarin' typemap. The line creating the temp$csinput variable is such an example; it is identical to what is in the 'pre' attribute. +

    19.8.5 Date example demonstrating the 'pre' and 'post' typemap attributes for directors

    -

    19.8.5 Turning wrapped classes into partial classes

    + +

    +The 'pre' and 'post' attributes in the "csdirectorin" typemap act like the attributes of the same name in the "csin" typemap. +For example if we modify the Date marshalling example like this: +

    + +
    +class CDate {
    +  ...
    +  void setYear(int);
    +  void setMonth(int);
    +  void setDay(int);
    +};
    +struct Action {
    +  virtual void someCallback(CDate &date);
    +  virtual ~Action();
    +  ...
    +};
    +
    + +

    +and declare %feature ("director") for the Action class, we would have to define additional +marshalling rules for CDate & parameter. The typemap may look like this: +

    + +
    +%typemap(csdirectorin,
    +         pre="System.DateTime temp$iminput = new System.DateTime();",
    +         post="CDate temp2$iminput = new CDate($iminput, false);\n"
    +              "temp2$iminput.setYear(tempdate.Year);\n"
    +              "temp2$iminput.setMonth(tempdate.Month);\n"
    +              "temp2$iminput.setDay(tempdate.Day);"
    +         ) CDate &date "out temp$iminput"
    +
    + +

    +The generated proxy class code will then contain the following wrapper for calling user-overloaded someCallback(): +

    + +
    +...
    +  private void SwigDirectorsomeCallback(IntPtr date) {
    +    System.DateTime tempdate = new System.DateTime();
    +    try {
    +      someCallback(out tempdate);
    +    } finally {
    +      // we create a managed wrapper around the existing C reference, just for convenience
    +      CDate temp2date = new CDate(date, false);
    +      temp2date.setYear(tempdate.Year);
    +      temp2date.setMonth(tempdate.Month);
    +      temp2date.setDay(tempdate.Day);
    +    }
    +  }
    +...
    +
    +

    +Pay special attention to the memory management issues, using these attributes. +

    + + +

    19.8.6 Turning wrapped classes into partial classes

    @@ -2430,7 +2508,7 @@ demonstrating that the class contains methods calling both unmanaged code - The following example is an alternative approach to adding managed code to the generated proxy class.

    -

    19.8.6 Extending proxy classes with additional C# code

    +

    19.8.7 Extending proxy classes with additional C# code

    @@ -2469,7 +2547,7 @@ public class ExtendMe : IDisposable {

  • -

    19.8.7 Underlying type for enums

    +

    19.8.8 Underlying type for enums

    diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html index 4af66298c..32fa32e96 100644 --- a/Doc/Manual/Contents.html +++ b/Doc/Manual/Contents.html @@ -16,13 +16,23 @@

    @@ -645,7 +655,9 @@
  • Examples introduction
  • Simple C example
  • C++ class example +
  • Other examples +
  • C++ STL @@ -684,6 +696,7 @@
  • Memory management for objects passed to the C++ layer
  • Date marshalling using the csin typemap and associated attributes
  • A date example demonstrating marshalling of C# properties +
  • Date example demonstrating the 'pre' and 'post' typemap attributes for directors
  • Turning wrapped classes into partial classes
  • Extending proxy classes with additional C# code
  • Underlying type for enums @@ -800,8 +813,9 @@

    -Since the SWIG_exception() function is defined at the C-level -it can be used elsewhere in SWIG. This includes typemaps and helper -functions. +The SWIG_exception() function can also be used in typemaps.

    11.2 Object ownership and %newobject

    diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html index c3b2740f4..5ea4e51f4 100644 --- a/Doc/Manual/Extending.html +++ b/Doc/Manual/Extending.html @@ -2975,7 +2975,7 @@ There are a lot of issues to address.
     virtual int functionWrapper(Node *n) {
    -  /* get useful atributes */
    +  /* get useful attributes */
       String   *name   = Getattr(n,"sym:name");
       SwigType *type   = Getattr(n,"type");
       ParmList *parms  = Getattr(n,"parms");
    @@ -3101,7 +3101,7 @@ As you can see, most usages are direct.
     
     
    -
    configure.in +
    configure.ac
    This file is processed by

    @@ -3536,7 +3536,7 @@ If you wish for a new language module to be distributed with SWIG, which we encourage for all popular languages, there are a few requirements. While we appreciate that getting all aspects of a new language working won't happen at the outset, there are a set of minimum requirements before -a module can be committed into the SVN repository for distribution with future +a module can be committed into the official Github repository for distribution with future versions of SWIG. The following are really a summary of this whole section with details being outlined earlier on.

    @@ -3551,7 +3551,7 @@ details being outlined earlier on. a runtime test, see for example Examples/python/class.
  • - Modify configure.in, Makefile.in and Examples/Makefile.in to run + Modify configure.ac, Makefile.in and Examples/Makefile.in to run these examples. Please make sure that if the new language is not installed properly on a box, make -k check should still work by skipping the tests and examples for the new language module. @@ -3578,7 +3578,7 @@ details being outlined earlier on.

    -Once accepted into SVN, development efforts should concentrate on +Once accepted into the official Git repository, development efforts should concentrate on getting the entire test-suite to work with plenty of runtime tests. Runtime tests should be for existing testcases and new test cases should be added should there be an area not already covered by diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html index 8abeada81..7a55a4364 100644 --- a/Doc/Manual/Go.html +++ b/Doc/Manual/Go.html @@ -93,25 +93,24 @@ swig -go -help Go specific options + +-intgo-type-size %lt;s%gt; +Set the size for the Go type int. This controls the size + that the C/C++ code expects to see. The %lt;s%gt; argument should + be 32 or 64. This option is currently required during the + transition from Go 1.0 to Go 1.1, as the size of int on + 64-bit x86 systems changes between those releases (from 32 bits to + 64 bits). In the future the option may become optional, and SWIG + will assume that the size of int is the size of a C + pointer. + + -gccgo Generate code for gccgo. The default is to generate code for 6g/8g/5g. - --gccgo-46 -Generate code for gccgo 4.6. The default is set by the configure - script. This generates code that does not use some facilities - that are only available in gccgo 4.7 and later. - - - --no-gccgo-46 -Turn off -gccgo-46, whether set by default or earlier - on the command line. - - -package <name> Set the name of the Go package to <name>. The default @@ -511,7 +510,7 @@ into Go types.

    Because of limitations in the way output arguments are processed in swig, a function with output arguments will not have multiple return values. Instead, you must pass a pointer into the C++ function to tell it where to -store the ouput value. In go, you supply a slice in the place of the output +store the output value. In go, you supply a slice in the place of the output argument.

    For example, suppose you were trying to wrap the modf() function in the diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html index 6f1300492..17e3a3fab 100644 --- a/Doc/Manual/Guile.html +++ b/Doc/Manual/Guile.html @@ -12,8 +12,9 @@

      +
    • Supported Guile Versions
    • Meaning of "Module" -
    • Using the SCM or GH Guile API +
    • Old GH Guile API
    • Linkage
      • Simple Linkage @@ -26,8 +27,7 @@
      • Typemaps
      • Representation of pointers as smobs
      • Exception Handling @@ -47,7 +47,21 @@

        This section details guile-specific support in SWIG. -

        23.1 Meaning of "Module"

        +

        23.1 Supported Guile Versions

        + + +

        +SWIG works with Guile versions 1.8.x and 2.0.x. Support for version +1.6.x has been dropped. The last version of SWIG that still works with +Guile version 1.6.x is SWIG 2.0.9. + +

        +Note that starting with guile 2.0, the guile sources can be compiled for +improved performance. This is currently not tested with swig +so your mileage may vary. To be safe set environment variable +GUILE_AUTO_COMPILE to 0 when using swig generated guile code. + +

        23.2 Meaning of "Module"

        @@ -55,55 +69,18 @@ There are three different concepts of "module" involved, defined separately for SWIG, Guile, and Libtool. To avoid horrible confusion, we explicitly prefix the context, e.g., "guile-module". -

        23.2 Using the SCM or GH Guile API

        +

        23.3 Old GH Guile API

        -

        The guile module can currently export wrapper files that use the guile GH interface or the -SCM interface. This is controlled by an argument passed to swig. The "-gh" argument causes swig -to output GH code, and the "-scm" argument causes swig to output SCM code. Right now the "-scm" argument -is the default. The "-scm" wrapper generation assumes a guile version >= 1.6 and has several advantages over -the "-gh" wrapper generation including garbage collection and GOOPS support. -The "-gh" wrapper generation can be used for older versions of guile. -The guile GH wrapper code generation is depreciated and the -SCM interface is the default. The SCM and GH interface differ greatly in how they store -pointers and have completely different run-time code. See below for more info. - -

        The GH interface to guile is deprecated. Read more about why in the +

        Guile 1.8 and older could be interfaced using two different api's, the SCM +or the GH API. The GH interface to guile is deprecated. Read more about why in the Guile manual. -The idea of the GH interface was to provide a high level API that other languages and projects -could adopt. This was a good idea, but didn't pan out well for general development. But for the -specific, minimal uses that the SWIG typemaps put the GH interface to use is ideal for -using a high level API. So even though the GH interface is depreciated, SWIG will continue to use -the GH interface and provide mappings from the GH interface to whatever API we need. -We can maintain this mapping where guile failed because SWIG uses a small subset of all the GH functions -which map easily. All the guile typemaps like typemaps.i and std_vector.i -will continue to use the GH functions to do things like create lists of values, convert strings to -integers, etc. Then every language module will define a mapping between the GH interface and -whatever custom API the language uses. This is currently implemented by the guile module to use -the SCM guile API rather than the GH guile API. -For example, here are some of the current mapping file for the SCM API

        -
        +

        Support for the guile GH wrapper code generation has been dropped from SWIG. The last +version of SWIG that can still generate guile GH wrapper code is 2.0.9. Please +use that version if you really need the GH wrapper code. -#define gh_append2(a, b) scm_append(scm_listify(a, b, SCM_UNDEFINED)) -#define gh_apply(a, b) scm_apply(a, b, SCM_EOL) -#define gh_bool2scm SCM_BOOL -#define gh_boolean_p SCM_BOOLP -#define gh_car SCM_CAR -#define gh_cdr SCM_CDR -#define gh_cons scm_cons -#define gh_double2scm scm_make_real -... -

        - -

        This file is parsed by SWIG at wrapper generation time, so every reference to a gh_ function is replaced -by a scm_ function in the wrapper file. Thus the gh_ function calls will never be seen in the wrapper; -the wrapper will look exactly like it was generated -for the specific API. Currently only the guile language module has created a mapping policy from gh_ to scm_, -but there is no reason other languages (like mzscheme or chicken) couldn't also use this. -If that happens, there is A LOT less code duplication in the standard typemaps.

        - -

        23.3 Linkage

        +

        23.4 Linkage

        @@ -111,7 +88,7 @@ Guile support is complicated by a lack of user community cohesiveness, which manifests in multiple shared-library usage conventions. A set of policies implementing a usage convention is called a linkage. -

        23.3.1 Simple Linkage

        +

        23.4.1 Simple Linkage

        @@ -134,7 +111,7 @@ libraries into Guile.

         (define-module (my module))
        -(define my-so (dynamic-link "./example.so"))
        +(define my-so (dynamic-link "./libexample.so"))
         (dynamic-call "SWIG_init" my-so) ; make SWIG bindings
         ;; Scheme definitions can go here
         
        @@ -147,7 +124,17 @@ and dynamic-call:
        -(load-extension "./example.so" "SWIG_init")
        +(load-extension "./libexample.so" "SWIG_init")
        +
        +
        + +

        +A more portable approach would be to drop the shared library extension: +

        + +
        +
        +(load-extension "./libexample" "SWIG_init")
         
        @@ -190,7 +177,7 @@ information by including a directive like this in the interface file:
        -%scheme %{ (load-extension "./example.so" "SWIG_init") %}
        +%scheme %{ (load-extension "./libexample.so" "SWIG_init") %}
         
        @@ -206,7 +193,7 @@ placed between the define-module form and the SWIG_init via a preprocessor define to avoid symbol clashes. For this case, however, passive linkage is available. -

        23.3.2 Passive Linkage

        +

        23.4.2 Passive Linkage

        Passive linkage is just like simple linkage, but it generates an @@ -216,12 +203,12 @@ package name (see below).

        You should use passive linkage rather than simple linkage when you are using multiple modules. -

        23.3.3 Native Guile Module Linkage

        +

        23.4.3 Native Guile Module Linkage

        SWIG can also generate wrapper code that does all the Guile module declarations on its own if you pass it the -Linkage -module command-line option. This requires Guile 1.5.0 or later. +module command-line option.

        The module name is set with the -package and -module command-line options. Suppose you want to define @@ -244,7 +231,7 @@ shared libraries into Guile; all bindings are automatically put in newly created Guile modules.

        -(define my-so (dynamic-link "./foo.so"))
        +(define my-so (dynamic-link "./libfoo"))
         ;; create new module and put bindings there:
         (dynamic-call "scm_init_my_modules_foo_module" my-so) 
         
        @@ -252,12 +239,12 @@ newly created Guile modules. Newer Guile versions have a shorthand procedure for this:
        -(load-extension "./foo.so" "scm_init_my_modules_foo_module")
        +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module")
         
      -

      23.3.4 Old Auto-Loading Guile Module Linkage

      +

      23.4.4 Old Auto-Loading Guile Module Linkage

      Guile used to support an autoloading facility for object-code @@ -283,7 +270,7 @@ option, SWIG generates an exported module initialization function with an appropriate name. -

      23.3.5 Hobbit4D Linkage

      +

      23.4.5 Hobbit4D Linkage

      @@ -308,7 +295,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very experimental; the (hobbit4d link) conventions are not well understood.

      -

      23.4 Underscore Folding

      +

      23.5 Underscore Folding

      @@ -320,7 +307,7 @@ complained so far. %rename to specify the Guile name of the wrapped functions and variables (see CHANGES). -

      23.5 Typemaps

      +

      23.6 Typemaps

      @@ -412,7 +399,7 @@ constant will appear as a scheme variable. See Features and the %feature directive for info on how to apply the %feature.

      -

      23.6 Representation of pointers as smobs

      +

      23.7 Representation of pointers as smobs

      @@ -433,7 +420,7 @@ representing the expected pointer type. See also If the Scheme object passed was not a SWIG smob representing a compatible pointer, a wrong-type-arg exception is raised. -

      23.6.1 GH Smobs

      +

      23.7.1 Smobs

      @@ -444,44 +431,19 @@ mangled type name. As Guile allows registering user types, so-called implemented now. The details will be discussed in the following.

      -

      A smob is a cons cell where the lower half of the CAR contains the smob type -tag, while the upper half of the CAR and the whole CDR are available. Every -module creates its own smob type in the clientdata field of the module. So the -lower 16 bits of the car of the smob store the tag and the upper 16 bits store -the index this type is in the array. We can then, given a smob, find its -swig_type_info struct by using the tag (lower 16 bits of car) to find which -module this type is in (since each tag is unique for the module). Then we use -the upper 16 bits to index into the array of types attached to this module. -Looking up the module from the tag is worst case O(# of modules) but average -case O(1). This is because the modules are stored in a circularly linked list, -and when we start searching the modules for the tag, we start looking with the -module that the function doing the lookup is in. SWIG_Guile_ConvertPtr() takes -as its first argument the swig_module_info * of the calling function, which is -where we start comparing tags. Most types will be looked up in the same module -that created them, so the first module we check will most likely be correct. -Once we have a swig_type_info structure, we loop through the linked list of -casts, using pointer comparisons.

      - -

      23.6.2 SCM Smobs

      - - -

      The SCM interface (using the "-scm" argument to swig) uses swigrun.swg. -The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". +

      The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig". The swig smob is used for non-garbage collected smobs, while the collected_swig smob is used as described below. Each smob has the same format, which is a double cell created by SCM_NEWSMOB2() The first word of data is the pointer to the object and the second word of data is the swig_type_info * -structure describing this type. This is a lot easier than the GH interface above because we can store -a pointer to the type info structure right in the type. With the GH interface, there was not enough -room in the smob to store two whole words of data so we needed to store part of the "swig_type_info address" -in the smob tag. If a generated GOOPS module has been loaded, smobs will be wrapped by the corresponding -GOOPS class.

      +structure describing this type. If a generated GOOPS module has been loaded, smobs will be wrapped by +the corresponding GOOPS class.

      -

      23.6.3 Garbage Collection

      +

      23.7.2 Garbage Collection

      -

      Garbage collection is a feature of the new SCM interface, and it is automatically included -if you pass the "-scm" flag to swig. Thus the swig garbage collection support requires guile >1.6. +

      Garbage collection is a feature of Guile since version 1.6. As SWIG now requires Guile > 1.8, +it is automatically included. Garbage collection works like this. Every swig_type_info structure stores in its clientdata field a pointer to the destructor for this type. The destructor is the generated wrapper around the delete function. So swig still exports a wrapper for the destructor, it just does not call scm_c_define_gsubr() for @@ -491,7 +453,7 @@ is exactly like described in 23.7 Exception Handling +

      23.8 Exception Handling

      @@ -517,14 +479,13 @@ mapping: The default when not specified here is to use "swig-error". See Lib/exception.i for details. -

      23.8 Procedure documentation

      +

      23.9 Procedure documentation

      If invoked with the command-line option -procdoc file, SWIG creates documentation strings for the generated wrapper functions, describing the procedure signature and -return value, and writes them to file. You need Guile 1.4 -or later to make use of the documentation files. +return value, and writes them to file.

      SWIG can generate documentation strings in three formats, which are selected via the command-line option -procdocformat @@ -553,7 +514,7 @@ like this: typemap argument doc. See Lib/guile/typemaps.i for details. -

      23.9 Procedures with setters

      +

      23.10 Procedures with setters

      For global variables, SWIG creates a single wrapper procedure @@ -581,7 +542,7 @@ struct members, the procedures (struct-member-get pointer) and (struct-member-set pointer value) are not generated. -

      23.10 GOOPS Proxy Classes

      +

      23.11 GOOPS Proxy Classes

      SWIG can also generate classes and generic functions for use with @@ -589,10 +550,7 @@ Guile's Object-Oriented Programming System (GOOPS). GOOPS is a sophisticated object system in the spirit of the Common Lisp Object System (CLOS). -

      GOOPS support is -only available with the new SCM interface (enabled with the --scm command-line option of SWIG). To enable GOOPS -support, pass the -proxy argument to +

      To enable GOOPS support, pass the -proxy argument to swig. This will export the GOOPS wrapper definitions into the module.scm file in the directory specified by -outdir or the current directory. GOOPS support requires either passive or module linkage.

      @@ -730,7 +688,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th %import "foo.h" before the %inline block.

      -

      23.10.1 Naming Issues

      +

      23.11.1 Naming Issues

      As you can see in the example above, there are potential naming conflicts. The default exported @@ -767,7 +725,7 @@ guile-modules. For example,

      (use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
    -

    23.10.2 Linking

    +

    23.11.2 Linking

    The guile-modules generated above all need to be linked together. GOOPS support requires @@ -787,10 +745,10 @@ and might conflict with names from the GOOPS guile-module (see above). Pass the argument to solve this problem. If the -exportprimitive option is passed to SWIG the (export ...) code that would be exported into the scmstub file is exported at the bottom of the generated GOOPS guile-module. -The %goops directive should contain code to load the .so library. +The %goops directive should contain code to load the shared library.

    -%goops %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     

    @@ -802,7 +760,7 @@ Produces the following code at the top of the generated GOOPS guile-module (define-module (my modules foo)) ;; %goops directive goes here -(load-extension "./foo.so" "scm_init_my_modules_foo_module") +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module") (use-modules (oop goops) (Swig common)) @@ -810,7 +768,7 @@ Produces the following code at the top of the generated GOOPS guile-module

  • Passive Linkage with -scmstub: Here, the name of the scmstub file should be Module-primitive.scm (with primitive replaced with whatever is given with the -primsuffix -argument. The code to load the .so library should be located in the %scheme directive, +argument. The code to load the shared library should be located in the %scheme directive, which will then be added to the scmstub file. SWIG will automatically generate the line (use-modules (Package Module-primitive)) into the GOOPS guile-module. So if Module-primitive.scm is on the autoload path for guile, the @@ -818,7 +776,7 @@ into the GOOPS guile-module. So if Module-primitive.scm is on the autolo whatever code is needed to load the Module-primitive.scm file into guile.

    -%scheme %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%scheme %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     // only include the following definition if (my modules foo) cannot
     // be loaded automatically
     %goops %{ 
    @@ -851,7 +809,7 @@ SWIG will also automatically generate the line (use-modules
     directive should contain whatever code is needed to get that module loaded into guile.

    -%goops %{ (load-extension "./foo.so" "scm_init_my_modules_foo_module") %}
    +%goops %{ (load-extension "./libfoo.so" "scm_init_my_modules_foo_module") %}
     

    @@ -862,7 +820,7 @@ Produces the following code at the top of the generated GOOPS guile-module (define-module (my modules foo)) ;; %goops directive goes here (if any) -(load-extension "./foo.so" "scm_init_my_modules_foo_module") +(load-extension "./libfoo.so" "scm_init_my_modules_foo_module") (use-modules (oop goops) (Swig common)) (use-modules ((my modules foo-primitive) :renamer (symbol-prefix-proc diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html index 76e147be5..0024d602a 100644 --- a/Doc/Manual/Java.html +++ b/Doc/Manual/Java.html @@ -86,6 +86,7 @@

  • Overhead and code bloat
  • Simple directors example
  • Director threading issues +
  • Director performance tuning
  • Accessing protected members
  • Common customization features @@ -326,12 +327,13 @@ The exact location may vary on your machine, but the above locations are typical

    The JNI code exists in a dynamic module or shared library (DLL on Windows) and gets loaded by the JVM. -To build a shared library file, you need to compile your module in a manner similar to the following (shown for Solaris):

    +Assuming you have code you need to link to in a file called example.c, in order to build a shared library file, you need to compile your module in a manner similar to the following (shown for Solaris):

     $ swig -java example.i
     $ gcc -c example_wrap.c  -I/usr/java/include -I/usr/java/include/solaris
    -$ ld -G example_wrap.o  -o libexample.so
    +$ gcc -c example.c
    +$ ld -G example_wrap.o example.o -o libexample.so
     

    @@ -1921,19 +1923,24 @@ The default behaviour described above can be improved via the

    -example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless
    -a package is specified
    -with -package - Java does not support types declared in a named package accessing types declared
    -in an unnamed package.
    +example.i:16: Warning 826: The nspace feature is used on 'MyWorld::Material::Color' without -package. The generated code 
    +may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package.
     
  • +

    +If it is undesirable to have a single top level package, the nspace feature may be used without the -package commandline option +(and the resulting warning ignored) if all of the types exposed using SWIG are placed in a package using the nspace feature and the +'jniclasspackage' pragma is used to specify a package for the JNI intermediary class. +

    +

    If the resulting use of the nspace feature and hence packages results in a proxy class in one package deriving or using a proxy class from another package, you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps. @@ -2223,6 +2230,9 @@ The intermediary JNI class can be tailored through the use of pragmas, but is no jniclassbase Base class for the intermediary JNI class + + jniclasspackage Package in which to place the intermediary JNI class + jniclassclassmodifiers Class modifiers and class type for the intermediary JNI class @@ -3354,9 +3364,6 @@ The %feature directive can be applied globally, to specific classes, and to spec // generate directors for all virtual methods in class Foo %feature("director") Foo; - -// generate a director for just Foo::bar() -%feature("director") Foo::bar; @@ -3527,6 +3534,28 @@ Macros can be defined on the commandline when compiling your C++ code, or altern +

    24.5.6 Director performance tuning

    + + +

    +When a new instance of a director (or subclass) is created in Java, the C++ side of the director performs a runtime check per director method to determine if that particular method is overridden in Java or if it should invoke the C++ base implementation directly. Although this makes initialization slightly more expensive, it is generally a good overall tradeoff. +

    + +

    +However, if all director methods are expected to usually be overridden by Java subclasses, then initialization can be made faster by avoiding these checks via the assumeoverride attribute. For example: +

    + +
    +
    +%feature("director", assumeoverride=1) Foo;
    +
    +
    + +

    +The disadvantage is that invocation of director methods from C++ when Java doesn't actually override the method will require an additional call up into Java and back to C++. As such, this option is only useful when overrides are extremely common and instantiation is frequent enough that its performance is critical. +

    + +

    24.6 Accessing protected members

    @@ -5468,6 +5497,22 @@ interfaces (implements) for Java class: empty default

    %typemap(javafinalize)

    the finalize() method (proxy classes only): default calls the delete() method + +

    +Note that the default javafinalize typemap must contain the full implementation of the finalize method. +Any customization to this typemap must still declare a java finalize method with the correct signature. +Note also that the name of the generated "delete" method may be affected by javadestruct and javadestruct_derived typemaps. +Below shows an example modifying the finalizer, assuming the delete method has been renamed to swig_delete. +

    + +
    +%typemap(javafinalize) SWIGTYPE %{
    +   protected void finalize() {
    +     swig_delete();  // renamed to prevent conflict with existing delete method
    +   }
    +]%
    +
    +

    @@ -5617,7 +5662,7 @@ to make the method and constructor public:

    The Java directors feature requires the "javadirectorin", "javadirectorout", "directorin" and the "directorout" typemaps in order to work properly. -The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes. +The "javapackage" typemap is an optional typemap used to identify the Java package path for individual SWIG generated proxy classes used in director methods.

    %typemap(directorin)

    @@ -5758,6 +5803,7 @@ The target method is the method in the Java proxy class which overrides the virt

    The "javapackage" typemap is optional; it serves to identify a class's Java package. This typemap should be used in conjunction with classes that are defined outside of the current SWIG interface file. +The typemap is only used if the type is used in a director method, that is, in a virtual method in a director class. For example:

    @@ -5774,7 +5820,7 @@ For example: class Example { public: virtual ~Example(); - void ping(Foo *arg1, Bar *arg2); + virtual void ping(Foo *arg1, Bar *arg2); }; } @@ -5799,7 +5845,7 @@ The corrected interface file looks like: class Example { public: virtual ~Example(); - void ping(Foo *arg1, Bar *arg2); + virtual void ping(Foo *arg1, Bar *arg2); }; } @@ -7864,4 +7910,3 @@ Many of these have runtime tests in the java subdirectory. - diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html index dcec21c90..1ae3c77a3 100644 --- a/Doc/Manual/Library.html +++ b/Doc/Manual/Library.html @@ -66,18 +66,19 @@ Library files are included using the %include directive. When searching for files, directories are searched in the following order:

    -
      +
      1. The current directory
      2. Directories specified with the -I command line option
      3. ./swig_lib
      4. SWIG library install location as reported by swig -swiglib, for example /usr/local/share/swig/1.3.30
      5. On Windows, a directory Lib relative to the location of swig.exe is also searched. -
    +

    -Within each directory, SWIG first looks for a subdirectory corresponding to a target language (e.g., python, -tcl, etc.). If found, SWIG will search the language specific directory first. This allows -for language-specific implementations of library files. +Within directories mentioned in points 3-5, SWIG first looks for a subdirectory +corresponding to a target language (e.g., python, tcl, etc.). +If found, SWIG will search the language specific directory first. This allows +for language-specific implementations of library files.

    @@ -1871,6 +1872,8 @@ Adding the missing %shared_ptr macros will fix this: +Note: There is currently no support for %shared_ptr and the director feature. +

    8.5 Utility Libraries

    diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html index ec32c4449..88d26f385 100644 --- a/Doc/Manual/Lua.html +++ b/Doc/Manual/Lua.html @@ -236,7 +236,7 @@ More information on building and configuring eLua can be found here:
     $ swig -lua example.i -o example_wrap.c
    @@ -1359,7 +1359,7 @@ extern void sort_double(double* arr, int len);
     to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but it's a bit tedious.
     More details can be found in the carrays.i documentation.

    -

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.

    +

    The second and more intuitive way, would be to pass a Lua table directly into the function, and have SWIG automatically convert between Lua-table and C-array. Within the <typemaps.i> file there are typemaps ready written to perform this task. To use them is again a matter of using %apply in the correct manner.

    The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays.

    diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html index ba8aa5fa9..127be904d 100644 --- a/Doc/Manual/Ocaml.html +++ b/Doc/Manual/Ocaml.html @@ -126,7 +126,7 @@ the resulting .ml and .mli files as well, and do the final link with -custom

    -The O'Caml SWIG module now requires you to compile a module (Swig) +The OCaml SWIG module now requires you to compile a module (Swig) separately. In addition to aggregating common SWIG functionality, the Swig module contains the data structure that represents C/C++ values. This allows easier data sharing between modules if two or more are combined, because diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html index 3229299d5..84c0a0f46 100644 --- a/Doc/Manual/Octave.html +++ b/Doc/Manual/Octave.html @@ -63,7 +63,7 @@ The SWIG implemention was first based on Octave 2.9.12, so this is the minimum v

    -As of SWIG 2.0.5, the Octave module should work with Octave versions 3.0.5, 3.2.4, and 3.4.0. +As of SWIG 2.0.7, the Octave module has been tested with Octave versions 3.0.5, 3.2.4, 3.4.3, and 3.6.1.

    30.2 Running SWIG

    @@ -74,7 +74,7 @@ Let's start with a very simple SWIG interface file, example.i:

    -%module example
    +%module swigexample
     %{
     #include "example.h"
     %}
    @@ -95,7 +95,7 @@ The -c++ option is also required when wrapping C++ code:
     
    $ swig -octave -c++ -o example_wrap.cpp example.i 

    -This creates a C++ source file example_wrap.cpp. A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module. +This creates a C++ source file "example_wrap.cpp". A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.

    30.2.1 Command-line options

    @@ -110,15 +110,12 @@ Options specific to the Octave module are:
    $ swig -octave -help
     ...
     Octave Options (available with -octave)
    -     -global       - Load all symbols into the global namespace [default]
          -globals name - Set name used to access C global variables [default: 'cvar']
    -                         - Use '.' to load C global variables into module namespace
    -     -noglobal     - Do not load all symbols into the global namespace
    +                     Use '.' to load C global variables into module namespace
          -opprefix str - Prefix str for global operator functions [default: 'op_']
     

    -The -global and -noglobal options determine whether the Octave module will load all symbols into the global namespace in addition to the global namespace. The -globals option sets the name of the variable which is the namespace for C global variables exported by the module. The special name "." loads C global variables into the module namespace, i.e. alongside C functions and structs exported by the module. The -opprefix options sets the prefix of the names of global/friend operator functions. @@ -138,7 +135,7 @@ $ mkoctfile example_wrap.cpp example.c

    - where example.c is the file containing the gcd() implementation. + where "example.c" is the file containing the gcd() implementation.

    @@ -146,10 +143,10 @@ $ mkoctfile example_wrap.cpp example.c

    - mkoctfile will produce example.oct, which contains the compiled extension module. Loading it into Octave is then a matter of invoking + mkoctfile will produce "swigexample.oct", which contains the compiled extension module. Loading it into Octave is then a matter of invoking

    -
    octave:1> example
    +
    octave:1> swigexample

    30.2.3 Using your module

    @@ -160,13 +157,13 @@ Assuming all goes well, you will be able to do this:

    $ octave -q
    -octave:1> example
    -octave:2> example.gcd(4,6)
    +octave:1> swigexample
    +octave:2> swigexample.gcd(4,6)
     ans =  2
    -octave:3> example.cvar.Foo
    +octave:3> swigexample.cvar.Foo
     ans =  3
    -octave:4> example.cvar.Foo=4;
    -octave:5> example.cvar.Foo
    +octave:4> swigexample.cvar.Foo=4;
    +octave:5> swigexample.cvar.Foo
     ans =  4 

    30.3 A tour of basic C/C++ wrapping

    @@ -176,59 +173,26 @@ ans = 4

    -The SWIG module directive specifies the name of the Octave module. If you specify `module example', then in Octave everything in the module will be accessible under "example", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name. +The SWIG module directive specifies the name of the Octave module. If you specify "module swigexample", then in Octave everything in the module will be accessible under "swigexample", as in the above example. When choosing a module name, make sure you don't use the same name as a built-in Octave command or standard module name.

    -When Octave is asked to invoke example, it will try to find the .m or .oct file that defines the function "example". It will thusly find example.oct, that upon loading will register all of the module's symbols. +When Octave is asked to invoke swigexample, it will try to find the ".m" or ".oct" file that defines the function "swigexample". You therefore need to make sure that "swigexample.oct" is in Octave's search path, which can be specified with the environment variable "OCTAVE_PATH".

    -An Octave module takes three options, -global, -noglobal, and -globals, which behave the same as the corresponding swig command-line options. -Here are some example usages: +To load an Octave module, simply type its name:

    -
    -octave:1> example -help
    -usage: example [-global|-noglobal] [-globals <name>]
    -octave:2> example -global
    -octave:3> gcd(4,6)
    +
    +octave:1> swigexample;
    +octave:2> gcd(4,6)
     ans =  2
    -octave:4> cvar.Foo
    -ans =  3
    -octave:5> cvar.Foo=4;
    -octave:6> cvar.Foo
    -ans =  4
    -
    -
    -
    -octave:1> example -noglobal
    -octave:2> gcd(6,9)
    -ans =  3
     octave:3> cvar.Foo
    -error: `cvar' undefined near line 3 column 1
    -octave:3> example.cvar.Foo
    -ans =  3
    -
    -
    -
    -octave:1> example -globals mycvar
    -octave:2> cvar.Foo
    -error: `cvar' undefined near line 2 column 1
    -octave:2> mycvar.Foo
    -ans =  3
    -
    - -

    - It is also possible to rename the module / global variables namespaces with an assignment, as in:
    -

    -octave:1> example
    -octave:2> c=example;
    -octave:3> c.gcd(10,4)
    -ans =  2
    -octave:4> some_vars = cvar;
    -octave:5> some_vars.Foo
     ans =  3
    +octave:4> cvar.Foo=4;
    +octave:5> cvar.Foo
    +ans =  4
     

    @@ -238,15 +202,15 @@ If the module is also used in the base context, however, it must first be loaded

     octave:1> function l = my_lcm(a,b)
    -> example
    -> l = abs(a*b)/example.gcd(a,b);
    +> swigexample
    +> l = abs(a*b)/swigexample.gcd(a,b);
     > endfunction
     octave:2> my_lcm(4,6)
     ans =  12
    -octave:3> example.gcd(4,6)
    +octave:3> swigexample.gcd(4,6)
     error: can't perform indexing operations for <unknown type> type
    -octave:3> example;
    -octave:4> example.gcd(4,6)
    +octave:3> swigexample;
    +octave:4> swigexample.gcd(4,6)
     ans =  2
     
    @@ -257,14 +221,14 @@ ans = 2 Global functions are wrapped as new Octave built-in functions. For example,

    -
    %module example
    +      
    %module swigexample
     int fact(int n); 

    - creates a built-in function example.fact(n) that works exactly like you think it does: + creates a built-in function swigexample.fact(n) that works exactly like you think it does:

    -
    octave:1> example.fact(4)
    +    
    octave:1> swigexample.fact(4)
     24 

    30.3.3 Global variables

    @@ -274,28 +238,28 @@ int fact(int n);
    Global variables are a little special in Octave. Given a global variable:

    -
    %module example
    +
    %module swigexample
     extern double Foo;
    -      
    +

    To expose variables, SWIG actually generates two functions, to get and set the value. In this case, Foo_set and Foo_set would be generated. SWIG then automatically calls these functions when you get and set the variable-- in the former case creating a local copy in the interpreter of the C variables, and in the latter case copying an interpreter variables onto the C variable.

    -
    octave:1> example;
    -octave:2> c=example.cvar.Foo
    +    
    octave:1> swigexample;
    +octave:2> c=swigexample.cvar.Foo
     c =  3
    -octave:3> example.cvar.Foo=4;
    +octave:3> swigexample.cvar.Foo=4;
     octave:4> c
     c =  3
    -octave:5> example.cvar.Foo
    +octave:5> swigexample.cvar.Foo
     ans =  4

    If a variable is marked with the %immutable directive then any attempts to set this variable will cause an Octave error. Given a global variable:

    -
    %module example
    +    
    %module swigexample
     %immutable;
     extern double Foo;
     %mutable;
    @@ -305,8 +269,8 @@ extern double Foo;
          SWIG will allow the reading of Foo but when a set attempt is made, an error function will be called. 
     

    -
    octave:1> example
    -octave:2> example.Foo=4
    +    
    octave:1> swigexample
    +octave:2> swigexample.Foo=4
     error: attempt to set immutable member variable
     error: assignment failed, or no method for `swig_type = scalar'
     error: evaluating assignment expression near line 2, column 12 
    @@ -315,9 +279,9 @@ error: evaluating assignment expression near line 2, column 12
    It is possible to add new functions or variables to the module. This also allows the user to rename/remove existing functions and constants (but not linked variables, mutable or immutable). Therefore users are recommended to be careful when doing so.

    -
    octave:1> example;
    -octave:2> example.PI=3.142;
    -octave:3> example.PI
    +    
    octave:1> swigexample;
    +octave:2> swigexample.PI=3.142;
    +octave:3> swigexample.PI
     ans =  3.1420 

    30.3.4 Constants and enums

    @@ -327,7 +291,7 @@ ans = 3.1420
    Because Octave doesn't really have the concept of constants, C/C++ constants are not really constant in Octave. They are actually just a copy of the value into the Octave interpreter. Therefore they can be changed just as any other value. For example given some constants:

    -
    %module example
    +    
    %module swigexample
     %constant int ICONST=42;
     #define    SCONST      "Hello World"
     enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
    @@ -337,9 +301,9 @@ enum Days{SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY};
         This is 'effectively' converted into the following Octave code: 
     

    -
    example.ICONST=42
    -example.SCONST="Hello World"
    -example.SUNDAY=0
    +    
    swigexample.ICONST=42
    +swigexample.SCONST="Hello World"
    +swigexample.SUNDAY=0
     .... 

    30.3.5 Pointers

    @@ -350,7 +314,7 @@ example.SUNDAY=0 C/C++ pointers are fully supported by SWIG. Furthermore, SWIG has no problem working with incomplete type information. Given a wrapping of the <file.h> interface:

    -
    %module example
    +
    %module swigexample
     FILE *fopen(const char *filename, const char *mode);
     int fputs(const char *, FILE *);
     int fclose(FILE *);
    @@ -361,18 +325,18 @@ When wrapped, you will be able to use the functions in a natural way from Octave
     

    -octave:1> example;
    -octave:2> f=example.fopen("w","junk");
    -octave:3> example.fputs("Hello world",f);
    -octave:4> example.fclose(f);
    +octave:1> swigexample;
    +octave:2> f=swigexample.fopen("w","junk");
    +octave:3> swigexample.fputs("Hello world",f);
    +octave:4> swigexample.fclose(f);
     

    Simply printing the value of a wrapped C++ type will print it's typename. E.g.,

    -
    octave:1> example;
    -octave:2> f=example.fopen("junk","w");
    +    
    octave:1> swigexample;
    +octave:2> f=swigexample.fopen("junk","w");
     octave:3> f
     f =
     
    @@ -384,8 +348,8 @@ f =
         As the user of the pointer, you are responsible for freeing it, or closing any resources associated with it (just as you would in a C program). This does not apply so strictly to classes and structs (see below).
     

    -
    octave:1> example;
    -octave:2> f=example.fopen("not there","r");
    +    
    octave:1> swigexample;
    +octave:2> f=swigexample.fopen("not there","r");
     error: value on right hand side of assignment is undefined
     error: evaluating assignment expression near line 2, column 2 
    @@ -407,8 +371,8 @@ For each wrapped structure and class, a swig_ref will be exposed that h

    -
    octave:1> example;
    -octave:2> p=example.Point();
    +      
    octave:1> swigexample;
    +octave:2> p=swigexample.Point();
     octave:3> p.x=3;
     octave:4> p.y=5;
     octave:5> p.x, p.y
    @@ -442,9 +406,9 @@ public:
     can be used from Octave like this
     

    -
    octave:1> example;
    -octave:2> p1=example.Point(3,5);
    -octave:3> p2=example.Point(1,2);
    +      
    octave:1> swigexample;
    +octave:2> p1=swigexample.Point(3,5);
    +octave:3> p2=swigexample.Point(1,2);
     octave:4> p1.distance(p2)
     ans =  3.6056
     
    @@ -685,7 +649,7 @@ C++ class and function templates are fully supported as in other modules, in tha For example, function templates can be instantiated as follows:

    -
    %module example
    +
    %module swigexample
     %inline {
      template<class __scalar>
        __scalar mul(__scalar a,__scalar b) {
    @@ -713,7 +677,7 @@ ans =  22 + 46i
     Similarly, class templates can be instantiated as in the following example,
     

    -
    %module example
    +
    %module swigexample
     %include <std_complex.i>
     %include <std_string.i>
     %inline {
    diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html
    index 0a4b61bd5..49e8965fa 100644
    --- a/Doc/Manual/Perl5.html
    +++ b/Doc/Manual/Perl5.html
    @@ -170,8 +170,8 @@ $ perl -e 'use Config; print "$Config{archlib}\n";'
     
     

    The preferred approach to building an extension module is to compile it into -a shared object file or DLL. To do this, you will need to compile your program -using commands like this (shown for Linux): +a shared object file or DLL. Assuming you have code you need to link to in a file called example.c, +you will need to compile your program using commands like this (shown for Linux):

    diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
    index 19ace7192..78ee6ea7f 100644
    --- a/Doc/Manual/Php.html
    +++ b/Doc/Manual/Php.html
    @@ -146,7 +146,7 @@ least work for Linux though):
     
     

    To test the extension from a PHP script, you need to load it first. You -can load it for every script by adding this line the [PHP] section of +can load it for every script by adding this line to the [PHP] section of php.ini:

    @@ -156,7 +156,7 @@ can load it for every script by adding this line the [PHP] section of

    Alternatively, you can load it explicitly only for scripts which need it -by adding this line: +by adding this line to the start of each such PHP script::

    @@ -164,7 +164,7 @@ by adding this line:
     

    -to the start of each PHP file. SWIG also generates a php module, which +SWIG also generates a php module, which attempts to do the dl() call for you:

    @@ -506,6 +506,12 @@ this, one needs to include phppointers.i which defines the named typemap REFERENCE.

    +

    +However, this relies on call-time pass-by-reference, which has been +deprecated in PHP for some time, and was finally removed in PHP 5.4. +So you should avoid creating new wrappers which rely on this approach. +

    +
     %module example
     %include "phppointers.i"
    @@ -705,7 +711,7 @@ would be accessed in PHP as,
     
     include("example.php");
     
    -echo "There has now been " . Ko::threats() . " threats\n";
    +echo "There have now been " . Ko::threats() . " threats\n";
     
     
    @@ -718,7 +724,7 @@ function, e.g. Ko::threats(10); -echo "There has now been " . Ko::threats() . " threats\n"; +echo "There have now been " . Ko::threats() . " threats\n";

    32.2.6.4 Static Member Functions

    @@ -895,9 +901,6 @@ globally, to specific classes, and to specific methods, like this: // generate directors for all virtual methods in class Foo %feature("director") Foo; - -// generate a director for just Foo::bar() -%feature("director") Foo::bar;
    diff --git a/Doc/Manual/Preface.html b/Doc/Manual/Preface.html index 2d0aa093e..d17dc229c 100644 --- a/Doc/Manual/Preface.html +++ b/Doc/Manual/Preface.html @@ -12,13 +12,23 @@
    @@ -57,13 +67,26 @@ In the late 1990's, the most stable version of SWIG was release over a period of 10 years starting from the year 2000. The final version in the 1.3.x series was 1.3.40, but in truth the 1.3.x series had been stable for many years. An official stable version was released along with the decision to make SWIG -license changes and this gave rise to version 2.0.0 in 2010. The license was clarified +license changes and this gave rise to version 2.0.0 in 2010. +

    + +

    1.3 SWIG License

    + + +

    +The LICENSE file shipped with SWIG in the top level directory contains the SWIG license. +For further insight into the license including the license of SWIG's output code, please visit +the SWIG legal page - http://www.swig.org/legal.html. +

    + +

    +The license was clarified in version 2.0.0 so that the code that SWIG generated could be distributed under license terms of the user's choice/requirements and at the same time the SWIG source was placed under the GNU General Public License version 3.

    -

    1.3 SWIG resources

    +

    1.4 SWIG resources

    @@ -93,16 +116,17 @@ SWIG along with information about beta releases and future work.

    -Subversion access to the latest version of SWIG is also available. More information +Git and Subversion access to the latest version of SWIG is also available. More information about this can be obtained at:

    -

    1.4 Prerequisites

    + +

    1.5 Prerequisites

    @@ -127,7 +151,7 @@ However, this isn't meant to be a tutorial on C++ programming. For many of the gory details, you will almost certainly want to consult a good C++ reference. If you don't program in C++, you may just want to skip those parts of the manual. -

    1.5 Organization of this manual

    +

    1.6 Organization of this manual

    @@ -139,7 +163,7 @@ can probably skip to that chapter and find almost everything you need to know.

    -

    1.6 How to avoid reading the manual

    +

    1.7 How to avoid reading the manual

    @@ -151,7 +175,7 @@ The SWIG distribution also comes with a large directory of examples that illustrate different topics.

    -

    1.7 Backwards compatibility

    +

    1.8 Backwards compatibility

    @@ -162,8 +186,8 @@ this isn't always possible as the primary goal over time is to make SWIG better---a process that would simply be impossible if the developers are constantly bogged down with backwards compatibility issues. -Potential incompatibilities are clearly marked in the detailed release notes -(CHANGES files). +Potential incompatibilities are clearly marked in the detailed +release notes.

    @@ -187,7 +211,16 @@ Note: The version symbol is not defined in the generated SWIG wrapper file. The SWIG preprocessor has defined SWIG_VERSION since SWIG-1.3.11.

    -

    1.8 Credits

    +

    1.9 Release notes

    + + +

    +The CHANGES.current, CHANGES and RELEASENOTES files shipped with SWIG in the top level directory +contain, respectively, detailed release notes for the current version, +detailed release notes for previous releases and summary release notes from SWIG-1.3.22 onwards. +

    + +

    1.10 Credits

    @@ -200,7 +233,7 @@ who have made contributions at all levels over time. Contributors are mentioned either in the COPYRIGHT file or CHANGES files shipped with SWIG or in submitted bugs.

    -

    1.9 Bug reports

    +

    1.11 Bug reports

    @@ -215,5 +248,204 @@ used, and any important pieces of the SWIG generated wrapper code. We can only fix bugs if we know about them.

    +

    1.12 Installation

    + + +

    1.12.1 Windows installation

    + + +

    +Please see the dedicated Windows chapter for instructions on installing +SWIG on Windows and running the examples. The Windows distribution is +called swigwin and includes a prebuilt SWIG executable, swig.exe, included in +the top level directory. Otherwise it is exactly the same as +the main SWIG distribution. There is no need to download anything else. +

    + +

    1.12.2 Unix installation

    + + +

    +You must use GNU make to build and install SWIG. +

    + +

    +PCRE +needs to be installed on your system to build SWIG, in particular +pcre-config must be available. If you have PCRE headers and libraries but not +pcre-config itself or, alternatively, wish to override the compiler or linker +flags returned by pcre-config, you may set PCRE_LIBS and PCRE_CFLAGS variables +to be used instead. And if you don't have PCRE at all, the configure script +will provide instructions for obtaining it. +

    + +

    +To build and install SWIG, simply type the following: +

    + +
    +$ ./configure
    +$ make
    +$ make install
    +
    + +

    +By default SWIG installs itself in /usr/local. If you need to install SWIG in +a different location or in your home directory, use the --prefix option +to ./configure. For example: +

    + +
    +$ ./configure --prefix=/home/yourname/projects
    +$ make
    +$ make install
    +
    + +

    +Note: the directory given to --prefix must be an absolute pathname. Do not use +the ~ shell-escape to refer to your home directory. SWIG won't work properly +if you do this. +

    + +

    +The INSTALL file shipped in the top level directory details more about using configure. Also try +

    + +
    +$ ./configure --help.
    +
    + +

    +The configure script will attempt to locate various packages on your machine +including Tcl, Perl5, Python and all the other target languages that SWIG +supports. Don't panic if you get 'not found' messages -- SWIG does not need these +packages to compile or run. The configure script is actually looking for +these packages so that you can try out the SWIG examples contained +in the 'Examples' directory without having to hack Makefiles. +Note that the --without-xxx options, where xxx is a target language, have +minimal effect. All they do is reduce the amount of testing done with +'make check'. The SWIG executable and library files installed cannot currently +be configured with a subset of target languages. +

    + +

    +SWIG used to include a set of runtime libraries for some languages for working +with multiple modules. These are no longer built during the installation stage. +However, users can build them just like any wrapper module as described in +the Modules chapter. +The CHANGES file shipped with SWIG in the top level directory +also lists some examples which build the runtime library. +

    + +

    +Note: +

    + +
      +
    • +If you checked the code out via Git, you will have to run ./autogen.sh +before ./configure. In addition, a full build of SWIG requires +a number of packages to be installed. Full instructions at +SWIG bleeding edge. +
    • +
    + +

    1.12.3 Macintosh OS X installation

    + + +

    +SWIG is known to work on various flavors of OS X. Follow the Unix installation +instructions above. However, as of this writing, there is still great deal of +inconsistency with how shared libaries are handled by various scripting languages +on OS X. +

    + +

    +Users of OS X should be aware that Darwin handles shared libraries and linking in +a radically different way than most Unix systems. In order to test SWIG and run +the examples, SWIG configures itself to use flat namespaces and to allow undefined +symbols (-flat_namespace -undefined suppress). This mostly closely follows the Unix +model and makes it more likely that the SWIG examples will work with whatever +installation of software you might have. However, this is generally not the recommended +technique for building larger extension modules. Instead, you should utilize +Darwin's two-level namespaces. Some details about this can be found here + +http://developer.apple.com/documentation/ReleaseNotes/DeveloperTools/TwoLevelNamespaces.html. + +

    + +

    +Needless to say, you might have to experiment a bit to get things working at first. +

    + +

    1.12.4 Testing

    + + +

    +If you want to test SWIG after building it, a check can be performed on Unix operating systems. +Type the following: +

    + +
    +    $ make -k check
    +
    + +

    +This step can be performed either before or after installation. +The check requires at least one of the target languages to be +installed. If it fails, it may mean that you have an uninstalled +language module or that the file 'Examples/Makefile' has been +incorrectly configured. It may also fail due to compiler issues such +as a broken C++ compiler. Even if the check fails, there is a +pretty good chance SWIG still works correctly --- you will just have to +mess around with one of the examples and some makefiles to get it to work. +Some tests may also fail due to missing dependency packages, eg PCRE +or Boost, but this will require careful analysis of the configure output +done during configuration. +

    + +

    +The test suite executed by the check is designed to stress-test +many parts of the implementation including obscure corner cases. If some +of these tests fail or generate warning messages, there is no reason for +alarm --- the test may be related to some new SWIG feature or a difficult bug +that we're trying to resolve. Chances are that SWIG will work just fine +for you. Note that if you have more than one CPU/core, then you can use +parallel make to speed up the check as it does take quite some time to run, +for example: +

    + +
    +    $ make -j2 -k check
    +
    + +

    +Also, SWIG's support for C++ is sufficiently advanced that certain +tests may fail on older C++ compilers (for instance if your compiler +does not support member templates). These errors are harmless if you +don't intend to use these features in your own programs. +

    + +

    +Note: The test-suite currently contains over 500 tests. If you +have many different target languages installed and a slow machine, it +might take more than an hour to run the test-suite. +

    + +

    1.12.5 Examples

    + + +

    +The Examples directory contains a variety of examples of using SWIG +and it has some browsable documentation. Simply point your browser to +the file "Example/index.html". +

    + +

    +The Examples directory also includes Visual C++ project 6 (.dsp) files for +building some of the examples on Windows. Later versions of Visual Studio +will convert these old style project files into a current solution file. +

    + diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html index a9a9bc44e..762abebba 100644 --- a/Doc/Manual/Python.html +++ b/Doc/Manual/Python.html @@ -2345,7 +2345,7 @@ doesn't know how to add an instance of MyString to itself.
  • If you have multiple SWIG modules that share type information (more info), -the -builtin option requiress a bit of extra discipline to ensure that base classes are initialized before derived classes. Specifically:

    +the -builtin option requires a bit of extra discipline to ensure that base classes are initialized before derived classes. Specifically:

    • There must be an unambiguous dependency graph for the modules.

    • Module dependencies must be explicitly stated with %import statements in the SWIG interface file.

      @@ -2782,9 +2782,6 @@ globally, to specific classes, and to specific methods, like this: // generate directors for all virtual methods in class Foo %feature("director") Foo; - -// generate a director for just Foo::bar() -%feature("director") Foo::bar; @@ -3389,7 +3386,39 @@ public: +

      +Note that when the underlying C++ method is overloaded, there is only one proxy Python method +for multiple C++ methods. In this case, only one of parsed methods is examined +for the feature. You are better off specifying the feature without the argument list to ensure it will get used, +as it will then get attached to all the overloaded C++ methods. For example: +

      +
      +
      +%module example
      +
      +// Add python code to bar()
      +
      +%pythonprepend Foo::bar %{
      +   #do something before C++ call
      +%}
      +
      +%pythonappend Foo::bar %{
      +   #do something after C++ call
      +%}
      +
      +
      +class Foo {
      +public:
      +    int bar(int x);
      +    int bar();
      +}
      +
      +
      + +

      +The same applies for overloaded constructors. +

      34.6.3 Class extension with %extend

      diff --git a/Doc/Manual/README b/Doc/Manual/README index f01013d54..66daaec90 100644 --- a/Doc/Manual/README +++ b/Doc/Manual/README @@ -1,9 +1,9 @@ This directory contains the HTML for the SWIG users manual. All of this HTML is hand-written. However, section numbering, indices, -and the table of contents is generated automatically by the 'maketoc.py' +and the table of contents are generated automatically by the 'maketoc.py' script. The Makefile has further information on how the various alternative -forms of the documentation is generated from the hand-written HTML. +forms of the documentation are generated from the hand-written HTML. There are 4 types of boxes that code or whatever can be inside: -
      ...
      diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html index 69005c731..9739e1109 100644 --- a/Doc/Manual/Ruby.html +++ b/Doc/Manual/Ruby.html @@ -398,7 +398,8 @@ can add this:

      to the end of the extconf.rb file. If for some reason you don't want to use the standard approach, you'll need to determine the correct compiler and linker flags for your build -platform. For example, a typical sequence of commands for the Linux +platform. For example, assuming you have code you need to link to in a file +called example.c, a typical sequence of commands for the Linux operating system would look something like this:

      @@ -3214,7 +3215,7 @@ directive which is unique to the Ruby module and was introduced in SWIG
      -
      %bang sort!(arr);

      int sort(int arr[]);
      +
      %bang sort(int arr[]);

      int sort(int arr[]);
      @@ -4925,7 +4926,7 @@ arguments. For example:

      -
      %typemap(in) (char *str, int len) {
      $1 = STR2CSTR($input);
      $2 = (int) RSTRING($input)->len;
      };

      int count(char c, char *str, int len);
      +
      %typemap(in) (char *str, int len) {
      $1 = StringValuePtr($input);
      $2 = (int) RSTRING($input)->len;
      };

      int count(char c, char *str, int len);
      @@ -7134,7 +7135,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input - char * STR2CSTR(String) + char * StringValuePtr(String) SWIG_AsCharPtrAndSize(VALUE, char*, size_t, int* alloc) @@ -7517,7 +7518,7 @@ Array instance to be used as a char ** object.

      -
      %module argv

      // This tells SWIG to treat char ** as a special case
      %typemap(in) char ** {
      /* Get the length of the array */
      int size = RARRAY($input)->len;
      int i;
      $1 = (char **) malloc((size+1)*sizeof(char *));
      /* Get the first element in memory */
      VALUE *ptr = RARRAY($input)->ptr;
      for (i=0; i < size; i++, ptr++)
      /* Convert Ruby Object String to char* */
      $1[i]= STR2CSTR(*ptr);
      $1[i]=NULL; /* End of list */
      }

      // This cleans up the char ** array created before
      // the function call

      %typemap(freearg) char ** {
      free((char *) $1);
      }

      // Now a test function
      %inline %{
      int print_args(char **argv) {
      int i = 0;
      while (argv[i]) {
      printf("argv[%d] = %s\n", i,argv[i]);
      i++;
      }
      return i;
      }
      %}

      +
      %module argv

      // This tells SWIG to treat char ** as a special case
      %typemap(in) char ** {
      /* Get the length of the array */
      int size = RARRAY($input)->len;
      int i;
      $1 = (char **) malloc((size+1)*sizeof(char *));
      /* Get the first element in memory */
      VALUE *ptr = RARRAY($input)->ptr;
      for (i=0; i < size; i++, ptr++)
      /* Convert Ruby Object String to char* */
      $1[i]= StringValuePtr(*ptr);
      $1[i]=NULL; /* End of list */
      }

      // This cleans up the char ** array created before
      // the function call

      %typemap(freearg) char ** {
      free((char *) $1);
      }

      // Now a test function
      %inline %{
      int print_args(char **argv) {
      int i = 0;
      while (argv[i]) {
      printf("argv[%d] = %s\n", i,argv[i]);
      i++;
      }
      return i;
      }
      %}

      @@ -7795,7 +7796,7 @@ equivalents and store them in our local C arrays:

      -
      %typemap(in) (int nattributes, const char **names, const int *values)
      (VALUE keys_arr, int i, VALUE key, VALUE val) {
      Check_Type($input, T_HASH);
      $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
      $2 = NULL;
      $3 = NULL;
      if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
      key = rb_ary_entry(keys_arr, i);
      val = rb_hash_aref($input, key);
      Check_Type(key, T_STRING);
      Check_Type(val, T_FIXNUM);
      $2[i] = STR2CSTR(key);
      $3[i] = NUM2INT(val);

      }
      }
      }
      +
      %typemap(in) (int nattributes, const char **names, const int *values)
      (VALUE keys_arr, int i, VALUE key, VALUE val) {
      Check_Type($input, T_HASH);
      $1 = NUM2INT(rb_funcall($input, rb_intern("size"), 0, NULL));
      $2 = NULL;
      $3 = NULL;
      if ($1 > 0) {
      $2 = (char **) malloc($1*sizeof(char *));
      $3 = (int *) malloc($1*sizeof(int));
      keys_arr = rb_funcall($input, rb_intern("keys"), 0, NULL);
      for (i = 0; i < $1; i++) {
      key = rb_ary_entry(keys_arr, i);
      val = rb_hash_aref($input, key);
      Check_Type(key, T_STRING);
      Check_Type(val, T_FIXNUM);
      $2[i] = StringValuePtr(key);
      $3[i] = NUM2INT(val);

      }
      }
      }
      diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html index 58a3c8e55..25dc899de 100644 --- a/Doc/Manual/SWIG.html +++ b/Doc/Manual/SWIG.html @@ -2699,7 +2699,7 @@ the following declaration :

       /* file : vector.h */
       ...
      -typedef struct {
      +typedef struct Vector {
       	double x,y,z;
       } Vector;
       
      @@ -2772,7 +2772,7 @@ of the Vector structure. For example:

      #include "vector.h" %} -typedef struct { +typedef struct Vector { double x,y,z; %extend { Vector(double x, double y, double z) { ... } @@ -2783,7 +2783,7 @@ typedef struct {

      -Finally, %extend can be used to access externally written +Note that %extend can be used to access externally written functions provided they follow the naming convention used in this example :

      @@ -2814,7 +2814,7 @@ double Vector_magnitude(Vector *v) { #include "vector.h" %} -typedef struct { +typedef struct Vector { double x,y,z; %extend { Vector(int,int,int); // This calls new_Vector() @@ -2826,6 +2826,37 @@ typedef struct {
      +

      +The name used for %extend should be the name of the struct and not the name of any typedef to the struct. +For example: +

      + +
      +typedef struct Integer {
      +	int value;
      +} Int;
      +%extend Integer { ...  } /* Correct name */
      +%extend Int { ...  } /* Incorrect name */
      +
      +struct Float {
      +	float value;
      +};
      +typedef struct Float FloatValue;
      +%extend Float { ...  } /* Correct name */
      +%extend FloatValue { ...  } /* Incorrect name */
      +
      + +

      +There is one exception to this rule and that is when the struct is anonymously named such as: +

      + +
      +typedef struct {
      +	double value;
      +} Double;
      +%extend Double { ...  } /* Okay */
      +
      +

      A little known feature of the %extend directive is that it can also be used to add synthesized attributes or to modify the @@ -2862,7 +2893,7 @@ For example, consider this interface:

      -typedef struct {
      +typedef struct Person {
         char name[50];
         ...
       } Person;
      @@ -2876,7 +2907,7 @@ the interface as follows to ensure this occurs whenever a name is read or writte
       
       
      -typedef struct {
      +typedef struct Person {
         %extend {
           char name[50];
         }
      diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
      index b4baca6ae..716882f53 100644
      --- a/Doc/Manual/SWIGPlus.html
      +++ b/Doc/Manual/SWIGPlus.html
      @@ -2838,6 +2838,12 @@ struct Derived : Base {
       }
       
      +

      +The following special variables are expanded if used within a %extend block: +$name, $symname, $overname, $decl, $fulldecl, $parentname and $parentsymname. +The Special variables section provides more information each of these special variables. +

      +

      The %extend directive follows all of the same conventions as its use with C structures. Please refer to the Adding member functions to C structures @@ -3121,8 +3127,8 @@ nothing is known about List<int>, you will get a warning message

      -example.h:42. Nothing known about class 'List<int >' (ignored). 
      -example.h:42. Maybe you forgot to instantiate 'List<int >' using %template. 
      +example.h:42: Warning 401. Nothing known about class 'List<int >'. Ignored. 
      +example.h:42: Warning 401. Maybe you forgot to instantiate 'List<int >' using %template. 
       
      @@ -3163,7 +3169,7 @@ Don't worry--if you get the order wrong, SWIG should generate a warning message. Occasionally, you may need to tell SWIG about base classes that are defined by templates, but which aren't supposed to be wrapped. Since SWIG is not able to automatically instantiate templates for this purpose, you must do it manually. To do this, simply -use %template with no name. For example: +use the empty template instantiation, that is, %template with no name. For example:

      diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html index 1151de1d5..9e4a3dd17 100644 --- a/Doc/Manual/Sections.html +++ b/Doc/Manual/Sections.html @@ -6,7 +6,7 @@

      SWIG-2.0 Documentation

      -Last update : SWIG-2.0.6 (30 April 2012) +Last update : SWIG-2.0.10 (in progress)

      Sections

      diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html index f55a7f139..e6b3b4a43 100644 --- a/Doc/Manual/Tcl.html +++ b/Doc/Manual/Tcl.html @@ -132,7 +132,8 @@ header file.

      The preferred approach to building an extension module is to compile it into -a shared object file or DLL. To do this, you will need to compile your program +a shared object file or DLL. Assuming you have code you need to link to in a file +called example.c, you will need to compile your program using commands like this (shown for Linux):

      diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html index b3b0bc7a9..81e3fd1bb 100644 --- a/Doc/Manual/Typemaps.html +++ b/Doc/Manual/Typemaps.html @@ -773,7 +773,7 @@ Here are some examples of valid typemap specifications: } /* Typemap with modifiers */ -%typemap(in,doc="integer") int "$1 = gh_scm2int($input);"; +%typemap(in,doc="integer") int "$1 = scm_to_int($input);"; /* Typemap applied to patterns of multiple arguments */ %typemap(in) (char *str, int len), diff --git a/Doc/Manual/Varargs.html b/Doc/Manual/Varargs.html index c27db603d..9564fe00b 100644 --- a/Doc/Manual/Varargs.html +++ b/Doc/Manual/Varargs.html @@ -398,7 +398,7 @@ int execlp(const char *path, const char *arg, ...);

      -Note that str3 is the name of the last argument, as we have used %vargars with 3. +Note that str3 is the name of the last argument, as we have used %varargs with 3. Now execlp("a", "b", "c", "d", "e") will result in an error as one too many arguments has been passed, as now only 2 additional 'str' arguments can be passed with the 3rd one always using the specified default NULL.

      @@ -509,10 +509,10 @@ like this:
      -%typemap(in) (...)(char *args[10]) {
      +%typemap(in) (...)(char *vargs[10]) {
         int i;
         int argc;
      -  for (i = 0; i < 10; i++) args[i] = 0;
      +  for (i = 0; i < 10; i++) vargs[i] = 0;
         argc = PyTuple_Size(varargs);
         if (argc > 10) {
           PyErr_SetString(PyExc_ValueError, "Too many arguments");
      @@ -528,7 +528,7 @@ like this:
              return NULL;
           }
           pystr = PyUnicode_AsUTF8String(pyobj);
      -    str = PyBytes_AsString(pystr);
      +    str = strdup(PyBytes_AsString(pystr));
           Py_XDECREF(pystr);
       %#else  
           if (!PyString_Check(pyobj)) {
      @@ -537,22 +537,34 @@ like this:
           }
           str = PyString_AsString(pyobj);
       %#endif
      -    args[i] = str;
      +    vargs[i] = str;
         }
      -  $1 = (void *) args;
      +  $1 = (void *)vargs;
      +}
      +
      +%typemap(freearg) (...) {
      +%#if PY_VERSION_HEX>=0x03000000
      +  int i;
      +  for (i = 0; i < 10; i++) {
      +    free(vargs$argnum[i]);
      +  }
      +%#endif
       }
       

      -In this typemap, the special variable varargs is a tuple +In the 'in' typemap, the special variable varargs is a tuple holding all of the extra arguments passed (this is specific to the Python module). The typemap then pulls this apart and sticks the values into the array of strings args. Then, the array is assigned to $1 (recall that this is the void * variable corresponding to (...)). However, this assignment is only half of the picture----clearly this alone is not enough to -make the function work. To patch everything up, you have to rewrite the +make the function work. The 'freearg' typemap cleans up memory +allocated in the 'in' typemap; this code is generated to be called +after the execlp function is called. To patch everything +up, you have to rewrite the underlying action code using the %feature directive like this:

      @@ -560,9 +572,9 @@ this:
       %feature("action") execlp {
      -   char *args = (char **) arg3;
      -   result = execlp(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
      -                   args[5],args[6],args[7],args[8],args[9], NULL);
      +  char **vargs = (char **) arg3;
      +  result = execlp(arg1, arg2, vargs[0], vargs[1], vargs[2], vargs[3], vargs[4],
      +                  vargs[5], vargs[6], vargs[7], vargs[8], vargs[9], NULL);
       }
       
       int execlp(const char *path, const char *arg, ...);
      @@ -839,13 +851,13 @@ of type va_list.  For example:
       
       
      -int vfprintf(FILE *f, const char *fmt, va_list ap);
      +int vprintf(const char *fmt, va_list ap);
       

      -As far as we know, there is no obvious way to wrap these functions -with SWIG. This is because there is no documented way to assemble the +As far as we know, there is no obvious way to wrap these functions with +SWIG. This is because there is no documented way to assemble the proper va_list structure (there are no C library functions to do it and the contents of va_list are opaque). Not only that, the contents of a va_list structure are closely tied to the underlying @@ -853,6 +865,36 @@ call-stack. It's not clear that exporting a va_list would have any use or that it would work at all.

      +

      +A workaround can be implemented by writing a simple varargs C wrapper and then using the techniques +discussed earlier in this chapter for varargs. Below is a simple wrapper for vprintf renamed so that +it can still be called as vprintf from your target language. The %varargs +used in the example restricts the function to taking one string argument. +

      + +
      +
      +%{
      +int vprintf(const char *fmt, va_list ap);
      +%}
      +
      +%varargs(const char *) my_vprintf;
      +%rename(vprintf) my_vprintf;
      +
      +%inline %{
      +int my_vprintf(const char *fmt, ...) {
      +  va_list ap;
      +  int result;
      +
      +  va_start(ap, fmt);
      +  result = vprintf(fmt, ap);
      +  va_end(ap);
      +  return result;
      +}
      +%}
      +
      +
      +

      13.8 C++ Issues

      diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html index 2a3ce560d..cf4c38d7e 100644 --- a/Doc/Manual/Warnings.html +++ b/Doc/Manual/Warnings.html @@ -423,7 +423,8 @@ example.i(4) : Syntax error in input.
    • 322. Redundant redeclaration of 'name'.
    • 323. Recursive scope inheritance of 'name'.
    • 324. Named nested template instantiations not supported. Processing as if no name was given to %template(). -
    • 325. Nested class not currently supported (name ignored). +
    • 325. Nested kind not currently supported (name ignored). +
    • 326. Deprecated %extend name used - the kind name 'name' should be used instead of the typedef name 'name'.
    • 350. operator new ignored.
    • 351. operator delete ignored.
    • 352. operator+ ignored. @@ -526,6 +527,8 @@ example.i(4) : Syntax error in input.
    • 519. %template() contains no name. Template method ignored: declaration
    • 520. Base/Derived class 'classname1' of 'classname2' is not similarly marked as a smart pointer.
    • 521. Illegal destructor name name. Ignored. +
    • 522. Use of an illegal constructor name 'name' in %extend is deprecated, the constructor name should be 'name'. +
    • 523. Use of an illegal destructor name 'name' in %extend is deprecated, the destructor name should be 'name'.

    14.9.6 Language module specific (700-899)

    @@ -551,6 +554,8 @@ example.i(4) : Syntax error in input.
  • 822. Covariant return types not supported in Java. Proxy method will return basetype (Java).
  • 823. No javaconstruct typemap defined for type (Java).
  • 824. Missing JNI descriptor in directorin typemap defined for type (Java). +
  • 825. "directorconnect" attribute missing in type "javaconstruct" typemap. (Java). +
  • 826. The nspace feature is used on 'type' without -package. The generated code may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package. (Java).
      diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html index 6349f355a..c94a3da3b 100644 --- a/Doc/Manual/Windows.html +++ b/Doc/Manual/Windows.html @@ -236,8 +236,8 @@ The short abbreviated instructions follow...

    -The step by step instructions to download and install MinGW and MSYS, then download and build the latest version of SWIG from SVN follow... -Note that the instructions for obtaining SWIG from SVN are also online at SWIG SVN. +The step by step instructions to download and install MinGW and MSYS, then download and build the latest version of SWIG from Github follow... +Note that the instructions for obtaining SWIG from Github are also online at SWIG Bleeding Edge.

    @@ -300,15 +300,19 @@ tar -zxf bison-2.0-MSYS.tar.gz

  • - To get the latest SWIG SVN (version from Subversion source control), type in the following: + The very latest development version of SWIG is available from SWIG on Github + and can be downloaded as a zip file or if you have Git installed, via Git. + Either download the latest Zip file snapshot and unzip and rename the top level folder to /usr/src/swig. + + Otherwise if using Git, type in the following:
     mkdir /usr/src
     cd /usr/src
    -svn co https://swig.svn.sourceforge.net/svnroot/swig/trunk swig
    +git clone https://github.com/swig/swig.git
     
    Pitfall note: -If you want to check out SWIG to a different folder to the proposed +If you want to place SWIG in a different folder to the proposed /usr/src/swig, do not use MSYS emulated windows drive letters, because the autotools will fail miserably on those.
  • diff --git a/Doc/Manual/margin-left.patch b/Doc/Manual/margin-left.patch index 70f087b92..8bef6305c 100644 --- a/Doc/Manual/margin-left.patch +++ b/Doc/Manual/margin-left.patch @@ -1,25 +1,66 @@ -# -# Patch managed by http://www.holgerschurig.de/patcher.html -# -# This patch is against htmldoc 1.8.24, and it hacks in support for +# This patch is against htmldoc 1.8.27, and it hacks in support for # correctly indenting the
    sections in the SWIG manual. # This patch should only be used until the 1.9 branch of htmldoc -# stabalizes, since the 1.9 branch includes true CSS1 support. +# stabilizes, since the 1.9 branch includes true CSS1 support. # # This patch only affects the PDF generation, an unpatched htmldoc # creates the one-page html documentation just fine. # ---- htmldoc-1.8.24/htmldoc/ps-pdf.cxx~margin-left -+++ htmldoc-1.8.24/htmldoc/ps-pdf.cxx -@@ -158,6 +158,7 @@ +diff -Naur htmldoc-1.8.27/htmldoc/htmldoc.cxx htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx +--- htmldoc-1.8.27/htmldoc/htmldoc.cxx 2006-03-30 14:01:20.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/htmldoc.cxx 2013-05-11 10:11:47.428435647 +0100 +@@ -65,6 +65,8 @@ + const char *__XOS2RedirRoot(const char *); + } + #endif ++ ++extern void parse_style(char *); + + + /* +@@ -1115,6 +1117,7 @@ + else if (compare_strings(argv[i], "--version", 6) == 0) + { + puts(SVERSION); ++ puts("Patched with margin-left.patch"); + return (0); + } + else if (compare_strings(argv[i], "--webpage", 3) == 0) +@@ -2403,6 +2406,10 @@ + } + else if (strcmp(temp, "--cookies") == 0) + file_cookies(temp2); ++ else if (strcmp(temp, "--stylesheet") == 0) ++ { ++ parse_style(temp2); ++ } + } + } + +diff -Naur htmldoc-1.8.27/htmldoc/Makefile htmldoc-1.8.27-margin-left/htmldoc/Makefile +--- htmldoc-1.8.27/htmldoc/Makefile 2005-10-28 21:32:59.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/Makefile 2013-05-11 09:39:04.392367869 +0100 +@@ -36,7 +36,7 @@ + OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o \ + http.o http-addr.o http-addrlist.o http-support.o image.o \ + iso8859.o license.o md5.o progress.o ps-pdf.o rc4.o \ +- snprintf.o string.o toc.o util.o ++ snprintf.o string.o toc.o util.o style.o + + + # +diff -Naur htmldoc-1.8.27/htmldoc/ps-pdf.cxx htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx +--- htmldoc-1.8.27/htmldoc/ps-pdf.cxx 2006-08-01 17:58:50.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/ps-pdf.cxx 2013-05-11 09:37:40.096364957 +0100 +@@ -160,6 +160,7 @@ # undef page_t #endif // __hpux +extern int lookup_div_class(uchar *); /* - * Constants... -@@ -4188,9 +4189,24 @@ + * Output options... +@@ -4230,9 +4231,24 @@ para->child = para->last_child = NULL; } @@ -45,30 +86,9 @@ if (para->child != NULL) { parse_paragraph(para, *left, *right, *bottom, *top, x, y, page, *needspace); ---- htmldoc-1.8.24/htmldoc/htmldoc.cxx~margin-left -+++ htmldoc-1.8.24/htmldoc/htmldoc.cxx -@@ -62,6 +62,8 @@ - const char *__XOS2RedirRoot(const char *); - } - #endif -+ -+extern void parse_style(char *); - - - /* -@@ -2140,6 +2142,10 @@ - } - else if (strcmp(temp, "--cookies") == 0) - file_cookies(temp2); -+ else if (strcmp(temp, "--stylesheet") == 0) -+ { -+ parse_style(temp2); -+ } - } - } - ---- /dev/null -+++ htmldoc-1.8.24/htmldoc/style.cxx +diff -Naur htmldoc-1.8.27/htmldoc/style.cxx htmldoc-1.8.27-margin-left/htmldoc/style.cxx +--- htmldoc-1.8.27/htmldoc/style.cxx 1970-01-01 01:00:00.000000000 +0100 ++++ htmldoc-1.8.27-margin-left/htmldoc/style.cxx 2013-05-11 09:37:40.096364957 +0100 @@ -0,0 +1,185 @@ +/* Extreamly simple parsing routines for CSS style sheets. + * We only parse div.class { } sections, and only look @@ -255,15 +275,3 @@ + + fclose(f); +} ---- htmldoc-1.8.24/htmldoc/Makefile~margin-left -+++ htmldoc-1.8.24/htmldoc/Makefile -@@ -35,7 +35,7 @@ - - OBJS = gui.o file.o html.o htmldoc.o htmllib.o htmlsep.o http.o \ - http-addr.o http-support.o image.o iso8859.o license.o md5.o \ -- progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o -+ progress.o ps-pdf.o rc4.o snprintf.o string.o toc.o util.o style.o - - - # - diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 9b14df4bf..30c7718f0 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -24,7 +24,7 @@ TARGET = CC = @CC@ CXX = @CXX@ -CFLAGS = @PLATFLAGS@ +CFLAGS = @BOOST_CPPFLAGS@ @PLATFLAGS@ prefix = @prefix@ exec_prefix= @exec_prefix@ SRCS = @@ -46,6 +46,10 @@ LIBPREFIX = RUNTOOL = # COMPILETOOL is a way to run the compiler under another tool, or more commonly just to stop the compiler executing COMPILETOOL= +# RUNPIPE is for piping output of running interpreter/compiled code somewhere, eg RUNPIPE=\>/dev/null +RUNPIPE= + +RUNME = runme # X11 options @@ -57,6 +61,27 @@ ISRCS = $(IWRAP:.i=.c) ICXXSRCS = $(IWRAP:.i=.cxx) IOBJS = $(IWRAP:.i=.@OBJEXT@) +################################################################## +# Some options for silent output +################################################################## + +ifneq (,$(findstring s, $(filter-out --%, $(MAKEFLAGS)))) + # make -s detected + SILENT=1 +else + SILENT= +endif + +ifneq (,$(SILENT)) + SILENT_OPTION = -s + SILENT_PIPE = >/dev/null + ANT_QUIET = -q -logfile /dev/null +else + SILENT_OPTION = + SILENT_PIPE = + ANT_QUIET = +endif + ################################################################## # Dynamic loading for C++ # If you are going to be building dynamic loadable modules in C++, @@ -86,7 +111,6 @@ OBJS = $(SRCS:.c=.@OBJEXT@) $(CXXSRCS:.cxx=.@OBJEXT@) distclean: rm -f Makefile - rm -f guile/Makefile rm -f xml/Makefile ################################################################## @@ -95,6 +119,7 @@ distclean: # Set these to your local copy of Tcl/Tk. +TCLSH = tclsh TCL_INCLUDE = @TCLINCLUDE@ TCL_LIB = @TCLLIB@ TCL_OPTS = @LIBS@ @@ -105,6 +130,7 @@ TCL_DLNK = @TCLDYNAMICLINKING@ TCL_SO = @TCL_SO@ TCLLDSHARED = @TCLLDSHARED@ TCLCXXSHARED = @TCLCXXSHARED@ +TCL_SCRIPT = $(RUNME).tcl # ----------------------------------------------------------- # Build a new version of the tclsh shell @@ -154,6 +180,20 @@ tcl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) $(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO) +# ----------------------------------------------------------------- +# Run Tcl example +# ----------------------------------------------------------------- + +tcl_run: + $(RUNTOOL) $(TCLSH) $(TCL_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +tcl_version: + echo 'puts $$tcl_version;exit 0' | $(TCLSH) + # ----------------------------------------------------------------- # Cleaning the Tcl examples # ----------------------------------------------------------------- @@ -176,6 +216,12 @@ PERL5_INCLUDE= @PERL5EXT@ # Extra Perl specific dynamic linking options PERL5_DLNK = @PERL5DYNAMICLINKING@ PERL5_CCFLAGS = @PERL5CCFLAGS@ +PERL5_CCDLFLAGS = @PERL5CCDLFLAGS@ +PERL5_CCCDLFLAGS = @PERL5CCCDLFLAGS@ +PERL5_LDFLAGS = @PERL5LDFLAGS@ +PERL = @PERL@ +PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) +PERL5_SCRIPT = $(RUNME).pl # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C) @@ -183,8 +229,8 @@ PERL5_CCFLAGS = @PERL5CCFLAGS@ perl5: $(SRCS) $(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) + $(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) + $(LDSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a Perl5 dynamically loadable module (C++) @@ -192,8 +238,8 @@ perl5: $(SRCS) perl5_cpp: $(SRCS) $(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) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) $(PERL5_CCCDLFLAGS) -I$(PERL5_INCLUDE) + $(CXXSHARED) $(CFLAGS) $(PERL5_CCDLFLAGS) $(OBJS) $(IOBJS) $(PERL5_LDFLAGS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) # ---------------------------------------------------------------- # Build a module from existing XS C source code. (ie. from xsubpp). @@ -206,8 +252,6 @@ perl5_xs: $(SRCS) # Build a statically linked Perl5 executable # ---------------------------------------------------------------- -PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS) - perl5_static: $(SRCS) $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) @@ -216,6 +260,20 @@ perl5_static_cpp: $(SRCS) $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH) $(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET) +# ----------------------------------------------------------------- +# Running a Perl5 example +# ----------------------------------------------------------------- + +perl5_run: + $(RUNTOOL) $(PERL) $(PERL5_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +perl5_version: + $(PERL) -v | grep "This is" + # ----------------------------------------------------------------- # Cleaning the Perl5 examples # ----------------------------------------------------------------- @@ -301,29 +359,38 @@ python_static_cpp: $(SRCS) # ----------------------------------------------------------------- ifeq (,$(PY3)) - PYSCRIPT = runme.py + PYSCRIPT = $(RUNME).py else - PYSCRIPT = runme3.py + PYSCRIPT = $(RUNME)3.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 + $(RUNTOOL) $(PYTHON) $(PYSCRIPT) $(RUNPIPE) -runme3.py: runme.py +$(RUNME)3.py: $(RUNME).py cp $< $@ $(PY2TO3) -w $@ >/dev/null 2>&1 +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +python_version: + $(PYTHON) -V + # ----------------------------------------------------------------- # Cleaning the python examples # ----------------------------------------------------------------- python_clean: + rm -rf __pycache__ 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 + rm -f $(TARGET).py + if [ -f $(RUNME).py ]; then rm -f $(RUNME)3.py $(RUNME)3.py.bak; fi ################################################################## @@ -331,14 +398,15 @@ python_clean: ################################################################## # Make sure these locate your Octave installation -OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@ -OCTAVE_LIB = -OCTAVE = @OCTAVE@ -qf +OCTAVE = OCTAVE_HISTFILE=/dev/null @OCTAVE@ -qfH +OCTAVE_CXX = $(DEFS) @OCTAVE_CPPFLAGS@ @OCTAVE_CXXFLAGS@ # Extra Octave specific dynamic linking options -OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@ +OCTAVE_DLNK = @OCTAVE_LDFLAGS@ OCTAVE_SO = @OCTAVE_SO@ +OCTAVE_SCRIPT = $(RUNME).m + # ---------------------------------------------------------------- # Build a C dynamically loadable module # Note: Octave requires C++ compiler when compiling C wrappers @@ -346,7 +414,7 @@ OCTAVE_SO = @OCTAVE_SO@ octave: $(SRCS) $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) + $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CSRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) @@ -356,25 +424,29 @@ octave: $(SRCS) octave_cpp: $(SRCS) $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH) - $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE) + $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(OCTAVE_CXX) $(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO) # ----------------------------------------------------------------- # Running an Octave example # ----------------------------------------------------------------- -OCTSCRIPT = runme.m - -octave_run: $(OCTSCRIPT) - for file in $(OCTSCRIPT); do \ - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(OCTAVE) $$file >/dev/null || break; \ - done +octave_run: + $(RUNTOOL) $(OCTAVE) $(OCTAVE_SCRIPT) $(RUNPIPE) # ----------------------------------------------------------------- -# Cleaning the octave examples +# Version display +# ----------------------------------------------------------------- + +octave_version: + $(OCTAVE) --version | head -n 1 + +# ----------------------------------------------------------------- +# Cleaning the Octave examples # ----------------------------------------------------------------- octave_clean: + rm -rf __pycache__ rm -f *_wrap* *~ .~* myoctave@EXEEXT@ *.pyc rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ *@OCTAVE_SO@ @@ -384,81 +456,81 @@ octave_clean: ################################################################## # Make sure these locate your Guile installation -GUILE_INCLUDE = @GUILEINCLUDE@ -GUILE_LIB = @GUILELIB@ +GUILE = @GUILE@ +GUILE_CFLAGS = @GUILE_CFLAGS@ GUILE_SO = @GUILE_SO@ +GUILE_LIBS = @GUILE_LIBS@ +GUILE_LIBOPTS = @LIBS@ $(SYSLIBS) GUILE_LIBPREFIX = lib +GUILE_SCRIPT = $(RUNME).scm #------------------------------------------------------------------ -# Build a dynamically loaded module with passive linkage and the scm interface +# Build a dynamically loaded module with passive linkage #------------------------------------------------------------------ guile: $(SRCS) - $(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) + $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCS) + $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) -guile_cpp: $(SRCS) - $(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) +guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) +$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCS) + $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH) + $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) + $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@ guile_externalhdr: $(SWIG) -guile -external-runtime $(TARGET) -#------------------------------------------------------------------ -# Build a dynamically loaded module with passive linkage and the gh interface -#------------------------------------------------------------------ -guile_gh: $(SRCS) - $(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) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) - # ----------------------------------------------------------------- -# Build a dynamically loadable module with passive linkage +# Build Guile interpreter augmented with extra functions # ----------------------------------------------------------------- -guile_passive: $(SRCS) - $(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) $(INTERFACEPATH) - $(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS) - $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO) +guile_augmented: + $(SWIG) -guile $(SWIGOPT) $(INTERFACE) + $(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) -o $(TARGET) # ----------------------------------------------------------------- # Build statically linked Guile interpreter # ----------------------------------------------------------------- -GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS) - guile_static: $(SRCS) $(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_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_static_cpp: $(SRCS) $(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_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple: $(SRCS) $(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_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile guile_simple_cpp: $(SRCS) $(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 + $(GUILE_CFLAGS) $(GUILE_LIBS) $(LIBS) $(GUILE_LIBOPTS) -o $(TARGET)-guile + +# ----------------------------------------------------------------- +# Running a Guile example +# ----------------------------------------------------------------- + +guile_run: + env GUILE_AUTO_COMPILE=0 $(RUNTOOL) $(GUILE) -l $(GUILE_SCRIPT) $(RUNPIPE) + +guile_augmented_run: + env GUILE_AUTO_COMPILE=0 $(RUNTOOL) ./$(TARGET) $(GUILE_RUNOPTIONS) -s $(GUILE_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +guile_version: + $(GUILE) --version | head -n 1 # ----------------------------------------------------------------- # Cleaning the Guile examples @@ -485,6 +557,8 @@ JAVASO =@JAVASO@ JAVALDSHARED = @JAVALDSHARED@ JAVACXXSHARED = @JAVACXXSHARED@ JAVACFLAGS = @JAVACFLAGS@ +JAVA = @JAVA@ +JAVAC = @JAVAC@ # ---------------------------------------------------------------- # Build a java dynamically loadable module (C) @@ -504,15 +578,92 @@ java_cpp: $(SRCS) $(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) +# ---------------------------------------------------------------- +# Compile java files +# ---------------------------------------------------------------- + +java_compile: $(SRCS) + $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(JAVASRCS) + +# ----------------------------------------------------------------- +# Run java example +# ----------------------------------------------------------------- + +java_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(JAVA) $(RUNME) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +java_version: + $(JAVA) -version + $(JAVAC) -version || echo "Unknown javac version" + # ----------------------------------------------------------------- # Cleaning the java examples # ----------------------------------------------------------------- java_clean: - rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java` + rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v $(RUNME).java` rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@JAVASO@ +################################################################## +##### ANDROID ###### +################################################################## + +ANDROID = android +ANDROID_NDK_BUILD = ndk-build +ANDROID_ADB = adb +ANT = ant +TARGETID = 1 + +# ---------------------------------------------------------------- +# Build an Android dynamically loadable module (C) +# ---------------------------------------------------------------- + +android: $(SRCS) + $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -java $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.c $(INTERFACEPATH) + +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) + $(ANT) $(ANT_QUIET) debug + +# ---------------------------------------------------------------- +# Build an Android dynamically loadable module (C++) +# ---------------------------------------------------------------- + +android_cpp: $(SRCS) + $(ANDROID) $(SILENT_OPTION) update project --target $(TARGETID) --name $(PROJECTNAME) --path . + $(SWIG) -java -c++ $(SWIGOPT) -o $(INTERFACEDIR)$(TARGET)_wrap.cpp $(INTERFACEPATH) + +$(ANDROID_NDK_BUILD) $(SILENT_PIPE) + $(ANT) $(ANT_QUIET) debug + +# ---------------------------------------------------------------- +# Android install +# ---------------------------------------------------------------- + +android_install: + -$(ANDROID_ADB) uninstall $(PACKAGENAME) + $(ANDROID_ADB) install $(INSTALLOPTIONS) bin/$(PROJECTNAME)-debug.apk + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +android_version: + $(ANDROID_ADB) version + +# ----------------------------------------------------------------- +# Cleaning the Android examples +# ----------------------------------------------------------------- + +android_clean: + ant -q -logfile /dev/null clean + rm -f $(INTERFACEDIR)$(TARGET)_wrap.* + rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` + rm -rf obj + ################################################################## ##### MODULA3 ###### ################################################################## @@ -531,6 +682,20 @@ modula3: $(SRCS) modula3_cpp: $(SRCS) $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Run modula3 example +# ----------------------------------------------------------------- + +modula3_run: + $(RUNTOOL) false $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +modula3_version: + echo "Unknown modula3 version" + # ----------------------------------------------------------------- # Cleaning the modula3 examples # ----------------------------------------------------------------- @@ -544,9 +709,11 @@ modula3_clean: ##### MZSCHEME ###### ################################################################## +MZSCHEME = mzscheme MZC = @MZC@ MZDYNOBJ = @MZDYNOBJ@ MZSCHEME_SO = @MZSCHEME_SO@ +MZSCHEME_SCRIPT = $(RUNME).scm # ---------------------------------------------------------------- # Build a C/C++ dynamically loadable module @@ -562,6 +729,21 @@ mzscheme_cpp: $(SRCS) $(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) +# ----------------------------------------------------------------- +# Run mzscheme example +# ----------------------------------------------------------------- + +mzscheme_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(MZSCHEME) -r $(MZSCHEME_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +mzscheme_version: + $(MZSCHEME) -v + $(MZC) -v + # ----------------------------------------------------------------- # Cleaning the mzscheme examples # ----------------------------------------------------------------- @@ -698,6 +880,24 @@ ocaml_dynamic_cpp: $(SRCS) -package dl -linkpkg \ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings' +# ----------------------------------------------------------------- +# Run ocaml example +# ----------------------------------------------------------------- + +ocaml_run: + $(RUNTOOL) ./$(TARGET) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +ocaml_version: + $(OCC) -version + +# ----------------------------------------------------------------- +# Cleaning the Ocaml examples +# ----------------------------------------------------------------- + ocaml_clean: rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo rm -f core @EXTRA_CLEAN@ @@ -712,6 +912,10 @@ RUBY_CFLAGS= @RUBYCCDLFLAGS@ $(DEFS) RUBY_INCLUDE= @RUBYINCLUDE@ RUBY_LIB = @RUBYLIB@ RUBY_DLNK = @RUBYDYNAMICLINKING@ +RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) +RUBY = @RUBY@ +RUBY_SCRIPT = $(RUNME).rb + # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -738,8 +942,6 @@ ruby_cpp: $(SRCS) # library file # ----------------------------------------------------------------- -RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS) - ruby_static: $(SRCS) $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -750,6 +952,19 @@ ruby_cpp_static: $(SRCS) $(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Run Ruby example +# ----------------------------------------------------------------- + +ruby_run: + $(RUNTOOL) $(RUBY) -I. $(RUBY_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +ruby_version: + $(RUBY) -v # ----------------------------------------------------------------- # Cleaning the Ruby examples @@ -764,13 +979,15 @@ ruby_clean: ##### PHP ###### ################################################################## +PHP = @PHP@ +PHP_INCLUDE = @PHPINC@ +PHP_SO = @PHP_SO@ +PHP_SCRIPT = $(RUNME).php + # ------------------------------------------------------------------- # Build a PHP dynamically loadable module (C) # ------------------------------------------------------------------- -PHP_INCLUDE = @PHPINC@ -PHP_SO = @PHP_SO@ - php: $(SRCS) $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE) @@ -789,11 +1006,15 @@ php_cpp: $(SRCS) # Running a PHP example # ----------------------------------------------------------------- -PHP=@PHP@ -PHPSCRIPT ?= runme.php - php_run: - $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT) + $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHP_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +php_version: + $(PHP) -v | head -n 1 # ----------------------------------------------------------------- # Cleaning the PHP examples @@ -809,10 +1030,13 @@ php_clean: ################################################################## # Make sure these locate your Pike installation +PIKE = pike PIKE_CFLAGS = @PIKECCDLFLAGS@ -DHAVE_CONFIG_H PIKE_INCLUDE = @PIKEINCLUDE@ PIKE_LIB = @PIKELIB@ PIKE_DLNK = @PIKEDYNAMICLINKING@ +PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) +PIKE_SCRIPT = $(RUNME).pike # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -839,8 +1063,6 @@ pike_cpp: $(SRCS) # library file # ----------------------------------------------------------------- -PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS) - pike_static: $(SRCS) $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH) $(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \ @@ -851,6 +1073,20 @@ pike_cpp_static: $(SRCS) $(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \ $(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET) +# ----------------------------------------------------------------- +# Run pike example +# ----------------------------------------------------------------- + +pike_run: + $(RUNTOOL) $(PIKE) $(PIKE_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +pike_version: + $(PIKE) -v 2>&1 | head -n 1 + # ----------------------------------------------------------------- # Cleaning the Pike examples # ----------------------------------------------------------------- @@ -867,11 +1103,13 @@ pike_clean: CHICKEN = @CHICKEN@ CHICKEN_CSC = @CHICKEN_CSC@ +CHICKEN_CSI = @CHICKEN_CSI@ CHICKEN_LIBOPTS = @CHICKENLIB@ $(SYSLIBS) CHICKEN_SHAREDLIBOPTS = @CHICKENSHAREDLIB@ $(SYSLIBS) CHICKEN_CFLAGS = @CHICKENOPTS@ CHICKENOPTS = -quiet CHICKEN_MAIN = +CHICKEN_SCRIPT = $(RUNME).scm # SWIG produces $(ISRCS) (the C wrapper file) # and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file): @@ -952,6 +1190,24 @@ chicken_cpp: chicken_externalhdr: $(SWIG) -chicken -external-runtime $(TARGET) +# ----------------------------------------------------------------- +# Run CHICKEN example +# ----------------------------------------------------------------- + +chicken_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(CHICKEN_CSI) $(CHICKEN_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +chicken_version: + $(CHICKEN) -version | grep -i version + +# ----------------------------------------------------------------- +# Cleaning the CHICKEN examples +# ----------------------------------------------------------------- + chicken_clean: rm -f *_wrap* *~ .~* *_chicken* rm -f core @EXTRA_CLEAN@ @@ -968,6 +1224,7 @@ CSHARPCOMPILER = @CSHARPCOMPILER@ CSHARPCILINTERPRETER = @CSHARPCILINTERPRETER@ CSHARPCFLAGS = @CSHARPCFLAGS@ CSHARPSO = @CSHARPSO@ +CSHARP_RUNME = ./$(RUNME).exe # ---------------------------------------------------------------- # Build a CSharp dynamically loadable module (C) @@ -994,6 +1251,21 @@ csharp_cpp: $(SRCS) csharp_compile: $(SRCS) $(COMPILETOOL) $(CSHARPCOMPILER) $(CSHARPFLAGS) $(CSHARPSRCS) +# ----------------------------------------------------------------- +# Run CSharp example +# ----------------------------------------------------------------- + +csharp_run: + env LD_LIBRARY_PATH=. $(RUNTOOL) $(CSHARP_RUNME) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +# Version check below also works with MS csc.exe which does not understand --version +csharp_version: + $(CSHARPCOMPILER) --version | head -n 1 + # ----------------------------------------------------------------- # Cleaning the CSharp examples # ----------------------------------------------------------------- @@ -1015,8 +1287,11 @@ LUA_LIB = @LUALINK@ LUA_DLNK = @LUADYNAMICLINKING@ LUA_SO = @LUA_SO@ +LUA = @LUABIN@ +LUA_SCRIPT = $(RUNME).lua + # Extra code for lua static link -LUA_INTERP = ../lua.c +LUA_INTERP = ../lua.c # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -1050,6 +1325,23 @@ lua_static_cpp: $(SRCS) $(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \ $(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET) +# ----------------------------------------------------------------- +# Run Lua example +# ----------------------------------------------------------------- + +lua_run: + $(RUNTOOL) $(LUA) $(LUA_SCRIPT) $(RUNPIPE) + +lua_embed_run: + $(RUNTOOL) ./$(TARGET) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +lua_version: + $(LUA) -v | head -n 1 + # ----------------------------------------------------------------- # Cleaning the lua examples # ----------------------------------------------------------------- @@ -1063,6 +1355,9 @@ lua_clean: ##### ALLEGRO CL ###### ################################################################## +ALLEGROCL = @ALLEGROCLBIN@ +ALLEGROCL_SCRIPT=$(RUNME).lisp + allegrocl: $(SRCS) $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH) $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1073,6 +1368,24 @@ allegrocl_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run ALLEGRO CL example +# ----------------------------------------------------------------- + +allegrocl_run: + $(RUNTOOL) $(ALLEGROCL) -batch -s $(ALLEGROCL_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +allegrocl_version: + $(ALLEGROCL) --version + +# ----------------------------------------------------------------- +# Cleaning the ALLEGRO CL examples +# ----------------------------------------------------------------- + allegrocl_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1082,12 +1395,33 @@ allegrocl_clean: ##### CLISP ###### ################################################################## +CLISP = @CLISPBIN@ +CLISP_SCRIPT=$(RUNME).lisp + clisp: $(SRCS) $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH) clisp_cpp: $(SRCS) $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH) +# ----------------------------------------------------------------- +# Run CLISP example +# ----------------------------------------------------------------- + +clisp_run: + $(RUNTOOL) $(CLISP) -batch -s $(CLISP_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +clisp_version: + $(CLISP) --version | head -n 1 + +# ----------------------------------------------------------------- +# Cleaning the CLISP examples +# ----------------------------------------------------------------- + clisp_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1097,6 +1431,9 @@ clisp_clean: ##### CFFI ###### ################################################################## +CFFI = @CFFIBIN@ +CFFI_SCRIPT=$(RUNME).lisp + cffi: $(SRCS) $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1107,6 +1444,24 @@ cffi_cpp: $(SRCS) $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run CFFI example +# ----------------------------------------------------------------- + +cffi_run: + $(RUNTOOL) $(CFFI) -batch -s $(CFFI_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +cffi_version: + $(CFFI) --version + +# ----------------------------------------------------------------- +# Cleaning the CFFI examples +# ----------------------------------------------------------------- + cffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1116,6 +1471,9 @@ cffi_clean: ##### UFFI ###### ################################################################## +UFFI = @UFFIBIN@ +UFFI_SCRIPT=$(RUNME).lisp + uffi: $(SRCS) $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH) # $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS) @@ -1126,6 +1484,24 @@ uffi_cpp: $(SRCS) # $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) # $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) +# ----------------------------------------------------------------- +# Run UFFI example +# ----------------------------------------------------------------- + +uffi_run: + $(RUNTOOL) $(UFFI) -batch -s $(UFFI_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +uffi_version: + $(UFFI) --version + +# ----------------------------------------------------------------- +# Cleaning the UFFI examples +# ----------------------------------------------------------------- + uffi_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ @@ -1139,18 +1515,27 @@ R = R RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system as it does not understand _wrap.cxx RRSRC = $(INTERFACE:.i=.R) R_CFLAGS=-fPIC +R_SCRIPT=$(RUNME).R # need to compile .cxx files outside of R build system to make sure that # we get -fPIC # CMD SHLIB stdout is piped to /dev/null to prevent echo of compiler command +# ---------------------------------------------------------------- +# Build a R dynamically loadable module (C) +# ---------------------------------------------------------------- + r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) ifneq ($(SRCS),) - $(CXX) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) + $(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) +# ---------------------------------------------------------------- +# Build a R dynamically loadable module (C++) +# ---------------------------------------------------------------- + r_cpp: $(CXXSRCS) $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH) ifneq ($(CXXSRCS),) @@ -1158,11 +1543,29 @@ ifneq ($(CXXSRCS),) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) $(OBJS) > /dev/null ) +# ----------------------------------------------------------------- +# Run R example +# ----------------------------------------------------------------- + +r_run: + $(RUNTOOL) $(R) CMD BATCH $(R_SCRIPT) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +r_version: + $(R) --version | head -n 1 + +# ----------------------------------------------------------------- +# Cleaning the R examples +# ----------------------------------------------------------------- + r_clean: rm -f *_wrap* *~ .~* rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *@SO@ NAMESPACE - rm -f $(RRSRC) runme.Rout .RData + rm -f $(RRSRC) $(RUNME).Rout .RData ################################################################## ##### SCILAB ###### @@ -1246,6 +1649,8 @@ GO = @GO@ GOGCC = @GOGCC@ GO1 = @GO1@ GOC = @GOC@ +GOOPT = @GOOPT@ +GOVERSIONOPTION = @GOVERSIONOPTION@ GOSWIGARG = `if $(GOGCC) ; then echo -gccgo; fi` GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; elif $(GO1) ; then echo tool $(GOC:c=g) ; fi` @@ -1268,7 +1673,7 @@ GOGCCOBJS = $(GOSRCS:.go=.@OBJEXT@) # ---------------------------------------------------------------- go: $(SRCS) - $(SWIG) -go $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -go $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) $(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS) @@ -1282,7 +1687,7 @@ go: $(SRCS) # ---------------------------------------------------------------- go_cpp: $(SRCS) - $(SWIG) -go -c++ $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) + $(SWIG) -go -c++ $(GOOPT) $(GOSWIGARG) $(SWIGOPT) $(INTERFACEPATH) $(CXX) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO) $(COMPILETOOL) $(GO) $(GOCOMPILEARG) -I . $(GOSRCS) @@ -1302,14 +1707,21 @@ go_run: runme.go else \ $(COMPILETOOL) $(GOTOOL) $(GOLD) -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o runme runme.$(GOOBJEXT); \ fi - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme + env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +go_version: + $(GO) $(GOVERSIONOPTION) # ----------------------------------------------------------------- # Cleaning the Go examples # ----------------------------------------------------------------- go_clean: - rm -f *_wrap* *_gc* .~* runme + rm -f *_wrap* *_gc* .~* runme $(GOSRCS) rm -f core @EXTRA_CLEAN@ rm -f *.@OBJEXT@ *.[568] *.a *@SO@ @@ -1331,6 +1743,8 @@ else DCOMPILER = @D1COMPILER@ endif +D_RUNME = ./$(RUNME) + # ---------------------------------------------------------------- # Build a dynamically loadable D wrapper for a C module # ---------------------------------------------------------------- @@ -1363,7 +1777,15 @@ d_compile: $(SRCS) # ----------------------------------------------------------------- d_run: - env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme + $(RUNTOOL) $(D_RUNME) $(RUNPIPE) + +# ----------------------------------------------------------------- +# Version display +# ----------------------------------------------------------------- + +d_version: + # Needs improvement! + echo D version guess - $(D_VERSION) # ----------------------------------------------------------------- # Clean the D examples diff --git a/Examples/android/check.list b/Examples/android/check.list index 69d56a4f6..0068e25ab 100644 --- a/Examples/android/check.list +++ b/Examples/android/check.list @@ -1,3 +1,4 @@ # see top-level Makefile.in class +extend simple diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile index 7de95f559..6155d9494 100644 --- a/Examples/android/class/Makefile +++ b/Examples/android/class/Makefile @@ -2,28 +2,25 @@ TOP = ../.. SWIG = $(TOP)/../preinst-swig TARGET = example INTERFACE = example.i +INTERFACEDIR = jni/ PACKAGEDIR = src/org/swig PACKAGENAME= org.swig.classexample SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/classexample PROJECTNAME= SwigClass TARGETID = 1 +#INSTALLOPTIONS = -s # To install on SD Card -all:: android +check: build -android:: - android update project --target $(TARGETID) --name $(PROJECTNAME) --path . - $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE) - ndk-build - ant debug +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp -install:: - -adb uninstall $(PACKAGENAME) - adb install bin/$(PROJECTNAME)-debug.apk +install: + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install -clean:: - ant clean - rm -f jni/$(TARGET)_wrap.cpp - rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java` - - -check: all +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/android/extend/AndroidManifest.xml b/Examples/android/extend/AndroidManifest.xml new file mode 100644 index 000000000..66d2469fa --- /dev/null +++ b/Examples/android/extend/AndroidManifest.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + diff --git a/Examples/android/extend/Makefile b/Examples/android/extend/Makefile new file mode 100644 index 000000000..ec53013af --- /dev/null +++ b/Examples/android/extend/Makefile @@ -0,0 +1,26 @@ +TOP = ../.. +SWIG = $(TOP)/../preinst-swig +TARGET = example +INTERFACE = example.i +INTERFACEDIR = jni/ +PACKAGEDIR = src/org/swig +PACKAGENAME= org.swig.extendexample +SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/extendexample +PROJECTNAME= SwigExtend +TARGETID = 1 +#INSTALLOPTIONS = -s # To install on SD Card + +check: build + +build: + $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' \ + TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' \ + PROJECTNAME='$(PROJECTNAME)' TARGETID='$(TARGETID)' android_cpp + +install: + $(MAKE) -f $(TOP)/Makefile INSTALLOPTIONS='$(INSTALLOPTIONS)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' PACKAGENAME='$(PACKAGENAME)' android_install + +clean: + $(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' PROJECTNAME='$(PROJECTNAME)' \ + PACKAGEDIR='$(PACKAGEDIR)' INTERFACEDIR='$(INTERFACEDIR)' android_clean diff --git a/Examples/android/extend/ant.properties b/Examples/android/extend/ant.properties new file mode 100644 index 000000000..ee52d86d9 --- /dev/null +++ b/Examples/android/extend/ant.properties @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked in Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff --git a/Examples/android/extend/build.xml b/Examples/android/extend/build.xml new file mode 100644 index 000000000..94fe847b7 --- /dev/null +++ b/Examples/android/extend/build.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/android/extend/jni/Android.mk b/Examples/android/extend/jni/Android.mk new file mode 100644 index 000000000..25d42b541 --- /dev/null +++ b/Examples/android/extend/jni/Android.mk @@ -0,0 +1,10 @@ +# File: Android.mk +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := example +LOCAL_SRC_FILES := example_wrap.cpp example.cpp +LOCAL_CFLAGS := -frtti + +include $(BUILD_SHARED_LIBRARY) diff --git a/Examples/android/extend/jni/Application.mk b/Examples/android/extend/jni/Application.mk new file mode 100644 index 000000000..45d13be4e --- /dev/null +++ b/Examples/android/extend/jni/Application.mk @@ -0,0 +1,2 @@ +# File: Application.mk +APP_STL := gnustl_static diff --git a/Examples/android/extend/jni/example.cpp b/Examples/android/extend/jni/example.cpp new file mode 100644 index 000000000..7d76571ca --- /dev/null +++ b/Examples/android/extend/jni/example.cpp @@ -0,0 +1,14 @@ +/* File : example.cxx */ + +#include "example.h" + +static Streamer * streamerInstance = 0; + +void setStreamer(Streamer* streamer) { + streamerInstance = streamer; +} + +Streamer& getStreamer() { + return *streamerInstance; +} + diff --git a/Examples/android/extend/jni/example.h b/Examples/android/extend/jni/example.h new file mode 100644 index 000000000..22430b501 --- /dev/null +++ b/Examples/android/extend/jni/example.h @@ -0,0 +1,71 @@ +/* File : example.h */ + +#include +#include +#include +#include +#include +#include + +struct Streamer { + virtual void display(std::string text) const = 0; + virtual ~Streamer() {} +}; +void setStreamer(Streamer* streamer); +Streamer& getStreamer(); + +template Streamer& operator<<(Streamer& stream, T const& val) { + std::ostringstream s; + s << val; + stream.display(s.str()); + return stream; +} + +class Employee { +private: + std::string name; +public: + Employee(const char* n): name(n) {} + virtual std::string getTitle() { return getPosition() + " " + getName(); } + virtual std::string getName() { return name; } + virtual std::string getPosition() const { return "Employee"; } + virtual ~Employee() { getStreamer() << "~Employee() @ " << this << "\n"; } +}; + + +class Manager: public Employee { +public: + Manager(const char* n): Employee(n) {} + virtual std::string getPosition() const { return "Manager"; } +}; + + +class EmployeeList { + std::vector list; +public: + EmployeeList() { + list.push_back(new Employee("Bob")); + list.push_back(new Employee("Jane")); + list.push_back(new Manager("Ted")); + } + void addEmployee(Employee *p) { + list.push_back(p); + getStreamer() << "New employee added. Current employees are:" << "\n"; + std::vector::iterator i; + for (i=list.begin(); i!=list.end(); i++) { + getStreamer() << " " << (*i)->getTitle() << "\n"; + } + } + const Employee *get_item(int i) { + return list[i]; + } + ~EmployeeList() { + std::vector::iterator i; + getStreamer() << "~EmployeeList, deleting " << list.size() << " employees." << "\n"; + for (i=list.begin(); i!=list.end(); i++) { + delete *i; + } + getStreamer() << "~EmployeeList empty." << "\n"; + } +}; + diff --git a/Examples/android/extend/jni/example.i b/Examples/android/extend/jni/example.i new file mode 100644 index 000000000..e550aac2c --- /dev/null +++ b/Examples/android/extend/jni/example.i @@ -0,0 +1,18 @@ +/* File : example.i */ +%module(directors="1") example +%{ +#include "example.h" +%} + +%include "std_vector.i" +%include "std_string.i" + +/* turn on director wrapping for Manager */ +%feature("director") Employee; +%feature("director") Manager; + +/* A base class for callbacks from C++ to output text on the Java side */ +%feature("director") Streamer; + +%include "example.h" + diff --git a/Examples/android/extend/local.properties b/Examples/android/extend/local.properties new file mode 100644 index 000000000..14b8d63b4 --- /dev/null +++ b/Examples/android/extend/local.properties @@ -0,0 +1,10 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must *NOT* be checked in Version Control Systems, +# as it contains information specific to your local configuration. + +# location of the SDK. This is only used by Ant +# For customization when using a Version Control System, please read the +# header note. +sdk.dir=/home/william/android/android-sdk-linux_x86 diff --git a/Examples/android/extend/proguard.cfg b/Examples/android/extend/proguard.cfg new file mode 100644 index 000000000..b1cdf17b5 --- /dev/null +++ b/Examples/android/extend/proguard.cfg @@ -0,0 +1,40 @@ +-optimizationpasses 5 +-dontusemixedcaseclassnames +-dontskipnonpubliclibraryclasses +-dontpreverify +-verbose +-optimizations !code/simplification/arithmetic,!field/*,!class/merging/* + +-keep public class * extends android.app.Activity +-keep public class * extends android.app.Application +-keep public class * extends android.app.Service +-keep public class * extends android.content.BroadcastReceiver +-keep public class * extends android.content.ContentProvider +-keep public class * extends android.app.backup.BackupAgentHelper +-keep public class * extends android.preference.Preference +-keep public class com.android.vending.licensing.ILicensingService + +-keepclasseswithmembernames class * { + native ; +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet); +} + +-keepclasseswithmembers class * { + public (android.content.Context, android.util.AttributeSet, int); +} + +-keepclassmembers class * extends android.app.Activity { + public void *(android.view.View); +} + +-keepclassmembers enum * { + public static **[] values(); + public static ** valueOf(java.lang.String); +} + +-keep class * implements android.os.Parcelable { + public static final android.os.Parcelable$Creator *; +} diff --git a/Examples/android/extend/project.properties b/Examples/android/extend/project.properties new file mode 100644 index 000000000..ea89160e0 --- /dev/null +++ b/Examples/android/extend/project.properties @@ -0,0 +1,11 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system use, +# "ant.properties", and override values to adapt the script to your +# project structure. + +# Project target. +target=android-8 diff --git a/Examples/android/extend/res/layout/main.xml b/Examples/android/extend/res/layout/main.xml new file mode 100644 index 000000000..d4e5d7fe8 --- /dev/null +++ b/Examples/android/extend/res/layout/main.xml @@ -0,0 +1,25 @@ + + +