summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Jezabek <jezabek@poczta.onet.pl>2009-06-21 22:39:32 +0000
committerJan Jezabek <jezabek@poczta.onet.pl>2009-06-21 22:39:32 +0000
commit948c2c9ee40a69a19accdfb389b5b5d15e09541d (patch)
treea073761c8bcfd10e672b1a5cbcd279d3ffe23111
parent810aa9117c59b5a0de496316d590d0732d1391c7 (diff)
downloadswig-948c2c9ee40a69a19accdfb389b5b5d15e09541d.tar.gz
Merged revisions 10794,10801-10809,10827-10831,10834,10846-10856,10860,10862-10881,10883-10887,10893,10896-10913,10915-11052,11054-11063,11069-11070,11072,11075-11076,11079-11080,11083,11092-11104,11107,11110-11111,11116-11117,11123-11137,11139-11143,11148,11150-11154,11156-11161,11163-11166,11169-11170,11174-11179,11182-11183,11185,11191-11201,11205-11206,11209-11210,11212-11216,11230-11241,11244,11246-11247,11259,11279-11283,11285,11287 via svnmerge from
https://swig.svn.sourceforge.net/svnroot/swig/trunk ................ r10794 | talby | 2008-08-19 09:09:29 +0200 (Tue, 19 Aug 2008) | 3 lines rollback 10737:10749, this work is better left on a branch until it is in support a significant feature enhancement. ................ r10801 | drjoe | 2008-08-31 18:07:43 +0200 (Sun, 31 Aug 2008) | 2 lines change Rf_warning to warning. Looks like a typo ................ r10802 | wsfulton | 2008-09-01 21:59:23 +0200 (Mon, 01 Sep 2008) | 1 line Fix ruby detection problem breaking configure ................ r10803 | wsfulton | 2008-09-01 22:00:28 +0200 (Mon, 01 Sep 2008) | 1 line Fix another perl global namespace pollution ................ r10804 | wsfulton | 2008-09-01 22:32:53 +0200 (Mon, 01 Sep 2008) | 1 line Fix array bounds checking in C# std::vector wrappers ................ r10805 | wsfulton | 2008-09-01 22:34:49 +0200 (Mon, 01 Sep 2008) | 1 line fix runtime problem in Ruby std_vector example ................ r10806 | wsfulton | 2008-09-01 22:42:40 +0200 (Mon, 01 Sep 2008) | 1 line Fix portability problem using /dev/null ................ r10807 | wsfulton | 2008-09-01 23:46:41 +0200 (Mon, 01 Sep 2008) | 1 line patch #2079381 submitted by Boris Smilga - constant exprs put into no-eval context in DEFCENUM ................ r10808 | wsfulton | 2008-09-02 22:56:52 +0200 (Tue, 02 Sep 2008) | 1 line Add new terminator attribute for the csin typemap for C# ................ r10809 | wsfulton | 2008-09-03 01:01:37 +0200 (Wed, 03 Sep 2008) | 1 line Fix #1988296 - Multiple module director linking issue ................ r10827 | richardb | 2008-09-10 12:08:21 +0200 (Wed, 10 Sep 2008) | 6 lines [Python] Commit patch #2089149: Director exception handling mangles returned exception. Exceptions raised by Python code in directors are now passed through to the caller without change. Also, remove the ": " prefix which used to be added to other director exceptions (eg, those due to incorrect return types). ................ r10828 | bhy | 2008-09-10 12:45:33 +0200 (Wed, 10 Sep 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-10827" from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ................ r10829 | bhy | 2008-09-10 13:04:09 +0200 (Wed, 10 Sep 2008) | 4 lines Removed merge tracking for "svnmerge" for https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy (Undo the init due to user error) ................ r10830 | bhy | 2008-09-10 13:08:16 +0200 (Wed, 10 Sep 2008) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-10403" from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ................ r10831 | bhy | 2008-09-10 13:51:12 +0200 (Wed, 10 Sep 2008) | 11 lines (Still trying to set right properity to get svnmerge work...) Recorded merge of revisions 10404 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ........ r10404 | bhy | 2008-05-01 08:35:49 +0800 (Thu, 01 May 2008) | 5 lines Start of gsoc2008-bhy branch. This is a branch for Haoyu Bai's Python 3.0 backend project. Some file already modified since a little of work already done when starting the branch. ........ ................ r10834 | bhy | 2008-09-11 19:18:07 +0200 (Thu, 11 Sep 2008) | 8 lines Merged the Python 3.0 support branch. The merging progress is not so smooth, so hope this commit won't make anything broken. This is the (incomplemete) log produced by svnmerge.py: Merged revisions 10405-10409,10420-10422,10426,10438,10445,10451,10454-10465,10467,10473-10475,10485,10488-10489,10493-10495,10497,10509-10510,10513-10514,10517,10520,10525,10528-10529,10533-10535,10554-10557,10570,10573,10593,10614,10666-10669,10673,10678,10687,10690,10704-10706,10731,10744,10750-10752,10755,10759,10770,10775-10776,10813,10819 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-bhy ................ r10846 | richardb | 2008-09-12 13:33:18 +0200 (Fri, 12 Sep 2008) | 2 lines Don't blame wsfulton for my recent change (this was a cut-and-paste error). ................ r10847 | bhy | 2008-09-12 13:52:11 +0200 (Fri, 12 Sep 2008) | 1 line A breif descirbe of Python 3 merge in CHANGES.current ................ r10848 | bhy | 2008-09-12 16:43:17 +0200 (Fri, 12 Sep 2008) | 1 line some more lines in CHANGES.current for Python 3 merge ................ r10849 | wsfulton | 2008-09-12 22:40:57 +0200 (Fri, 12 Sep 2008) | 1 line fix for when python3 not installed ................ r10850 | bhy | 2008-09-13 13:38:10 +0200 (Sat, 13 Sep 2008) | 1 line fix merge problem: remove USE_VALGRIND because it is already moved to common.mk ................ r10851 | bhy | 2008-09-13 14:16:44 +0200 (Sat, 13 Sep 2008) | 1 line add removing of 2to3 generated runme3.py in make clean target ................ r10852 | bhy | 2008-09-13 14:55:32 +0200 (Sat, 13 Sep 2008) | 1 line fix a typo in python/Makefile.in ................ r10853 | bhy | 2008-09-13 15:20:39 +0200 (Sat, 13 Sep 2008) | 1 line remove _runme3 file that was checked in by mistake ................ r10854 | bhy | 2008-09-13 15:39:34 +0200 (Sat, 13 Sep 2008) | 1 line more docs for Python 3 merge added in CHANGES.current ................ r10855 | bhy | 2008-09-13 15:42:24 +0200 (Sat, 13 Sep 2008) | 1 line fix some typo in CHANGES.current ................ r10856 | bhy | 2008-09-13 16:11:49 +0200 (Sat, 13 Sep 2008) | 1 line more document for limitation of parameter list, and doc of removal of -apply in CHANGES.current ................ r10860 | mutandiz | 2008-09-17 21:13:12 +0200 (Wed, 17 Sep 2008) | 1 line [allegrocl] Fix handling of forward references. Remove code breaking typical code generation. See ChangeLog for more details on the latter. ................ r10862 | olly | 2008-09-18 11:54:18 +0200 (Thu, 18 Sep 2008) | 3 lines [PHP5] Fix wrapping of a renamed enumerated value of an enum class member (SF#2095273). ................ r10863 | olly | 2008-09-18 15:01:52 +0200 (Thu, 18 Sep 2008) | 3 lines [PHP5] Fix extra code added to proxy class constructors in the case where the only constructor takes no arguments. ................ r10864 | olly | 2008-09-18 16:02:15 +0200 (Thu, 18 Sep 2008) | 5 lines [PHP5] Change the default input typemap for char * to turn PHP Null into C NULL (previously it was converted to an empty string). The new behaviour is consistent with how the corresponding output typemap works. ................ r10865 | olly | 2008-09-18 16:03:46 +0200 (Thu, 18 Sep 2008) | 2 lines Note the SF bug number for the previous fix. ................ r10866 | wsfulton | 2008-09-18 16:52:52 +0200 (Thu, 18 Sep 2008) | 1 line Document the module attribute in %import and add warning to Python for when it should be used ................ r10867 | wsfulton | 2008-09-18 22:16:03 +0200 (Thu, 18 Sep 2008) | 1 line pointer display correction ................ r10868 | wsfulton | 2008-09-18 22:16:50 +0200 (Thu, 18 Sep 2008) | 1 line minor typo and formatting improvements ................ r10869 | wsfulton | 2008-09-18 22:21:17 +0200 (Thu, 18 Sep 2008) | 1 line remove confusion over tab widths ................ r10870 | wsfulton | 2008-09-18 22:27:57 +0200 (Thu, 18 Sep 2008) | 1 line warning fix ................ r10871 | wsfulton | 2008-09-18 22:28:40 +0200 (Thu, 18 Sep 2008) | 1 line formatting fix ................ r10872 | wsfulton | 2008-09-18 22:32:28 +0200 (Thu, 18 Sep 2008) | 1 line Add C# array typemaps provided by Antti Karanta. ................ r10873 | wsfulton | 2008-09-18 22:33:37 +0200 (Thu, 18 Sep 2008) | 1 line revert debug break in last commit ................ r10874 | wsfulton | 2008-09-18 22:39:15 +0200 (Thu, 18 Sep 2008) | 1 line fix unused variable warning ................ r10875 | wsfulton | 2008-09-19 01:17:52 +0200 (Fri, 19 Sep 2008) | 1 line revert entry 2008-09-01 - C# Insert and InsertRange bounds checking ................ r10876 | olly | 2008-09-19 05:20:59 +0200 (Fri, 19 Sep 2008) | 2 lines [PHP5] Add typemaps for long long and unsigned long long. ................ r10877 | olly | 2008-09-19 08:40:39 +0200 (Fri, 19 Sep 2008) | 2 lines Clean out more PHP4 stuff. ................ r10878 | mutandiz | 2008-09-22 20:41:10 +0200 (Mon, 22 Sep 2008) | 1 line [allegrocl] Make type and namespace wrapping more compatible with other modules. cpp test-suite work. ................ r10879 | olly | 2008-09-23 08:52:41 +0200 (Tue, 23 Sep 2008) | 2 lines Remove stray lines ................ r10880 | wsfulton | 2008-09-24 21:28:15 +0200 (Wed, 24 Sep 2008) | 1 line fix clash between php and python when running scripts ................ r10881 | olly | 2008-09-25 09:11:36 +0200 (Thu, 25 Sep 2008) | 2 lines [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186). ................ r10883 | wsfulton | 2008-09-26 07:05:23 +0200 (Fri, 26 Sep 2008) | 1 line typo fix ................ r10884 | bhy | 2008-09-28 11:36:06 +0200 (Sun, 28 Sep 2008) | 1 line merge test case pybuf and benchmark pybuf_benchmark into a single test case ................ r10885 | mutandiz | 2008-09-30 21:45:13 +0200 (Tue, 30 Sep 2008) | 1 line [allegrocl] Various fixes to the generated C wrapper code (enums, constants, function declarations), as I progress through the test-suite. ................ r10886 | olly | 2008-10-01 07:28:45 +0200 (Wed, 01 Oct 2008) | 2 lines Fix non-standard indentation. ................ r10887 | olly | 2008-10-01 13:54:31 +0200 (Wed, 01 Oct 2008) | 4 lines Fix indentation. Use %{ %} in a couple of typemaps to avoid adding needless { } to the generated code. Use memcpy() instead of memmove() where the destination is freshly allocated so there's no possibility of overlap. ................ r10893 | wsfulton | 2008-10-10 00:42:45 +0200 (Fri, 10 Oct 2008) | 1 line suggest starting points for documentation ................ r10896 | wsfulton | 2008-11-01 23:52:26 +0100 (Sat, 01 Nov 2008) | 1 line Add the strip encoder patch from Anatoly Techtonik #2130016 ................ r10897 | wsfulton | 2008-11-02 00:09:26 +0100 (Sun, 02 Nov 2008) | 1 line Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy class being reported for Python docstrings when %rename is used ................ r10898 | wsfulton | 2008-11-03 13:51:45 +0100 (Mon, 03 Nov 2008) | 1 line customised ccache support: read the CCACHE_OUTFILES env variable and if exists, the names of all generated files are written to the filename specified in the env variable ................ r10899 | wsfulton | 2008-11-03 14:32:33 +0100 (Mon, 03 Nov 2008) | 1 line update this README ................ r10900 | wsfulton | 2008-11-03 14:37:28 +0100 (Mon, 03 Nov 2008) | 1 line Import ccache-2.4 source ................ r10901 | wsfulton | 2008-11-03 14:40:57 +0100 (Mon, 03 Nov 2008) | 1 line cvs -> svn ignores ................ r10902 | wsfulton | 2008-11-03 14:49:49 +0100 (Mon, 03 Nov 2008) | 1 line Import patches to ccache-2.4 from debian (ccache-2.4-15) ................ r10903 | wsfulton | 2008-11-03 14:59:23 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/01_no_home.diff ................ r10904 | wsfulton | 2008-11-03 15:02:32 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/02_ccache-compressed.diff ................ r10905 | wsfulton | 2008-11-03 15:02:57 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/04_ignore_profile.diff ................ r10906 | wsfulton | 2008-11-03 15:03:21 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/05_nfs_fix.diff ................ r10907 | wsfulton | 2008-11-03 15:03:52 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/06_md.diff ................ r10908 | wsfulton | 2008-11-03 15:04:15 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/07_cachedirtag.diff ................ r10909 | wsfulton | 2008-11-03 15:04:47 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/08_manpage_hyphens.diff ................ r10910 | wsfulton | 2008-11-03 15:05:12 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/09_respect_ldflags.diff ................ r10911 | wsfulton | 2008-11-03 15:06:06 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/10_lru_cleanup.diff ................ r10912 | wsfulton | 2008-11-03 15:07:51 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/11_utimes.diff ................ r10913 | wsfulton | 2008-11-03 15:08:28 +0100 (Mon, 03 Nov 2008) | 1 line apply debian/patches/12_cachesize_permissions.diff ................ r10915 | wsfulton | 2008-11-05 13:34:15 +0100 (Wed, 05 Nov 2008) | 1 line initial modifications for ccache to support SWIG ................ r10916 | wsfulton | 2008-11-05 17:53:55 +0100 (Wed, 05 Nov 2008) | 1 line fix Makefile for autoconf>2.60 ................ r10917 | wsfulton | 2008-11-05 17:55:07 +0100 (Wed, 05 Nov 2008) | 1 line fix configure.in when running autoreconf ................ r10918 | wsfulton | 2008-11-05 17:57:21 +0100 (Wed, 05 Nov 2008) | 1 line create executable name as ccache-swig instead of ccache to avoid conflict with the official ccache ................ r10919 | wsfulton | 2008-11-05 17:59:27 +0100 (Wed, 05 Nov 2008) | 1 line remove autotool generated files ................ r10920 | wsfulton | 2008-11-07 18:03:57 +0100 (Fri, 07 Nov 2008) | 1 line integrate ccache build ................ r10921 | wsfulton | 2008-11-07 22:25:31 +0100 (Fri, 07 Nov 2008) | 1 line update some comments ................ r10922 | wsfulton | 2008-11-10 11:34:25 +0100 (Mon, 10 Nov 2008) | 1 line ccache clean ................ r10923 | wsfulton | 2008-11-10 13:07:52 +0100 (Mon, 10 Nov 2008) | 1 line rename documentation from ccache to ccache-swig ................ r10924 | wsfulton | 2008-11-10 15:37:45 +0100 (Mon, 10 Nov 2008) | 1 line add in docs about new CCACHE_VERBOSE and CCACHE_SWIG env variables ................ r10925 | wsfulton | 2008-11-10 22:53:15 +0100 (Mon, 10 Nov 2008) | 1 line Add Antti Karanta's documentation about the new c# array marshalling library plus some docs on the carrays library ................ r10926 | wsfulton | 2008-11-11 23:17:40 +0100 (Tue, 11 Nov 2008) | 1 line add parameter list (or void) to all C functions ................ r10927 | wsfulton | 2008-11-11 23:28:18 +0100 (Tue, 11 Nov 2008) | 1 line fix Swig_search_path declaration ................ r10928 | wsfulton | 2008-11-11 23:56:36 +0100 (Tue, 11 Nov 2008) | 1 line Add patch #2152691 from MATSUURA Takanori which fixes compiles using the Intel compiler ................ r10929 | wsfulton | 2008-11-16 22:13:04 +0100 (Sun, 16 Nov 2008) | 1 line Add documentation on typemaps for 'self' based on patch from Art Clarke ................ r10930 | wsfulton | 2008-11-16 22:40:28 +0100 (Sun, 16 Nov 2008) | 1 line Fix -nopreprocess option to correctly generate output filenames and display filenames in warnings and errors ................ r10931 | wsfulton | 2008-11-17 23:43:15 +0100 (Mon, 17 Nov 2008) | 1 line add input and output files to hash for correct operation when swig is the compiler. Automatically detect when swig is the compiler. ................ r10932 | wsfulton | 2008-11-17 23:47:55 +0100 (Mon, 17 Nov 2008) | 1 line rename java run tests from main to runme for consistency across the languages ................ r10933 | wsfulton | 2008-11-19 01:57:09 +0100 (Wed, 19 Nov 2008) | 1 line dont replicate the -nopreprocess command if it is given when using swig as compiler ................ r10934 | wsfulton | 2008-11-20 00:47:53 +0100 (Thu, 20 Nov 2008) | 1 line added swig regression tests for ccache ................ r10935 | wsfulton | 2008-11-22 13:17:48 +0100 (Sat, 22 Nov 2008) | 1 line fix env variable settings and add swig tests ................ r10936 | wsfulton | 2008-11-22 13:29:41 +0100 (Sat, 22 Nov 2008) | 1 line deprecate use of include path to find the input file for behaviour that is compatible with other compilers and interopability for ccache ................ r10937 | wsfulton | 2008-11-22 13:32:51 +0100 (Sat, 22 Nov 2008) | 1 line add ccache install and rename php4 to php ................ r10938 | wsfulton | 2008-11-22 13:35:27 +0100 (Sat, 22 Nov 2008) | 1 line rename php4 to php ................ r10939 | wsfulton | 2008-11-23 20:44:29 +0100 (Sun, 23 Nov 2008) | 1 line gcc-4.3 warning fixes ................ r10940 | wsfulton | 2008-11-23 20:45:31 +0100 (Sun, 23 Nov 2008) | 1 line php4 rename to php fix ................ r10941 | wsfulton | 2008-11-23 22:47:39 +0100 (Sun, 23 Nov 2008) | 1 line error: ‘pthread_once’ was not declared in this scope ................ r10942 | wsfulton | 2008-11-23 22:59:00 +0100 (Sun, 23 Nov 2008) | 1 line Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace. ................ r10943 | wsfulton | 2008-11-23 23:07:15 +0100 (Sun, 23 Nov 2008) | 1 line give operator bool() a name ................ r10944 | wsfulton | 2008-11-23 23:29:07 +0100 (Sun, 23 Nov 2008) | 1 line Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in ruby 1.9. ................ r10945 | wsfulton | 2008-11-24 00:28:37 +0100 (Mon, 24 Nov 2008) | 1 line add sanity check on preprocessed output ................ r10946 | wsfulton | 2008-11-24 00:29:33 +0100 (Mon, 24 Nov 2008) | 1 line remove docs on old php4 switch ................ r10947 | wsfulton | 2008-11-26 00:36:23 +0100 (Wed, 26 Nov 2008) | 1 line Add -outcurrentdir option ................ r10948 | wsfulton | 2008-11-26 19:37:48 +0100 (Wed, 26 Nov 2008) | 1 line gcc-4.3 warning fixes ................ r10949 | wsfulton | 2008-11-26 22:35:15 +0100 (Wed, 26 Nov 2008) | 1 line modify test-suite (barring python atm) to not rely on the -I path to find the input .i file - removes the new warning 125 and sets up the test-suite for testing with ccache. This change required the use of -outcurrentdir and moving the .i files from the language subdirectories to the directory above along with some .i file name changes. ................ r10950 | wsfulton | 2008-11-26 22:44:53 +0100 (Wed, 26 Nov 2008) | 1 line warning fix for when zlib not available ................ r10951 | wsfulton | 2008-11-26 22:54:49 +0100 (Wed, 26 Nov 2008) | 1 line remove svn:executable property where applied incorrectly ................ r10952 | wsfulton | 2008-11-26 22:56:48 +0100 (Wed, 26 Nov 2008) | 1 line remove svn:executable property where applied incorrectly ................ r10953 | wsfulton | 2008-11-26 23:50:35 +0100 (Wed, 26 Nov 2008) | 1 line modifying build system not to rely on the -I path to find the input files avoiding warning 125: move python .i files up one directory, some files have been renamed - prepended with python ................ r10954 | wsfulton | 2008-11-27 00:04:18 +0100 (Thu, 27 Nov 2008) | 1 line modifying build system not to rely on the -I path to find the input files avoiding warning 125: merge .i files that are common between python and the main version ................ r10955 | wsfulton | 2008-11-27 00:25:47 +0100 (Thu, 27 Nov 2008) | 1 line fix test names since they were renamed recently ................ r10956 | wsfulton | 2008-11-29 00:30:45 +0100 (Sat, 29 Nov 2008) | 1 line minor fix to formatting in generated types table ................ r10957 | wsfulton | 2008-11-29 00:33:37 +0100 (Sat, 29 Nov 2008) | 1 line move iadd.h contents into iadd.i ................ r10958 | wsfulton | 2008-11-29 00:35:46 +0100 (Sat, 29 Nov 2008) | 1 line UTL - Fix some incorrect acceptance of types in the STL, eg a double * element passed into a vector<int *> constructor would be accepted, but the ensuing behaviour was undefined. Now the type conversion correctly raises an exception ................ r10959 | wsfulton | 2008-11-29 00:37:13 +0100 (Sat, 29 Nov 2008) | 1 line revert mistaken checkin ................ r10960 | wsfulton | 2008-12-02 21:21:16 +0100 (Tue, 02 Dec 2008) | 1 line Apply patch #2143727 for Python from Serge Monkewitz to fix importing base classes when the package option is specified in %module and that module is %import'ed ................ r10961 | bhy | 2008-12-03 19:43:44 +0100 (Wed, 03 Dec 2008) | 2 lines Commited SF#2158938: change all SWIG symbols start with Py to a new name. ................ r10962 | bhy | 2008-12-03 20:24:06 +0100 (Wed, 03 Dec 2008) | 1 line 2to3 has its way to exclude fixer now, so we nolonger need our hack ................ r10963 | bhy | 2008-12-03 22:36:53 +0100 (Wed, 03 Dec 2008) | 1 line add shebang for pyname_patch.py ................ r10964 | wsfulton | 2008-12-06 18:10:53 +0100 (Sat, 06 Dec 2008) | 1 line add test for inheritance of 3 classes deep which exposes a problem in the python shared_ptr wrappers. Manually added the %types for now. ................ r10965 | wsfulton | 2008-12-06 18:12:05 +0100 (Sat, 06 Dec 2008) | 1 line minor formatting fix ................ r10966 | wsfulton | 2008-12-06 18:18:38 +0100 (Sat, 06 Dec 2008) | 1 line remove SWIG_TypeCheck_Template so that the code within it is debuggable ................ r10967 | wsfulton | 2008-12-06 22:40:54 +0100 (Sat, 06 Dec 2008) | 1 line modify build system to use php instead of php4 ................ r10968 | wsfulton | 2008-12-06 22:55:15 +0100 (Sat, 06 Dec 2008) | 1 line modify build system to use php instead of php4 ................ r10969 | wsfulton | 2008-12-07 00:15:20 +0100 (Sun, 07 Dec 2008) | 1 line remove last vestiges of php4 and encourage use of -php rather than -php5 ................ r10970 | olly | 2008-12-07 01:38:14 +0100 (Sun, 07 Dec 2008) | 2 lines [PHP] Fix warnings when compiling generated wrapper with GCC 4.3. ................ r10971 | wsfulton | 2008-12-07 11:57:43 +0100 (Sun, 07 Dec 2008) | 1 line Clean up gcc-4.3 warnings ................ r10972 | wsfulton | 2008-12-07 14:40:36 +0100 (Sun, 07 Dec 2008) | 1 line Apply autoreconf_fixes.patch sent to debian -- restores documentation changes that the debian patches had if autoreconf is run ................ r10973 | wsfulton | 2008-12-08 21:40:20 +0100 (Mon, 08 Dec 2008) | 1 line Add ccache uninstall target. Fix ccache install/uninstall to take account of --program-prefix --program-suffix ................ r10974 | wsfulton | 2008-12-08 21:41:56 +0100 (Mon, 08 Dec 2008) | 1 line remove long options (which we don't use) from documentation ................ r10975 | wsfulton | 2008-12-09 22:31:31 +0100 (Tue, 09 Dec 2008) | 1 line section name update ................ r10976 | wsfulton | 2008-12-09 22:33:19 +0100 (Tue, 09 Dec 2008) | 1 line refine Makefile targets for documentation generation and remove generated ccache documentation from svn ................ r10977 | wsfulton | 2008-12-09 22:42:51 +0100 (Tue, 09 Dec 2008) | 1 line Add debian patch 13_html_links.diff ................ r10978 | wsfulton | 2008-12-09 22:44:58 +0100 (Tue, 09 Dec 2008) | 1 line add debian patch 14_hardllink_doc.diff ................ r10979 | wsfulton | 2008-12-09 23:27:32 +0100 (Tue, 09 Dec 2008) | 1 line update patches applied ................ r10980 | wsfulton | 2008-12-12 22:10:48 +0100 (Fri, 12 Dec 2008) | 1 line fix display of garbage where it should display an error message in error situations of unterminated string, comment etc within %inline, nested struct etc ................ r10981 | wsfulton | 2008-12-12 22:31:21 +0100 (Fri, 12 Dec 2008) | 1 line Apply patch from Kalyanov Dmitry which fixes parsing of nested structs containing comments ................ r10982 | wsfulton | 2008-12-17 01:21:13 +0100 (Wed, 17 Dec 2008) | 1 line initial win32 support mostly using ccache-win32-2.4 patches to ccache-2.4 ................ r10983 | wsfulton | 2008-12-17 01:25:30 +0100 (Wed, 17 Dec 2008) | 1 line add info about ccache-win32 patches applied ................ r10984 | wsfulton | 2008-12-17 01:28:51 +0100 (Wed, 17 Dec 2008) | 1 line remove cast needed for windows - doesn't work on linux ................ r10985 | wsfulton | 2008-12-17 02:33:00 +0100 (Wed, 17 Dec 2008) | 1 line some html fixes ................ r10986 | wsfulton | 2008-12-17 02:46:52 +0100 (Wed, 17 Dec 2008) | 1 line add ccache to windows build, better fail if executables don't run. Fix documentation build. Remove .cvsignore files removal as we are no longer using cvs. ................ r10987 | wsfulton | 2008-12-19 22:41:05 +0100 (Fri, 19 Dec 2008) | 1 line win32 fixes to pass the ccache test-suite ................ r10988 | wsfulton | 2008-12-20 00:25:40 +0100 (Sat, 20 Dec 2008) | 1 line update ccache man page for ccache-swig ................ r10989 | wsfulton | 2008-12-20 00:29:00 +0100 (Sat, 20 Dec 2008) | 1 line remove some warnings ................ r10990 | wsfulton | 2008-12-20 02:45:11 +0100 (Sat, 20 Dec 2008) | 1 line Add ccache documentation to main docs ................ r10991 | wsfulton | 2008-12-20 02:49:58 +0100 (Sat, 20 Dec 2008) | 1 line new section numbering since adding in ccache chapter ................ r10992 | wsfulton | 2008-12-20 18:20:25 +0100 (Sat, 20 Dec 2008) | 1 line Add Win32 ccache locking from Christophe Gisquet patch http://lists.samba.org/archive/ccache/2006q3/000242.html ................ r10993 | wsfulton | 2008-12-21 00:59:03 +0100 (Sun, 21 Dec 2008) | 1 line possibly slightly faster win32 process spawn from http://lists.samba.org/archive/ccache/2006q3/000242.html ................ r10994 | wsfulton | 2008-12-21 01:29:48 +0100 (Sun, 21 Dec 2008) | 1 line Apply patch #2440046 which fixes possible seg faults for member and global variable char arrays when the strings are larger than the string array size. ................ r10995 | wsfulton | 2008-12-21 01:55:27 +0100 (Sun, 21 Dec 2008) | 1 line Fix some make targets not running on cygwin ................ r10996 | wsfulton | 2008-12-22 00:16:56 +0100 (Mon, 22 Dec 2008) | 1 line Add CCACHE_STRIPC option to remove an unwarranted warning when using ccache with the Solaris Workshop C++ compiler ................ r10997 | wsfulton | 2008-12-22 22:43:48 +0100 (Mon, 22 Dec 2008) | 1 line Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors throw exceptions ................ r10998 | wsfulton | 2008-12-23 08:44:59 +0100 (Tue, 23 Dec 2008) | 1 line Fix #2153773 - %nojavaexception - disabling and clearing Java checked exceptions ................ r10999 | wsfulton | 2008-12-23 23:47:58 +0100 (Tue, 23 Dec 2008) | 1 line typo fix ................ r11000 | wsfulton | 2008-12-24 14:19:55 +0100 (Wed, 24 Dec 2008) | 1 line fix input filename containing a path on windows ................ r11001 | wsfulton | 2008-12-24 15:50:26 +0100 (Wed, 24 Dec 2008) | 1 line accept unix directory separators on windows for input file ................ r11002 | wsfulton | 2008-12-24 15:54:52 +0100 (Wed, 24 Dec 2008) | 1 line minor fixes from last checkin ................ r11003 | wsfulton | 2008-12-24 20:17:16 +0100 (Wed, 24 Dec 2008) | 1 line warning fixes ................ r11004 | wsfulton | 2008-12-24 20:20:54 +0100 (Wed, 24 Dec 2008) | 1 line warning fixes ................ r11005 | wsfulton | 2008-12-25 00:42:39 +0100 (Thu, 25 Dec 2008) | 1 line overlooked build system mods now implemented to remove warning 125 ................ r11006 | wsfulton | 2008-12-28 19:41:16 +0100 (Sun, 28 Dec 2008) | 1 line add strong exception guarantee to SwigValueWrapper ................ r11007 | wsfulton | 2008-12-28 21:16:31 +0100 (Sun, 28 Dec 2008) | 1 line SwigValueWrapper - remove two constructors which are not required by the code SWIG generates ................ r11008 | wsfulton | 2008-12-28 21:32:44 +0100 (Sun, 28 Dec 2008) | 1 line Add boost::intrusive_ptr wrappers from Mike Rowbotham ................ r11009 | wsfulton | 2008-12-28 21:35:22 +0100 (Sun, 28 Dec 2008) | 1 line li_intrusive_ptr test - commented out as not fully working ................ r11010 | wsfulton | 2008-12-28 21:36:21 +0100 (Sun, 28 Dec 2008) | 1 line comment correction ................ r11011 | wsfulton | 2008-12-29 01:11:51 +0100 (Mon, 29 Dec 2008) | 1 line Compiler warning fix in Perl out typemap for std::vector ................ r11012 | wsfulton | 2008-12-29 01:13:19 +0100 (Mon, 29 Dec 2008) | 1 line couple of minor Perl fixes from Ling Li ................ r11013 | drjoe | 2008-12-29 08:05:21 +0100 (Mon, 29 Dec 2008) | 2 lines check for yodl package ................ r11014 | drjoe | 2008-12-29 23:06:50 +0100 (Mon, 29 Dec 2008) | 3 lines allow for compilation with bison 2.4 which is more restrictive about $$ symbols than 2.3 ................ r11015 | drjoe | 2008-12-29 23:25:55 +0100 (Mon, 29 Dec 2008) | 2 lines change as(...,"integer") to as.integer to force conversion into integers ................ r11016 | wsfulton | 2008-12-29 23:56:25 +0100 (Mon, 29 Dec 2008) | 1 line create a common banner header for all target language specific files ................ r11017 | wsfulton | 2008-12-30 00:56:03 +0100 (Tue, 30 Dec 2008) | 1 line add missing language specific preprocessor define where missing for some languages ................ r11018 | wsfulton | 2008-12-30 01:38:34 +0100 (Tue, 30 Dec 2008) | 1 line All languages now define a macro in the generated C/C++ wrapper file indicating which language is being wrapped, eg #define SWIGJAVA ................ r11019 | wsfulton | 2008-12-30 02:14:14 +0100 (Tue, 30 Dec 2008) | 1 line getting ready for 1.3.37 release candidate ................ r11020 | wsfulton | 2008-12-30 11:46:41 +0100 (Tue, 30 Dec 2008) | 1 line remove duplicate SWIGR macro ................ r11021 | wsfulton | 2008-12-30 12:02:59 +0100 (Tue, 30 Dec 2008) | 1 line fix for new SWIGCSHARP defn in wrappers ................ r11022 | wsfulton | 2008-12-30 12:42:52 +0100 (Tue, 30 Dec 2008) | 1 line explicit type warning fix ................ r11023 | wsfulton | 2008-12-31 00:33:35 +0100 (Wed, 31 Dec 2008) | 1 line missing yodl2man should not break the configure stage for users as it is not required as the man pages are shipped with the release tarball ................ r11024 | wsfulton | 2008-12-31 00:50:32 +0100 (Wed, 31 Dec 2008) | 1 line fix ccache-swig man page generation ................ r11025 | wsfulton | 2008-12-31 02:02:16 +0100 (Wed, 31 Dec 2008) | 1 line re-order configure.in into sections for users and developers and requirements for the examples ................ r11026 | wsfulton | 2008-12-31 02:10:49 +0100 (Wed, 31 Dec 2008) | 1 line better #! for finding python ................ r11027 | wsfulton | 2008-12-31 02:11:37 +0100 (Wed, 31 Dec 2008) | 1 line put tagging back in ................ r11028 | wsfulton | 2009-01-03 02:59:42 +0100 (Sat, 03 Jan 2009) | 1 line compile fix on Cygwin ................ r11029 | wsfulton | 2009-01-05 18:19:32 +0100 (Mon, 05 Jan 2009) | 1 line fix up namespaces so that boost, std or std::tr1 can be used for shared_ptr/intrusive_ptr ................ r11030 | olly | 2009-01-05 23:40:07 +0100 (Mon, 05 Jan 2009) | 3 lines Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source code and remove documentation of them. ................ r11031 | wsfulton | 2009-01-06 19:13:57 +0100 (Tue, 06 Jan 2009) | 1 line Fix CCACHE_STRIPC being set when using swig as the compiler. ................ r11032 | wsfulton | 2009-01-07 01:45:04 +0100 (Wed, 07 Jan 2009) | 1 line log internal error wrt CCACHE_OUTFILES env variable ................ r11033 | wsfulton | 2009-01-07 01:50:06 +0100 (Wed, 07 Jan 2009) | 1 line Fix error display when there is a problem with CCACHE_OUTFILES ................ r11034 | wsfulton | 2009-01-07 03:26:34 +0100 (Wed, 07 Jan 2009) | 1 line Fix lack of error logging in some situations and fix failure to work on windows when swig is a pure Win32 (non-cygwin) compile ................ r11035 | wsfulton | 2009-01-07 11:36:00 +0100 (Wed, 07 Jan 2009) | 1 line remove unnecessary logging on Win32 builds ................ r11036 | wsfulton | 2009-01-07 12:24:07 +0100 (Wed, 07 Jan 2009) | 1 line reorder new test ................ r11037 | wsfulton | 2009-01-07 17:54:54 +0100 (Wed, 07 Jan 2009) | 1 line Fix spaces in CCACHE_DIR and probably other places ................ r11038 | wsfulton | 2009-01-07 22:10:46 +0100 (Wed, 07 Jan 2009) | 1 line Rename embedded smart pointer in SwigValueWrapper in order to avoid conflicts with the template type ................ r11039 | wsfulton | 2009-01-08 18:52:15 +0100 (Thu, 08 Jan 2009) | 1 line add some missing stats and logging ................ r11040 | wsfulton | 2009-01-08 20:12:24 +0100 (Thu, 08 Jan 2009) | 1 line missing function declaration fix ................ r11041 | wsfulton | 2009-01-08 20:20:51 +0100 (Thu, 08 Jan 2009) | 1 line correct return type for PyUnicode_GetSize ................ r11042 | wsfulton | 2009-01-08 20:35:13 +0100 (Thu, 08 Jan 2009) | 1 line fix cast of pointer to long ................ r11043 | wsfulton | 2009-01-08 20:46:38 +0100 (Thu, 08 Jan 2009) | 1 line fix cast of pointer to long ................ r11044 | wsfulton | 2009-01-09 00:29:33 +0100 (Fri, 09 Jan 2009) | 1 line minor formatting ................ r11045 | wsfulton | 2009-01-09 23:19:06 +0100 (Fri, 09 Jan 2009) | 1 line warning fix ................ r11046 | xavier98 | 2009-01-10 00:38:14 +0100 (Sat, 10 Jan 2009) | 3 lines Fix octave tests li_std_pair_extra, arrays_global, grouping, struct_value, unions. ................ r11047 | xavier98 | 2009-01-10 01:20:46 +0100 (Sat, 10 Jan 2009) | 6 lines Octave: add {save,load}_{ascii,binary,hdf} functions that silently do nothing; give default operator mappings a more conventional suffix; fix test li_std_string_extra. ................ r11048 | xavier98 | 2009-01-10 01:29:37 +0100 (Sat, 10 Jan 2009) | 3 lines Fix octave test allprotected. ................ r11049 | wsfulton | 2009-01-10 02:15:03 +0100 (Sat, 10 Jan 2009) | 1 line Patch #1992756 from Colin McDonald - %contract not working for classes in namespace ................ r11050 | xavier98 | 2009-01-10 03:17:58 +0100 (Sat, 10 Jan 2009) | 3 lines Octave: fix carrays regression caused by operator suffix change. ................ r11051 | drjoe | 2009-01-11 00:30:10 +0100 (Sun, 11 Jan 2009) | 2 lines add regression test for integers ................ r11052 | drjoe | 2009-01-11 01:08:37 +0100 (Sun, 11 Jan 2009) | 3 lines Fix integer handling in r. unsigned values where getting handled incorrected as reals leading to crashes ................ r11054 | wsfulton | 2009-01-11 18:57:21 +0100 (Sun, 11 Jan 2009) | 1 line more portable pointer in a string comparison ................ r11055 | wsfulton | 2009-01-11 22:32:42 +0100 (Sun, 11 Jan 2009) | 1 line another portability fix ................ r11056 | wsfulton | 2009-01-11 22:37:54 +0100 (Sun, 11 Jan 2009) | 1 line yet better pointer string comparison ................ r11057 | drjoe | 2009-01-12 08:41:38 +0100 (Mon, 12 Jan 2009) | 2 lines Add regression tests for R ................ r11058 | drjoe | 2009-01-12 09:54:36 +0100 (Mon, 12 Jan 2009) | 2 lines fix change to make compatible with integer framework ................ r11059 | drjoe | 2009-01-12 09:57:16 +0100 (Mon, 12 Jan 2009) | 2 lines put in integer fixes ................ r11060 | wsfulton | 2009-01-12 12:42:27 +0100 (Mon, 12 Jan 2009) | 1 line Fix union.i module name and rename to union_parameter.i ................ r11061 | mgossage | 2009-01-13 02:42:25 +0100 (Tue, 13 Jan 2009) | 3 lines [Lua] Added contract support for requiring that unsigned numbers are >=0 Rewrote much of Examples/Lua/embed3. Added a lot of to the Lua documentation. ................ r11062 | wsfulton | 2009-01-13 08:09:27 +0100 (Tue, 13 Jan 2009) | 1 line Fix compilation error when using directors on protected virtual overloaded methods reported by Sam Hendley. ................ r11063 | wsfulton | 2009-01-13 08:11:00 +0100 (Tue, 13 Jan 2009) | 1 line 1.3.37 final touches ................ r11069 | wsfulton | 2009-01-13 19:21:18 +0100 (Tue, 13 Jan 2009) | 1 line bump version to 1.3.38 ................ r11070 | wsfulton | 2009-01-15 08:29:28 +0100 (Thu, 15 Jan 2009) | 1 line Fix segfault when using -perl -v ................ r11072 | bhy | 2009-01-16 02:15:46 +0100 (Fri, 16 Jan 2009) | 1 line fix a wrong indent ................ r11075 | wsfulton | 2009-01-21 19:55:32 +0100 (Wed, 21 Jan 2009) | 1 line correct ccache-swig title in docs ................ r11076 | wsfulton | 2009-01-21 20:06:13 +0100 (Wed, 21 Jan 2009) | 2 lines auto formatting mods ................ r11079 | bhy | 2009-01-24 08:59:46 +0100 (Sat, 24 Jan 2009) | 1 line when doing partialcheck, don't skip any test-suite ................ r11080 | bhy | 2009-01-24 14:15:51 +0100 (Sat, 24 Jan 2009) | 6 lines Replaced all [const] String_or_char * to const_String_or_char_ptr, by the following command: sed -i "s/\(const \)\?String_or_char \*/const_String_or_char_ptr /g" CParse/* Include/* Modules/* Preprocessor/* Swig/* This is a preparation for moving to new DOH, since for strong typed objects we need the const_String_or_char_ptr class to implicit convert to and from String * or const char *. ................ r11083 | bhy | 2009-01-24 15:03:37 +0100 (Sat, 24 Jan 2009) | 3 lines Initialized merge tracking via "svnmerge" with revisions "1-11081" from https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0 ................ r11092 | wsfulton | 2009-01-28 19:45:13 +0100 (Wed, 28 Jan 2009) | 1 line Fix classLookup and enumLookup when the global scope operator is used on objects passed by value ................ r11093 | wsfulton | 2009-01-29 20:25:37 +0100 (Thu, 29 Jan 2009) | 1 line Fix regression introduced in 1.3.37 where the default output directory for target language specific files (in the absence of -outdir) was no longer the same as the generated c/c++ file ................ r11094 | wsfulton | 2009-01-29 22:20:31 +0100 (Thu, 29 Jan 2009) | 1 line remove debugging output ................ r11095 | bhy | 2009-01-30 09:00:38 +0100 (Fri, 30 Jan 2009) | 8 lines Blocked revisions 11084 via svnmerge ........ r11084 | bhy | 2009-01-24 22:24:49 +0800 (Sat, 24 Jan 2009) | 1 line Enforce all SWIG .c source code to compile under C++ compiler ........ ................ r11096 | bhy | 2009-01-30 10:15:35 +0100 (Fri, 30 Jan 2009) | 8 lines Blocked revisions 11087 via svnmerge ........ r11087 | bhy | 2009-01-25 02:16:31 +0800 (Sun, 25 Jan 2009) | 2 lines Removed all extern "C" since all code is compiled under C++ compiler. ........ ................ r11097 | bhy | 2009-01-30 11:27:37 +0100 (Fri, 30 Jan 2009) | 21 lines Merged revisions 11085-11086,11088-11089 via svnmerge from https://swig.svn.sourceforge.net/svnroot/swig/branches/swig-2.0 ........ r11085 | bhy | 2009-01-25 00:21:55 +0800 (Sun, 25 Jan 2009) | 2 lines Fix const-correctness. ........ r11086 | bhy | 2009-01-25 02:08:50 +0800 (Sun, 25 Jan 2009) | 2 lines Correct some function definition in header files, which implementation changed in previous commit caused mismatch. ........ r11088 | bhy | 2009-01-25 02:38:32 +0800 (Sun, 25 Jan 2009) | 1 line minor fix and now SWIG is alive again ........ r11089 | bhy | 2009-01-25 06:07:07 +0800 (Sun, 25 Jan 2009) | 1 line Correct some bug introduced in previous commits. Now SWIG is pretty good with C++ compiler. ........ ................ r11098 | bhy | 2009-01-30 11:32:59 +0100 (Fri, 30 Jan 2009) | 1 line Fix broken caused by merge ................ r11099 | bhy | 2009-01-31 14:38:39 +0100 (Sat, 31 Jan 2009) | 1 line Fix SF#2552048. Remove the 'self' parameter in Python proxy code for static member function. ................ r11100 | bhy | 2009-01-31 15:37:54 +0100 (Sat, 31 Jan 2009) | 1 line Fix SF#2552488: indentation adjust of %pythonappend and %pythonprepend ................ r11101 | wsfulton | 2009-01-31 20:02:10 +0100 (Sat, 31 Jan 2009) | 1 line const / non-const warning fix ................ r11102 | wsfulton | 2009-01-31 20:10:55 +0100 (Sat, 31 Jan 2009) | 1 line fix tab alignment - all tabs in SWIG are 8 chars ................ r11103 | wsfulton | 2009-01-31 20:37:58 +0100 (Sat, 31 Jan 2009) | 1 line finishing touches for 1.3.38 ................ r11104 | wsfulton | 2009-02-01 00:14:02 +0100 (Sun, 01 Feb 2009) | 1 line html fix ................ r11107 | wsfulton | 2009-02-01 01:31:19 +0100 (Sun, 01 Feb 2009) | 1 line bump version to 1.3.39 ................ r11110 | talby | 2009-02-05 16:47:42 +0100 (Thu, 05 Feb 2009) | 1 line Fix SF#2564192 ................ r11111 | wsfulton | 2009-02-07 02:58:39 +0100 (Sat, 07 Feb 2009) | 1 line Apply #2081967 configure changes for mzscheme configure errors and breaking of swig exe build ................ r11116 | wsfulton | 2009-02-07 21:25:54 +0100 (Sat, 07 Feb 2009) | 1 line fix older versions of mzscheme detection ................ r11117 | wsfulton | 2009-02-08 00:44:12 +0100 (Sun, 08 Feb 2009) | 1 line remove gcc warning when using -Wunreachable-code ................ r11123 | wsfulton | 2009-02-08 23:30:10 +0100 (Sun, 08 Feb 2009) | 1 line Fix %feature not working for conversion operators ................ r11124 | wsfulton | 2009-02-08 23:54:58 +0100 (Sun, 08 Feb 2009) | 1 line update old syntax to new _dim0 ................ r11125 | bhy | 2009-02-10 15:21:43 +0100 (Tue, 10 Feb 2009) | 1 line changed the mapped 'SIZE' of buffer interface from the length of raw buffer to number of items in the buffer. So it would be easier to use with type other than 'char' ................ r11126 | wsfulton | 2009-02-12 22:16:03 +0100 (Thu, 12 Feb 2009) | 1 line remove unnecessary temporary variable when wrapping return by reference ................ r11127 | wsfulton | 2009-02-13 08:26:06 +0100 (Fri, 13 Feb 2009) | 1 line Add support for %extend and memberin typemaps ................ r11128 | wsfulton | 2009-02-13 23:42:45 +0100 (Fri, 13 Feb 2009) | 1 line Add %attributeval and %attributestring to attribute.swg library ................ r11129 | wsfulton | 2009-02-17 09:03:22 +0100 (Tue, 17 Feb 2009) | 1 line make clean-test-suite now cleans all languages, not just languages detected at configure time ................ r11130 | wsfulton | 2009-02-17 19:54:56 +0100 (Tue, 17 Feb 2009) | 1 line typemap_namespace.i fix for mzscheme ................ r11131 | wsfulton | 2009-02-17 20:02:04 +0100 (Tue, 17 Feb 2009) | 1 line Fix make partialcheck-mzscheme-test-suite ................ r11132 | wsfulton | 2009-02-17 21:08:57 +0100 (Tue, 17 Feb 2009) | 1 line Fix make partialcheck-ocaml-test-suite ................ r11133 | wsfulton | 2009-02-20 08:52:24 +0100 (Fri, 20 Feb 2009) | 1 line add new %begin directive for inserting code at top of wrapper file ................ r11134 | wsfulton | 2009-02-20 09:03:49 +0100 (Fri, 20 Feb 2009) | 1 line minor correction about %begin ................ r11135 | wsfulton | 2009-02-20 21:55:16 +0100 (Fri, 20 Feb 2009) | 1 line Fix -co option which broke in 1.3.37 SF #2605955 ................ r11136 | wsfulton | 2009-02-21 00:55:37 +0100 (Sat, 21 Feb 2009) | 1 line CFFI - Fix seg faults when for %extend and using statements ................ r11137 | wsfulton | 2009-02-21 01:56:41 +0100 (Sat, 21 Feb 2009) | 1 line Fix seg fault wrapping some constant variable (%constant) types ................ r11139 | olly | 2009-02-26 06:53:37 +0100 (Thu, 26 Feb 2009) | 3 lines Fix several heading underlines to be the same length as the headings. Add a newline after a few headings which were missing it. ................ r11140 | bhy | 2009-02-28 15:02:02 +0100 (Sat, 28 Feb 2009) | 3 lines Fix SF#2637352, move declaration of SWIG_module before the call of SWIG_Python_FixMethods, since some C compiler don't allow declaration in middle of function body. ................ r11141 | bhy | 2009-03-01 10:37:21 +0100 (Sun, 01 Mar 2009) | 1 line Fix SF#2583160. Make swig_import_helper() in shadow wrapper able to deal with the case that module already imported at other place. ................ r11142 | bhy | 2009-03-02 17:35:12 +0100 (Mon, 02 Mar 2009) | 1 line Add searching for Python 3.1 in configure.in ................ r11143 | bhy | 2009-03-02 18:56:29 +0100 (Mon, 02 Mar 2009) | 1 line Fixes to support Python 3.0.1 and higher. ................ r11148 | wsfulton | 2009-03-11 22:01:55 +0100 (Wed, 11 Mar 2009) | 1 line undef bind for win32, problem reported by vondruch ................ r11150 | wsfulton | 2009-03-12 21:41:56 +0100 (Thu, 12 Mar 2009) | 1 line Fix #2676738 SWIG generated symbol name clashes. ................ r11151 | bhy | 2009-03-16 12:10:29 +0100 (Mon, 16 Mar 2009) | 1 line Remove an nonsense Py_INCREF. ................ r11152 | wsfulton | 2009-03-16 18:42:30 +0100 (Mon, 16 Mar 2009) | 1 line vc++ warning fixes ................ r11153 | wsfulton | 2009-03-16 20:33:38 +0100 (Mon, 16 Mar 2009) | 1 line add in correct specialization for std::vector<bool> to follow C++ standard - to create compileable wrappers with vc++ and recent return by reference changes ................ r11154 | wsfulton | 2009-03-16 22:39:36 +0100 (Mon, 16 Mar 2009) | 1 line minor rewrite ................ r11156 | wsfulton | 2009-03-19 00:30:57 +0100 (Thu, 19 Mar 2009) | 1 line std::vector<T> wrapper improvements for .NET 2 implementing IEnumerable<T> ................ r11157 | wsfulton | 2009-03-19 00:54:09 +0100 (Thu, 19 Mar 2009) | 1 line Add possibility of using when using shared_ptr and wrapping pointers ................ r11158 | wsfulton | 2009-03-19 01:04:28 +0100 (Thu, 19 Mar 2009) | 1 line remove debug comment ................ r11159 | bhy | 2009-03-19 15:20:38 +0100 (Thu, 19 Mar 2009) | 1 line Fix wrong year in changelog date ................ r11160 | bhy | 2009-03-19 16:26:57 +0100 (Thu, 19 Mar 2009) | 1 line Fix the memory leak related to Python 3 unicode and char * conversion. ................ r11161 | bhy | 2009-03-19 17:56:01 +0100 (Thu, 19 Mar 2009) | 1 line Fix problem caused by thread not properly terminated in director_thread test. This was cause crash in Python 3 ................ r11163 | wsfulton | 2009-03-21 00:29:36 +0100 (Sat, 21 Mar 2009) | 1 line final touches for 1.3.39 release ................ r11164 | wsfulton | 2009-03-21 00:35:52 +0100 (Sat, 21 Mar 2009) | 1 line add summary for 1.3.39 release ................ r11165 | wsfulton | 2009-03-21 00:40:39 +0100 (Sat, 21 Mar 2009) | 1 line Apply small documentation fix - patch #2579863 ................ r11166 | wsfulton | 2009-03-21 00:54:43 +0100 (Sat, 21 Mar 2009) | 1 line invoke using swig.exe instead of just swig in Visual Studio project files ................ r11169 | wsfulton | 2009-03-21 02:42:37 +0100 (Sat, 21 Mar 2009) | 1 line remove out of date info ................ r11170 | wsfulton | 2009-03-21 02:45:41 +0100 (Sat, 21 Mar 2009) | 1 line bump version to 1.3.40 ................ r11174 | olly | 2009-03-30 01:38:19 +0200 (Mon, 30 Mar 2009) | 7 lines Some distros (e.g. frugalware) build PHP with --enable-safe-mode, so as we need to explicitly disable it to avoid the testsuite failing with: Warning: dl(): Dynamically loaded extensions aren't allowed when running in Safe Mode Patch from Miklos Vajna. ................ r11175 | olly | 2009-03-30 04:01:12 +0200 (Mon, 30 Mar 2009) | 2 lines check::equal() now reports the values if they aren't equal. ................ r11176 | olly | 2009-03-30 04:22:14 +0200 (Mon, 30 Mar 2009) | 5 lines The default out typemap for char[ANY] now returns up to a zero byte, or the end of the array if there is no zero byte. This is the same as Python does, and seems more generally useful than the previous behaviour of returning the whole contents of the array including any zero bytes. ................ r11177 | olly | 2009-03-30 04:49:13 +0200 (Mon, 30 Mar 2009) | 2 lines Document the previous change. ................ r11178 | olly | 2009-03-31 12:25:54 +0200 (Tue, 31 Mar 2009) | 2 lines printf(string) -> printf("%s", string) ................ r11179 | wsfulton | 2009-03-31 14:23:47 +0200 (Tue, 31 Mar 2009) | 1 line don't unnecessarily set swigCPtr to zero again if Dispose/delete called multiple times ................ r11182 | wsfulton | 2009-04-01 10:41:41 +0200 (Wed, 01 Apr 2009) | 1 line update .dll -> .pyd for python ................ r11183 | wsfulton | 2009-04-01 14:46:26 +0200 (Wed, 01 Apr 2009) | 1 line fix ordering of chapters ................ r11185 | wsfulton | 2009-04-09 19:51:59 +0200 (Thu, 09 Apr 2009) | 1 line Fix #2746858 - C macro expression using floating point numbers ................ r11191 | wsfulton | 2009-04-21 22:09:15 +0200 (Tue, 21 Apr 2009) | 1 line Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation. ................ r11192 | olly | 2009-04-29 11:35:58 +0200 (Wed, 29 Apr 2009) | 7 lines [Python] Don't attempt to acquire the GIL in situations where we know that it will already be locked. This avoids some dead-locks with mod_python (due to mod_python bugs which are apparently unlikely to ever be fixed), and results in smaller wrappers which run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04, the stripped wrapper library was 11% smaller and ran 2.7% faster). ................ r11193 | olly | 2009-04-29 14:00:38 +0200 (Wed, 29 Apr 2009) | 2 lines Fix comment typos ................ r11194 | bhy | 2009-04-29 14:05:33 +0200 (Wed, 29 Apr 2009) | 1 line fix of unclear comment regarding Python 3 tp_compare removal ................ r11195 | olly | 2009-04-29 15:43:23 +0200 (Wed, 29 Apr 2009) | 2 lines int -> Py_ssize_t to fix 64 bit Python 3 failure to compile generated code ................ r11196 | wsfulton | 2009-04-29 19:58:32 +0200 (Wed, 29 Apr 2009) | 1 line Add the 'notderived' attribute to the javabase and csbase typemaps ................ r11197 | olly | 2009-04-30 01:59:06 +0200 (Thu, 30 Apr 2009) | 2 lines Remove two accidentally committed debug fprintf() calls. ................ r11198 | olly | 2009-04-30 02:13:14 +0200 (Thu, 30 Apr 2009) | 2 lines Remove accidentally committed conflict marker. ................ r11199 | wsfulton | 2009-04-30 08:12:32 +0200 (Thu, 30 Apr 2009) | 1 line add test for optimal attribute in out typemap ................ r11200 | wsfulton | 2009-05-01 08:21:56 +0200 (Fri, 01 May 2009) | 1 line remove executable bits ................ r11201 | wsfulton | 2009-05-01 08:26:42 +0200 (Fri, 01 May 2009) | 1 line Add test for notderived attribute in csbase/javabase typemap ................ r11205 | wsfulton | 2009-05-05 23:03:25 +0200 (Tue, 05 May 2009) | 1 line minor formatting mod ................ r11206 | wsfulton | 2009-05-05 23:11:11 +0200 (Tue, 05 May 2009) | 1 line minor formatting mod 2 ................ r11209 | wsfulton | 2009-05-11 19:46:51 +0200 (Mon, 11 May 2009) | 1 line Improved std::vector wrappers on the C# proxy side from Yuval Baror to implement IList<> instead of IEnumerable<> where possible. ................ r11210 | wsfulton | 2009-05-12 19:24:01 +0200 (Tue, 12 May 2009) | 1 line move std::multimap tests from li_std_map.i into new li_std_multimap.i ................ r11212 | mutandiz | 2009-05-14 02:35:17 +0200 (Thu, 14 May 2009) | 1 line [allegrocl] Minor tweak to improve wrapping in -nocwrap mode. ................ r11213 | bhy | 2009-05-14 17:58:09 +0200 (Thu, 14 May 2009) | 1 line fixed the wrong pointer value returned by SwigPyObject_repr() ................ r11214 | wsfulton | 2009-05-17 22:28:43 +0200 (Sun, 17 May 2009) | 1 line fix link ................ r11215 | olly | 2009-05-19 13:54:40 +0200 (Tue, 19 May 2009) | 2 lines Snip nonsensical comment left over from cut and paste from other examples. ................ r11216 | olly | 2009-05-19 14:00:48 +0200 (Tue, 19 May 2009) | 2 lines Remove note which is no longer relevant. ................ r11230 | wsfulton | 2009-05-22 08:10:52 +0200 (Fri, 22 May 2009) | 1 line std::map improvements based on patch from Yuval Baror ................ r11231 | wsfulton | 2009-05-22 08:11:45 +0200 (Fri, 22 May 2009) | 1 line use instead of self ................ r11232 | wsfulton | 2009-05-22 08:53:20 +0200 (Fri, 22 May 2009) | 1 line Improve C# std::map tests to do the bulk of the testing on a map where the key and value types are different ................ r11233 | wsfulton | 2009-05-26 08:23:39 +0200 (Tue, 26 May 2009) | 1 line Add std::vector copy constructor to proxy ................ r11234 | wsfulton | 2009-05-26 08:28:20 +0200 (Tue, 26 May 2009) | 1 line Add copy constructor to std::map and make more efficient by passing keys and mapped type by reference instead of value ................ r11235 | wsfulton | 2009-05-26 08:31:04 +0200 (Tue, 26 May 2009) | 1 line remove authors - these are in the CHANGES files and README files ................ r11236 | wsfulton | 2009-05-26 19:08:53 +0200 (Tue, 26 May 2009) | 1 line std::map C# improvements ................ r11237 | wsfulton | 2009-05-28 00:04:19 +0200 (Thu, 28 May 2009) | 1 line add test for $descriptor() macro ................ r11238 | wsfulton | 2009-05-28 00:55:14 +0200 (Thu, 28 May 2009) | 1 line add missing file omitted in earlier commit ................ r11239 | wsfulton | 2009-05-28 01:39:46 +0200 (Thu, 28 May 2009) | 1 line minor formatting ................ r11240 | wsfulton | 2009-05-29 19:42:49 +0200 (Fri, 29 May 2009) | 1 line trailing comma fix for ISOC89 compliance - patch from Ben Schmeckpeper ................ r11241 | wsfulton | 2009-05-29 19:44:20 +0200 (Fri, 29 May 2009) | 1 line minor format improvment ................ r11244 | talby | 2009-06-02 23:13:03 +0200 (Tue, 02 Jun 2009) | 2 lines bugfix for Lib/perl5/reference.i (test-suite enhancements coming soon). ................ r11246 | wsfulton | 2009-06-05 19:19:29 +0200 (Fri, 05 Jun 2009) | 1 line remove extra lookup of directorout typemap ................ r11247 | talby | 2009-06-05 20:47:30 +0200 (Fri, 05 Jun 2009) | 2 lines reference.i improvements, testcase coverage. language specific interface support for test-suite. ................ r11259 | olly | 2009-06-15 14:27:21 +0200 (Mon, 15 Jun 2009) | 6 lines Remove non-standard targets makecpptests, makectests, maketests, runcpptests, runctests, runtests - the C ones at least don't work properly, and haven't for a long time. Remove explicit use of bash from missingcpptests and missingctests as it isn't required and bash may not be available. ................ r11279 | wsfulton | 2009-06-16 21:29:08 +0200 (Tue, 16 Jun 2009) | 1 line fix Java and C# enums when one of the enum items is ignored ................ r11280 | wsfulton | 2009-06-16 22:26:28 +0200 (Tue, 16 Jun 2009) | 1 line remove perl specific modifications to the enum_thorough test ................ r11281 | wsfulton | 2009-06-16 22:39:53 +0200 (Tue, 16 Jun 2009) | 1 line fix error in bug reporter for enums and %ignore ................ r11282 | wsfulton | 2009-06-17 08:50:39 +0200 (Wed, 17 Jun 2009) | 1 line better clarification for %include and #include and %module ................ r11283 | wsfulton | 2009-06-17 08:56:55 +0200 (Wed, 17 Jun 2009) | 1 line quote %include statements ................ r11285 | wsfulton | 2009-06-19 00:36:39 +0200 (Fri, 19 Jun 2009) | 1 line add further clarification about modules ................ r11287 | wsfulton | 2009-06-20 02:32:49 +0200 (Sat, 20 Jun 2009) | 1 line a bit more on what is in a module ................ git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2008-jezabek@11293 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--ANNOUNCE22
-rw-r--r--CCache/COPYING339
-rw-r--r--CCache/Makefile.in73
-rw-r--r--CCache/README31
-rw-r--r--CCache/README.swig8
-rw-r--r--CCache/args.c91
-rw-r--r--CCache/ccache.c1388
-rw-r--r--CCache/ccache.h205
-rw-r--r--CCache/ccache.yo422
-rw-r--r--CCache/ccache_swig_config.h.in1
-rw-r--r--CCache/cleanup.c193
-rw-r--r--CCache/configure.in87
-rw-r--r--CCache/debian/NEWS22
-rw-r--r--CCache/debian/README.Debian59
-rw-r--r--CCache/debian/changelog221
-rw-r--r--CCache/debian/compat1
-rw-r--r--CCache/debian/control20
-rw-r--r--CCache/debian/copyright29
-rw-r--r--CCache/debian/dirs3
-rw-r--r--CCache/debian/docs1
-rw-r--r--CCache/debian/examples2
-rw-r--r--CCache/debian/patches/01_no_home.diff100
-rw-r--r--CCache/debian/patches/02_ccache-compressed.diff1026
-rw-r--r--CCache/debian/patches/03_long_options.diff133
-rw-r--r--CCache/debian/patches/04_ignore_profile.diff13
-rw-r--r--CCache/debian/patches/05_nfs_fix.diff45
-rw-r--r--CCache/debian/patches/06_md.diff77
-rw-r--r--CCache/debian/patches/07_cachedirtag.diff75
-rw-r--r--CCache/debian/patches/08_manpage_hyphens.diff89
-rw-r--r--CCache/debian/patches/09_respect_ldflags.diff11
-rw-r--r--CCache/debian/patches/10_lru_cleanup.diff23
-rw-r--r--CCache/debian/patches/11_utimes.diff85
-rw-r--r--CCache/debian/patches/12_cachesize_permissions.diff83
-rw-r--r--CCache/debian/patches/13_html_links.diff33
-rw-r--r--CCache/debian/patches/14_hardlink_doc.diff48
-rw-r--r--CCache/debian/patches/CREDITS47
-rw-r--r--CCache/debian/rules141
-rw-r--r--CCache/debian/update-ccache43
-rw-r--r--CCache/debian/watch2
-rw-r--r--CCache/execute.c286
-rw-r--r--CCache/hash.c80
-rwxr-xr-xCCache/install-sh238
-rw-r--r--CCache/mdfour.c284
-rw-r--r--CCache/mdfour.h36
-rw-r--r--CCache/packaging/README5
-rw-r--r--CCache/packaging/ccache.spec37
-rw-r--r--CCache/snprintf.c962
-rw-r--r--CCache/stats.c361
-rwxr-xr-xCCache/test.sh452
-rw-r--r--CCache/unify.c307
-rw-r--r--CCache/util.c884
-rw-r--r--CCache/web/index.html158
-rw-r--r--CHANGES508
-rw-r--r--CHANGES.current122
-rw-r--r--[-rwxr-xr-x]Doc/Manual/Allegrocl.html112
-rw-r--r--Doc/Manual/Arguments.html2
-rw-r--r--Doc/Manual/CSharp.html374
-rw-r--r--Doc/Manual/Contents.html73
-rw-r--r--Doc/Manual/Customization.html14
-rw-r--r--Doc/Manual/Extending.html9
-rw-r--r--Doc/Manual/Introduction.html3
-rw-r--r--Doc/Manual/Java.html45
-rw-r--r--Doc/Manual/Library.html6
-rw-r--r--Doc/Manual/Lisp.html4
-rw-r--r--Doc/Manual/Lua.html312
-rw-r--r--Doc/Manual/Makefile13
-rw-r--r--Doc/Manual/Modula3.html8
-rw-r--r--Doc/Manual/Modules.html133
-rw-r--r--Doc/Manual/Ocaml.html4
-rw-r--r--Doc/Manual/Perl5.html4
-rw-r--r--Doc/Manual/Php.html22
-rw-r--r--Doc/Manual/Preprocessor.html11
-rw-r--r--Doc/Manual/Python.html270
-rw-r--r--Doc/Manual/Ruby.html4
-rw-r--r--Doc/Manual/SWIG.html58
-rw-r--r--Doc/Manual/Sections.html3
-rw-r--r--Doc/Manual/Tcl.html4
-rw-r--r--Doc/Manual/Typemaps.html62
-rw-r--r--Doc/Manual/Warnings.html2
-rw-r--r--Doc/Manual/Windows.html2
-rw-r--r--Doc/Manual/chapters1
-rw-r--r--[-rwxr-xr-x]Doc/Manual/swig16.pngbin5538 -> 5538 bytes
-rw-r--r--Doc/README3
-rw-r--r--Examples/GIFPlot/Java/full/README6
-rw-r--r--Examples/GIFPlot/Java/full/runme.java (renamed from Examples/GIFPlot/Java/full/main.java)2
-rw-r--r--Examples/GIFPlot/Java/shadow/Makefile5
-rw-r--r--Examples/GIFPlot/Java/shadow/README4
-rw-r--r--Examples/GIFPlot/Java/shadow/runme.java (renamed from Examples/GIFPlot/Java/shadow/main.java)2
-rw-r--r--Examples/GIFPlot/Java/simple/README2
-rw-r--r--Examples/GIFPlot/Java/simple/runme.java (renamed from Examples/GIFPlot/Java/simple/main.java)2
-rw-r--r--Examples/GIFPlot/Lib/color.c5
-rw-r--r--Examples/GIFPlot/Lib/gif.c8
-rw-r--r--Examples/GIFPlot/Perl5/shadow/Makefile7
-rw-r--r--Examples/GIFPlot/Php/check.list (renamed from Examples/GIFPlot/Php4/check.list)0
-rw-r--r--Examples/GIFPlot/Php/full/Makefile (renamed from Examples/GIFPlot/Php4/full/Makefile)4
-rw-r--r--Examples/GIFPlot/Php/full/README (renamed from Examples/GIFPlot/Php4/full/README)0
-rw-r--r--Examples/GIFPlot/Php/full/cmap (renamed from Examples/GIFPlot/Php4/full/cmap)bin768 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Php/full/gifplot.i (renamed from Examples/GIFPlot/Php4/full/gifplot.i)0
-rw-r--r--Examples/GIFPlot/Php/full/runme.php (renamed from Examples/GIFPlot/Php4/full/runme.php4)0
-rw-r--r--Examples/GIFPlot/Php/shadow/Makefile (renamed from Examples/GIFPlot/Php4/shadow/Makefile)4
-rw-r--r--Examples/GIFPlot/Php/shadow/README (renamed from Examples/GIFPlot/Php4/shadow/README)0
-rw-r--r--Examples/GIFPlot/Php/shadow/cmap (renamed from Examples/GIFPlot/Php4/shadow/cmap)bin768 -> 768 bytes
-rw-r--r--Examples/GIFPlot/Php/shadow/runme.php (renamed from Examples/GIFPlot/Php4/shadow/runme.php4)0
-rw-r--r--Examples/GIFPlot/Php/simple/Makefile (renamed from Examples/GIFPlot/Php4/simple/Makefile)4
-rw-r--r--Examples/GIFPlot/Php/simple/README (renamed from Examples/GIFPlot/Php4/simple/README)0
-rw-r--r--Examples/GIFPlot/Php/simple/runme.php (renamed from Examples/GIFPlot/Php4/simple/runme.php4)0
-rw-r--r--Examples/GIFPlot/Php/simple/simple.i (renamed from Examples/GIFPlot/Php4/simple/simple.i)0
-rw-r--r--Examples/GIFPlot/Python/full/Makefile3
-rw-r--r--Examples/GIFPlot/Python/shadow/Makefile10
-rw-r--r--Examples/GIFPlot/Python/simple/Makefile3
-rw-r--r--Examples/GIFPlot/Ruby/shadow/Makefile7
-rw-r--r--Examples/Makefile.in252
-rw-r--r--Examples/csharp/arrays/Makefile20
-rw-r--r--Examples/csharp/arrays/example.c22
-rw-r--r--Examples/csharp/arrays/example.h4
-rw-r--r--Examples/csharp/arrays/example.i45
-rw-r--r--Examples/csharp/arrays/runme.cs43
-rw-r--r--Examples/csharp/check.list1
-rw-r--r--[-rwxr-xr-x]Examples/guile/matrix/matrix.scm0
-rw-r--r--Examples/java/callback/runme.java (renamed from Examples/java/callback/main.java)2
-rw-r--r--Examples/java/class/index.html2
-rw-r--r--Examples/java/class/runme.java (renamed from Examples/java/class/main.java)2
-rw-r--r--Examples/java/constants/index.html2
-rw-r--r--Examples/java/constants/runme.java (renamed from Examples/java/constants/main.java)2
-rw-r--r--Examples/java/enum/index.html2
-rw-r--r--Examples/java/enum/runme.java (renamed from Examples/java/enum/main.java)2
-rw-r--r--Examples/java/extend/runme.java (renamed from Examples/java/extend/main.java)2
-rw-r--r--Examples/java/funcptr/index.html2
-rw-r--r--Examples/java/funcptr/runme.java (renamed from Examples/java/funcptr/main.java)2
-rw-r--r--Examples/java/index.html4
-rw-r--r--Examples/java/multimap/runme.java (renamed from Examples/java/multimap/main.java)2
-rw-r--r--Examples/java/native/index.html2
-rw-r--r--Examples/java/native/runme.java (renamed from Examples/java/native/main.java)2
-rw-r--r--Examples/java/pointer/index.html2
-rw-r--r--Examples/java/pointer/runme.java (renamed from Examples/java/pointer/main.java)2
-rw-r--r--Examples/java/reference/index.html2
-rw-r--r--Examples/java/reference/runme.java (renamed from Examples/java/reference/main.java)2
-rw-r--r--Examples/java/simple/index.html8
-rw-r--r--Examples/java/simple/runme.java (renamed from Examples/java/simple/main.java)2
-rw-r--r--Examples/java/template/index.html2
-rw-r--r--Examples/java/template/runme.java (renamed from Examples/java/template/main.java)2
-rw-r--r--Examples/java/typemap/index.html2
-rw-r--r--Examples/java/typemap/runme.java (renamed from Examples/java/typemap/main.java)2
-rw-r--r--Examples/java/variables/index.html2
-rw-r--r--Examples/java/variables/runme.java (renamed from Examples/java/variables/main.java)2
-rw-r--r--Examples/lua/embed3/embed3.cpp7
-rw-r--r--Examples/perl5/class/example.dsp4
-rw-r--r--Examples/perl5/import/bar.dsp4
-rw-r--r--Examples/perl5/import/base.dsp4
-rw-r--r--Examples/perl5/import/foo.dsp4
-rw-r--r--Examples/perl5/import/spam.dsp4
-rw-r--r--Examples/perl5/multimap/example.dsp4
-rw-r--r--Examples/perl5/simple/example.dsp4
-rw-r--r--Examples/php/check.list (renamed from Examples/php4/check.list)0
-rw-r--r--Examples/php/class/Makefile (renamed from Examples/php4/enum/Makefile)10
-rw-r--r--Examples/php/class/example.cxx (renamed from Examples/php4/class/example.cxx)0
-rw-r--r--Examples/php/class/example.h (renamed from Examples/php4/class/example.h)0
-rw-r--r--Examples/php/class/example.i (renamed from Examples/php4/class/example.i)0
-rw-r--r--Examples/php/class/runme.php (renamed from Examples/php4/class/runme.php4)0
-rw-r--r--Examples/php/constants/Makefile (renamed from Examples/php4/constants/Makefile)10
-rw-r--r--Examples/php/constants/example.i (renamed from Examples/php4/constants/example.i)0
-rw-r--r--Examples/php/constants/runme.php (renamed from Examples/php4/constants/runme.php4)0
-rw-r--r--Examples/php/cpointer/Makefile (renamed from Examples/php4/simple/Makefile)10
-rw-r--r--Examples/php/cpointer/example.c (renamed from Examples/php4/cpointer/example.c)0
-rw-r--r--Examples/php/cpointer/example.i (renamed from Examples/php4/cpointer/example.i)0
-rw-r--r--Examples/php/cpointer/runme.php (renamed from Examples/php4/cpointer/runme.php4)0
-rw-r--r--Examples/php/disown/Makefile (renamed from Examples/php4/proxy/Makefile)10
-rw-r--r--Examples/php/disown/example.cxx (renamed from Examples/php4/disown/example.cxx)0
-rw-r--r--Examples/php/disown/example.h (renamed from Examples/php4/disown/example.h)0
-rw-r--r--Examples/php/disown/example.i (renamed from Examples/php4/disown/example.i)0
-rw-r--r--Examples/php/disown/runme.php (renamed from Examples/php4/disown/runme.php4)0
-rw-r--r--Examples/php/enum/Makefile (renamed from Examples/php4/class/Makefile)10
-rw-r--r--Examples/php/enum/example.cxx (renamed from Examples/php4/enum/example.cxx)0
-rw-r--r--Examples/php/enum/example.h (renamed from Examples/php4/enum/example.h)0
-rw-r--r--Examples/php/enum/example.i (renamed from Examples/php4/enum/example.i)0
-rw-r--r--Examples/php/enum/runme.php (renamed from Examples/php4/enum/runme.php4)0
-rw-r--r--Examples/php/funcptr/Makefile (renamed from Examples/php4/funcptr/Makefile)10
-rw-r--r--Examples/php/funcptr/example.c (renamed from Examples/php4/funcptr/example.c)0
-rw-r--r--Examples/php/funcptr/example.h (renamed from Examples/php4/funcptr/example.h)0
-rw-r--r--Examples/php/funcptr/example.i (renamed from Examples/php4/funcptr/example.i)0
-rw-r--r--Examples/php/funcptr/runme.php (renamed from Examples/php4/funcptr/runme.php4)0
-rw-r--r--Examples/php/overloading/Makefile (renamed from Examples/php4/sync/Makefile)10
-rw-r--r--Examples/php/overloading/example.cxx (renamed from Examples/php4/overloading/example.cxx)10
-rw-r--r--Examples/php/overloading/example.h (renamed from Examples/php4/overloading/example.h)10
-rw-r--r--Examples/php/overloading/example.i (renamed from Examples/php4/overloading/example.i)0
-rw-r--r--Examples/php/overloading/runme.php (renamed from Examples/php4/overloading/runme.php4)0
-rw-r--r--Examples/php/pointer/Makefile (renamed from Examples/php4/cpointer/Makefile)10
-rw-r--r--Examples/php/pointer/example.c (renamed from Examples/php4/pointer/example.c)0
-rw-r--r--Examples/php/pointer/example.i (renamed from Examples/php4/pointer/example.i)0
-rw-r--r--Examples/php/pointer/runme.php (renamed from Examples/php4/pointer/runme.php4)0
-rw-r--r--Examples/php/pragmas/Makefile (renamed from Examples/php4/pragmas/Makefile)10
-rw-r--r--Examples/php/pragmas/example.i (renamed from Examples/php4/pragmas/example.i)8
-rw-r--r--Examples/php/pragmas/include.php (renamed from Examples/php4/pragmas/include.php)0
-rwxr-xr-xExamples/php/pragmas/runme.php (renamed from Examples/php4/pragmas/runme.php4)0
-rw-r--r--Examples/php/proxy/Makefile (renamed from Examples/php4/overloading/Makefile)10
-rw-r--r--Examples/php/proxy/example.cxx (renamed from Examples/php4/proxy/example.cxx)0
-rw-r--r--Examples/php/proxy/example.h (renamed from Examples/php4/proxy/example.h)0
-rw-r--r--Examples/php/proxy/example.i (renamed from Examples/php4/proxy/example.i)0
-rw-r--r--Examples/php/proxy/runme.php (renamed from Examples/php4/proxy/runme.php4)0
-rw-r--r--Examples/php/reference/Makefile (renamed from Examples/php4/reference/Makefile)10
-rw-r--r--Examples/php/reference/example.cxx (renamed from Examples/php4/reference/example.cxx)0
-rw-r--r--Examples/php/reference/example.h (renamed from Examples/php4/reference/example.h)0
-rw-r--r--Examples/php/reference/example.i (renamed from Examples/php4/reference/example.i)0
-rw-r--r--Examples/php/reference/runme-proxy.php4 (renamed from Examples/php4/reference/runme-proxy.php4)0
-rw-r--r--Examples/php/reference/runme.php (renamed from Examples/php4/reference/runme.php4)0
-rw-r--r--Examples/php/simple/Makefile (renamed from Examples/php4/pointer/Makefile)10
-rw-r--r--Examples/php/simple/example.c (renamed from Examples/php4/simple/example.c)0
-rw-r--r--Examples/php/simple/example.i (renamed from Examples/php4/simple/example.i)0
-rwxr-xr-xExamples/php/simple/runme.php (renamed from Examples/php4/simple/runme.php4)0
-rw-r--r--Examples/php/sync/Makefile (renamed from Examples/php4/disown/Makefile)10
-rw-r--r--Examples/php/sync/example.cxx (renamed from Examples/php4/sync/example.cxx)2
-rw-r--r--Examples/php/sync/example.h (renamed from Examples/php4/sync/example.h)0
-rw-r--r--Examples/php/sync/example.i (renamed from Examples/php4/sync/example.i)0
-rw-r--r--Examples/php/sync/runme.php (renamed from Examples/php4/sync/runme.php4)0
-rw-r--r--Examples/php/value/Makefile (renamed from Examples/php4/value/Makefile)10
-rw-r--r--Examples/php/value/example.c (renamed from Examples/php4/value/example.c)0
-rw-r--r--Examples/php/value/example.h (renamed from Examples/php4/value/example.h)0
-rw-r--r--Examples/php/value/example.i (renamed from Examples/php4/value/example.i)0
-rw-r--r--Examples/php/value/runme.php (renamed from Examples/php4/value/runme.php4)0
-rw-r--r--Examples/php/variables/Makefile24
-rw-r--r--Examples/php/variables/example.c (renamed from Examples/php4/variables/example.c)0
-rw-r--r--Examples/php/variables/example.h (renamed from Examples/php4/variables/example.h)0
-rw-r--r--Examples/php/variables/example.i (renamed from Examples/php4/variables/example.i)0
-rw-r--r--Examples/php/variables/runme.php (renamed from Examples/php4/variables/runme.php4)0
-rw-r--r--Examples/php/variables/runme.php4.old (renamed from Examples/php4/variables/runme.php4.old)0
-rw-r--r--Examples/php4/variables/Makefile24
-rw-r--r--[-rwxr-xr-x]Examples/pike/class/Makefile0
-rw-r--r--[-rwxr-xr-x]Examples/pike/class/example.cxx0
-rw-r--r--[-rwxr-xr-x]Examples/pike/class/example.h0
-rw-r--r--[-rwxr-xr-x]Examples/pike/class/example.i0
-rw-r--r--[-rwxr-xr-x]Examples/pike/constants/Makefile0
-rw-r--r--[-rwxr-xr-x]Examples/pike/constants/example.i0
-rw-r--r--[-rwxr-xr-x]Examples/pike/overload/example.cxx0
-rw-r--r--[-rwxr-xr-x]Examples/pike/overload/example.h0
-rw-r--r--[-rwxr-xr-x]Examples/pike/template/Makefile0
-rw-r--r--[-rwxr-xr-x]Examples/pike/template/example.h0
-rw-r--r--[-rwxr-xr-x]Examples/pike/template/example.i0
-rw-r--r--Examples/python/callback/Makefile1
-rw-r--r--Examples/python/callback/runme.py2
-rw-r--r--Examples/python/class/Makefile1
-rw-r--r--Examples/python/class/example.dsp4
-rw-r--r--Examples/python/constants/Makefile1
-rw-r--r--Examples/python/contract/Makefile1
-rw-r--r--Examples/python/contract/example.dsp4
-rw-r--r--Examples/python/docstrings/Makefile1
-rw-r--r--Examples/python/enum/Makefile1
-rw-r--r--Examples/python/exception/Makefile1
-rw-r--r--Examples/python/exceptproxy/Makefile1
-rw-r--r--Examples/python/extend/Makefile1
-rw-r--r--Examples/python/funcptr/Makefile1
-rw-r--r--Examples/python/funcptr2/Makefile1
-rw-r--r--Examples/python/functor/Makefile1
-rw-r--r--Examples/python/import/Makefile1
-rw-r--r--Examples/python/import/bar.dsp4
-rw-r--r--Examples/python/import/base.dsp4
-rw-r--r--Examples/python/import/foo.dsp4
-rw-r--r--Examples/python/import/spam.dsp4
-rw-r--r--Examples/python/import_template/Makefile1
-rw-r--r--Examples/python/libffi/Makefile1
-rw-r--r--Examples/python/multimap/Makefile1
-rw-r--r--Examples/python/multimap/example.dsp4
-rw-r--r--Examples/python/multimap/example.i34
-rw-r--r--Examples/python/operator/Makefile1
-rw-r--r--Examples/python/pointer/Makefile1
-rw-r--r--Examples/python/reference/Makefile1
-rw-r--r--Examples/python/simple/Makefile1
-rw-r--r--Examples/python/simple/example.dsp4
-rw-r--r--Examples/python/smartptr/Makefile1
-rw-r--r--Examples/python/std_map/Makefile1
-rw-r--r--Examples/python/std_map/example.i4
-rw-r--r--Examples/python/std_vector/Makefile1
-rw-r--r--Examples/python/swigrun/Makefile1
-rw-r--r--Examples/python/template/Makefile1
-rw-r--r--Examples/python/varargs/Makefile1
-rw-r--r--Examples/python/variables/Makefile1
-rw-r--r--Examples/python/weave/Makefile1
-rw-r--r--Examples/r/class/example.dsp4
-rw-r--r--Examples/r/simple/example.dsp4
-rw-r--r--Examples/ruby/class/example.dsp4
-rw-r--r--Examples/ruby/free_function/example.dsp4
-rw-r--r--Examples/ruby/free_function/example.i4
-rw-r--r--[-rwxr-xr-x]Examples/ruby/hashargs/Makefile0
-rw-r--r--[-rwxr-xr-x]Examples/ruby/hashargs/example.i0
-rw-r--r--Examples/ruby/import/bar.dsp4
-rw-r--r--Examples/ruby/import/base.dsp4
-rw-r--r--Examples/ruby/import/foo.dsp4
-rw-r--r--Examples/ruby/import/spam.dsp4
-rw-r--r--Examples/ruby/mark_function/example.dsp4
-rw-r--r--Examples/ruby/multimap/example.dsp4
-rw-r--r--Examples/ruby/simple/example.dsp4
-rw-r--r--Examples/ruby/std_vector/runme.rb8
-rw-r--r--Examples/tcl/class/example.dsp4
-rw-r--r--Examples/tcl/contract/example.dsp4
-rw-r--r--Examples/tcl/import/bar.dsp4
-rw-r--r--Examples/tcl/import/base.dsp4
-rw-r--r--Examples/tcl/import/foo.dsp4
-rw-r--r--Examples/tcl/import/spam.dsp4
-rw-r--r--Examples/tcl/multimap/example.dsp4
-rw-r--r--Examples/tcl/simple/example.dsp4
-rw-r--r--Examples/test-suite/allegrocl/Makefile.in114
-rw-r--r--Examples/test-suite/argcargvtest.i (renamed from Examples/test-suite/python/argcargvtest.i)0
-rw-r--r--Examples/test-suite/callback.i (renamed from Examples/test-suite/python/callback.i)0
-rw-r--r--Examples/test-suite/char_strings.i5
-rw-r--r--Examples/test-suite/chicken/Makefile.in2
-rw-r--r--Examples/test-suite/chicken/chicken_ext_test_runme.ss (renamed from Examples/test-suite/chicken/ext_test_runme.ss)2
-rw-r--r--Examples/test-suite/chicken_ext_test.i (renamed from Examples/test-suite/chicken/ext_test.i)2
-rw-r--r--Examples/test-suite/common.mk26
-rw-r--r--Examples/test-suite/complextest.i (renamed from Examples/test-suite/python/complextest.i)0
-rw-r--r--Examples/test-suite/contract.i30
-rw-r--r--Examples/test-suite/csharp/Makefile.in13
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/csharp/bools_runme.cs0
-rw-r--r--Examples/test-suite/csharp/csharp_lib_arrays_runme.cs70
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/csharp/director_classic_runme.cs0
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/csharp/enum_thorough_runme.cs41
-rw-r--r--Examples/test-suite/csharp/enum_thorough_simple_runme.cs41
-rw-r--r--Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs41
-rw-r--r--Examples/test-suite/csharp/inherit_target_language_runme.cs24
-rw-r--r--Examples/test-suite/csharp/li_attribute_runme.cs78
-rw-r--r--Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs10
-rw-r--r--Examples/test-suite/csharp/li_std_map_runme.cs243
-rw-r--r--Examples/test-suite/csharp/li_std_vector_runme.cs43
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/csharp/li_std_wstring_runme.cs0
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/csharp/overload_complicated_runme.cs0
-rw-r--r--Examples/test-suite/csharp/typemap_out_optimal_runme.cs13
-rw-r--r--Examples/test-suite/csharp_lib_arrays.i61
-rw-r--r--Examples/test-suite/csharp_prepost.i101
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/director_classic.i0
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/director_ignore.i0
-rw-r--r--Examples/test-suite/director_profile.i (renamed from Examples/test-suite/python/director_profile.i)0
-rw-r--r--Examples/test-suite/director_protected_overloaded.i21
-rw-r--r--Examples/test-suite/director_stl.i (renamed from Examples/test-suite/python/director_stl.i)0
-rw-r--r--Examples/test-suite/director_thread.i19
-rw-r--r--Examples/test-suite/enum_thorough.i61
-rw-r--r--Examples/test-suite/enum_thorough_typesafe.i2
-rw-r--r--Examples/test-suite/features.i17
-rw-r--r--Examples/test-suite/global_namespace.i60
-rw-r--r--Examples/test-suite/guile/Makefile.in2
-rw-r--r--Examples/test-suite/guilescm/Makefile.in4
-rw-r--r--Examples/test-suite/guilescm/guilescm_ext_test_runme.scm (renamed from Examples/test-suite/guilescm/ext_test_runme.scm)2
-rw-r--r--Examples/test-suite/guilescm_ext_test.i (renamed from Examples/test-suite/guilescm/ext_test.i)2
-rw-r--r--Examples/test-suite/iadd.i (renamed from Examples/test-suite/python/iadd.h)11
-rw-r--r--Examples/test-suite/ignore_template_constructor.i6
-rw-r--r--Examples/test-suite/implicittest.i (renamed from Examples/test-suite/octave/implicittest.i)0
-rw-r--r--Examples/test-suite/import_nomodule.i3
-rw-r--r--Examples/test-suite/imports_b.i9
-rw-r--r--Examples/test-suite/inherit_target_language.i10
-rw-r--r--Examples/test-suite/inout.i (renamed from Examples/test-suite/python/inout.i)0
-rw-r--r--Examples/test-suite/inplaceadd.i (renamed from Examples/test-suite/python/inplaceadd.i)0
-rw-r--r--Examples/test-suite/input.i (renamed from Examples/test-suite/python/input.i)0
-rw-r--r--Examples/test-suite/insert_directive.i38
-rw-r--r--Examples/test-suite/intermediary_classname.i1
-rw-r--r--Examples/test-suite/java/Makefile.in4
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/java/allprotected_runme.java0
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/java/director_classic_runme.java0
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/java/director_ignore_runme.java0
-rw-r--r--Examples/test-suite/java/enum_thorough_proper_runme.java41
-rw-r--r--Examples/test-suite/java/enum_thorough_runme.java41
-rw-r--r--Examples/test-suite/java/enum_thorough_simple_runme.java41
-rw-r--r--Examples/test-suite/java/enum_thorough_typeunsafe_runme.java41
-rw-r--r--Examples/test-suite/java/global_namespace_runme.java25
-rw-r--r--Examples/test-suite/java/inherit_target_language_runme.java9
-rw-r--r--Examples/test-suite/java/java_throws_runme.java15
-rw-r--r--Examples/test-suite/java/li_boost_intrusive_ptr_runme.java701
-rw-r--r--Examples/test-suite/java/li_boost_shared_ptr_runme.java10
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/java/overload_complicated_runme.java0
-rw-r--r--Examples/test-suite/java/typemap_out_optimal_runme.java21
-rw-r--r--Examples/test-suite/java_throws.i38
-rw-r--r--Examples/test-suite/li_attribute.i31
-rw-r--r--Examples/test-suite/li_boost_intrusive_ptr.i494
-rw-r--r--Examples/test-suite/li_boost_shared_ptr.i38
-rw-r--r--Examples/test-suite/li_cstring.i8
-rw-r--r--Examples/test-suite/li_cwstring.i8
-rw-r--r--Examples/test-suite/li_std_carray.i (renamed from Examples/test-suite/python/li_std_carray.i)0
-rw-r--r--Examples/test-suite/li_std_functors.i (renamed from Examples/test-suite/ruby/li_std_functors.i)0
-rw-r--r--Examples/test-suite/li_std_list.i (renamed from Examples/test-suite/perl5/li_std_list.i)0
-rw-r--r--Examples/test-suite/li_std_map.i139
-rw-r--r--Examples/test-suite/li_std_multimap.i25
-rw-r--r--Examples/test-suite/li_std_pair_extra.i (renamed from Examples/test-suite/octave/li_std_pair.i)2
-rw-r--r--Examples/test-suite/li_std_pair_lang_object.i (renamed from Examples/test-suite/ruby/li_std_pair_lang_object.i)0
-rw-r--r--Examples/test-suite/li_std_queue.i (renamed from Examples/test-suite/ruby/li_std_queue.i)0
-rw-r--r--Examples/test-suite/li_std_set.i8
-rw-r--r--Examples/test-suite/li_std_stack.i (renamed from Examples/test-suite/ruby/li_std_stack.i)0
-rw-r--r--Examples/test-suite/li_std_string_extra.i (renamed from Examples/test-suite/octave/li_std_string.i)4
-rw-r--r--Examples/test-suite/li_std_vector.i2
-rw-r--r--Examples/test-suite/li_std_vector_extra.i (renamed from Examples/test-suite/python/li_std_vector.i)12
-rw-r--r--Examples/test-suite/li_std_vector_ptr.i29
-rw-r--r--Examples/test-suite/li_std_vectora.i (renamed from Examples/test-suite/python/li_std_vectora.i)0
-rw-r--r--Examples/test-suite/li_std_wstream.i (renamed from Examples/test-suite/python/li_std_wstream.i)0
-rw-r--r--Examples/test-suite/name_warnings.i3
-rw-r--r--Examples/test-suite/namespace_typemap.i2
-rw-r--r--Examples/test-suite/nested_comment.i27
-rw-r--r--Examples/test-suite/nested_structs.i22
-rw-r--r--Examples/test-suite/ocaml/Makefile.in2
-rw-r--r--Examples/test-suite/octave/Makefile.in4
-rw-r--r--Examples/test-suite/octave/li_attribute_runme.m38
-rw-r--r--Examples/test-suite/octave/li_std_map_runme.m2
-rw-r--r--Examples/test-suite/octave/li_std_pair_extra_runme.m69
-rw-r--r--Examples/test-suite/octave/li_std_pair_runme.m69
-rw-r--r--Examples/test-suite/octave/li_std_string_extra_runme.m162
-rw-r--r--Examples/test-suite/octave/li_std_string_runme.m162
-rw-r--r--Examples/test-suite/octave/octave_cell_deref_runme.m (renamed from Examples/test-suite/octave/cell_deref_runme.m)2
-rw-r--r--Examples/test-suite/octave_cell_deref.i (renamed from Examples/test-suite/octave/cell_deref.i)2
-rw-r--r--Examples/test-suite/operator_overload.i6
-rw-r--r--Examples/test-suite/operbool.i12
-rw-r--r--Examples/test-suite/packageoption.h9
-rw-r--r--Examples/test-suite/packageoption.list1
-rw-r--r--Examples/test-suite/packageoption_a.i8
-rw-r--r--Examples/test-suite/packageoption_b.i2
-rw-r--r--Examples/test-suite/packageoption_c.i13
-rw-r--r--Examples/test-suite/perl5/Makefile.in1
-rw-r--r--Examples/test-suite/perl5/byreference.i52
-rw-r--r--Examples/test-suite/perl5/byreference_runme.pl36
-rw-r--r--Examples/test-suite/perl5/char_strings_runme.pl5
-rw-r--r--Examples/test-suite/perl5/enum_thorough_runme.pl54
-rw-r--r--Examples/test-suite/perl5/imports_runme.pl2
-rw-r--r--Examples/test-suite/perl5/packageoption_runme.pl8
-rw-r--r--Examples/test-suite/php/Makefile.in56
-rw-r--r--Examples/test-suite/php/abstract_inherit_ok_runme.php (renamed from Examples/test-suite/php4/abstract_inherit_ok_runme.php4)2
-rw-r--r--Examples/test-suite/php/abstract_inherit_runme.php (renamed from Examples/test-suite/php4/abstract_inherit_runme.php4)2
-rw-r--r--Examples/test-suite/php/add_link_runme.php (renamed from Examples/test-suite/php4/add_link_runme.php4)2
-rw-r--r--Examples/test-suite/php/argout_runme.php (renamed from Examples/test-suite/php4/argout_runme.php4)2
-rw-r--r--Examples/test-suite/php/arrayptr_runme.php (renamed from Examples/test-suite/php4/arrayptr_runme.php4)2
-rw-r--r--Examples/test-suite/php/arrays_global_runme.php (renamed from Examples/test-suite/php4/arrays_global_runme.php4)12
-rw-r--r--Examples/test-suite/php/arrays_global_twodim_runme.php (renamed from Examples/test-suite/php4/arrays_global_twodim_runme.php4)2
-rw-r--r--Examples/test-suite/php/arrays_runme.php (renamed from Examples/test-suite/php4/arrays_runme.php4)2
-rw-r--r--Examples/test-suite/php/arrays_scope_runme.php (renamed from Examples/test-suite/php4/arrays_scope_runme.php4)2
-rw-r--r--Examples/test-suite/php/casts_runme.php (renamed from Examples/test-suite/php4/casts_runme.php4)2
-rw-r--r--Examples/test-suite/php/class_ignore_runme.php (renamed from Examples/test-suite/php4/class_ignore_runme.php4)2
-rw-r--r--Examples/test-suite/php/conversion_namespace_runme.php (renamed from Examples/test-suite/php4/conversion_namespace_runme.php4)2
-rw-r--r--Examples/test-suite/php/conversion_ns_template_runme.php (renamed from Examples/test-suite/php4/conversion_ns_template_runme.php4)2
-rw-r--r--Examples/test-suite/php/conversion_runme.php (renamed from Examples/test-suite/php4/conversion_runme.php4)2
-rw-r--r--Examples/test-suite/php/cpp_static_runme.php (renamed from Examples/test-suite/php4/cpp_static_runme.php4)2
-rw-r--r--Examples/test-suite/php/enum_scope_template_runme.php (renamed from Examples/test-suite/php4/enum_scope_template_runme.php4)2
-rw-r--r--Examples/test-suite/php/evil_diamond_ns_runme.php (renamed from Examples/test-suite/php4/evil_diamond_ns_runme.php4)2
-rw-r--r--Examples/test-suite/php/evil_diamond_prop_runme.php (renamed from Examples/test-suite/php4/evil_diamond_prop_runme.php4)2
-rw-r--r--Examples/test-suite/php/evil_diamond_runme.php (renamed from Examples/test-suite/php4/evil_diamond_runme.php4)2
-rw-r--r--Examples/test-suite/php/extend_template_ns_runme.php (renamed from Examples/test-suite/php4/extend_template_ns_runme.php4)2
-rw-r--r--Examples/test-suite/php/extend_template_runme.php (renamed from Examples/test-suite/php4/extend_template_runme.php4)2
-rw-r--r--Examples/test-suite/php/grouping_runme.php (renamed from Examples/test-suite/php4/grouping_runme.php4)2
-rw-r--r--Examples/test-suite/php/ignore_parameter_runme.php (renamed from Examples/test-suite/php4/ignore_parameter_runme.php4)2
-rw-r--r--Examples/test-suite/php/li_carrays_runme.php (renamed from Examples/test-suite/php4/li_carrays_runme.php4)2
-rw-r--r--Examples/test-suite/php/li_std_string_runme.php (renamed from Examples/test-suite/php4/li_std_string_runme.php4)2
-rw-r--r--Examples/test-suite/php/rename_scope_runme.php (renamed from Examples/test-suite/php4/rename_scope_runme.php4)2
-rw-r--r--Examples/test-suite/php/skel.php (renamed from Examples/test-suite/php4/skel.php4)2
-rw-r--r--Examples/test-suite/php/smart_pointer_rename_runme.php (renamed from Examples/test-suite/php4/smart_pointer_rename_runme.php4)2
-rw-r--r--Examples/test-suite/php/sym_runme.php (renamed from Examples/test-suite/php4/sym_runme.php4)2
-rw-r--r--Examples/test-suite/php/template_arg_typename_runme.php (renamed from Examples/test-suite/php4/template_arg_typename_runme.php4)2
-rw-r--r--Examples/test-suite/php/template_construct_runme.php (renamed from Examples/test-suite/php4/template_construct_runme.php4)2
-rw-r--r--Examples/test-suite/php/tests.php (renamed from Examples/test-suite/php4/tests.php4)2
-rw-r--r--Examples/test-suite/php/typedef_reference_runme.php (renamed from Examples/test-suite/php4/typedef_reference_runme.php4)2
-rw-r--r--Examples/test-suite/php/typemap_ns_using_runme.php (renamed from Examples/test-suite/php4/typemap_ns_using_runme.php4)2
-rw-r--r--Examples/test-suite/php/using1_runme.php (renamed from Examples/test-suite/php4/using1_runme.php4)2
-rw-r--r--Examples/test-suite/php/using2_runme.php (renamed from Examples/test-suite/php4/using2_runme.php4)2
-rw-r--r--Examples/test-suite/php/valuewrapper_base_runme.php (renamed from Examples/test-suite/php4/valuewrapper_base_runme.php4)2
-rw-r--r--Examples/test-suite/php4/Makefile.in69
-rw-r--r--Examples/test-suite/php_namewarn_rename.i (renamed from Examples/test-suite/php4/namewarn_rename.i)2
-rw-r--r--Examples/test-suite/preproc.i5
-rw-r--r--Examples/test-suite/pure_virtual.i4
-rw-r--r--Examples/test-suite/python/Makefile.in84
-rw-r--r--Examples/test-suite/python/README6
-rw-r--r--Examples/test-suite/python/contract_runme.py8
-rw-r--r--Examples/test-suite/python/cpp_namespace_runme.py20
-rw-r--r--Examples/test-suite/python/cpp_static_runme.py7
-rw-r--r--Examples/test-suite/python/director_classic_runme.py68
-rw-r--r--Examples/test-suite/python/director_exception_runme.py48
-rw-r--r--Examples/test-suite/python/director_thread_runme.py2
-rw-r--r--Examples/test-suite/python/file_test_runme.py3
-rw-r--r--Examples/test-suite/python/hugemod.pl8
-rw-r--r--Examples/test-suite/python/iadd.i12
-rw-r--r--Examples/test-suite/python/implicittest.i68
-rw-r--r--Examples/test-suite/python/li_attribute_runme.py36
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_runme.py9
-rw-r--r--Examples/test-suite/python/li_std_map.i58
-rw-r--r--Examples/test-suite/python/li_std_map_runme.py2
-rw-r--r--Examples/test-suite/python/li_std_pair.i210
-rw-r--r--Examples/test-suite/python/li_std_pair_extra_runme.py59
-rw-r--r--Examples/test-suite/python/li_std_pair_runme.py59
-rw-r--r--Examples/test-suite/python/li_std_set.i17
-rw-r--r--Examples/test-suite/python/li_std_stream.i59
-rw-r--r--Examples/test-suite/python/li_std_string.i55
-rw-r--r--Examples/test-suite/python/li_std_string_extra_runme.py (renamed from Examples/test-suite/python/li_std_string_runme.py)66
-rw-r--r--Examples/test-suite/python/li_std_vector_extra_runme.py (renamed from Examples/test-suite/python/li_std_vector_runme.py)23
-rw-r--r--Examples/test-suite/python/li_std_vector_ptr_runme.py8
-rw-r--r--Examples/test-suite/python/li_std_wstring.i89
-rw-r--r--Examples/test-suite/python/operbool_runme.py4
-rw-r--r--Examples/test-suite/python/python_abstractbase_runme3.py8
-rw-r--r--Examples/test-suite/python/python_append_runme.py4
-rw-r--r--Examples/test-suite/python/python_kwargs_runme.py (renamed from Examples/test-suite/python/kwargs_runme.py)2
-rw-r--r--Examples/test-suite/python/python_nondynamic_runme.py (renamed from Examples/test-suite/python/nondynamic_runme.py)10
-rw-r--r--Examples/test-suite/python/python_overload_simple_cast_runme.py (renamed from Examples/test-suite/python/overload_simple_cast_runme.py)2
-rw-r--r--Examples/test-suite/python/python_pybuf_runme3.py42
-rw-r--r--Examples/test-suite/python/rename_strip_encoder_runme.py6
-rw-r--r--Examples/test-suite/python/std_containers.i199
-rw-r--r--Examples/test-suite/python/swigobject_runme.py10
-rw-r--r--Examples/test-suite/python/tag_no_clash_with_variable_runme.i3
-rw-r--r--Examples/test-suite/python/template_typedef_cplx2_runme.py13
-rw-r--r--Examples/test-suite/python/template_typedef_cplx_runme.py13
-rw-r--r--Examples/test-suite/python/typemap_out_optimal_runme.py5
-rw-r--r--Examples/test-suite/python/vector.i51
-rw-r--r--Examples/test-suite/python_abstractbase.i18
-rw-r--r--Examples/test-suite/python_append.i32
-rw-r--r--Examples/test-suite/python_autodoc.i (renamed from Examples/test-suite/python/autodoc.i)2
-rw-r--r--Examples/test-suite/python_kwargs.i (renamed from Examples/test-suite/python/kwargs.i)2
-rw-r--r--Examples/test-suite/python_nondynamic.i (renamed from Examples/test-suite/python/nondynamic.i)2
-rw-r--r--Examples/test-suite/python_overload_simple_cast.i (renamed from Examples/test-suite/python/overload_simple_cast.i)2
-rw-r--r--Examples/test-suite/python_pybuf.i64
-rw-r--r--Examples/test-suite/r/Makefile.in4
-rw-r--r--Examples/test-suite/r/arrays_dimensionless_runme.R20
-rw-r--r--Examples/test-suite/r/double_delete_runme.R12
-rw-r--r--Examples/test-suite/r/integers_runme.R20
-rw-r--r--Examples/test-suite/r/r_copy_struct_runme.R (renamed from Examples/test-suite/r/copy_struct_runme.R)9
-rw-r--r--Examples/test-suite/r/r_double_delete_runme.R9
-rw-r--r--Examples/test-suite/r/r_legacy_runme.R (renamed from Examples/test-suite/r/legacy_runme.R)4
-rw-r--r--Examples/test-suite/r_copy_struct.i (renamed from Examples/test-suite/r/copy_struct.i)2
-rw-r--r--Examples/test-suite/r_double_delete.i (renamed from Examples/test-suite/r/double_delete.i)3
-rw-r--r--Examples/test-suite/r_legacy.i (renamed from Examples/test-suite/r/legacy.i)2
-rw-r--r--Examples/test-suite/rename_strip_encoder.i16
-rw-r--r--Examples/test-suite/ruby/Makefile.in15
-rwxr-xr-xExamples/test-suite/ruby/li_std_map_runme.rb13
-rwxr-xr-xExamples/test-suite/ruby/li_std_multimap_runme.rb27
-rw-r--r--Examples/test-suite/ruby/ruby_keywords_runme.rb (renamed from Examples/test-suite/ruby/keywords_runme.rb)4
-rwxr-xr-xExamples/test-suite/ruby/ruby_li_std_speed_runme.rb (renamed from Examples/test-suite/ruby/li_std_speed_runme.rb)4
-rw-r--r--Examples/test-suite/ruby/ruby_naming_runme.rb (renamed from Examples/test-suite/ruby/naming_runme.rb)40
-rw-r--r--Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb (renamed from Examples/test-suite/ruby/track_objects_directors_runme.rb)8
-rw-r--r--Examples/test-suite/ruby/ruby_track_objects_runme.rb (renamed from Examples/test-suite/ruby/track_objects_runme.rb)24
-rw-r--r--Examples/test-suite/ruby_keywords.i (renamed from Examples/test-suite/ruby/keywords.i)2
-rw-r--r--Examples/test-suite/ruby_li_std_speed.i (renamed from Examples/test-suite/ruby/li_std_speed.i)4
-rw-r--r--Examples/test-suite/ruby_naming.i (renamed from Examples/test-suite/ruby/naming.i)2
-rw-r--r--Examples/test-suite/ruby_track_objects.i (renamed from Examples/test-suite/ruby/track_objects.i)2
-rw-r--r--Examples/test-suite/ruby_track_objects_directors.i (renamed from Examples/test-suite/ruby/track_objects_directors.i)2
-rw-r--r--Examples/test-suite/simple_array.i (renamed from Examples/test-suite/r/simple_array.i)0
-rw-r--r--Examples/test-suite/simutry.i (renamed from Examples/test-suite/python/simutry.i)0
-rw-r--r--Examples/test-suite/stl_new.i (renamed from Examples/test-suite/ruby/stl_new.i)0
-rw-r--r--Examples/test-suite/swig_examples_lock.h17
-rw-r--r--Examples/test-suite/swigobject.i (renamed from Examples/test-suite/python/swigobject.i)2
-rw-r--r--Examples/test-suite/tcl/Makefile.in5
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/tcl/union_parameter_runme.tcl (renamed from Examples/test-suite/tcl/union_runme.tcl)2
-rw-r--r--Examples/test-suite/template_inherit_abstract.i2
-rw-r--r--Examples/test-suite/template_matrix.i (renamed from Examples/test-suite/python/template_matrix.i)0
-rw-r--r--Examples/test-suite/template_typedef_funcptr.i5
-rw-r--r--Examples/test-suite/typemap_namespace.i2
-rw-r--r--Examples/test-suite/typemap_out_optimal.i38
-rw-r--r--Examples/test-suite/typemap_subst.i8
-rw-r--r--Examples/test-suite/types_directive.i8
-rw-r--r--Examples/test-suite/union_parameter.i (renamed from Examples/test-suite/tcl/union.i)2
-rw-r--r--Lib/allegrocl/allegrocl.swg121
-rw-r--r--[-rwxr-xr-x]Lib/allegrocl/inout_typemaps.i0
-rw-r--r--[-rwxr-xr-x]Lib/allegrocl/longlongs.i0
-rw-r--r--[-rwxr-xr-x]Lib/allegrocl/std_list.i0
-rw-r--r--[-rwxr-xr-x]Lib/allegrocl/std_string.i0
-rw-r--r--Lib/allkw.swg2
-rw-r--r--Lib/csharp/arrays_csharp.i140
-rw-r--r--Lib/csharp/boost_shared_ptr.i22
-rw-r--r--Lib/csharp/csharp.swg35
-rw-r--r--Lib/csharp/csharphead.swg2
-rw-r--r--Lib/csharp/std_map.i753
-rw-r--r--[-rwxr-xr-x]Lib/csharp/std_vector.i148
-rw-r--r--[-rwxr-xr-x]Lib/csharp/std_wstring.i0
-rw-r--r--Lib/csharp/typemaps.i4
-rw-r--r--[-rwxr-xr-x]Lib/csharp/wchar.i0
-rw-r--r--Lib/intrusive_ptr.i95
-rw-r--r--Lib/java/boost_intrusive_ptr.i460
-rw-r--r--Lib/java/boost_shared_ptr.i22
-rw-r--r--Lib/java/java.swg31
-rw-r--r--Lib/java/javahead.swg5
-rw-r--r--Lib/java/std_vector.i34
-rw-r--r--Lib/lua/luatypemaps.swg25
-rw-r--r--Lib/ocaml/std_deque.i2
-rw-r--r--Lib/octave/carrays.i2
-rw-r--r--Lib/octave/octcontainer.swg10
-rw-r--r--Lib/octave/octopers.swg116
-rw-r--r--Lib/octave/octrun.swg117
-rw-r--r--Lib/octave/octruntime.swg1
-rw-r--r--Lib/octave/octstdcommon.swg2
-rw-r--r--Lib/octave/std_basic_string.i38
-rw-r--r--Lib/octave/std_carray.i6
-rw-r--r--Lib/octave/std_map.i14
-rw-r--r--Lib/perl5/noembed.h6
-rw-r--r--Lib/perl5/perlrun.swg25
-rw-r--r--Lib/perl5/perlstrings.swg5
-rw-r--r--Lib/perl5/perltypemaps.swg1
-rw-r--r--Lib/perl5/reference.i31
-rw-r--r--Lib/perl5/std_vector.i4
-rw-r--r--Lib/php/globalvar.i2
-rw-r--r--Lib/php/php.swg30
-rw-r--r--Lib/php/phprun.swg8
-rw-r--r--Lib/php/typemaps.i75
-rw-r--r--Lib/php/utils.i8
-rw-r--r--Lib/python/boost_shared_ptr.i14
-rw-r--r--Lib/python/director.swg11
-rw-r--r--Lib/python/embed.i4
-rw-r--r--Lib/python/embed15.i2
-rw-r--r--Lib/python/file.i4
-rw-r--r--Lib/python/pyabc.i10
-rw-r--r--Lib/python/pyapi.swg14
-rw-r--r--Lib/python/pybuffer.i107
-rw-r--r--Lib/python/pyclasses.swg62
-rw-r--r--Lib/python/pycomplex.swg8
-rw-r--r--Lib/python/pycontainer.swg219
-rw-r--r--Lib/python/pyerrors.swg7
-rw-r--r--Lib/python/pyhead.swg64
-rw-r--r--Lib/python/pyinit.swg80
-rw-r--r--Lib/python/pyiterators.swg180
-rw-r--r--Lib/python/pyname_compat.i88
-rw-r--r--Lib/python/pyopers.swg8
-rw-r--r--Lib/python/pyrun.swg424
-rw-r--r--Lib/python/pystdcommon.swg2
-rw-r--r--Lib/python/pystrings.swg34
-rw-r--r--Lib/python/pytypemaps.swg2
-rw-r--r--Lib/python/pywstrings.swg4
-rw-r--r--Lib/python/std_carray.i6
-rw-r--r--Lib/python/std_map.i48
-rw-r--r--Lib/python/std_multimap.i14
-rw-r--r--Lib/python/std_multiset.i12
-rw-r--r--Lib/python/std_pair.i8
-rw-r--r--Lib/python/std_set.i12
-rw-r--r--Lib/r/r.swg82
-rw-r--r--Lib/r/rrun.swg2
-rw-r--r--Lib/r/rstdcommon.swg2
-rw-r--r--Lib/r/rtype.swg101
-rw-r--r--Lib/ruby/file.i7
-rw-r--r--Lib/ruby/rubyhead.swg3
-rw-r--r--Lib/ruby/rubywstrings.swg2
-rw-r--r--Lib/shared_ptr.i12
-rw-r--r--Lib/swig.swg66
-rw-r--r--Lib/swigrun.swg98
-rw-r--r--Lib/typemaps/attribute.swg87
-rw-r--r--Lib/typemaps/swigtype.swg20
-rw-r--r--Makefile.in119
-rw-r--r--README23
-rw-r--r--Source/CParse/cparse.h8
-rw-r--r--Source/CParse/cscanner.c43
-rw-r--r--Source/CParse/parser.y141
-rw-r--r--Source/CParse/templ.c2
-rw-r--r--Source/DOH/README12
-rw-r--r--Source/DOH/base.c4
-rw-r--r--Source/DOH/doh.h15
-rw-r--r--Source/DOH/file.c11
-rw-r--r--Source/DOH/hash.c2
-rw-r--r--Source/DOH/list.c2
-rw-r--r--Source/DOH/string.c2
-rw-r--r--Source/Include/swigwarn.h5
-rw-r--r--Source/Modules/allegrocl.cxx394
-rw-r--r--Source/Modules/cffi.cxx51
-rw-r--r--Source/Modules/chicken.cxx41
-rw-r--r--Source/Modules/clisp.cxx13
-rw-r--r--Source/Modules/contract.cxx8
-rw-r--r--Source/Modules/csharp.cxx108
-rw-r--r--Source/Modules/directors.cxx4
-rw-r--r--Source/Modules/guile.cxx41
-rw-r--r--Source/Modules/java.cxx61
-rw-r--r--Source/Modules/lang.cxx79
-rw-r--r--Source/Modules/lua.cxx30
-rw-r--r--Source/Modules/main.cxx200
-rw-r--r--Source/Modules/modula3.cxx50
-rw-r--r--Source/Modules/mzscheme.cxx24
-rw-r--r--[-rwxr-xr-x]Source/Modules/ocaml.cxx35
-rw-r--r--Source/Modules/octave.cxx47
-rw-r--r--Source/Modules/overload.cxx8
-rw-r--r--Source/Modules/perl5.cxx143
-rw-r--r--Source/Modules/php.cxx130
-rw-r--r--Source/Modules/pike.cxx28
-rw-r--r--Source/Modules/python.cxx687
-rw-r--r--Source/Modules/r.cxx36
-rw-r--r--Source/Modules/ruby.cxx93
-rw-r--r--Source/Modules/s-exp.cxx12
-rw-r--r--Source/Modules/swigmain.cxx6
-rw-r--r--Source/Modules/swigmod.h21
-rw-r--r--Source/Modules/tcl8.cxx30
-rw-r--r--Source/Modules/typepass.cxx58
-rw-r--r--Source/Modules/uffi.cxx25
-rw-r--r--Source/Modules/xml.cxx6
-rw-r--r--Source/Preprocessor/cpp.c35
-rw-r--r--Source/Preprocessor/preprocessor.h4
-rw-r--r--Source/README9
-rw-r--r--Source/Swig/cwrap.c53
-rw-r--r--Source/Swig/error.c10
-rw-r--r--Source/Swig/getopt.c2
-rw-r--r--Source/Swig/include.c57
-rw-r--r--Source/Swig/misc.c95
-rw-r--r--Source/Swig/naming.c32
-rw-r--r--Source/Swig/parms.c2
-rw-r--r--Source/Swig/scanner.c25
-rw-r--r--Source/Swig/stype.c8
-rw-r--r--Source/Swig/swig.h137
-rw-r--r--Source/Swig/swigfile.h31
-rw-r--r--Source/Swig/swigopt.h2
-rw-r--r--Source/Swig/swigparm.h2
-rw-r--r--Source/Swig/swigscan.h4
-rw-r--r--Source/Swig/swigtree.h2
-rw-r--r--Source/Swig/swigwrap.h12
-rw-r--r--Source/Swig/symbol.c34
-rw-r--r--Source/Swig/tree.c2
-rw-r--r--Source/Swig/typemap.c30
-rw-r--r--Source/Swig/typeobj.c10
-rw-r--r--Source/Swig/typesys.c15
-rw-r--r--Source/Swig/wrapfunc.c12
-rw-r--r--TODO10
-rwxr-xr-xTools/mkdist.py10
-rwxr-xr-xTools/mkrelease.py2
-rwxr-xr-xTools/mkwindows.sh5
-rw-r--r--Tools/pyname_patch.py123
-rwxr-xr-xautogen.sh6
-rw-r--r--configure.in354
704 files changed, 21939 insertions, 4849 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index 7c0e95e3f..9ef41142a 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,11 +1,11 @@
-*** ANNOUNCE: SWIG 1.3.36 (24 June 2008) ***
+*** ANNOUNCE: SWIG 1.3.40 (in progress) ***
http://www.swig.org
-We're pleased to announce SWIG-1.3.36, the latest installment in the
-SWIG development effort. SWIG-1.3.36 includes a number of bug fixes
-and large number of enhancements throughout.
+We're pleased to announce SWIG-1.3.40, the latest installment in the
+SWIG development effort. SWIG-1.3.40 includes a number of bug fixes
+and enhancements.
What is SWIG?
-------------
@@ -24,21 +24,11 @@ Availability:
-------------
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-1.3.36.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-1.3.40.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-1.3.36.zip
-
-Release numbers
----------------
-With SWIG-1.3, we are adopting an odd/even version numbering scheme for
-SWIG. Odd version numbers (1.3, 1.5, 1.7, etc...) are considered to
-be development releases. Even numbers (1.4,1.6,1.8) are stable
-releases. The current 1.3 effort is working to produce a stable 2.0
-release. A stable 2.0 release will not be made until it can
-accompanied by fully updated documentation. In the meantime, we will
-continue to make periodic 1.3.x releases.
+ http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip
Please report problems with this release to the swig-dev mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CCache/COPYING b/CCache/COPYING
new file mode 100644
index 000000000..a43ea2126
--- /dev/null
+++ b/CCache/COPYING
@@ -0,0 +1,339 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ Appendix: How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) 19yy <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) 19yy name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/CCache/Makefile.in b/CCache/Makefile.in
new file mode 100644
index 000000000..ec55ccaf5
--- /dev/null
+++ b/CCache/Makefile.in
@@ -0,0 +1,73 @@
+datarootdir = @datarootdir@
+srcdir=@srcdir@
+VPATH=@srcdir@
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+mandir=@mandir@
+INSTALLCMD=@INSTALL@
+PACKAGE_NAME=@PACKAGE_NAME@
+# Soft link test can be skipped on systems that don't support soft linking
+NOSOFTLINKSTEST=
+
+CC=@CC@
+CFLAGS=@CFLAGS@ -I.
+SWIG=swig
+SWIG_LIB=../../Lib
+EXEEXT=@EXEEXT@
+
+# Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix
+transform = @program_transform_name@
+
+LIBS= @LIBS@
+OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \
+ cleanup.o snprintf.o unify.o
+HEADERS = ccache.h mdfour.h
+
+all: $(PACKAGE_NAME)$(EXEEXT)
+
+# Note that HTML documentation is actually generated and used from the main SWIG documentation Makefile
+docs: $(PACKAGE_NAME).1 web/ccache-man.html
+
+$(PACKAGE_NAME)$(EXEEXT): $(OBJS) $(HEADERS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+
+$(PACKAGE_NAME).1: ccache.yo
+ -yodl2man -o $(PACKAGE_NAME).1 ccache.yo
+
+web/ccache-man.html: ccache.yo
+ mkdir -p man
+ yodl2html -o web/ccache-man.html ccache.yo
+
+install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
+ ${INSTALLCMD} -d $(DESTDIR)${bindir}
+ ${INSTALLCMD} -m 755 $(PACKAGE_NAME)$(EXEEXT) $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
+ ${INSTALLCMD} -d $(DESTDIR)${mandir}/man1
+ ${INSTALLCMD} -m 644 ${srcdir}/$(PACKAGE_NAME).1 $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
+
+uninstall: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
+ rm -f $(DESTDIR)${bindir}/`echo $(PACKAGE_NAME) | sed '$(transform)'`$(EXEEXT)
+ rm -f $(DESTDIR)${mandir}/man1/`echo $(PACKAGE_NAME) | sed '$(transform)'`.1
+
+clean:
+ /bin/rm -f $(OBJS) *~ $(PACKAGE_NAME)$(EXEEXT)
+
+clean-docs:
+ rm -f $(PACKAGE_NAME).1 web/ccache-man.html
+
+check : test
+
+test: test.sh
+ SWIG_LIB='$(SWIG_LIB)' PATH=../..:$$PATH SWIG='$(SWIG)' CC='$(CC)' NOSOFTLINKSTEST='$(NOSOFTLINKSTEST)' ./test.sh
+
+check: test
+
+distclean: clean
+ /bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h
+
+# FIXME: To fix this, test.sh needs to be able to take ccache from the
+# installed prefix, not from the source dir.
+installcheck:
+ @echo "WARNING! This is not really \"installcheck\" yet."
+ $(MAKE) check
diff --git a/CCache/README b/CCache/README
new file mode 100644
index 000000000..6e68a6eb0
--- /dev/null
+++ b/CCache/README
@@ -0,0 +1,31 @@
+This is a re-implementation of "compilercache" in C
+
+The original compilercache scripts were by Erik Thiele
+(erikyyy@erikyyy.de) and I would like to thank him for an excellent
+piece of work. See http://www.erikyyy.de/compilercache/ for the
+original shell scripts.
+
+I wrote ccache because I wanted to get a bit more speed out of a
+compiler cache and I wanted to remove some of the limitations of the
+shell-script version.
+
+Please see the manual page and documentation at
+http://ccache.samba.org/
+
+INSTALLATION
+------------
+
+Please run:
+
+ ./configure
+ make
+ make install
+
+then read the ccache manual page
+
+-----------
+
+Andrew Tridgell
+http://samba.org/~tridge/
+bugs@ccache.samba.org
+
diff --git a/CCache/README.swig b/CCache/README.swig
new file mode 100644
index 000000000..aea0f3d82
--- /dev/null
+++ b/CCache/README.swig
@@ -0,0 +1,8 @@
+This directory contains a version of ccache. The initial version was based on ccache-2.4 plus
+debian patches 01-02, 04-14, see the debian/patches subdirectory. The ccache-win32-2.4 modifications
+to ccache-2.4 have also been merged in.
+
+Changes have been made to support cacheing the output from SWIG. The ability to cache c/c++ compiler
+output has been retained.
+
+Additional features added are the CCACHE_VERBOSE and CCACHE_SWIG environment variables, see docs.
diff --git a/CCache/args.c b/CCache/args.c
new file mode 100644
index 000000000..31e5471c1
--- /dev/null
+++ b/CCache/args.c
@@ -0,0 +1,91 @@
+/*
+ convenient routines for argument list handling
+
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+ARGS *args_init(int init_argc, char **init_args)
+{
+ ARGS *args;
+ int i;
+ args = (ARGS *)x_malloc(sizeof(ARGS));
+ args->argc = 0;
+ args->argv = (char **)x_malloc(sizeof(char *));
+ args->argv[0] = NULL;
+ for (i=0;i<init_argc;i++) {
+ args_add(args, init_args[i]);
+ }
+ return args;
+}
+
+
+void args_add(ARGS *args, const char *s)
+{
+ args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
+ args->argv[args->argc] = x_strdup(s);
+ args->argc++;
+ args->argv[args->argc] = NULL;
+}
+
+/* pop the last element off the args list */
+void args_pop(ARGS *args, int n)
+{
+ while (n--) {
+ args->argc--;
+ free(args->argv[args->argc]);
+ args->argv[args->argc] = NULL;
+ }
+}
+
+/* remove the first element of the argument list */
+void args_remove_first(ARGS *args)
+{
+ free(args->argv[0]);
+ memmove(&args->argv[0],
+ &args->argv[1],
+ args->argc * sizeof(args->argv[0]));
+ args->argc--;
+}
+
+/* add an argument into the front of the argument list */
+void args_add_prefix(ARGS *args, const char *s)
+{
+ args->argv = (char**)x_realloc(args->argv, (args->argc + 2) * sizeof(char *));
+ memmove(&args->argv[1], &args->argv[0],
+ (args->argc+1) * sizeof(args->argv[0]));
+ args->argv[0] = x_strdup(s);
+ args->argc++;
+}
+
+/* strip any arguments beginning with the specified prefix */
+void args_strip(ARGS *args, const char *prefix)
+{
+ int i;
+ for (i=0; i<args->argc; ) {
+ if (strncmp(args->argv[i], prefix, strlen(prefix)) == 0) {
+ free(args->argv[i]);
+ memmove(&args->argv[i],
+ &args->argv[i+1],
+ args->argc * sizeof(args->argv[i]));
+ args->argc--;
+ } else {
+ i++;
+ }
+ }
+}
diff --git a/CCache/ccache.c b/CCache/ccache.c
new file mode 100644
index 000000000..d1696da88
--- /dev/null
+++ b/CCache/ccache.c
@@ -0,0 +1,1388 @@
+/*
+ a re-implementation of the compilercache scripts in C
+
+ The idea is based on the shell-script compilercache by Erik Thiele <erikyyy@erikyyy.de>
+
+ Copyright (C) Andrew Tridgell 2002
+ Copyright (C) Martin Pool 2003
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+/* verbose mode */
+int ccache_verbose = 0;
+
+/* the base cache directory */
+char *cache_dir = NULL;
+
+/* the directory for temporary files */
+static char *temp_dir = NULL;
+
+/* the debug logfile name, if set */
+char *cache_logfile = NULL;
+
+/* the argument list after processing */
+static ARGS *stripped_args;
+
+/* the original argument list */
+static ARGS *orig_args;
+
+/* the output filename being compiled to */
+static char *output_file;
+
+/* the source file */
+static char *input_file;
+
+/* the name of the file containing the cached object code */
+static char *hashname;
+
+/* the extension of the file after pre-processing */
+static const char *i_extension;
+
+/* the name of the temporary pre-processor file */
+static char *i_tmpfile;
+
+/* are we compiling a .i or .ii file directly? */
+static int direct_i_file;
+
+/* the name of the cpp stderr file */
+static char *cpp_stderr;
+
+/* the name of the statistics file */
+char *stats_file = NULL;
+
+/* can we safely use the unification hashing backend? */
+static int enable_unify;
+
+/* should we strip -c when running the preprocessor only? */
+static int strip_c_option;
+
+/* customisation for using the SWIG compiler */
+static int swig;
+
+/* a list of supported file extensions, and the equivalent
+ extension for code that has been through the pre-processor
+*/
+static struct {
+ char *extension;
+ char *i_extension;
+} extensions[] = {
+ {"c", "i"},
+ {"C", "ii"},
+ {"m", "mi"},
+ {"cc", "ii"},
+ {"CC", "ii"},
+ {"cpp", "ii"},
+ {"CPP", "ii"},
+ {"cxx", "ii"},
+ {"CXX", "ii"},
+ {"c++", "ii"},
+ {"C++", "ii"},
+ {"i", "i"},
+ {"ii", "ii"},
+ {NULL, NULL}};
+
+/*
+ something went badly wrong - just execute the real compiler
+*/
+static void failed(void)
+{
+ char *e;
+
+ /* delete intermediate pre-processor file if needed */
+ if (i_tmpfile) {
+ if (!direct_i_file) {
+ unlink(i_tmpfile);
+ }
+ free(i_tmpfile);
+ i_tmpfile = NULL;
+ }
+
+ /* delete the cpp stderr file if necessary */
+ if (cpp_stderr) {
+ unlink(cpp_stderr);
+ free(cpp_stderr);
+ cpp_stderr = NULL;
+ }
+
+ /* strip any local args */
+ args_strip(orig_args, "--ccache-");
+
+ if ((e=getenv("CCACHE_PREFIX"))) {
+ char *p = find_executable(e, MYNAME);
+ if (!p) {
+ cc_log("could not find executable (%s)\n", e);
+ perror(e);
+ exit(1);
+ }
+ args_add_prefix(orig_args, p);
+ }
+
+ if (ccache_verbose) {
+ display_execute_args(orig_args->argv);
+ }
+
+ if (swig) {
+ putenv("CCACHE_OUTFILES");
+ }
+
+#ifndef _WIN32
+ execv(orig_args->argv[0], orig_args->argv);
+ cc_log("execv returned (%s)!\n", strerror(errno));
+ perror(orig_args->argv[0]);
+ exit(1);
+#else
+ /* execv on Windows causes the 'non-regular' testcase to fail, so use Win32 API instead */
+ {
+ PROCESS_INFORMATION pinfo;
+ STARTUPINFO sinfo;
+ BOOL ret;
+ DWORD exitcode;
+ char *args;
+
+ ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION));
+ ZeroMemory(&sinfo, sizeof(STARTUPINFO));
+ sinfo.cb = sizeof(STARTUPINFO);
+ args = argvtos(orig_args->argv);
+ ret = CreateProcessA(orig_args->argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL,
+ &sinfo, &pinfo);
+ if (!ret) {
+ exitcode = 1;
+ cc_log("CreateProcessA failed starting %s\n", orig_args->argv[0]);
+ perror_win32(orig_args->argv[0]);
+ } else {
+ WaitForSingleObject(pinfo.hProcess, INFINITE);
+ GetExitCodeProcess(pinfo.hProcess, &exitcode);
+ CloseHandle(pinfo.hProcess);
+ CloseHandle(pinfo.hThread);
+ }
+ free(args);
+ exit(exitcode);
+ }
+#endif
+}
+
+
+/* return a string to be used to distinguish temporary files
+ this also tries to cope with NFS by adding the local hostname
+*/
+static const char *tmp_string(void)
+{
+ static char *ret;
+
+ if (!ret) {
+ char hostname[200];
+ strcpy(hostname, "unknown");
+#if HAVE_GETHOSTNAME
+ gethostname(hostname, sizeof(hostname)-1);
+#endif
+ hostname[sizeof(hostname)-1] = 0;
+ if (asprintf(&ret, "%s.%u", hostname, (unsigned)getpid()) == -1) {
+ fatal("could not allocate tmp_string");
+ }
+ }
+
+ return ret;
+}
+
+/* update cached file sizes and count helper function for to_cache() */
+static void to_cache_stats_helper(struct stat *pstat, char *cached_filename, char *tmp_outfiles, int *files_size, int *cached_files_count)
+{
+#if ENABLE_ZLIB
+ /* do an extra stat on the cache file for the size statistics */
+ if (stat(cached_filename, pstat) != 0) {
+ cc_log("failed to stat cache files - %s\n", strerror(errno));
+ stats_update(STATS_ERROR);
+ if (tmp_outfiles) {
+ unlink(tmp_outfiles);
+ }
+ failed();
+ }
+#else
+ (void)cached_filename;
+ (void)tmp_outfiles;
+#endif
+ (*files_size) += file_size(pstat);
+ (*cached_files_count)++;
+}
+
+/* run the real compiler and put the result in cache */
+static void to_cache(ARGS *args)
+{
+ char *path_stderr;
+ char *tmp_stdout, *tmp_stderr, *tmp_outfiles;
+ struct stat st1;
+ int status;
+ int cached_files_count = 0;
+ int files_size = 0;
+
+ x_asprintf(&tmp_stdout, "%s/tmp.stdout.%s", temp_dir, tmp_string());
+ x_asprintf(&tmp_stderr, "%s/tmp.stderr.%s", temp_dir, tmp_string());
+ x_asprintf(&tmp_outfiles, "%s/tmp.outfiles.%s", temp_dir, tmp_string());
+
+ if (strip_c_option && !swig) {
+ args_add(stripped_args, "-c");
+ }
+
+ if (output_file) {
+ args_add(args, "-o");
+ args_add(args, output_file);
+ }
+
+ /* Turn off DEPENDENCIES_OUTPUT when running cc1, because
+ * otherwise it will emit a line like
+ *
+ * tmp.stdout.vexed.732.o: /home/mbp/.ccache/tmp.stdout.vexed.732.i
+ *
+ * unsetenv() is on BSD and Linux but not portable. */
+ putenv("DEPENDENCIES_OUTPUT");
+
+ /* Give SWIG a filename for it to create and populate with a list of files that it generates */
+ if (swig) {
+ char *ccache_outfiles;
+ x_asprintf(&ccache_outfiles, "CCACHE_OUTFILES=%s", tmp_outfiles);
+ unlink(tmp_outfiles);
+ if (getenv("CCACHE_OUTFILES") || putenv(ccache_outfiles) == -1) {
+ cc_log("CCACHE_OUTFILES env variable already set or could not be set\n");
+ stats_update(STATS_ERROR);
+ failed();
+ }
+ }
+
+ if (getenv("CCACHE_CPP2")) {
+ args_add(args, input_file);
+ } else {
+ if (swig) {
+ args_add(args, "-nopreprocess");
+ }
+ args_add(args, i_tmpfile);
+ }
+ status = execute(args->argv, tmp_stdout, tmp_stderr);
+ args_pop(args, 3);
+
+ if (stat(tmp_stdout, &st1) != 0 || st1.st_size != 0) {
+ cc_log("compiler produced stdout for %s\n", input_file);
+ stats_update(STATS_STDOUT);
+ unlink(tmp_stdout);
+ unlink(tmp_stderr);
+ unlink(tmp_outfiles);
+ if (!swig) unlink(output_file);
+ failed();
+ }
+ unlink(tmp_stdout);
+
+ if (status != 0) {
+ int fd;
+ cc_log("compile of %s gave status = %d\n", input_file, status);
+ stats_update(STATS_STATUS);
+
+ fd = open(tmp_stderr, O_RDONLY | O_BINARY);
+ if (fd != -1) {
+ if (cpp_stderr) {
+ /* we might have some stderr from cpp */
+ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY);
+ if (fd2 != -1) {
+ copy_fd(fd2, 2);
+ close(fd2);
+ unlink(cpp_stderr);
+ cpp_stderr = NULL;
+ }
+ }
+
+ /* we can use a quick method of
+ getting the failed output */
+ copy_fd(fd, 2);
+ close(fd);
+ unlink(tmp_stderr);
+ if (i_tmpfile && !direct_i_file) {
+ unlink(i_tmpfile);
+ }
+ exit(status);
+ }
+
+ unlink(tmp_stderr);
+ unlink(tmp_outfiles);
+ if (!swig) unlink(output_file);
+ failed();
+ } else {
+ int hardlink = (getenv("CCACHE_NOCOMPRESS") != 0) && (getenv("CCACHE_HARDLINK") != 0);
+ if (swig) {
+ /* read the list of generated files and copy each of them into the cache */
+ FILE *file;
+ file = fopen(tmp_outfiles, "r");
+ if (file) {
+ char out_filename[FILENAME_MAX + 1];
+ char out_filename_cache[FILENAME_MAX + 1];
+ while (fgets(out_filename, FILENAME_MAX, file)) {
+ char *linefeed = strchr(out_filename, '\n');
+ if (linefeed) {
+ char *potential_cr = linefeed - 1;
+ if (potential_cr >= out_filename && *potential_cr == '\r')
+ *potential_cr = 0;
+ *linefeed = 0;
+
+ if (cached_files_count == 0) {
+ strcpy(out_filename_cache, hashname);
+ } else {
+ sprintf(out_filename_cache, "%s.%d", hashname, cached_files_count);
+ }
+
+ if (commit_to_cache(out_filename, out_filename_cache, hardlink) != 0) {
+ fclose(file);
+ unlink(tmp_outfiles);
+ failed();
+ }
+ to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count);
+ } else {
+ cached_files_count = 0;
+ break;
+ }
+ }
+ fclose(file);
+ if (cached_files_count == 0) {
+ cc_log("failed to copy output files to cache - internal error\n");
+ stats_update(STATS_ERROR);
+ unlink(tmp_outfiles);
+ failed();
+ }
+
+ /* also copy the (uncompressed) file containing the list of generated files into the cache */
+ sprintf(out_filename_cache, "%s.outfiles", hashname);
+ if (stat(tmp_outfiles, &st1) != 0 ||
+ safe_rename(tmp_outfiles, out_filename_cache) != 0) {
+ cc_log("failed to copy outfiles file to cache - %s\n", strerror(errno));
+ stats_update(STATS_ERROR);
+ unlink(tmp_outfiles);
+ failed();
+ }
+ to_cache_stats_helper(&st1, out_filename_cache, tmp_outfiles, &files_size, &cached_files_count);
+ unlink(tmp_outfiles);
+ } else {
+ cc_log("failed to open temp outfiles file - %s\n", strerror(errno));
+ stats_update(STATS_ERROR);
+ failed();
+ }
+ } else {
+ if (commit_to_cache(output_file, hashname, hardlink) != 0) {
+ failed();
+ }
+ to_cache_stats_helper(&st1, hashname, 0, &files_size, &cached_files_count);
+ }
+ }
+
+ x_asprintf(&path_stderr, "%s.stderr", hashname);
+
+ if (stat(tmp_stderr, &st1) != 0 ||
+ move_file(tmp_stderr, path_stderr) != 0) {
+ cc_log("failed to rename tmp files - %s\n", strerror(errno));
+ stats_update(STATS_ERROR);
+ failed();
+ }
+
+ to_cache_stats_helper(&st1, path_stderr, 0, &files_size, &cached_files_count);
+
+ cc_log("Placed %d files for %s into cache\n", cached_files_count, input_file);
+ stats_tocache(files_size, cached_files_count);
+
+ free(tmp_stderr);
+ free(tmp_stdout);
+ free(tmp_outfiles);
+ free(path_stderr);
+}
+
+/* find the hash for a command. The hash includes all argument lists,
+ plus the output from running the compiler with -E */
+static void find_hash(ARGS *args)
+{
+ int i;
+ char *path_stdout, *path_stderr;
+ char *hash_dir;
+ char *s;
+ struct stat st;
+ int status;
+ int nlevels = 2;
+ char *input_base;
+ char *tmp;
+
+ if ((s = getenv("CCACHE_NLEVELS"))) {
+ nlevels = atoi(s);
+ if (nlevels < 1) nlevels = 1;
+ if (nlevels > 8) nlevels = 8;
+ }
+
+ hash_start();
+
+ /* when we are doing the unifying tricks we need to include
+ the input file name in the hash to get the warnings right */
+ if (enable_unify || swig) {
+ hash_string(input_file);
+ }
+
+ if (swig) {
+ if (output_file) {
+ hash_string(output_file);
+ }
+ } else {
+ /* we have to hash the extension, as a .i file isn't treated the same
+ by the compiler as a .ii file */
+ hash_string(i_extension);
+ }
+
+ /* first the arguments */
+ for (i=1;i<args->argc;i++) {
+ /* some arguments don't contribute to the hash. The
+ theory is that these arguments will change the
+ output of -E if they are going to have any effect
+ at all, or they only affect linking */
+ if (i < args->argc-1) {
+ if (strcmp(args->argv[i], "-I") == 0 ||
+ strcmp(args->argv[i], "-include") == 0 ||
+ strcmp(args->argv[i], "-L") == 0 ||
+ strcmp(args->argv[i], "-D") == 0 ||
+ strcmp(args->argv[i], "-idirafter") == 0 ||
+ strcmp(args->argv[i], "-isystem") == 0) {
+ i++;
+ continue;
+ }
+ }
+ if (strncmp(args->argv[i], "-I", 2) == 0 ||
+ strncmp(args->argv[i], "-L", 2) == 0 ||
+ strncmp(args->argv[i], "-D", 2) == 0 ||
+ strncmp(args->argv[i], "-idirafter", 10) == 0 ||
+ strncmp(args->argv[i], "-isystem", 8) == 0) {
+ continue;
+ }
+
+ if (strncmp(args->argv[i], "--specs=", 8) == 0 &&
+ stat(args->argv[i]+8, &st) == 0) {
+ /* if given a explicit specs file, then hash that file, but
+ don't include the path to it in the hash */
+ hash_file(args->argv[i]+8);
+ continue;
+ }
+
+ /* all other arguments are included in the hash */
+ hash_string(args->argv[i]);
+ }
+
+ /* the compiler driver size and date. This is a simple minded way
+ to try and detect compiler upgrades. It is not 100% reliable */
+ if (stat(args->argv[0], &st) != 0) {
+ cc_log("Couldn't stat the compiler!? (argv[0]='%s')\n", args->argv[0]);
+ stats_update(STATS_COMPILER);
+ failed();
+ }
+
+ /* also include the hash of the compiler name - as some compilers
+ use hard links and behave differently depending on the real name */
+ if (st.st_nlink > 1) {
+ hash_string(str_basename(args->argv[0]));
+ }
+
+ hash_int(st.st_size);
+ hash_int(st.st_mtime);
+
+ /* possibly hash the current working directory */
+ if (getenv("CCACHE_HASHDIR")) {
+ char *cwd = gnu_getcwd();
+ if (cwd) {
+ hash_string(cwd);
+ free(cwd);
+ }
+ }
+
+ /* ~/hello.c -> tmp.hello.123.i
+ limit the basename to 10
+ characters in order to cope with filesystem with small
+ maximum filename length limits */
+ input_base = str_basename(input_file);
+ tmp = strchr(input_base, '.');
+ if (tmp != NULL) {
+ *tmp = 0;
+ }
+ if (strlen(input_base) > 10) {
+ input_base[10] = 0;
+ }
+
+ /* now the run */
+ x_asprintf(&path_stdout, "%s/%s.tmp.%s.%s", temp_dir,
+ input_base, tmp_string(),
+ i_extension);
+ x_asprintf(&path_stderr, "%s/tmp.cpp_stderr.%s", temp_dir, tmp_string());
+
+ if (!direct_i_file) {
+ /* run cpp on the input file to obtain the .i */
+ args_add(args, "-E");
+ args_add(args, input_file);
+ status = execute(args->argv, path_stdout, path_stderr);
+ args_pop(args, 2);
+ } else {
+ /* we are compiling a .i or .ii file - that means we
+ can skip the cpp stage and directly form the
+ correct i_tmpfile */
+ path_stdout = x_strdup(input_file);
+ if (create_empty_file(path_stderr) != 0) {
+ cc_log("failed to create empty stderr file\n");
+ stats_update(STATS_ERROR);
+ failed();
+ }
+ status = 0;
+ }
+
+ if (status != 0) {
+ if (!direct_i_file) {
+ unlink(path_stdout);
+ }
+ unlink(path_stderr);
+ cc_log("the preprocessor gave %d\n", status);
+ stats_update(STATS_PREPROCESSOR);
+ failed();
+ }
+
+ /* if the compilation is with -g then we have to include the whole of the
+ preprocessor output, which means we are sensitive to line number
+ information. Otherwise we can discard line number info, which makes
+ us less sensitive to reformatting changes
+
+ Note! I have now disabled the unification code by default
+ as it gives the wrong line numbers for warnings. Pity.
+ */
+ if (!enable_unify) {
+ hash_file(path_stdout);
+ } else {
+ if (unify_hash(path_stdout) != 0) {
+ stats_update(STATS_ERROR);
+ failed();
+ }
+ }
+ hash_file(path_stderr);
+
+ i_tmpfile = path_stdout;
+
+ if (!getenv("CCACHE_CPP2")) {
+ /* if we are using the CPP trick then we need to remember this stderr
+ data and output it just before the main stderr from the compiler
+ pass */
+ cpp_stderr = path_stderr;
+ } else {
+ unlink(path_stderr);
+ free(path_stderr);
+ }
+
+ /* we use a N level subdir for the cache path to reduce the impact
+ on filesystems which are slow for large directories
+ */
+ s = hash_result();
+ x_asprintf(&hash_dir, "%s/%c", cache_dir, s[0]);
+ x_asprintf(&stats_file, "%s/stats", hash_dir);
+ for (i=1; i<nlevels; i++) {
+ char *p;
+ if (create_dir(hash_dir) != 0) {
+ cc_log("failed to create %s\n", hash_dir);
+ stats_update(STATS_ERROR);
+ failed();
+ }
+ x_asprintf(&p, "%s/%c", hash_dir, s[i]);
+ free(hash_dir);
+ hash_dir = p;
+ }
+ if (create_dir(hash_dir) != 0) {
+ cc_log("failed to create %s\n", hash_dir);
+ stats_update(STATS_ERROR);
+ failed();
+ }
+ x_asprintf(&hashname, "%s/%s", hash_dir, s+nlevels);
+ free(hash_dir);
+}
+
+/*
+ try to return the compile result from cache. If we can return from
+ cache then this function exits with the correct status code,
+ otherwise it returns */
+static void from_cache(int first)
+{
+ int fd_stderr, fd_cpp_stderr;
+ char *stderr_file;
+ struct stat st;
+
+ x_asprintf(&stderr_file, "%s.stderr", hashname);
+ fd_stderr = open(stderr_file, O_RDONLY | O_BINARY);
+ if (fd_stderr == -1) {
+ /* it isn't in cache ... */
+ free(stderr_file);
+ return;
+ }
+
+ /* make sure the output is there too */
+ if (stat(hashname, &st) != 0) {
+ close(fd_stderr);
+ unlink(stderr_file);
+ free(stderr_file);
+ return;
+ }
+
+ /* the user might be disabling cache hits */
+#ifndef ENABLE_ZLIB
+ /* if the cache file is compressed we must recache */
+ if ((first && getenv("CCACHE_RECACHE")) ||
+ test_if_compressed(hashname) == 1)
+#else
+ if (first && getenv("CCACHE_RECACHE"))
+#endif
+ {
+ close(fd_stderr);
+ unlink(stderr_file);
+ free(stderr_file);
+ return;
+ }
+
+ if (first) {
+ int hardlink;
+ int passfail = -1;
+
+ /* update timestamps for LRU cleanup
+ also gives output_file a sensible mtime when hard-linking (for make) */
+ x_utimes(stderr_file);
+
+ hardlink = (getenv("CCACHE_HARDLINK") != 0);
+
+ if (swig) {
+ /* read the list of generated files and copy each of them out of the cache */
+ FILE *file;
+ char *outfiles;
+ x_asprintf(&outfiles, "%s.outfiles", hashname);
+ file = fopen(outfiles, "r");
+ if (file) {
+ char out_filename[FILENAME_MAX + 1];
+ char out_filename_cache[FILENAME_MAX + 1];
+ int retrieved_files_count = 0;
+ x_utimes(outfiles);
+ while (fgets(out_filename, FILENAME_MAX, file)) {
+ char *linefeed = strchr(out_filename, '\n');
+ if (linefeed) {
+ char *potential_cr = linefeed - 1;
+ if (potential_cr >= out_filename && *potential_cr == '\r')
+ *potential_cr = 0;
+ *linefeed = 0;
+
+ if (retrieved_files_count == 0) {
+ strcpy(out_filename_cache, hashname);
+ } else {
+ sprintf(out_filename_cache, "%s.%d", hashname, retrieved_files_count);
+ }
+
+ passfail = retrieve_from_cache(out_filename_cache, out_filename, hardlink);
+ if (passfail == -1) {
+ break;
+ }
+
+ retrieved_files_count++;
+ } else {
+ cc_log("failed to copy output files from cache - internal error\n");
+ stats_update(STATS_ERROR);
+ passfail = -1;
+ break;
+ }
+ }
+ if (retrieved_files_count == 0) {
+ cc_log("failed to copy output files from cache - internal error\n");
+ stats_update(STATS_ERROR);
+ passfail = -1;
+ }
+ fclose(file);
+ } else {
+ cc_log("failed to open cached outfiles file - %s\n", strerror(errno));
+ stats_update(STATS_ERROR);
+ }
+ } else {
+ passfail = retrieve_from_cache(hashname, output_file, hardlink);
+ }
+
+ free(stderr_file);
+ if (passfail == -1) {
+ close(fd_stderr);
+ unlink(stderr_file);
+ return;
+ }
+ }
+
+ /* get rid of the intermediate preprocessor file */
+ if (i_tmpfile) {
+ if (!direct_i_file) {
+ unlink(i_tmpfile);
+ }
+ free(i_tmpfile);
+ i_tmpfile = NULL;
+ }
+
+ /* send the cpp stderr, if applicable */
+ fd_cpp_stderr = open(cpp_stderr, O_RDONLY | O_BINARY);
+ if (fd_cpp_stderr != -1) {
+ copy_fd(fd_cpp_stderr, 2);
+ close(fd_cpp_stderr);
+ unlink(cpp_stderr);
+ free(cpp_stderr);
+ cpp_stderr = NULL;
+ }
+
+ /* send the stderr */
+ copy_fd(fd_stderr, 2);
+ close(fd_stderr);
+
+ /* and exit with the right status code */
+ if (first) {
+ cc_log("got cached result for %s\n", input_file);
+ stats_update(STATS_CACHED);
+ }
+
+ exit(0);
+}
+
+/* find the real compiler. We just search the PATH to find a executable of the
+ same name that isn't a link to ourselves */
+static void find_compiler(int argc, char **argv)
+{
+ char *base;
+ char *path;
+
+ orig_args = args_init(argc, argv);
+
+ base = str_basename(argv[0]);
+
+ /* we might be being invoked like "ccache gcc -c foo.c" */
+ if (strcmp(base, MYNAME) == 0) {
+ args_remove_first(orig_args);
+ free(base);
+ if (strchr(argv[1],'/')
+#ifdef _WIN32
+ || strchr(argv[1],'\\')
+#endif
+ ) {
+ /* a full path was given */
+ return;
+ }
+ base = str_basename(argv[1]);
+ }
+
+ /* support user override of the compiler */
+ if ((path=getenv("CCACHE_CC"))) {
+ base = x_strdup(path);
+ }
+
+ orig_args->argv[0] = find_executable(base, MYNAME);
+
+ /* can't find the compiler! */
+ if (!orig_args->argv[0]) {
+ stats_update(STATS_COMPILER);
+ cc_log("could not find compiler (%s)\n", base);
+ perror(base);
+ exit(1);
+ }
+}
+
+
+/* check a filename for C/C++ extension. Return the pre-processor
+ extension */
+static const char *check_extension(const char *fname, int *direct_i)
+{
+ int i;
+ const char *p;
+
+ if (direct_i) {
+ *direct_i = 0;
+ }
+
+ if (swig) return "ii"; /* any file extension is acceptable as input for SWIG */
+
+ p = strrchr(fname, '.');
+ if (!p) return NULL;
+ p++;
+ for (i=0; extensions[i].extension; i++) {
+ if (strcmp(p, extensions[i].extension) == 0) {
+ if (direct_i && strcmp(p, extensions[i].i_extension) == 0) {
+ *direct_i = 1;
+ }
+ p = getenv("CCACHE_EXTENSION");
+ if (p) return p;
+ return extensions[i].i_extension;
+ }
+ }
+ return NULL;
+}
+
+
+/*
+ process the compiler options to form the correct set of options
+ for obtaining the preprocessor output
+*/
+static void process_args(int argc, char **argv)
+{
+ int i;
+ int found_c_opt = 0;
+ int found_S_opt = 0;
+ struct stat st;
+ char *e;
+ /* is gcc being asked to output dependencies? */
+ int generating_dependencies = 0;
+ /* is the dependency makefile name overridden with -MF? */
+ int dependency_filename_specified = 0;
+ /* is the dependency makefile target name specified with -MQ or -MF? */
+ int dependency_target_specified = 0;
+
+
+ stripped_args = args_init(0, NULL);
+
+ args_add(stripped_args, argv[0]);
+
+ /* -c not required for SWIG */
+ if (swig) {
+ found_c_opt = 1;
+ }
+
+ for (i=1; i<argc; i++) {
+ /* some options will never work ... */
+ if (strcmp(argv[i], "-E") == 0) {
+ failed();
+ }
+
+ /* these are too hard */
+ if (strcmp(argv[i], "-fbranch-probabilities")==0 ||
+ strcmp(argv[i], "-fprofile-arcs") == 0 ||
+ strcmp(argv[i], "-ftest-coverage") == 0 ||
+ strcmp(argv[i], "--coverage") == 0 ||
+ strcmp(argv[i], "-M") == 0 ||
+ strcmp(argv[i], "-MM") == 0 ||
+ strcmp(argv[i], "-x") == 0) {
+ cc_log("argument %s is unsupported\n", argv[i]);
+ stats_update(STATS_UNSUPPORTED);
+ failed();
+ continue;
+ }
+
+ /* we must have -c */
+ if (strcmp(argv[i], "-c") == 0) {
+ if (!strip_c_option) {
+ args_add(stripped_args, argv[i]);
+ }
+ found_c_opt = 1;
+ continue;
+ }
+
+ /* -S changes the default extension */
+ if (strcmp(argv[i], "-S") == 0) {
+ args_add(stripped_args, argv[i]);
+ found_S_opt = 1;
+ continue;
+ }
+
+ /* we need to work out where the output was meant to go */
+ if (strcmp(argv[i], "-o") == 0) {
+ if (i == argc-1) {
+ cc_log("missing argument to %s\n", argv[i]);
+ stats_update(STATS_ARGS);
+ failed();
+ }
+ output_file = argv[i+1];
+ i++;
+ continue;
+ }
+
+ /* alternate form of -o, with no space */
+ if (!swig) { /* some of SWIG's arguments begin with -o */
+ if (strncmp(argv[i], "-o", 2) == 0) {
+ output_file = &argv[i][2];
+ continue;
+ }
+ }
+
+ /* debugging is handled specially, so that we know if we
+ can strip line number info
+ */
+ if (strncmp(argv[i], "-g", 2) == 0) {
+ args_add(stripped_args, argv[i]);
+ if (strcmp(argv[i], "-g0") != 0) {
+ enable_unify = 0;
+ }
+ continue;
+ }
+
+ /* The user knows best: just swallow the next arg */
+ if (strcmp(argv[i], "--ccache-skip") == 0) {
+ i++;
+ if (i == argc) {
+ failed();
+ }
+ args_add(stripped_args, argv[i]);
+ continue;
+ }
+
+ /* These options require special handling, because they
+ behave differently with gcc -E, when the output
+ file is not specified. */
+
+ if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) {
+ generating_dependencies = 1;
+ } else if (strcmp(argv[i], "-MF") == 0) {
+ dependency_filename_specified = 1;
+ } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) {
+ dependency_target_specified = 1;
+ }
+
+ /* the input file is already preprocessed */
+ if (swig && strcmp(argv[i], "-nopreprocess") == 0) {
+ direct_i_file = 1;
+ continue;
+ }
+
+ /* options that take an argument */
+ {
+ const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
+ "-iwithprefix", "-iwithprefixbefore",
+ "-L", "-D", "-U", "-x", "-MF",
+ "-MT", "-MQ", "-isystem", "-aux-info",
+ "--param", "-A", "-Xlinker", "-u",
+ "-idirafter",
+ NULL};
+ int j;
+ for (j=0;opts[j];j++) {
+ if (strcmp(argv[i], opts[j]) == 0) {
+ if (i == argc-1) {
+ cc_log("missing argument to %s\n",
+ argv[i]);
+ stats_update(STATS_ARGS);
+ failed();
+ }
+
+ args_add(stripped_args, argv[i]);
+ args_add(stripped_args, argv[i+1]);
+ i++;
+ break;
+ }
+ }
+ if (opts[j]) continue;
+ }
+
+ /* other options */
+ if (argv[i][0] == '-') {
+ args_add(stripped_args, argv[i]);
+ continue;
+ }
+
+ /* if an argument isn't a plain file then assume its
+ an option, not an input file. This allows us to
+ cope better with unusual compiler options */
+ if (stat(argv[i], &st) != 0 || !S_ISREG(st.st_mode)) {
+ args_add(stripped_args, argv[i]);
+ continue;
+ }
+
+ if (input_file) {
+ if (check_extension(argv[i], NULL)) {
+ cc_log("multiple input files (%s and %s)\n",
+ input_file, argv[i]);
+ stats_update(STATS_MULTIPLE);
+ } else if (!found_c_opt) {
+ cc_log("called for link with %s\n", argv[i]);
+ if (strstr(argv[i], "conftest.")) {
+ stats_update(STATS_CONFTEST);
+ } else {
+ stats_update(STATS_LINK);
+ }
+ } else {
+ cc_log("non C/C++ file %s\n", argv[i]);
+ stats_update(STATS_NOTC);
+ }
+ failed();
+ }
+
+ input_file = argv[i];
+ }
+
+ if (!input_file) {
+ cc_log("No input file found\n");
+ stats_update(STATS_NOINPUT);
+ failed();
+ }
+
+ if (swig) {
+ i_extension = check_extension(input_file, NULL);
+ } else {
+ i_extension = check_extension(input_file, &direct_i_file);
+ }
+ if (i_extension == NULL) {
+ cc_log("Not a C/C++ file - %s\n", input_file);
+ stats_update(STATS_NOTC);
+ failed();
+ }
+
+ if (!found_c_opt) {
+ cc_log("No -c option found for %s\n", input_file);
+ /* I find that having a separate statistic for autoconf tests is useful,
+ as they are the dominant form of "called for link" in many cases */
+ if (strstr(input_file, "conftest.")) {
+ stats_update(STATS_CONFTEST);
+ } else {
+ stats_update(STATS_LINK);
+ }
+ failed();
+ }
+
+
+ /* don't try to second guess the compilers heuristics for stdout handling */
+ if (output_file && strcmp(output_file, "-") == 0) {
+ stats_update(STATS_OUTSTDOUT);
+ failed();
+ }
+
+ if (!swig && !output_file) {
+ char *p;
+ output_file = x_strdup(input_file);
+ if ((p = strrchr(output_file, '/'))) {
+ output_file = p+1;
+ }
+ p = strrchr(output_file, '.');
+ if (!p || !p[1]) {
+ cc_log("badly formed output_file %s\n", output_file);
+ stats_update(STATS_ARGS);
+ failed();
+ }
+ p[1] = found_S_opt ? 's' : 'o';
+ p[2] = 0;
+ }
+
+ /* If dependencies are generated, configure the preprocessor */
+
+ if (generating_dependencies && output_file) {
+ if (!dependency_filename_specified) {
+ char *default_depfile_name = x_strdup(output_file);
+ char *p = strrchr(default_depfile_name, '.');
+
+ if (p) {
+ if (strlen(p) < 2) {
+ cc_log("badly formed dependency file %s\n", output_file);
+ stats_update(STATS_ARGS);
+ failed();
+ return;
+ }
+ *p = 0;
+ }
+ else {
+ int len = p - default_depfile_name;
+
+ p = x_malloc(len + 3);
+ strncpy(default_depfile_name, p, len - 1);
+ free(default_depfile_name);
+ default_depfile_name = p;
+ }
+
+ strcat(default_depfile_name, ".d");
+ args_add(stripped_args, "-MF");
+ args_add(stripped_args, default_depfile_name);
+ }
+
+ if (!dependency_target_specified) {
+ args_add(stripped_args, "-MT");
+ args_add(stripped_args, output_file);
+ }
+ }
+
+ /* cope with -o /dev/null */
+ if (output_file && strcmp(output_file,"/dev/null") != 0 && stat(output_file, &st) == 0 && !S_ISREG(st.st_mode)) {
+ cc_log("Not a regular file %s\n", output_file);
+ stats_update(STATS_DEVICE);
+ failed();
+ }
+
+ if ((e=getenv("CCACHE_PREFIX"))) {
+ char *p = find_executable(e, MYNAME);
+ if (!p) {
+ cc_log("could not find executable (%s)\n", e);
+ stats_update(STATS_ENVIRONMMENT);
+ perror(e);
+ exit(1);
+ }
+ args_add_prefix(stripped_args, p);
+ }
+}
+
+static void detect_swig()
+{
+ char *basename = str_basename(orig_args->argv[0]);
+ if (strstr(basename, "swig") || getenv("CCACHE_SWIG")) {
+ swig = 1;
+ }
+ free(basename);
+}
+
+/* the main ccache driver function */
+static void ccache(int argc, char *argv[])
+{
+ /* find the real compiler */
+ find_compiler(argc, argv);
+
+ /* use the real compiler if HOME is not set */
+ if (!cache_dir) {
+ cc_log("Unable to determine home directory\n");
+ cc_log("ccache is disabled\n");
+ failed();
+ }
+
+ /* we might be disabled */
+ if (getenv("CCACHE_DISABLE")) {
+ cc_log("ccache is disabled\n");
+ failed();
+ }
+
+ if (getenv("CCACHE_STRIPC")) {
+ strip_c_option = 1;
+ }
+
+ if (getenv("CCACHE_UNIFY")) {
+ enable_unify = 1;
+ }
+
+ detect_swig();
+
+ /* process argument list, returning a new set of arguments for pre-processing */
+ process_args(orig_args->argc, orig_args->argv);
+
+ /* run with -E to find the hash */
+ find_hash(stripped_args);
+
+ /* if we can return from cache at this point then do */
+ from_cache(1);
+
+ if (getenv("CCACHE_READONLY")) {
+ cc_log("read-only set - doing real compile\n");
+ failed();
+ }
+
+ /* run real compiler, sending output to cache */
+ to_cache(stripped_args);
+
+ /* return from cache */
+ from_cache(0);
+
+ /* oh oh! */
+ cc_log("secondary from_cache failed!\n");
+ stats_update(STATS_ERROR);
+ failed();
+}
+
+
+static void usage(void)
+{
+ printf("%s, a compiler cache including support for SWIG. Version %s\n", MYNAME, CCACHE_VERSION);
+ printf("Copyright Andrew Tridgell, 2002\n\n");
+
+ printf("Usage:\n");
+ printf("\t" MYNAME " [options]\n");
+ printf("\t" MYNAME " compiler [compile options]\n");
+ printf("\tcompiler [compile options] (via symbolic link)\n");
+ printf("\nOptions:\n");
+
+ printf("-s show statistics summary\n");
+ printf("-z zero statistics\n");
+ printf("-c run a cache cleanup\n");
+ printf("-C clear the cache completely\n");
+ printf("-F <maxfiles> set maximum files in cache\n");
+ printf("-M <maxsize> set maximum size of cache (use G, M or K)\n");
+ printf("-h this help page\n");
+ printf("-V print version number\n");
+}
+
+static void check_cache_dir(void)
+{
+ if (!cache_dir) {
+ fatal("Unable to determine home directory");
+ }
+}
+
+/* the main program when not doing a compile */
+static int ccache_main(int argc, char *argv[])
+{
+ int c;
+ size_t v;
+
+ while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) {
+ switch (c) {
+ case 'V':
+ printf("%s version %s\n", MYNAME, CCACHE_VERSION);
+ printf("Copyright Andrew Tridgell 2002\n");
+ printf("Released under the GNU GPL v2 or later\n");
+ exit(0);
+
+ case 'h':
+ usage();
+ exit(0);
+
+ case 's':
+ check_cache_dir();
+ stats_summary();
+ break;
+
+ case 'c':
+ check_cache_dir();
+ cleanup_all(cache_dir);
+ printf("Cleaned cache\n");
+ break;
+
+ case 'C':
+ check_cache_dir();
+ wipe_all(cache_dir);
+ printf("Cleared cache\n");
+ break;
+
+ case 'z':
+ check_cache_dir();
+ stats_zero();
+ printf("Statistics cleared\n");
+ break;
+
+ case 'F':
+ check_cache_dir();
+ v = atoi(optarg);
+ if (stats_set_limits(v, -1) == 0) {
+ printf("Set cache file limit to %u\n", (unsigned)v);
+ } else {
+ printf("Could not set cache file limit.\n");
+ exit(1);
+ }
+ break;
+
+ case 'M':
+ check_cache_dir();
+ v = value_units(optarg);
+ if (stats_set_limits(-1, v) == 0) {
+ printf("Set cache size limit to %uk\n", (unsigned)v);
+ } else {
+ printf("Could not set cache size limit.\n");
+ exit(1);
+ }
+ break;
+
+ default:
+ usage();
+ exit(1);
+ }
+ }
+
+ return 0;
+}
+
+
+/* Make a copy of stderr that will not be cached, so things like
+ distcc can send networking errors to it. */
+static void setup_uncached_err(void)
+{
+ char *buf;
+ int uncached_fd;
+
+ uncached_fd = dup(2);
+ if (uncached_fd == -1) {
+ cc_log("dup(2) failed\n");
+ stats_update(STATS_ERROR);
+ failed();
+ }
+
+ /* leak a pointer to the environment */
+ x_asprintf(&buf, "UNCACHED_ERR_FD=%d", uncached_fd);
+
+ if (putenv(buf) == -1) {
+ cc_log("putenv failed\n");
+ stats_update(STATS_ERROR);
+ failed();
+ }
+}
+
+
+int main(int argc, char *argv[])
+{
+ char *p;
+
+ cache_dir = getenv("CCACHE_DIR");
+ if (!cache_dir) {
+ const char *home_directory = get_home_directory();
+ if (home_directory) {
+ x_asprintf(&cache_dir, "%s/.ccache", home_directory);
+ }
+ }
+
+ cache_logfile = getenv("CCACHE_LOGFILE");
+
+ if (getenv("CCACHE_VERBOSE")) {
+ ccache_verbose = 1;
+ }
+
+ setup_uncached_err();
+
+
+ /* the user might have set CCACHE_UMASK */
+ p = getenv("CCACHE_UMASK");
+ if (p) {
+ mode_t mask;
+ errno = 0;
+ mask = strtol(p, NULL, 8);
+ if (errno == 0) {
+ umask(mask);
+ }
+ }
+
+
+ /* check if we are being invoked as "ccache" */
+ if (strlen(argv[0]) >= strlen(MYNAME) &&
+ strcmp(argv[0] + strlen(argv[0]) - strlen(MYNAME), MYNAME) == 0) {
+ if (argc < 2) {
+ usage();
+ exit(1);
+ }
+ /* if the first argument isn't an option, then assume we are
+ being passed a compiler name and options */
+ if (argv[1][0] == '-') {
+ return ccache_main(argc, argv);
+ }
+ }
+
+ /* make sure the cache dir exists */
+ if (cache_dir && (create_dir(cache_dir) != 0)) {
+ fprintf(stderr,"ccache: failed to create %s (%s)\n",
+ cache_dir, strerror(errno));
+ exit(1);
+ }
+
+ temp_dir = getenv("CCACHE_TEMPDIR");
+ if (!temp_dir) {
+ x_asprintf(&temp_dir, "%s/temp", cache_dir);
+ /* make sure temp dir exists if not supplied by user */
+ if (temp_dir && create_dir(temp_dir) != 0) {
+ fprintf(stderr,"ccache: failed to create %s (%s)\n",
+ temp_dir, strerror(errno));
+ exit(1);
+ }
+ }
+
+ if (!getenv("CCACHE_READONLY")) {
+ if (create_cachedirtag(cache_dir) != 0) {
+ fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n",
+ cache_dir, strerror(errno));
+ exit(1);
+ }
+ }
+
+ ccache(argc, argv);
+ return 1;
+}
diff --git a/CCache/ccache.h b/CCache/ccache.h
new file mode 100644
index 000000000..668ce8288
--- /dev/null
+++ b/CCache/ccache.h
@@ -0,0 +1,205 @@
+#include "ccache_swig_config.h"
+
+#define CCACHE_VERSION SWIG_VERSION
+
+#ifndef _WIN32
+#include "config.h"
+#else
+#include <sys/locking.h>
+#define PACKAGE_NAME "ccache-swig.exe"
+#endif
+
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#ifndef _WIN32
+ #include <sys/wait.h>
+ #include <sys/mman.h>
+#else
+#define _WIN32_WINNT 0x0500
+ #include <windows.h>
+ #include <shlobj.h>
+#endif
+
+#include <sys/file.h>
+#include <fcntl.h>
+#include <time.h>
+#include <string.h>
+#include <ctype.h>
+#include <utime.h>
+#include <stdarg.h>
+#include <dirent.h>
+#include <limits.h>
+#ifdef HAVE_PWD_H
+#include <pwd.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+
+#ifdef ENABLE_ZLIB
+#include <zlib.h>
+#endif
+
+#define STATUS_NOTFOUND 3
+#define STATUS_FATAL 4
+#define STATUS_NOCACHE 5
+
+#define MYNAME PACKAGE_NAME
+
+#define LIMIT_MULTIPLE 0.8
+
+/* default maximum cache size */
+#ifndef DEFAULT_MAXSIZE
+#define DEFAULT_MAXSIZE (1000*1000)
+#endif
+
+/* file copy mode */
+#ifdef ENABLE_ZLIB
+#define COPY_UNCOMPRESSED 0
+#define COPY_FROM_CACHE 1
+#define COPY_TO_CACHE 2
+#endif
+
+enum stats {
+ STATS_NONE=0,
+ STATS_STDOUT,
+ STATS_STATUS,
+ STATS_ERROR,
+ STATS_TOCACHE,
+ STATS_PREPROCESSOR,
+ STATS_COMPILER,
+ STATS_MISSING,
+ STATS_CACHED,
+ STATS_ARGS,
+ STATS_LINK,
+ STATS_NUMFILES,
+ STATS_TOTALSIZE,
+ STATS_MAXFILES,
+ STATS_MAXSIZE,
+ STATS_NOTC,
+ STATS_DEVICE,
+ STATS_NOINPUT,
+ STATS_ENVIRONMMENT,
+ STATS_MULTIPLE,
+ STATS_CONFTEST,
+ STATS_UNSUPPORTED,
+ STATS_OUTSTDOUT,
+
+ STATS_END
+};
+
+typedef unsigned uint32;
+
+#include "mdfour.h"
+
+void hash_start(void);
+void hash_string(const char *s);
+void hash_int(int x);
+void hash_file(const char *fname);
+char *hash_result(void);
+void hash_buffer(const char *s, int len);
+
+void cc_log(const char *format, ...);
+void fatal(const char *msg);
+
+void copy_fd(int fd_in, int fd_out);
+int safe_rename(const char* oldpath, const char* newpath);
+int move_file(const char *src, const char *dest);
+int test_if_compressed(const char *filename);
+
+int commit_to_cache(const char *src, const char *dest, int hardlink);
+int retrieve_from_cache(const char *src, const char *dest, int hardlink);
+
+int create_dir(const char *dir);
+int create_cachedirtag(const char *dir);
+void x_asprintf(char **ptr, const char *format, ...);
+char *x_strdup(const char *s);
+void *x_realloc(void *ptr, size_t size);
+void *x_malloc(size_t size);
+void traverse(const char *dir, void (*fn)(const char *, struct stat *));
+char *str_basename(const char *s);
+char *dirname(char *s);
+int lock_fd(int fd);
+size_t file_size(struct stat *st);
+int safe_open(const char *fname);
+char *x_realpath(const char *path);
+char *gnu_getcwd(void);
+int create_empty_file(const char *fname);
+const char *get_home_directory(void);
+int x_utimes(const char *filename);
+#ifdef _WIN32
+void perror_win32(LPTSTR pszFunction);
+#endif
+
+void stats_update(enum stats stat);
+void stats_zero(void);
+void stats_summary(void);
+void stats_tocache(size_t size, size_t numfiles);
+void stats_read(const char *stats_file, unsigned counters[STATS_END]);
+int stats_set_limits(long maxfiles, long maxsize);
+size_t value_units(const char *s);
+void display_size(unsigned v);
+void stats_set_sizes(const char *dir, size_t num_files, size_t total_size);
+
+int unify_hash(const char *fname);
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **, const char *, va_list );
+#endif
+#ifndef HAVE_ASPRINTF
+int asprintf(char **ptr, const char *format, ...);
+#endif
+
+#ifndef HAVE_SNPRINTF
+int snprintf(char *,size_t ,const char *, ...);
+#endif
+
+void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize);
+void cleanup_all(const char *dir);
+void wipe_all(const char *dir);
+
+#ifdef _WIN32
+char *argvtos(char **argv);
+#endif
+int execute(char **argv,
+ const char *path_stdout,
+ const char *path_stderr);
+char *find_executable(const char *name, const char *exclude_name);
+void display_execute_args(char **argv);
+
+typedef struct {
+ char **argv;
+ int argc;
+} ARGS;
+
+
+ARGS *args_init(int , char **);
+void args_add(ARGS *args, const char *s);
+void args_add_prefix(ARGS *args, const char *s);
+void args_pop(ARGS *args, int n);
+void args_strip(ARGS *args, const char *prefix);
+void args_remove_first(ARGS *args);
+
+extern int ccache_verbose;
+
+#if HAVE_COMPAR_FN_T
+#define COMPAR_FN_T __compar_fn_t
+#else
+typedef int (*COMPAR_FN_T)(const void *, const void *);
+#endif
+
+/* work with silly DOS binary open */
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
+/* mkstemp() on some versions of cygwin don't handle binary files, so
+ override */
+#ifdef __CYGWIN__
+#undef HAVE_MKSTEMP
+#endif
diff --git a/CCache/ccache.yo b/CCache/ccache.yo
new file mode 100644
index 000000000..2477662dc
--- /dev/null
+++ b/CCache/ccache.yo
@@ -0,0 +1,422 @@
+whenman(
+COMMENT(html output not great if included when using html2doc)
+manpage(ccache-swig)(1)()()()
+)
+
+whenhtml(htmlcommand(
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>ccache-swig(1) manpage</title>
+<link rel="stylesheet" type="text/css" href="style.css">
+</head>
+
+<body bgcolor="#ffffff">
+<H1><a name="CCache"></a>Using SWIG with ccache - ccache-swig(1) manpage</H1>
+<!-- INDEX -->
+<div class="sectiontoc">
+<!-- INDEX -->
+
+))
+
+
+manpagename(ccache-swig)(a fast compiler cache)
+
+whenhtml(htmlcommand(
+ccache-swig - a fast compiler cache
+))
+
+manpagesynopsis()
+
+ccache-swig [OPTION]
+
+ccache-swig <compiler> [COMPILER OPTIONS]
+
+<compiler> [COMPILER OPTIONS]
+
+manpagedescription()
+
+ccache-swig is a compiler cache. It speeds up re-compilation of C/C++/SWIG code
+by caching previous compiles and detecting when the same compile is
+being done again. ccache-swig is ccache plus support for SWIG. ccache
+and ccache-swig are used interchangeably in this document.
+
+manpagesection(OPTIONS SUMMARY)
+
+Here is a summary of the options to ccache-swig.
+
+verb(
+-s show statistics summary
+-z zero statistics
+-c run a cache cleanup
+-C clear the cache completely
+-F <n> set maximum files in cache
+-M <n> set maximum size of cache (use G, M or K)
+-h this help page
+-V print version number
+)
+
+manpageoptions()
+
+These options only apply when you invoke ccache as "ccache-swig". When
+invoked as a compiler none of these options apply. In that case your
+normal compiler options apply and you should refer to your compilers
+documentation.
+
+startdit()
+dit(bf(-h)) Print a options summary page
+
+dit(bf(-s)) Print the current statistics summary for the cache. The
+statistics are stored spread across the subdirectories of the
+cache. Using "ccache-swig -s" adds up the statistics across all
+subdirectories and prints the totals.
+
+dit(bf(-z)) Zero the cache statistics.
+
+dit(bf(-V)) Print the ccache version number
+
+dit(bf(-c)) Clean the cache and re-calculate the cache file count and
+size totals. Normally the -c option should not be necessary as ccache
+keeps the cache below the specified limits at runtime and keeps
+statistics up to date on each compile. This option is mostly useful
+if you manually modify the cache contents or believe that the cache
+size statistics may be inaccurate.
+
+dit(bf(-C)) Clear the entire cache, removing all cached files.
+
+dit(bf(-F <maxfiles>)) This sets the maximum number of files allowed in
+the cache. The value is stored inside the cache directory and applies
+to all future compiles. Due to the way the value is stored the actual
+value used is always rounded down to the nearest multiple of 16.
+
+dit(bf(-M <maxsize>)) This sets the maximum cache size. You can specify
+a value in gigabytes, megabytes or kilobytes by appending a G, M or K
+to the value. The default is gigabytes. The actual value stored is
+rounded down to the nearest multiple of 16 kilobytes.
+
+enddit()
+
+manpagesection(INSTALLATION)
+
+There are two ways to use ccache. You can either prefix your compile
+commands with "ccache-swig" or you can create a symbolic link between
+ccache-swig and the names of your compilers. The first method is most
+convenient if you just want to try out ccache or wish to use it for
+some specific projects. The second method is most useful for when you
+wish to use ccache for all your compiles.
+
+To install for usage by the first method just copy ccache-swig to somewhere
+in your path.
+
+To install for the second method do something like this:
+verb(
+ cp ccache-swig /usr/local/bin/
+ ln -s /usr/local/bin/ccache-swig /usr/local/bin/gcc
+ ln -s /usr/local/bin/ccache-swig /usr/local/bin/g++
+ ln -s /usr/local/bin/ccache-swig /usr/local/bin/cc
+ ln -s /usr/local/bin/ccache-swig /usr/local/bin/swig
+)
+This will work as long as /usr/local/bin comes before the path to gcc
+(which is usually in /usr/bin). After installing you may wish to run
+"which gcc" to make sure that the correct link is being used.
+
+Note! Do not use a hard link, use a symbolic link. A hardlink will
+cause "interesting" problems.
+
+manpagesection(EXTRA OPTIONS)
+
+When run as a compiler front end ccache usually just takes the same
+command line options as the compiler you are using. The only exception
+to this is the option '--ccache-skip'. That option can be used to tell
+ccache that the next option is definitely not a input filename, and
+should be passed along to the compiler as-is.
+
+The reason this can be important is that ccache does need to parse the
+command line and determine what is an input filename and what is a
+compiler option, as it needs the input filename to determine the name
+of the resulting object file (among other things). The heuristic
+ccache uses in this parse is that any string on the command line that
+exists as a file is treated as an input file name (usually a C
+file). By using --ccache-skip you can force an option to not be
+treated as an input file name and instead be passed along to the
+compiler as a command line option.
+
+manpagesection(ENVIRONMENT VARIABLES)
+
+ccache uses a number of environment variables to control operation. In
+most cases you won't need any of these as the defaults will be fine.
+
+startdit()
+
+dit(bf(CCACHE_DIR)) the CCACHE_DIR environment variable specifies
+where ccache will keep its cached compiler output. The default is
+"$HOME/.ccache".
+
+dit(bf(CCACHE_TEMPDIR)) the CCACHE_TEMPDIR environment variable specifies
+where ccache will put temporary files. The default is the same as
+CCACHE_DIR. Note that the CCACHE_TEMPDIR path must be on the same
+filesystem as the CCACHE_DIR path, so that renames of files between
+the two directories can work.
+
+dit(bf(CCACHE_LOGFILE)) If you set the CCACHE_LOGFILE environment
+variable then ccache will write some log information on cache hits
+and misses in that file. This is useful for tracking down problems.
+
+dit(bf(CCACHE_VERBOSE)) If you set the CCACHE_VERBOSE environment
+variable then ccache will display on stdout all the compiler invocations
+that it makes. This can useful for debugging unexpected problems.
+
+dit(bf(CCACHE_PATH)) You can optionally set CCACHE_PATH to a colon
+separated path where ccache will look for the real compilers. If you
+don't do this then ccache will look for the first executable matching
+the compiler name in the normal PATH that isn't a symbolic link to
+ccache itself.
+
+dit(bf(CCACHE_CC)) You can optionally set CCACHE_CC to force the name
+of the compiler to use. If you don't do this then ccache works it out
+from the command line.
+
+dit(bf(CCACHE_PREFIX)) This option adds a prefix to the command line
+that ccache runs when invoking the compiler. Also see the section
+below on using ccache with distcc.
+
+dit(bf(CCACHE_DISABLE)) If you set the environment variable
+CCACHE_DISABLE then ccache will just call the real compiler,
+bypassing the cache completely.
+
+dit(bf(CCACHE_READONLY)) the CCACHE_READONLY environment variable
+tells ccache to attempt to use existing cached object files, but not
+to try to add anything new to the cache. If you are using this because
+your CCACHE_DIR is read-only, then you may find that you also need to
+set CCACHE_TEMPDIR as otherwise ccache will fail to create the
+temporary files.
+
+dit(bf(CCACHE_CPP2)) If you set the environment variable CCACHE_CPP2
+then ccache will not use the optimisation of avoiding the 2nd call to
+the pre-processor by compiling the pre-processed output that was used
+for finding the hash in the case of a cache miss. This is primarily a
+debugging option, although it is possible that some unusual compilers
+will have problems with the intermediate filename extensions used in
+this optimisation, in which case this option could allow ccache to be
+used.
+
+dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable
+CCACHE_NOCOMPRESS then there is no compression used on files that go
+into the cache. However, this setting has no effect on how files are
+retrieved from the cache, compressed results will still be usable.
+
+dit(bf(CCACHE_NOSTATS)) If you set the environment variable
+CCACHE_NOSTATS then ccache will not update the statistics files on
+each compile.
+
+dit(bf(CCACHE_NLEVELS)) The environment variable CCACHE_NLEVELS allows
+you to choose the number of levels of hash in the cache directory. The
+default is 2. The minimum is 1 and the maximum is 8.
+
+dit(bf(CCACHE_HARDLINK)) If you set the environment variable
+CCACHE_HARDLINK then ccache will attempt to use hard links from the
+cache directory when creating the compiler output rather than using a
+file copy. Using hard links is faster, but can confuse programs like
+'make' that rely on modification times. Hard links are never made for
+compressed cache files.
+
+dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached
+results, even if it finds them. New results are still cached, but
+existing cache entries are ignored.
+
+dit(bf(CCACHE_UMASK)) This sets the umask for ccache and all child
+processes (such as the compiler). This is mostly useful when you wish
+to share your cache with other users. Note that this also affects the
+file permissions set on the object files created from your
+compilations.
+
+dit(bf(CCACHE_HASHDIR)) This tells ccache to hash the current working
+directory when calculating the hash that is used to distinguish two
+compiles. This prevents a problem with the storage of the current
+working directory in the debug info of a object file, which can lead
+ccache to give a cached object file that has the working directory in
+the debug info set incorrectly. This option is off by default as the
+incorrect setting of this debug info rarely causes problems. If you
+strike problems with gdb not using the correct directory then enable
+this option.
+
+dit(bf(CCACHE_UNIFY)) If you set the environment variable CCACHE_UNIFY
+then ccache will use the C/C++ unifier when hashing the pre-processor
+output if -g is not used in the compile. The unifier is slower than a
+normal hash, so setting this environment variable loses a little bit
+of speed, but it means that ccache can take advantage of not
+recompiling when the changes to the source code consist of
+reformatting only. Note that using CCACHE_UNIFY changes the hash, so
+cached compiles with CCACHE_UNIFY set cannot be used when
+CCACHE_UNIFY is not set and vice versa. The reason the unifier is off
+by default is that it can give incorrect line number information in
+compiler warning messages.
+
+dit(bf(CCACHE_EXTENSION)) Normally ccache tries to automatically
+determine the extension to use for intermediate C pre-processor files
+based on the type of file being compiled. Unfortunately this sometimes
+doesn't work, for example when using the aCC compiler on HP-UX. On
+systems like this you can use the CCACHE_EXTENSION option to override
+the default. On HP-UX set this environment variable to "i" if you use
+the aCC compiler.
+
+dit(bf(CCACHE_STRIPC)) If you set the environment variable
+CCACHE_STRIPC then ccache will strip the -c option when invoking
+the preprocessor. This option is primarily for the Sun Workshop
+C++ compiler as without this option an unwarranted warning is displayed:
+CC: Warning: "-E" redefines product from "object" to "source (stdout)"
+when -E and -c is used together.
+
+dit(bf(CCACHE_SWIG)) When using SWIG as the compiler and it does not
+have 'swig' in the executable name, then the CCACHE_SWIG environment
+variable needs to be set in order for ccache to work correctly with
+SWIG. The use of CCACHE_CPP2 is also recommended for SWIG due to some
+preprocessor quirks, however, use of CCACHE_CPP2 can often be skipped
+-- check your generated code with and without this option set. Known
+problems are using preprocessor directives within %inline blocks and
+the use of '#pragma SWIG'.
+
+enddit()
+
+manpagesection(CACHE SIZE MANAGEMENT)
+
+By default ccache has a one gigabyte limit on the cache size and no
+maximum number of files. You can set a different limit using the
+"ccache -M" and "ccache -F" options, which set the size and number of
+files limits.
+
+When these limits are reached ccache will reduce the cache to 20%
+below the numbers you specified in order to avoid doing the cache
+clean operation too often.
+
+manpagesection(CACHE COMPRESSION)
+
+By default on most platforms ccache will compress all files it puts
+into the cache
+using the zlib compression. While this involves a negligible
+performance slowdown, it significantly increases the number of files
+that fit in the cache. You can turn off compression setting the
+CCACHE_NOCOMPRESS environment variable.
+
+manpagesection(HOW IT WORKS)
+
+The basic idea is to detect when you are compiling exactly the same
+code a 2nd time and use the previously compiled output. You detect
+that it is the same code by forming a hash of:
+
+itemization(
+ it() the pre-processor output from running the compiler with -E
+ it() the command line options
+ it() the real compilers size and modification time
+ it() any stderr output generated by the compiler
+)
+
+These are hashed using md4 (a strong hash) and a cache file is formed
+based on that hash result. When the same compilation is done a second
+time ccache is able to supply the correct compiler output (including
+all warnings etc) from the cache.
+
+ccache has been carefully written to always produce exactly the same
+compiler output that you would get without the cache. If you ever
+discover a case where ccache changes the output of your compiler then
+please let me know.
+
+manpagesection(USING CCACHE WITH DISTCC)
+
+distcc is a very useful program for distributing compilation across a
+range of compiler servers. It is often useful to combine distcc with
+ccache, so that compiles that are done are sped up by distcc, but that
+ccache avoids the compile completely where possible.
+
+To use distcc with ccache I recommend using the CCACHE_PREFIX
+option. You just need to set the environment variable CCACHE_PREFIX to
+'distcc' and ccache will prefix the command line used with the
+compiler with the command 'distcc'.
+
+manpagesection(SHARING A CACHE)
+
+A group of developers can increase the cache hit rate by sharing a
+cache directory. The hard links however cause unwanted side effects,
+as all links to a cached file share the file's modification timestamp.
+This results in false dependencies to be triggered by timestamp-based
+build systems whenever another user links to an existing
+file. Typically, users will see that their libraries and binaries are
+relinked without reason. To share a cache without side effects, the
+following conditions need to be met:
+
+itemization(
+ it() Use the same bf(CCACHE_DIR) environment variable setting
+ it() Unset the bf(CCACHE_HARDLINK) environment variable
+ it() Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+ the group.
+ it() Make sure that all users have write permission in the entire
+ cache directory (and that you trust all users of the shared cache).
+ it() Make sure that the setgid bit is set on all directories in the
+ cache. This tells the filesystem to inherit group ownership for new
+ directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
+ be useful for this.
+ it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with
+ versions of ccache that do not support compression.
+)
+
+manpagesection(HISTORY)
+
+ccache was inspired by the compilercache shell script script written
+by Erik Thiele and I would like to thank him for an excellent piece of
+work. See
+url(http://www.erikyyy.de/compilercache/)(http://www.erikyyy.de/compilercache/)
+for the Erik's scripts.
+ccache-swig is a port of the original ccache with support added for use
+with SWIG.
+
+I wrote ccache because I wanted to get a bit more speed out of a
+compiler cache and I wanted to remove some of the limitations of the
+shell-script version.
+
+manpagesection(DIFFERENCES FROM COMPILERCACHE)
+
+The biggest differences between Erik's compilercache script and ccache
+are:
+itemization(
+it() ccache is written in C, which makes it a bit faster (calling out to
+ external programs is mostly what slowed down the scripts).
+it() ccache can automatically find the real compiler
+it() ccache keeps statistics on hits/misses
+it() ccache can do automatic cache management
+it() ccache can cache compiler output that includes warnings. In many
+ cases this gives ccache a much higher cache hit rate.
+it() ccache can handle a much wider ranger of compiler options
+it() ccache avoids a double call to cpp on a cache miss
+)
+
+manpagesection(CREDITS)
+
+Thanks to the following people for their contributions to ccache
+itemization(
+ it() Erik Thiele for the original compilercache script
+ it() Luciano Rocha for the idea of compiling the pre-processor output
+ to avoid a 2nd cpp pass
+ it() Paul Russell for many suggestions and the debian packaging
+)
+
+manpageauthor()
+
+ccache was written by Andrew Tridgell
+url(http://samba.org/~tridge/)(http://samba.org/~tridge/).
+ccache was adapted to create ccache-swig for use with SWIG by William Fulton.
+
+If you wish to report a problem or make a suggestion then please email
+the SWIG developers on the swig-devel mailing list, see
+url(http://www.swig.org/mail.html)(http://www.swig.org/mail.html)
+
+ccache is released under the GNU General Public License version 2 or
+later. Please see the file COPYING for license details.
+
+whenhtml(htmlcommand(
+
+</body>
+</html>
+
+))
diff --git a/CCache/ccache_swig_config.h.in b/CCache/ccache_swig_config.h.in
new file mode 100644
index 000000000..bbb205f77
--- /dev/null
+++ b/CCache/ccache_swig_config.h.in
@@ -0,0 +1 @@
+#define SWIG_VERSION "@PACKAGE_VERSION@"
diff --git a/CCache/cleanup.c b/CCache/cleanup.c
new file mode 100644
index 000000000..99312283e
--- /dev/null
+++ b/CCache/cleanup.c
@@ -0,0 +1,193 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ functions to cleanup the cache directory when it gets too large
+ */
+
+#include "ccache.h"
+
+static struct files {
+ char *fname;
+ time_t mtime;
+ size_t size;
+} **files;
+static unsigned allocated;
+static unsigned num_files;
+static size_t total_size;
+static size_t total_files;
+static size_t size_threshold;
+static size_t files_threshold;
+
+/* file comparison function to try to delete the oldest files first */
+static int files_compare(struct files **f1, struct files **f2)
+{
+ if ((*f2)->mtime == (*f1)->mtime) {
+ return strcmp((*f2)->fname, (*f1)->fname);
+ }
+ if ((*f2)->mtime > (*f1)->mtime) {
+ return -1;
+ }
+ return 1;
+}
+
+/* this builds the list of files in the cache */
+static void traverse_fn(const char *fname, struct stat *st)
+{
+ char *p;
+
+ if (!S_ISREG(st->st_mode)) return;
+
+ p = str_basename(fname);
+ if (strcmp(p, "stats") == 0) {
+ free(p);
+ return;
+ }
+ free(p);
+
+ if (num_files == allocated) {
+ allocated = 10000 + num_files*2;
+ files = (struct files **)x_realloc(files,
+ sizeof(struct files *)*allocated);
+ }
+
+ files[num_files] = (struct files *)x_malloc(sizeof(struct files));
+ files[num_files]->fname = x_strdup(fname);
+ files[num_files]->mtime = st->st_mtime;
+ files[num_files]->size = file_size(st) / 1024;
+ total_size += files[num_files]->size;
+ num_files++;
+}
+
+/* sort the files we've found and delete the oldest ones until we are
+ below the thresholds */
+static void sort_and_clean(void)
+{
+ unsigned i;
+
+ if (num_files > 1) {
+ /* sort in ascending data order */
+ qsort(files, num_files, sizeof(struct files *),
+ (COMPAR_FN_T)files_compare);
+ }
+
+ /* delete enough files to bring us below the threshold */
+ for (i=0;i<num_files; i++) {
+ if ((size_threshold==0 || total_size < size_threshold) &&
+ (files_threshold==0 || (num_files-i) < files_threshold)) break;
+
+ if (unlink(files[i]->fname) != 0 && errno != ENOENT) {
+ fprintf(stderr, "unlink %s - %s\n",
+ files[i]->fname, strerror(errno));
+ continue;
+ }
+
+ total_size -= files[i]->size;
+ }
+
+ total_files = num_files - i;
+}
+
+/* cleanup in one cache subdir */
+void cleanup_dir(const char *dir, size_t maxfiles, size_t maxsize)
+{
+ unsigned i;
+
+ size_threshold = maxsize * LIMIT_MULTIPLE;
+ files_threshold = maxfiles * LIMIT_MULTIPLE;
+
+ num_files = 0;
+ total_size = 0;
+
+ /* build a list of files */
+ traverse(dir, traverse_fn);
+
+ /* clean the cache */
+ sort_and_clean();
+
+ stats_set_sizes(dir, total_files, total_size);
+
+ /* free it up */
+ for (i=0;i<num_files;i++) {
+ free(files[i]->fname);
+ free(files[i]);
+ files[i] = NULL;
+ }
+ if (files) free(files);
+ allocated = 0;
+ files = NULL;
+
+ num_files = 0;
+ total_size = 0;
+}
+
+/* cleanup in all cache subdirs */
+void cleanup_all(const char *dir)
+{
+ unsigned counters[STATS_END];
+ char *dname, *sfile;
+ int i;
+
+ for (i=0;i<=0xF;i++) {
+ x_asprintf(&dname, "%s/%1x", dir, i);
+ x_asprintf(&sfile, "%s/%1x/stats", dir, i);
+
+ memset(counters, 0, sizeof(counters));
+ stats_read(sfile, counters);
+
+ cleanup_dir(dname,
+ counters[STATS_MAXFILES],
+ counters[STATS_MAXSIZE]);
+ free(dname);
+ free(sfile);
+ }
+}
+
+
+/* traverse function for wiping files */
+static void wipe_fn(const char *fname, struct stat *st)
+{
+ char *p;
+
+ if (!S_ISREG(st->st_mode)) return;
+
+ p = str_basename(fname);
+ if (strcmp(p, "stats") == 0) {
+ free(p);
+ return;
+ }
+ free(p);
+
+ unlink(fname);
+}
+
+
+/* wipe all cached files in all subdirs */
+void wipe_all(const char *dir)
+{
+ char *dname;
+ int i;
+
+ for (i=0;i<=0xF;i++) {
+ x_asprintf(&dname, "%s/%1x", dir, i);
+ traverse(dir, wipe_fn);
+ free(dname);
+ }
+
+ /* and fix the counters */
+ cleanup_all(dir);
+}
diff --git a/CCache/configure.in b/CCache/configure.in
new file mode 100644
index 000000000..dfbf86dbc
--- /dev/null
+++ b/CCache/configure.in
@@ -0,0 +1,87 @@
+dnl Process this file with autoconf to produce a configure script.
+
+AC_INIT([ccache-swig], [0.0]) # Get version from SWIG in ccache_swig_config.h.in
+AC_PREREQ(2.52)
+AC_CONFIG_SRCDIR([ccache.h])
+
+AC_MSG_NOTICE([Configuring ccache])
+
+AC_CONFIG_HEADER(config.h)
+
+dnl Checks for programs.
+AC_PROG_CC
+AC_PROG_CPP
+AC_PROG_INSTALL
+AC_ARG_PROGRAM # for program_transform_name
+
+AC_DEFINE([_GNU_SOURCE], 1,
+ [Define _GNU_SOURCE so that we get all necessary prototypes])
+
+# If GCC, turn on warnings.
+if test "x$GCC" = "xyes"
+then
+ CFLAGS="$CFLAGS -Wall -W"
+else
+ CFLAGS="$CFLAGS -O"
+fi
+
+AC_HEADER_DIRENT
+AC_HEADER_TIME
+AC_HEADER_SYS_WAIT
+
+AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h)
+
+AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp)
+AC_CHECK_FUNCS(gethostname getpwuid)
+AC_CHECK_FUNCS(utimes)
+
+AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
+ AC_TRY_COMPILE(
+[#include <stdlib.h>],
+[
+void test_fn(void) { qsort(NULL, 0, 0, (__compar_fn_t)NULL); }
+],
+ ccache_cv_COMPAR_FN_T=yes,ccache_cv_COMPAR_FN_T=no)])
+if test x"$ccache_cv_COMPAR_FN_T" = x"yes"; then
+ AC_DEFINE(HAVE_COMPAR_FN_T, 1, [ ])
+fi
+
+dnl Note: This could be replaced by AC_FUNC_SNPRINTF() in the autoconf macro archive
+AC_CACHE_CHECK([for C99 vsnprintf],ccache_cv_HAVE_C99_VSNPRINTF,[
+AC_TRY_RUN([
+#include <sys/types.h>
+#include <stdarg.h>
+void foo(const char *format, ...) {
+ va_list ap;
+ int len;
+ char buf[5];
+
+ va_start(ap, format);
+ len = vsnprintf(0, 0, format, ap);
+ va_end(ap);
+ if (len != 5) exit(1);
+
+ if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);
+
+ exit(0);
+}
+main() { foo("hello"); }
+],
+ccache_cv_HAVE_C99_VSNPRINTF=yes,ccache_cv_HAVE_C99_VSNPRINTF=no,ccache_cv_HAVE_C99_VSNPRINTF=cross)])
+if test x"$ccache_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
+ AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
+fi
+
+dnl Check for zlib.
+dnl Note: This could be replaced by CHECK_ZLIB() in the autoconf macro archive
+AC_ARG_ENABLE([zlib],
+ AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),,
+ [enable_zlib=yes])
+
+if test x"$enable_zlib" = x"yes"; then
+ AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, [LIBS="-lz $LIBS"
+ AC_DEFINE([ENABLE_ZLIB], 1, [Define to 1 if you would like to have zlib compression for ccache.]) ] ))
+fi
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/CCache/debian/NEWS b/CCache/debian/NEWS
new file mode 100644
index 000000000..be245dc7d
--- /dev/null
+++ b/CCache/debian/NEWS
@@ -0,0 +1,22 @@
+ccache (2.4-8) unstable; urgency=high
+
+ zlib compression is now enabled by default in order to increase the amount
+ of object files that can fit in the cache.
+
+ The impact on performance is supposed to be almost negligible
+ (see http://www.gustaebel.de/lars/ccache/). If you do want to disable
+ it however, simply export the CCACHE_NOCOMPRESS environment variable.
+
+ Note that a zlib-enabled ccache will still read your existing
+ uncompressed cache. If you want to compress/uncompress your cache,
+ see the manage-cache.sh script under /usr/share/doc/ccache/examples/.
+
+ -- Francois Marier <francois@debian.org> Sun, 20 May 2007 19:45:07 +1200
+
+ccache (2.4-1) unstable; urgency=low
+
+ * This release changes the hash input slighly, so you will probably find
+ that you will not get any hits against your existing cache when you
+ upgrade.
+
+ -- Francois Marier <francois@debian.org> Sat, 11 Jun 2005 13:54:33 -0400
diff --git a/CCache/debian/README.Debian b/CCache/debian/README.Debian
new file mode 100644
index 000000000..5478bb720
--- /dev/null
+++ b/CCache/debian/README.Debian
@@ -0,0 +1,59 @@
+Installing ccache
+-----------------
+
+The recommended way to use this with Debian is to either create "cc"
+and "gcc" symlinks to /usr/bin/ccache in your private bin directory
+(which must be before the real cc and gcc in your path), or use
+CC="ccache gcc" on the make command line.
+
+Another option is to just prepend /usr/lib/ccache in your PATH
+environment variable, like
+
+ export PATH="/usr/lib/ccache:$PATH"
+
+Note that ccache works with both native and cross compilers.
+
+Ignoring whitespace
+-------------------
+
+If you wish to set up ccache so that it ignores blank lines, have a
+look at the CCACHE_UNIFY option. However, please note that this
+option is off by default since the reported line numbers may not
+match the source files anymore.
+
+
+NFS Issues
+----------
+
+(from John Coiner <john.coiner@amd.com> on the ccache mailing list)
+
+When CCache creates a hardlinked output file, it calls utime() to update
+the timestamp on the object, so that Make realizes that the object has
+changed.
+
+On NFS, utime() has no coherency guarantee, AFAIK. When utime() runs on
+host A, and our parallel implementation of Make is running on host B,
+sometimes Make doesn't see the new timestamp soon enough -- and neglects
+to relink the final binary. That's a one-way ticket to Silent Mysterious
+Failure Town.
+
+Instead of relying on the object file timestamp, we create a dummy file
+with a reliable timestamp:
+
+objs/foo.o objs/foo.o.built :
+ if ( ccache gcc -o foo.o -c foo.c ) ; \
+ then touch objs/foo.o.built ; \
+ else exit 1; \
+ fi
+
+binary : objs/foo.o.built
+ gcc -o binary objs/foo.o
+
+NFS does make a coherency guarantee, that if a file is written and
+close()d on host A, and subsequently open()ed on host B, that the second
+open() will reflect all modifications and attributes from the close().
+Since Make does open() when checking timestamps, and the dummy file is
+close()d when it's created, the binary will always relink after the
+object is recompiled.
+
+ -- Francois Marier <francois@debian.org> Sun, 20 May 2007 17:35:36 +1200
diff --git a/CCache/debian/changelog b/CCache/debian/changelog
new file mode 100644
index 000000000..45500d4bd
--- /dev/null
+++ b/CCache/debian/changelog
@@ -0,0 +1,221 @@
+ccache (2.4-15) unstable; urgency=low
+
+ * Add a new patch which improve the consistency of timestamps on cached
+ objects to make sure clean-up is based on least recently used objects.
+ * Patch the set_limit call so that non-writable cache directories return
+ an error when attempting to size the max(files|size) (closes: #332527)
+
+ -- Francois Marier <francois@debian.org> Sun, 13 Apr 2008 15:07:05 +1200
+
+ccache (2.4-14) unstable; urgency=low
+
+ * Mention the long options everywhere in the manpage
+ * Merge Gentoo patches:
+ - respect user's LDFLAGS
+ - use utimes() for timestamp if possible
+
+ -- Francois Marier <francois@debian.org> Sun, 23 Mar 2008 16:30:11 +1300
+
+ccache (2.4-13) unstable; urgency=low
+
+ * Update CACHEDIR.TAG patch to avoid creating the tag file when the
+ CCACHE_READONLY environment variable is set. (closes: #464356)
+ * Mention the GNU-style long options in the manpage
+
+ -- Francois Marier <francois@debian.org> Thu, 07 Feb 2008 10:50:42 +1300
+
+ccache (2.4-12) unstable; urgency=low
+
+ * Add symlink for gcc 4.3 (closes: #463590)
+ * Add support for the CACHEDIR.TAG spec, thanks to Karl Chen.
+ (see http://www.brynosaurus.com/cachedir/)
+ * Fix hyphens in manpage (lintian notice)
+ * Bump Standards-Version up to 3.7.3 (no changes)
+ * Bump debhelper compatibility to 6
+
+ -- Francois Marier <francois@debian.org> Sat, 02 Feb 2008 10:37:22 +1300
+
+ccache (2.4-11) unstable; urgency=low
+
+ * Add the collab-maint repo to debian/control
+
+ -- Francois Marier <francois@debian.org> Tue, 20 Nov 2007 15:26:37 +1300
+
+ccache (2.4-10) unstable; urgency=low
+
+ * Document where the patches are from in debian/patches/CREDITS
+ * debian/rules:
+ - Fixed "make distclean" lintian warning
+ - Removed commented-out entries
+ * Set debhelper compatibility to 5
+ * Add homepage field in debian/control
+ * Add symlinks for MinGW (closes: #445782)
+ * Bump the version to 5 in the debhelper dependency
+
+ -- Francois Marier <francois@debian.org> Fri, 19 Oct 2007 16:04:37 +1300
+
+ccache (2.4-9) unstable; urgency=low
+
+ * Add a symlink for gcc 4.2 (closes: #431007)
+ * Fix dependencies when using -o (closes: #217713)
+
+ -- Francois Marier <francois@debian.org> Sat, 30 Jun 2007 17:58:44 +1200
+
+ccache (2.4-8) unstable; urgency=low
+
+ * Enable zlib compression of the cache by default (closes: #409848).
+ Thanks to Sami Liedes for suggesting this.
+ * Disable ccache when profiling (closes: #215849).
+ Thanks to Ted Percival for the Patch.
+ * Fix NFS renaming issues and add instructions to the README.
+ Thanks to John Coiner and instructions.
+ * Put all patches in debian/patches and apply them at build time.
+
+ -- Francois Marier <francois@debian.org> Sun, 20 May 2007 19:42:34 +1200
+
+ccache (2.4-7) unstable; urgency=low
+
+ * Use the real compiler when HOME is not set (closes: #396350)
+ * Include user script under doc/examples (closes: #392435)
+ Thanks to Behan Webster!
+ * Add support for GNU --long options (closes: #297126)
+
+ -- Francois Marier <francois@debian.org> Sat, 18 Nov 2006 00:50:59 -0500
+
+ccache (2.4-6) unstable; urgency=low
+
+ * Include symlinks for gcc 4.1 (closes: #372838)
+ * Update watch file
+
+ -- Francois Marier <francois@debian.org> Tue, 13 Jun 2006 22:17:37 -0400
+
+ccache (2.4-5) unstable; urgency=low
+
+ * Document the fact that cross-compiling is supported (closes: #349221)
+ * Bump Standards-Version up to 3.7.2 (no changes)
+
+ -- Francois Marier <francois@debian.org> Sun, 4 Jun 2006 01:20:07 -0400
+
+ccache (2.4-4) unstable; urgency=low
+
+ * Mention another way to use ccache in README.Debian (thanks to Benjamin
+ Drieu for the suggestion) (closes: #267632)
+ * Update FSF address
+ * Fix watch file
+
+ -- Francois Marier <francois@debian.org> Sat, 26 Nov 2005 00:15:13 -0500
+
+ccache (2.4-3) unstable; urgency=low
+
+ * Actually use the configuration flags in debian/rules
+ * Bump Standards-Version up to 3.6.2 (no changes)
+
+ -- Francois Marier <francois@debian.org> Sun, 26 Jun 2005 13:33:19 -0400
+
+ccache (2.4-2) unstable; urgency=low
+
+ * Add gcc and g++ symlinks to /usr/lib/ccache (closes: #313490)
+ * Remove invalid entry from Depends
+
+ -- Francois Marier <francois@debian.org> Wed, 15 Jun 2005 20:51:03 -0400
+
+ccache (2.4-1) unstable; urgency=low
+
+ * New maintainer (closes: #312867)
+ * New upstream version: (closes: #273753, #239640)
+ - New CCACHE_READONLY and CCACHE_TEMPDIR options
+ - Fixed handling of hard-linked compilers on AIX
+ - Fixed handling of HOME environment variable (closes: #299880)
+ - Show cache directory in stats output
+ * Fix copyright file
+ * Add 'distcc' to Suggests (closes: #269158)
+ * Add a note about whitespace in README.Debian (closes: #229116)
+ * Update rules to add symmlinks for gcc 3.4 & 4.0 (closes: #261177)
+ * Acknowledge NMUs (closes: #200185, #177129, #174417)
+
+ -- Francois Marier <francois@debian.org> Sun, 12 Jun 2005 12:05:34 -0400
+
+ccache (2.3-1.1) unstable; urgency=low
+
+ * Non-maintainer upload during BSP
+ * Re-apply patch for
+ #200185 ccache: Incorrect symlinks in /usr/lib/ccache
+ (Closes: #200185)
+
+ -- Frank Lichtenheld <djpig@debian.org> Fri, 19 Mar 2004 11:14:50 +0100
+
+ccache (2.3-1) unstable; urgency=low
+
+ * New upstream release: obsoletes existing caches.
+ * Tweak package description in arbitrary way (closes: #181721)
+
+ -- Paul Russell <prussell@debian.org> Mon, 29 Sep 2003 02:53:20 +0200
+
+ccache (2.2-2) unstable; urgency=low
+
+ * Insert more symlinks in ccache dir (closes: #197468)
+
+ -- Paul Russell <prussell@debian.org> Mon, 16 Jun 2003 10:52:50 +0100
+
+ccache (2.2-1) unstable; urgency=low
+
+ * New upstream release (closes: #150755)
+ * Insert more symlinks in ccache dir (closes: #144462)
+
+ -- Paul Russell <prussell@debian.org> Mon, 17 Feb 2003 07:19:36 +0100
+
+ccache (2.1.1-2) unstable; urgency=low
+
+ * Restored /usr/lib/ccache symlinks (closes: #179393)
+ * Fixed manpage typo (closes: #179564)
+ * With thanks to Andreas Rottmann.
+
+ -- Paul Russell <prussell@debian.org> Wed, 5 Feb 2003 10:01:10 +0100
+
+ccache (2.1.1-1) unstable; urgency=low
+
+ * NMU (with maintainer consent).
+ * New upstream release (closes: #174417, #177129).
+ * debian/control:
+ + Build-Depend on and use dephelper 4 (DH_COMPAT = 4).
+ + Bumped Standards-Version to 3.5.8.
+ + No full stop on short package description (fixes linda warning).
+ * debian/copright:
+ + Make lintian feel comfortable; fixes warnings:
+ - copyright-should-refer-to-common-license-file-for-gpl
+ - copyright-lists-upstream-authors-with-dh_make-boilerplate
+ * Built with g++ 3.2 :-).
+
+ -- Andreas Rottmann <rotty@debian.org> Thu, 16 Jan 2003 11:42:38 +0100
+
+ccache (1.9-1) unstable; urgency=low
+
+ * New upstream release (closes: #144920)
+
+ -- Paul Russell <prussell@debian.org> Mon, 13 May 2002 10:01:09 +0200
+
+ccache (1.8-1) unstable; urgency=low
+
+ * New upstream release (closes: #145401)
+
+ -- Paul Russell <prussell@debian.org> Fri, 3 May 2002 02:26:32 +0200
+
+ccache (1.7-1) unstable; urgency=low
+
+ * New upstream release
+ * Install symlinks in /usr/lib/ccache (closes: #141337)
+
+ -- Paul Russell <prussell@debian.org> Wed, 10 Apr 2002 17:51:21 +0200
+
+ccache (1.4-1) unstable; urgency=low
+
+ * New upstream release
+
+ -- Paul Russell <prussell@debian.org> Wed, 3 Apr 2002 03:41:46 +0200
+
+ccache (1.2-1) unstable; urgency=low
+
+ * Initial Release.
+
+ -- Paul Russell <prussell@debian.org> Sun, 31 Mar 2002 14:08:57 +0200
+
diff --git a/CCache/debian/compat b/CCache/debian/compat
new file mode 100644
index 000000000..1e8b31496
--- /dev/null
+++ b/CCache/debian/compat
@@ -0,0 +1 @@
+6
diff --git a/CCache/debian/control b/CCache/debian/control
new file mode 100644
index 000000000..0b7e57282
--- /dev/null
+++ b/CCache/debian/control
@@ -0,0 +1,20 @@
+Source: ccache
+Section: devel
+Priority: optional
+Maintainer: Francois Marier <francois@debian.org>
+Build-Depends: debhelper (>> 6), autotools-dev, zlib1g-dev
+Standards-Version: 3.7.3
+Homepage: http://ccache.samba.org
+Vcs-Svn: svn://svn.debian.org/svn/collab-maint/deb-maint/ccache/
+Vcs-Browser: http://svn.debian.org/wsvn/collab-maint/deb-maint/ccache/
+
+Package: ccache
+Architecture: any
+Depends: ${shlibs:Depends}
+Suggests: distcc
+Description: Compiler results cacher, for fast recompiles
+ ccache is a compiler cache. It speeds up re-compilation of C/C++ code
+ by caching previous compiles and detecting when the same compile is
+ being done again.
+ .
+ This is similar to, but faster than, the compilercache package.
diff --git a/CCache/debian/copyright b/CCache/debian/copyright
new file mode 100644
index 000000000..7ac791dc5
--- /dev/null
+++ b/CCache/debian/copyright
@@ -0,0 +1,29 @@
+This package was debianized by Paul Russell <prussell@debian.org> on
+Sun, 31 Mar 2002 14:08:57 +0200.
+
+It was downloaded from http://ccache.samba.org/ftp/ccache/
+
+The ccache-zlib patch was downloaded from http://www.gustaebel.de/lars/ccache/
+
+Upstream Author: Andrew Tridgell <tridge@samba.org>
+
+Copyright: 2002-2005 Andrew Tridgell <tridge@samba.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ 02110-1301, USA
+
+You are free to distribute this software under the terms of the GNU General
+Public License. On Debian systems, the complete text of the GNU General
+Public License can be found in /usr/share/common-licenses/GPL file.
diff --git a/CCache/debian/dirs b/CCache/debian/dirs
new file mode 100644
index 000000000..8ceb4c4e8
--- /dev/null
+++ b/CCache/debian/dirs
@@ -0,0 +1,3 @@
+usr/bin
+usr/lib/ccache
+usr/share/man/man1
diff --git a/CCache/debian/docs b/CCache/debian/docs
new file mode 100644
index 000000000..e845566c0
--- /dev/null
+++ b/CCache/debian/docs
@@ -0,0 +1 @@
+README
diff --git a/CCache/debian/examples b/CCache/debian/examples
new file mode 100644
index 000000000..fc549228c
--- /dev/null
+++ b/CCache/debian/examples
@@ -0,0 +1,2 @@
+debian/update-ccache
+manage-cache.sh
diff --git a/CCache/debian/patches/01_no_home.diff b/CCache/debian/patches/01_no_home.diff
new file mode 100644
index 000000000..019634c0c
--- /dev/null
+++ b/CCache/debian/patches/01_no_home.diff
@@ -0,0 +1,100 @@
+--- ccache.c
++++ ccache.c
+@@ -836,6 +836,13 @@
+ {
+ /* find the real compiler */
+ find_compiler(argc, argv);
++
++ /* use the real compiler if HOME is not set */
++ if (!cache_dir) {
++ cc_log("Unable to determine home directory\n");
++ cc_log("ccache is disabled\n");
++ failed();
++ }
+
+ /* we might be disabled */
+ if (getenv("CCACHE_DISABLE")) {
+@@ -895,6 +902,13 @@
+ printf("-V print version number\n");
+ }
+
++static void check_cache_dir(void)
++{
++ if (!cache_dir) {
++ fatal("Unable to determine home directory");
++ }
++}
++
+ /* the main program when not doing a compile */
+ static int ccache_main(int argc, char *argv[])
+ {
+@@ -914,31 +928,37 @@
+ exit(0);
+
+ case 's':
++ check_cache_dir();
+ stats_summary();
+ break;
+
+ case 'c':
++ check_cache_dir();
+ cleanup_all(cache_dir);
+ printf("Cleaned cache\n");
+ break;
+
+ case 'C':
++ check_cache_dir();
+ wipe_all(cache_dir);
+ printf("Cleared cache\n");
+ break;
+
+ case 'z':
++ check_cache_dir();
+ stats_zero();
+ printf("Statistics cleared\n");
+ break;
+
+ case 'F':
++ check_cache_dir();
+ v = atoi(optarg);
+ stats_set_limits(v, -1);
+ printf("Set cache file limit to %u\n", (unsigned)v);
+ break;
+
+ case 'M':
++ check_cache_dir();
+ v = value_units(optarg);
+ stats_set_limits(-1, v);
+ printf("Set cache size limit to %uk\n", (unsigned)v);
+@@ -983,7 +1003,10 @@
+
+ cache_dir = getenv("CCACHE_DIR");
+ if (!cache_dir) {
+- x_asprintf(&cache_dir, "%s/.ccache", get_home_directory());
++ const char *home_directory = get_home_directory();
++ if (home_directory) {
++ x_asprintf(&cache_dir, "%s/.ccache", home_directory);
++ }
+ }
+
+ temp_dir = getenv("CCACHE_TEMPDIR");
+@@ -1023,7 +1046,7 @@
+ }
+
+ /* make sure the cache dir exists */
+- if (create_dir(cache_dir) != 0) {
++ if (cache_dir && (create_dir(cache_dir) != 0)) {
+ fprintf(stderr,"ccache: failed to create %s (%s)\n",
+ cache_dir, strerror(errno));
+ exit(1);
+--- util.c
++++ util.c
+@@ -448,7 +448,7 @@
+ }
+ }
+ #endif
+- fatal("Unable to determine home directory");
++ cc_log("Unable to determine home directory");
+ return NULL;
+ }
+
diff --git a/CCache/debian/patches/02_ccache-compressed.diff b/CCache/debian/patches/02_ccache-compressed.diff
new file mode 100644
index 000000000..5740c2ca4
--- /dev/null
+++ b/CCache/debian/patches/02_ccache-compressed.diff
@@ -0,0 +1,1026 @@
+Index: ccache.1
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/ccache.1,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.6
+diff -u -r1.1.1.1.2.1 -r1.6
+--- ccache.1 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ ccache.1 21 Nov 2004 18:19:28 -0000 1.6
+@@ -210,7 +210,8 @@
+ CCACHE_HARDLINK then ccache will attempt to use hard links from the
+ cache directory when creating the compiler output rather than using a
+ file copy\&. Using hard links is faster, but can confuse programs like
+-\&'make\&' that rely on modification times\&.
++\&'make\&' that rely on modification times\&. Hard links are never made for
++compressed cache files\&.
+ .IP
+ .IP "\fBCCACHE_RECACHE\fP"
+ This forces ccache to not use any cached
+@@ -257,6 +258,11 @@
+ the default\&. On HP-UX set this environment variable to "i" if you use
+ the aCC compiler\&.
+ .IP
++.IP "\fBCCACHE_NOCOMPRESS\fP"
++If you set the environment variable
++CCACHE_NOCOMPRESS then there is no compression used on files that go
++into the cache\&.
++.IP
+ .PP
+ .SH "CACHE SIZE MANAGEMENT"
+ .PP
+@@ -269,6 +275,14 @@
+ below the numbers you specified in order to avoid doing the cache
+ clean operation too often\&.
+ .PP
++.SH "CACHE COMPRESSION"
++.PP
++By default ccache will compress all files it puts into the cache
++using the zlib compression\&. While this involves a negligible
++performance slowdown, it significantly increases the number of files
++that fit in the cache\&. You can turn off compression setting the
++CCACHE_NOCOMPRESS environment variable\&.
++.PP
+ .SH "HOW IT WORKS"
+ .PP
+ The basic idea is to detect when you are compiling exactly the same
+Index: ccache.c
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/ccache.c,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.9
+diff -u -r1.1.1.1.2.1 -r1.9
+--- ccache.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ ccache.c 21 Nov 2004 18:19:28 -0000 1.9
+@@ -199,7 +199,7 @@
+ fd = open(tmp_stderr, O_RDONLY | O_BINARY);
+ if (fd != -1) {
+ if (strcmp(output_file, "/dev/null") == 0 ||
+- rename(tmp_hashname, output_file) == 0 || errno == ENOENT) {
++ move_file(tmp_hashname, output_file) == 0 || errno == ENOENT) {
+ if (cpp_stderr) {
+ /* we might have some stderr from cpp */
+ int fd2 = open(cpp_stderr, O_RDONLY | O_BINARY);
+@@ -231,14 +231,25 @@
+ x_asprintf(&path_stderr, "%s.stderr", hashname);
+
+ if (stat(tmp_stderr, &st1) != 0 ||
+- stat(tmp_hashname, &st2) != 0 ||
+- rename(tmp_hashname, hashname) != 0 ||
+- rename(tmp_stderr, path_stderr) != 0) {
++ stat(tmp_hashname, &st2) != 0 ||
++ move_file(tmp_hashname, hashname) != 0 ||
++ move_file(tmp_stderr, path_stderr) != 0) {
+ cc_log("failed to rename tmp files - %s\n", strerror(errno));
+ stats_update(STATS_ERROR);
+ failed();
+ }
+
++#if ENABLE_ZLIB
++ /* do an extra stat on the cache files for
++ the size statistics */
++ if (stat(path_stderr, &st1) != 0 ||
++ stat(hashname, &st2) != 0) {
++ cc_log("failed to stat cache files - %s\n", strerror(errno));
++ stats_update(STATS_ERROR);
++ failed();
++ }
++#endif
++
+ cc_log("Placed %s into cache\n", output_file);
+ stats_tocache(file_size(&st1) + file_size(&st2));
+
+@@ -474,7 +485,13 @@
+ }
+
+ /* the user might be disabling cache hits */
++#ifndef ENABLE_ZLIB
++ /* if the cache file is compressed we must recache */
++ if ((first && getenv("CCACHE_RECACHE")) ||
++ test_if_compressed(hashname) == 1) {
++#else
+ if (first && getenv("CCACHE_RECACHE")) {
++#endif
+ close(fd_stderr);
+ unlink(stderr_file);
+ free(stderr_file);
+@@ -487,7 +504,9 @@
+ ret = 0;
+ } else {
+ unlink(output_file);
+- if (getenv("CCACHE_HARDLINK")) {
++ /* only make a hardlink if the cache file is uncompressed */
++ if (getenv("CCACHE_HARDLINK") &&
++ test_if_compressed(hashname) == 0) {
+ ret = link(hashname, output_file);
+ } else {
+ ret = copy_file(hashname, output_file);
+Index: ccache.h
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/ccache.h,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.7
+diff -u -r1.1.1.1.2.1 -r1.7
+--- ccache.h 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ ccache.h 21 Nov 2004 18:19:28 -0000 1.7
+@@ -23,6 +23,10 @@
+ #include <pwd.h>
+ #endif
+
++#ifdef ENABLE_ZLIB
++#include <zlib.h>
++#endif
++
+ #define STATUS_NOTFOUND 3
+ #define STATUS_FATAL 4
+ #define STATUS_NOCACHE 5
+@@ -36,6 +40,13 @@
+ #define DEFAULT_MAXSIZE (1000*1000)
+ #endif
+
++/* file copy mode */
++#ifdef ENABLE_ZLIB
++#define COPY_UNCOMPRESSED 0
++#define COPY_FROM_CACHE 1
++#define COPY_TO_CACHE 2
++#endif
++
+ enum stats {
+ STATS_NONE=0,
+ STATS_STDOUT,
+@@ -79,6 +90,8 @@
+
+ void copy_fd(int fd_in, int fd_out);
+ int copy_file(const char *src, const char *dest);
++int move_file(const char *src, const char *dest);
++int test_if_compressed(const char *filename);
+
+ int create_dir(const char *dir);
+ void x_asprintf(char **ptr, const char *format, ...);
+Index: ccache.yo
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/ccache.yo,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.5
+diff -u -r1.1.1.1.2.1 -r1.5
+--- ccache.yo 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ ccache.yo 21 Nov 2004 18:19:28 -0000 1.5
+@@ -169,6 +169,11 @@
+ this optimisation, in which case this option could allow ccache to be
+ used.
+
++dit(bf(CCACHE_NOCOMPRESS)) If you set the environment variable
++CCACHE_NOCOMPRESS then there is no compression used on files that go
++into the cache. However, this setting has no effect on how files are
++retrieved from the cache, compressed results will still be usable.
++
+ dit(bf(CCACHE_NOSTATS)) If you set the environment variable
+ CCACHE_NOSTATS then ccache will not update the statistics files on
+ each compile.
+@@ -181,7 +186,8 @@
+ CCACHE_HARDLINK then ccache will attempt to use hard links from the
+ cache directory when creating the compiler output rather than using a
+ file copy. Using hard links is faster, but can confuse programs like
+-'make' that rely on modification times.
++'make' that rely on modification times. Hard links are never made for
++compressed cache files.
+
+ dit(bf(CCACHE_RECACHE)) This forces ccache to not use any cached
+ results, even if it finds them. New results are still cached, but
+@@ -236,6 +242,14 @@
+ below the numbers you specified in order to avoid doing the cache
+ clean operation too often.
+
++manpagesection(CACHE COMPRESSION)
++
++By default ccache will compress all files it puts into the cache
++using the zlib compression. While this involves a negligible
++performance slowdown, it significantly increases the number of files
++that fit in the cache. You can turn off compression setting the
++CCACHE_NOCOMPRESS environment variable.
++
+ manpagesection(HOW IT WORKS)
+
+ The basic idea is to detect when you are compiling exactly the same
+@@ -294,6 +308,8 @@
+ cache. This tells the filesystem to inherit group ownership for new
+ directories. The command "chmod g+s `find $CCACHE_DIR -type d`" might
+ be useful for this.
++ it() Set bf(CCACHE_NOCOMPRESS) for all users, if there are users with
++ versions of ccache that do not support compression.
+ )
+
+ manpagesection(HISTORY)
+Index: config.h.in
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/config.h.in,v
+retrieving revision 1.1.1.1
+retrieving revision 1.2
+diff -u -r1.1.1.1 -r1.2
+--- config.h.in 30 Apr 2004 13:13:41 -0000 1.1.1.1
++++ config.h.in 4 May 2004 20:49:26 -0000 1.2
+@@ -98,3 +98,6 @@
+
+ /* Define _GNU_SOURCE so that we get all necessary prototypes */
+ #undef _GNU_SOURCE
++
++/* Define to 1 if you like to have zlib compression for the ccache. */
++#undef ENABLE_ZLIB
+Index: configure
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/configure,v
+retrieving revision 1.1.1.1.2.1
+diff -u -r1.1.1.1.2.1 configure
+--- configure 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ configure 21 Nov 2004 18:24:42 -0000
+@@ -836,6 +836,11 @@
+
+ cat <<\_ACEOF
+
++Optional Features:
++ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
++ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
++ --enable-zlib enable zlib support for ccache compression
++
+ Some influential environment variables:
+ CC C compiler command
+ CFLAGS C compiler flags
+@@ -936,7 +941,7 @@
+ else
+ echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi
+- cd "$ac_popdir"
++ cd $ac_popdir
+ done
+ fi
+
+@@ -1859,7 +1864,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -1917,7 +1923,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2033,7 +2040,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2087,7 +2095,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2132,7 +2141,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2176,7 +2186,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2609,7 +2620,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2681,7 +2693,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2735,7 +2748,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2806,7 +2820,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2860,7 +2875,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2927,7 +2943,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -2997,7 +3014,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3078,7 +3096,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3248,7 +3267,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3319,7 +3339,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3509,7 +3530,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3611,7 +3633,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3676,7 +3699,8 @@
+ cat conftest.err >&5
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } &&
+- { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err'
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
+ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+ (eval $ac_try) 2>&5
+ ac_status=$?
+@@ -3775,6 +3799,229 @@
+
+ fi
+
++# Check whether --enable-zlib or --disable-zlib was given.
++if test "${enable_zlib+set}" = set; then
++ enableval="$enable_zlib"
++
++else
++ enable_zlib=yes
++fi;
++
++if test x"$enable_zlib" = x"yes"; then
++ if test "${ac_cv_header_zlib_h+set}" = set; then
++ echo "$as_me:$LINENO: checking for zlib.h" >&5
++echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
++if test "${ac_cv_header_zlib_h+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++fi
++echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
++echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
++else
++ # Is the header compilable?
++echo "$as_me:$LINENO: checking zlib.h usability" >&5
++echo $ECHO_N "checking zlib.h usability... $ECHO_C" >&6
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++$ac_includes_default
++#include <zlib.h>
++_ACEOF
++rm -f conftest.$ac_objext
++if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
++ (eval $ac_compile) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest.$ac_objext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_header_compiler=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_header_compiler=no
++fi
++rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
++echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
++echo "${ECHO_T}$ac_header_compiler" >&6
++
++# Is the header present?
++echo "$as_me:$LINENO: checking zlib.h presence" >&5
++echo $ECHO_N "checking zlib.h presence... $ECHO_C" >&6
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++#include <zlib.h>
++_ACEOF
++if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
++ (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } >/dev/null; then
++ if test -s conftest.err; then
++ ac_cpp_err=$ac_c_preproc_warn_flag
++ ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
++ else
++ ac_cpp_err=
++ fi
++else
++ ac_cpp_err=yes
++fi
++if test -z "$ac_cpp_err"; then
++ ac_header_preproc=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ ac_header_preproc=no
++fi
++rm -f conftest.err conftest.$ac_ext
++echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
++echo "${ECHO_T}$ac_header_preproc" >&6
++
++# So? What about this header?
++case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
++ yes:no: )
++ { echo "$as_me:$LINENO: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&5
++echo "$as_me: WARNING: zlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
++ { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the compiler's result" >&5
++echo "$as_me: WARNING: zlib.h: proceeding with the compiler's result" >&2;}
++ ac_header_preproc=yes
++ ;;
++ no:yes:* )
++ { echo "$as_me:$LINENO: WARNING: zlib.h: present but cannot be compiled" >&5
++echo "$as_me: WARNING: zlib.h: present but cannot be compiled" >&2;}
++ { echo "$as_me:$LINENO: WARNING: zlib.h: check for missing prerequisite headers?" >&5
++echo "$as_me: WARNING: zlib.h: check for missing prerequisite headers?" >&2;}
++ { echo "$as_me:$LINENO: WARNING: zlib.h: see the Autoconf documentation" >&5
++echo "$as_me: WARNING: zlib.h: see the Autoconf documentation" >&2;}
++ { echo "$as_me:$LINENO: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&5
++echo "$as_me: WARNING: zlib.h: section \"Present But Cannot Be Compiled\"" >&2;}
++ { echo "$as_me:$LINENO: WARNING: zlib.h: proceeding with the preprocessor's result" >&5
++echo "$as_me: WARNING: zlib.h: proceeding with the preprocessor's result" >&2;}
++ { echo "$as_me:$LINENO: WARNING: zlib.h: in the future, the compiler will take precedence" >&5
++echo "$as_me: WARNING: zlib.h: in the future, the compiler will take precedence" >&2;}
++ (
++ cat <<\_ASBOX
++## ------------------------------------------ ##
++## Report this to the AC_PACKAGE_NAME lists. ##
++## ------------------------------------------ ##
++_ASBOX
++ ) |
++ sed "s/^/$as_me: WARNING: /" >&2
++ ;;
++esac
++echo "$as_me:$LINENO: checking for zlib.h" >&5
++echo $ECHO_N "checking for zlib.h... $ECHO_C" >&6
++if test "${ac_cv_header_zlib_h+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_cv_header_zlib_h=$ac_header_preproc
++fi
++echo "$as_me:$LINENO: result: $ac_cv_header_zlib_h" >&5
++echo "${ECHO_T}$ac_cv_header_zlib_h" >&6
++
++fi
++if test $ac_cv_header_zlib_h = yes; then
++ echo "$as_me:$LINENO: checking for gzdopen in -lz" >&5
++echo $ECHO_N "checking for gzdopen in -lz... $ECHO_C" >&6
++if test "${ac_cv_lib_z_gzdopen+set}" = set; then
++ echo $ECHO_N "(cached) $ECHO_C" >&6
++else
++ ac_check_lib_save_LIBS=$LIBS
++LIBS="-lz $LIBS"
++cat >conftest.$ac_ext <<_ACEOF
++/* confdefs.h. */
++_ACEOF
++cat confdefs.h >>conftest.$ac_ext
++cat >>conftest.$ac_ext <<_ACEOF
++/* end confdefs.h. */
++
++/* Override any gcc2 internal prototype to avoid an error. */
++#ifdef __cplusplus
++extern "C"
++#endif
++/* We use char because int might match the return type of a gcc2
++ builtin and then its argument prototype would still apply. */
++char gzdopen ();
++int
++main ()
++{
++gzdopen ();
++ ;
++ return 0;
++}
++_ACEOF
++rm -f conftest.$ac_objext conftest$ac_exeext
++if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
++ (eval $ac_link) 2>conftest.er1
++ ac_status=$?
++ grep -v '^ *+' conftest.er1 >conftest.err
++ rm -f conftest.er1
++ cat conftest.err >&5
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); } &&
++ { ac_try='test -z "$ac_c_werror_flag"
++ || test ! -s conftest.err'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; } &&
++ { ac_try='test -s conftest$ac_exeext'
++ { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
++ (eval $ac_try) 2>&5
++ ac_status=$?
++ echo "$as_me:$LINENO: \$? = $ac_status" >&5
++ (exit $ac_status); }; }; then
++ ac_cv_lib_z_gzdopen=yes
++else
++ echo "$as_me: failed program was:" >&5
++sed 's/^/| /' conftest.$ac_ext >&5
++
++ac_cv_lib_z_gzdopen=no
++fi
++rm -f conftest.err conftest.$ac_objext \
++ conftest$ac_exeext conftest.$ac_ext
++LIBS=$ac_check_lib_save_LIBS
++fi
++echo "$as_me:$LINENO: result: $ac_cv_lib_z_gzdopen" >&5
++echo "${ECHO_T}$ac_cv_lib_z_gzdopen" >&6
++if test $ac_cv_lib_z_gzdopen = yes; then
++ LIBS="-lz $LIBS"; cat >>confdefs.h <<\_ACEOF
++#define ENABLE_ZLIB 1
++_ACEOF
++
++fi
++
++fi
++
++
++fi
++
+ ac_config_files="$ac_config_files Makefile"
+
+ cat >confcache <<\_ACEOF
+@@ -4568,6 +4815,11 @@
+ *) ac_INSTALL=$ac_top_builddir$INSTALL ;;
+ esac
+
++ if test x"$ac_file" != x-; then
++ { echo "$as_me:$LINENO: creating $ac_file" >&5
++echo "$as_me: creating $ac_file" >&6;}
++ rm -f "$ac_file"
++ fi
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+@@ -4606,12 +4858,6 @@
+ fi;;
+ esac
+ done` || { (exit 1); exit 1; }
+-
+- if test x"$ac_file" != x-; then
+- { echo "$as_me:$LINENO: creating $ac_file" >&5
+-echo "$as_me: creating $ac_file" >&6;}
+- rm -f "$ac_file"
+- fi
+ _ACEOF
+ cat >>$CONFIG_STATUS <<_ACEOF
+ sed "$ac_vpsub
+Index: configure.in
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/configure.in,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.4
+diff -u -r1.1.1.1.2.1 -r1.4
+--- configure.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ configure.in 21 Nov 2004 18:19:28 -0000 1.4
+@@ -68,5 +68,14 @@
+ AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [ ])
+ fi
+
++dnl Check for zlib.
++AC_ARG_ENABLE([zlib],
++ AS_HELP_STRING([--enable-zlib], [enable zlib support for ccache compression]),,
++ [enable_zlib=yes])
++
++if test x"$enable_zlib" = x"yes"; then
++ AC_CHECK_HEADER(zlib.h, AC_CHECK_LIB(z, gzdopen, LIBS="-lz $LIBS"; AC_DEFINE(ENABLE_ZLIB)))
++fi
++
+ AC_CONFIG_FILES([Makefile])
+ AC_OUTPUT
+Index: util.c
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/util.c,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.11
+diff -u -r1.1.1.1.2.1 -r1.11
+--- util.c 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ util.c 21 Nov 2004 18:19:28 -0000 1.11
+@@ -44,6 +44,7 @@
+ exit(1);
+ }
+
++#ifndef ENABLE_ZLIB
+ /* copy all data from one file descriptor to another */
+ void copy_fd(int fd_in, int fd_out)
+ {
+@@ -57,6 +58,11 @@
+ }
+ }
+
++/* move a file using rename */
++int move_file(const char *src, const char *dest) {
++ return rename(src, dest);
++}
++
+ /* copy a file - used when hard links don't work
+ the copy is done via a temporary file and atomic rename
+ */
+@@ -120,6 +126,174 @@
+ return 0;
+ }
+
++#else /* ENABLE_ZLIB */
++
++/* copy all data from one file descriptor to another
++ possibly decompressing it
++*/
++void copy_fd(int fd_in, int fd_out) {
++ char buf[10240];
++ int n;
++ gzFile gz_in;
++
++ gz_in = gzdopen(dup(fd_in), "rb");
++
++ if (!gz_in) {
++ fatal("Failed to copy fd");
++ }
++
++ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
++ if (write(fd_out, buf, n) != n) {
++ fatal("Failed to copy fd");
++ }
++ }
++}
++
++static int _copy_file(const char *src, const char *dest, int mode) {
++ int fd_in, fd_out;
++ gzFile gz_in, gz_out = NULL;
++ char buf[10240];
++ int n, ret;
++ char *tmp_name;
++ mode_t mask;
++ struct stat st;
++
++ x_asprintf(&tmp_name, "%s.XXXXXX", dest);
++
++ if (getenv("CCACHE_NOCOMPRESS")) {
++ mode = COPY_UNCOMPRESSED;
++ }
++
++ /* open source file */
++ fd_in = open(src, O_RDONLY);
++ if (fd_in == -1) {
++ return -1;
++ }
++
++ gz_in = gzdopen(fd_in, "rb");
++ if (!gz_in) {
++ close(fd_in);
++ return -1;
++ }
++
++ /* open destination file */
++ fd_out = mkstemp(tmp_name);
++ if (fd_out == -1) {
++ gzclose(gz_in);
++ free(tmp_name);
++ return -1;
++ }
++
++ if (mode == COPY_TO_CACHE) {
++ /* The gzip file format occupies at least 20 bytes. So
++ it will always occupy an entire filesystem block,
++ even for empty files.
++ Since most stderr files will be empty, we turn off
++ compression in this case to save space.
++ */
++ if (fstat(fd_in, &st) != 0) {
++ gzclose(gz_in);
++ close(fd_out);
++ free(tmp_name);
++ return -1;
++ }
++ if (file_size(&st) == 0) {
++ mode = COPY_UNCOMPRESSED;
++ }
++ }
++
++ if (mode == COPY_TO_CACHE) {
++ gz_out = gzdopen(dup(fd_out), "wb");
++ if (!gz_out) {
++ gzclose(gz_in);
++ close(fd_out);
++ free(tmp_name);
++ return -1;
++ }
++ }
++
++ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
++ if (mode == COPY_TO_CACHE) {
++ ret = gzwrite(gz_out, buf, n);
++ } else {
++ ret = write(fd_out, buf, n);
++ }
++ if (ret != n) {
++ gzclose(gz_in);
++ if (gz_out) {
++ gzclose(gz_out);
++ }
++ close(fd_out);
++ unlink(tmp_name);
++ free(tmp_name);
++ return -1;
++ }
++ }
++
++ gzclose(gz_in);
++ if (gz_out) {
++ gzclose(gz_out);
++ }
++
++ /* get perms right on the tmp file */
++ mask = umask(0);
++ fchmod(fd_out, 0666 & ~mask);
++ umask(mask);
++
++ /* the close can fail on NFS if out of space */
++ if (close(fd_out) == -1) {
++ unlink(tmp_name);
++ free(tmp_name);
++ return -1;
++ }
++
++ unlink(dest);
++
++ if (rename(tmp_name, dest) == -1) {
++ unlink(tmp_name);
++ free(tmp_name);
++ return -1;
++ }
++
++ free(tmp_name);
++
++ return 0;
++}
++
++/* move a file to the cache, compressing it */
++int move_file(const char *src, const char *dest) {
++ int ret;
++
++ ret = _copy_file(src, dest, COPY_TO_CACHE);
++ if (ret != -1) unlink(src);
++ return ret;
++}
++
++/* copy a file from the cache, decompressing it */
++int copy_file(const char *src, const char *dest) {
++ return _copy_file(src, dest, COPY_FROM_CACHE);
++}
++#endif /* ENABLE_ZLIB */
++
++/* test if a file is zlib compressed */
++int test_if_compressed(const char *filename) {
++ FILE *f;
++
++ f = fopen(filename, "rb");
++ if (!f) {
++ return 0;
++ }
++
++ /* test if file starts with 1F8B, which is zlib's
++ * magic number */
++ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) {
++ fclose(f);
++ return 0;
++ }
++
++ fclose(f);
++ return 1;
++}
+
+ /* make sure a directory exists */
+ int create_dir(const char *dir)
+Index: manage-cache.sh
+===================================================================
+RCS file: manage-cache.sh
+diff -N manage-cache.sh
+--- manage-cache.sh 1 Jan 1970 00:00:00 -0000
++++ manage-cache.sh-cache.sh 12 May 2004 19:22:20 -0000 1.1
+@@ -0,0 +1,68 @@
++#!/bin/bash
++#
++# 2004-05-12 lars@gustaebel.de
++
++CCACHE_DIR=${CCACHE_DIR:-$HOME/.ccache}
++
++echo "Do you want to compress or decompress the ccache in $CCACHE_DIR?"
++read -p "Type c or d: " mode
++
++if [ "$mode" != "c" ] && [ "$mode" != "d" ]
++then
++ exit 1
++fi
++
++is_compressed() {
++ test "$(head -c 2 $1)" = $'\x1f\x8b'
++ return $?
++}
++
++tmpfile=$(mktemp)
++
++for dir in 0 1 2 3 4 5 6 7 8 9 a b c d e f
++do
++ # process ccache subdir
++ echo -n "$dir "
++
++ # find cache files
++ find $CCACHE_DIR/$dir -type f -name '*-*' |
++ sort > $tmpfile
++
++ oldsize=$(cat $CCACHE_DIR/$dir/stats | cut -d ' ' -f 13)
++ newsize=0
++
++ while read file
++ do
++ # empty files will be ignored since compressing
++ # them makes them bigger
++ test $(stat -c %s $file) -eq 0 && continue
++
++ if [ $mode = c ]
++ then
++ if ! is_compressed $file
++ then
++ gzip $file
++ mv $file.gz $file
++ fi
++ else
++ if is_compressed $file
++ then
++ mv $file $file.gz
++ gzip -d $file.gz
++ fi
++ fi
++
++ # calculate new size statistic for this subdir
++ let newsize=$newsize+$(stat -c "%B*%b" $file)/1024
++ done < $tmpfile
++
++ # update statistic file
++ read -a numbers < $CCACHE_DIR/$dir/stats
++ numbers[12]=$newsize
++ echo "${numbers[*]} " > $CCACHE_DIR/$dir/stats
++done
++echo
++
++# clean up
++rm $tmpfile
++
+Index: Makefile.in
+===================================================================
+RCS file: /home/cvsroot/lars/ccache/Makefile.in,v
+retrieving revision 1.1.1.1.2.1
+retrieving revision 1.12
+diff -u -r1.1.1.1.2.1 -r1.12
+--- Makefile.in 21 Nov 2004 17:55:36 -0000 1.1.1.1.2.1
++++ Makefile.in 21 Nov 2004 18:19:28 -0000 1.12
+@@ -11,6 +11,7 @@
+ CFLAGS=@CFLAGS@ -I.
+ EXEEXT=@EXEEXT@
+
++LIBS= @LIBS@
+ OBJS= ccache.o mdfour.o hash.o execute.o util.o args.o stats.o \
+ cleanup.o snprintf.o unify.o
+ HEADERS = ccache.h mdfour.h
+@@ -20,7 +21,7 @@
+ docs: ccache.1 web/ccache-man.html
+
+ ccache$(EXEEXT): $(OBJS) $(HEADERS)
+- $(CC) $(CFLAGS) -o $@ $(OBJS)
++ $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
+
+ ccache.1: ccache.yo
+ -yodl2man -o ccache.1 ccache.yo
diff --git a/CCache/debian/patches/03_long_options.diff b/CCache/debian/patches/03_long_options.diff
new file mode 100644
index 000000000..3235c3806
--- /dev/null
+++ b/CCache/debian/patches/03_long_options.diff
@@ -0,0 +1,133 @@
+Index: ccache.c
+===================================================================
+--- ccache.c (révision 7695)
++++ ccache.c (copie de travail)
+@@ -22,6 +22,7 @@
+ */
+
+ #include "ccache.h"
++#include <getopt.h>
+
+ /* the base cache directory */
+ char *cache_dir = NULL;
+@@ -885,14 +886,14 @@
+ printf("\tcompiler [compile options] (via symbolic link)\n");
+ printf("\nOptions:\n");
+
+- printf("-s show statistics summary\n");
+- printf("-z zero statistics\n");
+- printf("-c run a cache cleanup\n");
+- printf("-C clear the cache completely\n");
+- printf("-F <maxfiles> set maximum files in cache\n");
+- printf("-M <maxsize> set maximum size of cache (use G, M or K)\n");
+- printf("-h this help page\n");
+- printf("-V print version number\n");
++ printf("-s, --show-stats show statistics summary\n");
++ printf("-z, --zero-stats zero statistics\n");
++ printf("-c, --cleanup run a cache cleanup\n");
++ printf("-C, --clear clear the cache completely\n");
++ printf("-F <n>, --max-files=<n> set maximum files in cache\n");
++ printf("-M <n>, --max-size=<n> set maximum size of cache (use G, M or K)\n");
++ printf("-h, --help this help page\n");
++ printf("-V, --version print version number\n");
+ }
+
+ /* the main program when not doing a compile */
+@@ -901,7 +902,21 @@
+ int c;
+ size_t v;
+
+- while ((c = getopt(argc, argv, "hszcCF:M:V")) != -1) {
++ static struct option long_options[] =
++ {
++ {"show-stats", no_argument, 0, 's'},
++ {"zero-stats", no_argument, 0, 'z'},
++ {"cleanup", no_argument, 0, 'c'},
++ {"clear", no_argument, 0, 'C'},
++ {"max-files", required_argument, 0, 'F'},
++ {"max-size", required_argument, 0, 'M'},
++ {"help", no_argument, 0, 'h'},
++ {"version", no_argument, 0, 'V'},
++ {0, 0, 0, 0}
++ };
++ int option_index = 0;
++
++ while ((c = getopt_long(argc, argv, "hszcCF:M:V", long_options, &option_index)) != -1) {
+ switch (c) {
+ case 'V':
+ printf("ccache version %s\n", CCACHE_VERSION);
+Index: ccache.1
+===================================================================
+--- ccache.1 (révision 7695)
++++ ccache.1 (copie de travail)
+@@ -23,14 +23,14 @@
+ .nf
+
+
+--s show statistics summary
+--z zero statistics
+--c run a cache cleanup
+--C clear the cache completely
+--F <maxfiles> set maximum files in cache
+--M <maxsize> set maximum size of cache (use G, M or K)
+--h this help page
+--V print version number
++\-s, \-\-show-stats show statistics summary
++\-z, \-\-zero-stats zero statistics
++\-c, \-\-cleanup run a cache cleanup
++\-C, \-\-clear clear the cache completely
++\-F <n>, \-\-max-files=<n> set maximum files in cache
++\-M <n>, \-\-max-size=<n> set maximum size of cache (use G, M or K)
++\-h, \-\-help this help page
++\-V, \-\-version print version number
+
+ .fi
+
+@@ -43,22 +43,22 @@
+ normal compiler options apply and you should refer to your compilers
+ documentation\&.
+ .PP
+-.IP "\fB-h\fP"
++.IP "\fB-h, --help\fP"
+ Print a options summary page
+ .IP
+-.IP "\fB-s\fP"
++.IP "\fB-s, --show-stats\fP"
+ Print the current statistics summary for the cache\&. The
+ statistics are stored spread across the subdirectories of the
+ cache\&. Using "ccache -s" adds up the statistics across all
+ subdirectories and prints the totals\&.
+ .IP
+-.IP "\fB-z\fP"
++.IP "\fB-z, --zero-stats\fP"
+ Zero the cache statistics\&.
+ .IP
+-.IP "\fB-V\fP"
++.IP "\fB-V, --version\fP"
+ Print the ccache version number
+ .IP
+-.IP "\fB-c\fP"
++.IP "\fB-c, --cleanup\fP"
+ Clean the cache and re-calculate the cache file count and
+ size totals\&. Normally the -c option should not be necessary as ccache
+ keeps the cache below the specified limits at runtime and keeps
+@@ -66,16 +66,16 @@
+ if you manually modify the cache contents or believe that the cache
+ size statistics may be inaccurate\&.
+ .IP
+-.IP "\fB-C\fP"
++.IP "\fB-C, --clear\fP"
+ Clear the entire cache, removing all cached files\&.
+ .IP
+-.IP "\fB-F maxfiles\fP"
++.IP "\fB-F <maxfiles>, --max-files=<maxfiles>\fP"
+ This sets the maximum number of files allowed in
+ the cache\&. The value is stored inside the cache directory and applies
+ to all future compiles\&. Due to the way the value is stored the actual
+ value used is always rounded down to the nearest multiple of 16\&.
+ .IP
+-.IP "\fB-M maxsize\fP"
++.IP "\fB-M <maxsize>, --max-size=<maxsize>\fP"
+ This sets the maximum cache size\&. You can specify
+ a value in gigabytes, megabytes or kilobytes by appending a G, M or K
+ to the value\&. The default is gigabytes\&. The actual value stored is
diff --git a/CCache/debian/patches/04_ignore_profile.diff b/CCache/debian/patches/04_ignore_profile.diff
new file mode 100644
index 000000000..568375092
--- /dev/null
+++ b/CCache/debian/patches/04_ignore_profile.diff
@@ -0,0 +1,13 @@
+diff -ru ccache-2.4/ccache.c ccache-2.4-tp/ccache.c
+--- ccache.c 2007-05-20 03:14:19.000000000 +1000
++++ ccache.c 2007-05-20 03:17:54.000000000 +1000
+@@ -641,6 +641,9 @@
+
+ /* these are too hard */
+ if (strcmp(argv[i], "-fbranch-probabilities")==0 ||
++ strcmp(argv[i], "-fprofile-arcs") == 0 ||
++ strcmp(argv[i], "-ftest-coverage") == 0 ||
++ strcmp(argv[i], "--coverage") == 0 ||
+ strcmp(argv[i], "-M") == 0 ||
+ strcmp(argv[i], "-MM") == 0 ||
+ strcmp(argv[i], "-x") == 0) {
diff --git a/CCache/debian/patches/05_nfs_fix.diff b/CCache/debian/patches/05_nfs_fix.diff
new file mode 100644
index 000000000..662d97639
--- /dev/null
+++ b/CCache/debian/patches/05_nfs_fix.diff
@@ -0,0 +1,45 @@
+--- ccache.1.orig 2007-05-20 17:30:57.000000000 +1200
++++ ccache.1 2007-05-20 17:31:27.000000000 +1200
+@@ -367,12 +367,6 @@
+ .IP o
+ ccache avoids a double call to cpp on a cache miss
+ .PP
+-.SH "BUGS"
+-.PP
+-When the cache is stored on an NFS filesystem, the filesystem must be
+-exported with the \fBno_subtree_check\fP option to make renames between
+-directories reliable\&.
+-.PP
+ .SH "CREDITS"
+ .PP
+ Thanks to the following people for their contributions to ccache
+--- util.c.patched 2007-05-20 18:19:11.000000000 +1200
++++ util.c 2007-05-20 18:20:55.000000000 +1200
+@@ -58,9 +58,26 @@
+ }
+ }
+
++static int safe_rename(const char* oldpath, const char* newpath)
++{
++ /* safe_rename is for creating entries in the cache.
++
++ Works like rename(), but it never overwrites an existing
++ cache entry. This avoids corruption on NFS. */
++ int status = link( oldpath, newpath );
++ if( status == 0 || errno == EEXIST )
++ {
++ return unlink( oldpath );
++ }
++ else
++ {
++ return -1;
++ }
++}
++
+ /* move a file using rename */
+ int move_file(const char *src, const char *dest) {
+- return rename(src, dest);
++ return safe_rename(src, dest);
+ }
+
+ /* copy a file - used when hard links don't work
diff --git a/CCache/debian/patches/06_md.diff b/CCache/debian/patches/06_md.diff
new file mode 100644
index 000000000..3f68850ca
--- /dev/null
+++ b/CCache/debian/patches/06_md.diff
@@ -0,0 +1,77 @@
+--- ccache.c Mon Sep 13 11:38:30 2004
++++ ccache.c Thu Jun 21 22:17:32 2007
+@@ -627,6 +627,13 @@ static void process_args(int argc, char
+ int found_S_opt = 0;
+ struct stat st;
+ char *e;
++ /* is gcc being asked to output dependencies? */
++ int generating_dependencies = 0;
++ /* is the dependency makefile name overridden with -MF? */
++ int dependency_filename_specified = 0;
++ /* is the dependency makefile target name specified with -MQ or -MF? */
++ int dependency_target_specified = 0;
++
+
+ stripped_args = args_init(0, NULL);
+
+@@ -702,6 +709,18 @@ static void process_args(int argc, char
+ continue;
+ }
+
++ /* These options require special handling, because they
++ behave differently with gcc -E, when the output
++ file is not specified. */
++
++ if (strcmp(argv[i], "-MD") == 0 || strcmp(argv[i], "-MMD") == 0) {
++ generating_dependencies = 1;
++ } else if (strcmp(argv[i], "-MF") == 0) {
++ dependency_filename_specified = 1;
++ } else if (strcmp(argv[i], "-MQ") == 0 || strcmp(argv[i], "-MT") == 0) {
++ dependency_target_specified = 1;
++ }
++
+ /* options that take an argument */
+ {
+ const char *opts[] = {"-I", "-include", "-imacros", "-iprefix",
+@@ -812,6 +831,41 @@ static void process_args(int argc, char
+ }
+ p[1] = found_S_opt ? 's' : 'o';
+ p[2] = 0;
++ }
++
++ /* If dependencies are generated, configure the preprocessor */
++
++ if (generating_dependencies && output_file) {
++ if (!dependency_filename_specified) {
++ char *default_depfile_name = x_strdup(output_file);
++ char *p = strrchr(default_depfile_name, '.');
++
++ if (p) {
++ if (strlen(p) < 2) {
++ stats_update(STATS_ARGS);
++ failed();
++ return;
++ }
++ *p = 0;
++ }
++ else {
++ int len = p - default_depfile_name;
++
++ p = x_malloc(len + 3);
++ strncpy(default_depfile_name, p, len - 1);
++ free(default_depfile_name);
++ default_depfile_name = p;
++ }
++
++ strcat(default_depfile_name, ".d");
++ args_add(stripped_args, "-MF");
++ args_add(stripped_args, default_depfile_name);
++ }
++
++ if (!dependency_target_specified) {
++ args_add(stripped_args, "-MT");
++ args_add(stripped_args, output_file);
++ }
+ }
+
+ /* cope with -o /dev/null */
diff --git a/CCache/debian/patches/07_cachedirtag.diff b/CCache/debian/patches/07_cachedirtag.diff
new file mode 100644
index 000000000..683b48d14
--- /dev/null
+++ b/CCache/debian/patches/07_cachedirtag.diff
@@ -0,0 +1,75 @@
+Index: ccache.c
+===================================================================
+--- ccache.c (révision 7695)
++++ ccache.c (copie de travail)
+@@ -1029,6 +1029,14 @@
+ exit(1);
+ }
+
++ if (!getenv("CCACHE_READONLY")) {
++ if (create_cachedirtag(cache_dir) != 0) {
++ fprintf(stderr,"ccache: failed to create %s/CACHEDIR.TAG (%s)\n",
++ cache_dir, strerror(errno));
++ exit(1);
++ }
++ }
++
+ ccache(argc, argv);
+ return 1;
+ }
+Index: ccache.h
+===================================================================
+--- ccache.h (révision 7695)
++++ ccache.h (copie de travail)
+@@ -81,6 +81,7 @@
+ int copy_file(const char *src, const char *dest);
+
+ int create_dir(const char *dir);
++int create_cachedirtag(const char *dir);
+ void x_asprintf(char **ptr, const char *format, ...);
+ char *x_strdup(const char *s);
+ void *x_realloc(void *ptr, size_t size);
+Index: util.c
+===================================================================
+--- util.c (révision 7695)
++++ util.c (copie de travail)
+@@ -138,6 +138,39 @@
+ return 0;
+ }
+
++char const CACHEDIR_TAG[] =
++ "Signature: 8a477f597d28d172789f06886806bc55\n"
++ "# This file is a cache directory tag created by ccache.\n"
++ "# For information about cache directory tags, see:\n"
++ "# http://www.brynosaurus.com/cachedir/\n";
++
++int create_cachedirtag(const char *dir)
++{
++ char *filename;
++ struct stat st;
++ FILE *f;
++ x_asprintf(&filename, "%s/CACHEDIR.TAG", dir);
++ if (stat(filename, &st) == 0) {
++ if (S_ISREG(st.st_mode)) {
++ goto success;
++ }
++ errno = EEXIST;
++ goto error;
++ }
++ f = fopen(filename, "w");
++ if (!f) goto error;
++ if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
++ goto error;
++ }
++ if (fclose(f)) goto error;
++success:
++ free(filename);
++ return 0;
++error:
++ free(filename);
++ return 1;
++}
++
+ /*
+ this is like asprintf() but dies if the malloc fails
+ note that we use vsnprintf in a rather poor way to make this more portable
diff --git a/CCache/debian/patches/08_manpage_hyphens.diff b/CCache/debian/patches/08_manpage_hyphens.diff
new file mode 100644
index 000000000..55ced4a23
--- /dev/null
+++ b/CCache/debian/patches/08_manpage_hyphens.diff
@@ -0,0 +1,89 @@
+Index: ccache.1
+===================================================================
+--- ccache.1 (révision 7695)
++++ ccache.1 (copie de travail)
+@@ -49,7 +49,7 @@
+ .IP "\fB-s\fP"
+ Print the current statistics summary for the cache\&. The
+ statistics are stored spread across the subdirectories of the
+-cache\&. Using "ccache -s" adds up the statistics across all
++cache\&. Using "ccache \-s" adds up the statistics across all
+ subdirectories and prints the totals\&.
+ .IP
+ .IP "\fB-z\fP"
+@@ -60,7 +60,7 @@
+ .IP
+ .IP "\fB-c\fP"
+ Clean the cache and re-calculate the cache file count and
+-size totals\&. Normally the -c option should not be necessary as ccache
++size totals\&. Normally the \-c option should not be necessary as ccache
+ keeps the cache below the specified limits at runtime and keeps
+ statistics up to date on each compile\&. This option is mostly useful
+ if you manually modify the cache contents or believe that the cache
+@@ -100,9 +100,9 @@
+
+
+ cp ccache /usr/local/bin/
+- ln -s /usr/local/bin/ccache /usr/local/bin/gcc
+- ln -s /usr/local/bin/ccache /usr/local/bin/g++
+- ln -s /usr/local/bin/ccache /usr/local/bin/cc
++ ln \-s /usr/local/bin/ccache /usr/local/bin/gcc
++ ln \-s /usr/local/bin/ccache /usr/local/bin/g++
++ ln \-s /usr/local/bin/ccache /usr/local/bin/cc
+
+ .fi
+
+@@ -118,7 +118,7 @@
+ .PP
+ When run as a compiler front end ccache usually just takes the same
+ command line options as the compiler you are using\&. The only exception
+-to this is the option \&'--ccache-skip\&'\&. That option can be used to tell
++to this is the option \&'\-\-ccache-skip\&'\&. That option can be used to tell
+ ccache that the next option is definitely not a input filename, and
+ should be passed along to the compiler as-is\&.
+ .PP
+@@ -128,7 +128,7 @@
+ of the resulting object file (among other things)\&. The heuristic
+ ccache uses in this parse is that any string on the command line that
+ exists as a file is treated as an input file name (usually a C
+-file)\&. By using --ccache-skip you can force an option to not be
++file)\&. By using \-\-ccache-skip you can force an option to not be
+ treated as an input file name and instead be passed along to the
+ compiler as a command line option\&.
+ .PP
+@@ -238,7 +238,7 @@
+ .IP "\fBCCACHE_UNIFY\fP"
+ If you set the environment variable CCACHE_UNIFY
+ then ccache will use the C/C++ unifier when hashing the pre-processor
+-output if -g is not used in the compile\&. The unifier is slower than a
++output if \-g is not used in the compile\&. The unifier is slower than a
+ normal hash, so setting this environment variable loses a little bit
+ of speed, but it means that ccache can take advantage of not
+ recompiling when the changes to the source code consist of
+@@ -262,7 +262,7 @@
+ .PP
+ By default ccache has a one gigabyte limit on the cache size and no
+ maximum number of files\&. You can set a different limit using the
+-"ccache -M" and "ccache -F" options, which set the size and number of
++"ccache \-M" and "ccache \-F" options, which set the size and number of
+ files limits\&.
+ .PP
+ When these limits are reached ccache will reduce the cache to 20%
+@@ -276,7 +276,7 @@
+ that it is the same code by forming a hash of:
+ .PP
+ .IP o
+-the pre-processor output from running the compiler with -E
++the pre-processor output from running the compiler with \-E
+ .IP o
+ the command line options
+ .IP o
+@@ -331,7 +331,7 @@
+ .IP o
+ Make sure that the setgid bit is set on all directories in the
+ cache\&. This tells the filesystem to inherit group ownership for new
+-directories\&. The command "chmod g+s `find $CCACHE_DIR -type d`" might
++directories\&. The command "chmod g+s `find $CCACHE_DIR \-type d`" might
+ be useful for this\&.
+ .PP
+ .SH "HISTORY"
diff --git a/CCache/debian/patches/09_respect_ldflags.diff b/CCache/debian/patches/09_respect_ldflags.diff
new file mode 100644
index 000000000..0ce2c2de3
--- /dev/null
+++ b/CCache/debian/patches/09_respect_ldflags.diff
@@ -0,0 +1,11 @@
+--- Makefile.in.orig 2008-03-23 17:01:19.000000000 +1300
++++ Makefile.in 2008-03-23 17:03:03.000000000 +1300
+@@ -21,7 +21,7 @@
+ docs: ccache.1 web/ccache-man.html
+
+ ccache$(EXEEXT): $(OBJS) $(HEADERS)
+- $(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
++ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+
+ ccache.1: ccache.yo
+ -yodl2man -o ccache.1 ccache.yo
diff --git a/CCache/debian/patches/10_lru_cleanup.diff b/CCache/debian/patches/10_lru_cleanup.diff
new file mode 100644
index 000000000..24463e529
--- /dev/null
+++ b/CCache/debian/patches/10_lru_cleanup.diff
@@ -0,0 +1,23 @@
+--- ccache.c (révision 8804)
++++ ccache.c (copie de travail)
+@@ -481,6 +481,9 @@
+ return;
+ }
+
++ /* update timestamps for LRU cleanup
++ also gives output_file a sensible mtime when hard-linking (for make) */
++ utime(hashname, NULL);
+ utime(stderr_file, NULL);
+
+ if (strcmp(output_file, "/dev/null") == 0) {
+@@ -513,10 +516,6 @@
+ failed();
+ }
+ }
+- if (ret == 0) {
+- /* update the mtime on the file so that make doesn't get confused */
+- utime(output_file, NULL);
+- }
+
+ /* get rid of the intermediate preprocessor file */
+ if (i_tmpfile) {
diff --git a/CCache/debian/patches/11_utimes.diff b/CCache/debian/patches/11_utimes.diff
new file mode 100644
index 000000000..2886bf3d6
--- /dev/null
+++ b/CCache/debian/patches/11_utimes.diff
@@ -0,0 +1,85 @@
+--- ccache.c 2004-09-13 03:38:30.000000000 -0700
++++ ccache.c 2006-06-09 16:29:16.695117780 -0700
+@@ -481,8 +481,13 @@
+
+ /* update timestamps for LRU cleanup
+ also gives output_file a sensible mtime when hard-linking (for make) */
++#ifdef HAVE_UTIMES
++ utimes(hashname, NULL);
++ utimes(stderr_file, NULL);
++#else
+ utime(hashname, NULL);
+ utime(stderr_file, NULL);
++#endif
+
+ if (strcmp(output_file, "/dev/null") == 0) {
+ ret = 0;
+--- ccache.h 2004-09-13 03:38:30.000000000 -0700
++++ ccache.h 2006-06-09 16:28:16.601658626 -0700
+@@ -22,6 +22,9 @@
+ #ifdef HAVE_PWD_H
+ #include <pwd.h>
+ #endif
++#ifdef HAVE_SYS_TIME_H
++#include <sys/time.h>
++#endif
+
+ #define STATUS_NOTFOUND 3
+ #define STATUS_FATAL 4
+--- config.h.in 2003-09-27 21:48:17.000000000 -0700
++++ config.h.in 2006-06-09 16:25:43.000000000 -0700
+@@ -19,6 +19,9 @@
+ /* Define to 1 if you have the `gethostname' function. */
+ #undef HAVE_GETHOSTNAME
+
++/* Define to 1 if you have the `getpwuid' function. */
++#undef HAVE_GETPWUID
++
+ /* Define to 1 if you have the <inttypes.h> header file. */
+ #undef HAVE_INTTYPES_H
+
+@@ -31,6 +34,9 @@
+ /* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+ #undef HAVE_NDIR_H
+
++/* Define to 1 if you have the <pwd.h> header file. */
++#undef HAVE_PWD_H
++
+ /* Define to 1 if you have the `realpath' function. */
+ #undef HAVE_REALPATH
+
+@@ -60,6 +66,9 @@
+ /* Define to 1 if you have the <sys/stat.h> header file. */
+ #undef HAVE_SYS_STAT_H
+
++/* Define to 1 if you have the <sys/time.h> header file. */
++#undef HAVE_SYS_TIME_H
++
+ /* Define to 1 if you have the <sys/types.h> header file. */
+ #undef HAVE_SYS_TYPES_H
+
+@@ -69,6 +78,9 @@
+ /* Define to 1 if you have the <unistd.h> header file. */
+ #undef HAVE_UNISTD_H
+
++/* Define to 1 if you have the `utimes' function. */
++#undef HAVE_UTIMES
++
+ /* Define to 1 if you have the `vasprintf' function. */
+ #undef HAVE_VASPRINTF
+
+--- configure.in 2004-09-13 03:38:30.000000000 -0700
++++ configure.in 2006-06-09 16:25:15.541288184 -0700
+@@ -27,10 +27,11 @@
+ AC_HEADER_TIME
+ AC_HEADER_SYS_WAIT
+
+-AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h)
++AC_CHECK_HEADERS(ctype.h strings.h stdlib.h string.h pwd.h sys/time.h)
+
+ AC_CHECK_FUNCS(realpath snprintf vsnprintf vasprintf asprintf mkstemp)
+ AC_CHECK_FUNCS(gethostname getpwuid)
++AC_CHECK_FUNCS(utimes)
+
+ AC_CACHE_CHECK([for compar_fn_t in stdlib.h],ccache_cv_COMPAR_FN_T, [
+ AC_TRY_COMPILE(
diff --git a/CCache/debian/patches/12_cachesize_permissions.diff b/CCache/debian/patches/12_cachesize_permissions.diff
new file mode 100644
index 000000000..28801b771
--- /dev/null
+++ b/CCache/debian/patches/12_cachesize_permissions.diff
@@ -0,0 +1,83 @@
+--- stats.c (révision 8804)
++++ stats.c (copie de travail)
+@@ -286,7 +286,7 @@
+
+
+ /* set the per directory limits */
+-void stats_set_limits(long maxfiles, long maxsize)
++int stats_set_limits(long maxfiles, long maxsize)
+ {
+ int dir;
+ unsigned counters[STATS_END];
+@@ -298,7 +298,9 @@
+ maxsize /= 16;
+ }
+
+- create_dir(cache_dir);
++ if (create_dir(cache_dir) != 0) {
++ return 1;
++ }
+
+ /* set the limits in each directory */
+ for (dir=0;dir<=0xF;dir++) {
+@@ -306,7 +308,9 @@
+ int fd;
+
+ x_asprintf(&cdir, "%s/%1x", cache_dir, dir);
+- create_dir(cdir);
++ if (create_dir(cdir) != 0) {
++ return 1;
++ }
+ x_asprintf(&fname, "%s/stats", cdir);
+ free(cdir);
+
+@@ -326,6 +330,8 @@
+ }
+ free(fname);
+ }
++
++ return 0;
+ }
+
+ /* set the per directory sizes */
+--- ccache.c (révision 8804)
++++ ccache.c (copie de travail)
+@@ -935,15 +934,23 @@
+ case 'F':
+ check_cache_dir();
+ v = atoi(optarg);
+- stats_set_limits(v, -1);
+- printf("Set cache file limit to %u\n", (unsigned)v);
++ if (stats_set_limits(v, -1) == 0) {
++ printf("Set cache file limit to %u\n", (unsigned)v);
++ } else {
++ printf("Could not set cache file limit.\n");
++ exit(1);
++ }
+ break;
+
+ case 'M':
+ check_cache_dir();
+ v = value_units(optarg);
+- stats_set_limits(-1, v);
+- printf("Set cache size limit to %uk\n", (unsigned)v);
++ if (stats_set_limits(-1, v) == 0) {
++ printf("Set cache size limit to %uk\n", (unsigned)v);
++ } else {
++ printf("Could not set cache size limit.\n");
++ exit(1);
++ }
+ break;
+
+ default:
+--- ccache.h (révision 8804)
++++ ccache.h (copie de travail)
+@@ -101,7 +101,7 @@
+ void stats_summary(void);
+ void stats_tocache(size_t size);
+ void stats_read(const char *stats_file, unsigned counters[STATS_END]);
+-void stats_set_limits(long maxfiles, long maxsize);
++int stats_set_limits(long maxfiles, long maxsize);
+ size_t value_units(const char *s);
+ void display_size(unsigned v);
+ void stats_set_sizes(const char *dir, size_t num_files, size_t total_size);
diff --git a/CCache/debian/patches/13_html_links.diff b/CCache/debian/patches/13_html_links.diff
new file mode 100644
index 000000000..dadf1b6c2
--- /dev/null
+++ b/CCache/debian/patches/13_html_links.diff
@@ -0,0 +1,33 @@
+--- web/index.html~ 2004-09-13 13:38:30.000000000 +0300
++++ web/index.html 2004-09-26 01:04:38.458008118 +0300
+@@ -29,10 +29,10 @@
+ <li>fixed handling of HOME environment variable
+ </ul>
+
+-See the <a href="/ccache/ccache-man.html">manual page</a> for details
++See the <a href="ccache-man.html">manual page</a> for details
+ on the new options.<p>
+
+-You can get this release from the <a href="/ftp/ccache/">download directory</a>
++You can get this release from the <a href="http://ccache.samba.org/ftp/ccache/">download directory</a>
+
+ <p>NOTE! This release changes the hash input slighly, so you will
+ probably find that you will not get any hits against your existing
+@@ -87,7 +87,7 @@
+
+ <h2>Documentation</h2>
+
+-See the <a href="/ccache/ccache-man.html">manual page</a>
++See the <a href="ccache-man.html">manual page</a>
+
+
+ <h2>Performance</h2>
+@@ -116,7 +116,7 @@
+ <h2>Download</h2>
+
+ You can download the latest release from the <a
+-href="/ftp/ccache/">download directory</a>.<p>
++href="http://ccache.samba.org/ftp/ccache/">download directory</a>.<p>
+
+ For the bleeding edge, you can fetch ccache via CVS or
+ rsync. To fetch via cvs use the following command:
diff --git a/CCache/debian/patches/14_hardlink_doc.diff b/CCache/debian/patches/14_hardlink_doc.diff
new file mode 100644
index 000000000..bd9e25ba6
--- /dev/null
+++ b/CCache/debian/patches/14_hardlink_doc.diff
@@ -0,0 +1,48 @@
+Index: ccache.1
+===================================================================
+RCS file: /cvsroot/ccache/ccache.1,v
+retrieving revision 1.26
+diff -u -r1.26 ccache.1
+--- ccache.1 24 Nov 2005 21:10:08 -0000 1.26
++++ ccache.1 21 Jul 2007 21:03:32 -0000
+@@ -330,7 +330,7 @@
+ .IP o
+ Use the same \fBCCACHE_DIR\fP environment variable setting
+ .IP o
+-Set the \fBCCACHE_NOLINK\fP environment variable
++Unset the \fBCCACHE_HARDLINK\fP environment variable
+ .IP o
+ Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+Index: ccache.yo
+===================================================================
+RCS file: /cvsroot/ccache/ccache.yo,v
+retrieving revision 1.27
+diff -u -r1.27 ccache.yo
+--- ccache.yo 24 Nov 2005 21:54:09 -0000 1.27
++++ ccache.yo 21 Jul 2007 21:03:32 -0000
+@@ -289,7 +289,7 @@
+
+ itemize(
+ it() Use the same bf(CCACHE_DIR) environment variable setting
+- it() Set the bf(CCACHE_NOLINK) environment variable
++ it() Unset the bf(CCACHE_HARDLINK) environment variable
+ it() Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+ the group.
+Index: web/ccache-man.html
+===================================================================
+RCS file: /cvsroot/ccache/web/ccache-man.html,v
+retrieving revision 1.25
+diff -u -r1.25 ccache-man.html
+--- web/ccache-man.html 13 Sep 2004 10:38:17 -0000 1.25
++++ web/ccache-man.html 21 Jul 2007 21:03:32 -0000
+@@ -256,7 +256,7 @@
+ following conditions need to be met:
+ <p><ul>
+ <li > Use the same <strong>CCACHE_DIR</strong> environment variable setting
+- <li > Set the <strong>CCACHE_NOLINK</strong> environment variable
++ <li > Unset the <strong>CCACHE_HARDLINK</strong> environment variable
+ <li > Make sure everyone sets the CCACHE_UMASK environment variable
+ to 002, this ensures that cached files are accessible to everyone in
+ the group.
diff --git a/CCache/debian/patches/CREDITS b/CCache/debian/patches/CREDITS
new file mode 100644
index 000000000..c4e323b7b
--- /dev/null
+++ b/CCache/debian/patches/CREDITS
@@ -0,0 +1,47 @@
+01_no_home.diff:
+ Francois Marier <francois@debian.org>
+ Made especially for the Debian package.
+
+02_ccache_compressed.diff:
+ Lars Gustäbel <lars@gustaebel.de>
+ http://www.gustaebel.de/lars/ccache/ (downloaded on 2007-05-20)
+
+03_long_options.diff:
+ Francois Marier <francois@debian.org>
+ Made especially for the Debian package.
+
+04_ignore_profile.diff:
+ Ted Percival <ted@midg3t.net>
+ http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=20;filename=ccache-profile.patch;att=1;bug=215849
+
+05_nfs_fix.diff:
+ John Coiner <john.coiner@amd.com>
+ http://lists.samba.org/archive/ccache/2007q1/000265.html
+
+06_md.diff:
+ Andrea Bittau <a.bittau@cs.ucl.ac.uk>
+ http://darkircop.org/ccache/ccache-2.4-md.patch (downloaded on 2007-06-30)
+
+07_cachedirtag.diff:
+ Karl Chen <quarl@cs.berkeley.edu>
+ http://lists.samba.org/archive/ccache/2008q1/000316.html (downloaded on 2008-02-02)
+
+08_manpage_hyphens.diff:
+ Francois Marier <francois@debian.org>
+ Made especially for the Debian package.
+
+09_respect_ldflags.diff:
+ Lisa Seelye <lisa@gentoo.org>
+ http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-respectflags.patch?rev=1.1&view=markup
+
+10_lru_cleanup.diff:
+ RW <fbsd06@mlists.homeunix.com>
+ http://lists.samba.org/archive/ccache/2008q2/000339.html (downloaded on 2008-04-11)
+
+11_utimes.diff:
+ Robin H. Johnson <robbat2@gentoo.org>
+ http://sources.gentoo.org/viewcvs.py/gentoo-x86/dev-util/ccache/files/ccache-2.4-utimes.patch?rev=1.1&view=markup
+
+12_cachesize_permissions.diff:
+ Francois Marier <francois@debian.org>
+ Made especially for the Debian package to fix http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=332527
diff --git a/CCache/debian/rules b/CCache/debian/rules
new file mode 100644
index 000000000..c5b538b78
--- /dev/null
+++ b/CCache/debian/rules
@@ -0,0 +1,141 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+export DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+export DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+ confflags += --build $(DEB_HOST_GNU_TYPE)
+else
+ confflags += --build $(DEB_BUILD_GNU_TYPE) --host $(DEB_HOST_GNU_TYPE)
+endif
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -g
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+config.status: configure
+ dh_testdir
+
+ # Apply Debian specific patches
+ cp $(CURDIR)/ccache.c $(CURDIR)/ccache.c.unpatched
+ cp $(CURDIR)/util.c $(CURDIR)/util.c.unpatched
+ cp $(CURDIR)/ccache.1 $(CURDIR)/ccache.1.unpatched
+ cp $(CURDIR)/ccache.h $(CURDIR)/ccache.h.unpatched
+ cp $(CURDIR)/ccache.yo $(CURDIR)/ccache.yo.unpatched
+ cp $(CURDIR)/config.h.in $(CURDIR)/config.h.in.unpatched
+ cp $(CURDIR)/configure $(CURDIR)/configure.unpatched
+ cp $(CURDIR)/configure.in $(CURDIR)/configure.in.unpatched
+ cp $(CURDIR)/Makefile.in $(CURDIR)/Makefile.in.unpatched
+ if test ! -f patch-stamp; then \
+ for patch in $(CURDIR)/debian/patches/*.diff ;\
+ do \
+ echo APPLYING PATCH\: $${patch##*/};\
+ patch -p0 < $$patch ;\
+ done ;\
+ touch patch-stamp ;\
+ fi
+ chmod +x $(CURDIR)/manage-cache.sh
+
+ ./configure $(confflags) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
+
+build: build-stamp
+
+build-stamp: config.status
+ dh_testdir
+
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Unapply patches
+ -test -r $(CURDIR)/ccache.c.unpatched && mv $(CURDIR)/ccache.c.unpatched $(CURDIR)/ccache.c
+ -test -r $(CURDIR)/util.c.unpatched && mv $(CURDIR)/util.c.unpatched $(CURDIR)/util.c
+ -test -r $(CURDIR)/ccache.1.unpatched && mv $(CURDIR)/ccache.1.unpatched $(CURDIR)/ccache.1
+ -test -r $(CURDIR)/ccache.h.unpatched && mv $(CURDIR)/ccache.h.unpatched $(CURDIR)/ccache.h
+ -test -r $(CURDIR)/ccache.yo.unpatched && mv $(CURDIR)/ccache.yo.unpatched $(CURDIR)/ccache.yo
+ -test -r $(CURDIR)/config.h.in.unpatched && mv $(CURDIR)/config.h.in.unpatched $(CURDIR)/config.h.in
+ -test -r $(CURDIR)/configure.unpatched && mv $(CURDIR)/configure.unpatched $(CURDIR)/configure
+ -test -r $(CURDIR)/configure.in.unpatched && mv $(CURDIR)/configure.in.unpatched $(CURDIR)/configure.in
+ -test -r $(CURDIR)/Makefile.in.unpatched && mv $(CURDIR)/Makefile.in.unpatched $(CURDIR)/Makefile.in
+ -rm -f $(CURDIR)/manage-cache.sh
+ -rm -f patch-stamp
+
+ [ ! -f Makefile ] || $(MAKE) distclean
+
+ dh_clean
+
+ # Update config.sub and config.guess
+ -test -r /usr/share/misc/config.sub && \
+ cp -f /usr/share/misc/config.sub config.sub
+ -test -r /usr/share/misc/config.guess && \
+ cp -f /usr/share/misc/config.guess config.guess
+
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/ccache.
+ $(MAKE) install prefix=$(CURDIR)/debian/ccache/usr
+
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++
+ set -e; for ver in 2.95 3.0 3.2 3.3 3.4 4.0 4.1 4.2 4.3; do \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-gcc-$$ver; \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc-$$ver; \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/$(DEB_BUILD_GNU_TYPE)-g++-$$ver; \
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++-$$ver; \
+ done
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/cc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/c++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/gcc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/g++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-c++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-cc
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-g++
+ ln -s ../../bin/ccache $(CURDIR)/debian/ccache/usr/lib/ccache/i586-mingw32msvc-gcc
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installdocs
+ dh_installexamples
+ dh_installmenu
+ dh_installcron
+ dh_installman
+ dh_installinfo
+ dh_installchangelogs
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/CCache/debian/update-ccache b/CCache/debian/update-ccache
new file mode 100644
index 000000000..0ef97a140
--- /dev/null
+++ b/CCache/debian/update-ccache
@@ -0,0 +1,43 @@
+#!/bin/sh
+#
+# Update compiler links to ccache (in /usr/local/bin)
+#
+# The idea is that /usr/local/bin is ahead of /usr/bin in your PATH, so adding
+# the link /usr/local/bin/cc -> /usr/bin/ccache means that it is run instead of
+# /usr/bin/cc
+#
+# Written by: Behan Webster <behanw@websterwood.com>
+#
+
+DIRECTORY=/usr/local/bin
+CCACHE=/usr/bin/ccache
+CCDIR=/usr/lib/ccache
+
+usage() {
+ echo "Usage: `basename $0` [--directory <dir>] [--remove]"
+ exit 0
+}
+
+while [ $# -gt 0 ] ; do
+ case "$1" in
+ -d*|--d*|--directory) DIRECTORY=$2; shift; shift;;
+ -h*|--h*|--help) usage;;
+ -r*|--r*|--remove) REMOVE=1; shift;;
+ -t*|--t*|--test) TEST=echo; shift;;
+ esac
+done
+
+for FILE in `cd $CCDIR; ls` ; do
+ LINK=$DIRECTORY/$FILE
+ if [ -z "$REMOVE" ] ; then
+ # Add link
+ $TEST ln -fs $CCACHE $LINK
+ else
+ # Remove link
+ if [ -L "$LINK" ] ; then
+ $TEST rm -f $LINK
+ fi
+ fi
+done
+
+# vim: sw=4 ts=4
diff --git a/CCache/debian/watch b/CCache/debian/watch
new file mode 100644
index 000000000..a72959e50
--- /dev/null
+++ b/CCache/debian/watch
@@ -0,0 +1,2 @@
+version=2
+http://samba.org/ftp/ccache/ccache-(.*)\.tar\.gz
diff --git a/CCache/execute.c b/CCache/execute.c
new file mode 100644
index 000000000..165b91e66
--- /dev/null
+++ b/CCache/execute.c
@@ -0,0 +1,286 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+#ifdef _WIN32
+char *argvtos(char **argv)
+{
+ int i, len;
+ char *ptr, *str;
+
+ for (i = 0, len = 0; argv[i]; i++) {
+ len += strlen(argv[i]) + 3;
+ }
+
+ str = ptr = (char *)malloc(len + 1);
+ if (str == NULL)
+ return NULL;
+
+ for (i = 0; argv[i]; i++) {
+ len = strlen(argv[i]);
+ *ptr++ = '"';
+ memcpy(ptr, argv[i], len);
+ ptr += len;
+ *ptr++ = '"';
+ *ptr++ = ' ';
+ }
+ *ptr = 0;
+
+ return str;
+}
+#endif
+
+/*
+ execute a compiler backend, capturing all output to the given paths
+ the full path to the compiler to run is in argv[0]
+*/
+int execute(char **argv,
+ const char *path_stdout,
+ const char *path_stderr)
+{
+#ifdef _WIN32
+
+#if 1
+ PROCESS_INFORMATION pinfo;
+ STARTUPINFO sinfo;
+ BOOL ret;
+ DWORD exitcode;
+ char *args;
+ HANDLE fd_out, fd_err;
+ SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), NULL, TRUE};
+
+ /* TODO: needs moving after possible exit() below, but before stdout is redirected */
+ if (ccache_verbose) {
+ display_execute_args(argv);
+ }
+
+ fd_out = CreateFile(path_stdout, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (fd_out == INVALID_HANDLE_VALUE) {
+ return STATUS_NOCACHE;
+ }
+
+ fd_err = CreateFile(path_stderr, GENERIC_WRITE, 0, &sa, CREATE_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (fd_err == INVALID_HANDLE_VALUE) {
+ return STATUS_NOCACHE;
+ }
+
+ ZeroMemory(&pinfo, sizeof(PROCESS_INFORMATION));
+ ZeroMemory(&sinfo, sizeof(STARTUPINFO));
+
+ sinfo.cb = sizeof(STARTUPINFO);
+ sinfo.hStdError = fd_err;
+ sinfo.hStdOutput = fd_out;
+ sinfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
+ sinfo.dwFlags |= STARTF_USESTDHANDLES;
+
+ args = argvtos(argv);
+
+ ret = CreateProcessA(argv[0], args, NULL, NULL, TRUE, 0, NULL, NULL,
+ &sinfo, &pinfo);
+
+ free(args);
+ CloseHandle(fd_out);
+ CloseHandle(fd_err);
+
+ if (ret == 0)
+ return -1;
+
+ WaitForSingleObject(pinfo.hProcess, INFINITE);
+ GetExitCodeProcess(pinfo.hProcess, &exitcode);
+ CloseHandle(pinfo.hProcess);
+ CloseHandle(pinfo.hThread);
+
+ return exitcode;
+#else /* possibly slightly faster */
+ /* needs fixing to quote commandline options to handle spaces in CCACHE_DIR etc */
+ int status = -2;
+ int fd, std_od = -1, std_ed = -1;
+
+ /* TODO: needs moving after possible exit() below, but before stdout is redirected */
+ if (ccache_verbose) {
+ display_execute_args(argv);
+ }
+
+ unlink(path_stdout);
+ std_od = _dup(1);
+ fd = _open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ _dup2(fd, 1);
+ _close(fd);
+
+ unlink(path_stderr);
+ fd = _open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ std_ed = _dup(2);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ _dup2(fd, 2);
+ _close(fd);
+
+ /* Spawn process (_exec* familly doesn't return) */
+ status = _spawnv(_P_WAIT, argv[0], (const char **)argv);
+
+ /* Restore descriptors */
+ if (std_od != -1) _dup2(std_od, 1);
+ if (std_ed != -1) _dup2(std_ed, 2);
+ _flushall();
+
+ return (status>0);
+
+#endif
+
+#else
+ pid_t pid;
+ int status;
+
+ pid = fork();
+ if (pid == -1) fatal("Failed to fork");
+
+ if (pid == 0) {
+ int fd;
+
+ /* TODO: needs moving after possible exit() below, but before stdout is redirected */
+ if (ccache_verbose) {
+ display_execute_args(argv);
+ }
+
+ unlink(path_stdout);
+ fd = open(path_stdout, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ dup2(fd, 1);
+ close(fd);
+
+ unlink(path_stderr);
+ fd = open(path_stderr, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ exit(STATUS_NOCACHE);
+ }
+ dup2(fd, 2);
+ close(fd);
+
+ exit(execv(argv[0], argv));
+ }
+
+ if (waitpid(pid, &status, 0) != pid) {
+ fatal("waitpid failed");
+ }
+
+ if (WEXITSTATUS(status) == 0 && WIFSIGNALED(status)) {
+ return -1;
+ }
+
+ return WEXITSTATUS(status);
+#endif
+}
+
+
+/*
+ find an executable by name in $PATH. Exclude any that are links to exclude_name
+*/
+char *find_executable(const char *name, const char *exclude_name)
+{
+#if _WIN32
+ (void)exclude_name;
+ DWORD ret;
+ char namebuf[MAX_PATH];
+
+ ret = SearchPathA(getenv("CCACHE_PATH"), name, ".exe",
+ sizeof(namebuf), namebuf, NULL);
+ if (ret != 0) {
+ return x_strdup(namebuf);
+ }
+
+ return NULL;
+#else
+ char *path;
+ char *tok;
+ struct stat st1, st2;
+
+ if (*name == '/') {
+ return x_strdup(name);
+ }
+
+ path = getenv("CCACHE_PATH");
+ if (!path) {
+ path = getenv("PATH");
+ }
+ if (!path) {
+ cc_log("no PATH variable!?\n");
+ stats_update(STATS_ENVIRONMMENT);
+ return NULL;
+ }
+
+ path = x_strdup(path);
+
+ /* search the path looking for the first compiler of the right name
+ that isn't us */
+ for (tok=strtok(path,":"); tok; tok = strtok(NULL, ":")) {
+ char *fname;
+ x_asprintf(&fname, "%s/%s", tok, name);
+ /* look for a normal executable file */
+ if (access(fname, X_OK) == 0 &&
+ lstat(fname, &st1) == 0 &&
+ stat(fname, &st2) == 0 &&
+ S_ISREG(st2.st_mode)) {
+ /* if its a symlink then ensure it doesn't
+ point at something called exclude_name */
+ if (S_ISLNK(st1.st_mode)) {
+ char *buf = x_realpath(fname);
+ if (buf) {
+ char *p = str_basename(buf);
+ if (strcmp(p, exclude_name) == 0) {
+ /* its a link to "ccache" ! */
+ free(p);
+ free(buf);
+ continue;
+ }
+ free(buf);
+ free(p);
+ }
+ }
+
+ /* found it! */
+ free(path);
+ return fname;
+ }
+ free(fname);
+ }
+
+ return NULL;
+#endif
+}
+
+void display_execute_args(char **argv)
+{
+ if (argv) {
+ printf("ccache executing: ");
+ while (*argv) {
+ printf("%s ", *argv);
+ ++argv;
+ }
+ printf("\n");
+ fflush(stdout);
+ }
+}
diff --git a/CCache/hash.c b/CCache/hash.c
new file mode 100644
index 000000000..d0ce8a6ba
--- /dev/null
+++ b/CCache/hash.c
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ simple front-end functions to mdfour code
+*/
+
+#include "ccache.h"
+
+static struct mdfour md;
+
+void hash_buffer(const char *s, int len)
+{
+ mdfour_update(&md, (unsigned char *)s, len);
+}
+
+void hash_start(void)
+{
+ mdfour_begin(&md);
+}
+
+void hash_string(const char *s)
+{
+ hash_buffer(s, strlen(s));
+}
+
+void hash_int(int x)
+{
+ hash_buffer((char *)&x, sizeof(x));
+}
+
+/* add contents of a file to the hash */
+void hash_file(const char *fname)
+{
+ char buf[1024];
+ int fd, n;
+
+ fd = open(fname, O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ cc_log("Failed to open %s\n", fname);
+ fatal("hash_file");
+ }
+
+ while ((n = read(fd, buf, sizeof(buf))) > 0) {
+ hash_buffer(buf, n);
+ }
+ close(fd);
+}
+
+/* return the hash result as a static string */
+char *hash_result(void)
+{
+ unsigned char sum[16];
+ static char ret[53];
+ int i;
+
+ hash_buffer(NULL, 0);
+ mdfour_result(&md, sum);
+
+ for (i=0;i<16;i++) {
+ sprintf(&ret[i*2], "%02x", (unsigned)sum[i]);
+ }
+ sprintf(&ret[i*2], "-%u", (unsigned)md.totalN);
+
+ return ret;
+}
diff --git a/CCache/install-sh b/CCache/install-sh
new file mode 100755
index 000000000..58719246f
--- /dev/null
+++ b/CCache/install-sh
@@ -0,0 +1,238 @@
+#! /bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+#
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+ case $1 in
+ -c) instcmd="$cpprog"
+ shift
+ continue;;
+
+ -d) dir_arg=true
+ shift
+ continue;;
+
+ -m) chmodcmd="$chmodprog $2"
+ shift
+ shift
+ continue;;
+
+ -o) chowncmd="$chownprog $2"
+ shift
+ shift
+ continue;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift
+ shift
+ continue;;
+
+ -s) stripcmd="$stripprog"
+ shift
+ continue;;
+
+ -t=*) transformarg=`echo $1 | sed 's/-t=//'`
+ shift
+ continue;;
+
+ -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+ shift
+ continue;;
+
+ *) if [ x"$src" = x ]
+ then
+ src=$1
+ else
+ # this colon is to work around a 386BSD /bin/sh bug
+ :
+ dst=$1
+ fi
+ shift
+ continue;;
+ esac
+done
+
+if [ x"$src" = x ]
+then
+ echo "install: no input file specified"
+ exit 1
+else
+ true
+fi
+
+if [ x"$dir_arg" != x ]; then
+ dst=$src
+ src=""
+
+ if [ -d $dst ]; then
+ instcmd=:
+ else
+ instcmd=mkdir
+ fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad
+# if $src (and thus $dsttmp) contains '*'.
+
+ if [ -f $src -o -d $src ]
+ then
+ true
+ else
+ echo "install: $src does not exist"
+ exit 1
+ fi
+
+ if [ x"$dst" = x ]
+ then
+ echo "install: no destination specified"
+ exit 1
+ else
+ true
+ fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+ if [ -d $dst ]
+ then
+ dst="$dst"/`basename $src`
+ else
+ true
+ fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+# this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+ pathcomp="${pathcomp}${1}"
+ shift
+
+ if [ ! -d "${pathcomp}" ] ;
+ then
+ $mkdirprog "${pathcomp}"
+ else
+ true
+ fi
+
+ pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+ $doit $instcmd $dst &&
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+ if [ x"$transformarg" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ dstfile=`basename $dst $transformbasename |
+ sed $transformarg`$transformbasename
+ fi
+
+# don't allow the sed command to completely eliminate the filename
+
+ if [ x"$dstfile" = x ]
+ then
+ dstfile=`basename $dst`
+ else
+ true
+ fi
+
+# Make a temp file name in the proper directory.
+
+ dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+ $doit $instcmd $src $dsttmp &&
+
+ trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing. If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+ if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+ if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+ if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+ if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+ $doit $rmcmd -f $dstdir/$dstfile &&
+ $doit $mvcmd $dsttmp $dstdir/$dstfile
+
+fi &&
+
+
+exit 0
diff --git a/CCache/mdfour.c b/CCache/mdfour.c
new file mode 100644
index 000000000..b098e0215
--- /dev/null
+++ b/CCache/mdfour.c
@@ -0,0 +1,284 @@
+/*
+ a implementation of MD4 designed for use in the SMB authentication protocol
+ Copyright (C) Andrew Tridgell 1997-1998.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+/* NOTE: This code makes no attempt to be fast!
+
+ It assumes that a int is at least 32 bits long
+*/
+
+static struct mdfour *m;
+
+#define MASK32 (0xffffffff)
+
+#define F(X,Y,Z) ((((X)&(Y)) | ((~(X))&(Z))))
+#define G(X,Y,Z) ((((X)&(Y)) | ((X)&(Z)) | ((Y)&(Z))))
+#define H(X,Y,Z) (((X)^(Y)^(Z)))
+#define lshift(x,s) (((((x)<<(s))&MASK32) | (((x)>>(32-(s)))&MASK32)))
+
+#define ROUND1(a,b,c,d,k,s) a = lshift((a + F(b,c,d) + M[k])&MASK32, s)
+#define ROUND2(a,b,c,d,k,s) a = lshift((a + G(b,c,d) + M[k] + 0x5A827999)&MASK32,s)
+#define ROUND3(a,b,c,d,k,s) a = lshift((a + H(b,c,d) + M[k] + 0x6ED9EBA1)&MASK32,s)
+
+/* this applies md4 to 64 byte chunks */
+static void mdfour64(uint32 *M)
+{
+ uint32 AA, BB, CC, DD;
+ uint32 A,B,C,D;
+
+ A = m->A; B = m->B; C = m->C; D = m->D;
+ AA = A; BB = B; CC = C; DD = D;
+
+ ROUND1(A,B,C,D, 0, 3); ROUND1(D,A,B,C, 1, 7);
+ ROUND1(C,D,A,B, 2, 11); ROUND1(B,C,D,A, 3, 19);
+ ROUND1(A,B,C,D, 4, 3); ROUND1(D,A,B,C, 5, 7);
+ ROUND1(C,D,A,B, 6, 11); ROUND1(B,C,D,A, 7, 19);
+ ROUND1(A,B,C,D, 8, 3); ROUND1(D,A,B,C, 9, 7);
+ ROUND1(C,D,A,B, 10, 11); ROUND1(B,C,D,A, 11, 19);
+ ROUND1(A,B,C,D, 12, 3); ROUND1(D,A,B,C, 13, 7);
+ ROUND1(C,D,A,B, 14, 11); ROUND1(B,C,D,A, 15, 19);
+
+
+ ROUND2(A,B,C,D, 0, 3); ROUND2(D,A,B,C, 4, 5);
+ ROUND2(C,D,A,B, 8, 9); ROUND2(B,C,D,A, 12, 13);
+ ROUND2(A,B,C,D, 1, 3); ROUND2(D,A,B,C, 5, 5);
+ ROUND2(C,D,A,B, 9, 9); ROUND2(B,C,D,A, 13, 13);
+ ROUND2(A,B,C,D, 2, 3); ROUND2(D,A,B,C, 6, 5);
+ ROUND2(C,D,A,B, 10, 9); ROUND2(B,C,D,A, 14, 13);
+ ROUND2(A,B,C,D, 3, 3); ROUND2(D,A,B,C, 7, 5);
+ ROUND2(C,D,A,B, 11, 9); ROUND2(B,C,D,A, 15, 13);
+
+ ROUND3(A,B,C,D, 0, 3); ROUND3(D,A,B,C, 8, 9);
+ ROUND3(C,D,A,B, 4, 11); ROUND3(B,C,D,A, 12, 15);
+ ROUND3(A,B,C,D, 2, 3); ROUND3(D,A,B,C, 10, 9);
+ ROUND3(C,D,A,B, 6, 11); ROUND3(B,C,D,A, 14, 15);
+ ROUND3(A,B,C,D, 1, 3); ROUND3(D,A,B,C, 9, 9);
+ ROUND3(C,D,A,B, 5, 11); ROUND3(B,C,D,A, 13, 15);
+ ROUND3(A,B,C,D, 3, 3); ROUND3(D,A,B,C, 11, 9);
+ ROUND3(C,D,A,B, 7, 11); ROUND3(B,C,D,A, 15, 15);
+
+ A += AA; B += BB;
+ C += CC; D += DD;
+
+ A &= MASK32; B &= MASK32;
+ C &= MASK32; D &= MASK32;
+
+ m->A = A; m->B = B; m->C = C; m->D = D;
+}
+
+static void copy64(uint32 *M, const unsigned char *in)
+{
+ int i;
+
+ for (i=0;i<16;i++)
+ M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
+ (in[i*4+1]<<8) | (in[i*4+0]<<0);
+}
+
+static void copy4(unsigned char *out,uint32 x)
+{
+ out[0] = x&0xFF;
+ out[1] = (x>>8)&0xFF;
+ out[2] = (x>>16)&0xFF;
+ out[3] = (x>>24)&0xFF;
+}
+
+void mdfour_begin(struct mdfour *md)
+{
+ md->A = 0x67452301;
+ md->B = 0xefcdab89;
+ md->C = 0x98badcfe;
+ md->D = 0x10325476;
+ md->totalN = 0;
+ md->tail_len = 0;
+}
+
+
+static void mdfour_tail(const unsigned char *in, int n)
+{
+ unsigned char buf[128];
+ uint32 M[16];
+ uint32 b;
+
+ m->totalN += n;
+
+ b = m->totalN * 8;
+
+ memset(buf, 0, 128);
+ if (n) memcpy(buf, in, n);
+ buf[n] = 0x80;
+
+ if (n <= 55) {
+ copy4(buf+56, b);
+ copy64(M, buf);
+ mdfour64(M);
+ } else {
+ copy4(buf+120, b);
+ copy64(M, buf);
+ mdfour64(M);
+ copy64(M, buf+64);
+ mdfour64(M);
+ }
+}
+
+void mdfour_update(struct mdfour *md, const unsigned char *in, int n)
+{
+ uint32 M[16];
+
+ m = md;
+
+ if (in == NULL) {
+ mdfour_tail(md->tail, md->tail_len);
+ return;
+ }
+
+ if (md->tail_len) {
+ int len = 64 - md->tail_len;
+ if (len > n) len = n;
+ memcpy(md->tail+md->tail_len, in, len);
+ md->tail_len += len;
+ n -= len;
+ in += len;
+ if (md->tail_len == 64) {
+ copy64(M, md->tail);
+ mdfour64(M);
+ m->totalN += 64;
+ md->tail_len = 0;
+ }
+ }
+
+ while (n >= 64) {
+ copy64(M, in);
+ mdfour64(M);
+ in += 64;
+ n -= 64;
+ m->totalN += 64;
+ }
+
+ if (n) {
+ memcpy(md->tail, in, n);
+ md->tail_len = n;
+ }
+}
+
+
+void mdfour_result(struct mdfour *md, unsigned char *out)
+{
+ m = md;
+
+ copy4(out, m->A);
+ copy4(out+4, m->B);
+ copy4(out+8, m->C);
+ copy4(out+12, m->D);
+}
+
+
+void mdfour(unsigned char *out, const unsigned char *in, int n)
+{
+ struct mdfour md;
+ mdfour_begin(&md);
+ mdfour_update(&md, in, n);
+ mdfour_update(&md, NULL, 0);
+ mdfour_result(&md, out);
+}
+
+#ifdef TEST_MDFOUR
+static void file_checksum1(char *fname)
+{
+ int fd, i;
+ struct mdfour md;
+ unsigned char buf[1024], sum[16];
+ unsigned chunk;
+
+ fd = open(fname,O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ perror("fname");
+ exit(1);
+ }
+
+ chunk = 1 + random() % (sizeof(buf) - 1);
+
+ mdfour_begin(&md);
+
+ while (1) {
+ int n = read(fd, buf, chunk);
+ if (n >= 0) {
+ mdfour_update(&md, buf, n);
+ }
+ if (n < chunk) break;
+ }
+
+ close(fd);
+
+ mdfour_update(&md, NULL, 0);
+
+ mdfour_result(&md, sum);
+
+ for (i=0;i<16;i++)
+ printf("%02x", sum[i]);
+ printf("\n");
+}
+
+#if 0
+#include "../md4.h"
+
+static void file_checksum2(char *fname)
+{
+ int fd, i;
+ MDstruct md;
+ unsigned char buf[64], sum[16];
+
+ fd = open(fname,O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ perror("fname");
+ exit(1);
+ }
+
+ MDbegin(&md);
+
+ while (1) {
+ int n = read(fd, buf, sizeof(buf));
+ if (n <= 0) break;
+ MDupdate(&md, buf, n*8);
+ }
+
+ if (!md.done) {
+ MDupdate(&md, buf, 0);
+ }
+
+ close(fd);
+
+ memcpy(sum, md.buffer, 16);
+
+ for (i=0;i<16;i++)
+ printf("%02x", sum[i]);
+ printf("\n");
+}
+#endif
+
+ int main(int argc, char *argv[])
+{
+ file_checksum1(argv[1]);
+#if 0
+ file_checksum2(argv[1]);
+#endif
+ return 0;
+}
+#endif
diff --git a/CCache/mdfour.h b/CCache/mdfour.h
new file mode 100644
index 000000000..92ef2f831
--- /dev/null
+++ b/CCache/mdfour.h
@@ -0,0 +1,36 @@
+/*
+ Unix SMB/Netbios implementation.
+ Version 1.9.
+ a implementation of MD4 designed for use in the SMB authentication protocol
+ Copyright (C) Andrew Tridgell 1997-1998.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+struct mdfour {
+ uint32 A, B, C, D;
+ uint32 totalN;
+ unsigned char tail[64];
+ unsigned tail_len;
+};
+
+void mdfour_begin(struct mdfour *md);
+void mdfour_update(struct mdfour *md, const unsigned char *in, int n);
+void mdfour_result(struct mdfour *md, unsigned char *out);
+void mdfour(unsigned char *out, const unsigned char *in, int n);
+
+
+
+
diff --git a/CCache/packaging/README b/CCache/packaging/README
new file mode 100644
index 000000000..fadc342c4
--- /dev/null
+++ b/CCache/packaging/README
@@ -0,0 +1,5 @@
+These packaging files are contributd by users of ccache. I do not
+maintain them, and they may well need updating before you use them.
+
+I don't distribute binary packages of ccache myself, but if you wish
+to add ccache to a distribution then that's OK
diff --git a/CCache/packaging/ccache.spec b/CCache/packaging/ccache.spec
new file mode 100644
index 000000000..0972121d7
--- /dev/null
+++ b/CCache/packaging/ccache.spec
@@ -0,0 +1,37 @@
+Summary: Compiler Cache
+Name: ccache
+Version: 2.3
+Release: 1
+Group: Development/Languages
+License: GPL
+URL: http://ccache.samba.org/
+Source: ccache-%{version}.tar.gz
+BuildRoot: %{_tmppath}/%{name}-%{version}-root
+
+%description
+ccache caches gcc output files
+
+%prep
+%setup -q
+
+%build
+%configure
+make
+
+install -d -m 0755 $RPM_BUILD_ROOT%{_bindir}
+install -m 0755 ccache $RPM_BUILD_ROOT%{_bindir}
+install -d -m 0755 $RPM_BUILD_ROOT%{_mandir}/man1
+install -m 0644 ccache.1 $RPM_BUILD_ROOT%{_mandir}/man1
+
+%files
+%defattr(-,root,root)
+%doc README
+%{_mandir}/man1/ccache.1*
+%{_bindir}/ccache
+
+%clean
+[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
+
+%changelog
+* Mon Apr 01 2002 Peter Jones <pjones@redhat.com>
+- Created the package
diff --git a/CCache/snprintf.c b/CCache/snprintf.c
new file mode 100644
index 000000000..32187c1a5
--- /dev/null
+++ b/CCache/snprintf.c
@@ -0,0 +1,962 @@
+/*
+ * Copyright Patrick Powell 1995
+ * This code is based on code written by Patrick Powell (papowell@astart.com)
+ * It may be used for any purpose as long as this notice remains intact
+ * on all source code distributions
+ */
+
+/**************************************************************
+ * Original:
+ * Patrick Powell Tue Apr 11 09:48:21 PDT 1995
+ * A bombproof version of doprnt (dopr) included.
+ * Sigh. This sort of thing is always nasty do deal with. Note that
+ * the version here does not include floating point...
+ *
+ * snprintf() is used instead of sprintf() as it does limit checks
+ * for string length. This covers a nasty loophole.
+ *
+ * The other functions are there to prevent NULL pointers from
+ * causing nast effects.
+ *
+ * More Recently:
+ * Brandon Long <blong@fiction.net> 9/15/96 for mutt 0.43
+ * This was ugly. It is still ugly. I opted out of floating point
+ * numbers, but the formatter understands just about everything
+ * from the normal C string format, at least as far as I can tell from
+ * the Solaris 2.5 printf(3S) man page.
+ *
+ * Brandon Long <blong@fiction.net> 10/22/97 for mutt 0.87.1
+ * Ok, added some minimal floating point support, which means this
+ * probably requires libm on most operating systems. Don't yet
+ * support the exponent (e,E) and sigfig (g,G). Also, fmtint()
+ * was pretty badly broken, it just wasn't being exercised in ways
+ * which showed it, so that's been fixed. Also, formated the code
+ * to mutt conventions, and removed dead code left over from the
+ * original. Also, there is now a builtin-test, just compile with:
+ * gcc -DTEST_SNPRINTF -o snprintf snprintf.c -lm
+ * and run snprintf for results.
+ *
+ * Thomas Roessler <roessler@guug.de> 01/27/98 for mutt 0.89i
+ * The PGP code was using unsigned hexadecimal formats.
+ * Unfortunately, unsigned formats simply didn't work.
+ *
+ * Michael Elkins <me@cs.hmc.edu> 03/05/98 for mutt 0.90.8
+ * The original code assumed that both snprintf() and vsnprintf() were
+ * missing. Some systems only have snprintf() but not vsnprintf(), so
+ * the code is now broken down under HAVE_SNPRINTF and HAVE_VSNPRINTF.
+ *
+ * Andrew Tridgell (tridge@samba.org) Oct 1998
+ * fixed handling of %.0f
+ * added test for HAVE_LONG_DOUBLE
+ *
+ * tridge@samba.org, idra@samba.org, April 2001
+ * got rid of fcvt code (twas buggy and made testing harder)
+ * added C99 semantics
+ *
+ **************************************************************/
+
+#ifndef NO_CONFIG_H /* for some tests */
+#include "config.h"
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
+#endif
+#ifdef HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+#include <sys/types.h>
+#include <stdarg.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+
+#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) && defined(HAVE_C99_VSNPRINTF)
+/* only include stdio.h if we are not re-defining snprintf or vsnprintf */
+#include <stdio.h>
+ /* make the compiler happy with an empty file */
+ void dummy_snprintf(void) {}
+#else
+
+#ifdef HAVE_LONG_DOUBLE
+#define LDOUBLE long double
+#else
+#define LDOUBLE double
+#endif
+
+#ifdef HAVE_LONG_LONG
+#define LLONG long long
+#else
+#define LLONG long
+#endif
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format,
+ va_list args);
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max);
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags);
+static void fmtfp(char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags);
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c);
+
+/*
+ * dopr(): poor man's version of doprintf
+ */
+
+/* format read states */
+#define DP_S_DEFAULT 0
+#define DP_S_FLAGS 1
+#define DP_S_MIN 2
+#define DP_S_DOT 3
+#define DP_S_MAX 4
+#define DP_S_MOD 5
+#define DP_S_CONV 6
+#define DP_S_DONE 7
+
+/* format flags - Bits */
+#define DP_F_MINUS (1 << 0)
+#define DP_F_PLUS (1 << 1)
+#define DP_F_SPACE (1 << 2)
+#define DP_F_NUM (1 << 3)
+#define DP_F_ZERO (1 << 4)
+#define DP_F_UP (1 << 5)
+#define DP_F_UNSIGNED (1 << 6)
+
+/* Conversion Flags */
+#define DP_C_SHORT 1
+#define DP_C_LONG 2
+#define DP_C_LDOUBLE 3
+#define DP_C_LLONG 4
+
+#define char_to_int(p) ((p)- '0')
+#ifndef MAX
+#define MAX(p,q) (((p) >= (q)) ? (p) : (q))
+#endif
+
+static size_t dopr(char *buffer, size_t maxlen, const char *format, va_list args)
+{
+ char ch;
+ LLONG value;
+ LDOUBLE fvalue;
+ char *strvalue;
+ int min;
+ int max;
+ int state;
+ int flags;
+ int cflags;
+ size_t currlen;
+
+ state = DP_S_DEFAULT;
+ currlen = flags = cflags = min = 0;
+ max = -1;
+ ch = *format++;
+
+ while (state != DP_S_DONE) {
+ if (ch == '\0')
+ state = DP_S_DONE;
+
+ switch(state) {
+ case DP_S_DEFAULT:
+ if (ch == '%')
+ state = DP_S_FLAGS;
+ else
+ dopr_outch (buffer, &currlen, maxlen, ch);
+ ch = *format++;
+ break;
+ case DP_S_FLAGS:
+ switch (ch) {
+ case '-':
+ flags |= DP_F_MINUS;
+ ch = *format++;
+ break;
+ case '+':
+ flags |= DP_F_PLUS;
+ ch = *format++;
+ break;
+ case ' ':
+ flags |= DP_F_SPACE;
+ ch = *format++;
+ break;
+ case '#':
+ flags |= DP_F_NUM;
+ ch = *format++;
+ break;
+ case '0':
+ flags |= DP_F_ZERO;
+ ch = *format++;
+ break;
+ default:
+ state = DP_S_MIN;
+ break;
+ }
+ break;
+ case DP_S_MIN:
+ if (isdigit((unsigned char)ch)) {
+ min = 10*min + char_to_int (ch);
+ ch = *format++;
+ } else if (ch == '*') {
+ min = va_arg (args, int);
+ ch = *format++;
+ state = DP_S_DOT;
+ } else {
+ state = DP_S_DOT;
+ }
+ break;
+ case DP_S_DOT:
+ if (ch == '.') {
+ state = DP_S_MAX;
+ ch = *format++;
+ } else {
+ state = DP_S_MOD;
+ }
+ break;
+ case DP_S_MAX:
+ if (isdigit((unsigned char)ch)) {
+ if (max < 0)
+ max = 0;
+ max = 10*max + char_to_int (ch);
+ ch = *format++;
+ } else if (ch == '*') {
+ max = va_arg (args, int);
+ ch = *format++;
+ state = DP_S_MOD;
+ } else {
+ state = DP_S_MOD;
+ }
+ break;
+ case DP_S_MOD:
+ switch (ch) {
+ case 'h':
+ cflags = DP_C_SHORT;
+ ch = *format++;
+ break;
+ case 'l':
+ cflags = DP_C_LONG;
+ ch = *format++;
+ if (ch == 'l') { /* It's a long long */
+ cflags = DP_C_LLONG;
+ ch = *format++;
+ }
+ break;
+ case 'L':
+ cflags = DP_C_LDOUBLE;
+ ch = *format++;
+ break;
+ default:
+ break;
+ }
+ state = DP_S_CONV;
+ break;
+ case DP_S_CONV:
+ switch (ch) {
+ case 'd':
+ case 'i':
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, int);
+ else if (cflags == DP_C_LONG)
+ value = va_arg (args, long int);
+ else if (cflags == DP_C_LLONG)
+ value = va_arg (args, LLONG);
+ else
+ value = va_arg (args, int);
+ fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'o':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, unsigned int);
+ else if (cflags == DP_C_LONG)
+ value = (long)va_arg (args, unsigned long int);
+ else if (cflags == DP_C_LLONG)
+ value = (long)va_arg (args, unsigned LLONG);
+ else
+ value = (long)va_arg (args, unsigned int);
+ fmtint (buffer, &currlen, maxlen, value, 8, min, max, flags);
+ break;
+ case 'u':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, unsigned int);
+ else if (cflags == DP_C_LONG)
+ value = (long)va_arg (args, unsigned long int);
+ else if (cflags == DP_C_LLONG)
+ value = (LLONG)va_arg (args, unsigned LLONG);
+ else
+ value = (long)va_arg (args, unsigned int);
+ fmtint (buffer, &currlen, maxlen, value, 10, min, max, flags);
+ break;
+ case 'X':
+ flags |= DP_F_UP;
+ case 'x':
+ flags |= DP_F_UNSIGNED;
+ if (cflags == DP_C_SHORT)
+ value = va_arg (args, unsigned int);
+ else if (cflags == DP_C_LONG)
+ value = (long)va_arg (args, unsigned long int);
+ else if (cflags == DP_C_LLONG)
+ value = (LLONG)va_arg (args, unsigned LLONG);
+ else
+ value = (long)va_arg (args, unsigned int);
+ fmtint (buffer, &currlen, maxlen, value, 16, min, max, flags);
+ break;
+ case 'f':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ /* um, floating point? */
+ fmtfp (buffer, &currlen, maxlen, fvalue, min, max, flags);
+ break;
+ case 'E':
+ flags |= DP_F_UP;
+ case 'e':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ break;
+ case 'G':
+ flags |= DP_F_UP;
+ case 'g':
+ if (cflags == DP_C_LDOUBLE)
+ fvalue = va_arg (args, LDOUBLE);
+ else
+ fvalue = va_arg (args, double);
+ break;
+ case 'c':
+ dopr_outch (buffer, &currlen, maxlen, va_arg (args, int));
+ break;
+ case 's':
+ strvalue = va_arg (args, char *);
+ if (!strvalue) strvalue = "(NULL)";
+ if (max == -1) {
+ max = strlen(strvalue);
+ }
+ if (min > 0 && max >= 0 && min > max) max = min;
+ fmtstr (buffer, &currlen, maxlen, strvalue, flags, min, max);
+ break;
+ case 'p':
+ strvalue = (char *)va_arg(args, void *);
+ fmtint (buffer, &currlen, maxlen, (long) strvalue, 16, min, max, flags);
+ break;
+ case 'n':
+ if (cflags == DP_C_SHORT) {
+ short int *num;
+ num = va_arg (args, short int *);
+ *num = currlen;
+ } else if (cflags == DP_C_LONG) {
+ long int *num;
+ num = va_arg (args, long int *);
+ *num = (long int)currlen;
+ } else if (cflags == DP_C_LLONG) {
+ LLONG *num;
+ num = va_arg (args, LLONG *);
+ *num = (LLONG)currlen;
+ } else {
+ int *num;
+ num = va_arg (args, int *);
+ *num = currlen;
+ }
+ break;
+ case '%':
+ dopr_outch (buffer, &currlen, maxlen, ch);
+ break;
+ case 'w':
+ /* not supported yet, treat as next char */
+ ch = *format++;
+ break;
+ default:
+ /* Unknown, skip */
+ break;
+ }
+ ch = *format++;
+ state = DP_S_DEFAULT;
+ flags = cflags = min = 0;
+ max = -1;
+ break;
+ case DP_S_DONE:
+ break;
+ default:
+ /* hmm? */
+ break; /* some picky compilers need this */
+ }
+ }
+ if (maxlen != 0) {
+ if (currlen < maxlen - 1)
+ buffer[currlen] = '\0';
+ else if (maxlen > 0)
+ buffer[maxlen - 1] = '\0';
+ }
+
+ return currlen;
+}
+
+static void fmtstr(char *buffer, size_t *currlen, size_t maxlen,
+ char *value, int flags, int min, int max)
+{
+ int padlen, strln; /* amount to pad */
+ int cnt = 0;
+
+#ifdef DEBUG_SNPRINTF
+ printf("fmtstr min=%d max=%d s=[%s]\n", min, max, value);
+#endif
+ if (value == 0) {
+ value = "<NULL>";
+ }
+
+ for (strln = 0; value[strln]; ++strln); /* strlen */
+ padlen = min - strln;
+ if (padlen < 0)
+ padlen = 0;
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justify */
+
+ while ((padlen > 0) && (cnt < max)) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ --padlen;
+ ++cnt;
+ }
+ while (*value && (cnt < max)) {
+ dopr_outch (buffer, currlen, maxlen, *value++);
+ ++cnt;
+ }
+ while ((padlen < 0) && (cnt < max)) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ ++padlen;
+ ++cnt;
+ }
+}
+
+/* Have to handle DP_F_NUM (ie 0x and 0 alternates) */
+
+static void fmtint(char *buffer, size_t *currlen, size_t maxlen,
+ long value, int base, int min, int max, int flags)
+{
+ int signvalue = 0;
+ unsigned long uvalue;
+ char convert[20];
+ int place = 0;
+ int spadlen = 0; /* amount to space pad */
+ int zpadlen = 0; /* amount to zero pad */
+ int caps = 0;
+
+ if (max < 0)
+ max = 0;
+
+ uvalue = value;
+
+ if(!(flags & DP_F_UNSIGNED)) {
+ if( value < 0 ) {
+ signvalue = '-';
+ uvalue = -value;
+ } else {
+ if (flags & DP_F_PLUS) /* Do a sign (+/i) */
+ signvalue = '+';
+ else if (flags & DP_F_SPACE)
+ signvalue = ' ';
+ }
+ }
+
+ if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+
+ do {
+ convert[place++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")
+ [uvalue % (unsigned)base ];
+ uvalue = (uvalue / (unsigned)base );
+ } while(uvalue && (place < 20));
+ if (place == 20) place--;
+ convert[place] = 0;
+
+ zpadlen = max - place;
+ spadlen = min - MAX (max, place) - (signvalue ? 1 : 0);
+ if (zpadlen < 0) zpadlen = 0;
+ if (spadlen < 0) spadlen = 0;
+ if (flags & DP_F_ZERO) {
+ zpadlen = MAX(zpadlen, spadlen);
+ spadlen = 0;
+ }
+ if (flags & DP_F_MINUS)
+ spadlen = -spadlen; /* Left Justifty */
+
+#ifdef DEBUG_SNPRINTF
+ printf("zpad: %d, spad: %d, min: %d, max: %d, place: %d\n",
+ zpadlen, spadlen, min, max, place);
+#endif
+
+ /* Spaces */
+ while (spadlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ --spadlen;
+ }
+
+ /* Sign */
+ if (signvalue)
+ dopr_outch (buffer, currlen, maxlen, signvalue);
+
+ /* Zeros */
+ if (zpadlen > 0) {
+ while (zpadlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+ }
+
+ /* Digits */
+ while (place > 0)
+ dopr_outch (buffer, currlen, maxlen, convert[--place]);
+
+ /* Left Justified spaces */
+ while (spadlen < 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ ++spadlen;
+ }
+}
+
+static LDOUBLE abs_val(LDOUBLE value)
+{
+ LDOUBLE result = value;
+
+ if (value < 0)
+ result = -value;
+
+ return result;
+}
+
+static LDOUBLE POW10(int exp)
+{
+ LDOUBLE result = 1;
+
+ while (exp) {
+ result *= 10;
+ exp--;
+ }
+
+ return result;
+}
+
+static LLONG ROUND(LDOUBLE value)
+{
+ LLONG intpart;
+
+ intpart = (LLONG)value;
+ value = value - intpart;
+ if (value >= 0.5) intpart++;
+
+ return intpart;
+}
+
+/* a replacement for modf that doesn't need the math library. Should
+ be portable, but slow */
+static double my_modf(double x0, double *iptr)
+{
+ int i;
+ long l;
+ double x = x0;
+ double f = 1.0;
+
+ for (i=0;i<100;i++) {
+ l = (long)x;
+ if (l <= (x+1) && l >= (x-1)) break;
+ x *= 0.1;
+ f *= 10.0;
+ }
+
+ if (i == 100) {
+ /* yikes! the number is beyond what we can handle. What do we do? */
+ (*iptr) = 0;
+ return 0;
+ }
+
+ if (i != 0) {
+ double i2;
+ double ret;
+
+ ret = my_modf(x0-l*f, &i2);
+ (*iptr) = l*f + i2;
+ return ret;
+ }
+
+ (*iptr) = l;
+ return x - (*iptr);
+}
+
+
+static void fmtfp (char *buffer, size_t *currlen, size_t maxlen,
+ LDOUBLE fvalue, int min, int max, int flags)
+{
+ int signvalue = 0;
+ double ufvalue;
+ char iconvert[311];
+ char fconvert[311];
+ int iplace = 0;
+ int fplace = 0;
+ int padlen = 0; /* amount to pad */
+ int zpadlen = 0;
+ int caps = 0;
+ int index;
+ double intpart;
+ double fracpart;
+ double temp;
+
+ /*
+ * AIX manpage says the default is 0, but Solaris says the default
+ * is 6, and sprintf on AIX defaults to 6
+ */
+ if (max < 0)
+ max = 6;
+
+ ufvalue = abs_val (fvalue);
+
+ if (fvalue < 0) {
+ signvalue = '-';
+ } else {
+ if (flags & DP_F_PLUS) { /* Do a sign (+/i) */
+ signvalue = '+';
+ } else {
+ if (flags & DP_F_SPACE)
+ signvalue = ' ';
+ }
+ }
+
+#if 0
+ if (flags & DP_F_UP) caps = 1; /* Should characters be upper case? */
+#endif
+
+#if 0
+ if (max == 0) ufvalue += 0.5; /* if max = 0 we must round */
+#endif
+
+ /*
+ * Sorry, we only support 16 digits past the decimal because of our
+ * conversion method
+ */
+ if (max > 16)
+ max = 16;
+
+ /* We "cheat" by converting the fractional part to integer by
+ * multiplying by a factor of 10
+ */
+
+ temp = ufvalue;
+ my_modf(temp, &intpart);
+
+ fracpart = ROUND((POW10(max)) * (ufvalue - intpart));
+
+ if (fracpart >= POW10(max)) {
+ intpart++;
+ fracpart -= POW10(max);
+ }
+
+
+ /* Convert integer part */
+ do {
+ temp = intpart;
+ my_modf(intpart*0.1, &intpart);
+ temp = temp*0.1;
+ index = (int) ((temp -intpart +0.05)* 10.0);
+ /* index = (int) (((double)(temp*0.1) -intpart +0.05) *10.0); */
+ /* printf ("%llf, %f, %x\n", temp, intpart, index); */
+ iconvert[iplace++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")[index];
+ } while (intpart && (iplace < 311));
+ if (iplace == 311) iplace--;
+ iconvert[iplace] = 0;
+
+ /* Convert fractional part */
+ if (fracpart)
+ {
+ do {
+ temp = fracpart;
+ my_modf(fracpart*0.1, &fracpart);
+ temp = temp*0.1;
+ index = (int) ((temp -fracpart +0.05)* 10.0);
+ /* index = (int) ((((temp/10) -fracpart) +0.05) *10); */
+ /* printf ("%lf, %lf, %ld\n", temp, fracpart, index); */
+ fconvert[fplace++] =
+ (caps? "0123456789ABCDEF":"0123456789abcdef")[index];
+ } while(fracpart && (fplace < 311));
+ if (fplace == 311) fplace--;
+ }
+ fconvert[fplace] = 0;
+
+ /* -1 for decimal point, another -1 if we are printing a sign */
+ padlen = min - iplace - max - 1 - ((signvalue) ? 1 : 0);
+ zpadlen = max - fplace;
+ if (zpadlen < 0) zpadlen = 0;
+ if (padlen < 0)
+ padlen = 0;
+ if (flags & DP_F_MINUS)
+ padlen = -padlen; /* Left Justifty */
+
+ if ((flags & DP_F_ZERO) && (padlen > 0)) {
+ if (signvalue) {
+ dopr_outch (buffer, currlen, maxlen, signvalue);
+ --padlen;
+ signvalue = 0;
+ }
+ while (padlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, '0');
+ --padlen;
+ }
+ }
+ while (padlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ --padlen;
+ }
+ if (signvalue)
+ dopr_outch (buffer, currlen, maxlen, signvalue);
+
+ while (iplace > 0)
+ dopr_outch (buffer, currlen, maxlen, iconvert[--iplace]);
+
+#ifdef DEBUG_SNPRINTF
+ printf("fmtfp: fplace=%d zpadlen=%d\n", fplace, zpadlen);
+#endif
+
+ /*
+ * Decimal point. This should probably use locale to find the correct
+ * char to print out.
+ */
+ if (max > 0) {
+ dopr_outch (buffer, currlen, maxlen, '.');
+
+ while (fplace > 0)
+ dopr_outch (buffer, currlen, maxlen, fconvert[--fplace]);
+ }
+
+ while (zpadlen > 0) {
+ dopr_outch (buffer, currlen, maxlen, '0');
+ --zpadlen;
+ }
+
+ while (padlen < 0) {
+ dopr_outch (buffer, currlen, maxlen, ' ');
+ ++padlen;
+ }
+}
+
+static void dopr_outch(char *buffer, size_t *currlen, size_t maxlen, char c)
+{
+ if (*currlen < maxlen) {
+ buffer[(*currlen)] = c;
+ }
+ (*currlen)++;
+}
+
+/* yes this really must be a ||. Don't muck with this (tridge) */
+#if !defined(HAVE_VSNPRINTF) || !defined(HAVE_C99_VSNPRINTF)
+ int vsnprintf (char *str, size_t count, const char *fmt, va_list args)
+{
+ return dopr(str, count, fmt, args);
+}
+#endif
+
+/* yes this really must be a ||. Don't muck wiith this (tridge)
+ *
+ * The logic for these two is that we need our own definition if the
+ * OS *either* has no definition of *sprintf, or if it does have one
+ * that doesn't work properly according to the autoconf test. Perhaps
+ * these should really be smb_snprintf to avoid conflicts with buggy
+ * linkers? -- mbp
+ */
+#if !defined(HAVE_SNPRINTF) || !defined(HAVE_C99_SNPRINTF)
+ int snprintf(char *str,size_t count,const char *fmt,...)
+{
+ size_t ret;
+ va_list ap;
+
+ va_start(ap, fmt);
+ ret = vsnprintf(str, count, fmt, ap);
+ va_end(ap);
+ return ret;
+}
+#endif
+
+#endif
+
+#ifndef HAVE_VASPRINTF
+ int vasprintf(char **ptr, const char *format, va_list ap)
+{
+ int ret;
+
+ ret = vsnprintf(0, 0, format, ap);
+ if (ret <= 0) return ret;
+
+ (*ptr) = (char *)malloc(ret+1);
+ if (!*ptr) return -1;
+ ret = vsnprintf(*ptr, ret+1, format, ap);
+
+ return ret;
+}
+#endif
+
+
+#ifndef HAVE_ASPRINTF
+ int asprintf(char **ptr, const char *format, ...)
+{
+ va_list ap;
+ int ret;
+
+ *ptr = 0;
+ va_start(ap, format);
+ ret = vasprintf(ptr, format, ap);
+ va_end(ap);
+
+ return ret;
+}
+#endif
+
+#ifndef HAVE_VSYSLOG
+#ifdef HAVE_SYSLOG
+ void vsyslog (int facility_priority, char *format, va_list arglist)
+{
+ char *msg = 0;
+ vasprintf(&msg, format, arglist);
+ if (!msg)
+ return;
+ syslog(facility_priority, "%s", msg);
+ free(msg);
+}
+#endif /* HAVE_SYSLOG */
+#endif /* HAVE_VSYSLOG */
+
+#ifdef TEST_SNPRINTF
+
+ int sprintf(char *str,const char *fmt,...);
+
+ int main (void)
+{
+ char buf1[1024];
+ char buf2[1024];
+ char *fp_fmt[] = {
+ "%1.1f",
+ "%-1.5f",
+ "%1.5f",
+ "%123.9f",
+ "%10.5f",
+ "% 10.5f",
+ "%+22.9f",
+ "%+4.9f",
+ "%01.3f",
+ "%4f",
+ "%3.1f",
+ "%3.2f",
+ "%.0f",
+ "%f",
+ "-16.16f",
+ 0
+ };
+ double fp_nums[] = { 6442452944.1234, -1.5, 134.21, 91340.2, 341.1234, 0203.9, 0.96, 0.996,
+ 0.9996, 1.996, 4.136, 0};
+ char *int_fmt[] = {
+ "%-1.5d",
+ "%1.5d",
+ "%123.9d",
+ "%5.5d",
+ "%10.5d",
+ "% 10.5d",
+ "%+22.33d",
+ "%01.3d",
+ "%4d",
+ "%d",
+ 0
+ };
+ long int_nums[] = { -1, 134, 91340, 341, 0203, 0};
+ char *str_fmt[] = {
+ "10.5s",
+ "5.10s",
+ "10.1s",
+ "0.10s",
+ "10.0s",
+ "1.10s",
+ "%s",
+ "%.1s",
+ "%.10s",
+ "%10s",
+ 0
+ };
+ char *str_vals[] = {"hello", "a", "", "a longer string", 0};
+ int x, y;
+ int fail = 0;
+ int num = 0;
+
+ printf ("Testing snprintf format codes against system sprintf...\n");
+
+ for (x = 0; fp_fmt[x] ; x++) {
+ for (y = 0; fp_nums[y] != 0 ; y++) {
+ int l1 = snprintf(0, 0, fp_fmt[x], fp_nums[y]);
+ int l2 = snprintf(buf1, sizeof(buf1), fp_fmt[x], fp_nums[y]);
+ sprintf (buf2, fp_fmt[x], fp_nums[y]);
+ if (strcmp (buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ fp_fmt[x], buf1, buf2);
+ fail++;
+ }
+ if (l1 != l2) {
+ printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, fp_fmt[x]);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ for (x = 0; int_fmt[x] ; x++) {
+ for (y = 0; int_nums[y] != 0 ; y++) {
+ int l1 = snprintf(0, 0, int_fmt[x], int_nums[y]);
+ int l2 = snprintf(buf1, sizeof(buf1), int_fmt[x], int_nums[y]);
+ sprintf (buf2, int_fmt[x], int_nums[y]);
+ if (strcmp (buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ int_fmt[x], buf1, buf2);
+ fail++;
+ }
+ if (l1 != l2) {
+ printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, int_fmt[x]);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ for (x = 0; str_fmt[x] ; x++) {
+ for (y = 0; str_vals[y] != 0 ; y++) {
+ int l1 = snprintf(0, 0, str_fmt[x], str_vals[y]);
+ int l2 = snprintf(buf1, sizeof(buf1), str_fmt[x], str_vals[y]);
+ sprintf (buf2, str_fmt[x], str_vals[y]);
+ if (strcmp (buf1, buf2)) {
+ printf("snprintf doesn't match Format: %s\n\tsnprintf = [%s]\n\t sprintf = [%s]\n",
+ str_fmt[x], buf1, buf2);
+ fail++;
+ }
+ if (l1 != l2) {
+ printf("snprintf l1 != l2 (%d %d) %s\n", l1, l2, str_fmt[x]);
+ fail++;
+ }
+ num++;
+ }
+ }
+
+ printf ("%d tests failed out of %d.\n", fail, num);
+
+ printf("seeing how many digits we support\n");
+ {
+ double v0 = 0.12345678901234567890123456789012345678901;
+ for (x=0; x<100; x++) {
+ snprintf(buf1, sizeof(buf1), "%1.1f", v0*pow(10, x));
+ sprintf(buf2, "%1.1f", v0*pow(10, x));
+ if (strcmp(buf1, buf2)) {
+ printf("we seem to support %d digits\n", x-1);
+ break;
+ }
+ }
+ }
+
+ return 0;
+}
+#endif /* SNPRINTF_TEST */
diff --git a/CCache/stats.c b/CCache/stats.c
new file mode 100644
index 000000000..92bc4a835
--- /dev/null
+++ b/CCache/stats.c
@@ -0,0 +1,361 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ routines to handle the stats files
+
+ the stats file is stored one per cache subdirectory to make this more
+ scalable
+ */
+
+#include "ccache.h"
+
+extern char *stats_file;
+extern char *cache_dir;
+
+#define STATS_VERSION 1
+
+#define FLAG_NOZERO 1 /* don't zero with the -z option */
+#define FLAG_ALWAYS 2 /* always show, even if zero */
+
+static struct {
+ enum stats stat;
+ char *message;
+ void (*fn)(unsigned );
+ unsigned flags;
+} stats_info[] = {
+ { STATS_CACHED, "cache hit ", NULL, FLAG_ALWAYS },
+ { STATS_TOCACHE, "cache miss ", NULL, FLAG_ALWAYS },
+ { STATS_LINK, "called for link ", NULL, 0 },
+ { STATS_MULTIPLE, "multiple source files ", NULL, 0 },
+ { STATS_STDOUT, "compiler produced stdout ", NULL, 0 },
+ { STATS_STATUS, "compile failed ", NULL, 0 },
+ { STATS_ERROR, "ccache internal error ", NULL, 0 },
+ { STATS_PREPROCESSOR, "preprocessor error ", NULL, 0 },
+ { STATS_COMPILER, "couldn't find the compiler ", NULL, 0 },
+ { STATS_MISSING, "cache file missing ", NULL, 0 },
+ { STATS_ARGS, "bad compiler arguments ", NULL, 0 },
+ { STATS_NOTC, "not a C/C++ file ", NULL, 0 },
+ { STATS_CONFTEST, "autoconf compile/link ", NULL, 0 },
+ { STATS_UNSUPPORTED, "unsupported compiler option ", NULL, 0 },
+ { STATS_OUTSTDOUT, "output to stdout ", NULL, 0 },
+ { STATS_DEVICE, "output to a non-regular file ", NULL, 0 },
+ { STATS_NOINPUT, "no input file ", NULL, 0 },
+ { STATS_ENVIRONMMENT, "error due to bad env variable ", NULL, 0 },
+ { STATS_NUMFILES, "files in cache ", NULL, FLAG_NOZERO|FLAG_ALWAYS },
+ { STATS_TOTALSIZE, "cache size ", display_size , FLAG_NOZERO|FLAG_ALWAYS },
+ { STATS_MAXFILES, "max files ", NULL, FLAG_NOZERO },
+ { STATS_MAXSIZE, "max cache size ", display_size, FLAG_NOZERO },
+ { STATS_NONE, NULL, NULL, 0 }
+};
+
+/* parse a stats file from a buffer - adding to the counters */
+static void parse_stats(unsigned counters[STATS_END], char *buf)
+{
+ int i;
+ char *p, *p2;
+
+ p = buf;
+ for (i=0;i<STATS_END;i++) {
+ counters[i] += strtol(p, &p2, 10);
+ if (!p2 || p2 == p) break;
+ p = p2;
+ }
+}
+
+/* write out a stats file */
+static void write_stats(int fd, unsigned counters[STATS_END])
+{
+ int i;
+ int len = 0;
+ char buf[1024];
+
+ for (i=0;i<STATS_END;i++) {
+ len += snprintf(buf+len, sizeof(buf)-(len+1), "%u ", counters[i]);
+ if (len >= (int)sizeof(buf)-1) fatal("stats too long?!");
+ }
+ len += snprintf(buf+len, sizeof(buf)-(len+1), "\n");
+ if (len >= (int)sizeof(buf)-1) fatal("stats too long?!");
+
+ lseek(fd, 0, SEEK_SET);
+ if (write(fd, buf, len) == -1) fatal("could not write stats");
+}
+
+
+/* fill in some default stats values */
+static void stats_default(unsigned counters[STATS_END])
+{
+ counters[STATS_MAXSIZE] += DEFAULT_MAXSIZE / 16;
+}
+
+/* read in the stats from one dir and add to the counters */
+static void stats_read_fd(int fd, unsigned counters[STATS_END])
+{
+ char buf[1024];
+ int len;
+ len = read(fd, buf, sizeof(buf)-1);
+ if (len <= 0) {
+ stats_default(counters);
+ return;
+ }
+ buf[len] = 0;
+ parse_stats(counters, buf);
+}
+
+/* update the stats counter for this compile */
+static void stats_update_size(enum stats stat, size_t size, size_t numfiles)
+{
+ int fd;
+ unsigned counters[STATS_END];
+ int need_cleanup = 0;
+
+ if (getenv("CCACHE_NOSTATS")) return;
+
+ if (!stats_file) {
+ if (!cache_dir) return;
+ x_asprintf(&stats_file, "%s/stats", cache_dir);
+ }
+
+ /* open safely to try to prevent symlink races */
+ fd = safe_open(stats_file);
+
+ /* still can't get it? don't bother ... */
+ if (fd == -1) return;
+
+ memset(counters, 0, sizeof(counters));
+
+ if (lock_fd(fd) != 0) return;
+
+ /* read in the old stats */
+ stats_read_fd(fd, counters);
+
+ /* update them */
+ counters[stat]++;
+
+ /* on a cache miss we up the file count and size */
+ if (stat == STATS_TOCACHE) {
+ counters[STATS_NUMFILES] += numfiles;
+ counters[STATS_TOTALSIZE] += size;
+ }
+
+ /* and write them out */
+ write_stats(fd, counters);
+ close(fd);
+
+ /* we might need to cleanup if the cache has now got too big */
+ if (counters[STATS_MAXFILES] != 0 &&
+ counters[STATS_NUMFILES] > counters[STATS_MAXFILES]) {
+ need_cleanup = 1;
+ }
+ if (counters[STATS_MAXSIZE] != 0 &&
+ counters[STATS_TOTALSIZE] > counters[STATS_MAXSIZE]) {
+ need_cleanup = 1;
+ }
+
+ if (need_cleanup) {
+ char *p = dirname(stats_file);
+ cleanup_dir(p, counters[STATS_MAXFILES], counters[STATS_MAXSIZE]);
+ free(p);
+ }
+}
+
+/* record a cache miss */
+void stats_tocache(size_t size, size_t numfiles)
+{
+ /* convert size to kilobytes */
+ size = size / 1024;
+
+ stats_update_size(STATS_TOCACHE, size, numfiles);
+}
+
+/* update a normal stat */
+void stats_update(enum stats stat)
+{
+ stats_update_size(stat, 0, 0);
+}
+
+/* read in the stats from one dir and add to the counters */
+void stats_read(const char *stats_file, unsigned counters[STATS_END])
+{
+ int fd;
+
+ fd = open(stats_file, O_RDONLY|O_BINARY);
+ if (fd == -1) {
+ stats_default(counters);
+ return;
+ }
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ close(fd);
+}
+
+/* sum and display the total stats for all cache dirs */
+void stats_summary(void)
+{
+ int dir, i;
+ unsigned counters[STATS_END];
+
+ memset(counters, 0, sizeof(counters));
+
+ /* add up the stats in each directory */
+ for (dir=-1;dir<=0xF;dir++) {
+ char *fname;
+
+ if (dir == -1) {
+ x_asprintf(&fname, "%s/stats", cache_dir);
+ } else {
+ x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir);
+ }
+
+ stats_read(fname, counters);
+ free(fname);
+
+ /* oh what a nasty hack ... */
+ if (dir == -1) {
+ counters[STATS_MAXSIZE] = 0;
+ }
+
+ }
+
+ printf("cache directory %s\n", cache_dir);
+
+ /* and display them */
+ for (i=0;stats_info[i].message;i++) {
+ enum stats stat = stats_info[i].stat;
+
+ if (counters[stat] == 0 &&
+ !(stats_info[i].flags & FLAG_ALWAYS)) {
+ continue;
+ }
+
+ printf("%s ", stats_info[i].message);
+ if (stats_info[i].fn) {
+ stats_info[i].fn(counters[stat]);
+ printf("\n");
+ } else {
+ printf("%8u\n", counters[stat]);
+ }
+ }
+}
+
+/* zero all the stats structures */
+void stats_zero(void)
+{
+ int dir, fd;
+ unsigned i;
+ char *fname;
+ unsigned counters[STATS_END];
+
+ x_asprintf(&fname, "%s/stats", cache_dir);
+ unlink(fname);
+ free(fname);
+
+ for (dir=0;dir<=0xF;dir++) {
+ x_asprintf(&fname, "%s/%1x/stats", cache_dir, dir);
+ fd = safe_open(fname);
+ if (fd == -1) {
+ free(fname);
+ continue;
+ }
+ memset(counters, 0, sizeof(counters));
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ for (i=0;stats_info[i].message;i++) {
+ if (!(stats_info[i].flags & FLAG_NOZERO)) {
+ counters[stats_info[i].stat] = 0;
+ }
+ }
+ write_stats(fd, counters);
+ close(fd);
+ free(fname);
+ }
+}
+
+
+/* set the per directory limits */
+int stats_set_limits(long maxfiles, long maxsize)
+{
+ int dir;
+ unsigned counters[STATS_END];
+
+ if (maxfiles != -1) {
+ maxfiles /= 16;
+ }
+ if (maxsize != -1) {
+ maxsize /= 16;
+ }
+
+ if (create_dir(cache_dir) != 0) {
+ return 1;
+ }
+
+ /* set the limits in each directory */
+ for (dir=0;dir<=0xF;dir++) {
+ char *fname, *cdir;
+ int fd;
+
+ x_asprintf(&cdir, "%s/%1x", cache_dir, dir);
+ if (create_dir(cdir) != 0) {
+ return 1;
+ }
+ x_asprintf(&fname, "%s/stats", cdir);
+ free(cdir);
+
+ memset(counters, 0, sizeof(counters));
+ fd = safe_open(fname);
+ if (fd != -1) {
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ if (maxfiles != -1) {
+ counters[STATS_MAXFILES] = maxfiles;
+ }
+ if (maxsize != -1) {
+ counters[STATS_MAXSIZE] = maxsize;
+ }
+ write_stats(fd, counters);
+ close(fd);
+ }
+ free(fname);
+ }
+
+ return 0;
+}
+
+/* set the per directory sizes */
+void stats_set_sizes(const char *dir, size_t num_files, size_t total_size)
+{
+ int fd;
+ unsigned counters[STATS_END];
+ char *stats_file;
+
+ create_dir(dir);
+ x_asprintf(&stats_file, "%s/stats", dir);
+
+ memset(counters, 0, sizeof(counters));
+
+ fd = safe_open(stats_file);
+ if (fd != -1) {
+ lock_fd(fd);
+ stats_read_fd(fd, counters);
+ counters[STATS_NUMFILES] = num_files;
+ counters[STATS_TOTALSIZE] = total_size;
+ write_stats(fd, counters);
+ close(fd);
+ }
+
+ free(stats_file);
+}
diff --git a/CCache/test.sh b/CCache/test.sh
new file mode 100755
index 000000000..9581c85e3
--- /dev/null
+++ b/CCache/test.sh
@@ -0,0 +1,452 @@
+#!/bin/sh
+
+# a simple test suite for ccache
+# tridge@samba.org
+
+if test -n "$CC"; then
+ COMPILER="$CC"
+else
+ COMPILER=cc
+fi
+
+if test -n "$SWIG"; then
+ SWIG="$SWIG"
+else
+ SWIG=swig
+fi
+
+CCACHE=../ccache-swig
+TESTDIR=test.$$
+
+test_failed() {
+ reason="$1"
+ echo $1
+ $CCACHE -s
+ cd ..
+ rm -rf $TESTDIR
+ echo TEST FAILED
+ exit 1
+}
+
+randcode() {
+ outfile="$1"
+ nlines=$2
+ i=0;
+ (
+ while [ $i -lt $nlines ]; do
+ echo "int foo$nlines$i(int x) { return x; }"
+ i=`expr $i + 1`
+ done
+ ) >> "$outfile"
+}
+
+genswigcode() {
+ outfile="$1"
+ nlines=$2
+ i=0;
+ (
+ echo "%module swigtest$2;"
+ while [ $i -lt $nlines ]; do
+ echo "int foo$nlines$i(int x);"
+ echo "struct Bar$nlines$i { int y; };"
+ i=`expr $i + 1`
+ done
+ ) >> "$outfile"
+}
+
+
+getstat() {
+ stat="$1"
+ value=`$CCACHE -s | grep "$stat" | cut -c34-40`
+ echo $value
+}
+
+checkstat() {
+ stat="$1"
+ expected_value="$2"
+ value=`getstat "$stat"`
+# echo "exp: $expected_value got: $value $testname"
+ if [ "$expected_value" != "$value" ]; then
+ test_failed "SUITE: $testsuite TEST: $testname - Expected $stat to be $expected_value got $value"
+ fi
+}
+
+
+basetests() {
+ echo "starting testsuite $testsuite"
+ rm -rf "$CCACHE_DIR"
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 0
+
+ j=1
+ rm -f *.c
+ while [ $j -lt 32 ]; do
+ randcode test$j.c $j
+ j=`expr $j + 1`
+ done
+
+ testname="BASIC"
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 1
+
+ testname="BASIC2"
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 1
+
+ testname="debug"
+ $CCACHE_COMPILE -c test1.c -g
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 2
+
+ testname="debug2"
+ $CCACHE_COMPILE -c test1.c -g
+ checkstat 'cache hit' 2
+ checkstat 'cache miss' 2
+
+ testname="output"
+ $CCACHE_COMPILE -c test1.c -o foo.o
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 2
+
+ testname="link"
+ $CCACHE_COMPILE test1.c -o test 2> /dev/null
+ checkstat 'called for link' 1
+
+ testname="multiple"
+ $CCACHE_COMPILE -c test1.c test2.c
+ checkstat 'multiple source files' 1
+
+ testname="find"
+ $CCACHE blahblah -c test1.c 2> /dev/null
+ checkstat "couldn't find the compiler" 1
+
+ testname="bad"
+ $CCACHE_COMPILE -c test1.c -I 2> /dev/null
+ checkstat 'bad compiler arguments' 1
+
+ testname="c/c++"
+ ln -f test1.c test1.ccc
+ $CCACHE_COMPILE -c test1.ccc 2> /dev/null
+ checkstat 'not a C/C++ file' 1
+
+ testname="unsupported"
+ $CCACHE_COMPILE -M foo -c test1.c > /dev/null 2>&1
+ checkstat 'unsupported compiler option' 1
+
+ testname="stdout"
+ $CCACHE echo foo -c test1.c > /dev/null
+ checkstat 'compiler produced stdout' 1
+
+ testname="non-regular"
+ mkdir testd
+ $CCACHE_COMPILE -o testd -c test1.c > /dev/null 2>&1
+ rmdir testd
+ checkstat 'output to a non-regular file' 1
+
+ testname="no-input"
+ $CCACHE_COMPILE -c -O2 2> /dev/null
+ checkstat 'no input file' 1
+
+
+ testname="CCACHE_DISABLE"
+ CCACHE_DISABLE=1 $CCACHE_COMPILE -c test1.c 2> /dev/null
+ checkstat 'cache hit' 3
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 4
+
+ testname="CCACHE_CPP2"
+ CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 4
+ checkstat 'cache miss' 3
+
+ CCACHE_CPP2=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_NOSTATS"
+ CCACHE_NOSTATS=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_RECACHE"
+ CCACHE_RECACHE=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 4
+
+ # strictly speaking should be 6 - RECACHE causes a double counting!
+ checkstat 'files in cache' 8
+ $CCACHE -c > /dev/null
+ checkstat 'files in cache' 6
+
+
+ testname="CCACHE_HASHDIR"
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 5
+
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -c test1.c -O -O
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 5
+
+ checkstat 'files in cache' 8
+
+ testname="comments"
+ echo '/* a silly comment */' > test1-comment.c
+ cat test1.c >> test1-comment.c
+ $CCACHE_COMPILE -c test1-comment.c
+ rm -f test1-comment*
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 6
+
+ testname="CCACHE_UNIFY"
+ CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 7
+ mv test1.c test1-saved.c
+ echo '/* another comment */' > test1.c
+ cat test1-saved.c >> test1.c
+ CCACHE_UNIFY=1 $CCACHE_COMPILE -c test1.c
+ mv test1-saved.c test1.c
+ checkstat 'cache hit' 7
+ checkstat 'cache miss' 7
+
+ testname="cache-size"
+ for f in *.c; do
+ $CCACHE_COMPILE -c $f
+ done
+ checkstat 'cache hit' 8
+ checkstat 'cache miss' 37
+ checkstat 'files in cache' 72
+ $CCACHE -F 48 -c > /dev/null
+ if [ `getstat 'files in cache'` -gt 48 ]; then
+ test_failed '-F test failed'
+ fi
+
+ testname="cpp call"
+ $CCACHE_COMPILE -c test1.c -E > test1.i
+ checkstat 'cache hit' 8
+ checkstat 'cache miss' 37
+
+ testname="direct .i compile"
+ $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 8
+ checkstat 'cache miss' 38
+
+ $CCACHE_COMPILE -c test1.i
+ checkstat 'cache hit' 9
+ checkstat 'cache miss' 38
+
+ $CCACHE_COMPILE -c test1.i
+ checkstat 'cache hit' 10
+ checkstat 'cache miss' 38
+
+ # removed these tests as some compilers (including newer versions of gcc)
+ # determine which language to use based on .ii/.i extension, and C++ may
+ # not be installed
+# testname="direct .ii file"
+# mv test1.i test1.ii
+# $CCACHE_COMPILE -c test1.ii
+# checkstat 'cache hit' 10
+# checkstat 'cache miss' 39
+
+# $CCACHE_COMPILE -c test1.ii
+# checkstat 'cache hit' 11
+# checkstat 'cache miss' 39
+
+ testname="stripc" # This test might not be portable
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 10
+ checkstat 'cache miss' 39
+
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -c test1.c
+ checkstat 'cache hit' 11
+ checkstat 'cache miss' 39
+
+ testname="zero-stats"
+ $CCACHE -z > /dev/null
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 0
+
+ testname="clear"
+ $CCACHE -C > /dev/null
+ checkstat 'files in cache' 0
+
+
+ rm -f test1.c
+}
+
+swigtests() {
+ echo "starting swig testsuite $testsuite"
+ rm -rf "$CCACHE_DIR"
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 0
+
+ j=1
+ rm -f *.i
+ genswigcode testswig1.i 1
+
+ testname="BASIC"
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 0
+ checkstat 'cache miss' 1
+
+ checkstat 'files in cache' 6
+
+ testname="BASIC2"
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 1
+
+ testname="output"
+ $CCACHE_COMPILE -java testswig1.i -o foo_wrap.c
+ checkstat 'cache hit' 1
+ checkstat 'cache miss' 2
+
+ testname="bad"
+ $CCACHE_COMPILE -java testswig1.i -I 2> /dev/null
+ checkstat 'bad compiler arguments' 1
+
+ testname="stdout"
+ $CCACHE_COMPILE -v -java testswig1.i > /dev/null
+ checkstat 'compiler produced stdout' 1
+
+ testname="non-regular"
+ mkdir testd
+ $CCACHE_COMPILE -o testd -java testswig1.i > /dev/null 2>&1
+ rmdir testd
+ checkstat 'output to a non-regular file' 1
+
+ testname="no-input"
+ $CCACHE_COMPILE -java 2> /dev/null
+ checkstat 'no input file' 1
+
+
+ testname="CCACHE_DISABLE"
+ CCACHE_DISABLE=1 $CCACHE_COMPILE -java testswig1.i 2> /dev/null
+ checkstat 'cache hit' 1
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 2
+
+ testname="CCACHE_CPP2"
+ CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 2
+ checkstat 'cache miss' 3
+
+ CCACHE_CPP2=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_NOSTATS"
+ CCACHE_NOSTATS=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 3
+
+ testname="CCACHE_RECACHE"
+ CCACHE_RECACHE=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 4
+
+ # strictly speaking should be 3x6=18 instead of 4x6=24 - RECACHE causes a double counting!
+ checkstat 'files in cache' 24
+ $CCACHE -c > /dev/null
+ checkstat 'files in cache' 18
+
+
+ testname="CCACHE_HASHDIR"
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 3
+ checkstat 'cache miss' 5
+
+ CCACHE_HASHDIR=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 4
+ checkstat 'cache miss' 5
+
+ checkstat 'files in cache' 24
+
+ testname="cpp call"
+ $CCACHE_COMPILE -java -E testswig1.i > testswig1-preproc.i
+ checkstat 'cache hit' 4
+ checkstat 'cache miss' 5
+
+ testname="direct .i compile"
+ $CCACHE_COMPILE -java testswig1.i
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 5
+
+ # No cache hit due to different input file name, -nopreprocess should not be given twice to SWIG
+ $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i
+ checkstat 'cache hit' 5
+ checkstat 'cache miss' 6
+
+ $CCACHE_COMPILE -java -nopreprocess testswig1-preproc.i
+ checkstat 'cache hit' 6
+ checkstat 'cache miss' 6
+
+ testname="stripc"
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O testswig1.i
+ checkstat 'cache hit' 7
+ checkstat 'cache miss' 6
+
+ CCACHE_STRIPC=1 $CCACHE_COMPILE -java -O -O -O testswig1.i
+ checkstat 'cache hit' 7
+ checkstat 'cache miss' 7
+
+ rm -f testswig1-preproc.i
+ rm -f testswig1.i
+}
+
+######
+# main program
+rm -rf $TESTDIR
+mkdir $TESTDIR
+cd $TESTDIR || exit 1
+CCACHE_DIR="ccache dir" # with space in directory name (like Windows default)
+mkdir "$CCACHE_DIR"
+export CCACHE_DIR
+
+testsuite="base"
+CCACHE_COMPILE="$CCACHE $COMPILER"
+basetests
+CCACHE_COMPILE="$CCACHE $SWIG"
+swigtests
+
+if test -z "$NOSOFTLINKSTEST"; then
+ testsuite="link"
+ ln -s $CCACHE $COMPILER
+ CCACHE_COMPILE="./$COMPILER"
+ basetests
+ rm "./$COMPILER"
+ ln -s $CCACHE $SWIG
+ CCACHE_COMPILE="./$SWIG"
+ swigtests
+ rm "./$SWIG"
+else
+ echo "skipping testsuite link"
+fi
+
+testsuite="hardlink"
+CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $COMPILER"
+basetests
+CCACHE_COMPILE="env CCACHE_NOCOMPRESS=1 CCACHE_HARDLINK=1 $CCACHE $SWIG"
+swigtests
+
+testsuite="cpp2"
+CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $COMPILER"
+basetests
+CCACHE_COMPILE="env CCACHE_CPP2=1 $CCACHE $SWIG"
+swigtests
+
+testsuite="nlevels4"
+CCACHE_COMPILE="env CCACHE_NLEVELS=4 $CCACHE $COMPILER"
+basetests
+
+testsuite="nlevels1"
+CCACHE_COMPILE="env CCACHE_NLEVELS=1 $CCACHE $COMPILER"
+basetests
+
+cd ..
+rm -rf $TESTDIR
+echo test done - OK
+exit 0
diff --git a/CCache/unify.c b/CCache/unify.c
new file mode 100644
index 000000000..a93d48a02
--- /dev/null
+++ b/CCache/unify.c
@@ -0,0 +1,307 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+/*
+ C/C++ unifier
+
+ the idea is that changes that don't affect the resulting C code
+ should not change the hash. This is achieved by folding white-space
+ and other non-semantic fluff in the input into a single unified format.
+
+ This unifier was design to match the output of the unifier in
+ compilercache, which is flex based. The major difference is that
+ this unifier is much faster (about 2x) and more forgiving of
+ syntactic errors. Continuing on syntactic errors is important to
+ cope with C/C++ extensions in the local compiler (for example,
+ inline assembly systems).
+*/
+
+#include "ccache.h"
+
+static char *s_tokens[] = {
+ "...", ">>=", "<<=", "+=", "-=", "*=", "/=", "%=", "&=", "^=",
+ "|=", ">>", "<<", "++", "--", "->", "&&", "||", "<=", ">=",
+ "==", "!=", ";", "{", "<%", "}", "%>", ",", ":", "=",
+ "(", ")", "[", "<:", "]", ":>", ".", "&", "!", "~",
+ "-", "+", "*", "/", "%", "<", ">", "^", "|", "?",
+ 0
+};
+
+#define C_ALPHA 1
+#define C_SPACE 2
+#define C_TOKEN 4
+#define C_QUOTE 8
+#define C_DIGIT 16
+#define C_HEX 32
+#define C_FLOAT 64
+#define C_SIGN 128
+
+static struct {
+ unsigned char type;
+ unsigned char num_toks;
+ char *toks[7];
+} tokens[256];
+
+/* build up the table used by the unifier */
+static void build_table(void)
+{
+ unsigned char c;
+ int i;
+ static int done;
+
+ if (done) return;
+ done = 1;
+
+ memset(tokens, 0, sizeof(tokens));
+ for (c=0;c<128;c++) {
+ if (isalpha(c) || c == '_') tokens[c].type |= C_ALPHA;
+ if (isdigit(c)) tokens[c].type |= C_DIGIT;
+ if (isspace(c)) tokens[c].type |= C_SPACE;
+ if (isxdigit(c)) tokens[c].type |= C_HEX;
+ }
+ tokens['\''].type |= C_QUOTE;
+ tokens['"'].type |= C_QUOTE;
+ tokens['l'].type |= C_FLOAT;
+ tokens['L'].type |= C_FLOAT;
+ tokens['f'].type |= C_FLOAT;
+ tokens['F'].type |= C_FLOAT;
+ tokens['U'].type |= C_FLOAT;
+ tokens['u'].type |= C_FLOAT;
+
+ tokens['-'].type |= C_SIGN;
+ tokens['+'].type |= C_SIGN;
+
+ for (i=0;s_tokens[i];i++) {
+ c = s_tokens[i][0];
+ tokens[c].type |= C_TOKEN;
+ tokens[c].toks[tokens[c].num_toks] = s_tokens[i];
+ tokens[c].num_toks++;
+ }
+}
+
+/* buffer up characters before hashing them */
+static void pushchar(unsigned char c)
+{
+ static unsigned char buf[64];
+ static int len;
+
+ if (c == 0) {
+ if (len > 0) {
+ hash_buffer((char *)buf, len);
+ len = 0;
+ }
+ hash_buffer(NULL, 0);
+ return;
+ }
+
+ buf[len++] = c;
+ if (len == 64) {
+ hash_buffer((char *)buf, len);
+ len = 0;
+ }
+}
+
+/* hash some C/C++ code after unifying */
+static void unify(unsigned char *p, size_t size)
+{
+ size_t ofs;
+ unsigned char q;
+ int i;
+
+ build_table();
+
+ for (ofs=0; ofs<size;) {
+ if (p[ofs] == '#') {
+ if ((size-ofs) > 2 && p[ofs+1] == ' ' && isdigit(p[ofs+2])) {
+ do {
+ ofs++;
+ } while (ofs < size && p[ofs] != '\n');
+ ofs++;
+ } else {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size && p[ofs] != '\n');
+ pushchar('\n');
+ ofs++;
+ }
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_ALPHA) {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size &&
+ (tokens[p[ofs]].type & (C_ALPHA|C_DIGIT)));
+ pushchar('\n');
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_DIGIT) {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size &&
+ ((tokens[p[ofs]].type & C_DIGIT) || p[ofs] == '.'));
+ if (ofs < size && (p[ofs] == 'x' || p[ofs] == 'X')) {
+ do {
+ pushchar(p[ofs]);
+ ofs++;
+ } while (ofs < size && (tokens[p[ofs]].type & C_HEX));
+ }
+ if (ofs < size && (p[ofs] == 'E' || p[ofs] == 'e')) {
+ pushchar(p[ofs]);
+ ofs++;
+ while (ofs < size &&
+ (tokens[p[ofs]].type & (C_DIGIT|C_SIGN))) {
+ pushchar(p[ofs]);
+ ofs++;
+ }
+ }
+ while (ofs < size && (tokens[p[ofs]].type & C_FLOAT)) {
+ pushchar(p[ofs]);
+ ofs++;
+ }
+ pushchar('\n');
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_SPACE) {
+ do {
+ ofs++;
+ } while (ofs < size && (tokens[p[ofs]].type & C_SPACE));
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_QUOTE) {
+ q = p[ofs];
+ pushchar(p[ofs]);
+ do {
+ ofs++;
+ while (ofs < size-1 && p[ofs] == '\\') {
+ pushchar(p[ofs]);
+ pushchar(p[ofs+1]);
+ ofs+=2;
+ }
+ pushchar(p[ofs]);
+ } while (ofs < size && p[ofs] != q);
+ pushchar('\n');
+ ofs++;
+ continue;
+ }
+
+ if (tokens[p[ofs]].type & C_TOKEN) {
+ q = p[ofs];
+ for (i=0;i<tokens[q].num_toks;i++) {
+ unsigned char *s = (unsigned char *)tokens[q].toks[i];
+ int len = strlen((char *)s);
+ if (size >= ofs+len && memcmp(&p[ofs], s, len) == 0) {
+ int j;
+ for (j=0;s[j];j++) {
+ pushchar(s[j]);
+ ofs++;
+ }
+ pushchar('\n');
+ break;
+ }
+ }
+ if (i < tokens[q].num_toks) {
+ continue;
+ }
+ }
+
+ pushchar(p[ofs]);
+ pushchar('\n');
+ ofs++;
+ }
+ pushchar(0);
+}
+
+
+/* hash a file that consists of preprocessor output, but remove any line
+ number information from the hash
+*/
+int unify_hash(const char *fname)
+{
+#ifdef _WIN32
+ HANDLE file;
+ HANDLE section;
+ DWORD filesize_low;
+ char *map;
+ int ret = -1;
+
+ file = CreateFileA(fname, GENERIC_READ, FILE_SHARE_READ, NULL,
+ OPEN_EXISTING, 0, NULL);
+ if (file != INVALID_HANDLE_VALUE) {
+ filesize_low = GetFileSize(file, NULL);
+ if (!(filesize_low == INVALID_FILE_SIZE && GetLastError() != NO_ERROR)) {
+ section = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, NULL);
+ CloseHandle(file);
+ if (section != NULL) {
+ map = MapViewOfFile(section, FILE_MAP_READ, 0, 0, 0);
+ CloseHandle(section);
+ if (map != NULL)
+ ret = 0;
+ }
+ }
+ }
+
+ if (ret == -1) {
+ cc_log("Failed to open preprocessor output %s\n", fname);
+ stats_update(STATS_PREPROCESSOR);
+ return -1;
+ }
+
+ /* pass it through the unifier */
+ unify((unsigned char *)map, filesize_low);
+
+ UnmapViewOfFile(map);
+
+ return 0;
+#else
+ int fd;
+ struct stat st;
+ char *map;
+
+ fd = open(fname, O_RDONLY|O_BINARY);
+ if (fd == -1 || fstat(fd, &st) != 0) {
+ cc_log("Failed to open preprocessor output %s\n", fname);
+ stats_update(STATS_PREPROCESSOR);
+ return -1;
+ }
+
+ /* we use mmap() to make it easy to handle arbitrarily long
+ lines in preprocessor output. I have seen lines of over
+ 100k in length, so this is well worth it */
+ map = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ if (map == (char *)-1) {
+ cc_log("Failed to mmap %s\n", fname);
+ stats_update(STATS_PREPROCESSOR);
+ return -1;
+ }
+ close(fd);
+
+ /* pass it through the unifier */
+ unify((unsigned char *)map, st.st_size);
+
+ munmap(map, st.st_size);
+
+ return 0;
+#endif
+}
+
diff --git a/CCache/util.c b/CCache/util.c
new file mode 100644
index 000000000..bba232492
--- /dev/null
+++ b/CCache/util.c
@@ -0,0 +1,884 @@
+/*
+ Copyright (C) Andrew Tridgell 2002
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ccache.h"
+
+static FILE *logfile;
+
+/* log a message to the CCACHE_LOGFILE location */
+void cc_log(const char *format, ...)
+{
+ va_list ap;
+ extern char *cache_logfile;
+
+ if (!cache_logfile) return;
+
+ if (!logfile) logfile = fopen(cache_logfile, "a");
+ if (!logfile) return;
+
+ va_start(ap, format);
+ vfprintf(logfile, format, ap);
+ va_end(ap);
+ fflush(logfile);
+}
+
+/* something went badly wrong! */
+void fatal(const char *msg)
+{
+ cc_log("FATAL: %s\n", msg);
+ exit(1);
+}
+
+int safe_rename(const char* oldpath, const char* newpath)
+{
+ /* safe_rename is for creating entries in the cache.
+
+ Works like rename(), but it never overwrites an existing
+ cache entry. This avoids corruption on NFS. */
+#ifndef _WIN32
+ int status = link(oldpath, newpath);
+ if( status == 0 || errno == EEXIST )
+#else
+ int status = CreateHardLinkA(newpath, oldpath, NULL) ? 0 : -1;
+ if( status == 0 || GetLastError() == ERROR_ALREADY_EXISTS )
+#endif
+ {
+ return unlink( oldpath );
+ }
+ else
+ {
+ return -1;
+ }
+}
+
+#ifndef ENABLE_ZLIB
+/* copy all data from one file descriptor to another */
+void copy_fd(int fd_in, int fd_out)
+{
+ char buf[10240];
+ int n;
+
+ while ((n = read(fd_in, buf, sizeof(buf))) > 0) {
+ if (write(fd_out, buf, n) != n) {
+ fatal("Failed to copy fd");
+ }
+ }
+}
+
+#ifndef HAVE_MKSTEMP
+/* cheap and nasty mkstemp replacement */
+static int mkstemp(char *template)
+{
+ mktemp(template);
+ return open(template, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
+}
+#endif
+
+/* move a file using rename */
+int move_file(const char *src, const char *dest) {
+ return safe_rename(src, dest);
+}
+
+/* copy a file - used when hard links don't work
+ the copy is done via a temporary file and atomic rename
+*/
+static int copy_file(const char *src, const char *dest)
+{
+ int fd1, fd2;
+ char buf[10240];
+ int n;
+ char *tmp_name;
+ mode_t mask;
+
+ x_asprintf(&tmp_name, "%s.XXXXXX", dest);
+
+ fd1 = open(src, O_RDONLY|O_BINARY);
+ if (fd1 == -1) {
+ free(tmp_name);
+ return -1;
+ }
+
+ fd2 = mkstemp(tmp_name);
+ if (fd2 == -1) {
+ close(fd1);
+ free(tmp_name);
+ return -1;
+ }
+
+ while ((n = read(fd1, buf, sizeof(buf))) > 0) {
+ if (write(fd2, buf, n) != n) {
+ close(fd2);
+ close(fd1);
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+ }
+
+ close(fd1);
+
+ /* get perms right on the tmp file */
+#ifndef _WIN32
+ mask = umask(0);
+ fchmod(fd2, 0666 & ~mask);
+ umask(mask);
+#else
+ (void)mask;
+#endif
+
+ /* the close can fail on NFS if out of space */
+ if (close(fd2) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ unlink(dest);
+
+ if (rename(tmp_name, dest) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ free(tmp_name);
+
+ return 0;
+}
+
+/* copy a file to the cache */
+static int copy_file_to_cache(const char *src, const char *dest) {
+ return copy_file(src, dest);
+}
+
+/* copy a file from the cache */
+static int copy_file_from_cache(const char *src, const char *dest) {
+ return copy_file(src, dest);
+}
+
+#else /* ENABLE_ZLIB */
+
+/* copy all data from one file descriptor to another
+ possibly decompressing it
+*/
+void copy_fd(int fd_in, int fd_out) {
+ char buf[10240];
+ int n;
+ gzFile gz_in;
+
+ gz_in = gzdopen(dup(fd_in), "rb");
+
+ if (!gz_in) {
+ fatal("Failed to copy fd");
+ }
+
+ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
+ if (write(fd_out, buf, n) != n) {
+ fatal("Failed to copy fd");
+ }
+ }
+}
+
+static int _copy_file(const char *src, const char *dest, int mode) {
+ int fd_in, fd_out;
+ gzFile gz_in, gz_out = NULL;
+ char buf[10240];
+ int n, ret;
+ char *tmp_name;
+ mode_t mask;
+ struct stat st;
+
+ x_asprintf(&tmp_name, "%s.XXXXXX", dest);
+
+ if (getenv("CCACHE_NOCOMPRESS")) {
+ mode = COPY_UNCOMPRESSED;
+ }
+
+ /* open source file */
+ fd_in = open(src, O_RDONLY);
+ if (fd_in == -1) {
+ return -1;
+ }
+
+ gz_in = gzdopen(fd_in, "rb");
+ if (!gz_in) {
+ close(fd_in);
+ return -1;
+ }
+
+ /* open destination file */
+ fd_out = mkstemp(tmp_name);
+ if (fd_out == -1) {
+ gzclose(gz_in);
+ free(tmp_name);
+ return -1;
+ }
+
+ if (mode == COPY_TO_CACHE) {
+ /* The gzip file format occupies at least 20 bytes. So
+ it will always occupy an entire filesystem block,
+ even for empty files.
+ Since most stderr files will be empty, we turn off
+ compression in this case to save space.
+ */
+ if (fstat(fd_in, &st) != 0) {
+ gzclose(gz_in);
+ close(fd_out);
+ free(tmp_name);
+ return -1;
+ }
+ if (file_size(&st) == 0) {
+ mode = COPY_UNCOMPRESSED;
+ }
+ }
+
+ if (mode == COPY_TO_CACHE) {
+ gz_out = gzdopen(dup(fd_out), "wb");
+ if (!gz_out) {
+ gzclose(gz_in);
+ close(fd_out);
+ free(tmp_name);
+ return -1;
+ }
+ }
+
+ while ((n = gzread(gz_in, buf, sizeof(buf))) > 0) {
+ if (mode == COPY_TO_CACHE) {
+ ret = gzwrite(gz_out, buf, n);
+ } else {
+ ret = write(fd_out, buf, n);
+ }
+ if (ret != n) {
+ gzclose(gz_in);
+ if (gz_out) {
+ gzclose(gz_out);
+ }
+ close(fd_out);
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+ }
+
+ gzclose(gz_in);
+ if (gz_out) {
+ gzclose(gz_out);
+ }
+
+ /* get perms right on the tmp file */
+ mask = umask(0);
+ fchmod(fd_out, 0666 & ~mask);
+ umask(mask);
+
+ /* the close can fail on NFS if out of space */
+ if (close(fd_out) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ unlink(dest);
+
+ if (rename(tmp_name, dest) == -1) {
+ unlink(tmp_name);
+ free(tmp_name);
+ return -1;
+ }
+
+ free(tmp_name);
+
+ return 0;
+}
+
+/* move a file to the cache, compressing it */
+int move_file(const char *src, const char *dest) {
+ int ret;
+
+ ret = _copy_file(src, dest, COPY_TO_CACHE);
+ if (ret != -1) unlink(src);
+ return ret;
+}
+
+/* copy a file to the cache, compressing it */
+static int copy_file_to_cache(const char *src, const char *dest) {
+ return _copy_file(src, dest, COPY_TO_CACHE);
+}
+
+/* copy a file from the cache, decompressing it */
+static int copy_file_from_cache(const char *src, const char *dest) {
+ return _copy_file(src, dest, COPY_FROM_CACHE);
+}
+#endif /* ENABLE_ZLIB */
+
+/* test if a file is zlib compressed */
+int test_if_compressed(const char *filename) {
+ FILE *f;
+
+ f = fopen(filename, "rb");
+ if (!f) {
+ return 0;
+ }
+
+ /* test if file starts with 1F8B, which is zlib's
+ * magic number */
+ if ((fgetc(f) != 0x1f) || (fgetc(f) != 0x8b)) {
+ fclose(f);
+ return 0;
+ }
+
+ fclose(f);
+ return 1;
+}
+
+/* copy file to the cache with error checking taking into account compression and hard linking if desired */
+int commit_to_cache(const char *src, const char *dest, int hardlink)
+{
+ int ret = -1;
+ struct stat st;
+ if (stat(src, &st) == 0) {
+ unlink(dest);
+ if (hardlink) {
+#ifdef _WIN32
+ ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1;
+#else
+ ret = link(src, dest);
+#endif
+ }
+ if (ret == -1) {
+ ret = copy_file_to_cache(src, dest);
+ if (ret == -1) {
+ cc_log("failed to commit %s -> %s (%s)\n", src, dest, strerror(errno));
+ stats_update(STATS_ERROR);
+ }
+ }
+ } else {
+ cc_log("failed to put %s in the cache (%s)\n", src, strerror(errno));
+ stats_update(STATS_ERROR);
+ }
+ return ret;
+}
+
+/* copy file out of the cache with error checking taking into account compression and hard linking if desired */
+int retrieve_from_cache(const char *src, const char *dest, int hardlink)
+{
+ int ret = 0;
+
+ x_utimes(src);
+
+ if (strcmp(dest, "/dev/null") == 0) {
+ ret = 0;
+ } else {
+ unlink(dest);
+ /* only make a hardlink if the cache file is uncompressed */
+ if (hardlink && test_if_compressed(src) == 0) {
+#ifdef _WIN32
+ ret = CreateHardLinkA(dest, src, NULL) ? 0 : -1;
+#else
+ ret = link(src, dest);
+#endif
+ } else {
+ ret = copy_file_from_cache(src, dest);
+ }
+ }
+
+ /* the cached file might have been deleted by some external process */
+ if (ret == -1 && errno == ENOENT) {
+ cc_log("hashfile missing for %s\n", dest);
+ stats_update(STATS_MISSING);
+ return -1;
+ }
+
+ if (ret == -1) {
+ ret = copy_file_from_cache(src, dest);
+ if (ret == -1) {
+ cc_log("failed to retrieve %s -> %s (%s)\n", src, dest, strerror(errno));
+ stats_update(STATS_ERROR);
+ return -1;
+ }
+ }
+ return ret;
+}
+
+/* make sure a directory exists */
+int create_dir(const char *dir)
+{
+ struct stat st;
+ if (stat(dir, &st) == 0) {
+ if (S_ISDIR(st.st_mode)) {
+ return 0;
+ }
+ errno = ENOTDIR;
+ return 1;
+ }
+#ifdef _WIN32
+ if (mkdir(dir) != 0 && errno != EEXIST) {
+ return 1;
+ }
+#else
+ if (mkdir(dir, 0777) != 0 && errno != EEXIST) {
+ return 1;
+ }
+#endif
+ return 0;
+}
+
+char const CACHEDIR_TAG[] =
+ "Signature: 8a477f597d28d172789f06886806bc55\n"
+ "# This file is a cache directory tag created by ccache.\n"
+ "# For information about cache directory tags, see:\n"
+ "# http://www.brynosaurus.com/cachedir/\n";
+
+int create_cachedirtag(const char *dir)
+{
+ char *filename;
+ struct stat st;
+ FILE *f;
+ x_asprintf(&filename, "%s/CACHEDIR.TAG", dir);
+ if (stat(filename, &st) == 0) {
+ if (S_ISREG(st.st_mode)) {
+ goto success;
+ }
+ errno = EEXIST;
+ goto error;
+ }
+ f = fopen(filename, "w");
+ if (!f) goto error;
+ if (fwrite(CACHEDIR_TAG, sizeof(CACHEDIR_TAG)-1, 1, f) != 1) {
+ goto error;
+ }
+ if (fclose(f)) goto error;
+success:
+ free(filename);
+ return 0;
+error:
+ free(filename);
+ return 1;
+}
+
+/*
+ this is like asprintf() but dies if the malloc fails
+ note that we use vsnprintf in a rather poor way to make this more portable
+*/
+void x_asprintf(char **ptr, const char *format, ...)
+{
+ va_list ap;
+
+ *ptr = NULL;
+ va_start(ap, format);
+ if (vasprintf(ptr, format, ap) == -1) {
+ fatal("out of memory in x_asprintf");
+ }
+ va_end(ap);
+
+ if (!ptr) fatal("out of memory in x_asprintf");
+}
+
+/*
+ this is like strdup() but dies if the malloc fails
+*/
+char *x_strdup(const char *s)
+{
+ char *ret;
+ ret = strdup(s);
+ if (!ret) {
+ fatal("out of memory in strdup\n");
+ }
+ return ret;
+}
+
+/*
+ this is like malloc() but dies if the malloc fails
+*/
+void *x_malloc(size_t size)
+{
+ void *ret;
+ ret = malloc(size);
+ if (!ret) {
+ fatal("out of memory in malloc\n");
+ }
+ return ret;
+}
+
+/*
+ this is like realloc() but dies if the malloc fails
+*/
+void *x_realloc(void *ptr, size_t size)
+{
+ void *p2;
+#if 1
+ /* Avoid invalid read in memcpy below */
+ p2 = realloc(ptr, size);
+ if (!p2) {
+ fatal("out of memory in x_realloc");
+ }
+#else
+ if (!ptr) return x_malloc(size);
+ p2 = malloc(size);
+ if (!p2) {
+ fatal("out of memory in x_realloc");
+ }
+ if (ptr) {
+ /* Note invalid read as the memcpy reads beyond the memory allocated by ptr */
+ memcpy(p2, ptr, size);
+ free(ptr);
+ }
+#endif
+ return p2;
+}
+
+
+/*
+ revsusive directory traversal - used for cleanup
+ fn() is called on all files/dirs in the tree
+ */
+void traverse(const char *dir, void (*fn)(const char *, struct stat *))
+{
+ DIR *d;
+ struct dirent *de;
+
+ d = opendir(dir);
+ if (!d) return;
+
+ while ((de = readdir(d))) {
+ char *fname;
+ struct stat st;
+
+ if (strcmp(de->d_name,".") == 0) continue;
+ if (strcmp(de->d_name,"..") == 0) continue;
+
+ if (strlen(de->d_name) == 0) continue;
+
+ x_asprintf(&fname, "%s/%s", dir, de->d_name);
+#ifdef _WIN32
+ if (stat(fname, &st))
+#else
+ if (lstat(fname, &st))
+#endif
+ {
+ if (errno != ENOENT) {
+ perror(fname);
+ }
+ free(fname);
+ continue;
+ }
+
+ if (S_ISDIR(st.st_mode)) {
+ traverse(fname, fn);
+ }
+
+ fn(fname, &st);
+ free(fname);
+ }
+
+ closedir(d);
+}
+
+
+/* return the base name of a file - caller frees */
+char *str_basename(const char *s)
+{
+ char *p = strrchr(s, '/');
+ if (p) {
+ s = (p+1);
+ }
+
+#ifdef _WIN32
+ p = strrchr(s, '\\');
+
+ if (p) {
+ s = (p+1);
+ }
+#endif
+
+ return x_strdup(s);
+}
+
+/* return the dir name of a file - caller frees */
+char *dirname(char *s)
+{
+ char *p;
+ s = x_strdup(s);
+ p = strrchr(s, '/');
+#ifdef _WIN32
+ p = strrchr(s, '\\');
+#endif
+ if (p) {
+ *p = 0;
+ }
+ return s;
+}
+
+/*
+ http://www.ecst.csuchico.edu/~beej/guide/ipc/flock.html
+ http://cvs.php.net/viewvc.cgi/php-src/win32/flock.c?revision=1.2&view=markup
+ Should return 0 for success, >0 otherwise
+ */
+int lock_fd(int fd)
+{
+#ifdef _WIN32
+# if 1
+ return _locking(fd, _LK_NBLCK, 1);
+# else
+ HANDLE fl = (HANDLE)_get_osfhandle(fd);
+ OVERLAPPED o;
+ memset(&o, 0, sizeof(o));
+ return (LockFileEx(fl, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &o))
+ ? 0 : GetLastError();
+# endif
+#else
+ struct flock fl;
+ int ret;
+
+ fl.l_type = F_WRLCK;
+ fl.l_whence = SEEK_SET;
+ fl.l_start = 0;
+ fl.l_len = 1;
+ fl.l_pid = 0;
+
+ /* not sure why we would be getting a signal here,
+ but one user claimed it is possible */
+ do {
+ ret = fcntl(fd, F_SETLKW, &fl);
+ } while (ret == -1 && errno == EINTR);
+ return ret;
+#endif
+}
+
+/* return size on disk of a file */
+size_t file_size(struct stat *st)
+{
+#ifdef _WIN32
+ return (st->st_size + 1023) & ~1023;
+#else
+ size_t size = st->st_blocks * 512;
+ if ((size_t)st->st_size > size) {
+ /* probably a broken stat() call ... */
+ size = (st->st_size + 1023) & ~1023;
+ }
+ return size;
+#endif
+}
+
+
+/* a safe open/create for read-write */
+int safe_open(const char *fname)
+{
+ int fd = open(fname, O_RDWR|O_BINARY);
+ if (fd == -1 && errno == ENOENT) {
+ fd = open(fname, O_RDWR|O_CREAT|O_EXCL|O_BINARY, 0666);
+ if (fd == -1 && errno == EEXIST) {
+ fd = open(fname, O_RDWR|O_BINARY);
+ }
+ }
+ return fd;
+}
+
+/* display a kilobyte unsigned value in M, k or G */
+void display_size(unsigned v)
+{
+ if (v > 1024*1024) {
+ printf("%8.1f Gbytes", v/((double)(1024*1024)));
+ } else if (v > 1024) {
+ printf("%8.1f Mbytes", v/((double)(1024)));
+ } else {
+ printf("%8u Kbytes", v);
+ }
+}
+
+/* return a value in multiples of 1024 give a string that can end
+ in K, M or G
+*/
+size_t value_units(const char *s)
+{
+ char m;
+ double v = atof(s);
+ m = s[strlen(s)-1];
+ switch (m) {
+ case 'G':
+ case 'g':
+ default:
+ v *= 1024*1024;
+ break;
+ case 'M':
+ case 'm':
+ v *= 1024;
+ break;
+ case 'K':
+ case 'k':
+ v *= 1;
+ break;
+ }
+ return (size_t)v;
+}
+
+
+/*
+ a sane realpath() function, trying to cope with stupid path limits and
+ a broken API
+*/
+char *x_realpath(const char *path)
+{
+#ifdef _WIN32
+ char namebuf[MAX_PATH];
+ DWORD ret;
+
+ ret = GetFullPathNameA(path, sizeof(namebuf), namebuf, NULL);
+ if (ret == 0 || ret >= sizeof(namebuf)) {
+ return NULL;
+ }
+
+ return x_strdup(namebuf);
+#else
+ int maxlen;
+ char *ret, *p;
+#ifdef PATH_MAX
+ maxlen = PATH_MAX;
+#elif defined(MAXPATHLEN)
+ maxlen = MAXPATHLEN;
+#elif defined(_PC_PATH_MAX)
+ maxlen = pathconf(path, _PC_PATH_MAX);
+#endif
+ if (maxlen < 4096) maxlen = 4096;
+
+ ret = x_malloc(maxlen);
+
+#if HAVE_REALPATH
+ p = realpath(path, ret);
+#else
+ /* yes, there are such systems. This replacement relies on
+ the fact that when we call x_realpath we only care about symlinks */
+ {
+ int len = readlink(path, ret, maxlen-1);
+ if (len == -1) {
+ free(ret);
+ return NULL;
+ }
+ ret[len] = 0;
+ p = ret;
+ }
+#endif
+ if (p) {
+ p = x_strdup(p);
+ free(ret);
+ return p;
+ }
+ free(ret);
+ return NULL;
+#endif
+}
+
+/* a getcwd that will returns an allocated buffer */
+char *gnu_getcwd(void)
+{
+ unsigned size = 128;
+
+ while (1) {
+ char *buffer = (char *)x_malloc(size);
+ if (getcwd(buffer, size) == buffer) {
+ return buffer;
+ }
+ free(buffer);
+ if (errno != ERANGE) {
+ return 0;
+ }
+ size *= 2;
+ }
+}
+
+/* create an empty file */
+int create_empty_file(const char *fname)
+{
+ int fd;
+
+ fd = open(fname, O_WRONLY|O_CREAT|O_TRUNC|O_EXCL|O_BINARY, 0666);
+ if (fd == -1) {
+ return -1;
+ }
+ close(fd);
+ return 0;
+}
+
+/*
+ return current users home directory or die
+*/
+const char *get_home_directory(void)
+{
+#ifdef _WIN32
+ static char home_path[MAX_PATH] = {0};
+ HRESULT ret;
+
+ /* we already have the path */
+ if (home_path[0] != 0) {
+ return home_path;
+ }
+
+ /* get the path to "Application Data" folder */
+ ret = SHGetFolderPathA(NULL, CSIDL_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, home_path);
+ if (SUCCEEDED(ret)) {
+ return home_path;
+ }
+
+ fprintf(stderr, "ccache: Unable to determine home directory\n");
+ return NULL;
+#else
+ const char *p = getenv("HOME");
+ if (p) {
+ return p;
+ }
+#ifdef HAVE_GETPWUID
+ {
+ struct passwd *pwd = getpwuid(getuid());
+ if (pwd) {
+ return pwd->pw_dir;
+ }
+ }
+#endif
+ fatal("Unable to determine home directory");
+ return NULL;
+#endif
+}
+
+int x_utimes(const char *filename)
+{
+#ifdef HAVE_UTIMES
+ return utimes(filename, NULL);
+#else
+ return utime(filename, NULL);
+#endif
+}
+
+#ifdef _WIN32
+/* perror for Win32 API calls, using GetLastError() instead of errno */
+void perror_win32(LPTSTR pszFunction)
+{
+ LPTSTR pszMessage;
+ DWORD dwLastError = GetLastError();
+
+ FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL,
+ dwLastError,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPTSTR)&pszMessage,
+ 0, NULL );
+
+ fprintf(stderr, "%s: %s\n", pszFunction, pszMessage);
+ LocalFree(pszMessage);
+}
+#endif
diff --git a/CCache/web/index.html b/CCache/web/index.html
new file mode 100644
index 000000000..4af839135
--- /dev/null
+++ b/CCache/web/index.html
@@ -0,0 +1,158 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
+<HTML>
+<HEAD>
+<TITLE>ccache</TITLE>
+</HEAD>
+<BODY BGCOLOR="#ffffff" TEXT="#000000" VLINK="#292555" LINK="#292555" ALINK="#cc0033">
+<h2>ccache</h2>
+
+ccache is a compiler cache. It acts as a caching pre-processor to
+C/C++ compilers, using the -E compiler switch and a hash to detect
+when a compilation can be satisfied from cache. This often results in
+a 5 to 10 times speedup in common compilations.<p>
+
+The idea came from Erik Thiele wrote the original <a
+href="http://compilercache.sourceforge.net/">compilercache</a> program
+as a bourne shell script. ccache is a re-implementation of Erik's idea
+in C with more features and better performance.<p>
+
+<h2>Latest release</h2>
+
+The latest release is ccache 2.4.
+
+<ul>
+<li>Added CCACHE_READONLY option
+<li>Added CCACHE_TEMPDIR option
+<li>fixed handling of hard-linked compilers on AIX
+<li>added O_BINARY support, to try and support win32 compiles
+<li>show cache directory in stats output
+<li>fixed handling of HOME environment variable
+</ul>
+
+See the <a href="ccache-man.html">manual page</a> for details
+on the new options.<p>
+
+You can get this release from the <a href="http://ccache.samba.org/ftp/ccache/">download directory</a>
+
+<p>NOTE! This release changes the hash input slighly, so you will
+probably find that you will not get any hits against your existing
+cache when you upgrade.
+
+<h2>Why bother?</h2>
+
+Why bother with a compiler cache? If you ever run "make clean; make"
+then you can probably benefit from ccache. It is very common for
+developers to do a clean build of a project for a whole host of
+reasons, and this throws away all the information from your previous
+compiles.<p>
+
+By using ccache you can get exactly the same effect as "make clean;
+make" but much faster. It also helps a lot when doing RPM builds,
+as RPM can make doing incremental builds tricky.<p>
+
+I put the effort into writing ccache for 2 reasons. The first is the
+Samba build farm
+(<a href="http://build.samba.org/">http://build.samba.org/</a>)
+which constantly does clean builds of Samba on about 30 machines after each
+CVS commit. On some of those machines the build took over an hour. By
+using ccache we get the same effect as clean builds but about 6 times
+faster.<p>
+
+The second reason is the autobuild system I used to run for
+Quantum. That system builds our whole Linux based OS from scratch
+after every CVS commit to catch compilation problems quickly. Using
+ccache those builds are much faster.
+
+<h2>Is it safe?</h2>
+
+Yes. The most important aspect of a compiler cache is to <b>always</b>
+produce exactly the same output that the real compiler would
+produce. The includes providing exactly the same object files and
+exactly the same compiler warnings that would be produced if you use
+the real compiler. The only way you should be able to tell that you
+are using ccache is the speed.<p>
+
+I have coded ccache very carefully to try to provide these guarantees.
+
+<h2>Features</h2>
+
+<ul>
+<li> keeps statistics on hits/misses
+<li> automatic cache size management
+<li> can cache compiles that generate warnings
+<li> easy installation
+<li> very low overhead
+<li> uses hard links where possible to avoid copies
+</ul>
+
+<h2>Documentation</h2>
+
+See the <a href="ccache-man.html">manual page</a>
+
+
+<h2>Performance</h2>
+
+Here are some results for compiling Samba on my Linux laptop. I have
+also included the results of using Erik's compilercache program
+(version 1.0.10) for comparison.<p>
+
+<table border=1>
+<tr><th> </th> <th>&nbsp;&nbsp;&nbsp;&nbsp;ccache</th> <th>&nbsp;compilercache</th> </tr>
+<tr><td>normal </td> <td align=right>13m 4s </td><td align=right>13m 4s</td> </tr>
+<tr><td>uncached </td> <td align=right>13m 15s </td><td align=right>15m 41s</td> </tr>
+<tr><td>cached </td> <td align=right>2m 45s </td><td align=right>4m 26s</td> </tr>
+</table>
+
+<h2>How to use it</h2>
+
+You can use ccache in two ways. The first is just to prefix your
+compile commands with "ccache". For example, you could change the
+"CC=gcc" line in your Makefile to be "CC=ccache gcc".<p>
+
+Alternatively, you can create symbolic links from your compilers name
+to ccache. This allows you to use ccache without any changes to your
+build system.
+
+<h2>Download</h2>
+
+You can download the latest release from the <a
+href="http://ccache.samba.org/ftp/ccache/">download directory</a>.<p>
+
+For the bleeding edge, you can fetch ccache via CVS or
+rsync. To fetch via cvs use the following command:
+
+<pre>
+ cvs -d :pserver:cvs@pserver.samba.org:/cvsroot co ccache
+</pre>
+
+To fetch via rsync use this command:
+
+<pre>
+ rsync -Pavz samba.org::ftp/unpacked/ccache .
+</pre>
+
+<h2>Related projects</h2>
+
+Here are some related programs you may find interesting
+
+<ul>
+<li> <a href="http://distcc.samba.org/">distcc</a> - a distributed compilation system
+<li> <a href="http://cachecc1.sourceforge.net/">cachecc1</a> - a gcc specific cache
+<li> <a href="http://sourceforge.net/projects/gocache/">gocache</a> - a cross platform compiler cache
+</ul>
+<p>
+
+<h2>Mailing list</h2>
+
+<p>A <a href="http://lists.samba.org/mailman/listinfo/ccache/">mailing
+list</a> is available for discussion of ccache.
+
+
+<hr>
+<tiny>
+<a href="http://samba.org/~tridge/">Andrew Tridgell</a><br>
+<a href="mailto:bugs@ccache.samba.org">bugs@ccache.samba.org</a>
+</tiny>
+
+</BODY>
+</HTML>
diff --git a/CHANGES b/CHANGES
index 782849c6f..d9426512b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,488 @@ SWIG (Simplified Wrapper and Interface Generator)
See CHANGES.current for current version.
+Version 1.3.39 (21 March 2009)
+==============================
+
+2009-03-19: bhy
+ [Python] Fix the memory leak related to Python 3 unicode and C char* conversion,
+ which can be shown in the following example before this fix:
+
+ from li_cstring import *
+ i=0
+ while True:
+ i += 1
+ n = str(i)*10
+ test3(n)
+
+ This fix affected SWIG_AsCharPtrAndSize() so you cannot call this function with
+ a null alloc and non-null cptr argument in Python 3, otherwise a runtime error
+ will be raised.
+
+2009-03-18: wsfulton
+ [C#] std::vector<T> wrapper improvements for .NET 2 and also providing the
+ necessary machinery to use the std::vector<T> wrappers with more advanced features such
+ as LINQ - the C# proxy class now derives from IEnumerable<>. The default is now to
+ generate code requiring .NET 2 as a minimum, although the C# code can be compiled
+ for .NET 1 by defining the SWIG_DOTNET_1 C# preprocessor constant. See the
+ std_vector.i file for more details.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2009-03-12: wsfulton
+ [Ruby] Fix #2676738 SWIG generated symbol name clashes.
+
+2009-03-01: bhy
+ [Python] Some fixes for Python 3.0.1 and higher support. In 3.0.1, the C API function
+ PyObject_Compare is removed, so PyObject_RichCompareBool is used for replacement.
+ Struct initilization of SwigPyObject and SwigPyObject_as_number changed to reflect
+ the drop of tp_compare and nb_long.
+
+2009-03-01: bhy
+ [Python] Fix SF#2583160. Now the importer in Python shadow wrapper take care of the
+ case that module already imported at other place.
+
+2009-02-28: bhy
+ [Python] Fix SF#2637352. Move struct declaration of SWIG_module in pyinit.swg before
+ the method calls, since some C compiler don't allow declaration in middle of function
+ body.
+
+2009-02-21: wsfulton
+ [Allegrocl] Fix seg fault wrapping some constant variable (%constant) types.
+
+2009-02-20: wsfulton
+ [CFFI] Fix seg faults when for %extend and using statements.
+
+2009-02-20: wsfulton
+ Fix SF #2605955: -co option which broke in 1.3.37.
+
+2009-02-20: wsfulton
+ New %insert("begin") section added. Also can be used as %begin. This is a new
+ code section reserved entirely for users and the code within the section is generated
+ at the top of the C/C++ wrapper file and so provides a means to put custom code
+ into the wrapper file before anything else that SWIG generates.
+
+2009-02-17: wsfulton
+ 'make clean-test-suite' will now run clean on ALL languages. Previously it only
+ ran the correctly configured languages. This way it is now possible to clean up
+ properly after running 'make partialcheck-test-suite'.
+
+2009-02-14: wsfulton
+ Extend attribute library support for structs/classes and the accessor functions use
+ pass/return by value semantics. Two new macros are available and usage is identical
+ to %attribute. These are %attributeval for structs/classes and %attributestring for
+ string classes, like std::string. See attribute.swg for more details.
+
+2009-02-13: wsfulton
+ Add support for %extend and memberin typemaps. Previously the memberin typemaps were
+ ignored for member variables within a %extend block.
+
+2009-02-12: wsfulton
+ Remove unnecessary temporary variable when wrapping return values that are references.
+ Example of generated code for wrapping:
+
+ struct XYZ {
+ std::string& refReturn();
+ };
+
+ used to be:
+
+ std::string *result = 0 ;
+ ...
+ {
+ std::string &_result_ref = (arg1)->refReturn();
+ result = (std::string *) &_result_ref;
+ }
+
+ Now it is:
+
+ std::string *result = 0 ;
+ ...
+ result = (std::string *) &(arg1)->refReturn();
+
+2009-02-08: bhy
+ Change the SIZE mapped by %pybuffer_mutable_binary and %pybuffer_binary in pybuffer.i from
+ the length of the buffer to the number of items in the buffer.
+
+2009-02-08: wsfulton
+ Fix %feature not working for conversion operators, reported by Matt Sprague, for example:
+ %feature("cs:methodmodifiers") operator bool "protected";
+
+2009-02-07: wsfulton
+ [MzScheme] Apply #2081967 configure changes for examples to build with recent PLT versions.
+ Also fixes Makefile errors building SWIG executable when mzscheme package is installed
+ (version 3.72 approx and later).
+
+2009-02-04: talby
+ [Perl] Fix SF#2564192 reported by David Kolovratnk.
+ SWIG_AsCharPtrAndSize() now handles "get" magic.
+
+Version 1.3.38 (31 January 2009)
+================================
+
+2009-01-31: bhy
+ [Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend
+ and %pythonappend have correct indentation.
+
+2009-01-31: bhy
+ [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list
+ of static member function in generated proxy code should not have the
+ 'self' parameter.
+
+2009-01-29: wsfulton
+ Fix regression introduced in 1.3.37 where the default output directory
+ for target language specific files (in the absence of -outdir) was no
+ longer the same directory as the generated c/c++ file.
+
+2009-01-28: wsfulton
+ [Java, C#] Fix proxy class not being used when the global scope operator
+ was used for parameters passed by value. Reported by David Piepgrass.
+
+2009-01-15: wsfulton
+ [Perl] Fix seg fault when running with -v option, reported by John Ky.
+
+Version 1.3.37 (13 January 2009)
+================================
+
+2009-01-13: mgossage
+ [Lua] Added contract support for requiring that unsigned numbers are >=0
+ Rewrote much of Examples/Lua/embed3.
+ Added a lot to the Lua documentation.
+
+2009-01-13: wsfulton
+ Fix compilation error when using directors on protected virtual overloaded
+ methods reported by Sam Hendley.
+
+2009-01-12: drjoe
+ [R] Fixed handling of integer arrays
+
+2009-01-10: drjoe
+ [R] Fix integer handling in r to deal correctly with signed
+ and unsigned issues
+
+2009-01-10: wsfulton
+ Patch #1992756 from Colin McDonald - %contract not working for classes
+ in namespace
+
+2009-01-05: olly
+ Mark SWIGPERL5, SWIGPHP5, and SWIGTCL8 as deprecated in the source
+ code and remove documentation of them.
+
+2008-12-30: wsfulton
+ Bug #2430756. All the languages now define a macro in the generated C/C++
+ wrapper file indicating which language is being wrapped. The macro name is the
+ same as those defined when SWIG is run, eg SWIGJAVA, SWIGOCTAVE, SWIGCSHARP etc
+ and are listed in the "Conditional Compilation" section in the documentation.
+
+2008-12-23: wsfulton
+ [Java] Fix #2153773 - %nojavaexception was clearing the exception feature
+ instead of disabling it. Clearing checked Java exceptions also didn't work.
+ The new %clearjavaexception can be used for clearing the exception feature.
+
+2008-12-22: wsfulton
+ Fix #2432801 - Make SwigValueWrapper exception safe for when copy constructors
+ throw exceptions.
+
+2008-12-21: wsfulton
+ Apply patch #2440046 which fixes possible seg faults for member and global
+ variable char arrays when the strings are larger than the string array size.
+
+2008-12-20: wsfulton
+ The ccache compiler cache has been adapted to work with SWIG and
+ named ccache-swig. It now works with C/C++ compilers as well as SWIG
+ and can result in impressive speedups when used to recompile unchanged
+ code with either a C/C++ compiler or SWIG. Documentation is in CCache.html
+ or the installed ccache-swig man page.
+
+2008-12-12: wsfulton
+ Apply patch from Kalyanov Dmitry which fixes parsing of nested structs
+ containing comments.
+
+2008-12-12: wsfulton
+ Fix error message in some nested struct and %inline parsing error situations
+ such as unterminated strings and comments.
+
+2008-12-07: olly
+ [PHP] Fix warnings when compiling generated wrapper with GCC 4.3.
+
+2008-12-06: wsfulton
+ [PHP] Deprecate %pragma(php4). Please use %pragma(php) instead.
+ The following two warnings have been renamed:
+ WARN_PHP4_MULTIPLE_INHERITANCE -> WARN_PHP_MULTIPLE_INHERITANCE
+ WARN_PHP4_UNKNOWN_PRAGMA -> WARN_PHP_UNKNOWN_PRAGMA
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2008-12-04: bhy
+ [Python] Applied patch SF#2158938: all the SWIG symbol names started with Py
+ are changed, since they are inappropriate and discouraged in Python
+ documentation (from http://www.python.org/doc/2.5.2/api/includes.html):
+
+ "All user visible names defined by Python.h (except those defined by
+ the included standard headers) have one of the prefixes "Py" or "_Py".
+ Names beginning with "_Py" are for internal use by the Python implementation
+ and should not be used by extension writers. Structure member names do
+ not have a reserved prefix.
+
+ Important: user code should never define names that begin with "Py" or "_Py".
+ This confuses the reader, and jeopardizes the portability of the user
+ code to future Python versions, which may define additional names beginning
+ with one of these prefixes."
+
+ Here is a brief list of what changed:
+
+ PySwig* -> SwigPy*
+ PyObject_ptr -> SwigPtr_PyObject
+ PyObject_var -> SwigVar_PyObject
+ PySequence_Base, PySequence_Cont, PySequence_Ref ->
+ SwigPySequence_Base, SwigPySequence_Cont, SwigPySequence_Ref
+ PyMap* -> SwigPyMap*
+
+ We provided a pyname_compat.i for backward compatibility. Users whose code having
+ these symbols and do not want to change it could simply include this file
+ at front of your code. A better solution is to run the converting tool on
+ your code, which has been put in SWIG's SVN trunk (Tools/pyname_patch.py) and
+ you can download it here:
+ https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2008-12-02: wsfulton
+ [Python] Apply patch #2143727 from Serge Monkewitz to fix importing base classes
+ when the package option is specified in %module and that module is %import'ed.
+
+2008-11-28: wsfulton
+ [UTL] Fix #2080497. Some incorrect acceptance of types in the STL, eg a double * element
+ passed into a vector<int *> constructor would be accepted, but the ensuing behaviour
+ was undefined. Now the type conversion correctly raises an exception.
+
+2008-11-24: wsfulton
+ Add -outcurrentdir option. This sets the default output directory to the current
+ directory instead of the path specified by the input file. This option enables
+ behaviour similar to c/c++ compilers. Note that this controls the output directory,
+ but only in the absence of the -o and/or -outdir options.
+
+2008-11-23: wsfulton
+ [ruby] Apply patch #2263850 to fix ruby/file.i ... rubyio.h filename change in
+ ruby 1.9.
+
+2008-11-23: wsfulton
+ Apply patch #2319790 from Johan Hake to fix shared_ptr usage in std::tr1 namespace.
+
+2008-11-21: wsfulton
+ The use of the include path to find the input file is now deprecated.
+ This makes the behaviour of SWIG the same as C/C++ compilers in preparation
+ for use with ccache.
+
+2008-11-16: wsfulton
+ Fix -nopreprocess option to:
+ - correctly report file names in warning and error messages.
+ - use the original input filename that created the preprocessed output when
+ determining the C++ wrapper file name (in the absence of -o). Previously
+ the name of the input file containing the preprocessed output was used.
+
+2008-11-11: wsfulton
+ [Java] Add patch #2152691 from MATSUURA Takanori which fixes compiles using the
+ Intel compiler
+
+2008-11-01: wsfulton
+ Add patch #2128249 from Anatoly Techtonik which corrects the C/C++ proxy
+ class being reported for Python docstrings when %rename is used.
+
+2008-11-01: wsfulton
+ Add the strip encoder patch from Anatoly Techtonik #2130016. This enables an
+ easy way to rename symbols by stripping a commonly used prefix in all the
+ function/struct names. It works in the same way as the other encoders, such as
+ title, lower, command etc outlined in CHANGES file dated 12/30/2005. Example
+ below will rename wxAnotherWidget to AnotherWidget and wxDoSomething to
+ DoSomething:
+
+ %rename("%(strip:[wx])s") "";
+
+ struct wxAnotherWidget {
+ void wxDoSomething();
+ };
+
+2008-09-26: mutandiz
+ [allegrocl]
+ Lots of test-suite work.
+ - Fix ordering of wrapper output and %{ %} header output.
+ - Fix declarations of local vars in C wrappers.
+ - Fix declaration of defined constants in C wrappers.
+ - Fix declaration of EnumValues in C wrappers.
+ - add some const typemaps to allegrocl.swg
+ - add rename for operator bool() overloads.
+
+2008-09-25: olly
+ [PHP5] Fill in typemaps for SWIGTYPE and void * (SF#2095186).
+
+2008-09-22: mutandiz (Mikel Bancroft)
+ [allegrocl]
+ - Support wrapping of types whose definitions are not seen by
+ SWIG. They are treated as forward-referenced classes and if a
+ definition is not seen are treated as (* :void).
+ - Don't wrap the contents of unnamed namespaces.
+ - More code cleanup. Removed some extraneous warnings.
+ - start work on having the allegrocl mod pass the cpp test-suite.
+
+2008-09-19: olly
+ [PHP5] Add typemaps for long long and unsigned long long.
+
+2008-09-18: wsfulton
+ [C#] Added C# array typemaps provided by Antti Karanta.
+ The arrays provide a way to use MarshalAs(UnmanagedType.LPArray)
+ and pinning the array using 'fixed'. See arrays_csharp.i library file
+ for details.
+
+2008-09-18: wsfulton
+ Document the optional module attribute in the %import directive,
+ see Modules.html. Add a warning for Python wrappers when the
+ module name for an imported base class is missing, requiring the
+ module attribute to be added to %import, eg
+
+ %import(module="FooModule") foo.h
+
+2008-09-18: olly
+ [PHP5] Change the default input typemap for char * to turn PHP
+ Null into C NULL (previously it was converted to an empty string).
+ The new behaviour is consistent with how the corresponding output
+ typemap works (SF#2025719).
+
+ If you want to keep the old behaviour, add the following typemap
+ to your interface file (PHP's convert_to_string_ex() function does
+ the converting from PHP Null to an empty string):
+
+ %typemap(in) char * {
+ convert_to_string_ex($input);
+ $1 = Z_STRVAL_PP($input);
+ }
+
+2008-09-18: olly
+ [PHP5] Fix extra code added to proxy class constructors in the case
+ where the only constructor takes no arguments.
+
+2008-09-18: olly
+ [PHP5] Fix wrapping of a renamed enumerated value of an enum class
+ member (SF#2095273).
+
+2008-09-17: mutandiz (Mikel Bancroft)
+ [allegrocl]
+ - Fix how forward reference typedefs are handled, so as not to conflict
+ with other legit typedefs.
+ - Don't (for now) perform an ffitype typemap lookup when trying to
+ when calling compose_foreign_type(). This is actually a useful thing
+ to do in certain cases, the test cases for which I can't currently
+ locate :/. It's breaking some wrapping behavior that is more commonly
+ seen, however. I'll readd in a more appropriate way when I can
+ recreate the needed test case, or a user complains (which means
+ they probably have a test case).
+ - document the -isolate command-line arg in the 'swig -help' output.
+ It was in the html docs, but not there.
+ - small amount of code cleanup, removed some unused code.
+ - some minor aesthetic changes.
+
+2008-09-12: bhy
+ [Python] Python 3.0 support branch merged into SWIG trunk. Thanks to
+ Google Summer of Code 2008 for supporting this project! By default
+ SWIG will generate interface files compatible with both Python 2.x
+ and 3.0. And there's also some Python 3 new features that can be
+ enabled by passing a "-py3" command line option to SWIG. These
+ features are:
+
+ - Function annotation support
+ Also, the parameter list of proxy function will be generated,
+ even without the "-py3" option. However, the parameter list
+ will fallback to *args if the function (or method) is overloaded.
+ - Buffer interface support
+ - Abstract base class support
+
+ For details of Python 3 support and these features, please see the
+ "Python 3 Support" section in the "SWIG and Python" chapter of the SWIG
+ documentation.
+
+ The "-apply" command line option and support of generating codes
+ using apply() is removed. Since this is only required by very old
+ Python.
+
+ This merge also patched SWIG's parser to solve a bug. By this patch,
+ SWIG features able to be correctly applied on C++ conversion operator,
+ such like this:
+
+ %feature("shadow") *::operator bool %{ ... %}
+
+2008-09-02: richardb
+ [Python] Commit patch #2089149: Director exception handling mangles
+ returned exception. Exceptions raised by Python code in directors
+ are now passed through to the caller without change. Also, remove
+ the ": " prefix which used to be added to other director exceptions
+ (eg, those due to incorrect return types).
+
+2008-09-02: wsfulton
+ [Python] Commit patch #1988296 GCItem multiple module linking issue when using
+ directors.
+
+2008-09-02: wsfulton
+ [C#] Support for 'using' and 'fixed' blocks in the 'csin' typemap is now
+ possible through the use of the pre attribute and the new terminator attribute, eg
+
+ %typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput)) {",
+ terminator=" } // terminate temp$csinput using block",
+ ) const CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+ See CSharp.html for more info.
+
+2008-09-01: wsfulton
+ [CFFI] Commit patch #2079381 submitted by Boris Smilga - constant exprs put into
+ no-eval context in DEFCENUM
+
+2008-08-02: wuzzeb
+ [Chicken,Allegro] Commit Patch 2019314
+ Fixes a build error in chicken, and several build errors and other errors
+ in Allegro CL
+
+2008-07-19: wsfulton
+ Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson.
+
+2008-07-17: wsfulton
+ Fix SF #2019156 Configuring with --without-octave or --without-alllang
+ did not disable octave.
+
+2008-07-14: wsfulton
+ [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly
+ marshalled to C#/Java null in director methods.
+
+2008-07-04: olly
+ [PHP] For std_vector.i and std_map.i, rename empty() to is_empty()
+ since "empty" is a PHP reserved word. Based on patch from Mark Klein
+ in SF#1943417.
+
+2008-07-04: olly
+ [PHP] The deprecated command line option "-make" has been removed.
+ Searches on Google codesearch suggest that nobody is using it now
+ anyway.
+
+2008-07-04: olly
+ [PHP] The SWIG cdata.i library module is now supported.
+
+2008-07-03: olly
+ [PHP] The deprecated command line option "-phpfull" has been
+ removed. We recommend building your extension as a dynamically
+ loadable module.
+
+2008-07-02: olly
+ [PHP4] Support for PHP4 has been removed. The PHP developers are
+ no longer making new PHP4 releases, and won't even be providing
+ patches for critical security issues after 2008-08-08.
+
+2008-07-02: olly
+ [Python] Import the C extension differently for Python 2.6 and
+ later so that an implicit relative import doesn't produce a
+ deprecation warning for 2.6 and a failure for 2.7 and later.
+ Patch from Richard Boulton in SF#2008229, plus follow-up patches
+ from Richard and Haoyu Bai.
+
Version 1.3.36 (24 June 2008)
=============================
@@ -477,7 +959,7 @@ Version 1.3.34 (27 February 2008)
};
Version 1.3.33 (November 23, 2007)
-=================================
+==================================
11/21/2007: mikel
[allegrocl] omit private slot type info in the classes/types
@@ -1409,7 +1891,7 @@ Version 1.3.31 (November 20, 2006)
[lua] update to typemap for object by value, to make it c89 compliant
Version 1.3.30 (November 13, 2006)
-=================================
+==================================
11/12/2006: wsfulton
[java] Remove DetachCurrentThread patch from 08/11/2006 - it causes segfaults
@@ -5732,7 +6214,7 @@ Version 1.3.24 (December 14, 2004)
compile with no errors, java shows some problems.
Version 1.3.23 (November 11, 2004)
-=================================
+==================================
11/05/2004: wsfulton
Patch #982753 from Fabrice Salvaire: Adds dependencies generation for
@@ -7983,7 +8465,8 @@ Version 1.3.22 (September 4, 2004)
exception instead.
Version 1.3.21 (January 11, 2004)
-==================================
+=================================
+
01/10/2004: cheetah (William Fulton)
The output format for both warnings and errors can be selected for
integration with your favourite IDE/editor. Editors and IDEs can usually
@@ -9757,6 +10240,7 @@ Version 1.3.20 (December 17, 2003)
Version 1.3.19 (March 28, 2003)
===============================
+
03/28/2003: beazley
Variety of minor bug fixes to the 1.3.18 release including:
@@ -10343,6 +10827,7 @@ Version 1.3.18 (March 23, 2003)
Version 1.3.17 (November 22, 2002)
==================================
+
11/19/2002: beazley
Fixed [ 613922 ] preprocessor errors with HAVE_LONG_LONG.
@@ -10698,6 +11183,7 @@ Version 1.3.16 (October 14, 2002)
Version 1.3.15 (September 9, 2002)
==================================
+
09/09/2002: beazley
Fixed nasty runtime type checking bug with subtypes and inheritance
and templates.
@@ -12390,6 +12876,7 @@ Version 1.3.14 (August 12, 2002)
Version 1.3.13 (June 17, 2002)
==============================
+
06/16/2002: beazley
Fixed a bug with __FILE__ expansion in the preprocessor. On Windows,
the backslash (\) is now converted to (\\) in the string literal
@@ -15521,6 +16008,7 @@ Version 1.3.10 (December 10, 2001)
Version 1.3.9 (September 25, 2001)
==================================
+
9/25/2001: beazley
Fixed parsing problem with type declarations like
'char ** const'. SWIG parsed this correctly, but the
@@ -15533,6 +16021,7 @@ Version 1.3.9 (September 25, 2001)
Version 1.3.8 (September 23, 2001)
==================================
+
9/23/2001: beazley
Included improved distutils setup.py file in the Tools
directory (look for the setup.py.tmpl file). Contributed by
@@ -16905,7 +17394,7 @@ Version 1.3 Alpha 5
and function bodies. Preprocessor bug.
Version 1.3 Alpha 4 (September 4, 2000)
-======================================
+=======================================
9/3/00 : ttn
Added instructions for maintainers in Examples/README on how
@@ -17991,6 +18480,7 @@ Version 1.3 Alpha 1 (February 11, 2000)
Version 1.1 Patch 5 (February 5, 1998)
======================================
+
2/4/98 : Fixed a bug in the configure script when different package
locations are specified (--with-tclincl, etc...).
@@ -18243,6 +18733,7 @@ Version 1.1 Patch 3 (November 24, 1997)
Version 1.1 Patch 2 (September 4, 1997)
=======================================
+
9/4/97 : Fixed problem with handling of virtual functions that
was introduced by some changes in the C++ module.
@@ -19378,7 +19869,7 @@ This release should fix most, if not all, of those problems.
it generated alot of unnecessary code).
Version 1.1 Beta3 (January 9, 1997)
-====================================
+===================================
Note : A *huge* number of changes related to ongoing modifications.
@@ -19501,6 +19992,7 @@ Version 1.1 Beta1 (October 30, 1996)
Version 1.0 Final (August 31, 1996)
===================================
+
1. Fixed minor bug in C++ module
2. Fixed minor bug in pointer type-checker when using
@@ -19584,7 +20076,7 @@ number of immediate problems :
3. A few minor fixes were made in the Makefile
Version 1.0 Beta 3 (June 14, 1996)
-===================================
+==================================
There are lots of changes in this release :
@@ -19674,6 +20166,7 @@ let me know.
Version 1.0 Beta 2 (April 26, 1996)
===================================
+
This release is identical to Beta1 except a few minor bugs are
fixed and the SWIG library has been updated to work with Tcl 7.5/Tk 4.1.
A tcl7.5 examples directory is now included.
@@ -19688,6 +20181,7 @@ A tcl7.5 examples directory is now included.
Version 1.0 Beta 1 (April 10, 1996).
=====================================
+
This is the first "semi-official" release of SWIG. It has a
number of substantial improvements over the Alpha release. These
notes are in no particular order--hope I remembered everything....
diff --git a/CHANGES.current b/CHANGES.current
index 7d1b70ca7..822d2feed 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -1,52 +1,72 @@
-Version 1.3.37 (in progress)
-=============================
-
-2008-08-09: talby
- [Perl5] Unify Perl and C portions of constructor wrappers.
-
-2008-08-02: wuzzeb
- [Chicken,Allegro] Commit Patch 2019314
- Fixes a build error in chicken, and several build errors and other errors
- in Allegro CL
-
-2008-07-19: wsfulton
- Fix building of Tcl examples/test-suite on Mac OSX reported by Gideon Simpson.
-
-2008-07-17: wsfulton
- Fix SF #2019156 Configuring with --without-octave or --without-alllang
- did not disable octave.
-
-2008-07-14: wsfultonn
- [Java, C#] Fix director typemaps for pointers so that NULL pointers are correctly
- marshalled to C#/Java null in director methods.
-
-2008-07-04: olly
- [PHP] For std_vector.i and std_map.i, rename empty() to is_empty()
- since "empty" is a PHP reserved word. Based on patch from Mark Klein
- in SF#1943417.
-
-2008-07-04: olly
- [PHP] The deprecated command line option "-make" has been removed.
- Searches on Google codesearch suggest that nobody is using it now
- anyway.
-
-2008-07-04: olly
- [PHP] The SWIG cdata.i library module is now supported.
-
-2008-07-03: olly
- [PHP] The deprecated command line option "-phpfull" has been
- removed. We recommend building your extension as a dynamically
- loadable module.
-
-2008-07-02: olly
- [PHP4] Support for PHP4 has been removed. The PHP developers are
- no longer making new PHP4 releases, and won't even be providing
- patches for critical security issues after 2008-08-08.
-
-2008-07-02: olly
- [Python] Import the C extension differently for Python 2.6 and
- later so that an implicit relative import doesn't produce a
- deprecation warning for 2.6 and a failure for 2.7 and later.
- Patch from Richard Boulton in SF#2008229, plus follow-up patches
- from Richard and Haoyu Bai.
+Version 1.3.40 (in progress)
+============================
+2009-06-16: wsfulton
+ [Java,C#] Fix enum marshalling when %ignore is used on one of the enum items.
+ Incorrect enum values were being passed to the C++ layer or compilation errors resulted.
+
+2009-06-02: talby
+ [Perl] Resolved reference.i overload support problem
+ identfied by John Potowsky.
+
+2009-05-26: wsfulton
+ [C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy
+ now implements System.Collections.Generic.IDictionary<>.
+
+ These std:map wrappers have a non-backwards compatible overhaul to make them
+ like a .NET IDictionary. Some method names have changed as following:
+ set -> setitem (use this[] property now)
+ get -> getitem (use this[] property now)
+ has_key -> ContainsKey
+ del -> Remove
+ clear -> Clear
+
+ The following macros used for std::map wrappers are deprecated and will no longer work:
+ specialize_std_map_on_key
+ specialize_std_map_on_value
+ specialize_std_map_on_both
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2009-05-14: bhy
+ [Python] Fix the wrong pointer value returned by SwigPyObject_repr().
+
+2009-05-13: mutandiz (Mikel Bancroft)
+ [allegrocl] Minor tweak when wrapping in -nocwrap mode.
+
+2009-05-11: wsfulton
+ [C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These
+ implement IList<> instead of IEnumerable<> where possible.
+
+2009-04-29: wsfulton
+ [Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps.
+ When this attribute is set, the typemap will not apply to classes that are derived
+ from a C++ base class, eg
+ %typemap(csbase, notderived="1") SWIGTYPE "CommonBase"
+
+2009-04-29: olly
+ [Python] Don't attempt to acquire the GIL in situations where we
+ know that it will already be locked. This avoids some dead-locks
+ with mod_python (due to mod_python bugs which are apparently
+ unlikely to ever be fixed), and results in smaller wrappers which
+ run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04,
+ the stripped wrapper library was 11% smaller and ran 2.7% faster).
+
+2009-04-21: wsfulton
+ [C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation.
+
+2009-04-09: wsfulton
+ Fix #2746858 - C macro expression using floating point numbers
+
+2009-03-30: olly
+ [PHP] The default out typemap for char[ANY] now returns the string up to a
+ zero byte, or the end of the array if there is no zero byte. This
+ is the same as Python does, and seems more generally useful than
+ the previous behaviour of returning the whole contents of the array
+ including any zero bytes. If you want the old behaviour, you can provide
+ your own typemap to do this:
+
+ %typemap(out) char [ANY]
+ %{
+ RETVAL_STRINGL($1, $1_dim0, 1);
+ %}
diff --git a/Doc/Manual/Allegrocl.html b/Doc/Manual/Allegrocl.html
index 8981f52b5..cc950db7c 100755..100644
--- a/Doc/Manual/Allegrocl.html
+++ b/Doc/Manual/Allegrocl.html
@@ -8,7 +8,7 @@
<body bgcolor="#ffffff">
-<H1><a name="Allegrocl_nn1"></a>16 SWIG and Allegro Common Lisp</H1>
+<H1><a name="Allegrocl_nn1"></a>17 SWIG and Allegro Common Lisp</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -135,10 +135,10 @@ be unhappy to see some enterprising folk use this work to add
to it.
</p>
-<H2><a name="Allegrocl_nn2"></a>16.1 Basics</H2>
+<H2><a name="Allegrocl_nn2"></a>17.1 Basics</H2>
-<H3><a name="Allegrocl_nn3"></a>16.1.1 Running Swig</H3>
+<H3><a name="Allegrocl_nn3"></a>17.1.1 Running Swig</H3>
<p>
@@ -360,7 +360,7 @@ need to link in the Allegro shared library. The library you create from
the C++ wrapper will be what you then load into Allegro CL.
</p>
-<H3><a name="Allegrocl_nn4"></a>16.1.2 Command Line Options</H3>
+<H3><a name="Allegrocl_nn4"></a>17.1.2 Command Line Options</H3>
<p>
@@ -396,7 +396,7 @@ See <a href="#Allegrocl_nn47">Section 17.5 Identifier converter
functions</a> for more details.
</p>
-<H3><a name="Allegrocl_nn5"></a>16.1.3 Inserting user code into generated files</H3>
+<H3><a name="Allegrocl_nn5"></a>17.1.3 Inserting user code into generated files</H3>
<p>
@@ -411,7 +411,7 @@ using the SWIG <tt>%insert(section) %{ ...code... %}</tt> directive:
<pre>
%module example
-%insert("runtime") %{
+%{
#include "header.h"
%}
@@ -432,11 +432,11 @@ generated lisp interface file
</ul>
<p>
Note that the block <tt>%{ ... %}</tt> is effectively a shortcut for
-<tt>%insert("runtime") %{ ... %}</tt>.
+<tt>%insert("header") %{ ... %}</tt>.
</p>
-<H2><a name="Allegrocl_nn6"></a>16.2 Wrapping Overview</H2>
+<H2><a name="Allegrocl_nn6"></a>17.2 Wrapping Overview</H2>
<p>
@@ -446,7 +446,7 @@ New users to SWIG are encouraged to read
interested in generating an interface to C++.
</p>
-<H3><a name="Allegrocl_nn7"></a>16.2.1 Function Wrapping</H3>
+<H3><a name="Allegrocl_nn7"></a>17.2.1 Function Wrapping</H3>
<p>
@@ -499,7 +499,7 @@ interested in generating an interface to C++.
</pre>
</div>
-<H3><a name="Allegrocl_nn8"></a>16.2.2 Foreign Wrappers</H3>
+<H3><a name="Allegrocl_nn8"></a>17.2.2 Foreign Wrappers</H3>
<p>
@@ -512,7 +512,7 @@ interested in generating an interface to C++.
typemap.
</p>
-<H3><a name="Allegrocl_nn9"></a>16.2.3 FFI Wrappers</H3>
+<H3><a name="Allegrocl_nn9"></a>17.2.3 FFI Wrappers</H3>
<p>
@@ -593,7 +593,7 @@ char *xxx();
ff:def-foreign-call's.
</p>
-<H3><a name="Allegrocl_nn10"></a>16.2.4 Non-overloaded Defuns</H3>
+<H3><a name="Allegrocl_nn10"></a>17.2.4 Non-overloaded Defuns</H3>
<p>
@@ -606,7 +606,7 @@ char *xxx();
this function can be manipulated via the <tt>lout</tt> typemap.
</p>
-<H3><a name="Allegrocl_nn11"></a>16.2.5 Overloaded Defuns</H3>
+<H3><a name="Allegrocl_nn11"></a>17.2.5 Overloaded Defuns</H3>
<p>
@@ -622,7 +622,7 @@ char *xxx();
can be manipulated via the <tt>lout</tt> typemap.
</p>
-<H3><a name="Allegrocl_nn12"></a>16.2.6 What about constant and variable access?</H3>
+<H3><a name="Allegrocl_nn12"></a>17.2.6 What about constant and variable access?</H3>
<p>
@@ -635,7 +635,7 @@ char *xxx();
into the foreign module.
</p>
-<H3><a name="Allegrocl_nn13"></a>16.2.7 Object Wrapping</H3>
+<H3><a name="Allegrocl_nn13"></a>17.2.7 Object Wrapping</H3>
<p>
@@ -657,7 +657,7 @@ char *xxx();
foreign function interface.
</p>
-<H2><a name="Allegrocl_nn14"></a>16.3 Wrapping Details</H2>
+<H2><a name="Allegrocl_nn14"></a>17.3 Wrapping Details</H2>
<p>
@@ -665,7 +665,7 @@ char *xxx();
translated into lisp.
</p>
-<H3><a name="Allegrocl_nn15"></a>16.3.1 Namespaces</H3>
+<H3><a name="Allegrocl_nn15"></a>17.3.1 Namespaces</H3>
<p>
@@ -742,7 +742,7 @@ namespace car {
function such as <tt>(car '(1 2 3)</tt>.
</p>
-<H3><a name="Allegrocl_nn16"></a>16.3.2 Constants</H3>
+<H3><a name="Allegrocl_nn16"></a>17.3.2 Constants</H3>
@@ -803,7 +803,7 @@ namespace car {
not use the <tt>-nocwrap</tt> command-line option.
</p>
-<H3><a name="Allegrocl_nn17"></a>16.3.3 Variables</H3>
+<H3><a name="Allegrocl_nn17"></a>17.3.3 Variables</H3>
<p>
@@ -881,7 +881,7 @@ globalvar&gt; (globalvar.nnn::glob_float)
</pre>
</div>
-<H3><a name="Allegrocl_nn18"></a>16.3.4 Enumerations</H3>
+<H3><a name="Allegrocl_nn18"></a>17.3.4 Enumerations</H3>
<p>
@@ -957,7 +957,7 @@ EXPORT const int ACL_ENUM___FOO3__SWIG_0 = FOO3;
</pre>
</div>
-<H3><a name="Allegrocl_nn19"></a>16.3.5 Arrays</H3>
+<H3><a name="Allegrocl_nn19"></a>17.3.5 Arrays</H3>
<p>
@@ -1105,10 +1105,10 @@ namespace BAR {
</pre>
</div>
-<H3><a name="Allegrocl_nn20"></a>16.3.6 Classes and Structs and Unions (oh my!)</H3>
+<H3><a name="Allegrocl_nn20"></a>17.3.6 Classes and Structs and Unions (oh my!)</H3>
-<H4><a name="Allegrocl_nn21"></a>16.3.6.1 CLOS wrapping of</H4>
+<H4><a name="Allegrocl_nn21"></a>17.3.6.1 CLOS wrapping of</H4>
<p>
@@ -1123,7 +1123,7 @@ namespace BAR {
integer values.
</p>
-<H4><a name="Allegrocl_nn22"></a>16.3.6.2 CLOS Inheritance</H4>
+<H4><a name="Allegrocl_nn22"></a>17.3.6.2 CLOS Inheritance</H4>
<p>
@@ -1136,7 +1136,7 @@ namespace BAR {
parameter.
</p>
-<H4><a name="Allegrocl_nn23"></a>16.3.6.3 Member fields and functions</H4>
+<H4><a name="Allegrocl_nn23"></a>17.3.6.3 Member fields and functions</H4>
<p>
@@ -1152,7 +1152,7 @@ namespace BAR {
the interface does nothing for <tt>friend</tt> directives,
</p>
-<H4><a name="Allegrocl_nn24"></a>16.3.6.4 Why not directly access C++ classes using foreign types?</H4>
+<H4><a name="Allegrocl_nn24"></a>17.3.6.4 Why not directly access C++ classes using foreign types?</H4>
<p>
@@ -1170,11 +1170,11 @@ namespace BAR {
use the more robust wrapper functions.
</p>
-<H3><a name="Allegrocl_nn25"></a>16.3.7 Templates</H3>
+<H3><a name="Allegrocl_nn25"></a>17.3.7 Templates</H3>
-<H4><a name="Allegrocl_nn26"></a>16.3.7.1 Generating wrapper code for templates</H4>
+<H4><a name="Allegrocl_nn26"></a>17.3.7.1 Generating wrapper code for templates</H4>
<p>
@@ -1187,7 +1187,7 @@ namespace BAR {
directive.
</p>
-<H4><a name="Allegrocl_nn27"></a>16.3.7.2 Implicit Template instantiation</H4>
+<H4><a name="Allegrocl_nn27"></a>17.3.7.2 Implicit Template instantiation</H4>
<p>
@@ -1197,7 +1197,7 @@ namespace BAR {
class schema.
</p>
-<H3><a name="Allegrocl_nn28"></a>16.3.8 Typedef, Templates, and Synonym Types</H3>
+<H3><a name="Allegrocl_nn28"></a>17.3.8 Typedef, Templates, and Synonym Types</H3>
<p>
@@ -1277,7 +1277,7 @@ synonym&gt;
</pre>
</div>
-<H4><a name="Allegrocl_nn29"></a>16.3.8.1 Choosing a primary type</H4>
+<H4><a name="Allegrocl_nn29"></a>17.3.8.1 Choosing a primary type</H4>
<p>
@@ -1298,7 +1298,7 @@ synonym&gt;
</li>
</ul>
-<H3><a name="Allegrocl_nn30"></a>16.3.9 Function overloading/Parameter defaulting</H3>
+<H3><a name="Allegrocl_nn30"></a>17.3.9 Function overloading/Parameter defaulting</H3>
<p>
@@ -1461,7 +1461,7 @@ overload&gt;
</pre>
</div>
-<H3><a name="Allegrocl_nn31"></a>16.3.10 Operator wrapping and Operator overloading</H3>
+<H3><a name="Allegrocl_nn31"></a>17.3.10 Operator wrapping and Operator overloading</H3>
<p>
@@ -1607,7 +1607,7 @@ opoverload&gt;
</pre>
</div>
-<H3><a name="Allegrocl_nn32"></a>16.3.11 Varargs</H3>
+<H3><a name="Allegrocl_nn32"></a>17.3.11 Varargs</H3>
<p>
@@ -1628,7 +1628,7 @@ opoverload&gt;
with other ways such functions can be wrapped.
</p>
-<H3><a name="Allegrocl_nn33"></a>16.3.12 C++ Exceptions</H3>
+<H3><a name="Allegrocl_nn33"></a>17.3.12 C++ Exceptions</H3>
<p>
@@ -1640,7 +1640,7 @@ opoverload&gt;
implemented.
</p>
-<H3><a name="Allegrocl_nn34"></a>16.3.13 Pass by value, pass by reference</H3>
+<H3><a name="Allegrocl_nn34"></a>17.3.13 Pass by value, pass by reference</H3>
<p>
@@ -1652,7 +1652,7 @@ opoverload&gt;
newly defined types.
</p>
-<H2><a name="Allegrocl_nn35"></a>16.4 Typemaps</H2>
+<H2><a name="Allegrocl_nn35"></a>17.4 Typemaps</H2>
<p>
@@ -1663,7 +1663,7 @@ opoverload&gt;
on <a href="Typemaps.html#Typemaps">Typemaps</a> for more information.
</p>
-<H3><a name="Allegrocl_nn36"></a>16.4.1 Code Generation in the C++ Wrapper</H3>
+<H3><a name="Allegrocl_nn36"></a>17.4.1 Code Generation in the C++ Wrapper</H3>
@@ -1693,7 +1693,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn37"></a>16.4.1.1 IN Typemap</H4>
+<H4><a name="Allegrocl_nn37"></a>17.4.1.1 IN Typemap</H4>
<p>
@@ -1728,7 +1728,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn38"></a>16.4.1.2 OUT Typemap</H4>
+<H4><a name="Allegrocl_nn38"></a>17.4.1.2 OUT Typemap</H4>
<p>
@@ -1752,7 +1752,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn39"></a>16.4.1.3 CTYPE Typemap</H4>
+<H4><a name="Allegrocl_nn39"></a>17.4.1.3 CTYPE Typemap</H4>
<p>
@@ -1784,7 +1784,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
these <a href="Typemaps.html#Typemaps_nn25">common typemaps</a> here.
</p>
-<H3><a name="Allegrocl_nn40"></a>16.4.2 Code generation in Lisp wrappers</H3>
+<H3><a name="Allegrocl_nn40"></a>17.4.2 Code generation in Lisp wrappers</H3>
<p>
@@ -1803,7 +1803,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
<a href="#Allegrocl_nn15">16.3.1 Namespaces</a> for details.
</p>
-<H4><a name="Allegrocl_nn41"></a>16.4.2.1 LIN Typemap</H4>
+<H4><a name="Allegrocl_nn41"></a>17.4.2.1 LIN Typemap</H4>
<p>
@@ -1846,7 +1846,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn42"></a>16.4.2.2 LOUT Typemap</H4>
+<H4><a name="Allegrocl_nn42"></a>17.4.2.2 LOUT Typemap</H4>
<p>
@@ -1889,7 +1889,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn43"></a>16.4.2.3 FFITYPE Typemap</H4>
+<H4><a name="Allegrocl_nn43"></a>17.4.2.3 FFITYPE Typemap</H4>
@@ -1939,7 +1939,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn44"></a>16.4.2.4 LISPTYPE Typemap</H4>
+<H4><a name="Allegrocl_nn44"></a>17.4.2.4 LISPTYPE Typemap</H4>
<p>
@@ -1959,7 +1959,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H4><a name="Allegrocl_nn45"></a>16.4.2.5 LISPCLASS Typemap</H4>
+<H4><a name="Allegrocl_nn45"></a>17.4.2.5 LISPCLASS Typemap</H4>
<p>
@@ -1983,7 +1983,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H3><a name="Allegrocl_nn46"></a>16.4.3 Modifying SWIG behavior using typemaps</H3>
+<H3><a name="Allegrocl_nn46"></a>17.4.3 Modifying SWIG behavior using typemaps</H3>
<p>
@@ -2017,10 +2017,10 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
</pre>
</div>
-<H2><a name="Allegrocl_nn47"></a>16.5 Identifier Converter functions</H2>
+<H2><a name="Allegrocl_nn47"></a>17.5 Identifier Converter functions</H2>
-<H3><a name="Allegrocl_nn48"></a>16.5.1 Creating symbols in the lisp environment</H3>
+<H3><a name="Allegrocl_nn48"></a>17.5.1 Creating symbols in the lisp environment</H3>
<p>
@@ -2041,11 +2041,11 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
of arguments.
</p>
-<H3><a name="Allegrocl_nn49"></a>16.5.2 Existing identifier-converter functions</H3>
+<H3><a name="Allegrocl_nn49"></a>17.5.2 Existing identifier-converter functions</H3>
<p>Two basic identifier routines have been defined.
-<H4><a name="Allegrocl_nn50"></a>16.5.2.1 identifier-convert-null</H4>
+<H4><a name="Allegrocl_nn50"></a>17.5.2.1 identifier-convert-null</H4>
<p>
@@ -2054,7 +2054,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
strings, from which a symbol will be created.
</p>
-<H4><a name="Allegrocl_nn51"></a>16.5.2.2 identifier-convert-lispify</H4>
+<H4><a name="Allegrocl_nn51"></a>17.5.2.2 identifier-convert-lispify</H4>
<p>
@@ -2063,7 +2063,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
same symbol transformations.
</p>
-<H4><a name="Allegrocl_nn52"></a>16.5.2.3 Default identifier to symbol conversions</H4>
+<H4><a name="Allegrocl_nn52"></a>17.5.2.3 Default identifier to symbol conversions</H4>
<p>
@@ -2072,7 +2072,7 @@ return-val wrapper-name(parm0, parm1, ..., parmN)
default naming conventions.
</p>
-<H3><a name="Allegrocl_nn53"></a>16.5.3 Defining your own identifier-converter</H3>
+<H3><a name="Allegrocl_nn53"></a>17.5.3 Defining your own identifier-converter</H3>
<p>
@@ -2128,7 +2128,7 @@ indicating the number of arguments passed to the routine indicated by
this identifier.
</p>
-<H3><a name="Allegrocl_nn54"></a>16.5.4 Instructing SWIG to use a particular identifier-converter</H3>
+<H3><a name="Allegrocl_nn54"></a>17.5.4 Instructing SWIG to use a particular identifier-converter</H3>
<p>
diff --git a/Doc/Manual/Arguments.html b/Doc/Manual/Arguments.html
index af8780452..911e8548e 100644
--- a/Doc/Manual/Arguments.html
+++ b/Doc/Manual/Arguments.html
@@ -351,7 +351,7 @@ function like this in an interface file :</p>
<div class="code"><pre>
%module example
-%include typemaps.i
+%include "typemaps.i"
...
%{
extern void negate(double *);
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 94e3eca79..f747fc213 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -11,6 +11,12 @@
<ul>
<li><a href="#csharp_introduction">Introduction</a>
<li><a href="#csharp_differences_java">Differences to the Java module</a>
+<li><a href="#CSharp_arrays">C# Arrays</a>
+<ul>
+<li><a href="#CSharp_arrays_swig_library">The SWIG C arrays library</a>
+<li><a href="#CSharp_arrays_pinvoke_default_array_marshalling">Managed arrays using P/Invoke default array marshalling</a>
+<li><a href="#CSharp_arrays_pinning">Managed arrays using pinning</a>
+</ul>
<li><a href="#csharp_exceptions">C# Exceptions</a>
<ul>
<li><a href="#csharp_exception_example_check_typemap">C# exception example using "check" typemap</a>
@@ -93,6 +99,7 @@ namespace com.bloggs.widget {
...
}
</pre></div>
+Note that by default, the generated C# classes have no namespace and the module name is unrelated to namespaces. The module name is just like in Java and is merely used to name some of the generated classes.
</li>
<li>
@@ -125,7 +132,7 @@ If it was used, it would generate an illegal runtime initialisation via a PInvok
C# doesn't support the notion of throws clauses.
Therefore there is no 'throws' typemap attribute support for adding exception classes to a throws clause.
Likewise there is no need for an equivalent to <tt>%javaexception</tt>.
-In fact, throwing C# exceptions works quite differently, see <a href="CSharp.html#csharp_exceptions">C# Exceptions></a> below.
+In fact, throwing C# exceptions works quite differently, see <a href="CSharp.html#csharp_exceptions">C# Exceptions</a> below.
</li>
<li>
@@ -201,7 +208,12 @@ $jnicall -&gt; $imcall
<li>
<p>
-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 an additional optional attribute called 'cshin'. It should contain the parameter type and name whenever a <a href="Java.html#java_constructor_helper_function">constructor helper function</a> is generated due to the 'pre' or 'post' attributes. Note that 'pre', 'post' and 'cshin' attributes are not used for marshalling the property set. Please see the <a href="#csharp_date_marshalling">Date marshalling example</a> and <a href="#CSharp.html#csharp_date_properties">Date marshalling of properties example</a> for further understanding.
+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 'cshin' attribute should contain the parameter type and name whenever a <a href="Java.html#java_constructor_helper_function">constructor helper function</a> 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# <tt>using</tt> or <tt>fixed</tt> block is started.
+Note that 'pre', 'post', 'terminator' and 'cshin' attributes are not used for marshalling the property set.
+Please see the <a href="#csharp_date_marshalling">Date marshalling example</a> and <a href="#csharp_date_properties">Date marshalling of properties example</a> for further understanding of these "csin" applicable attributes.
</p>
</li>
@@ -397,7 +409,275 @@ Windows users can also get the examples working using a
<a href="http://www.cygwin.com">Cygwin</a> or <a href="http://www.mingw.org">MinGW</a> environment for automatic configuration of the example makefiles.
Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
-<H2><a name="csharp_exceptions"></a>18.3 C# Exceptions</H2>
+<H2><a name="CSharp_arrays"></a>18.3 C# Arrays</H2>
+
+
+<p>
+There are various ways to pass arrays from C# to C/C++.
+The default wrapping treats arrays as pointers and as such simple type wrapper classes are generated,
+eg <tt>SWIGTYPE_p_int</tt> when wrapping the C type <tt>int []</tt> or <tt>int *</tt>.
+This gives a rather restricted use of the underlying unmanaged code and the most practical way to use arrays is to enhance or customise
+with one of the following three approaches; namely the SWIG C arrays library, P/Invoke default array marshalling or
+pinned arrays.
+</p>
+
+<H3><a name="CSharp_arrays_swig_library"></a>18.3.1 The SWIG C arrays library</H3>
+
+
+<p>
+The C arrays library keeps all the array memory in the unmanaged layer.
+The library is available to all language modules and is documented in the <a href="Library.html#Library_carrays">carrays.i library</a> section.
+Please refer to this section for details, but for convenience, the C# usage for the two examples outlined there is shown below.
+</p>
+
+<p>
+For the <tt>%array_functions</tt> example, the equivalent usage would be:
+</p>
+
+<div class="code">
+<pre>
+SWIGTYPE_p_double a = example.new_doubleArray(10); // Create an array
+for (int i=0; i&lt;10; i++)
+ example.doubleArray_setitem(a,i,2*i); // Set a value
+example.print_array(a); // Pass to C
+example.delete_doubleArray(a); // Destroy array
+</pre>
+</div>
+
+<p>
+and for the <tt>%array_class</tt> example, the equivalent usage would be:
+</p>
+
+<div class="code">
+<pre>
+doubleArray c = new doubleArray(10); // Create double[10]
+for (int i=0; i&lt;10; i++)
+ c.setitem(i, 2*i); // Assign values
+example.print_array(c.cast()); // Pass to C
+</pre>
+</div>
+
+
+<H3><a name="CSharp_arrays_pinvoke_default_array_marshalling"></a>18.3.2 Managed arrays using P/Invoke default array marshalling</H3>
+
+
+<p>
+In the P/Invoke default marshalling scheme, one needs to designate whether the invoked function will treat a managed
+array parameter as input, output, or both. When the function is invoked, the CLR allocates a separate chunk of memory as big as the given managed array,
+which is automatically released at the end of the function call. If the array parameter is marked as being input, the content of the managed array is copied
+into this buffer when the call is made. Correspondingly, if the array parameter is marked as being output, the contents of the reserved buffer are copied
+back into the managed array after the call returns. A pointer to to this buffer
+is passed to the native function.
+</p>
+
+<p>
+The reason for allocating a separate buffer is to leave the CLR free to relocate the managed array object
+during garbage collection. If the overhead caused by the copying is causing a significant performance penalty, consider pinning the managed array and
+passing a direct reference as described in the next section.
+</p>
+
+<p>
+For more information on the subject, see the
+<a href="http://msdn.microsoft.com/en-us/library/z6cfh6e6(VS.80).aspx">Default Marshaling for Arrays</a> article
+on MSDN.
+</p>
+
+
+<p>
+The P/Invoke default marshalling is supported by the <tt>arrays_csharp.i</tt> library via the INPUT, OUTPUT and INOUT typemaps.
+Let's look at some example usage. Consider the following C function:
+</p>
+<div class="code">
+<pre>
+void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
+</pre>
+</div>
+
+<p>
+We can now instruct SWIG to use the default marshalling typemaps by
+</p>
+
+<div class="code">
+<pre>
+%include "arrays_csharp.i"
+
+%apply int INPUT[] {int *sourceArray}
+%apply int OUTPUT[] {int *targetArray}
+</pre>
+</div>
+
+<p>
+As a result, we get the following method in the module class:
+</p>
+
+<div class="code">
+<pre>
+public static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
+ examplePINVOKE.myArrayCopy(sourceArray, targetArray, nitems);
+}
+</pre>
+</div>
+
+<p>
+If we look beneath the surface at the corresponding intermediary class code, we see
+that SWIG has generated code that uses attributes
+(from the System.Runtime.InteropServices namespace) to tell the CLR to use default
+marshalling for the arrays:
+</p>
+
+<div class="code">
+<pre>
+[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
+public static extern void myArrayCopy([In, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
+ [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+</pre>
+</div>
+
+<p>
+As an example of passing an inout array (i.e. the target function will both read from and
+write to the array), consider this C function that swaps a given number of elements
+in the given arrays:
+</p>
+
+<div class="code">
+<pre>
+void myArraySwap(int *array1, int *array2, int nitems);
+</pre>
+</div>
+
+<p>
+Now, we can instruct SWIG to wrap this by
+</p>
+
+<div class="code">
+<pre>
+%include "arrays_csharp.i"
+
+%apply int INOUT[] {int *array1}
+%apply int INOUT[] {int *array2}
+</pre>
+</div>
+
+<p>
+This results in the module class method
+</p>
+
+<div class="code">
+<pre>
+ public static void myArraySwap(int[] array1, int[] array2, int nitems) {
+ examplePINVOKE.myArraySwap(array1, array2, nitems);
+ }
+</pre>
+</div>
+
+<p>
+and intermediate class method
+</p>
+
+<div class="code">
+<pre>
+ [DllImport("example", EntryPoint="CSharp_myArraySwap")]
+ public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
+ [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+</pre>
+</div>
+
+
+<H3><a name="CSharp_arrays_pinning"></a>18.3.3 Managed arrays using pinning</H3>
+
+
+<p>
+It is also possible to pin a given array in memory (i.e. fix its location in memory), obtain a
+direct pointer to it, and then pass this pointer to the wrapped C/C++ function. This approach
+involves no copying, but it makes the work of the garbage collector harder as
+the managed array object can not be relocated before the fix on the array is released. You should avoid
+fixing arrays in memory in cases where the control may re-enter the managed side via a callback and/or
+another thread may produce enough garbage to trigger garbage collection.
+</p>
+
+<p>
+For more information, see the <a href="http://msdn.microsoft.com/en-us/library/f58wzh21(VS.80).aspx">fixed statement</a> in the C# language reference.
+</p>
+
+
+<p>
+Now let's look at an example using pinning, thus avoiding the CLR making copies
+of the arrays passed as parameters. The <tt>arrays_csharp.i</tt> library file again provides the required support via the <tt>FIXED</tt> typemaps.
+Let's use the same function from the previous section:
+</p>
+
+<div class="code">
+<pre>
+void myArrayCopy(int *sourceArray, int *targetArray, int nitems);
+</pre>
+</div>
+
+<p>
+We now need to declare the module class method unsafe, as we are using pointers:
+</p>
+
+<div class="code">
+<pre>
+%csmethodmodifiers myArrayCopy "public unsafe";
+ </pre>
+</div>
+
+<p>
+Apply the appropriate typemaps to the array parameters:
+</p>
+
+<div class="code">
+<pre>
+%include "arrays_csharp.i"
+
+%apply int FIXED[] {int *sourceArray}
+%apply int FIXED[] {int *targetArray}
+</pre>
+</div>
+
+<p>
+Notice that there is no need for separate in, out or inout typemaps as is the
+case when using P/Invoke default marshalling.
+</p>
+
+<p>
+As a result, we get the following method in the module class:
+</p>
+
+<div class="code">
+<pre>
+ public unsafe static void myArrayCopy(int[] sourceArray, int[] targetArray, int nitems) {
+ fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
+ fixed ( int *swig_ptrTo_targetArray = targetArray ) {
+ {
+ examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray, nitems);
+ }
+ }
+ }
+ }
+</pre>
+</div>
+
+<p>
+On the method signature level the only difference to the version using P/Invoke default
+marshalling is the "unsafe" quantifier, which is required because we are handling pointers.
+</p>
+
+<p>
+Also the intermediate class method looks a little different from the default marshalling
+example - the method is expecting an IntPtr as the parameter type.
+</p>
+
+<div class="code">
+<pre>
+[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
+public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3);
+</pre>
+</div>
+
+
+
+<H2><a name="csharp_exceptions"></a>18.4 C# Exceptions</H2>
<p>
@@ -494,7 +774,7 @@ set so should only be used when a C# exception is not created.
</p>
-<H3><a name="csharp_exception_example_check_typemap"></a>18.3.1 C# exception example using "check" typemap</H3>
+<H3><a name="csharp_exception_example_check_typemap"></a>18.4.1 C# exception example using "check" typemap</H3>
<p>
@@ -676,7 +956,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute
Actually it will issue this warning for any function beginning with <tt>SWIG_CSharpSetPendingException</tt>.
</P>
-<H3><a name="csharp_exception_example_percent_exception"></a>18.3.2 C# exception example using %exception</H3>
+<H3><a name="csharp_exception_example_percent_exception"></a>18.4.2 C# exception example using %exception</H3>
<p>
@@ -741,7 +1021,7 @@ The managed code generated does check for the pending exception as mentioned ear
</pre>
</div>
-<H3><a name="csharp_exception_example_exception_specifications"></a>18.3.3 C# exception example using exception specifications</H3>
+<H3><a name="csharp_exception_example_exception_specifications"></a>18.4.3 C# exception example using exception specifications</H3>
<p>
@@ -798,7 +1078,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
Multiple catch handlers are generated should there be more than one exception specifications declared.
</p>
-<H3><a name="csharp_custom_application_exception"></a>18.3.4 Custom C# ApplicationException example</H3>
+<H3><a name="csharp_custom_application_exception"></a>18.4.4 Custom C# ApplicationException example</H3>
<p>
@@ -932,7 +1212,7 @@ try {
</pre>
</div>
-<H2><a name="csharp_directors"></a>18.4 C# Directors</H2>
+<H2><a name="csharp_directors"></a>18.5 C# Directors</H2>
<p>
@@ -945,7 +1225,7 @@ The following sections provide information on the C# director implementation and
However, the <a href="Java.html#java_directors">Java directors</a> section should also be read in order to gain more insight into directors.
</p>
-<H3><a name="csharp_directors_example"></a>18.4.1 Directors example</H3>
+<H3><a name="csharp_directors_example"></a>18.5.1 Directors example</H3>
<p>
@@ -1066,7 +1346,7 @@ CSharpDerived - UIntMethod(123)
</pre>
</div>
-<H3><a name="csharp_directors_implementation"></a>18.4.2 Directors implementation</H3>
+<H3><a name="csharp_directors_implementation"></a>18.5.2 Directors implementation</H3>
<p>
@@ -1252,7 +1532,7 @@ void SwigDirector_Base::BaseBoolMethod(Base const &amp;b, bool flag) {
</pre>
</div>
-<H3><a name="csharp_director_caveats"></a>18.4.3 Director caveats</H3>
+<H3><a name="csharp_director_caveats"></a>18.5.3 Director caveats</H3>
<p>
@@ -1300,7 +1580,7 @@ However, a call from C# to <tt>CSharpDefaults.DefaultMethod()</tt> will of cours
should pass the call on to <tt>CSharpDefaults.DefaultMethod(int)</tt>using the C++ default value, as shown above.
</p>
-<H2><a name="csharp_typemap_examples"></a>18.5 C# Typemap examples</H2>
+<H2><a name="csharp_typemap_examples"></a>18.6 C# Typemap examples</H2>
This section includes a few examples of typemaps. For more examples, you
@@ -1308,7 +1588,7 @@ might look at the files "<tt>csharp.swg</tt>" and "<tt>typemaps.i</tt>" in
the SWIG library.
-<H3><a name="csharp_memory_management_member_variables"></a>18.5.1 Memory management when returning references to member variables</H3>
+<H3><a name="csharp_memory_management_member_variables"></a>18.6.1 Memory management when returning references to member variables</H3>
<p>
@@ -1432,7 +1712,7 @@ public class Bike : IDisposable {
Note the <tt>addReference</tt> call.
</p>
-<H3><a name="csharp_memory_management_objects"></a>18.5.2 Memory management for objects passed to the C++ layer</H3>
+<H3><a name="csharp_memory_management_objects"></a>18.6.2 Memory management for objects passed to the C++ layer</H3>
<p>
@@ -1551,7 +1831,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
</div>
-<H3><a name="csharp_date_marshalling"></a>18.5.3 Date marshalling using the csin typemap and associated attributes</H3>
+<H3><a name="csharp_date_marshalling"></a>18.6.3 Date marshalling using the csin typemap and associated attributes</H3>
<p>
@@ -1567,6 +1847,7 @@ Let's assume the code being wrapped is as follows:
<pre>
class CDate {
public:
+ CDate();
CDate(int year, int month, int day);
int getYear();
int getMonth();
@@ -1649,8 +1930,8 @@ The typemaps to achieve this are shown below.
<pre>
%typemap(cstype) const CDate&amp; "System.DateTime"
%typemap(csin,
- pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);")
- const CDate &amp;
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
+ ) const CDate &amp;
"$csclassname.getCPtr(temp$csinput)"
%typemap(cstype) CDate&amp; "out System.DateTime"
@@ -1658,7 +1939,8 @@ The typemaps to achieve this are shown below.
pre=" CDate temp$csinput = new CDate();",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- cshin="out $csinput") CDate &amp;
+ cshin="out $csinput"
+ ) CDate &amp;
"$csclassname.getCPtr(temp$csinput)"
</pre>
@@ -1763,7 +2045,8 @@ will be possible with the following <tt>CDate *</tt> typemaps
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- cshin="ref $csinput") CDate *
+ cshin="ref $csinput"
+ ) CDate *
"$csclassname.getCPtr(temp$csinput)"
</pre>
</div>
@@ -1788,7 +2071,51 @@ public class example {
</pre>
</div>
-<H3><a name="csharp_date_properties"></a>18.5.4 A date example demonstrating marshalling of C# properties</H3>
+<p>
+The following typemap is the same as the previous but demonstrates how a using block can be used for the temporary variable.
+The only change to the previous typemap is the introduction of the 'terminator' attribute to terminate the <tt>using</tt> block.
+The <tt>subtractYears</tt> method is nearly identical to the above <tt>addYears</tt> method.
+</p>
+
+<div class="code">
+<pre>
+%typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+void subtractYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate-&gt;getYear() - years, pDate-&gt;getMonth(), pDate-&gt;getDay());
+}
+</pre>
+</div>
+
+<p>
+The resulting generated code shows the termination of the <tt>using</tt> block:
+</p>
+
+<div class="code">
+<pre>
+public class example {
+ public static void subtractYears(ref System.DateTime pDate, int years) {
+ using (CDate temppDate = new CDate(pDate.Year, pDate.Month, pDate.Day)) {
+ try {
+ examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
+ } finally {
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ }
+ } // terminate temppDate using block
+ }
+ ...
+}
+</pre>
+</div>
+
+<H3><a name="csharp_date_properties"></a>18.6.4 A date example demonstrating marshalling of C# properties</H3>
<p>
@@ -1827,7 +2154,8 @@ The typemap type required is thus <tt>CDate *</tt>. Given that the previous sect
pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
" temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- cshin="ref $csinput") CDate *
+ cshin="ref $csinput"
+ ) CDate *
"$csclassname.getCPtr(temp$csinput)"
%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
@@ -1888,7 +2216,7 @@ Some points to note:
</ul>
-<H3><a name="csharp_partial_classes"></a>18.5.5 Turning wrapped classes into partial classes</H3>
+<H3><a name="csharp_partial_classes"></a>18.6.5 Turning wrapped classes into partial classes</H3>
<p>
@@ -1988,7 +2316,7 @@ demonstrating that the class contains methods calling both unmanaged code - <tt>
The following example is an alternative approach to adding managed code to the generated proxy class.
</p>
-<H3><a name="csharp_extending_proxy_class"></a>18.5.6 Extending proxy classes with additional C# code</H3>
+<H3><a name="csharp_extending_proxy_class"></a>18.6.6 Extending proxy classes with additional C# code</H3>
<p>
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 918af0626..d965e3050 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -272,7 +272,7 @@
<li><a href="Library.html#Library_nn3">C Arrays and Pointers</a>
<ul>
<li><a href="Library.html#Library_nn4">cpointer.i</a>
-<li><a href="Library.html#Library_nn5">carrays.i</a>
+<li><a href="Library.html#Library_carrays">carrays.i</a>
<li><a href="Library.html#Library_nn6">cmalloc.i</a>
<li><a href="Library.html#Library_nn7">cdata.i</a>
</ul>
@@ -390,6 +390,7 @@
<li><a href="Typemaps.html#Typemaps_nn48">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="Typemaps.html#Typemaps_nn49">Reducing wrapper code size</a>
<li><a href="Typemaps.html#Typemaps_nn47">Passing data between typemaps</a>
+<li><a href="Typemaps.html#Typemaps_nn52">C++ "this" pointer</a>
<li><a href="Typemaps.html#Typemaps_nn51">Where to go for more information?</a>
</ul>
</div>
@@ -487,6 +488,7 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
+<li><a href="Modules.html#Modules_introduction">Modules Introduction</a>
<li><a href="Modules.html#Modules_nn1">Basics</a>
<li><a href="Modules.html#Modules_nn2">The SWIG runtime code</a>
<li><a href="Modules.html#external_run_time">External access to the runtime</a>
@@ -497,7 +499,33 @@
</div>
<!-- INDEX -->
-<h3><a href="Allegrocl.html#Allegrocl">16 SWIG and Allegro Common Lisp</a></h3>
+<h3><a href="CCache.html#CCache">16 Using SWIG with ccache - ccache-swig(1) manpage</a></h3>
+
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="CCache.html#CCache_nn2">NAME</a>
+<li><a href="CCache.html#CCache_nn3">SYNOPSIS</a>
+<li><a href="CCache.html#CCache_nn4">DESCRIPTION</a>
+<li><a href="CCache.html#CCache_nn5">OPTIONS SUMMARY</a>
+<li><a href="CCache.html#CCache_nn6">OPTIONS</a>
+<li><a href="CCache.html#CCache_nn7">INSTALLATION</a>
+<li><a href="CCache.html#CCache_nn8">EXTRA OPTIONS</a>
+<li><a href="CCache.html#CCache_nn9">ENVIRONMENT VARIABLES</a>
+<li><a href="CCache.html#CCache_nn10">CACHE SIZE MANAGEMENT</a>
+<li><a href="CCache.html#CCache_nn11">CACHE COMPRESSION</a>
+<li><a href="CCache.html#CCache_nn12">HOW IT WORKS</a>
+<li><a href="CCache.html#CCache_nn13">USING CCACHE WITH DISTCC</a>
+<li><a href="CCache.html#CCache_nn14">SHARING A CACHE</a>
+<li><a href="CCache.html#CCache_nn15">HISTORY</a>
+<li><a href="CCache.html#CCache_nn16">DIFFERENCES FROM COMPILERCACHE</a>
+<li><a href="CCache.html#CCache_nn17">CREDITS</a>
+<li><a href="CCache.html#CCache_nn18">AUTHOR</a>
+</ul>
+</div>
+<!-- INDEX -->
+
+<h3><a href="Allegrocl.html#Allegrocl">17 SWIG and Allegro Common Lisp</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -641,6 +669,12 @@
<ul>
<li><a href="CSharp.html#csharp_introduction">Introduction</a>
<li><a href="CSharp.html#csharp_differences_java">Differences to the Java module</a>
+<li><a href="CSharp.html#CSharp_arrays">C# Arrays</a>
+<ul>
+<li><a href="CSharp.html#CSharp_arrays_swig_library">The SWIG C arrays library</a>
+<li><a href="CSharp.html#CSharp_arrays_pinvoke_default_array_marshalling">Managed arrays using P/Invoke default array marshalling</a>
+<li><a href="CSharp.html#CSharp_arrays_pinning">Managed arrays using pinning</a>
+</ul>
<li><a href="CSharp.html#csharp_exceptions">C# Exceptions</a>
<ul>
<li><a href="CSharp.html#csharp_exception_example_check_typemap">C# exception example using "check" typemap</a>
@@ -934,14 +968,29 @@
<li><a href="Lua.html#Lua_nn20">C++ templates</a>
<li><a href="Lua.html#Lua_nn21">C++ Smart Pointers</a>
<li><a href="Lua.html#Lua_nn22">C++ Exceptions</a>
-<li><a href="Lua.html#Lua_nn23">Writing your own custom wrappers</a>
-<li><a href="Lua.html#Lua_nn24">Adding additional Lua code</a>
</ul>
-<li><a href="Lua.html#Lua_nn25">Details on the Lua binding</a>
+<li><a href="Lua.html#Lua_nn23">Typemaps</a>
<ul>
-<li><a href="Lua.html#Lua_nn26">Binding global data into the module.</a>
-<li><a href="Lua.html#Lua_nn27">Userdata and Metatables</a>
-<li><a href="Lua.html#Lua_nn28">Memory management</a>
+<li><a href="Lua.html#Lua_nn24">What is a typemap?</a>
+<li><a href="Lua.html#Lua_nn25">Using typemaps</a>
+<li><a href="Lua.html#Lua_nn26">Typemaps and arrays</a>
+<li><a href="Lua.html#Lua_nn27">Typemaps and pointer-pointer functions</a>
+</ul>
+<li><a href="Lua.html#Lua_nn28">Writing typemaps</a>
+<ul>
+<li><a href="Lua.html#Lua_nn29">Typemaps you can write</a>
+<li><a href="Lua.html#Lua_nn30">SWIG's Lua-C API</a>
+</ul>
+<li><a href="Lua.html#Lua_nn31">Customization of your Bindings</a>
+<ul>
+<li><a href="Lua.html#Lua_nn32">Writing your own custom wrappers</a>
+<li><a href="Lua.html#Lua_nn33">Adding additional Lua code</a>
+</ul>
+<li><a href="Lua.html#Lua_nn34">Details on the Lua binding</a>
+<ul>
+<li><a href="Lua.html#Lua_nn35">Binding global data into the module.</a>
+<li><a href="Lua.html#Lua_nn36">Userdata and Metatables</a>
+<li><a href="Lua.html#Lua_nn37">Memory management</a>
</ul>
</ul>
</div>
@@ -1246,7 +1295,7 @@
<li><a href="Python.html#Python_nn30">Memory management</a>
<li><a href="Python.html#Python_nn31">Python 2.2 and classic classes</a>
</ul>
-<li><a href="Python.html#directors">Cross language polymorphism</a>
+<li><a href="Python.html#Python_directors">Cross language polymorphism</a>
<ul>
<li><a href="Python.html#Python_nn33">Enabling directors</a>
<li><a href="Python.html#Python_nn34">Director classes</a>
@@ -1301,6 +1350,12 @@
<li><a href="Python.html#Python_nn71">%feature("docstring")</a>
</ul>
<li><a href="Python.html#Python_nn72">Python Packages</a>
+<li><a href="Python.html#Python_python3support">Python 3 Support</a>
+<ul>
+<li><a href="Python.html#Python_nn74">Function annotation</a>
+<li><a href="Python.html#Python_nn75">Buffer interface</a>
+<li><a href="Python.html#Python_nn76">Abstract base classes</a>
+</ul>
</ul>
</div>
<!-- INDEX -->
diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html
index e9d70e39a..ec73e5460 100644
--- a/Doc/Manual/Customization.html
+++ b/Doc/Manual/Customization.html
@@ -1019,6 +1019,20 @@ but this will:
</pre>
</div>
+<p>
+SWIG provides macros for disabling and clearing features. Many of these can be found in the <tt>swig.swg</tt> library file.
+The typical pattern is to define three macros; one to define the feature itself, one to disable the feature and one to clear the feature.
+The three macros below show this for the "except" feature:
+</p>
+
+<div class="code">
+<pre>
+#define %exception %feature("except")
+#define %noexception %feature("except","0")
+#define %clearexception %feature("except","")
+</pre>
+</div>
+
<H3><a name="Customization_features_default_args"></a>11.3.4 Features and default arguments</H3>
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index 617327c9f..73f1a6673 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -232,10 +232,11 @@ of <tt>swig.swg</tt> looks like this:
...
/* Code insertion directives such as %wrapper %{ ... %} */
-#define %init %insert("init")
-#define %wrapper %insert("wrapper")
-#define %header %insert("header")
+#define %begin %insert("begin")
#define %runtime %insert("runtime")
+#define %header %insert("header")
+#define %wrapper %insert("wrapper")
+#define %init %insert("init")
/* Access control directives */
@@ -3114,7 +3115,7 @@ entirely upcased.
<p>
At the end of the new section is the place to put the aforementioned
-nickname kludges (should they be needed). See Perl5 and Php4 for
+nickname kludges (should they be needed). See Perl5 for
examples of what to do. [If this is still unclear after you've read
the code, ping me and I'll expand on this further. --ttn]
</p>
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 491204d1d..099454cf0 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -414,7 +414,8 @@ SWIG_LINK_LIBRARIES(example ${PYTHON_LIBRARIES})
</pre></div>
<p>
The above example will generate native build files such as makefiles, nmake files and Visual Studio projects
-which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.dll (Windows).
+which will invoke SWIG and compile the generated C++ files into _example.so (UNIX) or _example.pyd (Windows).
+For other target languages on Windows a dll, instead of a .pyd file, is usually generated.
</p>
<H2><a name="Introduction_nn12"></a>2.7 Hands off code generation</H2>
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index 21085c803..2cde5ddab 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -254,6 +254,12 @@ It is also possible to change the <a href="SWIG.html#output">output directory </
</p>
<p>
+The module name, specified with <tt>%module</tt>, determines the name of various generated classes as discussed <a href=#module_packages_classes>later</a>.
+Note that the module name does not define a Java package and by default, the generated Java classes do not have a Java package.
+The <tt>-package</tt> option described below can specify a Java package name to use.
+</p>
+
+<p>
The following sections have further practical examples and details on how you might go about
compiling and using the generated files.
</p>
@@ -353,9 +359,9 @@ The name of the module is specified using the <tt>%module</tt> directive or<tt>
To load your shared native library module in Java, simply use Java's <tt>System.loadLibrary</tt> method in a Java class:</p>
<div class="code"><pre>
-// main.java
+// runme.java
-public class main {
+public class runme {
static {
  System.loadLibrary("example");
}
@@ -372,7 +378,7 @@ Compile all the Java files and run:
<div class="code"><pre>
$ javac *.java
-$ java main
+$ java runme
24
$
</pre></div>
@@ -394,12 +400,12 @@ You may get an exception similar to this:
</p>
<div class="code"><pre>
-$ java main
+$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: no example in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1312)
at java.lang.Runtime.loadLibrary0(Runtime.java:749)
at java.lang.System.loadLibrary(System.java:820)
- at main.&lt;clinit&gt;(main.java:5)
+ at runme.&lt;clinit&gt;(runme.java:5)
</pre></div>
<p>
@@ -426,7 +432,7 @@ The following exception is indicative of this:
</p>
<div class="code"><pre>
-$ java main
+$ java runme
Exception in thread "main" java.lang.UnsatisfiedLinkError: libexample.so: undefined
symbol: fact
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
@@ -434,7 +440,7 @@ symbol: fact
at java.lang.ClassLoader.loadLibrary(ClassLoader.java, Compiled Code)
at java.lang.Runtime.loadLibrary0(Runtime.java, Compiled Code)
at java.lang.System.loadLibrary(System.java, Compiled Code)
- at main.&lt;clinit&gt;(main.java:5)
+ at runme.&lt;clinit&gt;(runme.java:5)
$
</pre></div>
@@ -2858,7 +2864,7 @@ and therefore there is no possibility of premature garbage collection. In practi
<p>
The premature garbage collection prevention parameter for proxy classes is generated by default whenever proxy classes are passed by value, reference or with a pointer.
The implementation for this extra parameter generation requires the "jtype" typemap to contain <tt>long</tt> and the "jstype" typemap to contain the name of a proxy class.
-<p>
+</p>
<p>
The additional parameter does impose a slight performance overhead and the parameter generation can be suppressed globally with the <tt>-nopgcpp</tt> commandline option.
@@ -3760,7 +3766,7 @@ will produce a familiar looking Java exception:
Exception in thread "main" java.lang.OutOfMemoryError: Not enough memory
at exampleJNI.malloc(Native Method)
at example.malloc(example.java:16)
- at main.main(main.java:112)
+ at runme.main(runme.java:112)
</pre>
</div>
@@ -3820,7 +3826,9 @@ public:
In the example above, <tt>java.lang.Exception</tt> is a checked exception class and so ought to be declared in the throws clause of <tt>getitem</tt>.
Classes can be specified for adding to the throws clause using <tt>%javaexception(classes)</tt> instead of <tt>%exception</tt>,
where <tt>classes</tt> is a string containing one or more comma separated Java classes.
-The <tt>%nojavaexception</tt> feature is the equivalent to <tt>%noexception</tt> and clears previously declared exception handlers.
+The <tt>%clearjavaexception</tt> feature is the equivalent to <tt>%clearexception</tt> and clears previously declared exception handlers.
+The <tt>%nojavaexception</tt> feature is the equivalent to <tt>%noexception</tt> and disables the exception handler.
+See <a href="Customization.html#Customization_clearing_features">Clearing features</a> for the difference on disabling and clearing features.
</p>
<div class="code">
@@ -5300,6 +5308,9 @@ base (extends) for Java class: empty default
Note that this typemap accepts a <tt>replace</tt> attribute as an optional flag. When set to "1", it will replace/override any C++ base classes
that might have been parsed. If this flag is not specified and there are C++ base classes, then a multiple inheritance warning
is issued and the code in the typemap is ignored.
+The typemap also accepts a <tt>notderived</tt> attribute as an optional flag. When set to "1", it will not apply to classes that
+are derived from a C++ base.
+When used with the SWIGTYPE type, it is useful for giving a common base for all proxy classes, that is, providing a base class that sits in between all proxy classes and the Java base class <tt>Object</tt> for example: <tt>%typemap(javabase, notderived="1") SWIGTYPE "CommonBase"</tt>.
</div>
<p><tt>%typemap(javabody)</tt></p>
@@ -6168,9 +6179,9 @@ When this module is compiled, our wrapped C functions can be used by the followi
</p>
<div class="code"><pre>
-// File main.java
+// File runme.java
-public class main {
+public class runme {
static {
try {
@@ -6196,7 +6207,7 @@ When compiled and run we get:
</p>
<div class="code"><pre>
-$ java main
+$ java runme
argv[0] = Cat
argv[1] = Dog
argv[2] = Cow
@@ -6387,9 +6398,9 @@ The following Java program demonstrates this:
</p>
<div class="code"><pre>
-// File: main.java
+// File: runme.java
-public class main {
+public class runme {
static {
try {
@@ -6414,7 +6425,7 @@ When compiled and run we get:
</p>
<div class="code"><pre>
-$ java main
+$ java runme
1 12.0 340.0
</pre></div>
@@ -6474,7 +6485,7 @@ We get:
<div class="code"><pre>
Ambulance started
java.lang.ClassCastException
- at main.main(main.java:16)
+ at runme.main(runme.java:16)
</pre></div>
<p>
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 586e1ecab..7293f31fe 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -14,7 +14,7 @@
<li><a href="#Library_nn3">C Arrays and Pointers</a>
<ul>
<li><a href="#Library_nn4">cpointer.i</a>
-<li><a href="#Library_nn5">carrays.i</a>
+<li><a href="#Library_carrays">carrays.i</a>
<li><a href="#Library_nn6">cmalloc.i</a>
<li><a href="#Library_nn7">cdata.i</a>
</ul>
@@ -316,7 +316,7 @@ In this example, the function <tt>int_to_uint()</tt> would be used to cast type
<b>Note:</b> When working with simple pointers, typemaps can often be used to provide more seamless operation.
</p>
-<H3><a name="Library_nn5"></a>8.2.2 carrays.i</H3>
+<H3><a name="Library_carrays"></a>8.2.2 carrays.i</H3>
<p>
@@ -419,7 +419,9 @@ delete_doubleArray(a) # Destroy array
</div>
+<p>
<b><tt>%array_class(type,name)</tt></b>
+</p>
<div class="indent">
<p>
diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html
index 14abead00..53cddab83 100644
--- a/Doc/Manual/Lisp.html
+++ b/Doc/Manual/Lisp.html
@@ -583,7 +583,7 @@ using the SWIG <tt>%insert(section) %{ ...code... %}</tt> directive:
<pre>
%module example
-%insert("runtime") %{
+%{
#include "header.h"
%}
@@ -604,7 +604,7 @@ generated lisp interface file:
</ul>
<p>
Note that the block <tt>%{ ... %}</tt> is effectively a shortcut for
-<tt>%insert("runtime") %{ ... %}</tt>.
+<tt>%insert("header") %{ ... %}</tt>.
</p>
diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
index 99c7c9a3c..e66c1c7f3 100644
--- a/Doc/Manual/Lua.html
+++ b/Doc/Manual/Lua.html
@@ -34,14 +34,29 @@
<li><a href="#Lua_nn20">C++ templates</a>
<li><a href="#Lua_nn21">C++ Smart Pointers</a>
<li><a href="#Lua_nn22">C++ Exceptions</a>
-<li><a href="#Lua_nn23">Writing your own custom wrappers</a>
-<li><a href="#Lua_nn24">Adding additional Lua code</a>
</ul>
-<li><a href="#Lua_nn25">Details on the Lua binding</a>
+<li><a href="#Lua_nn23">Typemaps</a>
<ul>
-<li><a href="#Lua_nn26">Binding global data into the module.</a>
-<li><a href="#Lua_nn27">Userdata and Metatables</a>
-<li><a href="#Lua_nn28">Memory management</a>
+<li><a href="#Lua_nn24">What is a typemap?</a>
+<li><a href="#Lua_nn25">Using typemaps</a>
+<li><a href="#Lua_nn26">Typemaps and arrays</a>
+<li><a href="#Lua_nn27">Typemaps and pointer-pointer functions</a>
+</ul>
+<li><a href="#Lua_nn28">Writing typemaps</a>
+<ul>
+<li><a href="#Lua_nn29">Typemaps you can write</a>
+<li><a href="#Lua_nn30">SWIG's Lua-C API</a>
+</ul>
+<li><a href="#Lua_nn31">Customization of your Bindings</a>
+<ul>
+<li><a href="#Lua_nn32">Writing your own custom wrappers</a>
+<li><a href="#Lua_nn33">Adding additional Lua code</a>
+</ul>
+<li><a href="#Lua_nn34">Details on the Lua binding</a>
+<ul>
+<li><a href="#Lua_nn35">Binding global data into the module.</a>
+<li><a href="#Lua_nn36">Userdata and Metatables</a>
+<li><a href="#Lua_nn37">Memory management</a>
</ul>
</ul>
</div>
@@ -1003,8 +1018,9 @@ stack traceback:
</pre></div>
<p>
-SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem.
-However its not so simple for to throw objects.
+SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into and error string. </p>
+<p>
+However its not so simple for to throw other types of objects.
Thrown objects are not valid outside the 'catch' block. Therefore they cannot be
returned to the interpreter.
The obvious ways to overcome this would be to either return a copy of the object, or so convert the object to a string and
@@ -1038,10 +1054,6 @@ To get a more useful behaviour out of SWIG you must either: provide a way to con
throw objects which can be copied.
</p>
<p>
-SWIG has typemaps for std::exception and its children already written, so a function which throws any of these will
-automatically have its exception converted into an error string.
-</p>
-<p>
If you have your own class which you want output as a string you will need to add a typemap something like this:
</p>
<div class="code"><pre>
@@ -1098,7 +1110,271 @@ add exception specification to functions or globally (respectively).
</p>
-<H3><a name="Lua_nn23"></a>23.3.16 Writing your own custom wrappers</H3>
+<H2><a name="Lua_nn23"></a>23.4 Typemaps</H2>
+
+
+<p>This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect</p>
+
+<H3><a name="Lua_nn24"></a>23.4.1 What is a typemap?</H3>
+
+
+<p>A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:</p>
+
+<div class="code"><pre>%module example
+
+%typemap(in) int {
+ $1 = (int) lua_tonumber(L,$input);
+ printf("Received an integer : %d\n",$1);
+}
+%inline %{
+extern int fact(int n);
+%}
+</pre></div>
+
+<p><i>Note: you shouldn't use this typemap, as SWIG already has a typemap for this task. This is purely for example.</i></p>
+
+<p>Typemaps are always associated with some specific aspect of code generation. In this case, the "in" method refers to the conversion of input arguments to C/C++. The datatype int is the datatype to which the typemap will be applied. The supplied C code is used to convert values. In this code a number of special variable prefaced by a $ are used. The $1 variable is placeholder for a local variable of type int. The $input is the index on the Lua stack for the value to be used.</p>
+
+<p>When this example is compiled into a Lua module, it operates as follows:</p>
+
+<div class="targetlang"><pre>&gt; require "example"
+&gt; print(example.fact(6))
+Received an integer : 6
+720
+</pre></div>
+
+<H3><a name="Lua_nn25"></a>23.4.2 Using typemaps</H3>
+
+
+<p>There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.</p>
+
+<p>However for more complex functions which use input/output parameters or arrays, you will need to make use of &lt;typemaps.i&gt;, which contains typemaps for these situations. For example, consider these functions:</p>
+
+<div class="code"><pre>void add(int x, int y, int *result) {
+ *result = x + y;
+}
+
+int sub(int *x1, int *y1) {
+ return *x1-*y1;
+}
+
+void swap(int *sx, int *sy) {
+ int t=*sx;
+ *sx=*sy;
+ *sy=t;
+}
+</pre></div>
+
+<p>It is clear to the programmer, that 'result' is an output parameter, 'x1' and 'y1' are input parameters and 'sx' and 'sy' are input/output parameters. However is not apparent to SWIG, so SWIG must to informed about which kind they are, so it can wrapper accordingly.</p>
+
+<p>One means would be to rename the argument name to help SWIG, eg <tt>void add(int x, int y, int *OUTPUT)</tt>, however it is easier to use the <tt>%apply</tt> to achieve the same result, as shown below.</p>
+
+<div class="code"><pre>%include &lt;typemaps.i&gt;
+%apply int* OUTPUT {int *result}; // int *result is output
+%apply int* INPUT {int *x1, int *y1}; // int *x1 and int *y1 are input
+%apply int* INOUT {int *sx, int *sy}; // int *sx and int *sy are input and output
+
+void add(int x, int y, int *result);
+int sub(int *x1, int *y1);
+void swap(int *sx, int *sy);
+</pre></div>
+
+<p>When wrapped, it gives the following results:</p>
+
+<div class="targetlang"><pre>&gt; require "example"
+&gt; print(example.add(1,2))
+3
+&gt; print(demo.sub(1,2))
+-1
+&gt; a,b=1,2
+&gt; c,d=demo.swap(a,b)
+&gt; print(a,b,c,d)
+1 2 2 1
+</pre></div>
+
+<p>Notice, that 'result' is not required in the arguments to call the function, as it an output parameter only. For 'sx' and 'sy' they must be passed in (as they are input), but the original value is not modified (Lua does not have a pass by reference feature). The modified results are then returned as two return values. All INPUT/OUTPUT/INOUT arguments will behave in a similar manner.</p>
+
+<p>Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a <tt>const int&amp;</tt> as an input parameter (since that it obviously input).</p>
+
+<H3><a name="Lua_nn26"></a>23.4.3 Typemaps and arrays</H3>
+
+
+<p>Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
+does SWIG have any indication of how large an array should be. However with the proper guidance SWIG can easily wrapper
+arrays for convenient usage.</p>
+
+<p>Given the functions:</p>
+<div class="code"><pre>extern void sort_int(int* arr, int len);
+extern void sort_double(double* arr, int len);
+</pre></div>
+
+<p>There are basically two ways that SWIG can deal with this. The first way, uses the <tt>&lt;carrays.i&gt;</tt> library
+to create an array in C/C++ then this can be filled within Lua and passed into the function. It works, but its a bit tedious.
+More details can be found in the <a href="Library.html#Library_nn5">carrays.i</a> documention.</p>
+
+<p>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 <tt>&lt;typemaps.i&gt;</tt> file there are typemaps ready written to perform this task. To use them is again a matter of using %appy in the correct manner.</p>
+
+<p>The wrapper file below, shows both the use of carrays as well as the use of the typemap to wrap arrays. </p>
+
+<div class="code"><pre>// using the C-array
+%include &lt;carrays.i&gt;
+// this declares a batch of function for manipulating C integer arrays
+%array_functions(int,int)
+
+extern void sort_int(int* arr, int len); // the function to wrap
+
+// using typemaps
+%include &lt;typemaps.i&gt;
+%apply (double *INOUT,int) {(double* arr,int len)};
+
+extern void sort_double(double* arr, int len); // the function to wrap
+</pre></div>
+
+<p>Once wrappered, the functions can both be called, though with different ease of use:</p>
+
+<div class="targetlang"><pre>require "example"
+ARRAY_SIZE=10
+
+-- passing a C array to the sort_int()
+arr=example.new_int(ARRAY_SIZE) -- create the array
+for i=0,ARRAY_SIZE-1 do -- index 0..9 (just like C)
+ example.int_setitem(arr,i,math.random(1000))
+end
+example.sort_int(arr,ARRAY_SIZE) -- call the function
+example.delete_int(arr) -- must delete the allocated memory
+
+-- use a typemap to call with a Lua-table
+-- one item of note: the typemap creates a copy, rather than edit-in-place
+t={} -- a Lua table
+for i=1,ARRAY_SIZE do -- index 1..10 (Lua style)
+ t[i]=math.random(1000)/10
+end
+t=example.sort_double(t) -- replace t with the result
+</pre></div>
+
+<p>Obviously the first version could be made less tedious by writing a Lua function to perform the conversion from a table
+to a C-array. The <tt>%luacode</tt> directive is good for this. See SWIG\Examples\lua\arrays for an example of this.</p>
+
+<p><b>Warning:</b> in C indexes start at ZERO, in Lua indexes start at ONE. SWIG expects C-arrays to be filled for 0..N-1
+and Lua tables to be 1..N, (the indexing follows the norm for the language). In the typemap when it converts the table to an array it quietly changes the indexing accordingly. Take note of this behaviour if you have a C function which returns indexes.</p>
+
+<p>Note: SWIG also can support arrays of pointers in a similar manner.</p>
+
+<H3><a name="Lua_nn27"></a>23.4.4 Typemaps and pointer-pointer functions</H3>
+
+
+<p>Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:</p>
+
+<div class="code"><pre>struct iMath; // some structure
+int Create_Math(iMath** pptr); // its creator (assume it mallocs)
+</pre></div>
+
+<p>Which would be used with the following C code:</p>
+
+<div class="code"><pre>iMath* ptr;
+int ok;
+ok=Create_Math(&amp;ptr);
+// do things with ptr
+//...
+free(ptr); // dispose of iMath
+</pre></div>
+
+<p>SWIG has a ready written typemap to deal with such a kind of function in &lt;typemaps.i&gt;. It provides the correct wrappering as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:</p>
+
+<div class="code"><pre>%include &lt;typemaps.i&gt;
+%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
+
+struct iMath; // some structure
+int Create_Math(iMath** pptr); // its creator (assume it mallocs)
+</pre></div>
+
+<p>The usage is as follows:</p>
+
+<div class="targetlang"><pre>ok,ptr=Create_Math() -- ptr is a iMath* which is returned with the int (ok)
+ptr=nil -- the iMath* will be GC'ed as normal
+</pre></div>
+
+<H2><a name="Lua_nn28"></a>23.5 Writing typemaps</H2>
+
+
+<p>This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the <tt>%typemap</tt> directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter.</p>
+
+<p>Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrappering, or to achieve an effect which in not available with the default bindings.</p>
+
+<p>Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).</p>
+
+<H3><a name="Lua_nn29"></a>23.5.1 Typemaps you can write</H3>
+
+
+<p>There are many different types of typemap that can be written, the full list can be found in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter. However the following are the most commonly used ones.</p>
+
+<ul>
+<li><tt>in</tt> this is for input arguments to functions</li>
+<li><tt>out</tt> this is for return types from functions</li>
+<li><tt>argout</tt> this is for a function argument which is actually returning something</li>
+<li><tt>typecheck</tt> this is used to determine which overloaded function should be called
+(the syntax for the typecheck is different from the typemap, see typemaps for details).</li>
+</ul>
+
+<H3><a name="Lua_nn30"></a>23.5.2 SWIG's Lua-C API</H3>
+
+
+<p>This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.</p>
+
+<p><tt>int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);</tt></p>
+
+<div class="indent">
+This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the neccesary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer.
+If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.<br>
+The returns a value which can be checked with the macro SWIG_IsOK()
+</div>
+
+<p><tt>void SWIG_NewPointerObj(lua_State* L,void* ptr,swig_type_info *type,int own);</tt></p>
+
+<div class="indent">
+This is the opposite of SWIG_ConvertPtr, as it pushes a new userdata which wrappers the pointer 'ptr' of type 'type'.
+The parameter 'own' specifies if the object is owned be Lua and if it is 1 then Lua will GC the object when the userdata is disposed of.
+</div>
+
+<p><tt>void* SWIG_MustGetPtr(lua_State* L,int index,swig_type_info *type,int flags,int argnum,const char* func_name);</tt></p>
+
+<div class="indent">
+This function is a version of SWIG_ConvertPtr(), except that it will either work, or it will trigger a lua_error() with a text error message. This function is rarely used, and may be deprecated in the future.
+</div>
+
+<p><tt>SWIG_fail</tt></p>
+
+<div class="indent">
+This macro, when called within the context of a SWIG wrappered function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.<br>
+A common use for this code is:<br><pre>
+if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
+ lua_pushstring(L,"something bad happened");
+ SWIG_fail;
+}</pre></div>
+
+<p><tt>SWIG_fail_arg(char* func_name,int argnum,char* type)</tt></p>
+
+<div class="indent">
+This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form
+<pre>
+"Error in <i>func_name</i> (arg <i>argnum</i>), expected '<i>type</i>' got '<i>whatever the type was</i>'"
+</pre></div>
+
+<p><tt>SWIG_fail_ptr(const char* fn_name,int argnum,swig_type_info* type);</tt></p>
+
+<div class="indent">
+Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.</div>
+
+<H2><a name="Lua_nn31"></a>23.6 Customization of your Bindings</H2>
+
+
+<p>
+This section covers adding of some small extra bits to your module to add the last finishing touches.
+</p>
+
+
+
+<H3><a name="Lua_nn32"></a>23.6.1 Writing your own custom wrappers</H3>
<p>
@@ -1117,7 +1393,7 @@ int native_function(lua_State*L) // my native code
The <tt>%native</tt> directive in the above example, tells SWIG that there is a function <tt>int native_function(lua_State*L);</tt> which is to be added into the module under the name '<tt>my_func</tt>'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
</p>
-<H3><a name="Lua_nn24"></a>23.3.17 Adding additional Lua code</H3>
+<H3><a name="Lua_nn33"></a>23.6.2 Adding additional Lua code</H3>
<p>
@@ -1155,7 +1431,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
</p>
-<H2><a name="Lua_nn25"></a>23.4 Details on the Lua binding</H2>
+<H2><a name="Lua_nn34"></a>23.7 Details on the Lua binding</H2>
<p>
@@ -1166,7 +1442,7 @@ See Examples/lua/arrays for an example of this code.
</i>
</p>
-<H3><a name="Lua_nn26"></a>23.4.1 Binding global data into the module.</H3>
+<H3><a name="Lua_nn35"></a>23.7.1 Binding global data into the module.</H3>
<p>
@@ -1226,7 +1502,7 @@ end
<p>
That way when you call '<tt>a=example.Foo</tt>', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code '<tt>example.Foo=10</tt>', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
</p>
-<H3><a name="Lua_nn27"></a>23.4.2 Userdata and Metatables</H3>
+<H3><a name="Lua_nn36"></a>23.7.2 Userdata and Metatables</H3>
<p>
@@ -1306,7 +1582,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
<p>
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' &amp; '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
</p>
-<H3><a name="Lua_nn28"></a>23.4.3 Memory management</H3>
+<H3><a name="Lua_nn37"></a>23.7.3 Memory management</H3>
<p>
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 1923c2c48..4c907791b 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -18,15 +18,19 @@ HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Cont
all: maketoc check generate
-maketoc:
+maketoc: CCache.html
python maketoc.py
+CCache.html: ../../CCache/ccache.yo
+ yodl2html -o CCache.html ../../CCache/ccache.yo
+
# Use htmltidy to warn about some HTML errors. Note that it is not used to clean/tidy the HTML,
# it is just used as a primitive HTML checker.
+# CCache.html is generated by yodl2html and has a few insignificant problems, so we don't put it through tidy
check:
tidy -errors --gnu-emacs yes -quiet index.html
tidy -errors --gnu-emacs yes -quiet Sections.html
- all=`sed '/^#/d' chapters`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
+ all=`sed '/^#/d' chapters | grep -v CCache.html`; for a in $$all; do tidy -errors --gnu-emacs yes -quiet $$a; done;
generate: swightml.book swigpdf.book
htmldoc --batch swightml.book || true
@@ -45,11 +49,14 @@ swightml.book:
echo "Sections.html" >> swightml.book
cat chapters >> swightml.book
-clean:
+clean: clean-baks
rm -f swightml.book
rm -f swigpdf.book
+ rm -f CCache.html
rm -f SWIGDocumentation.html
rm -f SWIGDocumentation.pdf
+
+clean-baks:
rm -f *.bak
test:
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index 7a6bacd34..c4e485202 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -860,8 +860,8 @@ that split the task up into converting
the C bit patterns (integer or bit set)
into Modula-3 bit patterns (integer or bit set)
and change the type as requested.
-See the corresponding
-<a href="../../Examples/modula3/enum/example.i">example</a>.
+See the corresponding example in the
+Examples/modula3/enum/example.i file.
This is quite messy and not satisfying.
So the best what you can currently do is
to rewrite constant definitions manually.
@@ -877,8 +877,8 @@ that I'd like to automate.
Declarations of C++ classes are mapped to <tt>OBJECT</tt> types
while it is tried to retain the access hierarchy
"public - protected - private" using partial revelation.
-Though the
-<a href="../../Examples/modula3/class/example.i">implementation</a>
+Though the example in
+Examples/modula3/class/example.i
is not really useful, yet.
</p>
diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
index 8971324fb..1b628f802 100644
--- a/Doc/Manual/Modules.html
+++ b/Doc/Manual/Modules.html
@@ -10,6 +10,7 @@
<!-- INDEX -->
<div class="sectiontoc">
<ul>
+<li><a href="#Modules_introduction">Modules Introduction</a>
<li><a href="#Modules_nn1">Basics</a>
<li><a href="#Modules_nn2">The SWIG runtime code</a>
<li><a href="#external_run_time">External access to the runtime</a>
@@ -22,11 +23,49 @@
+<H2><a name="Modules_introduction"></a>15.1 Modules Introduction</H2>
+
+
+<p>
+Each invocation of SWIG requires a module name to be specified.
+The module name is used to name the resulting target language extension module.
+Exactly what this means and and what the name is used for
+depends on the target language, for example the name can define
+a target language namespace or merely be a useful name for naming files or helper classes.
+Essentially, a module comprises target language wrappers for a chosen collection of global variables/functions, structs/classes and other C/C++ types.
+</p>
+
+<p>
+The module name can be supplied in one of two ways.
+The first is to specify it with the special <tt>%module</tt>
+directive. This directive must appear at the beginning of the interface file.
+The general form of this directive is:
+</p>
+
+<div class="code"><pre>
+<tt>%module(option1="value1",option2="value2",...) modulename</tt>
+</pre></div>
+
+<p>
+where the modulename is mandatory and the options add one or more optional additional features.
+Typically no options are specified, for example:
+</p>
+
+<div class="code"><pre>
+<tt>%module mymodule</tt>
+</pre></div>
+
+<p>
+The second way to specify the module name is with the <tt>-module</tt> command line option, for example <tt>-module mymodule</tt>.
+If the module name is supplied on the command line, it overrides the name specified by the
+<tt>%module</tt> directive.
+</p>
+
<p>
When first working with SWIG, users commonly start by creating a
single module. That is, you might define a single SWIG interface that
wraps some set of C/C++ code. You then compile all of the generated
-wrapper code into a module and use it. For large applications, however,
+wrapper code together and use it. For large applications, however,
this approach is problematic---the size of the generated wrapper code
can be rather large. Moreover, it is probably easier to manage the
target language interface when it is broken up into smaller pieces.
@@ -34,10 +73,11 @@ target language interface when it is broken up into smaller pieces.
<p>
This chapter describes the problem of using SWIG in programs
-where you want to create a collection of modules.
+where you want to create a collection of modules.
+Each module in the collection is created via separate invocations of SWIG.
</p>
-<H2><a name="Modules_nn1"></a>15.1 Basics</H2>
+<H2><a name="Modules_nn1"></a>15.2 Basics</H2>
<p>
@@ -50,43 +90,92 @@ scripting language runtime as you would do for the single module case.
<p>
A bit more complex is the case in which modules need to share information.
-For example, when one module extends the class of the another by deriving from
+For example, when one module extends the class of another by deriving from
it:
</p>
<div class="code"><pre>
-%module base
-
-%inline %{
+// File: base.h
class base {
public:
- int foo(void);
+ int foo();
};
+</pre></div>
+&nbsp;
+
+<div class="code"><pre>
+// File: base_module.i
+%module base_module
+
+%{
+#include "base.h"
%}
+%include "base.h"
</pre></div>
&nbsp;
+
<div class="code"><pre>
-%module derived
+// File: derived_module.i
+%module derived_module
-%import "base.i"
+%import "base_module.i"
%inline %{
class derived : public base {
public:
- int bar(void);
+ int bar();
};
%}
</pre></div>
-<p>To create the wrapper properly, module <tt>derived</tt> needs to know the
-<tt>base</tt> class and that it's interface is covered in another module. The
-line <tt>%import "base.i"</tt> lets SWIG know exactly that. The common mistake here is
-to <tt>%import</tt> the <tt>.h</tt> file instead of the <tt>.i</tt>, which sadly won't do the trick. Another issue
-to take care of is that multiple dependent wrappers should not be linked/loaded
+<p>To create the wrapper properly, module <tt>derived_module</tt> needs to know about the
+<tt>base</tt> class and that its interface is covered in another module. The
+line <tt>%import "base_module.i"</tt> lets SWIG know exactly that. Oftentimes
+the <tt>.h</tt> file is passed to <tt>%import</tt> instead of the <tt>.i</tt>,
+which unfortunately doesn't work for all language modules. For example, Python requires the
+name of module that the base class exists in so that the proxy classes can fully inherit the
+base class's methods. Typically you will get a warning when the module name is missing, eg:
+</p>
+
+<div class="shell"> <pre>
+derived_module.i:8: Warning(401): Base class 'base' ignored - unknown module name for base. Either import
+the appropriate module interface file or specify the name of the module in the %import directive.
+</pre></div>
+
+<p>
+It is sometimes desirable to import the header file rather than the interface file and overcome
+the above warning.
+For example in the case of the imported interface being quite large, it may be desirable to
+simplify matters and just import a small header file of dependent types.
+This can be done by specifying the optional <tt>module</tt> attribute in the <tt>%import</tt> directive.
+The <tt>derived_module.i</tt> file shown above could be replaced with the following:
+
+<div class="code"><pre>
+// File: derived_module.i
+%module derived_module
+
+%import(module="base_module") "base.h"
+
+%inline %{
+class derived : public base {
+public:
+ int bar();
+};
+</pre></div>
+
+<p>
+Note that "base_module" is the module name and is the same as that specified in <tt>%module</tt>
+in <tt>base_module.i</tt> as well as the <tt>%import</tt> in <tt>derived_module.i</tt>.
+</p>
+
+<p>
+Another issue
+to beware of is that multiple dependent wrappers should not be linked/loaded
in parallel from multiple threads as SWIG provides no locking - for more on that
-issue, read on.</p>
+issue, read on.
+</p>
-<H2><a name="Modules_nn2"></a>15.2 The SWIG runtime code</H2>
+<H2><a name="Modules_nn2"></a>15.3 The SWIG runtime code</H2>
<p>
@@ -152,7 +241,7 @@ can peacefully coexist. So the type structures are separated by the
is empty. Only modules compiled with the same pair will share type information.
</p>
-<H2><a name="external_run_time"></a>15.3 External access to the runtime</H2>
+<H2><a name="external_run_time"></a>15.4 External access to the runtime</H2>
<p>As described in <a href="Typemaps.html#runtime_type_checker">The run-time type checker</a>,
@@ -189,7 +278,7 @@ SWIG_TYPE_TABLE to be the same as the module whose types you are trying to
access.
</p>
-<H2><a name="Modules_nn4"></a>15.4 A word of caution about static libraries</H2>
+<H2><a name="Modules_nn4"></a>15.5 A word of caution about static libraries</H2>
<p>
@@ -200,7 +289,7 @@ into it. This is very often <b>NOT</b> what you want and it can lead to unexpect
behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libraries.
</p>
-<H2><a name="Modules_nn5"></a>15.5 References</H2>
+<H2><a name="Modules_nn5"></a>15.6 References</H2>
<p>
@@ -208,7 +297,7 @@ Due to the complexity of working with shared libraries and multiple modules, it
an outside reference. John Levine's "Linkers and Loaders" is highly recommended.
</p>
-<H2><a name="Modules_nn6"></a>15.6 Reducing the wrapper file size</H2>
+<H2><a name="Modules_nn6"></a>15.7 Reducing the wrapper file size</H2>
<p>
diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html
index 6dbf24c11..b65831192 100644
--- a/Doc/Manual/Ocaml.html
+++ b/Doc/Manual/Ocaml.html
@@ -634,13 +634,13 @@ length. Instead, use multiple returns, as in the argout_ref example.
#include "example.h"
%}
-%include stl.i
+%include &lt;stl.i&gt;
namespace std {
%template(StringVector) std::vector &lt; string &gt;;
};
-%include example.h
+%include "example.h"
</pre></td></tr>
<tr><td><font size="-1"><i>This example is in Examples/ocaml/stl
</i></font></td></tr>
diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html
index 1dc8e7d2f..f77dc2f01 100644
--- a/Doc/Manual/Perl5.html
+++ b/Doc/Manual/Perl5.html
@@ -264,7 +264,7 @@ extern int fact(int);
%}
// Include code for rebuilding Perl
-%include perlmain.i
+%include &lt;perlmain.i&gt;
</pre></div>
<p>
@@ -1543,7 +1543,7 @@ example:
<div class="code">
<pre>
%module example
-%include typemaps.i
+%include "typemaps.i"
void add(int x, int y, int *REFERENCE);
</pre>
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index e0f1e200a..ab2c73f6c 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -413,7 +413,7 @@ Overloaded Functions and Methods</a>.
<!-- This isn't correct for 1.3.30 and needs rewriting to reflect reality
<p>
-Because PHP4 is a dynamically typed language, simple values can be
+Because PHP is a dynamically typed language, simple values can be
silently converted from one type to another. For example, integers,
doubles and strings silently convert to each other depending on
context. This situation make overloading slightly problematic because
@@ -433,7 +433,7 @@ PHP. The string <tt>"2"</tt> simultaneously represents the integer
<p>
In order to provide the most natural experience to PHP programmers,
-the default <tt>%typecheck</tt> implemented in <tt>php4.swg</tt>
+the default <tt>%typecheck</tt> implemented in <tt>php.swg</tt>
allows any simple type (integer, double, string) in PHP to be used for
any simple C type (int, double, char *). The function selected then
depends only on the argument type precedence defined by SWIG.
@@ -479,7 +479,7 @@ One can include <b>cpointer.i</b> to generate PHP wrappers to <tt>int
<div class="code"><pre>
%module example
-%include cpointer.i
+%include "cpointer.i"
%pointer_functions(int,intp)
void add( int *in1, int *in2, int *result);
@@ -513,7 +513,7 @@ parameter names as appropriate.
<div class="code"><pre>
%module example
-%include typemaps.i
+%include "typemaps.i"
void add( int *INPUT, int *INPUT, int *OUTPUT);
@@ -545,7 +545,7 @@ named typemap REFERENCE.
<div class="code"><pre>
%module example
-%include phppointers.i
+%include "phppointers.i"
void add( int *REF, int *REF, int *REF);
@@ -782,12 +782,6 @@ Ko::threats();
<p>
-Note: Currently pragmas for PHP need to be specified using
-<tt>%pragma(php4)</tt> but also apply for PHP5! This is just a historical
-oddity because SWIG's PHP support predates PHP5.
-</p>
-
-<p>
To place PHP code in the generated "example.php" file one can use the
<b>code</b> pragma. The code is inserted after loading the shared
object.
@@ -795,7 +789,7 @@ object.
<div class="code"><pre>
%module example
-%pragma(php4) code="
+%pragma(php) code="
# This code is inserted into example.php
echo \"example.php execution\\n\";
"
@@ -817,7 +811,7 @@ the example.php file.
<div class="code"><pre>
%module example
-%pragma(php4) code="
+%pragma(php) code="
include \"include.php\";
"
%pragma(php) include="include.php" // equivalent.
@@ -831,7 +825,7 @@ phpinfo() function.
<div class="code"><pre>
%module example;
-%pragma(php4) phpinfo="
+%pragma(php) phpinfo="
zend_printf("An example of PHP support through SWIG\n");
php_info_print_table_start();
php_info_print_table_header(2, \"Directive\", \"Value\");
diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
index a454c8124..5afa59243 100644
--- a/Doc/Manual/Preprocessor.html
+++ b/Doc/Manual/Preprocessor.html
@@ -81,7 +81,7 @@ Such information generally includes type declarations (e.g., <tt>typedef</tt>) a
C++ classes that might be used as base-classes for class declarations in the interface.
The use of <tt>%import</tt> is also important when SWIG is used to generate
extensions as a collection of related modules. This is an advanced topic and is described
-in a later chapter.
+in later in the <a href="Modules.html">Working with Modules</a> chapter.
</p>
<P>
@@ -107,7 +107,10 @@ SWIGWIN Defined when running SWIG under Windows
SWIG_VERSION Hexadecimal number containing SWIG version,
such as 0x010311 (corresponding to SWIG-1.3.11).
+SWIGALLEGROCL Defined when using Allegro CL
+SWIGCFFI Defined when using CFFI
SWIGCHICKEN Defined when using CHICKEN
+SWIGCLISP Defined when using CLISP
SWIGCSHARP Defined when using C#
SWIGGUILE Defined when using Guile
SWIGJAVA Defined when using Java
@@ -115,17 +118,15 @@ SWIGLUA Defined when using Lua
SWIGMODULA3 Defined when using Modula-3
SWIGMZSCHEME Defined when using Mzscheme
SWIGOCAML Defined when using Ocaml
+SWIGOCTAVE Defined when using Octave
SWIGPERL Defined when using Perl
-SWIGPERL5 Defined when using Perl5
SWIGPHP Defined when using PHP
-SWIGPHP4 Defined when using PHP4
-SWIGPHP5 Defined when using PHP5
SWIGPIKE Defined when using Pike
SWIGPYTHON Defined when using Python
+SWIGR Defined when using R
SWIGRUBY Defined when using Ruby
SWIGSEXP Defined when using S-expressions
SWIGTCL Defined when using Tcl
-SWIGTCL8 Defined when using Tcl8.0
SWIGXML Defined when using XML
</pre></div>
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 5a8653597..cfc035f00 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -46,7 +46,7 @@
<li><a href="#Python_nn30">Memory management</a>
<li><a href="#Python_nn31">Python 2.2 and classic classes</a>
</ul>
-<li><a href="#directors">Cross language polymorphism</a>
+<li><a href="#Python_directors">Cross language polymorphism</a>
<ul>
<li><a href="#Python_nn33">Enabling directors</a>
<li><a href="#Python_nn34">Director classes</a>
@@ -101,6 +101,12 @@
<li><a href="#Python_nn71">%feature("docstring")</a>
</ul>
<li><a href="#Python_nn72">Python Packages</a>
+<li><a href="#Python_python3support">Python 3 Support</a>
+<ul>
+<li><a href="#Python_nn74">Function annotation</a>
+<li><a href="#Python_nn75">Buffer interface</a>
+<li><a href="#Python_nn76">Abstract base classes</a>
+</ul>
</ul>
</div>
<!-- INDEX -->
@@ -113,9 +119,9 @@
<p>
This chapter describes SWIG's support of Python. SWIG is compatible
-with most recent Python versions including Python 2.2 as well as older
-versions dating back to Python 1.5.2. For the best results, consider using Python
-2.0 or newer.
+with most recent Python versions including Python 3.0 and Python 2.6,
+as well as older versions dating back to Python 2.0. For the best results,
+consider using Python 2.3 or newer.
</p>
<p>
@@ -427,7 +433,7 @@ extern int mod(int, int);
extern double My_variable;
%}
-%include embed.i // Include code for a static version of Python
+%include "embed.i" // Include code for a static version of Python
</pre></div>
@@ -2544,7 +2550,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
</p>
-<H2><a name="directors"></a>31.5 Cross language polymorphism</H2>
+<H2><a name="Python_directors"></a>31.5 Cross language polymorphism</H2>
<p>
@@ -4929,7 +4935,7 @@ with more than one line.
<p>
Using the <tt>package</tt> option of the <tt>%module</tt> directive
allows you to specify what Python package that the module will be
-living in when installed.
+living in when installed.
</p>
<div class="code">
@@ -4950,6 +4956,256 @@ and also in base class declarations, etc. if the package name is
different than its own.
</p>
+<H2><a name="Python_python3support"></a>31.12 Python 3 Support</H2>
+
+
+<p>
+SWIG is able to support Python 3.0. The wrapper code generated by
+SWIG can be compiled with both Python 2.x or 3.0. Further more, by
+passing the <tt>-py3</tt> command line option to SWIG, wrapper code
+with some Python 3 specific features can be generated (see below
+subsections for details of these features). The <tt>-py3</tt> option also
+disables some incompatible features for Python 3, such as
+<tt>-classic</tt>.
+
+<p>
+There is a list of known-to-be-broken features in Python 3:
+</p>
+<ul>
+ <li>No more support for FILE* typemaps, because PyFile_AsFile has been dropped
+ in Python 3.</li>
+ <li>The <tt>-apply</tt> command line option is removed and generating
+ code using apply() is no longer supported.</li>
+</ul>
+
+<p>
+The following are Python 3.0 new features that are currently supported by
+SWIG.
+</p>
+
+<H3><a name="Python_nn74"></a>31.12.1 Function annotation</H3>
+
+
+<p>
+The <tt>-py3</tt> option will enable function annotation support. When used
+SWIG is able to generate proxy method definitions like this:
+</p>
+
+<div class="code"><pre>
+ def foo(self, bar : "int" = 0) -&gt; "void" : ...
+</pre></div>
+
+<p>
+Also, even if without passing SWIG the <tt>-py3</tt> option, the parameter list
+still could be generated:
+</p>
+
+<div class="code"><pre>
+ def foo(self, bar = 0): ...
+</pre></div>
+
+<p>
+But for overloaded function or method, the parameter list would fallback to
+<tt>*args</tt> or <tt>self, *args</tt>, and <tt>**kwargs</tt> may be append
+depend on whether you enabled the keyword argument. This fallback is due to
+all overloaded functions share the same function in SWIG generated proxy class.
+</p>
+
+<p>
+For detailed usage of function annotation, see PEP 3107.
+</p>
+
+<H3><a name="Python_nn75"></a>31.12.2 Buffer interface</H3>
+
+
+<p>
+Buffer protocols were revised in Python 3. SWIG also gains a series of
+new typemaps to support buffer interfaces. These typemap macros are
+defined in <tt>pybuffer.i</tt>, which must be included in order to use them.
+By using these typemaps, your wrapped function will be able to
+accept any Python object that exposes a suitable buffer interface.
+</p>
+
+<p>
+For example, the <tt>get_path()</tt> function puts the path string
+into the memory pointed to by its argument:
+</p>
+
+<div class="code"><pre>
+void get_path(char *s);
+</pre></div>
+
+<p>
+Then you can write a typemap like this: (the following example is
+applied to both Python 3.0 and 2.6, since the <tt>bytearray</tt> type
+is backported to 2.6.
+</p>
+
+
+<div class="code"><pre>
+%include &lt;pybuffer.i&gt;
+%pybuffer_mutable_string(char *str);
+void get_path(char *s);
+</pre></div>
+
+<p>
+And then on the Python side the wrapped <tt>get_path</tt> could be used in this
+way:
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; p = bytearray(10)
+&gt;&gt;&gt; get_path(p)
+&gt;&gt;&gt; print(p)
+bytearray(b'/Foo/Bar/\x00')
+</pre></div>
+
+<p>
+The macros defined in <tt>pybuffer.i</tt> are similar to those in
+<tt>cstring.i</tt>:
+</p>
+
+<p>
+<b>%pybuffer_mutable_binary(parm, size_parm)</b>
+</p>
+
+<div class="indent">
+
+<p>
+The macro can be used to generate a typemap which maps a buffer of an
+object to a pointer provided by <tt>parm</tt> and a size argument
+provided by <tt>size_parm</tt>. For example:
+</p>
+
+<div class="code"><pre>
+%pybuffer_mutable_binary(char *str, size_t size);
+...
+int snprintf(char *str, size_t size, const char *format, ...);
+</pre></div>
+
+<p>
+In Python:
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; buf = bytearray(6)
+&gt;&gt;&gt; snprintf(buf, "Hello world!")
+&gt;&gt;&gt; print(buf)
+bytearray(b'Hello\x00')
+&gt;&gt;&gt;
+</pre></div>
+
+</div>
+
+<p>
+<b>%pybuffer_mutable_string(parm)</b>
+</p>
+
+<div class="indent">
+
+<p>
+This typemap macro requires the buffer to be a zero terminated string,
+and maps the pointer of the buffer to <tt>parm</tt>. For example:
+</p>
+
+<div class="code"><pre>
+%pybuffer_mutable_string(char *str);
+...
+size_t make_upper(char *str);
+</pre></div>
+
+<p>
+In Python:
+</p>
+
+<div class="targetlang"><pre>
+&gt;&gt;&gt; buf = bytearray(b'foo\x00')
+&gt;&gt;&gt; make_upper(buf)
+&gt;&gt;&gt; print(buf)
+bytearray(b'FOO\x00')
+&gt;&gt;&gt;
+</pre></div>
+
+<p>
+Both <tt>%pybuffer_mutable_binary</tt> and <tt>%pybuffer_mutable_string</tt>
+require the provided buffer to be mutable, eg. they can accept a
+<tt>bytearray</tt> type but can't accept an immutable <tt>byte</tt>
+type.
+</p>
+
+</div>
+
+<p>
+<b>%pybuffer_binary(parm, size_parm)</b>
+</p>
+
+<div class="indent">
+
+<p>
+This macro maps an object's buffer to a pointer <tt>parm</tt> and a
+size <tt>size_parm</tt>. It is similar to
+<tt>%pybuffer_mutable_binary</tt>, except the
+<tt>%pybuffer_binary</tt> an accept both mutable and immutable
+buffers. As a result, the wrapped function should not modify the buffer.
+</p>
+
+</div>
+
+<p>
+<b>%pybuffer_string(parm)</b>
+</p>
+
+<div class="indent">
+
+<p>
+This macro maps an object's buffer as a string pointer <tt>parm</tt>.
+It is similar to <tt>%pybuffer_mutable_string</tt> but the buffer
+could be both mutable and immutable. And your function should not
+modify the buffer.
+</p>
+
+</div>
+
+
+<H3><a name="Python_nn76"></a>31.12.3 Abstract base classes</H3>
+
+
+<p>
+By including <tt>pyabc.i</tt> and using the <tt>-py3</tt> command
+line option when calling SWIG, the proxy classes of the STL containers
+will automatically gain an appropriate abstract base class. For
+example, the following SWIG interface:
+</p>
+
+<div class="code"><pre>
+%include &lt;pyabc.i&gt;
+%include &lt;std_map.i&gt;
+%include &lt;std_list.i&gt;
+
+namespace std {
+ %template(Mapii) map&lt;int, int&gt;;
+ %template(IntList) list&lt;int&gt;;
+}
+</pre></div>
+
+<p>
+will generate a Python proxy class <tt>Mapii</tt> inheriting from
+<tt>collections.MutableMap</tt> and a proxy class <tt>IntList</tt>
+inheriting from <tt>collections.MutableSequence</tt>.
+</p>
+
+<p>
+<tt>pyabc.i</tt> also provides a macro <tt>%pythonabc</tt> that could be
+used to define an abstract base class for your own C++ class:
+</p>
+
+<div class="code"><pre>
+%pythonabc(MySet, collections.MutableSet);
+</pre></div>
+
+<p>
+For details of abstract base class, please see PEP 3119.
+</p>
</body>
</html>
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index 7360f732d..98fa315d0 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -2393,7 +2393,7 @@ intset;<br>
-%include std_set.i<br>
+%include &lt;std_set.i&gt;<br>
@@ -10567,7 +10567,7 @@ existing Ruby object to the destroyed C++ object and raise an exception.<br>
<div class="code">
-<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Specify that ownership is transferred to the zoo<br> when calling add_animal */<br>%apply SWIGTYPE *DISOWN { Animal* animal };<br><br>/* Track objects */<br>%trackobjects;<br><br>/* Specify the mark function */<br>%freefunc Zoo "free_Zoo";<br><br>%include "example.h"<br><br>%header %{<br> static void free_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each animal */<br> int count = zoo-&gt;get_num_animals();<br><br> for(int i = 0; i &lt; count; ++i) {<br> /* Get an animal */<br> Animal* animal = zoo-&gt;get_animal(i);<br><br> /* Unlink the Ruby object from the C++ object */<br> SWIG_RubyUnlinkObjects(animal);<br><br> /* Now remove the tracking for this animal */<br> SWIG_RubyRemoveTracking(animal);<br> }<br><br> /* Now call SWIG_RemoveMapping for the zoo */<br> SWIG_RemoveMapping(ptr);<br> <br> /* Now free the zoo which will free the animals it contains */<br> delete zoo;<br> }<br>%} </pre>
+<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Specify that ownership is transferred to the zoo<br> when calling add_animal */<br>%apply SWIGTYPE *DISOWN { Animal* animal };<br><br>/* Track objects */<br>%trackobjects;<br><br>/* Specify the mark function */<br>%freefunc Zoo "free_Zoo";<br><br>%include "example.h"<br><br>%header %{<br> static void free_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each animal */<br> int count = zoo-&gt;get_num_animals();<br><br> for(int i = 0; i &lt; count; ++i) {<br> /* Get an animal */<br> Animal* animal = zoo-&gt;get_animal(i);<br><br> /* Unlink the Ruby object from the C++ object */<br> SWIG_RubyUnlinkObjects(animal);<br><br> /* Now remove the tracking for this animal */<br> SWIG_RubyRemoveTracking(animal);<br> }<br><br> /* Now call SWIG_RubyRemoveTracking for the zoo */<br> SWIG_RubyRemoveTracking(ptr);<br> <br> /* Now free the zoo which will free the animals it contains */<br> delete zoo;<br> }<br>%} </pre>
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index c1ffcff60..1bdc6b4d0 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -120,8 +120,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
-mzscheme Generate Mzscheme wrappers
-ocaml Generate Ocaml wrappers
-perl Generate Perl wrappers
--php4 Generate PHP4 wrappers
--php5 Generate PHP5 wrappers
+-php Generate PHP wrappers
-pike Generate Pike wrappers
-python Generate Python wrappers
-r Generate R (aka GNU S) wrappers
@@ -140,6 +139,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
-l<em>file</em> Include a SWIG library file.
-module <em>name</em> Set the name of the SWIG module
-o <em>outfile</em> Name of output file
+-outcurrentdir Set default output dir to current dir instead of input file's path
-outdir <em>dir</em> Set language specific files output directory
-swiglib Show location of SWIG library
-version Show SWIG version number
@@ -174,13 +174,8 @@ int bar(int x);
...
</pre></div>
<p>
-The name of the module is supplied using the special <tt>%module</tt>
-directive (or the <tt>-module</tt> command line option). This
-directive must appear at the beginning of the file and is used to name
-the resulting extension module (in addition, this name often defines
-a namespace in the target language). If the module name is supplied on the
-command line, it overrides the name specified with the
-<tt>%module</tt> directive.
+The module name is supplied using the special <tt>%module</tt>
+directive. Modules are described further in the <a href="Modules.html#Modules_introduction">Modules Introduction</a> section.
</p>
<p>
@@ -247,6 +242,17 @@ cppfiles/example_wrap.cpp
pyfiles/example.py
</pre></div>
+<p>
+If the <tt>-outcurrentdir</tt> option is used (without <tt>-o</tt>)
+then SWIG behaves like a typical C/C++
+compiler and the default output directory is then the current directory. Without
+this option the default output directory is the path to the input file.
+If <tt>-o</tt> and
+<tt>-outcurrentdir</tt> are used together, <tt>-outcurrentdir</tt> is effectively ignored
+as the output directory for the language files is the same directory as the
+generated C/C++ file if not overidden with <tt>-outdir</tt>.
+</p>
+
<H3><a name="SWIG_nn5"></a>5.1.3 Comments</H3>
@@ -2350,7 +2356,7 @@ You can make a <tt>Vector</tt> look a lot like a class by writing a SWIG interfa
#include "vector.h"
%}
-%include vector.h // Just grab original C header file
+%include "vector.h" // Just grab original C header file
%extend Vector { // Attach these functions to struct Vector
Vector(double x, double y, double z) {
Vector *v;
@@ -2726,11 +2732,16 @@ the module upon loading.
<p>
Code is inserted into the appropriate code section by using one
-of the following code insertion directives:
+of the code insertion directives listed below. The order of the sections in
+the wrapper file is as shown:
</p>
<div class="code">
<pre>
+%begin %{
+ ... code in begin section ...
+%}
+
%runtime %{
... code in runtime section ...
%}
@@ -2751,10 +2762,12 @@ of the following code insertion directives:
<p>
The bare <tt>%{ ... %}</tt> directive is a shortcut that is the same as
-<tt>%header %{ ... %}</tt>.
+<tt>%header %{ ... %}</tt>.
</p>
<p>
+The <tt>%begin</tt> section is effectively empty as it just contains the SWIG banner by default.
+This section is provided as a way for users to insert code at the top of the wrapper file before any other code is generated.
Everything in a code insertion block is copied verbatim into the output file and is
not parsed by SWIG. Most SWIG input files have at least one such block to include header
files and support C code. Additional code blocks may be placed anywhere in a
@@ -2865,10 +2878,16 @@ interface to your program.
SWIG's <tt>%include</tt> directive to process an entire C
source/header file.
-<li>Make sure everything in the interface file uses ANSI C/C++syntax.
+<li>Make sure everything in the interface file uses ANSI C/C++ syntax.
<li>Make sure all necessary `<tt>typedef</tt>' declarations and
-type-information is available in the interface file.
+type-information is available in the interface file.
+In particular, ensure that the type information is specified in the correct order as required by a C/C++ compiler.
+Most importantly, define a type before it is used! A C compiler will tell you
+if the full type information is not available if it is needed, whereas
+SWIG will usually not warn or error out as it is designed to work without
+full type information. However, if type information is not specified
+correctly, the wrappers can be sub-optimal and even result in uncompileable C/C++ code.
<li>If your program has a main() function, you may need to rename it
(read on).
@@ -2927,16 +2946,21 @@ extern void dump(FILE *f);
<p>
Of course, in this case, our header file is pretty simple so we could
-have made an interface file like this as well:</p>
+use a simpler approach and use an interface file like this:</p>
<div class="code"><pre>
/* File : interface.i */
%module mymodule
-%include header.h
+%{
+#include "header.h"
+%}
+%include "header.h"
</pre></div>
<p>
-Naturally, your mileage may vary.</p>
+The main advantage of this approach is minimal maintenance of an interface file for when the header file changes in the future.
+In more complex projects, an interface file containing numerous <tt>%include</tt> and <tt>#include</tt> statements like this is one of the most common approaches to interface file design due to lower maintenance overhead.
+</p>
<H3><a name="SWIG_nn48"></a>5.7.3 Why use separate interface files?</H3>
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 5406f44ea..789efc129 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-1.3 Development Documentation</H1>
-Last update : SWIG-1.3.37 (in progress)
+Last update : SWIG-1.3.40 (in progress)
<H2>Sections</H2>
@@ -35,6 +35,7 @@ to help!).
<li><a href="Varargs.html#Varargs">Variable length arguments</a></li>
<li><a href="Warnings.html#Warnings">Warning messages</a></li>
<li><a href="Modules.html#Modules">Working with Modules</a></li>
+<li><a href="CCache.html#CCache">Using SWIG with ccache</a></li>
</ul>
<H3>Language Module Documentation</H3>
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index b36395cab..04959de5f 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -190,7 +190,7 @@ extern int mod(int, int);
extern double My_variable;
%}
-%include tclsh.i // Include code for rebuilding tclsh
+%include "tclsh.i" // Include code for rebuilding tclsh
</pre></div>
@@ -2822,7 +2822,7 @@ int print_args(char **argv) {
return i;
}
%}
-%include tclsh.i
+%include "tclsh.i"
</pre></div>
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 8f3035dc8..777184069 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -75,6 +75,7 @@
<li><a href="#Typemaps_nn48">More about <tt>%apply</tt> and <tt>%clear</tt></a>
<li><a href="#Typemaps_nn49">Reducing wrapper code size</a>
<li><a href="#Typemaps_nn47">Passing data between typemaps</a>
+<li><a href="#Typemaps_nn52">C++ "this" pointer</a>
<li><a href="#Typemaps_nn51">Where to go for more information?</a>
</ul>
</div>
@@ -3899,7 +3900,66 @@ sure that the typemaps sharing information have exactly the same types and names
</p>
-<H2><a name="Typemaps_nn51"></a>10.15 Where to go for more information?</H2>
+<H2><a name="Typemaps_nn52"></a>10.15 C++ "this" pointer</H2>
+
+
+<p>
+All the rules discussed for Typemaps apply to C++ as well as C.
+However in addition C++ passes an extra parameter into every
+non-static class method -- the <tt>this</tt> pointer. Occasionally it can be
+useful to apply a typemap to this pointer (for example to check
+and make sure <tt>this</tt> is non-null before deferencing).
+Actually, C also has an the equivalent of the <tt>this</tt> pointer which is used
+when accessing variables in a C struct.
+</p>
+<p>
+In order to customise the <tt>this</tt> pointer handling, target a variable named <tt>self</tt> in your typemaps.
+<tt>self</tt> is the name SWIG uses to refer to the extra parameter in wrapped functions.
+</p>
+<p>
+For example, if wrapping for Java generation:
+</p>
+
+<div class="code">
+<pre>
+%typemap(check) SWIGTYPE *self %{
+if (!$1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "swigCPtr null");
+ return $null;
+}
+%}
+</pre>
+</div>
+
+<p>
+In the above case, the <tt>$1</tt> variable is expanded into the argument
+name that SWIG is using as the <tt>this</tt> pointer.
+
+SWIG will then insert the check code before the actual C++ class method
+is called, and will raise an exception rather than crash
+the Java virtual machine.
+
+The generated code will look something like:
+</p>
+
+<div class="code">
+<pre>
+ if (!arg1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException,
+ "invalid native object; delete() likely already called");
+ return ;
+ }
+ (arg1)->wrappedFunction(...);
+</pre>
+</div>
+
+<p>
+Note that if you have a parameter named <tt>self</tt> then it
+will also match the typemap. One work around is to create an interface file that wraps
+the method, but give the argument a name other than <tt>self</tt>.
+</p>
+
+<H2><a name="Typemaps_nn51"></a>10.16 Where to go for more information?</H2>
<p>
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 0b3cb37e9..95af1ec6b 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -558,7 +558,7 @@ example.i(4): Syntax error in input.
</ul>
<ul>
-<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in Php4. (Php).
+<li>870. Warning for <em>classname</em>: Base <em>baseclass</em> ignored. Multiple inheritance is not supported in PHP.
<li>871. Unrecognized pragma <em>pragma</em>. (Php).
</ul>
diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html
index 8a718ffad..bc8c8fa51 100644
--- a/Doc/Manual/Windows.html
+++ b/Doc/Manual/Windows.html
@@ -281,7 +281,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
</li>
<li>
- Copy the followig to the MSYS install folder (C:\msys\1.0 is default):
+ Copy the following to the MSYS install folder (C:\msys\1.0 is default):
<ul>
<li>msys-automake-1.8.2.tar.bz2</li>
<li>msys-autoconf-2.59.tar.bz2</li>
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 66c7caa19..062dbe231 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -13,6 +13,7 @@ Contract.html
Varargs.html
Warnings.html
Modules.html
+CCache.html
Allegrocl.html
COM.html
CSharp.html
diff --git a/Doc/Manual/swig16.png b/Doc/Manual/swig16.png
index 73f3adc3e..73f3adc3e 100755..100644
--- a/Doc/Manual/swig16.png
+++ b/Doc/Manual/swig16.png
Binary files differ
diff --git a/Doc/README b/Doc/README
index 110428199..f7a493933 100644
--- a/Doc/README
+++ b/Doc/README
@@ -2,4 +2,5 @@ Doc/Manual - Latest version of the SWIG user manual
Doc/Devel - Developer documentation concerning SWIG internals.
(not necessarily up to date)
- \ No newline at end of file
+Open the index.html file in each of these directories with a web browser.
+
diff --git a/Examples/GIFPlot/Java/full/README b/Examples/GIFPlot/Java/full/README
index f536864de..93463ea30 100644
--- a/Examples/GIFPlot/Java/full/README
+++ b/Examples/GIFPlot/Java/full/README
@@ -1,8 +1,8 @@
This example runs the entire gifplot.h header file through SWIG without
-any changes. The program 'main.java' does something a little more
-interesting. After doing a make, run it using 'java main'. You'll have to go
+any changes. The program 'runme.java' does something a little more
+interesting. After doing a make, run it using 'java runme'. You'll have to go
look at the header file to get a complete listing of the functions.
-Note the differences in the main.java files between this example and the
+Note the differences in the runme.java files between this example and the
'full' example. This example does not use shadow classes.
diff --git a/Examples/GIFPlot/Java/full/main.java b/Examples/GIFPlot/Java/full/runme.java
index 8fb65c86d..c47c1e672 100644
--- a/Examples/GIFPlot/Java/full/main.java
+++ b/Examples/GIFPlot/Java/full/runme.java
@@ -1,7 +1,7 @@
// Plot a 3D function
import java.lang.Math;
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/GIFPlot/Java/shadow/Makefile b/Examples/GIFPlot/Java/shadow/Makefile
index e513b9b5a..8062c2700 100644
--- a/Examples/GIFPlot/Java/shadow/Makefile
+++ b/Examples/GIFPlot/Java/shadow/Makefile
@@ -1,8 +1,9 @@
TOP = ../../..
SWIG = $(TOP)/../swig
-SWIGOPT = -I../../Interface
+SWIGOPT = -outcurrentdir
SRCS =
TARGET = gifplot
+INTERFACEDIR = ../../Interface/
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
INCLUDES = -I../../Include
@@ -10,7 +11,7 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' java
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' java
javac *.java
clean::
diff --git a/Examples/GIFPlot/Java/shadow/README b/Examples/GIFPlot/Java/shadow/README
index 4adbde306..b06c5a8f1 100644
--- a/Examples/GIFPlot/Java/shadow/README
+++ b/Examples/GIFPlot/Java/shadow/README
@@ -1,5 +1,5 @@
This example uses the file in ../../Interface/gifplot.i to build
-an interface with shadow classes. After doing a make, run the program main, ie: 'java main'.
+an interface with shadow classes. After doing a make, run the program runme, ie: 'java runme'.
-Note the differences in the main.java files between this example and the
+Note the differences in the runme.java files between this example and the
'full' example. This example uses the shadow classes.
diff --git a/Examples/GIFPlot/Java/shadow/main.java b/Examples/GIFPlot/Java/shadow/runme.java
index fbcf6e792..91db03898 100644
--- a/Examples/GIFPlot/Java/shadow/main.java
+++ b/Examples/GIFPlot/Java/shadow/runme.java
@@ -2,7 +2,7 @@
import java.lang.Math;
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/GIFPlot/Java/simple/README b/Examples/GIFPlot/Java/simple/README
index 1fb8453f0..13ff49611 100644
--- a/Examples/GIFPlot/Java/simple/README
+++ b/Examples/GIFPlot/Java/simple/README
@@ -1,5 +1,5 @@
This is a very minimalistic example in which just a few functions
and constants from library are wrapped and used to draw some simple
-shapes. After doing a make, run the java program, ie 'java main'.
+shapes. After doing a make, run the java program, ie 'java runme'.
diff --git a/Examples/GIFPlot/Java/simple/main.java b/Examples/GIFPlot/Java/simple/runme.java
index b165a4baa..2d8d2bb48 100644
--- a/Examples/GIFPlot/Java/simple/main.java
+++ b/Examples/GIFPlot/Java/simple/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/GIFPlot/Lib/color.c b/Examples/GIFPlot/Lib/color.c
index a4eaf285e..7d79baca9 100644
--- a/Examples/GIFPlot/Lib/color.c
+++ b/Examples/GIFPlot/Lib/color.c
@@ -132,7 +132,10 @@ int ColorMap_write(ColorMap *cm, char *filename) {
f = fopen(filename,"w");
- fwrite(cm->cmap,768,1,f);
+ if (fwrite(cm->cmap,768,1,f) != 1) {
+ fclose(f);
+ return -1;
+ }
fclose(f);
return 0;
}
diff --git a/Examples/GIFPlot/Lib/gif.c b/Examples/GIFPlot/Lib/gif.c
index a0cfca1d5..7953e5ce9 100644
--- a/Examples/GIFPlot/Lib/gif.c
+++ b/Examples/GIFPlot/Lib/gif.c
@@ -268,7 +268,7 @@ static int maxmaxcode = 1 << GP_BITS; /* NEVER generate this */
static count_int *htab;
static unsigned short *codetab;
-static GIFOutBufSize;
+static int GIFOutBufSize;
/* static count_int htab [HSIZE];
static unsigned short codetab [HSIZE]; */
@@ -656,7 +656,11 @@ int FrameBuffer_writeGIF(FrameBuffer *f, ColorMap *c, char *filename) {
fclose(file);
return -1;
}
- fwrite(buffer,nbytes,1,file);
+ if (fwrite(buffer,nbytes,1,file) != 1) {
+ free(buffer);
+ fclose(file);
+ return -1;
+ }
fclose(file);
free(buffer);
return 0;
diff --git a/Examples/GIFPlot/Perl5/shadow/Makefile b/Examples/GIFPlot/Perl5/shadow/Makefile
index c5cb7aec4..c39eac52c 100644
--- a/Examples/GIFPlot/Perl5/shadow/Makefile
+++ b/Examples/GIFPlot/Perl5/shadow/Makefile
@@ -1,8 +1,9 @@
TOP = ../../..
SWIG = $(TOP)/../swig
-SWIGOPT = -I../../Interface
+SWIGOPT = -outcurrentdir
SRCS =
TARGET = gifplot
+INTERFACEDIR = ../../Interface/
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot -lm
INCLUDES = -I../../Include
@@ -10,12 +11,12 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' perl5
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='myperl' INTERFACE='$(INTERFACE)' perl5_static
+ TARGET='myperl' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' perl5_static
clean::
$(MAKE) -f $(TOP)/Makefile perl5_clean
diff --git a/Examples/GIFPlot/Php4/check.list b/Examples/GIFPlot/Php/check.list
index e75ee586a..e75ee586a 100644
--- a/Examples/GIFPlot/Php4/check.list
+++ b/Examples/GIFPlot/Php/check.list
diff --git a/Examples/GIFPlot/Php4/full/Makefile b/Examples/GIFPlot/Php/full/Makefile
index 3aa632b99..e33e7a730 100644
--- a/Examples/GIFPlot/Php4/full/Makefile
+++ b/Examples/GIFPlot/Php/full/Makefile
@@ -10,10 +10,10 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f *.gif
rm -f php_gifplot.h
diff --git a/Examples/GIFPlot/Php4/full/README b/Examples/GIFPlot/Php/full/README
index f8d38d9af..f8d38d9af 100644
--- a/Examples/GIFPlot/Php4/full/README
+++ b/Examples/GIFPlot/Php/full/README
diff --git a/Examples/GIFPlot/Php4/full/cmap b/Examples/GIFPlot/Php/full/cmap
index a20c331a9..a20c331a9 100644
--- a/Examples/GIFPlot/Php4/full/cmap
+++ b/Examples/GIFPlot/Php/full/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Php4/full/gifplot.i b/Examples/GIFPlot/Php/full/gifplot.i
index 5a7f5008f..5a7f5008f 100644
--- a/Examples/GIFPlot/Php4/full/gifplot.i
+++ b/Examples/GIFPlot/Php/full/gifplot.i
diff --git a/Examples/GIFPlot/Php4/full/runme.php4 b/Examples/GIFPlot/Php/full/runme.php
index de5371ee8..de5371ee8 100644
--- a/Examples/GIFPlot/Php4/full/runme.php4
+++ b/Examples/GIFPlot/Php/full/runme.php
diff --git a/Examples/GIFPlot/Php4/shadow/Makefile b/Examples/GIFPlot/Php/shadow/Makefile
index 5627e53a0..df8ee30c0 100644
--- a/Examples/GIFPlot/Php4/shadow/Makefile
+++ b/Examples/GIFPlot/Php/shadow/Makefile
@@ -10,10 +10,10 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f *.gif
check: all
diff --git a/Examples/GIFPlot/Php4/shadow/README b/Examples/GIFPlot/Php/shadow/README
index 3e91f7d59..3e91f7d59 100644
--- a/Examples/GIFPlot/Php4/shadow/README
+++ b/Examples/GIFPlot/Php/shadow/README
diff --git a/Examples/GIFPlot/Php4/shadow/cmap b/Examples/GIFPlot/Php/shadow/cmap
index a20c331a9..a20c331a9 100644
--- a/Examples/GIFPlot/Php4/shadow/cmap
+++ b/Examples/GIFPlot/Php/shadow/cmap
Binary files differ
diff --git a/Examples/GIFPlot/Php4/shadow/runme.php4 b/Examples/GIFPlot/Php/shadow/runme.php
index 3dffba050..3dffba050 100644
--- a/Examples/GIFPlot/Php4/shadow/runme.php4
+++ b/Examples/GIFPlot/Php/shadow/runme.php
diff --git a/Examples/GIFPlot/Php4/simple/Makefile b/Examples/GIFPlot/Php/simple/Makefile
index 6903bec0b..e60b641fa 100644
--- a/Examples/GIFPlot/Php4/simple/Makefile
+++ b/Examples/GIFPlot/Php/simple/Makefile
@@ -10,10 +10,10 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php4
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' php
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f *.gif
rm -f php_simple.h
diff --git a/Examples/GIFPlot/Php4/simple/README b/Examples/GIFPlot/Php/simple/README
index c2c799a70..c2c799a70 100644
--- a/Examples/GIFPlot/Php4/simple/README
+++ b/Examples/GIFPlot/Php/simple/README
diff --git a/Examples/GIFPlot/Php4/simple/runme.php4 b/Examples/GIFPlot/Php/simple/runme.php
index cf21a0927..cf21a0927 100644
--- a/Examples/GIFPlot/Php4/simple/runme.php4
+++ b/Examples/GIFPlot/Php/simple/runme.php
diff --git a/Examples/GIFPlot/Php4/simple/simple.i b/Examples/GIFPlot/Php/simple/simple.i
index 457bc4c09..457bc4c09 100644
--- a/Examples/GIFPlot/Php4/simple/simple.i
+++ b/Examples/GIFPlot/Php/simple/simple.i
diff --git a/Examples/GIFPlot/Python/full/Makefile b/Examples/GIFPlot/Python/full/Makefile
index ae927b72b..83a7c864b 100644
--- a/Examples/GIFPlot/Python/full/Makefile
+++ b/Examples/GIFPlot/Python/full/Makefile
@@ -1,5 +1,5 @@
TOP = ../../..
-SWIG = $(TOP)/../swig
+SWIG = $(TOP)/../preinst-swig
SWIGOPT = -I../../Include
SRCS =
TARGET = gifplot
@@ -23,3 +23,4 @@ clean::
rm -f *.gif
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/GIFPlot/Python/shadow/Makefile b/Examples/GIFPlot/Python/shadow/Makefile
index 1f5014895..3ae9a9897 100644
--- a/Examples/GIFPlot/Python/shadow/Makefile
+++ b/Examples/GIFPlot/Python/shadow/Makefile
@@ -1,8 +1,9 @@
TOP = ../../..
-SWIG = $(TOP)/../swig
-SWIGOPT = -I../../Interface
+SWIG = $(TOP)/../preinst-swig
+SWIGOPT = -outcurrentdir
SRCS =
TARGET = gifplot
+INTERFACEDIR = ../../Interface/
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
INCLUDES = -I../../Include
@@ -10,12 +11,12 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' python
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='mypython' INTERFACE='$(INTERFACE)' python_static
+ TARGET='mypython' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' python_static
clean::
$(MAKE) -f $(TOP)/Makefile python_clean
@@ -23,3 +24,4 @@ clean::
rm -f *.gif
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/GIFPlot/Python/simple/Makefile b/Examples/GIFPlot/Python/simple/Makefile
index 5eb0344e8..9fc9a6c72 100644
--- a/Examples/GIFPlot/Python/simple/Makefile
+++ b/Examples/GIFPlot/Python/simple/Makefile
@@ -1,5 +1,5 @@
TOP = ../../..
-SWIG = $(TOP)/../swig
+SWIG = $(TOP)/../preinst-swig
SWIGOPT =
SRCS =
TARGET = simple
@@ -23,3 +23,4 @@ clean::
rm -f *.gif
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/GIFPlot/Ruby/shadow/Makefile b/Examples/GIFPlot/Ruby/shadow/Makefile
index ea382ea88..8cbea2a57 100644
--- a/Examples/GIFPlot/Ruby/shadow/Makefile
+++ b/Examples/GIFPlot/Ruby/shadow/Makefile
@@ -1,8 +1,9 @@
TOP = ../../..
SWIG = $(TOP)/../swig
-SWIGOPT = -I../../Interface
+SWIGOPT = -outcurrentdir
SRCS =
TARGET = gifplot
+INTERFACEDIR = ../../Interface/
INTERFACE = gifplot.i
LIBS = -L../.. -lgifplot
INCLUDES = -I../../Include
@@ -10,12 +11,12 @@ INCLUDES = -I../../Include
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' ruby
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
INCLUDES='$(INCLUDES)' LIBS='$(LIBS)' SWIGOPT='$(SWIGOPT)' \
- TARGET='myruby' INTERFACE='$(INTERFACE)' ruby_static
+ TARGET='myruby' INTERFACE='$(INTERFACE)' INTERFACEDIR='$(INTERFACEDIR)' ruby_static
clean::
$(MAKE) -f $(TOP)/Makefile ruby_clean
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 317d2ffff..e3f05b7b8 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -12,11 +12,11 @@
# certain packages have been installed. Set the prefixes
# accordingly.
#
-# 2. To use this makefile, simply set SRCS, INTERFACE, INCLUDES, LIBS,
-# TARGET, and do a
+# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE,
+# INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a
# $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \
# INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \
-# TARGET='$(TARGET)' method
+# INTERFACEDIR='$(INTERFACEDIR)' TARGET='$(TARGET)' method
#
# 'method' describes what is being built.
#---------------------------------------------------------------
@@ -31,6 +31,8 @@ SRCS =
INCLUDES =
LIBS =
INTERFACE =
+INTERFACEDIR =
+INTERFACEPATH = $(INTERFACEDIR)$(INTERFACE)
SWIGOPT =
SWIG = swig
@@ -105,12 +107,12 @@ TCLCXXSHARED = @TCLCXXSHARED@
tclsh: $(SRCS)
- $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE)
+ $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
$(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
tclsh_cpp: $(SRCS)
- $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACE)
+ $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -ltclsh.i $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(TCL_LIB) $(TCL_OPTS) $(LIBS) $(SYSLIBS) -o $(TARGET)
@@ -119,13 +121,13 @@ tclsh_cpp: $(SRCS)
# -----------------------------------------------------------
wish: $(SRCS)
- $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE)
+ $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH)
$(CC) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET)
wish_cpp: $(SRCS)
- $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACE)
+ $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) -lwish.i $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE) \
$(XINCLUDE) $(TCL_LIB) $(TK_OPTS) $(XLIB) $(LIBS) $(SYSLIBS) -o $(TARGET)
@@ -134,7 +136,7 @@ wish_cpp: $(SRCS)
# -----------------------------------------------------------
tcl: $(SRCS)
- $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE)
+ $(SWIG) -tcl8 $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(TCL_INCLUDE)
$(TCLLDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
@@ -143,7 +145,7 @@ tcl: $(SRCS)
# -----------------------------------------------------------
tcl_cpp: $(SRCS)
- $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACE)
+ $(SWIG) -tcl8 -c++ $(SWIGOPT) $(TCL_SWIGOPTS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(TCL_INCLUDE)
$(TCLCXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(TCL_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(TCL_SO)
@@ -175,7 +177,7 @@ PERL5_CCFLAGS = @PERL5CCFLAGS@
# ----------------------------------------------------------------
perl5: $(SRCS)
- $(SWIG) -perl5 $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -perl5 $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c -Dbool=char $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -184,7 +186,7 @@ perl5: $(SRCS)
# ----------------------------------------------------------------
perl5_cpp: $(SRCS)
- $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -perl5 -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PERL5_CCFLAGS) -I$(PERL5_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PERL5_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -202,11 +204,11 @@ perl5_xs: $(SRCS)
PERL5_LIB = -L$(PERL5_INCLUDE) -l@PERL5LIB@ @LIBS@ $(SYSLIBS)
perl5_static: $(SRCS)
- $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -perl5 -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) -Dbool=char $(SRCS) $(ISRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
perl5_static_cpp: $(SRCS)
- $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -perl5 -c++ -static -lperlmain.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) -I$(PERL5_INCLUDE) $(PERL5_LIB) $(LIBS) -o $(TARGET)
# -----------------------------------------------------------------
@@ -223,19 +225,39 @@ perl5_clean:
##################################################################
# Make sure these locate your Python installation
-PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@
-PYTHON_LIB = @PYLIB@
-
-# Extra Python specific dynamic linking options
-PYTHON_DLNK = @PYTHONDYNAMICLINKING@
+ifeq (,$(PY3))
+ PYTHON_INCLUDE= $(DEFS) @PYINCLUDE@
+ PYTHON_LIB = @PYLIB@
+ PYTHON = @PYTHON@
+else
+ PYTHON_INCLUDE= $(DEFS) @PY3INCLUDE@
+ PYTHON_LIB = @PY3LIB@
+ PYTHON = @PYTHON3@
+endif
+
+# Extra Python specific linking options
+ifeq (,$(PY3))
+ PYTHON_DLNK = @PYTHONDYNAMICLINKING@
+ PYTHON_LINK = @PYLINK@
+else
+ PYTHON_DLNK = @PYTHON3DYNAMICLINKING@
+ PYTHON_LINK = @PY3LINK@
+endif
PYTHON_SO = @PYTHON_SO@
+# SWIG option for Python
+ifeq (,$(PY3))
+ SWIGPYTHON = $(SWIG) -python
+else
+ SWIGPYTHON = $(SWIG) -python -py3
+endif
+
# ----------------------------------------------------------------
# Build a C dynamically loadable module
# ----------------------------------------------------------------
python: $(SRCS)
- $(SWIG) -python $(SWIGOPT) $(INTERFACE)
+ $(SWIGPYTHON) $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
@@ -244,7 +266,7 @@ python: $(SRCS)
# -----------------------------------------------------------------
python_cpp: $(SRCS)
- $(SWIG) -c++ -python $(SWIGOPT) $(INTERFACE)
+ $(SWIGPYTHON) -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PYTHON_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PYTHON_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)_$(TARGET)$(PYTHON_SO)
@@ -257,18 +279,37 @@ python_cpp: $(SRCS)
#TKINTER = -L/usr/X11R6.3/lib -L/usr/local/compat/lib -ltk4.0 -ltcl7.4 -lX11
TKINTER =
-PYTHON_LIBOPTS = @PYLINK@ @LIBS@ $(TKINTER) $(SYSLIBS)
+PYTHON_LIBOPTS = $(PYTHON_LINK) @LIBS@ $(TKINTER) $(SYSLIBS)
python_static: $(SRCS)
- $(SWIG) -python -lembed.i $(SWIGOPT) $(INTERFACE)
+ $(SWIGPYTHON) -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
python_static_cpp: $(SRCS)
- $(SWIG) -c++ -python -lembed.i $(SWIGOPT) $(INTERFACE)
+ $(SWIGPYTHON) -c++ -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
+# -----------------------------------------------------------------
+# Running a Python example
+# -----------------------------------------------------------------
+
+ifeq (,$(PY3))
+ PYSCRIPT = runme.py
+else
+ PYSCRIPT = runme3.py
+endif
+
+PY2TO3 = 2to3 `2to3 -l | grep -v -E "Available|import$$" | awk '{print "-f "$$0}'`
+
+python_run: $(PYSCRIPT)
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT) >/dev/null
+
+runme3.py: runme.py
+ cp $< $@
+ $(PY2TO3) -w $@ >/dev/null 2>&1
+
# -----------------------------------------------------------------
# Cleaning the python examples
# -----------------------------------------------------------------
@@ -277,6 +318,8 @@ python_clean:
rm -f *_wrap* *~ .~* mypython@EXEEXT@ *.pyc
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@ *@PYTHON_SO@
+ if [ -f runme.py ]; then (rm -f runme3.py runme3.py.bak;) fi;
+
##################################################################
##### OCTAVE ######
@@ -295,7 +338,7 @@ OCTAVE_SO = @OCTAVE_SO@
# ----------------------------------------------------------------
octave: $(SRCS)
- $(SWIG) -octave $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -octave $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
$(CC) -g -c $(CCSHARED) $(CFLAGS) $(SRCS) $(INCLUDES) $(OCTAVE_INCLUDE)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
@@ -305,7 +348,7 @@ octave: $(SRCS)
# -----------------------------------------------------------------
octave_cpp: $(SRCS)
- $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -octave $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
$(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
@@ -332,12 +375,12 @@ GUILE_LIBPREFIX = lib
# Build a dynamically loaded module with passive linkage and the scm interface
#------------------------------------------------------------------
guile: $(SRCS)
- $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
guile_cpp: $(SRCS)
- $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -guile -scm -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
@@ -348,12 +391,12 @@ guile_externalhdr:
# Build a dynamically loaded module with passive linkage and the gh interface
#------------------------------------------------------------------
guile_gh: $(SRCS)
- $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
guile_gh_cpp: $(SRCS)
- $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -guile -gh -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
@@ -362,12 +405,12 @@ guile_gh_cpp: $(SRCS)
# -----------------------------------------------------------------
guile_passive: $(SRCS)
- $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ISRCS) $(SRCS)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
guile_passive_cpp: $(SRCS)
- $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(INCLUDES) $(GUILE_INCLUDE) $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
@@ -378,24 +421,24 @@ guile_passive_cpp: $(SRCS)
GUILE_LIBOPTS = @GUILELINK@ @LIBS@ $(SYSLIBS)
guile_static: $(SRCS)
- $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \
-DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
$(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
guile_static_cpp: $(SRCS)
- $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -guile -lguilemain.i -Linkage ltdlmod $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
-DSWIGINIT="SCM scm_init_$(TARGET)_module(void); scm_init_$(TARGET)_module();" \
$(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
guile_simple: $(SRCS)
- $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) \
$(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
guile_simple_cpp: $(SRCS)
- $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -guile -lguilemain.i -Linkage simple $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(GUILE_INCLUDE) $(LIBS) -L$(GUILE_LIB) $(GUILE_LIBOPTS) -o $(TARGET)-guile
@@ -430,7 +473,7 @@ JAVACFLAGS = @JAVACFLAGS@
# ----------------------------------------------------------------
java: $(SRCS)
- $(SWIG) -java $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -java $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(JAVA_INCLUDE)
$(JAVALDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
@@ -439,7 +482,7 @@ java: $(SRCS)
# ----------------------------------------------------------------
java_cpp: $(SRCS)
- $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -java -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(JAVACFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(JAVA_INCLUDE)
$(JAVACXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(JAVA_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(JAVA_LIBPREFIX)$(TARGET)$(JAVASO)
@@ -448,7 +491,7 @@ java_cpp: $(SRCS)
# -----------------------------------------------------------------
java_clean:
- rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v main.java`
+ rm -f *_wrap* *~ .~* *.class `find . -name \*.java | grep -v runme.java`
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@JAVASO@
@@ -463,12 +506,12 @@ MODULA3_INCLUDE= @MODULA3INC@
# ----------------------------------------------------------------
modula3: $(SRCS)
- $(SWIG) -modula3 $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -modula3 $(SWIGOPT) $(INTERFACEPATH)
# $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) \
# $(OBJS) $(IOBJS) $(LIBS)
modula3_cpp: $(SRCS)
- $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -modula3 -c++ $(SWIGOPT) $(INTERFACEPATH)
# -----------------------------------------------------------------
# Cleaning the modula3 examples
@@ -483,7 +526,7 @@ modula3_clean:
##### MZSCHEME ######
##################################################################
-MZC = test -n "@MZC@" && @MZC@
+MZC = @MZC@
MZDYNOBJ = @MZDYNOBJ@
MZSCHEME_SO = @MZSCHEME_SO@
@@ -492,13 +535,13 @@ MZSCHEME_SO = @MZSCHEME_SO@
# ----------------------------------------------------------------
mzscheme: $(SRCS)
- $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACE)
- $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS)
- $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
+ $(SWIG) -mzscheme $(SWIGOPT) $(INTERFACEPATH)
+ $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS)
+ $(COMPILETOOL) $(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
mzscheme_cpp: $(SRCS)
- $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
- $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
+ $(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
$(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
# -----------------------------------------------------------------
@@ -520,6 +563,7 @@ OCAMLFIND=@OCAMLFIND@
OCAMLMKTOP=@OCAMLMKTOP@ $(SWIGWHERE)
NOLINK ?= false
OCAMLPP= -pp "camlp4o ./swigp4.cmo"
+OCAMLP4WHERE=`$(COMPILETOOL) camlp4 -where`
OCAMLCORE=\
rm -rf swig.mli swig.ml swigp4.ml && \
$(SWIG) -ocaml -co swig.mli 2>/dev/null && \
@@ -527,12 +571,12 @@ OCAMLCORE=\
$(SWIG) -ocaml -co swigp4.ml 2>/dev/null && \
$(OCC) -c swig.mli && \
$(OCC) -c swig.ml && \
- $(OCC) -I `camlp4 -where` -pp "camlp4o pa_extend.cmo q_MLast.cmo" \
+ $(OCC) -I $(OCAMLP4WHERE) -pp "camlp4o pa_extend.cmo q_MLast.cmo" \
-c swigp4.ml
ocaml_static: $(SRCS)
$(OCAMLCORE)
- $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -546,7 +590,7 @@ ocaml_static: $(SRCS)
ocaml_dynamic: $(SRCS)
$(OCAMLCORE)
- $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(CXXSHARED) $(CFLAGS) $(CCSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) $(LIBS)
@@ -565,7 +609,7 @@ ocaml_dynamic: $(SRCS)
ocaml_static_toplevel: $(SRCS)
$(OCAMLCORE)
- $(SWIG) -ocaml $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ocaml $(SWIGOPT) $(INTERFACEPATH)
$(OCC) -g -c -ccopt -g -ccopt "$(INCLUDES)" $(ISRCS) $(SRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -573,14 +617,14 @@ ocaml_static_toplevel: $(SRCS)
$(OCC) $(OCAMLPP) -c $(PROGFILE)
$(NOLINK) || $(OCAMLMKTOP) \
swig.cmo \
- -I `camlp4 -where` camlp4o.cma swigp4.cmo \
+ -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
$(INTERFACE:%.i=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) -cclib "$(LIBS)"
ocaml_static_cpp: $(SRCS)
$(OCAMLCORE)
- $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
@@ -597,7 +641,7 @@ ocaml_static_cpp: $(SRCS)
ocaml_static_cpp_toplevel: $(SRCS)
$(OCAMLCORE)
- $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
@@ -607,7 +651,7 @@ ocaml_static_cpp_toplevel: $(SRCS)
$(OCC) $(OCAMLPP) -c $(PROGFILE)
$(NOLINK) || $(OCAMLMKTOP) \
swig.cmo \
- -I `camlp4 -where` camlp4o.cma swigp4.cmo \
+ -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
$(INTERFACE:%.i=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
@@ -615,7 +659,7 @@ ocaml_static_cpp_toplevel: $(SRCS)
ocaml_dynamic_cpp: $(SRCS)
$(OCAMLCORE)
- $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
$(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
@@ -656,7 +700,7 @@ RUBY_DLNK = @RUBYDYNAMICLINKING@
# ----------------------------------------------------------------
ruby: $(SRCS)
- $(SWIG) -ruby $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ruby $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(RUBY_INCLUDE)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -665,7 +709,7 @@ ruby: $(SRCS)
# -----------------------------------------------------------------
ruby_cpp: $(SRCS)
- $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -ruby $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(RUBY_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(RUBY_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -679,12 +723,12 @@ ruby_cpp: $(SRCS)
RUBY_LIBOPTS = @RUBYLINK@ @LIBS@ $(SYSLIBS)
ruby_static: $(SRCS)
- $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) $(RUBY_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
ruby_cpp_static: $(SRCS)
- $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -ruby -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(RUBY_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(RUBY_INCLUDE) $(LIBS) -L$(RUBY_LIB) $(RUBY_LIBOPTS) -o $(TARGET)
@@ -703,41 +747,41 @@ ruby_clean:
##################################################################
# -------------------------------------------------------------------
-# Build a PHP4 dynamically loadable module (C)
+# Build a PHP dynamically loadable module (C)
# -------------------------------------------------------------------
-PHP4_INCLUDE = @PHP4INC@
-PHP4_SO = @PHP4_SO@
+PHP_INCLUDE = @PHPINC@
+PHP_SO = @PHP_SO@
-php4: $(SRCS)
- $(SWIG) -php5 $(SWIGOPT) $(INTERFACE)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP4_INCLUDE)
- $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO)
+php: $(SRCS)
+ $(SWIG) -php $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES) $(PHP_INCLUDE)
+ $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
# --------------------------------------------------------------------
-# Build a PHP4 dynamically loadable module (C++)
+# Build a PHP dynamically loadable module (C++)
# --------------------------------------------------------------------
-php4_cpp: $(SRCS)
- $(SWIG) -php5 -cppext cxx -c++ $(SWIGOPT) $(INTERFACE)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP4_INCLUDE)
- $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP4_SO)
+php_cpp: $(SRCS)
+ $(SWIG) -php -cppext cxx -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES) $(PHP_INCLUDE)
+ $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(PHP_SO)
# -----------------------------------------------------------------
-# Running a PHP4 example
+# Running a PHP example
# -----------------------------------------------------------------
-PHP4=@PHP4@
-SCRIPT ?= runme.php4
+PHP=@PHP@
+PHPSCRIPT ?= runme.php
-php4_run:
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP4) -n -q -d extension_dir=. $(SCRIPT)
+php_run:
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
# -----------------------------------------------------------------
-# Cleaning the PHP4 examples
+# Cleaning the PHP examples
# -----------------------------------------------------------------
-php4_clean:
+php_clean:
rm -f *_wrap* *~ .~* example.php php_example.h
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -757,7 +801,7 @@ PIKE_DLNK = @PIKEDYNAMICLINKING@
# ----------------------------------------------------------------
pike: $(SRCS)
- $(SWIG) -pike $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -pike $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(PIKE_INCLUDE)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -766,7 +810,7 @@ pike: $(SRCS)
# -----------------------------------------------------------------
pike_cpp: $(SRCS)
- $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -pike $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(PIKE_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(PIKE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -780,12 +824,12 @@ pike_cpp: $(SRCS)
PIKE_LIBOPTS = @PIKELINK@ @LIBS@ $(SYSLIBS)
pike_static: $(SRCS)
- $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) $(PIKE_CFLAGS) @LINKFORSHARED@ $(ISRCS) $(SRCS) $(INCLUDES) \
$(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
pike_cpp_static: $(SRCS)
- $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -pike -lembed.i $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(PIKE_CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PIKE_INCLUDE) $(LIBS) -L$(PIKE_LIB) $(PIKE_LIBOPTS) -o $(TARGET)
@@ -827,7 +871,7 @@ CHICKEN_COMPILED_MAIN_OBJECT = $(CHICKEN_COMPILED_MAIN:.c=.@OBJEXT@)
# This is the old way to build chicken, but it does not work correctly with exceptions
chicken_direct: $(SRCS)
- $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
+ $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-dynamic -feature chicken-compile-shared \
-output-file $(CHICKEN_COMPILED_SCHEME)
@@ -837,7 +881,7 @@ chicken_direct: $(SRCS)
$(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(LIBPREFIX)$(TARGET)$(SO)
chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
- $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
+ $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-dynamic -feature chicken-compile-shared \
-output-file $(CHICKEN_COMPILED_SCHEME)
@@ -852,7 +896,7 @@ chicken_direct_cpp: $(CXXSRCS) $(CHICKSRCS)
# The following two targets are also used by the test suite
chicken_static: $(SRCS) $(CHICKSRCS)
- $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
+ $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-output-file $(CHICKEN_COMPILED_SCHEME)
$(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
@@ -864,7 +908,7 @@ chicken_static: $(SRCS) $(CHICKSRCS)
$(OBJS) $(IOBJS) $(LIBS) $(CHICKEN_SHAREDLIBOPTS) -o $(TARGET)
chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
- $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
+ $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
$(CHICKEN) $(CHICKEN_GENERATED_SCHEME) $(CHICKENOPTS) \
-output-file $(CHICKEN_COMPILED_SCHEME)
$(CHICKEN) $(CHICKEN_MAIN) $(CHICKENOPTS) \
@@ -880,11 +924,11 @@ chicken_static_cpp: $(CXXSRCS) $(CHICKSRCS)
# ----------------------------------------------------------------
chicken:
- $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
+ $(SWIG) -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
$(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ISRCS) -o $(TARGET)$(SO)
chicken_cpp:
- $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACE)
+ $(SWIG) -c++ -chicken $(SWIGOPT) $(INCLUDE) $(INTERFACEPATH)
$(COMPILETOOL) $(CHICKEN_CSC) -s `echo $(INCLUDES) | sed 's/-I/-C -I/g'` $(CHICKEN_GENERATED_SCHEME) $(SRCS) $(ICXXSRCS) $(CXXSRCS) -o $(TARGET)$(SO)
chicken_externalhdr:
@@ -912,7 +956,7 @@ CSHARPSO = @CSHARPSO@
# ----------------------------------------------------------------
csharp: $(SRCS)
- $(SWIG) -csharp $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -csharp $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
@@ -921,7 +965,7 @@ csharp: $(SRCS)
# ----------------------------------------------------------------
csharp_cpp: $(SRCS)
- $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -csharp -c++ $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(CSHARPCFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(CSHARP_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(CSHARP_LIBPREFIX)$(TARGET)$(CSHARPSO)
@@ -961,7 +1005,7 @@ LUA_INTERP = ../lua.c
# ----------------------------------------------------------------
lua: $(SRCS)
- $(SWIG) -lua $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -lua $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(SRCS) $(INCLUDES) $(LUA_INCLUDE)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
@@ -970,7 +1014,7 @@ lua: $(SRCS)
# -----------------------------------------------------------------
lua_cpp: $(SRCS)
- $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -lua $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) $(LUA_INCLUDE)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(LUA_LIB) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(LUA_SO)
@@ -979,12 +1023,12 @@ lua_cpp: $(SRCS)
# -----------------------------------------------------------------
lua_static: $(SRCS)
- $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -lua -module example $(SWIGOPT) $(INTERFACEPATH)
$(CC) $(CFLAGS) $(ISRCS) $(SRCS) $(LUA_INTERP) $(INCLUDES) \
$(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET)
lua_static_cpp: $(SRCS)
- $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -lua -module example $(SWIGOPT) $(INTERFACEPATH)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(LUA_INTERP) $(INCLUDES) \
$(LUA_INCLUDE) $(LIBS) $(LUA_LIB) -o $(TARGET)
@@ -1002,12 +1046,12 @@ lua_clean:
##################################################################
allegrocl: $(SRCS)
- $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH)
$(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
allegrocl_cpp: $(SRCS)
- $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -1021,10 +1065,10 @@ allegrocl_clean:
##################################################################
clisp: $(SRCS)
- $(SWIG) -clisp $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -clisp $(SWIGOPT) $(INTERFACEPATH)
clisp_cpp: $(SRCS)
- $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -clisp $(SWIGOPT) $(INTERFACEPATH)
clisp_clean:
rm -f *_wrap* *~ .~*
@@ -1036,12 +1080,12 @@ clisp_clean:
##################################################################
cffi: $(SRCS)
- $(SWIG) -cffi $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH)
# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
cffi_cpp: $(SRCS)
- $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -1055,12 +1099,12 @@ cffi_clean:
##################################################################
uffi: $(SRCS)
- $(SWIG) -uffi $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH)
# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
uffi_cpp: $(SRCS)
- $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
# $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
@@ -1078,11 +1122,11 @@ RCXXSRCS = $(INTERFACE:.i=_wrap.cpp) #Need to use _wrap.cpp for R build system a
RRSRC = $(INTERFACE:.i=.R)
r: $(SRCS)
- $(SWIG) -r $(SWIGOPT) $(INTERFACE)
+ $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
+( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) )
r_cpp: $(CXXSRCS)
- $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACE)
+ $(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
+( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) )
r_clean:
diff --git a/Examples/csharp/arrays/Makefile b/Examples/csharp/arrays/Makefile
new file mode 100644
index 000000000..b3446d895
--- /dev/null
+++ b/Examples/csharp/arrays/Makefile
@@ -0,0 +1,20 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+SWIGOPT =
+CSHARPSRCS = *.cs
+CSHARPFLAGS= -nologo -unsafe -out:runme.exe
+
+all:: csharp
+
+csharp::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' csharp
+ $(MAKE) -f $(TOP)/Makefile CSHARPSRCS='$(CSHARPSRCS)' CSHARPFLAGS='$(CSHARPFLAGS)' csharp_compile
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile csharp_clean
+
+check: all
diff --git a/Examples/csharp/arrays/example.c b/Examples/csharp/arrays/example.c
new file mode 100644
index 000000000..2498e1f4e
--- /dev/null
+++ b/Examples/csharp/arrays/example.c
@@ -0,0 +1,22 @@
+/* File : example.c */
+
+#include "example.h"
+
+/* copy the contents of the first array to the second */
+void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
+ int i;
+ for ( i = 0; i < nitems; i++ ) {
+ targetArray[ i ] = sourceArray[ i ];
+ }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwap( int* array1, int* array2, int nitems ) {
+ int i, temp;
+ for ( i = 0; i < nitems; i++ ) {
+ temp = array1[ i ];
+ array1[ i ] = array2[ i ];
+ array2[ i ] = temp;
+ }
+}
+
diff --git a/Examples/csharp/arrays/example.h b/Examples/csharp/arrays/example.h
new file mode 100644
index 000000000..113b92c1b
--- /dev/null
+++ b/Examples/csharp/arrays/example.h
@@ -0,0 +1,4 @@
+
+void myArrayCopy( int *sourceArray, int* targetArray, int nitems );
+void myArraySwap( int* array1, int* array2, int nitems );
+
diff --git a/Examples/csharp/arrays/example.i b/Examples/csharp/arrays/example.i
new file mode 100644
index 000000000..488565a74
--- /dev/null
+++ b/Examples/csharp/arrays/example.i
@@ -0,0 +1,45 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+%include "arrays_csharp.i"
+
+%apply int INPUT[] { int* sourceArray }
+%apply int OUTPUT[] { int* targetArray }
+
+%apply int INOUT[] { int* array1 }
+%apply int INOUT[] { int* array2 }
+
+%include "example.h"
+
+%clear int* sourceArray;
+%clear int* targetArray;
+
+%clear int* array1;
+%clear int* array2;
+
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers "public unsafe";
+
+%apply int FIXED[] { int* sourceArray }
+%apply int FIXED[] { int* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
+ myArrayCopy(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply int FIXED[] { int* array1 }
+%apply int FIXED[] { int* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
+ myArraySwap(array1, array2, nitems);
+}
+%}
+
+
diff --git a/Examples/csharp/arrays/runme.cs b/Examples/csharp/arrays/runme.cs
new file mode 100644
index 000000000..c2b8a6bdd
--- /dev/null
+++ b/Examples/csharp/arrays/runme.cs
@@ -0,0 +1,43 @@
+using System;
+
+public class runme
+{
+ static void Main()
+ {
+ int[] source = { 1, 2, 3 };
+ int[] target = new int[ source.Length ];
+
+ example.myArrayCopy( source, target, target.Length );
+
+ Console.WriteLine( "Contents of copy target array using default marshaling" );
+ PrintArray( target );
+
+ target = new int[ source.Length ];
+
+ example.myArrayCopyUsingFixedArrays( source, target, target.Length );
+ Console.WriteLine( "Contents of copy target array using fixed arrays" );
+ PrintArray( target );
+
+ target = new int[] { 4, 5, 6 };
+ example.myArraySwap( source, target, target.Length );
+ Console.WriteLine( "Contents of arrays after swapping using default marshaling" );
+ PrintArray( source );
+ PrintArray( target );
+
+ source = new int[] { 1, 2, 3 };
+ target = new int[] { 4, 5, 6 };
+
+ example.myArraySwapUsingFixedArrays( source, target, target.Length );
+ Console.WriteLine( "Contents of arrays after swapping using fixed arrays" );
+ PrintArray( source );
+ PrintArray( target );
+ }
+
+ static void PrintArray( int[] a )
+ {
+ foreach ( int i in a )
+ Console.Write( "{0} ", i );
+ Console.WriteLine();
+ }
+}
+
diff --git a/Examples/csharp/check.list b/Examples/csharp/check.list
index c4d92402b..5454d8531 100644
--- a/Examples/csharp/check.list
+++ b/Examples/csharp/check.list
@@ -1,4 +1,5 @@
# see top-level Makefile.in
+arrays
callback
class
enum
diff --git a/Examples/guile/matrix/matrix.scm b/Examples/guile/matrix/matrix.scm
index 18e52842d..18e52842d 100755..100644
--- a/Examples/guile/matrix/matrix.scm
+++ b/Examples/guile/matrix/matrix.scm
diff --git a/Examples/java/callback/main.java b/Examples/java/callback/runme.java
index 4800f8cc9..4090f0ac3 100644
--- a/Examples/java/callback/main.java
+++ b/Examples/java/callback/runme.java
@@ -1,4 +1,4 @@
-public class main
+public class runme
{
static {
try {
diff --git a/Examples/java/class/index.html b/Examples/java/class/index.html
index e9db7e94a..cf9130c62 100644
--- a/Examples/java/class/index.html
+++ b/Examples/java/class/index.html
@@ -88,7 +88,7 @@ Note: when creating a C++ extension, you must run SWIG with the <tt>-c++</tt> op
<h2>A sample Java program</h2>
-Click <a href="main.java">here</a> to see a Java program that calls the C++ functions from Java.
+Click <a href="runme.java">here</a> to see a Java program that calls the C++ functions from Java.
<h2>Key points</h2>
diff --git a/Examples/java/class/main.java b/Examples/java/class/runme.java
index 8ef35db6d..e1ea0d71c 100644
--- a/Examples/java/class/main.java
+++ b/Examples/java/class/runme.java
@@ -1,7 +1,7 @@
// This example illustrates how C++ classes can be used from Java using SWIG.
// The Java class gets mapped onto the C++ class and behaves as if it is a Java class.
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/constants/index.html b/Examples/java/constants/index.html
index 8367d0571..9f1e95a03 100644
--- a/Examples/java/constants/index.html
+++ b/Examples/java/constants/index.html
@@ -20,7 +20,7 @@ to see a SWIG interface with some constant declarations in it.
Click <a href="../../../Doc/Manual/Java.html#constants">here</a> for the section on constants in the SWIG and Java documentation.
<p>
-Click <a href="main.java">here</a> to see a Java program that prints out the values
+Click <a href="runme.java">here</a> to see a Java program that prints out the values
of the constants contained in the above file.</p>
<h2>Key points</h2>
<ul>
diff --git a/Examples/java/constants/main.java b/Examples/java/constants/runme.java
index 7130c3d70..2c67d86aa 100644
--- a/Examples/java/constants/main.java
+++ b/Examples/java/constants/runme.java
@@ -1,6 +1,6 @@
import java.lang.reflect.*;
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/enum/index.html b/Examples/java/enum/index.html
index 52c06c5d1..20daf2691 100644
--- a/Examples/java/enum/index.html
+++ b/Examples/java/enum/index.html
@@ -21,7 +21,7 @@ See the documentation for the other approaches for wrapping enums.
<ul>
<li><a href="example.h">example.h</a>. Header file containing some enums.
<li><a href="example.i">example.i</a>. Interface file.
-<li><a href="main.java">main.java</a>. Sample Java program.
+<li><a href="runme.java">runme.java</a>. Sample Java program.
</ul>
<hr>
diff --git a/Examples/java/enum/main.java b/Examples/java/enum/runme.java
index 8646e0087..56e49af91 100644
--- a/Examples/java/enum/main.java
+++ b/Examples/java/enum/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/extend/main.java b/Examples/java/extend/runme.java
index ee3a94ed0..629bb14a6 100644
--- a/Examples/java/extend/main.java
+++ b/Examples/java/extend/runme.java
@@ -17,7 +17,7 @@ class CEO extends Manager {
}
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/funcptr/index.html b/Examples/java/funcptr/index.html
index 0ad2be1cf..56d3baa18 100644
--- a/Examples/java/funcptr/index.html
+++ b/Examples/java/funcptr/index.html
@@ -66,7 +66,7 @@ Here are some files that illustrate this with a simple example:
<li><a href="example.c">example.c</a>
<li><a href="example.h">example.h</a>
<li><a href="example.i">example.i</a> (SWIG interface)
-<li><a href="main.java">main.java</a> (Sample program)
+<li><a href="runme.java">runme.java</a> (Sample program)
</ul>
<h2>Notes</h2>
diff --git a/Examples/java/funcptr/main.java b/Examples/java/funcptr/runme.java
index cf81f92b4..cd34c1b65 100644
--- a/Examples/java/funcptr/main.java
+++ b/Examples/java/funcptr/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/index.html b/Examples/java/index.html
index d98f9a393..007e14dbc 100644
--- a/Examples/java/index.html
+++ b/Examples/java/index.html
@@ -30,7 +30,7 @@ certain C declarations are turned into constants.
<h2>Running the examples</h2>
Please see the <a href="../../Doc/Manual/Windows.html">Windows</a> page in the main manual for information on using the examples on Windows. <p>
-On Unix most of the examples work by making the Makefile before executing the program main.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.
+On Unix most of the examples work by making the Makefile before executing the program runme.java. The Makefile will output the swig generated JNI c code as well as the Java wrapper classes. Additionally the JNI c/c++ code is compiled into the shared object (dynamic link library) which is needed for dynamic linking to the native code. The Makefiles also compile the Java files using javac.
<p>
Ensure that the dynamic link library file is in the appropriate path before executing the Java program. For example in Unix, libexample.so must be in the LD_LIBRARY_PATH.
<p>
@@ -39,7 +39,7 @@ A Unix example:
<pre>
$ make
$ export LD_LIBRARY_PATH=. #ksh
-$ java main
+$ java runme
</pre>
</blockquote>
<p>
diff --git a/Examples/java/multimap/main.java b/Examples/java/multimap/runme.java
index 331ac6b89..738330e77 100644
--- a/Examples/java/multimap/main.java
+++ b/Examples/java/multimap/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/native/index.html b/Examples/java/native/index.html
index 7ecf129ce..1ca51c1e9 100644
--- a/Examples/java/native/index.html
+++ b/Examples/java/native/index.html
@@ -18,7 +18,7 @@ This example compares wrapping a c global function using the manual way and the
<ul>
<li><a href="example.i">example.i</a>. Interface file comparing code wrapped by SWIG and wrapped manually.
-<li><a href="main.java">main.java</a>. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.
+<li><a href="runme.java">runme.java</a>. Sample Java program showing calls to both manually wrapped and SWIG wrapped c functions.
</ul>
<h2>Notes</h2>
diff --git a/Examples/java/native/main.java b/Examples/java/native/runme.java
index f4760bb3d..e9a18b21a 100644
--- a/Examples/java/native/main.java
+++ b/Examples/java/native/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/pointer/index.html b/Examples/java/pointer/index.html
index c30d549e6..e20fe3328 100644
--- a/Examples/java/pointer/index.html
+++ b/Examples/java/pointer/index.html
@@ -144,7 +144,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
-<li> <a href="main.java">main.java</a> (Java program)
+<li> <a href="runme.java">runme.java</a> (Java program)
</ul>
<h2>Notes</h2>
diff --git a/Examples/java/pointer/main.java b/Examples/java/pointer/runme.java
index e96e02eaa..f32f980f9 100644
--- a/Examples/java/pointer/main.java
+++ b/Examples/java/pointer/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/reference/index.html b/Examples/java/reference/index.html
index 64b129cbb..33c80c50f 100644
--- a/Examples/java/reference/index.html
+++ b/Examples/java/reference/index.html
@@ -121,7 +121,7 @@ Click <a href="example.i">here</a> to see a SWIG interface file with these addit
<h2>Sample Java program</h2>
-Click <a href="main.java">here</a> to see a Java program that manipulates some C++ references.
+Click <a href="runme.java">here</a> to see a Java program that manipulates some C++ references.
<h2>Notes:</h2>
diff --git a/Examples/java/reference/main.java b/Examples/java/reference/runme.java
index 4fd354761..6a2d9bf70 100644
--- a/Examples/java/reference/main.java
+++ b/Examples/java/reference/runme.java
@@ -1,6 +1,6 @@
// This example illustrates the manipulation of C++ references in Java.
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/simple/index.html b/Examples/java/simple/index.html
index a363327fe..9729e6dd8 100644
--- a/Examples/java/simple/index.html
+++ b/Examples/java/simple/index.html
@@ -65,15 +65,15 @@ to create the extension <tt>libexample.so (unix)</tt>.
<h2>Using the extension</h2>
-Click <a href="main.java">here</a> to see a program that calls our C functions from Java.
+Click <a href="runme.java">here</a> to see a program that calls our C functions from Java.
<p>
-Compile the java files <tt><a href="example.java">example.java</a></tt> and <tt><a href="main.java">main.java</a></tt>
-to create the class files example.class and main.class before running main in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
+Compile the java files <tt><a href="example.java">example.java</a></tt> and <tt><a href="runme.java">runme.java</a></tt>
+to create the class files example.class and runme.class before running runme in the JVM. Ensure that the libexample.so file is in your LD_LIBRARY_PATH before running. For example:
<blockquote>
<pre>
export LD_LIBRARY_PATH=. #ksh
javac *.java
-java main
+java runme
</pre>
</blockquote>
diff --git a/Examples/java/simple/main.java b/Examples/java/simple/runme.java
index 6d224a4dc..92880e8f9 100644
--- a/Examples/java/simple/main.java
+++ b/Examples/java/simple/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/template/index.html b/Examples/java/template/index.html
index 1aebd4c2a..f4408e568 100644
--- a/Examples/java/template/index.html
+++ b/Examples/java/template/index.html
@@ -85,7 +85,7 @@ Note that SWIG parses the templated function <tt>max</tt> and templated class <t
<h2>A sample Java program</h2>
-Click <a href="main.java">here</a> to see a Java program that calls the C++ functions from Java.
+Click <a href="runme.java">here</a> to see a Java program that calls the C++ functions from Java.
<h2>Notes</h2>
Use templated classes just like you would any other SWIG generated Java class. Use the classnames specified by the %template directive.
diff --git a/Examples/java/template/main.java b/Examples/java/template/runme.java
index 9129fcf2a..5d1097bba 100644
--- a/Examples/java/template/main.java
+++ b/Examples/java/template/runme.java
@@ -1,6 +1,6 @@
// This example illustrates how C++ templates can be used from Java.
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/java/typemap/index.html b/Examples/java/typemap/index.html
index 486aa8e79..5dd591941 100644
--- a/Examples/java/typemap/index.html
+++ b/Examples/java/typemap/index.html
@@ -16,7 +16,7 @@ This example shows how typemaps can be used to modify the default behaviour of t
<ul>
<li><a href="example.i">example.i</a>. Interface file.
-<li><a href="main.java">main.java</a>. Sample Java program.
+<li><a href="runme.java">runme.java</a>. Sample Java program.
</ul>
<h2>Notes</h2>
diff --git a/Examples/java/typemap/main.java b/Examples/java/typemap/runme.java
index bd9a4e1b6..fcbcc3067 100644
--- a/Examples/java/typemap/main.java
+++ b/Examples/java/typemap/runme.java
@@ -1,5 +1,5 @@
-public class main {
+public class runme {
static {
try {
diff --git a/Examples/java/variables/index.html b/Examples/java/variables/index.html
index 05aaa2d6e..07b19d4e7 100644
--- a/Examples/java/variables/index.html
+++ b/Examples/java/variables/index.html
@@ -38,7 +38,7 @@ example.set_foo(12.3);
</pre>
</blockquote>
-Click <a href="main.java">here</a> to see the example program that updates and prints
+Click <a href="runme.java">here</a> to see the example program that updates and prints
out the values of the variables using this technique.
<h2>Key points</h2>
diff --git a/Examples/java/variables/main.java b/Examples/java/variables/runme.java
index 92745db99..361a30fa6 100644
--- a/Examples/java/variables/main.java
+++ b/Examples/java/variables/runme.java
@@ -2,7 +2,7 @@
import java.lang.reflect.*;
-public class main {
+public class runme {
static {
try {
System.loadLibrary("example");
diff --git a/Examples/lua/embed3/embed3.cpp b/Examples/lua/embed3/embed3.cpp
index c2424f9af..e5e0e0a7d 100644
--- a/Examples/lua/embed3/embed3.cpp
+++ b/Examples/lua/embed3/embed3.cpp
@@ -26,7 +26,12 @@ extern "C" {
#include <lauxlib.h>
#include <lualib.h>
}
-
+
+/* The SWIG external runtime is generated by using.
+swig -lua -externalruntime swigluarun.h
+It contains useful function used by SWIG in its wrappering
+SWIG_TypeQuery() SWIG_NewPointerObj()
+*/
#include "swigluarun.h" // the SWIG external runtime
/* the SWIG wrappered library */
diff --git a/Examples/perl5/class/example.dsp b/Examples/perl5/class/example.dsp
index bbdedc094..b5ccd1928 100644
--- a/Examples/perl5/class/example.dsp
+++ b/Examples/perl5/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/bar.dsp b/Examples/perl5/import/bar.dsp
index 682c21757..64786b8f6 100644
--- a/Examples/perl5/import/bar.dsp
+++ b/Examples/perl5/import/bar.dsp
@@ -118,7 +118,7 @@ InputName=bar
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/base.dsp b/Examples/perl5/import/base.dsp
index 7a0ea8027..920891cbf 100644
--- a/Examples/perl5/import/base.dsp
+++ b/Examples/perl5/import/base.dsp
@@ -118,7 +118,7 @@ InputName=base
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/foo.dsp b/Examples/perl5/import/foo.dsp
index 755560165..d519a5316 100644
--- a/Examples/perl5/import/foo.dsp
+++ b/Examples/perl5/import/foo.dsp
@@ -118,7 +118,7 @@ InputName=foo
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/import/spam.dsp b/Examples/perl5/import/spam.dsp
index ed41de36b..e5c8046eb 100644
--- a/Examples/perl5/import/spam.dsp
+++ b/Examples/perl5/import/spam.dsp
@@ -118,7 +118,7 @@ InputName=spam
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -c++ -perl5 $(InputPath)
+ ..\..\..\swig.exe -c++ -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/multimap/example.dsp b/Examples/perl5/multimap/example.dsp
index 2d295763b..be8a0070e 100644
--- a/Examples/perl5/multimap/example.dsp
+++ b/Examples/perl5/multimap/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/perl5/simple/example.dsp b/Examples/perl5/simple/example.dsp
index 2d295763b..be8a0070e 100644
--- a/Examples/perl5/simple/example.dsp
+++ b/Examples/perl5/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PERL5_INCLUDE: %PERL5_INCLUDE%
echo PERL5_LIB: %PERL5_LIB%
echo on
- ..\..\..\swig -perl5 $(InputPath)
+ ..\..\..\swig.exe -perl5 $(InputPath)
# End Custom Build
diff --git a/Examples/php4/check.list b/Examples/php/check.list
index 9daad455b..9daad455b 100644
--- a/Examples/php4/check.list
+++ b/Examples/php/check.list
diff --git a/Examples/php4/enum/Makefile b/Examples/php/class/Makefile
index 39c4d2f23..252a72660 100644
--- a/Examples/php4/enum/Makefile
+++ b/Examples/php/class/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/class/example.cxx b/Examples/php/class/example.cxx
index f171f10e9..f171f10e9 100644
--- a/Examples/php4/class/example.cxx
+++ b/Examples/php/class/example.cxx
diff --git a/Examples/php4/class/example.h b/Examples/php/class/example.h
index 02eaf7232..02eaf7232 100644
--- a/Examples/php4/class/example.h
+++ b/Examples/php/class/example.h
diff --git a/Examples/php4/class/example.i b/Examples/php/class/example.i
index 75700b305..75700b305 100644
--- a/Examples/php4/class/example.i
+++ b/Examples/php/class/example.i
diff --git a/Examples/php4/class/runme.php4 b/Examples/php/class/runme.php
index a9ca657dc..a9ca657dc 100644
--- a/Examples/php4/class/runme.php4
+++ b/Examples/php/class/runme.php
diff --git a/Examples/php4/constants/Makefile b/Examples/php/constants/Makefile
index aed110eb2..23e2675d7 100644
--- a/Examples/php4/constants/Makefile
+++ b/Examples/php/constants/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/constants/example.i b/Examples/php/constants/example.i
index 0098a893a..0098a893a 100644
--- a/Examples/php4/constants/example.i
+++ b/Examples/php/constants/example.i
diff --git a/Examples/php4/constants/runme.php4 b/Examples/php/constants/runme.php
index cea06485f..cea06485f 100644
--- a/Examples/php4/constants/runme.php4
+++ b/Examples/php/constants/runme.php
diff --git a/Examples/php4/simple/Makefile b/Examples/php/cpointer/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/simple/Makefile
+++ b/Examples/php/cpointer/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/cpointer/example.c b/Examples/php/cpointer/example.c
index 3326dec3e..3326dec3e 100644
--- a/Examples/php4/cpointer/example.c
+++ b/Examples/php/cpointer/example.c
diff --git a/Examples/php4/cpointer/example.i b/Examples/php/cpointer/example.i
index 52e6df190..52e6df190 100644
--- a/Examples/php4/cpointer/example.i
+++ b/Examples/php/cpointer/example.i
diff --git a/Examples/php4/cpointer/runme.php4 b/Examples/php/cpointer/runme.php
index f5ef08a3c..f5ef08a3c 100644
--- a/Examples/php4/cpointer/runme.php4
+++ b/Examples/php/cpointer/runme.php
diff --git a/Examples/php4/proxy/Makefile b/Examples/php/disown/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/proxy/Makefile
+++ b/Examples/php/disown/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/disown/example.cxx b/Examples/php/disown/example.cxx
index 6393735e9..6393735e9 100644
--- a/Examples/php4/disown/example.cxx
+++ b/Examples/php/disown/example.cxx
diff --git a/Examples/php4/disown/example.h b/Examples/php/disown/example.h
index 985bc333d..985bc333d 100644
--- a/Examples/php4/disown/example.h
+++ b/Examples/php/disown/example.h
diff --git a/Examples/php4/disown/example.i b/Examples/php/disown/example.i
index 599f162c5..599f162c5 100644
--- a/Examples/php4/disown/example.i
+++ b/Examples/php/disown/example.i
diff --git a/Examples/php4/disown/runme.php4 b/Examples/php/disown/runme.php
index 73d50786b..73d50786b 100644
--- a/Examples/php4/disown/runme.php4
+++ b/Examples/php/disown/runme.php
diff --git a/Examples/php4/class/Makefile b/Examples/php/enum/Makefile
index 39c4d2f23..252a72660 100644
--- a/Examples/php4/class/Makefile
+++ b/Examples/php/enum/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/enum/example.cxx b/Examples/php/enum/example.cxx
index df7bb6328..df7bb6328 100644
--- a/Examples/php4/enum/example.cxx
+++ b/Examples/php/enum/example.cxx
diff --git a/Examples/php4/enum/example.h b/Examples/php/enum/example.h
index 525d62afc..525d62afc 100644
--- a/Examples/php4/enum/example.h
+++ b/Examples/php/enum/example.h
diff --git a/Examples/php4/enum/example.i b/Examples/php/enum/example.i
index abf254731..abf254731 100644
--- a/Examples/php4/enum/example.i
+++ b/Examples/php/enum/example.i
diff --git a/Examples/php4/enum/runme.php4 b/Examples/php/enum/runme.php
index 55b0bc4c3..55b0bc4c3 100644
--- a/Examples/php4/enum/runme.php4
+++ b/Examples/php/enum/runme.php
diff --git a/Examples/php4/funcptr/Makefile b/Examples/php/funcptr/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/funcptr/Makefile
+++ b/Examples/php/funcptr/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/funcptr/example.c b/Examples/php/funcptr/example.c
index 99583b72e..99583b72e 100644
--- a/Examples/php4/funcptr/example.c
+++ b/Examples/php/funcptr/example.c
diff --git a/Examples/php4/funcptr/example.h b/Examples/php/funcptr/example.h
index 58989db79..58989db79 100644
--- a/Examples/php4/funcptr/example.h
+++ b/Examples/php/funcptr/example.h
diff --git a/Examples/php4/funcptr/example.i b/Examples/php/funcptr/example.i
index 39390da27..39390da27 100644
--- a/Examples/php4/funcptr/example.i
+++ b/Examples/php/funcptr/example.i
diff --git a/Examples/php4/funcptr/runme.php4 b/Examples/php/funcptr/runme.php
index 712d4147c..712d4147c 100644
--- a/Examples/php4/funcptr/runme.php4
+++ b/Examples/php/funcptr/runme.php
diff --git a/Examples/php4/sync/Makefile b/Examples/php/overloading/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/sync/Makefile
+++ b/Examples/php/overloading/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/overloading/example.cxx b/Examples/php/overloading/example.cxx
index fc7aff195..2f684f05c 100644
--- a/Examples/php4/overloading/example.cxx
+++ b/Examples/php/overloading/example.cxx
@@ -34,22 +34,22 @@ double Square::perimeter(void) {
return 4*width;
}
-char *overloaded(int i) {
+const char *overloaded(int i) {
return "Overloaded with int";
}
-char *overloaded(double d) {
+const char *overloaded(double d) {
return "Overloaded with double";
}
-char *overloaded(const char * str) {
+const char *overloaded(const char * str) {
return "Overloaded with char *";
}
-char *overloaded( const Circle& ) {
+const char *overloaded( const Circle& ) {
return "Overloaded with Circle";
}
-char *overloaded( const Shape& ) {
+const char *overloaded( const Shape& ) {
return "Overloaded with Shape";
}
diff --git a/Examples/php4/overloading/example.h b/Examples/php/overloading/example.h
index 39ccc1cb1..01d71dd70 100644
--- a/Examples/php4/overloading/example.h
+++ b/Examples/php/overloading/example.h
@@ -38,9 +38,9 @@ public:
virtual double perimeter(void);
};
-char *overloaded( int i );
-char *overloaded( double d );
-char *overloaded( const char * str );
-char *overloaded( const Circle& );
-char *overloaded( const Shape& );
+const char *overloaded( int i );
+const char *overloaded( double d );
+const char *overloaded( const char * str );
+const char *overloaded( const Circle& );
+const char *overloaded( const Shape& );
diff --git a/Examples/php4/overloading/example.i b/Examples/php/overloading/example.i
index 950d2549d..950d2549d 100644
--- a/Examples/php4/overloading/example.i
+++ b/Examples/php/overloading/example.i
diff --git a/Examples/php4/overloading/runme.php4 b/Examples/php/overloading/runme.php
index 5aa69048d..5aa69048d 100644
--- a/Examples/php4/overloading/runme.php4
+++ b/Examples/php/overloading/runme.php
diff --git a/Examples/php4/cpointer/Makefile b/Examples/php/pointer/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/cpointer/Makefile
+++ b/Examples/php/pointer/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/pointer/example.c b/Examples/php/pointer/example.c
index 3326dec3e..3326dec3e 100644
--- a/Examples/php4/pointer/example.c
+++ b/Examples/php/pointer/example.c
diff --git a/Examples/php4/pointer/example.i b/Examples/php/pointer/example.i
index c14b94189..c14b94189 100644
--- a/Examples/php4/pointer/example.i
+++ b/Examples/php/pointer/example.i
diff --git a/Examples/php4/pointer/runme.php4 b/Examples/php/pointer/runme.php
index 5e86de6a2..5e86de6a2 100644
--- a/Examples/php4/pointer/runme.php4
+++ b/Examples/php/pointer/runme.php
diff --git a/Examples/php4/pragmas/Makefile b/Examples/php/pragmas/Makefile
index aed110eb2..23e2675d7 100644
--- a/Examples/php4/pragmas/Makefile
+++ b/Examples/php/pragmas/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/pragmas/example.i b/Examples/php/pragmas/example.i
index 289d4ec99..c7e8bf303 100644
--- a/Examples/php4/pragmas/example.i
+++ b/Examples/php/pragmas/example.i
@@ -21,11 +21,11 @@
zend_printf("This was %%rshutdown\n");
}
-%pragma(php4) include="include.php";
+%pragma(php) include="include.php";
-%pragma(php4) code="
+%pragma(php) code="
# This code is inserted into example.php
-echo \"this was php4 code\\n\";
+echo \"this was php code\\n\";
"
-%pragma(php4) phpinfo="php_info_print_table_start();"
+%pragma(php) phpinfo="php_info_print_table_start();"
diff --git a/Examples/php4/pragmas/include.php b/Examples/php/pragmas/include.php
index e19880a06..e19880a06 100644
--- a/Examples/php4/pragmas/include.php
+++ b/Examples/php/pragmas/include.php
diff --git a/Examples/php4/pragmas/runme.php4 b/Examples/php/pragmas/runme.php
index 538548b6f..538548b6f 100755
--- a/Examples/php4/pragmas/runme.php4
+++ b/Examples/php/pragmas/runme.php
diff --git a/Examples/php4/overloading/Makefile b/Examples/php/proxy/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/overloading/Makefile
+++ b/Examples/php/proxy/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/proxy/example.cxx b/Examples/php/proxy/example.cxx
index 94e4a7888..94e4a7888 100644
--- a/Examples/php4/proxy/example.cxx
+++ b/Examples/php/proxy/example.cxx
diff --git a/Examples/php4/proxy/example.h b/Examples/php/proxy/example.h
index 361dff898..361dff898 100644
--- a/Examples/php4/proxy/example.h
+++ b/Examples/php/proxy/example.h
diff --git a/Examples/php4/proxy/example.i b/Examples/php/proxy/example.i
index ce73746d0..ce73746d0 100644
--- a/Examples/php4/proxy/example.i
+++ b/Examples/php/proxy/example.i
diff --git a/Examples/php4/proxy/runme.php4 b/Examples/php/proxy/runme.php
index dea80e358..dea80e358 100644
--- a/Examples/php4/proxy/runme.php4
+++ b/Examples/php/proxy/runme.php
diff --git a/Examples/php4/reference/Makefile b/Examples/php/reference/Makefile
index 39c4d2f23..252a72660 100644
--- a/Examples/php4/reference/Makefile
+++ b/Examples/php/reference/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/reference/example.cxx b/Examples/php/reference/example.cxx
index 3e13841d2..3e13841d2 100644
--- a/Examples/php4/reference/example.cxx
+++ b/Examples/php/reference/example.cxx
diff --git a/Examples/php4/reference/example.h b/Examples/php/reference/example.h
index 4915adb1b..4915adb1b 100644
--- a/Examples/php4/reference/example.h
+++ b/Examples/php/reference/example.h
diff --git a/Examples/php4/reference/example.i b/Examples/php/reference/example.i
index 55d1828a8..55d1828a8 100644
--- a/Examples/php4/reference/example.i
+++ b/Examples/php/reference/example.i
diff --git a/Examples/php4/reference/runme-proxy.php4 b/Examples/php/reference/runme-proxy.php4
index 9d216f78b..9d216f78b 100644
--- a/Examples/php4/reference/runme-proxy.php4
+++ b/Examples/php/reference/runme-proxy.php4
diff --git a/Examples/php4/reference/runme.php4 b/Examples/php/reference/runme.php
index 00aaa5298..00aaa5298 100644
--- a/Examples/php4/reference/runme.php4
+++ b/Examples/php/reference/runme.php
diff --git a/Examples/php4/pointer/Makefile b/Examples/php/simple/Makefile
index caeec2d73..0862ce5ec 100644
--- a/Examples/php4/pointer/Makefile
+++ b/Examples/php/simple/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/simple/example.c b/Examples/php/simple/example.c
index 2fe275632..2fe275632 100644
--- a/Examples/php4/simple/example.c
+++ b/Examples/php/simple/example.c
diff --git a/Examples/php4/simple/example.i b/Examples/php/simple/example.i
index af4ff08a7..af4ff08a7 100644
--- a/Examples/php4/simple/example.i
+++ b/Examples/php/simple/example.i
diff --git a/Examples/php4/simple/runme.php4 b/Examples/php/simple/runme.php
index 0e96fe800..0e96fe800 100755
--- a/Examples/php4/simple/runme.php4
+++ b/Examples/php/simple/runme.php
diff --git a/Examples/php4/disown/Makefile b/Examples/php/sync/Makefile
index ef3acc773..1bc0beaab 100644
--- a/Examples/php4/disown/Makefile
+++ b/Examples/php/sync/Makefile
@@ -9,16 +9,16 @@ SWIGOPT =
all::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4_cpp
+ php_cpp
static::
$(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_cpp_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_cpp_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/sync/example.cxx b/Examples/php/sync/example.cxx
index 47378924b..31ed2021b 100644
--- a/Examples/php4/sync/example.cxx
+++ b/Examples/php/sync/example.cxx
@@ -2,7 +2,7 @@
#include <stdio.h>
int x = 42;
-char *s = "Test";
+char *s = (char *)"Test";
void Sync::printer(void) {
diff --git a/Examples/php4/sync/example.h b/Examples/php/sync/example.h
index d67ec21dc..d67ec21dc 100644
--- a/Examples/php4/sync/example.h
+++ b/Examples/php/sync/example.h
diff --git a/Examples/php4/sync/example.i b/Examples/php/sync/example.i
index 17ff87cf3..17ff87cf3 100644
--- a/Examples/php4/sync/example.i
+++ b/Examples/php/sync/example.i
diff --git a/Examples/php4/sync/runme.php4 b/Examples/php/sync/runme.php
index a7c43474f..a7c43474f 100644
--- a/Examples/php4/sync/runme.php4
+++ b/Examples/php/sync/runme.php
diff --git a/Examples/php4/value/Makefile b/Examples/php/value/Makefile
index cc383ea3f..9e69d00a4 100644
--- a/Examples/php4/value/Makefile
+++ b/Examples/php/value/Makefile
@@ -9,16 +9,16 @@ SWIGOPT = -noproxy
all::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
+ php
static::
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
+ $(MAKE) -f $(TOP)/Makefile php_clean
rm -f $(TARGET).php
check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/value/example.c b/Examples/php/value/example.c
index 3c402a214..3c402a214 100644
--- a/Examples/php4/value/example.c
+++ b/Examples/php/value/example.c
diff --git a/Examples/php4/value/example.h b/Examples/php/value/example.h
index f55752a5f..f55752a5f 100644
--- a/Examples/php4/value/example.h
+++ b/Examples/php/value/example.h
diff --git a/Examples/php4/value/example.i b/Examples/php/value/example.i
index 386fa3b84..386fa3b84 100644
--- a/Examples/php4/value/example.i
+++ b/Examples/php/value/example.i
diff --git a/Examples/php4/value/runme.php4 b/Examples/php/value/runme.php
index 49115376c..49115376c 100644
--- a/Examples/php4/value/runme.php4
+++ b/Examples/php/value/runme.php
diff --git a/Examples/php/variables/Makefile b/Examples/php/variables/Makefile
new file mode 100644
index 000000000..0862ce5ec
--- /dev/null
+++ b/Examples/php/variables/Makefile
@@ -0,0 +1,24 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+LIBS =
+SWIGOPT =
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
+ php
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ SWIGOPT='$(SWIGOPT)' TARGET='myphp' INTERFACE='$(INTERFACE)' \
+ php_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile php_clean
+ rm -f $(TARGET).php
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile php_run
diff --git a/Examples/php4/variables/example.c b/Examples/php/variables/example.c
index 3114c7c5f..3114c7c5f 100644
--- a/Examples/php4/variables/example.c
+++ b/Examples/php/variables/example.c
diff --git a/Examples/php4/variables/example.h b/Examples/php/variables/example.h
index 3b3659ce5..3b3659ce5 100644
--- a/Examples/php4/variables/example.h
+++ b/Examples/php/variables/example.h
diff --git a/Examples/php4/variables/example.i b/Examples/php/variables/example.i
index 3edbb72d7..3edbb72d7 100644
--- a/Examples/php4/variables/example.i
+++ b/Examples/php/variables/example.i
diff --git a/Examples/php4/variables/runme.php4 b/Examples/php/variables/runme.php
index bbfeb610b..bbfeb610b 100644
--- a/Examples/php4/variables/runme.php4
+++ b/Examples/php/variables/runme.php
diff --git a/Examples/php4/variables/runme.php4.old b/Examples/php/variables/runme.php4.old
index 9a6bfb386..9a6bfb386 100644
--- a/Examples/php4/variables/runme.php4.old
+++ b/Examples/php/variables/runme.php4.old
diff --git a/Examples/php4/variables/Makefile b/Examples/php4/variables/Makefile
deleted file mode 100644
index caeec2d73..000000000
--- a/Examples/php4/variables/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-TOP = ../..
-SWIG = $(TOP)/../preinst-swig
-SRCS = example.c
-TARGET = example
-INTERFACE = example.i
-LIBS =
-SWIGOPT =
-
-all::
- $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
- php4
-
-static::
- $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
- SWIGOPT='$(SWIGOPT)' TARGET='myphp4' INTERFACE='$(INTERFACE)' \
- php4_static
-
-clean::
- $(MAKE) -f $(TOP)/Makefile php4_clean
- rm -f $(TARGET).php
-
-check: all
- $(MAKE) -f $(TOP)/Makefile php4_run
diff --git a/Examples/pike/class/Makefile b/Examples/pike/class/Makefile
index 981ccef6f..981ccef6f 100755..100644
--- a/Examples/pike/class/Makefile
+++ b/Examples/pike/class/Makefile
diff --git a/Examples/pike/class/example.cxx b/Examples/pike/class/example.cxx
index c7a3194a4..c7a3194a4 100755..100644
--- a/Examples/pike/class/example.cxx
+++ b/Examples/pike/class/example.cxx
diff --git a/Examples/pike/class/example.h b/Examples/pike/class/example.h
index f74a4fefc..f74a4fefc 100755..100644
--- a/Examples/pike/class/example.h
+++ b/Examples/pike/class/example.h
diff --git a/Examples/pike/class/example.i b/Examples/pike/class/example.i
index 75700b305..75700b305 100755..100644
--- a/Examples/pike/class/example.i
+++ b/Examples/pike/class/example.i
diff --git a/Examples/pike/constants/Makefile b/Examples/pike/constants/Makefile
index 7fa493851..7fa493851 100755..100644
--- a/Examples/pike/constants/Makefile
+++ b/Examples/pike/constants/Makefile
diff --git a/Examples/pike/constants/example.i b/Examples/pike/constants/example.i
index 4f7b1a4d7..4f7b1a4d7 100755..100644
--- a/Examples/pike/constants/example.i
+++ b/Examples/pike/constants/example.i
diff --git a/Examples/pike/overload/example.cxx b/Examples/pike/overload/example.cxx
index 3760fdd49..3760fdd49 100755..100644
--- a/Examples/pike/overload/example.cxx
+++ b/Examples/pike/overload/example.cxx
diff --git a/Examples/pike/overload/example.h b/Examples/pike/overload/example.h
index e47a122ee..e47a122ee 100755..100644
--- a/Examples/pike/overload/example.h
+++ b/Examples/pike/overload/example.h
diff --git a/Examples/pike/template/Makefile b/Examples/pike/template/Makefile
index b3f012927..b3f012927 100755..100644
--- a/Examples/pike/template/Makefile
+++ b/Examples/pike/template/Makefile
diff --git a/Examples/pike/template/example.h b/Examples/pike/template/example.h
index 7401df650..7401df650 100755..100644
--- a/Examples/pike/template/example.h
+++ b/Examples/pike/template/example.h
diff --git a/Examples/pike/template/example.i b/Examples/pike/template/example.i
index 8f94c4da1..8f94c4da1 100755..100644
--- a/Examples/pike/template/example.i
+++ b/Examples/pike/template/example.i
diff --git a/Examples/python/callback/Makefile b/Examples/python/callback/Makefile
index ad36d7d7e..a29276e58 100644
--- a/Examples/python/callback/Makefile
+++ b/Examples/python/callback/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/callback/runme.py b/Examples/python/callback/runme.py
index 5d93e8223..026e9520b 100644
--- a/Examples/python/callback/runme.py
+++ b/Examples/python/callback/runme.py
@@ -5,8 +5,6 @@
import example
-# CEO class, which overrides Employee::getPosition().
-
class PyCallback(example.Callback):
def __init__(self):
example.Callback.__init__(self)
diff --git a/Examples/python/class/Makefile b/Examples/python/class/Makefile
index f331b8203..74625b992 100644
--- a/Examples/python/class/Makefile
+++ b/Examples/python/class/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/class/example.dsp b/Examples/python/class/example.dsp
index dccba46b0..fd7bf8c06 100644
--- a/Examples/python/class/example.dsp
+++ b/Examples/python/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/constants/Makefile b/Examples/python/constants/Makefile
index 01d0f943a..1420b4e0b 100644
--- a/Examples/python/constants/Makefile
+++ b/Examples/python/constants/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/contract/Makefile b/Examples/python/contract/Makefile
index c7b476995..77fe94b1a 100644
--- a/Examples/python/contract/Makefile
+++ b/Examples/python/contract/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/contract/example.dsp b/Examples/python/contract/example.dsp
index 7a32f4dc1..32845e0e8 100644
--- a/Examples/python/contract/example.dsp
+++ b/Examples/python/contract/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/docstrings/Makefile b/Examples/python/docstrings/Makefile
index 74ab112a1..f25450cac 100644
--- a/Examples/python/docstrings/Makefile
+++ b/Examples/python/docstrings/Makefile
@@ -21,3 +21,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/enum/Makefile b/Examples/python/enum/Makefile
index f331b8203..74625b992 100644
--- a/Examples/python/enum/Makefile
+++ b/Examples/python/enum/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/exception/Makefile b/Examples/python/exception/Makefile
index 17c4f30b7..7dbdde944 100644
--- a/Examples/python/exception/Makefile
+++ b/Examples/python/exception/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/exceptproxy/Makefile b/Examples/python/exceptproxy/Makefile
index a4f334311..ba5c79827 100644
--- a/Examples/python/exceptproxy/Makefile
+++ b/Examples/python/exceptproxy/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/extend/Makefile b/Examples/python/extend/Makefile
index ad36d7d7e..a29276e58 100644
--- a/Examples/python/extend/Makefile
+++ b/Examples/python/extend/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/funcptr/Makefile b/Examples/python/funcptr/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/funcptr/Makefile
+++ b/Examples/python/funcptr/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/funcptr2/Makefile b/Examples/python/funcptr2/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/funcptr2/Makefile
+++ b/Examples/python/funcptr2/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/functor/Makefile b/Examples/python/functor/Makefile
index c45536529..fe389757a 100644
--- a/Examples/python/functor/Makefile
+++ b/Examples/python/functor/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/import/Makefile b/Examples/python/import/Makefile
index e00e81864..74d4f88cf 100644
--- a/Examples/python/import/Makefile
+++ b/Examples/python/import/Makefile
@@ -19,3 +19,4 @@ clean::
@rm -f foo.py bar.py spam.py base.py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/import/bar.dsp b/Examples/python/import/bar.dsp
index edb45811b..17b05cc39 100644
--- a/Examples/python/import/bar.dsp
+++ b/Examples/python/import/bar.dsp
@@ -118,7 +118,7 @@ InputName=bar
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import/base.dsp b/Examples/python/import/base.dsp
index 0ddb65157..2bc9736d1 100644
--- a/Examples/python/import/base.dsp
+++ b/Examples/python/import/base.dsp
@@ -118,7 +118,7 @@ InputName=base
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import/foo.dsp b/Examples/python/import/foo.dsp
index 86e11699f..9a92c4b85 100644
--- a/Examples/python/import/foo.dsp
+++ b/Examples/python/import/foo.dsp
@@ -118,7 +118,7 @@ InputName=foo
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import/spam.dsp b/Examples/python/import/spam.dsp
index 7245f7a7c..0a6595bfe 100644
--- a/Examples/python/import/spam.dsp
+++ b/Examples/python/import/spam.dsp
@@ -118,7 +118,7 @@ InputName=spam
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -c++ -python $(InputPath)
+ ..\..\..\swig.exe -c++ -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/import_template/Makefile b/Examples/python/import_template/Makefile
index fa49f3145..ee47e994d 100644
--- a/Examples/python/import_template/Makefile
+++ b/Examples/python/import_template/Makefile
@@ -19,3 +19,4 @@ clean::
@rm -f foo.py bar.py spam.py base.py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/libffi/Makefile b/Examples/python/libffi/Makefile
index 8c7edfa65..fafb7de09 100644
--- a/Examples/python/libffi/Makefile
+++ b/Examples/python/libffi/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/multimap/Makefile b/Examples/python/multimap/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/multimap/Makefile
+++ b/Examples/python/multimap/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/multimap/example.dsp b/Examples/python/multimap/example.dsp
index 7a32f4dc1..32845e0e8 100644
--- a/Examples/python/multimap/example.dsp
+++ b/Examples/python/multimap/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/multimap/example.i b/Examples/python/multimap/example.i
index 163d7cc8e..f1c4d9990 100644
--- a/Examples/python/multimap/example.i
+++ b/Examples/python/multimap/example.i
@@ -27,11 +27,24 @@ extern int gcd(int x, int y);
$2 = (char **) malloc(($1+1)*sizeof(char *));
for (i = 0; i < $1; i++) {
PyObject *s = PyList_GetItem($input,i);
- if (!PyString_Check(s)) {
+%#if PY_VERSION_HEX >= 0x03000000
+ if (!PyUnicode_Check(s))
+%#else
+ if (!PyString_Check(s))
+%#endif
+ {
free($2);
SWIG_exception(SWIG_ValueError, "List items must be strings");
}
+%#if PY_VERSION_HEX >= 0x03000000
+ {
+ int l;
+ $2[i] = PyUnicode_AsStringAndSize(s, &l);
+ }
+%#else
$2[i] = PyString_AsString(s);
+%#endif
+
}
$2[i] = 0;
}
@@ -39,12 +52,21 @@ extern int gcd(int x, int y);
extern int gcdmain(int argc, char *argv[]);
%typemap(in) (char *bytes, int len) {
+
+%#if PY_VERSION_HEX >= 0x03000000
+ if (!PyUnicode_Check($input)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ $1 = PyUnicode_AsStringAndSize($input, &$2);
+%#else
if (!PyString_Check($input)) {
PyErr_SetString(PyExc_ValueError,"Expected a string");
return NULL;
}
$1 = PyString_AsString($input);
$2 = PyString_Size($input);
+%#endif
}
extern int count(char *bytes, int len, char c);
@@ -56,9 +78,15 @@ extern int count(char *bytes, int len, char c);
so that we don't violate it's mutability */
%typemap(in) (char *str, int len) {
+%#if PY_VERSION_HEX >= 0x03000000
+ $2 = PyUnicode_GetSize($input);
+ $1 = (char *) malloc($2+1);
+ memmove($1,PyUnicode_AsString($input),$2);
+%#else
$2 = PyString_Size($input);
$1 = (char *) malloc($2+1);
memmove($1,PyString_AsString($input),$2);
+%#endif
}
/* Return the mutated string as a new object. The t_output_helper
@@ -67,7 +95,11 @@ extern int count(char *bytes, int len, char c);
%typemap(argout) (char *str, int len) {
PyObject *o;
+%#if PY_VERSION_HEX >= 0x03000000
+ o = PyUnicode_FromStringAndSize($1,$2);
+%#else
o = PyString_FromStringAndSize($1,$2);
+%#endif
$result = t_output_helper($result,o);
free($1);
}
diff --git a/Examples/python/operator/Makefile b/Examples/python/operator/Makefile
index c45536529..fe389757a 100644
--- a/Examples/python/operator/Makefile
+++ b/Examples/python/operator/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/pointer/Makefile b/Examples/python/pointer/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/pointer/Makefile
+++ b/Examples/python/pointer/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/reference/Makefile b/Examples/python/reference/Makefile
index f331b8203..74625b992 100644
--- a/Examples/python/reference/Makefile
+++ b/Examples/python/reference/Makefile
@@ -18,3 +18,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/simple/Makefile b/Examples/python/simple/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/simple/Makefile
+++ b/Examples/python/simple/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/simple/example.dsp b/Examples/python/simple/example.dsp
index 7a32f4dc1..32845e0e8 100644
--- a/Examples/python/simple/example.dsp
+++ b/Examples/python/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
- ..\..\..\swig -python $(InputPath)
+ ..\..\..\swig.exe -python $(InputPath)
# End Custom Build
diff --git a/Examples/python/smartptr/Makefile b/Examples/python/smartptr/Makefile
index 58d139643..f73802a6b 100644
--- a/Examples/python/smartptr/Makefile
+++ b/Examples/python/smartptr/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/std_map/Makefile b/Examples/python/std_map/Makefile
index 2d4c1b4a3..5d13da764 100644
--- a/Examples/python/std_map/Makefile
+++ b/Examples/python/std_map/Makefile
@@ -22,3 +22,4 @@ run:
python runme.py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/std_map/example.i b/Examples/python/std_map/example.i
index 36354a882..6a7af7108 100644
--- a/Examples/python/std_map/example.i
+++ b/Examples/python/std_map/example.i
@@ -23,5 +23,5 @@ namespace std {
%template(halfi) half_map<std::string,int>;
-%template() std::pair<swig::PyObject_ptr, swig::PyObject_ptr>;
-%template(pymap) std::map<swig::PyObject_ptr, swig::PyObject_ptr>;
+%template() std::pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
+%template(pymap) std::map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
diff --git a/Examples/python/std_vector/Makefile b/Examples/python/std_vector/Makefile
index a4f334311..ba5c79827 100644
--- a/Examples/python/std_vector/Makefile
+++ b/Examples/python/std_vector/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/swigrun/Makefile b/Examples/python/swigrun/Makefile
index 53bf701c9..2142be5bb 100644
--- a/Examples/python/swigrun/Makefile
+++ b/Examples/python/swigrun/Makefile
@@ -22,3 +22,4 @@ clean::
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/template/Makefile b/Examples/python/template/Makefile
index a4f334311..ba5c79827 100644
--- a/Examples/python/template/Makefile
+++ b/Examples/python/template/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/varargs/Makefile b/Examples/python/varargs/Makefile
index 01d0f943a..1420b4e0b 100644
--- a/Examples/python/varargs/Makefile
+++ b/Examples/python/varargs/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/variables/Makefile b/Examples/python/variables/Makefile
index 4a1e1bb71..0f4a1e077 100644
--- a/Examples/python/variables/Makefile
+++ b/Examples/python/variables/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/python/weave/Makefile b/Examples/python/weave/Makefile
index 822779bd1..88f95c095 100644
--- a/Examples/python/weave/Makefile
+++ b/Examples/python/weave/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile python_run
diff --git a/Examples/r/class/example.dsp b/Examples/r/class/example.dsp
index 682b156fb..b831989cc 100644
--- a/Examples/r/class/example.dsp
+++ b/Examples/r/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath)
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -c++ -r -o example_wrap.cpp $(InputPath)
+ ..\..\..\swig.exe -c++ -r -o example_wrap.cpp $(InputPath)
# End Custom Build
diff --git a/Examples/r/simple/example.dsp b/Examples/r/simple/example.dsp
index aaa5ef8e0..356815d19 100644
--- a/Examples/r/simple/example.dsp
+++ b/Examples/r/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -r $(InputPath)
+ ..\..\..\swig.exe -r $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo R_INCLUDE: %R_INCLUDE%
echo R_LIB: %R_LIB%
echo on
- ..\..\..\swig -r $(InputPath)
+ ..\..\..\swig.exe -r $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/class/example.dsp b/Examples/ruby/class/example.dsp
index 9a26322ec..2adab787a 100644
--- a/Examples/ruby/class/example.dsp
+++ b/Examples/ruby/class/example.dsp
@@ -128,7 +128,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/free_function/example.dsp b/Examples/ruby/free_function/example.dsp
index 9a26322ec..2adab787a 100644
--- a/Examples/ruby/free_function/example.dsp
+++ b/Examples/ruby/free_function/example.dsp
@@ -128,7 +128,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/free_function/example.i b/Examples/ruby/free_function/example.i
index 5ab29bd58..a446b3f99 100644
--- a/Examples/ruby/free_function/example.i
+++ b/Examples/ruby/free_function/example.i
@@ -20,7 +20,7 @@
static void free_Zoo(void* ptr) {
Zoo* zoo = (Zoo*) ptr;
- /* Loop over each object and call SWIG_RemoveMapping */
+ /* Loop over each object and call SWIG_RubyRemoveTracking */
int count = zoo->get_num_animals();
for(int i = 0; i < count; ++i) {
@@ -32,7 +32,7 @@
SWIG_RubyRemoveTracking(animal);
}
- /* Now call SWIG_RemoveMapping for the zoo */
+ /* Now call SWIG_RubyRemoveTracking for the zoo */
SWIG_RubyRemoveTracking(ptr);
/* Now free the zoo which will free the animals it contains */
diff --git a/Examples/ruby/hashargs/Makefile b/Examples/ruby/hashargs/Makefile
index a2fbbd397..a2fbbd397 100755..100644
--- a/Examples/ruby/hashargs/Makefile
+++ b/Examples/ruby/hashargs/Makefile
diff --git a/Examples/ruby/hashargs/example.i b/Examples/ruby/hashargs/example.i
index 159bbd32a..159bbd32a 100755..100644
--- a/Examples/ruby/hashargs/example.i
+++ b/Examples/ruby/hashargs/example.i
diff --git a/Examples/ruby/import/bar.dsp b/Examples/ruby/import/bar.dsp
index dd09ca021..29d9abf2f 100644
--- a/Examples/ruby/import/bar.dsp
+++ b/Examples/ruby/import/bar.dsp
@@ -120,7 +120,7 @@ InputName=bar
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=bar
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/base.dsp b/Examples/ruby/import/base.dsp
index 2bd4fa243..174afef3e 100644
--- a/Examples/ruby/import/base.dsp
+++ b/Examples/ruby/import/base.dsp
@@ -120,7 +120,7 @@ InputName=base
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=base
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/foo.dsp b/Examples/ruby/import/foo.dsp
index 2a764bbd7..7f4754915 100644
--- a/Examples/ruby/import/foo.dsp
+++ b/Examples/ruby/import/foo.dsp
@@ -120,7 +120,7 @@ InputName=foo
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=foo
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/import/spam.dsp b/Examples/ruby/import/spam.dsp
index d2d7158bb..72729f290 100644
--- a/Examples/ruby/import/spam.dsp
+++ b/Examples/ruby/import/spam.dsp
@@ -120,7 +120,7 @@ InputName=spam
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -135,7 +135,7 @@ InputName=spam
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/mark_function/example.dsp b/Examples/ruby/mark_function/example.dsp
index 9a26322ec..2adab787a 100644
--- a/Examples/ruby/mark_function/example.dsp
+++ b/Examples/ruby/mark_function/example.dsp
@@ -128,7 +128,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
@@ -143,7 +143,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -c++ -ruby $(InputPath)
+ ..\..\..\swig.exe -c++ -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/multimap/example.dsp b/Examples/ruby/multimap/example.dsp
index ccb99d44d..4888299f5 100644
--- a/Examples/ruby/multimap/example.dsp
+++ b/Examples/ruby/multimap/example.dsp
@@ -124,7 +124,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
@@ -139,7 +139,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/simple/example.dsp b/Examples/ruby/simple/example.dsp
index ccb99d44d..4888299f5 100644
--- a/Examples/ruby/simple/example.dsp
+++ b/Examples/ruby/simple/example.dsp
@@ -124,7 +124,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
@@ -139,7 +139,7 @@ InputName=example
echo RUBY_INCLUDE: %RUBY_INCLUDE%
echo RUBY_LIB: %RUBY_LIB%
echo on
- ..\..\..\swig -ruby $(InputPath)
+ ..\..\..\swig.exe -ruby $(InputPath)
# End Custom Build
diff --git a/Examples/ruby/std_vector/runme.rb b/Examples/ruby/std_vector/runme.rb
index 1529d38c6..851190536 100644
--- a/Examples/ruby/std_vector/runme.rb
+++ b/Examples/ruby/std_vector/runme.rb
@@ -9,7 +9,7 @@ puts Example::average([1,2,3,4])
# ... or a wrapped std::vector<int>
v = Example::IntVector.new(4)
-0.upto(v.length-1) { |i| v[i] = i+1 }
+0.upto(v.size-1) { |i| v[i] = i+1 }
puts Example::average(v)
@@ -17,7 +17,7 @@ puts Example::average(v)
# Call it with a Ruby array...
w = Example::half([1.0, 1.5, 2.0, 2.5, 3.0])
-0.upto(w.length-1) { |i| print w[i],"; " }
+0.upto(w.size-1) { |i| print w[i],"; " }
puts
# ... or a wrapped std::vector<double>
@@ -25,12 +25,12 @@ puts
v = Example::DoubleVector.new
[1,2,3,4].each { |i| v.push(i) }
w = Example::half(v)
-0.upto(w.length-1) { |i| print w[i],"; " }
+0.upto(w.size-1) { |i| print w[i],"; " }
puts
# now halve a wrapped std::vector<double> in place
Example::halve_in_place(v)
-0.upto(v.length-1) { |i| print v[i],"; " }
+0.upto(v.size-1) { |i| print v[i],"; " }
puts
diff --git a/Examples/tcl/class/example.dsp b/Examples/tcl/class/example.dsp
index bf6149407..0ff54829f 100644
--- a/Examples/tcl/class/example.dsp
+++ b/Examples/tcl/class/example.dsp
@@ -126,7 +126,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -141,7 +141,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/contract/example.dsp b/Examples/tcl/contract/example.dsp
index 296cb313b..c1568f2c5 100644
--- a/Examples/tcl/contract/example.dsp
+++ b/Examples/tcl/contract/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/bar.dsp b/Examples/tcl/import/bar.dsp
index 35b4e608b..d22b6a6fa 100644
--- a/Examples/tcl/import/bar.dsp
+++ b/Examples/tcl/import/bar.dsp
@@ -118,7 +118,7 @@ InputName=bar
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=bar
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/base.dsp b/Examples/tcl/import/base.dsp
index 74870ccb0..b27bbfdb6 100644
--- a/Examples/tcl/import/base.dsp
+++ b/Examples/tcl/import/base.dsp
@@ -118,7 +118,7 @@ InputName=base
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=base
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/foo.dsp b/Examples/tcl/import/foo.dsp
index ac7f09f06..4d3765bd7 100644
--- a/Examples/tcl/import/foo.dsp
+++ b/Examples/tcl/import/foo.dsp
@@ -118,7 +118,7 @@ InputName=foo
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=foo
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/import/spam.dsp b/Examples/tcl/import/spam.dsp
index db9ade0a3..5674c4373 100644
--- a/Examples/tcl/import/spam.dsp
+++ b/Examples/tcl/import/spam.dsp
@@ -118,7 +118,7 @@ InputName=spam
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
@@ -133,7 +133,7 @@ InputName=spam
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -c++ -tcl8 $(InputPath)
+ ..\..\..\swig.exe -c++ -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/multimap/example.dsp b/Examples/tcl/multimap/example.dsp
index 296cb313b..c1568f2c5 100644
--- a/Examples/tcl/multimap/example.dsp
+++ b/Examples/tcl/multimap/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/tcl/simple/example.dsp b/Examples/tcl/simple/example.dsp
index 296cb313b..c1568f2c5 100644
--- a/Examples/tcl/simple/example.dsp
+++ b/Examples/tcl/simple/example.dsp
@@ -122,7 +122,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
@@ -137,7 +137,7 @@ InputName=example
echo TCL_INCLUDE: %TCL_INCLUDE%
echo TCL_LIB: %TCL_LIB%
echo on
- ..\..\..\swig -tcl8 $(InputPath)
+ ..\..\..\swig.exe -tcl8 $(InputPath)
# End Custom Build
diff --git a/Examples/test-suite/allegrocl/Makefile.in b/Examples/test-suite/allegrocl/Makefile.in
index 394d2d524..df7193389 100644
--- a/Examples/test-suite/allegrocl/Makefile.in
+++ b/Examples/test-suite/allegrocl/Makefile.in
@@ -9,116 +9,75 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+
+# these cpp tests generate warnings/errors when compiling
+# the wrapper .cxx file.
+CPP_TEST_BROKEN_CXX =
+# the error is wrap:action code generated by swig. \
+# error: can't convert [std::string] 'b' to 'bool' \
+# might just need a bool overload op for std::string. \
+ global_vars \
+# same as w/ global_vars but with more errors in cxx file \
+ naturalvar \
+
# these cpp tests aren't working. Fix 'em
# need to further separate these into tests requiring
# std libraries, or the $ldestructor problem.
CPP_TEST_BROKEN_ACL = \
- array_member \
- char_strings \
- class_ignore \
- constant_pointers \
contract \
+ allprotected \
+# 'throws' typemap entries. \
cplusplus_throw \
- cpp_basic \
- cpp_enum \
- cpp_typedef \
- default_constructor \
+# 'throws' typemap entries. \
default_args \
+# missing typemaps. suspect module support needed \
dynamic_cast \
- enum_thorough \
extend_variable \
- global_vars \
- import_nomodule \
- kind \
- li_carrays \
+# cdata.i support needed \
li_cdata \
- li_windows \
- namespace_class \
- namespace_spaces \
- naturalvar \
+# warning generated. otherwise all good. \
operator_overload \
- overload_simple \
- register_par \
+# std_common.i support \
sizet \
- smart_pointer_extend \
- smart_pointer_namespace \
- template \
- template_classes \
+# std_vector.i support. \
template_default \
- template_default_inherit \
- template_enum \
- template_explicit \
- template_extend_overload \
- template_ns \
- template_ns4 \
- template_ns_enum \
- template_rename \
- template_retvalue \
- template_static \
- template_tbase_template \
- template_typedef \
- template_typedef_cplx \
- template_typedef_cplx2 \
- template_typedef_cplx3 \
- template_typedef_cplx4 \
- template_typedef_cplx5 \
- template_typedef_ns \
- template_typedef_rec \
- threads \
- typedef_array_member \
- typedef_sizet \
+# *** line 31. can't copy typemap?? \
typemap_namespace \
- union_scope \
- using_pointers \
- valuewrapper_opaque \
- varargs \
- virtual_poly \
- voidtest \
- wrapmacro
# these aren't working due to longlong support. (low hanging fruit)
CPP_TEST_BROKEN_LONGLONG = \
arrays_dimensionless \
arrays_global \
arrays_global_twodim \
- li_stdint \
li_typemaps \
+ li_windows \
long_long_apply \
- mixed_types \
primitive_ref \
reference_global_vars \
template_default_arg
# These are currently unsupported.
CPP_TEST_CASES_ACL_UNSUPPORTED = \
+# contract support \
aggregate \
+# directors support \
+ apply_signed_char \
+# contract support \
contract \
- director_abstract \
- director_basic \
- director_constructor \
- director_detect \
- director_default \
- director_enum \
director_exception \
- director_frob \
- director_finalizer \
- director_nested \
director_protected \
- director_redefined \
- director_unroll \
- director_using \
- director_wombat \
exception_order \
+# 'throws' typemap support \
extern_throws \
- throw_exception
+ throw_exception \
+ using_pointers \
C_TEST_CASES_ACL_BROKEN = \
- arrays \
- enums \
- extern_declaration \
- immutable \
- integers \
+# 'cdate.i' module support \
li_cdata \
+# adding an existing type defnition... \
+ typedef_struct \
+# swigrun.swg support. \
typemap_subst
C_TEST_BROKEN_LONGLONG = \
@@ -128,12 +87,10 @@ C_TEST_BROKEN_LONGLONG = \
# std lib support hasn't been done yet.
SKIP_CPP_STD_CASES = Yes
-C_TEST_CASES =
-
-CPP_TEST_CASES =
-
include $(srcdir)/../common.mk
+# SWIGOPT += -debug-module 4
+
# Rules for the different types of tests
%.cpptest:
$(setup)
@@ -157,9 +114,8 @@ run_testcase = \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(ALLEGROCLBIN) -batch -s $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
fi;
-# Clean: (does nothing, we dont generate extra allegrocl code)
%.clean:
-
+ @rm -f $*.cl
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile allegrocl_clean
diff --git a/Examples/test-suite/python/argcargvtest.i b/Examples/test-suite/argcargvtest.i
index ed5aa0985..ed5aa0985 100644
--- a/Examples/test-suite/python/argcargvtest.i
+++ b/Examples/test-suite/argcargvtest.i
diff --git a/Examples/test-suite/python/callback.i b/Examples/test-suite/callback.i
index c4d50d3fe..c4d50d3fe 100644
--- a/Examples/test-suite/python/callback.i
+++ b/Examples/test-suite/callback.i
diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i
index 126a58215..12e4b5aa2 100644
--- a/Examples/test-suite/char_strings.i
+++ b/Examples/test-suite/char_strings.i
@@ -9,8 +9,13 @@ below.
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
+#ifdef SWIG_ALLEGRO_CL
%{
#include <stdio.h>
+%}
+#endif
+
+%{
#define OTHERLAND_MSG "Little message from the safe world."
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
static char *global_str = NULL;
diff --git a/Examples/test-suite/chicken/Makefile.in b/Examples/test-suite/chicken/Makefile.in
index ef6d7056c..764518880 100644
--- a/Examples/test-suite/chicken/Makefile.in
+++ b/Examples/test-suite/chicken/Makefile.in
@@ -19,7 +19,7 @@ SKIP_CPP_STD_CASES = Yes
CPP_TEST_CASES += li_std_string
-EXTRA_TEST_CASES += ext_test.externaltest
+EXTRA_TEST_CASES += chicken_ext_test.externaltest
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/chicken/ext_test_runme.ss b/Examples/test-suite/chicken/chicken_ext_test_runme.ss
index ea3eaa487..65fa4e085 100644
--- a/Examples/test-suite/chicken/ext_test_runme.ss
+++ b/Examples/test-suite/chicken/chicken_ext_test_runme.ss
@@ -1,4 +1,4 @@
-(load "ext_test.so")
+(load "chicken_ext_test.so")
(define a (test-create))
diff --git a/Examples/test-suite/chicken/ext_test.i b/Examples/test-suite/chicken_ext_test.i
index e8f5930df..b4f726cc7 100644
--- a/Examples/test-suite/chicken/ext_test.i
+++ b/Examples/test-suite/chicken_ext_test.i
@@ -1,4 +1,4 @@
-%module ext_test
+%module chicken_ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 7bf8474a3..7afb55bb2 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -59,11 +59,12 @@ CXXSRCS =
CSRCS =
TARGETPREFIX =
TARGETSUFFIX =
-SWIGOPT = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE) -DSWIG_NOEXTRA_QUALIFICATION
-INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$(LANGUAGE) -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+SWIGOPT = -outcurrentdir -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
+INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
LIBS = -L.
LIBPREFIX = lib
ACTION = check
+INTERFACEDIR = $(if $(wildcard $*.i), ./, ../)
#
# Please keep test cases in alphabetical order.
@@ -76,8 +77,9 @@ CPP_TEST_BROKEN += \
cpp_broken \
exception_partial_info \
extend_variable \
+ li_std_vector_ptr \
namespace_union \
- nested_comment \
+ nested_struct \
overload_complicated \
template_default_pointer \
template_expr
@@ -164,6 +166,7 @@ CPP_TEST_CASES += \
director_overload \
director_primitives \
director_protected \
+ director_protected_overloaded \
director_redefined \
director_thread \
director_unroll \
@@ -191,6 +194,7 @@ CPP_TEST_CASES += \
fragments \
friends \
fvirtual \
+ global_namespace \
global_ns_arg \
global_vars \
grouping \
@@ -205,6 +209,7 @@ CPP_TEST_CASES += \
inherit_target_language \
inherit_void_arg \
inline_initializer \
+ insert_directive \
keyword_rename \
kind \
langobj \
@@ -236,10 +241,12 @@ CPP_TEST_CASES += \
namespace_typemap \
namespace_virtual_method \
naturalvar \
+ nested_comment \
newobject1 \
null_pointer \
operator_overload \
operator_overload_break \
+ operbool \
ordering \
overload_copy \
overload_extend \
@@ -262,6 +269,7 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
+ rename_strip_encoder \
restrict_cplusplus \
return_const_value \
return_value_scope \
@@ -366,6 +374,7 @@ CPP_TEST_CASES += \
typemap_namespace \
typemap_ns_using \
typemap_numinputs \
+ typemap_out_optimal \
typemap_variables \
typemap_various \
typename \
@@ -406,6 +415,7 @@ CPP_STD_TEST_CASES += \
template_typedef_fnc \
template_type_namespace \
template_opaque
+# li_std_list
ifndef SKIP_CPP_STD_CASES
@@ -442,11 +452,13 @@ C_TEST_CASES += \
overload_extendc \
preproc \
ret_by_value \
+ simple_array \
sizeof_pointer \
sneaky1 \
struct_rename \
typedef_struct \
typemap_subst \
+ union_parameter \
unions
@@ -492,14 +504,14 @@ swig_and_compile_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_c = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)
swig_and_compile_multi_cpp = \
@@ -507,7 +519,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
@@ -519,7 +531,7 @@ swig_and_compile_external = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS) $*_external.cxx" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
- TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACE="$*.i" \
+ TARGET="$(TARGETPREFIX)$*$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
$(LANGUAGE)$(VARIANT)_cpp
swig_and_compile_runtime = \
diff --git a/Examples/test-suite/python/complextest.i b/Examples/test-suite/complextest.i
index 64c751a82..64c751a82 100644
--- a/Examples/test-suite/python/complextest.i
+++ b/Examples/test-suite/complextest.i
diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i
index 760f8e994..174808c1e 100644
--- a/Examples/test-suite/contract.i
+++ b/Examples/test-suite/contract.i
@@ -202,3 +202,33 @@ struct E {
};
%}
+
+// Namespace
+
+%{
+namespace myNames {
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+%}
+
+namespace myNames {
+
+%contract myClass::myClass( int i ) {
+require:
+ i > 0;
+}
+
+class myClass
+{
+ public:
+ myClass(int i) {}
+};
+
+}
+
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 5fd576ed8..5fb547f3f 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -21,12 +21,17 @@ CPP_TEST_CASES = \
enum_thorough_typesafe \
exception_partial_info
-CUSTOM_TEST_CASES = intermediary_classname
+CUSTOM_TEST_CASES = \
+ csharp_lib_arrays \
+ intermediary_classname
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL)
+INTERFACEDIR = ../../
+
+CSHARPFLAGSSPECIAL =
# Rules for the different types of tests
%.cpptest:
@@ -47,6 +52,8 @@ SWIGOPT += -namespace $*Namespace $(SWIGOPTSPECIAL)
# Rules for custom tests
intermediary_classname.customtest:
$(MAKE) intermediary_classname.cpptest SWIGOPTSPECIAL="-dllimport intermediary_classname"
+csharp_lib_arrays.customtest:
+ $(MAKE) csharp_lib_arrays.cpptest CSHARPFLAGSSPECIAL="-unsafe"
# Makes a directory for the testcase if it does not exist
setup = \
@@ -65,14 +72,14 @@ setup = \
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
- CSHARPFLAGS='-nologo -out:$*_runme.exe' \
+ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \
$*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; ) \
else ( \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
- CSHARPFLAGS='-nologo -t:module -out:$*.netmodule' \
+ CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='*.cs' csharp_compile; ); \
fi;
diff --git a/Examples/test-suite/csharp/bools_runme.cs b/Examples/test-suite/csharp/bools_runme.cs
index 70620fcef..70620fcef 100755..100644
--- a/Examples/test-suite/csharp/bools_runme.cs
+++ b/Examples/test-suite/csharp/bools_runme.cs
diff --git a/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs
new file mode 100644
index 000000000..9f3ea6b88
--- /dev/null
+++ b/Examples/test-suite/csharp/csharp_lib_arrays_runme.cs
@@ -0,0 +1,70 @@
+using System;
+using csharp_lib_arraysNamespace;
+
+public class runme
+{
+ static void Main()
+ {
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[ source.Length ];
+
+ csharp_lib_arrays.myArrayCopy( source, target, target.Length );
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[ source.Length ];
+
+ csharp_lib_arrays.myArrayCopyUsingFixedArrays( source, target, target.Length );
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[] { 6, 7, 8, 9, 10 };
+
+ csharp_lib_arrays.myArraySwap( source, target, target.Length );
+
+ for (int i=0; i<target.Length; ++i)
+ target[i] += 5;
+ CompareArrays(source, target);
+ }
+
+ {
+ int[] source = { 1, 2, 3, 4, 5 };
+ int[] target = new int[] { 6, 7, 8, 9, 10 };
+
+ csharp_lib_arrays.myArraySwapUsingFixedArrays( source, target, target.Length );
+
+ for (int i=0; i<target.Length; ++i)
+ target[i] += 5;
+ CompareArrays(source, target);
+ }
+ }
+
+ static void CompareArrays( int[] a, int[] b )
+ {
+ if (a.Length != b.Length)
+ throw new Exception("size mismatch");
+
+ for(int i=0; i<a.Length; ++i) {
+ if (a[i] != b[i]) {
+ Console.Error.WriteLine("a:");
+ PrintArray(a);
+ Console.Error.WriteLine("b:");
+ PrintArray(b);
+ throw new Exception("element mismatch");
+ }
+ }
+ }
+
+ static void PrintArray( int[] a )
+ {
+ foreach ( int i in a )
+ Console.Error.Write( "{0} ", i );
+ Console.Error.WriteLine();
+ }
+}
+
diff --git a/Examples/test-suite/csharp/director_classic_runme.cs b/Examples/test-suite/csharp/director_classic_runme.cs
index 7220437d5..7220437d5 100755..100644
--- a/Examples/test-suite/csharp/director_classic_runme.cs
+++ b/Examples/test-suite/csharp/director_classic_runme.cs
diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs
index 765347e4b..144736f2b 100755..100644
--- a/Examples/test-suite/csharp/enum_thorough_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_runme.cs
@@ -358,12 +358,51 @@ public class runme {
i.MemberInstance = Instances.memberinstance3;
if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
+ if ((int)enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
+ if ((int)enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
+ if ((int)enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
+ if ((int)enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
+ if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
+ if ((int)enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if ((int)enum_thorough.repeatTest(repeat.one) != 1) throw new Exception("repeatTest 1 failed");
if ((int)enum_thorough.repeatTest(repeat.initial) != 1) throw new Exception("repeatTest 2 failed");
if ((int)enum_thorough.repeatTest(repeat.two) != 2) throw new Exception("repeatTest 3 failed");
if ((int)enum_thorough.repeatTest(repeat.three) != 3) throw new Exception("repeatTest 4 failed");
- if ((int)enum_thorough.repeatTest(repeat.last) != 3) throw new Exception("repeatTest 5 failed");
+ if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
index f8556ff37..d5bba1b7d 100644
--- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
@@ -358,12 +358,51 @@ public class runme {
i.MemberInstance = Instances.memberinstance3;
if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if (enum_thorough_simple.repeatTest(enum_thorough_simple.one) != 1) throw new Exception("repeatTest 1 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.initial) != 1) throw new Exception("repeatTest 2 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.two) != 2) throw new Exception("repeatTest 3 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.three) != 3) throw new Exception("repeatTest 4 failed");
- if (enum_thorough_simple.repeatTest(enum_thorough_simple.last) != 3) throw new Exception("repeatTest 5 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
index dc2a981de..3606d1137 100644
--- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
@@ -358,12 +358,51 @@ public class runme {
i.MemberInstance = Instances.memberinstance3;
if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue != 0) throw new Exception("ignoreATest 0 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue != 3) throw new Exception("ignoreATest 3 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue != 10) throw new Exception("ignoreATest 10 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue != 11) throw new Exception("ignoreATest 11 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue != 13) throw new Exception("ignoreATest 13 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue != 14) throw new Exception("ignoreATest 14 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue != 20) throw new Exception("ignoreATest 20 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue != 30) throw new Exception("ignoreATest 30 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue != 32) throw new Exception("ignoreATest 32 failed");
+ if (enum_thorough_typesafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue != 11) throw new Exception("ignoreBTest 11 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue != 12) throw new Exception("ignoreBTest 12 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue != 31) throw new Exception("ignoreBTest 31 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue != 32) throw new Exception("ignoreBTest 32 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue != 41) throw new Exception("ignoreBTest 41 failed");
+ if (enum_thorough_typesafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue != 10) throw new Exception("ignoreCTest 10 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue != 12) throw new Exception("ignoreCTest 12 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue != 30) throw new Exception("ignoreCTest 30 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue != 32) throw new Exception("ignoreCTest 32 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue != 40) throw new Exception("ignoreCTest 40 failed");
+ if (enum_thorough_typesafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue != 21) throw new Exception("ignoreDTest 21 failed");
+ if (enum_thorough_typesafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue != 0) throw new Exception("ignoreETest 0 failed");
+ if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue != 21) throw new Exception("ignoreETest 21 failed");
+ if (enum_thorough_typesafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if (enum_thorough_typesafe.repeatTest(repeat.one).swigValue != 1) throw new Exception("repeatTest 1 failed");
if (enum_thorough_typesafe.repeatTest(repeat.initial).swigValue != 1) throw new Exception("repeatTest 2 failed");
if (enum_thorough_typesafe.repeatTest(repeat.two).swigValue != 2) throw new Exception("repeatTest 3 failed");
if (enum_thorough_typesafe.repeatTest(repeat.three).swigValue != 3) throw new Exception("repeatTest 4 failed");
- if (enum_thorough_typesafe.repeatTest(repeat.last).swigValue != 3) throw new Exception("repeatTest 5 failed");
+ if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/csharp/inherit_target_language_runme.cs b/Examples/test-suite/csharp/inherit_target_language_runme.cs
new file mode 100644
index 000000000..2f9e2a75d
--- /dev/null
+++ b/Examples/test-suite/csharp/inherit_target_language_runme.cs
@@ -0,0 +1,24 @@
+using System;
+using inherit_target_languageNamespace;
+
+public class inherit_target_language_runme {
+ public static void Main() {
+ new Derived1().targetLanguageBaseMethod();
+ new Derived2().targetLanguageBaseMethod();
+
+ new MultipleDerived1().targetLanguageBaseMethod();
+ new MultipleDerived2().targetLanguageBaseMethod();
+ new MultipleDerived3().f();
+ new MultipleDerived4().g();
+
+ BaseX baseX = new BaseX();
+ baseX.basex();
+ baseX.targetLanguageBase2Method();
+
+ DerivedX derivedX = new DerivedX();
+ derivedX.basex();
+ derivedX.derivedx();
+ derivedX.targetLanguageBase2Method();
+ }
+}
+
diff --git a/Examples/test-suite/csharp/li_attribute_runme.cs b/Examples/test-suite/csharp/li_attribute_runme.cs
new file mode 100644
index 000000000..46f982637
--- /dev/null
+++ b/Examples/test-suite/csharp/li_attribute_runme.cs
@@ -0,0 +1,78 @@
+// Ported from Python li_attribute_runme.py
+
+using System;
+using li_attributeNamespace;
+
+public class li_attribute_runme {
+
+ public static void Main() {
+ A aa = new A(1,2,3);
+
+ if (aa.a != 1)
+ throw new ApplicationException("error");
+ aa.a = 3;
+ if (aa.a != 3)
+ throw new ApplicationException("error");
+
+ if (aa.b != 2)
+ throw new ApplicationException("error");
+ aa.b = 5;
+ if (aa.b != 5)
+ throw new ApplicationException("error");
+
+ if (aa.d != aa.b)
+ throw new ApplicationException("error");
+
+ if (aa.c != 3)
+ throw new ApplicationException("error");
+ //aa.c = 5;
+ //if (aa.c != 3)
+ // throw new ApplicationException("error");
+
+ Param_i pi = new Param_i(7);
+ if (pi.value != 7)
+ throw new ApplicationException("error");
+
+ pi.value=3;
+ if (pi.value != 3)
+ throw new ApplicationException("error");
+
+ B b = new B(aa);
+
+ if (b.a.c != 3)
+ throw new ApplicationException("error");
+
+ // class/struct attribute with get/set methods using return/pass by reference
+ MyFoo myFoo = new MyFoo();
+ myFoo.x = 8;
+ MyClass myClass = new MyClass();
+ myClass.Foo = myFoo;
+ if (myClass.Foo.x != 8)
+ throw new ApplicationException("error");
+
+ // class/struct attribute with get/set methods using return/pass by value
+ MyClassVal myClassVal = new MyClassVal();
+ if (myClassVal.ReadWriteFoo.x != -1)
+ throw new ApplicationException("error");
+ if (myClassVal.ReadOnlyFoo.x != -1)
+ throw new ApplicationException("error");
+ myClassVal.ReadWriteFoo = myFoo;
+ if (myClassVal.ReadWriteFoo.x != 8)
+ throw new ApplicationException("error");
+ if (myClassVal.ReadOnlyFoo.x != 8)
+ throw new ApplicationException("error");
+
+ // string attribute with get/set methods using return/pass by value
+ MyStringyClass myStringClass = new MyStringyClass("initial string");
+ if (myStringClass.ReadWriteString != "initial string")
+ throw new ApplicationException("error");
+ if (myStringClass.ReadOnlyString != "initial string")
+ throw new ApplicationException("error");
+ myStringClass.ReadWriteString = "changed string";
+ if (myStringClass.ReadWriteString != "changed string")
+ throw new ApplicationException("error");
+ if (myStringClass.ReadOnlyString != "changed string")
+ throw new ApplicationException("error");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs b/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs
index 27bc4628f..6ded989b5 100644
--- a/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs
+++ b/Examples/test-suite/csharp/li_boost_shared_ptr_runme.cs
@@ -345,6 +345,16 @@ public class runme
verifyCount(1, kret);
}
+ // 3rd derived class
+ {
+ Klass k = new Klass3rdDerived("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = li_boost_shared_ptr.test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
////////////////////////////////// Member variables ////////////////////////////////////////
// smart pointer by value
diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs
new file mode 100644
index 000000000..685b20e47
--- /dev/null
+++ b/Examples/test-suite/csharp/li_std_map_runme.cs
@@ -0,0 +1,243 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * li_std_map_runme.cs
+ *
+ * SWIG C# tester for std_map.i
+ * Implementation by Yuval Baror (http://yuval.bar-or.org)
+ *
+ * This class tests all the functionality of the std_map.i wrapper.
+ * Upon successful testing, the main function doesn't print out anything.
+ * If any error is found - it will be printed on the screen.
+ * ----------------------------------------------------------------------------- */
+
+using System;
+using System.Collections.Generic;
+using li_std_mapNamespace;
+
+public class li_std_map_runme {
+
+ private static readonly int collectionSize = 20;
+ private static readonly int midCollection = collectionSize / 2;
+
+ public static void Main()
+ {
+ // Set up an int int map
+ StringIntMap simap = new StringIntMap();
+ for (int i = 0; i < collectionSize; i++)
+ {
+ int val = i * 18;
+ simap.Add(i.ToString(), val);
+ }
+
+ // Count property test
+ if (simap.Count != collectionSize)
+ throw new Exception("Count test failed");
+
+ // IsReadOnly property test
+ if (simap.IsReadOnly)
+ throw new Exception("IsReadOnly test failed");
+
+ // Item indexing test
+ simap["0"] = 200;
+ if (simap["0"] != 200)
+ throw new Exception("Item property test failed");
+ simap["0"] = 0 * 18;
+
+ // ContainsKey() test
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!simap.ContainsKey(i.ToString()))
+ throw new Exception("ContainsKey test " + i + " failed");
+ }
+
+ // ContainsKey() test
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!simap.Contains(new KeyValuePair<string, int>(i.ToString(), i * 18)))
+ throw new Exception("Contains test " + i + " failed");
+ }
+
+ // TryGetValue() test
+ int value;
+ bool rc = simap.TryGetValue("3", out value);
+ if (rc != true || value != (3 * 18))
+ throw new Exception("TryGetValue test 1 failed");
+
+ rc = simap.TryGetValue("-1", out value);
+ if (rc != false)
+ throw new Exception("TryGetValue test 2 failed");
+
+ // Keys and Values test
+ {
+ IList<string> keys = new List<string>(simap.Keys);
+ IList<int> values = new List<int>(simap.Values);
+ if (keys.Count != collectionSize)
+ throw new Exception("Keys count test failed");
+
+ if (values.Count != collectionSize)
+ throw new Exception("Values count test failed");
+
+ for (int i = 0; i < keys.Count; i++)
+ {
+ if (simap[keys[i]] != values[i])
+ throw new Exception("Keys and values test failed for index " + i);
+ }
+ }
+
+ // Add and Remove test
+ for (int i = 100; i < 103; i++)
+ {
+ simap.Add(i.ToString(), i * 18);
+ if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
+ throw new Exception("Add test failed for index " + i);
+
+ simap.Remove(i.ToString());
+ if (simap.ContainsKey(i.ToString()))
+ throw new Exception("Remove test failed for index " + i);
+ }
+
+ for (int i = 200; i < 203; i++)
+ {
+ simap.Add(new KeyValuePair<string, int>(i.ToString(), i * 18));
+ if (!simap.ContainsKey(i.ToString()) || simap[i.ToString()] != (i * 18))
+ throw new Exception("Add explicit test failed for index " + i);
+
+ simap.Remove(new KeyValuePair<string, int>(i.ToString(), i * 18));
+ if (simap.ContainsKey(i.ToString()))
+ throw new Exception("Remove explicit test failed for index " + i);
+ }
+
+ // Duplicate key test
+ try
+ {
+ simap.Add("3", 0);
+ throw new Exception("Adding duplicate key test failed");
+ }
+ catch (ArgumentException)
+ {
+ }
+
+ // CopyTo() test
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize];
+ simap.CopyTo(outputarray);
+ foreach (KeyValuePair<string, int> val in outputarray)
+ {
+ if (simap[val.Key] != val.Value)
+ throw new Exception("CopyTo (1) test failed, index:" + val.Key);
+ }
+ }
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[midCollection + collectionSize];
+ simap.CopyTo(outputarray, midCollection);
+ for (int i = midCollection; i < midCollection + collectionSize; i++)
+ {
+ KeyValuePair<string, int> val = outputarray[i];
+ if (simap[val.Key] != val.Value)
+ throw new Exception("CopyTo (2) test failed, index:" + val.Key);
+ }
+ }
+ {
+ KeyValuePair<string, int>[] outputarray = new KeyValuePair<string, int>[collectionSize - 1];
+ try
+ {
+ simap.CopyTo(outputarray);
+ throw new Exception("CopyTo (4) test failed");
+ }
+ catch (ArgumentException)
+ {
+ }
+ }
+
+ // Clear test
+ simap.Clear();
+ if (simap.Count != 0)
+ throw new Exception("Clear test failed");
+
+ // Test wrapped methods
+ for (int i = 1; i <= 5; i++)
+ {
+ simap[i.ToString()] = i;
+ }
+ double avg = li_std_map.valueAverage(simap);
+ if (avg != 3.0)
+ throw new Exception("Wrapped method valueAverage test failed. Got " + avg);
+
+ string keyStringified = li_std_map.stringifyKeys(simap);
+ if (keyStringified != " 1 2 3 4 5")
+ throw new Exception("Wrapped method stringifyKeys test failed. Got " + keyStringified);
+
+ // Test a map with a new specialized type (Struct)
+ {
+ IntStructMap ismap = new IntStructMap();
+ for (int i = 0; i < 10; i++)
+ {
+ ismap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (ismap.Count != 10)
+ throw new Exception("Count test on specialized map failed");
+
+ foreach (KeyValuePair<int, Struct> p in ismap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on specialized map failed for index " + p.Key);
+ }
+ }
+
+ // Test a map of pointers
+ {
+ IntStructPtrMap ispmap = new IntStructPtrMap();
+ for (int i = 0; i < 10; i++)
+ {
+ ispmap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (ispmap.Count != 10)
+ throw new Exception("Count test on specialized pointer map failed");
+
+ foreach (KeyValuePair<int, Struct> p in ispmap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on specialized pointer map failed for index " + p.Key);
+ }
+ }
+ {
+ IntStructConstPtrMap iscpmap = new IntStructConstPtrMap();
+ for (int i = 0; i < 10; i++)
+ {
+ iscpmap.Add(i, new Struct(i * 10.1));
+ }
+
+ if (iscpmap.Count != 10)
+ throw new Exception("Count test on specialized const pointer map failed");
+
+ foreach (KeyValuePair<int, Struct> p in iscpmap)
+ {
+ if ((p.Key * 10.1) != p.Value.num)
+ throw new Exception("Iteration test on specialized const pointer map failed for index " + p.Key);
+ }
+ }
+
+ // Test non-specialized map
+ {
+ StructIntMap limap = new StructIntMap();
+ Struct s7 = new Struct(7);
+ Struct s8 = new Struct(8);
+ limap.setitem(s7 , 8);
+ if (limap.getitem(s7) != 8)
+ throw new Exception("Assignment test on non-specialized map failed");
+
+ if (!limap.ContainsKey(s7))
+ throw new Exception("Key test (1) on non-specialized map failed");
+
+ if (limap.ContainsKey(s8))
+ throw new Exception("Key test (2) on non-specialized map failed");
+ }
+
+ // All done
+ }
+}
+
diff --git a/Examples/test-suite/csharp/li_std_vector_runme.cs b/Examples/test-suite/csharp/li_std_vector_runme.cs
index 718087336..a2da91e15 100644
--- a/Examples/test-suite/csharp/li_std_vector_runme.cs
+++ b/Examples/test-suite/csharp/li_std_vector_runme.cs
@@ -82,14 +82,17 @@ public class li_std_vector_runme {
} catch (ArgumentException) {
}
}
+#if SWIG_DOTNET_1
{
+ // runtime check that 2D arrays fail
double[,] outputarray = new double[collectionSize,collectionSize];
try {
vect.CopyTo(outputarray);
- throw new Exception("CopyTo (5) test failed");
+ throw new Exception("CopyTo (5a) test failed");
} catch (ArgumentException) {
}
}
+#endif
{
StructVector inputvector = new StructVector();
int arrayLen = 10;
@@ -150,10 +153,13 @@ public class li_std_vector_runme {
}
}
try {
- new DoubleVector(null);
+ new DoubleVector((System.Collections.ICollection)null);
throw new Exception("ICollection constructor null test failed");
} catch (ArgumentNullException) {
}
+ {
+ myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
+ }
// IndexOf() test
for (int i=0; i<collectionSize; i++) {
@@ -174,6 +180,13 @@ public class li_std_vector_runme {
throw new Exception("LastIndexOf non-existent test failed");
if (dv.LastIndexOf(33.3) != 6)
throw new Exception("LastIndexOf position test failed");
+
+ // Copy constructor test
+ DoubleVector dvCopy = new DoubleVector(dv);
+ for (int i=0; i<doubleArray.Length; i++) {
+ if (doubleArray[i] != dvCopy[i])
+ throw new Exception("Copy constructor failed, index:" + i);
+ }
}
{
// Repeat() test
@@ -187,11 +200,22 @@ public class li_std_vector_runme {
throw new Exception("Repeat count test failed");
// Also tests enumerator
- System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
- while ( myEnumerator.MoveNext() ) {
- if ((double)myEnumerator.Current != 77.7)
- throw new Exception("Repeat test failed");
+ {
+ System.Collections.IEnumerator myEnumerator = dv.GetEnumerator();
+ while ( myEnumerator.MoveNext() ) {
+ if ((double)myEnumerator.Current != 77.7)
+ throw new Exception("Repeat (1) test failed");
+ }
}
+#if !SWIG_DOTNET_1
+ {
+ System.Collections.Generic.IEnumerator<double> myEnumerator = dv.GetEnumerator();
+ while ( myEnumerator.MoveNext() ) {
+ if (myEnumerator.Current != 77.7)
+ throw new Exception("Repeat (2) test failed");
+ }
+ }
+#endif
}
{
@@ -516,6 +540,13 @@ public class li_std_vector_runme {
li_std_vector.halve_in_place(dvec);
}
+ // Dispose()
+ {
+ using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } )
+ using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) {
+ }
+ }
+
// More wrapped methods
{
RealVector v0 = li_std_vector.vecreal(new RealVector());
diff --git a/Examples/test-suite/csharp/li_std_wstring_runme.cs b/Examples/test-suite/csharp/li_std_wstring_runme.cs
index fe663a3e0..fe663a3e0 100755..100644
--- a/Examples/test-suite/csharp/li_std_wstring_runme.cs
+++ b/Examples/test-suite/csharp/li_std_wstring_runme.cs
diff --git a/Examples/test-suite/csharp/overload_complicated_runme.cs b/Examples/test-suite/csharp/overload_complicated_runme.cs
index 13741827e..13741827e 100755..100644
--- a/Examples/test-suite/csharp/overload_complicated_runme.cs
+++ b/Examples/test-suite/csharp/overload_complicated_runme.cs
diff --git a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs
new file mode 100644
index 000000000..5bc1d14be
--- /dev/null
+++ b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs
@@ -0,0 +1,13 @@
+using System;
+using typemap_out_optimalNamespace;
+
+public class typemap_out_optimal_runme {
+
+ public static XX x = null;
+ public static void Main() {
+ XX.debug = false;
+ x = XX.create();
+ }
+
+}
+
diff --git a/Examples/test-suite/csharp_lib_arrays.i b/Examples/test-suite/csharp_lib_arrays.i
new file mode 100644
index 000000000..d07d43737
--- /dev/null
+++ b/Examples/test-suite/csharp_lib_arrays.i
@@ -0,0 +1,61 @@
+%module csharp_lib_arrays
+
+%include "arrays_csharp.i"
+
+%apply int INPUT[] { int* sourceArray }
+%apply int OUTPUT[] { int* targetArray }
+
+%apply int INOUT[] { int* array1 }
+%apply int INOUT[] { int* array2 }
+
+%inline %{
+/* copy the contents of the first array to the second */
+void myArrayCopy( int* sourceArray, int* targetArray, int nitems ) {
+ int i;
+ for ( i = 0; i < nitems; i++ ) {
+ targetArray[ i ] = sourceArray[ i ];
+ }
+}
+
+/* swap the contents of the two arrays */
+void myArraySwap( int* array1, int* array2, int nitems ) {
+ int i, temp;
+ for ( i = 0; i < nitems; i++ ) {
+ temp = array1[ i ];
+ array1[ i ] = array2[ i ];
+ array2[ i ] = temp;
+ }
+}
+%}
+
+
+%clear int* sourceArray;
+%clear int* targetArray;
+
+%clear int* array1;
+%clear int* array2;
+
+
+// Below replicates the above array handling but this time using the pinned (fixed) array typemaps
+%csmethodmodifiers myArrayCopyUsingFixedArrays "public unsafe";
+%csmethodmodifiers myArraySwapUsingFixedArrays "public unsafe";
+
+%apply int FIXED[] { int* sourceArray }
+%apply int FIXED[] { int* targetArray }
+
+%inline %{
+void myArrayCopyUsingFixedArrays( int *sourceArray, int* targetArray, int nitems ) {
+ myArrayCopy(sourceArray, targetArray, nitems);
+}
+%}
+
+%apply int FIXED[] { int* array1 }
+%apply int FIXED[] { int* array2 }
+
+%inline %{
+void myArraySwapUsingFixedArrays( int* array1, int* array2, int nitems ) {
+ myArraySwap(array1, array2, nitems);
+}
+%}
+
+
diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i
index 9c2cedc83..0c35c1833 100644
--- a/Examples/test-suite/csharp_prepost.i
+++ b/Examples/test-suite/csharp_prepost.i
@@ -1,6 +1,6 @@
%module csharp_prepost
-// Test the pre, post and cshin attributes for csin typemaps
+// Test the pre, post, terminate and cshin attributes for csin typemaps
%include "std_vector.i"
@@ -88,3 +88,102 @@ public:
};
%}
+
+
+// test Date marshalling with pre post and terminate typemap attributes (Documented in CSharp.html)
+%typemap(cstype) const CDate& "System.DateTime"
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);"
+ ) const CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+%typemap(cstype) CDate& "out System.DateTime"
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate();",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ cshin="out $csinput"
+ ) CDate &
+ "$csclassname.getCPtr(temp$csinput)"
+
+
+%inline %{
+class CDate {
+public:
+ CDate();
+ CDate(int year, int month, int day);
+ int getYear();
+ int getMonth();
+ int getDay();
+private:
+ int m_year;
+ int m_month;
+ int m_day;
+};
+struct Action {
+ int doSomething(const CDate &dateIn, CDate &dateOut);
+ Action(const CDate &dateIn, CDate& dateOut);
+};
+%}
+
+%{
+Action::Action(const CDate &dateIn, CDate& dateOut) {dateOut = dateIn;}
+int Action::doSomething(const CDate &dateIn, CDate &dateOut) { dateOut = dateIn; return 0; }
+CDate::CDate() : m_year(0), m_month(0), m_day(0) {}
+CDate::CDate(int year, int month, int day) : m_year(year), m_month(month), m_day(day) {}
+int CDate::getYear() { return m_year; }
+int CDate::getMonth() { return m_month; }
+int CDate::getDay() { return m_day; }
+%}
+
+%typemap(cstype, out="System.DateTime") CDate * "ref System.DateTime"
+
+%typemap(csin,
+ pre=" CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+%inline %{
+void addYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() + years, pDate->getMonth(), pDate->getDay());
+}
+%}
+
+%typemap(csin,
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
+
+%inline %{
+void subtractYears(CDate *pDate, int years) {
+ *pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
+}
+%}
+
+%typemap(csvarin, excode=SWIGEXCODE2) CDate * %{
+ /* csvarin typemap code */
+ set {
+ CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day);
+ $imcall;$excode
+ } %}
+
+%typemap(csvarout, excode=SWIGEXCODE2) CDate * %{
+ /* csvarout typemap code */
+ get {
+ IntPtr cPtr = $imcall;
+ CDate tempDate = (cPtr == IntPtr.Zero) ? null : new CDate(cPtr, $owner);$excode
+ return new System.DateTime(tempDate.getYear(), tempDate.getMonth(), tempDate.getDay(),
+ 0, 0, 0);
+ } %}
+
+%inline %{
+CDate ImportantDate = CDate(1999, 12, 31);
+%}
+
diff --git a/Examples/test-suite/director_classic.i b/Examples/test-suite/director_classic.i
index f22de4c98..f22de4c98 100755..100644
--- a/Examples/test-suite/director_classic.i
+++ b/Examples/test-suite/director_classic.i
diff --git a/Examples/test-suite/director_ignore.i b/Examples/test-suite/director_ignore.i
index 51317fbe0..51317fbe0 100755..100644
--- a/Examples/test-suite/director_ignore.i
+++ b/Examples/test-suite/director_ignore.i
diff --git a/Examples/test-suite/python/director_profile.i b/Examples/test-suite/director_profile.i
index 25ed895b5..25ed895b5 100644
--- a/Examples/test-suite/python/director_profile.i
+++ b/Examples/test-suite/director_profile.i
diff --git a/Examples/test-suite/director_protected_overloaded.i b/Examples/test-suite/director_protected_overloaded.i
new file mode 100644
index 000000000..a9f786fc7
--- /dev/null
+++ b/Examples/test-suite/director_protected_overloaded.i
@@ -0,0 +1,21 @@
+%module(directors="1",dirprot="1") director_protected_overloaded
+
+%director IDataObserver;
+%director DerivedDataObserver;
+
+// protected overloaded methods
+%inline %{
+ class IDataObserver
+ {
+ public:
+ virtual ~IDataObserver(){}
+
+ protected:
+ virtual void notoverloaded() = 0;
+ virtual void isoverloaded() = 0;
+ virtual void isoverloaded(int i) = 0;
+ virtual void isoverloaded(int i, double d) = 0;
+ };
+ class DerivedDataObserver : public IDataObserver {
+ };
+%}
diff --git a/Examples/test-suite/python/director_stl.i b/Examples/test-suite/director_stl.i
index cbcb4ba85..cbcb4ba85 100644
--- a/Examples/test-suite/python/director_stl.i
+++ b/Examples/test-suite/director_stl.i
diff --git a/Examples/test-suite/director_thread.i b/Examples/test-suite/director_thread.i
index 4f4e55cfe..2732eb907 100644
--- a/Examples/test-suite/director_thread.i
+++ b/Examples/test-suite/director_thread.i
@@ -13,6 +13,7 @@
#include <process.h>
#else
#include <pthread.h>
+#include <signal.h>
#include <unistd.h>
#endif
@@ -27,6 +28,8 @@ extern "C" {
void* working(void* t);
pthread_t thread;
#endif
+ static int thread_terminate = 0;
+
}
%}
@@ -51,6 +54,15 @@ extern "C" {
virtual ~Foo() {
}
+ void stop() {
+ thread_terminate = 1;
+ %#ifdef _WIN32
+ /*TODO(bhy) what to do for win32? */
+ %#else
+ pthread_join(thread, NULL);
+ %#endif
+ }
+
void run() {
%#ifdef _WIN32
_beginthreadex(NULL,0,working,this,0,&thread_id);
@@ -75,10 +87,15 @@ extern "C" {
#endif
{
Foo* f = static_cast<Foo*>(t);
- while (1) {
+ while ( ! thread_terminate ) {
MilliSecondSleep(50);
f->do_foo();
}
+#ifdef _WIN32
+ /* TODO(bhy) what's the corresponding of pthread_exit in win32? */
+#else
+ pthread_exit(0);
+#endif
return 0;
}
}
diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i
index 31e3e2105..974227a01 100644
--- a/Examples/test-suite/enum_thorough.i
+++ b/Examples/test-suite/enum_thorough.i
@@ -487,29 +487,53 @@ struct Instances {
// Repeated values
#if defined(SWIGJAVA)
%javaconst(1);
+// needed for typesafe and proper enums only
+%javaconst(0) ignoreA_three;
+%javaconst(0) ignoreA_thirteen;
#elif defined(SWIGCSHARP)
+// needed for typesafe enums only
+#ifdef SWIG_TEST_NOCSCONST
+ %csconst(0) ignoreA_three;
+ %csconst(0) ignoreA_thirteen;
+#endif
%csconst(1);
#endif
-#if defined(SWIGPERL)
-%inline %{
+%ignore ignoreA_one;
+%ignore ignoreA_two;
+%ignore ignoreA_twelve;
+%ignore ignoreA_thirty_one;
-namespace RepeatSpace {
-typedef enum
-{
- one = 1,
- initial = one,
- two,
- three,
- llast = three,
- end = llast
-} repeat;
-repeat repeatTest(repeat e) { return e; }
-}
+%ignore ignoreB_ten;
+%ignore ignoreB_twenty;
+%ignore ignoreB_thirty;
+%ignore ignoreB_forty;
+
+%ignore ignoreC_eleven;
+%ignore ignoreC_thirty_one;
+%ignore ignoreC_forty_one;
+
+%ignore ignoreD_ten;
+%ignore ignoreD_twenty;
+
+%ignore ignoreE_twenty;
+
+%inline %{
+struct IgnoreTest {
+ enum IgnoreA { ignoreA_zero, ignoreA_one, ignoreA_two, ignoreA_three, ignoreA_ten=10, ignoreA_eleven, ignoreA_twelve, ignoreA_thirteen, ignoreA_fourteen, ignoreA_twenty=20, ignoreA_thirty=30, ignoreA_thirty_one, ignoreA_thirty_two, ignoreA_thirty_three };
+ enum IgnoreB { ignoreB_ten=10, ignoreB_eleven, ignoreB_twelve, ignoreB_twenty=20, ignoreB_thirty=30, ignoreB_thirty_one, ignoreB_thirty_two, ignoreB_forty=40, ignoreB_forty_one, ignoreB_forty_two };
+ enum IgnoreC { ignoreC_ten=10, ignoreC_eleven, ignoreC_twelve, ignoreC_twenty=20, ignoreC_thirty=30, ignoreC_thirty_one, ignoreC_thirty_two, ignoreC_forty=40, ignoreC_forty_one, ignoreC_forty_two };
+ enum IgnoreD { ignoreD_ten=10, ignoreD_twenty=20, ignoreD_twenty_one, ignoreD_twenty_two };
+ enum IgnoreE { ignoreE_zero, ignoreE_twenty=20, ignoreE_twenty_one, ignoreE_twenty_two };
+};
+IgnoreTest::IgnoreA ignoreATest(IgnoreTest::IgnoreA n) { return n; }
+IgnoreTest::IgnoreB ignoreBTest(IgnoreTest::IgnoreB n) { return n; }
+IgnoreTest::IgnoreC ignoreCTest(IgnoreTest::IgnoreC n) { return n; }
+IgnoreTest::IgnoreD ignoreDTest(IgnoreTest::IgnoreD n) { return n; }
+IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; }
%}
-#else
%inline %{
namespace RepeatSpace {
@@ -519,14 +543,11 @@ typedef enum
initial = one,
two,
three,
- last = three,
- end = last
+ llast = three,
+ end = llast
} repeat;
repeat repeatTest(repeat e) { return e; }
}
%}
-
-#endif
-
diff --git a/Examples/test-suite/enum_thorough_typesafe.i b/Examples/test-suite/enum_thorough_typesafe.i
index 8bae5b07a..e205e8ad1 100644
--- a/Examples/test-suite/enum_thorough_typesafe.i
+++ b/Examples/test-suite/enum_thorough_typesafe.i
@@ -3,5 +3,7 @@
// Test enum wrapping using the typesafe enum pattern in the target language
%include "enumtypesafe.swg"
+#define SWIG_TEST_NOCSCONST // For C# typesafe enums
+
%include "enum_thorough.i"
diff --git a/Examples/test-suite/features.i b/Examples/test-suite/features.i
index 2db51ae6b..2ccbe725a 100644
--- a/Examples/test-suite/features.i
+++ b/Examples/test-suite/features.i
@@ -162,3 +162,20 @@ namespace Space {
}
%}
+// Test 8 conversion operators
+%rename(opbool) operator bool;
+%rename(opuint) operator unsigned int;
+
+%exception ConversionOperators::ConversionOperators() "$action /* ConversionOperators::ConversionOperators() */";
+%exception ConversionOperators::~ConversionOperators() "$action /* ConversionOperators::~ConversionOperators() */";
+%exception ConversionOperators::operator bool "$action /* ConversionOperators::operator bool */";
+%exception ConversionOperators::operator unsigned int "$action /* ConversionOperators::unsigned int*/";
+
+%inline %{
+ class ConversionOperators {
+ public:
+ operator bool() { return false; }
+ operator unsigned int() { return 0; }
+ };
+%}
+
diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i
new file mode 100644
index 000000000..02139f6c4
--- /dev/null
+++ b/Examples/test-suite/global_namespace.i
@@ -0,0 +1,60 @@
+%module global_namespace
+
+// classes
+%inline %{
+class Klass1 {};
+class Klass2 {};
+class Klass3 {};
+class Klass4 {};
+class Klass5 {};
+class Klass6 {};
+class Klass7 {};
+
+struct KlassMethods {
+ static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, Klass7*& pr) {}
+ static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {}
+};
+%}
+
+%inline %{
+namespace Space {
+class XYZ1 {};
+class XYZ2 {};
+class XYZ3 {};
+class XYZ4 {};
+class XYZ5 {};
+class XYZ6 {};
+class XYZ7 {};
+}
+
+struct XYZMethods {
+ static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, Space::XYZ7*& pr) {}
+ static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {}
+};
+%}
+
+//enums
+%inline %{
+enum AnEnum1 { anenum1 };
+enum AnEnum2 { anenum2 };
+enum AnEnum3 { anenum3 };
+
+struct AnEnumMethods {
+ static void methodA(::AnEnum1 v, const ::AnEnum2 cv, const ::AnEnum3 &cr) {}
+ static void methodB( AnEnum1 v, const AnEnum2 cv, const AnEnum3 &cr) {}
+};
+%}
+
+%inline %{
+namespace Space {
+enum TheEnum1 { theenum1 };
+enum TheEnum2 { theenum2 };
+enum TheEnum3 { theenum3 };
+
+struct TheEnumMethods {
+ static void methodA(::Space::TheEnum1 v, const ::Space::TheEnum2 cv, const ::Space::TheEnum3 &cr) {}
+ static void methodB( Space::TheEnum1 v, const Space::TheEnum2 cv, const Space::TheEnum3 &cr) {}
+};
+}
+%}
+
diff --git a/Examples/test-suite/guile/Makefile.in b/Examples/test-suite/guile/Makefile.in
index 97f30e3b2..25d40674d 100644
--- a/Examples/test-suite/guile/Makefile.in
+++ b/Examples/test-suite/guile/Makefile.in
@@ -36,7 +36,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \
- TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
SWIGOPT=" -noruntime "; \
done
diff --git a/Examples/test-suite/guilescm/Makefile.in b/Examples/test-suite/guilescm/Makefile.in
index 04de236db..eb53f020e 100644
--- a/Examples/test-suite/guilescm/Makefile.in
+++ b/Examples/test-suite/guilescm/Makefile.in
@@ -2,7 +2,7 @@
# Makefile for guile test-suite (with SCM API)
#######################################################################
-EXTRA_TEST_CASES += ext_test.externaltest
+EXTRA_TEST_CASES += guilescm_ext_test.externaltest
include ../guile/Makefile
@@ -31,7 +31,7 @@ swig_and_compile_multi_cpp = \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT) $$SWIGOPT" NOLINK=true \
- TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACE="$$f.i" \
+ TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
$(LANGUAGE)$(VARIANT)_cpp; \
done
diff --git a/Examples/test-suite/guilescm/ext_test_runme.scm b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
index 67add849e..ff3df064b 100644
--- a/Examples/test-suite/guilescm/ext_test_runme.scm
+++ b/Examples/test-suite/guilescm/guilescm_ext_test_runme.scm
@@ -1,4 +1,4 @@
-(dynamic-call "scm_init_ext_test_module" (dynamic-link "./libext_test.so"))
+(dynamic-call "scm_init_guilescm_ext_test_module" (dynamic-link "./libguilescm_ext_test.so"))
; This is a test for SF Bug 1573892
; If IsPointer is called before TypeQuery, the test-is-pointer will fail
diff --git a/Examples/test-suite/guilescm/ext_test.i b/Examples/test-suite/guilescm_ext_test.i
index 8b117bb5a..fd5655d4f 100644
--- a/Examples/test-suite/guilescm/ext_test.i
+++ b/Examples/test-suite/guilescm_ext_test.i
@@ -1,4 +1,4 @@
-%module ext_test
+%module guilescm_ext_test
/* just use the imports_a.h header... for this test we only need a class */
%{
diff --git a/Examples/test-suite/python/iadd.h b/Examples/test-suite/iadd.i
index 367eda26f..514bd3e4f 100644
--- a/Examples/test-suite/python/iadd.h
+++ b/Examples/test-suite/iadd.i
@@ -1,3 +1,12 @@
+%module iadd
+
+%include attribute.i
+class Foo;
+%attribute_ref(test::Foo, test::A& , AsA);
+%attribute_ref(test::Foo, long, AsLong);
+
+
+%inline %{
struct B {
int x;
B(const int x) : x(x) {}
@@ -45,3 +54,5 @@ private:
long *_n;
};
}
+
+%}
diff --git a/Examples/test-suite/ignore_template_constructor.i b/Examples/test-suite/ignore_template_constructor.i
index 5225d5183..ffd541986 100644
--- a/Examples/test-suite/ignore_template_constructor.i
+++ b/Examples/test-suite/ignore_template_constructor.i
@@ -37,3 +37,9 @@ public:
#endif
%template(VectFlow) std::vector<Flow>;
+
+%inline %{
+std::vector<Flow> inandout(std::vector<Flow> v) {
+ return v;
+}
+%}
diff --git a/Examples/test-suite/octave/implicittest.i b/Examples/test-suite/implicittest.i
index 91205aafa..91205aafa 100644
--- a/Examples/test-suite/octave/implicittest.i
+++ b/Examples/test-suite/implicittest.i
diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i
index b06f14001..3cf511032 100644
--- a/Examples/test-suite/import_nomodule.i
+++ b/Examples/test-suite/import_nomodule.i
@@ -3,6 +3,9 @@
#include "import_nomodule.h"
%}
+// For Python
+%warnfilter(SWIGWARN_TYPE_UNDEFINED_CLASS) Bar; // Base class 'Foo' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %import directive.
+
%import "import_nomodule.h"
#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGCOM)
diff --git a/Examples/test-suite/imports_b.i b/Examples/test-suite/imports_b.i
index afc573a39..81e84cddd 100644
--- a/Examples/test-suite/imports_b.i
+++ b/Examples/test-suite/imports_b.i
@@ -34,9 +34,14 @@
*/
#if 0
-%import "imports_a.i"
+ %import "imports_a.i"
#else
-%import(module="imports_a") "imports_a.h"
+# if 0
+ // Test Warning 401 (Python only)
+ %import "imports_a.h"
+# else
+ %import(module="imports_a") "imports_a.h"
+# endif
#endif
%include "imports_b.h"
diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i
index 770e11d36..20fb93fda 100644
--- a/Examples/test-suite/inherit_target_language.i
+++ b/Examples/test-suite/inherit_target_language.i
@@ -12,10 +12,12 @@
using System;
using System.Runtime.InteropServices;
public class TargetLanguageBase { public virtual void targetLanguageBaseMethod() {} };
+public class TargetLanguageBase2 { public virtual void targetLanguageBase2Method() {} };
%}
%pragma(java) moduleimports=%{
class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
+class TargetLanguageBase2 { public void targetLanguageBase2Method() {} };
%}
@@ -61,3 +63,11 @@ struct MultipleDerived3 : MBase3a, MBase3b {};
struct MultipleDerived4 : MBase4a, MBase4b {};
%}
+// Replace a C++ base, but only classes that do not have a C++ base
+%typemap(csbase, notderived="1") SWIGTYPE "TargetLanguageBase2"
+
+%inline %{
+struct BaseX { virtual ~BaseX() {}; void basex() {} };
+struct DerivedX : BaseX { void derivedx() {} };
+%}
+
diff --git a/Examples/test-suite/python/inout.i b/Examples/test-suite/inout.i
index dc6db0ecb..dc6db0ecb 100644
--- a/Examples/test-suite/python/inout.i
+++ b/Examples/test-suite/inout.i
diff --git a/Examples/test-suite/python/inplaceadd.i b/Examples/test-suite/inplaceadd.i
index 91ef84bd2..91ef84bd2 100644
--- a/Examples/test-suite/python/inplaceadd.i
+++ b/Examples/test-suite/inplaceadd.i
diff --git a/Examples/test-suite/python/input.i b/Examples/test-suite/input.i
index 6cef3f9f5..6cef3f9f5 100644
--- a/Examples/test-suite/python/input.i
+++ b/Examples/test-suite/input.i
diff --git a/Examples/test-suite/insert_directive.i b/Examples/test-suite/insert_directive.i
new file mode 100644
index 000000000..8ad966a99
--- /dev/null
+++ b/Examples/test-suite/insert_directive.i
@@ -0,0 +1,38 @@
+%module insert_directive
+
+// check %insert and the order of each insert section is correct
+
+%begin %{
+// %inserted code %begin
+int inserted_begin(int i) { return i; }
+%}
+
+%runtime %{
+// %inserted code %runtime
+int inserted_runtime(int i) { return inserted_begin(i); }
+%}
+
+%{
+// %inserted code %header
+int inserted_header1(int i) { return inserted_runtime(i); }
+%}
+
+%header %{
+// %inserted code %header
+int inserted_header2(int i) { return inserted_header1(i); }
+%}
+
+%{
+// %inserted code %header
+int inserted_header3(int i) { return inserted_header2(i); }
+%}
+
+%wrapper %{
+// %inserted code %wrapper
+int inserted_wrapper(int i) { return inserted_header3(i); }
+%}
+
+%init %{
+// %inserted code %init
+int inserted_init_value = inserted_wrapper(0);
+%}
diff --git a/Examples/test-suite/intermediary_classname.i b/Examples/test-suite/intermediary_classname.i
index 0f90f9cdd..94858a5fb 100644
--- a/Examples/test-suite/intermediary_classname.i
+++ b/Examples/test-suite/intermediary_classname.i
@@ -18,6 +18,7 @@
"new $javaclassname($jniinput, false)/*javadirectorin*/"
%typemap(out, throws="IllegalAccessException/*out Base&*/") Base& {
// XYZ& typemap out
+ $result = 0; // remove unused variable warning
}
%inline %{
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index ace8dee86..03c10d498 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -32,11 +32,13 @@ CPP_TEST_CASES = \
java_throws \
java_typemaps_proxy \
java_typemaps_typewrapper
+# li_boost_intrusive_ptr
include $(srcdir)/../common.mk
# Overridden variables here
SWIGOPT += -package $*
+INTERFACEDIR = ../../
# Rules for the different types of tests
%.cpptest:
@@ -72,7 +74,7 @@ run_testcase = \
(cd $* && $(COMPILETOOL) $(JAVAC) -classpath . *.java) && \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(JAVAC) -classpath . -d . $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
- env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*\_runme;) \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_LIBRARY_PATH="$*:$$DYLD_LIBRARY_PATH" $(RUNTOOL) $(JAVA) -classpath . $*_runme;) \
fi;
# Clean: remove testcase directories
diff --git a/Examples/test-suite/java/allprotected_runme.java b/Examples/test-suite/java/allprotected_runme.java
index aa5413a95..aa5413a95 100755..100644
--- a/Examples/test-suite/java/allprotected_runme.java
+++ b/Examples/test-suite/java/allprotected_runme.java
diff --git a/Examples/test-suite/java/director_classic_runme.java b/Examples/test-suite/java/director_classic_runme.java
index 50ea2b8d3..50ea2b8d3 100755..100644
--- a/Examples/test-suite/java/director_classic_runme.java
+++ b/Examples/test-suite/java/director_classic_runme.java
diff --git a/Examples/test-suite/java/director_ignore_runme.java b/Examples/test-suite/java/director_ignore_runme.java
index 9b98ee4cf..9b98ee4cf 100755..100644
--- a/Examples/test-suite/java/director_ignore_runme.java
+++ b/Examples/test-suite/java/director_ignore_runme.java
diff --git a/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java
index 243d3bddd..66968060d 100644
--- a/Examples/test-suite/java/enum_thorough_proper_runme.java
+++ b/Examples/test-suite/java/enum_thorough_proper_runme.java
@@ -369,12 +369,51 @@ public class enum_thorough_proper_runme {
i.setMemberInstance(Instances.memberinstance3);
if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue() != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue() != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue() != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue() != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue() != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue() != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue() != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue() != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough_proper.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue() != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue() != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue() != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue() != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue() != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough_proper.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue() != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue() != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue() != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue() != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue() != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough_proper.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue() != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough_proper.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue() != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough_proper.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if (enum_thorough_proper.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed");
if (enum_thorough_proper.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed");
if (enum_thorough_proper.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed");
if (enum_thorough_proper.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed");
- if (enum_thorough_proper.repeatTest(repeat.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java
index 1cd02d38d..79c902ccf 100644
--- a/Examples/test-suite/java/enum_thorough_runme.java
+++ b/Examples/test-suite/java/enum_thorough_runme.java
@@ -369,12 +369,51 @@ public class enum_thorough_runme {
i.setMemberInstance(Instances.memberinstance3);
if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero).swigValue() != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three).swigValue() != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten).swigValue() != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven).swigValue() != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen).swigValue() != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen).swigValue() != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty).swigValue() != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty).swigValue() != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three).swigValue() != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven).swigValue() != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve).swigValue() != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one).swigValue() != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one).swigValue() != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two).swigValue() != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten).swigValue() != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve).swigValue() != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty).swigValue() != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two).swigValue() != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty).swigValue() != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two).swigValue() != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero).swigValue() != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one).swigValue() != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two).swigValue() != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if (enum_thorough.repeatTest(repeat.one).swigValue() != 1) throw new RuntimeException("repeatTest 1 failed");
if (enum_thorough.repeatTest(repeat.initial).swigValue() != 1) throw new RuntimeException("repeatTest 2 failed");
if (enum_thorough.repeatTest(repeat.two).swigValue() != 2) throw new RuntimeException("repeatTest 3 failed");
if (enum_thorough.repeatTest(repeat.three).swigValue() != 3) throw new RuntimeException("repeatTest 4 failed");
- if (enum_thorough.repeatTest(repeat.last).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java
index 9bd56273e..e54acda70 100644
--- a/Examples/test-suite/java/enum_thorough_simple_runme.java
+++ b/Examples/test-suite/java/enum_thorough_simple_runme.java
@@ -369,12 +369,51 @@ public class enum_thorough_simple_runme {
i.setMemberInstance(Instances.memberinstance3);
if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough_simple.ignoreATest(IgnoreTest.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough_simple.ignoreBTest(IgnoreTest.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough_simple.ignoreCTest(IgnoreTest.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough_simple.ignoreDTest(IgnoreTest.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough_simple.ignoreETest(IgnoreTest.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.one) != 1) throw new RuntimeException("repeatTest 1 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.initial) != 1) throw new RuntimeException("repeatTest 2 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.two) != 2) throw new RuntimeException("repeatTest 3 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.three) != 3) throw new RuntimeException("repeatTest 4 failed");
- if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.last) != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
index 35d1a1937..b00788911 100644
--- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
+++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
@@ -369,12 +369,51 @@ public class enum_thorough_typeunsafe_runme {
i.setMemberInstance(Instances.memberinstance3);
if (i.getMemberInstance() != Instances.memberinstance3) throw new RuntimeException("MemberInstance 1 failed");
}
+ // ignore enum item tests start
+ {
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new RuntimeException("ignoreATest 0 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new RuntimeException("ignoreATest 3 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new RuntimeException("ignoreATest 10 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new RuntimeException("ignoreATest 11 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new RuntimeException("ignoreATest 13 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new RuntimeException("ignoreATest 14 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new RuntimeException("ignoreATest 20 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new RuntimeException("ignoreATest 30 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new RuntimeException("ignoreATest 32 failed");
+ if (enum_thorough_typeunsafe.ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new RuntimeException("ignoreATest 33 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new RuntimeException("ignoreBTest 11 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new RuntimeException("ignoreBTest 12 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new RuntimeException("ignoreBTest 31 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new RuntimeException("ignoreBTest 32 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new RuntimeException("ignoreBTest 41 failed");
+ if (enum_thorough_typeunsafe.ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new RuntimeException("ignoreBTest 42 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new RuntimeException("ignoreCTest 10 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new RuntimeException("ignoreCTest 12 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new RuntimeException("ignoreCTest 30 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new RuntimeException("ignoreCTest 32 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new RuntimeException("ignoreCTest 40 failed");
+ if (enum_thorough_typeunsafe.ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new RuntimeException("ignoreCTest 42 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new RuntimeException("ignoreDTest 21 failed");
+ if (enum_thorough_typeunsafe.ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new RuntimeException("ignoreDTest 22 failed");
+ }
+ {
+ if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new RuntimeException("ignoreETest 0 failed");
+ if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new RuntimeException("ignoreETest 21 failed");
+ if (enum_thorough_typeunsafe.ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new RuntimeException("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
{
if (enum_thorough_typeunsafe.repeatTest(repeat.one) != 1) throw new RuntimeException("repeatTest 1 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.initial) != 1) throw new RuntimeException("repeatTest 2 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.two) != 2) throw new RuntimeException("repeatTest 3 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.three) != 3) throw new RuntimeException("repeatTest 4 failed");
- if (enum_thorough_typeunsafe.repeatTest(repeat.last) != 3) throw new RuntimeException("repeatTest 5 failed");
+ if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
}
diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java
new file mode 100644
index 000000000..faab7d4ba
--- /dev/null
+++ b/Examples/test-suite/java/global_namespace_runme.java
@@ -0,0 +1,25 @@
+import global_namespace.*;
+
+public class global_namespace_runme {
+
+ static {
+ try {
+ System.loadLibrary("global_namespace");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+
+ KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+ KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+
+ XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
+ XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
+
+ TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
+ TheEnumMethods.methodA(TheEnum1.theenum1, TheEnum2.theenum2, TheEnum3.theenum3);
+ }
+}
diff --git a/Examples/test-suite/java/inherit_target_language_runme.java b/Examples/test-suite/java/inherit_target_language_runme.java
index 6c7c1bf33..184272fe2 100644
--- a/Examples/test-suite/java/inherit_target_language_runme.java
+++ b/Examples/test-suite/java/inherit_target_language_runme.java
@@ -21,6 +21,15 @@ public class inherit_target_language_runme {
new MultipleDerived2().targetLanguageBaseMethod();
new MultipleDerived3().f();
new MultipleDerived4().g();
+
+ BaseX baseX = new BaseX();
+ baseX.basex();
+ baseX.targetLanguageBase2Method();
+
+ DerivedX derivedX = new DerivedX();
+ derivedX.basex();
+ derivedX.derivedx();
+ derivedX.targetLanguageBase2Method();
}
}
diff --git a/Examples/test-suite/java/java_throws_runme.java b/Examples/test-suite/java/java_throws_runme.java
index 3538aa6d4..6a73ea563 100644
--- a/Examples/test-suite/java/java_throws_runme.java
+++ b/Examples/test-suite/java/java_throws_runme.java
@@ -94,5 +94,20 @@ public class java_throws_runme {
if (!pass)
throw new RuntimeException("Test 7 failed");
+
+ // Test %nojavaexception
+ NoExceptTest net = new NoExceptTest();
+
+ pass = false;
+ try {
+ net.exceptionPlease();
+ pass = true;
+ }
+ catch (MyException e) {}
+
+ if (!pass)
+ throw new RuntimeException("Test 8 failed");
+
+ net.noExceptionPlease();
}
}
diff --git a/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
new file mode 100644
index 000000000..f40c28e9e
--- /dev/null
+++ b/Examples/test-suite/java/li_boost_intrusive_ptr_runme.java
@@ -0,0 +1,701 @@
+import li_boost_intrusive_ptr.*;
+
+public class li_boost_intrusive_ptr_runme {
+ static {
+ try {
+ System.loadLibrary("li_boost_intrusive_ptr");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ // Debugging flag
+ public final static boolean debug = false;
+
+ public static void main(String argv[])
+ {
+ if (debug)
+ System.out.println("Started");
+
+ li_boost_intrusive_ptr.setDebug_shared(debug);
+
+ // Change loop count to run for a long time to monitor memory
+ final int loopCount = 5000; //5000;
+ for (int i=0; i<loopCount; i++) {
+ new li_boost_intrusive_ptr_runme().runtest();
+ System.gc();
+ System.runFinalization();
+ try {
+ if (i%100 == 0) {
+ java.lang.Thread.sleep(1); // give some time to the lower priority finalizer thread
+ }
+ } catch (java.lang.InterruptedException e) {
+ }
+ }
+
+ if (debug)
+ System.out.println("Nearly finished");
+
+ int countdown = 50;
+ while (true) {
+ System.gc();
+ System.runFinalization();
+ try {
+ java.lang.Thread.sleep(100);
+ } catch (java.lang.InterruptedException e) {
+ }
+ if (--countdown == 0)
+ break;
+ if (Klass.getTotal_count() == 1 && KlassWithoutRefCount.getTotal_count() == 0 &&
+ li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() == 0 &&
+ KlassDerived.getTotal_count() == 0 && KlassDerivedDerived.getTotal_count() == 1)
+ // Expect 1 Klass instance - the one global variable (GlobalValue)
+ break;
+ };
+ if (Klass.getTotal_count() != 1)
+ throw new RuntimeException("Klass.total_count=" + Klass.getTotal_count());
+ if (KlassWithoutRefCount.getTotal_count() != 0)
+ throw new RuntimeException("KlassWithoutRefCount.total_count=" + KlassWithoutRefCount.getTotal_count());
+ if (li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count() != 0)
+ throw new RuntimeException("IgnoredRefCountingBase.total_count=" + li_boost_intrusive_ptr.getTotal_IgnoredRefCountingBase_count());
+ if (KlassDerived.getTotal_count() != 0)
+ throw new RuntimeException("KlassDerived.total_count=" + KlassDerived.getTotal_count());
+ if (KlassDerivedDerived.getTotal_count() != 0)
+ throw new RuntimeException("KlassDerivedDerived.total_count=" + KlassDerivedDerived.getTotal_count());
+
+ int wrapper_count = li_boost_intrusive_ptr.intrusive_ptr_wrapper_count();
+ if (wrapper_count != li_boost_intrusive_ptr.getNOT_COUNTING())
+ if (wrapper_count != 1) // Expect 1 instance - the one global variable (GlobalSmartValue)
+ throw new RuntimeException("shared_ptr wrapper count=" + wrapper_count);
+
+ if (debug)
+ System.out.println("Finished");
+ }
+
+ private void runtest() {
+ // simple shared_ptr usage - created in C++
+ {
+ Klass k = new Klass("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ Klass k = li_boost_intrusive_ptr.factorycreate();
+ String val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.smartpointerpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointerpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.constsmartpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, kret);
+ verifyIntrusiveCount(2, kret);
+ }
+
+ // pass by value
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.valuetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.pointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.reftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ Klass k = new Klass("me oh my");
+ Klass kret = li_boost_intrusive_ptr.pointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ if (li_boost_intrusive_ptr.smartpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerpointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (li_boost_intrusive_ptr.smartpointerpointerreftest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ if (!li_boost_intrusive_ptr.nullsmartpointerpointertest(null).equals("null pointer"))
+ throw new RuntimeException("not null smartpointer pointer");
+
+ try { li_boost_intrusive_ptr.valuetest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+
+ if (li_boost_intrusive_ptr.pointertest(k) != null)
+ throw new RuntimeException("return was not null");
+
+ try { li_boost_intrusive_ptr.reftest(k); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ // $owner
+ {
+ Klass k = li_boost_intrusive_ptr.pointerownertest();
+ String val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ Klass k = li_boost_intrusive_ptr.smartpointerpointerownertest();
+ String val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived access to base class which cannot be wrapped in an intrusive_ptr
+ {
+ KlassWithoutRefCount k = new KlassDerived("me oh my");
+ verifyValue("this class cannot be wrapped by intrusive_ptrs but we can still use it", k.getSpecialValueFromUnwrappableClass());
+ }
+ // derived pass by shared_ptr
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // derived pass by shared_ptr pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+ // derived pass by pointer
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
+ verifyCount(2, kret);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ KlassDerived k = new KlassDerived("me oh my");
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
+ verifyCount(2, kret);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(2, k); // includes extra reference for upcast
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrtest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedsmartptrpointerreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-DerivedDerived", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(2, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedvaluetest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedvaluetest-Derived", val); // note slicing
+ verifyIntrusiveCount(1, k);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret);
+ verifyCount(2, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedpointertest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-DerivedDerived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ KlassDerived k = new KlassDerivedDerived("me oh my");
+ KlassDerived kret = li_boost_intrusive_ptr.derivedreftest(k);
+ String val = kret.getValue();
+ verifyValue("me oh my derivedreftest-DerivedDerived", val);
+ verifyIntrusiveCount(1, k); //one shared_ptr has a null deleter
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyIntrusiveCount(1, kret); //one shared_ptr has a null deleter
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member value");
+ m.setSmartMemberValue(k);
+ String val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ verifyCount(1, kmember);
+
+ m.delete();
+ verifyIntrusiveCount(2, kmember);
+ verifyIntrusiveCount(2, k);
+ }
+
+ // smart pointer by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member pointer");
+ m.setSmartMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+ verifyIntrusiveCount(2, k);
+
+ Klass kmember = m.getSmartMemberPointer();
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyIntrusiveCount(2, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+ }
+ // smart pointer by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("smart member reference");
+ m.setSmartMemberReference(k);
+ String val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ Klass kmember = m.getSmartMemberReference();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ m.setSmartMemberValue(k);
+ Klass kmemberVal = m.getSmartMemberValue();
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyIntrusiveCount(5, kmemberVal);
+ verifyCount(1, kmemberVal);
+ verifyIntrusiveCount(5, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(5, k);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyIntrusiveCount(3, kmemberVal);
+ verifyCount(1, kmemberVal);
+ verifyIntrusiveCount(3, kmember);
+ verifyCount(1, kmember);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ }
+
+ //plain by value
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member value");
+ m.setMemberValue(k);
+ String val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberValue();
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //plain by pointer
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member pointer");
+ m.setMemberPointer(k);
+ String val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberPointer();
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //plain by reference
+ {
+ MemberVariables m = new MemberVariables();
+ Klass k = new Klass("plain member reference");
+ m.setMemberReference(k);
+ String val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ Klass kmember = m.getMemberReference();
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ m.delete();
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ //null member variables
+ {
+ MemberVariables m = new MemberVariables();
+
+ // shared_ptr by value
+ Klass k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ m.setSmartMemberValue(null);
+ k = m.getSmartMemberValue();
+ if (k != null)
+ throw new RuntimeException("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.setMemberValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+}
+private void toIgnore() {
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ Klass kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("smart global value");
+ li_boost_intrusive_ptr.setGlobalSmartValue(k);
+ verifyIntrusiveCount(2, k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalSmartValue();
+ String val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyIntrusiveCount(3, kglobal);
+ verifyCount(1, kglobal);
+ verifyIntrusiveCount(3, k);
+ verifyCount(1, k);
+ verifyValue("smart global value", li_boost_intrusive_ptr.getGlobalSmartValue().getValue());
+ li_boost_intrusive_ptr.setGlobalSmartValue(null);
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global value");
+ li_boost_intrusive_ptr.setGlobalValue(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalValue();
+ String val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", li_boost_intrusive_ptr.getGlobalValue().getValue());
+
+ try { li_boost_intrusive_ptr.setGlobalValue(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+ //plain pointer
+ {
+ Klass kglobal = li_boost_intrusive_ptr.getGlobalPointer();
+ if (kglobal != null)
+ throw new RuntimeException("expected null");
+
+ Klass k = new Klass("global pointer");
+ li_boost_intrusive_ptr.setGlobalPointer(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalPointer();
+ String val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ li_boost_intrusive_ptr.setGlobalPointer(null);
+ }
+
+ // plain reference
+ {
+ Klass kglobal;
+
+ Klass k = new Klass("global reference");
+ li_boost_intrusive_ptr.setGlobalReference(k);
+ verifyCount(1, k);
+
+ kglobal = li_boost_intrusive_ptr.getGlobalReference();
+ String val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { li_boost_intrusive_ptr.setGlobalReference(null); throw new RuntimeException("Failed to catch null pointer"); } catch (NullPointerException e) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.getBaseVal1() != 20 || pid.getBaseVal2() != 40.4)
+ throw new RuntimeException("Base values wrong");
+ if (pid.getVal1() != 10 || pid.getVal2() != 20.2)
+ throw new RuntimeException("Derived Values wrong");
+ }
+ }
+ private void verifyValue(String expected, String got) {
+ if (!expected.equals(got))
+ throw new RuntimeException("verify value failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, Klass k) {
+ int got = li_boost_intrusive_ptr.use_count(k);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, KlassDerived kd) {
+ int got = li_boost_intrusive_ptr.use_count(kd);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyCount(int expected, KlassDerivedDerived kdd) {
+ int got = li_boost_intrusive_ptr.use_count(kdd);
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, Klass k) {
+ int got = k.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, KlassDerived kd) {
+ int got = kd.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+ private void verifyIntrusiveCount(int expected, KlassDerivedDerived kdd) {
+ int got = kdd.use_count();
+ if (expected != got)
+ throw new RuntimeException("verify use_count failed. Expected: " + expected + " Got: " + got);
+ }
+}
diff --git a/Examples/test-suite/java/li_boost_shared_ptr_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_runme.java
index a699222e5..02d6d6502 100644
--- a/Examples/test-suite/java/li_boost_shared_ptr_runme.java
+++ b/Examples/test-suite/java/li_boost_shared_ptr_runme.java
@@ -357,6 +357,16 @@ public class li_boost_shared_ptr_runme {
verifyCount(1, kret);
}
+ // 3rd derived class
+ {
+ Klass k = new Klass3rdDerived("me oh my");
+ String val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = li_boost_shared_ptr.test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
////////////////////////////////// Member variables ////////////////////////////////////////
// smart pointer by value
diff --git a/Examples/test-suite/java/overload_complicated_runme.java b/Examples/test-suite/java/overload_complicated_runme.java
index ac8523d75..ac8523d75 100755..100644
--- a/Examples/test-suite/java/overload_complicated_runme.java
+++ b/Examples/test-suite/java/overload_complicated_runme.java
diff --git a/Examples/test-suite/java/typemap_out_optimal_runme.java b/Examples/test-suite/java/typemap_out_optimal_runme.java
new file mode 100644
index 000000000..8a87f0c4b
--- /dev/null
+++ b/Examples/test-suite/java/typemap_out_optimal_runme.java
@@ -0,0 +1,21 @@
+
+import typemap_out_optimal.*;
+
+public class typemap_out_optimal_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_out_optimal");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static XX x = null;
+ public static void main(String argv[]) {
+ XX.setDebug(false);
+ x = XX.create();
+ }
+}
+
diff --git a/Examples/test-suite/java_throws.i b/Examples/test-suite/java_throws.i
index 3aa11defb..b020fefcb 100644
--- a/Examples/test-suite/java_throws.i
+++ b/Examples/test-suite/java_throws.i
@@ -143,3 +143,41 @@ try {
}
%}
+// Test %nojavaexception
+%javaexception("MyException") %{
+/* global exception handler */
+try {
+ $action
+} catch (MyException) {
+ jclass excep = jenv->FindClass("java_throws/MyException");
+ if (excep)
+ jenv->ThrowNew(excep, "exception message");
+ return $null;
+}
+%}
+
+%nojavaexception *::noExceptionPlease();
+%nojavaexception NoExceptTest::NoExceptTest();
+
+// Need to handle the checked exception in NoExceptTest.delete()
+%typemap(javafinalize) SWIGTYPE %{
+ protected void finalize() {
+ try {
+ delete();
+ } catch (MyException e) {
+ throw new RuntimeException(e);
+ }
+ }
+%}
+
+%inline %{
+struct NoExceptTest {
+ unsigned int noExceptionPlease() { return 123; }
+ unsigned int exceptionPlease() { return 456; }
+ ~NoExceptTest() {}
+};
+%}
+
+// Turn global exceptions off (for the implicit destructors/constructors)
+%nojavaexception;
+
diff --git a/Examples/test-suite/li_attribute.i b/Examples/test-suite/li_attribute.i
index 5b4379ebf..4f9497afb 100644
--- a/Examples/test-suite/li_attribute.i
+++ b/Examples/test-suite/li_attribute.i
@@ -93,9 +93,11 @@ struct MyFoo; // %attribute2 does not work with templates
%template(Param_i) Param<int>;
+// class/struct attribute with get/set methods using return/pass by reference
%attribute2(MyClass, MyFoo, Foo, GetFoo, SetFoo);
%inline %{
struct MyFoo {
+ MyFoo() : x(-1) {}
int x;
};
class MyClass {
@@ -106,3 +108,32 @@ struct MyFoo; // %attribute2 does not work with templates
};
%}
+
+// class/struct attribute with get/set methods using return/pass by value
+%attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo);
+%attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo);
+%inline %{
+ class MyClassVal {
+ MyFoo foo;
+ public:
+ MyFoo GetFoo() { return foo; }
+ void SetFoo(MyFoo other) { foo = other; }
+ };
+%}
+
+
+// string attribute with get/set methods using return/pass by value
+%include <std_string.i>
+%attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString);
+%attributestring(MyStringyClass, std::string, ReadOnlyString, GetString);
+%inline %{
+ class MyStringyClass {
+ std::string str;
+ public:
+ MyStringyClass(const std::string &val) : str(val) {}
+ std::string GetString() { return str; }
+ void SetString(std::string other) { str = other; }
+ };
+%}
+
+
diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i
new file mode 100644
index 000000000..7c37e6843
--- /dev/null
+++ b/Examples/test-suite/li_boost_intrusive_ptr.i
@@ -0,0 +1,494 @@
+// This tests intrusive_ptr is working okay. It also checks that there are no memory leaks in the
+// class that intrusive_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
+// In order to test that there are no leaks of the intrusive_ptr class itself (as it is created on the heap)
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// like 'top'. There is a wrapper for intrusive_ptr in intrusive_ptr_wrapper.h which enables one to
+// count the instances of intrusive_ptr. Uncomment the INTRUSIVE_PTR_WRAPPER macro to turn this on.
+//
+// Also note the debug_shared flag which can be set from the target language.
+
+%module li_boost_intrusive_ptr
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+
+%inline %{
+#include "boost/shared_ptr.hpp"
+#include "boost/intrusive_ptr.hpp"
+#include <boost/detail/atomic_count.hpp>
+
+// Uncomment macro below to turn on intrusive_ptr memory leak checking as described above
+//#define INTRUSIVE_PTR_WRAPPER
+
+#ifdef INTRUSIVE_PTR_WRAPPER
+# include "intrusive_ptr_wrapper.h"
+# include "shared_ptr_wrapper.h"
+#endif
+%}
+
+%{
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SwigBoost boost
+#endif
+%}
+
+%include "std_string.i"
+#ifndef INTRUSIVE_PTR_WRAPPER
+# define SWIG_INTRUSIVE_PTR_NAMESPACE SwigBoost
+# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
+#endif
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+%include <boost_intrusive_ptr.i>
+SWIG_INTRUSIVE_PTR(Klass, Space::Klass)
+SWIG_INTRUSIVE_PTR_NO_WRAP(KlassWithoutRefCount, Space::KlassWithoutRefCount)
+SWIG_INTRUSIVE_PTR_DERIVED(KlassDerived, Space::KlassWithoutRefCount, Space::KlassDerived)
+SWIG_INTRUSIVE_PTR_DERIVED(KlassDerivedDerived, Space::KlassDerived, Space::KlassDerivedDerived)
+
+//For the use_count shared_ptr functions
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & "Klass.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerived > & "KlassDerived.getCPtr($javainput)"
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & ($*1_ltype tempnull) %{
+ $1 = $input ? *($&1_ltype)&$input : &tempnull;
+%}
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
+
+#endif
+
+// TODO:
+// const intrusive_ptr
+// std::vector
+// Add in generic %extend for the Upcast function for derived classes
+// Remove proxy upcast method - implement %feature("shadow") ??? which replaces the proxy method
+
+%exception {
+ if (debug_shared) {
+ cout << "++++++" << endl << flush;
+ cout << "calling $name" << endl << flush;
+ }
+ $action
+ if (debug_shared) {
+ cout << "------" << endl << flush;
+ }
+}
+
+%ignore IgnoredRefCountingBase;
+%ignore *::operator=;
+%ignore intrusive_ptr_add_ref;
+%ignore intrusive_ptr_release;
+%newobject pointerownertest();
+%newobject smartpointerpointerownertest();
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+static bool debug_shared = false;
+
+namespace Space {
+
+struct Klass {
+ Klass() : value("EMPTY"), count(0) { if (debug_shared) cout << "Klass() [" << value << "]" << endl << flush; increment(); }
+
+ Klass(const std::string &val) : value(val), count(0) { if (debug_shared) cout << "Klass(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~Klass() { if (debug_shared) cout << "~Klass() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ Klass(const Klass &other) : value(other.value), count(0) { if (debug_shared) cout << "Klass(const Klass&) [" << value << "]" << endl << flush; increment(); }
+
+ Klass &operator=(const Klass &other) { value = other.value; return *this; }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx Klass::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+ mutable boost::detail::atomic_count count;
+};
+
+struct KlassWithoutRefCount {
+ KlassWithoutRefCount() : value("EMPTY") { if (debug_shared) cout << "KlassWithoutRefCount() [" << value << "]" << endl << flush; increment(); }
+
+ KlassWithoutRefCount(const std::string &val) : value(val) { if (debug_shared) cout << "KlassWithoutRefCount(string) [" << value << "]" << endl << flush; increment(); }
+
+ virtual ~KlassWithoutRefCount() { if (debug_shared) cout << "~KlassWithoutRefCount() [" << value << "]" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return value; }
+ void append(const std::string &s) { value += s; }
+ KlassWithoutRefCount(const KlassWithoutRefCount &other) : value(other.value) { if (debug_shared) cout << "KlassWithoutRefCount(const KlassWithoutRefCount&) [" << value << "]" << endl << flush; increment(); }
+ std::string getSpecialValueFromUnwrappableClass() { return "this class cannot be wrapped by intrusive_ptrs but we can still use it"; }
+ KlassWithoutRefCount &operator=(const KlassWithoutRefCount &other) { value = other.value; return *this; }
+ static long getTotal_count() { return total_count; }
+
+private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassWithoutRefCount::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassWithoutRefCount::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ std::string value;
+ int array[1024];
+};
+
+struct IgnoredRefCountingBase {
+ IgnoredRefCountingBase() : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase()" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase(const IgnoredRefCountingBase &other) : count(0) { if (debug_shared) cout << "IgnoredRefCountingBase(const IgnoredRefCountingBase&)" << endl << flush; increment(); }
+
+ IgnoredRefCountingBase &operator=(const IgnoredRefCountingBase& other) {
+ return *this;
+ }
+
+ virtual ~IgnoredRefCountingBase() { if (debug_shared) cout << "~IgnoredRefCountingBase()" << endl << flush; decrement(); }
+
+ void addref(void) const { ++count; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx IgnoredRefCountingBase::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx IgnoredRefCountingBase::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+ double d;
+ double e;
+ mutable boost::detail::atomic_count count;
+};
+
+long getTotal_IgnoredRefCountingBase_count() {
+ return IgnoredRefCountingBase::getTotal_count();
+}
+
+// For most compilers, this use of multiple inheritance results in different derived and base class
+// pointer values ... for some more challenging tests :)
+struct KlassDerived : IgnoredRefCountingBase, KlassWithoutRefCount {
+ KlassDerived() : KlassWithoutRefCount() { if (debug_shared) cout << "KlassDerived()" << endl << flush; increment(); }
+ KlassDerived(const std::string &val) : KlassWithoutRefCount(val) { if (debug_shared) cout << "KlassDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerived(const KlassDerived &other) : KlassWithoutRefCount(other) { if (debug_shared) cout << "KlassDerived(const KlassDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerived() { if (debug_shared) cout << "~KlassDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-Derived"; }
+ int use_count(void) const { return IgnoredRefCountingBase::use_count(); }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+struct KlassDerivedDerived : KlassDerived {
+ KlassDerivedDerived() : KlassDerived() { if (debug_shared) cout << "KlassDerivedDerived()" << endl << flush; increment(); }
+ KlassDerivedDerived(const std::string &val) : KlassDerived(val) { if (debug_shared) cout << "KlassDerivedDerived(string) [" << val << "]" << endl << flush; increment(); }
+ KlassDerivedDerived(const KlassDerived &other) : KlassDerived(other) { if (debug_shared) cout << "KlassDerivedDerived(const KlassDerivedDerived&))" << endl << flush; increment(); }
+ virtual ~KlassDerivedDerived() { if (debug_shared) cout << "~KlassDerivedDerived()" << endl << flush; decrement(); }
+ virtual std::string getValue() const { return KlassWithoutRefCount::getValue() + "-DerivedDerived"; }
+ static long getTotal_count() { return total_count; }
+
+ private:
+ static void increment() { ++total_count; if (debug_shared) cout << " ++xxxxx KlassDerivedDerived::increment tot: " << total_count << endl;}
+ static void decrement() { --total_count; if (debug_shared) cout << " --xxxxx KlassDerivedDerived::decrement tot: " << total_count << endl;}
+ static boost::detail::atomic_count total_count;
+};
+KlassDerived* derivedpointertest(KlassDerived* kd) {
+ if (kd)
+ kd->append(" derivedpointertest");
+ return kd;
+}
+KlassDerived derivedvaluetest(KlassDerived kd) {
+ kd.append(" derivedvaluetest");
+ return kd;
+}
+KlassDerived& derivedreftest(KlassDerived& kd) {
+ kd.append(" derivedreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived> derivedsmartptrtest(SwigBoost::intrusive_ptr<KlassDerived> kd) {
+ if (kd)
+ kd->append(" derivedsmartptrtest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrpointertest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointertest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>* derivedsmartptrreftest(SwigBoost::intrusive_ptr<KlassDerived>* kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrreftest");
+ return kd;
+}
+SwigBoost::intrusive_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::intrusive_ptr<KlassDerived>*& kd) {
+ if (kd && *kd)
+ (*kd)->append(" derivedsmartptrpointerreftest");
+ return kd;
+}
+
+SwigBoost::intrusive_ptr<Klass> factorycreate() {
+ return SwigBoost::intrusive_ptr<Klass>(new Klass("factorycreate"));
+}
+// smart pointer
+SwigBoost::intrusive_ptr<Klass> smartpointertest(SwigBoost::intrusive_ptr<Klass> k) {
+ if (k)
+ k->append(" smartpointertest");
+ return SwigBoost::intrusive_ptr<Klass>(k);
+}
+SwigBoost::intrusive_ptr<Klass>* smartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointertest");
+ return k;
+}
+SwigBoost::intrusive_ptr<Klass>& smartpointerreftest(SwigBoost::intrusive_ptr<Klass>& k) {
+ if (k)
+ k->append(" smartpointerreftest");
+ return k;
+}
+SwigBoost::intrusive_ptr<Klass>*& smartpointerpointerreftest(SwigBoost::intrusive_ptr<Klass>*& k) {
+ if (k && *k)
+ (*k)->append(" smartpointerpointerreftest");
+ return k;
+}
+// const
+SwigBoost::intrusive_ptr<const Klass> constsmartpointertest(SwigBoost::intrusive_ptr<const Klass> k) {
+ return SwigBoost::intrusive_ptr<const Klass>(k);
+}
+SwigBoost::intrusive_ptr<const Klass>* constsmartpointerpointertest(SwigBoost::intrusive_ptr<const Klass>* k) {
+ return k;
+}
+SwigBoost::intrusive_ptr<const Klass>& constsmartpointerreftest(SwigBoost::intrusive_ptr<const Klass>& k) {
+ return k;
+}
+// plain pointer
+Klass valuetest(Klass k) {
+ k.append(" valuetest");
+ return k;
+}
+Klass *pointertest(Klass *k) {
+ if (k)
+ k->append(" pointertest");
+ return k;
+}
+Klass& reftest(Klass& k) {
+ k.append(" reftest");
+ return k;
+}
+Klass*& pointerreftest(Klass*& k) {
+ k->append(" pointerreftest");
+ return k;
+}
+// null
+std::string nullsmartpointerpointertest(SwigBoost::intrusive_ptr<Klass>* k) {
+ if (k && *k)
+ return "not null";
+ else if (!k)
+ return "null smartpointer pointer";
+ else if (!*k)
+ return "null pointer";
+ else
+ return "also not null";
+}
+// $owner
+Klass *pointerownertest() {
+ return new Klass("pointerownertest");
+}
+SwigBoost::intrusive_ptr<Klass>* smartpointerpointerownertest() {
+ return new SwigBoost::intrusive_ptr<Klass>(new Klass("smartpointerpointerownertest"));
+}
+
+const SwigBoost::intrusive_ptr<Klass>& ref_1() {
+ static SwigBoost::intrusive_ptr<Klass> sptr;
+ return sptr;
+}
+
+// overloading tests
+std::string overload_rawbyval(int i) { return "int"; }
+std::string overload_rawbyval(Klass k) { return "rawbyval"; }
+
+std::string overload_rawbyref(int i) { return "int"; }
+std::string overload_rawbyref(Klass &k) { return "rawbyref"; }
+
+std::string overload_rawbyptr(int i) { return "int"; }
+std::string overload_rawbyptr(Klass *k) { return "rawbyptr"; }
+
+std::string overload_rawbyptrref(int i) { return "int"; }
+std::string overload_rawbyptrref(Klass *&k) { return "rawbyptrref"; }
+
+
+
+std::string overload_smartbyval(int i) { return "int"; }
+std::string overload_smartbyval(SwigBoost::intrusive_ptr<Klass> k) { return "smartbyval"; }
+
+std::string overload_smartbyref(int i) { return "int"; }
+std::string overload_smartbyref(SwigBoost::intrusive_ptr<Klass> &k) { return "smartbyref"; }
+
+std::string overload_smartbyptr(int i) { return "int"; }
+std::string overload_smartbyptr(SwigBoost::intrusive_ptr<Klass> *k) { return "smartbyptr"; }
+
+std::string overload_smartbyptrref(int i) { return "int"; }
+std::string overload_smartbyptrref(SwigBoost::intrusive_ptr<Klass> *&k) { return "smartbyptrref"; }
+
+} // namespace Space
+
+%}
+%{
+ boost::detail::atomic_count Space::Klass::total_count(0);
+ boost::detail::atomic_count Space::KlassWithoutRefCount::total_count(0);
+ boost::detail::atomic_count Space::IgnoredRefCountingBase::total_count(0);
+ boost::detail::atomic_count Space::KlassDerived::total_count(0);
+ boost::detail::atomic_count Space::KlassDerivedDerived::total_count(0);
+%}
+
+// Member variables
+
+%inline %{
+struct MemberVariables {
+ MemberVariables() : SmartMemberPointer(new SwigBoost::intrusive_ptr<Space::Klass>()), SmartMemberReference(*(new SwigBoost::intrusive_ptr<Space::Klass>())), MemberPointer(0), MemberReference(MemberValue) {}
+ virtual ~MemberVariables() {
+ delete SmartMemberPointer;
+ delete &SmartMemberReference;
+ }
+ SwigBoost::intrusive_ptr<Space::Klass> SmartMemberValue;
+ SwigBoost::intrusive_ptr<Space::Klass> * SmartMemberPointer;
+ SwigBoost::intrusive_ptr<Space::Klass> & SmartMemberReference;
+ Space::Klass MemberValue;
+ Space::Klass * MemberPointer;
+ Space::Klass & MemberReference;
+};
+
+// Global variables
+SwigBoost::intrusive_ptr<Space::Klass> GlobalSmartValue;
+Space::Klass GlobalValue;
+Space::Klass * GlobalPointer = 0;
+Space::Klass & GlobalReference = GlobalValue;
+
+%}
+
+#if defined(INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED)
+
+// Note: %template after the intrusive_ptr typemaps
+SWIG_INTRUSIVE_PTR(BaseIntDouble, Base<int, double>)
+// Note: cannot use Base<int, double> in the macro below because of the comma in the type,
+// so we use a typedef instead. Alternatively use %arg(Base<int, double>). %arg is defined in swigmacros.swg.
+SWIG_INTRUSIVE_PTR_DERIVED(PairIntDouble, BaseIntDouble_t, Pair<int, double>)
+
+#endif
+
+// Templates
+%inline %{
+template <class T1, class T2> struct Base {
+ Space::Klass klassBase;
+ T1 baseVal1;
+ T2 baseVal2;
+ Base(T1 t1, T2 t2) : baseVal1(t1*2), baseVal2(t2*2) {}
+ virtual std::string getValue() const { return "Base<>"; };
+ mutable int count;
+ void addref(void) const { count++; }
+ void release(void) const { if (--count == 0) delete this; }
+ int use_count(void) const { return count; }
+};
+typedef Base<int, double> BaseIntDouble_t;
+%}
+
+%template(BaseIntDouble) Base<int, double>;
+
+%inline %{
+template <class T1, class T2> struct Pair : Base<T1, T2> {
+ Space::Klass klassPair;
+ T1 val1;
+ T2 val2;
+ Pair(T1 t1, T2 t2) : Base<T1, T2>(t1, t2), val1(t1), val2(t2) {}
+ virtual std::string getValue() const { return "Pair<>"; };
+};
+
+Pair<int, double> pair_id2(Pair<int, double> p) { return p; }
+SwigBoost::intrusive_ptr< Pair<int, double> > pair_id1(SwigBoost::intrusive_ptr< Pair<int, double> > p) { return p; }
+
+template<typename T> void intrusive_ptr_add_ref(const T* r) { r->addref(); }
+
+template<typename T> void intrusive_ptr_release(const T* r) { r->release(); }
+
+long use_count(const SwigBoost::shared_ptr<Space::Klass>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Space::KlassDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Space::KlassDerivedDerived>& sptr) {
+ return sptr.use_count();
+}
+%}
+
+%template(PairIntDouble) Pair<int, double>;
+
+// For counting the instances of intrusive_ptr (all of which are created on the heap)
+// intrusive_ptr_wrapper_count() gives overall count
+%inline %{
+namespace SwigBoost {
+ const int NOT_COUNTING = -123456;
+ int intrusive_ptr_wrapper_count() {
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ return SwigBoost::IntrusivePtrWrapper::getTotalCount();
+ #else
+ return NOT_COUNTING;
+ #endif
+ }
+ #ifdef INTRUSIVE_PTR_WRAPPER
+ template<> std::string show_message(boost::intrusive_ptr<Space::Klass >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<const Space::Klass >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "Klass: " + (*t)->getValue();
+ else
+ return "Klass: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<Space::KlassDerived >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ template<> std::string show_message(boost::intrusive_ptr<const Space::KlassDerived >*t) {
+ if (!t)
+ return "null intrusive_ptr!!!";
+ if (*t)
+ return "KlassDerived: " + (*t)->getValue();
+ else
+ return "KlassDerived: NULL";
+ }
+ #endif
+}
+%}
+
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index a6225410b..f992a3c08 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -43,6 +43,14 @@
%include <boost_shared_ptr.i>
SWIG_SHARED_PTR(Klass, Space::Klass)
SWIG_SHARED_PTR_DERIVED(KlassDerived, Space::Klass, Space::KlassDerived)
+SWIG_SHARED_PTR_DERIVED(Klass2ndDerived, Space::Klass, Space::Klass2ndDerived)
+SWIG_SHARED_PTR_DERIVED(Klass3rdDerived, Space::Klass2ndDerived, Space::Klass3rdDerived)
+
+// TEMP for python
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >) {
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< Space::Klass3rdDerived > *)$from);
+}
#endif
@@ -101,7 +109,13 @@ private:
};
SwigExamples::CriticalSection Space::Klass::critical_section;
-struct IgnoredMultipleInheritBase { virtual ~IgnoredMultipleInheritBase() {} double d; double e;};
+struct IgnoredMultipleInheritBase {
+ IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
+ virtual ~IgnoredMultipleInheritBase() {}
+ double d;
+ double e;
+ virtual void AVirtualMethod() {}
+};
// For most compilers, this use of multiple inheritance results in different derived and base class
// pointer values ... for some more challenging tests :)
@@ -142,7 +156,21 @@ SwigBoost::shared_ptr<KlassDerived>*& derivedsmartptrpointerreftest(SwigBoost::s
return kd;
}
+// 3 classes in inheritance chain test
+struct Klass2ndDerived : Klass {
+ Klass2ndDerived() : Klass() {}
+ Klass2ndDerived(const std::string &val) : Klass(val) {}
+};
+struct Klass3rdDerived : IgnoredMultipleInheritBase, Klass2ndDerived {
+ Klass3rdDerived() : Klass2ndDerived() {}
+ Klass3rdDerived(const std::string &val) : Klass2ndDerived(val) {}
+ virtual ~Klass3rdDerived() {}
+ virtual std::string getValue() const { return Klass2ndDerived::getValue() + "-3rdDerived"; }
+};
+std::string test3rdupcast( SwigBoost::shared_ptr< Klass > k) {
+ return k->getValue();
+}
@@ -217,8 +245,14 @@ SwigBoost::shared_ptr<Klass>* smartpointerpointerownertest() {
return new SwigBoost::shared_ptr<Klass>(new Klass("smartpointerpointerownertest"));
}
-// Provide overloads for Klass and KlassDerived as some language modules, eg Python, create an extra reference in
+// Provide overloads for Klass and derived classes as some language modules, eg Python, create an extra reference in
// the marshalling if an upcast to a base class is required.
+long use_count(const SwigBoost::shared_ptr<Klass3rdDerived>& sptr) {
+ return sptr.use_count();
+}
+long use_count(const SwigBoost::shared_ptr<Klass2ndDerived>& sptr) {
+ return sptr.use_count();
+}
long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) {
return sptr.use_count();
}
diff --git a/Examples/test-suite/li_cstring.i b/Examples/test-suite/li_cstring.i
index fd92ac7d3..28e8049e8 100644
--- a/Examples/test-suite/li_cstring.i
+++ b/Examples/test-suite/li_cstring.i
@@ -4,7 +4,7 @@
#ifndef SWIG_CSTRING_UNIMPL
-%cstring_input_binary(char *in, int n);
+%cstring_input_binary(char *str_in, int n);
%cstring_bounded_output(char *out1, 512);
%cstring_chunk_output(char *out2, 64);
%cstring_bounded_mutable(char *out3, 512);
@@ -22,13 +22,13 @@
%inline %{
-int count(char *in, int n, char c) {
+int count(char *str_in, int n, char c) {
int r = 0;
while (n > 0) {
- if (*in == c) {
+ if (*str_in == c) {
r++;
}
- in++;
+ str_in++;
--n;
}
return r;
diff --git a/Examples/test-suite/li_cwstring.i b/Examples/test-suite/li_cwstring.i
index dc9a1c4b9..769dcce12 100644
--- a/Examples/test-suite/li_cwstring.i
+++ b/Examples/test-suite/li_cwstring.i
@@ -4,7 +4,7 @@
#ifndef SWIG_CWSTRING_UNIMPL
-%cwstring_input_binary(wchar_t *in, int n);
+%cwstring_input_binary(wchar_t *str_in, int n);
%cwstring_bounded_output(wchar_t *out1, 512);
%cwstring_chunk_output(wchar_t *out2, 64);
%cwstring_bounded_mutable(wchar_t *out3, 512);
@@ -22,13 +22,13 @@
%inline %{
-int count(wchar_t *in, int n, wchar_t c) {
+int count(wchar_t *str_in, int n, wchar_t c) {
int r = 0;
while (n > 0) {
- if (*in == c) {
+ if (*str_in == c) {
r++;
}
- in++;
+ str_in++;
--n;
}
return r;
diff --git a/Examples/test-suite/python/li_std_carray.i b/Examples/test-suite/li_std_carray.i
index b38e0e441..b38e0e441 100644
--- a/Examples/test-suite/python/li_std_carray.i
+++ b/Examples/test-suite/li_std_carray.i
diff --git a/Examples/test-suite/ruby/li_std_functors.i b/Examples/test-suite/li_std_functors.i
index 067bb1002..067bb1002 100644
--- a/Examples/test-suite/ruby/li_std_functors.i
+++ b/Examples/test-suite/li_std_functors.i
diff --git a/Examples/test-suite/perl5/li_std_list.i b/Examples/test-suite/li_std_list.i
index bae475eea..bae475eea 100644
--- a/Examples/test-suite/perl5/li_std_list.i
+++ b/Examples/test-suite/li_std_list.i
diff --git a/Examples/test-suite/li_std_map.i b/Examples/test-suite/li_std_map.i
index edcb05641..356e86df3 100644
--- a/Examples/test-suite/li_std_map.i
+++ b/Examples/test-suite/li_std_map.i
@@ -1,45 +1,96 @@
-/**
- * @file li_std_map.i
- * @author gga
- * @date Mon Apr 30 15:03:58 2007
- *
- * @brief a test of map containers.
- * Languages should define swig::LANGUAGE_OBJ to be
- * an entity of their native pointer type which can be
- * included in a STL container.
- *
- * For example:
- * swig::LANGUAGE_OBJ is GC_VALUE in Ruby
- * swig::LANGUAGE_OBJ is PyObject_ptr in python
- *
- *
- */
-
%module("templatereduce") li_std_map
%feature("trackobjects");
-%include std_pair.i
-%include std_map.i
-%include std_multimap.i
+%include "std_pair.i"
+%include "std_map.i"
+%include "std_string.i"
+
+// Declare some maps to play around with
+%template(IntIntMap) std::map<int, int>;
+%template(StringIntMap) std::map<std::string, int>;
+
+%ignore Struct::operator<;
+%ignore Struct::operator==;
+// Add an inline function to test
%inline %{
-struct A{
- int val;
+
+double valueAverage(std::map<std::string, int> m) {
+ if (m.size() == 0) {
+ return 0.0;
+ }
- A(int v = 0): val(v)
- {
- }
+ double a = 0.0;
+ for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) {
+ a += i->second;
+ }
+
+ return a / m.size();
+}
+
+std::string stringifyKeys(std::map<std::string, int> m) {
+ std::string a;
+ for (std::map<std::string, int>::iterator i = m.begin(); i != m.end(); i++) {
+ a += " " + i->first;
+ }
+ return a;
+}
+struct Struct {
+ double num;
+ Struct() : num(0.0) {}
+ Struct(double d) : num(d) {}
+ bool operator<(const Struct &other) const { return num < other.num; }
+ bool operator==(const Struct &other) const { return num == other.num; }
};
+
+%}
+
+#if defined(SWIGCSHARP)
+
+// Specialize some more non-default map types
+SWIG_STD_MAP_SPECIALIZED(int, int *, int, SWIGTYPE_p_int)
+SWIG_STD_MAP_SPECIALIZED(int, const int *, int, SWIGTYPE_p_int)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, Struct)
+SWIG_STD_MAP_SPECIALIZED(int, Struct *, int, Struct)
+SWIG_STD_MAP_SPECIALIZED(int, const Struct *, int, Struct)
+SWIG_STD_MAP_SPECIALIZED(Struct *, int, Struct, int)
+
+#endif
+
+//#if !defined(SWIGR)
+
+// Test out some maps with pointer types
+%template(IntIntPtrMap) std::map<int, int *>;
+%template(IntConstIntPtrMap) std::map<int, const int *>;
+
+//#endif
+
+
+// Test out some maps with non-basic types and non-basic pointer types
+%template(IntStructMap) std::map<int, Struct>;
+%template(IntStructPtrMap) std::map<int, Struct *>;
+%template(IntStructConstPtrMap) std::map<int, const Struct *>;
+%template(StructPtrIntMap) std::map<Struct *, int>;
+
+// Test out a non-specialized map
+%template(StructIntMap) std::map<Struct, int>;
+
+// Additional map definitions for Ruby, Python and Octave tests
+%inline %{
+ struct A{
+ int val;
+
+ A(int v = 0): val(v) {
+ }
+ };
%}
-namespace std
-{
+namespace std {
%template(pairii) pair<int, int>;
%template(pairAA) pair<int, A>;
%template(pairA) pair<int, A*>;
%template(mapA) map<int, A*>;
- %template(mmapA) multimap<int, A*>;
%template(paircA1) pair<const int, A*>;
%template(paircA2) pair<const int, const A*>;
@@ -47,30 +98,26 @@ namespace std
%template(pairiiAc) pair<int,const pair<int, A*> >;
+#ifdef SWIGRUBY
%template() pair< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
%template(LanguageMap) map< swig::LANGUAGE_OBJ, swig::LANGUAGE_OBJ >;
-
-}
-
-
+#endif
-%inline
-{
-std::pair<int, A*>
-p_identa(std::pair<int, A*> p) {
- return p;
+#ifdef SWIGPYTHON
+ %template() pair<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
+ %template(pymap) map<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject>;
+#endif
+
}
-std::map<int,A*> m_identa(const std::map<int,A*>& v)
-{
- return v;
-}
+%inline {
+ std::pair<int, A*> p_identa(std::pair<int, A*> p) {
+ return p;
+ }
+ std::map<int, A*> m_identa(const std::map<int,A*>& v) {
+ return v;
+ }
}
-
-namespace std
-{
-%template(mapii) map<int,int>;
-}
diff --git a/Examples/test-suite/li_std_multimap.i b/Examples/test-suite/li_std_multimap.i
new file mode 100644
index 000000000..a29417919
--- /dev/null
+++ b/Examples/test-suite/li_std_multimap.i
@@ -0,0 +1,25 @@
+%module("templatereduce") li_std_multimap
+
+%feature("trackobjects");
+
+%include std_pair.i
+%include std_map.i
+%include std_multimap.i
+
+%inline %{
+struct A{
+ int val;
+
+ A(int v = 0): val(v)
+ {
+ }
+
+};
+%}
+
+namespace std
+{
+ %template(pairA) pair<int, A*>;
+ %template(mapA) map<int, A*>;
+ %template(multimapA) multimap<int, A*>;
+}
diff --git a/Examples/test-suite/octave/li_std_pair.i b/Examples/test-suite/li_std_pair_extra.i
index 886bf1a4b..4e3b3a571 100644
--- a/Examples/test-suite/octave/li_std_pair.i
+++ b/Examples/test-suite/li_std_pair_extra.i
@@ -1,4 +1,4 @@
-%module li_std_pair
+%module li_std_pair_extra
//
// activate the automatic comparison methods generation (==,!=,...)
diff --git a/Examples/test-suite/ruby/li_std_pair_lang_object.i b/Examples/test-suite/li_std_pair_lang_object.i
index a830af728..a830af728 100644
--- a/Examples/test-suite/ruby/li_std_pair_lang_object.i
+++ b/Examples/test-suite/li_std_pair_lang_object.i
diff --git a/Examples/test-suite/ruby/li_std_queue.i b/Examples/test-suite/li_std_queue.i
index 2d322b4d9..2d322b4d9 100644
--- a/Examples/test-suite/ruby/li_std_queue.i
+++ b/Examples/test-suite/li_std_queue.i
diff --git a/Examples/test-suite/li_std_set.i b/Examples/test-suite/li_std_set.i
index c2cdc2ebe..8c335b24c 100644
--- a/Examples/test-suite/li_std_set.i
+++ b/Examples/test-suite/li_std_set.i
@@ -10,7 +10,7 @@
*
* For example:
* swig::LANGUAGE_OBJ is GC_VALUE in Ruby
- * swig::LANGUAGE_OBJ is PyObject_ptr in python
+ * swig::LANGUAGE_OBJ is SwigPtr_PyObject in python
*
*
*/
@@ -31,4 +31,10 @@
+#if defined(SWIGRUBY)
%template(LanguageSet) std::set<swig::LANGUAGE_OBJ>;
+#endif
+
+#if defined(SWIGPYTHON)
+%template(pyset) std::set<swig::SwigPtr_PyObject>;
+#endif
diff --git a/Examples/test-suite/ruby/li_std_stack.i b/Examples/test-suite/li_std_stack.i
index d29254089..d29254089 100644
--- a/Examples/test-suite/ruby/li_std_stack.i
+++ b/Examples/test-suite/li_std_stack.i
diff --git a/Examples/test-suite/octave/li_std_string.i b/Examples/test-suite/li_std_string_extra.i
index 822d713c4..aa758532a 100644
--- a/Examples/test-suite/octave/li_std_string.i
+++ b/Examples/test-suite/li_std_string_extra.i
@@ -1,4 +1,4 @@
-%module li_std_string
+%module li_std_string_extra
%naturalvar A;
@@ -51,5 +51,5 @@ std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_
%}
-%include ../li_std_string.i
+%include "li_std_string.i"
diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index 587ea2217..c6e2ea9ad 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -85,8 +85,10 @@ SWIG_STD_VECTOR_SPECIALIZE(SWIGTYPE_p_int, const int *)
%template(StructureConstPtrVector) std::vector<const Structure *>;
#endif
+#if !defined(SWIGR)
%template(IntPtrVector) std::vector<int *>;
%template(IntConstPtrVector) std::vector<const int *>;
+#endif
%template(StructVector) std::vector<Struct>;
%template(StructPtrVector) std::vector<Struct *>;
%template(StructConstPtrVector) std::vector<const Struct *>;
diff --git a/Examples/test-suite/python/li_std_vector.i b/Examples/test-suite/li_std_vector_extra.i
index 06dafce59..9c2497f7c 100644
--- a/Examples/test-suite/python/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector_extra.i
@@ -1,4 +1,4 @@
-%module li_std_vector
+%module li_std_vector_extra
%warnfilter(509) overloaded1;
%warnfilter(509) overloaded2;
@@ -123,11 +123,17 @@ std::vector<std::string> vecStr(std::vector<std::string> v) {
%pointer_class(int,PtrInt)
%array_functions(int,ArrInt)
+%inline %{
+ int *makeIntPtr(int v) { return new int(v); }
+ double *makeDoublePtr(double v) { return new double(v); }
+ int extractInt(int *p) { return *p; }
+%}
-%template(pyvector) std::vector<swig::PyObject_ptr>;
+%template(pyvector) std::vector<swig::SwigPtr_PyObject>;
namespace std {
- %template(ConstIntVector) vector<const int *>;
+ %template(ConstShortVector) vector<const short *>;
+// %template(ConstIntVector) vector<const int *>; // interferes with vector<int *>... see new testcase li_std_vector_ptr
}
%inline %{
diff --git a/Examples/test-suite/li_std_vector_ptr.i b/Examples/test-suite/li_std_vector_ptr.i
new file mode 100644
index 000000000..688cbdd54
--- /dev/null
+++ b/Examples/test-suite/li_std_vector_ptr.i
@@ -0,0 +1,29 @@
+%module li_std_vector_ptr
+
+%include "std_vector.i"
+
+%template(IntPtrVector) std::vector<int *>;
+
+%inline %{
+#include <iostream>
+using namespace std;
+int* makeIntPtr(int v) {
+ return new int(v);
+}
+double* makeDoublePtr(double v) {
+ return new double(v);
+}
+
+#if 1
+int** makeIntPtrPtr(int* v) {
+ return new int*(v);
+}
+#endif
+
+void displayVector(std::vector<int *> vpi) {
+ cout << "displayVector..." << endl;
+ for (int i=0; i<vpi.size(); ++i)
+ cout << *vpi[i] << endl;
+}
+%}
+
diff --git a/Examples/test-suite/python/li_std_vectora.i b/Examples/test-suite/li_std_vectora.i
index d95fdf648..d95fdf648 100644
--- a/Examples/test-suite/python/li_std_vectora.i
+++ b/Examples/test-suite/li_std_vectora.i
diff --git a/Examples/test-suite/python/li_std_wstream.i b/Examples/test-suite/li_std_wstream.i
index e4d725f10..e4d725f10 100644
--- a/Examples/test-suite/python/li_std_wstream.i
+++ b/Examples/test-suite/li_std_wstream.i
diff --git a/Examples/test-suite/name_warnings.i b/Examples/test-suite/name_warnings.i
index a9cb35686..527dbcfaa 100644
--- a/Examples/test-suite/name_warnings.i
+++ b/Examples/test-suite/name_warnings.i
@@ -58,13 +58,12 @@ namespace std
%template(max_i) max<int>;
-
%inline {
/* silently rename the parameter names in csharp/java */
#ifdef SWIGR
double foo(double inparam, double out) { return 1.0; }
#else
- double foo(double in, double out) { return 1.0; }
+ double foo(double abstract, double out) { return 1.0; }
#endif
double bar(double native, bool boolean) { return 1.0; }
}
diff --git a/Examples/test-suite/namespace_typemap.i b/Examples/test-suite/namespace_typemap.i
index e4e0af905..984b93a6f 100644
--- a/Examples/test-suite/namespace_typemap.i
+++ b/Examples/test-suite/namespace_typemap.i
@@ -75,7 +75,7 @@ namespace test {
class string_class;
#ifdef SWIGPYTHON
%typemap(in) string_class * {
- $1 = new string_class(PyString_AsString($input));
+ $1 = new string_class(SWIG_Python_str_AsChar($input));
}
%typemap(freearg) string_class * {
delete $1;
diff --git a/Examples/test-suite/nested_comment.i b/Examples/test-suite/nested_comment.i
index 16f1b7af2..ea365a6fe 100644
--- a/Examples/test-suite/nested_comment.i
+++ b/Examples/test-suite/nested_comment.i
@@ -18,24 +18,17 @@ in rlgc models */
char *name;
} n ;
} s2;
-
-%}
-
-// bug #491476
-%inline %{
-struct {
-struct {
-int a;
-} a, b;
-} a;
-
%}
-// bug #909387
+// comment in nested struct
%inline %{
-struct foo {
- struct happy; // no warning
- struct sad { int x; }; // warning
- happy *good(); // produces good code
- sad *bad(); // produces bad code
+struct a
+{
+ struct {
+ /*struct*/
+ struct {
+ int b;
+ } c;
+ } d;
};
+%}
diff --git a/Examples/test-suite/nested_structs.i b/Examples/test-suite/nested_structs.i
new file mode 100644
index 000000000..4b13ff69d
--- /dev/null
+++ b/Examples/test-suite/nested_structs.i
@@ -0,0 +1,22 @@
+%module nested_structs
+
+// bug #491476
+%inline %{
+struct {
+struct {
+int a;
+} a, b;
+} a;
+
+%}
+
+// bug #909387
+%inline %{
+struct foo {
+ struct happy; // no warning
+ struct sad { int x; }; // warning
+ happy *good(); // produces good code
+ sad *bad(); // produces bad code
+};
+%}
+
diff --git a/Examples/test-suite/ocaml/Makefile.in b/Examples/test-suite/ocaml/Makefile.in
index 6f0b65489..0e6235f94 100644
--- a/Examples/test-suite/ocaml/Makefile.in
+++ b/Examples/test-suite/ocaml/Makefile.in
@@ -16,7 +16,7 @@ run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) -a \
-f $(top_srcdir)/Examples/test-suite/$*.list ] ; then ( \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
- $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& ./runme) ; \
+ $(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme `cat $(top_srcdir)/Examples/test-suite/$(*).list | sed -e 's/\(.*\)/\1_wrap.o \1.cmo/g'`&& $(RUNTOOL) ./runme) ; \
elif [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
$(COMPILETOOL) $(OCAMLC) -c $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
$(COMPILETOOL) $(OCAMLC) swig.cmo -custom -g -cc '$(CXX)' -o runme $(srcdir)/$(*).cmo $(srcdir)/$(*)_runme.cmo $(srcdir)/$(*)_wrap.o && \
diff --git a/Examples/test-suite/octave/Makefile.in b/Examples/test-suite/octave/Makefile.in
index 534da55c4..b12cf500a 100644
--- a/Examples/test-suite/octave/Makefile.in
+++ b/Examples/test-suite/octave/Makefile.in
@@ -10,7 +10,9 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
- cell_deref
+ li_std_pair_extra \
+ li_std_string_extra \
+ octave_cell_deref
CPP_TEST_BROKEN += \
implicittest \
diff --git a/Examples/test-suite/octave/li_attribute_runme.m b/Examples/test-suite/octave/li_attribute_runme.m
index c66e27c5b..548e733ed 100644
--- a/Examples/test-suite/octave/li_attribute_runme.m
+++ b/Examples/test-suite/octave/li_attribute_runme.m
@@ -10,7 +10,6 @@ if (aa.a != 3)
error("aa.a = %i",aa.a)
endif
-
if (aa.b != 2)
error(aa.b)
endif
@@ -19,8 +18,6 @@ if (aa.b != 5)
error
endif
-
-
if (aa.d != aa.b)
error
endif
@@ -39,14 +36,13 @@ if (pi.value != 3)
error
endif
-
b = li_attribute.B(aa);
if (b.a.c != 3)
error
endif
-
+# class/struct attribute with get/set methods using return/pass by reference
myFoo = li_attribute.MyFoo();
myFoo.x = 8;
myClass = li_attribute.MyClass();
@@ -55,3 +51,35 @@ if (myClass.Foo.x != 8)
error
endif
+# class/struct attribute with get/set methods using return/pass by value
+myClassVal = li_attribute.MyClassVal();
+if (myClassVal.ReadWriteFoo.x != -1)
+ error
+endif
+if (myClassVal.ReadOnlyFoo.x != -1)
+ error
+endif
+myClassVal.ReadWriteFoo = myFoo;
+if (myClassVal.ReadWriteFoo.x != 8)
+ error
+endif
+if (myClassVal.ReadOnlyFoo.x != 8)
+ error
+endif
+
+# string attribute with get/set methods using return/pass by value
+myStringyClass = li_attribute.MyStringyClass("initial string");
+if (myStringyClass.ReadWriteString != "initial string")
+ error
+endif
+if (myStringyClass.ReadOnlyString != "initial string")
+ error
+endif
+myStringyClass.ReadWriteString = "changed string";
+if (myStringyClass.ReadWriteString != "changed string")
+ error
+endif
+if (myStringyClass.ReadOnlyString != "changed string")
+ error
+endif
+
diff --git a/Examples/test-suite/octave/li_std_map_runme.m b/Examples/test-suite/octave/li_std_map_runme.m
index e74fc79fc..f37c78012 100644
--- a/Examples/test-suite/octave/li_std_map_runme.m
+++ b/Examples/test-suite/octave/li_std_map_runme.m
@@ -49,7 +49,7 @@ for k in pm,
endif
endfor
-mii = li_std_map.mapii();
+mii = li_std_map.IntIntMap();
mii{1} = 1;
mii{1} = 2;
diff --git a/Examples/test-suite/octave/li_std_pair_extra_runme.m b/Examples/test-suite/octave/li_std_pair_extra_runme.m
new file mode 100644
index 000000000..0f9e9a23d
--- /dev/null
+++ b/Examples/test-suite/octave/li_std_pair_extra_runme.m
@@ -0,0 +1,69 @@
+li_std_pair_extra
+
+p = {1,2};
+p1 = li_std_pair_extra.p_inout(p);
+assert(all(cell2mat(p1)==[2,1]));
+p2 = li_std_pair_extra.p_inoutd(p1);
+assert(all(cell2mat(p2)==[1,2]));
+
+d1 = li_std_pair_extra.d_inout(2);
+assert(d1==4);
+
+[i,d2] = li_std_pair_extra.d_inout2(2);
+assert(all([i,d2]==[1,4]));
+
+[i,p] = li_std_pair_extra.p_inout2(p);
+assert(i==1&&all([cell2mat(p)]==[2,1]));
+[p3,p4] = li_std_pair_extra.p_inout3(p1,p1);
+assert(all(cell2mat(p3)==[2,1]));
+assert(all(cell2mat(p4)==[2,1]));
+
+psi = li_std_pair_extra.SIPair("hello",1);
+assert(psi=={"hello",1});
+pci = li_std_pair_extra.CIPair(complex(1,2),1);
+assert(pci.first==complex(1,2)&&pci.second==1);
+
+
+psi = li_std_pair_extra.SIPair("hi",1);
+assert(psi.first=="hi"&&psi.second==1);
+
+psii = li_std_pair_extra.SIIPair(psi,1);
+assert(psii.first.first=="hi");
+assert(psii.first.second==1);
+assert(psii.second==1);
+
+a = li_std_pair_extra.A();
+b = li_std_pair_extra.B();
+
+pab = li_std_pair_extra.ABPair(a,b);
+
+pab.first = a;
+pab.first.val = 2;
+
+assert(pab.first.val == 2);
+
+pci = li_std_pair_extra.CIntPair(1,0);
+assert(pci.first==1&&pci.second==0);
+
+a = li_std_pair_extra.A(5);
+p1 = li_std_pair_extra.pairP1(1,a);
+p2 = li_std_pair_extra.pairP2(a,1);
+p3 = li_std_pair_extra.pairP3(a,a);
+
+assert(a.val == li_std_pair_extra.p_identa(p1){2}.val);
+
+p = li_std_pair_extra.IntPair(1,10);
+assert(p.first==1&&p.second==10);
+p.first = 1;
+assert(p.first==1);
+
+p = li_std_pair_extra.paircA1(1,a);
+assert(p.first==1);
+assert(swig_this(p.second)==swig_this(a));
+
+p = li_std_pair_extra.paircA2(1,a);
+assert(p.first==1);
+assert(swig_this(p.second)==swig_this(a));
+#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2
+pp = li_std_pair_extra.pairiiA(1,{1,A()});
+
diff --git a/Examples/test-suite/octave/li_std_pair_runme.m b/Examples/test-suite/octave/li_std_pair_runme.m
deleted file mode 100644
index 83e9fe5b5..000000000
--- a/Examples/test-suite/octave/li_std_pair_runme.m
+++ /dev/null
@@ -1,69 +0,0 @@
-li_std_pair
-
-p = {1,2};
-p1 = li_std_pair.p_inout(p);
-assert(all(cell2mat(p1)==[2,1]));
-p2 = li_std_pair.p_inoutd(p1);
-assert(all(cell2mat(p2)==[1,2]));
-
-d1 = li_std_pair.d_inout(2);
-assert(d1==4);
-
-[i,d2] = li_std_pair.d_inout2(2);
-assert(all([i,d2]==[1,4]));
-
-[i,p] = li_std_pair.p_inout2(p);
-assert(i==1&&all([cell2mat(p)]==[2,1]));
-[p3,p4] = li_std_pair.p_inout3(p1,p1);
-assert(all(cell2mat(p3)==[2,1]));
-assert(all(cell2mat(p4)==[2,1]));
-
-psi = li_std_pair.SIPair("hello",1);
-assert(psi=={"hello",1});
-pci = li_std_pair.CIPair(complex(1,2),1);
-assert(pci.first==complex(1,2)&&pci.second==1);
-
-
-psi = li_std_pair.SIPair("hi",1);
-assert(psi.first=="hi"&&psi.second==1);
-
-psii = li_std_pair.SIIPair(psi,1);
-assert(psii.first.first=="hi");
-assert(psii.first.second==1);
-assert(psii.second==1);
-
-a = li_std_pair.A();
-b = li_std_pair.B();
-
-pab = li_std_pair.ABPair(a,b);
-
-pab.first = a;
-pab.first.val = 2;
-
-assert(pab.first.val == 2);
-
-pci = li_std_pair.CIntPair(1,0);
-assert(pci.first==1&&pci.second==0);
-
-a = li_std_pair.A(5);
-p1 = li_std_pair.pairP1(1,a);
-p2 = li_std_pair.pairP2(a,1);
-p3 = li_std_pair.pairP3(a,a);
-
-assert(a.val == li_std_pair.p_identa(p1){2}.val);
-
-p = li_std_pair.IntPair(1,10);
-assert(p.first==1&&p.second==10);
-p.first = 1;
-assert(p.first==1);
-
-p = li_std_pair.paircA1(1,a);
-assert(p.first==1);
-assert(swig_this(p.second)==swig_this(a));
-
-p = li_std_pair.paircA2(1,a);
-assert(p.first==1);
-assert(swig_this(p.second)==swig_this(a));
-#pp = li_std_pair.pairiiA(1,p); # conversion pb re const of pairA1/A2
-pp = li_std_pair.pairiiA(1,{1,A()});
-
diff --git a/Examples/test-suite/octave/li_std_string_extra_runme.m b/Examples/test-suite/octave/li_std_string_extra_runme.m
new file mode 100644
index 000000000..8d506af8a
--- /dev/null
+++ b/Examples/test-suite/octave/li_std_string_extra_runme.m
@@ -0,0 +1,162 @@
+li_std_string_extra
+
+x="hello";
+
+
+
+if (li_std_string_extra.test_ccvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_cvalue(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_value(x) != x)
+ error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
+endif
+
+if (li_std_string_extra.test_const_reference(x) != x)
+ error("bad string mapping")
+endif
+
+
+s = li_std_string_extra.string("he");
+#s += "ll"
+#s.append("ll")
+s = s + "llo";
+
+if (s != x)
+ error("bad string mapping: %s, %s", s, x);
+endif
+
+#if (s(1:4) != x(1:4))
+# error("bad string mapping")
+#endif
+
+if (li_std_string_extra.test_value(s) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_const_reference(s) != x)
+ error("bad string mapping")
+endif
+
+a = li_std_string_extra.A(s);
+
+if (li_std_string_extra.test_value(a) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_const_reference(a) != x)
+ error("bad string mapping")
+endif
+
+b = li_std_string_extra.string(" world");
+
+s = a + b;
+if (a + b != "hello world")
+ error("bad string mapping: %s", a + b)
+endif
+
+if (a + " world" != "hello world")
+ error("bad string mapping")
+endif
+
+#if ("hello" + b != "hello world")
+# error("bad string mapping")
+#endif
+
+c = (li_std_string_extra.string("hello") + b);
+if (c.find_last_of("l") != 9)
+ error("bad string mapping")
+endif
+
+s = "hello world";
+
+b = li_std_string_extra.B("hi");
+
+b.name = li_std_string_extra.string("hello");
+if (b.name != "hello")
+ error("bad string mapping")
+endif
+
+
+b.a = li_std_string_extra.A("hello");
+if (b.a != "hello")
+ error("bad string mapping")
+endif
+
+
+if (li_std_string_extra.test_value_basic1(x) != x)
+ error("bad string mapping")
+endif
+
+if (li_std_string_extra.test_value_basic2(x) != x)
+ error("bad string mapping")
+endif
+
+
+if (li_std_string_extra.test_value_basic3(x) != x)
+ error("bad string mapping")
+endif
+
+# Global variables
+s = "initial string";
+if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
+ error("GlobalString2 test 1")
+endif
+li_std_string_extra.cvar.GlobalString2 = s;
+if (li_std_string_extra.cvar.GlobalString2 != s)
+ error("GlobalString2 test 2")
+endif
+if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
+ error("ConstGlobalString test")
+endif
+
+# Member variables
+myStructure = li_std_string_extra.Structure();
+if (myStructure.MemberString2 != "member string 2")
+ error("MemberString2 test 1")
+endif
+myStructure.MemberString2 = s;
+if (myStructure.MemberString2 != s)
+ error("MemberString2 test 2")
+endif
+if (myStructure.ConstMemberString != "const member string")
+ error("ConstMemberString test")
+endif
+
+if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
+ error("StaticMemberString2 test 1")
+endif
+li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
+if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
+ error("StaticMemberString2 test 2")
+endif
+if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
+ error("ConstStaticMemberString test")
+endif
+
+
+if (li_std_string_extra.test_reference_input("hello") != "hello")
+ error
+endif
+s = li_std_string_extra.test_reference_inout("hello");
+if (s != "hellohello")
+ error
+endif
+
+
+if (li_std_string_extra.stdstring_empty() != "")
+ error
+endif
+
+
+if (li_std_string_extra.c_empty() != "")
+ error
+endif
+
+#if (li_std_string_extra.c_null() != None)
+# error
+#endif
diff --git a/Examples/test-suite/octave/li_std_string_runme.m b/Examples/test-suite/octave/li_std_string_runme.m
deleted file mode 100644
index fa0e260e0..000000000
--- a/Examples/test-suite/octave/li_std_string_runme.m
+++ /dev/null
@@ -1,162 +0,0 @@
-li_std_string
-
-x="hello";
-
-
-
-if (li_std_string.test_ccvalue(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_cvalue(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_value(x) != x)
- error("bad string mapping: %s, %s", x, li_std_string.test_value(x))
-endif
-
-if (li_std_string.test_const_reference(x) != x)
- error("bad string mapping")
-endif
-
-
-s = li_std_string.string("he");
-#s += "ll"
-#s.append('o')
-s = s + "llo";
-
-if (s != x)
- error("bad string mapping: %s, %s", s, x);
-endif
-
-if (s[1:4] != x[1:4])
- error("bad string mapping")
-endif
-
-if (li_std_string.test_value(s) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_const_reference(s) != x)
- error("bad string mapping")
-endif
-
-a = li_std_string.A(s);
-
-if (li_std_string.test_value(a) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_const_reference(a) != x)
- error("bad string mapping")
-endif
-
-b = li_std_string.string(" world");
-
-s = a + b;
-if (a + b != "hello world")
- error("bad string mapping: %s", a + b)
-endif
-
-if (a + " world" != "hello world")
- error("bad string mapping")
-endif
-
-if ("hello" + b != "hello world")
- error("bad string mapping")
-endif
-
-c = ("hello" + b)
-if (c.find_last_of("l") != 9)
- error("bad string mapping")
-endif
-
-s = "hello world";
-
-b = li_std_string.B("hi");
-
-b.name = li_std_string.string("hello");
-if (b.name != "hello")
- error("bad string mapping")
-endif
-
-
-b.a = li_std_string.A("hello");
-if (b.a != "hello")
- error("bad string mapping")
-endif
-
-
-if (li_std_string.test_value_basic1(x) != x)
- error("bad string mapping")
-endif
-
-if (li_std_string.test_value_basic2(x) != x)
- error("bad string mapping")
-endif
-
-
-if (li_std_string.test_value_basic3(x) != x)
- error("bad string mapping")
-endif
-
-# Global variables
-s = "initial string";
-if (li_std_string.cvar.GlobalString2 != "global string 2")
- error("GlobalString2 test 1")
-endif
-li_std_string.cvar.GlobalString2 = s;
-if (li_std_string.cvar.GlobalString2 != s)
- error("GlobalString2 test 2")
-endif
-if (li_std_string.cvar.ConstGlobalString != "const global string")
- error("ConstGlobalString test")
-endif
-
-# Member variables
-myStructure = li_std_string.Structure();
-if (myStructure.MemberString2 != "member string 2")
- error("MemberString2 test 1")
-endif
-myStructure.MemberString2 = s;
-if (myStructure.MemberString2 != s)
- error("MemberString2 test 2")
-endif
-if (myStructure.ConstMemberString != "const member string")
- error("ConstMemberString test")
-endif
-
-if (li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2")
- error("StaticMemberString2 test 1")
-endif
-li_std_string.cvar.Structure_StaticMemberString2 = s;
-if (li_std_string.cvar.Structure_StaticMemberString2 != s)
- error("StaticMemberString2 test 2")
-endif
-if (li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string")
- error("ConstStaticMemberString test")
-endif
-
-
-if (li_std_string.test_reference_input("hello") != "hello")
- error
-endif
-s = li_std_string.test_reference_inout("hello");
-if (s != "hellohello")
- error
-endif
-
-
-if (li_std_string.stdstring_empty() != "")
- error
-endif
-
-
-if (li_std_string.c_empty() != "")
- error
-endif
-
-if (li_std_string.c_null() != None)
- error
-endif
diff --git a/Examples/test-suite/octave/cell_deref_runme.m b/Examples/test-suite/octave/octave_cell_deref_runme.m
index 1c370fe85..5a98c0a3b 100644
--- a/Examples/test-suite/octave/cell_deref_runme.m
+++ b/Examples/test-suite/octave/octave_cell_deref_runme.m
@@ -1,4 +1,4 @@
-cell_deref;
+octave_cell_deref;
assert(func("hello"));
assert(func({"hello"}));
diff --git a/Examples/test-suite/octave/cell_deref.i b/Examples/test-suite/octave_cell_deref.i
index fddcd80ec..2e92ec4de 100644
--- a/Examples/test-suite/octave/cell_deref.i
+++ b/Examples/test-suite/octave_cell_deref.i
@@ -1,4 +1,4 @@
-%module cell_deref
+%module octave_cell_deref
%inline {
bool func(const char* s) {
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 775818e83..b2537c669 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -71,6 +71,12 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
+#ifdef SWIG_ALLEGRO_CL
+%{
+#include <stdio.h>
+%}
+#endif
+
%rename(IntCast) operator int();
%rename(DoubleCast) operator double();
diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i
new file mode 100644
index 000000000..793c0174e
--- /dev/null
+++ b/Examples/test-suite/operbool.i
@@ -0,0 +1,12 @@
+%module operbool
+
+%rename(operbool) operator bool();
+
+%inline %{
+ class Test {
+ public:
+ operator bool() {
+ return false;
+ }
+ };
+%}
diff --git a/Examples/test-suite/packageoption.h b/Examples/test-suite/packageoption.h
index a7ef499aa..82f29d1c7 100644
--- a/Examples/test-suite/packageoption.h
+++ b/Examples/test-suite/packageoption.h
@@ -1,5 +1,6 @@
-class A
-{
- public:
- int testInt() { return 2;}
+struct Base {
+ virtual int vmethod() { return 1; }
+ int basemethod() { return 1; }
+ virtual ~Base() {}
};
+
diff --git a/Examples/test-suite/packageoption.list b/Examples/test-suite/packageoption.list
index 4bdabeccf..da125c2a3 100644
--- a/Examples/test-suite/packageoption.list
+++ b/Examples/test-suite/packageoption.list
@@ -1,2 +1,3 @@
packageoption_a
packageoption_b
+packageoption_c
diff --git a/Examples/test-suite/packageoption_a.i b/Examples/test-suite/packageoption_a.i
index e95091b0d..b28278282 100644
--- a/Examples/test-suite/packageoption_a.i
+++ b/Examples/test-suite/packageoption_a.i
@@ -1,4 +1,4 @@
-%module(package="C") "packageoption_a";
+%module(package="CommonPackage") "packageoption_a";
%inline %{
class A
@@ -6,5 +6,11 @@ class A
public:
int testInt() { return 2;}
};
+%}
+%{
+#include "packageoption.h"
%}
+
+%include "packageoption.h"
+
diff --git a/Examples/test-suite/packageoption_b.i b/Examples/test-suite/packageoption_b.i
index 466853cc0..40a44be14 100644
--- a/Examples/test-suite/packageoption_b.i
+++ b/Examples/test-suite/packageoption_b.i
@@ -1,4 +1,4 @@
-%module(package="C") "packageoption_b";
+%module(package="CommonPackage") "packageoption_b";
%inline %{
class B
diff --git a/Examples/test-suite/packageoption_c.i b/Examples/test-suite/packageoption_c.i
new file mode 100644
index 000000000..f43e47002
--- /dev/null
+++ b/Examples/test-suite/packageoption_c.i
@@ -0,0 +1,13 @@
+%module(package="PackageC") "packageoption_c";
+
+%import "packageoption_a.i"
+
+%inline %{
+#include "packageoption.h"
+
+struct Derived : Base {
+ virtual int vmethod() { return 2; }
+ virtual ~Derived() {}
+};
+
+%}
diff --git a/Examples/test-suite/perl5/Makefile.in b/Examples/test-suite/perl5/Makefile.in
index 3fee35bcb..518d341b2 100644
--- a/Examples/test-suite/perl5/Makefile.in
+++ b/Examples/test-suite/perl5/Makefile.in
@@ -15,6 +15,7 @@ CPP_TEST_CASES += \
li_cdata \
li_cstring \
li_cdata_carrays \
+ byreference \
C_TEST_CASES += \
li_cdata \
diff --git a/Examples/test-suite/perl5/byreference.i b/Examples/test-suite/perl5/byreference.i
new file mode 100644
index 000000000..43215f1cc
--- /dev/null
+++ b/Examples/test-suite/perl5/byreference.i
@@ -0,0 +1,52 @@
+%module byreference
+
+%include "reference.i"
+
+%inline %{
+ double FrVal;
+ double ToVal;
+ void PDouble(double *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RDouble(double &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PFloat(float *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RFloat(float &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PInt(int *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RInt(int &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PShort(short *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RShort(short &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PLong(long *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RLong(long &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PUInt(unsigned int *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RUInt(unsigned int &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PUShort(unsigned short *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RUShort(unsigned short &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PULong(unsigned long *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RULong(unsigned long &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PUChar(unsigned char *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RUChar(unsigned char &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PChar(signed char *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RChar(signed char &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+ void PBool(bool *REFERENCE, int t = 0)
+ { ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
+ void RBool(bool &REFERENCE, int t = 0)
+ { ToVal = REFERENCE; REFERENCE = FrVal + t; }
+%}
diff --git a/Examples/test-suite/perl5/byreference_runme.pl b/Examples/test-suite/perl5/byreference_runme.pl
new file mode 100644
index 000000000..845d870cd
--- /dev/null
+++ b/Examples/test-suite/perl5/byreference_runme.pl
@@ -0,0 +1,36 @@
+use strict;
+use warnings;
+use Test::More tests => 68;
+BEGIN { use_ok('byreference') }
+require_ok('byreference');
+
+sub chk { my($type, $call, $v1, $v2) = @_;
+ $byreference::FrVal = $v1;
+ my $v = $v2;
+ eval { $call->(\$v) };
+ is($@, '', "$type check");
+ is($byreference::ToVal, $v2, "$type out");
+ is($v, $v1, "$type in");
+}
+chk("double*", \&byreference::PDouble, 12.2, 18.6);
+chk("double&", \&byreference::RDouble, 32.5, 64.8);
+chk("float*", \&byreference::PFloat, 64.5, 96.0);
+chk("float&", \&byreference::RFloat, 98.5, 6.25);
+chk("int*", \&byreference::PInt, 1887, 3356);
+chk("int&", \&byreference::RInt, 2622, 9867);
+chk("short*", \&byreference::PShort, 4752, 3254);
+chk("short&", \&byreference::RShort, 1898, 5757);
+chk("long*", \&byreference::PLong, 6687, 7132);
+chk("long&", \&byreference::RLong, 8346, 4398);
+chk("uint*", \&byreference::PUInt, 6853, 5529);
+chk("uint&", \&byreference::RUInt, 5483, 7135);
+chk("ushort*", \&byreference::PUShort, 9960, 9930);
+chk("ushort&", \&byreference::RUShort, 1193, 4178);
+chk("ulong*", \&byreference::PULong, 7960, 4788);
+chk("ulong&", \&byreference::RULong, 8829, 1603);
+chk("uchar*", \&byreference::PUChar, 110, 239);
+chk("uchar&", \&byreference::RUChar, 15, 97);
+chk("char*", \&byreference::PChar, -7, 118);
+chk("char&", \&byreference::RChar, -3, -107);
+chk("bool*", \&byreference::PBool, 0, 1);
+chk("bool&", \&byreference::RBool, 1, 0);
diff --git a/Examples/test-suite/perl5/char_strings_runme.pl b/Examples/test-suite/perl5/char_strings_runme.pl
index 51c227bb9..c4573737e 100644
--- a/Examples/test-suite/perl5/char_strings_runme.pl
+++ b/Examples/test-suite/perl5/char_strings_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 5;
BEGIN { use_ok('char_strings') }
require_ok('char_strings');
@@ -10,3 +10,6 @@ is(char_strings::CharPingPong($val1), "100", 'cstr1');
my $val2 = "greetings";
is(char_strings::CharPingPong($val2), "greetings", 'cstr2');
+# SF#2564192
+"this is a test" =~ /(\w+)$/;
+is(char_strings::CharPingPong($1), "test", "handles Magical");
diff --git a/Examples/test-suite/perl5/enum_thorough_runme.pl b/Examples/test-suite/perl5/enum_thorough_runme.pl
index 80a2ccae9..66e719275 100644
--- a/Examples/test-suite/perl5/enum_thorough_runme.pl
+++ b/Examples/test-suite/perl5/enum_thorough_runme.pl
@@ -1,7 +1,7 @@
# an adaptation of ../java/enum_thorough_runme.java
use strict;
use warnings;
-use Test::More tests => 272;
+use Test::More tests => 298;
BEGIN { use_ok('enum_thorough') }
require_ok('enum_thorough');
@@ -348,17 +348,51 @@ SKIP: {
$i->{MemberInstance} = $enum_thorough::Instances::memberinstance3;
is($i->{MemberInstance}, $enum_thorough::Instances::memberinstance3, "MemberInstance 1");
}
+# ignore enum item tests start
+{
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_zero), 0, "ignoreATest 0");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_three), 3, "ignoreATest 3");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_ten), 10, "ignoreATest 10");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_eleven), 11, "ignoreATest 11");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirteen), 13, "ignoreATest 13");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_fourteen), 14, "ignoreATest 14");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_twenty), 20, "ignoreATest 20");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty), 30, "ignoreATest 30");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_two), 32, "ignoreATest 32");
+ is(enum_thorough::ignoreATest($enum_thorough::IgnoreTest::ignoreA_thirty_three), 33, "ignoreATest 33");
+}
+{
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_eleven), 11, "ignoreBTest 11");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_twelve), 12, "ignoreBTest 12");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_one), 31, "ignoreBTest 31");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_thirty_two), 32, "ignoreBTest 32");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_one), 41, "ignoreBTest 41");
+ is(enum_thorough::ignoreBTest($enum_thorough::IgnoreTest::ignoreB_forty_two), 42, "ignoreBTest 42");
+}
+{
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_ten), 10, "ignoreCTest 10");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_twelve), 12, "ignoreCTest 12");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty), 30, "ignoreCTest 30");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_thirty_two), 32, "ignoreCTest 32");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty), 40, "ignoreCTest 40");
+ is(enum_thorough::ignoreCTest($enum_thorough::IgnoreTest::ignoreC_forty_two), 42, "ignoreCTest 42");
+}
+{
+ is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_one), 21, "ignoreDTest 21");
+ is(enum_thorough::ignoreDTest($enum_thorough::IgnoreTest::ignoreD_twenty_two), 22, "ignoreDTest 22");
+}
+{
+ is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_zero), 0, "ignoreETest 0");
+ is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_one), 21, "ignoreETest 21");
+ is(enum_thorough::ignoreETest($enum_thorough::IgnoreTest::ignoreE_twenty_two), 22, "ignoreETest 22");
+}
+# ignore enum item tests end
{
is(enum_thorough::repeatTest($enum_thorough::one), 1, "repeatTest 1");
is(enum_thorough::repeatTest($enum_thorough::initial), 1, "repeatTest 2");
is(enum_thorough::repeatTest($enum_thorough::two), 2, "repeatTest 3");
is(enum_thorough::repeatTest($enum_thorough::three), 3, "repeatTest 4");
-{ local $TODO = "overzealous keyword guarding";
- ok(defined($enum_thorough::last), "found enum value");
-SKIP: {
- skip "enum value not in expected package", 1 unless defined $enum_thorough::last;
- is(enum_thorough::repeatTest($enum_thorough::last), 3, "repeatTest 5");
-}}
+ is(enum_thorough::repeatTest($enum_thorough::llast), 3, "repeatTest 5");
is(enum_thorough::repeatTest($enum_thorough::end), 3, "repeatTest 6");
}
@@ -368,8 +402,8 @@ SKIP: {
is(enum_thorough::speedTest4($enum_thorough::SpeedClass::slow),
$enum_thorough::SpeedClass::slow, "speedTest Global 4");
is(enum_thorough::speedTest5($enum_thorough::SpeedClass::slow),
- $enum_thorough::SpeedClass::slow, "speedTest Global 5 failed");
+ $enum_thorough::SpeedClass::slow, "speedTest Global 5");
is(enum_thorough::speedTest4($enum_thorough::SpeedClass::fast),
- $enum_thorough::SpeedClass::fast, "speedTest Global 4 failed");
+ $enum_thorough::SpeedClass::fast, "speedTest Global 4");
is(enum_thorough::speedTest5($enum_thorough::SpeedClass::fast),
- $enum_thorough::SpeedClass::fast, "speedTest Global 5 failed");
+ $enum_thorough::SpeedClass::fast, "speedTest Global 5");
diff --git a/Examples/test-suite/perl5/imports_runme.pl b/Examples/test-suite/perl5/imports_runme.pl
index 13ca08a1c..fd730fedf 100644
--- a/Examples/test-suite/perl5/imports_runme.pl
+++ b/Examples/test-suite/perl5/imports_runme.pl
@@ -1,5 +1,5 @@
use imports_b;
use imports_a;
-$x = imports_b::B->new();
+$x = imports_bc::new_B();
imports_ac::A_hello($x);
diff --git a/Examples/test-suite/perl5/packageoption_runme.pl b/Examples/test-suite/perl5/packageoption_runme.pl
index debea78e1..d94a7a1fd 100644
--- a/Examples/test-suite/perl5/packageoption_runme.pl
+++ b/Examples/test-suite/perl5/packageoption_runme.pl
@@ -14,11 +14,11 @@ sub ok_not ($;$) {
ok($test, $name);
}
-my $a = C::A->new();
+my $a = CommonPackage::A->new();
-isa_ok($a, 'C::A');
+isa_ok($a, 'CommonPackage::A');
-my $b = C::B->new();
+my $b = CommonPackage::B->new();
-isa_ok($b, 'C::B');
+isa_ok($b, 'CommonPackage::B');
diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
new file mode 100644
index 000000000..d48f37e8a
--- /dev/null
+++ b/Examples/test-suite/php/Makefile.in
@@ -0,0 +1,56 @@
+#######################################################################
+# Makefile for php test-suite
+#######################################################################
+
+LANGUAGE = php
+SCRIPTSUFFIX = _runme.php
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+
+#CPP_TEST_CASES += \
+# php_namewarn_rename \
+
+include $(srcdir)/../common.mk
+
+# Overridden variables here
+TARGETPREFIX =# Should be php_ for Windows, empty otherwise
+
+# write out tests without a _runme.php
+missingcpptests:
+ for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
+
+missingctests:
+ for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php || echo $${test}; done
+
+missingtests: missingcpptests missingctests
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +$(swig_and_compile_cpp)
+ +$(run_testcase)
+
+%.ctest:
+ $(setup)
+ +$(swig_and_compile_c)
+ +$(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +$(swig_and_compile_multi_cpp)
+ +$(run_testcase)
+
+# Runs the testcase. A testcase is only run if
+# a file is found which has _runme.php appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile PHPSCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php_run;) \
+ fi;
+
+# Clean: remove the generated .php file
+%.clean:
+ @rm -f $*.php;
+
+clean:
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php_clean
diff --git a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4 b/Examples/test-suite/php/abstract_inherit_ok_runme.php
index 1182e4cec..c2d86499b 100644
--- a/Examples/test-suite/php4/abstract_inherit_ok_runme.php4
+++ b/Examples/test-suite/php/abstract_inherit_ok_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "abstract_inherit_ok.php";
check::classes(array(Foo,Spam));
diff --git a/Examples/test-suite/php4/abstract_inherit_runme.php4 b/Examples/test-suite/php/abstract_inherit_runme.php
index fbc971711..3554e6fd8 100644
--- a/Examples/test-suite/php4/abstract_inherit_runme.php4
+++ b/Examples/test-suite/php/abstract_inherit_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "abstract_inherit.php";
check::classes(array(Foo,Bar,Spam,NRFilter_i,NRRCFilter_i,NRRCFilterpro_i,NRRCFilterpri_i));
diff --git a/Examples/test-suite/php4/add_link_runme.php4 b/Examples/test-suite/php/add_link_runme.php
index b9d5334dd..4d8c31d5e 100644
--- a/Examples/test-suite/php4/add_link_runme.php4
+++ b/Examples/test-suite/php/add_link_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "add_link.php";
// No new functions, except the flat functions
diff --git a/Examples/test-suite/php4/argout_runme.php4 b/Examples/test-suite/php/argout_runme.php
index 1328b0926..1c9026b6c 100644
--- a/Examples/test-suite/php4/argout_runme.php4
+++ b/Examples/test-suite/php/argout_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "argout.php";
check::functions(array(incp,incr,inctr,new_intp,copy_intp,delete_intp,intp_assign,intp_value,voidhandle,handle));
diff --git a/Examples/test-suite/php4/arrayptr_runme.php4 b/Examples/test-suite/php/arrayptr_runme.php
index c057a6772..717c870d9 100644
--- a/Examples/test-suite/php4/arrayptr_runme.php4
+++ b/Examples/test-suite/php/arrayptr_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "arrayptr.php";
// No new functions
diff --git a/Examples/test-suite/php4/arrays_global_runme.php4 b/Examples/test-suite/php/arrays_global_runme.php
index d6a3955e1..baa5521ed 100644
--- a/Examples/test-suite/php4/arrays_global_runme.php4
+++ b/Examples/test-suite/php/arrays_global_runme.php
@@ -1,14 +1,20 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "arrays_global.php";
check::functions(array(test_a,test_b,new_simplestruct,new_material));
check::classes(array(arrays_global,SimpleStruct,Material));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat));
-check::set(array_c,"hac");
-check::equal("ha",check::get(array_c,"ha"),"set array_c");
+// The size of array_c is 2, but the last byte is \0, so we can only store a
+// single byte string in it.
+check::set(array_c,"Z");
+check::equal("Z",check::get(array_c),"set array_c");
+check::set(array_c,"xy");
+check::equal("x",check::get(array_c),"set array_c");
+check::set(array_c,"h");
+check::equal("h",check::get(array_c),"set array_c");
check::done();
?>
diff --git a/Examples/test-suite/php4/arrays_global_twodim_runme.php4 b/Examples/test-suite/php/arrays_global_twodim_runme.php
index 352ad2568..d9b62de0d 100644
--- a/Examples/test-suite/php4/arrays_global_twodim_runme.php4
+++ b/Examples/test-suite/php/arrays_global_twodim_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "arrays_global_twodim.php";
check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
diff --git a/Examples/test-suite/php4/arrays_runme.php4 b/Examples/test-suite/php/arrays_runme.php
index 407c32c31..97ee6bbbf 100644
--- a/Examples/test-suite/php4/arrays_runme.php4
+++ b/Examples/test-suite/php/arrays_runme.php
@@ -1,6 +1,6 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "arrays.php";
check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));
diff --git a/Examples/test-suite/php4/arrays_scope_runme.php4 b/Examples/test-suite/php/arrays_scope_runme.php
index 75c7ccf27..92de96920 100644
--- a/Examples/test-suite/php4/arrays_scope_runme.php4
+++ b/Examples/test-suite/php/arrays_scope_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "arrays_scope.php";
// No new functions
diff --git a/Examples/test-suite/php4/casts_runme.php4 b/Examples/test-suite/php/casts_runme.php
index c3d19e29e..03ee6829c 100644
--- a/Examples/test-suite/php4/casts_runme.php4
+++ b/Examples/test-suite/php/casts_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "casts.php";
// No new functions
diff --git a/Examples/test-suite/php4/class_ignore_runme.php4 b/Examples/test-suite/php/class_ignore_runme.php
index 5da23e502..861576026 100644
--- a/Examples/test-suite/php4/class_ignore_runme.php4
+++ b/Examples/test-suite/php/class_ignore_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "class_ignore.php";
check::functions(array(do_blah,new_bar,bar_blah,new_boo,boo_away,new_far,new_hoo));
diff --git a/Examples/test-suite/php4/conversion_namespace_runme.php4 b/Examples/test-suite/php/conversion_namespace_runme.php
index ae49d2002..e6866f871 100644
--- a/Examples/test-suite/php4/conversion_namespace_runme.php4
+++ b/Examples/test-suite/php/conversion_namespace_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "conversion_namespace.php";
check::classes(array("Foo","Bar"));
diff --git a/Examples/test-suite/php4/conversion_ns_template_runme.php4 b/Examples/test-suite/php/conversion_ns_template_runme.php
index e799cdd48..9702eedb7 100644
--- a/Examples/test-suite/php4/conversion_ns_template_runme.php4
+++ b/Examples/test-suite/php/conversion_ns_template_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "conversion_ns_template.php";
check::classes(array("conversion_ns_template","Foo_One","Bar_One","Hi"));
diff --git a/Examples/test-suite/php4/conversion_runme.php4 b/Examples/test-suite/php/conversion_runme.php
index 7941a7bbe..69ade46db 100644
--- a/Examples/test-suite/php4/conversion_runme.php4
+++ b/Examples/test-suite/php/conversion_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "conversion.php";
check::classes(array("Foo","Bar"));
diff --git a/Examples/test-suite/php4/cpp_static_runme.php4 b/Examples/test-suite/php/cpp_static_runme.php
index b7f987505..54dbfc7d8 100644
--- a/Examples/test-suite/php4/cpp_static_runme.php4
+++ b/Examples/test-suite/php/cpp_static_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "cpp_static.php";
// No new functions
diff --git a/Examples/test-suite/php4/enum_scope_template_runme.php4 b/Examples/test-suite/php/enum_scope_template_runme.php
index 40efc5743..7cea23911 100644
--- a/Examples/test-suite/php4/enum_scope_template_runme.php4
+++ b/Examples/test-suite/php/enum_scope_template_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "enum_scope_template.php";
check::classes(array("enum_scope_template", "TreeInt"));
diff --git a/Examples/test-suite/php4/evil_diamond_ns_runme.php4 b/Examples/test-suite/php/evil_diamond_ns_runme.php
index 29e8cd520..b76d1443f 100644
--- a/Examples/test-suite/php4/evil_diamond_ns_runme.php4
+++ b/Examples/test-suite/php/evil_diamond_ns_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "evil_diamond_ns.php";
check::classes(array("evil_diamond_ns","foo","bar","baz","spam"));
diff --git a/Examples/test-suite/php4/evil_diamond_prop_runme.php4 b/Examples/test-suite/php/evil_diamond_prop_runme.php
index c0b157fca..6f66d01c5 100644
--- a/Examples/test-suite/php4/evil_diamond_prop_runme.php4
+++ b/Examples/test-suite/php/evil_diamond_prop_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "evil_diamond_prop.php";
check::classes(array("evil_diamond_prop","foo","bar","baz","spam"));
diff --git a/Examples/test-suite/php4/evil_diamond_runme.php4 b/Examples/test-suite/php/evil_diamond_runme.php
index 677813bfa..a6ef211b1 100644
--- a/Examples/test-suite/php4/evil_diamond_runme.php4
+++ b/Examples/test-suite/php/evil_diamond_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "evil_diamond.php";
check::classes(array("evil_diamond","foo","bar","baz","spam"));
diff --git a/Examples/test-suite/php4/extend_template_ns_runme.php4 b/Examples/test-suite/php/extend_template_ns_runme.php
index 16a6434bf..604e0470e 100644
--- a/Examples/test-suite/php4/extend_template_ns_runme.php4
+++ b/Examples/test-suite/php/extend_template_ns_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "extend_template_ns.php";
check::classes(array("extend_template_ns","Foo_One"));
diff --git a/Examples/test-suite/php4/extend_template_runme.php4 b/Examples/test-suite/php/extend_template_runme.php
index c12f330a5..bf77e9b1c 100644
--- a/Examples/test-suite/php4/extend_template_runme.php4
+++ b/Examples/test-suite/php/extend_template_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "extend_template.php";
check::classes(array("Foo_0"));
diff --git a/Examples/test-suite/php4/grouping_runme.php4 b/Examples/test-suite/php/grouping_runme.php
index 45e321fd3..8a2a88fa9 100644
--- a/Examples/test-suite/php4/grouping_runme.php4
+++ b/Examples/test-suite/php/grouping_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "grouping.php";
check::functions(array("test1","test2","do_unary","negate"));
diff --git a/Examples/test-suite/php4/ignore_parameter_runme.php4 b/Examples/test-suite/php/ignore_parameter_runme.php
index 8a2bf899e..745720c3c 100644
--- a/Examples/test-suite/php4/ignore_parameter_runme.php4
+++ b/Examples/test-suite/php/ignore_parameter_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "ignore_parameter.php";
// No new functions
diff --git a/Examples/test-suite/php4/li_carrays_runme.php4 b/Examples/test-suite/php/li_carrays_runme.php
index b0b93dafe..babf8443b 100644
--- a/Examples/test-suite/php4/li_carrays_runme.php4
+++ b/Examples/test-suite/php/li_carrays_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "li_carrays.php";
// No new functions
diff --git a/Examples/test-suite/php4/li_std_string_runme.php4 b/Examples/test-suite/php/li_std_string_runme.php
index fb3da3598..c7270df3d 100644
--- a/Examples/test-suite/php4/li_std_string_runme.php4
+++ b/Examples/test-suite/php/li_std_string_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "li_std_string.php";
// Global variables
diff --git a/Examples/test-suite/php4/rename_scope_runme.php4 b/Examples/test-suite/php/rename_scope_runme.php
index ad86321d3..33925a6db 100644
--- a/Examples/test-suite/php4/rename_scope_runme.php4
+++ b/Examples/test-suite/php/rename_scope_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "rename_scope.php";
check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));
diff --git a/Examples/test-suite/php4/skel.php4 b/Examples/test-suite/php/skel.php
index d6f33758d..780a999ed 100644
--- a/Examples/test-suite/php4/skel.php4
+++ b/Examples/test-suite/php/skel.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "____.php";
// No new functions
diff --git a/Examples/test-suite/php4/smart_pointer_rename_runme.php4 b/Examples/test-suite/php/smart_pointer_rename_runme.php
index 5f21b6dda..a1759cb95 100644
--- a/Examples/test-suite/php4/smart_pointer_rename_runme.php4
+++ b/Examples/test-suite/php/smart_pointer_rename_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "smart_pointer_rename.php";
check::classes(array("Foo","Bar"));
diff --git a/Examples/test-suite/php4/sym_runme.php4 b/Examples/test-suite/php/sym_runme.php
index ce89ea4b2..a6d2a6c74 100644
--- a/Examples/test-suite/php4/sym_runme.php4
+++ b/Examples/test-suite/php/sym_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "sym.php";
// No new functions
diff --git a/Examples/test-suite/php4/template_arg_typename_runme.php4 b/Examples/test-suite/php/template_arg_typename_runme.php
index 7062c674e..58835eafe 100644
--- a/Examples/test-suite/php4/template_arg_typename_runme.php4
+++ b/Examples/test-suite/php/template_arg_typename_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "template_arg_typename.php";
// No new functions
diff --git a/Examples/test-suite/php4/template_construct_runme.php4 b/Examples/test-suite/php/template_construct_runme.php
index d0fbc9bb7..3a3986f7e 100644
--- a/Examples/test-suite/php4/template_construct_runme.php4
+++ b/Examples/test-suite/php/template_construct_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "template_construct.php";
check::classes(array(Foo_int));
diff --git a/Examples/test-suite/php4/tests.php4 b/Examples/test-suite/php/tests.php
index 36e9f4163..b62e878fc 100644
--- a/Examples/test-suite/php4/tests.php4
+++ b/Examples/test-suite/php/tests.php
@@ -185,7 +185,7 @@ class check {
}
function equal($a,$b,$message) {
- if (! ($a===$b)) return check::fail($message);
+ if (! ($a===$b)) return check::fail($message . ": '$a'!=='$b'");
return TRUE;
}
diff --git a/Examples/test-suite/php4/typedef_reference_runme.php4 b/Examples/test-suite/php/typedef_reference_runme.php
index 2c64efce6..88a70f8d3 100644
--- a/Examples/test-suite/php4/typedef_reference_runme.php4
+++ b/Examples/test-suite/php/typedef_reference_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "typedef_reference.php";
check::functions(array(somefunc,otherfunc,new_intp,copy_intp,delete_intp,intp_assign,intp_value));
diff --git a/Examples/test-suite/php4/typemap_ns_using_runme.php4 b/Examples/test-suite/php/typemap_ns_using_runme.php
index 44403d138..6a599f008 100644
--- a/Examples/test-suite/php4/typemap_ns_using_runme.php4
+++ b/Examples/test-suite/php/typemap_ns_using_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "typemap_ns_using.php";
if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");
diff --git a/Examples/test-suite/php4/using1_runme.php4 b/Examples/test-suite/php/using1_runme.php
index ed7e32b06..51841bc78 100644
--- a/Examples/test-suite/php4/using1_runme.php4
+++ b/Examples/test-suite/php/using1_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "using1.php";
if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");
diff --git a/Examples/test-suite/php4/using2_runme.php4 b/Examples/test-suite/php/using2_runme.php
index e57f0ce9a..391a98f52 100644
--- a/Examples/test-suite/php4/using2_runme.php4
+++ b/Examples/test-suite/php/using2_runme.php
@@ -1,6 +1,6 @@
<?php
-require "tests.php4";
+require "tests.php";
require "using2.php";
if (! class_exists("_fooimpl")) die("_fooimpl class not found\n");
if (! 3==spam(3)) die("spam function not working right\n");
diff --git a/Examples/test-suite/php4/valuewrapper_base_runme.php4 b/Examples/test-suite/php/valuewrapper_base_runme.php
index 355bb41c5..aff88486e 100644
--- a/Examples/test-suite/php4/valuewrapper_base_runme.php4
+++ b/Examples/test-suite/php/valuewrapper_base_runme.php
@@ -1,7 +1,7 @@
<?php
// Sample test file
-require "tests.php4";
+require "tests.php";
require "valuewrapper_base.php";
check::classes(array("valuewrapper_base","Base","Interface_BP"));
diff --git a/Examples/test-suite/php4/Makefile.in b/Examples/test-suite/php4/Makefile.in
deleted file mode 100644
index 2e14ef9a2..000000000
--- a/Examples/test-suite/php4/Makefile.in
+++ /dev/null
@@ -1,69 +0,0 @@
-#######################################################################
-# Makefile for php4 test-suite
-#######################################################################
-
-LANGUAGE = php4
-SCRIPTSUFFIX = _runme.php4
-srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = @top_builddir@
-
-include $(srcdir)/../common.mk
-
-# Overridden variables here
-TARGETPREFIX =# Should be php_ for Windows, empty otherwise
-
-makecpptests:
- @bash -ec 'for test in $(CPP_TEST_CASES) ; do $(MAKE) clean && $(MAKE) $${test}.cpptest; done'
-
-maketests: makecpptests makectests
-
-makectests:
- @bash -ec 'for test in $(C_TEST_CASES) ; do $($(MAKE)) clean && $(MAKE) $${test}.cpptest; done'
-
-runcpptests:
- @bash -ec 'for test in $(CPP_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi ; done'
-
-runctests:
- @bash -ec 'for test in $(C_TEST_CASES) ; do if [ -f $${test}_runme.php4 ] ; then $(MAKE) clean && $(MAKE) $${test}.cpptest; fi; done'
-
-runtests: runcpptests runctests
-
-# write out tests without a _runme.php4
-missingcpptests:
- @bash -ec 'for test in $(CPP_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
-
-missingctests:
- @bash -ec 'for test in $(C_TEST_CASES) ; do test -f $${test}_runme.php4 || echo $${test}; done'
-
-missingtests: missingcpptests missingctests
-
-# Rules for the different types of tests
-%.cpptest:
- $(setup)
- +$(swig_and_compile_cpp)
- +$(run_testcase)
-
-%.ctest:
- $(setup)
- +$(swig_and_compile_c)
- +$(run_testcase)
-
-%.multicpptest:
- $(setup)
- +$(swig_and_compile_multi_cpp)
- +$(run_testcase)
-
-# Runs the testcase. A testcase is only run if
-# a file is found which has _runme.php4 appended after the testcase name.
-run_testcase = \
- if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SCRIPT=$(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) RUNTOOL=$(RUNTOOL) php4_run;) \
- fi;
-
-# Clean: remove the generated .php file
-%.clean:
- @rm -f $*.php;
-
-clean:
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile php4_clean
diff --git a/Examples/test-suite/php4/namewarn_rename.i b/Examples/test-suite/php_namewarn_rename.i
index 98de311b9..87877c4f0 100644
--- a/Examples/test-suite/php4/namewarn_rename.i
+++ b/Examples/test-suite/php_namewarn_rename.i
@@ -1,4 +1,4 @@
-%module namewarn_rename
+%module php_namewarn_rename
%inline %{
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i
index 9491fc1d2..b9f357b90 100644
--- a/Examples/test-suite/preproc.i
+++ b/Examples/test-suite/preproc.i
@@ -313,6 +313,11 @@ int test(int defined)
#define MASK(shift, size) (((1 << (size)) - 1) <<(shift))
#define SOME_MASK_DEF (80*MASK(8, 10))
+/* some constants */
+#define BOLTZMANN (1.380658e-23)
+#define AVOGADRO (6.0221367e23)
+#define RGAS (BOLTZMANN*AVOGADRO)
+#define RGASX (BOLTZMANN*AVOGADRO*BOLTZMANN)
%{
#define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \
diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i
index f8189a502..27a90bc72 100644
--- a/Examples/test-suite/pure_virtual.i
+++ b/Examples/test-suite/pure_virtual.i
@@ -63,16 +63,18 @@ class E : public C, public AA {
public:
virtual void something() { };
};
+%}
/* Fill in method from AA. This class should be constructable */
#ifdef SWIGCSHARP
%ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored.
#endif
+
+%inline %{
class F : public E {
public:
virtual void method2() { }
};
-
%}
%{
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 7f11cd495..b8bd8944c 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -2,16 +2,37 @@
# Makefile for python test-suite
#######################################################################
+ifeq (,$(PY3))
+ PYBIN = @PYTHON@
+else
+ PYBIN = @PYTHON3@
+endif
+
LANGUAGE = python
-PYTHON = @PYTHON@
-SCRIPTSUFFIX = _runme.py
+PYTHON = $(PYBIN)
+
+#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
+PY2SCRIPTSUFFIX = _runme.py
+PY3SCRIPTSUFFIX = _runme3.py
+
+ifeq (,$(PY3))
+ SCRIPTSUFFIX = $(PY2SCRIPTSUFFIX)
+else
+ SCRIPTSUFFIX = $(PY3SCRIPTSUFFIX)
+endif
+
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+
+PY2TO3 = 2to3 -x import
+
+
CPP_TEST_CASES += \
argcargvtest \
- autodoc \
+ python_autodoc \
+ python_append \
callback \
complextest \
director_stl \
@@ -22,32 +43,39 @@ CPP_TEST_CASES += \
input \
inplaceadd \
implicittest \
- kwargs \
li_cstring \
li_cwstring \
li_factory \
li_implicit \
li_std_vectora \
+ li_std_vector_extra \
li_std_map \
+ li_std_multimap \
+ li_std_pair_extra \
li_std_set \
li_std_stream \
+ li_std_string_extra \
li_std_wstream \
li_std_wstring \
- nondynamic \
- overload_simple_cast \
primitive_types \
+ python_abstractbase \
+ python_kwargs \
+ python_nondynamic \
+ python_overload_simple_cast \
std_containers \
swigobject \
template_matrix \
- simutry \
- vector
+ simutry
+# li_std_carray
+# director_profile
+# python_pybuf
C_TEST_CASES += \
file_test \
li_cstring \
li_cwstring \
- nondynamic
+ python_nondynamic
#
# This test only works with modern C compilers
@@ -77,17 +105,42 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
+$(swig_and_compile_multi_cpp)
$(run_testcase)
+
+# Call 2to3 to generate Python 3.x test from the Python 2.x's *_runme.py file
+%$(PY3SCRIPTSUFFIX): %$(PY2SCRIPTSUFFIX)
+ cp $< $@
+ $(PY2TO3) -w $@ >/dev/null 2>&1
+
+
# Runs the testcase. A testcase is only run if
-# a file is found which has _runme.py appended after the testcase name.
+# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
+
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+
+py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
+py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
+
+ifeq (,$(PY3))
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX);) \
+ $(run_python);)\
+ fi;
+else
+run_testcase = \
+ if [ -f $(py2_runme) ]; then ( \
+ $(MAKE) -f $(srcdir)/Makefile $(py3_runme) && \
+ $(run_python);) \
+ elif [ -f $(py3_runme) ]; then ( \
+ $(run_python);) \
fi;
+endif
# Clean: remove the generated .py file
%.clean:
@rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@rm -f $*.py;
+ @#We only remove the _runme3.py if it is generated by 2to3 from a _runme.py.
+ @if [ -f $(py2_runme) ]; then (rm -f $(py3_runme) $(py3_runme).bak;) fi;
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile python_clean
@@ -101,14 +154,15 @@ cvsignore:
@echo clientdata_prop_b.py
@echo imports_a.py
@echo imports_b.py
- @echo mod_a.py mod_b.py
+ @echo mod_a.py mod_b.py
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.py hugemod_b.py hugemod_runme.py
@echo template_typedef_import.py
+hugemod_runme = hugemod$(SCRIPTPREFIX)
hugemod:
- perl hugemod.pl
+ perl hugemod.pl $(hugemod_runme)
$(MAKE) hugemod_a.cpptest
$(MAKE) hugemod_b.cpptest
- time $(PYTHON) hugemod_runme.py
- time $(PYTHON) hugemod_runme.py
+ sh -c "time $(PYTHON) $(hugemod_runme)"
+ sh -c "time $(PYTHON) $(hugemod_runme)"
diff --git a/Examples/test-suite/python/README b/Examples/test-suite/python/README
index b86ec5289..71db759b5 100644
--- a/Examples/test-suite/python/README
+++ b/Examples/test-suite/python/README
@@ -1,4 +1,8 @@
See ../README for common README file.
-Any testcases which have _runme.py appended after the testcase name will be detected and run.
+Any testcases which have _runme.py (or _runme3.py for Python 3) appended after the testcase name will be detected and run.
+If you intend to write a testcase for both Python 2.x and 3.x, do *not* directly put the _runme3.py in this directory. Just write Python 2.x's _runme.py testcase and it will be automatically converted to Python 3 code during test.
+
+You can run make with PY3=y to run test case with Python 3.x, eg.
+ $ make voidtest.cpptest PY3=y
diff --git a/Examples/test-suite/python/contract_runme.py b/Examples/test-suite/python/contract_runme.py
index 9ded5bb5b..905bf1196 100644
--- a/Examples/test-suite/python/contract_runme.py
+++ b/Examples/test-suite/python/contract_runme.py
@@ -133,3 +133,11 @@ try:
except:
pass
+#Namespace
+my = contract.myClass(1)
+try:
+ my = contract.myClass(0)
+ print "Failed! constructor preassertion"
+except:
+ pass
+
diff --git a/Examples/test-suite/python/cpp_namespace_runme.py b/Examples/test-suite/python/cpp_namespace_runme.py
index 3108b4f47..a454774f5 100644
--- a/Examples/test-suite/python/cpp_namespace_runme.py
+++ b/Examples/test-suite/python/cpp_namespace_runme.py
@@ -3,20 +3,20 @@ import cpp_namespace
n = cpp_namespace.fact(4)
if n != 24:
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.cvar.Foo != 42:
- raise "Bad variable value!"
+ raise RuntimeError("Bad variable value!")
t = cpp_namespace.Test()
if t.method() != "Test::method":
- raise "Bad method return value!"
+ raise RuntimeError("Bad method return value!")
if cpp_namespace.do_method(t) != "Test::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method2(t) != "Test::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
cpp_namespace.weird("hello", 4)
@@ -28,18 +28,18 @@ t4 = cpp_namespace.Test4()
t5 = cpp_namespace.Test5()
if cpp_namespace.foo3(42) != 42:
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t2,40) != "Test2::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t3,40) != "Test3::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t4,40) != "Test4::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
if cpp_namespace.do_method3(t5,40) != "Test5::method":
- raise "Bad return value!"
+ raise RuntimeError("Bad return value!")
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
new file mode 100644
index 000000000..ef8623359
--- /dev/null
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -0,0 +1,7 @@
+#!/usr/bin/evn python
+from cpp_static import *
+StaticFunctionTest.static_func()
+StaticFunctionTest.static_func_2(1)
+StaticFunctionTest.static_func_3(1,2)
+StaticMemberTest.static_int = 10
+assert StaticMemberTest.static_int == 10
diff --git a/Examples/test-suite/python/director_classic_runme.py b/Examples/test-suite/python/director_classic_runme.py
index 878905679..7e18a9a61 100644
--- a/Examples/test-suite/python/director_classic_runme.py
+++ b/Examples/test-suite/python/director_classic_runme.py
@@ -1,56 +1,56 @@
from director_classic import *
class TargetLangPerson(Person):
- def __init__(self):
- Person.__init__(self)
- def id(self):
- identifier = "TargetLangPerson"
- return identifier
+ def __init__(self):
+ Person.__init__(self)
+ def id(self):
+ identifier = "TargetLangPerson"
+ return identifier
class TargetLangChild(Child):
- def __init__(self):
- Child.__init__(self)
- def id(self):
- identifier = "TargetLangChild"
- return identifier
+ def __init__(self):
+ Child.__init__(self)
+ def id(self):
+ identifier = "TargetLangChild"
+ return identifier
class TargetLangGrandChild(GrandChild):
- def __init__(self):
- GrandChild.__init__(self)
- def id(self):
- identifier = "TargetLangGrandChild"
- return identifier
+ def __init__(self):
+ GrandChild.__init__(self)
+ def id(self):
+ identifier = "TargetLangGrandChild"
+ return identifier
# Semis - don't override id() in target language
class TargetLangSemiPerson(Person):
- def __init__(self):
- Person.__init__(self)
+ def __init__(self):
+ Person.__init__(self)
# No id() override
class TargetLangSemiChild(Child):
- def __init__(self):
- Child.__init__(self)
+ def __init__(self):
+ Child.__init__(self)
# No id() override
class TargetLangSemiGrandChild(GrandChild):
- def __init__(self):
- GrandChild.__init__(self)
+ def __init__(self):
+ GrandChild.__init__(self)
# No id() override
# Orphans - don't override id() in C++
class TargetLangOrphanPerson(OrphanPerson):
- def __init__(self):
- OrphanPerson.__init__(self)
- def id(self):
- identifier = "TargetLangOrphanPerson"
- return identifier
+ def __init__(self):
+ OrphanPerson.__init__(self)
+ def id(self):
+ identifier = "TargetLangOrphanPerson"
+ return identifier
class TargetLangOrphanChild(OrphanChild):
- def __init__(self):
- Child.__init__(self)
- def id(self):
- identifier = "TargetLangOrphanChild"
- return identifier
+ def __init__(self):
+ Child.__init__(self)
+ def id(self):
+ identifier = "TargetLangOrphanChild"
+ return identifier
def check(person, expected):
@@ -61,7 +61,7 @@ def check(person, expected):
if (debug):
print(ret)
if (ret != expected):
- raise ("Failed. Received: " + ret + " Expected: " + expected)
+ raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
# Polymorphic call from C++
caller = Caller()
@@ -70,7 +70,7 @@ def check(person, expected):
if (debug):
print(ret)
if (ret != expected):
- raise ("Failed. Received: " + ret + " Expected: " + expected)
+ raise RuntimeError("Failed. Received: " + str(ret) + " Expected: " + expected)
# Polymorphic call of object created in target language and passed to C++ and back again
baseclass = caller.baseClass()
@@ -78,7 +78,7 @@ def check(person, expected):
if (debug):
print(ret)
if (ret != expected):
- raise ("Failed. Received: " + ret + " Expected: " + expected)
+ raise RuntimeError("Failed. Received: " + str(ret)+ " Expected: " + expected)
caller.resetCallback()
if (debug):
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 7c9e69250..ef7a044f1 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -1,5 +1,8 @@
from director_exception import *
-from exceptions import *
+
+class MyException(Exception):
+ def __init__(self, a, b):
+ self.msg = a + b
class MyFoo(Foo):
def ping(self):
@@ -7,39 +10,62 @@ class MyFoo(Foo):
class MyFoo2(Foo):
def ping(self):
- return true
+ return True
pass # error: should return a string
-ok = 0
+class MyFoo3(Foo):
+ def ping(self):
+ raise MyException("foo", "bar")
+# Check that the NotImplementedError raised by MyFoo.ping() is returned by
+# MyFoo.pong().
+ok = 0
a = MyFoo()
b = launder(a)
-
try:
b.pong()
except NotImplementedError, e:
- ok = 1
+ if str(e) == "MyFoo::ping() EXCEPTION":
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
except:
pass
-
if not ok:
raise RuntimeError
-ok = 0
+# Check that the director returns the appropriate TypeError if the return type
+# is wrong.
+ok = 0
a = MyFoo2()
b = launder(a)
-
try:
b.pong()
-except:
- ok = 1
+except TypeError, e:
+ if str(e) == "Swig director type mismatch in output value of type 'std::string'":
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
+if not ok:
+ raise RuntimeError
+# Check that the director can return an exception which requires two arguments
+# to the constructor, without mangling it.
+ok = 0
+a = MyFoo3()
+b = launder(a)
+try:
+ b.pong()
+except MyException, e:
+ if e.msg == 'foobar':
+ ok = 1
+ else:
+ print "Unexpected error message: %s" % str(e)
if not ok:
raise RuntimeError
-
try:
raise Exception2()
except Exception2:
diff --git a/Examples/test-suite/python/director_thread_runme.py b/Examples/test-suite/python/director_thread_runme.py
index e66817e17..15a12ab80 100644
--- a/Examples/test-suite/python/director_thread_runme.py
+++ b/Examples/test-suite/python/director_thread_runme.py
@@ -14,3 +14,5 @@ d.run()
if d.val >= 0:
print d.val
raise RuntimeError
+
+d.stop()
diff --git a/Examples/test-suite/python/file_test_runme.py b/Examples/test-suite/python/file_test_runme.py
index 64154c619..de4e2669e 100644
--- a/Examples/test-suite/python/file_test_runme.py
+++ b/Examples/test-suite/python/file_test_runme.py
@@ -1,7 +1,8 @@
import sys
import file_test
-file_test.nfile(sys.stdout)
+if sys.version_info < (3,0):
+ file_test.nfile(sys.stdout)
cstdout = file_test.GetStdOut()
diff --git a/Examples/test-suite/python/hugemod.pl b/Examples/test-suite/python/hugemod.pl
index 15c4ce41b..5420926e4 100644
--- a/Examples/test-suite/python/hugemod.pl
+++ b/Examples/test-suite/python/hugemod.pl
@@ -2,8 +2,12 @@
use strict;
+my $modsize = 399; #adjust it so you can have a smaller or bigger hugemod
+
+my $runme = shift @ARGV;
+
open HEADER, ">hugemod.h" or die "error";
-open TEST, ">hugemod_runme.py" or die "error";
+open TEST, ">$runme" or die "error";
open I1, ">hugemod_a.i" or die "error";
open I2, ">hugemod_b.i" or die "error";
@@ -21,7 +25,7 @@ print I2 "\%inline \%{\n";
my $i;
-for ($i = 0; $i < 6000; $i++) {
+for ($i = 0; $i < $modsize; $i++) {
my $t = $i * 4;
print HEADER "class type$i { public: int a; };\n";
print I2 "class dtype$i : public type$i { public: int b; };\n";
diff --git a/Examples/test-suite/python/iadd.i b/Examples/test-suite/python/iadd.i
deleted file mode 100644
index 76604c027..000000000
--- a/Examples/test-suite/python/iadd.i
+++ /dev/null
@@ -1,12 +0,0 @@
-%module iadd
-
-%include attribute.i
-%{
-#include "iadd.h"
-%}
-class Foo;
-%attribute_ref(test::Foo, test::A& , AsA);
-%attribute_ref(test::Foo, long, AsLong);
-
-
-%include "iadd.h"
diff --git a/Examples/test-suite/python/implicittest.i b/Examples/test-suite/python/implicittest.i
deleted file mode 100644
index 91205aafa..000000000
--- a/Examples/test-suite/python/implicittest.i
+++ /dev/null
@@ -1,68 +0,0 @@
-%module(naturalvar="1") implicittest
-
-%implicitconv;
-
-%inline
-{
- struct B { };
-}
-
-%inline
-{
- struct A
- {
- int ii;
- A(int i) { ii = 1; }
- A(double d) { ii = 2; }
- A(const B& b) { ii = 3; }
- explicit A(char *s) { ii = 4; }
-
- int get() const { return ii; }
-
- };
-
- int get(const A& a) { return a.ii; }
-
- template <class T>
- struct A_T
- {
- int ii;
- A_T(int i) { ii = 1; }
- A_T(double d) { ii = 2; }
- A_T(const B& b) { ii = 3; }
- explicit A_T(char *s) { ii = 4; }
-
- int get() const { return ii; }
-
- };
-}
-
-%inline
-{
- struct Foo
- {
- int ii;
- Foo(){ ii = 0;}
- Foo(int){ ii = 1;}
- Foo(double){ ii = 2;}
- explicit Foo(char *s){ii = 3;}
- Foo(const Foo& f){ ii = f.ii;}
-
- };
-
- struct Bar
- {
- int ii;
- Foo f;
- Bar() {ii = -1;}
- Bar(const Foo& ff){ ii = ff.ii;}
- };
-
-
- int get_b(const Bar&b) { return b.ii; }
-
- Foo foo;
-
-}
-
-%template(A_int) A_T<int>;
diff --git a/Examples/test-suite/python/li_attribute_runme.py b/Examples/test-suite/python/li_attribute_runme.py
index 5eeec299b..db40b9b2a 100644
--- a/Examples/test-suite/python/li_attribute_runme.py
+++ b/Examples/test-suite/python/li_attribute_runme.py
@@ -1,3 +1,5 @@
+# Ported to C# li_attribute_runme.cs
+
import li_attribute
aa = li_attribute.A(1,2,3)
@@ -9,7 +11,6 @@ if aa.a != 3:
print aa.a
raise RuntimeError
-
if aa.b != 2:
print aa.b
raise RuntimeError
@@ -17,8 +18,6 @@ aa.b = 5
if aa.b != 5:
raise RuntimeError
-
-
if aa.d != aa.b:
raise RuntimeError
@@ -36,17 +35,40 @@ pi.value=3
if pi.value != 3:
raise RuntimeError
-
b = li_attribute.B(aa)
if b.a.c != 3:
raise RuntimeError
-
-myFoo = li_attribute.MyFoo
+# class/struct attribute with get/set methods using return/pass by reference
+myFoo = li_attribute.MyFoo()
myFoo.x = 8
-myClass = li_attribute.MyClass
+myClass = li_attribute.MyClass()
myClass.Foo = myFoo
if myClass.Foo.x != 8:
raise RuntimeError
+# class/struct attribute with get/set methods using return/pass by value
+myClassVal = li_attribute.MyClassVal()
+if myClassVal.ReadWriteFoo.x != -1:
+ raise RuntimeError
+if myClassVal.ReadOnlyFoo.x != -1:
+ raise RuntimeError
+myClassVal.ReadWriteFoo = myFoo
+if myClassVal.ReadWriteFoo.x != 8:
+ raise RuntimeError
+if myClassVal.ReadOnlyFoo.x != 8:
+ raise RuntimeError
+
+# string attribute with get/set methods using return/pass by value
+myStringyClass = li_attribute.MyStringyClass("initial string")
+if myStringyClass.ReadWriteString != "initial string":
+ raise RuntimeError
+if myStringyClass.ReadOnlyString != "initial string":
+ raise RuntimeError
+myStringyClass.ReadWriteString = "changed string"
+if myStringyClass.ReadWriteString != "changed string":
+ raise RuntimeError
+if myStringyClass.ReadOnlyString != "changed string":
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
index 5f6cbd211..f967def14 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
@@ -304,6 +304,15 @@ class li_boost_shared_ptr_runme:
self.verifyValue(li_boost_shared_ptr.overload_smartbyptr(k), "smartbyptr")
self.verifyValue(li_boost_shared_ptr.overload_smartbyptrref(k), "smartbyptrref")
+ # 3rd derived class
+ k = li_boost_shared_ptr.Klass3rdDerived("me oh my")
+ val = k.getValue()
+ self.verifyValue("me oh my-3rdDerived", val)
+ self.verifyCount(1, k)
+ val = li_boost_shared_ptr.test3rdupcast(k)
+ self.verifyValue("me oh my-3rdDerived", val)
+ self.verifyCount(1, k)
+
# //////////////////////////////// Member variables ////////////////////////////////////////
# smart pointer by value
m = li_boost_shared_ptr.MemberVariables()
diff --git a/Examples/test-suite/python/li_std_map.i b/Examples/test-suite/python/li_std_map.i
deleted file mode 100644
index a8ba4f2e2..000000000
--- a/Examples/test-suite/python/li_std_map.i
+++ /dev/null
@@ -1,58 +0,0 @@
-%module("templatereduce") li_std_map
-
-%include std_pair.i
-%include std_map.i
-%include std_multimap.i
-
-%inline %{
-struct A{
- int val;
-
- A(int v = 0): val(v)
- {
- }
-
-};
-%}
-
-namespace std
-{
- %template(pairii) pair<int, int>;
- %template(pairAA) pair<int, A>;
- %template(pairA) pair<int, A*>;
- %template(mapA) map<int, A*>;
- %template(mmapA) multimap<int, A*>;
-
- %template(paircA1) pair<const int, A*>;
- %template(paircA2) pair<const int, const A*>;
- %template(pairiiA) pair<int,pair<int, A*> >;
- %template(pairiiAc) pair<int,const pair<int, A*> >;
-
-
- %template() pair<swig::PyObject_ptr, swig::PyObject_ptr>;
- %template(pymap) map<swig::PyObject_ptr, swig::PyObject_ptr>;
-
-}
-
-
-
-%inline
-{
-std::pair<int, A*>
-p_identa(std::pair<int, A*> p) {
- return p;
-}
-
-std::map<int,A*> m_identa(const std::map<int,A*>& v)
-{
- return v;
-}
-
-}
-
-
-
-namespace std
-{
-%template(mapii) map<int,int>;
-}
diff --git a/Examples/test-suite/python/li_std_map_runme.py b/Examples/test-suite/python/li_std_map_runme.py
index 461421a54..ae75bdda0 100644
--- a/Examples/test-suite/python/li_std_map_runme.py
+++ b/Examples/test-suite/python/li_std_map_runme.py
@@ -48,7 +48,7 @@ for k in pm:
-mii = li_std_map.mapii()
+mii = li_std_map.IntIntMap()
mii[1] = 1
mii[1] = 2
diff --git a/Examples/test-suite/python/li_std_pair.i b/Examples/test-suite/python/li_std_pair.i
deleted file mode 100644
index 886bf1a4b..000000000
--- a/Examples/test-suite/python/li_std_pair.i
+++ /dev/null
@@ -1,210 +0,0 @@
-%module li_std_pair
-
-//
-// activate the automatic comparison methods generation (==,!=,...)
-//
-
-%{
-#include <algorithm> // for std::swap
-%}
-
-
-%include std_pair.i
-%include std_string.i
-%include std_complex.i
-
-%inline
-%{
- struct A
- {
- int val;
-
- A(int v = 0): val(v)
- {
- }
-
- };
- struct B
- {
- };
-%}
-
-%std_comp_methods(std::pair<std::string, int>);
-
-namespace std {
- %template(CIntPair) pair<const int, const int>;
- %template() pair<double, double>;
- %template(ShortPair) pair<short, short>;
-
- %template(IntPair) pair<int, int>;
- %extend pair<int, int>
- {
- %template(pair) pair<short,short>;
- }
-
-
-
- %template(SIPair) pair<std::string, int>;
- %template(CIPair) pair<std::complex<double>, int>;
- %template(SIIPair) pair<std::pair<std::string, int>, int>;
- %template(AIntPair) pair<A, int>;
-
- %template(CCIntPair) pair<const A, const pair<int, int> >;
-
- %template(ABPair) pair<A, B>;
- %template(IntAPair) pair<int, A>;
-
- %template(pairP1) pair<int, A*>;
- %template(pairP2) pair<A*, int>;
- %template(pairP3) pair<A*, A*>;
- %template(pairP4) pair<int, int*>;
- %template(pairP5) pair<int*, int>;
- %template(pairP6) pair<int*, int*>;
-
-}
-%std_comp_methods(std::pair<std::pair<std::string, int>, int>);
-
-%apply std::pair<int,int> *INOUT {std::pair<int,int> *INOUT2};
-
-%inline %{
-
-/* Test the "out" typemap for pair<T, U> */
-std::pair<int, int> makeIntPair(int a, int b) {
- return std::make_pair(a, b);
-}
-
-/**
- * There is no "out" typemap for a pointer to a pair, so
- * this should return a wrapped instance of a std::pair
- * instead of the native "array" type for the target language.
- */
-std::pair<int, int> * makeIntPairPtr(int a, int b) {
- static std::pair<int, int> p = std::make_pair(a, b);
- return &p;
-}
-
-/**
- * There is no "out" typemap for a non-const reference to a pair, so
- * this should return a wrapped instance of a std::pair instead of
- * the native "array" type for the target language.
- */
-std::pair<int, int>& makeIntPairRef(int a, int b) {
- static std::pair<int, int> p = std::make_pair(a, b);
- return p;
-}
-
-/**
- * There is no "out" typemap for a const reference to a pair, so
- * this should return a wrapped instance of a std::pair
- * instead of the native "array" type for the target language.
- */
-const std::pair<int, int> & makeIntPairConstRef(int a, int b) {
- static std::pair<int, int> p = std::make_pair(a, b);
- return p;
-}
-
-/* Test the "in" typemap for pair<T, U> */
-int product1(std::pair<int, int> p) {
- return p.first*p.second;
-}
-
-/* Test the "in" typemap for const pair<T, U>& */
-int product2(const std::pair<int, int>& p) {
- return p.first*p.second;
-}
-
-std::pair<int, int>
- p_ident(std::pair<int, int> p, const std::pair<int, int>& q) {
- return p;
-}
-
-
-std::pair<int, A*>
-p_identa(const std::pair<int, A*>& p) {
- return p;
-}
-
-void
-d_inout(double *INOUT) {
- *INOUT += *INOUT;
-}
-
-void
-d_inout(int *INOUT) {
- *INOUT += *INOUT;
-}
-
-int
-d_inout2(double *INOUT) {
- *INOUT += *INOUT;
- return 1;
-}
-
-void
-p_inout(std::pair<int, int> *INOUT) {
- std::swap(INOUT->first, INOUT->second);
-}
-
-int
-p_inout2(std::pair<int, int> *INOUT) {
- std::swap(INOUT->first, INOUT->second);
- return 1;
-}
-
-void
- p_inout3(std::pair<int,int> *INOUT, std::pair<int,int> *INOUT2) {
- std::swap(*INOUT, *INOUT2);
-}
-
-void
-p_inoutd(std::pair<double, double> *INOUT) {
- std::swap(INOUT->first, INOUT->second);
-}
-
-std::string
- s_ident(const std::string& s) {
- return s;
-}
-
-#if 0
-std::pair<char, char>
- p_ident(std::pair<char, char> p, const std::pair<char, char>& q) {
- return p;
-}
-
-/* Test the "in" typemap for const pair<T, U>* */
-std::pair<A, B>
- p_ident(std::pair<A, B> p, const std::pair<A, B>& q) {
- return q;
-}
-
-/* Test the "in" typemap for const pair<T, U>* */
-std::pair<int, A>
- p_ident(std::pair<int, A> p, const std::pair<int, A>& q) {
- return p;
-}
-
-
-std::pair<int, int>
- p_ident(std::pair<int, int> p, const std::pair<A, int>& q) {
- return p;
-}
-
-std::pair<int, int>
- p_ident(std::pair<int, int> p, const std::pair<A, B>& q) {
- return p;
-}
-
-
-
-#endif
-%}
-
-
-namespace std
-{
- %template(paircA1) pair<const int, A*>;
- %template(paircA2) pair<const int, const A*>;
- %template(pairiiA) pair<int,pair<int, A*> >;
-}
-
diff --git a/Examples/test-suite/python/li_std_pair_extra_runme.py b/Examples/test-suite/python/li_std_pair_extra_runme.py
new file mode 100644
index 000000000..dc6e31b76
--- /dev/null
+++ b/Examples/test-suite/python/li_std_pair_extra_runme.py
@@ -0,0 +1,59 @@
+import li_std_pair_extra
+
+p = (1,2)
+p1 = li_std_pair_extra.p_inout(p)
+p2 = li_std_pair_extra.p_inoutd(p1)
+
+d1 = li_std_pair_extra.d_inout(2)
+
+i,d2 = li_std_pair_extra.d_inout2(2)
+
+i,p = li_std_pair_extra.p_inout2(p)
+p3,p4 = li_std_pair_extra.p_inout3(p1,p1)
+
+psi = li_std_pair_extra.SIPair("hello",1)
+pci = li_std_pair_extra.CIPair(1,1)
+
+
+#psi.first = "hi"
+
+
+psi = li_std_pair_extra.SIPair("hi",1)
+if psi != ("hi",1):
+ raise RuntimeError
+
+psii = li_std_pair_extra.SIIPair(psi,1)
+
+a = li_std_pair_extra.A()
+b = li_std_pair_extra.B()
+
+pab = li_std_pair_extra.ABPair(a,b);
+
+pab.first = a
+pab.first.val = 2
+
+if pab.first.val != 2:
+ raise RuntimeError
+
+
+pci = li_std_pair_extra.CIntPair(1,0)
+
+a = li_std_pair_extra.A(5)
+p1 = li_std_pair_extra.pairP1(1,a.this)
+p2 = li_std_pair_extra.pairP2(a,1)
+p3 = li_std_pair_extra.pairP3(a,a)
+
+
+if a.val != li_std_pair_extra.p_identa(p1.this)[1].val:
+ raise RuntimeError
+
+p = li_std_pair_extra.IntPair(1,10)
+p.first = 1
+
+p = li_std_pair_extra.paircA1(1,a)
+p.first
+p.second
+
+p = li_std_pair_extra.paircA2(1,a)
+pp = li_std_pair_extra.pairiiA(1,p)
+
diff --git a/Examples/test-suite/python/li_std_pair_runme.py b/Examples/test-suite/python/li_std_pair_runme.py
deleted file mode 100644
index b301f0d24..000000000
--- a/Examples/test-suite/python/li_std_pair_runme.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import li_std_pair
-
-p = (1,2)
-p1 = li_std_pair.p_inout(p)
-p2 = li_std_pair.p_inoutd(p1)
-
-d1 = li_std_pair.d_inout(2)
-
-i,d2 = li_std_pair.d_inout2(2)
-
-i,p = li_std_pair.p_inout2(p)
-p3,p4 = li_std_pair.p_inout3(p1,p1)
-
-psi = li_std_pair.SIPair("hello",1)
-pci = li_std_pair.CIPair(1,1)
-
-
-#psi.first = "hi"
-
-
-psi = li_std_pair.SIPair("hi",1)
-if psi != ("hi",1):
- raise RuntimeError
-
-psii = li_std_pair.SIIPair(psi,1)
-
-a = li_std_pair.A()
-b = li_std_pair.B()
-
-pab = li_std_pair.ABPair(a,b);
-
-pab.first = a
-pab.first.val = 2
-
-if pab.first.val != 2:
- raise RuntimeError
-
-
-pci = li_std_pair.CIntPair(1,0)
-
-a = li_std_pair.A(5)
-p1 = li_std_pair.pairP1(1,a.this)
-p2 = li_std_pair.pairP2(a,1)
-p3 = li_std_pair.pairP3(a,a)
-
-
-if a.val != li_std_pair.p_identa(p1.this)[1].val:
- raise RuntimeError
-
-p = li_std_pair.IntPair(1,10)
-p.first = 1
-
-p = li_std_pair.paircA1(1,a)
-p.first
-p.second
-
-p = li_std_pair.paircA2(1,a)
-pp = li_std_pair.pairiiA(1,p)
-
diff --git a/Examples/test-suite/python/li_std_set.i b/Examples/test-suite/python/li_std_set.i
deleted file mode 100644
index f0fddb058..000000000
--- a/Examples/test-suite/python/li_std_set.i
+++ /dev/null
@@ -1,17 +0,0 @@
-%module li_std_set
-
-%include <std_string.i>
-%include <std_set.i>
-%include <std_multiset.i>
-%include <std_vector.i>
-
-%template(set_string) std::set<std::string>;
-%template(set_int) std::multiset<int>;
-
-
-%template(v_int) std::vector<int>;
-
-
-
-
-%template(pyset) std::set<swig::PyObject_ptr>;
diff --git a/Examples/test-suite/python/li_std_stream.i b/Examples/test-suite/python/li_std_stream.i
deleted file mode 100644
index 0a999ddbf..000000000
--- a/Examples/test-suite/python/li_std_stream.i
+++ /dev/null
@@ -1,59 +0,0 @@
-%module li_std_stream
-
-%inline %{
- struct A;
-%}
-
-%include <std_iostream.i>
-%include <std_sstream.i>
-
-
-
-%callback(1) A::bar;
-
-%inline %{
-
- struct B {
- virtual ~B()
- {
- }
-
- };
-
- struct A : B
- {
- void __add__(int a)
- {
- }
-
- void __add__(double a)
- {
- }
-
- static int bar(int a){
- return a;
- }
-
- static int foo(int a, int (*pf)(int a))
- {
- return pf(a);
- }
-
-
- std::ostream& __rlshift__(std::ostream& out)
- {
- out << "A class";
- return out;
- }
- };
-%}
-
-%extend std::basic_ostream<char>{
- std::basic_ostream<char>&
- operator<<(const A& a)
- {
- *self << "A class";
- return *self;
- }
-}
-
diff --git a/Examples/test-suite/python/li_std_string.i b/Examples/test-suite/python/li_std_string.i
deleted file mode 100644
index 822d713c4..000000000
--- a/Examples/test-suite/python/li_std_string.i
+++ /dev/null
@@ -1,55 +0,0 @@
-%module li_std_string
-
-%naturalvar A;
-
-
-%include <std_basic_string.i>
-%include <std_string.i>
-
-
-%inline %{
-
-struct A : std::string
-{
- A(const std::string& s) : std::string(s)
- {
- }
-};
-
-struct B
-{
- B(const std::string& s) : cname(0), name(s), a(s)
- {
- }
-
- char *cname;
- std::string name;
- A a;
-
-};
-
-
-const char* test_ccvalue(const char* x) {
- return x;
-}
-
-char* test_cvalue(char* x) {
- return x;
-}
-
-std::basic_string<char> test_value_basic1(std::basic_string<char> x) {
- return x;
-}
-
-std::basic_string<char,std::char_traits<char> > test_value_basic2(std::basic_string<char,std::char_traits<char> > x) {
- return x;
-}
-
-std::basic_string<char,std::char_traits<char>,std::allocator<char> > test_value_basic3(std::basic_string<char,std::char_traits<char>,std::allocator<char> > x) {
- return x;
-}
-
-%}
-
-%include ../li_std_string.i
-
diff --git a/Examples/test-suite/python/li_std_string_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
index c0dae1e25..cef5921b0 100644
--- a/Examples/test-suite/python/li_std_string_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -1,24 +1,24 @@
-import li_std_string
+import li_std_string_extra
x="hello"
-if li_std_string.test_ccvalue(x) != x:
+if li_std_string_extra.test_ccvalue(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_cvalue(x) != x:
+if li_std_string_extra.test_cvalue(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value(x) != x:
- print x, li_std_string.test_value(x)
+if li_std_string_extra.test_value(x) != x:
+ print x, li_std_string_extra.test_value(x)
raise RuntimeError, "bad string mapping"
-if li_std_string.test_const_reference(x) != x:
+if li_std_string_extra.test_const_reference(x) != x:
raise RuntimeError, "bad string mapping"
-s = li_std_string.string("he")
+s = li_std_string_extra.string("he")
#s += "ll"
#s.append('o')
s = s + "llo"
@@ -30,21 +30,21 @@ if s != x:
if s[1:4] != x[1:4]:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value(s) != x:
+if li_std_string_extra.test_value(s) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_const_reference(s) != x:
+if li_std_string_extra.test_const_reference(s) != x:
raise RuntimeError, "bad string mapping"
-a = li_std_string.A(s)
+a = li_std_string_extra.A(s)
-if li_std_string.test_value(a) != x:
+if li_std_string_extra.test_value(a) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_const_reference(a) != x:
+if li_std_string_extra.test_const_reference(a) != x:
raise RuntimeError, "bad string mapping"
-b = li_std_string.string(" world")
+b = li_std_string_extra.string(" world")
s = a + b
if a + b != "hello world":
@@ -63,40 +63,40 @@ if c.find_last_of("l") != 9:
s = "hello world"
-b = li_std_string.B("hi")
+b = li_std_string_extra.B("hi")
-b.name = li_std_string.string("hello")
+b.name = li_std_string_extra.string("hello")
if b.name != "hello":
raise RuntimeError, "bad string mapping"
-b.a = li_std_string.A("hello")
+b.a = li_std_string_extra.A("hello")
if b.a != "hello":
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value_basic1(x) != x:
+if li_std_string_extra.test_value_basic1(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value_basic2(x) != x:
+if li_std_string_extra.test_value_basic2(x) != x:
raise RuntimeError, "bad string mapping"
-if li_std_string.test_value_basic3(x) != x:
+if li_std_string_extra.test_value_basic3(x) != x:
raise RuntimeError, "bad string mapping"
# Global variables
s = "initial string"
-if li_std_string.cvar.GlobalString2 != "global string 2":
+if li_std_string_extra.cvar.GlobalString2 != "global string 2":
raise RuntimeError, "GlobalString2 test 1"
-li_std_string.cvar.GlobalString2 = s
-if li_std_string.cvar.GlobalString2 != s:
+li_std_string_extra.cvar.GlobalString2 = s
+if li_std_string_extra.cvar.GlobalString2 != s:
raise RuntimeError, "GlobalString2 test 2"
-if li_std_string.cvar.ConstGlobalString != "const global string":
+if li_std_string_extra.cvar.ConstGlobalString != "const global string":
raise RuntimeError, "ConstGlobalString test"
# Member variables
-myStructure = li_std_string.Structure()
+myStructure = li_std_string_extra.Structure()
if myStructure.MemberString2 != "member string 2":
raise RuntimeError, "MemberString2 test 1"
myStructure.MemberString2 = s
@@ -105,28 +105,28 @@ if myStructure.MemberString2 != s:
if myStructure.ConstMemberString != "const member string":
raise RuntimeError, "ConstMemberString test"
-if li_std_string.cvar.Structure_StaticMemberString2 != "static member string 2":
+if li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2":
raise RuntimeError, "StaticMemberString2 test 1"
-li_std_string.cvar.Structure_StaticMemberString2 = s
-if li_std_string.cvar.Structure_StaticMemberString2 != s:
+li_std_string_extra.cvar.Structure_StaticMemberString2 = s
+if li_std_string_extra.cvar.Structure_StaticMemberString2 != s:
raise RuntimeError, "StaticMemberString2 test 2"
-if li_std_string.cvar.Structure_ConstStaticMemberString != "const static member string":
+if li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string":
raise RuntimeError, "ConstStaticMemberString test"
-if li_std_string.test_reference_input("hello") != "hello":
+if li_std_string_extra.test_reference_input("hello") != "hello":
raise RuntimeError
-s = li_std_string.test_reference_inout("hello")
+s = li_std_string_extra.test_reference_inout("hello")
if s != "hellohello":
raise RuntimeError
-if li_std_string.stdstring_empty() != "":
+if li_std_string_extra.stdstring_empty() != "":
raise RuntimeError
-if li_std_string.c_empty() != "":
+if li_std_string_extra.c_empty() != "":
raise RuntimeError
-if li_std_string.c_null() != None:
+if li_std_string_extra.c_null() != None:
raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_vector_runme.py b/Examples/test-suite/python/li_std_vector_extra_runme.py
index a0d96d4aa..776eacfb3 100644
--- a/Examples/test-suite/python/li_std_vector_runme.py
+++ b/Examples/test-suite/python/li_std_vector_extra_runme.py
@@ -1,4 +1,4 @@
-from li_std_vector import *
+from li_std_vector_extra import *
iv = IntVector(4)
for i in range(0,4):
@@ -133,3 +133,24 @@ if overloaded3(None) != "vector<int> *":
if overloaded3(100) != "int":
raise RuntimeError
+
+# vector pointer checks
+ip = makeIntPtr(11)
+dp = makeDoublePtr(33.3)
+error = 0
+try:
+ vi = IntPtrVector((ip, dp)) # check vector<int *> does not accept double * element
+ error = 1
+except:
+ pass
+
+if error:
+ raise RuntimeError
+
+vi = IntPtrVector((ip, makeIntPtr(22)))
+if extractInt(vi[0]) != 11:
+ raise RuntimeError
+
+if extractInt(vi[1]) != 22:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/li_std_vector_ptr_runme.py b/Examples/test-suite/python/li_std_vector_ptr_runme.py
new file mode 100644
index 000000000..c5f72fde4
--- /dev/null
+++ b/Examples/test-suite/python/li_std_vector_ptr_runme.py
@@ -0,0 +1,8 @@
+from li_std_vector_ptr import *
+
+ip1 = makeIntPtr(11)
+ip2 = makeIntPtr(22)
+
+vi = IntPtrVector((ip1, ip2))
+displayVector(vi)
+
diff --git a/Examples/test-suite/python/li_std_wstring.i b/Examples/test-suite/python/li_std_wstring.i
deleted file mode 100644
index c809e11ec..000000000
--- a/Examples/test-suite/python/li_std_wstring.i
+++ /dev/null
@@ -1,89 +0,0 @@
-%module li_std_wstring
-%include <std_basic_string.i>
-%include <std_wstring.i>
-
-
-%inline %{
-
-struct A : std::wstring
-{
- A(const std::wstring& s) : std::wstring(s)
- {
- }
-};
-
-struct B
-{
- B(const std::wstring& s) : cname(0), name(s), a(s)
- {
- }
-
- char *cname;
- std::wstring name;
- A a;
-
-};
-
-
-wchar_t test_wcvalue(wchar_t x) {
- return x;
-}
-
-const wchar_t* test_ccvalue(const wchar_t* x) {
- return x;
-}
-
-wchar_t* test_cvalue(wchar_t* x) {
- return x;
-}
-
-
-std::wstring test_value(std::wstring x) {
- return x;
-}
-
-const std::wstring& test_const_reference(const std::wstring &x) {
- return x;
-}
-
-void test_pointer(std::wstring *x) {
-}
-
-std::wstring *test_pointer_out() {
- static std::wstring x = L"x";
- return &x;
-}
-
-void test_const_pointer(const std::wstring *x) {
-}
-
-const std::wstring *test_const_pointer_out() {
- static std::wstring x = L"x";
- return &x;
-}
-
-void test_reference(std::wstring &x) {
-}
-
-std::wstring& test_reference_out() {
- static std::wstring x = L"x";
- return x;
-}
-
-#if defined(_MSC_VER)
- #pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-void test_throw() throw(std::wstring){
- static std::wstring x = L"x";
-
- throw x;
-}
-
-#if defined(_MSC_VER)
- #pragma warning(default: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
-#endif
-
-%}
-
-
diff --git a/Examples/test-suite/python/operbool_runme.py b/Examples/test-suite/python/operbool_runme.py
new file mode 100644
index 000000000..4218b5dd4
--- /dev/null
+++ b/Examples/test-suite/python/operbool_runme.py
@@ -0,0 +1,4 @@
+#!/usr/bin/env python
+import operbool
+assert not operbool.Test()
+
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
new file mode 100644
index 000000000..e34777558
--- /dev/null
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -0,0 +1,8 @@
+from python_abstractbase import *
+from collections import *
+assert issubclass(Mapii, MutableMapping)
+assert issubclass(Multimapii, MutableMapping)
+assert issubclass(IntSet, MutableSet)
+assert issubclass(IntMultiset, MutableSet)
+assert issubclass(IntVector, MutableSequence)
+assert issubclass(IntList, MutableSequence)
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
new file mode 100644
index 000000000..c8e6b2640
--- /dev/null
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -0,0 +1,4 @@
+from python_append import *
+t=Test()
+t.func()
+t.static_func()
diff --git a/Examples/test-suite/python/kwargs_runme.py b/Examples/test-suite/python/python_kwargs_runme.py
index 91812929d..fb6e191dd 100644
--- a/Examples/test-suite/python/kwargs_runme.py
+++ b/Examples/test-suite/python/python_kwargs_runme.py
@@ -1,4 +1,4 @@
-from kwargs import *
+from python_kwargs import *
class MyFoo(Foo):
def __init__(self, a , b = 0):
diff --git a/Examples/test-suite/python/nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py
index 18230616d..27755db9c 100644
--- a/Examples/test-suite/python/nondynamic_runme.py
+++ b/Examples/test-suite/python/python_nondynamic_runme.py
@@ -1,6 +1,6 @@
-import nondynamic
+import python_nondynamic
-aa = nondynamic.A()
+aa = python_nondynamic.A()
aa.a = 1
aa.b = 2
@@ -14,10 +14,10 @@ if not err:
raise RuntimeError, "A is not static"
-class B(nondynamic.A):
+class B(python_nondynamic.A):
c = 4
def __init__(self):
- nondynamic.A.__init__(self)
+ python_nondynamic.A.__init__(self)
pass
pass
@@ -35,5 +35,5 @@ if not err:
raise RuntimeError, "B is not static"
-cc = nondynamic.C()
+cc = python_nondynamic.C()
cc.d = 3
diff --git a/Examples/test-suite/python/overload_simple_cast_runme.py b/Examples/test-suite/python/python_overload_simple_cast_runme.py
index 87e6e5d43..1b3a5482c 100644
--- a/Examples/test-suite/python/overload_simple_cast_runme.py
+++ b/Examples/test-suite/python/python_overload_simple_cast_runme.py
@@ -1,4 +1,4 @@
-from overload_simple_cast import *
+from python_overload_simple_cast import *
class Ai:
def __init__(self,x):
diff --git a/Examples/test-suite/python/python_pybuf_runme3.py b/Examples/test-suite/python/python_pybuf_runme3.py
new file mode 100644
index 000000000..152aecdc0
--- /dev/null
+++ b/Examples/test-suite/python/python_pybuf_runme3.py
@@ -0,0 +1,42 @@
+#run:
+# python python_pybuf_runme3.py benchmark
+#for the benchmark, other wise the test case will be run
+import python_pybuf
+import sys
+if len(sys.argv)>=2 and sys.argv[1]=="benchmark":
+ #run the benchmark
+ import time
+ k=1000000 #number of times to excute the functions
+
+ t=time.time()
+ a = bytearray(b'hello world')
+ for i in range(k):
+ pybuf.title1(a)
+ print("Time used by bytearray:",time.time()-t)
+
+ t=time.time()
+ b = 'hello world'
+ for i in range(k):
+ pybuf.title2(b)
+ print("Time used by string:",time.time()-t)
+else:
+ #run the test case
+ buf1 = bytearray(10)
+ buf2 = bytearray(50)
+
+ pybuf.func1(buf1)
+ assert buf1 == b'a'*10
+
+ pybuf.func2(buf2)
+ assert buf2.startswith(b"Hello world!\x00")
+
+ count = pybuf.func3(buf2)
+ assert count==10 #number of alpha and number in 'Hello world!'
+
+ length = pybuf.func4(buf2)
+ assert length==12
+
+ buf3 = bytearray(b"hello")
+ pybuf.title1(buf3)
+ assert buf3==b'Hello'
+
diff --git a/Examples/test-suite/python/rename_strip_encoder_runme.py b/Examples/test-suite/python/rename_strip_encoder_runme.py
new file mode 100644
index 000000000..64be611d6
--- /dev/null
+++ b/Examples/test-suite/python/rename_strip_encoder_runme.py
@@ -0,0 +1,6 @@
+from rename_strip_encoder import *
+
+s = SomeWidget()
+a = AnotherWidget()
+a.DoSomething()
+
diff --git a/Examples/test-suite/python/std_containers.i b/Examples/test-suite/python/std_containers.i
deleted file mode 100644
index a1d39e7ab..000000000
--- a/Examples/test-suite/python/std_containers.i
+++ /dev/null
@@ -1,199 +0,0 @@
-%module std_containers
-
-%{
-#include <set>
-%}
-%include std_vector.i
-%include std_string.i
-%include std_deque.i
-%include std_list.i
-%include std_set.i
-%include std_multiset.i
-%include std_pair.i
-%include std_map.i
-%include std_multimap.i
-%include std_complex.i
-
-%template() std::vector<double>;
-%template() std::pair<std::string, int>;
-%template() std::pair<int,double>;
-
-%template() std::vector< std::vector<double > > ;
-%template(ccube) std::vector< std::vector< std::vector<double > > >;
-
-%inline
-{
- typedef
- std::vector<std::vector<std::vector<double > > >
- ccube;
-
- ccube cident(const ccube& c)
- {
- return c;
- }
-
- struct C
- {
- };
-}
-
-
-%template(map_si) std::map<std::string, int>;
-%template(pair_iC) std::pair<int, C*>;
-%template(map_iC) std::map<int, C*>;
-%template(mmap_si) std::multimap<std::string, int>;
-%template(set_i) std::set<int>;
-%template(multiset_i) std::multiset<int>;
-%template(list_i) std::list<int>;
-%template(deque_i) std::deque<int>;
-
-%template(vector_b) std::vector<bool>;
-%template(vector_i) std::vector<int>;
-%template(vector_c) std::vector<std::complex<double> >;
-%template(vector_ui) std::vector<unsigned int>;
-
-%template(bmatrix) std::vector<std::vector<bool> >;
-%template(imatrix) std::vector<std::vector<int> >;
-%template(cmatrix) std::vector<std::vector<std::complex<double> > >;
-
-%apply std::vector<int> *INOUT {std::vector<int> *INOUT2};
-
-%inline
-{
- typedef std::vector<std::vector<int> > imatrix;
- imatrix midenti(const imatrix& v)
- {
- return v;
- }
-
- typedef std::vector<std::vector<bool> > bmatrix;
- bmatrix midentb(const bmatrix& v)
- {
- return v;
- }
-
- std::map<int,C*> mapidentc(const std::map<int,C*>& v)
- {
- return v;
- }
-
- std::map<int,int> mapidenti(const std::map<int,int>& v)
- {
- return v;
- }
-
- std::map<std::string,int> mapident(const std::map<std::string,int>& v)
- {
- return v;
- }
-
- std::multimap<std::string,int> mapident(const std::multimap<std::string,int>& v)
- {
- return v;
- }
-
- std::vector<int> vident(const std::vector<int>& v)
- {
- return v;
- }
-
- std::set<int> sident(const std::set<int>& v)
- {
- return v;
- }
-
- std::vector<unsigned int> videntu(const std::vector<unsigned int>& v)
- {
- return v;
- }
-
-
- int get_elem(const std::vector<int>& v, int index)
- {
- return v[index];
- }
-
- std::pair<int,double> pident(const std::pair<int,double>& p)
- {
- return p;
- }
-
- void
- v_inout(std::vector<int> *INOUT) {
- *INOUT = *INOUT;
- }
-
- void
- v_inout2(std::vector<int> *INOUT, std::vector<int> *INOUT2) {
- std::swap(*INOUT, *INOUT2);
- }
-
-}
-
-
-%{
-
- template <class C> struct Param
- {
- };
-%}
-
-
-template <class C> struct Param
-{
-};
-
-
-%template(Param_c) Param<std::complex<double> >;
-%inline
-{
- int hello(Param<std::complex<double> > c)
- {
- return 0;
- }
-}
-
-%inline
-{
- struct A
- {
- A(int aa = 0) : a(aa)
- {
- }
- int a;
- };
-}
-
-%template() std::pair<A,int>;
-%template(pair_iA) std::pair<int,A>;
-%template(vector_piA) std::vector<std::pair<int,A> >;
-
-
-%inline {
- std::pair<A,int> ident(std::pair<int,A> a, const std::pair<int,int>& b)
- {
- return std::pair<A,int>();
- }
-
-
- std::vector<std::pair<int,A> > pia_vident(std::vector<std::pair<int,A> > a )
- {
- return a;
- }
-
- struct Foo
- {
- Foo(int i) {
- }
- };
-
-}
-
-
-%std_nodefconst_type(Foo);
-
-%template(vector_Foo) std::vector<Foo>;
-%template(deque_Foo) std::deque<Foo>;
-%template(list_Foo) std::list<Foo>;
-
-
diff --git a/Examples/test-suite/python/swigobject_runme.py b/Examples/test-suite/python/swigobject_runme.py
index 7f629e1d5..a906108e3 100644
--- a/Examples/test-suite/python/swigobject_runme.py
+++ b/Examples/test-suite/python/swigobject_runme.py
@@ -12,11 +12,17 @@ if a1.this != a2.this:
lthis = long(a.this)
-xstr1 = "0x%x" % (lthis,)
+# match pointer value, but deal with leading zeros on 8/16 bit systems and different C++ compilers interpretation of %p
+xstr1 = "%016X" % (lthis,)
+xstr1 = str.lstrip(xstr1, '0')
xstr2 = pointer_str(a)
+xstr2 = str.replace(xstr2, "0x", "")
+xstr2 = str.replace(xstr2, "0X", "")
+xstr2 = str.lstrip(xstr2, '0')
+xstr2 = str.upper(xstr2)
if xstr1 != xstr2:
- print xstr1, xstr2
+ print xstr1, xstr2
raise RuntimeError
s = str(a.this)
diff --git a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i b/Examples/test-suite/python/tag_no_clash_with_variable_runme.i
deleted file mode 100644
index 0f8fdafed..000000000
--- a/Examples/test-suite/python/tag_no_clash_with_variable_runme.i
+++ /dev/null
@@ -1,3 +0,0 @@
-import enum_tag_no_clash_with_variable
-
-error_action = error_action
diff --git a/Examples/test-suite/python/template_typedef_cplx2_runme.py b/Examples/test-suite/python/template_typedef_cplx2_runme.py
index 030fe02d8..04c599329 100644
--- a/Examples/test-suite/python/template_typedef_cplx2_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx2_runme.py
@@ -1,4 +1,3 @@
-import string
from template_typedef_cplx2 import *
#
@@ -13,7 +12,7 @@ except:
raise RuntimeError
s = '%s' % d
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print d, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -25,7 +24,7 @@ except:
raise RuntimeError
s = '%s' % e
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print e, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -42,7 +41,7 @@ except:
raise RuntimeError
s = '%s' % c
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print c, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -54,7 +53,7 @@ except:
raise RuntimeError
s = '%s' % f
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print f, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -70,7 +69,7 @@ except:
raise RuntimeError
s = '%s' % g
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print g, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -83,7 +82,7 @@ except:
raise RuntimeError
s = '%s' % h
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print h, "is not an ArithUnaryFunction"
raise RuntimeError
diff --git a/Examples/test-suite/python/template_typedef_cplx_runme.py b/Examples/test-suite/python/template_typedef_cplx_runme.py
index 99ffcb9aa..2cd9c8348 100644
--- a/Examples/test-suite/python/template_typedef_cplx_runme.py
+++ b/Examples/test-suite/python/template_typedef_cplx_runme.py
@@ -1,4 +1,3 @@
-import string
from template_typedef_cplx import *
#
@@ -13,7 +12,7 @@ except:
raise RuntimeError
s = '%s' % d
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print d, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -25,7 +24,7 @@ except:
raise RuntimeError
s = '%s' % e
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print e, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -42,7 +41,7 @@ except:
raise RuntimeError
s = '%s' % c
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print c, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -54,7 +53,7 @@ except:
raise RuntimeError
s = '%s' % f
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print f, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -70,7 +69,7 @@ except:
raise RuntimeError
s = '%s' % g
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print g, "is not an ArithUnaryFunction"
raise RuntimeError
@@ -83,6 +82,6 @@ except:
raise RuntimeError
s = '%s' % h
-if string.find(s, 'ArithUnaryFunction') == -1:
+if str.find(s, 'ArithUnaryFunction') == -1:
print h, "is not an ArithUnaryFunction"
raise RuntimeError
diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py
new file mode 100644
index 000000000..b148f2d06
--- /dev/null
+++ b/Examples/test-suite/python/typemap_out_optimal_runme.py
@@ -0,0 +1,5 @@
+from typemap_out_optimal import *
+
+cvar.XX_debug = False
+x = XX.create()
+
diff --git a/Examples/test-suite/python/vector.i b/Examples/test-suite/python/vector.i
deleted file mode 100644
index 04c961cda..000000000
--- a/Examples/test-suite/python/vector.i
+++ /dev/null
@@ -1,51 +0,0 @@
-%module vector
-%{
-#include <vector>
-%}
-
-%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
- public:
- typedef size_t size_type;
- typedef CTYPE value_type;
- size_type size() const;
- vector();
- %extend {
- static std::vector<CTYPE > *Repeat(const value_type& value, int count) /*throw (std::out_of_range)*/ {
-// if (count < 0)
-// throw std::out_of_range("count");
- return new std::vector<CTYPE >(count, value);
- }
- }
-%enddef
-
-namespace std {
- // primary (unspecialized) class template for std::vector
- // does not require operator== to be defined
- template<class T> class vector {
- SWIG_STD_VECTOR_MINIMUM(T, T)
- };
-}
-
-%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
-namespace std {
- template<> class vector<CTYPE > {
- SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
- };
-}
-%enddef
-
-SWIG_STD_VECTOR_SPECIALIZE(float, float)
-
-%inline %{
-typedef float Real;
-%}
-
-#if 1
-//fails
-namespace std {
- %template(RealVector) vector<Real>;
-}
-#else
-//works
-%template(RealVector) std::vector<Real>;
-#endif
diff --git a/Examples/test-suite/python_abstractbase.i b/Examples/test-suite/python_abstractbase.i
new file mode 100644
index 000000000..f72688237
--- /dev/null
+++ b/Examples/test-suite/python_abstractbase.i
@@ -0,0 +1,18 @@
+%module python_abstractbase
+%include <pyabc.i>
+%include <std_map.i>
+%include <std_multimap.i>
+%include <std_set.i>
+%include <std_multiset.i>
+%include <std_list.i>
+%include <std_vector.i>
+
+namespace std
+{
+ %template(Mapii) map<int, int>;
+ %template(Multimapii) multimap<int, int>;
+ %template(IntSet) set<int>;
+ %template(IntMultiset) multiset<int>;
+ %template(IntVector) vector<int>;
+ %template(IntList) list<int>;
+}
diff --git a/Examples/test-suite/python_append.i b/Examples/test-suite/python_append.i
new file mode 100644
index 000000000..2dc9cb970
--- /dev/null
+++ b/Examples/test-suite/python_append.i
@@ -0,0 +1,32 @@
+/*
+Testcase to test %pythonprepend and %pythonappend
+*/
+
+%module python_append
+
+%pythonappend Test::func %{
+ pass
+%}
+
+%pythonprepend Test::func %{
+ pass
+%}
+
+%pythonappend Test::static_func %{
+pass
+%}
+
+%pythonprepend Test::static_func {
+ pass
+}
+
+%inline %{
+
+class Test {
+public:
+ static void static_func() {};
+ void func() {};
+};
+
+%}
+
diff --git a/Examples/test-suite/python/autodoc.i b/Examples/test-suite/python_autodoc.i
index c22cc02f0..c363e4384 100644
--- a/Examples/test-suite/python/autodoc.i
+++ b/Examples/test-suite/python_autodoc.i
@@ -1,4 +1,4 @@
-%module(docstring="hello") autodoc
+%module(docstring="hello") python_autodoc
%feature("autodoc");
diff --git a/Examples/test-suite/python/kwargs.i b/Examples/test-suite/python_kwargs.i
index 83713d8c2..28089bbf1 100644
--- a/Examples/test-suite/python/kwargs.i
+++ b/Examples/test-suite/python_kwargs.i
@@ -1,4 +1,4 @@
-%module kwargs
+%module python_kwargs
%nocopyctor;
%kwargs;
diff --git a/Examples/test-suite/python/nondynamic.i b/Examples/test-suite/python_nondynamic.i
index 2acc9bf8b..26c69644d 100644
--- a/Examples/test-suite/python/nondynamic.i
+++ b/Examples/test-suite/python_nondynamic.i
@@ -1,4 +1,4 @@
-%module nondynamic
+%module python_nondynamic
/*
Use the %pythonnondynamic directuve to make the wrapped class a
diff --git a/Examples/test-suite/python/overload_simple_cast.i b/Examples/test-suite/python_overload_simple_cast.i
index d274722c0..e7f58d788 100644
--- a/Examples/test-suite/python/overload_simple_cast.i
+++ b/Examples/test-suite/python_overload_simple_cast.i
@@ -1,4 +1,4 @@
// Simple tests of overloaded functions
-%module("castmode") overload_simple_cast
+%module("castmode") python_overload_simple_cast
%include overload_simple.i
diff --git a/Examples/test-suite/python_pybuf.i b/Examples/test-suite/python_pybuf.i
new file mode 100644
index 000000000..8e1302582
--- /dev/null
+++ b/Examples/test-suite/python_pybuf.i
@@ -0,0 +1,64 @@
+%module python_pybuf
+%include<pybuffer.i>
+%include<cstring.i>
+/*functions for the test case*/
+%pybuffer_mutable_binary(char *buf1, int len);
+%pybuffer_mutable_string(char *buf2);
+%pybuffer_binary(const char *buf3, int len);
+%pybuffer_string(const char *buf4);
+
+%inline %{
+ void func1(char *buf1, int len)
+ {
+ int i;
+ for (i=0; i<len; ++i)
+ buf1[i] = 'a';
+ return;
+ }
+ void func2(char *buf2)
+ {
+ strcpy(buf2, "Hello world!");
+ }
+ int func3(const char *buf3, int len)
+ {
+ int count = 0;
+ int i;
+ for(i=0; i<len; ++i)
+ if (isalnum(buf3[i]))
+ ++count;
+ return count;
+ }
+ int func4(const char *buf4)
+ {
+ return strlen(buf4);
+ }
+%}
+
+/*functions for the benchmark*/
+%pybuffer_mutable_string(char *str1);
+%cstring_mutable(char *str2);
+
+%inline %{
+void title(char *str) {
+ int outword = 1;
+ while(*str) {
+ if (isalnum(*str)) {
+ if (outword) {
+ outword = 0;
+ *str = toupper(*str);
+ }
+ }
+ else {
+ outword = 0;
+ }
+ str++;
+ }
+}
+
+void title1(char *str1) {
+ title(str1);
+}
+void title2(char *str2) {
+ title(str2);
+}
+%}
diff --git a/Examples/test-suite/r/Makefile.in b/Examples/test-suite/r/Makefile.in
index 70dd62ec5..98d1f9571 100644
--- a/Examples/test-suite/r/Makefile.in
+++ b/Examples/test-suite/r/Makefile.in
@@ -10,8 +10,8 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
-C_TEST_CASES = copy_struct simple_array legacy
-CPP_TEST_CASES = double_delete
+C_TEST_CASES = r_copy_struct r_legacy
+CPP_TEST_CASES = r_double_delete
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/r/arrays_dimensionless_runme.R b/Examples/test-suite/r/arrays_dimensionless_runme.R
new file mode 100644
index 000000000..9b97de2d8
--- /dev/null
+++ b/Examples/test-suite/r/arrays_dimensionless_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("arrays_dimensionless", .Platform$dynlib.ext, sep=""))
+source("arrays_dimensionless.R")
+cacheMetaData(1)
+
+unittest(arr_short(1:4, 3), 6)
+unittest(arr_ushort(1:4, 3), 6)
+unittest(arr_int(1:4, 3), 6)
+unittest(arr_uint(1:4, 3), 6)
+unittest(arr_long(1:4, 3), 6)
+unittest(arr_ulong(1:4, 3), 6)
+unittest(arr_ll(1:4, 3), 6)
+unittest(arr_ull(1:4, 3), 6)
+unittest(arr_float(as.numeric(1:4), 3), 6)
+unittest(arr_double(as.numeric(1:4), 3), 6)
+
+q(save="no")
+
+
+
diff --git a/Examples/test-suite/r/double_delete_runme.R b/Examples/test-suite/r/double_delete_runme.R
deleted file mode 100644
index 8ac6b4344..000000000
--- a/Examples/test-suite/r/double_delete_runme.R
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file illustrates the proxy class C++ interface generated
-# by SWIG.
-
-dyn.load(paste("double_delete", .Platform$dynlib.ext, sep=""))
-source("double_delete.R")
-cacheMetaData(1)
-
-# ----- Object creation -----
-
-f <- Foo(2.0)
-delete(f);
-delete(f);
diff --git a/Examples/test-suite/r/integers_runme.R b/Examples/test-suite/r/integers_runme.R
new file mode 100644
index 000000000..e31099a3b
--- /dev/null
+++ b/Examples/test-suite/r/integers_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("integers", .Platform$dynlib.ext, sep=""))
+source("integers.R")
+cacheMetaData(1)
+
+unittest(signed_char_identity(1), 1)
+unittest(unsigned_char_identity(1), 1)
+unittest(signed_short_identity(1), 1)
+unittest(unsigned_short_identity(1), 1)
+unittest(signed_int_identity(1), 1)
+unittest(unsigned_int_identity(1), 1)
+unittest(signed_long_identity(1), 1)
+unittest(unsigned_long_identity(1), 1)
+unittest(signed_long_long_identity(1), 1)
+unittest(unsigned_long_long_identity(1), 1)
+
+q(save="no")
+
+
+
diff --git a/Examples/test-suite/r/copy_struct_runme.R b/Examples/test-suite/r/r_copy_struct_runme.R
index 523f1d680..21bd93b64 100644
--- a/Examples/test-suite/r/copy_struct_runme.R
+++ b/Examples/test-suite/r/r_copy_struct_runme.R
@@ -1,6 +1,6 @@
source("unittest.R")
-dyn.load(paste("copy_struct", .Platform$dynlib.ext, sep=""))
-source("copy_struct.R")
+dyn.load(paste("r_copy_struct", .Platform$dynlib.ext, sep=""))
+source("r_copy_struct.R")
cacheMetaData(1)
a <- getA()
@@ -41,7 +41,7 @@ unittest(d$u, 0)
la <- new("A");
-la@ui <- 5
+la@ui <- as.integer(5)
# Removing the next line makes this fail in R 2.4
la@str <- ""
@@ -49,9 +49,10 @@ other = A()
foo <- copyToC(la, other)
aa = A()
-aa$i = 201
+aa$i = as.integer(201)
aa$d = pi
aa$str = "foo"
+aa$ui = as.integer(0)
copyToR(aa)
diff --git a/Examples/test-suite/r/r_double_delete_runme.R b/Examples/test-suite/r/r_double_delete_runme.R
new file mode 100644
index 000000000..7b6fdb77f
--- /dev/null
+++ b/Examples/test-suite/r/r_double_delete_runme.R
@@ -0,0 +1,9 @@
+dyn.load(paste("r_double_delete", .Platform$dynlib.ext, sep=""))
+source("r_double_delete.R")
+cacheMetaData(1)
+
+# ----- Object creation -----
+
+f <- Foo(2.0)
+delete(f);
+delete(f);
diff --git a/Examples/test-suite/r/legacy_runme.R b/Examples/test-suite/r/r_legacy_runme.R
index a1466e4ce..7e5ade87f 100644
--- a/Examples/test-suite/r/legacy_runme.R
+++ b/Examples/test-suite/r/r_legacy_runme.R
@@ -1,6 +1,6 @@
source("unittest.R")
-dyn.load(paste("legacy", .Platform$dynlib.ext, sep=""))
-source("legacy.R")
+dyn.load(paste("r_legacy", .Platform$dynlib.ext, sep=""))
+source("r_legacy.R")
cacheMetaData(1)
obj <- getObject(1,3)
diff --git a/Examples/test-suite/r/copy_struct.i b/Examples/test-suite/r_copy_struct.i
index db6223303..fda321afb 100644
--- a/Examples/test-suite/r/copy_struct.i
+++ b/Examples/test-suite/r_copy_struct.i
@@ -1,4 +1,4 @@
-%module copy_struct
+%module r_copy_struct
%feature("opaque", "yes") B;
%feature("opaque", "yes") C;
diff --git a/Examples/test-suite/r/double_delete.i b/Examples/test-suite/r_double_delete.i
index 4f2d1e0a2..9743d0454 100644
--- a/Examples/test-suite/r/double_delete.i
+++ b/Examples/test-suite/r_double_delete.i
@@ -1,5 +1,4 @@
-/* File : example.i */
-%module double_delete
+%module r_double_delete
%inline %{
diff --git a/Examples/test-suite/r/legacy.i b/Examples/test-suite/r_legacy.i
index 4e2080262..c89263082 100644
--- a/Examples/test-suite/r/legacy.i
+++ b/Examples/test-suite/r_legacy.i
@@ -1,4 +1,4 @@
-%module legacy
+%module r_legacy
%inline %{
typedef char *String;
diff --git a/Examples/test-suite/rename_strip_encoder.i b/Examples/test-suite/rename_strip_encoder.i
new file mode 100644
index 000000000..691173b02
--- /dev/null
+++ b/Examples/test-suite/rename_strip_encoder.i
@@ -0,0 +1,16 @@
+%module rename_strip_encoder
+
+// strip the wx prefix from all identifiers
+%rename("%(strip:[wx])s") "";
+
+%inline %{
+
+class wxSomeWidget {
+};
+
+struct wxAnotherWidget {
+ void wxDoSomething() {}
+};
+
+
+%}
diff --git a/Examples/test-suite/ruby/Makefile.in b/Examples/test-suite/ruby/Makefile.in
index 7339373fb..d50b478be 100644
--- a/Examples/test-suite/ruby/Makefile.in
+++ b/Examples/test-suite/ruby/Makefile.in
@@ -10,21 +10,24 @@ top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES = \
- keywords \
li_cdata \
li_cstring \
li_factory \
li_std_functors \
li_std_map \
+ li_std_multimap \
li_std_pair_lang_object \
li_std_queue \
li_std_set \
li_std_stack \
- naming \
primitive_types \
- std_containers \
- track_objects \
- track_objects_directors
+ ruby_keywords \
+ ruby_naming \
+ ruby_track_objects \
+ ruby_track_objects_directors \
+ std_containers
+# ruby_li_std_speed
+# stl_new
C_TEST_CASES += \
li_cdata \
@@ -39,7 +42,7 @@ SWIGOPT += -w801 -noautorename -features autodoc=4
# Rules for the different types of tests
# make sure -autorename is true for the naming test
-naming.cpptest: SWIGOPT = -autorename
+ruby_naming.cpptest: SWIGOPT += -autorename
%.cpptest:
$(setup)
diff --git a/Examples/test-suite/ruby/li_std_map_runme.rb b/Examples/test-suite/ruby/li_std_map_runme.rb
index 319fdec52..0ec8cac84 100755
--- a/Examples/test-suite/ruby/li_std_map_runme.rb
+++ b/Examples/test-suite/ruby/li_std_map_runme.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
#
-# Tests for std::map and std::multimap
+# Tests for std::map
#
#
#
@@ -41,18 +41,9 @@ m["foo"] = "hello"
pm = Li_std_map::LanguageMap.new
m.each_key { |k| pm[k] = m[k] }
m.each_key { |k| swig_assert_equal("pm[#{k.inspect}]", "m[#{k.inspect}]", binding) }
-
-m = Li_std_map::MmapA.new
-m[0] = a1
-m[0] = a2
-m[0].size == 2
-m.respond_to?(:each) == true
-m.respond_to?(:each_key) == true
-m.respond_to?(:each_value) == true
-m.values_at(0)[0] == m[0]
EOF
-mii = Li_std_map::Mapii.new
+mii = Li_std_map::IntIntMap.new
mii[1] = 1
mii[1] = 2
diff --git a/Examples/test-suite/ruby/li_std_multimap_runme.rb b/Examples/test-suite/ruby/li_std_multimap_runme.rb
new file mode 100755
index 000000000..b0c2bb359
--- /dev/null
+++ b/Examples/test-suite/ruby/li_std_multimap_runme.rb
@@ -0,0 +1,27 @@
+#!/usr/bin/env ruby
+#
+# Tests for std::multimap
+#
+#
+#
+#
+#
+
+require 'swig_assert'
+require 'li_std_multimap'
+
+swig_assert_each_line(<<'EOF', binding)
+
+a1 = Li_std_multimap::A.new(3)
+a2 = Li_std_multimap::A.new(7)
+
+m = Li_std_multimap::MultimapA.new
+m[0] = a1
+m[0] = a2
+m[0].size == 2
+m.respond_to?(:each) == true
+m.respond_to?(:each_key) == true
+m.respond_to?(:each_value) == true
+m.values_at(0)[0] == m[0]
+EOF
+
diff --git a/Examples/test-suite/ruby/keywords_runme.rb b/Examples/test-suite/ruby/ruby_keywords_runme.rb
index cb8bd38bf..9b06ecf1d 100644
--- a/Examples/test-suite/ruby/keywords_runme.rb
+++ b/Examples/test-suite/ruby/ruby_keywords_runme.rb
@@ -9,9 +9,9 @@
require 'swig_assert'
-require 'keywords'
+require 'ruby_keywords'
-kw = Keywords::Keywords.new
+kw = Ruby_keywords::Keywords.new
if kw.alias != 'alias' then
raise RuntimeError, 'Keyword method did not work: alias'
diff --git a/Examples/test-suite/ruby/li_std_speed_runme.rb b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb
index a67e618a3..825f3c593 100755
--- a/Examples/test-suite/ruby/li_std_speed_runme.rb
+++ b/Examples/test-suite/ruby/ruby_li_std_speed_runme.rb
@@ -10,8 +10,8 @@
require 'benchmark'
require 'mathn'
-require 'li_std_speed'
-include Li_std_speed
+require 'ruby_li_std_speed'
+include Ruby_li_std_speed
def benchmark(f, phigh, sequences)
diff --git a/Examples/test-suite/ruby/naming_runme.rb b/Examples/test-suite/ruby/ruby_naming_runme.rb
index dab3a50b6..8ea5f13d3 100644
--- a/Examples/test-suite/ruby/naming_runme.rb
+++ b/Examples/test-suite/ruby/ruby_naming_runme.rb
@@ -9,86 +9,86 @@
require 'swig_assert'
-require 'naming'
+require 'ruby_naming'
# Check class names
-if not Naming
- raise RuntimeError, 'Invalid module name for Naming'
+if not Ruby_naming
+ raise RuntimeError, 'Invalid module name for Ruby_naming'
end
-if not Naming::MyClass
+if not Ruby_naming::MyClass
raise RuntimeError, 'Invalid class name for MyClass'
end
# Check constant names / values
-if Naming::CONSTANT1 != 1
+if Ruby_naming::CONSTANT1 != 1
raise RuntimeError, "Incorrect value for CONSTANT1"
end
-if Naming::CONSTANT2 != 2
+if Ruby_naming::CONSTANT2 != 2
raise RuntimeError, "Incorrect value for CONSTANT2"
end
# Check constant names / values
-if Naming::CONSTANT3 != 3
+if Ruby_naming::CONSTANT3 != 3
raise RuntimeError, "Incorrect value for CONSTANT3"
end
-if not Naming::methods.include?("constant4")
+if not Ruby_naming::methods.include?("constant4")
raise RuntimeError, "Incorrect mapping for constant4"
end
-if not Naming::methods.include?("constant5")
+if not Ruby_naming::methods.include?("constant5")
raise RuntimeError, "Incorrect mapping for constant5"
end
-if not Naming::methods.include?("constant6")
+if not Ruby_naming::methods.include?("constant6")
raise RuntimeError, "Incorrect mapping for constant6"
end
-if not Naming::TestConstants.instance_methods.include?("constant7")
+if not Ruby_naming::TestConstants.instance_methods.include?("constant7")
raise RuntimeError, "Incorrect mapping for constant7"
end
-if not Naming::TestConstants.methods.include?("constant8")
+if not Ruby_naming::TestConstants.methods.include?("constant8")
raise RuntimeError, "Incorrect mapping for constant8"
end
# There is no constant9 because it is illegal C++
-#if not Naming::TestConstants.instance_methods.include?("constant9")
+#if not Ruby_naming::TestConstants.instance_methods.include?("constant9")
# raise RuntimeError, "Incorrect mapping for constant9"
#end
-if Naming::TestConstants::CONSTANT10 != 10
+if Ruby_naming::TestConstants::CONSTANT10 != 10
raise RuntimeError, "Incorrect value for CONSTANT10"
end
-if not Naming::methods.include?("constant11")
+if not Ruby_naming::methods.include?("constant11")
raise RuntimeError, "Incorrect mapping for constant11"
end
# Check enums
-if Naming::constants.include?("Color")
+if Ruby_naming::constants.include?("Color")
raise RuntimeError, "Color enum should not be exposed to Ruby"
end
-if Naming::Red != 0
+if Ruby_naming::Red != 0
raise RuntimeError, "Incorrect value for enum RED"
end
-if Naming::Green != 1
+if Ruby_naming::Green != 1
raise RuntimeError, "Incorrect value for enum GREEN"
end
-if Naming::Blue != 2
+if Ruby_naming::Blue != 2
raise RuntimeError, "Incorrect value for enum BLUE"
end
# Check method names
-my_class = Naming::MyClass.new()
+my_class = Ruby_naming::MyClass.new()
if my_class.method_one != 1
raise RuntimeError, "Incorrect value for method_one"
diff --git a/Examples/test-suite/ruby/track_objects_directors_runme.rb b/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb
index 247d3e98b..fb55323a8 100644
--- a/Examples/test-suite/ruby/track_objects_directors_runme.rb
+++ b/Examples/test-suite/ruby/ruby_track_objects_directors_runme.rb
@@ -9,9 +9,9 @@
require 'swig_assert'
-require 'track_objects_directors'
+require 'ruby_track_objects_directors'
-class MyFoo < Track_objects_directors::Foo
+class MyFoo < Ruby_track_objects_directors::Foo
def ping
"MyFoo::ping()"
end
@@ -22,12 +22,12 @@ a = MyFoo.new
raise RuntimeError if a.ping != "MyFoo::ping()"
raise RuntimeError if a.pong != "Foo::pong();MyFoo::ping()"
-b = Track_objects_directors::Foo.new
+b = Ruby_track_objects_directors::Foo.new
raise RuntimeError if b.ping != "Foo::ping()"
raise RuntimeError if b.pong != "Foo::pong();Foo::ping()"
-container = Track_objects_directors::Container.new
+container = Ruby_track_objects_directors::Container.new
foo = MyFoo.new
container.set_foo(foo)
diff --git a/Examples/test-suite/ruby/track_objects_runme.rb b/Examples/test-suite/ruby/ruby_track_objects_runme.rb
index 27d8f6da7..7bc67a478 100644
--- a/Examples/test-suite/ruby/track_objects_runme.rb
+++ b/Examples/test-suite/ruby/ruby_track_objects_runme.rb
@@ -9,7 +9,7 @@
require 'swig_assert'
-require 'track_objects'
+require 'ruby_track_objects'
def test_same_ruby_object(foo1, foo2)
if not foo1.equal?(foo2)
@@ -23,12 +23,12 @@ def test_same_cpp_object(foo1, foo2)
end
end
-bar = Track_objects::Bar.new
-foo1 = Track_objects::Foo.new()
+bar = Ruby_track_objects::Bar.new
+foo1 = Ruby_track_objects::Foo.new()
bar.set_unowned_foo(foo1)
# test_simple_identity
-foo2 = Track_objects::Foo.new()
+foo2 = Ruby_track_objects::Foo.new()
foo3 = foo2
test_same_ruby_object(foo2, foo3)
@@ -48,8 +48,8 @@ test_same_ruby_object(foo5, foo6)
test_same_cpp_object(foo5, foo6)
# test_new_foo_identity
-foo7 = Track_objects::Bar.get_new_foo()
-foo8 = Track_objects::Bar.get_new_foo()
+foo7 = Ruby_track_objects::Bar.get_new_foo()
+foo8 = Ruby_track_objects::Bar.get_new_foo()
if foo7.equal?(foo8)
raise "Ruby objects should be different."
@@ -60,7 +60,7 @@ if foo7.cpp_equal(foo8)
end
# test_set_owned_identity
-foo9 = Track_objects::Foo.new
+foo9 = Ruby_track_objects::Foo.new
bar.set_owned_foo(foo9)
foo10 = bar.get_owned_foo()
@@ -69,7 +69,7 @@ test_same_cpp_object(foo9, foo10)
# test_set_owned_identity2
begin
- foo11 = Track_objects::Foo.new
+ foo11 = Ruby_track_objects::Foo.new
bar.set_owned_foo(foo11)
foo11 = nil
end
@@ -90,20 +90,20 @@ test_same_ruby_object(foo13, foo14)
test_same_cpp_object(foo13, foo14)
# Now create the factory
-factory = Track_objects::Factory.new
+factory = Ruby_track_objects::Factory.new
# Create itemA which is really an itemB
itemA = factory.createItem
# Check class
-if itemA.class != Track_objects::ItemA
+if itemA.class != Ruby_track_objects::ItemA
raise RuntimeError, 'Item should have an ItemA class'
end
# Now downcast
-itemB = Track_objects.downcast(itemA)
+itemB = Ruby_track_objects.downcast(itemA)
-if itemB.class != Track_objects::ItemB
+if itemB.class != Ruby_track_objects::ItemB
raise RuntimeError, 'Item should have an ItemB class'
end
diff --git a/Examples/test-suite/ruby/keywords.i b/Examples/test-suite/ruby_keywords.i
index eb91b4ffa..c87efab33 100644
--- a/Examples/test-suite/ruby/keywords.i
+++ b/Examples/test-suite/ruby_keywords.i
@@ -1,4 +1,4 @@
-%module keywords
+%module ruby_keywords
// fix up conflicts with C++ keywords
%rename("and") Keywords::and_;
diff --git a/Examples/test-suite/ruby/li_std_speed.i b/Examples/test-suite/ruby_li_std_speed.i
index 0dad81690..3c8e60643 100644
--- a/Examples/test-suite/ruby/li_std_speed.i
+++ b/Examples/test-suite/ruby_li_std_speed.i
@@ -1,5 +1,5 @@
/**
- * @file li_std_speed.i
+ * @file ruby_li_std_speed.i
* @author gga
* @date Fri May 18 18:03:15 2007
*
@@ -8,7 +8,7 @@
*
*/
-%module li_std_speed
+%module ruby_li_std_speed
%include <std_list.i>
%include <std_vector.i>
diff --git a/Examples/test-suite/ruby/naming.i b/Examples/test-suite/ruby_naming.i
index 75500ae34..d8ef50ad3 100644
--- a/Examples/test-suite/ruby/naming.i
+++ b/Examples/test-suite/ruby_naming.i
@@ -1,4 +1,4 @@
-%module naming
+%module ruby_naming
%predicate predicateMethod();
%bang bangMethod();
diff --git a/Examples/test-suite/ruby/track_objects.i b/Examples/test-suite/ruby_track_objects.i
index 0a50e1fad..f4bbb37e7 100644
--- a/Examples/test-suite/ruby/track_objects.i
+++ b/Examples/test-suite/ruby_track_objects.i
@@ -1,4 +1,4 @@
-%module track_objects
+%module ruby_track_objects
%include typemaps.i
diff --git a/Examples/test-suite/ruby/track_objects_directors.i b/Examples/test-suite/ruby_track_objects_directors.i
index adac8ae4d..131209828 100644
--- a/Examples/test-suite/ruby/track_objects_directors.i
+++ b/Examples/test-suite/ruby_track_objects_directors.i
@@ -1,4 +1,4 @@
-%module(directors="1") track_objects_directors
+%module(directors="1") ruby_track_objects_directors
%{
#include <string>
diff --git a/Examples/test-suite/r/simple_array.i b/Examples/test-suite/simple_array.i
index 6ddc43678..6ddc43678 100644
--- a/Examples/test-suite/r/simple_array.i
+++ b/Examples/test-suite/simple_array.i
diff --git a/Examples/test-suite/python/simutry.i b/Examples/test-suite/simutry.i
index addea14db..addea14db 100644
--- a/Examples/test-suite/python/simutry.i
+++ b/Examples/test-suite/simutry.i
diff --git a/Examples/test-suite/ruby/stl_new.i b/Examples/test-suite/stl_new.i
index 690a1672b..690a1672b 100644
--- a/Examples/test-suite/ruby/stl_new.i
+++ b/Examples/test-suite/stl_new.i
diff --git a/Examples/test-suite/swig_examples_lock.h b/Examples/test-suite/swig_examples_lock.h
index 7710f9361..feef26d0f 100644
--- a/Examples/test-suite/swig_examples_lock.h
+++ b/Examples/test-suite/swig_examples_lock.h
@@ -1,10 +1,10 @@
-namespace SwigExamples {
-
# if defined(_WIN32) || defined(__WIN32__)
#include <windows.h>
+namespace SwigExamples {
+
class CriticalSection {
public:
CriticalSection() {
@@ -27,9 +27,18 @@ private:
CriticalSection &critical_section;
};
+}
+
#else
#include <pthread.h>
+#ifndef PTHREAD_MUTEX_RECURSIVE_NP
+ // For Cygwin and possibly other OSs: _NP is "non-portable"
+ #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE
+#endif
+
+namespace SwigExamples {
+
class CriticalSection {
public:
CriticalSection() {
@@ -55,7 +64,7 @@ private:
CriticalSection &critical_section;
};
-#endif
-
}
+#endif
+
diff --git a/Examples/test-suite/python/swigobject.i b/Examples/test-suite/swigobject.i
index 2e77969b9..2ec064509 100644
--- a/Examples/test-suite/python/swigobject.i
+++ b/Examples/test-suite/swigobject.i
@@ -10,7 +10,7 @@
const char* pointer_str(A *a){
static char result[1024];
- sprintf(result,"0x%lx", (unsigned long)(void *)a);
+ sprintf(result,"%p", a);
return result;
}
diff --git a/Examples/test-suite/tcl/Makefile.in b/Examples/test-suite/tcl/Makefile.in
index e26d77582..7c4b7ed61 100644
--- a/Examples/test-suite/tcl/Makefile.in
+++ b/Examples/test-suite/tcl/Makefile.in
@@ -11,15 +11,12 @@ top_builddir = @top_builddir@
CPP_TEST_CASES += \
primitive_types \
- li_cdata \
li_cstring \
li_cwstring
C_TEST_CASES += \
- li_cdata \
li_cstring \
- li_cwstring \
- union
+ li_cwstring
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/tcl/union_runme.tcl b/Examples/test-suite/tcl/union_parameter_runme.tcl
index 2c47ecef3..fb3e092b8 100755..100644
--- a/Examples/test-suite/tcl/union_runme.tcl
+++ b/Examples/test-suite/tcl/union_parameter_runme.tcl
@@ -1,4 +1,4 @@
-if [ catch { load ./union[info sharedlibextension] unions} err_msg ] {
+if [ catch { load ./union_parameter[info sharedlibextension] union_parameter} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i
index 61743f9a5..b2d29c943 100644
--- a/Examples/test-suite/template_inherit_abstract.i
+++ b/Examples/test-suite/template_inherit_abstract.i
@@ -57,7 +57,7 @@ namespace oss
%inline %{
namespace oss
{
-#ifdef SWIGCSHARP
+#if defined(SWIG) && defined(SWIGCSHARP)
%ignore HModule<B>::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored.
#endif
struct test : HModule<B>
diff --git a/Examples/test-suite/python/template_matrix.i b/Examples/test-suite/template_matrix.i
index 27696542a..27696542a 100644
--- a/Examples/test-suite/python/template_matrix.i
+++ b/Examples/test-suite/template_matrix.i
diff --git a/Examples/test-suite/template_typedef_funcptr.i b/Examples/test-suite/template_typedef_funcptr.i
index 0175c7516..cec43e7c8 100644
--- a/Examples/test-suite/template_typedef_funcptr.i
+++ b/Examples/test-suite/template_typedef_funcptr.i
@@ -2,6 +2,10 @@
//Bug #1832613
+#if !defined(SWIGR)
+// R Swig fails on this test. Because it tries to return a nil SEXP in
+// an error
+
%include <std_string.i>
%inline %{
@@ -46,3 +50,4 @@ typedef MCContractPtr* ContractPtrPtr;
// Plain pointers were also causing problems...
%template(MCContractFactory2) ContractFactory<MCContract, std::string, ContractPtrPtr>;
+#endif
diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i
index 5375c43b6..b3fa1a733 100644
--- a/Examples/test-suite/typemap_namespace.i
+++ b/Examples/test-suite/typemap_namespace.i
@@ -27,7 +27,7 @@ namespace Foo {
%typemap(javaout) Str1 * = char *;
#endif
%typemap(in) Str1 * = char *;
-#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP))
+#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML))
%typemap(freearg) Str1 * = char *;
#endif
%typemap(typecheck) Str1 * = char *;
diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i
new file mode 100644
index 000000000..8bac2fa89
--- /dev/null
+++ b/Examples/test-suite/typemap_out_optimal.i
@@ -0,0 +1,38 @@
+// Test the optimal attribute in the out typemap
+%module typemap_out_optimal
+
+// Just the following languages tested
+#if defined (SWIGCSHARP)
+%typemap(out, optimal="1") SWIGTYPE %{
+ $result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGJAVA)
+%typemap(out, optimal="1") SWIGTYPE %{
+ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGUTL)
+%typemap(out,noblock="1", optimal="1") SWIGTYPE {
+ %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
+}
+#endif
+
+%ignore XX::operator=;
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+struct XX {
+ XX() { cout << "XX()" << endl; }
+ XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; }
+ XX(const XX &other) { cout << "XX(const XX &)" << endl; }
+ XX& operator =(const XX &other) { cout << "operator=(const XX &)" << endl; return *this; }
+ ~XX() { if (debug) cout << "~XX()" << endl; }
+ static XX create() {
+ return XX(123);
+ }
+ static bool debug;
+};
+bool XX::debug = true;
+%}
+
diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i
index 67d412442..d5a8416db 100644
--- a/Examples/test-suite/typemap_subst.i
+++ b/Examples/test-suite/typemap_subst.i
@@ -50,6 +50,14 @@
(void)stardesc;
(void)ampdesc;
}
+ { /* Test descriptor macro */
+ void *desc = $descriptor(const struct xyzzy **);
+ void *stardesc = $descriptor(const struct xyzzy *);
+ void *ampdesc = $descriptor(const struct xyzzy ***);
+ (void)desc;
+ (void)stardesc;
+ (void)ampdesc;
+ }
$1 = ($ltype) temp;
}
diff --git a/Examples/test-suite/types_directive.i b/Examples/test-suite/types_directive.i
index 44312263d..26cb6aeeb 100644
--- a/Examples/test-suite/types_directive.i
+++ b/Examples/test-suite/types_directive.i
@@ -1,5 +1,13 @@
%module types_directive
+#if defined(SWIGR)
+// Avoid conflict with Date class in R
+#define Date DateSwig
+%inline %{
+#define Date DateSwig
+%}
+#endif
+
%ignore Time2::operator Date *;
%inline %{
diff --git a/Examples/test-suite/tcl/union.i b/Examples/test-suite/union_parameter.i
index d8ac62bfb..bb010d3fa 100644
--- a/Examples/test-suite/tcl/union.i
+++ b/Examples/test-suite/union_parameter.i
@@ -1,4 +1,4 @@
-%module unions
+%module union_parameter
%inline %{
diff --git a/Lib/allegrocl/allegrocl.swg b/Lib/allegrocl/allegrocl.swg
index 8132e4628..4479f6ac2 100644
--- a/Lib/allegrocl/allegrocl.swg
+++ b/Lib/allegrocl/allegrocl.swg
@@ -26,37 +26,76 @@
%typemap(lout) SWIGTYPE "(cl::let* ((address $body)\n (new-inst (cl::make-instance '$lclass :foreign-address address)))\n (cl::unless (cl::zerop address)\n (excl:schedule-finalization new-inst #'$ldestructor))\n (cl::setq ACL_ffresult new-inst))";
-%typemap(lisptype) bool "cl:boolean";
-%typemap(lisptype) char "cl:character";
-%typemap(lisptype) unsigned char "cl:integer";
-%typemap(lisptype) signed char "cl:integer";
-
-%typemap(ffitype) bool ":int";
-%typemap(ffitype) char ":char";
-%typemap(ffitype) unsigned char ":unsigned-char";
-%typemap(ffitype) signed char ":char";
-%typemap(ffitype) short, signed short ":short";
-%typemap(ffitype) unsigned short ":unsigned-short";
-%typemap(ffitype) int, signed int ":int";
-%typemap(ffitype) unsigned int ":unsigned-int";
-%typemap(ffitype) long, signed long ":long";
-%typemap(ffitype) unsigned long ":unsigned-long";
-%typemap(ffitype) float ":float";
-%typemap(ffitype) double ":double";
-%typemap(ffitype) char * "(* :char)";
+%typemap(lisptype) bool, const bool "cl:boolean";
+%typemap(lisptype) char, const char "cl:character";
+%typemap(lisptype) unsigned char, const unsigned char "cl:integer";
+%typemap(lisptype) signed char, const signed char "cl:integer";
+
+%typemap(ffitype) bool, const bool ":int";
+%typemap(ffitype) char, const char,
+ signed char, const signed char ":char";
+%typemap(ffitype) unsigned char, const unsigned char ":unsigned-char";
+%typemap(ffitype) short, const short,
+ signed short, const signed short ":short";
+%typemap(ffitype) unsigned short, const unsigned short ":unsigned-short";
+%typemap(ffitype) int, const int, signed int, const signed int ":int";
+%typemap(ffitype) unsigned int, const unsigned int ":unsigned-int";
+%typemap(ffitype) long, const long, signed long, const signed long ":long";
+%typemap(ffitype) unsigned long, const unsigned long ":unsigned-long";
+%typemap(ffitype) float, const float ":float";
+%typemap(ffitype) double, const double ":double";
+%typemap(ffitype) char *, const char *, signed char *,
+ const signed char *, signed char &,
+ const signed char & "(* :char)";
+%typemap(ffitype) unsigned char *, const unsigned char *,
+ unsigned char &, const unsigned char & "(* :unsigned-char)";
+%typemap(ffitype) short *, const short *, short &,
+ const short & "(* :short)";
+%typemap(ffitype) unsigned short *, const unsigned short *,
+ unsigned short &, const unsigned short & "(* :unsigned-short)";
+%typemap(ffitype) int *, const int *, int &, const int & "(* :int)";
+%typemap(ffitype) unsigned int *, const unsigned int *,
+ unsigned int &, const unsigned int & "(* :unsigned-int)";
%typemap(ffitype) void * "(* :void)";
%typemap(ffitype) void ":void";
%typemap(ffitype) enum SWIGTYPE ":int";
%typemap(ffitype) SWIGTYPE & "(* :void)";
-%typemap(ctype) bool "int";
+/* const typemaps
+idea: marshall all primitive c types to their respective lisp types
+to maintain const corretness. For pointers/references, all bets
+are off if you try to modify them.
+
+idea: add a constant-p slot to the base foreign-pointer class. For
+constant pointer/references check this value when setting (around method?)
+and error if a setf operation is performed on the address of this object.
+
+*/
+
+/*
+%exception %{
+ try {
+ $action
+ } catch (...) {
+ return $null;
+ }
+%}
+
+*/
+
+// %typemap(throws) SWIGTYPE {
+// (void)$1;
+// SWIG_fail;
+// }
+
+%typemap(ctype) bool, const bool "int";
%typemap(ctype) char, unsigned char, signed char,
short, signed short, unsigned short,
int, signed int, unsigned int,
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
- enum SWIGTYPE, SWIGTYPE *,
- SWIGTYPE[ANY], SWIGTYPE & "$1_ltype";
+ enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[],
+ SWIGTYPE[ANY], SWIGTYPE &, const SWIGTYPE "$1_ltype";
%typemap(ctype) SWIGTYPE "$&1_type";
%typemap(in) bool "$1 = (bool)$input;";
@@ -65,7 +104,7 @@
int, signed int, unsigned int,
long, signed long, unsigned long,
float, double, long double, char *, void *, void,
- enum SWIGTYPE, SWIGTYPE *,
+ enum SWIGTYPE, SWIGTYPE *, SWIGTYPE[],
SWIGTYPE[ANY], SWIGTYPE & "$1 = $input;";
%typemap(in) SWIGTYPE "$1 = *$input;";
@@ -122,7 +161,8 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
long, signed long, unsigned long,
enum SWIGTYPE { $1 = 1; };
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &,
- SWIGTYPE[ANY], SWIGTYPE { $1 = 1; };
+ SWIGTYPE[], SWIGTYPE[ANY],
+ SWIGTYPE { $1 = 1; };
/* This maps C/C++ types to Lisp classes for overload dispatch */
@@ -147,7 +187,7 @@ SWIG_TYPECHECK_STRING_ARRAY 1140
enum SWIGTYPE, SWIGTYPE *,
SWIGTYPE[ANY], SWIGTYPE & "$result = $1;";
#ifdef __cplusplus
-%typemap(out) SWIGTYPE "$result = new $1_type($1);";
+%typemap(out) SWIGTYPE "$result = new $1_ltype($1);";
#else
%typemap(out) SWIGTYPE {
$result = ($&1_ltype) malloc(sizeof($1_type));
@@ -243,12 +283,15 @@ $body)"
%rename(__funcall__) *::operator();
%rename(__aref__) *::operator[];
+
+%rename(__bool__) *::operator bool();
+%rename(__bool__) *::operator bool() const;
#endif
%insert("lisphead") %{
;; $Id$
-(eval-when (compile load eval)
+(eval-when (:compile-toplevel :load-toplevel :execute)
;; avoid compiling ef-templates at runtime
(excl:find-external-format :fat)
@@ -375,7 +418,7 @@ $body)"
(defswig2 swig-defconstant (string value)
(cl::let ((symbol (id-convert-and-export string :type :constant)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(cl::defconstant ,symbol ,value))))
(cl::defun maybe-reorder-args (funcname arglist)
@@ -421,7 +464,7 @@ $body)"
)
(cl::when (swig-anyvarargs-p ffargs)
(cl::setq ffargs '()))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(excl::compiler-let ((*record-xref-info* nil))
(ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs))
(cl::macrolet ((swig-ff-call (&rest args)
@@ -447,7 +490,7 @@ $body)"
ffargs
(cl::loop for (nil name nil . ffi) in ffargs
collect `(,name ,@ffi)))))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(excl::compiler-let ((*record-xref-info* nil))
(ff:def-foreign-call (,mangle ,mangled-name) ,ffargs ,@kwargs))
(cl::macrolet ((swig-ff-call (&rest args)
@@ -459,7 +502,7 @@ $body)"
(defswig1 swig-dispatcher ((name &key (type :operator) class arities))
(cl::let ((symbol (id-convert-and-export name
:type type :class class)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(cl::defun ,symbol (&rest args)
(cl::case (cl::length args)
,@(cl::loop for arity in arities
@@ -472,14 +515,14 @@ $body)"
(defswig2 swig-def-foreign-stub (name)
(cl::let ((lsymbol (id-convert-and-export name :type :class))
(symbol (id-convert-and-export name :type :type)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(ff:def-foreign-type ,symbol (:class ))
(cl::defclass ,lsymbol (ff:foreign-pointer) ()))))
(defswig2 swig-def-foreign-class (name supers &rest rest)
(cl::let ((lsymbol (id-convert-and-export name :type :class))
(symbol (id-convert-and-export name :type :type)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(ff:def-foreign-type ,symbol ,@rest)
(cl::defclass ,lsymbol ,supers
((foreign-type :initform ',symbol :initarg :foreign-type
@@ -487,11 +530,11 @@ $body)"
(defswig2 swig-def-foreign-type (name &rest rest)
(cl::let ((symbol (id-convert-and-export name :type :type)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(ff:def-foreign-type ,symbol ,@rest))))
(defswig2 swig-def-synonym-type (synonym of ff-synonym)
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(cl::setf (cl::find-class ',synonym) (cl::find-class ',of))
(ff:def-foreign-type ,ff-synonym (:struct ))))
@@ -511,24 +554,24 @@ $body)"
(parent-strings (cl::mapcar #'package-name-for-namespace
parent-namespaces))
(string (package-name-for-namespace namespace)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(cl::defpackage ,string
(:use :swig :ff #+ignore '(:common-lisp :ff :excl)
,@parent-strings ,*swig-module-name*)
(:import-from :cl :* :nil :t)))))
(cl::defmacro swig-in-package (namespace)
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(cl::in-package ,(package-name-for-namespace namespace))))
(defswig2 swig-defvar (name mangled-name &key type (ftype :unsigned-natural))
(cl::let ((symbol (id-convert-and-export name :type type)))
- `(cl::eval-when (compile load eval)
+ `(cl::eval-when (:compile-toplevel :load-toplevel :execute)
(ff:def-foreign-variable (,symbol ,mangled-name) :type ,ftype))))
) ;; eval-when
-(cl::eval-when (compile eval)
+(cl::eval-when (:compile-toplevel :execute)
(cl::flet ((starts-with-p (str prefix)
(cl::and (cl::>= (cl::length str) (cl::length prefix))
(cl::string= str prefix :end1 (cl::length prefix)))))
@@ -539,7 +582,7 @@ $body)"
%}
-
+typedef void *__SWIGACL_FwdReference;
%{
@@ -551,6 +594,8 @@ $body)"
#define EXPORT EXTERN SWIGEXPORT
+typedef void *__SWIGACL_FwdReference;
+
#include <string.h>
#include <stdlib.h>
%}
diff --git a/Lib/allegrocl/inout_typemaps.i b/Lib/allegrocl/inout_typemaps.i
index d8d61feed..d8d61feed 100755..100644
--- a/Lib/allegrocl/inout_typemaps.i
+++ b/Lib/allegrocl/inout_typemaps.i
diff --git a/Lib/allegrocl/longlongs.i b/Lib/allegrocl/longlongs.i
index b887a8a0a..b887a8a0a 100755..100644
--- a/Lib/allegrocl/longlongs.i
+++ b/Lib/allegrocl/longlongs.i
diff --git a/Lib/allegrocl/std_list.i b/Lib/allegrocl/std_list.i
index c8ab45649..c8ab45649 100755..100644
--- a/Lib/allegrocl/std_list.i
+++ b/Lib/allegrocl/std_list.i
diff --git a/Lib/allegrocl/std_string.i b/Lib/allegrocl/std_string.i
index 4da0148fe..4da0148fe 100755..100644
--- a/Lib/allegrocl/std_string.i
+++ b/Lib/allegrocl/std_string.i
diff --git a/Lib/allkw.swg b/Lib/allkw.swg
index dec6c7c03..2a2fe18d8 100644
--- a/Lib/allkw.swg
+++ b/Lib/allkw.swg
@@ -19,7 +19,7 @@
%include <chicken/chickenkw.swg>
%include <csharp/csharpkw.swg>
%include <java/javakw.swg>
-%include <php4/php4kw.swg>
+%include <php/php.swg>
%include <pike/pikekw.swg>
%include <python/pythonkw.swg>
%include <ocaml/ocamlkw.swg>
diff --git a/Lib/csharp/arrays_csharp.i b/Lib/csharp/arrays_csharp.i
new file mode 100644
index 000000000..ea22da584
--- /dev/null
+++ b/Lib/csharp/arrays_csharp.i
@@ -0,0 +1,140 @@
+/* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
+ * arrays_csharp.i
+ *
+ * This file contains a two approaches to marshaling arrays. The first uses
+ * default p/invoke marshaling and the second uses pinning of the arrays.
+ *
+ * Default marshaling approach
+ * ----------------------------
+ * Array typemaps using default p/invoke marshaling. The data is copied to a separately
+ * allocated buffer when passing over the managed-native boundary.
+ *
+ * There are separate typemaps for in, out and inout arrays to enable avoiding
+ * unnecessary copying.
+ *
+ * Example usage:
+ *
+ * %include "arrays_csharp.i"
+ * %apply int INPUT[] { int* sourceArray }
+ * %apply int OUTPUT[] { int* targetArray }
+ * void myArrayCopy( int* sourceArray, int* targetArray, int nitems );
+ *
+ * %apply int INOUT[] { int* array1, int *array2 }
+ * void myArraySwap( int* array1, int* array2, int nitems );
+ *
+ * If handling large arrays you should consider using the pinning array typemaps
+ * described next.
+ *
+ * Pinning approach
+ * ----------------
+ * Array typemaps using pinning. These typemaps pin the managed array given
+ * as parameter and pass a pointer to it to the c/c++ side. This is very
+ * efficient as no copying is done (unlike in the default array marshaling),
+ * but it makes garbage collection more difficult. When considering using
+ * these typemaps, think carefully whether you have callbacks that may cause
+ * the control to re-enter the managed side from within the call (and produce
+ * garbage for the gc) or whether other threads may produce enough garbage to
+ * trigger gc while the call is being executed. In those cases it may be
+ * wiser to use the default marshaling typemaps.
+ *
+ * Please note that when using fixed arrays, you have to mark your corresponding
+ * module class method unsafe using
+ * %csmethodmodifiers "public unsafe"
+ * (the visibility of the method is up to you).
+ *
+ * Example usage:
+ *
+ * %include "arrays_csharp.i"
+ * %apply int FIXED[] { int* sourceArray, int *targetArray }
+ * %csmethodmodifiers myArrayCopy "public unsafe";
+ * void myArrayCopy( int *sourceArray, int* targetArray, int nitems );
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define CSHARP_ARRAYS( CTYPE, CSTYPE )
+
+// input only arrays
+
+%typemap(ctype) CTYPE INPUT[] "CTYPE*"
+%typemap(cstype) CTYPE INPUT[] "CSTYPE[]"
+%typemap(imtype, inattributes="[In, MarshalAs(UnmanagedType.LPArray)]") CTYPE INPUT[] "CSTYPE[]"
+%typemap(csin) CTYPE INPUT[] "$csinput"
+
+%typemap(in) CTYPE INPUT[] "$1 = $input;"
+%typemap(freearg) CTYPE INPUT[] ""
+%typemap(argout) CTYPE INPUT[] ""
+
+// output only arrays
+
+%typemap(ctype) CTYPE OUTPUT[] "CTYPE*"
+%typemap(cstype) CTYPE OUTPUT[] "CSTYPE[]"
+%typemap(imtype, inattributes="[Out, MarshalAs(UnmanagedType.LPArray)]") CTYPE OUTPUT[] "CSTYPE[]"
+%typemap(csin) CTYPE OUTPUT[] "$csinput"
+
+%typemap(in) CTYPE OUTPUT[] "$1 = $input;"
+%typemap(freearg) CTYPE OUTPUT[] ""
+%typemap(argout) CTYPE OUTPUT[] ""
+
+// inout arrays
+
+%typemap(ctype) CTYPE INOUT[] "CTYPE*"
+%typemap(cstype) CTYPE INOUT[] "CSTYPE[]"
+%typemap(imtype, inattributes="[In, Out, MarshalAs(UnmanagedType.LPArray)]") CTYPE INOUT[] "CSTYPE[]"
+%typemap(csin) CTYPE INOUT[] "$csinput"
+
+%typemap(in) CTYPE INOUT[] "$1 = $input;"
+%typemap(freearg) CTYPE INOUT[] ""
+%typemap(argout) CTYPE INOUT[] ""
+
+%enddef // CSHARP_ARRAYS
+
+CSHARP_ARRAYS(signed char, sbyte)
+CSHARP_ARRAYS(unsigned char, byte)
+CSHARP_ARRAYS(short, short)
+CSHARP_ARRAYS(unsigned short, ushort)
+CSHARP_ARRAYS(int, int)
+CSHARP_ARRAYS(unsigned int, uint)
+// FIXME - on Unix 64 bit, long is 8 bytes but is 4 bytes on Windows 64 bit.
+// How can this be handled sensibly?
+// See e.g. http://www.xml.com/ldd/chapter/book/ch10.html
+CSHARP_ARRAYS(long, int)
+CSHARP_ARRAYS(unsigned long, uint)
+CSHARP_ARRAYS(long long, long)
+CSHARP_ARRAYS(unsigned long long, ulong)
+CSHARP_ARRAYS(float, float)
+CSHARP_ARRAYS(double, double)
+
+
+%define CSHARP_ARRAYS_FIXED( CTYPE, CSTYPE )
+
+%typemap(ctype) CTYPE FIXED[] "CTYPE*"
+%typemap(imtype) CTYPE FIXED[] "IntPtr"
+%typemap(cstype) CTYPE FIXED[] "CSTYPE[]"
+%typemap(csin,
+ pre= " fixed ( CSTYPE* swig_ptrTo_$csinput = $csinput ) {",
+ terminator=" }")
+ CTYPE FIXED[] "(IntPtr)swig_ptrTo_$csinput"
+
+%typemap(in) CTYPE FIXED[] "$1 = $input;"
+%typemap(freearg) CTYPE FIXED[] ""
+%typemap(argout) CTYPE FIXED[] ""
+
+
+%enddef // CSHARP_ARRAYS_FIXED
+
+CSHARP_ARRAYS_FIXED(signed char, sbyte)
+CSHARP_ARRAYS_FIXED(unsigned char, byte)
+CSHARP_ARRAYS_FIXED(short, short)
+CSHARP_ARRAYS_FIXED(unsigned short, ushort)
+CSHARP_ARRAYS_FIXED(int, int)
+CSHARP_ARRAYS_FIXED(unsigned int, uint)
+CSHARP_ARRAYS_FIXED(long, int)
+CSHARP_ARRAYS_FIXED(unsigned long, uint)
+CSHARP_ARRAYS_FIXED(long long, long)
+CSHARP_ARRAYS_FIXED(unsigned long long, ulong)
+CSHARP_ARRAYS_FIXED(float, float)
+CSHARP_ARRAYS_FIXED(double, double)
+
diff --git a/Lib/csharp/boost_shared_ptr.i b/Lib/csharp/boost_shared_ptr.i
index 47fbaba1d..2cb687356 100644
--- a/Lib/csharp/boost_shared_ptr.i
+++ b/Lib/csharp/boost_shared_ptr.i
@@ -33,7 +33,7 @@
// plain reference
%typemap(in, canthrow=1) CONST TYPE & %{
$1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
- if(!$1) {
+ if (!$1) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type reference is null", 0);
return $null;
} %}
@@ -199,22 +199,26 @@
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
- if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnBase) {
- swigCMemOwnBase = false;
- $imcall;
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
}
- swigCPtr = new HandleRef(null, IntPtr.Zero);
GC.SuppressFinalize(this);
}
}
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") TYPE {
lock(this) {
- if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwnDerived) {
- swigCMemOwnDerived = false;
- $imcall;
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
}
- swigCPtr = new HandleRef(null, IntPtr.Zero);
GC.SuppressFinalize(this);
base.Dispose();
}
diff --git a/Lib/csharp/csharp.swg b/Lib/csharp/csharp.swg
index e381ff9ae..fe459547c 100644
--- a/Lib/csharp/csharp.swg
+++ b/Lib/csharp/csharp.swg
@@ -396,7 +396,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
SWIG_UnpackData($input, (void *)&$1, sizeof($1));
%}
%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
- if(!$1) {
+ if (!$1) {
SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "$1_type type is null", 0);
return $null;
} %}
@@ -803,6 +803,19 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+/* Marshal C/C++ pointer to IntPtr */
+%typemap(ctype) void *VOID_INT_PTR "void *"
+%typemap(imtype) void *VOID_INT_PTR "IntPtr"
+%typemap(cstype) void *VOID_INT_PTR "IntPtr"
+%typemap(in) void *VOID_INT_PTR %{ $1 = ($1_ltype)$input; %}
+%typemap(out) void *VOID_INT_PTR %{ $result = (void *)$1; %}
+%typemap(csin) void *VOID_INT_PTR "$csinput"
+%typemap(csout, excode=SWIGEXCODE) void *VOID_INT_PTR {
+ IntPtr ret = $imcall;$excode
+ return ret;
+ }
+
+
/* Typemaps used for the generation of proxy and type wrapper class code */
%typemap(csbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
%typemap(csclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "public class"
@@ -885,22 +898,26 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(csdestruct, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
lock(this) {
- if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
- swigCMemOwn = false;
- $imcall;
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
}
- swigCPtr = new HandleRef(null, IntPtr.Zero);
GC.SuppressFinalize(this);
}
}
%typemap(csdestruct_derived, methodname="Dispose", methodmodifiers="public") SWIGTYPE {
lock(this) {
- if(swigCPtr.Handle != IntPtr.Zero && swigCMemOwn) {
- swigCMemOwn = false;
- $imcall;
+ if (swigCPtr.Handle != IntPtr.Zero) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $imcall;
+ }
+ swigCPtr = new HandleRef(null, IntPtr.Zero);
}
- swigCPtr = new HandleRef(null, IntPtr.Zero);
GC.SuppressFinalize(this);
base.Dispose();
}
diff --git a/Lib/csharp/csharphead.swg b/Lib/csharp/csharphead.swg
index ffff70372..927a54b3b 100644
--- a/Lib/csharp/csharphead.swg
+++ b/Lib/csharp/csharphead.swg
@@ -68,7 +68,7 @@ static SWIG_CSharpException_t SWIG_csharp_exceptions[] = {
static SWIG_CSharpExceptionArgument_t SWIG_csharp_exceptions_argument[] = {
{ SWIG_CSharpArgumentException, NULL },
{ SWIG_CSharpArgumentNullException, NULL },
- { SWIG_CSharpArgumentOutOfRangeException, NULL },
+ { SWIG_CSharpArgumentOutOfRangeException, NULL }
};
static void SWIGUNUSED SWIG_CSharpSetPendingException(SWIG_CSharpExceptionCodes code, const char *msg) {
diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i
index c35f21dc7..3b09861a2 100644
--- a/Lib/csharp/std_map.i
+++ b/Lib/csharp/std_map.i
@@ -5,171 +5,618 @@
* std_map.i
*
* SWIG typemaps for std::map
+ *
+ * The C# wrapper is made to look and feel like a C# System.Collections.Generic.IDictionary<>.
+ *
+ * Using this wrapper is fairly simple. For example, to create a map from integers to doubles use:
+ *
+ * %include <std_map.i>
+ * %template(Map_Int_Double) std::map<int, double>
+ *
+ * Very often the C# generated code will not compile as the C++ template type is not the same as the C#
+ * proxy type, so use the SWIG_STD_MAP_SPECIALIZED or SWIG_STD_MAP_SPECIALIZED_SIMPLE macros. For example:
+ *
+ * SWIG_STD_MAP_SPECIALIZED(MyCppKeyClass, MyCppValueClass, MyCsKeyClass, MyCsValueClass)
+ * %template(Map_MyCppKeyClass_MyCppValueClass) std::map<MyCppKeyClass, MyCppValueClass >;
+ *
+ * Or if the C# class names are the same as the C++ class names, you can use:
+ *
+ * SWIG_STD_MAP_SPECIALIZED_SIMPLE(MyKeyClass, MyValueClass)
+ * %template(Map_MyCppKeyClass_MyCppValueClass) std::map<MyKeyClass, MyValueClass >;
+ *
+ * Notes:
+ * 1) For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code. In this case
+ * the C# wrapper has only basic functionality.
+ * 2) IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
+ * C++ std::map wrappers.
+ *
+ * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
* ----------------------------------------------------------------------------- */
-%include <std_common.i>
-
-// ------------------------------------------------------------------------
-// std::map
-// ------------------------------------------------------------------------
-
%{
#include <map>
#include <algorithm>
#include <stdexcept>
%}
-// exported class
+// A minimal implementation to be used when no specialization exists.
+%define SWIG_STD_MAP_MINIMAL_INTERNAL(K, T)
+ public:
+ map();
+ map(const map<K, T > &other);
-namespace std {
+ typedef K key_type;
+ typedef T mapped_type;
+ typedef size_t size_type;
+ size_type size() const;
+ bool empty() const;
+ %rename(Clear) clear;
+ void clear();
+ %extend {
+ const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
+ std::map<K,T >::iterator iter = $self->find(key);
+ if (iter != $self->end())
+ return iter->second;
+ else
+ throw std::out_of_range("key not found");
+ }
- template<class K, class T> class map {
- // add typemaps here
- public:
- map();
- map(const map<K,T> &);
-
- unsigned int size() const;
- bool empty() const;
- void clear();
- %extend {
- T& get(const K& key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- return i->second;
- else
- throw std::out_of_range("key not found");
- }
- void set(const K& key, const T& x) {
- (*self)[key] = x;
- }
- void del(const K& key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- self->erase(i);
- else
- throw std::out_of_range("key not found");
- }
- bool has_key(const K& key) {
- std::map<K,T >::iterator i = self->find(key);
- return i != self->end();
- }
- }
- };
-
-
- // specializations for built-ins
-
- %define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
-
- template<class T> class map<K,T> {
- // add typemaps here
- public:
- map();
- map(const map<K,T> &);
-
- unsigned int size() const;
- bool empty() const;
- void clear();
- %extend {
- T& get(K key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- return i->second;
- else
- throw std::out_of_range("key not found");
- }
- void set(K key, const T& x) {
- (*self)[key] = x;
- }
- void del(K key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- self->erase(i);
- else
- throw std::out_of_range("key not found");
- }
- bool has_key(K key) {
- std::map<K,T >::iterator i = self->find(key);
- return i != self->end();
- }
- }
- };
- %enddef
-
- %define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
- template<class K> class map<K,T> {
- // add typemaps here
- public:
- map();
- map(const map<K,T> &);
-
- unsigned int size() const;
- bool empty() const;
- void clear();
- %extend {
- T get(const K& key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- return i->second;
- else
- throw std::out_of_range("key not found");
- }
- void set(const K& key, T x) {
- (*self)[key] = x;
- }
- void del(const K& key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- self->erase(i);
- else
- throw std::out_of_range("key not found");
- }
- bool has_key(const K& key) {
- std::map<K,T >::iterator i = self->find(key);
- return i != self->end();
- }
+ void setitem(const key_type& key, const mapped_type& x) {
+ (*$self)[key] = x;
+ }
+
+ bool ContainsKey(const key_type& key) {
+ std::map<K, T >::iterator iter = $self->find(key);
+ return iter != $self->end();
+ }
+
+ void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
+ std::map<K, T >::iterator iter = $self->find(key);
+ if (iter != $self->end())
+ throw std::out_of_range("key already exists");
+ $self->insert(std::pair<K, T >(key, val));
+ }
+
+ bool Remove(const key_type& key) {
+ std::map<K, T >::iterator iter = $self->find(key);
+ if (iter != $self->end()) {
+ $self->erase(iter);
+ return true;
+ }
+ return false;
+ }
+
+ }
+
+%enddef
+
+/* The specialized std::map implementation
+ * K is the C++ key type
+ * T is the C++ value type
+ * CSKEYTYPE is the C# key type
+ * CSVALUETYPE is the C# value type
+ */
+%define SWIG_STD_MAP_SPECIALIZED_INTERNAL(K, T, CSKEYTYPE, CSVALUETYPE)
+// add typemaps here
+%typemap(csinterfaces) std::map<K, T > "IDisposable \n#if !SWIG_DOTNET_1\n , System.Collections.Generic.IDictionary<CSKEYTYPE, CSVALUETYPE>\n#endif\n";
+%typemap(cscode) std::map<K, T > %{
+
+ public CSVALUETYPE this[CSKEYTYPE key] {
+ get {
+ return getitem(key);
+ }
+
+ set {
+ setitem(key, value);
+ }
+ }
+
+ public bool TryGetValue(CSKEYTYPE key, out CSVALUETYPE value) {
+ if (this.ContainsKey(key)) {
+ value = this[key];
+ return true;
+ }
+ value = default(CSVALUETYPE);
+ return false;
+ }
+
+ public int Count {
+ get {
+ return (int)size();
+ }
+ }
+
+ public bool IsReadOnly {
+ get {
+ return false;
+ }
+ }
+
+#if !SWIG_DOTNET_1
+
+ public System.Collections.Generic.ICollection<CSKEYTYPE> Keys {
+ get {
+ System.Collections.Generic.ICollection<CSKEYTYPE> keys = new System.Collections.Generic.List<CSKEYTYPE>();
+ IntPtr iter = create_iterator_begin();
+ try {
+ while (true) {
+ keys.Add(get_next_key(iter));
}
- };
- %enddef
-
- %define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO,
- T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
- template<> class map<K,T> {
- // add typemaps here
- public:
- map();
- map(const map<K,T> &);
-
- unsigned int size() const;
- bool empty() const;
- void clear();
- %extend {
- T get(K key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- return i->second;
- else
- throw std::out_of_range("key not found");
- }
- void set(K key, T x) {
- (*self)[key] = x;
- }
- void del(K key) throw (std::out_of_range) {
- std::map<K,T >::iterator i = self->find(key);
- if (i != self->end())
- self->erase(i);
- else
- throw std::out_of_range("key not found");
- }
- bool has_key(K key) {
- std::map<K,T >::iterator i = self->find(key);
- return i != self->end();
- }
+ } catch (ArgumentOutOfRangeException) {
+ }
+ return keys;
+ }
+ }
+
+ public System.Collections.Generic.ICollection<CSVALUETYPE> Values {
+ get {
+ System.Collections.Generic.ICollection<CSVALUETYPE> vals = new System.Collections.Generic.List<CSVALUETYPE>();
+ foreach (System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> pair in this) {
+ vals.Add(pair.Value);
+ }
+ return vals;
+ }
+ }
+
+ public void Add(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> item) {
+ Add(item.Key, item.Value);
+ }
+
+ public bool Remove(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> item) {
+ if (Contains(item)) {
+ return Remove(item.Key);
+ } else {
+ return false;
+ }
+ }
+
+ public bool Contains(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> item) {
+ if (this[item.Key] == item.Value) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public void CopyTo(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>[] array) {
+ CopyTo(array, 0);
+ }
+
+ public void CopyTo(System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>[] array, int arrayIndex) {
+ if (array == null)
+ throw new ArgumentNullException("array");
+ if (arrayIndex < 0)
+ throw new ArgumentOutOfRangeException("arrayIndex", "Value is less than zero");
+ if (array.Rank > 1)
+ throw new ArgumentException("Multi dimensional array.", "array");
+ if (arrayIndex+this.Count > array.Length)
+ throw new ArgumentException("Number of elements to copy is too large.");
+
+ System.Collections.Generic.IList<CSKEYTYPE> keyList = new System.Collections.Generic.List<CSKEYTYPE>(this.Keys);
+ for (int i = 0; i < keyList.Count; i++) {
+ CSKEYTYPE currentKey = keyList[i];
+ array.SetValue(new System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>(currentKey, this[currentKey]), arrayIndex+i);
+ }
+ }
+
+ System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>>.GetEnumerator() {
+ return new $csclassnameEnumerator(this);
+ }
+
+ System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
+ return new $csclassnameEnumerator(this);
+ }
+
+ public $csclassnameEnumerator GetEnumerator() {
+ return new $csclassnameEnumerator(this);
+ }
+
+ // Type-safe enumerator
+ /// Note that the IEnumerator documentation requires an InvalidOperationException to be thrown
+ /// whenever the collection is modified. This has been done for changes in the size of the
+ /// collection but not when one of the elements of the collection is modified as it is a bit
+ /// tricky to detect unmanaged code that modifies the collection under our feet.
+ public sealed class $csclassnameEnumerator : System.Collections.IEnumerator,
+ System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>>
+ {
+ private $csclassname collectionRef;
+ private System.Collections.Generic.IList<CSKEYTYPE> keyCollection;
+ private int currentIndex;
+ private object currentObject;
+ private int currentSize;
+
+ public $csclassnameEnumerator($csclassname collection) {
+ collectionRef = collection;
+ keyCollection = new System.Collections.Generic.List<CSKEYTYPE>(collection.Keys);
+ currentIndex = -1;
+ currentObject = null;
+ currentSize = collectionRef.Count;
+ }
+
+ // Type-safe iterator Current
+ public System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE> Current {
+ get {
+ if (currentIndex == -1)
+ throw new InvalidOperationException("Enumeration not started.");
+ if (currentIndex > currentSize - 1)
+ throw new InvalidOperationException("Enumeration finished.");
+ if (currentObject == null)
+ throw new InvalidOperationException("Collection modified.");
+ return (System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>)currentObject;
+ }
+ }
+
+ // Type-unsafe IEnumerator.Current
+ object System.Collections.IEnumerator.Current {
+ get {
+ return Current;
+ }
+ }
+
+ public bool MoveNext() {
+ int size = collectionRef.Count;
+ bool moveOkay = (currentIndex+1 < size) && (size == currentSize);
+ if (moveOkay) {
+ currentIndex++;
+ CSKEYTYPE currentKey = keyCollection[currentIndex];
+ currentObject = new System.Collections.Generic.KeyValuePair<CSKEYTYPE, CSVALUETYPE>(currentKey, collectionRef[currentKey]);
+ } else {
+ currentObject = null;
+ }
+ return moveOkay;
+ }
+
+ public void Reset() {
+ currentIndex = -1;
+ currentObject = null;
+ if (collectionRef.Count != currentSize) {
+ throw new InvalidOperationException("Collection modified.");
+ }
+ }
+
+ public void Dispose() {
+ currentIndex = -1;
+ currentObject = null;
+ }
+ }
+#endif
+
+%}
+
+ public:
+ map();
+ map(const map<K, T > &other);
+
+ typedef K key_type;
+ typedef T mapped_type;
+ typedef size_t size_type;
+ size_type size() const;
+ bool empty() const;
+ %rename(Clear) clear;
+ void clear();
+ %extend {
+ const mapped_type& getitem(const key_type& key) throw (std::out_of_range) {
+ std::map<K,T >::iterator iter = $self->find(key);
+ if (iter != $self->end())
+ return iter->second;
+ else
+ throw std::out_of_range("key not found");
+ }
+
+ void setitem(const key_type& key, const mapped_type& x) {
+ (*$self)[key] = x;
+ }
+
+ bool ContainsKey(const key_type& key) {
+ std::map<K, T >::iterator iter = $self->find(key);
+ return iter != $self->end();
+ }
+
+ void Add(const key_type& key, const mapped_type& val) throw (std::out_of_range) {
+ std::map<K, T >::iterator iter = $self->find(key);
+ if (iter != $self->end())
+ throw std::out_of_range("key already exists");
+ $self->insert(std::pair<K, T >(key, val));
+ }
+
+ bool Remove(const key_type& key) {
+ std::map<K, T >::iterator iter = $self->find(key);
+ if (iter != $self->end()) {
+ $self->erase(iter);
+ return true;
+ }
+ return false;
+ }
+
+ // create_iterator_begin() and get_next_key() work together to provide a collection of keys to C#
+ %apply void *VOID_INT_PTR { std::map<K, T >::iterator *std::map<K, T >::create_iterator_begin }
+ %apply void *VOID_INT_PTR { std::map<K, T >::iterator *swigiterator }
+
+ std::map<K, T >::iterator *create_iterator_begin() {
+ return new std::map<K, T >::iterator($self->begin());
+ }
+
+ const key_type& get_next_key(std::map<K, T >::iterator *swigiterator) throw (std::out_of_range) {
+ std::map<K, T >::iterator iter = *swigiterator;
+ if (iter == $self->end()) {
+ delete swigiterator;
+ throw std::out_of_range("no more map elements");
}
- };
- %enddef
+ (*swigiterator)++;
+ return (*iter).first;
+ }
+ }
+
+
+%csmethodmodifiers std::map<K, T >::size "private"
+%csmethodmodifiers std::map<K, T >::getitem "private"
+%csmethodmodifiers std::map<K, T >::setitem "private"
+%csmethodmodifiers std::map<K, T >::create_iterator_begin "private"
+%csmethodmodifiers std::map<K, T >::get_next_key "private"
+
+%enddef
+
+
+// Main specialization macros
+%define SWIG_STD_MAP_SPECIALIZED(K, T, CSKEY, CSVAL)
+namespace std {
+ template<> class map<K, T > {
+ SWIG_STD_MAP_SPECIALIZED_INTERNAL(K, T, CSKEY, CSVAL)
+ };
+}
+%enddef
+
+%define SWIG_STD_MAP_SPECIALIZED_SIMPLE(K, T)
+ SWIG_STD_MAP_SPECIALIZED(K, T, K, T)
+%enddef
+
+// Old macros (deprecated)
+%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
+#warning specialize_std_map_on_key ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i
+%enddef
- // add specializations here
+%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
+#warning specialize_std_map_on_value ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i
+%enddef
+%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
+#warning specialize_std_map_on_both ignored - macro is deprecated, please use SWIG_STD_MAP_MINIMAL_INTERNAL in Lib/csharp/std_map.i
+%enddef
+
+// Default implementation
+namespace std {
+ template<class K, class T> class map {
+ SWIG_STD_MAP_MINIMAL_INTERNAL(K, T)
+ };
}
+
+// specializations for built-ins
+SWIG_STD_MAP_SPECIALIZED(std::string, std::string, string, string)
+SWIG_STD_MAP_SPECIALIZED(std::string, bool, string, bool)
+SWIG_STD_MAP_SPECIALIZED(std::string, int, string, int)
+SWIG_STD_MAP_SPECIALIZED(std::string, unsigned long long, string, ulong)
+SWIG_STD_MAP_SPECIALIZED(std::string, unsigned long, string, uint)
+SWIG_STD_MAP_SPECIALIZED(std::string, unsigned short, string, ushort)
+SWIG_STD_MAP_SPECIALIZED(std::string, long long, string, long)
+SWIG_STD_MAP_SPECIALIZED(std::string, unsigned int, string, uint)
+SWIG_STD_MAP_SPECIALIZED(std::string, unsigned char, string, byte)
+SWIG_STD_MAP_SPECIALIZED(std::string, signed char, string, sbyte)
+SWIG_STD_MAP_SPECIALIZED(std::string, double, string, double)
+SWIG_STD_MAP_SPECIALIZED(std::string, short, string, short)
+SWIG_STD_MAP_SPECIALIZED(std::string, float, string, float)
+SWIG_STD_MAP_SPECIALIZED(std::string, char, string, char)
+SWIG_STD_MAP_SPECIALIZED(std::string, long, string, int)
+SWIG_STD_MAP_SPECIALIZED(bool, std::string, bool, string)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, bool)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, int)
+SWIG_STD_MAP_SPECIALIZED(bool, unsigned long long, bool, ulong)
+SWIG_STD_MAP_SPECIALIZED(bool, unsigned long, bool, uint)
+SWIG_STD_MAP_SPECIALIZED(bool, unsigned short, bool, ushort)
+SWIG_STD_MAP_SPECIALIZED(bool, long long, bool, long)
+SWIG_STD_MAP_SPECIALIZED(bool, unsigned int, bool, uint)
+SWIG_STD_MAP_SPECIALIZED(bool, unsigned char, bool, byte)
+SWIG_STD_MAP_SPECIALIZED(bool, signed char, bool, sbyte)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, double)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, short)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, float)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(bool, char)
+SWIG_STD_MAP_SPECIALIZED(bool, long, bool, int)
+SWIG_STD_MAP_SPECIALIZED(int, std::string, int, string)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, bool)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, int)
+SWIG_STD_MAP_SPECIALIZED(int, unsigned long long, int, ulong)
+SWIG_STD_MAP_SPECIALIZED(int, unsigned long, int, uint)
+SWIG_STD_MAP_SPECIALIZED(int, unsigned short, int, ushort)
+SWIG_STD_MAP_SPECIALIZED(int, long long, int, long)
+SWIG_STD_MAP_SPECIALIZED(int, unsigned int, int, uint)
+SWIG_STD_MAP_SPECIALIZED(int, unsigned char, int, byte)
+SWIG_STD_MAP_SPECIALIZED(int, signed char, int, sbyte)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, double)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, short)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, float)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(int, char)
+SWIG_STD_MAP_SPECIALIZED(int, long, int, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, std::string, ulong, string)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, bool, ulong, bool)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, int, ulong, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned long long, ulong, ulong)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned long, ulong, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned short, ulong, ushort)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, long long, ulong, long)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned int, ulong, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, unsigned char, ulong, byte)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, signed char, ulong, sbyte)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, double, ulong, double)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, short, ulong, short)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, float, ulong, float)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, char, ulong, char)
+SWIG_STD_MAP_SPECIALIZED(unsigned long long, long, ulong, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, std::string, uint, string)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, bool, uint, bool)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, int, uint, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned long long, uint, ulong)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned long, uint, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned short, uint, ushort)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, long long, uint, long)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned int, uint, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, unsigned char, uint, byte)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, signed char, uint, sbyte)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, double, uint, double)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, short, uint, short)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, float, uint, float)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, char, uint, char)
+SWIG_STD_MAP_SPECIALIZED(unsigned long, long, uint, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, std::string, ushort, string)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, bool, ushort, bool)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, int, ushort, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned long long, ushort, ulong)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned long, ushort, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned short, ushort, ushort)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, long long, ushort, long)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned int, ushort, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, unsigned char, ushort, byte)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, signed char, ushort, sbyte)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, double, ushort, double)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, short, ushort, short)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, float, ushort, float)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, char, ushort, char)
+SWIG_STD_MAP_SPECIALIZED(unsigned short, long, ushort, int)
+SWIG_STD_MAP_SPECIALIZED(long long, std::string, long, string)
+SWIG_STD_MAP_SPECIALIZED(long long, bool, long, bool)
+SWIG_STD_MAP_SPECIALIZED(long long, int, long, int)
+SWIG_STD_MAP_SPECIALIZED(long long, unsigned long long, long, ulong)
+SWIG_STD_MAP_SPECIALIZED(long long, unsigned long, long, uint)
+SWIG_STD_MAP_SPECIALIZED(long long, unsigned short, long, ushort)
+SWIG_STD_MAP_SPECIALIZED(long long, long long, long, long)
+SWIG_STD_MAP_SPECIALIZED(long long, unsigned int, long, uint)
+SWIG_STD_MAP_SPECIALIZED(long long, unsigned char, long, byte)
+SWIG_STD_MAP_SPECIALIZED(long long, signed char, long, sbyte)
+SWIG_STD_MAP_SPECIALIZED(long long, double, long, double)
+SWIG_STD_MAP_SPECIALIZED(long long, short, long, short)
+SWIG_STD_MAP_SPECIALIZED(long long, float, long, float)
+SWIG_STD_MAP_SPECIALIZED(long long, char, long, char)
+SWIG_STD_MAP_SPECIALIZED(long long, long, long, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, std::string, uint, string)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, bool, uint, bool)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, int, uint, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned long long, uint, ulong)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned long, uint, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned short, uint, ushort)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, long long, uint, long)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned int, uint, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, unsigned char, uint, byte)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, signed char, uint, sbyte)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, double, uint, double)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, short, uint, short)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, float, uint, float)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, char, uint, char)
+SWIG_STD_MAP_SPECIALIZED(unsigned int, long, uint, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, std::string, byte, string)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, bool, byte, bool)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, int, byte, int)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned long long, byte, ulong)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned long, byte, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned short, byte, ushort)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, long long, byte, long)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned int, byte, uint)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, unsigned char, byte, byte)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, signed char, byte, sbyte)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, double, byte, double)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, short, byte, short)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, float, byte, float)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, char, byte, char)
+SWIG_STD_MAP_SPECIALIZED(unsigned char, long, byte, int)
+SWIG_STD_MAP_SPECIALIZED(signed char, std::string, sbyte, string)
+SWIG_STD_MAP_SPECIALIZED(signed char, bool, sbyte, bool)
+SWIG_STD_MAP_SPECIALIZED(signed char, int, sbyte, int)
+SWIG_STD_MAP_SPECIALIZED(signed char, unsigned long long, sbyte, ulong)
+SWIG_STD_MAP_SPECIALIZED(signed char, unsigned long, sbyte, uint)
+SWIG_STD_MAP_SPECIALIZED(signed char, unsigned short, sbyte, ushort)
+SWIG_STD_MAP_SPECIALIZED(signed char, long long, sbyte, long)
+SWIG_STD_MAP_SPECIALIZED(signed char, unsigned int, sbyte, uint)
+SWIG_STD_MAP_SPECIALIZED(signed char, unsigned char, sbyte, byte)
+SWIG_STD_MAP_SPECIALIZED(signed char, signed char, sbyte, sbyte)
+SWIG_STD_MAP_SPECIALIZED(signed char, double, sbyte, double)
+SWIG_STD_MAP_SPECIALIZED(signed char, short, sbyte, short)
+SWIG_STD_MAP_SPECIALIZED(signed char, float, sbyte, float)
+SWIG_STD_MAP_SPECIALIZED(signed char, char, sbyte, char)
+SWIG_STD_MAP_SPECIALIZED(signed char, long, sbyte, int)
+SWIG_STD_MAP_SPECIALIZED(double, std::string, double, string)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, bool)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, int)
+SWIG_STD_MAP_SPECIALIZED(double, unsigned long long, double, ulong)
+SWIG_STD_MAP_SPECIALIZED(double, unsigned long, double, uint)
+SWIG_STD_MAP_SPECIALIZED(double, unsigned short, double, ushort)
+SWIG_STD_MAP_SPECIALIZED(double, long long, double, long)
+SWIG_STD_MAP_SPECIALIZED(double, unsigned int, double, uint)
+SWIG_STD_MAP_SPECIALIZED(double, unsigned char, double, byte)
+SWIG_STD_MAP_SPECIALIZED(double, signed char, double, sbyte)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, double)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, short)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, float)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(double, char)
+SWIG_STD_MAP_SPECIALIZED(double, long, double, int)
+SWIG_STD_MAP_SPECIALIZED(short, std::string, short, string)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, bool)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, int)
+SWIG_STD_MAP_SPECIALIZED(short, unsigned long long, short, ulong)
+SWIG_STD_MAP_SPECIALIZED(short, unsigned long, short, uint)
+SWIG_STD_MAP_SPECIALIZED(short, unsigned short, short, ushort)
+SWIG_STD_MAP_SPECIALIZED(short, long long, short, long)
+SWIG_STD_MAP_SPECIALIZED(short, unsigned int, short, uint)
+SWIG_STD_MAP_SPECIALIZED(short, unsigned char, short, byte)
+SWIG_STD_MAP_SPECIALIZED(short, signed char, short, sbyte)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, double)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, short)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, float)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(short, char)
+SWIG_STD_MAP_SPECIALIZED(short, long, short, int)
+SWIG_STD_MAP_SPECIALIZED(float, std::string, float, string)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, bool)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, int)
+SWIG_STD_MAP_SPECIALIZED(float, unsigned long long, float, ulong)
+SWIG_STD_MAP_SPECIALIZED(float, unsigned long, float, uint)
+SWIG_STD_MAP_SPECIALIZED(float, unsigned short, float, ushort)
+SWIG_STD_MAP_SPECIALIZED(float, long long, float, long)
+SWIG_STD_MAP_SPECIALIZED(float, unsigned int, float, uint)
+SWIG_STD_MAP_SPECIALIZED(float, unsigned char, float, byte)
+SWIG_STD_MAP_SPECIALIZED(float, signed char, float, sbyte)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, double)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, short)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, float)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(float, char)
+SWIG_STD_MAP_SPECIALIZED(float, long, float, int)
+SWIG_STD_MAP_SPECIALIZED(char, std::string, char, string)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, bool)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, int)
+SWIG_STD_MAP_SPECIALIZED(char, unsigned long long, char, ulong)
+SWIG_STD_MAP_SPECIALIZED(char, unsigned long, char, uint)
+SWIG_STD_MAP_SPECIALIZED(char, unsigned short, char, ushort)
+SWIG_STD_MAP_SPECIALIZED(char, long long, char, long)
+SWIG_STD_MAP_SPECIALIZED(char, unsigned int, char, uint)
+SWIG_STD_MAP_SPECIALIZED(char, unsigned char, char, byte)
+SWIG_STD_MAP_SPECIALIZED(char, signed char, char, sbyte)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, double)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, short)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, float)
+SWIG_STD_MAP_SPECIALIZED_SIMPLE(char, char)
+SWIG_STD_MAP_SPECIALIZED(char, long, char, int)
+SWIG_STD_MAP_SPECIALIZED(long, std::string, int, string)
+SWIG_STD_MAP_SPECIALIZED(long, bool, int, bool)
+SWIG_STD_MAP_SPECIALIZED(long, int, int, int)
+SWIG_STD_MAP_SPECIALIZED(long, unsigned long long, int, ulong)
+SWIG_STD_MAP_SPECIALIZED(long, unsigned long, int, uint)
+SWIG_STD_MAP_SPECIALIZED(long, unsigned short, int, ushort)
+SWIG_STD_MAP_SPECIALIZED(long, long long, int, long)
+SWIG_STD_MAP_SPECIALIZED(long, unsigned int, int, uint)
+SWIG_STD_MAP_SPECIALIZED(long, unsigned char, int, byte)
+SWIG_STD_MAP_SPECIALIZED(long, signed char, int, sbyte)
+SWIG_STD_MAP_SPECIALIZED(long, double, int, double)
+SWIG_STD_MAP_SPECIALIZED(long, short, int, short)
+SWIG_STD_MAP_SPECIALIZED(long, float, int, float)
+SWIG_STD_MAP_SPECIALIZED(long, char, int, char)
+SWIG_STD_MAP_SPECIALIZED(long, long, int, int)
+
+// add specializations here
+
+
diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i
index a04831f75..d3a4a5541 100755..100644
--- a/Lib/csharp/std_vector.i
+++ b/Lib/csharp/std_vector.i
@@ -6,15 +6,23 @@
*
* SWIG typemaps for std::vector
* C# implementation
- * The C# wrapper is made to look and feel like a typesafe C# System.Collections.ArrayList
- * All the methods in IList are defined, but we don't derive from IList as this is a typesafe collection.
- * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
+ * The C# wrapper is made to look and feel like a C# System.Collections.Generic.List<> collection.
+ * For .NET 1 compatibility, define SWIG_DOTNET_1 when compiling the C# code; then the C# wrapper is
+ * made to look and feel like a typesafe C# System.Collections.ArrayList. All the methods in IList
+ * are defined, but we don't derive from IList as this is a typesafe collection and the C++ operator==
+ * must always be defined for the collection type (which it isn't).
*
* Very often the C# generated code will not compile as the C++ template type is not the same as the C#
* proxy type, so use the SWIG_STD_VECTOR_SPECIALIZE or SWIG_STD_VECTOR_SPECIALIZE_MINIMUM macro, eg
*
* SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(Klass, SomeNamespace::Klass)
* %template(VectKlass) std::vector<SomeNamespace::Klass>;
+ *
+ * Note that IEnumerable<> is implemented in the proxy class which is useful for using LINQ with
+ * C++ std::vector wrappers. IEnumerable<> is replaced by IList<> wherever we are confident that the
+ * required C++ operator== is available for correct compilation.
+ *
+ * Warning: heavy macro usage in this file. Use swig -E to get a sane view on the real file contents!
* ----------------------------------------------------------------------------- */
// Warning: Use the typemaps here in the expectation that the macros they are in will change name.
@@ -24,8 +32,8 @@
// MACRO for use within the std::vector class body
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
-%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
-%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable";
+%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE_TYPE, CSTYPE, CTYPE...)
+%typemap(csinterfaces) std::vector<CTYPE > "IDisposable, System.Collections.IEnumerable\n#if !SWIG_DOTNET_1\n , System.Collections.Generic.CSINTERFACE<CSTYPE>\n#endif\n";
%typemap(cscode) std::vector<CTYPE > %{
public $csclassname(System.Collections.ICollection c) : this() {
if (c == null)
@@ -79,15 +87,30 @@
}
}
- public void CopyTo(System.Array array) {
+#if SWIG_DOTNET_1
+ public void CopyTo(System.Array array)
+#else
+ public void CopyTo(CSTYPE[] array)
+#endif
+ {
CopyTo(0, array, 0, this.Count);
}
- public void CopyTo(System.Array array, int arrayIndex) {
+#if SWIG_DOTNET_1
+ public void CopyTo(System.Array array, int arrayIndex)
+#else
+ public void CopyTo(CSTYPE[] array, int arrayIndex)
+#endif
+ {
CopyTo(0, array, arrayIndex, this.Count);
}
- public void CopyTo(int index, System.Array array, int arrayIndex, int count) {
+#if SWIG_DOTNET_1
+ public void CopyTo(int index, System.Array array, int arrayIndex, int count)
+#else
+ public void CopyTo(int index, CSTYPE[] array, int arrayIndex, int count)
+#endif
+ {
if (array == null)
throw new ArgumentNullException("array");
if (index < 0)
@@ -97,14 +120,19 @@
if (count < 0)
throw new ArgumentOutOfRangeException("count", "Value is less than zero");
if (array.Rank > 1)
- throw new ArgumentException("Multi dimensional array.");
+ throw new ArgumentException("Multi dimensional array.", "array");
if (index+count > this.Count || arrayIndex+count > array.Length)
throw new ArgumentException("Number of elements to copy is too large.");
for (int i=0; i<count; i++)
array.SetValue(getitemcopy(index+i), arrayIndex+i);
}
- // Type-safe version of IEnumerable.GetEnumerator
+#if !SWIG_DOTNET_1
+ System.Collections.Generic.IEnumerator<CSTYPE> System.Collections.Generic.IEnumerable<CSTYPE>.GetEnumerator() {
+ return new $csclassnameEnumerator(this);
+ }
+#endif
+
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
return new $csclassnameEnumerator(this);
}
@@ -118,7 +146,11 @@
/// whenever the collection is modified. This has been done for changes in the size of the
/// collection but not when one of the elements of the collection is modified as it is a bit
/// tricky to detect unmanaged code that modifies the collection under our feet.
- public sealed class $csclassnameEnumerator : System.Collections.IEnumerator {
+ public sealed class $csclassnameEnumerator : System.Collections.IEnumerator
+#if !SWIG_DOTNET_1
+ , System.Collections.Generic.IEnumerator<CSTYPE>
+#endif
+ {
private $csclassname collectionRef;
private int currentIndex;
private object currentObject;
@@ -170,13 +202,20 @@
throw new InvalidOperationException("Collection modified.");
}
}
+
+#if !SWIG_DOTNET_1
+ public void Dispose() {
+ currentIndex = -1;
+ currentObject = null;
+ }
+#endif
}
%}
public:
typedef size_t size_type;
typedef CTYPE value_type;
- typedef const value_type& const_reference;
+ typedef CONST_REFERENCE_TYPE const_reference;
%rename(Clear) clear;
void clear();
%rename(Add) push_back;
@@ -187,6 +226,7 @@
%newobject GetRange(int index, int count);
%newobject Repeat(const value_type& value, int count);
vector();
+ vector(const vector &other);
%extend {
vector(int capacity) throw (std::out_of_range) {
std::vector<CTYPE >* pv = 0;
@@ -199,26 +239,26 @@
return pv;
}
CTYPE getitemcopy(int index) throw (std::out_of_range) {
- if (index>=0 && index<(int)self->size())
- return (*self)[index];
+ if (index>=0 && index<(int)$self->size())
+ return (*$self)[index];
else
throw std::out_of_range("index");
}
const_reference getitem(int index) throw (std::out_of_range) {
- if (index>=0 && index<(int)self->size())
- return (*self)[index];
+ if (index>=0 && index<(int)$self->size())
+ return (*$self)[index];
else
throw std::out_of_range("index");
}
void setitem(int index, const value_type& val) throw (std::out_of_range) {
- if (index>=0 && index<(int)self->size())
- (*self)[index] = val;
+ if (index>=0 && index<(int)$self->size())
+ (*$self)[index] = val;
else
throw std::out_of_range("index");
}
// Takes a deep copy of the elements unlike ArrayList.AddRange
void AddRange(const std::vector<CTYPE >& values) {
- self->insert(self->end(), values.begin(), values.end());
+ $self->insert($self->end(), values.begin(), values.end());
}
// Takes a deep copy of the elements unlike ArrayList.GetRange
std::vector<CTYPE > *GetRange(int index, int count) throw (std::out_of_range, std::invalid_argument) {
@@ -226,26 +266,26 @@
throw std::out_of_range("index");
if (count < 0)
throw std::out_of_range("count");
- if (index >= (int)self->size()+1 || index+count > (int)self->size())
+ if (index >= (int)$self->size()+1 || index+count > (int)$self->size())
throw std::invalid_argument("invalid range");
- return new std::vector<CTYPE >(self->begin()+index, self->begin()+index+count);
+ return new std::vector<CTYPE >($self->begin()+index, $self->begin()+index+count);
}
void Insert(int index, const value_type& x) throw (std::out_of_range) {
- if (index>=0 && index<(int)self->size()+1)
- self->insert(self->begin()+index, x);
+ if (index>=0 && index<(int)$self->size()+1)
+ $self->insert($self->begin()+index, x);
else
throw std::out_of_range("index");
}
// Takes a deep copy of the elements unlike ArrayList.InsertRange
void InsertRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) {
- if (index>=0 && index<(int)self->size()+1)
- self->insert(self->begin()+index, values.begin(), values.end());
+ if (index>=0 && index<(int)$self->size()+1)
+ $self->insert($self->begin()+index, values.begin(), values.end());
else
throw std::out_of_range("index");
}
void RemoveAt(int index) throw (std::out_of_range) {
- if (index>=0 && index<(int)self->size())
- self->erase(self->begin() + index);
+ if (index>=0 && index<(int)$self->size())
+ $self->erase($self->begin() + index);
else
throw std::out_of_range("index");
}
@@ -254,9 +294,9 @@
throw std::out_of_range("index");
if (count < 0)
throw std::out_of_range("count");
- if (index >= (int)self->size()+1 || index+count > (int)self->size())
+ if (index >= (int)$self->size()+1 || index+count > (int)$self->size())
throw std::invalid_argument("invalid range");
- self->erase(self->begin()+index, self->begin()+index+count);
+ $self->erase($self->begin()+index, $self->begin()+index+count);
}
static std::vector<CTYPE > *Repeat(const value_type& value, int count) throw (std::out_of_range) {
if (count < 0)
@@ -264,53 +304,61 @@
return new std::vector<CTYPE >(count, value);
}
void Reverse() {
- std::reverse(self->begin(), self->end());
+ std::reverse($self->begin(), $self->end());
}
void Reverse(int index, int count) throw (std::out_of_range, std::invalid_argument) {
if (index < 0)
throw std::out_of_range("index");
if (count < 0)
throw std::out_of_range("count");
- if (index >= (int)self->size()+1 || index+count > (int)self->size())
+ if (index >= (int)$self->size()+1 || index+count > (int)$self->size())
throw std::invalid_argument("invalid range");
- std::reverse(self->begin()+index, self->begin()+index+count);
+ std::reverse($self->begin()+index, $self->begin()+index+count);
}
// Takes a deep copy of the elements unlike ArrayList.SetRange
void SetRange(int index, const std::vector<CTYPE >& values) throw (std::out_of_range) {
if (index < 0)
throw std::out_of_range("index");
- if (index+values.size() > self->size())
+ if (index+values.size() > $self->size())
throw std::out_of_range("index");
- std::copy(values.begin(), values.end(), self->begin()+index);
+ std::copy(values.begin(), values.end(), $self->begin()+index);
}
}
%enddef
+%define SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE...)
+SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, CSTYPE, CTYPE)
+%enddef
+
// Extra methods added to the collection class if operator== is defined for the class being wrapped
// CSTYPE and CTYPE respectively correspond to the types in the cstype and ctype typemaps
+// The class will then implement IList<>, which adds extra functionality
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE...)
%extend {
bool Contains(const value_type& value) {
- return std::find(self->begin(), self->end(), value) != self->end();
+ return std::find($self->begin(), $self->end(), value) != $self->end();
}
int IndexOf(const value_type& value) {
int index = -1;
- std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value);
- if (it != self->end())
- index = (int)(it - self->begin());
+ std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
+ if (it != $self->end())
+ index = (int)(it - $self->begin());
return index;
}
int LastIndexOf(const value_type& value) {
int index = -1;
- std::vector<CTYPE >::reverse_iterator rit = std::find(self->rbegin(), self->rend(), value);
- if (rit != self->rend())
- index = (int)(self->rend() - 1 - rit);
+ std::vector<CTYPE >::reverse_iterator rit = std::find($self->rbegin(), $self->rend(), value);
+ if (rit != $self->rend())
+ index = (int)($self->rend() - 1 - rit);
return index;
}
- void Remove(const value_type& value) {
- std::vector<CTYPE >::iterator it = std::find(self->begin(), self->end(), value);
- if (it != self->end())
- self->erase(it);
+ bool Remove(const value_type& value) {
+ std::vector<CTYPE >::iterator it = std::find($self->begin(), $self->end(), value);
+ if (it != $self->end()) {
+ $self->erase(it);
+ return true;
+ }
+ return false;
}
}
%enddef
@@ -320,7 +368,7 @@
%define SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE...)
namespace std {
template<> class vector<CTYPE > {
- SWIG_STD_VECTOR_MINIMUM(CSTYPE, CTYPE)
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, CSTYPE, CTYPE)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CSTYPE, CTYPE)
};
}
@@ -334,7 +382,6 @@ namespace std {
}
%enddef
-
%{
#include <vector>
#include <algorithm>
@@ -361,11 +408,15 @@ namespace std {
template<class T> class vector<const T*> {
SWIG_STD_VECTOR_MINIMUM(T, const T*)
};
+ // bool is a bit different in the C++ standard
+ template<> class vector<bool> {
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, bool, bool, bool)
+ SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool, bool)
+ };
}
// template specializations for std::vector
// these provide extra collections methods as operator== is defined
-SWIG_STD_VECTOR_SPECIALIZE(bool, bool)
SWIG_STD_VECTOR_SPECIALIZE(char, char)
SWIG_STD_VECTOR_SPECIALIZE(sbyte, signed char)
SWIG_STD_VECTOR_SPECIALIZE(byte, unsigned char)
@@ -381,4 +432,3 @@ SWIG_STD_VECTOR_SPECIALIZE(float, float)
SWIG_STD_VECTOR_SPECIALIZE(double, double)
SWIG_STD_VECTOR_SPECIALIZE(string, std::string) // also requires a %include <std_string.i>
-
diff --git a/Lib/csharp/std_wstring.i b/Lib/csharp/std_wstring.i
index 938070e4b..938070e4b 100755..100644
--- a/Lib/csharp/std_wstring.i
+++ b/Lib/csharp/std_wstring.i
diff --git a/Lib/csharp/typemaps.i b/Lib/csharp/typemaps.i
index ddfbd1b0c..56cc6cb61 100644
--- a/Lib/csharp/typemaps.i
+++ b/Lib/csharp/typemaps.i
@@ -192,6 +192,10 @@ OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR)
#undef OUTPUT_TYPEMAP
+%typemap(in) bool *OUTPUT, bool &OUTPUT
+%{ *$input = 0;
+ $1 = ($1_ltype)$input; %}
+
/*
INOUT typemaps
diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i
index be87560c3..be87560c3 100755..100644
--- a/Lib/csharp/wchar.i
+++ b/Lib/csharp/wchar.i
diff --git a/Lib/intrusive_ptr.i b/Lib/intrusive_ptr.i
new file mode 100644
index 000000000..43e78f986
--- /dev/null
+++ b/Lib/intrusive_ptr.i
@@ -0,0 +1,95 @@
+// Allow for different namespaces for shared_ptr / intrusive_ptr - they could be boost or std or std::tr1
+// For example for std::tr1, use:
+// #define SWIG_SHARED_PTR_NAMESPACE std
+// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
+// #define SWIG_INTRUSIVE_PTR_NAMESPACE boost
+// #define SWIG_INTRUSIVE_PTR_SUBNAMESPACE
+
+#if !defined(SWIG_INTRUSIVE_PTR_NAMESPACE)
+# define SWIG_INTRUSIVE_PTR_NAMESPACE boost
+#endif
+
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE::SWIG_INTRUSIVE_PTR_SUBNAMESPACE
+#else
+# define SWIG_INTRUSIVE_PTR_QNAMESPACE SWIG_INTRUSIVE_PTR_NAMESPACE
+#endif
+
+namespace SWIG_INTRUSIVE_PTR_NAMESPACE {
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+ namespace SWIG_INTRUSIVE_PTR_SUBNAMESPACE {
+#endif
+ template <class T> class intrusive_ptr {
+ };
+#if defined(SWIG_INTRUSIVE_PTR_SUBNAMESPACE)
+ }
+#endif
+}
+
+%fragment("SWIG_intrusive_deleter", "header") {
+template<class T> struct SWIG_intrusive_deleter {
+ void operator()(T *p) {
+ if (p)
+ intrusive_ptr_release(p);
+ }
+};
+}
+
+%fragment("SWIG_null_deleter", "header") {
+struct SWIG_null_deleter {
+ void operator() (void const *) const {
+ }
+};
+%#define SWIG_NO_NULL_DELETER_0 , SWIG_null_deleter()
+%#define SWIG_NO_NULL_DELETER_1
+}
+
+// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
+// For plain classes, do not use for derived classes
+%define SWIG_INTRUSIVE_PTR(PROXYCLASS, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%enddef
+
+// Main user macro for defining intrusive_ptr typemaps for both const and non-const pointer types
+// For derived classes
+%define SWIG_INTRUSIVE_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+ %}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
+// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
+// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
+// For plain classes, do not use for derived classes
+%define SWIG_INTRUSIVE_PTR_NO_WRAP(PROXYCLASS, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
+%enddef
+
+// Extra user macro for including classes in intrusive_ptr typemaps for both const and non-const pointer types
+// This caters for classes which cannot be wrapped by intrusive_ptrs but are still part of the class hierarchy
+// For derived classes
+%define SWIG_INTRUSIVE_PTR_DERIVED_NO_WRAP(PROXYCLASS, BASECLASSTYPE, TYPE...)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, , TYPE)
+SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, const, TYPE)
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+ *newmemory = SWIG_CAST_NEW_MEMORY;
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+%}
+%extend TYPE {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ return swigSharedPtrUpcast;
+ }
+}
+%enddef
+
+
diff --git a/Lib/java/boost_intrusive_ptr.i b/Lib/java/boost_intrusive_ptr.i
new file mode 100644
index 000000000..48f6c317b
--- /dev/null
+++ b/Lib/java/boost_intrusive_ptr.i
@@ -0,0 +1,460 @@
+%include <intrusive_ptr.i>
+
+%define SWIG_INTRUSIVE_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
+
+%naturalvar TYPE;
+%naturalvar SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
+
+// destructor mods
+%feature("unref") TYPE "(void)arg1; delete smartarg1;"
+
+
+%typemap(in) CONST TYPE ($&1_type argp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // plain value
+ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
+ if (!argp) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
+ return $null;
+ }
+ $1 = *argp;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") CONST TYPE %{
+ //plain value(out)
+ $1_ltype* resultp = new $1_ltype(($1_ltype &)$1);
+ intrusive_ptr_add_ref(resultp);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(resultp, SWIG_intrusive_deleter< CONST TYPE >());
+%}
+
+%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // plain pointer
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0);
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE * %{
+ //plain pointer(out)
+ #if ($owner)
+ if ($1) {
+ intrusive_ptr_add_ref($1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ #endif
+%}
+
+%typemap(in) CONST TYPE & (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // plain reference
+ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ if(!$1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
+ return $null;
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE & %{
+ //plain reference(out)
+ #if ($owner)
+ if ($1) {
+ intrusive_ptr_add_ref($1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ #endif
+%}
+
+%typemap(in) CONST TYPE *& ($*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ // plain pointer by reference
+ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ $1 = &temp;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter,SWIG_null_deleter") CONST TYPE *& %{
+ // plain pointer by reference(out)
+ #if ($owner)
+ if (*$1) {
+ intrusive_ptr_add_ref(*$1);
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1, SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ #else
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_0);
+ #endif
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > ($&1_type argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by value
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ if (smartarg) {
+ $1 = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > %{
+ if ($1) {
+ intrusive_ptr_add_ref(result.get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(result.get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
+ // shared_ptr by value
+ smartarg = *($&1_ltype*)&$input;
+ if (smartarg) $1 = *smartarg;
+%}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
+ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by reference
+ if ( $input ) {
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ $1 = &temp;
+ } else {
+ $1 = &tempnull;
+ }
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
+ delete &($1);
+ if ($self) {
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * temp = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
+ $1 = *temp;
+ }
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & %{
+ if (*$1) {
+ intrusive_ptr_add_ref($1->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * ($*1_ltype tempnull, $*1_ltype temp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by pointer
+ if ( $input ) {
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ $1 = &temp;
+ } else {
+ $1 = &tempnull;
+ }
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
+ delete $1;
+ if ($self) $1 = new SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(*$input);
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * %{
+ if ($1 && *$1) {
+ intrusive_ptr_add_ref($1->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+ if ($owner) delete $1;
+%}
+
+%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& (SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > temp, $*1_ltype tempp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * smartarg) %{
+ // intrusive_ptr by pointer reference
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >**)&$input;
+ if ($input) {
+ temp = SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >(smartarg->get(), true);
+ }
+ tempp = &temp;
+ $1 = &tempp;
+%}
+%typemap(memberin) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
+ if ($self) $1 = *$input;
+%}
+%typemap(out, fragment="SWIG_intrusive_deleter") SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& %{
+ if (*$1 && **$1) {
+ intrusive_ptr_add_ref((*$1)->get());
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >((*$1)->get(), SWIG_intrusive_deleter< CONST TYPE >());
+ } else {
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = 0;
+ }
+%}
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%typemap (jni) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "jlong"
+%typemap (jtype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "long"
+%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS"
+%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > &,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *,
+ SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& "PROXYCLASS.getCPtr($javainput)"
+
+%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > & {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > * {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+%typemap(javaout) SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE > *& {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+
+
+%typemap(javaout) CONST TYPE {
+ return new PROXYCLASS($jnicall, true);
+ }
+%typemap(javaout) CONST TYPE & {
+ return new PROXYCLASS($jnicall, true);
+ }
+%typemap(javaout) CONST TYPE * {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+%typemap(javaout) CONST TYPE *& {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+
+// Base proxy classes
+%typemap(javabody) TYPE %{
+ private long swigCPtr;
+ private boolean swigCMemOwnBase;
+
+ protected $javaclassname(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(javabody_derived) TYPE %{
+ private long swigCPtr;
+ private boolean swigCMemOwnDerived;
+
+ protected $javaclassname(long cPtr, boolean cMemoryOwn) {
+ super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
+ if(swigCPtr != 0 && swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
+ }
+
+%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
+ if(swigCPtr != 0 && swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
+ super.delete();
+ }
+
+// CONST version needed ???? also for C#
+%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
+%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%template() SWIG_INTRUSIVE_PTR_QNAMESPACE::intrusive_ptr< CONST TYPE >;
+%enddef
+
+
+/////////////////////////////////////////////////////////////////////
+
+
+%include <shared_ptr.i>
+
+%define SWIG_INTRUSIVE_PTR_TYPEMAPS_NO_WRAP(PROXYCLASS, CONST, TYPE...)
+
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor mods
+%feature("unref") TYPE "(void)arg1; delete smartarg1;"
+
+
+// plain value
+%typemap(in) CONST TYPE ($&1_type argp = 0) %{
+ argp = (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0;
+ if (!argp) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
+ return $null;
+ }
+ $1 = *argp; %}
+%typemap(out) CONST TYPE
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
+
+// plain pointer
+%typemap(in) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ smartarg = *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
+ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+%}
+
+// plain reference
+%typemap(in) CONST TYPE & %{
+ $1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ if (!$1) {
+ SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
+ return $null;
+ } %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
+
+// plain pointer by reference
+%typemap(in) CONST TYPE *& ($*1_ltype temp = 0)
+%{ temp = ((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
+ $1 = &temp; %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE *&
+%{ *(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
+
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast ($&1_type smartarg) %{
+ // shared_ptr by value
+ smartarg = *($&1_ltype*)&$input;
+ if (smartarg) $1 = *smartarg;
+%}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > ANY_TYPE_SWIGSharedPtrUpcast %{
+ *($&1_ltype*)&$result = $1 ? new $1_ltype($1) : 0;
+%}
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%typemap (jni) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "jlong"
+%typemap (jtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "long"
+%typemap (jstype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS"
+%typemap (javain) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > "PROXYCLASS.getCPtr($javainput)"
+%typemap(javaout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+
+%typemap(javaout) CONST TYPE {
+ return new PROXYCLASS($jnicall, true);
+ }
+%typemap(javaout) CONST TYPE & {
+ return new PROXYCLASS($jnicall, true);
+ }
+%typemap(javaout) CONST TYPE * {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+%typemap(javaout) CONST TYPE *& {
+ long cPtr = $jnicall;
+ return (cPtr == 0) ? null : new PROXYCLASS(cPtr, true);
+ }
+
+// Base proxy classes
+%typemap(javabody) TYPE %{
+ private long swigCPtr;
+ private boolean swigCMemOwnBase;
+
+ protected $javaclassname(long cPtr, boolean cMemoryOwn) {
+ swigCMemOwnBase = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+// Derived proxy classes
+%typemap(javabody_derived) TYPE %{
+ private long swigCPtr;
+ private boolean swigCMemOwnDerived;
+
+ protected $javaclassname(long cPtr, boolean cMemoryOwn) {
+ super($imclassname.$javaclassname_SWIGSharedPtrUpcast(cPtr), true);
+ swigCMemOwnDerived = cMemoryOwn;
+ swigCPtr = cPtr;
+ }
+
+ protected static long getCPtr($javaclassname obj) {
+ return (obj == null) ? 0 : obj.swigCPtr;
+ }
+%}
+
+%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
+ if (swigCPtr != 0) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
+ }
+ }
+
+%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
+ if (swigCPtr != 0) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
+ }
+ super.delete();
+ }
+
+// CONST version needed ???? also for C#
+%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast "long"
+%typemap(jtype, nopgcpp="1") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > swigSharedPtrUpcast "long"
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%enddef
+
diff --git a/Lib/java/boost_shared_ptr.i b/Lib/java/boost_shared_ptr.i
index 1f555bf85..75762f84f 100644
--- a/Lib/java/boost_shared_ptr.i
+++ b/Lib/java/boost_shared_ptr.i
@@ -33,7 +33,7 @@
// plain reference
%typemap(in) CONST TYPE & %{
$1 = ($1_ltype)((*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input) ? (*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > **)&$input)->get() : 0);
- if(!$1) {
+ if (!$1) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
return $null;
} %}
@@ -166,19 +166,23 @@
%}
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") TYPE {
- if(swigCPtr != 0 && swigCMemOwnBase) {
- swigCMemOwnBase = false;
- $jnicall;
+ if (swigCPtr != 0) {
+ if (swigCMemOwnBase) {
+ swigCMemOwnBase = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
}
- swigCPtr = 0;
}
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") TYPE {
- if(swigCPtr != 0 && swigCMemOwnDerived) {
- swigCMemOwnDerived = false;
- $jnicall;
+ if (swigCPtr != 0) {
+ if (swigCMemOwnDerived) {
+ swigCMemOwnDerived = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
}
- swigCPtr = 0;
super.delete();
}
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 7d1808632..bd2357a86 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -364,7 +364,7 @@
}
%typemap(freearg, noblock=1) char * { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
-%typemap(out, noblock=1) char * { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
+%typemap(out, noblock=1) char * { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
%typemap(javadirectorin) char * "$jniinput"
%typemap(javadirectorout) char * "$javacall"
@@ -378,7 +378,7 @@
$1 = &temp;
}
%typemap(freearg, noblock=1) char *& { if ($1 && *$1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)*$1); }
-%typemap(out, noblock=1) char *& { if(*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); }
+%typemap(out, noblock=1) char *& { if (*$1) $result = JCALL1(NewStringUTF, jenv, (const char *)*$1); }
%typemap(out) void ""
%typemap(javadirectorin) void "$jniinput"
@@ -597,7 +597,7 @@
/* Generic pointers and references */
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
- if(!$1) {
+ if (!$1) {
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
return $null;
} %}
@@ -656,7 +656,7 @@
%typemap(argout) char[ANY], char[] ""
%typemap(freearg, noblock=1) char[ANY], char[] { if ($1) JCALL2(ReleaseStringUTFChars, jenv, $input, (const char *)$1); }
-%typemap(out, noblock=1) char[ANY], char[] { if($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
+%typemap(out, noblock=1) char[ANY], char[] { if ($1) $result = JCALL1(NewStringUTF, jenv, (const char *)$1); }
%typemap(javadirectorin) char[ANY], char[] "$jniinput"
%typemap(javadirectorout) char[ANY], char[] "$javacall"
@@ -1148,19 +1148,23 @@ SWIG_PROXY_CONSTRUCTOR(true, false, TYPENAME)
SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
%typemap(javadestruct, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
- if(swigCPtr != 0 && swigCMemOwn) {
- swigCMemOwn = false;
- $jnicall;
+ if (swigCPtr != 0) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
}
- swigCPtr = 0;
}
%typemap(javadestruct_derived, methodname="delete", methodmodifiers="public synchronized") SWIGTYPE {
- if(swigCPtr != 0 && swigCMemOwn) {
- swigCMemOwn = false;
- $jnicall;
+ if (swigCPtr != 0) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $jnicall;
+ }
+ swigCPtr = 0;
}
- swigCPtr = 0;
super.delete();
}
@@ -1191,7 +1195,8 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
#define %javaenum(wrapapproach) %feature("java:enum","wrapapproach")
#define %javamethodmodifiers %feature("java:methodmodifiers")
#define %javaexception(exceptionclasses) %feature("except",throws=exceptionclasses)
-#define %nojavaexception %feature("except","",throws="")
+#define %nojavaexception %feature("except","0",throws="")
+#define %clearjavaexception %feature("except","",throws="")
%pragma(java) jniclassclassmodifiers="class"
%pragma(java) moduleclassmodifiers="public class"
diff --git a/Lib/java/javahead.swg b/Lib/java/javahead.swg
index 4aa0c84b5..7626bf50d 100644
--- a/Lib/java/javahead.swg
+++ b/Lib/java/javahead.swg
@@ -34,7 +34,7 @@
%insert(runtime) %{
/* Fix for jlong on some versions of gcc on Windows */
-#if defined(__GNUC__) && !defined(__INTELC__)
+#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
typedef long long __int64;
#endif
@@ -83,7 +83,8 @@ static void SWIGUNUSED SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionC
{ SWIG_JavaNullPointerException, "java/lang/NullPointerException" },
{ SWIG_JavaDirectorPureVirtual, "java/lang/RuntimeException" },
{ SWIG_JavaUnknownError, "java/lang/UnknownError" },
- { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } };
+ { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" }
+ };
const SWIG_JavaExceptions_t *except_ptr = java_exceptions;
while (except_ptr->code != code && except_ptr->code)
diff --git a/Lib/java/std_vector.i b/Lib/java/std_vector.i
index 92fa25ac2..29439606b 100644
--- a/Lib/java/std_vector.i
+++ b/Lib/java/std_vector.i
@@ -46,6 +46,40 @@ namespace std {
}
}
};
+
+ // bool specialization
+ template<> class vector<bool> {
+ public:
+ typedef size_t size_type;
+ typedef bool value_type;
+ typedef bool const_reference;
+ vector();
+ vector(size_type n);
+ size_type size() const;
+ size_type capacity() const;
+ void reserve(size_type n);
+ %rename(isEmpty) empty;
+ bool empty() const;
+ void clear();
+ %rename(add) push_back;
+ void push_back(const value_type& x);
+ %extend {
+ const_reference get(int i) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i>=0 && i<size)
+ return (*self)[i];
+ else
+ throw std::out_of_range("vector index out of range");
+ }
+ void set(int i, const value_type& val) throw (std::out_of_range) {
+ int size = int(self->size());
+ if (i>=0 && i<size)
+ (*self)[i] = val;
+ else
+ throw std::out_of_range("vector index out of range");
+ }
+ }
+ };
}
%define specialize_std_vector(T)
diff --git a/Lib/lua/luatypemaps.swg b/Lib/lua/luatypemaps.swg
index 0941c9da1..caa2a6ce1 100644
--- a/Lib/lua/luatypemaps.swg
+++ b/Lib/lua/luatypemaps.swg
@@ -20,11 +20,15 @@
to reflect the number of values returned (normally SWIG_arg++; will do)
*/
// numbers
-%typemap(in,checkfn="lua_isnumber") int,short,long,
- unsigned int,unsigned short,unsigned long,
- signed char,unsigned char,
- float,double
+%typemap(in,checkfn="lua_isnumber") int, short, long,
+ signed char, float, double
%{$1 = ($type)lua_tonumber(L, $input);%}
+
+// additional check for unsigned numbers, to not permit negative input
+%typemap(in,checkfn="lua_isnumber") unsigned int,
+ unsigned short, unsigned long, unsigned char
+%{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative")
+$1 = ($type)lua_tonumber(L, $input);%}
%typemap(out) int,short,long,
unsigned int,unsigned short,unsigned long,
@@ -41,15 +45,20 @@
%typemap(in,checkfn="lua_isnumber") const int&($basetype temp)
%{ temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
-%typemap(out) const int&
+%typemap(in,checkfn="lua_isnumber") const unsigned int&($basetype temp)
+%{SWIG_contract_assert((lua_tonumber(L,$input)>=0),"number must not be negative")
+temp=($basetype)lua_tonumber(L,$input); $1=&temp;%}
+
+%typemap(out) const int&, const unsigned int&
%{ lua_pushnumber(L, (lua_Number) *$1); SWIG_arg++;%}
// for the other numbers we can just use an apply statement to cover them
-%apply const int & {const short&,const long&,
- const unsigned int&,const unsigned short&,const unsigned long&,
- const signed char&,const unsigned char&,
+%apply const int & {const short&,const long&,const signed char&,
const float&,const double&};
+%apply const unsigned int & {const unsigned short&,const unsigned long&,
+ const unsigned char&};
+
/* enums have to be handled slightly differently
VC++ .net will not allow a cast from lua_Number(double) to enum directly.
*/
diff --git a/Lib/ocaml/std_deque.i b/Lib/ocaml/std_deque.i
index 44815ebda..baadb4e53 100644
--- a/Lib/ocaml/std_deque.i
+++ b/Lib/ocaml/std_deque.i
@@ -28,4 +28,4 @@
}
};
-%include <_std_deque.i>
+%include <std/_std_deque.i>
diff --git a/Lib/octave/carrays.i b/Lib/octave/carrays.i
index 454762aa1..014de37ff 100644
--- a/Lib/octave/carrays.i
+++ b/Lib/octave/carrays.i
@@ -1,5 +1,5 @@
%define %array_class(TYPE,NAME)
- %array_class_wrap(TYPE,NAME,__paren,__paren_asgn)
+ %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
%enddef
%include <typemaps/carrays.swg>
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index bb1122a7b..afc3ed147 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -204,7 +204,7 @@ namespace swig
operator T () const
{
- // swig::PyObject_var item = OctSequence_GetItem(_seq, _index);
+ // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, _index);
octave_value item; // * todo
try {
return swig::as<T>(item, true);
@@ -410,7 +410,7 @@ namespace swig
{
int s = size();
for (int i = 0; i < s; ++i) {
- // swig::PyObject_var item = OctSequence_GetItem(_seq, i);
+ // swig::SwigVar_PyObject item = OctSequence_GetItem(_seq, i);
octave_value item; // * todo
if (!swig::check<value_type>(item)) {
if (set_err) {
@@ -453,7 +453,7 @@ namespace swig
$result = Cell(tmpc);
}
- %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {}
+ %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="OctSequence_Cont") {}
%typemap(out,fragment="OctPairBoolOutputIterator")
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
@@ -513,11 +513,11 @@ namespace swig
return x;
}
- value_type __paren(difference_type i) throw (std::out_of_range) {
+ value_type __paren__(difference_type i) throw (std::out_of_range) {
return *(swig::cgetpos(self, i));
}
- void __paren_asgn(difference_type i, value_type x) throw (std::out_of_range) {
+ void __paren_asgn__(difference_type i, value_type x) throw (std::out_of_range) {
*(swig::getpos(self,i)) = x;
}
diff --git a/Lib/octave/octopers.swg b/Lib/octave/octopers.swg
index a9ccf44b8..c38e64d8c 100644
--- a/Lib/octave/octopers.swg
+++ b/Lib/octave/octopers.swg
@@ -6,68 +6,68 @@
// operators supported in Octave, and the methods they are routed to
-// __brace a{args}
-// __brace_asgn a{args} = rhs
-// __paren a(args)
-// __paren_asgn a(args) = rhs
-// __str generates string rep
+// __brace__ a{args}
+// __brace_asgn__ a{args} = rhs
+// __paren__ a(args)
+// __paren_asgn__ a(args) = rhs
+// __str__ generates string rep
-// __not !a
-// __uplus +a
-// __uminus -a
-// __transpose a.'
-// __hermitian a'
-// __incr a++
-// __decr a--
-// __add a + b
-// __sub a - b
-// __mul a * b
-// __div a / b
-// __pow a ^ b
-// __ldiv a \ b
-// __lshift a << b
-// __rshift a >> b
-// __lt a < b
-// __le a <= b
-// __eq a == b
-// __ge a >= b
-// __gt a > b
-// __ne a != b
-// __el_mul a .* b
-// __el_div a ./ b
-// __el_pow a .^ b
-// __el_ldiv a .\ b
-// __el_and a & b
-// __el_or a | b
+// __not__ !a
+// __uplus__ +a
+// __uminus__ -a
+// __transpose__ a.'
+// __hermitian__ a'
+// __incr__ a++
+// __decr__ a--
+// __add__ a + b
+// __sub__ a - b
+// __mul__ a * b
+// __div__ a / b
+// __pow__ a ^ b
+// __ldiv__ a \ b
+// __lshift__ a << b
+// __rshift__ a >> b
+// __lt__ a < b
+// __le__ a <= b
+// __eq__ a == b
+// __ge__ a >= b
+// __gt__ a > b
+// __ne__ a != b
+// __el_mul__ a .* b
+// __el_div__ a ./ b
+// __el_pow__ a .^ b
+// __el_ldiv__ a .\ b
+// __el_and__ a & b
+// __el_or__ a | b
// operators supported in C++, and the methods that route to them
-%rename(__add) *::operator+;
-%rename(__add) *::operator+();
-%rename(__add) *::operator+() const;
-%rename(__sub) *::operator-;
-%rename(__uminus) *::operator-();
-%rename(__uminus) *::operator-() const;
-%rename(__mul) *::operator*;
-%rename(__div) *::operator/;
-%rename(__mod) *::operator%;
-%rename(__lshift) *::operator<<;
-%rename(__rshift) *::operator>>;
-%rename(__el_and) *::operator&&;
-%rename(__el_or) *::operator||;
-%rename(__xor) *::operator^;
-%rename(__invert) *::operator~;
-%rename(__lt) *::operator<;
-%rename(__le) *::operator<=;
-%rename(__gt) *::operator>;
-%rename(__ge) *::operator>=;
-%rename(__eq) *::operator==;
-%rename(__ne) *::operator!=;
-%rename(__not) *::operator!;
-%rename(__incr) *::operator++;
-%rename(__decr) *::operator--;
-%rename(__paren) *::operator();
-%rename(__brace) *::operator[];
+%rename(__add__) *::operator+;
+%rename(__add__) *::operator+();
+%rename(__add__) *::operator+() const;
+%rename(__sub__) *::operator-;
+%rename(__uminus__) *::operator-();
+%rename(__uminus__) *::operator-() const;
+%rename(__mul__) *::operator*;
+%rename(__div__) *::operator/;
+%rename(__mod__) *::operator%;
+%rename(__lshift__) *::operator<<;
+%rename(__rshift__) *::operator>>;
+%rename(__el_and__) *::operator&&;
+%rename(__el_or__) *::operator||;
+%rename(__xor__) *::operator^;
+%rename(__invert__) *::operator~;
+%rename(__lt__) *::operator<;
+%rename(__le__) *::operator<=;
+%rename(__gt__) *::operator>;
+%rename(__ge__) *::operator>=;
+%rename(__eq__) *::operator==;
+%rename(__ne__) *::operator!=;
+%rename(__not__) *::operator!;
+%rename(__incr__) *::operator++;
+%rename(__decr__) *::operator--;
+%rename(__paren__) *::operator();
+%rename(__brace__) *::operator[];
// Ignored inplace operators
%ignoreoperator(PLUSEQ) operator+=;
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index 07aa47cb5..c48310e27 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -589,7 +589,7 @@ namespace Swig {
// index operator
else {
if (ops[skip] == '(' || ops[skip] == '{') {
- const char *op_name = ops[skip] == '(' ? "__paren" : "__brace";
+ const char *op_name = ops[skip] == '(' ? "__paren__" : "__brace__";
octave_value_list args;
args.append(*idx_it++);
++skip;
@@ -628,7 +628,7 @@ namespace Swig {
}
else if (ops[skip] == '(' || ops[skip] == '{') {
- const char *op_name = ops[skip] == '(' ? "__paren_asgn" : "__brace_asgn";
+ const char *op_name = ops[skip] == '(' ? "__paren_asgn__" : "__brace_asgn__";
member_value_pair *m = find_member(op_name, false);
if (m) {
octave_value_list args;
@@ -666,40 +666,27 @@ namespace Swig {
virtual bool is_string() const {
octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
- return !!nc_this->find_member("__str", false);
+ return !!nc_this->find_member("__str__", false);
}
virtual std::string string_value(bool force = false) const {
octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
- member_value_pair *m = nc_this->find_member("__str", false);
+ member_value_pair *m = nc_this->find_member("__str__", false);
if (!m) {
- error("__str method not defined");
+ error("__str__ method not defined");
return std::string();
}
octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1);
if (outarg.length() < 1 || !outarg(0).is_string()) {
- error("__str method did not return a string");
+ error("__str__ method did not return a string");
return std::string();
}
return outarg(0).string_value();
}
- /*
virtual Octave_map map_value() const {
- octave_swig_type *nc_this = const_cast < octave_swig_type *>(this);
- member_value_pair *m = nc_this->find_member("__str", false);
- if (!m) {
- error("__map method not defined");
- return std::string();
- }
- octave_value_list outarg = nc_this->member_invoke(m, octave_value_list(nc_this->as_value()), 1);
- if (outarg.length() < 1 || !outarg(0).is_map()) {
- error("__map method did not return a string");
- return std::string();
- }
- return outarg(0).map_value();
+ return Octave_map();
}
- */
virtual string_vector map_keys() const {
member_map tmp;
@@ -713,6 +700,35 @@ namespace Swig {
return keys;
}
+ virtual bool save_ascii (std::ostream& os) {
+ return true;
+ }
+
+ virtual bool load_ascii (std::istream& is) {
+ return true;
+ }
+
+ virtual bool save_binary (std::ostream& os, bool& save_as_floats) {
+ return true;
+ }
+
+ virtual bool load_binary (std::istream& is, bool swap,
+ oct_mach_info::float_format fmt) {
+ return true;
+ }
+
+#if defined (HAVE_HDF5)
+ virtual bool
+ save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) {
+ return true;
+ }
+
+ virtual bool
+ load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) {
+ return true;
+ }
+#endif
+
virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const {
return string_value();
}
@@ -737,7 +753,7 @@ namespace Swig {
assert(ost);
octave_value ret;
- if (ost->dispatch_unary_op(std::string("__") + op_name, ret))
+ if (ost->dispatch_unary_op(std::string("__") + op_name + std::string("__"), ret))
return ret;
std::string symbol = "op_" + ost->swig_type_name() + "_" + op_name;
octave_value_list args;
@@ -754,7 +770,7 @@ namespace Swig {
octave_swig_type *rhs_ost = Swig::swig_value_deref(rhs);
octave_value ret;
- if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name, rhs, ret))
+ if (lhs_ost && lhs_ost->dispatch_binary_op(std::string("__") + op_name + std::string("__"), rhs, ret))
return ret;
std::string symbol;
@@ -876,9 +892,35 @@ namespace Swig {
virtual std::string string_value(bool force = false) const
{ return ptr->string_value(force); }
+ virtual Octave_map map_value() const
+ { return ptr->map_value(); }
+
virtual string_vector map_keys() const
{ return ptr->map_keys(); }
+ virtual bool save_ascii (std::ostream& os)
+ { return ptr->save_ascii(os); }
+
+ virtual bool load_ascii (std::istream& is)
+ { return ptr->load_ascii(is); }
+
+ virtual bool save_binary (std::ostream& os, bool& save_as_floats)
+ { return ptr->save_binary(os, save_as_floats); }
+
+ virtual bool load_binary (std::istream& is, bool swap,
+ oct_mach_info::float_format fmt)
+ { return ptr->load_binary(is, swap, fmt); }
+
+#if defined (HAVE_HDF5)
+ virtual bool
+ save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats)
+ { return ptr->save_hdf5(loc_id, name, save_as_floats); }
+
+ virtual bool
+ load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug)
+ { return ptr->load_hdf5(loc_id, name, have_h5giterate_bug); }
+#endif
+
virtual octave_value convert_to_str(bool pad = false, bool force = false, char type = '"') const
{ return ptr->convert_to_str(pad, force, type); }
@@ -927,6 +969,37 @@ namespace Swig {
void print(std::ostream &os, bool pr_as_read_syntax = false) const {
os << "swig packed type: name = " << (type ? type->name : std::string()) << ", len = " << buf.size() << std::endl;
}
+
+
+ virtual bool save_ascii (std::ostream& os) {
+ return true;
+ }
+
+ virtual bool load_ascii (std::istream& is) {
+ return true;
+ }
+
+ virtual bool save_binary (std::ostream& os, bool& save_as_floats) {
+ return true;
+ }
+
+ virtual bool load_binary (std::istream& is, bool swap,
+ oct_mach_info::float_format fmt) {
+ return true;
+ }
+
+#if defined (HAVE_HDF5)
+ virtual bool
+ save_hdf5 (hid_t loc_id, const char *name, bool save_as_floats) {
+ return true;
+ }
+
+ virtual bool
+ load_hdf5 (hid_t loc_id, const char *name, bool have_h5giterate_bug) {
+ return true;
+ }
+#endif
+
private:
DECLARE_OCTAVE_ALLOCATOR;
DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA;
diff --git a/Lib/octave/octruntime.swg b/Lib/octave/octruntime.swg
index dd68ca4c1..82a17285a 100644
--- a/Lib/octave/octruntime.swg
+++ b/Lib/octave/octruntime.swg
@@ -3,6 +3,7 @@
#include <octave/parse.h>
#include <octave/ov-fcn-handle.h>
#include <octave/Cell.h>
+#include <octave/oct-map.h>
%}
%insert(runtime) "swigrun.swg";
diff --git a/Lib/octave/octstdcommon.swg b/Lib/octave/octstdcommon.swg
index e69c7e629..96923f40a 100644
--- a/Lib/octave/octstdcommon.swg
+++ b/Lib/octave/octstdcommon.swg
@@ -42,7 +42,7 @@ namespace swig {
struct traits_asptr {
static int asptr(const octave_value& obj, Type **val) {
Type *p;
- int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0;
+ int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
diff --git a/Lib/octave/std_basic_string.i b/Lib/octave/std_basic_string.i
index f2dac405a..9fc0b0730 100644
--- a/Lib/octave/std_basic_string.i
+++ b/Lib/octave/std_basic_string.i
@@ -1,5 +1,6 @@
#if !defined(SWIG_STD_STRING)
#define SWIG_STD_BASIC_STRING
+#define SWIG_STD_MODERN_STL
%include <octcontainer.swg>
@@ -9,39 +10,22 @@
%fragment(SWIG_AsPtr_frag(std::basic_string<char>),"header",
fragment="SWIG_AsCharPtrAndSize") {
SWIGINTERN int
-SWIG_AsPtr(std::basic_string<char>)(PyObject* obj, std::string **val)
+SWIG_AsPtr(std::basic_string<char>)(octave_value obj, std::string **val)
{
- static swig_type_info* string_info =
- SWIG_TypeQuery("std::basic_string<char> *");
- std::string *vptr;
- if (SWIG_ConvertPtr(obj, (void**)&vptr, string_info, 0) == SWIG_OK) {
- if (val) *val = vptr;
- return SWIG_OLDOBJ;
- } else {
- PyErr_Clear();
- char* buf = 0 ; size_t size = 0; int alloc = 0;
- if (SWIG_AsCharPtrAndSize(obj, &buf, &size, &alloc) == SWIG_OK) {
- if (buf) {
- if (val) *val = new std::string(buf, size - 1);
- if (alloc == SWIG_NEWOBJ) %delete_array(buf);
- return SWIG_NEWOBJ;
- }
- } else {
- PyErr_Clear();
- }
- if (val) {
- SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- PyErr_SetString(PyExc_TypeError,"a string is expected");
- SWIG_PYTHON_THREAD_END_BLOCK;
- }
- return 0;
+ if (obj.is_string()) {
+ if (val)
+ *val = new std::string(obj.string_value());
+ return SWIG_NEWOBJ;
}
-}
+ if (val)
+ error("a string is expected");
+ return 0;
+}
}
%fragment(SWIG_From_frag(std::basic_string<char>),"header",
fragment="SWIG_FromCharPtrAndSize") {
-SWIGINTERNINLINE PyObject*
+SWIGINTERNINLINE octave_value
SWIG_From(std::basic_string<char>)(const std::string& s)
{
return SWIG_FromCharPtrAndSize(s.data(), s.size());
diff --git a/Lib/octave/std_carray.i b/Lib/octave/std_carray.i
index 1477479da..9e2338a61 100644
--- a/Lib/octave/std_carray.i
+++ b/Lib/octave/std_carray.i
@@ -17,7 +17,7 @@ namespace swig {
%extend std::carray {
%fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
- fragment="PySwigIterator_T",
+ fragment="SwigPyIterator_T",
fragment=SWIG_Traits_frag(_Type),
fragment="StdCarrayTraits") {
namespace swig {
@@ -36,7 +36,7 @@ namespace swig {
%typemap(out,noblock=1) iterator, const_iterator {
$result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
- swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
}
inline size_t __len__() const { return self->size(); }
@@ -46,7 +46,7 @@ namespace swig {
inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
- swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) {
+ swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
}
diff --git a/Lib/octave/std_map.i b/Lib/octave/std_map.i
index a54e5f753..20003df58 100644
--- a/Lib/octave/std_map.i
+++ b/Lib/octave/std_map.i
@@ -22,7 +22,7 @@
/*
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
- PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL);
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
@@ -58,8 +58,8 @@
}
PyObject *obj = PyDict_New();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
- swig::PyObject_var key = swig::from(i->first);
- swig::PyObject_var val = swig::from(i->second);
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
@@ -92,10 +92,10 @@
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
- struct OctMapIterator_T : PySwigIteratorClosed_T<OutIterator, ValueType, FromOper>
+ struct OctMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
{
OctMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, octave_value seq)
- : PySwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
+ : SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
};
@@ -112,7 +112,7 @@
};
template<typename OutIter>
- inline PySwigIterator*
+ inline SwigPyIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = octave_value())
{
return new OctMapKeyIterator_T<OutIter>(current, begin, end, seq);
@@ -130,7 +130,7 @@
template<typename OutIter>
- inline PySwigIterator*
+ inline SwigPyIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, octave_value seq = 0)
{
return new OctMapValueIterator_T<OutIter>(current, begin, end, seq);
diff --git a/Lib/perl5/noembed.h b/Lib/perl5/noembed.h
index a29de61f5..55c3752aa 100644
--- a/Lib/perl5/noembed.h
+++ b/Lib/perl5/noembed.h
@@ -91,3 +91,9 @@
#ifdef open
#undef open
#endif
+#ifdef readdir
+ #undef readdir
+#endif
+#ifdef bind
+ #undef bind
+#endif
diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg
index 54d098d9b..6fb2968f0 100644
--- a/Lib/perl5/perlrun.swg
+++ b/Lib/perl5/perlrun.swg
@@ -205,13 +205,32 @@ SWIG_Perl_TypeProxyName(const swig_type_info *type) {
}
}
+/* Identical to SWIG_TypeCheck, except for strcmp comparison */
SWIGRUNTIME swig_cast_info *
SWIG_TypeProxyCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0))
- || (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0))), ty);
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if ( (!iter->type->clientdata && (strcmp(iter->type->name, c) == 0)) ||
+ (iter->type->clientdata && (strcmp((char*)iter->type->clientdata, c) == 0)) ) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
}
-
/* Function for getting a pointer value */
SWIGRUNTIME int
diff --git a/Lib/perl5/perlstrings.swg b/Lib/perl5/perlstrings.swg
index 2083f0bba..242a9c967 100644
--- a/Lib/perl5/perlstrings.swg
+++ b/Lib/perl5/perlstrings.swg
@@ -6,6 +6,11 @@
SWIGINTERN int
SWIG_AsCharPtrAndSize(SV *obj, char** cptr, size_t* psize, int *alloc)
{
+ if (SvMAGICAL(obj)) {
+ SV *tmp = sv_newmortal();
+ SvSetSV(tmp, obj);
+ obj = tmp;
+ }
if (SvPOK(obj)) {
STRLEN len = 0;
char *cstr = SvPV(obj, len);
diff --git a/Lib/perl5/perltypemaps.swg b/Lib/perl5/perltypemaps.swg
index c17e410b9..a59f84689 100644
--- a/Lib/perl5/perltypemaps.swg
+++ b/Lib/perl5/perltypemaps.swg
@@ -43,6 +43,7 @@
/* Perl types */
#define SWIG_Object SV *
+#define VOID_Object sv_newmortal()
/* Perl $shadow flag */
#define %newpointer_flags $shadow
diff --git a/Lib/perl5/reference.i b/Lib/perl5/reference.i
index d3d745cfc..6f5eda518 100644
--- a/Lib/perl5/reference.i
+++ b/Lib/perl5/reference.i
@@ -202,6 +202,35 @@ as follows :
$1 = &dvalue;
}
+%typemap(typecheck) int *REFERENCE, int &REFERENCE,
+ short *REFERENCE, short &REFERENCE,
+ long *REFERENCE, long &REFERENCE,
+ signed char *REFERENCE, signed char &REFERENCE,
+ bool *REFERENCE, bool &REFERENCE
+{
+ $1 = SvROK($input) && SvIOK(SvRV($input));
+}
+%typemap(typecheck) double *REFERENCE, double &REFERENCE,
+ float *REFERENCE, float &REFERENCE
+{
+ $1 = SvROK($input);
+ if($1) {
+ SV *tmpsv = SvRV($input);
+ $1 = SvNOK(tmpsv) || SvIOK(tmpsv);
+ }
+}
+%typemap(typecheck) unsigned int *REFERENCE, unsigned int &REFERENCE,
+ unsigned short *REFERENCE, unsigned short &REFERENCE,
+ unsigned long *REFERENCE, unsigned long &REFERENCE,
+ unsigned char *REFERENCE, unsigned char &REFERENCE
+{
+ $1 = SvROK($input);
+ if($1) {
+ SV *tmpsv = SvRV($input);
+ $1 = SvUOK(tmpsv) || SvIOK(tmpsv);
+ }
+}
+
%typemap(argout) double *REFERENCE, double &REFERENCE,
float *REFERENCE, float &REFERENCE
{
@@ -214,7 +243,7 @@ as follows :
%typemap(argout) int *REFERENCE, int &REFERENCE,
short *REFERENCE, short &REFERENCE,
long *REFERENCE, long &REFERENCE,
- signed char *REFERENCE, unsigned char &REFERENCE,
+ signed char *REFERENCE, signed char &REFERENCE,
bool *REFERENCE, bool &REFERENCE
{
SV *tempsv;
diff --git a/Lib/perl5/std_vector.i b/Lib/perl5/std_vector.i
index b1f722d4b..7c4f72919 100644
--- a/Lib/perl5/std_vector.i
+++ b/Lib/perl5/std_vector.i
@@ -105,9 +105,9 @@ namespace std {
}
}
%typemap(out) vector<T> {
- int len = $1.size();
+ size_t len = $1.size();
SV **svs = new SV*[len];
- for (unsigned int i=0; i<len; i++) {
+ for (size_t i=0; i<len; i++) {
T* ptr = new T($1[i]);
svs[i] = sv_newmortal();
SWIG_MakePtr(svs[i], (void*) ptr,
diff --git a/Lib/php/globalvar.i b/Lib/php/globalvar.i
index a75b1a41e..df8cfade7 100644
--- a/Lib/php/globalvar.i
+++ b/Lib/php/globalvar.i
@@ -299,7 +299,7 @@
zend_hash_find(&EG(symbol_table), (char*)"$1", sizeof("$1"), (void**)&z_var);
if($1)
- SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0);
+ SWIG_SetPointerZval(*z_var, (void*)$1, $1_descriptor, 0);
}
%typemap(varout) char [ANY]
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index d30e0b2a9..087525be4 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -110,6 +110,7 @@
SWIG_PHP_Error(E_ERROR, "Type error in argument $argnum of $symname. Expected $&1_descriptor");
}
}
+
%typemap(argout) SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE&;
@@ -204,15 +205,15 @@
%typemap(out) SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE &
-{
- SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
-}
+%{
+ SWIG_SetPointerZval(return_value, (void *)$1, $1_descriptor, $owner);
+%}
%typemap(out) SWIGTYPE *DYNAMIC,
SWIGTYPE &DYNAMIC
{
- swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
- SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner);
+ swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **) &$1);
+ SWIG_SetPointerZval(return_value, (void *)$1, ty, $owner);
}
%typemap(out) SWIGTYPE
@@ -224,7 +225,7 @@
#else
{
$&1_ltype resultobj = ($&1_ltype) emalloc(sizeof($1_type));
- memmove(resultobj, &$1, sizeof($1_type));
+ memcpy(resultobj, &$1, sizeof($1_type));
SWIG_SetPointerZval(return_value, (void *)resultobj, $&1_descriptor, 1);
}
#endif
@@ -233,7 +234,9 @@
%typemap(out) char [ANY]
{
- RETVAL_STRINGL($1,$1_dim0,1);
+ int len = 0;
+ while (len < $1_dim0 && $1[len]) ++len;
+ RETVAL_STRINGL($1, len, 1);
}
// This typecheck does hard checking for proper argument type. If you want
@@ -264,19 +267,24 @@
%php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE)
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE
- " /* typecheck SWIGTYPE */ "
+{
+ void *tmp;
+ _v = (SWIG_ConvertPtr(*$input, (void **)&tmp, $&1_descriptor, 0) >= 0);
+}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *,
SWIGTYPE [],
SWIGTYPE &
{
void *tmp;
- _v = (SWIG_ConvertPtr( *$input, (void**)&tmp, $1_descriptor, 0) >= 0);
+ _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
}
%typecheck(SWIG_TYPECHECK_VOIDPTR) void *
- " /* typecheck void * */ "
-
+{
+ void *tmp;
+ _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, 0, 0) >= 0);
+}
/* Exception handling */
diff --git a/Lib/php/phprun.swg b/Lib/php/phprun.swg
index b4e4276f5..5196b95b4 100644
--- a/Lib/php/phprun.swg
+++ b/Lib/php/phprun.swg
@@ -70,8 +70,8 @@ static int default_error_code = E_ERROR;
if (!(expr) ) { zend_printf("Contract Assert Failed %s\n",msg ); } else
/* Standard SWIG API */
-#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule()
-#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer)
+#define SWIG_GetModule(clientdata) SWIG_Php_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Php_SetModule(pointer)
/* used to wrap returned objects in so we know whether they are newobject
and need freeing, or not */
@@ -199,7 +199,7 @@ SWIG_ZTS_ConvertPtr(zval *z, void **ptr, swig_type_info *ty, int flags TSRMLS_DC
}
static char const_name[] = "swig_runtime_data_type_pointer";
-static swig_module_info *SWIG_Php4_GetModule() {
+static swig_module_info *SWIG_Php_GetModule() {
zval *pointer;
swig_module_info *ret = 0;
@@ -216,7 +216,7 @@ static swig_module_info *SWIG_Php4_GetModule() {
return ret;
}
-static void SWIG_Php4_SetModule(swig_module_info *pointer) {
+static void SWIG_Php_SetModule(swig_module_info *pointer) {
TSRMLS_FETCH();
REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0);
}
diff --git a/Lib/php/typemaps.i b/Lib/php/typemaps.i
index c5b749578..7af301d0d 100644
--- a/Lib/php/typemaps.i
+++ b/Lib/php/typemaps.i
@@ -4,7 +4,7 @@
*
* typemaps.i.
*
- * SWIG Typemap library for PHP4.
+ * SWIG Typemap library for PHP.
*
* This library provides standard typemaps for modifying SWIG's behavior.
* With enough entries in this file, I hope that very few people actually
@@ -96,16 +96,83 @@ int_typemap(unsigned short);
int_typemap(unsigned long);
int_typemap(unsigned char);
+int_typemap(long long);
+%typemap(argout,fragment="t_output_helper") long long *OUTPUT
+{
+ zval *o;
+ MAKE_STD_ZVAL(o);
+ if ((long long)LONG_MIN <= temp$argnum && temp$argnum <= (long long)LONG_MAX) {
+ ZVAL_LONG(o, temp$argnum);
+ } else {
+ char temp[256];
+ sprintf(temp, "%lld", temp$argnum);
+ ZVAL_STRING(o, temp, 1);
+ }
+ t_output_helper( &$result, o );
+}
+%typemap(in) TYPE *REFERENCE (long long lvalue)
+%{
+ // FIXME won't work for values which don't fit in a long...
+ convert_to_long_ex($input);
+ lvalue = (long long) (*$input)->value.lval;
+ $1 = &lvalue;
+%}
+%typemap(argout) long long *REFERENCE
+%{
+ if ((long long)LONG_MIN <= lvalue$argnum && lvalue$argnum <= (long long)LONG_MAX) {
+ (*$arg)->value.lval = (long)(lvalue$argnum);
+ (*$arg)->type = IS_LONG;
+ } else {
+ char temp[256];
+ sprintf(temp, "%lld", lvalue$argnum);
+ ZVAL_STRING((*$arg), temp, 1);
+ }
+%}
+int_typemap(unsigned long long);
+%typemap(argout,fragment="t_output_helper") unsigned long long *OUTPUT
+{
+ zval *o;
+ MAKE_STD_ZVAL(o);
+ if (temp$argnum <= (unsigned long long)LONG_MAX) {
+ ZVAL_LONG(o, temp$argnum);
+ } else {
+ char temp[256];
+ sprintf(temp, "%llu", temp$argnum);
+ ZVAL_STRING(o, temp, 1);
+ }
+ t_output_helper( &$result, o );
+}
+%typemap(in) TYPE *REFERENCE (unsigned long long lvalue)
+%{
+ // FIXME won't work for values which don't fit in a long...
+ convert_to_long_ex($input);
+ lvalue = (unsigned long long) (*$input)->value.lval;
+ $1 = &lvalue;
+%}
+%typemap(argout) unsigned long long *REFERENCE
+%{
+ if (lvalue$argnum <= (unsigned long long)LONG_MAX) {
+ (*$arg)->value.lval = (long)(lvalue$argnum);
+ (*$arg)->type = IS_LONG;
+ } else {
+ char temp[256];
+ sprintf(temp, "%llu", lvalue$argnum);
+ ZVAL_STRING((*$arg), temp, 1);
+ }
+%}
+
%typemap(in) float *INOUT = float *INPUT;
%typemap(in) double *INOUT = double *INPUT;
%typemap(in) int *INOUT = int *INPUT;
%typemap(in) short *INOUT = short *INPUT;
%typemap(in) long *INOUT = long *INPUT;
+%typemap(in) long long *INOUT = long long *INPUT;
%typemap(in) unsigned *INOUT = unsigned *INPUT;
%typemap(in) unsigned short *INOUT = unsigned short *INPUT;
%typemap(in) unsigned long *INOUT = unsigned long *INPUT;
%typemap(in) unsigned char *INOUT = unsigned char *INPUT;
+%typemap(in) unsigned long long *INOUT = unsigned long long *INPUT;
%typemap(in) float &INOUT = float *INPUT;
%typemap(in) double &INOUT = double *INPUT;
@@ -113,10 +180,12 @@ int_typemap(unsigned char);
%typemap(in) int &INOUT = int *INPUT;
%typemap(in) short &INOUT = short *INPUT;
%typemap(in) long &INOUT = long *INPUT;
+%typemap(in) long long &INOUT = long long *INPUT;
%typemap(in) unsigned &INOUT = unsigned *INPUT;
%typemap(in) unsigned short &INOUT = unsigned short *INPUT;
%typemap(in) unsigned long &INOUT = unsigned long *INPUT;
%typemap(in) unsigned char &INOUT = unsigned char *INPUT;
+%typemap(in) unsigned long long &INOUT = unsigned long long *INPUT;
%typemap(argout) float *INOUT = float *OUTPUT;
%typemap(argout) double *INOUT= double *OUTPUT;
@@ -124,9 +193,11 @@ int_typemap(unsigned char);
%typemap(argout) int *INOUT = int *OUTPUT;
%typemap(argout) short *INOUT = short *OUTPUT;
%typemap(argout) long *INOUT= long *OUTPUT;
+%typemap(argout) long long *INOUT= long long *OUTPUT;
%typemap(argout) unsigned short *INOUT= unsigned short *OUTPUT;
%typemap(argout) unsigned long *INOUT = unsigned long *OUTPUT;
%typemap(argout) unsigned char *INOUT = unsigned char *OUTPUT;
+%typemap(argout) unsigned long long *INOUT = unsigned long long *OUTPUT;
%typemap(argout) float &INOUT = float *OUTPUT;
%typemap(argout) double &INOUT= double *OUTPUT;
@@ -134,9 +205,11 @@ int_typemap(unsigned char);
%typemap(argout) int &INOUT = int *OUTPUT;
%typemap(argout) short &INOUT = short *OUTPUT;
%typemap(argout) long &INOUT= long *OUTPUT;
+%typemap(argout) long long &INOUT= long long *OUTPUT;
%typemap(argout) unsigned short &INOUT= unsigned short *OUTPUT;
%typemap(argout) unsigned long &INOUT = unsigned long *OUTPUT;
%typemap(argout) unsigned char &INOUT = unsigned char *OUTPUT;
+%typemap(argout) unsigned long long &INOUT = unsigned long long *OUTPUT;
%typemap(in) char INPUT[ANY] ( char temp[$1_dim0] )
%{
diff --git a/Lib/php/utils.i b/Lib/php/utils.i
index 661a48777..facf54196 100644
--- a/Lib/php/utils.i
+++ b/Lib/php/utils.i
@@ -24,8 +24,12 @@
%enddef
%define CONVERT_STRING_IN(lvar,t,invar)
- convert_to_string_ex(invar);
- lvar = (t) Z_STRVAL_PP(invar);
+ if ((*invar)->type==IS_NULL) {
+ lvar = (t) 0;
+ } else {
+ convert_to_string_ex(invar);
+ lvar = (t) Z_STRVAL_PP(invar);
+ }
%enddef
%define %pass_by_val( TYPE, CONVERT_IN )
diff --git a/Lib/python/boost_shared_ptr.i b/Lib/python/boost_shared_ptr.i
index 2e34290ac..b4c0b5b83 100644
--- a/Lib/python/boost_shared_ptr.i
+++ b/Lib/python/boost_shared_ptr.i
@@ -1,5 +1,11 @@
%include <shared_ptr.i>
+// Set SHARED_PTR_DISOWN to $disown if required, for example
+// #define SHARED_PTR_DISOWN $disown
+#if !defined(SHARED_PTR_DISOWN)
+#define SHARED_PTR_DISOWN 0
+#endif
+
%define SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, CONST, TYPE...)
%naturalvar TYPE;
@@ -51,10 +57,10 @@
}
// plain pointer
-// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
int newmem = 0;
- res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
@@ -139,10 +145,10 @@
}
// plain pointer by reference
-// Note: $disown not implemented as it will lead to a memory leak of the shared_ptr instance
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
%typemap(in) CONST TYPE *& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
int newmem = 0;
- res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
diff --git a/Lib/python/director.swg b/Lib/python/director.swg
index 176ee3336..ba9144539 100644
--- a/Lib/python/director.swg
+++ b/Lib/python/director.swg
@@ -47,7 +47,7 @@
/*
Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the
- 'Swig' namespace. This could be usefull for multi-modules projects.
+ 'Swig' namespace. This could be useful for multi-modules projects.
*/
#ifdef SWIG_DIRECTOR_STATIC
/* Force anonymous (static) namespace */
@@ -107,7 +107,7 @@ namespace Swig {
/* memory handler */
struct GCItem
{
- virtual ~GCItem() = 0;
+ virtual ~GCItem() {}
virtual int get_own() const
{
@@ -115,10 +115,6 @@ namespace Swig {
}
};
- GCItem::~GCItem()
- {
- }
-
struct GCItem_var
{
GCItem_var(GCItem *item = 0) : _item(item)
@@ -212,10 +208,7 @@ namespace Swig {
swig_msg += msg;
}
if (!PyErr_Occurred()) {
- swig_msg.insert(0, ": ");
PyErr_SetString(error, getMessage());
- } else {
- SWIG_Python_AddErrorMsg(getMessage());
}
SWIG_PYTHON_THREAD_END_BLOCK;
}
diff --git a/Lib/python/embed.i b/Lib/python/embed.i
index 4855e3dbb..c29e8fd9f 100644
--- a/Lib/python/embed.i
+++ b/Lib/python/embed.i
@@ -1,11 +1,11 @@
//
-// embed15.i
+// embed.i
// SWIG file embedding the Python interpreter in something else.
// This file is based on Python-1.5. It will not work with
// earlier versions.
//
// This file makes it possible to extend Python and all of its
-// built-in functions without having to hack it's setup script.
+// built-in functions without having to hack its setup script.
//
diff --git a/Lib/python/embed15.i b/Lib/python/embed15.i
index f677d166e..32808b1aa 100644
--- a/Lib/python/embed15.i
+++ b/Lib/python/embed15.i
@@ -9,7 +9,7 @@
* earlier versions.
*
* This file makes it possible to extend Python and all of its
- * built-in functions without having to hack it's setup script.
+ * built-in functions without having to hack its setup script.
* ----------------------------------------------------------------------------- */
#ifdef AUTODOC
diff --git a/Lib/python/file.i b/Lib/python/file.i
index c0e7d5ea9..294ab9178 100644
--- a/Lib/python/file.i
+++ b/Lib/python/file.i
@@ -20,11 +20,13 @@ SWIG_AsValFilePtr(PyObject *obj, FILE **val) {
if ((SWIG_ConvertPtr(obj, &vptr, desc, 0)) == SWIG_OK) {
if (val) *val = (FILE *)vptr;
return SWIG_OK;
- }
+ }
+%#if PY_VERSION_HEX < 0x03000000
if (PyFile_Check(obj)) {
if (val) *val = PyFile_AsFile(obj);
return SWIG_OK;
}
+%#endif
return SWIG_TypeError;
}
}
diff --git a/Lib/python/pyabc.i b/Lib/python/pyabc.i
new file mode 100644
index 000000000..3da06b5a9
--- /dev/null
+++ b/Lib/python/pyabc.i
@@ -0,0 +1,10 @@
+%define %pythonabc(Type, Abc)
+ %feature("python:abc", #Abc) Type;
+%enddef
+%pythoncode {import collections};
+%pythonabc(std::vector, collections.MutableSequence);
+%pythonabc(std::list, collections.MutableSequence);
+%pythonabc(std::map, collections.MutableMapping);
+%pythonabc(std::multimap, collections.MutableMapping);
+%pythonabc(std::set, collections.MutableSet);
+%pythonabc(std::multiset, collections.MutableSet);
diff --git a/Lib/python/pyapi.swg b/Lib/python/pyapi.swg
index 1d5148dbf..d980f9263 100644
--- a/Lib/python/pyapi.swg
+++ b/Lib/python/pyapi.swg
@@ -27,6 +27,20 @@ typedef struct swig_const_info {
swig_type_info **ptype;
} swig_const_info;
+
+/* -----------------------------------------------------------------------------
+ * Wrapper of PyInstanceMethod_New() used in Python 3
+ * It is exported to the generated module, used for -fastproxy
+ * ----------------------------------------------------------------------------- */
+SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *self, PyObject *func)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ return PyInstanceMethod_New(func);
+#else
+ return NULL;
+#endif
+}
+
#ifdef __cplusplus
#if 0
{ /* cc-mode */
diff --git a/Lib/python/pybuffer.i b/Lib/python/pybuffer.i
new file mode 100644
index 000000000..121cd709f
--- /dev/null
+++ b/Lib/python/pybuffer.i
@@ -0,0 +1,107 @@
+/* Implementing buffer protocol typemaps */
+
+/* %pybuffer_mutable_binary(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept mutable buffer pointer with a size.
+ * This can be used for both input and output. For example:
+ *
+ * %pybuffer_mutable_binary(char *buff, int size);
+ * void foo(char *buff, int size) {
+ * for(int i=0; i<size; ++i)
+ * buff[i]++;
+ * }
+ */
+
+%define %pybuffer_mutable_binary(TYPEMAP, SIZE)
+%typemap(in) (TYPEMAP, SIZE)
+ (int res, Py_ssize_t size = 0, void *buf = 0) {
+ res = PyObject_AsWriteBuffer($input, &buf, &size);
+ if (res<0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) (size/sizeof($*1_type));
+}
+%enddef
+
+/* %pybuffer_mutable_string(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept mutable zero terminated string pointer.
+ * This can be used for both input and output. For example:
+ *
+ * %pybuffer_mutable_string(char *str);
+ * void foo(char *str) {
+ * while(*str) {
+ * *str = toupper(*str);
+ * str++;
+ * }
+ */
+
+%define %pybuffer_mutable_string(TYPEMAP)
+%typemap(in) (TYPEMAP)
+ (int res, Py_ssize_t size = 0, void *buf = 0) {
+ res = PyObject_AsWriteBuffer($input, &buf, &size);
+ if (res<0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+}
+%enddef
+
+/* pybuffer_binary(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept read only buffer pointer with a size.
+ * This must be used for input. For example:
+ *
+ * %pybuffer_binary(char *buff, int size);
+ * int foo(char *buff, int size) {
+ * int count = 0;
+ * for(int i=0; i<size; ++i)
+ * if (0==buff[i]) count++;
+ * return count;
+ * }
+ */
+
+%define %pybuffer_binary(TYPEMAP, SIZE)
+%typemap(in) (TYPEMAP, SIZE)
+ (int res, Py_ssize_t size = 0, const void *buf = 0) {
+ res = PyObject_AsReadBuffer($input, &buf, &size);
+ if (res<0) {
+ PyErr_Clear();
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+ $2 = ($2_ltype) (size / sizeof($*1_type));
+}
+%enddef
+
+/* %pybuffer_string(TYPEMAP, SIZE)
+ *
+ * Macro for functions accept read only zero terminated string pointer.
+ * This can be used for input. For example:
+ *
+ * %pybuffer_string(char *str);
+ * int foo(char *str) {
+ * int count = 0;
+ * while(*str) {
+ * if (isalnum(*str))
+ * count++;
+ * str++;
+ * }
+ */
+
+%define %pybuffer_string(TYPEMAP)
+%typemap(in) (TYPEMAP)
+ (int res, Py_ssize_t size = 0, const void *buf = 0) {
+ res = PyObject_AsReadBuffer($input, &buf, &size);
+ if (res<0) {
+ %argument_fail(res, "(TYPEMAP, SIZE)", $symname, $argnum);
+ }
+ $1 = ($1_ltype) buf;
+}
+%enddef
+
+
+
diff --git a/Lib/python/pyclasses.swg b/Lib/python/pyclasses.swg
index 0caecd697..65f6dec47 100644
--- a/Lib/python/pyclasses.swg
+++ b/Lib/python/pyclasses.swg
@@ -1,55 +1,55 @@
#ifdef __cplusplus
/*
- PyObject_ptr is used as a replacement of PyObject *, where
+ SwigPtr_PyObject is used as a replacement of PyObject *, where
the INCREF/DECREF are applied as needed.
- You can use PyObject_ptr in a container, such as
+ You can use SwigPtr_PyObject in a container, such as
- std::vector<PyObject_ptr>;
+ std::vector<SwigPtr_PyObject>;
or as a member variable:
struct A {
- PyObject_ptr obj;
+ SwigPtr_PyObject obj;
A(PyObject *o) : _obj(o) {
}
};
or as a input/output value
- PyObject_ptr func(PyObject_ptr obj) {
- PyObject_ptr out = PyString_FromFormat("hello %s", PyObject_AsString(obj));
+ SwigPtr_PyObject func(SwigPtr_PyObject obj) {
+ SwigPtr_PyObject out = PyString_FromFormat("hello %s", PyObject_AsString(obj));
Py_DECREF(out);
return out;
}
just remember to pair the object creation with the proper DECREF,
- the same as with plain PyObject *ptr, since PyObject_ptr always add
+ the same as with plain PyObject *ptr, since SwigPtr_PyObject always add
one reference at construction.
- PyObject_ptr is 'visible' at the wrapped side, so you can do:
+ SwigPtr_PyObject is 'visible' at the wrapped side, so you can do:
- %template(pyvector) std::vector<swig::PyObject_ptr>;
+ %template(pyvector) std::vector<swig::SwigPtr_PyObject>;
and all the proper typemaps will be used.
*/
namespace swig {
- %ignore PyObject_ptr;
- struct PyObject_ptr {};
- %apply PyObject * {PyObject_ptr};
- %apply PyObject * const& {PyObject_ptr const&};
+ %ignore SwigPtr_PyObject;
+ struct SwigPtr_PyObject {};
+ %apply PyObject * {SwigPtr_PyObject};
+ %apply PyObject * const& {SwigPtr_PyObject const&};
/* For output */
- %typemap(out,noblock=1) PyObject_ptr {
+ %typemap(out,noblock=1) SwigPtr_PyObject {
$result = (PyObject *)$1;
Py_INCREF($result);
}
- %typemap(out,noblock=1) PyObject_ptr const & {
+ %typemap(out,noblock=1) SwigPtr_PyObject const & {
$result = (PyObject *)*$1;
Py_INCREF($result);
}
@@ -58,28 +58,28 @@ namespace swig {
%{
namespace swig {
- class PyObject_ptr {
+ class SwigPtr_PyObject {
protected:
PyObject *_obj;
public:
- PyObject_ptr() :_obj(0)
+ SwigPtr_PyObject() :_obj(0)
{
}
- PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj)
+ SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
{
Py_XINCREF(_obj);
}
- PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
+ SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
{
if (initial_ref) {
Py_XINCREF(_obj);
}
}
- PyObject_ptr & operator=(const PyObject_ptr& item)
+ SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item)
{
Py_XINCREF(item._obj);
Py_XDECREF(_obj);
@@ -87,7 +87,7 @@ namespace swig {
return *this;
}
- ~PyObject_ptr()
+ ~SwigPtr_PyObject()
{
Py_XDECREF(_obj);
}
@@ -106,33 +106,33 @@ namespace swig {
%}
/*
- PyObject_var is used to manage 'in the scope' PyObject * variables,
+ SwigVar_PyObject is used to manage 'in the scope' PyObject * variables,
as in
int func () {
- PyObject_var obj = PyString_FromString("hello");
+ SwigVar_PyObject obj = PyString_FromString("hello");
}
ie, 'obj' is created and destructed in the same scope from
a python object that carries at least one reference value.
- PyObject_var just take care of applying the proper Py_DECREF.
+ SwigVar_PyObject just take care of applying the proper Py_DECREF.
Hence, this class is purely internal and not visible at the wrapped side.
*/
namespace swig {
- %ignore PyObject_var;
- struct PyObject_var {};
- %apply PyObject * {PyObject_var};
- %apply PyObject * const& {PyObject_var const&};
+ %ignore SwigVar_PyObject;
+ struct SwigVar_PyObject {};
+ %apply PyObject * {SwigVar_PyObject};
+ %apply PyObject * const& {SwigVar_PyObject const&};
}
%{
namespace swig {
- struct PyObject_var : PyObject_ptr {
- PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { }
+ struct SwigVar_PyObject : SwigPtr_PyObject {
+ SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
- PyObject_var & operator = (PyObject* obj)
+ SwigVar_PyObject & operator = (PyObject* obj)
{
Py_XDECREF(_obj);
_obj = obj;
diff --git a/Lib/python/pycomplex.swg b/Lib/python/pycomplex.swg
index 7914b0e91..74be5b970 100644
--- a/Lib/python/pycomplex.swg
+++ b/Lib/python/pycomplex.swg
@@ -1,13 +1,13 @@
/*
- Defines the As/From conversors for double/float complex, you need to
- provide complex Type, the Name you want to use in the conversors,
+ Defines the As/From converters for double/float complex, you need to
+ provide complex Type, the Name you want to use in the converters,
the complex Constructor method, and the Real and Imag complex
- accesor methods.
+ accessor methods.
See the std_complex.i and ccomplex.i for concret examples.
*/
-/* the common from conversor */
+/* the common from converter */
%define %swig_fromcplx_conv(Type, Real, Imag)
%fragment(SWIG_From_frag(Type),"header")
{
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index ed0eb7f0b..7d7fdfc72 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -36,15 +36,15 @@
%include <std_except.i>
-%fragment(SWIG_Traits_frag(swig::PyObject_ptr),"header",fragment="StdTraits") {
+%fragment(SWIG_Traits_frag(swig::SwigPtr_PyObject),"header",fragment="StdTraits") {
namespace swig {
- template <> struct traits<PyObject_ptr > {
+ template <> struct traits<SwigPtr_PyObject > {
typedef value_category category;
- static const char* type_name() { return "PyObject_ptr"; }
+ static const char* type_name() { return "SwigPtr_PyObject"; }
};
- template <> struct traits_from<PyObject_ptr> {
- typedef PyObject_ptr value_type;
+ template <> struct traits_from<SwigPtr_PyObject> {
+ typedef SwigPtr_PyObject value_type;
static PyObject *from(const value_type& val) {
PyObject *obj = static_cast<PyObject *>(val);
Py_XINCREF(obj);
@@ -53,14 +53,14 @@ namespace swig {
};
template <>
- struct traits_check<PyObject_ptr, value_category> {
- static bool check(PyObject_ptr) {
+ struct traits_check<SwigPtr_PyObject, value_category> {
+ static bool check(SwigPtr_PyObject) {
return true;
}
};
- template <> struct traits_asval<PyObject_ptr > {
- typedef PyObject_ptr value_type;
+ template <> struct traits_asval<SwigPtr_PyObject > {
+ typedef SwigPtr_PyObject value_type;
static int asval(PyObject *obj, value_type *val) {
if (val) *val = obj;
return SWIG_OK;
@@ -69,15 +69,15 @@ namespace swig {
}
}
-%fragment(SWIG_Traits_frag(swig::PyObject_var),"header",fragment="StdTraits") {
+%fragment(SWIG_Traits_frag(swig::SwigVar_PyObject),"header",fragment="StdTraits") {
namespace swig {
- template <> struct traits<PyObject_var > {
+ template <> struct traits<SwigVar_PyObject > {
typedef value_category category;
- static const char* type_name() { return "PyObject_var"; }
+ static const char* type_name() { return "SwigVar_PyObject"; }
};
- template <> struct traits_from<PyObject_var> {
- typedef PyObject_var value_type;
+ template <> struct traits_from<SwigVar_PyObject> {
+ typedef SwigVar_PyObject value_type;
static PyObject *from(const value_type& val) {
PyObject *obj = static_cast<PyObject *>(val);
Py_XINCREF(obj);
@@ -86,14 +86,14 @@ namespace swig {
};
template <>
- struct traits_check<PyObject_var, value_category> {
- static bool check(PyObject_var) {
+ struct traits_check<SwigVar_PyObject, value_category> {
+ static bool check(SwigVar_PyObject) {
return true;
}
};
- template <> struct traits_asval<PyObject_var > {
- typedef PyObject_var value_type;
+ template <> struct traits_asval<SwigVar_PyObject > {
+ typedef SwigVar_PyObject value_type;
static int asval(PyObject *obj, value_type *val) {
if (val) *val = obj;
return SWIG_OK;
@@ -102,7 +102,7 @@ namespace swig {
}
}
-%fragment("PySequence_Base","header")
+%fragment("SwigPySequence_Base","header")
{
%#include <functional>
@@ -115,27 +115,38 @@ namespace std {
{
bool res;
SWIG_PYTHON_THREAD_BEGIN_BLOCK;
- res = PyObject_Compare(v, w) < 0;
+ res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false;
+ /* This may fall into a case of inconsistent
+ eg. ObjA > ObjX > ObjB
+ but ObjA < ObjB
+ */
+ if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) )
+ {
+ /* Objects can't be compared, this mostly occurred in Python 3.0 */
+ /* Compare their ptr directly for a workaround */
+ res = (v < w);
+ PyErr_Clear();
+ }
SWIG_PYTHON_THREAD_END_BLOCK;
return res;
}
};
template <>
- struct less <swig::PyObject_ptr>: public binary_function<swig::PyObject_ptr, swig::PyObject_ptr, bool>
+ struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool>
{
bool
- operator()(const swig::PyObject_ptr& v, const swig::PyObject_ptr& w) const
+ operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const
{
return std::less<PyObject *>()(v, w);
}
};
template <>
- struct less <swig::PyObject_var>: public binary_function<swig::PyObject_var, swig::PyObject_var, bool>
+ struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool>
{
bool
- operator()(const swig::PyObject_var& v, const swig::PyObject_var& w) const
+ operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const
{
return std::less<PyObject *>()(v, w);
}
@@ -277,24 +288,24 @@ namespace swig {
}
}
-%fragment("PySequence_Cont","header",
+%fragment("SwigPySequence_Cont","header",
fragment="StdTraits",
- fragment="PySequence_Base",
- fragment="PySwigIterator_T")
+ fragment="SwigPySequence_Base",
+ fragment="SwigPyIterator_T")
{
namespace swig
{
template <class T>
- struct PySequence_Ref
+ struct SwigPySequence_Ref
{
- PySequence_Ref(PyObject* seq, int index)
+ SwigPySequence_Ref(PyObject* seq, int index)
: _seq(seq), _index(index)
{
}
operator T () const
{
- swig::PyObject_var item = PySequence_GetItem(_seq, _index);
+ swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
try {
return swig::as<T>(item, true);
} catch (std::exception& e) {
@@ -309,7 +320,7 @@ namespace swig
}
}
- PySequence_Ref& operator=(const T& v)
+ SwigPySequence_Ref& operator=(const T& v)
{
PySequence_SetItem(_seq, _index, swig::from<T>(v));
return *this;
@@ -321,18 +332,18 @@ namespace swig
};
template <class T>
- struct PySequence_ArrowProxy
+ struct SwigPySequence_ArrowProxy
{
- PySequence_ArrowProxy(const T& x): m_value(x) {}
+ SwigPySequence_ArrowProxy(const T& x): m_value(x) {}
const T* operator->() const { return &m_value; }
operator const T*() const { return &m_value; }
T m_value;
};
template <class T, class Reference >
- struct PySequence_InputIterator
+ struct SwigPySequence_InputIterator
{
- typedef PySequence_InputIterator<T, Reference > self;
+ typedef SwigPySequence_InputIterator<T, Reference > self;
typedef std::random_access_iterator_tag iterator_category;
typedef Reference reference;
@@ -340,11 +351,11 @@ namespace swig
typedef T* pointer;
typedef int difference_type;
- PySequence_InputIterator()
+ SwigPySequence_InputIterator()
{
}
- PySequence_InputIterator(PyObject* seq, int index)
+ SwigPySequence_InputIterator(PyObject* seq, int index)
: _seq(seq), _index(index)
{
}
@@ -354,9 +365,9 @@ namespace swig
return reference(_seq, _index);
}
- PySequence_ArrowProxy<T>
+ SwigPySequence_ArrowProxy<T>
operator->() const {
- return PySequence_ArrowProxy<T>(operator*());
+ return SwigPySequence_ArrowProxy<T>(operator*());
}
bool operator==(const self& ri) const
@@ -425,19 +436,19 @@ namespace swig
};
template <class T>
- struct PySequence_Cont
+ struct SwigPySequence_Cont
{
- typedef PySequence_Ref<T> reference;
- typedef const PySequence_Ref<T> const_reference;
+ typedef SwigPySequence_Ref<T> reference;
+ typedef const SwigPySequence_Ref<T> const_reference;
typedef T value_type;
typedef T* pointer;
typedef int difference_type;
typedef int size_type;
typedef const pointer const_pointer;
- typedef PySequence_InputIterator<T, reference> iterator;
- typedef PySequence_InputIterator<T, const_reference> const_iterator;
+ typedef SwigPySequence_InputIterator<T, reference> iterator;
+ typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
- PySequence_Cont(PyObject* seq) : _seq(0)
+ SwigPySequence_Cont(PyObject* seq) : _seq(0)
{
if (!PySequence_Check(seq)) {
throw std::invalid_argument("a sequence is expected");
@@ -446,7 +457,7 @@ namespace swig
Py_INCREF(_seq);
}
- ~PySequence_Cont()
+ ~SwigPySequence_Cont()
{
Py_XDECREF(_seq);
}
@@ -495,7 +506,7 @@ namespace swig
{
int s = size();
for (int i = 0; i < s; ++i) {
- swig::PyObject_var item = PySequence_GetItem(_seq, i);
+ swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
if (!swig::check<value_type>(item)) {
if (set_err) {
char msg[1024];
@@ -522,40 +533,40 @@ namespace swig
class const_iterator;
class const_reverse_iterator;
- %typemap(out,noblock=1,fragment="PySequence_Cont")
+ %typemap(out,noblock=1,fragment="SwigPySequence_Cont")
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
$result = SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
- swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
}
- %typemap(out,noblock=1,fragment="PySequence_Cont")
+ %typemap(out,noblock=1,fragment="SwigPySequence_Cont")
std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
$result = PyTuple_New(2);
PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
- swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN));
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
PyTuple_SetItem($result,1,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).second),
- swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN));
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
}
- %fragment("PyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="PySequence_Cont") {}
+ %fragment("SwigPyPairBoolOutputIterator","header",fragment=SWIG_From_frag(bool),fragment="SwigPySequence_Cont") {}
- %typemap(out,noblock=1,fragment="PyPairBoolOutputIterator")
+ %typemap(out,noblock=1,fragment="SwigPyPairBoolOutputIterator")
std::pair<iterator, bool>, std::pair<const_iterator, bool> {
$result = PyTuple_New(2);
PyTuple_SetItem($result,0,SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &).first),
- swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN));
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN));
PyTuple_SetItem($result,1,SWIG_From(bool)(%static_cast($1,const $type &).second));
}
- %typemap(in,noblock=1,fragment="PySequence_Cont")
- iterator(swig::PySwigIterator *iter = 0, int res),
- reverse_iterator(swig::PySwigIterator *iter = 0, int res),
- const_iterator(swig::PySwigIterator *iter = 0, int res),
- const_reverse_iterator(swig::PySwigIterator *iter = 0, int res) {
- res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+ %typemap(in,noblock=1,fragment="SwigPySequence_Cont")
+ iterator(swig::SwigPyIterator *iter = 0, int res),
+ reverse_iterator(swig::SwigPyIterator *iter = 0, int res),
+ const_iterator(swig::SwigPyIterator *iter = 0, int res),
+ const_reverse_iterator(swig::SwigPyIterator *iter = 0, int res) {
+ res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
if (!SWIG_IsOK(res) || !iter) {
%argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
} else {
- swig::PySwigIterator_T<$type > *iter_t = dynamic_cast<swig::PySwigIterator_T<$type > *>(iter);
+ swig::SwigPyIterator_T<$type > *iter_t = dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter);
if (iter_t) {
$1 = iter_t->get_current();
} else {
@@ -564,18 +575,18 @@ namespace swig
}
}
- %typecheck(%checkcode(ITERATOR),noblock=1,fragment="PySequence_Cont")
+ %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SwigPySequence_Cont")
iterator, reverse_iterator, const_iterator, const_reverse_iterator {
- swig::PySwigIterator *iter = 0;
- int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
- $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<$type > *>(iter) != 0));
+ swig::SwigPyIterator *iter = 0;
+ int res = SWIG_ConvertPtr($input, %as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
+ $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<$type > *>(iter) != 0));
}
- %fragment("PySequence_Cont");
+ %fragment("SwigPySequence_Cont");
%newobject iterator(PyObject **PYTHON_SELF);
%extend {
- swig::PySwigIterator* iterator(PyObject **PYTHON_SELF) {
+ swig::SwigPyIterator* iterator(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
@@ -597,6 +608,11 @@ namespace swig
return !(self->empty());
}
+ /* Alias for Python 3 compatibility */
+ bool __bool__() const {
+ return !(self->empty());
+ }
+
size_type __len__() const {
return self->size();
}
@@ -607,7 +623,7 @@ namespace swig
%swig_sequence_iterator(%arg(Sequence))
%swig_container_methods(%arg(Sequence))
- %fragment("PySequence_Base");
+ %fragment("SwigPySequence_Base");
%extend {
value_type pop() throw (std::out_of_range) {
@@ -618,6 +634,14 @@ namespace swig
return x;
}
+ /* typemap for slice object support */
+ %typemap(in) PySliceObject* {
+ $1 = (PySliceObject *) $input;
+ }
+ %typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER) PySliceObject* {
+ $1 = PySlice_Check($input);
+ }
+
Sequence* __getslice__(difference_type i, difference_type j) throw (std::out_of_range) {
return swig::getslice(self, i, j);
}
@@ -634,6 +658,43 @@ namespace swig
void __delitem__(difference_type i) throw (std::out_of_range) {
self->erase(swig::getpos(self,i));
}
+
+
+ /* Overloaded methods for Python 3 compatibility
+ * (Also useful in Python 2.x)
+ */
+ Sequence* __getitem__(PySliceObject *slice) throw (std::out_of_range) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+ return NULL;
+ }
+ PySlice_GetIndices(slice, self->size(), &i, &j, &step);
+ return swig::getslice(self, i, j);
+ }
+
+ void __setitem__(PySliceObject *slice, const Sequence& v)
+ throw (std::out_of_range, std::invalid_argument) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+ return;
+ }
+ PySlice_GetIndices(slice, self->size(), &i, &j, &step);
+ swig::setslice(self, i, j, v);
+ }
+
+ void __delitem__(PySliceObject *slice)
+ throw (std::out_of_range) {
+ Py_ssize_t i, j, step;
+ if( !PySlice_Check(slice) ) {
+ SWIG_Error(SWIG_TypeError, "Slice object expected.");
+ return;
+ }
+ PySlice_GetIndices(slice, self->size(), &i, &j, &step);
+ swig::delslice(self, i,j);
+ }
+
}
%enddef
@@ -679,16 +740,16 @@ namespace swig
%fragment("StdSequenceTraits","header",
fragment="StdTraits",
- fragment="PySequence_Cont")
+ fragment="SwigPySequence_Cont")
{
namespace swig {
- template <class PySeq, class Seq>
+ template <class SwigPySeq, class Seq>
inline void
- assign(const PySeq& pyseq, Seq* seq) {
- // seq->assign(pyseq.begin(), pyseq.end()); // not used as not always implemented
- typedef typename PySeq::value_type value_type;
- typename PySeq::const_iterator it = pyseq.begin();
- for (;it != pyseq.end(); ++it) {
+ assign(const SwigPySeq& swigpyseq, Seq* seq) {
+ // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}
@@ -708,14 +769,14 @@ namespace swig {
}
} else if (PySequence_Check(obj)) {
try {
- PySequence_Cont<value_type> pyseq(obj);
+ SwigPySequence_Cont<value_type> swigpyseq(obj);
if (seq) {
sequence *pseq = new sequence();
- assign(pyseq, pseq);
+ assign(swigpyseq, pseq);
*seq = pseq;
return SWIG_NEWOBJ;
} else {
- return pyseq.check() ? SWIG_OK : SWIG_ERROR;
+ return swigpyseq.check() ? SWIG_OK : SWIG_ERROR;
}
} catch (std::exception& e) {
if (seq) {
diff --git a/Lib/python/pyerrors.swg b/Lib/python/pyerrors.swg
index e287e2fc8..fe7313554 100644
--- a/Lib/python/pyerrors.swg
+++ b/Lib/python/pyerrors.swg
@@ -55,15 +55,16 @@ SWIG_Python_AddErrorMsg(const char* mesg)
if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
if (value) {
+ char *tmp;
PyObject *old_str = PyObject_Str(value);
PyErr_Clear();
Py_XINCREF(type);
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+
+ PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+ SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
Py_DECREF(value);
} else {
PyErr_SetString(PyExc_RuntimeError, mesg);
}
}
-
-
diff --git a/Lib/python/pyhead.swg b/Lib/python/pyhead.swg
index 7839511bc..2edbf631f 100644
--- a/Lib/python/pyhead.swg
+++ b/Lib/python/pyhead.swg
@@ -1,3 +1,64 @@
+/* Compatibility macros for Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+
+#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
+#define PyInt_Check(x) PyLong_Check(x)
+#define PyInt_AsLong(x) PyLong_AsLong(x)
+#define PyInt_FromLong(x) PyLong_FromLong(x)
+#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args)
+
+#endif
+
+#ifndef Py_TYPE
+# define Py_TYPE(op) ((op)->ob_type)
+#endif
+
+/* SWIG APIs for compatibility of both Python 2 & 3 */
+
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_Python_str_FromFormat PyUnicode_FromFormat
+#else
+# define SWIG_Python_str_FromFormat PyString_FromFormat
+#endif
+
+
+/* Warning: This function will allocate a new string in Python 3,
+ * so please call SWIG_Python_str_DelForPy3(x) to free the space.
+ */
+SWIGINTERN char*
+SWIG_Python_str_AsChar(PyObject *str)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ char *cstr;
+ char *newstr;
+ Py_ssize_t len;
+ str = PyUnicode_AsUTF8String(str);
+ PyBytes_AsStringAndSize(str, &cstr, &len);
+ newstr = (char *) malloc(len+1);
+ memcpy(newstr, cstr, len+1);
+ Py_XDECREF(str);
+ return newstr;
+#else
+ return PyString_AsString(str);
+#endif
+}
+
+#if PY_VERSION_HEX >= 0x03000000
+# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
+#else
+# define SWIG_Python_str_DelForPy3(x)
+#endif
+
+
+SWIGINTERN PyObject*
+SWIG_Python_str_FromChar(const char *c)
+{
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_FromString(c);
+#else
+ return PyString_FromString(c);
+#endif
+}
/* Add PyOS_snprintf for old Pythons */
#if PY_VERSION_HEX < 0x02020000
@@ -44,6 +105,7 @@ PyString_FromFormat(const char *fmt, ...) {
# define PyObject_GenericGetAttr 0
# endif
#endif
+
/* Py_NotImplemented is defined in 2.1 and up. */
#if PY_VERSION_HEX < 0x02010000
# ifndef Py_NotImplemented
@@ -51,7 +113,6 @@ PyString_FromFormat(const char *fmt, ...) {
# endif
#endif
-
/* A crude PyString_AsStringAndSize implementation for old Pythons */
#if PY_VERSION_HEX < 0x02010000
# ifndef PyString_AsStringAndSize
@@ -66,7 +127,6 @@ PyString_FromFormat(const char *fmt, ...) {
# endif
#endif
-
/* PyBool_FromLong for old Pythons */
#if PY_VERSION_HEX < 0x02030000
static
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index e6109b7bd..058934b04 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -33,26 +33,58 @@ typedef struct swig_varlinkobject {
SWIGINTERN PyObject *
swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
+#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_InternFromString("<Swig global variables>");
+#else
return PyString_FromString("<Swig global variables>");
+#endif
}
SWIGINTERN PyObject *
swig_varlink_str(swig_varlinkobject *v) {
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject *str = PyUnicode_InternFromString("(");
+ PyObject *tail;
+ PyObject *joined;
+ swig_globalvar *var;
+ for (var = v->vars; var; var=var->next) {
+ tail = PyUnicode_FromString(var->name);
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+ if (var->next) {
+ tail = PyUnicode_InternFromString(", ");
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+ }
+ }
+ tail = PyUnicode_InternFromString(")");
+ joined = PyUnicode_Concat(str, tail);
+ Py_DecRef(str);
+ Py_DecRef(tail);
+ str = joined;
+#else
PyObject *str = PyString_FromString("(");
- swig_globalvar *var;
+ swig_globalvar *var;
for (var = v->vars; var; var=var->next) {
PyString_ConcatAndDel(&str,PyString_FromString(var->name));
if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
}
PyString_ConcatAndDel(&str,PyString_FromString(")"));
+#endif
return str;
}
SWIGINTERN int
swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
+ char *tmp;
PyObject *str = swig_varlink_str(v);
fprintf(fp,"Swig global variables ");
- fprintf(fp,"%s\n", PyString_AsString(str));
+ fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
+ SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(str);
return 0;
}
@@ -110,12 +142,17 @@ swig_varlink_type(void) {
if (!type_init) {
const PyTypeObject tmp
= {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
PyObject_HEAD_INIT(NULL)
0, /* Number of items in variable part (ob_size) */
+#endif
(char *)"swigvarlink", /* Type name (tp_name) */
sizeof(swig_varlinkobject), /* Basic size (tp_basicsize) */
0, /* Itemsize (tp_itemsize) */
- (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
+ (destructor) swig_varlink_dealloc, /* Deallocator (tp_dealloc) */
(printfunc) swig_varlink_print, /* Print (tp_print) */
(getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
(setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
@@ -126,7 +163,7 @@ swig_varlink_type(void) {
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
- (reprfunc)swig_varlink_str, /* tp_str */
+ (reprfunc) swig_varlink_str, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@@ -147,7 +184,10 @@ swig_varlink_type(void) {
#endif
};
varlink_type = tmp;
+ /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
+#if PY_VERSION_HEX < 0x03000000
varlink_type.ob_type = &PyType_Type;
+#endif
type_init = 1;
}
return &varlink_type;
@@ -272,13 +312,37 @@ SWIG_Python_FixMethods(PyMethodDef *methods,
#ifdef __cplusplus
extern "C"
#endif
-SWIGEXPORT void SWIG_init(void) {
- PyObject *m, *d;
-
+
+SWIGEXPORT
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject*
+#else
+ void
+#endif
+SWIG_init(void) {
+ PyObject *m, *d;
+#if PY_VERSION_HEX >= 0x03000000
+ static struct PyModuleDef SWIG_module = {
+ PyModuleDef_HEAD_INIT,
+ (char *) SWIG_name,
+ NULL,
+ -1,
+ SwigMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+ };
+#endif
+
/* Fix SwigMethods to carry the callback ptrs when needed */
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
-
+
+#if PY_VERSION_HEX >= 0x03000000
+ m = PyModule_Create(&SWIG_module);
+#else
m = Py_InitModule((char *) SWIG_name, SwigMethods);
+#endif
d = PyModule_GetDict(m);
SWIG_InitializeModule(0);
diff --git a/Lib/python/pyiterators.swg b/Lib/python/pyiterators.swg
index 38f1791a9..8719f73ce 100644
--- a/Lib/python/pyiterators.swg
+++ b/Lib/python/pyiterators.swg
@@ -6,56 +6,56 @@
*
* Implement a python 'output' iterator for Python 2.2 or higher.
*
- * Users can derive form the PySwigIterator to implement their
+ * Users can derive form the SwigPyIterator to implement their
* own iterators. As an example (real one since we use it for STL/STD
- * containers), the template PySwigIterator_T does the
- * implementation for genereic C++ iterators.
+ * containers), the template SwigPyIterator_T does the
+ * implementation for generic C++ iterators.
* ----------------------------------------------------------------------------- */
%include <std_common.i>
-%fragment("PySwigIterator","header") {
+%fragment("SwigPyIterator","header") {
namespace swig {
struct stop_iteration {
};
- struct PySwigIterator {
+ struct SwigPyIterator {
private:
- PyObject_ptr _seq;
+ SwigPtr_PyObject _seq;
protected:
- PySwigIterator(PyObject *seq) : _seq(seq)
+ SwigPyIterator(PyObject *seq) : _seq(seq)
{
}
public:
- virtual ~PySwigIterator() {}
+ virtual ~SwigPyIterator() {}
// Access iterator method, required by Python
virtual PyObject *value() const = 0;
// Forward iterator method, required by Python
- virtual PySwigIterator *incr(size_t n = 1) = 0;
+ virtual SwigPyIterator *incr(size_t n = 1) = 0;
// Backward iterator method, very common in C++, but not required in Python
- virtual PySwigIterator *decr(size_t /*n*/ = 1)
+ virtual SwigPyIterator *decr(size_t /*n*/ = 1)
{
throw stop_iteration();
}
// Random access iterator methods, but not required in Python
- virtual ptrdiff_t distance(const PySwigIterator &/*x*/) const
+ virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const
{
throw std::invalid_argument("operation not supported");
}
- virtual bool equal (const PySwigIterator &/*x*/) const
+ virtual bool equal (const SwigPyIterator &/*x*/) const
{
throw std::invalid_argument("operation not supported");
}
// C++ common/needed methods
- virtual PySwigIterator *copy() const = 0;
+ virtual SwigPyIterator *copy() const = 0;
PyObject *next()
{
@@ -66,6 +66,12 @@ namespace swig {
return obj;
}
+ /* Make an alias for Python 3.x */
+ PyObject *__next__()
+ {
+ return next();
+ }
+
PyObject *previous()
{
SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads
@@ -75,42 +81,42 @@ namespace swig {
return obj;
}
- PySwigIterator *advance(ptrdiff_t n)
+ SwigPyIterator *advance(ptrdiff_t n)
{
return (n > 0) ? incr(n) : decr(-n);
}
- bool operator == (const PySwigIterator& x) const
+ bool operator == (const SwigPyIterator& x) const
{
return equal(x);
}
- bool operator != (const PySwigIterator& x) const
+ bool operator != (const SwigPyIterator& x) const
{
return ! operator==(x);
}
- PySwigIterator& operator += (ptrdiff_t n)
+ SwigPyIterator& operator += (ptrdiff_t n)
{
return *advance(n);
}
- PySwigIterator& operator -= (ptrdiff_t n)
+ SwigPyIterator& operator -= (ptrdiff_t n)
{
return *advance(-n);
}
- PySwigIterator* operator + (ptrdiff_t n) const
+ SwigPyIterator* operator + (ptrdiff_t n) const
{
return copy()->advance(n);
}
- PySwigIterator* operator - (ptrdiff_t n) const
+ SwigPyIterator* operator - (ptrdiff_t n) const
{
return copy()->advance(-n);
}
- ptrdiff_t operator - (const PySwigIterator& x) const
+ ptrdiff_t operator - (const SwigPyIterator& x) const
{
return x.distance(*this);
}
@@ -119,7 +125,7 @@ namespace swig {
static int init = 0;
static swig_type_info* desc = 0;
if (!init) {
- desc = SWIG_TypeQuery("swig::PySwigIterator *");
+ desc = SWIG_TypeQuery("swig::SwigPyIterator *");
init = 1;
}
return desc;
@@ -128,18 +134,18 @@ namespace swig {
}
}
-%fragment("PySwigIterator_T","header",fragment="PySwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
+%fragment("SwigPyIterator_T","header",fragment="SwigPyIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
namespace swig {
template<typename OutIterator>
- class PySwigIterator_T : public PySwigIterator
+ class SwigPyIterator_T : public SwigPyIterator
{
public:
typedef OutIterator out_iterator;
typedef typename std::iterator_traits<out_iterator>::value_type value_type;
- typedef PySwigIterator_T<out_iterator> self_type;
+ typedef SwigPyIterator_T<out_iterator> self_type;
- PySwigIterator_T(out_iterator curr, PyObject *seq)
- : PySwigIterator(seq), current(curr)
+ SwigPyIterator_T(out_iterator curr, PyObject *seq)
+ : SwigPyIterator(seq), current(curr)
{
}
@@ -149,7 +155,7 @@ namespace swig {
}
- bool equal (const PySwigIterator &iter) const
+ bool equal (const SwigPyIterator &iter) const
{
const self_type *iters = dynamic_cast<const self_type *>(&iter);
if (iters) {
@@ -159,7 +165,7 @@ namespace swig {
}
}
- ptrdiff_t distance(const PySwigIterator &iter) const
+ ptrdiff_t distance(const SwigPyIterator &iter) const
{
const self_type *iters = dynamic_cast<const self_type *>(&iter);
if (iters) {
@@ -187,17 +193,17 @@ namespace swig {
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
- class PySwigIteratorOpen_T : public PySwigIterator_T<OutIterator>
+ class SwigPyIteratorOpen_T : public SwigPyIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
- typedef PySwigIterator_T<out_iterator> base;
- typedef PySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
+ typedef SwigPyIterator_T<out_iterator> base;
+ typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
- PySwigIteratorOpen_T(out_iterator curr, PyObject *seq)
- : PySwigIterator_T<OutIterator>(curr, seq)
+ SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
+ : SwigPyIterator_T<OutIterator>(curr, seq)
{
}
@@ -205,12 +211,12 @@ namespace swig {
return from(static_cast<const value_type&>(*(base::current)));
}
- PySwigIterator *copy() const
+ SwigPyIterator *copy() const
{
return new self_type(*this);
}
- PySwigIterator *incr(size_t n = 1)
+ SwigPyIterator *incr(size_t n = 1)
{
while (n--) {
++base::current;
@@ -218,7 +224,7 @@ namespace swig {
return this;
}
- PySwigIterator *decr(size_t n = 1)
+ SwigPyIterator *decr(size_t n = 1)
{
while (n--) {
--base::current;
@@ -230,17 +236,17 @@ namespace swig {
template<typename OutIterator,
typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
typename FromOper = from_oper<ValueType> >
- class PySwigIteratorClosed_T : public PySwigIterator_T<OutIterator>
+ class SwigPyIteratorClosed_T : public SwigPyIterator_T<OutIterator>
{
public:
FromOper from;
typedef OutIterator out_iterator;
typedef ValueType value_type;
- typedef PySwigIterator_T<out_iterator> base;
- typedef PySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
+ typedef SwigPyIterator_T<out_iterator> base;
+ typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
- PySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
- : PySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
+ SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
+ : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
{
}
@@ -252,12 +258,12 @@ namespace swig {
}
}
- PySwigIterator *copy() const
+ SwigPyIterator *copy() const
{
return new self_type(*this);
}
- PySwigIterator *incr(size_t n = 1)
+ SwigPyIterator *incr(size_t n = 1)
{
while (n--) {
if (base::current == end) {
@@ -269,7 +275,7 @@ namespace swig {
return this;
}
- PySwigIterator *decr(size_t n = 1)
+ SwigPyIterator *decr(size_t n = 1)
{
while (n--) {
if (base::current == begin) {
@@ -287,23 +293,23 @@ namespace swig {
};
template<typename OutIter>
- inline PySwigIterator*
+ inline SwigPyIterator*
make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
{
- return new PySwigIteratorClosed_T<OutIter>(current, begin, end, seq);
+ return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq);
}
template<typename OutIter>
- inline PySwigIterator*
+ inline SwigPyIterator*
make_output_iterator(const OutIter& current, PyObject *seq = 0)
{
- return new PySwigIteratorOpen_T<OutIter>(current, seq);
+ return new SwigPyIteratorOpen_T<OutIter>(current, seq);
}
}
}
-%fragment("PySwigIterator");
+%fragment("SwigPyIterator");
namespace swig
{
/*
@@ -321,65 +327,67 @@ namespace swig
/*
Mark methods that return new objects
*/
- %newobject PySwigIterator::copy;
- %newobject PySwigIterator::operator + (ptrdiff_t n) const;
- %newobject PySwigIterator::operator - (ptrdiff_t n) const;
+ %newobject SwigPyIterator::copy;
+ %newobject SwigPyIterator::operator + (ptrdiff_t n) const;
+ %newobject SwigPyIterator::operator - (ptrdiff_t n) const;
- %nodirector PySwigIterator;
- %extend PySwigIterator {
+ %nodirector SwigPyIterator;
+ %extend SwigPyIterator {
%pythoncode {def __iter__(self): return self}
}
- %catches(swig::stop_iteration) PySwigIterator::value() const;
- %catches(swig::stop_iteration) PySwigIterator::incr(size_t n = 1);
- %catches(swig::stop_iteration) PySwigIterator::decr(size_t n = 1);
- %catches(std::invalid_argument) PySwigIterator::distance(const PySwigIterator &x) const;
- %catches(std::invalid_argument) PySwigIterator::equal (const PySwigIterator &x) const;
- %catches(swig::stop_iteration) PySwigIterator::next();
- %catches(swig::stop_iteration) PySwigIterator::previous();
- %catches(swig::stop_iteration) PySwigIterator::advance(ptrdiff_t n);
- %catches(swig::stop_iteration) PySwigIterator::operator += (ptrdiff_t n);
- %catches(swig::stop_iteration) PySwigIterator::operator -= (ptrdiff_t n);
- %catches(swig::stop_iteration) PySwigIterator::operator + (ptrdiff_t n) const;
- %catches(swig::stop_iteration) PySwigIterator::operator - (ptrdiff_t n) const;
-
-
- struct PySwigIterator
+ %catches(swig::stop_iteration) SwigPyIterator::value() const;
+ %catches(swig::stop_iteration) SwigPyIterator::incr(size_t n = 1);
+ %catches(swig::stop_iteration) SwigPyIterator::decr(size_t n = 1);
+ %catches(std::invalid_argument) SwigPyIterator::distance(const SwigPyIterator &x) const;
+ %catches(std::invalid_argument) SwigPyIterator::equal (const SwigPyIterator &x) const;
+ %catches(swig::stop_iteration) SwigPyIterator::__next__();
+ %catches(swig::stop_iteration) SwigPyIterator::next();
+ %catches(swig::stop_iteration) SwigPyIterator::previous();
+ %catches(swig::stop_iteration) SwigPyIterator::advance(ptrdiff_t n);
+ %catches(swig::stop_iteration) SwigPyIterator::operator += (ptrdiff_t n);
+ %catches(swig::stop_iteration) SwigPyIterator::operator -= (ptrdiff_t n);
+ %catches(swig::stop_iteration) SwigPyIterator::operator + (ptrdiff_t n) const;
+ %catches(swig::stop_iteration) SwigPyIterator::operator - (ptrdiff_t n) const;
+
+
+ struct SwigPyIterator
{
protected:
- PySwigIterator(PyObject *seq);
+ SwigPyIterator(PyObject *seq);
public:
- virtual ~PySwigIterator();
+ virtual ~SwigPyIterator();
// Access iterator method, required by Python
virtual PyObject *value() const = 0;
// Forward iterator method, required by Python
- virtual PySwigIterator *incr(size_t n = 1) = 0;
+ virtual SwigPyIterator *incr(size_t n = 1) = 0;
// Backward iterator method, very common in C++, but not required in Python
- virtual PySwigIterator *decr(size_t n = 1);
+ virtual SwigPyIterator *decr(size_t n = 1);
// Random access iterator methods, but not required in Python
- virtual ptrdiff_t distance(const PySwigIterator &x) const;
+ virtual ptrdiff_t distance(const SwigPyIterator &x) const;
- virtual bool equal (const PySwigIterator &x) const;
+ virtual bool equal (const SwigPyIterator &x) const;
// C++ common/needed methods
- virtual PySwigIterator *copy() const = 0;
+ virtual SwigPyIterator *copy() const = 0;
PyObject *next();
+ PyObject *__next__();
PyObject *previous();
- PySwigIterator *advance(ptrdiff_t n);
-
- bool operator == (const PySwigIterator& x) const;
- bool operator != (const PySwigIterator& x) const;
- PySwigIterator& operator += (ptrdiff_t n);
- PySwigIterator& operator -= (ptrdiff_t n);
- PySwigIterator* operator + (ptrdiff_t n) const;
- PySwigIterator* operator - (ptrdiff_t n) const;
- ptrdiff_t operator - (const PySwigIterator& x) const;
+ SwigPyIterator *advance(ptrdiff_t n);
+
+ bool operator == (const SwigPyIterator& x) const;
+ bool operator != (const SwigPyIterator& x) const;
+ SwigPyIterator& operator += (ptrdiff_t n);
+ SwigPyIterator& operator -= (ptrdiff_t n);
+ SwigPyIterator* operator + (ptrdiff_t n) const;
+ SwigPyIterator* operator - (ptrdiff_t n) const;
+ ptrdiff_t operator - (const SwigPyIterator& x) const;
};
}
diff --git a/Lib/python/pyname_compat.i b/Lib/python/pyname_compat.i
new file mode 100644
index 000000000..b5acca955
--- /dev/null
+++ b/Lib/python/pyname_compat.i
@@ -0,0 +1,88 @@
+/*
+* From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py,
+* since they are inappropriate and discouraged in Python documentation
+* (from http://www.python.org/doc/2.5.2/api/includes.html):
+*
+* "All user visible names defined by Python.h (except those defined by the included
+* standard headers) have one of the prefixes "Py" or "_Py". Names beginning with
+* "_Py" are for internal use by the Python implementation and should not be used
+* by extension writers. Structure member names do not have a reserved prefix.
+*
+* Important: user code should never define names that begin with "Py" or "_Py".
+* This confuses the reader, and jeopardizes the portability of the user code to
+* future Python versions, which may define additional names beginning with one
+* of these prefixes."
+*
+* This file defined macros to provide backward compatibility for these deprecated
+* symbols. In the case you have these symbols in your interface file, you can simply
+* include this file at beginning of it.
+*
+* However, this file may be removed in future release of SWIG, so using this file to
+* keep these inappropriate names in your SWIG interface file is also not recommended.
+* Instead, we provide a simple tool for converting your interface files to
+* the new naming convention. You can download the tool here:
+* https://swig.svn.sourceforge.net/svnroot/swig/trunk/Tools/pyname_patch.py
+*/
+
+%fragment("PySequence_Base", "header", fragment="SwigPySequence_Base") {}
+%fragment("PySequence_Cont", "header", fragment="SwigPySequence_Cont") {}
+%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {}
+%fragment("PyPairBoolOutputIterator", "header", fragment="SwigPyPairBoolOutputIterator") {}
+%fragment("PySwigIterator", "header", fragment="SwigPyIterator") {}
+%fragment("PySwigIterator_T", "header", fragment="SwigPyIterator_T") {}
+
+%inline %{
+#define PyMapIterator_T SwigPyMapIterator_T
+#define PyMapKeyIterator_T SwigPyMapKeyIterator_T
+#define PyMapValueIterator_T SwigPyMapValueITerator_T
+#define PyObject_ptr SwigPtr_PyObject
+#define PyObject_var SwigVar_PyObject
+#define PyOper SwigPyOper
+#define PySeq SwigPySeq
+#define PySequence_ArrowProxy SwigPySequence_ArrowProxy
+#define PySequence_Cont SwigPySequence_Cont
+#define PySequence_InputIterator SwigPySequence_InputIterator
+#define PySequence_Ref SwigPySequence_Ref
+#define PySwigClientData SwigPyClientData
+#define PySwigClientData_Del SwigPyClientData_Del
+#define PySwigClientData_New SwigPyClientData_New
+#define PySwigIterator SwigPyIterator
+#define PySwigIteratorClosed_T SwigPyIteratorClosed_T
+#define PySwigIteratorOpen_T SwigPyIteratorOpen_T
+#define PySwigIterator_T SwigPyIterator_T
+#define PySwigObject SwigPyObject
+#define PySwigObject_Check SwigPyObject_Check
+#define PySwigObject_GetDesc SwigPyObject_GetDesc
+#define PySwigObject_New SwigPyObject_New
+#define PySwigObject_acquire SwigPyObject_acquire
+#define PySwigObject_append SwigPyObject_append
+#define PySwigObject_as_number SwigPyObject_as_number
+#define PySwigObject_compare SwigPyObject_compare
+#define PySwigObject_dealloc SwigPyObject_dealloc
+#define PySwigObject_disown SwigPyObject_disown
+#define PySwigObject_format SwigPyObject_format
+#define PySwigObject_getattr SwigPyObject_getattr
+#define PySwigObject_hex SwigPyObject_hex
+#define PySwigObject_long SwigPyObject_long
+#define PySwigObject_next SwigPyObject_next
+#define PySwigObject_oct SwigPyObject_oct
+#define PySwigObject_own SwigPyObject_own
+#define PySwigObject_print SwigPyObject_print
+#define PySwigObject_repr SwigPyObject_repr
+#define PySwigObject_richcompare SwigPyObject_richcompare
+#define PySwigObject_str SwigPyObject_str
+#define PySwigObject_type SwigPyObject_type
+#define PySwigPacked SwigPyPacked
+#define PySwigPacked_Check SwigPyPacked_Check
+#define PySwigPacked_New SwigPyPacked_New
+#define PySwigPacked_UnpackData SwigPyPacked_UnpackData
+#define PySwigPacked_compare SwigPyPacked_compare
+#define PySwigPacked_dealloc SwigPyPacked_dealloc
+#define PySwigPacked_print SwigPyPacked_print
+#define PySwigPacked_repr SwigPyPacked_repr
+#define PySwigPacked_str SwigPyPacked_str
+#define PySwigPacked_type SwigPyPacked_type
+#define pyseq swigpyseq
+#define pyswigobject_type swigpyobject_type
+#define pyswigpacked_type swigpypacked_type
+%}
diff --git a/Lib/python/pyopers.swg b/Lib/python/pyopers.swg
index 76f1e6789..30775b84e 100644
--- a/Lib/python/pyopers.swg
+++ b/Lib/python/pyopers.swg
@@ -33,6 +33,12 @@
/* Special cases */
%rename(__invert__) *::operator~;
%rename(__call__) *::operator();
+
+%feature("shadow") *::operator bool %{
+def __nonzero__(self):
+ return $action(self)
+__bool__ = __nonzero__
+%};
%rename(__nonzero__) *::operator bool;
/* Ignored operators */
@@ -84,7 +90,7 @@
*/
-#define %pyinplaceoper(PyOper, Oper) %delobject Oper; %newobject Oper; %rename(PyOper) Oper
+#define %pyinplaceoper(SwigPyOper, Oper) %delobject Oper; %newobject Oper; %rename(SwigPyOper) Oper
%pyinplaceoper(__iadd__ , *::operator +=);
%pyinplaceoper(__isub__ , *::operator -=);
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index 844a66bec..38632e1ab 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -42,7 +42,7 @@
#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj) PySwigClientData_New(obj)
+#define SWIG_NewClientData(obj) SwigPyClientData_New(obj)
#define SWIG_SetErrorObj SWIG_Python_SetErrorObj
#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg
@@ -238,7 +238,7 @@ SWIG_Py_Void(void)
return none;
}
-/* PySwigClientData */
+/* SwigPyClientData */
typedef struct {
PyObject *klass;
@@ -247,30 +247,30 @@ typedef struct {
PyObject *destroy;
int delargs;
int implicitconv;
-} PySwigClientData;
+} SwigPyClientData;
SWIGRUNTIMEINLINE int
SWIG_Python_CheckImplicit(swig_type_info *ty)
{
- PySwigClientData *data = (PySwigClientData *)ty->clientdata;
+ SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
return data ? data->implicitconv : 0;
}
SWIGRUNTIMEINLINE PyObject *
SWIG_Python_ExceptionType(swig_type_info *desc) {
- PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
+ SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
PyObject *klass = data ? data->klass : 0;
return (klass ? klass : PyExc_RuntimeError);
}
-SWIGRUNTIME PySwigClientData *
-PySwigClientData_New(PyObject* obj)
+SWIGRUNTIME SwigPyClientData *
+SwigPyClientData_New(PyObject* obj)
{
if (!obj) {
return 0;
} else {
- PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
+ SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
/* the klass element */
data->klass = obj;
Py_INCREF(data->klass);
@@ -318,14 +318,14 @@ PySwigClientData_New(PyObject* obj)
}
SWIGRUNTIME void
-PySwigClientData_Del(PySwigClientData* data)
+SwigPyClientData_Del(SwigPyClientData* data)
{
Py_XDECREF(data->newraw);
Py_XDECREF(data->newargs);
Py_XDECREF(data->destroy);
}
-/* =============== PySwigObject =====================*/
+/* =============== SwigPyObject =====================*/
typedef struct {
PyObject_HEAD
@@ -333,24 +333,28 @@ typedef struct {
swig_type_info *ty;
int own;
PyObject *next;
-} PySwigObject;
+} SwigPyObject;
SWIGRUNTIME PyObject *
-PySwigObject_long(PySwigObject *v)
+SwigPyObject_long(SwigPyObject *v)
{
return PyLong_FromVoidPtr(v->ptr);
}
SWIGRUNTIME PyObject *
-PySwigObject_format(const char* fmt, PySwigObject *v)
+SwigPyObject_format(const char* fmt, SwigPyObject *v)
{
PyObject *res = NULL;
PyObject *args = PyTuple_New(1);
if (args) {
- if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
- PyObject *ofmt = PyString_FromString(fmt);
+ if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
+ PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
if (ofmt) {
+#if PY_VERSION_HEX >= 0x03000000
+ res = PyUnicode_Format(ofmt,args);
+#else
res = PyString_Format(ofmt,args);
+#endif
Py_DECREF(ofmt);
}
Py_DECREF(args);
@@ -360,49 +364,57 @@ PySwigObject_format(const char* fmt, PySwigObject *v)
}
SWIGRUNTIME PyObject *
-PySwigObject_oct(PySwigObject *v)
+SwigPyObject_oct(SwigPyObject *v)
{
- return PySwigObject_format("%o",v);
+ return SwigPyObject_format("%o",v);
}
SWIGRUNTIME PyObject *
-PySwigObject_hex(PySwigObject *v)
+SwigPyObject_hex(SwigPyObject *v)
{
- return PySwigObject_format("%x",v);
+ return SwigPyObject_format("%x",v);
}
SWIGRUNTIME PyObject *
#ifdef METH_NOARGS
-PySwigObject_repr(PySwigObject *v)
+SwigPyObject_repr(SwigPyObject *v)
#else
-PySwigObject_repr(PySwigObject *v, PyObject *args)
+SwigPyObject_repr(SwigPyObject *v, PyObject *args)
#endif
{
const char *name = SWIG_TypePrettyName(v->ty);
- PyObject *hex = PySwigObject_hex(v);
- PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
- Py_DECREF(hex);
+ PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", name, v);
if (v->next) {
#ifdef METH_NOARGS
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
#else
- PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
+ PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
#endif
+#if PY_VERSION_HEX >= 0x03000000
+ PyObject *joined = PyUnicode_Concat(repr, nrep);
+ Py_DecRef(repr);
+ Py_DecRef(nrep);
+ repr = joined;
+#else
PyString_ConcatAndDel(&repr,nrep);
+#endif
}
return repr;
}
SWIGRUNTIME int
-PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
{
+ char *str;
#ifdef METH_NOARGS
- PyObject *repr = PySwigObject_repr(v);
+ PyObject *repr = SwigPyObject_repr(v);
#else
- PyObject *repr = PySwigObject_repr(v, NULL);
+ PyObject *repr = SwigPyObject_repr(v, NULL);
#endif
if (repr) {
- fputs(PyString_AsString(repr), fp);
+ str = SWIG_Python_str_AsChar(repr);
+ fputs(str, fp);
+ SWIG_Python_str_DelForPy3(str);
Py_DECREF(repr);
return 0;
} else {
@@ -411,53 +423,71 @@ PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
}
SWIGRUNTIME PyObject *
-PySwigObject_str(PySwigObject *v)
+SwigPyObject_str(SwigPyObject *v)
{
char result[SWIG_BUFFER_SIZE];
return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
- PyString_FromString(result) : 0;
+ SWIG_Python_str_FromChar(result) : 0;
}
SWIGRUNTIME int
-PySwigObject_compare(PySwigObject *v, PySwigObject *w)
+SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
{
void *i = v->ptr;
void *j = w->ptr;
return (i < j) ? -1 : ((i > j) ? 1 : 0);
}
+/* Added for Python 3.x, would it also be useful for Python 2.x? */
+SWIGRUNTIME PyObject*
+SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
+{
+ PyObject* res;
+ if( op != Py_EQ && op != Py_NE ) {
+ Py_INCREF(Py_NotImplemented);
+ return Py_NotImplemented;
+ }
+ if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) )
+ res = Py_True;
+ else
+ res = Py_False;
+ Py_INCREF(res);
+ return res;
+}
+
+
SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
SWIGRUNTIME PyTypeObject*
-PySwigObject_type(void) {
+SwigPyObject_type(void) {
static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
return type;
}
SWIGRUNTIMEINLINE int
-PySwigObject_Check(PyObject *op) {
- return ((op)->ob_type == PySwigObject_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
+SwigPyObject_Check(PyObject *op) {
+ return (Py_TYPE(op) == SwigPyObject_type())
+ || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
}
SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own);
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
SWIGRUNTIME void
-PySwigObject_dealloc(PyObject *v)
+SwigPyObject_dealloc(PyObject *v)
{
- PySwigObject *sobj = (PySwigObject *) v;
+ SwigPyObject *sobj = (SwigPyObject *) v;
PyObject *next = sobj->next;
if (sobj->own == SWIG_POINTER_OWN) {
swig_type_info *ty = sobj->ty;
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+ SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
PyObject *destroy = data ? data->destroy : 0;
if (destroy) {
/* destroy is always a VARARGS method */
PyObject *res;
if (data->delargs) {
- /* we need to create a temporal object to carry the destroy operation */
- PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
+ /* we need to create a temporary object to carry the destroy operation */
+ PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
res = SWIG_Python_CallFunctor(destroy, tmp);
Py_DECREF(tmp);
} else {
@@ -479,15 +509,15 @@ PySwigObject_dealloc(PyObject *v)
}
SWIGRUNTIME PyObject*
-PySwigObject_append(PyObject* v, PyObject* next)
+SwigPyObject_append(PyObject* v, PyObject* next)
{
- PySwigObject *sobj = (PySwigObject *) v;
+ SwigPyObject *sobj = (SwigPyObject *) v;
#ifndef METH_O
PyObject *tmp = 0;
if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
next = tmp;
#endif
- if (!PySwigObject_Check(next)) {
+ if (!SwigPyObject_Check(next)) {
return NULL;
}
sobj->next = next;
@@ -497,12 +527,12 @@ PySwigObject_append(PyObject* v, PyObject* next)
SWIGRUNTIME PyObject*
#ifdef METH_NOARGS
-PySwigObject_next(PyObject* v)
+SwigPyObject_next(PyObject* v)
#else
-PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
#endif
{
- PySwigObject *sobj = (PySwigObject *) v;
+ SwigPyObject *sobj = (SwigPyObject *) v;
if (sobj->next) {
Py_INCREF(sobj->next);
return sobj->next;
@@ -513,30 +543,30 @@ PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
SWIGINTERN PyObject*
#ifdef METH_NOARGS
-PySwigObject_disown(PyObject *v)
+SwigPyObject_disown(PyObject *v)
#else
-PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
#endif
{
- PySwigObject *sobj = (PySwigObject *)v;
+ SwigPyObject *sobj = (SwigPyObject *)v;
sobj->own = 0;
return SWIG_Py_Void();
}
SWIGINTERN PyObject*
#ifdef METH_NOARGS
-PySwigObject_acquire(PyObject *v)
+SwigPyObject_acquire(PyObject *v)
#else
-PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
#endif
{
- PySwigObject *sobj = (PySwigObject *)v;
+ SwigPyObject *sobj = (SwigPyObject *)v;
sobj->own = SWIG_POINTER_OWN;
return SWIG_Py_Void();
}
SWIGINTERN PyObject*
-PySwigObject_own(PyObject *v, PyObject *args)
+SwigPyObject_own(PyObject *v, PyObject *args)
{
PyObject *val = 0;
#if (PY_VERSION_HEX < 0x02020000)
@@ -549,20 +579,20 @@ PySwigObject_own(PyObject *v, PyObject *args)
}
else
{
- PySwigObject *sobj = (PySwigObject *)v;
+ SwigPyObject *sobj = (SwigPyObject *)v;
PyObject *obj = PyBool_FromLong(sobj->own);
if (val) {
#ifdef METH_NOARGS
if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v);
+ SwigPyObject_acquire(v);
} else {
- PySwigObject_disown(v);
+ SwigPyObject_disown(v);
}
#else
if (PyObject_IsTrue(val)) {
- PySwigObject_acquire(v,args);
+ SwigPyObject_acquire(v,args);
} else {
- PySwigObject_disown(v,args);
+ SwigPyObject_disown(v,args);
}
#endif
}
@@ -573,30 +603,30 @@ PySwigObject_own(PyObject *v, PyObject *args)
#ifdef METH_O
static PyMethodDef
swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"},
+ {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"},
{0, 0, 0, 0}
};
#else
static PyMethodDef
swigobject_methods[] = {
- {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
- {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
- {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
- {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
- {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
- {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"},
+ {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"},
+ {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"},
+ {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+ {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"},
+ {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"},
+ {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"},
{0, 0, 0, 0}
};
#endif
#if PY_VERSION_HEX < 0x02020000
SWIGINTERN PyObject *
-PySwigObject_getattr(PySwigObject *sobj,char *name)
+SwigPyObject_getattr(SwigPyObject *sobj,char *name)
{
return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
}
@@ -606,11 +636,14 @@ SWIGRUNTIME PyTypeObject*
_PySwigObject_type(void) {
static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
- static PyNumberMethods PySwigObject_as_number = {
+ static PyNumberMethods SwigPyObject_as_number = {
(binaryfunc)0, /*nb_add*/
(binaryfunc)0, /*nb_subtract*/
(binaryfunc)0, /*nb_multiply*/
+ /* nb_divide removed in Python 3 */
+#if PY_VERSION_HEX < 0x03000000
(binaryfunc)0, /*nb_divide*/
+#endif
(binaryfunc)0, /*nb_remainder*/
(binaryfunc)0, /*nb_divmod*/
(ternaryfunc)0,/*nb_power*/
@@ -624,13 +657,23 @@ _PySwigObject_type(void) {
0, /*nb_and*/
0, /*nb_xor*/
0, /*nb_or*/
- (coercion)0, /*nb_coerce*/
- (unaryfunc)PySwigObject_long, /*nb_int*/
- (unaryfunc)PySwigObject_long, /*nb_long*/
+#if PY_VERSION_HEX < 0x03000000
+ 0, /*nb_coerce*/
+#endif
+ (unaryfunc)SwigPyObject_long, /*nb_int*/
+#if PY_VERSION_HEX < 0x03000000
+ (unaryfunc)SwigPyObject_long, /*nb_long*/
+#else
+ 0, /*nb_reserved*/
+#endif
(unaryfunc)0, /*nb_float*/
- (unaryfunc)PySwigObject_oct, /*nb_oct*/
- (unaryfunc)PySwigObject_hex, /*nb_hex*/
-#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
+#if PY_VERSION_HEX < 0x03000000
+ (unaryfunc)SwigPyObject_oct, /*nb_oct*/
+ (unaryfunc)SwigPyObject_hex, /*nb_hex*/
+#endif
+#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
+#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
@@ -639,32 +682,41 @@ _PySwigObject_type(void) {
#endif
};
- static PyTypeObject pyswigobject_type;
+ static PyTypeObject swigpyobject_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp
= {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX >= 0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
- (char *)"PySwigObject", /* tp_name */
- sizeof(PySwigObject), /* tp_basicsize */
+#endif
+ (char *)"SwigPyObject", /* tp_name */
+ sizeof(SwigPyObject), /* tp_basicsize */
0, /* tp_itemsize */
- (destructor)PySwigObject_dealloc, /* tp_dealloc */
- (printfunc)PySwigObject_print, /* tp_print */
+ (destructor)SwigPyObject_dealloc, /* tp_dealloc */
+ (printfunc)SwigPyObject_print, /* tp_print */
#if PY_VERSION_HEX < 0x02020000
- (getattrfunc)PySwigObject_getattr, /* tp_getattr */
+ (getattrfunc)SwigPyObject_getattr, /* tp_getattr */
#else
(getattrfunc)0, /* tp_getattr */
#endif
(setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigObject_compare, /* tp_compare */
- (reprfunc)PySwigObject_repr, /* tp_repr */
- &PySwigObject_as_number, /* tp_as_number */
+#if PY_VERSION_HEX >= 0x03000000
+ 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
+#else
+ (cmpfunc)SwigPyObject_compare, /* tp_compare */
+#endif
+ (reprfunc)SwigPyObject_repr, /* tp_repr */
+ &SwigPyObject_as_number, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigObject_str, /* tp_str */
+ (reprfunc)SwigPyObject_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@@ -672,7 +724,7 @@ _PySwigObject_type(void) {
swigobject_doc, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
- 0, /* tp_richcompare */
+ (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */
0, /* tp_weaklistoffset */
#if PY_VERSION_HEX >= 0x02020000
0, /* tp_iter */
@@ -689,11 +741,11 @@ _PySwigObject_type(void) {
0, /* tp_alloc */
0, /* tp_new */
0, /* tp_free */
- 0, /* tp_is_gc */
+ 0, /* tp_is_gc */
0, /* tp_bases */
0, /* tp_mro */
0, /* tp_cache */
- 0, /* tp_subclasses */
+ 0, /* tp_subclasses */
0, /* tp_weaklist */
#endif
#if PY_VERSION_HEX >= 0x02030000
@@ -703,17 +755,20 @@ _PySwigObject_type(void) {
0,0,0,0 /* tp_alloc -> tp_next */
#endif
};
- pyswigobject_type = tmp;
- pyswigobject_type.ob_type = &PyType_Type;
+ swigpyobject_type = tmp;
+ /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */
+#if PY_VERSION_HEX < 0x03000000
+ swigpyobject_type.ob_type = &PyType_Type;
+#endif
type_init = 1;
}
- return &pyswigobject_type;
+ return &swigpyobject_type;
}
SWIGRUNTIME PyObject *
-PySwigObject_New(void *ptr, swig_type_info *ty, int own)
+SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
{
- PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
+ SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
if (sobj) {
sobj->ptr = ptr;
sobj->ty = ty;
@@ -732,10 +787,10 @@ typedef struct {
void *pack;
swig_type_info *ty;
size_t size;
-} PySwigPacked;
+} SwigPyPacked;
SWIGRUNTIME int
-PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
{
char result[SWIG_BUFFER_SIZE];
fputs("<Swig Packed ", fp);
@@ -749,29 +804,29 @@ PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
}
SWIGRUNTIME PyObject *
-PySwigPacked_repr(PySwigPacked *v)
+SwigPyPacked_repr(SwigPyPacked *v)
{
char result[SWIG_BUFFER_SIZE];
if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
- return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+ return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
} else {
- return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
+ return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
}
}
SWIGRUNTIME PyObject *
-PySwigPacked_str(PySwigPacked *v)
+SwigPyPacked_str(SwigPyPacked *v)
{
char result[SWIG_BUFFER_SIZE];
if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
- return PyString_FromFormat("%s%s", result, v->ty->name);
+ return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
} else {
- return PyString_FromString(v->ty->name);
+ return SWIG_Python_str_FromChar(v->ty->name);
}
}
SWIGRUNTIME int
-PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
+SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
{
size_t i = v->size;
size_t j = w->size;
@@ -782,22 +837,22 @@ PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
SWIGRUNTIME PyTypeObject*
-PySwigPacked_type(void) {
+SwigPyPacked_type(void) {
static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
return type;
}
SWIGRUNTIMEINLINE int
-PySwigPacked_Check(PyObject *op) {
+SwigPyPacked_Check(PyObject *op) {
return ((op)->ob_type == _PySwigPacked_type())
- || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
+ || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
}
SWIGRUNTIME void
-PySwigPacked_dealloc(PyObject *v)
+SwigPyPacked_dealloc(PyObject *v)
{
- if (PySwigPacked_Check(v)) {
- PySwigPacked *sobj = (PySwigPacked *) v;
+ if (SwigPyPacked_Check(v)) {
+ SwigPyPacked *sobj = (SwigPyPacked *) v;
free(sobj->pack);
}
PyObject_DEL(v);
@@ -806,28 +861,37 @@ PySwigPacked_dealloc(PyObject *v)
SWIGRUNTIME PyTypeObject*
_PySwigPacked_type(void) {
static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
- static PyTypeObject pyswigpacked_type;
+ static PyTypeObject swigpypacked_type;
static int type_init = 0;
if (!type_init) {
const PyTypeObject tmp
= {
+ /* PyObject header changed in Python 3 */
+#if PY_VERSION_HEX>=0x03000000
+ PyVarObject_HEAD_INIT(&PyType_Type, 0)
+#else
PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- (char *)"PySwigPacked", /* tp_name */
- sizeof(PySwigPacked), /* tp_basicsize */
+ 0, /* ob_size */
+#endif
+ (char *)"SwigPyPacked", /* tp_name */
+ sizeof(SwigPyPacked), /* tp_basicsize */
0, /* tp_itemsize */
- (destructor)PySwigPacked_dealloc, /* tp_dealloc */
- (printfunc)PySwigPacked_print, /* tp_print */
+ (destructor)SwigPyPacked_dealloc, /* tp_dealloc */
+ (printfunc)SwigPyPacked_print, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
- (cmpfunc)PySwigPacked_compare, /* tp_compare */
- (reprfunc)PySwigPacked_repr, /* tp_repr */
- 0, /* tp_as_number */
+#if PY_VERSION_HEX>=0x03000000
+ 0, /* tp_reserved in 3.0.1 */
+#else
+ (cmpfunc)SwigPyPacked_compare, /* tp_compare */
+#endif
+ (reprfunc)SwigPyPacked_repr, /* tp_repr */
+ 0, /* tp_as_number */
0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- (hashfunc)0, /* tp_hash */
- (ternaryfunc)0, /* tp_call */
- (reprfunc)PySwigPacked_str, /* tp_str */
+ 0, /* tp_as_mapping */
+ (hashfunc)0, /* tp_hash */
+ (ternaryfunc)0, /* tp_call */
+ (reprfunc)SwigPyPacked_str, /* tp_str */
PyObject_GenericGetAttr, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
@@ -866,17 +930,20 @@ _PySwigPacked_type(void) {
0,0,0,0 /* tp_alloc -> tp_next */
#endif
};
- pyswigpacked_type = tmp;
- pyswigpacked_type.ob_type = &PyType_Type;
+ swigpypacked_type = tmp;
+ /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */
+#if PY_VERSION_HEX < 0x03000000
+ swigpypacked_type.ob_type = &PyType_Type;
+#endif
type_init = 1;
}
- return &pyswigpacked_type;
+ return &swigpypacked_type;
}
SWIGRUNTIME PyObject *
-PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
+SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
{
- PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
+ SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
if (sobj) {
void *pack = malloc(size);
if (pack) {
@@ -893,10 +960,10 @@ PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
}
SWIGRUNTIME swig_type_info *
-PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
{
- if (PySwigPacked_Check(obj)) {
- PySwigPacked *sobj = (PySwigPacked *)obj;
+ if (SwigPyPacked_Check(obj)) {
+ SwigPyPacked *sobj = (SwigPyPacked *)obj;
if (sobj->size != size) return 0;
memcpy(ptr, sobj->pack, size);
return sobj->ty;
@@ -912,7 +979,7 @@ PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
SWIGRUNTIMEINLINE PyObject *
_SWIG_This(void)
{
- return PyString_FromString("this");
+ return SWIG_Python_str_FromChar("this");
}
SWIGRUNTIME PyObject *
@@ -924,11 +991,16 @@ SWIG_This(void)
/* #define SWIG_PYTHON_SLOW_GETSET_THIS */
-SWIGRUNTIME PySwigObject *
+/* TODO: I don't know how to implement the fast getset in Python 3 right now */
+#if PY_VERSION_HEX>=0x03000000
+#define SWIG_PYTHON_SLOW_GETSET_THIS
+#endif
+
+SWIGRUNTIME SwigPyObject *
SWIG_Python_GetSwigThis(PyObject *pyobj)
{
- if (PySwigObject_Check(pyobj)) {
- return (PySwigObject *) pyobj;
+ if (SwigPyObject_Check(pyobj)) {
+ return (SwigPyObject *) pyobj;
} else {
PyObject *obj = 0;
#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
@@ -964,12 +1036,12 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
return 0;
}
#endif
- if (obj && !PySwigObject_Check(obj)) {
+ if (obj && !SwigPyObject_Check(obj)) {
/* a PyObject is called 'this', try to get the 'real this'
- PySwigObject from it */
+ SwigPyObject from it */
return SWIG_Python_GetSwigThis(obj);
}
- return (PySwigObject *)obj;
+ return (SwigPyObject *)obj;
}
}
@@ -978,7 +1050,7 @@ SWIG_Python_GetSwigThis(PyObject *pyobj)
SWIGRUNTIME int
SWIG_Python_AcquirePtr(PyObject *obj, int own) {
if (own == SWIG_POINTER_OWN) {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
if (sobj) {
int oldown = sobj->own;
sobj->own = own;
@@ -997,7 +1069,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
if (ptr) *ptr = 0;
return SWIG_OK;
} else {
- PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+ SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
if (own)
*own = 0;
while (sobj) {
@@ -1011,7 +1083,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
} else {
swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
if (!tc) {
- sobj = (PySwigObject *)sobj->next;
+ sobj = (SwigPyObject *)sobj->next;
} else {
if (ptr) {
int newmemory = 0;
@@ -1040,7 +1112,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
} else {
int res = SWIG_ERROR;
if (flags & SWIG_POINTER_IMPLICIT_CONV) {
- PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+ SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
if (data && !data->implicitconv) {
PyObject *klass = data->klass;
if (klass) {
@@ -1053,7 +1125,7 @@ SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int
impconv = 0;
}
if (impconv) {
- PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
+ SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
if (iobj) {
void *vptr;
res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
@@ -1115,7 +1187,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
SWIGRUNTIME int
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
- swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
+ swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
if (!to) return SWIG_ERROR;
if (ty) {
if (to != ty) {
@@ -1132,12 +1204,12 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t
* ----------------------------------------------------------------------------- */
/*
- Create a new instance object, whitout calling __init__, and set the
+ Create a new instance object, without calling __init__, and set the
'this' attribute.
*/
SWIGRUNTIME PyObject*
-SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
+SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
{
#if (PY_VERSION_HEX >= 0x02020000)
PyObject *inst = 0;
@@ -1161,10 +1233,16 @@ SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
#endif
}
} else {
+#if PY_VERSION_HEX >= 0x03000000
+ inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
+ PyObject_SetAttr(inst, SWIG_This(), swig_this);
+ Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
+#else
PyObject *dict = PyDict_New();
PyDict_SetItem(dict, SWIG_This(), swig_this);
inst = PyInstance_NewRaw(data->newargs, dict);
Py_DECREF(dict);
+#endif
}
return inst;
#else
@@ -1227,9 +1305,9 @@ SWIG_Python_InitShadowInstance(PyObject *args) {
if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
return NULL;
} else {
- PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+ SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
if (sthis) {
- PySwigObject_append((PyObject*) sthis, obj[1]);
+ SwigPyObject_append((PyObject*) sthis, obj[1]);
} else {
SWIG_Python_SetSwigThis(obj[0], obj[1]);
}
@@ -1245,8 +1323,8 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
return SWIG_Py_Void();
} else {
int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
- PyObject *robj = PySwigObject_New(ptr, type, own);
- PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
+ PyObject *robj = SwigPyObject_New(ptr, type, own);
+ SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
if (inst) {
@@ -1262,7 +1340,7 @@ SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
SWIGRUNTIMEINLINE PyObject *
SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
- return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+ return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
}
/* -----------------------------------------------------------------------------*
@@ -1333,8 +1411,8 @@ SWIG_Python_DestroyModule(void *vptr)
for (i =0; i < swig_module->size; ++i) {
swig_type_info *ty = types[i];
if (ty->owndata) {
- PySwigClientData *data = (PySwigClientData *) ty->clientdata;
- if (data) PySwigClientData_Del(data);
+ SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
+ if (data) SwigPyClientData_Del(data);
}
}
Py_DECREF(SWIG_This());
@@ -1344,8 +1422,13 @@ SWIGRUNTIME void
SWIG_Python_SetModule(swig_module_info *swig_module) {
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+#if PY_VERSION_HEX >= 0x03000000
+ /* Add a dummy module object into sys.modules */
+ PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
+#else
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
swig_empty_runtime_method_table);
+#endif
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
if (pointer && module) {
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
@@ -1365,7 +1448,7 @@ SWIGRUNTIME swig_type_info *
SWIG_Python_TypeQuery(const char *type)
{
PyObject *cache = SWIG_Python_TypeCache();
- PyObject *key = PyString_FromString(type);
+ PyObject *key = SWIG_Python_str_FromChar(type);
PyObject *obj = PyDict_GetItem(cache, key);
swig_type_info *descriptor;
if (obj) {
@@ -1392,21 +1475,23 @@ SWIG_Python_TypeQuery(const char *type)
SWIGRUNTIME int
SWIG_Python_AddErrMesg(const char* mesg, int infront)
-{
+{
if (PyErr_Occurred()) {
PyObject *type = 0;
PyObject *value = 0;
PyObject *traceback = 0;
PyErr_Fetch(&type, &value, &traceback);
if (value) {
+ char *tmp;
PyObject *old_str = PyObject_Str(value);
Py_XINCREF(type);
PyErr_Clear();
if (infront) {
- PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
+ PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
} else {
- PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
+ PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
}
+ SWIG_Python_str_DelForPy3(tmp);
Py_DECREF(old_str);
}
return 1;
@@ -1429,9 +1514,9 @@ SWIG_Python_ArgFail(int argnum)
}
SWIGRUNTIMEINLINE const char *
-PySwigObject_GetDesc(PyObject *self)
+SwigPyObject_GetDesc(PyObject *self)
{
- PySwigObject *v = (PySwigObject *)self;
+ SwigPyObject *v = (SwigPyObject *)self;
swig_type_info *ty = v ? v->ty : 0;
return ty ? ty->str : (char*)"";
}
@@ -1441,10 +1526,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
{
if (type) {
#if defined(SWIG_COBJECT_TYPES)
- if (obj && PySwigObject_Check(obj)) {
- const char *otype = (const char *) PySwigObject_GetDesc(obj);
+ if (obj && SwigPyObject_Check(obj)) {
+ const char *otype = (const char *) SwigPyObject_GetDesc(obj);
if (otype) {
- PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
+ PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
type, otype);
return;
}
@@ -1454,10 +1539,11 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
const char *otype = (obj ? obj->ob_type->tp_name : 0);
if (otype) {
PyObject *str = PyObject_Str(obj);
- const char *cstr = str ? PyString_AsString(str) : 0;
+ const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
if (cstr) {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
type, otype, cstr);
+ SWIG_Python_str_DelForPy3(cstr);
} else {
PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
type, otype);
@@ -1479,10 +1565,12 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
void *result;
if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
PyErr_Clear();
- if (flags & SWIG_POINTER_EXCEPTION) {
+#if SWIG_POINTER_EXCEPTION
+ if (flags) {
SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
SWIG_Python_ArgFail(argnum);
}
+#endif
}
return result;
}
diff --git a/Lib/python/pystdcommon.swg b/Lib/python/pystdcommon.swg
index 48b1fdcd5..7e9720cc0 100644
--- a/Lib/python/pystdcommon.swg
+++ b/Lib/python/pystdcommon.swg
@@ -46,7 +46,7 @@ namespace swig {
struct traits_asptr {
static int asptr(PyObject *obj, Type **val) {
Type *p;
- int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0;
+ int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
diff --git a/Lib/python/pystrings.swg b/Lib/python/pystrings.swg
index d4d60c42b..1983037a5 100644
--- a/Lib/python/pystrings.swg
+++ b/Lib/python/pystrings.swg
@@ -5,10 +5,28 @@
SWIGINTERN int
SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
{
- if (PyString_Check(obj)) {
+%#if PY_VERSION_HEX>=0x03000000
+ if (PyUnicode_Check(obj))
+%#else
+ if (PyString_Check(obj))
+%#endif
+ {
char *cstr; Py_ssize_t len;
+%#if PY_VERSION_HEX>=0x03000000
+ if (!alloc && cptr) {
+ /* We can't allow converting without allocation, since the internal
+ representation of string in Python 3 is UCS-2/UCS-4 but we require
+ a UTF-8 representation.
+ TODO(bhy) More detailed explanation */
+ return SWIG_RuntimeError;
+ }
+ obj = PyUnicode_AsUTF8String(obj);
+ PyBytes_AsStringAndSize(obj, &cstr, &len);
+ if(alloc) *alloc = SWIG_NEWOBJ;
+%#else
PyString_AsStringAndSize(obj, &cstr, &len);
- if (cptr) {
+%#endif
+ if (cptr) {
if (alloc) {
/*
In python the user should not be able to modify the inner
@@ -33,10 +51,16 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
*alloc = SWIG_OLDOBJ;
}
} else {
- *cptr = PyString_AsString(obj);
+ %#if PY_VERSION_HEX>=0x03000000
+ assert(0); /* Should never reach here in Python 3 */
+ %#endif
+ *cptr = SWIG_Python_str_AsChar(obj);
}
}
if (psize) *psize = len + 1;
+%#if PY_VERSION_HEX>=0x03000000
+ Py_XDECREF(obj);
+%#endif
return SWIG_OK;
} else {
swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
@@ -64,7 +88,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
return pchar_descriptor ?
SWIG_NewPointerObj(%const_cast(carray,char *), pchar_descriptor, 0) : SWIG_Py_Void();
} else {
+%#if PY_VERSION_HEX >= 0x03000000
+ return PyUnicode_FromStringAndSize(carray, %numeric_cast(size,int));
+%#else
return PyString_FromStringAndSize(carray, %numeric_cast(size,int));
+%#endif
}
} else {
return SWIG_Py_Void();
diff --git a/Lib/python/pytypemaps.swg b/Lib/python/pytypemaps.swg
index 2d0aa576c..e8df069ef 100644
--- a/Lib/python/pytypemaps.swg
+++ b/Lib/python/pytypemaps.swg
@@ -88,7 +88,7 @@
if ($result) {
PyObject *robj = PyObject_CallMethod($result, (char *)"__deref__", NULL);
if (robj && !PyErr_Occurred()) {
- PySwigObject_append((PyObject *) SWIG_Python_GetSwigThis($result),
+ SwigPyObject_append((PyObject *) SWIG_Python_GetSwigThis($result),
(PyObject *) SWIG_Python_GetSwigThis(robj));
Py_DECREF(robj);
}
diff --git a/Lib/python/pywstrings.swg b/Lib/python/pywstrings.swg
index 8254bf8f7..7c36f248d 100644
--- a/Lib/python/pywstrings.swg
+++ b/Lib/python/pywstrings.swg
@@ -8,14 +8,16 @@ SWIG_AsWCharPtrAndSize(PyObject *obj, wchar_t **cptr, size_t *psize, int *alloc)
{
PyObject *tmp = 0;
int isunicode = PyUnicode_Check(obj);
+%#if PY_VERSION_HEX < 0x03000000
if (!isunicode && PyString_Check(obj)) {
if (cptr) {
obj = tmp = PyUnicode_FromObject(obj);
}
isunicode = 1;
}
+%#endif
if (isunicode) {
- int len = PyUnicode_GetSize(obj);
+ Py_ssize_t len = PyUnicode_GetSize(obj);
if (cptr) {
*cptr = %new_array(len + 1, wchar_t);
PyUnicode_AsWideChar((PyUnicodeObject *)obj, *cptr, len);
diff --git a/Lib/python/std_carray.i b/Lib/python/std_carray.i
index 2e40757f2..680d67115 100644
--- a/Lib/python/std_carray.i
+++ b/Lib/python/std_carray.i
@@ -17,7 +17,7 @@ namespace swig {
%extend std::carray {
%fragment(SWIG_Traits_frag(std::carray<_Type, _Size >), "header",
- fragment="PySwigIterator_T",
+ fragment="SwigPyIterator_T",
fragment=SWIG_Traits_frag(_Type),
fragment="StdCarrayTraits") {
namespace swig {
@@ -36,7 +36,7 @@ namespace swig {
%typemap(out,noblock=1) iterator, const_iterator {
$result = SWIG_NewPointerObj(swig::make_output_iterator((const $type &)$1),
- swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+ swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
}
inline size_t __len__() const { return self->size(); }
@@ -46,7 +46,7 @@ namespace swig {
inline void __setitem__(size_t i, const _Type& v) { (*self)[i] = v; }
- swig::PySwigIterator* __iter__(PyObject **PYTHON_SELF) {
+ swig::SwigPyIterator* __iter__(PyObject **PYTHON_SELF) {
return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
}
diff --git a/Lib/python/std_map.i b/Lib/python/std_map.i
index 12dc23ccf..c93ffe61b 100644
--- a/Lib/python/std_map.i
+++ b/Lib/python/std_map.i
@@ -5,12 +5,12 @@
%fragment("StdMapTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
- template <class PySeq, class K, class T >
+ template <class SwigPySeq, class K, class T >
inline void
- assign(const PySeq& pyseq, std::map<K,T > *map) {
+ assign(const SwigPySeq& swigpyseq, std::map<K,T > *map) {
typedef typename std::map<K,T>::value_type value_type;
- typename PySeq::const_iterator it = pyseq.begin();
- for (;it != pyseq.end(); ++it) {
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
map->insert(value_type(it->first, it->second));
}
}
@@ -21,7 +21,11 @@
static int asptr(PyObject *obj, map_type **val) {
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
- PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL);
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
+%#if PY_VERSION_HEX >= 0x03000000
+ /* In Python 3.x the ".items()" method return a dict_items object */
+ items = PySequence_Fast(items, ".items() havn't returned a sequence!");
+%#endif
res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
map_type *p;
@@ -54,8 +58,8 @@
}
PyObject *obj = PyDict_New();
for (const_iterator i= map.begin(); i!= map.end(); ++i) {
- swig::PyObject_var key = swig::from(i->first);
- swig::PyObject_var val = swig::from(i->second);
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
@@ -86,10 +90,10 @@
};
template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
- struct PyMapIterator_T : PySwigIteratorClosed_T<OutIterator, ValueType, FromOper>
+ struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
{
- PyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
- : PySwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
+ SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
{
}
};
@@ -97,37 +101,37 @@
template<class OutIterator,
class FromOper = from_key_oper<typename OutIterator::value_type> >
- struct PyMapKeyIterator_T : PyMapIterator_T<OutIterator, FromOper>
+ struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
- PyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
- : PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+ SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
- inline PySwigIterator*
+ inline SwigPyIterator*
make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
- return new PyMapKeyIterator_T<OutIter>(current, begin, end, seq);
+ return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
}
template<class OutIterator,
class FromOper = from_value_oper<typename OutIterator::value_type> >
- struct PyMapValueIterator_T : PyMapIterator_T<OutIterator, FromOper>
+ struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
{
- PyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
- : PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+ SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+ : SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
{
}
};
template<typename OutIter>
- inline PySwigIterator*
+ inline SwigPyIterator*
make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
{
- return new PyMapValueIterator_T<OutIter>(current, begin, end, seq);
+ return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
}
}
}
@@ -218,12 +222,12 @@
}
%newobject key_iterator(PyObject **PYTHON_SELF);
- swig::PySwigIterator* key_iterator(PyObject **PYTHON_SELF) {
+ swig::SwigPyIterator* key_iterator(PyObject **PYTHON_SELF) {
return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
%newobject value_iterator(PyObject **PYTHON_SELF);
- swig::PySwigIterator* value_iterator(PyObject **PYTHON_SELF) {
+ swig::SwigPyIterator* value_iterator(PyObject **PYTHON_SELF) {
return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
}
diff --git a/Lib/python/std_multimap.i b/Lib/python/std_multimap.i
index f923af06b..58336bc4b 100644
--- a/Lib/python/std_multimap.i
+++ b/Lib/python/std_multimap.i
@@ -6,12 +6,12 @@
%fragment("StdMultimapTraits","header",fragment="StdSequenceTraits")
{
namespace swig {
- template <class PySeq, class K, class T >
+ template <class SwigPySeq, class K, class T >
inline void
- assign(const PySeq& pyseq, std::multimap<K,T > *multimap) {
+ assign(const SwigPySeq& swigpyseq, std::multimap<K,T > *multimap) {
typedef typename std::multimap<K,T>::value_type value_type;
- typename PySeq::const_iterator it = pyseq.begin();
- for (;it != pyseq.end(); ++it) {
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
multimap->insert(value_type(it->first, it->second));
}
}
@@ -22,7 +22,7 @@
static int asptr(PyObject *obj, std::multimap<K,T> **val) {
int res = SWIG_ERROR;
if (PyDict_Check(obj)) {
- PyObject_var items = PyObject_CallMethod(obj,(char *)"items",NULL);
+ SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
return traits_asptr_stdseq<std::multimap<K,T>, std::pair<K, T> >::asptr(items, val);
} else {
multimap_type *p;
@@ -55,8 +55,8 @@
}
PyObject *obj = PyDict_New();
for (const_iterator i= multimap.begin(); i!= multimap.end(); ++i) {
- swig::PyObject_var key = swig::from(i->first);
- swig::PyObject_var val = swig::from(i->second);
+ swig::SwigVar_PyObject key = swig::from(i->first);
+ swig::SwigVar_PyObject val = swig::from(i->second);
PyDict_SetItem(obj, key, val);
}
return obj;
diff --git a/Lib/python/std_multiset.i b/Lib/python/std_multiset.i
index 35a689026..ac430334c 100644
--- a/Lib/python/std_multiset.i
+++ b/Lib/python/std_multiset.i
@@ -7,13 +7,13 @@
%fragment("StdMultisetTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
- template <class PySeq, class T>
+ template <class SwigPySeq, class T>
inline void
- assign(const PySeq& pyseq, std::multiset<T>* seq) {
- // seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented
- typedef typename PySeq::value_type value_type;
- typename PySeq::const_iterator it = pyseq.begin();
- for (;it != pyseq.end(); ++it) {
+ assign(const SwigPySeq& swigpyseq, std::multiset<T>* seq) {
+ // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}
diff --git a/Lib/python/std_pair.i b/Lib/python/std_pair.i
index 673e85eef..bc8ccaade 100644
--- a/Lib/python/std_pair.i
+++ b/Lib/python/std_pair.i
@@ -42,8 +42,8 @@
}
} else if (PySequence_Check(obj)) {
if (PySequence_Size(obj) == 2) {
- swig::PyObject_var first = PySequence_GetItem(obj,0);
- swig::PyObject_var second = PySequence_GetItem(obj,1);
+ swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
+ swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
res = get_pair(first, second, val);
}
} else {
@@ -92,8 +92,8 @@
}
} else if (PySequence_Check(obj)) {
if (PySequence_Size(obj) == 2) {
- swig::PyObject_var first = PySequence_GetItem(obj,0);
- swig::PyObject_var second = PySequence_GetItem(obj,1);
+ swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
+ swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
res = get_pair(first, second, val);
}
} else {
diff --git a/Lib/python/std_set.i b/Lib/python/std_set.i
index 94ef667e2..59f69cdc9 100644
--- a/Lib/python/std_set.i
+++ b/Lib/python/std_set.i
@@ -5,13 +5,13 @@
%fragment("StdSetTraits","header",fragment="StdSequenceTraits")
%{
namespace swig {
- template <class PySeq, class T>
+ template <class SwigPySeq, class T>
inline void
- assign(const PySeq& pyseq, std::set<T>* seq) {
- // seq->insert(pyseq.begin(), pyseq.end()); // not used as not always implemented
- typedef typename PySeq::value_type value_type;
- typename PySeq::const_iterator it = pyseq.begin();
- for (;it != pyseq.end(); ++it) {
+ assign(const SwigPySeq& swigpyseq, std::set<T>* seq) {
+ // seq->insert(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
+ typedef typename SwigPySeq::value_type value_type;
+ typename SwigPySeq::const_iterator it = swigpyseq.begin();
+ for (;it != swigpyseq.end(); ++it) {
seq->insert(seq->end(),(value_type)(*it));
}
}
diff --git a/Lib/r/r.swg b/Lib/r/r.swg
index 0ab7e11a0..7fd6d761f 100644
--- a/Lib/r/r.swg
+++ b/Lib/r/r.swg
@@ -55,14 +55,63 @@ SWIG_InitializeModule(0);
%typemap(out) void "";
-%typemap(in) int *, int[ANY] %{
- $1 = INTEGER($input);
-%}
+%typemap(in) int *, int[ANY],
+ signed int *, signed int[ANY],
+ unsigned int *, unsigned int[ANY],
+ short *, short[ANY],
+ signed short *, signed short[ANY],
+ unsigned short *, unsigned short[ANY],
+ long *, long[ANY],
+ signed long *, signed long[ANY],
+ unsigned long *, unsigned long[ANY],
+ long long *, long long[ANY],
+ signed long long *, signed long long[ANY],
+ unsigned long long *, unsigned long long[ANY]
+
+{
+{ int _rswigi;
+ int _rswiglen = LENGTH($input);
+ $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype);
+ for (_rswigi=0; _rswigi< _rswiglen; _rswigi++) {
+ $1[_rswigi] = INTEGER($input)[_rswigi];
+ }
+}
+}
-%typemap(in) double *, double[ANY] %{
- $1 = REAL($input);
+%typemap(in) float *, float[ANY],
+ double *, double[ANY]
+
+{
+{ int _rswigi;
+ int _rswiglen = LENGTH($input);
+ $1 = %static_cast(calloc(sizeof($1_basetype), _rswiglen), $1_ltype);
+ for (_rswigi=0; _rswigi<_rswiglen; _rswigi++) {
+ $1[_rswigi] = REAL($input)[_rswigi];
+ }
+}
+}
+
+%typemap(freearg,noblock=1) int *, int[ANY],
+ signed int *, signed int[ANY],
+ unsigned int *, unsigned int[ANY],
+ short *, short[ANY],
+ signed short *, signed short[ANY],
+ unsigned short *, unsigned short[ANY],
+ long *, long[ANY],
+ signed long *, signed long[ANY],
+ unsigned long *, unsigned long[ANY],
+ long long *, long long[ANY],
+ signed long long *, signed long long[ANY],
+ unsigned long long *, unsigned long long[ANY],
+ float *, float[ANY],
+ double *, double[ANY]
+%{
+ free($1);
%}
+
+
+
/* Shoul dwe recycle to make the length correct.
And warn if length() > the dimension.
*/
@@ -77,9 +126,9 @@ SWIG_InitializeModule(0);
%}
-%typemap(scheck) int %{
+%typemap(scheck) int, long %{
if(length($input) > 1) {
- Rf_warning("using only the first element of $input")
+ warning("using only the first element of $input")
}
%}
@@ -91,8 +140,6 @@ SWIG_InitializeModule(0);
%include <typemaps/swigtypemaps.swg>
%include <rtype.swg>
-%apply int[ANY] { enum SWIGTYPE[ANY] };
-
%typemap(in,noblock=1) enum SWIGTYPE[ANY] {
$1 = %reinterpret_cast(INTEGER($input), $1_ltype);
}
@@ -157,11 +204,12 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype);
}
-%typemap(in,noblock=1) int {
+%typemap(in,noblock=1) int, long
+{
$1 = %static_cast(INTEGER($input)[0], $1_ltype);
}
-%typemap(out,noblock=1) int
+%typemap(out,noblock=1) int, long
"$result = Rf_ScalarInteger($1);";
@@ -172,18 +220,16 @@ $1 = %static_cast(CHAR(STRING_ELT($input, 0))[0],$1_ltype);
%typemap(out,noblock=1) bool
"$result = Rf_ScalarLogical($1);";
-%typemap(in,noblock=1) unsigned int,
- unsigned long,
+%typemap(in,noblock=1)
float,
- double,
- long
+ double
{
$1 = %static_cast(REAL($input)[0], $1_ltype);
}
-
-%typemap(out,noblock=1) unsigned int *
- "$result = ScalarReal(*($1));";
+/* Why is this here ? */
+/* %typemap(out,noblock=1) unsigned int *
+ "$result = ScalarReal(*($1));"; */
%Rruntime %{
setMethod('[', "ExternalReference",
diff --git a/Lib/r/rrun.swg b/Lib/r/rrun.swg
index b5375c213..32946c7b5 100644
--- a/Lib/r/rrun.swg
+++ b/Lib/r/rrun.swg
@@ -16,8 +16,6 @@ extern "C" {
#include <stdlib.h>
#include <assert.h>
-#define SWIGR 1
-
#if R_VERSION >= R_Version(2,6,0)
#define VMAXTYPE void *
#else
diff --git a/Lib/r/rstdcommon.swg b/Lib/r/rstdcommon.swg
index 223203773..56cbe2cdd 100644
--- a/Lib/r/rstdcommon.swg
+++ b/Lib/r/rstdcommon.swg
@@ -40,7 +40,7 @@ namespace swig {
struct traits_asptr {
static int asptr(SWIG_Object obj, Type **val) {
Type *p;
- int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0;
+ int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
if (SWIG_IsOK(res)) {
if (val) *val = p;
}
diff --git a/Lib/r/rtype.swg b/Lib/r/rtype.swg
index 9206b5e3e..d388d1eae 100644
--- a/Lib/r/rtype.swg
+++ b/Lib/r/rtype.swg
@@ -3,17 +3,23 @@
for use in class representations.
*/
-%typemap("rtype") int, int *, int & "numeric";
+%typemap("rtype") int, int *, int & "integer";
%apply int {size_t}
%apply int {std::size_t}
%apply int {ptrdiff_t}
%apply int {std::ptrdiff_t}
+%apply int {signed int}
+%apply int {unsigned int}
+%apply int {short}
+%apply int {unsigned short}
+
+%typemap("rtype") long, long *, long & "integer";
+%apply long {long long}
+%apply long {signed long long}
+%apply long {unsigned long long}
+%apply long {signed long}
+%apply long {unsigned long}
-%typemap("rtype") long, long * "numeric";
-%typemap("rtype") unsigned long,
- unsigned long * "numeric";
-%typemap("rtype") unsigned int,
- unsigned int * "numeric";
%typemap("rtype") double, double*, double & "numeric";
%typemap("rtype") float, float *, float & "numeric";
%typemap("rtype") char *, char ** "character";
@@ -35,15 +41,14 @@
INTSXP.
*/
+/* Force coercion of integer, since by default R sets all constants to
+ numeric, which means that you can't directly call a function with an
+ integer using an R numercal literal */
%typemap(scoercein) int, int *, int &
- %{ $input = as($input, "integer"); %}
-%typemap(scoercein) ptrdiff_t, ptrdiff_t *, ptrdiff_t &
- %{ $input = as($input, "integer"); %}
-%typemap(scoercein) unsigned long, unsigned long *, unsigned long &
- %{ $input = as($input, "integer"); %}
-%typemap(scoercein) unsigned int, unsigned int *, unsigned int &
- %{ $input = as($input, "integer"); %}
+ %{ $input = as.integer($input); %}
+%typemap(scoercein) long, long *, long &
+ %{ $input = as.integer($input); %}
%typemap(scoercein) double, double *, double &
%{ %}
%typemap(scoercein) float, float *, float &
@@ -87,45 +92,16 @@
%typemap(scoercein) bool, bool *, bool &
"$input = as.logical($input) ";
-/*
%typemap(scoercein) int,
int *,
int &,
int[ANY],
- size_t,
- std::size_t,
- size_t &,
- std::size_t &
+ long,
+ long *,
+ long &,
+ long[ANY]
"$input = as.integer($input) ";
-
-%typemap(scoercein) unsigned int,
- unsigned long,
- double,
- float,
- long,
- long long,
- unsigned int[],
- unsigned long[],
- double[],
- float[],
- long[],
- long long[],
- unsigned int[ANY],
- unsigned long[ANY],
- double[ANY],
- float[ANY],
- long[ANY],
- long long[ANY],
- unsigned int *,
- unsigned long *,
- double*,
- float*,
- long*,
- long long *
-%{ $input = as.numeric($input) %}
-*/
-
%typemap(scoercein) char *, string, std::string,
string &, std::string &
%{ $input = as($input, "character") %}
@@ -153,31 +129,38 @@ string &, std::string &
%typemap(scoerceout) char,
char *,
char &,
- unsigned int,
- unsigned int &,
- unsigned long,
- unsigned long &,
double,
double &,
float,
float &,
- long,
- long &,
- long long,
- long long &,
int,
int &,
+ long,
+ long &,
bool,
bool &,
string,
std::string,
string &,
std::string &,
- size_t,
- std::size_t,
- size_t &,
- std::size_t &,
- void
+ void,
+ signed int,
+ signed int &,
+ unsigned int,
+ unsigned int &,
+ short,
+ short &,
+ unsigned short,
+ unsigned short &,
+ long long,
+ signed long long,
+ signed long long &,
+ unsigned long long,
+ unsigned long long &,
+ signed long,
+ signed long &,
+ unsigned long,
+ unsigned long &
%{ %}
diff --git a/Lib/ruby/file.i b/Lib/ruby/file.i
index 54ed0a609..d64937ed1 100644
--- a/Lib/ruby/file.i
+++ b/Lib/ruby/file.i
@@ -3,7 +3,14 @@
#ifdef __cplusplus
extern "C" {
#endif
+
+// Ruby 1.9 changed the file name of this header
+#ifdef HAVE_RUBY_IO_H
+#include "ruby/io.h"
+#else
#include "rubyio.h"
+#endif
+
#ifdef __cplusplus
}
#endif
diff --git a/Lib/ruby/rubyhead.swg b/Lib/ruby/rubyhead.swg
index 8e6e2e7d0..d17fdbaae 100644
--- a/Lib/ruby/rubyhead.swg
+++ b/Lib/ruby/rubyhead.swg
@@ -7,6 +7,9 @@
#ifdef read
# undef read
#endif
+#ifdef bind
+# undef bind
+#endif
/* Ruby 1.7 defines NUM2LL(), LL2NUM() and ULL2NUM() macros */
diff --git a/Lib/ruby/rubywstrings.swg b/Lib/ruby/rubywstrings.swg
index 0cf9d7ed9..862928c95 100644
--- a/Lib/ruby/rubywstrings.swg
+++ b/Lib/ruby/rubywstrings.swg
@@ -29,7 +29,7 @@ SWIG_AsWCharPtrAndSize(VALUE obj, wchar_t **cptr, size_t *psize, int *alloc)
// }
// }
// if (ok) {
-// int len = PyUnicode_GetSize(obj);
+// Py_ssize_t len = PyUnicode_GetSize(obj);
// rb_notimplement();
// if (cptr) {
// *cptr = %new_array(len + 1, wchar_t);
diff --git a/Lib/shared_ptr.i b/Lib/shared_ptr.i
index 0ccce64bf..709791502 100644
--- a/Lib/shared_ptr.i
+++ b/Lib/shared_ptr.i
@@ -1,4 +1,8 @@
// shared_ptr namespaces could be boost or std or std::tr1
+// For example for std::tr1, use:
+// #define SWIG_SHARED_PTR_NAMESPACE std
+// #define SWIG_SHARED_PTR_SUBNAMESPACE tr1
+
#if !defined(SWIG_SHARED_PTR_NAMESPACE)
# define SWIG_SHARED_PTR_NAMESPACE boost
#endif
@@ -44,12 +48,12 @@ SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
%define SWIG_SHARED_PTR_DERIVED(PROXYCLASS, BASECLASSTYPE, TYPE...)
SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, , TYPE)
SWIG_SHARED_PTR_TYPEMAPS(PROXYCLASS, const, TYPE)
-%types(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >) %{
+%types(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > = SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >) %{
*newmemory = SWIG_CAST_NEW_MEMORY;
- return (void *) new SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > *)$from);
- %}
+ return (void *) new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE >(*(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *)$from);
+%}
%extend TYPE {
- static SWIG_SHARED_PTR_NAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_NAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
+ static SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< BASECLASSTYPE > SWIGSharedPtrUpcast(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > swigSharedPtrUpcast) {
return swigSharedPtrUpcast;
}
}
diff --git a/Lib/swig.swg b/Lib/swig.swg
index 6f40a8fe9..77308e080 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -25,10 +25,11 @@
/* Code insertion directives such as %wrapper %{ ... %} */
-#define %init %insert("init")
-#define %wrapper %insert("wrapper")
-#define %header %insert("header")
+#define %begin %insert("begin")
#define %runtime %insert("runtime")
+#define %header %insert("header")
+#define %wrapper %insert("wrapper")
+#define %init %insert("init")
/* Class extension */
@@ -423,13 +424,21 @@ namespace std {
/* Character array handling */
%typemap(memberin) char [ANY] {
- if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0);
- else $1[0] = 0;
+ if($input) {
+ strncpy((char*)$1, (const char *)$input, $1_dim0-1);
+ $1[$1_dim0-1] = 0;
+ } else {
+ $1[0] = 0;
+ }
}
%typemap(globalin) char [ANY] {
- if ($input) strncpy((char *)$1, (const char *)$input, $1_dim0);
- else $1[0] = 0;
+ if($input) {
+ strncpy((char*)$1, (const char *)$input, $1_dim0-1);
+ $1[$1_dim0-1] = 0;
+ } else {
+ $1[0] = 0;
+ }
}
%typemap(memberin) char [] {
@@ -459,26 +468,26 @@ namespace std {
/* memberin/globalin typemap for double arrays. */
%typemap(memberin) SWIGTYPE [ANY][ANY] {
- $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input);
- $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1);
+ $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
+ $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
size_t ii = 0;
- for (; ii < $dim0; ++ii) {
+ for (; ii < $1_dim0; ++ii) {
$basetype *ip = inp[ii];
$basetype *dp = dest[ii];
size_t jj = 0;
- for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
+ for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj];
}
}
%typemap(globalin) SWIGTYPE [ANY][ANY] {
- $basetype (*inp)[$dim1] = ($basetype (*)[$dim1])($input);
- $basetype (*dest)[$dim1] = ($basetype (*)[$dim1])($1);
+ $basetype (*inp)[$1_dim1] = ($basetype (*)[$1_dim1])($input);
+ $basetype (*dest)[$1_dim1] = ($basetype (*)[$1_dim1])($1);
size_t ii = 0;
- for (; ii < $dim0; ++ii) {
+ for (; ii < $1_dim0; ++ii) {
$basetype *ip = inp[ii];
$basetype *dp = dest[ii];
size_t jj = 0;
- for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
+ for (; jj < $1_dim1; ++jj) dp[jj] = ip[jj];
}
}
@@ -625,6 +634,10 @@ namespace std {
* arg1 = *inarg1; // Assignment from a pointer
* arg1 = Vector(1,2,3); // Assignment from a value
*
+ * The class offers a strong guarantee of exception safety.
+ * With regards to the implementation, the private SwigMovePointer nested class is
+ * a simple smart pointer with move semantics, much like std::auto_ptr.
+ *
* This wrapping technique was suggested by William Fulton and is henceforth
* known as the "Fulton Transform" :-).
*/
@@ -632,18 +645,21 @@ namespace std {
#ifdef __cplusplus
%insert("runtime") %{
#ifdef __cplusplus
+/* SwigValueWrapper is described in swig.swg */
template<typename T> class SwigValueWrapper {
- T *tt;
+ struct SwigMovePointer {
+ T *ptr;
+ SwigMovePointer(T *p) : ptr(p) { }
+ ~SwigMovePointer() { delete ptr; }
+ SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
+ } pointer;
+ SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+ SwigValueWrapper(const SwigValueWrapper<T>& rhs);
public:
- SwigValueWrapper() : tt(0) { }
- SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
- SwigValueWrapper(const T& t) : tt(new T(t)) { }
- ~SwigValueWrapper() { delete tt; }
- SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
- operator T&() const { return *tt; }
- T *operator&() { return tt; }
-private:
- SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
+ SwigValueWrapper() : pointer(0) { }
+ SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
+ operator T&() const { return *pointer.ptr; }
+ T *operator&() { return pointer.ptr; }
};%}
/*
diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg
index 9ee676a2b..a8e9ad74c 100644
--- a/Lib/swigrun.swg
+++ b/Lib/swigrun.swg
@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------------
* swigrun.swg
*
- * This file contains generic CAPI SWIG runtime support for pointer
+ * This file contains generic C API SWIG runtime support for pointer
* type checking.
* ----------------------------------------------------------------------------- */
@@ -20,11 +20,11 @@
/*
You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
- creating a static or dynamic library from the swig runtime code.
- In 99.9% of the cases, swig just needs to declare them as 'static'.
+ creating a static or dynamic library from the SWIG runtime code.
+ In 99.9% of the cases, SWIG just needs to declare them as 'static'.
- But only do this if is strictly necessary, ie, if you have problems
- with your compiler or so.
+ But only do this if strictly necessary, ie, if you have problems
+ with your compiler or suchlike.
*/
#ifndef SWIGRUNTIME
@@ -51,14 +51,14 @@
/*
Flags/methods for returning states.
- The swig conversion methods, as ConvertPtr, return and integer
+ The SWIG conversion methods, as ConvertPtr, return and integer
that tells if the conversion was successful or not. And if not,
an error code can be returned (see swigerrors.swg for the codes).
Use the following macros/flags to set or process the returning
states.
- In old swig versions, you usually write code as:
+ In old versions of SWIG, code such as the following was usually written:
if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
// success code
@@ -66,7 +66,7 @@
//fail code
}
- Now you can be more explicit as:
+ Now you can be more explicit:
int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
if (SWIG_IsOK(res)) {
@@ -75,7 +75,7 @@
// fail code
}
- that seems to be the same, but now you can also do
+ which is the same really, but now you can also do
Type *ptr;
int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
@@ -93,7 +93,7 @@
I.e., now SWIG_ConvertPtr can return new objects and you can
identify the case and take care of the deallocation. Of course that
- requires also to SWIG_ConvertPtr to return new result values, as
+ also requires SWIG_ConvertPtr to return new result values, such as
int SWIG_ConvertPtr(obj, ptr,...) {
if (<obj is ok>) {
@@ -111,7 +111,7 @@
Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
- swig errors code.
+ SWIG errors code.
Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
allows to return the 'cast rank', for example, if you have this
@@ -125,9 +125,8 @@
fooi(1) // cast rank '0'
just use the SWIG_AddCast()/SWIG_CheckState()
+*/
-
- */
#define SWIG_OK (0)
#define SWIG_ERROR (-1)
#define SWIG_IsOK(r) (r >= 0)
@@ -152,7 +151,6 @@
#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
-
/* Cast-Rank Mode */
#if defined(SWIG_CASTRANK_MODE)
# ifndef SWIG_TypeRank
@@ -175,8 +173,6 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
#endif
-
-
#include <string.h>
#ifdef __cplusplus
@@ -273,40 +269,58 @@ SWIG_TypeCompare(const char *nb, const char *tb) {
}
-/* think of this as a c++ template<> or a scheme macro */
-#define SWIG_TypeCheck_Template(comparison, ty) \
- if (ty) { \
- swig_cast_info *iter = ty->cast; \
- while (iter) { \
- if (comparison) { \
- if (iter == ty->cast) return iter; \
- /* Move iter to the top of the linked list */ \
- iter->prev->next = iter->next; \
- if (iter->next) \
- iter->next->prev = iter->prev; \
- iter->next = ty->cast; \
- iter->prev = 0; \
- if (ty->cast) ty->cast->prev = iter; \
- ty->cast = iter; \
- return iter; \
- } \
- iter = iter->next; \
- } \
- } \
- return 0
-
/*
Check the typename
*/
SWIGRUNTIME swig_cast_info *
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
- SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if (strcmp(iter->type->name, c) == 0) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
}
-/* Same as previous function, except strcmp is replaced with a pointer comparison */
+/*
+ Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
+*/
SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
- SWIG_TypeCheck_Template(iter->type == from, into);
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
+ if (ty) {
+ swig_cast_info *iter = ty->cast;
+ while (iter) {
+ if (iter->type == from) {
+ if (iter == ty->cast)
+ return iter;
+ /* Move iter to the top of the linked list */
+ iter->prev->next = iter->next;
+ if (iter->next)
+ iter->next->prev = iter->prev;
+ iter->next = ty->cast;
+ iter->prev = 0;
+ if (ty->cast) ty->cast->prev = iter;
+ ty->cast = iter;
+ return iter;
+ }
+ iter = iter->next;
+ }
+ }
+ return 0;
}
/*
diff --git a/Lib/typemaps/attribute.swg b/Lib/typemaps/attribute.swg
index f6335be82..4bc6315b7 100644
--- a/Lib/typemaps/attribute.swg
+++ b/Lib/typemaps/attribute.swg
@@ -11,7 +11,7 @@
The following macros convert a pair of set/get methods
into a "native" attribute.
- Use %attribute when you have a pair of get/set methods
+ Use %attribute when you have a pair of get/set methods to a primitive type
like in:
%attribute(A, int, a, get_a, set_a);
@@ -27,8 +27,8 @@
%attribute(A, int, c, get_c);
- Use %attributeref when you have const/non-const reference
- access methods, like in:
+ Use %attributeref when you have const/non-const reference access methods
+ for primitive types or class/structs, like in:
%attributeref(A, int, b);
@@ -99,6 +99,40 @@
where %arg() 'normalizes' the type to be understood as a single
argument, otherwise the macro will get confused by the comma.
+
+ The %attributeval is the same as %attribute, but should be used when the type
+ is a class/struct (ie a non-primitive type) and when the get and set methods
+ return/pass by value. The following is very similar to the above example, but
+ note that the access is by value rather than reference.
+
+ %attributeval(MyClassVal, MyFoo, ReadWriteFoo, GetFoo, SetFoo);
+ %attributeval(MyClassVal, MyFoo, ReadOnlyFoo, GetFoo);
+ %inline %{
+ class MyClassVal {
+ MyFoo foo;
+ public:
+ MyFoo GetFoo() { return foo; }
+ void SetFoo(MyFoo other) { foo = other; }
+ };
+ %}
+
+ The %attributestring is the same as %attributeval, but should be used for string
+ class types, which are unusual as they are a class on the C++ side, but normally an
+ immutable/primitive type in the target language. Example usage for std::string:
+
+ %include <std_string.i>
+ %attributestring(MyStringyClass, std::string, ReadWriteString, GetString, SetString);
+ %attributestring(MyStringyClass, std::string, ReadOnlyString, GetString);
+ %inline %{
+ class MyStringyClass {
+ std::string str;
+ public:
+ MyStringyClass(const std::string &val) : str(val) {}
+ std::string GetString() { return str; }
+ void SetString(std::string other) { str = other; }
+ };
+ %}
+
*/
//
@@ -203,3 +237,50 @@
#endif
%enddef
+
+%define %attributeval(Class, AttributeType, AttributeName, GetMethod, SetMethod...)
+ %{
+ #define %mangle(Class) ##_## AttributeName ## _get(self_) new AttributeType(self_->GetMethod())
+ %}
+ #if #SetMethod != ""
+ %{
+ #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(*val_)
+ %}
+ #if #SetMethod != #AttributeName
+ %ignore Class::SetMethod;
+ #endif
+ #else
+ %immutable Class::AttributeName;
+ #endif
+ %ignore Class::GetMethod();
+ %ignore Class::GetMethod() const;
+ %newobject Class::AttributeName;
+ %extend Class {
+ AttributeType AttributeName;
+ }
+%enddef
+
+
+%define %attributestring(Class, AttributeType, AttributeName, GetMethod, SetMethod...)
+ %{
+ #define %mangle(Class) ##_## AttributeName ## _get(self_) *new AttributeType(self_->GetMethod())
+ %}
+ #if #SetMethod != ""
+ %{
+ #define %mangle(Class) ##_## AttributeName ## _set(self_, val_) self_->SetMethod(val_)
+ %}
+ #if #SetMethod != #AttributeName
+ %ignore Class::SetMethod;
+ #endif
+ #else
+ %immutable Class::AttributeName;
+ #endif
+ %ignore Class::GetMethod();
+ %ignore Class::GetMethod() const;
+ %newobject Class::AttributeName;
+ %typemap(newfree) const AttributeType &AttributeName "delete $1;// my newfree override"
+ %extend Class {
+ AttributeType AttributeName;
+ }
+%enddef
+
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index f5c88a717..15f2f9b41 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -124,7 +124,7 @@
%typemap(memberin) SWIGTYPE [ANY] {
if ($input) {
size_t ii = 0;
- for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii];
+ for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = $input[ii];
} else {
%variable_nullref("$type","$name");
}
@@ -133,7 +133,7 @@
%typemap(globalin) SWIGTYPE [ANY] {
if ($input) {
size_t ii = 0;
- for (; ii < (size_t)$dim0; ++ii) $1[ii] = $input[ii];
+ for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = $input[ii];
} else {
%variable_nullref("$type","$name");
}
@@ -146,7 +146,7 @@
%variable_fail(res, "$type", "$name");
} else if (inp) {
size_t ii = 0;
- for (; ii < (size_t)$dim0; ++ii) $1[ii] = inp[ii];
+ for (; ii < (size_t)$1_dim0; ++ii) $1[ii] = inp[ii];
} else {
%variable_nullref("$type", "$name");
}
@@ -158,10 +158,10 @@
%typemap(memberin) SWIGTYPE [ANY][ANY] {
if ($input) {
size_t ii = 0;
- for (; ii < (size_t)$dim0; ++ii) {
+ for (; ii < (size_t)$1_dim0; ++ii) {
if ($input[ii]) {
size_t jj = 0;
- for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj];
+ for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj];
} else {
%variable_nullref("$type","$name");
}
@@ -174,10 +174,10 @@
%typemap(globalin) SWIGTYPE [ANY][ANY] {
if ($input) {
size_t ii = 0;
- for (; ii < (size_t)$dim0; ++ii) {
+ for (; ii < (size_t)$1_dim0; ++ii) {
if ($input[ii]) {
size_t jj = 0;
- for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj];
+ for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = $input[ii][jj];
} else {
%variable_nullref("$type","$name");
}
@@ -188,16 +188,16 @@
}
%typemap(varin) SWIGTYPE [ANY][ANY] {
- $basetype (*inp)[$dim1] = 0;
+ $basetype (*inp)[$1_dim1] = 0;
int res = SWIG_ConvertPtr($input, %as_voidptrptr(&inp), $descriptor, %convertptr_flags);
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
} else if (inp) {
size_t ii = 0;
- for (; ii < (size_t)$dim0; ++ii) {
+ for (; ii < (size_t)$1_dim0; ++ii) {
if (inp[ii]) {
size_t jj = 0;
- for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = inp[ii][jj];
+ for (; jj < (size_t)$1_dim1; ++jj) $1[ii][jj] = inp[ii][jj];
} else {
%variable_nullref("$type", "$name");
}
diff --git a/Makefile.in b/Makefile.in
index 168171047..e2b62d6a7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,6 +2,8 @@
# $Id$
#######################################################################
+.PHONY: ccache source swig
+
prefix = @prefix@
exec_prefix = @exec_prefix@
srcdir = @srcdir@
@@ -14,23 +16,39 @@ datarootdir = @datarootdir@
SHELL = /bin/sh
SWIG_LIB = @swig_lib@
BIN_DIR = @bindir@
+ENABLE_CCACHE = @ENABLE_CCACHE@
TARGET_NOEXE= swig
TARGET = $(TARGET_NOEXE)@EXEEXT@
SOURCE = Source
+CCACHE = CCache
DOCS = Doc/Manual
-swig: libfiles source
+swig: libfiles source ccache
source:
@cd $(SOURCE) && $(MAKE)
+ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE))
+
libfiles: $(srcdir)/Lib/swigwarn.swg
# Files required just for the tarball
maintainer: libfiles
@cd $(SOURCE) && $(MAKE) CParse/parser.h
-.PHONY: source libfiles maintainer
+#####################################################################
+# Documentation
+#####################################################################
+
+docs: docs-main docs-ccache
+
+docs-main:
+ @echo making docs
+ @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) all clean-baks
+
+docs-ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) docs)
#####################################################################
# All the languages SWIG speaks (when it wants to)
@@ -44,7 +62,7 @@ skip-guilescm = test -n "@SKIP_GUILESCM@"
skip-guile = test -n "@SKIP_GUILE@"
skip-mzscheme = test -n "@SKIP_MZSCHEME@"
skip-ruby = test -n "@SKIP_RUBY@"
-skip-php4 = test -n "@SKIP_PHP4@"
+skip-php = test -n "@SKIP_PHP@"
skip-ocaml = test -n "@SKIP_OCAML@"
skip-octave = test -n "@SKIP_OCTAVE@"
skip-pike = test -n "@SKIP_PIKE@"
@@ -67,6 +85,7 @@ skip-gcj = test -n "@SKIP_GCJ@"
#####################################################################
ACTION = check
+NOSKIP =
chk-set-swiglib = SWIG_LIB=@ROOT_DIR@/Lib
chk-set-swig = SWIG=@ROOT_DIR@/$(TARGET)
@@ -85,7 +104,7 @@ check-aliveness:
@$(skip-ruby) || ./$(TARGET) -ruby -help
@$(skip-ocaml) || ./$(TARGET) -ocaml -help
@$(skip-octave) || ./$(TARGET) -octave -help
- @$(skip-php4) || ./$(TARGET) -php4 -help
+ @$(skip-php) || ./$(TARGET) -php -help
@$(skip-pike) || ./$(TARGET) -pike -help
@$(skip-chicken) || ./$(TARGET) -chicken -help
@$(skip-csharp) || ./$(TARGET) -csharp -help
@@ -94,6 +113,9 @@ check-aliveness:
@$(skip-r) || ./$(TARGET) -r -help
@$(skip-com) || ./$(TARGET) -com -help
+check-ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check)
+
# Checks examples for compilation (does not run them)
check-examples: \
check-tcl-examples \
@@ -105,7 +127,7 @@ check-examples: \
check-ruby-examples \
check-ocaml-examples \
check-octave-examples \
- check-php4-examples \
+ check-php-examples \
check-pike-examples \
check-chicken-examples \
check-csharp-examples \
@@ -127,7 +149,7 @@ mzscheme_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/mzscheme/check.list
ruby_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ruby/check.list)
ocaml_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/ocaml/check.list)
octave_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/octave/check.list)
-php4_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php4/check.list)
+php_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/php/check.list)
pike_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/pike/check.list)
chicken_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/chicken/check.list)
csharp_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/csharp/check.list)
@@ -180,7 +202,7 @@ check-gifplot: \
check-ruby-gifplot \
check-ocaml-gifplot \
check-octave-gifplot \
- check-php4-gifplot \
+ check-php-gifplot \
check-pike-gifplot \
check-chicken-gifplot \
check-com-gifplot \
@@ -223,7 +245,7 @@ check-test-suite: \
check-ruby-test-suite \
check-ocaml-test-suite \
check-octave-test-suite \
- check-php4-test-suite \
+ check-php-test-suite \
check-pike-test-suite \
check-csharp-test-suite \
check-modula3-test-suite \
@@ -243,7 +265,7 @@ check-%-test-suite:
fi
@passed=true; \
dir="Examples/test-suite/$*"; \
- if $(skip-$*); then \
+ if $(skip-$*) -a "$(NOSKIP)" != "1"; then \
echo skipping $* test-suite $(ACTION); \
elif [ ! -d $$dir ]; then \
echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\
@@ -256,12 +278,12 @@ check-%-test-suite:
# Partial test-suite check - it only invokes SWIG, ie no compilation and no runtime testing
partialcheck-test-suite:
- @$(MAKE) -k -s check-test-suite ACTION=partialcheck
+ @$(MAKE) -k -s check-test-suite ACTION=partialcheck NOSKIP=1
partialcheck-%-test-suite:
- @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck
+ @$(MAKE) -k -s check-$*-test-suite ACTION=partialcheck NOSKIP=1
-check: check-aliveness check-examples check-gifplot check-test-suite
+check: check-aliveness check-ccache check-examples check-gifplot check-test-suite
# Run known-to-be-broken as well as not broken testcases in the test-suite
all-test-suite: \
@@ -275,7 +297,7 @@ all-test-suite: \
all-ruby-test-suite \
all-ocaml-test-suite \
all-octave-test-suite \
- all-php4-test-suite \
+ all-php-test-suite \
all-pike-test-suite \
all-csharp-test-suite \
all-modula3-test-suite \
@@ -303,7 +325,7 @@ broken-test-suite: \
broken-ruby-test-suite \
broken-ocaml-test-suite \
broken-octave-test-suite \
- broken-php4-test-suite \
+ broken-php-test-suite \
broken-pike-test-suite \
broken-csharp-test-suite \
broken-modula3-test-suite \
@@ -325,7 +347,7 @@ broken-%-test-suite:
clean: clean-objects clean-libfiles clean-examples clean-gifplot clean-test-suite clean-docs
-clean-objects: clean-source
+clean-objects: clean-source clean-ccache
clean-source:
@echo cleaning Source
@@ -342,20 +364,28 @@ clean-gifplot:
@$(MAKE) -k -s check-gifplot ACTION=clean
clean-test-suite:
- @$(MAKE) -k -s check-test-suite ACTION=clean
+ @$(MAKE) -k -s check-test-suite ACTION=clean NOSKIP=1
clean-%-examples:
@$(MAKE) -k -s check-$*-examples ACTION=clean
clean-%-test-suite:
- @$(MAKE) -k -s check-$*-test-suite ACTION=clean
+ @$(MAKE) -k -s check-$*-test-suite ACTION=clean NOSKIP=1
clean-%-gifplot:
@$(MAKE) -k -s check-$*-gifplot ACTION=clean
-clean-docs:
+clean-ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s clean)
+
+clean-docs: clean-docs-main clean-docs-ccache
+
+clean-docs-main:
@echo cleaning Docs
- @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) -s clean
+ @test -d $(DOCS) || exit 0; cd $(DOCS) && $(MAKE) clean
+
+clean-docs-ccache:
+ @test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) clean-docs)
maintainer-clean: clean-libfiles
@cd $(SOURCE) && $(MAKE) maintainer-clean
@@ -366,7 +396,7 @@ maintainer-clean: clean-libfiles
DISTCLEAN-DEAD = config.status config.log config.cache swig.spec Makefile mkmf.log libtool
-distclean: distclean-objects clean-examples clean-gifplot distclean-test-suite clean-docs distclean-dead
+distclean: distclean-objects clean-examples clean-gifplot distclean-test-suite clean-docs distclean-dead distclean-ccache
distclean-objects: distclean-source
@@ -377,39 +407,10 @@ distclean-source:
distclean-test-suite:
@echo distcleaning Examples/test-suite
- @$(MAKE) -k -s noskip-test-suite ACTION=distclean
-
-noskip-test-suite: \
- noskip-tcl-test-suite \
- noskip-perl5-test-suite \
- noskip-python-test-suite \
- noskip-java-test-suite \
- noskip-guilescm-test-suite \
- noskip-guile-test-suite \
- noskip-mzscheme-test-suite \
- noskip-ruby-test-suite \
- noskip-ocaml-test-suite \
- noskip-octave-test-suite \
- noskip-php4-test-suite \
- noskip-pike-test-suite \
- noskip-csharp-test-suite \
- noskip-lua-test-suite \
- noskip-allegrocl-test-suite \
- noskip-clisp-test-suite \
- noskip-uffi-test-suite \
- noskip-cffi-test-suite \
- noskip-chicken-test-suite \
- noskip-r-test-suite \
- noskip-com-test-suite
-
-noskip-%-test-suite:
- dir="Examples/test-suite/$*"; \
- if [ ! -d $$dir ]; then \
- echo warning: cannot $(ACTION) $* test-suite "(no dir $$dir)";\
- else \
- echo $(ACTION)ing $$dir; \
- (cd $$dir && $(MAKE) -k -s $(ACTION)) \
- fi;
+ @$(MAKE) -k -s check-test-suite ACTION=distclean NOSKIP=1
+
+distclean-ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) -s distclean)
distclean-dead:
rm -f $(DISTCLEAN-DEAD)
@@ -439,7 +440,7 @@ MKINSTDIRS = @abs_srcdir@/Tools/config/install-sh -m 0755 -d
# Use standard autoconf approach to transform executable name using --program-prefix and --program-suffix
transform = @program_transform_name@
-install: install-main install-lib
+install: install-main install-lib install-ccache
@echo "Installation complete"
install-main:
@@ -448,7 +449,7 @@ install-main:
@echo "Installing $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@"
@$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@
-lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php4 ocaml octave \
+lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \
pike chicken csharp modula3 allegrocl clisp lua cffi uffi r com
lib-modules = std
@@ -483,12 +484,15 @@ install-lib:
fi) ; \
done
+install-ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) install)
+
#####################################################################
# TARGETS: uninstall & friends
#####################################################################
-uninstall: uninstall-main uninstall-lib
+uninstall: uninstall-main uninstall-lib uninstall-ccache
@echo "Uninstall complete"
uninstall-main:
@@ -499,6 +503,9 @@ uninstall-lib:
@echo "Uninstalling the SWIG library"
rm -rf $(DESTDIR)$(SWIG_LIB)/
+uninstall-ccache:
+ test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) uninstall)
+
############################################################################
# DIST and other maintenance
############################################################################
diff --git a/README b/README
index 2898130b0..3df9e506a 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 1.3.36 (24 June 2008)
+Version: 1.3.40 (in progress)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua,
@@ -91,6 +91,27 @@ A SWIG FAQ and other hints can be found on the SWIG Wiki:
What's New?
===========
+SWIG-1.3.39 summary:
+- Some new small feature enhancements.
+- Improved C# std::vector wrappers.
+- Bug fixes: mainly Python, but also Perl, MzScheme, CFFI, Allegrocl
+ and Ruby
+
+SWIG-1.3.38 summary:
+- Output directory regression fix and other minor bug fixes
+
+SWIG-1.3.37 summary:
+- Python 3 support added
+- SWIG now ships with a version of ccache that can be used with SWIG.
+ This enables the files generated by SWIG to be cached so that repeated
+ use of SWIG on unchanged input files speeds up builds quite considerably.
+- PHP 4 support removed and PHP support improved in general
+- Improved C# array support
+- Numerous Allegro CL improvements
+- Bug fixes/enhancements for Python, PHP, Java, C#, Chicken, Allegro CL,
+ CFFI, Ruby, Tcl, Perl, R, Lua.
+- Other minor generic bug fixes and enhancements
+
SWIG-1.3.36 summary:
- Enhancement to directors to wrap all protected members
- Optimisation feature for objects returned by value
diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h
index 06a901c0d..9be41c60e 100644
--- a/Source/CParse/cparse.h
+++ b/Source/CParse/cparse.h
@@ -34,16 +34,18 @@ extern "C" {
extern void scanner_ignore_typedef(void);
extern void scanner_last_id(int);
extern void scanner_clear_rename(void);
- extern void scanner_set_location(String_or_char *, int line);
+ extern void scanner_set_location(String *file, int line);
+ extern void scanner_set_main_input_file(String *file);
+ extern String *scanner_get_main_input_file();
extern void Swig_cparse_follow_locators(int);
extern void start_inline(char *, int);
extern String *scanner_ccode;
- extern int yylex();
+ extern int yylex(void);
/* parser.y */
extern SwigType *Swig_cparse_type(String *);
extern Node *Swig_cparse(File *);
- extern Hash *Swig_cparse_features();
+ extern Hash *Swig_cparse_features(void);
extern void SWIG_cparse_set_compact_default_args(int defargs);
extern int SWIG_cparse_template_reduce(int treduce);
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index 032c71f7e..8734c7d0e 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -22,7 +22,10 @@ char cvsroot_cscanner_c[] = "$Id$";
static Scanner *scan = 0;
/* Global string containing C code. Used by the parser to grab code blocks */
-DOHString *scanner_ccode = 0;
+String *scanner_ccode = 0;
+
+/* The main file being parsed */
+static String *main_input_file = 0;
/* Error reporting/location information */
int cparse_line = 1;
@@ -261,10 +264,8 @@ int yylook(void) {
while (1) {
if ((tok = Scanner_token(scan)) == 0)
return 0;
- if (tok == SWIG_TOKEN_ERROR) {
- Swig_error(Scanner_file(scan), Scanner_errline(scan), Scanner_errmsg(scan));
- continue;
- }
+ if (tok == SWIG_TOKEN_ERROR)
+ return 0;
cparse_start_line = Scanner_start_line(scan);
cparse_line = Scanner_line(scan);
cparse_file = Scanner_file(scan);
@@ -441,7 +442,7 @@ int yylook(void) {
static int check_typedef = 0;
-void scanner_set_location(String_or_char *file, int line) {
+void scanner_set_location(String *file, int line) {
Scanner_set_location(scan,file,line-1);
}
@@ -467,6 +468,14 @@ void scanner_next_token(int tok) {
next_token = tok;
}
+void scanner_set_main_input_file(String *file) {
+ main_input_file = file;
+}
+
+String *scanner_get_main_input_file() {
+ return main_input_file;
+}
+
/* ----------------------------------------------------------------------------
* int yylex()
*
@@ -690,10 +699,22 @@ int yylex(void) {
termtoken = SWIG_TOKEN_LPAREN;
termvalue = "(";
break;
- } else if (nexttok == SWIG_TOKEN_SEMI) {
+ } else if (nexttok == SWIG_TOKEN_CODEBLOCK) {
+ termtoken = SWIG_TOKEN_CODEBLOCK;
+ termvalue = Char(Scanner_text(scan));
+ break;
+ } else if (nexttok == SWIG_TOKEN_LBRACE) {
+ termtoken = SWIG_TOKEN_LBRACE;
+ termvalue = "{";
+ break;
+ } else if (nexttok == SWIG_TOKEN_SEMI) {
termtoken = SWIG_TOKEN_SEMI;
termvalue = ";";
break;
+ } else if (nexttok == SWIG_TOKEN_STRING) {
+ termtoken = SWIG_TOKEN_STRING;
+ termvalue = Swig_copy_string(Char(Scanner_text(scan)));
+ break;
} else if (nexttok == SWIG_TOKEN_ID) {
if (needspace) {
Append(s," ");
@@ -859,8 +880,14 @@ int yylex(void) {
return (INLINE);
if (strcmp(yytext, "%typemap") == 0)
return (TYPEMAP);
- if (strcmp(yytext, "%feature") == 0)
+ if (strcmp(yytext, "%feature") == 0) {
+ /* The rename_active indicates we don't need the information of the
+ * following function's return type. This applied for %rename, so do
+ * %feature.
+ */
+ rename_active = 1;
return (FEATURE);
+ }
if (strcmp(yytext, "%except") == 0)
return (EXCEPT);
if (strcmp(yytext, "%importfile") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 58e0c0c41..0babfbbb8 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -66,7 +66,7 @@ static void yyerror (const char *e) {
(void)e;
}
-static Node *new_node(const String_or_char *tag) {
+static Node *new_node(const_String_or_char_ptr tag) {
Node *n = NewHash();
set_nodeType(n,tag);
Setfile(n,cparse_file);
@@ -203,7 +203,7 @@ static String *yyrename = 0;
static String *resolve_node_scope(String *cname);
-Hash *Swig_cparse_features() {
+Hash *Swig_cparse_features(void) {
static Hash *features_hash = 0;
if (!features_hash) features_hash = NewHash();
return features_hash;
@@ -1002,6 +1002,68 @@ static void add_nested(Nested *n) {
}
}
+/* Strips C-style and C++-style comments from string in-place. */
+static void strip_comments(char *string) {
+ int state = 0; /*
+ * 0 - not in comment
+ * 1 - in c-style comment
+ * 2 - in c++-style comment
+ * 3 - in string
+ * 4 - after reading / not in comments
+ * 5 - after reading * in c-style comments
+ * 6 - after reading \ in strings
+ */
+ char * c = string;
+ while (*c) {
+ switch (state) {
+ case 0:
+ if (*c == '\"')
+ state = 3;
+ else if (*c == '/')
+ state = 4;
+ break;
+ case 1:
+ if (*c == '*')
+ state = 5;
+ *c = ' ';
+ break;
+ case 2:
+ if (*c == '\n')
+ state = 0;
+ else
+ *c = ' ';
+ break;
+ case 3:
+ if (*c == '\"')
+ state = 0;
+ else if (*c == '\\')
+ state = 6;
+ break;
+ case 4:
+ if (*c == '/') {
+ *(c-1) = ' ';
+ *c = ' ';
+ state = 2;
+ } else if (*c == '*') {
+ *(c-1) = ' ';
+ *c = ' ';
+ state = 1;
+ } else
+ state = 0;
+ break;
+ case 5:
+ if (*c == '/')
+ state = 0;
+ *c = ' ';
+ break;
+ case 6:
+ state = 3;
+ break;
+ }
+ ++c;
+ }
+}
+
/* Dump all of the nested class declarations to the inline processor
* However. We need to do a few name replacements and other munging
* first. This function must be called before closing a class! */
@@ -1053,6 +1115,9 @@ static Node *dump_nested(const char *parent) {
ret = retx;
*/
+ /* Strip comments - further code may break in presence of comments. */
+ strip_comments(Char(n->code));
+
/* Make all SWIG created typedef structs/unions/classes unnamed else
redefinition errors occur - nasty hack alert.*/
@@ -1360,7 +1425,7 @@ static void default_arguments(Node *n) {
* Used by the parser to mark subtypes with extra information.
* ----------------------------------------------------------------------------- */
-static void tag_nodes(Node *n, const String_or_char *attrname, DOH *value) {
+static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
while (n) {
Setattr(n, attrname, value);
tag_nodes(firstChild(n), attrname, value);
@@ -1886,14 +1951,19 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
;
/* ------------------------------------------------------------
- %includefile "filename" [ declarations ]
- %importfile "filename" [ declarations ]
+ %includefile "filename" [option1="xyz", ...] [ declarations ]
+ %importfile "filename" [option1="xyz", ...] [ declarations ]
------------------------------------------------------------ */
include_directive: includetype options string LBRACKET {
$1.filename = Copy(cparse_file);
$1.line = cparse_line;
scanner_set_location(NewString($3),1);
+ if ($2) {
+ String *maininput = Getattr($2, "maininput");
+ if (maininput)
+ scanner_set_main_input_file(NewString(maininput));
+ }
} interface RBRACKET {
String *mname = 0;
$$ = $6;
@@ -2290,21 +2360,25 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
String *val = $7 ? NewString($7) : NewString("1");
new_feature($3, val, 0, $5.id, $5.type, $5.parms, $6.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN declarator cpp_const SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, 0, $7.id, $7.type, $7.parms, $8.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring featattr RPAREN declarator cpp_const stringbracesemi {
String *val = $8 ? NewString($8) : NewString("1");
new_feature($3, val, $4, $6.id, $6.type, $6.parms, $7.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN declarator cpp_const SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, $6, $8.id, $8.type, $8.parms, $9.qualifier);
$$ = 0;
+ scanner_clear_rename();
}
/* Global feature */
@@ -2312,21 +2386,25 @@ feature_directive : FEATURE LPAREN idstring RPAREN declarator cpp_const stringbr
String *val = $5 ? NewString($5) : NewString("1");
new_feature($3, val, 0, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum RPAREN SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, 0, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring featattr RPAREN stringbracesemi {
String *val = $6 ? NewString($6) : NewString("1");
new_feature($3, val, $4, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
| FEATURE LPAREN idstring COMMA stringnum featattr RPAREN SEMI {
String *val = Len($5) ? NewString($5) : 0;
new_feature($3, val, $6, 0, 0, 0, 0);
$$ = 0;
+ scanner_clear_rename();
}
;
@@ -3152,15 +3230,15 @@ cpp_class_decl :
storage_class cpptype idcolon inherit LBRACE {
List *bases = 0;
Node *scope = 0;
- $$ = new_node("class");
- Setline($$,cparse_start_line);
- Setattr($$,"kind",$2);
+ $<node>$ = new_node("class");
+ Setline($<node>$,cparse_start_line);
+ Setattr($<node>$,"kind",$2);
if ($4) {
- Setattr($$,"baselist", Getattr($4,"public"));
- Setattr($$,"protectedbaselist", Getattr($4,"protected"));
- Setattr($$,"privatebaselist", Getattr($4,"private"));
+ Setattr($<node>$,"baselist", Getattr($4,"public"));
+ Setattr($<node>$,"protectedbaselist", Getattr($4,"protected"));
+ Setattr($<node>$,"privatebaselist", Getattr($4,"private"));
}
- Setattr($$,"allows_typedef","1");
+ Setattr($<node>$,"allows_typedef","1");
/* preserve the current scope */
prev_symtab = Swig_symbol_current();
@@ -3189,10 +3267,10 @@ cpp_class_decl :
nscope_inner = 0;
}
}
- Setattr($$,"name",$3);
+ Setattr($<node>$,"name",$3);
Delete(class_rename);
- class_rename = make_name($$,$3,0);
+ class_rename = make_name($<node>$,$3,0);
Classprefix = NewString($3);
/* Deal with inheritance */
if ($4) {
@@ -3256,12 +3334,12 @@ cpp_class_decl :
} else {
max_class_levels *= 2;
}
- class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels);
+ class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels);
if (!class_decl) {
Swig_error(cparse_file, cparse_line, "realloc() failed\n");
}
}
- class_decl[class_level++] = $$;
+ class_decl[class_level++] = $<node>$;
inclass = 1;
} cpp_members RBRACE cpp_opt_declarators {
Node *p;
@@ -3384,14 +3462,14 @@ cpp_class_decl :
| storage_class cpptype LBRACE {
String *unnamed;
unnamed = make_unnamed();
- $$ = new_node("class");
- Setline($$,cparse_start_line);
- Setattr($$,"kind",$2);
- Setattr($$,"storage",$1);
- Setattr($$,"unnamed",unnamed);
- Setattr($$,"allows_typedef","1");
+ $<node>$ = new_node("class");
+ Setline($<node>$,cparse_start_line);
+ Setattr($<node>$,"kind",$2);
+ Setattr($<node>$,"storage",$1);
+ Setattr($<node>$,"unnamed",unnamed);
+ Setattr($<node>$,"allows_typedef","1");
Delete(class_rename);
- class_rename = make_name($$,0,0);
+ class_rename = make_name($<node>$,0,0);
if (strcmp($2,"class") == 0) {
cplus_mode = CPLUS_PRIVATE;
} else {
@@ -3405,12 +3483,12 @@ cpp_class_decl :
} else {
max_class_levels *= 2;
}
- class_decl = realloc(class_decl, sizeof(Node*) * max_class_levels);
+ class_decl = (Node**) realloc(class_decl, sizeof(Node*) * max_class_levels);
if (!class_decl) {
Swig_error(cparse_file, cparse_line, "realloc() failed\n");
}
}
- class_decl[class_level++] = $$;
+ class_decl[class_level++] = $<node>$;
inclass = 1;
Classprefix = NewStringEmpty();
Delete(Namespaceprefix);
@@ -5414,7 +5492,18 @@ valexpr : exprnum { $$ = $1; }
| LPAREN expr RPAREN expr %prec CAST {
$$ = $4;
if ($4.type != T_STRING) {
- $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val);
+ switch ($2.type) {
+ case T_FLOAT:
+ case T_DOUBLE:
+ case T_LONGDOUBLE:
+ case T_FLTCPLX:
+ case T_DBLCPLX:
+ $$.val = NewStringf("(%s)%s", $2.val, $4.val); /* SwigType_str and decimal points don't mix! */
+ break;
+ default:
+ $$.val = NewStringf("(%s) %s", SwigType_str($2.val,0), $4.val);
+ break;
+ }
}
}
| LPAREN expr pointer RPAREN expr %prec CAST {
diff --git a/Source/CParse/templ.c b/Source/CParse/templ.c
index a3e992f83..14886605f 100644
--- a/Source/CParse/templ.c
+++ b/Source/CParse/templ.c
@@ -15,7 +15,7 @@ char cvsroot_templ_c[] = "$Id$";
static int template_debug = 0;
-String *baselists[3];
+const char *baselists[3];
void SwigType_template_init() {
baselists[0] = "baselist";
diff --git a/Source/DOH/README b/Source/DOH/README
index 1e948105c..9a42e8b8b 100644
--- a/Source/DOH/README
+++ b/Source/DOH/README
@@ -92,12 +92,12 @@ DohEncoding(name, fn) Register a format encoding for Printf
Currently Available datatypes
------------------------------
-NewString(char *initial) Strings
-NewHash() Hash
-NewList() List
-NewVoid(void *ptr, void (*del)(void *)) Void
-NewFile(char *file, char *mode) File
-NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object
+NewString(char *initial) Strings
+NewHash() Hash
+NewList() List
+NewVoid(void *ptr, void (*del)(void *)) Void
+NewFile(char *filename, char *mode, List *newfiles) File
+NewCallable(DOH *(*func)(DOH *, DOH *)) Callable object
Odds and ends:
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index dcb0140e0..15827f328 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -827,7 +827,7 @@ void DohSetfile(DOH *ho, DOH *file) {
/* -----------------------------------------------------------------------------
* DohGetFile()
* ----------------------------------------------------------------------------- */
-DOH *DohGetfile(DOH *ho) {
+DOH *DohGetfile(const DOH *ho) {
DohBase *h = (DohBase *) ho;
DohObjInfo *objinfo;
if (!h)
@@ -854,7 +854,7 @@ void DohSetline(DOH *ho, int l) {
/* -----------------------------------------------------------------------------
* DohGetLine()
* ----------------------------------------------------------------------------- */
-int DohGetline(DOH *ho) {
+int DohGetline(const DOH *ho) {
DohBase *h = (DohBase *) ho;
DohObjInfo *objinfo;
if (!h)
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index 7ab244fab..766e12a34 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -144,6 +144,9 @@ typedef void DOH;
#define DOHString_or_char DOH
#define DOHObj_or_char DOH
+typedef const DOHString_or_char * const_String_or_char_ptr;
+typedef const DOHString_or_char * DOHconst_String_or_char_ptr;
+
#define DOH_BEGIN -1
#define DOH_END -2
#define DOH_CUR -3
@@ -234,9 +237,9 @@ extern DohIterator DohNext(DohIterator x);
/* Positional */
-extern int DohGetline(DOH *obj);
+extern int DohGetline(const DOH *obj);
extern void DohSetline(DOH *obj, int line);
-extern DOH *DohGetfile(DOH *obj);
+extern DOH *DohGetfile(const DOH *obj);
extern void DohSetfile(DOH *obj, DOH *file);
/* String Methods */
@@ -271,7 +274,7 @@ extern int DohGetmark(DOH *obj);
* Strings.
* ----------------------------------------------------------------------------- */
-extern DOHString *DohNewStringEmpty();
+extern DOHString *DohNewStringEmpty(void);
extern DOHString *DohNewString(const DOH *c);
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
extern DOHString *DohNewStringf(const DOH *fmt, ...);
@@ -297,7 +300,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
* Files
* ----------------------------------------------------------------------------- */
-extern DOHFile *DohNewFile(DOH *file, const char *mode);
+extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
extern DOHFile *DohNewFileFromFile(FILE *f);
extern DOHFile *DohNewFileFromFd(int fd);
extern void DohFileErrorDisplay(DOHString * filename);
@@ -309,14 +312,14 @@ extern int DohCopyto(DOHFile * input, DOHFile * output);
* List
* ----------------------------------------------------------------------------- */
-extern DOHList *DohNewList();
+extern DOHList *DohNewList(void);
extern void DohSortList(DOH *lo, int (*cmp) (const DOH *, const DOH *));
/* -----------------------------------------------------------------------------
* Hash
* ----------------------------------------------------------------------------- */
-extern DOHHash *DohNewHash();
+extern DOHHash *DohNewHash(void);
/* -----------------------------------------------------------------------------
* Void
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index 8c53978ee..65c2336a4 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -228,15 +228,16 @@ static DohObjInfo DohFileType = {
* NewFile()
*
* Create a new file from a given filename and mode.
+ * If newfiles is non-zero, the filename is added to the list of new files.
* ----------------------------------------------------------------------------- */
-DOH *DohNewFile(DOH *fn, const char *mode) {
+DOH *DohNewFile(DOH *filename, const char *mode, DOHList *newfiles) {
DohFile *f;
FILE *file;
- char *filename;
+ char *filen;
- filename = Char(fn);
- file = fopen(filename, mode);
+ filen = Char(filename);
+ file = fopen(filen, mode);
if (!file)
return 0;
@@ -245,6 +246,8 @@ DOH *DohNewFile(DOH *fn, const char *mode) {
fclose(file);
return 0;
}
+ if (newfiles)
+ Append(newfiles, filename);
f->filep = file;
f->fd = 0;
f->closeondel = 1;
diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c
index 62aef10f2..045de8b5b 100644
--- a/Source/DOH/hash.c
+++ b/Source/DOH/hash.c
@@ -535,7 +535,7 @@ DohObjInfo DohHashType = {
* Create a new hash table.
* ----------------------------------------------------------------------------- */
-DOH *DohNewHash() {
+DOH *DohNewHash(void) {
Hash *h;
int i;
h = (Hash *) DohMalloc(sizeof(Hash));
diff --git a/Source/DOH/list.c b/Source/DOH/list.c
index a45731de1..7a1786299 100644
--- a/Source/DOH/list.c
+++ b/Source/DOH/list.c
@@ -345,7 +345,7 @@ DohObjInfo DohListType = {
#define MAXLISTITEMS 8
-DOH *DohNewList() {
+DOH *DohNewList(void) {
List *l;
int i;
l = (List *) DohMalloc(sizeof(List));
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 1498d717a..141cd58e8 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -1056,7 +1056,7 @@ DOHString *DohNewString(const DOH *so) {
* NewStringEmpty() - Create a new string
* ----------------------------------------------------------------------------- */
-DOHString *DohNewStringEmpty() {
+DOHString *DohNewStringEmpty(void) {
int max = INIT_MAXSIZE;
String *str = (String *) DohMalloc(sizeof(String));
str->hashkey = 0;
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index 90d668d6c..41b31d0ea 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -49,6 +49,7 @@
#define WARN_DEPRECATED_NOEXTERN 122
#define WARN_DEPRECATED_NODEFAULT 123
#define WARN_DEPRECATED_TYPEMAP_LANG 124
+#define WARN_DEPRECATED_INPUT_FILE 125
/* -- Preprocessor -- */
@@ -251,8 +252,8 @@
* PHP4 versions of new warnings since existing user interface files can't
* be using them.
*/
-#define WARN_PHP4_MULTIPLE_INHERITANCE 870
-#define WARN_PHP4_UNKNOWN_PRAGMA 871
+#define WARN_PHP_MULTIPLE_INHERITANCE 870
+#define WARN_PHP_UNKNOWN_PRAGMA 871
#define WARN_PHP_MULTIPLE_INHERITANCE 870
#define WARN_PHP_UNKNOWN_PRAGMA 871
diff --git a/Source/Modules/allegrocl.cxx b/Source/Modules/allegrocl.cxx
index 217c89b1f..1eb12630c 100644
--- a/Source/Modules/allegrocl.cxx
+++ b/Source/Modules/allegrocl.cxx
@@ -21,7 +21,8 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
static File *f_cl = 0;
String *f_clhead = NewString("");
String *f_clwrap = NewString("(swig-in-package ())\n\n");
-static File *f_cxx;
+static File *f_begin;
+static File *f_runtime;
static File *f_cxx_header = 0;
static File *f_cxx_wrapper = 0;
@@ -34,6 +35,8 @@ static bool CWrap = true; // generate wrapper file for C code by default. most c
static bool Generate_Wrapper = false;
static bool unique_swig_package = false;
+static SwigType *fwdref_ffi_type = NewString("__SWIGACL_FwdReference");
+
static String *current_namespace = NewString("");
static String *current_package = NewString("");
static Hash *defined_namespace_packages = NewHash();
@@ -168,6 +171,7 @@ static String *namespace_of(String *str) {
void add_linked_type(Node *n) {
#ifdef ALLEGROCL_CLASS_DEBUG
Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n);
+ // Swig_print_node(n);
#endif
if (!first_linked_type) {
first_linked_type = n;
@@ -297,7 +301,8 @@ void add_forward_referenced_type(Node *n, int overwrite = 0) {
}
}
-void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String *name = 0, String *ns = current_namespace) {
+void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
+ String *name = 0, String *ns = current_namespace) {
String *val;
String *ns_list = listify_namespace(ns);
@@ -321,22 +326,34 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String
/*
For typedefs of the form:
- typedef __xxx { ... } xxx;
+ typedef struct __xxx { ... } xxx;
+
+ behavior differs between C mode and C++ mode.
+ C Mode:
add_defined_foreign_type will be called once via classHandler
- to define the type for 'struct __xxx', and once via typedefHandler
- to associate xxx with 'struct __xxx'.
+ to define the type for 'struct __xxx' and add the mapping from
+ 'struct __xxx' -> 'xxx'
- We create the following type to identifier mappings:
+ It will also be called once via typedefHandler to add the
+ mapping 'xxx' -> 'xxx'
- struct __xxx -> (swig-insert-id "xxx") via classHand
- xxx -> (swig-insert-id "xxx") via typedefHand
+ C++ Mode:
+ add_defined_foreign_type will be called once via classHandler
+ to define the type for 'xxx'. it also adds the mapping from
+ 'xxx' -> 'xxx' and also for 'struct xxx' -> 'xxx'
- and all references to this typedef'd struct will appear in
- generated code as 'xxx'. For non-typedef'd structs, the
- classHand mapping will be
+ In typedefHandler, we again try to add the mapping from
+ 'xxx' -> 'xxx', which already exists. This second mapping
+ is ignored.
- struct __xxx -> (swig-insert-id "__xxx")
+ Both modes:
+
+ All references to this typedef'd struct will appear in
+ generated lisp code as an objectd of type 'xxx'. For
+ non-typedef'd structs, the classHand mapping will be
+
+ struct __xxx -> (swig-insert-id "__xxx")
*/
// Swig_print_node(n);
String *unnamed = Getattr(n, "unnamed");
@@ -466,7 +483,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String
if (!Strcmp(nodeType(n), "cdecl") && !Strcmp(Getattr(n, "storage"), "typedef")) {
SwigType *type = SwigType_strip_qualifiers(Getattr(n, "type"));
#ifdef ALLEGROCL_CLASS_DEBUG
- Printf(stderr, "Examining typedef '%s' for class references.\n", type);
+ Printf(stderr, "Examining typedef '%s' for class references. (%d)\n", type, SwigType_isclass(type));
#endif
if (SwigType_isclass(type)) {
#ifdef ALLEGROCL_CLASS_DEBUG
@@ -585,7 +602,11 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0, String
Delete(mangled_name_gen);
Delete(mangled_lname_gen);
} else {
- Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n), "Attempting to store a foreign type that exists: %s (%s)\n", k, val);
+ if (!CPlusPlus || Strcmp(Getattr(n,"kind"),"typedef")) {
+ Swig_warning(WARN_TYPE_REDEFINED, Getfile(n), Getline(n),
+ "Attempting to store a foreign type that exists: %s (%s)\n",
+ k, val);
+ }
}
Delete(ns_list);
@@ -605,7 +626,7 @@ void note_implicit_template_instantiation(SwigType *t) {
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
}
-String *get_ffi_type(SwigType *ty, const String_or_char *name) {
+String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
/* lookup defined foreign type.
if it exists, it will return a form suitable for placing
into lisp code to generate the def-foreign-type name */
@@ -620,7 +641,8 @@ String *get_ffi_type(SwigType *ty, const String_or_char *name) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "found_type '%s'\n", found_type);
#endif
- return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : NewString(":void"));
+ return (Strcmp(found_type, "forward-reference") ? Copy(found_type) :
+ get_ffi_type(fwdref_ffi_type, ""));
} else {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
@@ -707,25 +729,40 @@ String *internal_compose_foreign_type(SwigType *ty) {
if (res)
Printf(ffiType, "%s", res);
}
-// while(resolved_type) {
-// // the resolved_type may expand into something like p.NS1::NS2::SomeType
-// // for which get_ffi_type will not find any match (due to the p.).
-// // Printf(stderr, "\n in resolved type loop on '%s'\n", resolved_type);
-// res = get_ffi_type(resolved_type, "");
-// if (res) {
-// Printf(ffiType, "%s", res);
-// break;
-// } else {
-// resolved_type = SwigType_typedef_resolve(resolved_type);
-// }
-// }
+
if (!res) {
- if (Strstr(tok, "struct ")) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok);
- } else {
- Printf(stderr, "Unable to compose foreign type of: '%s'\n", tok);
+ String *is_struct = 0;
+ String *tok_remove_text = 0;
+ String *tok_name = Copy(tok);
+ String *tok_key = SwigType_str(tok,0);
+ if ((is_struct = Strstr(tok_key, "struct ")) || Strstr(tok_key, "union ")) {
+ tok_remove_text = NewString(is_struct ? "struct " : "union ");
+ }
+
+ /* be more permissive of opaque types. This is the swig way.
+ compiles will notice if these types are ultimately not
+ present. */
+
+ if(tok_remove_text) {
+ Replaceall(tok_name,tok_remove_text,"");
}
- Printf(ffiType, "(* :void)");
+ tok_name = strip_namespaces(tok_name);
+ Delete(tok_remove_text);
+ // Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(tok), Getline(tok), "Unable to find definition of '%s', assuming forward reference.\n", tok);
+
+#ifdef ALLEGROCL_TYPE_DEBUG
+ Printf(stderr, "i-c-f-t: adding forward reference for unknown type '%s'. mapping: %s -> %s\n", tok, tok_key, tok_name);
+#endif
+ Node *nn = NewHash();
+ Setattr(nn,"nodeType","classforward");
+ Setattr(nn,"kind","class");
+ Setattr(nn,"sym:name",tok_name);
+ Setattr(nn,"name",tok_key);
+ Setattr(nn,"allegrocl:package",current_namespace);
+
+ add_forward_referenced_type(nn, 0);
+ // tok_name is dangling here, unused. ouch. why?
+ Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name);
}
}
}
@@ -733,24 +770,36 @@ String *internal_compose_foreign_type(SwigType *ty) {
return ffiType;
}
-String *compose_foreign_type(SwigType *ty, String *id = 0) {
+String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
+
+/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */
- Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0);
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
- String *id_ref = SwigType_str(ty, id);
+ // Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0));
+ /* String *id_ref = SwigType_str(ty, id);
Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n",
id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res);
+ if (lookup_res) Swig_print_node(lookup_res);
+ */
#endif
+
/* should we allow named lookups in the typemap here? YES! */
/* unnamed lookups should be found in get_ffi_type, called
by internal_compose_foreign_type(), below. */
+
+ /* I'm reverting to 'no' for the question above. I can no longer
+ remember why I needed it. If a user needed it, I'll find out
+ as soon as they upgrade. Sigh. -mutandiz 9/16/2008. */
+
+/*
if(id && lookup_res) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "compose_foreign_type: EXIT-1 (%s)\n ", Getattr(lookup_res, "code"));
#endif
return NewString(Getattr(lookup_res, "code"));
}
+*/
SwigType *temp = SwigType_strip_qualifiers(ty);
String *res = internal_compose_foreign_type(temp);
@@ -828,6 +877,10 @@ String *strip_parens(String *string) {
}
int ALLEGROCL::validIdentifier(String *s) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "validIdentifier %s\n", s);
+#endif
+
char *c = Char(s);
bool got_dot = false;
@@ -882,9 +935,8 @@ String *infix_to_prefix(String *val, char split_op, const String *op, String *ty
Printf(result, ")");
Delete(ored);
return part_failed ? 0 : result;
- } else {
- Delete(ored);
}
+ Delete(ored);
return 0;
}
@@ -903,7 +955,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
String *ns = listify_namespace(current_namespace);
// very basic parsing of infix expressions.
- if (try_to_split) {
+ if (try_to_split && SwigType_type(type) != T_STRING) {
if ((res = infix_to_prefix(num, '|', "logior", type)))
return res;
if ((res = infix_to_prefix(num, '&', "logand", type)))
@@ -918,9 +970,20 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
return res;
if ((res = infix_to_prefix(num, '-', "-", type)))
return res;
+ // if ((res = infix_to_prefix(num, '~', "lognot", type))) return res;
// if( (res = infix_to_prefix(num, '<<', "ash", type)) ) return res;
}
+ // unary complement...
+ if (s[0] == '~' && Len(num) >= 2) {
+ String *id = NewString(++s);
+ String *id_conv = convert_literal(id, type, false);
+ Delete(id);
+ if (id_conv)
+ return NewStringf("(lognot %s)", id_conv);
+ s--;
+ }
+
if (SwigType_type(type) == T_FLOAT || SwigType_type(type) == T_DOUBLE || SwigType_type(type) == T_LONGDOUBLE) {
// Use CL syntax for float literals
String *oldnum = Copy(num);
@@ -954,6 +1017,7 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
Delete(num);
num = 0;
}
+ Delete(lisp_exp);
} else {
String *id = NewStringf("#.(swig-insert-id \"%s\" %s :type :constant)",
num, ns);
@@ -1083,7 +1147,7 @@ void emit_synonym(Node *synonym) {
of_ltype = lookup_defined_foreign_ltype(of_name);
- // Printf(f_clhead,";; from emit-synonym\n");
+ // Printf(stderr,";; from emit-synonym syn='%s' of_ltype='%s'\n", syn_ltype, of_ltype);
if( of_ltype )
Printf(f_clhead, "(swig-def-synonym-type %s\n %s\n %s)\n", syn_ltype, of_ltype, syn_type);
@@ -1285,7 +1349,6 @@ void emit_typedef(Node *n) {
// leave these in for now. might want to change these to def-foreign-class at some point.
// Printf(f_clhead, ";; %s\n", SwigType_typedef_resolve_all(lisp_type));
- // Swig_print_node(n);
Printf(f_clhead, "(swig-def-foreign-type \"%s\"\n %s)\n", name, lisp_type);
Delete(name);
@@ -1469,6 +1532,7 @@ extern "C" Language *swig_allegrocl(void) {
void ALLEGROCL::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGALLEGROCL 1", 0);
SWIG_library_directory("allegrocl");
SWIG_config_file("allegrocl.swg");
@@ -1516,14 +1580,15 @@ void ALLEGROCL::main(int argc, char *argv[]) {
"\tcalled to convert identifiers to symbols.\n"
"\n"
" -[no]cwrap\n"
- "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n");
+ "\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"
+ " -isolate\n"
+ "Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n"
+ "into the same running Allegro CL image.\n");
}
}
- Preprocessor_define("SWIGALLEGROCL 1", 0);
-
allow_overloading();
}
@@ -1536,7 +1601,7 @@ int ALLEGROCL::top(Node *n) {
Printf(cl_filename, "%s%s.cl", SWIG_output_directory(), module_name);
- f_cl = NewFile(cl_filename, "w");
+ f_cl = NewFile(cl_filename, "w", SWIG_output_files());
if (!f_cl) {
Printf(stderr, "Unable to open %s for writing\n", cl_filename);
SWIG_exit(EXIT_FAILURE);
@@ -1545,33 +1610,42 @@ int ALLEGROCL::top(Node *n) {
Generate_Wrapper = CPlusPlus || CWrap;
if (Generate_Wrapper) {
- f_cxx = NewFile(cxx_filename, "w");
- if (!f_cxx) {
+ f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
+ if (!f_begin) {
Close(f_cl);
Delete(f_cl);
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
SWIG_exit(EXIT_FAILURE);
}
} else
- f_cxx = NewString("");
+ f_begin = NewString("");
- f_cxx_header = f_cxx;
+ f_runtime = NewString("");
+ f_cxx_header = f_runtime;
f_cxx_wrapper = NewString("");
Swig_register_filebyname("header", f_cxx_header);
Swig_register_filebyname("wrapper", f_cxx_wrapper);
- Swig_register_filebyname("runtime", f_cxx);
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("lisp", f_clwrap);
Swig_register_filebyname("lisphead", f_cl);
- Printf(f_cl, ";; This is an automatically generated file. Make changes in\n"
- ";; the definition file, not here.\n\n"
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGALLEGROCL\n");
+ Printf(f_runtime, "\n");
+
+ Swig_banner_target_lang(f_cl, ";;");
+
+ Printf(f_cl, "\n"
"(defpackage :%s\n"
" (:use :common-lisp :ff :excl)\n"
" (:export #:*swig-identifier-converter* #:*swig-module-name*\n"
" #:*void* #:*swig-export-list*))\n"
"(in-package :%s)\n\n"
- "(eval-when (compile load eval)\n"
+ "(eval-when (:compile-toplevel :load-toplevel :execute)\n"
" (defparameter *swig-identifier-converter* '%s)\n"
" (defparameter *swig-module-name* :%s))\n\n", swig_package, swig_package, identifier_converter, module_name);
Printf(f_cl, "(defpackage :%s\n" " (:use :common-lisp :%s :ff :excl))\n\n", module_name, swig_package);
@@ -1582,7 +1656,7 @@ int ALLEGROCL::top(Node *n) {
Language::top(n);
- // SwigType_emit_type_table(f_cxx,f_cxx_wrapper);
+ // SwigType_emit_type_table(f_runtime,f_cxx_wrapper);
// Swig_print_tree(n);
#ifdef ALLEGROCL_TYPE_DEBUG
@@ -1605,8 +1679,12 @@ int ALLEGROCL::top(Node *n) {
Delete(f_clhead);
Delete(f_clwrap);
- Close(f_cxx);
- Delete(f_cxx);
+ Dump(f_runtime, f_begin);
+ Printf(f_begin, "%s\n", f_cxx_wrapper);
+
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
Delete(f_cxx_wrapper);
// Swig_print_tree(n);
@@ -1901,7 +1979,7 @@ int any_varargs(ParmList *pl) {
return 0;
}
-String *get_lisp_type(SwigType *ty, const String_or_char *name) {
+String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
@@ -2087,7 +2165,9 @@ struct IDargs {
String *arity;
IDargs():name(0), type(0), klass(0), arity(0) {
- } String *full_quoted_str() {
+ }
+
+ String *full_quoted_str() {
String *result = no_others_quoted_str();
if (arity)
Printf(result, " :arity %s", arity);
@@ -2338,41 +2418,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
for (p = pl; p; p = nextSibling(p), argnum++, largnum++) {
// SwigType *argtype=Getattr(p, "type");
SwigType *argtype = Swig_cparse_type(Getattr(p, "tmap:ctype"));
+ SwigType *parmtype = Getattr(p,"type");
if (!first) {
Printf(fcl, "\n ");
}
- if (SwigType_isvarargs(argtype)) {
- Printf(stderr, "Function %s (line %d) contains varargs, which is not directly supported. Use %%varargs instead.\n", Getattr(n, "name"), Getline(n));
- } else {
+ /* by default, skip varargs */
+ if (!SwigType_isvarargs(parmtype)) {
String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name"));
- // Swig_print_node(p);
// Printf(stderr,"%s\n", Getattr(p,"tmap:lin"));
String *ffitype = compose_foreign_type(argtype, Getattr(p,"name"));
- String *deref_ffitype;
-
- deref_ffitype = dereference_ffitype(ffitype);
-
-/*
- String *temp = Copy(argtype);
-
- if (SwigType_ispointer(temp)) {
- SwigType_pop(temp);
- deref_ffitype = compose_foreign_type(temp);
- } else {
- deref_ffitype = Copy(ffitype);
- }
-
- Delete(temp);
-*/
- // String *lisptype=get_lisp_type(argtype, argname);
- String *lisptype = get_lisp_type(Getattr(p, "type"), Getattr(p, "name"));
+ String *deref_ffitype = dereference_ffitype(ffitype);
+ String *lisptype = get_lisp_type(parmtype, Getattr(p, "name"));
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "lisptype of '%s' '%s' = '%s'\n",
- Getattr(p, "type"), Getattr(p, "name"), lisptype);
+ Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype,
+ Getattr(p, "name"), lisptype);
#endif
// while we're walking the parameters, generating LIN
@@ -2403,7 +2466,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
first = 0;
}
+ Delete(argname);
Delete(ffitype);
+ Delete(deref_ffitype);
Delete(lisptype);
}
}
@@ -2441,11 +2506,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
lclass = lookup_defined_foreign_ltype(cl_t);
isPtrReturn = 1;
}
- // if (SwigType_ispointer(cl_t)) {
- // isPtrReturn = 1;
- // SwigType_pop(cl_t);
- // lclass = lookup_defined_foreign_ltype(cl_t);
- // }
int ff_foreign_ptr = 0;
if (!lclass) {
@@ -2518,6 +2578,11 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
}
int ALLEGROCL::functionWrapper(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "functionWrapper %s\n", Getattr(n,"name"));
+ Swig_print_node(n);
+#endif
+
ParmList *parms = CopyParmList(Getattr(n, "parms"));
Wrapper *f = NewWrapper();
@@ -2532,11 +2597,13 @@ int ALLEGROCL::functionWrapper(Node *n) {
Delete(resolved);
if (!is_void_return) {
- String *lresult_init = NewStringf("= (%s)0", raw_return_type);
- Wrapper_add_localv(f, "lresult",
- SwigType_lstr(SwigType_ltype(return_type), "lresult"),
- lresult_init, NIL);
- Delete(lresult_init);
+ String *lresult_init =
+ NewStringf("= (%s)0",
+ SwigType_str(SwigType_strip_qualifiers(return_type),0));
+ Wrapper_add_localv(f, "lresult",
+ SwigType_lstr(SwigType_ltype(return_type), "lresult"),
+ lresult_init, NIL);
+ Delete(lresult_init);
}
// Emit all of the local variables for holding arguments.
emit_parameter_variables(parms, f);
@@ -2632,26 +2699,32 @@ int ALLEGROCL::functionWrapper(Node *n) {
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
if (!is_void_return && tm) {
- Replaceall(tm, "$result", "lresult");
- Printf(f->code, "%s\n", tm);
- Printf(f->code, " return lresult;\n");
- Delete(tm);
- } else {
- Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), name);
+ if (tm) {
+ Replaceall(tm, "$result", "lresult");
+ Printf(f->code, "%s\n", tm);
+ Printf(f->code, " return lresult;\n");
+ Delete(tm);
+ } else {
+ Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number,
+ "Unable to use return type %s in function %s.\n",
+ SwigType_str(t, 0), name);
+ }
}
+
emit_return_variable(n, t, f);
if (CPlusPlus) {
Printf(f->code, " } catch (...) {\n");
if (!is_void_return)
- Printf(f->code, " return (%s)0;\n", raw_return_type);
+ Printf(f->code, " return (%s)0;\n",
+ SwigType_str(SwigType_strip_qualifiers(return_type),0));
Printf(f->code, " }\n");
}
Printf(f->code, "}\n");
/* print this when in C mode? make this a command-line arg? */
if (Generate_Wrapper)
- Wrapper_print(f, f_cxx);
+ Wrapper_print(f, f_cxx_wrapper);
String *f_buffer = NewString("");
@@ -2673,13 +2746,15 @@ int ALLEGROCL::functionWrapper(Node *n) {
}
int ALLEGROCL::namespaceDeclaration(Node *n) {
- // Empty namespaces are not worth DEFPACKAGEing.
- // Swig_print_node(n);
#ifdef ALLEGROCL_DEBUG
Printf(stderr, "namespaceDecl: '%s'(0x%x) (fc=0x%x)\n", Getattr(n, "sym:name"), n, firstChild(n));
#endif
- if (!firstChild(n))
+ /* don't wrap a namespace with no contents. package bloat.
+ also, test-suite/namespace_class.i claims an unnamed namespace
+ is 'private' and should not be wrapped. Complying...
+ */
+ if (Getattr(n,"unnamed") || !firstChild(n))
return SWIG_OK;
String *name = Getattr(n, "sym:name");
@@ -2706,7 +2781,7 @@ int ALLEGROCL::namespaceDeclaration(Node *n) {
int ALLEGROCL::constructorHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "constructor %s\n", Getattr(n, "name"));
+ Printf(stderr, "constructorHandler %s\n", Getattr(n, "name"));
#endif
// Swig_print_node(n);
Setattr(n, "allegrocl:kind", "constructor");
@@ -2718,7 +2793,7 @@ int ALLEGROCL::constructorHandler(Node *n) {
int ALLEGROCL::destructorHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "destructor %s\n", Getattr(n, "name"));
+ Printf(stderr, "destructorHandler %s\n", Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "destructor");
@@ -2729,9 +2804,8 @@ int ALLEGROCL::destructorHandler(Node *n) {
}
int ALLEGROCL::constantWrapper(Node *n) {
-
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "constant %s\n", Getattr(n, "name"));
+ Printf(stderr, "constantWrapper %s\n", Getattr(n, "name"));
#endif
if (Generate_Wrapper) {
@@ -2750,10 +2824,10 @@ int ALLEGROCL::constantWrapper(Node *n) {
}
SwigType_add_qualifier(const_type, "const");
- SwigType_add_qualifier(const_type, "static");
- String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "name"));
- Printf(f_cxx, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val);
+ String *ppcname = NewStringf("ACLppc_%s", Getattr(n, "sym:name"));
+ // Printf(f_runtime, "static const %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val);
+ Printf(f_runtime, "static %s = %s;\n", SwigType_lstr(const_type, ppcname), const_val);
Setattr(n, "name", ppcname);
SetFlag(n, "feature:immutable");
@@ -2787,6 +2861,10 @@ int ALLEGROCL::constantWrapper(Node *n) {
}
int ALLEGROCL::globalvariableHandler(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "globalvariableHandler %s\n", Getattr(n, "name"));
+#endif
+
if (Generate_Wrapper)
return Language::globalvariableHandler(n);
@@ -2806,7 +2884,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
ctype = SwigType_str(type, 0);
// EXPORT <SwigType_str> <mangled_name>;
// <SwigType_str> <mangled_name> = <name>;
- // Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
+ // Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
// ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n",
@@ -2817,7 +2895,7 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
int ALLEGROCL::variableWrapper(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "variable %s\n", Getattr(n, "name"));
+ Printf(stderr, "variableWrapper %s\n", Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "variable");
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
@@ -2842,24 +2920,30 @@ int ALLEGROCL::variableWrapper(Node *n) {
}
ctype = SwigType_str(type, 0);
+
// EXPORT <SwigType_str> <mangled_name>;
// <SwigType_str> <mangled_name> = <name>;
- Printf(f_cxx, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
+ Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable"));
/*
- Printf(f_cxx, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
- Printf(f_cxx, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
+ Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
+ Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
*/
+ Printf(stderr,"***\n");
Delete(mangled_name);
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "DONE variable %s\n", Getattr(n, "name"));
+#endif
+
return SWIG_OK;
}
int ALLEGROCL::memberfunctionHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "member function %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
+ Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "member function");
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
@@ -2870,7 +2954,7 @@ int ALLEGROCL::memberfunctionHandler(Node *n) {
int ALLEGROCL::membervariableHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "member variable %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
+ Printf(stderr, "membervariableHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
#endif
Setattr(n, "allegrocl:kind", "member variable");
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
@@ -2880,10 +2964,8 @@ int ALLEGROCL::membervariableHandler(Node *n) {
}
int ALLEGROCL::typedefHandler(Node *n) {
-
#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "In typedefHAND\n");
- // Swig_print_node(n);
+ Printf(stderr, "In typedefHandler\n");
#endif
SwigType *typedef_type = Getattr(n,"type");
@@ -2901,9 +2983,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
Printf(stderr, " typedef in class '%s'(%x)\n", Getattr(in_class, "sym:name"), in_class);
#endif
Setattr(n, "allegrocl:typedef:in-class", in_class);
- }
- if (in_class) {
String *class_name = Getattr(in_class, "name");
name = NewStringf("%s__%s", class_name, sym_name);
type_ref = NewStringf("%s::%s", class_name, sym_name);
@@ -2917,14 +2997,19 @@ int ALLEGROCL::typedefHandler(Node *n) {
String *lookup = lookup_defined_foreign_type(typedef_type);
- // Printf(stderr, "** lookup='%s'(%x), ff_type='%s', strstr = '%d'\n", lookup, lookup, ff_type, !Strstr(ff_type,"void"));
+#ifdef ALLEGROCL_TYPE_DEBUG
+ Printf(stderr, "** lookup='%s'(%x), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference"));
+#endif
- if(lookup || (!lookup && !Strstr(ff_type,"void")))
+ if(lookup || (!lookup && Strcmp(typedef_type,"void")) ||
+ (!lookup && Strstr(ff_type,"__SWIGACL_FwdReference"))) {
add_defined_foreign_type(n, 0, type_ref, name);
- else add_forward_referenced_type(n);
+ } else {
+ add_forward_referenced_type(n);
+ }
#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "Out typedefHAND\n");
+ Printf(stderr, "Out typedefHandler\n");
#endif
Delete(ff_type);
@@ -2934,22 +3019,33 @@ int ALLEGROCL::typedefHandler(Node *n) {
// forward referenced classes are added specially to defined_foreign_types
int ALLEGROCL::classforwardDeclaration(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "classforwardDeclaration %s\n", Getattr(n, "name"));
+#endif
+
add_forward_referenced_type(n);
return SWIG_OK;
}
int ALLEGROCL::classHandler(Node *n) {
#ifdef ALLEGROCL_DEBUG
- Printf(stderr, "class %s::%s\n", current_namespace, Getattr(n, "sym:name"));
+ Printf(stderr, "classHandler %s::%s\n", current_namespace, Getattr(n, "sym:name"));
#endif
+ int result;
+
if (Generate_Wrapper)
- return cppClassHandler(n);
+ result = cppClassHandler(n);
else
- return cClassHandler(n);
+ result = cClassHandler(n);
+
+ return result;
}
int ALLEGROCL::cClassHandler(Node *n) {
+#ifdef ALLEGROCL_TYPE_DEBUG
+ Printf(stderr, "In cClassHandler\n");
+#endif
// String *cDeclName = Getattr(n,"classDeclaration:name");
// String *name= Getattr(n, "sym:name");
// String *kind = Getattr(n,"kind");
@@ -2959,22 +3055,21 @@ int ALLEGROCL::cClassHandler(Node *n) {
// Printf(stderr, "Adding %s foreign type\n", name);
String *ns = listify_namespace(current_namespace);
-#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "In cClassHAND\n");
-#endif
-
add_defined_foreign_type(n);
Delete(ns);
#ifdef ALLEGROCL_TYPE_DEBUG
- Printf(stderr, "Out cClassHAND\n");
+ Printf(stderr, "Out cClassHandler\n");
#endif
return SWIG_OK;
}
int ALLEGROCL::cppClassHandler(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "cppClassHandler %s\n", Getattr(n, "name"));
+#endif
// String *name=Getattr(n, "sym:name");
// String *kind = Getattr(n,"kind");
@@ -3033,6 +3128,9 @@ int ALLEGROCL::cppClassHandler(Node *n) {
// so their types can be added to the linked_type_list.
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
Getattr(c, "type"));
+#ifdef ALLEGROCL_CLASS_DEBUG
+ Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
+#endif
if (!SwigType_isfunction(childType))
Delete(compose_foreign_type(childType));
@@ -3073,6 +3171,9 @@ int ALLEGROCL::emit_one(Node *n) {
}
int ALLEGROCL::enumDeclaration(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "enumDeclaration %s\n", Getattr(n, "name"));
+#endif
if (Getattr(n, "sym:name")) {
add_defined_foreign_type(n);
@@ -3089,21 +3190,34 @@ int ALLEGROCL::enumDeclaration(Node *n) {
int ALLEGROCL::enumvalueDeclaration(Node *n) {
-
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "enumvalueDeclaration %s\n", Getattr(n, "name"));
+#endif
/* print this when in C mode? make this a command-line arg? */
-
if (Generate_Wrapper) {
- String *mangled_name = mangle_name(n, "ACL_ENUM");
-
- Printf(f_cxx, "EXPORT const %s %s = %s;\n", Getattr(n, "type"), mangled_name, Getattr(n, "value"));
+ SwigType *enum_type = Copy(Getattr(n,"type"));
+ String *mangled_name =
+ mangle_name(n, "ACL_ENUM",
+ in_class ? Getattr(in_class,"name") :
+ current_namespace);
+
+ SwigType_add_qualifier(enum_type,"const");
+
+ String *enum_decl = SwigType_str(enum_type, mangled_name);
+ Printf(f_cxx_wrapper, "EXPORT %s;\n", enum_decl);
+ Printf(f_cxx_wrapper, "%s = %s;\n", enum_decl, Getattr(n, "value"));
Delete(mangled_name);
+ Delete(enum_type);
+ Delete(enum_decl);
}
-
return SWIG_OK;
}
int ALLEGROCL::templateDeclaration(Node *n) {
+#ifdef ALLEGROCL_DEBUG
+ Printf(stderr, "templateDeclaration %s\n", Getattr(n, "name"));
+#endif
String *type = Getattr(n, "templatetype");
diff --git a/Source/Modules/cffi.cxx b/Source/Modules/cffi.cxx
index 736564d1a..0aa933c56 100644
--- a/Source/Modules/cffi.cxx
+++ b/Source/Modules/cffi.cxx
@@ -22,7 +22,8 @@ public:
String *f_clhead;
String *f_clwrap;
bool CWrap; // generate wrapper file for C code?
- File *f_cxx;
+ File *f_begin;
+ File *f_runtime;
File *f_cxx_header;
File *f_cxx_wrapper;
File *f_clos;
@@ -67,6 +68,7 @@ private:
void CFFI::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGCFFI 1", 0);
SWIG_library_directory("cffi");
SWIG_config_file("cffi.swg");
generate_typedef_flag = 0;
@@ -119,16 +121,15 @@ int CFFI::top(Node *n) {
Printf(lisp_filename, "%s%s.lisp", SWIG_output_directory(), module);
- File *f_lisp = NewFile(lisp_filename, "w");
- NewFile(lisp_filename, "w");
+ File *f_lisp = NewFile(lisp_filename, "w", SWIG_output_files());
if (!f_lisp) {
FileErrorDisplay(lisp_filename);
SWIG_exit(EXIT_FAILURE);
}
if (CPlusPlus || CWrap) {
- f_cxx = NewFile(cxx_filename, "w");
- if (!f_cxx) {
+ f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
+ if (!f_begin) {
Close(f_lisp);
Delete(f_lisp);
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
@@ -137,7 +138,7 @@ int CFFI::top(Node *n) {
String *clos_filename = NewString("");
Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module);
- f_clos = NewFile(clos_filename, "w");
+ f_clos = NewFile(clos_filename, "w", SWIG_output_files());
if (!f_clos) {
Close(f_lisp);
Delete(f_lisp);
@@ -145,22 +146,32 @@ int CFFI::top(Node *n) {
SWIG_exit(EXIT_FAILURE);
}
} else {
- f_cxx = NewString("");
+ f_begin = NewString("");
f_clos = NewString("");
}
- f_cxx_header = f_cxx;
+ f_runtime = NewString("");
+ f_cxx_header = f_runtime;
f_cxx_wrapper = NewString("");
Swig_register_filebyname("header", f_cxx_header);
Swig_register_filebyname("wrapper", f_cxx_wrapper);
- Swig_register_filebyname("runtime", f_cxx);
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("lisphead", f_clhead);
if (!no_swig_lisp)
Swig_register_filebyname("swiglisp", f_cl);
else
Swig_register_filebyname("swiglisp", f_null);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGCFFI\n");
+ Printf(f_runtime, "\n");
+
+ Swig_banner_target_lang(f_lisp, ";;;");
+
Language::top(n);
Printf(f_lisp, "%s\n", f_clhead);
Printf(f_lisp, "%s\n", f_cl);
@@ -171,8 +182,10 @@ int CFFI::top(Node *n) {
Delete(f_cl);
Delete(f_clhead);
Delete(f_clwrap);
- Close(f_cxx);
- Delete(f_cxx);
+ Dump(f_runtime, f_begin);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
Delete(f_cxx_wrapper);
Delete(f_null);
@@ -232,7 +245,7 @@ void CFFI::emit_defmethod(Node *n) {
ParmList *pl = Getattr(n, "parms");
int argnum = 0;
- Node *parent = parentNode(n);
+ Node *parent = getCurrentClass();
bool first = 0;
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
@@ -287,7 +300,7 @@ void CFFI::emit_initialize_instance(Node *n) {
ParmList *pl = Getattr(n, "parms");
int argnum = 0;
- Node *parent = parentNode(n);
+ Node *parent = getCurrentClass();
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");
@@ -324,18 +337,18 @@ void CFFI::emit_initialize_instance(Node *n) {
}
void CFFI::emit_setter(Node *n) {
- Node *p = parentNode(n);
+ Node *parent = getCurrentClass();
Printf(f_clos, "(cl:defmethod (cl:setf %s) (arg0 (obj %s))\n (%s (ff-pointer obj) arg0))\n\n",
lispify_name(n, Getattr(n, "name"), "'method"),
- lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
+ lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
}
void CFFI::emit_getter(Node *n) {
- Node *p = parentNode(n);
+ Node *parent = getCurrentClass();
Printf(f_clos, "(cl:defmethod %s ((obj %s))\n (%s (ff-pointer obj)))\n\n",
lispify_name(n, Getattr(n, "name"), "'method"),
- lispify_name(p, lispy_name(Char(Getattr(p, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
+ lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'class"), lispify_name(n, Getattr(n, "sym:name"), "'function"));
}
int CFFI::memberfunctionHandler(Node *n) {
@@ -455,7 +468,7 @@ int CFFI::functionWrapper(Node *n) {
Printf(f->code, "}\n");
if (CPlusPlus)
- Wrapper_print(f, f_cxx);
+ Wrapper_print(f, f_runtime);
if (CPlusPlus) {
emit_defun(n, wname);
@@ -630,7 +643,7 @@ int CFFI::enumDeclaration(Node *n) {
else {
String *type = Getattr(c, "type");
String *converted_value = convert_literal(value, type);
- Printf(f_cl, "\n\t(%s %s)", slot_name, converted_value);
+ Printf(f_cl, "\n\t(%s #.%s)", slot_name, converted_value);
Delete(converted_value);
}
Delete(value);
diff --git a/Source/Modules/chicken.cxx b/Source/Modules/chicken.cxx
index 2298d2939..12ef4b454 100644
--- a/Source/Modules/chicken.cxx
+++ b/Source/Modules/chicken.cxx
@@ -30,6 +30,7 @@ static char *module = 0;
static char *chicken_path = (char *) "chicken";
static int num_methods = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -101,12 +102,12 @@ protected:
int isPointer(SwigType *t);
void dispatchFunction(Node *n);
- String *chickenNameMapping(String *, String_or_char *);
+ String *chickenNameMapping(String *, const_String_or_char_ptr );
String *chickenPrimitiveName(String *);
String *runtimeCode();
String *defaultExternalRuntimeFilename();
- String *buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname);
+ String *buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname);
};
/* -----------------------------------------------------------------------
@@ -188,11 +189,12 @@ int CHICKEN::top(Node *n) {
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -205,6 +207,7 @@ int CHICKEN::top(Node *n) {
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -215,14 +218,16 @@ int CHICKEN::top(Node *n) {
clos_methods = NewString("");
scm_const_defs = NewString("");
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
- Printf(f_runtime, "/* Implementation : CHICKEN */\n\n");
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGCHICKEN\n");
if (no_collection)
Printf(f_runtime, "#define SWIG_CHICKEN_NO_COLLECTION 1\n");
+ Printf(f_runtime, "\n");
+
/* Set module name */
module = Swig_copy_string(Char(Getattr(n, "name")));
scmmodule = NewString(module);
@@ -251,14 +256,14 @@ int CHICKEN::top(Node *n) {
Printf(f_init, "#endif\n");
Printf(chicken_filename, "%s%s.scm", SWIG_output_directory(), module);
- if ((f_scm = NewFile(chicken_filename, "w")) == 0) {
+ if ((f_scm = NewFile(chicken_filename, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(chicken_filename);
SWIG_exit(EXIT_FAILURE);
}
- Printv(f_scm,
- ";; -*- buffer-read-only: t -*- vi: set ro:\n",
- ";; This file was created automatically by SWIG.\n", ";; Don't modify this file, modify the SWIG interface instead.\n", NIL);
+ Swig_banner_target_lang(f_scm, ";;");
+ Printf(f_scm, "\n");
+
if (declare_unit)
Printv(f_scm, "(declare (unit ", scmmodule, "))\n\n", NIL);
Printv(f_scm, "(declare \n",
@@ -307,15 +312,17 @@ int CHICKEN::top(Node *n) {
/* Close all of the files */
Delete(primitive_names);
Delete(scmmodule);
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_sym_size);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1233,7 +1240,7 @@ int CHICKEN::importDirective(Node *n) {
return Language::importDirective(n);
}
-String *CHICKEN::buildClosFunctionCall(List *types, String_or_char *closname, String_or_char *funcname) {
+String *CHICKEN::buildClosFunctionCall(List *types, const_String_or_char_ptr closname, const_String_or_char_ptr funcname) {
String *method_signature = NewString("");
String *func_args = NewString("");
String *func_call = NewString("");
@@ -1507,7 +1514,7 @@ int CHICKEN::validIdentifier(String *s) {
* If class_name = "" that means the mapping is for a function or
* variable not attached to any class.
* ------------------------------------------------------------ */
-String *CHICKEN::chickenNameMapping(String *name, String_or_char *class_name) {
+String *CHICKEN::chickenNameMapping(String *name, const_String_or_char_ptr class_name) {
String *n = NewString("");
if (Strcmp(class_name, "") == 0) {
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index 823f22e2c..fa73b3a0b 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -36,6 +36,7 @@ private:
void CLISP::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGCLISP 1", 0);
SWIG_library_directory("clisp");
SWIG_config_file("clisp.swg");
generate_typedef_flag = 0;
@@ -79,20 +80,22 @@ int CLISP::top(Node *n) {
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
}
- f_cl = NewFile(output_filename, "w+");
+ f_cl = NewFile(output_filename, "w+", SWIG_output_files());
if (!f_cl) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
}
Swig_register_filebyname("header", f_null);
+ Swig_register_filebyname("begin", f_null);
Swig_register_filebyname("runtime", f_null);
Swig_register_filebyname("wrapper", f_null);
- String *header =
- NewStringf
- (";; This is an automatically generated file. \n;;Make changes as you feel are necessary (but remember if you try to regenerate this file, your changes will be lost). \n\n(defpackage :%s\n (:use :common-lisp :ffi)",
- module);
+ String *header = NewString("");
+
+ Swig_banner_target_lang(header, ";;");
+
+ Printf(header, "\n(defpackage :%s\n (:use :common-lisp :ffi)", module);
Language::top(n);
diff --git a/Source/Modules/contract.cxx b/Source/Modules/contract.cxx
index 9bf8decf6..518dc2997 100644
--- a/Source/Modules/contract.cxx
+++ b/Source/Modules/contract.cxx
@@ -46,6 +46,7 @@ public:
int extendDirective(Node *n);
int importDirective(Node *n);
int includeDirective(Node *n);
+ int namespaceDeclaration(Node *n);
int classDeclaration(Node *n);
virtual int top(Node *n);
};
@@ -320,16 +321,23 @@ int Contracts::constructorDeclaration(Node *n) {
int Contracts::externDeclaration(Node *n) {
return emit_children(n);
}
+
int Contracts::extendDirective(Node *n) {
return emit_children(n);
}
+
int Contracts::importDirective(Node *n) {
return emit_children(n);
}
+
int Contracts::includeDirective(Node *n) {
return emit_children(n);
}
+int Contracts::namespaceDeclaration(Node *n) {
+ return emit_children(n);
+}
+
int Contracts::classDeclaration(Node *n) {
int ret = SWIG_OK;
InClass = 1;
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index c802ad3a2..ad6830ec6 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -24,6 +24,7 @@ class CSHARP:public Language {
const String *protected_string;
Hash *swig_types_hash;
+ File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@@ -85,7 +86,7 @@ class CSHARP:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
- static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
+ static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
@@ -102,6 +103,7 @@ public:
public_string(NewString("public")),
protected_string(NewString("protected")),
swig_types_hash(NULL),
+ f_begin(NULL),
f_runtime(NULL),
f_runtime_h(NULL),
f_header(NULL),
@@ -286,8 +288,8 @@ public:
SWIG_exit(EXIT_FAILURE);
}
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
@@ -297,13 +299,14 @@ public:
Printf(stderr, "Unable to determine outfile_h\n");
SWIG_exit(EXIT_FAILURE);
}
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
}
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -313,6 +316,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@@ -358,13 +362,17 @@ public:
if (!dllimport)
dllimport = Copy(module_class_name);
- Swig_banner(f_runtime); // Print the SWIG banner message
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGCSHARP\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name);
@@ -376,6 +384,8 @@ public:
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
}
+ Printf(f_runtime, "\n");
+
Swig_name_register((char *) "wrapper", (char *) "CSharp_%f");
if (old_variable_names) {
Swig_name_register((char *) "set", (char *) "set_%v");
@@ -396,7 +406,7 @@ public:
// Generate the intermediary class
{
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), imclass_name);
- File *f_im = NewFile(filen, "w");
+ File *f_im = NewFile(filen, "w", SWIG_output_files());
if (!f_im) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -440,7 +450,7 @@ public:
// Generate the C# module class
{
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), module_class_name);
- File *f_module = NewFile(filen, "w");
+ File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -567,10 +577,11 @@ public:
n_dmethods = 0;
/* Close all of the files */
- Dump(f_header, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
if (directorsEnabled()) {
- Dump(f_directors, f_runtime);
+ Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
@@ -585,13 +596,14 @@ public:
f_directors_h = NULL;
}
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -601,11 +613,7 @@ public:
void emitBanner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n");
- Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f, " * Version %s\n", Swig_package_version());
- Printf(f, " *\n");
- Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n");
- Printf(f, " * the SWIG interface file instead.\n");
+ Swig_banner_target_lang(f, " *");
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
}
@@ -1155,7 +1163,7 @@ public:
} else {
// Global enums are defined in their own file
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname);
- File *f_enum = NewFile(filen, "w");
+ File *f_enum = NewFile(filen, "w", SWIG_output_files());
if (!f_enum) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1219,7 +1227,7 @@ public:
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymous) C/C++ enum with a proper C# enum
// Emit the enum item.
- if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
+ if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
Printf(enum_code, " %s", symname);
@@ -1489,6 +1497,7 @@ public:
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
+ bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
Delete(attributes);
// C++ inheritance
@@ -1521,17 +1530,22 @@ public:
}
}
- const String *wanted_base = baseclass ? baseclass : pure_baseclass;
bool derived = baseclass && getProxyName(c_baseclassname);
+ if (derived && purebase_notderived)
+ pure_baseclass = empty_string;
+ const String *wanted_base = baseclass ? baseclass : pure_baseclass;
if (purebase_replace) {
wanted_base = pure_baseclass;
derived = false;
Delete(baseclass);
baseclass = NULL;
+ if (purebase_notderived)
+ Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. Perhaps you need the replace attribute in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
+ "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure C# interfaces
@@ -1734,7 +1748,7 @@ public:
}
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), proxy_class_name);
- f_proxy = NewFile(filen, "w");
+ f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1887,6 +1901,7 @@ public:
bool setter_flag = false;
String *pre_code = NewString("");
String *post_code = NewString("");
+ String *terminator_code = NewString("");
if (!proxy_flag)
return;
@@ -2035,6 +2050,14 @@ public:
Printf(post_code, "\n");
Printv(post_code, post, NIL);
}
+ String *terminator = Getattr(p, "tmap:csin:terminator");
+ if (terminator) {
+ substituteClassname(pt, terminator);
+ Replaceall(terminator, "$csinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
Printv(imcall, tm, NIL);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
@@ -2060,7 +2083,8 @@ public:
excodeSubstitute(n, tm, "csout", n);
bool is_pre_code = Len(pre_code) > 0;
bool is_post_code = Len(post_code) > 0;
- if (is_pre_code || is_post_code) {
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
if (is_post_code) {
Insert(tm, 0, "\n try ");
@@ -2072,6 +2096,9 @@ public:
Insert(tm, 0, pre_code);
Insert(tm, 0, "\n");
}
+ if (is_terminator_code) {
+ Printv(tm, "\n", terminator_code, NIL);
+ }
Insert(tm, 0, "{");
Printf(tm, "\n }");
}
@@ -2171,6 +2198,7 @@ public:
Delete(pre_code);
Delete(post_code);
+ Delete(terminator_code);
Delete(function_code);
Delete(return_type);
Delete(imcall);
@@ -2191,6 +2219,7 @@ public:
String *helper_args = NewString("");
String *pre_code = NewString("");
String *post_code = NewString("");
+ String *terminator_code = NewString("");
String *im_return_type = NewString("");
bool feature_director = (parentNode(n) && Swig_directorclass(n));
@@ -2286,6 +2315,14 @@ public:
Printf(post_code, "\n");
Printv(post_code, post, NIL);
}
+ String *terminator = Getattr(p, "tmap:csin:terminator");
+ if (terminator) {
+ substituteClassname(pt, terminator);
+ Replaceall(terminator, "$csinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
cshin = Getattr(p, "tmap:csin:cshin");
if (cshin)
Replaceall(cshin, "$csinput", arg);
@@ -2342,7 +2379,8 @@ public:
bool is_pre_code = Len(pre_code) > 0;
bool is_post_code = Len(post_code) > 0;
- if (is_pre_code || is_post_code) {
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
Printf(helper_code, " {\n");
if (is_pre_code) {
Printv(helper_code, pre_code, "\n", NIL);
@@ -2354,6 +2392,9 @@ public:
} else {
Printv(helper_code, " return ", imcall, ";", NIL);
}
+ if (is_terminator_code) {
+ Printv(helper_code, "\n", terminator_code, NIL);
+ }
Printf(helper_code, "\n }\n");
String *helper_name = NewStringf("%s.SwigConstruct%s(%s)", proxy_class_name, proxy_class_name, helper_args);
String *im_outattributes = Getattr(n, "tmap:imtype:outattributes");
@@ -2372,6 +2413,7 @@ public:
Delete(im_return_type);
Delete(pre_code);
Delete(post_code);
+ Delete(terminator_code);
Delete(construct_tm);
Delete(attributes);
Delete(overloaded_name);
@@ -2489,6 +2531,7 @@ public:
bool setter_flag = false;
String *pre_code = NewString("");
String *post_code = NewString("");
+ String *terminator_code = NewString("");
if (l) {
if (SwigType_type(Getattr(l, "type")) == T_VOID) {
@@ -2593,6 +2636,14 @@ public:
Printf(post_code, "\n");
Printv(post_code, post, NIL);
}
+ String *terminator = Getattr(p, "tmap:csin:terminator");
+ if (terminator) {
+ substituteClassname(pt, terminator);
+ Replaceall(terminator, "$csinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
Printv(imcall, tm, NIL);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSIN_UNDEF, input_file, line_number, "No csin typemap defined for %s\n", SwigType_str(pt, 0));
@@ -2617,7 +2668,8 @@ public:
excodeSubstitute(n, tm, "csout", n);
bool is_pre_code = Len(pre_code) > 0;
bool is_post_code = Len(post_code) > 0;
- if (is_pre_code || is_post_code) {
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
Replaceall(tm, "\n ", "\n "); // add extra indentation to code in typemap
if (is_post_code) {
Insert(tm, 0, "\n try ");
@@ -2629,6 +2681,9 @@ public:
Insert(tm, 0, pre_code);
Insert(tm, 0, "\n");
}
+ if (is_terminator_code) {
+ Printv(tm, "\n", terminator_code, NIL);
+ }
Insert(tm, 0, "{");
Printf(tm, "\n }");
}
@@ -2704,6 +2759,7 @@ public:
Delete(pre_code);
Delete(post_code);
+ Delete(terminator_code);
Delete(function_code);
Delete(return_type);
Delete(imcall);
@@ -2918,7 +2974,7 @@ public:
void emitTypeWrapperClass(String *classname, SwigType *type) {
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
- File *f_swigtype = NewFile(filen, "w");
+ File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
diff --git a/Source/Modules/directors.cxx b/Source/Modules/directors.cxx
index 4363cd813..158b53502 100644
--- a/Source/Modules/directors.cxx
+++ b/Source/Modules/directors.cxx
@@ -84,7 +84,7 @@ String *Swig_director_declaration(Node *n) {
}
-String *Swig_method_call(String_or_char *name, ParmList *parms) {
+String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
String *func;
int i = 0;
int comma = 0;
@@ -128,7 +128,7 @@ String *Swig_method_call(String_or_char *name, ParmList *parms) {
*
*/
-String *Swig_method_decl(SwigType *returntype, SwigType *decl, const String_or_char *id, List *args, int strip, int values) {
+String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
String *result;
List *elements;
String *element = 0, *nextelement;
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index f5f080034..0c72de8d0 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -47,6 +47,7 @@ Guile Options (available with -guile)\n\
-exportprimitive - Add the (export ...) code from scmstub into the\n\
GOOPS file.\n";
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -174,7 +175,7 @@ public:
}
} else if (strcmp(argv[i], "-procdoc") == 0) {
if (argv[i + 1]) {
- procdoc = NewFile(argv[i + 1], (char *) "w");
+ procdoc = NewFile(argv[i + 1], "w", SWIG_output_files());
if (!procdoc) {
FileErrorDisplay(argv[i + 1]);
SWIG_exit(EXIT_FAILURE);
@@ -299,11 +300,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -311,6 +313,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -322,10 +325,10 @@ public:
goopscode = NewString("");
goopsexport = NewString("");
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
- Printf(f_runtime, "/* Implementation : GUILE */\n\n");
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGGUILE\n");
if (!use_scm_interface) {
if (SwigRuntime == 1)
@@ -358,6 +361,8 @@ public:
Printf(f_runtime, "\n}\n");
}
+ Printf(f_runtime, "\n");
+
Language::top(n);
/* Close module */
@@ -392,14 +397,16 @@ public:
Delete(goopstext);
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -499,15 +506,15 @@ public:
SWIG_output_directory(),
primitive_name);
Delete(primitive_name);
- File *scmstubfile = NewFile(fname, (char *) "w");
+ File *scmstubfile = NewFile(fname, "w", SWIG_output_files());
if (!scmstubfile) {
FileErrorDisplay(fname);
SWIG_exit(EXIT_FAILURE);
}
Delete(fname);
- Printf(scmstubfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n");
- Printf(scmstubfile, ";;; Automatically generated by SWIG; do not edit.\n\n");
+ Swig_banner_target_lang(scmstubfile, ";;;");
+ Printf(scmstubfile, "\n");
if (linkage == GUILE_LSTYLE_SIMPLE || linkage == GUILE_LSTYLE_PASSIVE)
Printf(scmstubfile, "(define-module (%s))\n\n", mod);
Delete(mod);
@@ -530,14 +537,14 @@ public:
String *fname = NewStringf("%s%s.scm", SWIG_output_directory(),
module_name);
- File *goopsfile = NewFile(fname, (char *) "w");
+ File *goopsfile = NewFile(fname, "w", SWIG_output_files());
if (!goopsfile) {
FileErrorDisplay(fname);
SWIG_exit(EXIT_FAILURE);
}
Delete(fname);
- Printf(goopsfile, ";;; -*- buffer-read-only: t -*- vi: set ro: */\n");
- Printf(goopsfile, ";;; Automatically generated by SWIG; do not edit.\n\n");
+ Swig_banner_target_lang(goopsfile, ";;;");
+ Printf(goopsfile, "\n");
Printf(goopsfile, "(define-module (%s))\n", mod);
Printf(goopsfile, "%s\n", goopstext);
Printf(goopsfile, "(use-modules (oop goops) (Swig common))\n");
@@ -1653,7 +1660,7 @@ public:
* If class_name = "" that means the mapping is for a function or
* variable not attached to any class.
* ------------------------------------------------------------ */
- String *goopsNameMapping(String *name, String_or_char *class_name) {
+ String *goopsNameMapping(String *name, const_String_or_char_ptr class_name) {
String *n = NewString("");
if (Strcmp(class_name, "") == 0) {
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index b92fccdfb..50ef506ed 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -24,6 +24,7 @@ class JAVA:public Language {
const String *protected_string;
Hash *swig_types_hash;
+ File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@@ -70,6 +71,7 @@ class JAVA:public Language {
String *imclass_cppcasts_code; //C++ casts up inheritance hierarchies intermediary class code
String *imclass_directors; // Intermediate class director code
String *destructor_call; //C++ destructor call if any
+ String *destructor_throws_clause; //C++ destructor throws clause if any
// Director method stuff:
List *dmethods_seq;
@@ -81,7 +83,7 @@ class JAVA:public Language {
enum EnumFeature { SimpleEnum, TypeunsafeEnum, TypesafeEnum, ProperEnum };
- static Parm *NewParmFromNode(SwigType *type, const String_or_char *name, Node *n) {
+ static Parm *NewParmFromNode(SwigType *type, const_String_or_char_ptr name, Node *n) {
Parm *p = NewParm(type, name);
Setfile(p, Getfile(n));
Setline(p, Getline(n));
@@ -98,6 +100,7 @@ public:
public_string(NewString("public")),
protected_string(NewString("protected")),
swig_types_hash(NULL),
+ f_begin(NULL),
f_runtime(NULL),
f_runtime_h(NULL),
f_header(NULL),
@@ -141,6 +144,7 @@ public:
imclass_cppcasts_code(NULL),
imclass_directors(NULL),
destructor_call(NULL),
+ destructor_throws_clause(NULL),
dmethods_seq(NULL),
dmethods_table(NULL),
n_dmethods(0),
@@ -293,8 +297,8 @@ public:
SWIG_exit(EXIT_FAILURE);
}
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
@@ -304,13 +308,14 @@ public:
Printf(stderr, "Unable to determine outfile_h\n");
SWIG_exit(EXIT_FAILURE);
}
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
}
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -318,6 +323,7 @@ public:
f_directors = NewString("");
/* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("runtime", f_runtime);
@@ -365,13 +371,16 @@ public:
jnipackage = NewString("");
package_path = NewString("");
- Swig_banner(f_runtime); // Print the SWIG banner message
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n#define SWIGJAVA\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_class_name);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_class_name);
@@ -383,6 +392,8 @@ public:
Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
}
+ Printf(f_runtime, "\n");
+
String *wrapper_name = NewString("");
if (Len(package)) {
@@ -420,7 +431,7 @@ public:
// Generate the intermediary class
{
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), imclass_name);
- File *f_im = NewFile(filen, "w");
+ File *f_im = NewFile(filen, "w", SWIG_output_files());
if (!f_im) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -471,7 +482,7 @@ public:
// Generate the Java module class
{
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), module_class_name);
- File *f_module = NewFile(filen, "w");
+ File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -523,7 +534,7 @@ public:
// Generate the Java constants interface
if (Len(module_class_constants_code) != 0) {
String *filen = NewStringf("%s%sConstants.java", SWIG_output_directory(), module_class_name);
- File *f_module = NewFile(filen, "w");
+ File *f_module = NewFile(filen, "w", SWIG_output_files());
if (!f_module) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -660,8 +671,10 @@ public:
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Dump(f_runtime, f_begin);
Delete(f_runtime);
+ Close(f_begin);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -671,11 +684,7 @@ public:
void emitBanner(File *f) {
Printf(f, "/* ----------------------------------------------------------------------------\n");
- Printf(f, " * This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f, " * Version %s\n", Swig_package_version());
- Printf(f, " *\n");
- Printf(f, " * Do not make changes to this file unless you know what you are doing--modify\n");
- Printf(f, " * the SWIG interface file instead.\n");
+ Swig_banner_target_lang(f, " *");
Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
}
@@ -1210,7 +1219,7 @@ public:
} else {
// Global enums are defined in their own file
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname);
- File *f_enum = NewFile(filen, "w");
+ File *f_enum = NewFile(filen, "w", SWIG_output_files());
if (!f_enum) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1274,7 +1283,7 @@ public:
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
// Emit the enum item.
- if (!Getattr(n, "_last")) // Only the first enum item has this attribute set
+ if (!GetFlag(n, "firstenumitem"))
Printf(enum_code, ",\n");
Printf(enum_code, " %s", symname);
if (Getattr(n, "enumvalue")) {
@@ -1558,6 +1567,7 @@ public:
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
+ bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false;
Delete(attributes);
// C++ inheritance
@@ -1591,6 +1601,8 @@ public:
}
bool derived = baseclass && getProxyName(c_baseclassname);
+ if (derived && purebase_notderived)
+ pure_baseclass = empty_string;
const String *wanted_base = baseclass ? baseclass : pure_baseclass;
if (purebase_replace) {
@@ -1598,9 +1610,12 @@ public:
derived = false;
Delete(baseclass);
baseclass = NULL;
+ if (purebase_notderived)
+ Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. Perhaps you need the replace attribute in the javabase typemap?\n", typemap_lookup_type, pure_baseclass);
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
+ "Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
// Pure Java interfaces
@@ -1654,7 +1669,7 @@ public:
else
Replaceall(destruct, "$jnicall", "throw new UnsupportedOperationException(\"C++ destructor does not have public access\")");
if (*Char(destruct))
- Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "() ", destruct, "\n", NIL);
+ Printv(proxy_class_def, "\n ", destruct_methodmodifiers, " void ", destruct_methodname, "()", destructor_throws_clause, " ", destruct, "\n", NIL);
}
/* Insert directordisconnect typemap, if this class has directors enabled */
@@ -1742,7 +1757,7 @@ public:
}
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), proxy_class_name);
- f_proxy = NewFile(filen, "w");
+ f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -1761,6 +1776,7 @@ public:
Clear(proxy_class_code);
destructor_call = NewString("");
+ destructor_throws_clause = NewString("");
proxy_class_constants_code = NewString("");
}
@@ -1819,6 +1835,8 @@ public:
proxy_class_name = NULL;
Delete(destructor_call);
destructor_call = NULL;
+ Delete(destructor_throws_clause);
+ destructor_throws_clause = NULL;
Delete(proxy_class_constants_code);
proxy_class_constants_code = NULL;
}
@@ -2336,6 +2354,7 @@ public:
if (proxy_flag) {
Printv(destructor_call, imclass_name, ".", Swig_name_destroy(symname), "(swigCPtr)", NIL);
+ generateThrowsClause(n, destructor_throws_clause);
}
return SWIG_OK;
}
@@ -2798,7 +2817,7 @@ public:
void emitTypeWrapperClass(String *classname, SwigType *type) {
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
- File *f_swigtype = NewFile(filen, "w");
+ File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -2870,7 +2889,7 @@ public:
String *throws_attribute = NewStringf("%s:throws", attribute);
String *throws = Getattr(parameter, throws_attribute);
- if (throws) {
+ if (throws && Len(throws) > 0) {
String *throws_list = Getattr(n, "java:throwslist");
if (!throws_list) {
throws_list = NewList();
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 6718903d0..38658ce9c 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -61,7 +61,7 @@ static String *AttributeFunctionGet = 0;
static String *AttributeFunctionSet = 0;
static Node *CurrentClass = 0;
int line_number = 0;
-char *input_file = 0;
+String *input_file = 0;
int SmartPointer = 0;
static Hash *classhash;
@@ -352,7 +352,7 @@ int Language::emit_one(Node *n) {
Extend = 1;
line_number = Getline(n);
- input_file = Char(Getfile(n));
+ input_file = Getfile(n);
/*
symtab = Getattr(n,"symtab");
@@ -830,9 +830,8 @@ int Language::cDeclaration(Node *n) {
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) {
return SWIG_NOWRAP;
}
-#if 0
-// I don't see why this is needed - WSF
- /* prevent wrapping the method twice due to overload */
+ // Prevent wrapping protected overloaded director methods more than once -
+ // This bit of code is only needed due to the cDeclaration call in classHandler()
String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname"));
if (Getattr(CurrentClass, wrapname)) {
Delete(wrapname);
@@ -840,7 +839,6 @@ int Language::cDeclaration(Node *n) {
}
SetFlag(CurrentClass, wrapname);
Delete(wrapname);
-#endif
}
}
@@ -1424,36 +1422,39 @@ int Language::membervariableHandler(Node *n) {
target = NewStringf("%s->%s", pname, name);
Delete(pname);
}
- tm = Swig_typemap_lookup("memberin", n, target, 0);
+ } else {
+ target = NewStringf("$extendgetcall"); // member variable access expanded later
}
+ tm = Swig_typemap_lookup("memberin", n, target, 0);
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
if (is_non_virtual_protected_access(n))
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
- Swig_MembersetToFunction(n, ClassType, flags);
+ String *call = 0;
+ Swig_MembersetToFunction(n, ClassType, flags, &call);
Setattr(n, "memberset", "1");
- if (!Extend) {
- /* Check for a member in typemap here */
- if (!tm) {
- if (SwigType_isarray(type)) {
- Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
- make_set_wrapper = 0;
- }
- } else {
- String *pname0 = Swig_cparm_name(0, 0);
- String *pname1 = Swig_cparm_name(0, 1);
- Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
- Replace(tm, "$target", target, DOH_REPLACE_ANY);
- Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
- Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
- Setattr(n, "wrap:action", tm);
- Delete(tm);
- Delete(pname0);
- Delete(pname1);
+ if (!tm) {
+ if (SwigType_isarray(type)) {
+ Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
+ make_set_wrapper = 0;
}
- Delete(target);
+ } else {
+ String *pname0 = Swig_cparm_name(0, 0);
+ String *pname1 = Swig_cparm_name(0, 1);
+ Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
+ Replace(tm, "$target", target, DOH_REPLACE_ANY);
+ Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
+ Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
+ Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY);
+ Setattr(n, "wrap:action", tm);
+ Delete(tm);
+ Delete(pname0);
+ Delete(pname1);
}
+ Delete(call);
+ Delete(target);
+
if (make_set_wrapper) {
Setattr(n, "sym:name", mrename_set);
functionWrapper(n);
@@ -2476,6 +2477,13 @@ int Language::classHandler(Node *n) {
Node *m = Copy(method);
Setattr(m, "director", "1");
Setattr(m, "parentNode", n);
+ /*
+ * There is a bug that needs fixing still...
+ * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base)
+ * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method
+ * See director_protected_overloaded.i - Possibly sym:overname needs correcting here.
+ Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms")));
+ */
cDeclaration(m);
Delete(m);
}
@@ -2955,14 +2963,9 @@ Node *Language::classLookup(SwigType *s) {
n = Getattr(classtypes, s);
if (!n) {
Symtab *stab = 0;
-// SwigType *lt = SwigType_ltype(s);
-// SwigType *ty1 = SwigType_typedef_resolve_all(lt);
SwigType *ty1 = SwigType_typedef_resolve_all(s);
SwigType *ty2 = SwigType_strip_qualifiers(ty1);
-// Printf(stdout, " stages... ty1: %s ty2: %s\n", ty1, ty2);
-// Delete(lt);
Delete(ty1);
-// lt = 0;
ty1 = 0;
String *base = SwigType_base(ty2);
@@ -2971,6 +2974,12 @@ Node *Language::classLookup(SwigType *s) {
Replaceall(base, "struct ", "");
Replaceall(base, "union ", "");
+ if (strncmp(Char(base), "::", 2) == 0) {
+ String *oldbase = base;
+ base = NewString(Char(base) + 2);
+ Delete(oldbase);
+ }
+
String *prefix = SwigType_prefix(ty2);
/* Do a symbol table search on the base type */
@@ -3044,6 +3053,12 @@ Node *Language::enumLookup(SwigType *s) {
Replaceall(base, "enum ", "");
String *prefix = SwigType_prefix(ty2);
+ if (strncmp(Char(base), "::", 2) == 0) {
+ String *oldbase = base;
+ base = NewString(Char(base) + 2);
+ Delete(oldbase);
+ }
+
/* Look for type in symbol table */
while (!n) {
Hash *nstab;
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index 6113da960..78cd7ce96 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -92,6 +92,7 @@ NEW LANGUAGE NOTE:END ************************************************/
class LUA:public Language {
private:
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@@ -132,6 +133,7 @@ public:
* --------------------------------------------------------------------- */
LUA() {
+ f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@@ -213,11 +215,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* Open the output file */
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -226,6 +229,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
@@ -249,11 +253,17 @@ public:
current=NO_CPP;
/* Standard stuff for the SWIG runtime section */
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGLUA\n");
+
// if (NoInclude) {
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
// }
+ Printf(f_runtime, "\n");
+
//String *init_name = NewStringf("%(title)s_Init", module);
//Printf(f_header, "#define SWIG_init %s\n", init_name);
//Printf(f_header, "#define SWIG_name \"%s\"\n", module);
@@ -288,13 +298,14 @@ public:
this basically combines several of the strings together
and then writes it all to a file
NEW LANGUAGE NOTE:END ************************************************/
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Dump(f_initbeforefunc, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
/* for the Lua code it needs to be properly excaped to be added into the C/C++ code */
EscapeCode(s_luacode);
- Printf(f_runtime, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
- Wrapper_pretty_print(f_init, f_runtime);
+ Printf(f_begin, "const char* SWIG_LUACODE=\n \"%s\";\n\n",s_luacode);
+ Wrapper_pretty_print(f_init, f_begin);
/* Close all of the files */
Delete(s_luacode);
Delete(s_cmd_tab);
@@ -304,8 +315,9 @@ public:
Delete(f_wrappers);
Delete(f_init);
Delete(f_initbeforefunc);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
/* Done */
return SWIG_OK;
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 901ee812e..c824db6f9 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -117,7 +117,8 @@ static const char *usage3 = (const char *) "\
-fastdispatch -fvirtual \n\
-o <outfile> - Set name of the output file to <outfile>\n\
-oh <headfile> - Set name of the output header file to <headfile>\n\
- -outdir <dir> - Set language specific files output directory <dir>\n\
+ -outcurrentdir - Set default output dir to current dir instead of input file's path\n\
+ -outdir <dir> - Set language specific files output directory to <dir>\n\
-small - Compile in virtual elimination & compact mode\n\
-swiglib - Report location of SWIG library and exit\n\
-templatereduce - Reduce all the typedefs in templates\n\
@@ -153,6 +154,7 @@ static char *cpp_extension = (char *) "cxx";
static char *depends_extension = (char *) "d";
static String *outdir = 0;
static String *xmlout = 0;
+static int outcurrentdir = 0;
static int help = 0;
static int checkout = 0;
static int cpp_only = 0;
@@ -180,14 +182,16 @@ static String *dependencies_target = 0;
static int external_runtime = 0;
static String *external_runtime_name = 0;
enum { STAGE1=1, STAGE2=2, STAGE3=4, STAGE4=8, STAGEOVERFLOW=16 };
+static List *all_output_files = 0;
// -----------------------------------------------------------------------------
-// check_suffix(char *name)
+// check_suffix()
//
// Checks the suffix of a file to see if we should emit extern declarations.
// -----------------------------------------------------------------------------
-static int check_suffix(const char *name) {
+static int check_suffix(String *filename) {
+ const char *name = Char(filename);
const char *c;
if (!name)
return 0;
@@ -281,7 +285,7 @@ static void set_outdir(const String *c_wrapper_file_dir) {
}
/* This function sets the name of the configuration file */
-void SWIG_config_file(const String_or_char *filename) {
+void SWIG_config_file(const_String_or_char_ptr filename) {
lang_config = NewString(filename);
}
@@ -300,6 +304,11 @@ void SWIG_config_cppext(const char *ext) {
cpp_extension = (char *) ext;
}
+List *SWIG_output_files() {
+ assert(all_output_files);
+ return all_output_files;
+}
+
void SWIG_setfeature(const char *cfeature, const char *cvalue) {
Hash *features_hash = Swig_cparse_features();
String *name = NewString("");
@@ -363,13 +372,14 @@ static void SWIG_dump_runtime() {
}
}
- runtime = NewFile(outfile, "w");
+ runtime = NewFile(outfile, "w", SWIG_output_files());
if (!runtime) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
Swig_banner(runtime);
+ Printf(runtime, "\n");
s = Swig_include_sys("swiglabels.swg");
if (!s) {
@@ -688,6 +698,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else {
Swig_arg_error();
}
+ } else if (strcmp(argv[i], "-outcurrentdir") == 0) {
+ Swig_mark_arg(i);
+ outcurrentdir = 1;
} else if (strcmp(argv[i], "-Wall") == 0) {
Swig_mark_arg(i);
Swig_warnall();
@@ -867,6 +880,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
libfiles = NewList();
+ all_output_files = NewList();
/* Check for SWIG_FEATURES environment variable */
@@ -924,12 +938,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
// If we made it this far, looks good. go for it....
- input_file = argv[argc - 1];
+ input_file = NewString(argv[argc - 1]);
+ Swig_filename_correct(input_file);
// If the user has requested to check out a file, handle that
if (checkout) {
DOH *s;
- char *outfile = input_file;
+ char *outfile = Char(input_file);
if (outfile_name)
outfile = outfile_name;
@@ -938,30 +953,26 @@ int SWIG_main(int argc, char *argv[], Language *l) {
s = Swig_include(input_file);
if (!s) {
- fprintf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
+ Printf(stderr, "Unable to locate '%s' in the SWIG library.\n", input_file);
} else {
- FILE *f = fopen(outfile, "r");
+ FILE *f = Swig_open(outfile);
if (f) {
fclose(f);
- fprintf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
+ Printf(stderr, "File '%s' already exists. Checkout aborted.\n", outfile);
} else {
- f = fopen(outfile, "w");
- if (!f) {
- fprintf(stderr, "Unable to create file '%s'\n", outfile);
- } else {
- if (Verbose)
- fprintf(stdout, "'%s' checked out from the SWIG library.\n", input_file);
- fputs(Char(s), f);
- fclose(f);
- }
+ File *f_outfile = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_outfile) {
+ FileErrorDisplay(outfile);
+ SWIG_exit(EXIT_FAILURE);
+ } else {
+ if (Verbose)
+ Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile);
+ Printv(f_outfile, s, NIL);
+ Close(f_outfile);
+ }
}
}
} else {
- // Check the suffix for a .c file. If so, we're going to
- // declare everything we see as "extern"
-
- ForceExtern = check_suffix(input_file);
-
// Run the preprocessor
if (Verbose)
printf("Preprocessing...\n");
@@ -971,17 +982,22 @@ int SWIG_main(int argc, char *argv[], Language *l) {
String *fs = NewString("");
FILE *df = Swig_open(input_file);
if (!df) {
- char *cfile = Char(input_file);
- if (cfile && cfile[0] == '-') {
- Printf(stderr, "Unable to find option or file '%s', ", input_file);
- Printf(stderr, "use 'swig -help' for more information.\n");
+ df = Swig_include_open(input_file);
+ if (!df) {
+ char *cfile = Char(input_file);
+ if (cfile && cfile[0] == '-') {
+ Printf(stderr, "Unable to find option or file '%s', ", input_file);
+ Printf(stderr, "use 'swig -help' for more information.\n");
+ } else {
+ Printf(stderr, "Unable to find file '%s'.\n", input_file);
+ }
+ SWIG_exit(EXIT_FAILURE);
} else {
- Printf(stderr, "Unable to find file '%s'.\n", input_file);
+ Swig_warning(WARN_DEPRECATED_INPUT_FILE, "SWIG", 1, "Use of the include path to find the input file is deprecated and will not work with ccache. Please include the path when specifying the input file.\n"); // so that behaviour is like c/c++ compilers
}
- SWIG_exit(EXIT_FAILURE);
}
- fclose(df);
if (!no_cpp) {
+ fclose(df);
Printf(fs, "%%include <swig.swg>\n");
if (allkw) {
Printf(fs, "%%include <allkw.swg>\n");
@@ -989,7 +1005,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (lang_config) {
Printf(fs, "\n%%include <%s>\n", lang_config);
}
- Printf(fs, "%%include \"%s\"\n", Swig_last_file());
+ Printf(fs, "%%include(maininput=\"%s\") \"%s\"\n", Swig_filename_escape(input_file), Swig_last_file());
for (i = 0; i < Len(libfiles); i++) {
Printf(fs, "\n%%include \"%s\"\n", Getitem(libfiles, i));
}
@@ -997,8 +1013,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
cpps = Preprocessor_parse(fs);
Delete(fs);
} else {
- df = Swig_open(input_file);
- cpps = NewFileFromFile(df);
+ cpps = Swig_read_file(df);
+ fclose(df);
}
if (Swig_error_count()) {
SWIG_exit(EXIT_FAILURE);
@@ -1008,47 +1024,55 @@ int SWIG_main(int argc, char *argv[], Language *l) {
SWIG_exit(EXIT_SUCCESS);
}
if (depend) {
- String *outfile;
- if (!outfile_name) {
- if (CPlusPlus || lang->cplus_runtime_mode()) {
- outfile = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension);
+ if (!no_cpp) {
+ String *outfile;
+
+ char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
+ if (!outfile_name) {
+ if (CPlusPlus || lang->cplus_runtime_mode()) {
+ outfile = NewStringf("%s_wrap.%s", basename, cpp_extension);
+ } else {
+ outfile = NewStringf("%s_wrap.c", basename);
+ }
} else {
- outfile = NewStringf("%s_wrap.c", Swig_file_basename(input_file));
+ outfile = NewString(outfile_name);
}
- } else {
- outfile = NewString(outfile_name);
- }
- if (dependencies_file && Len(dependencies_file) != 0) {
- f_dependencies_file = NewFile(dependencies_file, "w");
- if (!f_dependencies_file) {
- FileErrorDisplay(dependencies_file);
- SWIG_exit(EXIT_FAILURE);
+ if (dependencies_file && Len(dependencies_file) != 0) {
+ f_dependencies_file = NewFile(dependencies_file, "w", SWIG_output_files());
+ if (!f_dependencies_file) {
+ FileErrorDisplay(dependencies_file);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ } else if (!depend_only) {
+ String *filename = NewStringf("%s_wrap.%s", basename, depends_extension);
+ f_dependencies_file = NewFile(filename, "w", SWIG_output_files());
+ if (!f_dependencies_file) {
+ FileErrorDisplay(filename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ } else
+ f_dependencies_file = stdout;
+ if (dependencies_target) {
+ Printf(f_dependencies_file, "%s: ", dependencies_target);
+ } else {
+ Printf(f_dependencies_file, "%s: ", outfile);
}
- } else if (!depend_only) {
- String *filename = NewStringf("%s_wrap.%s", Swig_file_basename(input_file), depends_extension);
- f_dependencies_file = NewFile(filename, "w");
- if (!f_dependencies_file) {
- FileErrorDisplay(filename);
- SWIG_exit(EXIT_FAILURE);
+ List *files = Preprocessor_depend();
+ for (int i = 0; i < Len(files); i++) {
+ if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
+ Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
+ }
}
- } else
- f_dependencies_file = stdout;
- if (dependencies_target) {
- Printf(f_dependencies_file, "%s: ", dependencies_target);
+ Printf(f_dependencies_file, "\n");
+ if (f_dependencies_file != stdout)
+ Close(f_dependencies_file);
+ if (depend_only)
+ SWIG_exit(EXIT_SUCCESS);
} else {
- Printf(f_dependencies_file, "%s: ", outfile);
- }
- List *files = Preprocessor_depend();
- for (int i = 0; i < Len(files); i++) {
- if ((depend != 2) || ((depend == 2) && (Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) != 0))) {
- Printf(f_dependencies_file, "\\\n %s ", Getitem(files, i));
- }
+ Printf(stderr, "Cannot generate dependencies with -nopreprocess\n");
+ // Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse
+ SWIG_exit(EXIT_FAILURE);
}
- Printf(f_dependencies_file, "\n");
- if (f_dependencies_file != stdout)
- Close(f_dependencies_file);
- if (depend_only)
- SWIG_exit(EXIT_SUCCESS);
}
Seek(cpps, 0, SEEK_SET);
}
@@ -1126,22 +1150,30 @@ int SWIG_main(int argc, char *argv[], Language *l) {
}
if (top) {
if (!Getattr(top, "name")) {
- Printf(stderr, "*** No module name specified using %%module or -module.\n");
+ Printf(stderr, "No module name specified using %%module or -module.\n");
SWIG_exit(EXIT_FAILURE);
} else {
/* Set some filename information on the object */
- Setattr(top, "infile", input_file);
+ String *infile = scanner_get_main_input_file();
+ if (!infile) {
+ Printf(stderr, "Missing input file in preprocessed output.\n");
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file
+ Setattr(top, "inputfile", input_file);
+
+ char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile));
if (!outfile_name) {
if (CPlusPlus || lang->cplus_runtime_mode()) {
- Setattr(top, "outfile", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), cpp_extension));
+ Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension));
} else {
- Setattr(top, "outfile", NewStringf("%s_wrap.c", Swig_file_basename(input_file)));
+ Setattr(top, "outfile", NewStringf("%s_wrap.c", basename));
}
} else {
Setattr(top, "outfile", outfile_name);
}
if (!outfile_name_h) {
- Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", Swig_file_basename(input_file), hpp_extension));
+ Setattr(top, "outfile_h", NewStringf("%s_wrap.%s", basename, hpp_extension));
} else {
Setattr(top, "outfile_h", outfile_name_h);
}
@@ -1149,7 +1181,12 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (Swig_contract_mode_get()) {
Swig_contracts(top);
}
+
+ // Check the suffix for a c/c++ file. If so, we're going to declare everything we see as "extern"
+ ForceExtern = check_suffix(input_file);
+
lang->top(top);
+
if (browse) {
Swig_browser(top, 0);
}
@@ -1173,6 +1210,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
if (memory_debug)
DohMemoryDebug();
+ char *outfiles = getenv("CCACHE_OUTFILES");
+ if (outfiles) {
+ File *f_outfiles = NewFile(outfiles, "w", 0);
+ if (!f_outfiles) {
+ Printf(stderr, "Failed to write list of output files to the filename '%s' specified in CCACHE_OUTFILES environment variable - ", outfiles);
+ FileErrorDisplay(outfiles);
+ SWIG_exit(EXIT_FAILURE);
+ } else {
+ int i;
+ for (i = 0; i < Len(all_output_files); i++)
+ Printf(f_outfiles, "%s\n", Getitem(all_output_files, i));
+ Close(f_outfiles);
+ }
+ }
+
// Deletes
Delete(libfiles);
Preprocessor_delete();
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index 6cb24d39a..b3568c0bf 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -127,7 +127,7 @@ char cvsroot_modula3_cxx[] = "$Id$";
#include <limits.h> // for INT_MAX
#include <ctype.h>
-const char usageArgDir[] = "m3wrapargdir typemap expect values: in, out, inout\n";
+#define USAGE_ARG_DIR "m3wrapargdir typemap expect values: in, out, inout\n"
class MODULA3:public Language {
public:
@@ -172,6 +172,7 @@ private:
const String *empty_string;
Hash *swig_types_hash;
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@@ -237,6 +238,7 @@ public:
MODULA3():
empty_string(NewString("")),
swig_types_hash(NULL),
+ f_begin(NULL),
f_runtime(NULL),
f_header(NULL),
f_wrappers(NULL),
@@ -374,7 +376,7 @@ MODULA3():
} else if (Strcmp(dir, "out") == 0) {
return false;
} else {
- printf(usageArgDir);
+ printf("%s", USAGE_ARG_DIR);
return false;
}
}
@@ -386,7 +388,7 @@ MODULA3():
} else if ((Strcmp(dir, "out") == 0) || (Strcmp(dir, "inout") == 0)) {
return true;
} else {
- printf(usageArgDir);
+ printf("%s", USAGE_ARG_DIR);
return false;
}
}
@@ -542,7 +544,7 @@ MODULA3():
* ----------------------------------------------------------------------------- */
File *openWriteFile(String *name) {
- File *file = NewFile(name, "w");
+ File *file = NewFile(name, "w", SWIG_output_files());
if (!file) {
FileErrorDisplay(name);
SWIG_exit(EXIT_FAILURE);
@@ -902,11 +904,12 @@ MODULA3():
/* Initialize all of the output files */
outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -916,6 +919,7 @@ MODULA3():
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -956,7 +960,11 @@ MODULA3():
module_imports = NewString("");
upcasts_code = NewString("");
- Swig_banner(f_runtime); // Print the SWIG banner message
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGMODULA3\n");
+ Printf(f_runtime, "\n");
Swig_name_register((char *) "wrapper", (char *) "Modula3_%f");
if (old_variable_names) {
@@ -1143,14 +1151,16 @@ MODULA3():
typemapfilename = NULL;
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1159,14 +1169,9 @@ MODULA3():
* ----------------------------------------------------------------------------- */
void emitBanner(File *f) {
- Printf(f, "\
-(*******************************************************************************\n\
- * This file was automatically generated by SWIG (http://www.swig.org/).\n\
- * Version %s\n\
- *\n\
- * Do not make changes to this file unless you know what you are doing --\n\
- * modify the SWIG interface file instead.\n\
- *******************************************************************************)\n\n", Swig_package_version());
+ Printf(f, "(*******************************************************************************\n");
+ Swig_banner_target_lang(f, " *");
+ Printf(f, "*******************************************************************************)\n\n");
}
/* ----------------------------------------------------------------------
@@ -2382,7 +2387,7 @@ MODULA3():
}
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name);
- f_proxy = NewFile(filen, "w");
+ f_proxy = NewFile(filen, "w", SWIG_output_files());
if (!f_proxy) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -3174,8 +3179,7 @@ MODULA3():
Clear(result_m3wraptype);
Printv(result_m3wraptype, tm, NIL);
} else {
- Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN,
- input_file, line_number,
+ Swig_warning(WARN_MODULA3_TYPEMAP_MULTIPLE_RETURN, input_file, line_number,
"Typemap m3wrapargdir set to 'out' for %s implies a RETURN value, but the routine %s has already one.\nUse %%multiretval feature.\n",
SwigType_str(Getattr(p, "type"), 0), raw_name);
}
@@ -3762,7 +3766,7 @@ MODULA3():
void emitTypeWrapperClass(String *classname, SwigType *type) {
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
- File *f_swigtype = NewFile(filen, "w");
+ File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
index 78d4a4b65..28dd8ecd2 100644
--- a/Source/Modules/mzscheme.cxx
+++ b/Source/Modules/mzscheme.cxx
@@ -39,6 +39,7 @@ static String *module = 0;
static char *mzscheme_path = (char *) "mzscheme";
static String *init_func_def = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -129,11 +130,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -141,13 +143,17 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
init_func_def = NewString("");
Swig_register_filebyname("init", init_func_def);
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGMZSCHEME\n");
+ Printf(f_runtime, "\n");
module = Getattr(n, "name");
@@ -186,14 +192,16 @@ public:
}
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 0d0f4c7f2..8a797759c 100755..100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -38,6 +38,7 @@ static Hash *seen_enumvalues = 0;
static Hash *seen_constructors = 0;
static File *f_header = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_wrappers = 0;
static File *f_directors = 0;
@@ -214,11 +215,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -247,6 +249,7 @@ public:
Swig_register_filebyname("init", init_func_def);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("mli", f_mlibody);
Swig_register_filebyname("ml", f_mlbody);
@@ -262,7 +265,10 @@ public:
Swig_name_register("get", "%v__get__");
}
- Printf(f_runtime, "/* -*- buffer-read-only: t -*- vi: set ro: */\n");
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGOCAML\n");
Printf(f_runtime, "#define SWIG_MODULE \"%s\"\n", module);
/* Module name */
Printf(f_mlbody, "let module_name = \"%s\"\n", module);
@@ -276,12 +282,12 @@ public:
Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n");
- Swig_banner(f_runtime);
-
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
+ Printf(f_runtime, "\n");
+
/* Produce the enum_to_int and int_to_enum functions */
Printf(f_enumtypes_type, "open Swig\n" "type c_enum_type = [ \n `unknown\n");
@@ -293,12 +299,12 @@ public:
Printv(mlifile, module, ".mli", NIL);
String *mlfilen = NewStringf("%s%s", SWIG_output_directory(), mlfile);
- if ((f_mlout = NewFile(mlfilen, "w")) == 0) {
+ if ((f_mlout = NewFile(mlfilen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(mlfilen);
SWIG_exit(EXIT_FAILURE);
}
String *mlifilen = NewStringf("%s%s", SWIG_output_directory(), mlifile);
- if ((f_mliout = NewFile(mlifilen, "w")) == 0) {
+ if ((f_mliout = NewFile(mlifilen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(mlifilen);
SWIG_exit(EXIT_FAILURE);
}
@@ -322,16 +328,18 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
+ Dump(f_runtime, f_begin);
Dump(f_directors_h, f_header);
- Dump(f_header, f_runtime);
+ Dump(f_header, f_begin);
Dump(f_directors, f_wrappers);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
Dump(f_enumtypes_type, f_mlout);
Dump(f_enumtypes_value, f_mlout);
@@ -1619,11 +1627,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "c_result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("c_result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
Replaceall(tm, "$input", "swig_result");
/* TODO check this */
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index d582e8a6c..55ffe8cbb 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -18,6 +18,7 @@ Octave Options (available with -octave)\n\
class OCTAVE:public Language {
private:
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_doc;
@@ -37,9 +38,16 @@ private:
Hash *docs;
public:
- OCTAVE():f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
+ OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0),
s_global_tab(0), s_members_tab(0), class_name(0) {
+ /* Add code to manage protected constructors and directors */
+ director_prot_ctor_code = NewString("");
+ Printv(director_prot_ctor_code,
+ "if ( $comparison ) { /* subclassed */\n",
+ " $director_new \n",
+ "} else {\n", " error(\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
+
enable_cplus_runtime_mode();
allow_overloading();
director_multiple_inheritance = 1;
@@ -87,11 +95,12 @@ public:
String *module = Getattr(n, "name");
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_header = NewString("");
f_doc = NewString("");
f_wrappers = NewString("");
@@ -100,6 +109,7 @@ public:
f_directors_h = NewString("");
f_directors = NewString("");
s_global_tab = NewString("");
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("doc", f_doc);
@@ -108,11 +118,16 @@ public:
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
Swig_register_filebyname("director", f_directors);
Swig_register_filebyname("director_h", f_directors_h);
- Swig_banner(f_runtime);
+
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGOCTAVE\n");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
if (directorsEnabled()) {
+ Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h);
if (dirprot_mode()) {
// Printf(f_directors_h, "#include <map>\n");
@@ -120,6 +135,7 @@ public:
}
}
+ Printf(f_runtime, "\n");
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n");
@@ -143,15 +159,16 @@ public:
Printv(f_wrappers, s_global_tab, NIL);
SwigType_emit_type_table(f_runtime, f_wrappers);
- Dump(f_header, f_runtime);
- Dump(f_doc, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_doc, f_begin);
if (directorsEnabled()) {
- Dump(f_directors_h, f_runtime);
- Dump(f_directors, f_runtime);
+ Dump(f_directors_h, f_begin);
+ Dump(f_directors, f_begin);
}
- Dump(f_wrappers, f_runtime);
- Dump(f_initbeforefunc, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(s_global_tab);
Delete(f_initbeforefunc);
@@ -161,8 +178,9 @@ public:
Delete(f_header);
Delete(f_directors);
Delete(f_directors_h);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1287,11 +1305,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
char temp[24];
sprintf(temp, "out(%d)", idx);
diff --git a/Source/Modules/overload.cxx b/Source/Modules/overload.cxx
index d16913885..511e55004 100644
--- a/Source/Modules/overload.cxx
+++ b/Source/Modules/overload.cxx
@@ -316,7 +316,7 @@ static bool print_typecheck(String *f, int j, Parm *pj) {
* ReplaceFormat()
* ----------------------------------------------------------------------------- */
-static String *ReplaceFormat(const String_or_char *fmt, int j) {
+static String *ReplaceFormat(const_String_or_char_ptr fmt, int j) {
String *lfmt = NewString(fmt);
char buf[50];
sprintf(buf, "%d", j);
@@ -352,7 +352,7 @@ static String *ReplaceFormat(const String_or_char *fmt, int j) {
/*
Cast dispatch mechanism.
*/
-String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *maxargs) {
+String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
int i, j;
*maxargs = 1;
@@ -536,7 +536,7 @@ String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *max
/*
Fast dispatch mechanism, provided by Salvador Fandi~no Garc'ia (#930586).
*/
-String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *maxargs) {
+String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
int i, j;
*maxargs = 1;
@@ -695,7 +695,7 @@ String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *max
return f;
}
-String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
+String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxargs) {
if (fast_dispatch_mode || GetFlag(n, "feature:fastdispatch")) {
return Swig_overload_dispatch_fast(n, fmt, maxargs);
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index 2e714efe5..eace179a7 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -78,6 +78,7 @@ static String *command_tab = 0;
static String *constant_tab = 0;
static String *variable_tab = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
@@ -100,6 +101,8 @@ static int have_constructor = 0;
static int have_destructor = 0;
static int have_data_members = 0;
static String *class_name = 0; /* Name of the class (what Perl thinks it is) */
+static String *real_classname = 0; /* Real name of C/C++ class */
+static String *fullclassname = 0;
static String *pcode = 0; /* Perl code associated with each class */
/* static String *blessedmembers = 0; *//* Member data associated with each class */
@@ -205,6 +208,7 @@ public:
}
Preprocessor_define("SWIGPERL 1", 0);
+ // SWIGPERL5 is deprecated, and no longer documented.
Preprocessor_define("SWIGPERL5 1", 0);
SWIG_typemap_lang("perl5");
SWIG_config_file("perl5.swg");
@@ -220,11 +224,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -232,6 +237,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -250,11 +256,12 @@ public:
constant_tab = NewString("static swig_constant_info swig_constants[] = {\n");
variable_tab = NewString("static swig_variable_info swig_variables[] = {\n");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+ Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPERL\n");
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
-
+ Printf(f_runtime, "\n");
// Is the imported module in another package? (IOW, does it use the
// %module(package="name") option and it's different than the package
@@ -313,7 +320,7 @@ public:
pmfile = NewStringf("%s.pm", m);
}
String *filen = NewStringf("%s%s", SWIG_output_directory(), pmfile);
- if ((f_pm = NewFile(filen, "w")) == 0) {
+ if ((f_pm = NewFile(filen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
@@ -330,10 +337,7 @@ public:
Delete(boot_name);
}
- Printf(f_pm, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f_pm, "# Version %s\n", Swig_package_version());
- Printf(f_pm, "#\n");
- Printf(f_pm, "# Don't modify this file, modify the SWIG interface instead.\n");
+ Swig_banner_target_lang(f_pm, "#");
Printf(f_pm, "\n");
Printf(f_pm, "package %s;\n", module);
@@ -522,14 +526,16 @@ public:
Delete(underscore_module);
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -556,7 +562,6 @@ public:
String *iname = Getattr(n, "sym:name");
SwigType *d = Getattr(n, "type");
ParmList *l = Getattr(n, "parms");
- ParmList *outer = Getattr(n, "perl5:implicits");
String *overname = 0;
Parm *p;
@@ -566,7 +571,7 @@ public:
String *tm;
String *cleanup, *outarg;
int num_saved = 0;
- int num_arguments, num_required, num_implicits;
+ int num_arguments, num_required;
int varargs = 0;
if (Getattr(n, "sym:overloaded")) {
@@ -588,19 +593,6 @@ public:
Printv(f->def, "XS(", wname, ") {\n", "{\n", /* scope to destroy C++ objects before croaking */
NIL);
- num_implicits = 0;
- if (outer) {
- Parm *tmp = outer;
- Parm *tail;
- while(tmp) {
- tail = tmp;
- num_implicits++;
- tmp = nextSibling(tmp);
- }
- /* link the outer with inner parms */
- set_nextSibling(tail, l);
- }
-
emit_parameter_variables(l, f);
emit_attach_parmmaps(l, f);
Setattr(n, "wrap:parms", l);
@@ -613,29 +605,13 @@ public:
/* Check the number of arguments */
if (!varargs) {
- Printf(f->code, " if ((items < %d) || (items > %d)) {\n",
- num_required + num_implicits, num_arguments + num_implicits);
+ Printf(f->code, " if ((items < %d) || (items > %d)) {\n", num_required, num_arguments);
} else {
- Printf(f->code, " if (items < %d) {\n",
- num_required + num_implicits);
+ Printf(f->code, " if (items < %d) {\n", num_required);
}
- Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, outer, l));
+ Printf(f->code, " SWIG_croak(\"Usage: %s\");\n", usage_func(Char(iname), d, l));
Printf(f->code, "}\n");
- if (num_implicits) {
- /* TODO: support implicits of types other than SVs */
- Parm *p = outer;
- for(i = 0; i < num_implicits; i++) {
- String *pname = Getattr(p, "name");
- String *pinit = SwigType_str(Getattr(p, "type"), pname);
- Wrapper_add_local(f, pname, pinit);
- Delete(pinit);
- Printf(f->code, "%s = ST(%d);\n", pname, i++);
- p = nextSibling(p);
- }
- if (l)
- Printf(f->code, "ax += %d;\n", num_implicits);
- }
/* Write code to extract parameters. */
i = 0;
for (i = 0, p = l; i < num_arguments; i++) {
@@ -748,9 +724,6 @@ public:
Wrapper_add_localv(f, "_saved", "SV *", temp, NIL);
}
- if (num_implicits && l)
- Printf(f->code, "ax -= %d;\n", num_implicits);
-
/* Now write code to make the function call */
Swig_director_emit_dynamic_cast(n, f);
@@ -797,11 +770,6 @@ public:
Printf(f->code, "%s\n", tm);
}
- if (blessed && Equal(nodeType(n), "constructor")) {
- Append(f->code,
- "if (SvOK(ST(0))) sv_bless(ST(0), gv_stashsv(proto, 0));\n");
- }
-
Printv(f->code, "XSRETURN(argvi);\n", "fail:\n", cleanup, "SWIG_croak_null();\n" "}\n" "}\n", NIL);
/* Add the dXSARGS last */
@@ -833,10 +801,6 @@ public:
Printv(df->def, "XS(", dname, ") {\n", NIL);
Wrapper_add_local(df, "dXSARGS", "dXSARGS");
- if (num_implicits) {
- Printf(df->code, "ax += %d;\n", num_implicits);
- Printf(df->code, "items -= %d;\n", num_implicits);
- }
Printv(df->code, dispatch, "\n", NIL);
Printf(df->code, "croak(\"No matching function for overloaded '%s'\");\n", iname);
Printf(df->code, "XSRETURN(0);\n");
@@ -1073,7 +1037,7 @@ public:
/* ------------------------------------------------------------
* usage_func()
* ------------------------------------------------------------ */
- char *usage_func(char *iname, SwigType *, ParmList *il, ParmList *l) {
+ char *usage_func(char *iname, SwigType *, ParmList *l) {
static String *temp = 0;
Parm *p;
int i;
@@ -1083,17 +1047,13 @@ public:
Clear(temp);
Printf(temp, "%s(", iname);
- i = 0;
- /* Print implicit parameters */
- for(p = il; p; p = nextSibling(p))
- Printv(temp, (i > 0 ? "," : ""), Getattr(p, "name"), NIL);
- /* Now go through and print normal parameters */
+ /* Now go through and print parameters */
p = l;
+ i = 0;
while (p != 0) {
SwigType *pt = Getattr(p, "type");
String *pn = Getattr(p, "name");
if (!checkAttribute(p,"tmap:in:numinputs","0")) {
- if (i > 0) Append(temp, ",");
/* If parameter has been named, use that. Otherwise, just print a type */
if (SwigType_type(pt) != T_VOID) {
if (Len(pn) > 0) {
@@ -1103,8 +1063,16 @@ public:
}
}
i++;
+ p = nextSibling(p);
+ if (p)
+ if (!checkAttribute(p,"tmap:in:numinputs","0"))
+ Putc(',', temp);
+ } else {
+ p = nextSibling(p);
+ if (p)
+ if ((i > 0) && (!checkAttribute(p,"tmap:in:numinputs","0")))
+ Putc(',', temp);
}
- p = nextSibling(p);
}
Printf(temp, ");");
return Char(temp);
@@ -1177,8 +1145,9 @@ public:
/* Do some work on the class name */
if (verbose > 0) {
+ String *modulename = Getattr(clsmodule, "name");
fprintf(stdout, "setclassname: Found sym:name: %s\n", Char(symname));
- fprintf(stdout, "setclassname: Found module: %s\n", Char(clsmodule));
+ fprintf(stdout, "setclassname: Found module: %s\n", Char(modulename));
fprintf(stdout, "setclassname: No package found\n");
}
@@ -1222,8 +1191,6 @@ public:
* ------------------------------------------------------------ */
virtual int classHandler(Node *n) {
- String *name = 0; /* Real name of C/C++ class */
- String *fullclassname = 0;
if (blessed) {
have_constructor = 0;
@@ -1243,7 +1210,7 @@ public:
} else {
fullclassname = NewString(class_name);
}
- name = Getattr(n, "name");
+ real_classname = Getattr(n, "name");
pcode = NewString("");
// blessedmembers = NewString("");
}
@@ -1255,7 +1222,7 @@ public:
/* Finish the rest of the class */
if (blessed) {
/* Generate a client-data entry */
- SwigType *ct = NewStringf("p.%s", name);
+ SwigType *ct = NewStringf("p.%s", real_classname);
Printv(f_init, "SWIG_TypeClientData(SWIGTYPE", SwigType_manglestr(ct), ", (void*) \"", fullclassname, "\");\n", NIL);
SwigType_remember(ct);
Delete(ct);
@@ -1528,15 +1495,6 @@ public:
String *symname = Getattr(n, "sym:name");
- {
- String *type = NewString("SV");
- SwigType_add_pointer(type);
- Parm *p = NewParm(type, "proto");
- Delete(type);
- Setattr(n, "perl5:implicits", p);
- Delete(p);
- }
-
member_func = 1;
Language::constructorHandler(n);
@@ -1548,16 +1506,17 @@ public:
Delete(plaction);
Printv(pcode, plcode, NIL);
} else {
- /* Emit a blessed constructor */
- String *cname = Swig_name_construct(symname);
- char *pname;
- /* override Class->Class to be Class->new */
- if (Cmp(symname, class_name) == 0)
- pname = "new";
- else
- pname = Char(cname);
- Printf(pcode, "*%s = *%s::%s;\n", pname, cmodule, cname);
- Delete(cname);
+ if ((Cmp(symname, class_name) == 0)) {
+ /* Emit a blessed constructor */
+ Printf(pcode, "sub new {\n");
+ } else {
+ /* Constructor doesn't match classname so we'll just use the normal name */
+ Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
+ }
+
+ Printv(pcode,
+ tab4, "my $pkg = shift;\n",
+ tab4, "my $self = ", cmodule, "::", Swig_name_construct(symname), "(@_);\n", tab4, "bless $self, $pkg if defined($self);\n", "}\n\n", NIL);
have_constructor = 1;
}
@@ -1670,7 +1629,7 @@ public:
} else if (Strcmp(code, "include") == 0) {
/* Include a file into the .pm file */
if (value) {
- FILE *f = Swig_open(value);
+ FILE *f = Swig_include_open(value);
if (!f) {
Printf(stderr, "%s : Line %d. Unable to locate file %s\n", input_file, line_number, value);
} else {
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 9369c2489..ee69c1864 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -2,9 +2,9 @@
* See the LICENSE file for information on copyright, usage and redistribution
* of SWIG, and the README file for authors - http://www.swig.org/release.html.
*
- * php4.cxx
+ * php.cxx
*
- * Php language module for SWIG.
+ * PHP language module for SWIG.
* -----------------------------------------------------------------------------
*/
@@ -40,7 +40,7 @@
* (may need to add more WARN_PHP_xxx codes...)
*/
-char cvsroot_php4_cxx[] = "$Id$";
+char cvsroot_php_cxx[] = "$Id$";
#include "swigmod.h"
@@ -48,13 +48,13 @@ char cvsroot_php4_cxx[] = "$Id$";
#include <errno.h>
static const char *usage = (char *) "\
-PHP Options (available with -php5)\n\
+PHP Options (available with -php)\n\
-cppext - cpp file extension (default to .cpp)\n\
-noproxy - Don't generate proxy classes.\n\
- -prefix <prefix> - Prepend <prefix> to all class names in PHP5 wrappers\n\
+ -prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
\n";
-/* The original class wrappers for PHP4 store the pointer to the C++ class in
+/* The original class wrappers for PHP stored the pointer to the C++ class in
* the object property _cPtr. If we use the same name for the member variable
* which we put the pointer to the C++ class in, then the flat function
* wrappers will automatically pull it out without any changes being required.
@@ -71,6 +71,7 @@ static String *prefix = 0;
static String *shadow_classname = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_h = 0;
static File *f_phpcode = 0;
@@ -141,7 +142,7 @@ void SwigPHP_emit_resource_registrations() {
Printf(s_wrappers, "/* NEW Destructor style */\nstatic ZEND_RSRC_DTOR_FUNC(_wrap_destroy%s) {\n", key);
// write out body
- if ((class_node != NOTCLASS)) {
+ if (class_node != NOTCLASS) {
String *destructor = Getattr(class_node, "destructor");
human_name = Getattr(class_node, "sym:name");
if (!human_name)
@@ -172,12 +173,9 @@ void SwigPHP_emit_resource_registrations() {
}
}
-class PHP:public Language {
- int php_version;
-
+class PHP : public Language {
public:
- PHP(int php_version_):php_version(php_version_) {
- }
+ PHP() { }
/* Test to see if a type corresponds to something wrapped with a shadow class. */
@@ -242,8 +240,9 @@ public:
}
Preprocessor_define("SWIGPHP 1", 0);
+ // SWIGPHP5 is deprecated, and no longer documented.
Preprocessor_define("SWIGPHP5 1", 0);
- SWIG_typemap_lang("php4");
+ SWIG_typemap_lang("php");
SWIG_config_file("php.swg");
allow_overloading();
}
@@ -261,13 +260,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* main output file */
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
-
- Swig_banner(f_runtime);
+ f_runtime = NewString("");
/* sections of the output file */
s_init = NewString("/* init section */\n");
@@ -286,6 +284,7 @@ public:
s_phpclasses = NewString("/* PHP Proxy Classes */\n");
/* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", s_init);
Swig_register_filebyname("rinit", r_init);
@@ -294,6 +293,12 @@ public:
Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", s_wrappers);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGPHP\n");
+ Printf(f_runtime, "\n");
+
/* Set the module name */
module = Copy(Getattr(n, "name"));
cap_module = NewStringf("%(upper)s", module);
@@ -305,7 +310,7 @@ public:
Printv(filen, SWIG_output_directory(), module, ".php", NIL);
phpfilename = NewString(filen);
- f_phpcode = NewFile(filen, "w");
+ f_phpcode = NewFile(filen, "w", SWIG_output_files());
if (!f_phpcode) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -315,6 +320,7 @@ public:
Swig_banner(f_phpcode);
+ Printf(f_phpcode, "\n");
Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n");
Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module);
Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n");
@@ -384,7 +390,7 @@ public:
/* Create the .h file too */
filen = NewStringEmpty();
Printv(filen, SWIG_output_directory(), "php_", module, ".h", NIL);
- f_h = NewFile(filen, "w");
+ f_h = NewFile(filen, "w", SWIG_output_files());
if (!f_h) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
@@ -392,7 +398,7 @@ public:
Swig_banner(f_h);
- Printf(f_h, "\n\n");
+ Printf(f_h, "\n");
Printf(f_h, "#ifndef PHP_%s_H\n", cap_module);
Printf(f_h, "#define PHP_%s_H\n\n", cap_module);
Printf(f_h, "extern zend_module_entry %s_module_entry;\n", module);
@@ -521,16 +527,19 @@ public:
Printf(s_wrappers, "/* end wrapper section */\n");
Printf(s_vdecl, "/* end vdecl subsection */\n");
- Printv(f_runtime, s_header, s_vdecl, s_wrappers, NIL);
- Printv(f_runtime, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL);
- Printv(f_runtime, s_init, NIL);
+ Dump(f_runtime, f_begin);
+ Printv(f_begin, s_header, s_vdecl, s_wrappers, NIL);
+ Printv(f_begin, all_cs_entry, "\n\n", s_entry, "{NULL, NULL, NULL}\n};\n\n", NIL);
+ Printv(f_begin, s_init, NIL);
Delete(s_header);
Delete(s_wrappers);
Delete(s_init);
Delete(s_vdecl);
Delete(all_cs_entry);
Delete(s_entry);
- Close(f_runtime);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
Printf(f_phpcode, "%s\n%s\n", pragma_incl, pragma_code);
if (s_fakeoowrappers) {
@@ -589,7 +598,7 @@ public:
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
- Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());\n", NIL);
+ Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n", NIL);
Printv(f->code, "}\n", NIL);
Wrapper_print(f, s_wrappers);
@@ -710,7 +719,7 @@ public:
Printf(f->code, "WRONG_PARAM_COUNT;\n}\n\n");
}
- /* Now convert from php to C variables */
+ /* Now convert from PHP to C variables */
// At this point, argcount if used is the number of deliberately passed args
// not including this_ptr even if it is used.
// It means error messages may be out by argbase with error
@@ -845,7 +854,7 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
- Printv(f->code, "zend_error(SWIG_ErrorCode(),SWIG_ErrorMsg());", NIL);
+ Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
Printf(f->code, "}\n");
@@ -861,7 +870,7 @@ public:
Delete(wname);
wname = NULL;
- if (!(shadow && php_version == 5)) {
+ if (!shadow) {
DelWrapper(f);
return SWIG_OK;
}
@@ -1104,7 +1113,8 @@ public:
case T_LONG: {
char *p;
errno = 0;
- (void) strtol(Char(value), &p, 0);
+ unsigned int n = strtol(Char(value), &p, 0);
+ (void) n;
if (errno || *p) {
Clear(value);
Append(value, "?");
@@ -1117,7 +1127,8 @@ public:
case T_ULONG: {
char *p;
errno = 0;
- (void) strtoul(Char(value), &p, 0);
+ unsigned int n = strtoul(Char(value), &p, 0);
+ (void) n;
if (errno || *p) {
Clear(value);
Append(value, "?");
@@ -1358,16 +1369,26 @@ public:
Printf(output, "\n");
// If it's a member function or a class constructor...
if (wrapperType == memberfn || (newobject && current_class)) {
- Printf(output, "\tfunction %s(%s) {\n", methodname, args);
// We don't need this code if the wrapped class has a copy ctor
// since the flat function new_CLASSNAME will handle it for us.
if (newobject && !Getattr(current_class, "allocate:copy_constructor")) {
+ const char * arg0;
+ if (max_num_of_arguments > 0) {
+ arg0 = Char(arg_names[0]);
+ } else {
+ arg0 = "res";
+ Delete(args);
+ args = NewString("$res=null");
+ }
SwigType *t = Getattr(current_class, "classtype");
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
- Printf(s_oowrappers, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg_names[0], arg_names[0], mangled_type);
- Printf(s_oowrappers, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg_names[0]);
- Printf(s_oowrappers, "\t\t\treturn;\n");
- Printf(s_oowrappers, "\t\t}\n");
+ Printf(output, "\tfunction %s(%s) {\n", methodname, args);
+ Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg0, arg0, mangled_type);
+ Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
+ Printf(output, "\t\t\treturn;\n");
+ Printf(output, "\t\t}\n");
+ } else {
+ Printf(output, "\tfunction %s(%s) {\n", methodname, args);
}
} else {
Printf(output, "\tstatic function %s(%s) {\n", methodname, args);
@@ -1480,8 +1501,7 @@ public:
Replaceall(tm, "$symname", iname);
Printf(f_c->code, "%s\n", tm);
} else {
- Printf(stderr,"%s: Line %d, Unable to link with type %s\n",
- input_file, line_number, SwigType_str(t, 0));
+ Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
}
*/
/* Now generate C -> PHP sync blocks */
@@ -1493,8 +1513,7 @@ public:
Replaceall(tm, "$symname", iname);
Printf(f_php->code, "%s\n", tm);
} else {
- Printf(stderr,"%s: Line %d, Unable to link with type %s\n",
- input_file, line_number, SwigType_str(t, 0));
+ Printf(stderr,"%s: Line %d, Unable to link with type %s\n", input_file, line_number, SwigType_str(t, 0));
}
}
*/
@@ -1525,7 +1544,7 @@ public:
Printf(s_cinit, "%s\n", tm);
}
- if (shadow && php_version == 5) {
+ if (shadow) {
String *enumvalue = GetChar(n, "enumvalue");
String *set_to = iname;
@@ -1567,8 +1586,8 @@ public:
*
* Pragma directive.
*
- * %pragma(php4) code="String" # Includes a string in the .php file
- * %pragma(php4) include="file.pl" # Includes a file in the .php file
+ * %pragma(php) code="String" # Includes a string in the .php file
+ * %pragma(php) include="file.pl" # Includes a file in the .php file
*/
virtual int pragmaDirective(Node *n) {
@@ -1577,7 +1596,7 @@ public:
String *type = Getattr(n, "name");
String *value = Getattr(n, "value");
- if (Strcmp(lang, "php4") == 0) {
+ if (Strcmp(lang, "php") == 0 || Strcmp(lang, "php4") == 0) {
if (Strcmp(type, "code") == 0) {
if (value) {
Printf(pragma_code, "%s\n", value);
@@ -1815,7 +1834,7 @@ public:
String *iname = Getattr(n, "sym:name");
/* A temporary(!) hack for static member variables.
- * Php currently supports class functions, but not class variables.
+ * PHP currently supports class functions, but not class variables.
* Until it does, we convert a class variable to a class function
* that returns the current value of the variable. E.g.
*
@@ -1824,7 +1843,7 @@ public:
* static int ncount;
* };
*
- * would be available in php as Example::ncount()
+ * would be available in PHP as Example::ncount()
*/
// If the variable is const, then it's wrapped as a constant with set/get
@@ -1923,7 +1942,7 @@ public:
return NewStringEmpty();
}
- String *PhpTypeFromTypemap(char *op, Node *n, String_or_char *lname) {
+ String *PhpTypeFromTypemap(char *op, Node *n, const_String_or_char_ptr lname) {
String *tms = Swig_typemap_lookup(op, n, lname, 0);
if (!tms)
return 0;
@@ -1999,7 +2018,6 @@ public:
Wrapper_print(f, s_wrappers);
return SWIG_OK;
-
}
/* ------------------------------------------------------------
@@ -2007,7 +2025,7 @@ public:
* ------------------------------------------------------------ */
virtual int memberconstantHandler(Node *n) {
- wrapping_member_constant = Getattr(n, "name");
+ wrapping_member_constant = Getattr(n, "sym:name");
Language::memberconstantHandler(n);
wrapping_member_constant = NULL;
return SWIG_OK;
@@ -2015,10 +2033,6 @@ public:
}; /* class PHP */
-/* -----------------------------------------------------------------------------
- * swig_php() - Instantiate module
- * ----------------------------------------------------------------------------- */
-
static PHP *maininstance = 0;
// We use this function to be able to write out zend_register_list_destructor_ex
@@ -2045,8 +2059,12 @@ extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
(*r_prevtracefunc) (ty, mangled, (String *) clientdata);
}
-static Language *new_swig_php(int php_version) {
- maininstance = new PHP(php_version);
+/* -----------------------------------------------------------------------------
+ * new_swig_php() - Instantiate module
+ * ----------------------------------------------------------------------------- */
+
+static Language *new_swig_php() {
+ maininstance = new PHP;
if (!r_prevtracefunc) {
r_prevtracefunc = SwigType_remember_trace(typetrace);
} else {
@@ -2063,6 +2081,6 @@ extern "C" Language *swig_php4(void) {
return NULL; // To avoid compiler warnings.
}
-extern "C" Language *swig_php5(void) {
- return new_swig_php(5);
+extern "C" Language *swig_php(void) {
+ return new_swig_php();
}
diff --git a/Source/Modules/pike.cxx b/Source/Modules/pike.cxx
index 30f9b3d74..98f63056c 100644
--- a/Source/Modules/pike.cxx
+++ b/Source/Modules/pike.cxx
@@ -39,6 +39,7 @@ Pike Options (available with -pike)\n\
class PIKE:public Language {
private:
+ File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@@ -69,6 +70,7 @@ public:
* --------------------------------------------------------------------- */
PIKE() {
+ f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@@ -123,11 +125,12 @@ public:
String *outfile = Getattr(n, "outfile");
/* Open the output file */
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_classInit = NewString("");
f_header = NewString("");
@@ -136,12 +139,17 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("classInit", f_classInit);
/* Standard stuff for the SWIG runtime section */
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGPIKE\n");
+ Printf(f_runtime, "\n");
Printf(f_header, "#define SWIG_init pike_module_init\n");
Printf(f_header, "#define SWIG_name \"%s\"\n\n", module);
@@ -161,17 +169,19 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
- Dump(f_header, f_runtime);
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Delete(f_classInit);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
/* Done */
return SWIG_OK;
@@ -221,7 +231,7 @@ public:
* name (i.e. "enum_test").
* ------------------------------------------------------------ */
- String *strip(const DOHString_or_char *name) {
+ String *strip(const DOHconst_String_or_char_ptr name) {
String *s = Copy(name);
if (Strncmp(name, PrefixPlusUnderscore, Len(PrefixPlusUnderscore)) != 0) {
return s;
@@ -234,7 +244,7 @@ public:
* add_method()
* ------------------------------------------------------------ */
- void add_method(const DOHString_or_char *name, const DOHString_or_char *function, const DOHString_or_char *description) {
+ void add_method(const DOHconst_String_or_char_ptr name, const DOHconst_String_or_char_ptr function, const DOHconst_String_or_char_ptr description) {
String *rename = NULL;
switch (current) {
case NO_CPP:
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index ddd23d1f3..73f280e6b 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -10,11 +10,8 @@
char cvsroot_python_cxx[] = "$Id$";
#include "swigmod.h"
-#define ctab2 " "
-#define ctab4 " "
-#define ctab8 " "
-
#include "cparse.h"
+
static int treduce = SWIG_cparse_template_reduce(0);
#include <ctype.h>
@@ -31,6 +28,7 @@ static int shadow = 1;
static int use_kw = 0;
static int director_method_index = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
static File *f_runtime_h = 0;
static File *f_header = 0;
@@ -49,10 +47,11 @@ static String *shadow_indent = 0;
static int in_class = 0;
static int classic = 0;
static int modern = 0;
-static int apply = 0;
static int new_repr = 1;
static int no_header_file = 0;
+static int py3 = 0;
+
/* C++ Support + Shadow Classes */
static int have_constructor;
@@ -96,7 +95,6 @@ enum autodoc_t {
static const char *usage1 = (char *) "\
Python Options (available with -python)\n\
-aliasobj0 - Alias obj0 when using fastunpack, needed for some old typemaps \n\
- -apply - Use apply() in proxy classes\n\
-buildnone - Use Py_BuildValue(" ") to obtain Py_None (default in Windows)\n\
-castmode - Enable the casting mode, which allows implicit cast between types in python\n\
-classic - Use classic classes only\n\
@@ -148,6 +146,8 @@ static const char *usage3 = (char *) "\
-O - Enable all the optimization options: \n\
-modern -fastdispatch -dirvtable -nosafecstrings -fvirtual -noproxydel \n\
-fastproxy -fastinit -fastunpack -fastquery -modernargs -nobuildnone \n\
+ -py3 - Generate code with Python 3 specific features:\n\
+ Function annotation \n\
\n";
class PYTHON:public Language {
@@ -259,9 +259,6 @@ public:
} else if ((strcmp(argv[i], "-shadow") == 0) || ((strcmp(argv[i], "-proxy") == 0))) {
shadow = 1;
Swig_mark_arg(i);
- } else if (strcmp(argv[i], "-apply") == 0) {
- apply = 1;
- Swig_mark_arg(i);
} else if ((strcmp(argv[i], "-new_repr") == 0) || (strcmp(argv[i], "-newrepr") == 0)) {
new_repr = 1;
Swig_mark_arg(i);
@@ -284,7 +281,6 @@ public:
} else if (strcmp(argv[i], "-classic") == 0) {
classic = 1;
modernargs = 0;
- apply = 1;
modern = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-cppcast") == 0) {
@@ -390,7 +386,6 @@ public:
proxydel = 0;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-modern") == 0) {
- apply = 0;
classic = 0;
modern = 1;
modernargs = 1;
@@ -408,7 +403,6 @@ public:
no_header_file = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i], "-O") == 0) {
- apply = 0;
classic = 0;
modern = 1;
dirvtable = 1;
@@ -429,8 +423,17 @@ public:
fputs(usage1, stdout);
fputs(usage2, stdout);
fputs(usage3, stdout);
- }
+ } else if (strcmp(argv[i], "-py3") == 0) {
+ py3 = 1;
+ Swig_mark_arg(i);
+ }
+
}
+ } /* for */
+
+ if (py3) {
+ /* force disable features that not compatible with Python 3.x */
+ classic = 0;
}
if (cppcast) {
@@ -511,15 +514,21 @@ public:
String *outfile = Getattr(n, "outfile");
String *outfile_h = !no_header_file ? Getattr(n, "outfile_h") : 0;
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
+ f_init = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_directors_h = NewString("");
+ f_directors = NewString("");
if (directorsEnabled()) {
if (!no_header_file) {
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
@@ -529,15 +538,10 @@ public:
}
}
- f_init = NewString("");
- f_header = NewString("");
- f_wrappers = NewString("");
- f_directors_h = NewString("");
- f_directors = NewString("");
-
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@@ -546,8 +550,9 @@ public:
const_code = NewString("");
methods = NewString("");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+ Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGPYTHON\n");
if (directorsEnabled()) {
@@ -599,6 +604,8 @@ public:
Printf(f_runtime, "#define SWIG_PYTHON_CLASSIC\n");
}
+ Printf(f_runtime, "\n");
+
Printf(f_header, "#if (PY_VERSION_HEX <= 0x02000000)\n");
Printf(f_header, "# if !defined(SWIG_PYTHON_CLASSIC)\n");
Printf(f_header, "# error \"This python version requires swig to be run with the '-classic' option\"\n");
@@ -637,6 +644,7 @@ public:
if (directorsEnabled()) {
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
if (dirprot_mode()) {
@@ -660,7 +668,7 @@ public:
module = interface;
else
Insert(module, 0, "_");
- if ((f_shadow_py = NewFile(filen, "w")) == 0) {
+ if ((f_shadow_py = NewFile(filen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
@@ -674,10 +682,7 @@ public:
Swig_register_filebyname("shadow", f_shadow);
Swig_register_filebyname("python", f_shadow);
- Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f_shadow, "# Version %s\n", Swig_package_version());
- Printf(f_shadow, "#\n");
- Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n");
+ Swig_banner_target_lang(f_shadow, "#");
if (!modern) {
Printv(f_shadow, "# This file is compatible with both classic and new-style classes.\n", NIL);
@@ -691,6 +696,13 @@ public:
Printv(f_shadow, "\nfrom sys import version_info\n", NULL);
+ if(fastproxy)
+ {
+ Printv(f_shadow, "if version_info >= (3,0,0):\n", NULL);
+ Printf(f_shadow, tab4 "new_instancemethod = lambda func, inst, cls: %s.SWIG_PyInstanceMethod_New(func)\n", module);
+ Printv(f_shadow, "else:\n", NULL);
+ Printv(f_shadow, tab4, "from new import instancemethod as new_instancemethod\n", NULL);
+ }
/* Import the C-extension module. This should be a relative import,
* since the shadow module may also have been imported by a relative
* import, and there is thus no guarantee that the C-extension is on
@@ -704,12 +716,19 @@ public:
Printv(f_shadow, tab4, "def swig_import_helper():\n", NULL);
Printv(f_shadow, tab8, "from os.path import dirname\n", NULL);
Printv(f_shadow, tab8, "import imp\n", NULL);
+ Printv(f_shadow, tab8, "fp = None\n", NULL);
Printv(f_shadow, tab8, "try:\n", NULL);
Printf(f_shadow, tab4 tab8 "fp, pathname, description = imp.find_module('%s', [dirname(__file__)])\n", module);
- Printf(f_shadow, tab4 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
- Printv(f_shadow, tab8, "finally:\n", NULL);
- Printv(f_shadow, tab4 tab8, "if fp is not None: fp.close()\n", NULL);
- Printv(f_shadow, tab8, "return _mod\n", NULL);
+ Printf(f_shadow, tab8 "except ImportError:\n");
+ /* At here, the module may already loaded, so simply import it. */
+ Printf(f_shadow, tab4 tab8 "import %s\n", module);
+ Printf(f_shadow, tab4 tab8 "return %s\n", module);
+ Printv(f_shadow, tab8 "if fp is not None:\n", NULL);
+ Printv(f_shadow, tab4 tab8 "try:\n", NULL);
+ Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
+ Printv(f_shadow, tab4 tab8, "finally:\n", NULL);
+ Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL);
+ Printv(f_shadow, tab8 tab8, "return _mod\n", NULL);
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
Printv(f_shadow, "else:\n", NULL);
@@ -719,11 +738,9 @@ public:
* module. */
Printv(f_shadow, "del version_info\n", NULL);
- Printv(f_shadow, "import new\n", NULL);
- Printv(f_shadow, "new_instancemethod = new.instancemethod\n", NULL);
if (modern || !classic) {
Printv(f_shadow, "try:\n", tab4, "_swig_property = property\n", "except NameError:\n", tab4, "pass # Python < 2.2 doesn't have 'property'.\n", NULL);
- }
+ }
/* if (!modern) */
/* always needed, a class can be forced to be no-modern, such as an exception */
{
@@ -731,7 +748,7 @@ public:
Printv(f_shadow,
"def _swig_setattr_nondynamic(self,class_type,name,value,static=1):\n",
tab4, "if (name == \"thisown\"): return self.this.own(value)\n",
- tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'PySwigObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
+ tab4, "if (name == \"this\"):\n", tab4, tab4, "if type(value).__name__ == 'SwigPyObject':\n", tab4, tab8, "self.__dict__[name] = value\n",
#ifdef USE_THISOWN
tab4, tab8, "if hasattr(value,\"thisown\"): self.__dict__[\"thisown\"] = value.thisown\n", tab4, tab8, "del value.thisown\n",
#endif
@@ -750,7 +767,7 @@ public:
"def _swig_getattr(self,class_type,name):\n",
tab4, "if (name == \"thisown\"): return self.this.own()\n",
tab4, "method = class_type.__swig_getmethods__.get(name,None)\n",
- tab4, "if method: return method(self)\n", tab4, "raise AttributeError,name\n\n", NIL);
+ tab4, "if method: return method(self)\n", tab4, "raise AttributeError(name)\n\n", NIL);
Printv(f_shadow,
"def _swig_repr(self):\n",
@@ -758,11 +775,17 @@ public:
tab4, "except: strthis = \"\"\n", tab4, "return \"<%s.%s; %s >\" % (self.__class__.__module__, self.__class__.__name__, strthis,)\n\n", NIL);
if (!classic) {
+ /* Usage of types.ObjectType is deprecated.
+ * But don't sure wether this would broken old Python?
+ */
Printv(f_shadow,
- "import types\n",
+// "import types\n",
"try:\n",
- " _object = types.ObjectType\n",
- " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n", "del types\n", "\n\n", NIL);
+// " _object = types.ObjectType\n",
+ " _object = object\n",
+ " _newclass = 1\n", "except AttributeError:\n", " class _object : pass\n", " _newclass = 0\n",
+// "del types\n",
+ "\n\n", NIL);
}
}
if (modern) {
@@ -788,7 +811,11 @@ public:
}
- Printf(f_header, "#define SWIG_init init%s\n\n", module);
+ Printf(f_header, "#if PY_VERSION_HEX >= 0x03000000\n");
+ Printf(f_header, "# define SWIG_init PyInit_%s\n\n", module);
+ Printf(f_header, "#else\n");
+ Printf(f_header, "# define SWIG_init init%s\n\n", module);
+ Printf(f_header, "#endif\n");
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
Printf(f_wrappers, "#ifdef __cplusplus\n");
@@ -797,6 +824,9 @@ public:
Append(const_code, "static swig_const_info swig_const_table[] = {\n");
Append(methods, "static PyMethodDef SwigMethods[] = {\n");
+ /* the method exported for replacement of new.instancemethod in Python 3 */
+ add_pyinstancemethod_new();
+
/* emit code */
Language::top(n);
@@ -815,6 +845,12 @@ public:
Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n");
Printf(f_wrappers, "%s\n", const_code);
initialize_threads(f_init);
+
+ Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n");
+ Printf(f_init, " return m;\n");
+ Printf(f_init, "#else\n");
+ Printf(f_init, " return;\n");
+ Printf(f_init, "#endif\n");
Printf(f_init, "}\n");
Printf(f_wrappers, "#ifdef __cplusplus\n");
@@ -822,10 +858,6 @@ public:
Printf(f_wrappers, "#endif\n");
if (shadow) {
- /*
- Printf(f_shadow_imports,"\nimport %s\n", module);
- Printv(f_shadow_py, f_shadow_imports, "\n",NIL);
- */
Printv(f_shadow_py, f_shadow, "\n", NIL);
Printv(f_shadow_py, f_shadow_stubs, "\n", NIL);
@@ -834,19 +866,20 @@ public:
}
/* Close all of the files */
- Dump(f_header, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
if (directorsEnabled()) {
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
- if (f_runtime_h != f_runtime)
+ if (f_runtime_h != f_begin)
Close(f_runtime_h);
- Dump(f_directors, f_runtime);
+ Dump(f_directors, f_begin);
}
- Dump(f_wrappers, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
@@ -854,11 +887,25 @@ public:
Delete(f_directors);
Delete(f_directors_h);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
+
+ /* ------------------------------------------------------------
+ * Emit the wrapper for PyInstanceMethod_New to MethodDef array.
+ * This wrapper is used to implement -fastproxy,
+ * as a replacement of new.instancemethod in Python 3.
+ * ------------------------------------------------------------ */
+ int add_pyinstancemethod_new()
+ {
+ String* name = NewString("SWIG_PyInstanceMethod_New");
+ Printf(methods, "\t { (char *)\"%s\", (PyCFunction)%s, METH_O, NULL},\n", name, name);
+ Delete(name);
+ return 0;
+ }
/* ------------------------------------------------------------
* importDirective()
@@ -890,7 +937,11 @@ public:
if (!options || (!Getattr(options, "noshadow") && !Getattr(options, "noproxy"))) {
Printf(import, "_%s\n", modname);
if (!Strstr(f_shadow_imports, import)) {
- Printf(f_shadow, "import %s\n", modname);
+ if (pkg && (!package || Strcmp(pkg, package) != 0)) {
+ Printf(f_shadow, "import %s.%s\n", pkg, modname);
+ } else {
+ Printf(f_shadow, "import %s\n", modname);
+ }
Printv(f_shadow_imports, import, NULL);
}
}
@@ -902,31 +953,25 @@ public:
return Language::importDirective(n);
}
-
/* ------------------------------------------------------------
- * emitFuncCallHelper()
- * Write the shadow code to call a function in the extension
- * module. Takes into account the -apply flag and whether
- * to use keyword args or not.
+ * funcCall()
+ * Emit shadow code to call a function in the extension
+ * module. Using proper argument and calling style for
+ * given node n.
* ------------------------------------------------------------ */
+ String *funcCall(String *name, String *parms) {
+ String *str = NewString("");
- String *funcCallHelper(String *name, int kw) {
- String *str;
-
- str = NewString("");
- if (apply) {
- Printv(str, "apply(", module, ".", name, ", args", (kw ? ", kwargs" : ""), ")", NIL);
- } else {
- Printv(str, module, ".", name, "(*args", (kw ? ", **kwargs" : ""), ")", NIL);
- }
+ Printv(str, module, ".", name, "(", parms, ")", NIL);
return str;
- }
+ }
+
/* ------------------------------------------------------------
* pythoncode() - Output python code into the shadow file
* ------------------------------------------------------------ */
- String *pythoncode(String *code, const String *indent) {
+ String *pythoncode(String *code, const_String_or_char_ptr indent) {
String *out = NewString("");
String *temp;
char *t;
@@ -1088,29 +1133,84 @@ public:
return doc;
}
+ /* -----------------------------------------------------------------------------
+ * makeParameterName()
+ * Note: the generated name should consist with that in kwnames[]
+ *
+ * Inputs:
+ * n - Node
+ * p - parameter node
+ * arg_num - parameter argument number
+ * Return:
+ * arg - a unique parameter name
+ * ----------------------------------------------------------------------------- */
+
+ String *makeParameterName(ParmList *plist, Parm *p, int arg_num) {
+ String *arg = 0;
+ String *pn = Swig_name_make(p, 0, Getattr(p, "name"), 0, 0);
+ // Use C parameter name unless it is a duplicate or an empty parameter name
+ int count = 0;
+ if ( SwigType_isvarargs(Getattr(p, "type")) ) {
+ return NewString("*args");
+ }
+ while (plist) {
+ if ((Cmp(pn, Getattr(plist, "name")) == 0))
+ count++;
+ plist = nextSibling(plist);
+ }
+ arg = (!pn || !Len(pn) || (count > 1)) ? NewStringf("arg%d", arg_num) : Copy(pn);
+ return arg;
+ }
+
+
/* ------------------------------------------------------------
* make_autodocParmList()
* Generate the documentation for the function parameters
+ * Parameters:
+ * func_annotation: Function annotation support
* ------------------------------------------------------------ */
- String *make_autodocParmList(Node *n, bool showTypes) {
+ String *make_autodocParmList(Node *n, bool showTypes, bool calling=false, bool func_annotation=false) {
+
+
String *doc = NewString("");
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p;
Parm *pnext;
- Node *lookup;
+ Node *lookup;
+
+
int lines = 0;
+ int arg_num = 0;
const int maxwidth = 50;
+ if(calling)
+ func_annotation = false;
+
if (pdocs)
Append(pdocs, "\n");
-
Swig_typemap_attach_parms("in", plist, 0);
Swig_typemap_attach_parms("doc", plist, 0);
-
+
+ if (Strcmp(ParmList_protostr(plist), "void")==0) {
+ //No parameters actually
+ return doc;
+ }
+
for (p = plist; p; p = pnext) {
+
+ String *tm = Getattr(p, "tmap:in");
+ if (tm) {
+ pnext = Getattr(p, "tmap:in:next");
+ if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ continue;
+ }
+ } else {
+ pnext = nextSibling(p);
+ }
+
String *name = 0;
String *type = 0;
String *value = 0;
@@ -1127,12 +1227,14 @@ public:
type = type ? type : Getattr(p, "type");
value = value ? value : Getattr(p, "value");
- String *tm = Getattr(p, "tmap:in");
- if (tm) {
- pnext = Getattr(p, "tmap:in:next");
- } else {
- pnext = nextSibling(p);
- }
+ name = makeParameterName(plist, p, arg_num);
+ // Reset it for convinient in further use. (mainly for makeParameterName())
+ // Since the plist is created by CopyParmList,
+ // we can hope that the set would have no side effect
+ Setattr(p, "name", name);
+
+ arg_num++;
+
if (Len(doc)) {
// add a comma to the previous one if any
@@ -1144,39 +1246,40 @@ public:
lines += 1;
}
}
+
+ type = SwigType_base(type);
+ lookup = Swig_symbol_clookup(type, 0);
+ if (lookup)
+ type = Getattr(lookup, "sym:name");
+
// Do the param type too?
- if (showTypes) {
- type = SwigType_base(type);
- lookup = Swig_symbol_clookup(type, 0);
- if (lookup)
- type = Getattr(lookup, "sym:name");
- Printf(doc, "%s ", type);
- }
-
- if (name) {
- Append(doc, name);
- if (pdoc) {
- if (!pdocs)
- pdocs = NewString("Parameters:\n");
- Printf(pdocs, " %s\n", pdoc);
- }
- } else {
- Append(doc, "?");
+ if (showTypes)
+ Printf(doc, "%s ", type);
+
+
+ Append(doc, name);
+ if (pdoc) {
+ if (!pdocs)
+ pdocs = NewString("Parameters:\n");
+ Printf(pdocs, " %s\n", pdoc);
}
- if (value) {
- if (Strcmp(value, "NULL") == 0)
- value = NewString("None");
- else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
- value = NewString("True");
- else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0)
- value = NewString("False");
+ // Write the function annoation
+ if (func_annotation)
+ Printf(doc, " : '%s'", type);
+
+ // Write default value
+ if (value && !calling) {
+ String* pv = pyvalue(value, Getattr(p, "type"));
+ if (pv)
+ value = pv;
else {
lookup = Swig_symbol_clookup(value, 0);
- if (lookup)
+ if (lookup) {
value = Getattr(lookup, "sym:name");
+ }
}
- Printf(doc, "=%s", value);
+ Printf(doc, " = %s", value);
}
}
if (pdocs)
@@ -1254,9 +1357,9 @@ public:
String *str = Getattr(n, "feature:docstring");
if (str == NULL || Len(str) == 0) {
if (CPlusPlus) {
- Printf(doc, "Proxy of C++ %s class", class_name);
+ Printf(doc, "Proxy of C++ %s class", real_classname);
} else {
- Printf(doc, "Proxy of C %s struct", class_name);
+ Printf(doc, "Proxy of C %s struct", real_classname);
}
}
}
@@ -1314,6 +1417,132 @@ public:
return doc;
}
+
+ /* ------------------------------------------------------------
+ * pyvalue()
+ * Check if string v can be a Python value literal,
+ * (eg. number or string), or translate it to a Python literal.
+ * ------------------------------------------------------------ */
+ String* pyvalue(String *v, SwigType *t)
+ {
+ if (v && Len(v)>0) {
+ char fc = (Char(v))[0];
+ if (('0'<=fc && fc<='9') || '\''==fc || '"'==fc) {
+ /* number or string (or maybe NULL pointer)*/
+ if (SwigType_ispointer(t) && Strcmp(v, "0")==0)
+ return NewString("None");
+ else
+ return v;
+ }
+ if (Strcmp(v, "true")==0 || Strcmp(v, "FALSE")==0)
+ return NewString("True");
+ if (Strcmp(v, "false")==0 || Strcmp(v, "FALSE")==0)
+ return NewString("False");
+ if (Strcmp(v, "NULL")==0)
+ return NewString("None");
+ }
+ return 0;
+ }
+ /* ------------------------------------------------------------
+ * is_primitive_defaultargs()
+ * Check if all the default args have primitive type.
+ * (So we can generate proper parameter list with default
+ * values..)
+ * ------------------------------------------------------------ */
+ bool is_primitive_defaultargs(Node *n)
+ {
+ ParmList *plist = CopyParmList(Getattr(n, "parms"));
+ Parm *p;
+ Parm *pnext;
+
+ Swig_typemap_attach_parms("in", plist, 0);
+ for (p = plist; p; p = pnext) {
+ String *tm = Getattr(p, "tmap:in");
+ if (tm) {
+ pnext = Getattr(p, "tmap:in:next");
+ if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ continue;
+ }
+ } else {
+ pnext = nextSibling(p);
+ }
+ String *type = Getattr(p, "type");
+ String *value = Getattr(p, "value");
+ if (!pyvalue(value, type))
+ return false;
+ }
+ return true;
+ }
+
+
+ /* ------------------------------------------------------------
+ * is_real_overloaded()
+ * Check if the function is overloaded, but not just have some
+ * siblings generated due to the original function have
+ * default arguments.
+ * ------------------------------------------------------------ */
+ bool is_real_overloaded(Node *n)
+ {
+ Node *h = Getattr(n, "sym:overloaded");
+ Node *i;
+ if (!h)
+ return false;
+
+ i = Getattr(h, "sym:nextSibling");
+ while (i) {
+ Node *nn = Getattr(i, "defaultargs");
+ if (nn != h) {
+ /* Check if overloaded function has defaultargs and
+ * pointed to the first overloaded. */
+ return true;
+ }
+ i = Getattr(i, "sym:nextSibling");
+ }
+
+ return false;
+ }
+
+ /* ------------------------------------------------------------
+ * make_pyParmList()
+ * Generate parameter list for Python functions or methods,
+ * reuse make_autodocParmList() to do so.
+ * ------------------------------------------------------------ */
+ String* make_pyParmList(Node *n, bool in_class, bool is_calling, int kw)
+ {
+ /* Get the original function for a defaultargs copy,
+ * see default_arguments() in parser.y. */
+ Node *nn = Getattr(n, "defaultargs");
+ if (nn) n = nn;
+
+ /* For overloaded function, just use *args */
+ if (is_real_overloaded(n) ||
+ GetFlag(n, "feature:compactdefaultargs") ||
+ !is_primitive_defaultargs(n))
+ {
+ String *parms = NewString("");
+ if(in_class)
+ Printf(parms, "self, ");
+ Printf(parms, "*args");
+ if (kw)
+ Printf(parms, ", **kwargs");
+ return parms;
+ }
+
+ bool funcanno = py3 ? true : false;
+ String *params = NewString("");
+ String *_params = make_autodocParmList(n, false, is_calling, funcanno);
+
+ if (in_class)
+ {
+ Printf(params, "self");
+ if(Len(_params) > 0)
+ Printf(params, ", ");
+ }
+
+ Printv(params, _params, NULL);
+
+ return params;
+ }
/* ------------------------------------------------------------
* have_pythonprepend()
@@ -1379,6 +1608,40 @@ public:
return have_pythonappend(n) || have_pythonprepend(n) || have_docstring(n);
}
+
+ /* ------------------------------------------------------------
+ * returnTypeAnnotation()
+ * Helper function for constructing the function annotation
+ * of the returning type, return a empty string for Python 2.x
+ * ------------------------------------------------------------ */
+ String* returnTypeAnnotation(Node *n)
+ {
+ String *ret=0;
+ Parm *p = Getattr(n, "parms");
+ String *tm;
+ /* Try to guess the returning type by argout typemap,
+ * however the result may not accurate. */
+ while (p) {
+ if ((tm=Getattr(p, "tmap:argout:match_type"))) {
+ tm = SwigType_str(tm, 0);
+ if (ret)
+ Printv(ret, ", ", tm, NULL);
+ else
+ ret = tm;
+ p = Getattr(p, "tmap:argout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+ /* If no argout typemap, then get the returning type from
+ * the function prototype. */
+ if (!ret) {
+ ret = Getattr(n, "type");
+ if (ret) ret = SwigType_str(ret, 0);
+ }
+ return (ret && py3) ? NewStringf(" -> \"%s\" ", ret)
+ : NewString("");
+ }
/* ------------------------------------------------------------
* emitFunctionShadowHelper()
@@ -1388,24 +1651,26 @@ public:
* ------------------------------------------------------------ */
void emitFunctionShadowHelper(Node *n, File *f_dest, String *name, int kw) {
- if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) {
- /* If there is no addtofunc directive then just assign from the extension module */
- Printv(f_dest, name, " = ", module, ".", name, "\n", NIL);
+ String *parms = make_pyParmList(n, false, false, kw);
+ String *callParms = make_pyParmList(n, false, true, kw);
+ /* Make a wrapper function to insert the code into */
+ Printv(f_dest, "\ndef ", name, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
+ if (have_docstring(n))
+ Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
+ if (have_pythonprepend(n))
+ Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL);
+ if (have_pythonappend(n)) {
+ Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL);
+ Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL);
+ Printv(f_dest, " return val\n", NIL);
} else {
- /* Otherwise make a wrapper function to insert the code into */
- Printv(f_dest, "\ndef ", name, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
- if (have_docstring(n))
- Printv(f_dest, ctab4, docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
- if (have_pythonprepend(n))
- Printv(f_dest, ctab4, pythonprepend(n), "\n", NIL);
- if (have_pythonappend(n)) {
- Printv(f_dest, ctab4, "val = ", funcCallHelper(name, kw), "\n", NIL);
- Printv(f_dest, ctab4, pythonappend(n), "\n", NIL);
- Printv(f_dest, ctab4, "return val\n", NIL);
- } else {
- Printv(f_dest, ctab4, "return ", funcCallHelper(name, kw), "\n", NIL);
- }
+ Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL);
}
+
+ if (Getattr(n, "feature:python:callback") || !have_addtofunc(n)) {
+ /* If there is no addtofunc directive then just assign from the extension module (for speed up) */
+ Printv(f_dest, name, " = ", module, ".", name, "\n", NIL);
+ }
}
@@ -1474,7 +1739,6 @@ public:
/* Last node in overloaded chain */
int maxargs;
- int allow_thread = threads_enable(n);
String *tmp = NewString("");
String *dispatch;
@@ -1497,8 +1761,6 @@ public:
Wrapper_add_local(f, "argc", "int argc");
Printf(tmp, "PyObject *argv[%d]", maxargs + 1);
Wrapper_add_local(f, "argv", tmp);
- if (allow_thread)
- thread_begin_block(n, f->code);
if (!fastunpack) {
Wrapper_add_local(f, "ii", "int ii");
@@ -1515,19 +1777,8 @@ public:
Replaceall(dispatch, "$args", "self,args");
- if (allow_thread) {
- String *ret = NewStringEmpty();
- thread_end_block(n, ret);
- Append(ret, "return ");
- Replaceall(dispatch, "return ", ret);
- Delete(ret);
- }
-
Printv(f->code, dispatch, "\n", NIL);
- if (allow_thread)
- thread_end_block(n, f->code);
-
if (GetFlag(n, "feature:python:maybecall")) {
Append(f->code, "fail:\n");
Append(f->code, "Py_INCREF(Py_NotImplemented);\n");
@@ -1634,8 +1885,6 @@ public:
kwargs = NewString("");
int allow_thread = threads_enable(n);
- if (allow_thread)
- thread_begin_block(n, f->code);
Wrapper_add_local(f, "resultobj", "PyObject *resultobj = 0");
@@ -1806,7 +2055,7 @@ public:
/* finish argument marshalling */
Append(kwargs, " NULL }");
if (allow_kwargs) {
- Printv(f->locals, ctab4, "char * kwnames[] = ", kwargs, ";\n", NIL);
+ Printv(f->locals, " char * kwnames[] = ", kwargs, ";\n", NIL);
}
if (use_parse || allow_kwargs || !modernargs) {
@@ -2066,8 +2315,6 @@ public:
}
}
- if (allow_thread)
- thread_end_block(n, f->code);
Append(f->code, " return resultobj;\n");
/* Error handling code */
@@ -2076,9 +2323,7 @@ public:
if (need_cleanup) {
Printv(f->code, cleanup, NIL);
}
- if (allow_thread)
- thread_end_block(n, f->code);
- Printv(f->code, ctab4, "return NULL;\n", NIL);
+ Printv(f->code, " return NULL;\n", NIL);
if (funpack) {
@@ -2210,9 +2455,9 @@ public:
} else {
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
}
- Printv(setf->code, ctab4, "return 0;\n", NULL);
+ Printv(setf->code, " return 0;\n", NULL);
Append(setf->code, "fail:\n");
- Printv(setf->code, ctab4, "return 1;\n", NULL);
+ Printv(setf->code, " return 1;\n", NULL);
} else {
/* Is a readonly variable. Issue an error */
if (CPlusPlus) {
@@ -2220,7 +2465,7 @@ public:
} else {
Printf(setf->def, "SWIGINTERN int %s(PyObject *_val SWIGUNUSED) {", varsetname);
}
- Printv(setf->code, ctab4, "SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", ctab4, "return 1;\n", NIL);
+ Printv(setf->code, " SWIG_Error(SWIG_AttributeError,\"Variable ", iname, " is read-only.\");\n", " return 1;\n", NIL);
}
Append(setf->code, "}\n");
@@ -2488,7 +2733,7 @@ public:
Printf(f_directors_h, " PyObject *swig_get_method(size_t method_index, const char *method_name) const {\n");
Printf(f_directors_h, " PyObject *method = vtable[method_index];\n");
Printf(f_directors_h, " if (!method) {\n");
- Printf(f_directors_h, " swig::PyObject_var name = PyString_FromString(method_name);\n");
+ Printf(f_directors_h, " swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);\n");
Printf(f_directors_h, " method = PyObject_GetAttr(swig_get_self(), name);\n");
Printf(f_directors_h, " if (method == NULL) {\n");
Printf(f_directors_h, " std::string msg = \"Method in class %s doesn't exist, undefined \";\n", classname);
@@ -2500,7 +2745,7 @@ public:
Printf(f_directors_h, " return method;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
- Printf(f_directors_h, " mutable swig::PyObject_var vtable[%d];\n", director_method_index);
+ Printf(f_directors_h, " mutable swig::SwigVar_PyObject vtable[%d];\n", director_method_index);
Printf(f_directors_h, "#endif\n\n");
}
@@ -2612,7 +2857,12 @@ public:
b = First(baselist);
while (b.item) {
String *bname = Getattr(b.item, "python:proxy");
- if (!bname || GetFlag(b.item, "feature:ignore")) {
+ bool ignore = GetFlag(b.item, "feature:ignore") ? true : false;
+ if (!bname || ignore) {
+ if (!bname && !ignore) {
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number,
+ "Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name")));
+ }
b = Next(b);
continue;
}
@@ -2623,6 +2873,16 @@ public:
}
}
}
+
+ /* dealing with abstract base class */
+ String *abcs = Getattr(n, "feature:python:abc");
+ if (py3 && abcs) {
+ if (Len(base_class)) {
+ Putc(',', base_class);
+ }
+ Printv(base_class, abcs, NIL);
+ }
+
Printv(f_shadow, "class ", class_name, NIL);
if (Len(base_class)) {
@@ -2631,6 +2891,9 @@ public:
if (!classic) {
Printf(f_shadow, modern ? "(object)" : "(_object)");
}
+ if (GetFlag(n, "feature:exceptionclass") ) {
+ Printf(f_shadow, "(Exception)");
+ }
}
Printf(f_shadow, ":\n");
if (have_docstring(n)) {
@@ -2699,20 +2962,20 @@ public:
SwigType_add_pointer(realct);
SwigType_remember(realct);
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
- Printv(f_wrappers, ctab4, "PyObject *obj;\n", NIL);
+ Printv(f_wrappers, " PyObject *obj;\n", NIL);
if (modernargs) {
if (fastunpack) {
- Printv(f_wrappers, ctab4, "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
+ Printv(f_wrappers, " if (!SWIG_Python_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
} else {
- Printv(f_wrappers, ctab4, "if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
+ Printv(f_wrappers, " if (!PyArg_UnpackTuple(args,(char*)\"swigregister\", 1, 1,&obj)) return NULL;\n", NIL);
}
} else {
- Printv(f_wrappers, ctab4, "if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL);
+ Printv(f_wrappers, " if (!PyArg_ParseTuple(args,(char*)\"O:swigregister\", &obj)) return NULL;\n", NIL);
}
Printv(f_wrappers,
- ctab4, "SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n",
- ctab4, "return SWIG_Py_Void();\n", "}\n\n", NIL);
+ " SWIG_TypeNewClientData(SWIGTYPE", SwigType_manglestr(ct), ", SWIG_NewClientData(obj));\n",
+ " return SWIG_Py_Void();\n", "}\n\n", NIL);
String *cname = NewStringf("%s_swigregister", class_name);
add_method(cname, cname, 0);
Delete(smart);
@@ -2721,11 +2984,11 @@ public:
Delete(realct);
}
if (!have_constructor) {
- Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError, \"No constructor defined\"\n", NIL);
+ Printv(f_shadow_file, tab4, "def __init__(self, *args, **kwargs): raise AttributeError(\"No constructor defined\")\n", NIL);
} else if (fastinit) {
Printv(f_wrappers, "SWIGINTERN PyObject *", class_name, "_swiginit(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", NIL);
- Printv(f_wrappers, ctab4, "return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL);
+ Printv(f_wrappers, " return SWIG_Python_InitShadowInstance(args);\n", "}\n\n", NIL);
String *cname = NewStringf("%s_swiginit", class_name);
add_method(cname, cname, 0);
Delete(cname);
@@ -2834,27 +3097,29 @@ public:
Delete(pycode);
fproxy = 0;
} else {
+ String *parms = make_pyParmList(n, true, false, allow_kwargs);
+ String *callParms = make_pyParmList(n, true, true, allow_kwargs);
if (!have_addtofunc(n)) {
if (!fastproxy || olddefs) {
- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
- Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL);
+ Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":", NIL);
+ Printv(f_shadow, " return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
}
} else {
- Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
+ Printv(f_shadow, tab4, "def ", symname, "(",parms , ")", returnTypeAnnotation(n), ":", NIL);
Printv(f_shadow, "\n", NIL);
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
if (have_pythonprepend(n)) {
fproxy = 0;
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
}
if (have_pythonappend(n)) {
fproxy = 0;
- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n", NIL);
- Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
+ Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
- Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), allow_kwargs), "\n\n", NIL);
+ Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL);
}
}
}
@@ -2887,17 +3152,19 @@ public:
if (shadow) {
if (!classic && !Getattr(n, "feature:python:callback") && have_addtofunc(n)) {
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
- Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
+ String *parms = make_pyParmList(n, false, false, kw);
+ String *callParms = make_pyParmList(n, false, true, kw);
+ Printv(f_shadow, tab4, "def ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
if (have_pythonappend(n)) {
- Printv(f_shadow, tab8, "val = ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n", NIL);
- Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
+ Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL);
} else {
- Printv(f_shadow, tab8, "return ", funcCallHelper(Swig_name_member(class_name, symname), kw), "\n\n", NIL);
+ Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL);
}
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname, " = staticmethod(", symname, ")\n", NIL);
@@ -2969,8 +3236,8 @@ public:
handled_as_init = (Strcmp(nname, sname) == 0) || (Strcmp(nname, cname) == 0);
Delete(cname);
}
-
- if (!have_constructor && handled_as_init) {
+
+ if (!have_constructor && handled_as_init) {
if (Getattr(n, "feature:shadow")) {
String *pycode = pythoncode(Getattr(n, "feature:shadow"), tab4);
String *pyaction = NewStringf("%s.%s", module, Swig_name_construct(symname));
@@ -2984,27 +3251,34 @@ public:
String *classname = Swig_class_name(parent);
String *rclassname = Swig_class_name(getCurrentClass());
assert(rclassname);
- if (use_director) {
+
+ String *parms = make_pyParmList(n, true, false, allow_kwargs);
+ /* Pass 'self' only if using director */
+ String *callParms = make_pyParmList(n, false, true, allow_kwargs);
+
+ if (use_director) {
+ Insert(callParms, 0, "_self, ");
Printv(pass_self, tab8, NIL);
Printf(pass_self, "if self.__class__ == %s:\n", classname);
- Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL);
+ //Printv(pass_self, tab8, tab4, "args = (None,) + args\n", tab8, "else:\n", tab8, tab4, "args = (self,) + args\n", NIL);
+ Printv(pass_self, tab8, tab4, "_self = None\n", tab8, "else:\n", tab8, tab4, "_self = self\n", NIL);
}
- Printv(f_shadow, tab4, "def __init__(self, *args", (allow_kwargs ? ", **kwargs" : ""), "): \n", NIL);
+ Printv(f_shadow, tab4, "def __init__(", parms, ")", returnTypeAnnotation(n), ": \n", NIL);
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pass_self, NIL);
if (fastinit) {
- Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCallHelper(Swig_name_construct(symname), allow_kwargs), ")\n", NIL);
+ Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL);
} else {
Printv(f_shadow,
- tab8, "this = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n",
+ tab8, "this = ", funcCall(Swig_name_construct(symname), callParms), "\n",
tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL);
}
if (have_pythonappend(n))
- Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL);
Delete(pass_self);
}
have_constructor = 1;
@@ -3020,18 +3294,20 @@ public:
Printv(f_shadow_stubs, pycode, "\n", NIL);
Delete(pycode);
} else {
+ String *parms = make_pyParmList(n, true, false, allow_kwargs);
+ String *callParms = make_pyParmList(n, true, true, allow_kwargs);
- Printv(f_shadow_stubs, "\ndef ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):\n", NIL);
+ Printv(f_shadow_stubs, "\ndef ", symname, "(", parms, ")", returnTypeAnnotation(n), ":\n", NIL);
if (have_docstring(n))
Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL);
- Printv(f_shadow_stubs, tab4, "val = ", funcCallHelper(Swig_name_construct(symname), allow_kwargs), "\n", NIL);
+ Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL);
+ Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL);
#ifdef USE_THISOWN
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
#endif
if (have_pythonappend(n))
- Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL);
+ Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL);
Printv(f_shadow_stubs, tab4, "return val\n", NIL);
}
}
@@ -3073,7 +3349,7 @@ public:
if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL);
if (have_pythonprepend(n))
- Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
#ifdef USE_THISOWN
Printv(f_shadow, tab8, "try:\n", NIL);
Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL);
@@ -3081,7 +3357,7 @@ public:
#else
#endif
if (have_pythonappend(n))
- Printv(f_shadow, tab8, pythonappend(n), "\n", NIL);
+ Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "pass\n", NIL);
Printv(f_shadow, "\n", NIL);
}
@@ -3469,8 +3745,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Replaceall(tm, "$input", input);
Delete(input);
Replaceall(tm, "$owner", "0");
- /* Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL); */
- Printv(wrap_args, "swig::PyObject_var ", source, ";\n", NIL);
+ /* Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL); */
+ Printv(wrap_args, "swig::SwigVar_PyObject ", source, ";\n", NIL);
Printv(wrap_args, tm, "\n", NIL);
Printv(arglist, "(PyObject *)", source, NIL);
@@ -3526,7 +3802,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
if (target) {
String *director = NewStringf("director_%s", mangle);
Wrapper_add_localv(w, director, "Swig::Director *", director, "= 0", NIL);
- Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL);
+ Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL);
Printf(wrap_args, "%s = SWIG_DIRECTOR_CAST(%s);\n", director, nonconst);
Printf(wrap_args, "if (!%s) {\n", director);
Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
@@ -3537,7 +3813,7 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Delete(director);
Printv(arglist, source, NIL);
} else {
- Wrapper_add_localv(w, source, "swig::PyObject_var", source, "= 0", NIL);
+ Wrapper_add_localv(w, source, "swig::SwigVar_PyObject", source, "= 0", NIL);
Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE%s, 0);\n", source, nonconst, mangle);
//Printf(wrap_args, "%s = SWIG_NewPointerObj(%s, SWIGTYPE_p_%s, 0);\n",
// source, nonconst, base);
@@ -3562,10 +3838,8 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
int allow_thread = threads_enable(n);
- if (allow_thread)
- thread_begin_block(n, w->code);
-
if (allow_thread) {
+ thread_begin_block(n, w->code);
Append(w->code, "{\n");
}
@@ -3588,33 +3862,33 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Append(w->code, "PyObject* method = swig_get_method(swig_method_index, swig_method_name);\n");
if (Len(parse_args) > 0) {
if (use_parse || !modernargs) {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, (char *)\"(%s)\" %s);\n", parse_args, arglist);
} else {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunctionObjArgs(method %s, NULL);\n", arglist);
}
} else {
if (modernargs) {
- Append(w->code, "swig::PyObject_var args = PyTuple_New(0);\n");
- Append(w->code, "swig::PyObject_var result = PyObject_Call(method, (PyObject*) args, NULL);\n");
+ Append(w->code, "swig::SwigVar_PyObject args = PyTuple_New(0);\n");
+ Append(w->code, "swig::SwigVar_PyObject result = PyObject_Call(method, (PyObject*) args, NULL);\n");
} else {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallFunction(method, NULL, NULL);\n");
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallFunction(method, NULL, NULL);\n");
}
}
Append(w->code, "#else\n");
if (Len(parse_args) > 0) {
if (use_parse || !modernargs) {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n",
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *)\"%s\", (char *)\"(%s)\" %s);\n",
pyname, parse_args, arglist);
- } else {
- Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname);
- Printf(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist);
+ } else {
+ Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name %s, NULL);\n", arglist);
}
} else {
if (!modernargs) {
- Printf(w->code, "swig::PyObject_var result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname);
+ Printf(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethod(swig_get_self(), (char *) \"%s\", NULL);\n", pyname);
} else {
- Printf(w->code, "swig::PyObject_var swig_method_name = PyString_FromString((char *)\"%s\");\n", pyname);
- Append(w->code, "swig::PyObject_var result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n");
+ Printf(w->code, "swig::SwigVar_PyObject swig_method_name = SWIG_Python_str_FromChar((char *)\"%s\");\n", pyname);
+ Append(w->code, "swig::SwigVar_PyObject result = PyObject_CallMethodObjArgs(swig_get_self(), (PyObject *) swig_method_name, NULL);\n");
}
}
Append(w->code, "#endif\n");
@@ -3675,11 +3949,6 @@ int PYTHON::classDirectorMethod(Node *n, Node *parent, String *super) {
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
if (outputs > 1) {
Printf(w->code, "output = PyTuple_GetItem(result, %d);\n", idx++);
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 49d3ecc89..8e9aa557d 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -424,6 +424,7 @@ protected:
String *sfile;
String *f_init;
String *s_classes;
+ String *f_begin;
String *f_runtime;
String *f_wrapper;
String *s_header;
@@ -487,6 +488,7 @@ R::R() :
sfile(0),
f_init(0),
s_classes(0),
+ f_begin(0),
f_runtime(0),
f_wrapper(0),
s_header(0),
@@ -767,6 +769,7 @@ void R::init() {
sfile = NewString("");
f_init = NewString("");
s_header = NewString("");
+ f_begin = NewString("");
f_runtime = NewString("");
f_wrapper = NewString("");
s_classes = NewString("");
@@ -811,16 +814,22 @@ int R::top(Node *n) {
Swig_register_filebyname("sinit", s_init);
Swig_register_filebyname("sinitroutine", s_init_routine);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("header", s_header);
Swig_register_filebyname("wrapper", f_wrapper);
Swig_register_filebyname("s", sfile);
-
Swig_register_filebyname("sclasses", s_classes);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGR\n");
+ Printf(f_runtime, "\n");
- Printf(s_init, "# This is an automatically generated file by the R module for SWIG.\n\n");
+
+ Swig_banner_target_lang(s_init, "#");
outputCommandLineArguments(s_init);
Printf(f_wrapper, "#ifdef __cplusplus\n");
@@ -858,7 +867,9 @@ int R::top(Node *n) {
Delete(f_init);
Delete(s_header);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -878,7 +889,7 @@ int R::DumpCode(Node *n) {
Printf(stderr, "Writing S code to %s\n", output_filename);
#endif
- File *scode = NewFile(output_filename, "w");
+ File *scode = NewFile(output_filename, "w", SWIG_output_files());
if (!scode) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
@@ -893,25 +904,16 @@ int R::DumpCode(Node *n) {
Close(scode);
// Delete(scode);
String *outfile = Getattr(n,"outfile");
- File *runtime = NewFile(outfile,"w");
+ File *runtime = NewFile(outfile,"w", SWIG_output_files());
if (!runtime) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
- Swig_banner(runtime);
-
-
- Printf(runtime, "/* Runtime */\n");
+ Printf(runtime, "%s", f_begin);
Printf(runtime, "%s\n", f_runtime);
-
- Printf(runtime, "/* Header */\n");
Printf(runtime, "%s\n", s_header);
-
- Printf(runtime, "/* Wrapper */\n");
Printf(runtime, "%s\n", f_wrapper);
-
- Printf(runtime, "/* Init code */\n");
Printf(runtime, "%s\n", f_init);
Close(runtime);
@@ -920,7 +922,7 @@ int R::DumpCode(Node *n) {
if(outputNamespaceInfo) {
output_filename = NewString("");
Printf(output_filename, "%sNAMESPACE", SWIG_output_directory());
- File *ns = NewFile(output_filename, "w");
+ File *ns = NewFile(output_filename, "w", SWIG_output_files());
if (!ns) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
@@ -2574,9 +2576,9 @@ String * R::runtimeCode() {
void R::main(int argc, char *argv[]) {
bool cppcast = true;
init();
+ Preprocessor_define("SWIGR 1", 0);
SWIG_library_directory("r");
SWIG_config_file("r.swg");
- Preprocessor_define("SWIGR 1", 0);
debugMode = false;
copyStruct = true;
memoryProfile = false;
@@ -2659,7 +2661,7 @@ int R::outputCommandLineArguments(File *out)
if(Argc < 1 || !Argv || !Argv[0])
return(-1);
- Printf(out, "## Generated via the command line invocation:\n##\t");
+ Printf(out, "\n## Generated via the command line invocation:\n##\t");
for(int i = 0; i < Argc ; i++) {
Printf(out, " %s", Argv[i]);
}
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index ad448d34e..8d5ab4fae 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -30,7 +30,7 @@ public:
/**
* The C variable name used in the SWIG-generated wrapper code to refer to
- * this class; usually it is of the form "cClassName.klass", where cClassName
+ * this class; usually it is of the form "SwigClassXXX.klass", where SwigClassXXX
* is a swig_class struct instance and klass is a member of that struct.
*/
String *vname;
@@ -39,7 +39,7 @@ public:
* The C variable name used in the SWIG-generated wrapper code to refer to
* the module that implements this class's methods (when we're trying to
* support C++ multiple inheritance). Usually it is of the form
- * "cClassName.mImpl", where cClassName is a swig_class struct instance
+ * "SwigClassClassName.mImpl", where SwigClassXXX is a swig_class struct instance
* and mImpl is a member of that struct.
*/
String *mImpl;
@@ -78,7 +78,7 @@ public:
Delete(temp);
}
- void set_name(const String_or_char *cn, const String_or_char *rn, const String_or_char *valn) {
+ void set_name(const_String_or_char_ptr cn, const_String_or_char_ptr rn, const_String_or_char_ptr valn) {
/* Original C/C++ class (or struct) name */
Clear(cname);
Append(cname, cn);
@@ -93,18 +93,18 @@ public:
/* Variable name for the VALUE that refers to the Ruby Class object */
Clear(vname);
- Printf(vname, "c%s.klass", name);
+ Printf(vname, "SwigClass%s.klass", name);
/* Variable name for the VALUE that refers to the Ruby Class object */
Clear(mImpl);
- Printf(mImpl, "c%s.mImpl", name);
+ Printf(mImpl, "SwigClass%s.mImpl", name);
/* Prefix */
Clear(prefix);
Printv(prefix, (rn ? rn : cn), "_", NIL);
}
- char *strip(const String_or_char *s) {
+ char *strip(const_String_or_char_ptr s) {
Clear(temp);
Append(temp, s);
if (Strncmp(s, prefix, Len(prefix)) == 0) {
@@ -158,6 +158,7 @@ private:
File *f_directors;
File *f_directors_h;
File *f_directors_helpers;
+ File *f_begin;
File *f_runtime;
File *f_runtime_h;
File *f_header;
@@ -762,6 +763,7 @@ public:
classes = 0;
klass = 0;
special_methods = 0;
+ f_begin = 0;
f_runtime = 0;
f_header = 0;
f_wrappers = 0;
@@ -992,35 +994,37 @@ public:
SWIG_exit(EXIT_FAILURE);
}
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
+ f_init = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_directors_h = NewString("");
+ f_directors = NewString("");
+ f_directors_helpers = NewString("");
+ f_initbeforefunc = NewString("");
+
if (directorsEnabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
SWIG_exit(EXIT_FAILURE);
}
- f_runtime_h = NewFile(outfile_h, "w");
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
SWIG_exit(EXIT_FAILURE);
}
}
- f_init = NewString("");
- f_header = NewString("");
- f_wrappers = NewString("");
- f_directors_h = NewString("");
- f_directors = NewString("");
- f_directors_helpers = NewString("");
- f_initbeforefunc = NewString("");
-
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
Swig_register_filebyname("director", f_directors);
@@ -1035,14 +1039,17 @@ public:
registerMagicMethods();
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+ Printf(f_runtime, "\n");
Printf(f_runtime, "#define SWIGRUBY\n");
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
+ Printf(f_runtime, "\n");
+
/* typedef void *VALUE */
SwigType *value = NewSwigType(T_VOID);
SwigType_add_pointer(value);
@@ -1058,6 +1065,7 @@ public:
Replaceall(module_macro, "::", "__");
Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module_macro);
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module_macro);
Printf(f_directors_h, "namespace Swig {\n");
@@ -1110,27 +1118,29 @@ public:
SwigType_emit_type_table(f_runtime, f_wrappers);
/* Close all of the files */
- Dump(f_header, f_runtime);
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
if (directorsEnabled()) {
- Dump(f_directors_helpers, f_runtime);
- Dump(f_directors, f_runtime);
+ Dump(f_directors_helpers, f_begin);
+ Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
Close(f_runtime_h);
}
- Dump(f_wrappers, f_runtime);
- Dump(f_initbeforefunc, f_runtime);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_wrappers, f_begin);
+ Dump(f_initbeforefunc, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Delete(f_initbeforefunc);
- Close(f_runtime);
+ Close(f_begin);
Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
@@ -1226,7 +1236,7 @@ public:
/**
* Process the comma-separated list of aliases (if any).
*/
- void defineAliases(Node *n, const String_or_char *iname) {
+ void defineAliases(Node *n, const_String_or_char_ptr iname) {
String *aliasv = Getattr(n, "feature:alias");
if (aliasv) {
List *aliases = Split(aliasv, ',', INT_MAX);
@@ -1260,7 +1270,7 @@ public:
* as another instance of the same class.
* --------------------------------------------------------------------- */
- void create_command(Node *n, const String_or_char *iname) {
+ void create_command(Node *n, const_String_or_char_ptr iname) {
String *alloc_func = Swig_name_wrapper(iname);
String *wname = Swig_name_wrapper(iname);
@@ -2392,9 +2402,9 @@ public:
void handleMarkFuncDirective(Node *n) {
String *markfunc = Getattr(n, "feature:markfunc");
if (markfunc) {
- Printf(klass->init, "c%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc);
+ Printf(klass->init, "SwigClass%s.mark = (void (*)(void *)) %s;\n", klass->name, markfunc);
} else {
- Printf(klass->init, "c%s.mark = 0;\n", klass->name);
+ Printf(klass->init, "SwigClass%s.mark = 0;\n", klass->name);
}
}
@@ -2404,10 +2414,10 @@ public:
void handleFreeFuncDirective(Node *n) {
String *freefunc = Getattr(n, "feature:freefunc");
if (freefunc) {
- Printf(klass->init, "c%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc);
+ Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) %s;\n", klass->name, freefunc);
} else {
if (klass->destructor_defined) {
- Printf(klass->init, "c%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname);
+ Printf(klass->init, "SwigClass%s.destroy = (void (*)(void *)) free_%s;\n", klass->name, klass->mname);
}
}
}
@@ -2418,9 +2428,9 @@ public:
void handleTrackDirective(Node *n) {
int trackObjects = GetFlag(n, "feature:trackobjects");
if (trackObjects) {
- Printf(klass->init, "c%s.trackObjects = 1;\n", klass->name);
+ Printf(klass->init, "SwigClass%s.trackObjects = 1;\n", klass->name);
} else {
- Printf(klass->init, "c%s.trackObjects = 0;\n", klass->name);
+ Printf(klass->init, "SwigClass%s.trackObjects = 0;\n", klass->name);
}
}
@@ -2445,7 +2455,7 @@ public:
Clear(klass->type);
Printv(klass->type, Getattr(n, "classtype"), NIL);
- Printv(f_wrappers, "swig_class c", valid_name, ";\n\n", NIL);
+ Printv(f_wrappers, "swig_class SwigClass", valid_name, ";\n\n", NIL);
Printv(klass->init, "\n", tab4, NIL);
if (!useGlobalModule) {
@@ -2463,7 +2473,7 @@ public:
SwigType_add_pointer(tt);
SwigType_remember(tt);
String *tm = SwigType_manglestr(tt);
- Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &c%s);\n", tm, valid_name);
+ Printf(klass->init, "SWIG_TypeClientData(SWIGTYPE%s, (void *) &SwigClass%s);\n", tm, valid_name);
Delete(tm);
Delete(tt);
Delete(valid_name);
@@ -2564,7 +2574,7 @@ public:
/* First wrap the allocate method */
current = CONSTRUCTOR_ALLOCATE;
- Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate");
+ Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
Language::constructorHandler(n);
@@ -2599,7 +2609,7 @@ public:
Delete(docs);
current = CONSTRUCTOR_INITIALIZE;
- Swig_name_register((String_or_char *) "construct", (String_or_char *) "new_%c");
+ Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "new_%c");
Language::constructorHandler(n);
/* Restore original parameter list */
@@ -2607,7 +2617,7 @@ public:
Swig_restore(n);
/* Done */
- Swig_name_unregister((String_or_char *) "construct");
+ Swig_name_unregister((const_String_or_char_ptr ) "construct");
current = NO_CPP;
klass->constructor_defined = 1;
return SWIG_OK;
@@ -2621,7 +2631,7 @@ public:
/* First wrap the allocate method */
current = CONSTRUCTOR_ALLOCATE;
- Swig_name_register((String_or_char *) "construct", (String_or_char *) "%c_allocate");
+ Swig_name_register((const_String_or_char_ptr ) "construct", (const_String_or_char_ptr ) "%c_allocate");
return Language::copyconstructorHandler(n);
}
@@ -3235,11 +3245,6 @@ public:
Setattr(n, "type", return_type);
tm = Swig_typemap_lookup("directorout", n, "result", w);
Setattr(n, "type", type);
- if (tm == 0) {
- String *name = NewString("result");
- tm = Swig_typemap_search("directorout", return_type, name, NULL);
- Delete(name);
- }
if (tm != 0) {
if (outputs > 1 && !asvoid ) {
Printf(w->code, "output = rb_ary_entry(result, %d);\n", idx++);
diff --git a/Source/Modules/s-exp.cxx b/Source/Modules/s-exp.cxx
index b89b3097f..90791ec70 100644
--- a/Source/Modules/s-exp.cxx
+++ b/Source/Modules/s-exp.cxx
@@ -29,6 +29,9 @@ public:
}
virtual void main(int argc, char *argv[]) {
+ // Add a symbol to the parser for conditional compilation
+ Preprocessor_define("SWIGSEXP 1", 0);
+
SWIG_typemap_lang("sexp");
for (int iX = 0; iX < argc; iX++) {
if (strcmp(argv[iX], "-typemaplang") == 0) {
@@ -42,9 +45,6 @@ public:
fputs(usage, stdout);
}
}
-
- // Add a symbol to the parser for conditional compilation
- Preprocessor_define("SWIGSEXP 1", 0);
}
DOHHash *print_circle_hash;
@@ -59,7 +59,7 @@ public:
String *outfile = Getattr(n, "outfile");
Replaceall(outfile, "_wrap.cxx", ".lisp");
Replaceall(outfile, "_wrap.c", ".lisp");
- out = NewFile(outfile, "w");
+ out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
@@ -68,10 +68,14 @@ public:
String *f_sink = NewString("");
Swig_register_filebyname("header", f_sink);
Swig_register_filebyname("wrapper", f_sink);
+ Swig_register_filebyname("begin", f_sink);
Swig_register_filebyname("runtime", f_sink);
Swig_register_filebyname("init", f_sink);
+ Swig_banner_target_lang(out, ";;;");
+
Language::top(n);
+ Printf(out, "\n");
Printf(out, ";;; Lisp parse tree produced by SWIG\n");
print_circle_hash = DohNewHash();
print_circle_count = 0;
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index b2d9bf575..4800201ca 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -32,8 +32,8 @@ extern "C" {
Language *swig_modula3(void);
Language *swig_mzscheme(void);
Language *swig_java(void);
+ Language *swig_php(void);
Language *swig_php4(void);
- Language *swig_php5(void);
Language *swig_ocaml(void);
Language *swig_octave(void);
Language *swig_pike(void);
@@ -76,9 +76,9 @@ static swig_module modules[] = {
{"-octave", swig_octave, "Octave"},
{"-perl", swig_perl5, "Perl"},
{"-perl5", swig_perl5, 0},
- {"-php", swig_php5, 0},
+ {"-php", swig_php, "PHP"},
{"-php4", swig_php4, 0},
- {"-php5", swig_php5, "PHP5"},
+ {"-php5", swig_php, 0},
{"-pike", swig_pike, "Pike"},
{"-python", swig_python, "Python"},
{"-r", swig_r, "R (aka GNU S)"},
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 5835c6362..8dec8d0af 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -26,7 +26,7 @@ typedef int bool;
#define PLAIN_VIRTUAL 1
#define PURE_VIRTUAL 2
-extern char *input_file;
+extern String *input_file;
extern int line_number;
extern int start_line;
extern int CPlusPlus; // C++ mode
@@ -114,8 +114,8 @@ protected:
class Language:public Dispatcher {
public:
- Language ();
- virtual ~ Language ();
+ Language();
+ virtual ~Language();
virtual int emit_one(Node *n);
/* Parse command line options */
@@ -313,10 +313,13 @@ int SWIG_main(int, char **, Language *);
void emit_parameter_variables(ParmList *l, Wrapper *f);
void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
void SWIG_exit(int); /* use EXIT_{SUCCESS,FAILURE} */
-void SWIG_config_file(const String_or_char *);
+void SWIG_config_file(const_String_or_char_ptr );
const String *SWIG_output_directory();
void SWIG_config_cppext(const char *ext);
+/* get the list of generated files */
+List *SWIG_output_files();
+
void SWIG_library_directory(const char *);
int emit_num_arguments(ParmList *);
int emit_num_required(ParmList *);
@@ -326,17 +329,17 @@ void emit_mark_varargs(ParmList *l);
String *emit_action(Node *n);
int emit_action_code(Node *n, String *wrappercode, String *action);
void Swig_overload_check(Node *n);
-String *Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *);
-String *Swig_overload_dispatch_cast(Node *n, const String_or_char *fmt, int *);
-String *Swig_overload_dispatch_fast(Node *n, const String_or_char *fmt, int *);
+String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *);
+String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *);
+String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *);
SwigType *cplus_value_type(SwigType *t);
/* directors.cxx start */
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
String *Swig_class_declaration(Node *n, String *name);
String *Swig_class_name(Node *n);
-String *Swig_method_call(String_or_char *name, ParmList *parms);
-String *Swig_method_decl(SwigType *rtype, SwigType *decl, const String_or_char *id, List *args, int strip, int values);
+String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
+String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values);
String *Swig_director_declaration(Node *n);
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
/* directors.cxx end */
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index 09bd266c3..015ac5e45 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -46,6 +46,7 @@ static int nosafe = 0;
static File *f_header = 0;
static File *f_wrappers = 0;
static File *f_init = 0;
+static File *f_begin = 0;
static File *f_runtime = 0;
@@ -121,6 +122,7 @@ public:
}
Preprocessor_define("SWIGTCL 1", 0);
+ // SWIGTCL8 is deprecated, and no longer documented.
Preprocessor_define("SWIGTCL8 1", 0);
SWIG_typemap_lang("tcl8");
SWIG_config_file("tcl8.swg");
@@ -136,11 +138,12 @@ public:
/* Initialize all of the output files */
String *outfile = Getattr(n, "outfile");
- f_runtime = NewFile(outfile, "w");
- if (!f_runtime) {
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
+ f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
@@ -148,6 +151,7 @@ public:
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
@@ -158,7 +162,11 @@ public:
methods_tab = NewString("");
const_tab = NewString("");
- Swig_banner(f_runtime);
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGTCL\n");
+ Printf(f_runtime, "\n");
/* Set the module name, namespace, and prefix */
@@ -177,7 +185,7 @@ public:
Insert(module, 0, "_");
- if ((f_shadow = NewFile(filen, "w")) == 0) {
+ if ((f_shadow = NewFile(filen, "w", SWIG_output_files())) == 0) {
FileErrorDisplay(filen);
SWIG_exit(EXIT_FAILURE);
}
@@ -186,10 +194,7 @@ public:
Swig_register_filebyname("shadow", f_shadow);
Swig_register_filebyname("itcl", f_shadow);
- Printf(f_shadow, "# This file was automatically generated by SWIG (http://www.swig.org).\n");
- Printf(f_shadow, "# Version %s\n", Swig_package_version());
- Printf(f_shadow, "#\n");
- Printf(f_shadow, "# Don't modify this file, modify the SWIG interface instead.\n");
+ Swig_banner_target_lang(f_shadow, "#");
Printv(f_shadow, "\npackage require Itcl\n\n", NIL);
Delete(filen);
@@ -244,12 +249,15 @@ public:
}
/* Close all of the files */
- Printv(f_runtime, f_header, f_wrappers, NIL);
- Wrapper_pretty_print(f_init, f_runtime);
+ Dump(f_runtime, f_begin);
+ Printv(f_begin, f_header, f_wrappers, NIL);
+ Wrapper_pretty_print(f_init, f_begin);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
- Close(f_runtime);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
return SWIG_OK;
}
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index d663aed6e..9b42bc1a3 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -730,6 +730,49 @@ class TypePass:private Dispatcher {
}
Setattr(n, "enumtype", enumtype);
+ // This block of code is for dealing with %ignore on an enum item where the target language
+ // attempts to use the C enum value in the target language itself and expects the previous enum value
+ // to be one more than the previous value... the previous enum item might not exist if it is ignored!
+ // - It sets the first non-ignored enum item with the "firstenumitem" attribute.
+ // - It adds an enumvalue attribute if the previous enum item is ignored
+ {
+ Node *c;
+ int count = 0;
+ String *previous = 0;
+ bool previous_ignored = false;
+ bool firstenumitem = false;
+ for (c = firstChild(n); c; c = nextSibling(c)) {
+ assert(strcmp(Char(nodeType(c)), "enumitem") == 0);
+
+ bool reset;
+ String *enumvalue = Getattr(c, "enumvalue");
+ if (GetFlag(c, "feature:ignore")) {
+ reset = enumvalue ? true : false;
+ previous_ignored = true;
+ } else {
+ if (!enumvalue && previous_ignored) {
+ if (previous)
+ Setattr(c, "enumvalue", NewStringf("(%s) + %d", previous, count+1));
+ else
+ Setattr(c, "enumvalue", NewStringf("%d", count));
+ SetFlag(c, "virtenumvalue"); // identify enumvalue as virtual, ie not from the parsed source
+ }
+ if (!firstenumitem) {
+ SetFlag(c, "firstenumitem");
+ firstenumitem = true;
+ }
+ reset = true;
+ previous_ignored = false;
+ }
+ if (reset) {
+ previous = enumvalue ? enumvalue : Getattr(c, "name");
+ count = 0;
+ } else {
+ count++;
+ }
+ }
+ }
+
emit_children(n);
return SWIG_OK;
}
@@ -753,13 +796,16 @@ class TypePass:private Dispatcher {
Setattr(n, "value", new_value);
Delete(new_value);
}
- // Make up an enumvalue if one was not specified in the parsed code
- if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set
- Setattr(n, "enumvalueex", "0");
- }
Node *next = nextSibling(n);
- if (next && !Getattr(next, "enumvalue")) {
- Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
+
+ // Make up an enumvalue if one was not specified in the parsed code (not designed to be used on enum items and %ignore - enumvalue will be set instead)
+ if (!GetFlag(n, "feature:ignore")) {
+ if (Getattr(n, "_last") && !Getattr(n, "enumvalue")) { // Only the first enum item has _last set (Note: first non-ignored enum item has firstenumitem set)
+ Setattr(n, "enumvalueex", "0");
+ }
+ if (next && !Getattr(next, "enumvalue")) {
+ Setattr(next, "enumvalueex", NewStringf("%s + 1", Getattr(n, "sym:name")));
+ }
}
return SWIG_OK;
diff --git a/Source/Modules/uffi.cxx b/Source/Modules/uffi.cxx
index 7a94b77bb..d3f8401f0 100644
--- a/Source/Modules/uffi.cxx
+++ b/Source/Modules/uffi.cxx
@@ -26,7 +26,6 @@ public:
};
static File *f_cl = 0;
-static File *f_null = 0;
static struct {
int count;
@@ -132,7 +131,7 @@ static void add_defined_foreign_type(String *type) {
}
-static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
+static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
@@ -168,7 +167,7 @@ static String *get_ffi_type(SwigType *ty, const String_or_char *name) {
return 0;
}
-static String *get_lisp_type(SwigType *ty, const String_or_char *name) {
+static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
@@ -181,6 +180,7 @@ static String *get_lisp_type(SwigType *ty, const String_or_char *name) {
void UFFI::main(int argc, char *argv[]) {
int i;
+ Preprocessor_define("SWIGUFFI 1", 0);
SWIG_library_directory("uffi");
SWIG_config_file("uffi.swg");
@@ -225,31 +225,26 @@ void UFFI::main(int argc, char *argv[]) {
int UFFI::top(Node *n) {
String *module = Getattr(n, "name");
String *output_filename = NewString("");
- String *devnull = NewString("/dev/null");
-
- f_null = NewFile(devnull, "w+");
- if (!f_null) {
- FileErrorDisplay(devnull);
- SWIG_exit(EXIT_FAILURE);
- }
- Delete(devnull);
-
+ File *f_null = NewString("");
Printf(output_filename, "%s%s.cl", SWIG_output_directory(), module);
- f_cl = NewFile(output_filename, "w");
+ f_cl = NewFile(output_filename, "w", SWIG_output_files());
if (!f_cl) {
FileErrorDisplay(output_filename);
SWIG_exit(EXIT_FAILURE);
}
Swig_register_filebyname("header", f_null);
+ Swig_register_filebyname("begin", f_null);
Swig_register_filebyname("runtime", f_null);
Swig_register_filebyname("wrapper", f_cl);
- Printf(f_cl,
- ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n;; This is an automatically generated file. Make changes in\n;; the definition file, not here.\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
+ Swig_banner_target_lang(f_cl, ";;");
+
+ Printf(f_cl, "\n"
+ ";; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; package: %s -*-\n\n(defpackage :%s\n (:use :common-lisp :uffi))\n\n(in-package :%s)\n",
module, module, module);
Printf(f_cl, "(eval-when (compile load eval)\n (defparameter *swig-identifier-converter* '%s))\n", identifier_converter);
diff --git a/Source/Modules/xml.cxx b/Source/Modules/xml.cxx
index c74b48d7c..2edd01cf0 100644
--- a/Source/Modules/xml.cxx
+++ b/Source/Modules/xml.cxx
@@ -47,7 +47,7 @@ public:
iX++;
Swig_mark_arg(iX);
String *outfile = NewString(argv[iX]);
- out = NewFile(outfile, "w");
+ out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
@@ -82,7 +82,7 @@ public:
Replaceall(outfile, ".cxx", ".xml");
Replaceall(outfile, ".cpp", ".xml");
Replaceall(outfile, ".c", ".xml");
- out = NewFile(outfile, "w");
+ out = NewFile(outfile, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
@@ -301,7 +301,7 @@ void Swig_print_xml(DOH *obj, String *filename) {
if (!filename) {
out = stdout;
} else {
- out = NewFile(filename, "w");
+ out = NewFile(filename, "w", SWIG_output_files());
if (!out) {
FileErrorDisplay(filename);
SWIG_exit(EXIT_FAILURE);
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index c04f95f00..81646171a 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -74,7 +74,7 @@ static void copy_location(const DOH *s1, DOH *s2) {
Setline(s2, Getline((DOH *) s1));
}
-static String *cpp_include(String_or_char *fn, int sysfile) {
+static String *cpp_include(const_String_or_char_ptr fn, int sysfile) {
String *s = sysfile ? Swig_include_sys(fn) : Swig_include(fn);
if (s && single_include) {
String *file = Getfile(s);
@@ -85,7 +85,8 @@ static String *cpp_include(String_or_char *fn, int sysfile) {
Setattr(included_files, file, file);
}
if (!s) {
- Seek(fn, 0, SEEK_SET);
+ /* XXX(bhy) may not need the seek */
+ /* Seek(fn, 0, SEEK_SET); */
if (ignore_missing) {
Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn);
} else {
@@ -261,8 +262,9 @@ void Preprocessor_error_as_warning(int a) {
* ----------------------------------------------------------------------------- */
-String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) {
- String_or_char *argname, *varargname;
+String *Macro_vararg_name(const_String_or_char_ptr str, const_String_or_char_ptr line) {
+ String *argname;
+ String *varargname;
char *s, *dots;
argname = Copy(str);
@@ -288,24 +290,24 @@ String_or_char *Macro_vararg_name(String_or_char *str, String_or_char *line) {
return varargname;
}
-Hash *Preprocessor_define(const String_or_char *_str, int swigmacro) {
+Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
String *macroname = 0, *argstr = 0, *macrovalue = 0, *file = 0, *s = 0;
Hash *macro = 0, *symbols = 0, *m1;
List *arglist = 0;
int c, line;
int varargs = 0;
- String_or_char *str = (String_or_char *) _str;
+ String *str;
assert(cpp);
- assert(str);
+ assert(_str);
/* First make sure that string is actually a string */
- if (DohCheck(str)) {
- s = Copy(str);
- copy_location(str, s);
+ if (DohCheck(_str)) {
+ s = Copy(_str);
+ copy_location(_str, s);
str = s;
} else {
- str = NewString((char *) str);
+ str = NewString((char *) _str);
}
Seek(str, 0, SEEK_SET);
line = Getline(str);
@@ -532,7 +534,7 @@ macro_error:
*
* Undefines a macro.
* ----------------------------------------------------------------------------- */
-void Preprocessor_undef(const String_or_char *str) {
+void Preprocessor_undef(const_String_or_char_ptr str) {
Hash *symbols;
assert(cpp);
symbols = Getattr(cpp, kpp_symbols);
@@ -650,14 +652,7 @@ static String *get_filename(String *str, int *sysfile) {
if (isspace(c))
Ungetc(c, str);
}
-#if defined(_WIN32) || defined(MACSWIG)
- /* accept Unix path separator on non-Unix systems */
- Replaceall(fn, "/", SWIG_FILE_DELIMITER);
-#endif
-#if defined(__CYGWIN__)
- /* accept Windows path separator in addition to Unix path separator */
- Replaceall(fn, "\\", SWIG_FILE_DELIMITER);
-#endif
+ Swig_filename_correct(fn);
Seek(fn, 0, SEEK_SET);
return fn;
}
diff --git a/Source/Preprocessor/preprocessor.h b/Source/Preprocessor/preprocessor.h
index 4f7ff8804..3579eede2 100644
--- a/Source/Preprocessor/preprocessor.h
+++ b/Source/Preprocessor/preprocessor.h
@@ -19,8 +19,8 @@ extern "C" {
#endif
extern int Preprocessor_expr(String *s, int *error);
extern char *Preprocessor_expr_error(void);
- extern Hash *Preprocessor_define(const String_or_char *str, int swigmacro);
- extern void Preprocessor_undef(const String_or_char *name);
+ extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro);
+ extern void Preprocessor_undef(const_String_or_char_ptr name);
extern void Preprocessor_init(void);
extern void Preprocessor_delete(void);
extern String *Preprocessor_parse(String *s);
diff --git a/Source/README b/Source/README
index 8d910e405..814ec45bd 100644
--- a/Source/README
+++ b/Source/README
@@ -1,9 +1,5 @@
SWIG Source directory
-This directory currently contains a mix of legacy SWIG1.1 code and
-recent development work. As a result, it's still a little messy.
-Here is a rough breakdown of the directories:
-
Source/DOH - A core set of basic datatypes including
strings, lists, hashes, and files. Used
extensively by the rest of SWIG.
@@ -16,8 +12,9 @@ Here is a rough breakdown of the directories:
Source/Modules - Language modules.
+ Source/Include - Include files.
-The following directories may be in CVS, but are largely deprecated:
+Historic directories which may be in CVS, but have been removed:
Source/Modules1.1 - Old SWIG-1.1 modules. Empty.
@@ -26,5 +23,3 @@ The following directories may be in CVS, but are largely deprecated:
Source/SWIG1.1 - Old SWIG1.1 core. Completely empty now.
-
-
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index 18920ecc2..7c6837a2b 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -45,7 +45,7 @@ String *Swig_cparm_name(Parm *p, int i) {
* and user defined types to pointers.
* ----------------------------------------------------------------------------- */
-static String *Swig_clocal(SwigType *t, const String_or_char *name, const String_or_char *value) {
+static String *Swig_clocal(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr value) {
String *decl;
decl = NewStringEmpty();
@@ -147,7 +147,7 @@ String *Swig_wrapped_member_var_type(SwigType *t, int varcref) {
}
-static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int varcref) {
+static String *Swig_wrapped_var_deref(SwigType *t, const_String_or_char_ptr name, int varcref) {
if (SwigType_isclass(t)) {
if (varcref) {
if (cparse_cplusplus) {
@@ -163,7 +163,7 @@ static String *Swig_wrapped_var_deref(SwigType *t, String_or_char *name, int var
}
}
-static String *Swig_wrapped_var_assign(SwigType *t, const String_or_char *name, int varcref) {
+static String *Swig_wrapped_var_assign(SwigType *t, const_String_or_char_ptr name, int varcref) {
if (SwigType_isclass(t)) {
if (varcref) {
return NewStringf("%s", name);
@@ -251,7 +251,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
* function call.
* ----------------------------------------------------------------------------- */
-String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) {
+String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
String *fcall;
fcall = NewStringEmpty();
@@ -260,10 +260,9 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
break;
case T_REFERENCE:
{
- String *str = SwigType_str(t, "_result_ref");
- Printf(fcall, "{\n");
- Printf(fcall, "%s = ", str);
- Delete(str);
+ String *lstr = SwigType_lstr(t, 0);
+ Printf(fcall, "%s = (%s) &", name, lstr);
+ Delete(lstr);
}
break;
case T_USER:
@@ -290,12 +289,6 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
Append(fcall, ";");
}
- if (SwigType_type(t) == T_REFERENCE) {
- String *lstr = SwigType_lstr(t, 0);
- Printf(fcall, "\n%s = (%s) &_result_ref;\n", name, lstr);
- Append(fcall, "}");
- Delete(lstr);
- }
return fcall;
}
@@ -309,7 +302,7 @@ String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_ch
*
* ----------------------------------------------------------------------------- */
-String *Swig_cfunction_call(String_or_char *name, ParmList *parms) {
+String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms) {
String *func;
int i = 0;
int comma = 0;
@@ -376,7 +369,7 @@ String *Swig_cfunction_call(String_or_char *name, ParmList *parms) {
* set to "(*this)->" or some similar sequence.
* ----------------------------------------------------------------------------- */
-static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier, SwigType *director_type) {
+static String *Swig_cmethod_call(const_String_or_char_ptr name, ParmList *parms, const_String_or_char_ptr self, String *explicit_qualifier, SwigType *director_type) {
String *func, *nname;
int i = 0;
Parm *p = parms;
@@ -468,7 +461,7 @@ static String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_o
* calloc(1,sizeof(name));
* ----------------------------------------------------------------------------- */
-String *Swig_cconstructor_call(String_or_char *name) {
+String *Swig_cconstructor_call(const_String_or_char_ptr name) {
DOH *func;
func = NewStringEmpty();
@@ -487,7 +480,7 @@ String *Swig_cconstructor_call(String_or_char *name) {
*
* ----------------------------------------------------------------------------- */
-String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_self) {
+String *Swig_cppconstructor_base_call(const_String_or_char_ptr name, ParmList *parms, int skip_self) {
String *func;
String *nname;
int i = 0;
@@ -532,15 +525,15 @@ String *Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int
return func;
}
-String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms) {
+String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms) {
return Swig_cppconstructor_base_call(name, parms, 0);
}
-String *Swig_cppconstructor_nodirector_call(String_or_char *name, ParmList *parms) {
+String *Swig_cppconstructor_nodirector_call(const_String_or_char_ptr name, ParmList *parms) {
return Swig_cppconstructor_base_call(name, parms, 1);
}
-String *Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) {
+String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmList *parms) {
return Swig_cppconstructor_base_call(name, parms, 0);
}
@@ -683,7 +676,7 @@ String *Swig_cppdestructor_call(Node *n) {
*
* ----------------------------------------------------------------------------- */
-String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref) {
+String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref) {
String *func;
String *pname0 = Swig_cparm_name(0, 0);
String *pname1 = Swig_cparm_name(0, 1);
@@ -718,7 +711,7 @@ String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_cha
*
* ----------------------------------------------------------------------------- */
-String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref) {
+String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref) {
String *func;
String *call;
String *pname0 = Swig_cparm_name(0, 0);
@@ -1210,7 +1203,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
* This function creates a C wrapper for setting a structure member.
* ----------------------------------------------------------------------------- */
-int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
+int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call) {
String *name;
ParmList *parms;
Parm *p;
@@ -1258,23 +1251,21 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
Delete(p);
if (flags & CWRAP_EXTEND) {
- String *call;
String *cres;
String *code = Getattr(n, "code");
if (code) {
/* I don't think this ever gets run - WSF */
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
}
- call = Swig_cfunction_call(mangled, parms);
- cres = NewStringf("%s;", call);
+ *call = Swig_cfunction_call(mangled, parms);
+ cres = NewStringf("%s;", *call);
Setattr(n, "wrap:action", cres);
- Delete(call);
Delete(cres);
} else {
- String *call = Swig_cmemberset_call(name, type, self, varcref);
- String *cres = NewStringf("%s;", call);
+ String *cres;
+ *call = Swig_cmemberset_call(name, type, self, varcref);
+ cres = NewStringf("%s;", *call);
Setattr(n, "wrap:action", cres);
- Delete(call);
Delete(cres);
}
Setattr(n, "type", void_type);
diff --git a/Source/Swig/error.c b/Source/Swig/error.c
index 1eaba1f17..156fe06a7 100644
--- a/Source/Swig/error.c
+++ b/Source/Swig/error.c
@@ -50,7 +50,7 @@ static char wrn_nnum_fmt[64];
static char err_line_fmt[64];
static char err_eof_fmt[64];
-static String *format_filename(const String_or_char *filename);
+static String *format_filename(const_String_or_char_ptr filename);
/* -----------------------------------------------------------------------------
* Swig_warning()
@@ -58,7 +58,7 @@ static String *format_filename(const String_or_char *filename);
* Issue a warning message
* ----------------------------------------------------------------------------- */
-void Swig_warning(int wnum, const String_or_char *filename, int line, const char *fmt, ...) {
+void Swig_warning(int wnum, const_String_or_char_ptr filename, int line, const char *fmt, ...) {
String *out;
char *msg;
int wrn = 1;
@@ -121,7 +121,7 @@ void Swig_warning(int wnum, const String_or_char *filename, int line, const char
* Issue an error message
* ----------------------------------------------------------------------------- */
-void Swig_error(const String_or_char *filename, int line, const char *fmt, ...) {
+void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...) {
va_list ap;
String *formatted_filename = NULL;
@@ -170,7 +170,7 @@ void Swig_error_silent(int s) {
* Takes a comma separate list of warning numbers and puts in the filter.
* ----------------------------------------------------------------------------- */
-void Swig_warnfilter(const String_or_char *wlist, int add) {
+void Swig_warnfilter(const_String_or_char_ptr wlist, int add) {
char *c;
char *cw;
String *s;
@@ -268,7 +268,7 @@ void Swig_error_msg_format(ErrorMessageFormat format) {
*
* Remove double backslashes in Windows filename paths for display
* ----------------------------------------------------------------------------- */
-static String *format_filename(const String_or_char *filename) {
+static String *format_filename(const_String_or_char_ptr filename) {
String *formatted_filename = NewString(filename);
#if defined(_WIN32)
Replaceall(formatted_filename, "\\\\", "\\");
diff --git a/Source/Swig/getopt.c b/Source/Swig/getopt.c
index 87b0f7c9d..cbd051d9f 100644
--- a/Source/Swig/getopt.c
+++ b/Source/Swig/getopt.c
@@ -100,7 +100,7 @@ void Swig_check_options(int check_input) {
* Generates a generic error message and exits.
* ----------------------------------------------------------------------------- */
-void Swig_arg_error() {
+void Swig_arg_error(void) {
Printf(stderr, "SWIG : Unable to parse command line options.\n");
Printf(stderr, "Use 'swig -help' for available options.\n");
exit(1);
diff --git a/Source/Swig/include.c b/Source/Swig/include.c
index 3f47be15b..f42eb5d45 100644
--- a/Source/Swig/include.c
+++ b/Source/Swig/include.c
@@ -33,7 +33,7 @@ int Swig_get_push_dir(void) {
* Adds a directory to the SWIG search path.
* ----------------------------------------------------------------------------- */
-List *Swig_add_directory(const String_or_char *dirname) {
+List *Swig_add_directory(const_String_or_char_ptr dirname) {
String *adirname;
if (!directories)
directories = NewList();
@@ -53,7 +53,7 @@ List *Swig_add_directory(const String_or_char *dirname) {
* the preprocessor to grab files in the same directory as other included files.
* ----------------------------------------------------------------------------- */
-void Swig_push_directory(const String_or_char *dirname) {
+void Swig_push_directory(const_String_or_char_ptr dirname) {
String *pdirname;
if (!Swig_get_push_dir())
return;
@@ -73,7 +73,7 @@ void Swig_push_directory(const String_or_char *dirname) {
* the preprocessor.
* ----------------------------------------------------------------------------- */
-void Swig_pop_directory() {
+void Swig_pop_directory(void) {
if (!Swig_get_push_dir())
return;
if (!pdirectories)
@@ -87,13 +87,13 @@ void Swig_pop_directory() {
* Returns the full pathname of the last file opened.
* ----------------------------------------------------------------------------- */
-String *Swig_last_file() {
+String *Swig_last_file(void) {
assert(lastpath);
return lastpath;
}
/* -----------------------------------------------------------------------------
- * Swig_search_path()
+ * Swig_search_path_any()
*
* Returns a list of the current search paths.
* ----------------------------------------------------------------------------- */
@@ -151,10 +151,11 @@ List *Swig_search_path() {
/* -----------------------------------------------------------------------------
* Swig_open()
*
- * Looks for a file and open it. Returns an open FILE * on success.
+ * open a file, optionally looking for it in the include path. Returns an open
+ * FILE * on success.
* ----------------------------------------------------------------------------- */
-static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
+static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_include_path) {
FILE *f;
String *filename;
List *spath = 0;
@@ -169,7 +170,7 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
filename = NewString(cname);
assert(filename);
f = fopen(Char(filename), "r");
- if (!f) {
+ if (!f && use_include_path) {
spath = Swig_search_path_any(sysfile);
ilen = Len(spath);
for (i = 0; i < ilen; i++) {
@@ -182,19 +183,21 @@ static FILE *Swig_open_any(const String_or_char *name, int sysfile) {
Delete(spath);
}
if (f) {
-#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
- Replaceall(filename, "\\\\", "\\"); /* remove double '\' in case any already present */
- Replaceall(filename, "\\", "\\\\");
-#endif
Delete(lastpath);
- lastpath = Copy(filename);
+ lastpath = Swig_filename_escape(filename);
}
Delete(filename);
return f;
}
-FILE *Swig_open(const String_or_char *name) {
- return Swig_open_any(name, 0);
+/* Open a file - searching the include paths to find it */
+FILE *Swig_include_open(const_String_or_char_ptr name) {
+ return Swig_open_file(name, 0, 1);
+}
+
+/* Open a file - does not use include paths to find it */
+FILE *Swig_open(const_String_or_char_ptr name) {
+ return Swig_open_file(name, 0, 0);
}
@@ -230,12 +233,12 @@ String *Swig_read_file(FILE *f) {
* Opens a file and returns it as a string.
* ----------------------------------------------------------------------------- */
-static String *Swig_include_any(const String_or_char *name, int sysfile) {
+static String *Swig_include_any(const_String_or_char_ptr name, int sysfile) {
FILE *f;
String *str;
String *file;
- f = Swig_open_any(name, sysfile);
+ f = Swig_open_file(name, sysfile, 1);
if (!f)
return 0;
str = Swig_read_file(f);
@@ -248,11 +251,11 @@ static String *Swig_include_any(const String_or_char *name, int sysfile) {
return str;
}
-String *Swig_include(const String_or_char *name) {
+String *Swig_include(const_String_or_char_ptr name) {
return Swig_include_any(name, 0);
}
-String *Swig_include_sys(const String_or_char *name) {
+String *Swig_include_sys(const_String_or_char_ptr name) {
return Swig_include_any(name, 1);
}
@@ -262,10 +265,10 @@ String *Swig_include_sys(const String_or_char *name) {
* Copies the contents of a file into another file
* ----------------------------------------------------------------------------- */
-int Swig_insert_file(const String_or_char *filename, File *outfile) {
+int Swig_insert_file(const_String_or_char_ptr filename, File *outfile) {
char buffer[4096];
int nbytes;
- FILE *f = Swig_open(filename);
+ FILE *f = Swig_include_open(filename);
if (!f)
return -1;
@@ -286,7 +289,7 @@ int Swig_insert_file(const String_or_char *filename, File *outfile) {
static Hash *named_files = 0;
-void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
+void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile) {
if (!named_files)
named_files = NewHash();
Setattr(named_files, filename, outfile);
@@ -298,7 +301,7 @@ void Swig_register_filebyname(const String_or_char *filename, File *outfile) {
* Get a named file
* ----------------------------------------------------------------------------- */
-File *Swig_filebyname(const String_or_char *filename) {
+File *Swig_filebyname(const_String_or_char_ptr filename) {
if (!named_files)
return 0;
return Getattr(named_files, filename);
@@ -310,7 +313,7 @@ File *Swig_filebyname(const String_or_char *filename) {
* Returns the suffix of a file
* ----------------------------------------------------------------------------- */
-char *Swig_file_suffix(const String_or_char *filename) {
+char *Swig_file_suffix(const_String_or_char_ptr filename) {
char *d;
char *c = Char(filename);
int len = Len(filename);
@@ -332,7 +335,7 @@ char *Swig_file_suffix(const String_or_char *filename) {
* Returns the filename with no suffix attached.
* ----------------------------------------------------------------------------- */
-char *Swig_file_basename(const String_or_char *filename) {
+char *Swig_file_basename(const_String_or_char_ptr filename) {
static char tmp[1024];
char *c;
strcpy(tmp, Char(filename));
@@ -346,7 +349,7 @@ char *Swig_file_basename(const String_or_char *filename) {
*
* Return the file with any leading path stripped off
* ----------------------------------------------------------------------------- */
-char *Swig_file_filename(const String_or_char *filename) {
+char *Swig_file_filename(const_String_or_char_ptr filename) {
static char tmp[1024];
const char *delim = SWIG_FILE_DELIMITER;
char *c;
@@ -364,7 +367,7 @@ char *Swig_file_filename(const String_or_char *filename) {
*
* Return the name of the directory associated with a file
* ----------------------------------------------------------------------------- */
-char *Swig_file_dirname(const String_or_char *filename) {
+char *Swig_file_dirname(const_String_or_char_ptr filename) {
static char tmp[1024];
const char *delim = SWIG_FILE_DELIMITER;
char *c;
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index d29250517..050e5357a 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -54,7 +54,7 @@ const char *Swig_package_version(void) {
/* -----------------------------------------------------------------------------
* Swig_banner()
*
- * Emits the SWIG identifying banner.
+ * Emits the SWIG identifying banner for the C/C++ wrapper file.
* ----------------------------------------------------------------------------- */
void Swig_banner(File *f) {
@@ -67,11 +67,25 @@ void Swig_banner(File *f) {
* changes to this file unless you know what you are doing--modify the SWIG \n\
* interface file instead. \n", Swig_package_version());
/* String too long for ISO compliance */
- Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
+ Printf(f, " * ----------------------------------------------------------------------------- */\n");
}
/* -----------------------------------------------------------------------------
+ * Swig_banner_target_lang()
+ *
+ * Emits a SWIG identifying banner in the target language
+ * ----------------------------------------------------------------------------- */
+
+void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar) {
+ Printf(f, "%s This file was automatically generated by SWIG (http://www.swig.org).\n", commentchar);
+ Printf(f, "%s Version %s\n", commentchar, Swig_package_version());
+ Printf(f, "%s\n", commentchar);
+ Printf(f, "%s Do not make changes to this file unless you know what you are doing--modify\n", commentchar);
+ Printf(f, "%s the SWIG interface file instead.\n", commentchar);
+}
+
+/* -----------------------------------------------------------------------------
* Swig_strip_c_comments()
*
* Return a new string with C comments stripped from the input string. Null is
@@ -118,6 +132,39 @@ String *Swig_strip_c_comments(const String *s) {
/* -----------------------------------------------------------------------------
+ * Swig_filename_correct()
+ *
+ * Corrects filenames on non-unix systems
+ * ----------------------------------------------------------------------------- */
+
+void Swig_filename_correct(String *filename) {
+ (void)filename;
+#if defined(_WIN32) || defined(MACSWIG)
+ /* accept Unix path separator on non-Unix systems */
+ Replaceall(filename, "/", SWIG_FILE_DELIMITER);
+#endif
+#if defined(__CYGWIN__)
+ /* accept Windows path separator in addition to Unix path separator */
+ Replaceall(filename, "\\", SWIG_FILE_DELIMITER);
+#endif
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_filename_escape()
+ *
+ * Escapes backslashes in filename - for Windows
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_filename_escape(String *filename) {
+ String *adjusted_filename = Copy(filename);
+#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
+ Replaceall(adjusted_filename, "\\\\", "\\"); /* remove double '\' in case any already present */
+ Replaceall(adjusted_filename, "\\", "\\\\");
+#endif
+ return adjusted_filename;
+}
+
+/* -----------------------------------------------------------------------------
* Swig_string_escape()
*
* Takes a string object and produces a string with escape codes added to it.
@@ -604,7 +651,7 @@ String *Swig_string_emangle(String *s) {
* In this case, "A::B". Returns NULL if there is no base.
* ----------------------------------------------------------------------------- */
-void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
+void Swig_scopename_split(const String *s, String **rprefix, String **rlast) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
@@ -658,7 +705,7 @@ void Swig_scopename_split(String *s, String **rprefix, String **rlast) {
}
-String *Swig_scopename_prefix(String *s) {
+String *Swig_scopename_prefix(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
@@ -710,7 +757,7 @@ String *Swig_scopename_prefix(String *s) {
* case, "C".
* ----------------------------------------------------------------------------- */
-String *Swig_scopename_last(String *s) {
+String *Swig_scopename_last(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *cc = c;
@@ -754,7 +801,7 @@ String *Swig_scopename_last(String *s) {
* In this case, "A". Returns NULL if there is no base.
* ----------------------------------------------------------------------------- */
-String *Swig_scopename_first(String *s) {
+String *Swig_scopename_first(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *co = 0;
@@ -804,7 +851,7 @@ String *Swig_scopename_first(String *s) {
* In this case, "B::C". Returns NULL if there is no suffix.
* ----------------------------------------------------------------------------- */
-String *Swig_scopename_suffix(String *s) {
+String *Swig_scopename_suffix(const String *s) {
char *tmp = Char(s);
char *c = tmp;
char *co = 0;
@@ -848,7 +895,7 @@ String *Swig_scopename_suffix(String *s) {
* Checks to see if a name is qualified with a scope name
* ----------------------------------------------------------------------------- */
-int Swig_scopename_check(String *s) {
+int Swig_scopename_check(const String *s) {
char *c = Char(s);
char *co = strstr(c, "operator ");
@@ -927,6 +974,37 @@ String *Swig_string_command(String *s) {
/* -----------------------------------------------------------------------------
+ * Swig_string_strip()
+ *
+ * Strip given prefix from identifiers
+ *
+ * Printf(stderr,"%(strip:[wx])s","wxHello") -> Hello
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_string_strip(String *s) {
+ String *ns;
+ if (!Len(s)) {
+ ns = NewString(s);
+ } else {
+ const char *cs = Char(s);
+ const char *ce = Strchr(cs, ']');
+ if (*cs != '[' || ce == NULL) {
+ ns = NewString(s);
+ } else {
+ String *fmt = NewStringf("%%.%ds", ce-cs-1);
+ String *prefix = NewStringf(fmt, cs+1);
+ if (0 == Strncmp(ce+1, prefix, Len(prefix))) {
+ ns = NewString(ce+1+Len(prefix));
+ } else {
+ ns = NewString(ce+1);
+ }
+ }
+ }
+ return ns;
+}
+
+
+/* -----------------------------------------------------------------------------
* Swig_string_rxspencer()
*
* Executes a regexp substitution via the RxSpencer library. For example:
@@ -1053,6 +1131,7 @@ void Swig_init() {
DohEncoding("command", Swig_string_command);
DohEncoding("rxspencer", Swig_string_rxspencer);
DohEncoding("schemify", Swig_string_schemify);
+ DohEncoding("strip", Swig_string_strip);
/* aliases for the case encoders */
DohEncoding("uppercase", Swig_string_upper);
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index f34a24612..013ce5929 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -27,13 +27,13 @@ static Hash *naming_hash = 0;
* Register a new naming format.
* ----------------------------------------------------------------------------- */
-void Swig_name_register(const String_or_char *method, const String_or_char *format) {
+void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format) {
if (!naming_hash)
naming_hash = NewHash();
Setattr(naming_hash, method, format);
}
-void Swig_name_unregister(const String_or_char *method) {
+void Swig_name_unregister(const_String_or_char_ptr method) {
if (naming_hash) {
Delattr(naming_hash, method);
}
@@ -127,7 +127,7 @@ static int name_mangle(String *r) {
* Converts all of the non-identifier characters of a string to underscores.
* ----------------------------------------------------------------------------- */
-String *Swig_name_mangle(const String_or_char *s) {
+String *Swig_name_mangle(const_String_or_char_ptr s) {
#if 0
String *r = NewString(s);
name_mangle(r);
@@ -143,7 +143,7 @@ String *Swig_name_mangle(const String_or_char *s) {
* Returns the name of a wrapper function.
* ----------------------------------------------------------------------------- */
-String *Swig_name_wrapper(const String_or_char *fname) {
+String *Swig_name_wrapper(const_String_or_char_ptr fname) {
String *r;
String *f;
@@ -168,7 +168,7 @@ String *Swig_name_wrapper(const String_or_char *fname) {
* Returns the name of a class method.
* ----------------------------------------------------------------------------- */
-String *Swig_name_member(const String_or_char *classname, const String_or_char *mname) {
+String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname) {
String *r;
String *f;
String *rclassname;
@@ -201,7 +201,7 @@ String *Swig_name_member(const String_or_char *classname, const String_or_char *
* Returns the name of the accessor function used to get a variable.
* ----------------------------------------------------------------------------- */
-String *Swig_name_get(const String_or_char *vname) {
+String *Swig_name_get(const_String_or_char_ptr vname) {
String *r;
String *f;
@@ -229,7 +229,7 @@ String *Swig_name_get(const String_or_char *vname) {
* Returns the name of the accessor function used to set a variable.
* ----------------------------------------------------------------------------- */
-String *Swig_name_set(const String_or_char *vname) {
+String *Swig_name_set(const_String_or_char_ptr vname) {
String *r;
String *f;
@@ -253,7 +253,7 @@ String *Swig_name_set(const String_or_char *vname) {
* Returns the name of the accessor function used to create an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_construct(const String_or_char *classname) {
+String *Swig_name_construct(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -286,7 +286,7 @@ String *Swig_name_construct(const String_or_char *classname) {
* Returns the name of the accessor function used to copy an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_copyconstructor(const String_or_char *classname) {
+String *Swig_name_copyconstructor(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -319,7 +319,7 @@ String *Swig_name_copyconstructor(const String_or_char *classname) {
* Returns the name of the accessor function used to destroy an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_destroy(const String_or_char *classname) {
+String *Swig_name_destroy(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -351,7 +351,7 @@ String *Swig_name_destroy(const String_or_char *classname) {
* Returns the name of the accessor function used to disown an object.
* ----------------------------------------------------------------------------- */
-String *Swig_name_disown(const String_or_char *classname) {
+String *Swig_name_disown(const_String_or_char_ptr classname) {
String *r;
String *f;
String *rclassname;
@@ -600,7 +600,7 @@ static void merge_features(Hash *features, Node *n) {
* ----------------------------------------------------------------------------- */
static
-void features_get(Hash *features, String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
+void features_get(Hash *features, const String *tname, SwigType *decl, SwigType *ncdecl, Node *node) {
Node *n = Getattr(features, tname);
#ifdef SWIG_DEBUG
Printf(stdout, " features_get: %s\n", tname);
@@ -655,7 +655,7 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
}
#ifdef SWIG_DEBUG
- Printf(stdout, "Swig_features_get: %s %s %s\n", prefix, name, decl);
+ Printf(stdout, "Swig_features_get: '%s' '%s' '%s'\n", prefix, name, decl);
#endif
/* Global features */
@@ -727,12 +727,12 @@ void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *d
* concatenating the feature name plus ':' plus the attribute name.
* ----------------------------------------------------------------------------- */
-void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs) {
+void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs) {
Hash *n;
Hash *fhash;
#ifdef SWIG_DEBUG
- Printf(stdout, "Swig_feature_set: %s %s %s %s\n", name, decl, featurename, value);
+ Printf(stdout, "Swig_feature_set: '%s' '%s' '%s' '%s'\n", name, decl, featurename, value);
#endif
n = Getattr(features, name);
@@ -1436,7 +1436,7 @@ static String *apply_rename(String *newname, int fullname, String *prefix, Strin
*
* ----------------------------------------------------------------------------- */
-String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname) {
+String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname) {
String *nname = 0;
String *result = 0;
String *name = NewString(cname);
diff --git a/Source/Swig/parms.c b/Source/Swig/parms.c
index baa1dfbf3..9b58f5fcb 100644
--- a/Source/Swig/parms.c
+++ b/Source/Swig/parms.c
@@ -17,7 +17,7 @@ char cvsroot_parms_c[] = "$Id$";
* Create a new parameter from datatype 'type' and name 'name'.
* ------------------------------------------------------------------------ */
-Parm *NewParm(SwigType *type, const String_or_char *name) {
+Parm *NewParm(SwigType *type, const_String_or_char_ptr name) {
Parm *p = NewHash();
set_nodeType(p, "parm");
if (type) {
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 06e78db37..53f1ad4a0 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -15,6 +15,9 @@ char cvsroot_scanner_c[] = "$Id$";
#include "swig.h"
#include <ctype.h>
+extern String *cparse_file;
+extern int cparse_start_line;
+
struct Scanner {
String *text; /* Current token value */
List *scanobjs; /* Objects being scanned */
@@ -36,7 +39,7 @@ struct Scanner {
* Create a new scanner object
* ----------------------------------------------------------------------------- */
-Scanner *NewScanner() {
+Scanner *NewScanner(void) {
Scanner *s;
s = (Scanner *) malloc(sizeof(Scanner));
s->line = 1;
@@ -115,11 +118,11 @@ void Scanner_push(Scanner * s, String *txt) {
* call to Scanner_token().
* ----------------------------------------------------------------------------- */
-void Scanner_pushtoken(Scanner * s, int nt, const String_or_char *val) {
+void Scanner_pushtoken(Scanner * s, int nt, const_String_or_char_ptr val) {
assert(s);
assert((nt >= 0) && (nt < SWIG_MAXTOKENS));
s->nexttoken = nt;
- if (val != s->text) {
+ if ( Char(val) != Char(s->text) ) {
Clear(s->text);
Append(s->text,val);
}
@@ -209,7 +212,7 @@ static char nextchar(Scanner * s) {
* Sets error information on the scanner.
* ----------------------------------------------------------------------------- */
-static void set_error(Scanner *s, int line, String_or_char *msg) {
+static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) {
s->error_line = line;
s->error = NewString(msg);
}
@@ -536,7 +539,7 @@ static int look(Scanner * s) {
break;
case 10: /* C++ style comment */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated comment");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n");
return SWIG_TOKEN_ERROR;
}
if (c == '\n') {
@@ -548,7 +551,7 @@ static int look(Scanner * s) {
break;
case 11: /* C style comment block */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated comment");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n");
return SWIG_TOKEN_ERROR;
}
if (c == '*') {
@@ -559,7 +562,7 @@ static int look(Scanner * s) {
break;
case 12: /* Still in C style comment */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated comment");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated comment\n");
return SWIG_TOKEN_ERROR;
}
if (c == '*') {
@@ -573,7 +576,7 @@ static int look(Scanner * s) {
case 2: /* Processing a string */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line, "Unterminated string");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated string\n");
return SWIG_TOKEN_ERROR;
}
if (c == '\"') {
@@ -656,7 +659,7 @@ static int look(Scanner * s) {
case 40: /* Process an include block */
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated code block");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated block\n");
return SWIG_TOKEN_ERROR;
}
if (c == '%')
@@ -933,7 +936,7 @@ static int look(Scanner * s) {
/* A character constant */
case 9:
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated character constant");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n");
return SWIG_TOKEN_ERROR;
}
if (c == '\'') {
@@ -1048,7 +1051,7 @@ static int look(Scanner * s) {
/* Reverse string */
case 900:
if ((c = nextchar(s)) == 0) {
- set_error(s,s->start_line,"Unterminated character constant");
+ Swig_error(cparse_file, cparse_start_line, "Unterminated character constant\n");
return SWIG_TOKEN_ERROR;
}
if (c == '`') {
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index 5ffd28eec..8a7700bec 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -537,7 +537,7 @@ String *SwigType_namestr(const SwigType *t) {
* Create a C string representation of a datatype.
* ----------------------------------------------------------------------------- */
-String *SwigType_str(SwigType *s, const String_or_char *id) {
+String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
String *result;
String *element = 0, *nextelement;
List *elements;
@@ -732,7 +732,7 @@ SwigType *SwigType_ltype(SwigType *s) {
* with an equivalent assignable version.
* -------------------------------------------------------------------- */
-String *SwigType_lstr(SwigType *s, const String_or_char *id) {
+String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
String *result;
SwigType *tc;
@@ -749,7 +749,7 @@ String *SwigType_lstr(SwigType *s, const String_or_char *id) {
* datatype printed by str().
* ----------------------------------------------------------------------------- */
-String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
+String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
String *result, *cast;
String *element = 0, *nextelement;
SwigType *td, *rs, *tc = 0;
@@ -892,7 +892,7 @@ String *SwigType_rcaststr(SwigType *s, const String_or_char *name) {
* Casts a variable from the real type to the local datatype.
* ----------------------------------------------------------------------------- */
-String *SwigType_lcaststr(SwigType *s, const String_or_char *name) {
+String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
String *result;
result = NewStringEmpty();
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 451de86c4..2b2c797c9 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -110,15 +110,15 @@ extern "C" {
extern SwigType *NewSwigType(int typecode);
extern SwigType *SwigType_del_element(SwigType *t);
extern SwigType *SwigType_add_pointer(SwigType *t);
- extern SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *qual);
+ extern SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr qual);
extern SwigType *SwigType_del_memberpointer(SwigType *t);
extern SwigType *SwigType_del_pointer(SwigType *t);
- extern SwigType *SwigType_add_array(SwigType *t, const String_or_char *size);
+ extern SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size);
extern SwigType *SwigType_del_array(SwigType *t);
extern SwigType *SwigType_pop_arrays(SwigType *t);
extern SwigType *SwigType_add_reference(SwigType *t);
extern SwigType *SwigType_del_reference(SwigType *t);
- extern SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual);
+ extern SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual);
extern SwigType *SwigType_del_qualifier(SwigType *t);
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
@@ -129,10 +129,10 @@ extern "C" {
extern void SwigType_push(SwigType *t, SwigType *s);
extern List *SwigType_parmlist(const SwigType *p);
extern String *SwigType_parm(String *p);
- extern String *SwigType_str(SwigType *s, const String_or_char *id);
- extern String *SwigType_lstr(SwigType *s, const String_or_char *id);
- extern String *SwigType_rcaststr(SwigType *s, const String_or_char *id);
- extern String *SwigType_lcaststr(SwigType *s, const String_or_char *id);
+ extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id);
extern String *SwigType_manglestr(SwigType *t);
extern SwigType *SwigType_ltype(SwigType *t);
extern int SwigType_ispointer(SwigType *t);
@@ -151,7 +151,7 @@ extern "C" {
extern int SwigType_isvarargs(const SwigType *t);
extern int SwigType_istemplate(const SwigType *t);
extern int SwigType_isenum(SwigType *t);
- extern int SwigType_check_decl(SwigType *t, const String_or_char *decl);
+ extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl);
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
extern String *SwigType_base(const SwigType *t);
@@ -162,7 +162,7 @@ extern "C" {
extern String *SwigType_prefix(const SwigType *t);
extern int SwigType_array_ndim(SwigType *t);
extern String *SwigType_array_getdim(SwigType *t, int n);
- extern void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep);
+ extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
extern SwigType *SwigType_array_type(SwigType *t);
extern String *SwigType_default(SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
@@ -173,27 +173,27 @@ extern "C" {
/* --- Type-system managment --- */
extern void SwigType_typesystem_init(void);
- extern int SwigType_typedef(SwigType *type, String_or_char *name);
- extern int SwigType_typedef_class(String_or_char *name);
- extern int SwigType_typedef_using(String_or_char *qname);
+ extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name);
+ extern int SwigType_typedef_class(const_String_or_char_ptr name);
+ extern int SwigType_typedef_using(const_String_or_char_ptr qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
extern void SwigType_using_scope(Typetab *t);
- extern void SwigType_new_scope(const String_or_char *name);
+ extern void SwigType_new_scope(const_String_or_char_ptr name);
extern void SwigType_inherit_scope(Typetab *scope);
extern Typetab *SwigType_pop_scope(void);
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
- extern SwigType *SwigType_typedef_resolve(SwigType *t);
+ extern SwigType *SwigType_typedef_resolve(const SwigType *t);
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
extern SwigType *SwigType_typedef_qualified(SwigType *t);
extern int SwigType_istypedef(SwigType *t);
extern int SwigType_isclass(SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
extern void SwigType_remember(SwigType *t);
- extern void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata);
- extern void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata);
+ extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata);
+ extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
extern int SwigType_type(SwigType *t);
@@ -201,25 +201,25 @@ extern "C" {
/* --- Symbol table module --- */
extern void Swig_symbol_init(void);
- extern void Swig_symbol_setscopename(const String_or_char *name);
+ extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
extern String *Swig_symbol_getscopename(void);
extern String *Swig_symbol_qualifiedscopename(Symtab *symtab);
extern Symtab *Swig_symbol_newscope(void);
extern Symtab *Swig_symbol_setscope(Symtab *);
- extern Symtab *Swig_symbol_getscope(const String_or_char *symname);
+ extern Symtab *Swig_symbol_getscope(const_String_or_char_ptr symname);
extern Symtab *Swig_symbol_current(void);
extern Symtab *Swig_symbol_popscope(void);
- extern Node *Swig_symbol_add(String_or_char *symname, Node *node);
- extern void Swig_symbol_cadd(String_or_char *symname, Node *node);
- extern Node *Swig_symbol_clookup(String_or_char *symname, Symtab *tab);
- extern Node *Swig_symbol_clookup_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
- extern Symtab *Swig_symbol_cscope(String_or_char *symname, Symtab *tab);
- extern Node *Swig_symbol_clookup_local(String_or_char *symname, Symtab *tab);
- extern Node *Swig_symbol_clookup_local_check(String_or_char *symname, Symtab *tab, int (*check) (Node *));
+ extern Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *node);
+ extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node);
+ extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab);
+ extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
+ extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab);
+ extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab);
+ extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
extern String *Swig_symbol_qualified(Node *node);
extern Node *Swig_symbol_isoverloaded(Node *node);
extern void Swig_symbol_remove(Node *node);
- extern void Swig_symbol_alias(String_or_char *aliasname, Symtab *tab);
+ extern void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *tab);
extern void Swig_symbol_inherit(Symtab *tab);
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
@@ -246,17 +246,17 @@ extern int ParmList_is_compactdefargs(ParmList *p);
/* --- Naming functions --- */
- extern void Swig_name_register(const String_or_char *method, const String_or_char *format);
- extern void Swig_name_unregister(const String_or_char *method);
- extern String *Swig_name_mangle(const String_or_char *s);
- extern String *Swig_name_wrapper(const String_or_char *fname);
- extern String *Swig_name_member(const String_or_char *classname, const String_or_char *mname);
- extern String *Swig_name_get(const String_or_char *vname);
- extern String *Swig_name_set(const String_or_char *vname);
- extern String *Swig_name_construct(const String_or_char *classname);
- extern String *Swig_name_copyconstructor(const String_or_char *classname);
- extern String *Swig_name_destroy(const String_or_char *classname);
- extern String *Swig_name_disown(const String_or_char *classname);
+ extern void Swig_name_register(const_String_or_char_ptr method, const_String_or_char_ptr format);
+ extern void Swig_name_unregister(const_String_or_char_ptr method);
+ extern String *Swig_name_mangle(const_String_or_char_ptr s);
+ extern String *Swig_name_wrapper(const_String_or_char_ptr fname);
+ extern String *Swig_name_member(const_String_or_char_ptr classname, const_String_or_char_ptr mname);
+ extern String *Swig_name_get(const_String_or_char_ptr vname);
+ extern String *Swig_name_set(const_String_or_char_ptr vname);
+ extern String *Swig_name_construct(const_String_or_char_ptr classname);
+ extern String *Swig_name_copyconstructor(const_String_or_char_ptr classname);
+ extern String *Swig_name_destroy(const_String_or_char_ptr classname);
+ extern String *Swig_name_disown(const_String_or_char_ptr classname);
extern void Swig_naming_init(void);
extern void Swig_name_namewarn_add(String *prefix, String *name, SwigType *decl, Hash *namewrn);
@@ -267,33 +267,36 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_need_name_warning(Node *n);
extern int Swig_need_redefined_warn(Node *a, Node *b, int InClass);
- extern String *Swig_name_make(Node *n, String *prefix, String_or_char *cname, SwigType *decl, String *oldname);
+ extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
extern String *Swig_name_decl(Node *n);
extern String *Swig_name_fulldecl(Node *n);
/* --- parameterized rename functions --- */
- extern void Swig_name_object_set(Hash *namehash, String_or_char *name, SwigType *decl, DOH *object);
- extern DOH *Swig_name_object_get(Hash *namehash, String_or_char *prefix, String_or_char *name, SwigType *decl);
+ extern void Swig_name_object_set(Hash *namehash, String *name, SwigType *decl, DOH *object);
+ extern DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType *decl);
extern void Swig_name_object_inherit(Hash *namehash, String *base, String *derived);
- extern void Swig_features_get(Hash *features, String_or_char *prefix, String_or_char *name, SwigType *decl, Node *n);
- extern void Swig_feature_set(Hash *features, const String_or_char *name, SwigType *decl, const String_or_char *featurename, String *value, Hash *featureattribs);
+ extern void Swig_features_get(Hash *features, String *prefix, String *name, SwigType *decl, Node *n);
+ extern void Swig_feature_set(Hash *features, const_String_or_char_ptr name, SwigType *decl, const_String_or_char_ptr featurename, String *value, Hash *featureattribs);
/* --- Misc --- */
extern char *Swig_copy_string(const char *c);
extern void Swig_set_fakeversion(const char *version);
extern const char *Swig_package_version(void);
extern void Swig_banner(File *f);
+ extern void Swig_banner_target_lang(File *f, const_String_or_char_ptr commentchar);
extern String *Swig_strip_c_comments(const String *s);
+ extern String *Swig_filename_escape(String *filename);
+ extern void Swig_filename_correct(String *filename);
extern String *Swig_string_escape(String *s);
extern String *Swig_string_mangle(const String *s);
- extern void Swig_scopename_split(String *s, String **prefix, String **last);
- extern String *Swig_scopename_prefix(String *s);
- extern String *Swig_scopename_last(String *s);
- extern String *Swig_scopename_first(String *s);
- extern String *Swig_scopename_suffix(String *s);
- extern int Swig_scopename_check(String *s);
+ extern void Swig_scopename_split(const String *s, String **prefix, String **last);
+ extern String *Swig_scopename_prefix(const String *s);
+ extern String *Swig_scopename_last(const String *s);
+ extern String *Swig_scopename_first(const String *s);
+ extern String *Swig_scopename_suffix(const String *s);
+ extern int Swig_scopename_check(const String *s);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
@@ -308,11 +311,11 @@ extern int ParmList_is_compactdefargs(ParmList *p);
typedef enum { EMF_STANDARD, EMF_MICROSOFT } ErrorMessageFormat;
- extern void Swig_warning(int num, const String_or_char *filename, int line, const char *fmt, ...);
- extern void Swig_error(const String_or_char *filename, int line, const char *fmt, ...);
+ extern void Swig_warning(int num, const_String_or_char_ptr filename, int line, const char *fmt, ...);
+ extern void Swig_error(const_String_or_char_ptr filename, int line, const char *fmt, ...);
extern int Swig_error_count(void);
extern void Swig_error_silent(int s);
- extern void Swig_warnfilter(const String_or_char *wlist, int val);
+ extern void Swig_warnfilter(const_String_or_char_ptr wlist, int val);
extern void Swig_warnall(void);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
@@ -321,17 +324,17 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_cparm_name(Parm *p, int i);
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
extern int Swig_cargs(Wrapper *w, ParmList *l);
- extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
+ extern String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or_char_ptr decl);
- extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
- extern String *Swig_cconstructor_call(String_or_char *name);
- extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
+ extern String *Swig_cfunction_call(const_String_or_char_ptr name, ParmList *parms);
+ extern String *Swig_cconstructor_call(const_String_or_char_ptr name);
+ extern String *Swig_cppconstructor_call(const_String_or_char_ptr name, ParmList *parms);
extern String *Swig_unref_call(Node *n);
extern String *Swig_ref_call(Node *n, const String *lname);
extern String *Swig_cdestructor_call(Node *n);
extern String *Swig_cppdestructor_call(Node *n);
- extern String *Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self, int varcref);
- extern String *Swig_cmemberget_call(const String_or_char *name, SwigType *t, String_or_char *self, int varcref);
+ extern String *Swig_cmemberset_call(const_String_or_char_ptr name, SwigType *type, String *self, int varcref);
+ extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref);
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self);
@@ -340,7 +343,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
- extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
+ extern int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call);
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
extern int Swig_VargetToFunction(Node *n, int flags);
extern int Swig_VarsetToFunction(Node *n, int flags);
@@ -360,22 +363,22 @@ extern int ParmList_is_compactdefargs(ParmList *p);
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
extern void Swig_typemap_init(void);
- extern void Swig_typemap_register(const String_or_char *op, ParmList *pattern, String_or_char *code, ParmList *locals, ParmList *kwargs);
- extern int Swig_typemap_copy(const String_or_char *op, ParmList *srcpattern, ParmList *pattern);
- extern void Swig_typemap_clear(const String_or_char *op, ParmList *pattern);
+ extern void Swig_typemap_register(const_String_or_char_ptr op, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs);
+ extern int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcpattern, ParmList *pattern);
+ extern void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *pattern);
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug(void);
- extern Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *pname, SwigType **matchtype);
- extern Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch);
- extern String *Swig_typemap_lookup(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f);
- extern String *Swig_typemap_lookup_out(const String_or_char *op, Node *n, const String_or_char *lname, Wrapper *f, String *actioncode);
- extern void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p);
+ extern Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr pname, SwigType **matchtype);
+ extern Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch);
+ extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f);
+ extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
+ extern void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p);
extern void Swig_typemap_new_scope(void);
extern Hash *Swig_typemap_pop_scope(void);
- extern void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f);
+ extern void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f);
/* --- Code fragment support --- */
diff --git a/Source/Swig/swigfile.h b/Source/Swig/swigfile.h
index c945fb1ac..92c7945e6 100644
--- a/Source/Swig/swigfile.h
+++ b/Source/Swig/swigfile.h
@@ -9,24 +9,25 @@
/* $Id: swig.h 9603 2006-12-05 21:47:01Z beazley $ */
-extern List *Swig_add_directory(const String_or_char *dirname);
-extern void Swig_push_directory(const String_or_char *dirname);
-extern void Swig_pop_directory();
-extern String *Swig_last_file();
-extern List *Swig_search_path();
-extern FILE *Swig_open(const String_or_char *name);
+extern List *Swig_add_directory(const_String_or_char_ptr dirname);
+extern void Swig_push_directory(const_String_or_char_ptr dirname);
+extern void Swig_pop_directory(void);
+extern String *Swig_last_file(void);
+extern List *Swig_search_path(void);
+extern FILE *Swig_include_open(const_String_or_char_ptr name);
+extern FILE *Swig_open(const_String_or_char_ptr name);
extern String *Swig_read_file(FILE *f);
-extern String *Swig_include(const String_or_char *name);
-extern String *Swig_include_sys(const String_or_char *name);
-extern int Swig_insert_file(const String_or_char *name, File *outfile);
+extern String *Swig_include(const_String_or_char_ptr name);
+extern String *Swig_include_sys(const_String_or_char_ptr name);
+extern int Swig_insert_file(const_String_or_char_ptr name, File *outfile);
extern void Swig_set_push_dir(int dopush);
extern int Swig_get_push_dir(void);
-extern void Swig_register_filebyname(const String_or_char *filename, File *outfile);
-extern File *Swig_filebyname(const String_or_char *filename);
-extern char *Swig_file_suffix(const String_or_char *filename);
-extern char *Swig_file_basename(const String_or_char *filename);
-extern char *Swig_file_filename(const String_or_char *filename);
-extern char *Swig_file_dirname(const String_or_char *filename);
+extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile);
+extern File *Swig_filebyname(const_String_or_char_ptr filename);
+extern char *Swig_file_suffix(const_String_or_char_ptr filename);
+extern char *Swig_file_basename(const_String_or_char_ptr filename);
+extern char *Swig_file_filename(const_String_or_char_ptr filename);
+extern char *Swig_file_dirname(const_String_or_char_ptr filename);
/* Delimiter used in accessing files and directories */
diff --git a/Source/Swig/swigopt.h b/Source/Swig/swigopt.h
index 428d90dce..11eb5ba99 100644
--- a/Source/Swig/swigopt.h
+++ b/Source/Swig/swigopt.h
@@ -13,4 +13,4 @@
extern void Swig_mark_arg(int n);
extern int Swig_check_marked(int n);
extern void Swig_check_options(int check_input);
- extern void Swig_arg_error();
+ extern void Swig_arg_error(void);
diff --git a/Source/Swig/swigparm.h b/Source/Swig/swigparm.h
index 529438bae..49ae7992e 100644
--- a/Source/Swig/swigparm.h
+++ b/Source/Swig/swigparm.h
@@ -11,7 +11,7 @@
/* $Id: swig.h 9629 2006-12-30 18:27:47Z beazley $ */
/* Individual parameters */
-extern Parm *NewParm(SwigType *type, const String_or_char *name);
+extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name);
extern Parm *CopyParm(Parm *p);
/* Parameter lists */
diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
index 2486286a9..3403098df 100644
--- a/Source/Swig/swigscan.h
+++ b/Source/Swig/swigscan.h
@@ -11,11 +11,11 @@
typedef struct Scanner Scanner;
-extern Scanner *NewScanner();
+extern Scanner *NewScanner(void);
extern void DelScanner(Scanner *);
extern void Scanner_clear(Scanner *);
extern void Scanner_push(Scanner *, String *);
-extern void Scanner_pushtoken(Scanner *, int, const String_or_char *value);
+extern void Scanner_pushtoken(Scanner *, int, const_String_or_char_ptr value);
extern int Scanner_token(Scanner *);
extern String *Scanner_text(Scanner *);
extern void Scanner_skip_line(Scanner *);
diff --git a/Source/Swig/swigtree.h b/Source/Swig/swigtree.h
index 2e5c4da36..5b43006a9 100644
--- a/Source/Swig/swigtree.h
+++ b/Source/Swig/swigtree.h
@@ -31,7 +31,7 @@
/* Utility functions */
-extern int checkAttribute(Node *obj, const String_or_char *name, const String_or_char *value);
+extern int checkAttribute(Node *obj, const_String_or_char_ptr name, const_String_or_char_ptr value);
extern void appendChild(Node *node, Node *child);
extern void prependChild(Node *node, Node *child);
extern void removeNode(Node *node);
diff --git a/Source/Swig/swigwrap.h b/Source/Swig/swigwrap.h
index 25eeb6f7f..0dcf88059 100644
--- a/Source/Swig/swigwrap.h
+++ b/Source/Swig/swigwrap.h
@@ -16,14 +16,14 @@ typedef struct Wrapper {
String *code;
} Wrapper;
-extern Wrapper *NewWrapper();
+extern Wrapper *NewWrapper(void);
extern void DelWrapper(Wrapper *w);
extern void Wrapper_compact_print_mode_set(int flag);
extern void Wrapper_pretty_print(String *str, File *f);
extern void Wrapper_compact_print(String *str, File *f);
extern void Wrapper_print(Wrapper *w, File *f);
-extern int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
-extern int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...);
-extern int Wrapper_check_local(Wrapper *w, const String_or_char *name);
-extern char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl);
-extern char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...);
+extern int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
+extern int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...);
+extern int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name);
+extern char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl);
+extern char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...);
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index c9691fa54..055af854f 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -220,7 +220,7 @@ void Swig_symbol_init() {
* Set the C scopename of the current symbol table.
* ----------------------------------------------------------------------------- */
-void Swig_symbol_setscopename(const String_or_char *name) {
+void Swig_symbol_setscopename(const_String_or_char_ptr name) {
String *qname;
/* assert(!Getattr(current_symtab,"name")); */
Setattr(current_symtab, "name", name);
@@ -250,10 +250,10 @@ String *Swig_symbol_getscopename() {
* Given a fully qualified C scopename, this function returns a symbol table
* ----------------------------------------------------------------------------- */
-Symtab *Swig_symbol_getscope(const String_or_char *name) {
+Symtab *Swig_symbol_getscope(const_String_or_char_ptr name) {
if (!symtabs)
return 0;
- if (Equal("::", (String_or_char *) name))
+ if (Equal("::", (const_String_or_char_ptr ) name))
name = "";
return Getattr(symtabs, name);
}
@@ -373,7 +373,7 @@ Symtab *Swig_symbol_current() {
* Makes an alias for a symbol in the global symbol table.
* ----------------------------------------------------------------------------- */
-void Swig_symbol_alias(String_or_char *aliasname, Symtab *s) {
+void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) {
String *qname = Swig_symbol_qualifiedscopename(current_symtab);
if (qname) {
Printf(qname, "::%s", aliasname);
@@ -421,7 +421,7 @@ void Swig_symbol_inherit(Symtab *s) {
* Adds a node to the C symbol table only.
* ----------------------------------------------------------------------------- */
-void Swig_symbol_cadd(String_or_char *name, Node *n) {
+void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
Node *append = 0;
Node *cn;
@@ -594,7 +594,7 @@ void Swig_symbol_cadd(String_or_char *name, Node *n) {
* for namespace support, type resolution, and other issues.
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_add(String_or_char *symname, Node *n) {
+Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) {
Hash *c, *cn, *cl = 0;
SwigType *decl, *ndecl;
String *cstorage, *nstorage;
@@ -827,7 +827,7 @@ Node *Swig_symbol_add(String_or_char *symname, Node *n) {
* verifying that a class hierarchy implements all pure virtual methods.
* ----------------------------------------------------------------------------- */
-static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)) {
+static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (Node *n)) {
Node *n;
List *inherit;
Hash *sym = Getattr(symtab, "csymtab");
@@ -890,7 +890,7 @@ static Node *_symbol_lookup(String *name, Symtab *symtab, int (*check) (Node *n)
return 0;
}
-static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (Node *n)) {
+static Node *symbol_lookup(const_String_or_char_ptr name, Symtab *symtab, int (*check) (Node *n)) {
Node *n = 0;
if (DohCheck(name)) {
n = _symbol_lookup(name, symtab, check);
@@ -908,7 +908,7 @@ static Node *symbol_lookup(String_or_char *name, Symtab *symtab, int (*check) (N
* symbol_lookup_qualified()
* ----------------------------------------------------------------------------- */
-static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, String *prefix, int local, int (*checkfunc) (Node *n)) {
+static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symtab, const String *prefix, int local, int (*checkfunc) (Node *n)) {
/* This is a little funky, we search by fully qualified names */
if (!symtab)
@@ -928,6 +928,7 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
/* Make qualified name of current scope */
String *qalloc = 0;
String *qname = Swig_symbol_qualifiedscopename(symtab);
+ const String *cqname;
if (qname) {
if (Len(qname)) {
if (prefix && Len(prefix)) {
@@ -937,10 +938,11 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
Append(qname, prefix);
}
qalloc = qname;
+ cqname = qname;
} else {
- qname = prefix;
+ cqname = prefix;
}
- st = Getattr(symtabs, qname);
+ st = Getattr(symtabs, cqname);
/* Found a scope match */
if (st) {
if (!name) {
@@ -974,7 +976,7 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
* to get the real node.
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) {
+Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
Hash *hsym = 0;
Node *s = 0;
@@ -1046,7 +1048,7 @@ Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) {
* inheritance hierarchy.
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *n)) {
+Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *n)) {
Hash *hsym = 0;
Node *s = 0;
@@ -1110,7 +1112,7 @@ Node *Swig_symbol_clookup_check(String_or_char *name, Symtab *n, int (*checkfunc
* Swig_symbol_clookup_local()
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
+Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
Hash *h, *hsym;
Node *s = 0;
@@ -1158,7 +1160,7 @@ Node *Swig_symbol_clookup_local(String_or_char *name, Symtab *n) {
* Swig_symbol_clookup_local_check()
* ----------------------------------------------------------------------------- */
-Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*checkfunc) (Node *)) {
+Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) {
Hash *h, *hsym;
Node *s = 0;
@@ -1209,7 +1211,7 @@ Node *Swig_symbol_clookup_local_check(String_or_char *name, Symtab *n, int (*che
* Look up a scope name.
* ----------------------------------------------------------------------------- */
-Symtab *Swig_symbol_cscope(String_or_char *name, Symtab *symtab) {
+Symtab *Swig_symbol_cscope(const_String_or_char_ptr name, Symtab *symtab) {
char *cname = Char(name);
if (strncmp(cname, "::", 2) == 0)
return symbol_lookup_qualified(0, global_scope, name, 0, 0);
diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c
index 61dca8353..14d231afa 100644
--- a/Source/Swig/tree.c
+++ b/Source/Swig/tree.c
@@ -229,7 +229,7 @@ Node *copyNode(Node *n) {
* checkAttribute()
* ----------------------------------------------------------------------------- */
-int checkAttribute(Node *n, const String_or_char *name, const String_or_char *value) {
+int checkAttribute(Node *n, const_String_or_char_ptr name, const_String_or_char_ptr value) {
String *v = Getattr(n, name);
return v ? Equal(v, value) : 0;
}
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index 6cbeb67ea..401a99801 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -107,7 +107,7 @@ void Swig_typemap_init() {
tm_scope = 0;
}
-static String *tmop_name(const String_or_char *op) {
+static String *tmop_name(const_String_or_char_ptr op) {
static Hash *names = 0;
String *s;
/* Due to "interesting" object-identity semantics of DOH,
@@ -164,7 +164,7 @@ Hash *Swig_typemap_pop_scope() {
* Add a new multi-valued typemap
* ----------------------------------------------------------------------------- */
-void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_char *code, ParmList *locals, ParmList *kwargs) {
+void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) {
Hash *tm;
Hash *tm1;
Hash *tm2;
@@ -270,7 +270,7 @@ void Swig_typemap_register(const String_or_char *op, ParmList *parms, String_or_
* Retrieve typemap information from current scope.
* ----------------------------------------------------------------------------- */
-static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) {
+static Hash *Swig_typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) {
Hash *tm, *tm1;
/* See if this type has been seen before */
if ((scope < 0) || (scope > tm_scope))
@@ -292,7 +292,7 @@ static Hash *Swig_typemap_get(SwigType *type, String_or_char *name, int scope) {
* Copy a typemap
* ----------------------------------------------------------------------------- */
-int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *parms) {
+int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList *parms) {
Hash *tm = 0;
String *tmop;
Parm *p;
@@ -347,7 +347,7 @@ int Swig_typemap_copy(const String_or_char *op, ParmList *srcparms, ParmList *pa
* Delete a multi-valued typemap
* ----------------------------------------------------------------------------- */
-void Swig_typemap_clear(const String_or_char *op, ParmList *parms) {
+void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
SwigType *type;
String *name;
Parm *p;
@@ -590,7 +590,7 @@ static SwigType *strip_arrays(SwigType *type) {
* that includes a 'code' attribute.
* ----------------------------------------------------------------------------- */
-Hash *Swig_typemap_search(const String_or_char *op, SwigType *type, const String_or_char *name, SwigType **matchtype) {
+Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) {
Hash *result = 0, *tm, *tm1, *tma;
Hash *backup = 0;
SwigType *noarrays = 0;
@@ -737,7 +737,7 @@ ret_result:
* Search for a multi-valued typemap.
* ----------------------------------------------------------------------------- */
-Hash *Swig_typemap_search_multi(const String_or_char *op, ParmList *parms, int *nmatch) {
+Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) {
SwigType *type;
SwigType *mtype = 0;
String *name;
@@ -1173,7 +1173,7 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
* $1 in the out typemap will be replaced by the code in actioncode.
* ----------------------------------------------------------------------------- */
-static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) {
+static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
SwigType *type;
SwigType *mtype = 0;
String *pname;
@@ -1384,13 +1384,13 @@ static String *Swig_typemap_lookup_impl(const String_or_char *op, Node *node, co
return s;
}
-String *Swig_typemap_lookup_out(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f, String *actioncode) {
+String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
assert(actioncode);
assert(Cmp(op, "out") == 0);
return Swig_typemap_lookup_impl(op, node, lname, f, actioncode);
}
-String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_or_char *lname, Wrapper *f) {
+String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f) {
return Swig_typemap_lookup_impl(op, node, lname, f, 0);
}
@@ -1406,7 +1406,7 @@ String *Swig_typemap_lookup(const String_or_char *op, Node *node, const String_o
* A new attribute called "tmap:in:foo" with value "xyz" is attached to p.
* ----------------------------------------------------------------------------- */
-void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {
+void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringEmpty();
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
@@ -1438,7 +1438,7 @@ void Swig_typemap_attach_kwargs(Hash *tm, const String_or_char *op, Parm *p) {
* attribute, print that warning message.
* ----------------------------------------------------------------------------- */
-static void Swig_typemap_warn(const String_or_char *op, Parm *p) {
+static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringf("%s:warning", op);
String *w = Getattr(p, tmop_name(temp));
Delete(temp);
@@ -1447,7 +1447,7 @@ static void Swig_typemap_warn(const String_or_char *op, Parm *p) {
}
}
-static void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p) {
+static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringf("%s:fragment", op);
String *f = Getattr(p, tmop_name(temp));
if (f) {
@@ -1467,7 +1467,7 @@ static void Swig_typemap_emit_code_fragments(const String_or_char *op, Parm *p)
* given typemap type
* ----------------------------------------------------------------------------- */
-String *Swig_typemap_get_option(Hash *tm, String *name) {
+String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
String *kname = Getattr(kw, "name");
@@ -1479,7 +1479,7 @@ String *Swig_typemap_get_option(Hash *tm, String *name) {
return 0;
}
-void Swig_typemap_attach_parms(const String_or_char *op, ParmList *parms, Wrapper *f) {
+void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) {
Parm *p, *firstp;
Hash *tm;
int nmatch = 0;
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c
index 18d1b2304..8ff31bc0b 100644
--- a/Source/Swig/typeobj.c
+++ b/Source/Swig/typeobj.c
@@ -110,7 +110,7 @@ char cvsroot_typeobj_c[] = "$Id$";
* ----------------------------------------------------------------------------- */
#ifdef NEW
-SwigType *NewSwigType(const String_or_char *initial) {
+SwigType *NewSwigType(const_String_or_char_ptr initial) {
return NewString(initial);
}
@@ -419,7 +419,7 @@ int SwigType_isreference(SwigType *t) {
* stored in exactly the same way as "q(const volatile)".
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_add_qualifier(SwigType *t, const String_or_char *qual) {
+SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
char temp[256], newq[256];
int sz, added = 0;
char *q, *cqual;
@@ -537,7 +537,7 @@ SwigType *SwigType_functionpointer_decompose(SwigType *t) {
* Add, remove, and test for C++ pointer to members.
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_add_memberpointer(SwigType *t, const String_or_char *name) {
+SwigType *SwigType_add_memberpointer(SwigType *t, const_String_or_char_ptr name) {
String *temp = NewStringf("m(%s).", name);
Insert(t, 0, temp);
Delete(temp);
@@ -579,7 +579,7 @@ int SwigType_ismemberpointer(SwigType *t) {
* SwigType_pop_arrays() - Remove all arrays
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_add_array(SwigType *t, const String_or_char *size) {
+SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
char temp[512];
strcpy(temp, "a(");
strcat(temp, Char(size));
@@ -673,7 +673,7 @@ String *SwigType_array_getdim(SwigType *t, int n) {
}
/* Replace nth array dimension */
-void SwigType_array_setdim(SwigType *t, int n, const String_or_char *rep) {
+void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
String *result = 0;
char temp;
char *start;
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index a9e2898bd..2562e12f8 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -163,7 +163,7 @@ void SwigType_typesystem_init() {
* already defined.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef(SwigType *type, String_or_char *name) {
+int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) {
if (Getattr(current_typetab, name))
return -1; /* Already defined */
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
@@ -193,7 +193,7 @@ int SwigType_typedef(SwigType *type, String_or_char *name) {
* Defines a class in the current scope.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef_class(String_or_char *name) {
+int SwigType_typedef_class(const_String_or_char_ptr name) {
String *cname;
/* Printf(stdout,"class : '%s'\n", name); */
if (Getattr(current_typetab, name))
@@ -232,7 +232,7 @@ String *SwigType_scope_name(Typetab *ttab) {
* Creates a new scope
* ----------------------------------------------------------------------------- */
-void SwigType_new_scope(const String_or_char *name) {
+void SwigType_new_scope(const_String_or_char_ptr name) {
Typetab *s;
Hash *ttab;
String *qname;
@@ -539,7 +539,7 @@ static SwigType *typedef_resolve(Typetab *s, String *base) {
* ----------------------------------------------------------------------------- */
/* #define SWIG_DEBUG */
-SwigType *SwigType_typedef_resolve(SwigType *t) {
+SwigType *SwigType_typedef_resolve(const SwigType *t) {
String *base;
String *type = 0;
String *r = 0;
@@ -840,6 +840,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
*
* Given a type declaration, this function tries to fully qualify it according to
* typedef scope rules.
+ * Inconsistency to be fixed: ::Foo returns ::Foo, whereas ::Foo * returns Foo *
* ----------------------------------------------------------------------------- */
SwigType *SwigType_typedef_qualified(SwigType *t) {
@@ -1071,7 +1072,7 @@ int SwigType_istypedef(SwigType *t) {
* Name is a qualified name like A::B.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef_using(String_or_char *name) {
+int SwigType_typedef_using(const_String_or_char_ptr name) {
String *base;
String *td;
String *prefix;
@@ -1415,7 +1416,7 @@ static Hash *r_remembered = 0; /* Hash of types we remembered already */
static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
-void SwigType_remember_mangleddata(String *mangled, const String_or_char *clientdata) {
+void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) {
if (!r_mangleddata) {
r_mangleddata = NewHash();
}
@@ -1423,7 +1424,7 @@ void SwigType_remember_mangleddata(String *mangled, const String_or_char *client
}
-void SwigType_remember_clientdata(SwigType *t, const String_or_char *clientdata) {
+void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) {
String *mt;
SwigType *lt;
Hash *h;
diff --git a/Source/Swig/wrapfunc.c b/Source/Swig/wrapfunc.c
index 3778066ce..11518bfc2 100644
--- a/Source/Swig/wrapfunc.c
+++ b/Source/Swig/wrapfunc.c
@@ -23,7 +23,7 @@ static int Max_line_size = 128;
* Create a new wrapper function object.
* ----------------------------------------------------------------------------- */
-Wrapper *NewWrapper() {
+Wrapper *NewWrapper(void) {
Wrapper *w;
w = (Wrapper *) malloc(sizeof(Wrapper));
w->localh = NewHash();
@@ -406,7 +406,7 @@ void Wrapper_print(Wrapper *w, File *f) {
* present (which may or may not be okay to the caller).
* ----------------------------------------------------------------------------- */
-int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
+int Wrapper_add_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
/* See if the local has already been declared */
if (Getattr(w->localh, name)) {
return -1;
@@ -424,7 +424,7 @@ int Wrapper_add_local(Wrapper *w, const String_or_char *name, const String_or_ch
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
-int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
+int Wrapper_add_localv(Wrapper *w, const_String_or_char_ptr name, ...) {
va_list ap;
int ret;
String *decl;
@@ -451,7 +451,7 @@ int Wrapper_add_localv(Wrapper *w, const String_or_char *name, ...) {
* Check to see if a local name has already been declared
* ----------------------------------------------------------------------------- */
-int Wrapper_check_local(Wrapper *w, const String_or_char *name) {
+int Wrapper_check_local(Wrapper *w, const_String_or_char_ptr name) {
if (Getattr(w->localh, name)) {
return 1;
}
@@ -465,7 +465,7 @@ int Wrapper_check_local(Wrapper *w, const String_or_char *name) {
* used. Returns the name that was actually selected.
* ----------------------------------------------------------------------------- */
-char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_char *decl) {
+char *Wrapper_new_local(Wrapper *w, const_String_or_char_ptr name, const_String_or_char_ptr decl) {
int i;
String *nname = NewString(name);
String *ndecl = NewString(decl);
@@ -496,7 +496,7 @@ char *Wrapper_new_local(Wrapper *w, const String_or_char *name, const String_or_
* to manually construct the 'decl' string before calling.
* ----------------------------------------------------------------------------- */
-char *Wrapper_new_localv(Wrapper *w, const String_or_char *name, ...) {
+char *Wrapper_new_localv(Wrapper *w, const_String_or_char_ptr name, ...) {
va_list ap;
char *ret;
String *decl;
diff --git a/TODO b/TODO
index 103185d23..879e65f1f 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,5 @@
SWIG TO-DO
-Release: SWIG-1.3.36
-
-----------------------------------------------------------------------------
**** = High Priority
@@ -339,6 +337,14 @@ Common Lisp
typemaps would be written as Lisp programs that generate Lisp
code.
+ALLEGROCL
+-----
+These first three will remove most of the warnings from most of the
+remaining checkpartial tests that are failing.
+**** Throws typemap support
+**** const typemaps
+**** long long typemaps
+
Ocaml
-----
** I've been working with my camlp4 module and type information
diff --git a/Tools/mkdist.py b/Tools/mkdist.py
index f5bdd01c7..0e2eafa79 100755
--- a/Tools/mkdist.py
+++ b/Tools/mkdist.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/env python
# This script builds a swig-1.3 distribution.
# Usage : mkdist.py version, where version should be 1.3.x
@@ -43,11 +43,6 @@ os.system("svn export -r HEAD https://swig.svn.sourceforge.net/svnroot/swig/trun
os.system("rm -Rf "+dirname+"/debian") == 0 or failed()
-# Blow away all .cvsignore files
-
-print "Blowing away .cvsignore files"
-os.system("find "+dirname+" -name .cvsignore -exec rm {} \\;") == 0 or failed()
-
# Go build the system
print "Building system"
@@ -61,7 +56,8 @@ os.system("find "+dirname+" -name autom4te.cache -exec rm -rf {} \\;")
# Build documentation
print "Building documentation"
-os.system("cd "+dirname+"/Doc/Manual && make && rm *.bak") == 0 or failed()
+os.system("cd "+dirname+"/Doc/Manual && make all clean-baks") == 0 or failed()
+os.system("cd "+dirname+"/CCache && yodl2man -o ccache-swig.1 ccache.yo") == 0 or failed()
# Build the tar-ball
os.system("tar -cf "+dirname+".tar "+dirname) == 0 or failed()
diff --git a/Tools/mkrelease.py b/Tools/mkrelease.py
index d7927f8e6..edf3b07fe 100755
--- a/Tools/mkrelease.py
+++ b/Tools/mkrelease.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python
+#!/usr/bin/env python
# This script builds the SWIG source tarball, creates the Windows executable and the Windows zip package
# and uploads them both to SF ready for release
diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh
index 116e32d11..fb2547e14 100755
--- a/Tools/mkwindows.sh
+++ b/Tools/mkwindows.sh
@@ -82,10 +82,13 @@ if test -f "$tarball"; then
echo "Compiling (quietly)..."
make > build.log
echo "Simple check to see if swig.exe runs..."
- env LD_LIBRARY_PATH= PATH= ./swig.exe -version
+ env LD_LIBRARY_PATH= PATH= ./swig.exe -version || exit 1
+ echo "Simple check to see if ccache-swig.exe runs..."
+ env LD_LIBRARY_PATH= PATH= ./CCache/ccache-swig.exe -V || exit 1
echo "Creating $swigwinbasename.zip..."
cd ..
cp $swigbasename/swig.exe $swigwinbasename
+ cp $swigbasename/CCache/ccache-swig.exe $swigwinbasename/CCache
cp $swigbasename/Lib/swigwarn.swg $swigwinbasename/Lib
sleep 2 # fix strange not finding swig.exe
echo "Unzip into a directory of your choice. Please read the README file as well as Doc\Manual\Windows.html for installation instructions." > swig_windows_zip_comments.txt
diff --git a/Tools/pyname_patch.py b/Tools/pyname_patch.py
new file mode 100644
index 000000000..5931269f9
--- /dev/null
+++ b/Tools/pyname_patch.py
@@ -0,0 +1,123 @@
+#!/usr/bin/env python
+"""
+From SWIG 1.3.37 we deprecated all SWIG symbols that start with Py,
+since they are inappropriate and discouraged in Python documentation
+(from http://www.python.org/doc/2.5.2/api/includes.html):
+
+"All user visible names defined by Python.h (except those defined by the included
+standard headers) have one of the prefixes "Py" or "_Py". Names beginning with
+"_Py" are for internal use by the Python implementation and should not be used
+by extension writers. Structure member names do not have a reserved prefix.
+
+Important: user code should never define names that begin with "Py" or "_Py".
+This confuses the reader, and jeopardizes the portability of the user code to
+future Python versions, which may define additional names beginning with one
+of these prefixes."
+
+This file is a simple script used for change all of these symbols, for user code
+or SWIG itself.
+"""
+import re
+from shutil import copyfile
+import sys
+
+symbols = [
+ #(old name, new name)
+ ("PySequence_Base", "SwigPySequence_Base"),
+ ("PySequence_Cont", "SwigPySequence_Cont"),
+ ("PySwigIterator_T", "SwigPyIterator_T"),
+ ("PyPairBoolOutputIterator", "SwigPyPairBoolOutputIterator"),
+ ("PySwigIterator", "SwigPyIterator"),
+ ("PySwigIterator_T", "SwigPyIterator_T"),
+ ("PyMapIterator_T", "SwigPyMapIterator_T"),
+ ("PyMapKeyIterator_T", "SwigPyMapKeyIterator_T"),
+ ("PyMapValueIterator_T", "SwigPyMapValueITerator_T"),
+ ("PyObject_ptr", "SwigPtr_PyObject"),
+ ("PyObject_var", "SwigVar_PyObject"),
+ ("PyOper", "SwigPyOper"),
+ ("PySeq", "SwigPySeq"),
+ ("PySequence_ArrowProxy", "SwigPySequence_ArrowProxy"),
+ ("PySequence_Cont", "SwigPySequence_Cont"),
+ ("PySequence_InputIterator", "SwigPySequence_InputIterator"),
+ ("PySequence_Ref", "SwigPySequence_Ref"),
+ ("PySwigClientData", "SwigPyClientData"),
+ ("PySwigClientData_Del", "SwigPyClientData_Del"),
+ ("PySwigClientData_New", "SwigPyClientData_New"),
+ ("PySwigIterator", "SwigPyIterator"),
+ ("PySwigIteratorClosed_T", "SwigPyIteratorClosed_T"),
+ ("PySwigIteratorOpen_T", "SwigPyIteratorOpen_T"),
+ ("PySwigIterator_T", "SwigPyIterator_T"),
+ ("PySwigObject", "SwigPyObject"),
+ ("PySwigObject_Check", "SwigPyObject_Check"),
+ ("PySwigObject_GetDesc", "SwigPyObject_GetDesc"),
+ ("PySwigObject_New", "SwigPyObject_New"),
+ ("PySwigObject_acquire", "SwigPyObject_acquire"),
+ ("PySwigObject_append", "SwigPyObject_append"),
+ ("PySwigObject_as_number", "SwigPyObject_as_number"),
+ ("PySwigObject_compare", "SwigPyObject_compare"),
+ ("PySwigObject_dealloc", "SwigPyObject_dealloc"),
+ ("PySwigObject_disown", "SwigPyObject_disown"),
+ ("PySwigObject_format", "SwigPyObject_format"),
+ ("PySwigObject_getattr", "SwigPyObject_getattr"),
+ ("PySwigObject_hex", "SwigPyObject_hex"),
+ ("PySwigObject_long", "SwigPyObject_long"),
+ ("PySwigObject_next", "SwigPyObject_next"),
+ ("PySwigObject_oct", "SwigPyObject_oct"),
+ ("PySwigObject_own", "SwigPyObject_own"),
+ ("PySwigObject_print", "SwigPyObject_print"),
+ ("PySwigObject_repr", "SwigPyObject_repr"),
+ ("PySwigObject_richcompare", "SwigPyObject_richcompare"),
+ ("PySwigObject_str", "SwigPyObject_str"),
+ ("PySwigObject_type", "SwigPyObject_type"),
+ ("PySwigPacked", "SwigPyPacked"),
+ ("PySwigPacked_Check", "SwigPyPacked_Check"),
+ ("PySwigPacked_New", "SwigPyPacked_New"),
+ ("PySwigPacked_UnpackData", "SwigPyPacked_UnpackData"),
+ ("PySwigPacked_compare", "SwigPyPacked_compare"),
+ ("PySwigPacked_dealloc", "SwigPyPacked_dealloc"),
+ ("PySwigPacked_print", "SwigPyPacked_print"),
+ ("PySwigPacked_repr", "SwigPyPacked_repr"),
+ ("PySwigPacked_str", "SwigPyPacked_str"),
+ ("PySwigPacked_type", "SwigPyPacked_type"),
+ ("pyseq", "swigpyseq"),
+ ("pyswigobject_type", "swigpyobject_type"),
+ ("pyswigpacked_type", "swigpypacked_type"),
+ ]
+
+res = [(re.compile("\\b(%s)\\b"%oldname), newname) for oldname, newname in symbols]
+
+def patch_file(fn):
+ newf = []
+ changed = False
+ for line in open(fn):
+ for r, newname in res:
+ line, n = r.subn(newname, line)
+ if n>0:
+ changed = True
+ newf.append(line)
+
+ if changed:
+ copyfile(fn, fn+".bak")
+ f = open(fn, "w")
+ f.write("".join(newf))
+ f.close()
+ return changed
+
+def main(fns):
+ for fn in fns:
+ try:
+ if patch_file(fn):
+ print "Patched file", fn
+ except IOError:
+ print "Error occured during patching", fn
+ return
+
+if __name__=="__main__":
+ if len(sys.argv) > 1:
+ main(sys.argv[1:])
+ else:
+ print "Patch your interface file for SWIG's Py* symbol name deprecation."
+ print "Usage:"
+ print " %s files..."%sys.argv[0]
+
+
diff --git a/autogen.sh b/autogen.sh
index 33f54aa7c..97916d9f3 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -2,9 +2,8 @@
# Bootstrap the development environment - add extra files needed to run configure.
# Note autoreconf should do what this file achieves, but it has a bug when working with automake!
-# The latest config.guess and config.sub should be copied into Tools/config and checked into SVN
-# when upgrading the autotools. Otherwise this script will ensure the latest is copied from
-# your autotool installation.
+# The latest config.guess and config.sub should be copied into Tools/config.
+# This script will ensure the latest is copied from your autotool installation.
set -e
set -x
@@ -13,3 +12,4 @@ ${ACLOCAL-aclocal} -I Tools/config
${AUTOHEADER-autoheader}
${AUTOMAKE-automake} --add-missing --copy --force-missing
${AUTOCONF-autoconf}
+cd CCache && ${AUTORECONF-autoreconf}
diff --git a/configure.in b/configure.in
index d5ce3e518..d4833ec4a 100644
--- a/configure.in
+++ b/configure.in
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl The macros which aren't shipped with the autotools are stored in the
dnl Tools/config directory in .m4 files.
-AC_INIT([swig],[1.3.37],[http://www.swig.org])
+AC_INIT([swig],[1.3.40],[http://www.swig.org])
AC_PREREQ(2.58)
AC_CONFIG_SRCDIR([Source/Swig/swig.h])
AC_CONFIG_AUX_DIR([Tools/config])
@@ -21,26 +21,83 @@ AH_BOTTOM([
#endif
])
-dnl Checks for programs.
+dnl Check for programs that a user requires to build SWIG
AC_PROG_CC
AC_PROG_CXX
-AC_PROG_YACC
AC_EXEEXT
AC_OBJEXT
-AC_PROG_RANLIB
AM_PROG_CC_C_O # Needed for subdir-objects in AUTOMAKE_OPTIONS
-AC_CHECK_PROGS(AR, ar aal, ar)
-AC_SUBST(AR)
AC_COMPILE_WARNINGS # Increase warning levels
AC_DEFINE_UNQUOTED(SWIG_CXX, ["$CXX"], [Compiler that built SWIG])
AC_DEFINE_UNQUOTED(SWIG_PLATFORM, ["$build"], [Platform that SWIG is built for])
-
dnl Checks for header files.
AC_HEADER_STDC
+dnl Checks for types.
+AC_LANG_PUSH([C++])
+AC_CHECK_TYPES([bool])
+AC_LANG_POP([C++])
+
+dnl Look for popen
+AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval")
+if test x"${with_popen}" = xno ; then
+AC_MSG_NOTICE([Disabling popen])
+else
+AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen]))
+fi
+
+dnl Look for RxSpencer
+AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes")
+if test x"${with_rxspencer}" = xyes ; then
+#check first for the header
+ AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no")
+ if test x"${with_rxspencer}" = xyes ; then
+# now check for the library
+ AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no")
+ fi
+ if test x"${with_rxspencer}" = xyes ; then
+# library and header are available
+ AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available])
+ LIBS="$LIBS -lrxspencer"
+ else
+ AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html])
+ fi
+fi
+
+dnl CCache
+AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes])
+AC_MSG_CHECKING([whether to enable ccache-swig])
+AC_MSG_RESULT([$enable_ccache])
+
+if test "$enable_ccache" = yes; then
+ AC_CONFIG_SUBDIRS(CCache)
+ ENABLE_CCACHE=1
+fi
+AC_SUBST(ENABLE_CCACHE)
+
+
+echo ""
+echo "Checking packages required for SWIG developers."
+echo "Note : None of the following packages are required for users to compile and install SWIG"
+echo ""
+
+AC_PROG_YACC
+AC_PROG_RANLIB
+AC_CHECK_PROGS(AR, ar aal, ar)
+AC_SUBST(AR)
+AC_CHECK_PROGS(YODL2MAN, yodl2man)
+AC_CHECK_PROGS(YODL2HTML, yodl2html)
+
+
+echo ""
+echo "Checking for installed target languages and other information in order to compile and run the examples."
+echo "Note : None of the following packages are required for users to compile and install SWIG"
+echo ""
+
+
dnl How to specify include directories that may be system directories.
# -I should not be used on system directories (GCC)
if test "$GCC" = yes; then
@@ -50,21 +107,9 @@ else
fi
-dnl Checks for types.
-AC_LANG_PUSH([C++])
-AC_CHECK_TYPES([bool])
-AC_LANG_POP([C++])
-
+dnl Info for building shared libraries ... in order to run the examples
-# Set info about shared libraries.
-AC_SUBST(SO)
-AC_SUBST(LDSHARED)
-AC_SUBST(CCSHARED)
-AC_SUBST(CXXSHARED)
-AC_SUBST(TRYLINKINGWITHCXX)
-AC_SUBST(LINKFORSHARED)
-
-# SO is the extension of shared libraries `(including the dot!)
+# SO is the extension of shared libraries (including the dot!)
AC_MSG_CHECKING(SO)
if test -z "$SO"
then
@@ -201,7 +246,6 @@ then
esac
fi
AC_MSG_RESULT($RPATH)
-AC_SUBST(RPATH)
# LINKFORSHARED are the flags passed to the $(CC) command that links
# the a few executables -- this is only needed for a few systems
@@ -221,6 +265,15 @@ then
fi
AC_MSG_RESULT($LINKFORSHARED)
+# Set info about shared libraries.
+AC_SUBST(SO)
+AC_SUBST(LDSHARED)
+AC_SUBST(CCSHARED)
+AC_SUBST(CXXSHARED)
+AC_SUBST(TRYLINKINGWITHCXX)
+AC_SUBST(LINKFORSHARED)
+AC_SUBST(RPATH)
+
# This variation is needed on OS-X because there is no (apparent) consistency in shared library naming.
# Sometimes .bundle works, but sometimes .so is needed. It depends on the target language
@@ -243,10 +296,10 @@ case $host in
*) GUILE_SO=$SO;;
esac
-AC_SUBST(PHP4_SO)
+AC_SUBST(PHP_SO)
case $host in
- *-*-darwin*) PHP4_SO=.so;;
- *) PHP4_SO=$SO;;
+ *-*-darwin*) PHP_SO=.so;;
+ *) PHP_SO=$SO;;
esac
AC_SUBST(MZSCHEME_SO)
@@ -269,46 +322,6 @@ case $host in
esac
-
-echo ""
-echo "Checking for installed packages."
-echo "Note : None of the following packages are required to compile SWIG"
-echo ""
-
-#----------------------------------------------------------------
-# Look for popen
-#----------------------------------------------------------------
-
-AC_ARG_WITH(popen, AS_HELP_STRING([--without-popen], [Disable popen]), with_popen="$withval")
-if test x"${with_popen}" = xno ; then
-AC_MSG_NOTICE([Disabling popen])
-else
-AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen]))
-fi
-
-#----------------------------------------------------------------
-# Look for RxSpencer
-#----------------------------------------------------------------
-
-AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes")
-if test x"${with_rxspencer}" = xyes ; then
-#check first for the header
- AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no")
- if test x"${with_rxspencer}" = xyes ; then
-# now check for the library
- AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no")
- fi
- if test x"${with_rxspencer}" = xyes ; then
-# library and header are available
- AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available])
- LIBS="$LIBS -lrxspencer"
- else
- AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html])
- fi
-fi
-
-#----------------------------------------------------------------
-
# Check for specific libraries. Used for SWIG examples
AC_CHECK_LIB(dl, dlopen) # Dynamic linking for SunOS/Solaris and SYSV
AC_CHECK_LIB(dld, shl_load) # Dynamic linking for HP-UX
@@ -573,7 +586,7 @@ else
# First figure out the name of the Python executable
if test "x$PYBIN" = xyes; then
-AC_CHECK_PROGS(PYTHON, python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python)
+AC_CHECK_PROGS(PYTHON, [python python2.8 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0 python1.6 python1.5 python1.4 python])
else
PYTHON="$PYBIN"
fi
@@ -657,6 +670,107 @@ AC_SUBST(PYLIB)
AC_SUBST(PYLINK)
AC_SUBST(PYTHONDYNAMICLINKING)
+
+#----------------------------------------------------------------
+# Look for Python 3.x
+#----------------------------------------------------------------
+
+# mostly copy & pasted from "Look for Python" section,
+# did some trim, fix and rename
+
+PY3INCLUDE=
+PY3LIB=
+PY3PACKAGE=
+
+AC_ARG_WITH(python3, AS_HELP_STRING([--without-python3], [Disable Python 3.x support])
+AS_HELP_STRING([--with-python3=path], [Set location of Python 3.x executable]),[ PY3BIN="$withval"], [PY3BIN=yes])
+
+# First, check for "--without-python3" or "--with-python3=no".
+if test x"${PY3BIN}" = xno -o x"${with_alllang}" = xno ; then
+AC_MSG_NOTICE([Disabling Python 3.x support])
+else
+# First figure out the name of the Python3 executable
+
+if test "x$PY3BIN" = xyes; then
+ AC_CHECK_PROGS(PYTHON3, [python3 python3.0 python3.1])
+else
+ PYTHON3="$PY3BIN"
+fi
+
+# Check for Python 3.x development tools (header files, static library and python3-config)
+if test "x$PYTHON3" = x; then
+ AC_CHECK_PROGS(PY3CONFIG, [python3-config python3.0-config python3.1-config])
+else
+ AC_CHECK_PROGS(PY3CONFIG, [$PYTHON3-config python3-config python3.0-config python3.1-config])
+fi
+
+if test -n "$PYTHON3" -a -n "$PY3CONFIG"; then
+ AC_MSG_CHECKING([for Python 3.x prefix])
+ PY3PREFIX=`($PY3CONFIG --prefix) 2>/dev/null`
+ AC_MSG_RESULT($PY3PREFIX)
+ AC_MSG_CHECKING(for Python 3.x exec-prefix)
+ PY3EPREFIX=`($PY3CONFIG --exec-prefix) 2>/dev/null`
+ AC_MSG_RESULT($PY3EPREFIX)
+
+ # Note: I could not think of a standard way to get the version string from different versions.
+ # This trick pulls it out of the file location for a standard library file.
+
+ AC_MSG_CHECKING([for Python 3.x version])
+
+ # Need to do this hack since autoconf replaces __file__ with the name of the configure file
+ filehack="file__"
+ PY3VERSION=`($PYTHON3 -c "import string,operator,os.path; print(operator.getitem(os.path.split(operator.getitem(os.path.split(string.__$filehack),0)),1))")`
+ AC_MSG_RESULT($PY3VERSION)
+
+ # Find the directory for libraries this is necessary to deal with
+ # platforms that can have apps built for multiple archs: e.g. x86_64
+ AC_MSG_CHECKING([for Python 3.x lib dir])
+ PY3LIBDIR=`($PYTHON3 -c "import sys; print(sys.lib)") 2>/dev/null`
+ if test -z "$PY3LIBDIR"; then
+ # some dists don't have sys.lib so the best we can do is assume lib
+ PY3LIBDIR="lib"
+ fi
+ AC_MSG_RESULT($PY3LIBDIR)
+
+ # Set the include directory
+
+ AC_MSG_CHECKING([for Python 3.x header files])
+ PY3INCLUDE=`($PY3CONFIG --includes) 2>/dev/null`
+ AC_MSG_RESULT($PY3INCLUDE)
+
+ # Set the library directory blindly. This probably won't work with older versions
+ AC_MSG_CHECKING([for Python 3.x library])
+ dirs="$PY3VERSION/config $PY3VERSION/$PY3LIBDIR python/$PY3LIBDIR"
+ for i in $dirs; do
+ if test -d $PY3EPREFIX/$PY3LIBDIR/$i; then
+ PY3LIB="$PY3EPREFIX/$PY3LIBDIR/$i"
+ break
+ fi
+ done
+ if test -z "$PY3LIB"; then
+ AC_MSG_RESULT([Not found])
+ else
+ AC_MSG_RESULT($PY3LIB)
+ fi
+
+ PY3LINK="-l$PY3VERSION"
+fi
+
+# Cygwin (Windows) needs the library for dynamic linking
+case $host in
+*-*-cygwin* | *-*-mingw*) PYTHON3DYNAMICLINKING="-L$PYLIB $PY3LINK"
+ DEFS="-DUSE_DL_IMPORT $DEFS" PY3INCLUDE="$PY3INCLUDE"
+ ;;
+*)PYTHON3DYNAMICLINKING="";;
+esac
+fi
+
+AC_SUBST(PY3INCLUDE)
+AC_SUBST(PY3LIB)
+AC_SUBST(PY3LINK)
+AC_SUBST(PYTHON3DYNAMICLINKING)
+
+
#----------------------------------------------------------------
# Look for Perl5
#----------------------------------------------------------------
@@ -1081,25 +1195,35 @@ AC_ARG_WITH(mzc, AS_HELP_STRING([--with-mzc=path], [Set location of MzScheme's m
# First, check for "--without-mzscheme" or "--with-mzscheme=no".
if test x"${MZSCHEMEBIN}" = xno -o x"${with_alllang}" = xno ; then
-AC_MSG_NOTICE([Disabling MzScheme])
-MZC=
-else
-
-if test "x$MZSCHEMEBIN" = xyes; then
- AC_PATH_PROG(MZSCHEME, mzscheme)
+ AC_MSG_NOTICE([Disabling MzScheme])
+ MZC=
else
- MZSCHEME="$MZSCHEMEBIN"
-fi
-
-if test -z "$MZCBIN"; then
- AC_PATH_PROG(MZC, mzc)
-fi
+ if test "x$MZSCHEMEBIN" = xyes; then
+ AC_PATH_PROG(MZSCHEME, mzscheme)
+ else
+ MZSCHEME="$MZSCHEMEBIN"
+ fi
+
+ if test -z "$MZCBIN"; then
+ AC_PATH_PROG(MZC, mzc)
+ fi
-if test -n "$MZSCHEME"; then
-AC_MSG_CHECKING(for MzScheme dynext object)
-MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) (expand-for-link-variant (current-standard-link-libraries)))))'`
-AC_MSG_RESULT($MZDYNOBJ)
-fi
+ if test -n "$MZSCHEME"; then
+ AC_MSG_CHECKING(for MzScheme dynext object)
+ MZDYNOBJ=`$MZSCHEME --eval '(begin (require dynext/link) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (printf "~a" x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null`
+ if test -f "$MZDYNOBJ"; then
+ MZDYNOBJ="$MZDYNOBJ"
+ else
+ # older versions (3.72 approx and earlier)
+ MZDYNOBJ=`$MZSCHEME --mute-banner --version --eval '(begin (require (lib "link.ss" "dynext")) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x) (display " ")) ((current-make-standard-link-libraries)))) (with-handlers (((lambda args #t) (lambda args #f))) (for-each (lambda (x) (display x)) (expand-for-link-variant (current-standard-link-libraries)))))' 2>/dev/null`
+ fi
+ if test -f "$MZDYNOBJ"; then
+ AC_MSG_RESULT($MZDYNOBJ)
+ else
+ AC_MSG_RESULT(not found)
+ MZDYNOBJ=""
+ fi
+ fi
fi
AC_SUBST(MZDYNOBJ)
@@ -1129,7 +1253,7 @@ fi
AC_MSG_CHECKING(for Ruby header files)
if test -n "$RUBY"; then
RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
- if test "$RUBYDIR" != ""; then
+ if test x"$RUBYDIR" != x""; then
dirs="$RUBYDIR"
RUBYINCLUDE=none
for i in $dirs; do
@@ -1228,37 +1352,37 @@ AC_SUBST(RUBYDYNAMICLINKING)
# Look for PHP
#-------------------------------------------------------------------------
-PHP4BIN=
+PHPBIN=
-AC_ARG_WITH(php4, AS_HELP_STRING([--without-php4], [Disable PHP])
-AS_HELP_STRING([--with-php4=path], [Set location of PHP executable]),[ PHP4BIN="$withval"], [PHP4BIN=yes])
+AC_ARG_WITH(php, AS_HELP_STRING([--without-php], [Disable PHP])
+AS_HELP_STRING([--with-php=path], [Set location of PHP executable]),[ PHPBIN="$withval"], [PHPBIN=yes])
-# First, check for "--without-php4" or "--with-php4=no".
-if test x"${PHP4BIN}" = xno -o x"${with_alllang}" = xno ; then
+# First, check for "--without-php" or "--with-php=no".
+if test x"${PHPBIN}" = xno -o x"${with_alllang}" = xno ; then
AC_MSG_NOTICE([Disabling PHP])
- PHP4=
+ PHP=
else
- if test "x$PHP4BIN" = xyes; then
- AC_CHECK_PROGS(PHP4, [php5 php])
+ if test "x$PHPBIN" = xyes; then
+ AC_CHECK_PROGS(PHP, [php5 php])
else
- PHP4=$PHP4BIN
+ PHP=$PHPBIN
fi
AC_MSG_CHECKING(for PHP header files)
dnl /usr/bin/php5 -> /usr/bin/php-config5
- case $PHP4 in
+ case $PHP in
*5)
- PHP4CONFIG=`echo "$PHP4"|sed 's/5$/-config5/'` ;;
+ PHPCONFIG=`echo "$PHP"|sed 's/5$/-config5/'` ;;
*)
- PHP4CONFIG=$PHP4-config ;;
+ PHPCONFIG=$PHP-config ;;
esac
- php_version=`$PHP4CONFIG --version 2>/dev/null`
+ php_version=`$PHPCONFIG --version 2>/dev/null`
case $php_version in
5*)
- PHP4INC=`$PHP4CONFIG --includes 2>/dev/null`
- if test -n "$PHP4INC"; then
- AC_MSG_RESULT($PHP4INC)
+ PHPINC=`$PHPCONFIG --includes 2>/dev/null`
+ if test -n "$PHPINC"; then
+ AC_MSG_RESULT($PHPINC)
else
AC_MSG_RESULT(not found)
fi
@@ -1267,8 +1391,8 @@ else
AC_MSG_RESULT([found PHP $version, but only PHP 5 is supported]) ;;
esac
fi
-AC_SUBST(PHP4)
-AC_SUBST(PHP4INC)
+AC_SUBST(PHP)
+AC_SUBST(PHPINC)
#----------------------------------------------------------------
# Look for ocaml
@@ -2015,11 +2139,17 @@ AC_SUBST(SKIP_OCTAVE)
SKIP_PYTHON=
-if test -z "$PYINCLUDE" || test -z "$PYLIB" ; then
+if (test -z "$PYINCLUDE" || test -z "$PYLIB") &&
+ (test -z "$PY3INCLUDE" || test -z "PY3LIB") ; then
SKIP_PYTHON="1"
fi
AC_SUBST(SKIP_PYTHON)
+SKIP_PYTHON3=
+if test -z "$PY3INCLUDE" || test -z "$PY3LIB" ; then
+ SKIP_PYTHON3="1"
+fi
+AC_SUBST(SKIP_PYTHON3)
SKIP_JAVA=
if test -z "$JAVA" || test -z "$JAVAC" || test -z "$JAVAINC" ; then
@@ -2042,7 +2172,7 @@ AC_SUBST(SKIP_GUILESCM)
SKIP_MZSCHEME=
-if test -z "$MZC" ; then
+if test -z "$MZC" || test -z "$MZDYNOBJ" ; then
SKIP_MZSCHEME="1"
fi
AC_SUBST(SKIP_MZSCHEME)
@@ -2055,11 +2185,11 @@ fi
AC_SUBST(SKIP_RUBY)
-SKIP_PHP4=
-if test -z "$PHP4" || test -z "$PHP4INC" ; then
- SKIP_PHP4="1"
+SKIP_PHP=
+if test -z "$PHP" || test -z "$PHPINC" ; then
+ SKIP_PHP="1"
fi
-AC_SUBST(SKIP_PHP4)
+AC_SUBST(SKIP_PHP)
SKIP_OCAML=
@@ -2157,6 +2287,7 @@ AC_SUBST(SKIP_GCJ)
# Miscellaneous
#----------------------------------------------------------------
+
# Root directory
# Translate path for native Windows compilers for use with 'make check'
ROOT_DIR=`pwd`
@@ -2189,7 +2320,6 @@ case $host in
esac
AC_DEFINE_UNQUOTED(SWIG_LIB_WIN_UNIX, ["$SWIG_LIB_WIN_UNIX"], [Directory for SWIG system-independent libraries (Unix install on native Windows)])
-
AC_CONFIG_FILES([ \
Makefile \
swig.spec \
@@ -2208,7 +2338,7 @@ AC_CONFIG_FILES([ \
Examples/test-suite/ocaml/Makefile \
Examples/test-suite/octave/Makefile \
Examples/test-suite/perl5/Makefile \
- Examples/test-suite/php4/Makefile \
+ Examples/test-suite/php/Makefile \
Examples/test-suite/pike/Makefile \
Examples/test-suite/python/Makefile \
Examples/test-suite/ruby/Makefile \
@@ -2223,7 +2353,7 @@ AC_CONFIG_FILES([ \
Lib/ocaml/swigp4.ml
])
AC_CONFIG_FILES([preinst-swig], [chmod +x preinst-swig])
-AC_OUTPUT
-
+AC_CONFIG_FILES([CCache/ccache_swig_config.h])
+AC_OUTPUT
dnl configure.in ends here