From a615d8dd1d27bcd0df78c90c15fc8cce4290360e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 20 Jul 2010 22:58:37 +0000
Subject: [PATCH 0001/1045] minor clarification about directors
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12163 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Java.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index f572ffa32..d014feef6 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -166,7 +166,7 @@ SWIG wraps C/C++ code using Java proxy classes and is very useful if you want to
If only one or two JNI functions are needed then using SWIG may be overkill.
SWIG enables a Java program to easily call into C/C++ code from Java.
Historically, SWIG was not able to generate any code to call into Java code from C++.
-However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods.
+However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods via the director feature.
From 1f939323a4e0700172db875ebd3ef9c9a7b4c33a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 16:59:08 +0000
Subject: [PATCH 0002/1045] Fix PYTHONPATH value when running Python tests
outside source directory.
PYTHONPATH needs to include the current directory and not (just) the source
directory as the SWIG-generated files are produced here and not under the
source directory when the top build directory is different from it.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12166 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/python/Makefile.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 4938ddc27..a05542b70 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -117,7 +117,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Runs the testcase. A testcase is only run if
# 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)
+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)
From ac5ddb03150577ab5d7f53bde0c1aa801e975855 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 16:59:29 +0000
Subject: [PATCH 0003/1045] Make argument of DohWrite() const.
Writing a buffer to a DOH object doesn't modify so it should be const.
This allows the code using const pointers to pass them to DohWrite() without
neither the casts nor gcc warnings.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12167 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/DOH/base.c | 2 +-
Source/DOH/doh.h | 2 +-
Source/DOH/dohint.h | 2 +-
Source/DOH/file.c | 2 +-
Source/DOH/string.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index 36ceb7ae3..cfbd2bdc4 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -645,7 +645,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
* DohWrite()
* ----------------------------------------------------------------------------- */
-int DohWrite(DOH *obj, void *buffer, int length) {
+int DohWrite(DOH *obj, const void *buffer, int length) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo;
if (DohCheck(obj)) {
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index 1ed196058..e46d103de 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -221,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
/* File methods */
-extern int DohWrite(DOHFile * obj, void *buffer, int length);
+extern int DohWrite(DOHFile * obj, const void *buffer, int length);
extern int DohRead(DOHFile * obj, void *buffer, int length);
extern int DohSeek(DOHFile * obj, long offset, int whence);
extern long DohTell(DOHFile * obj);
diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h
index 661bed075..3d812b849 100644
--- a/Source/DOH/dohint.h
+++ b/Source/DOH/dohint.h
@@ -43,7 +43,7 @@ typedef struct {
/* File methods */
typedef struct {
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
- int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
+ int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
int (*doh_putc) (DOH *obj, int ch); /* Put character */
int (*doh_getc) (DOH *obj); /* Get character */
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index a9ee332bf..11482fa7f 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -67,7 +67,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
* File_write()
* ----------------------------------------------------------------------------- */
-static int File_write(DOH *fo, void *buffer, int len) {
+static int File_write(DOH *fo, const void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
int ret = (int) fwrite(buffer, 1, len, f->filep);
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index bd36c4094..05ae6e963 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -419,7 +419,7 @@ static int String_read(DOH *so, void *buffer, int len) {
/* -----------------------------------------------------------------------------
* int String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
-static int String_write(DOH *so, void *buffer, int len) {
+static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
String *s = (String *) ObjData(so);
s->hashkey = -1;
From f2a5ef0c57767d972edc583c66ef31cb32a53b1c Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 16:59:45 +0000
Subject: [PATCH 0004/1045] Document advanced %rename capabilities.
Document the possibility to apply %rename to all declarations or only those of
a particular type. Also document extended format strings used with it and the
functions which can be used in them.
Also clarify that %ignore is basically just a %rename alias.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12168 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 194 +++++++++++++++++++++++++++++++++++++++++--
1 file changed, 188 insertions(+), 6 deletions(-)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index d523bee77..e68003325 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1661,6 +1661,7 @@ generate a warning message. Simply change the directives to %immutable;5.4.7 Renaming and ignoring declarations
+
5.4.7.1 Simple renaming of specific identifiers
Normally, the name of a C declaration is used when that declaration is
@@ -1741,12 +1742,6 @@ to add conditional compilation to the header. However, it should be stressed t
declarations. If you need to remove a whole section of problematic code, the SWIG preprocessor should be used instead.
-
-More powerful variants of %rename and %ignore directives can be used to help
-wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
-Ambiguity resolution and renaming section in the C++ chapter.
-
-
Compatibility note: Older versions of SWIG provided a special %name directive for renaming declarations.
For example:
@@ -1763,6 +1758,193 @@ This directive is still supported, but it is deprecated and should probably be a
directive is more powerful and better supports wrapping of raw header file information.
+
5.4.7.2 Advanced renaming support
+
+
+While writing %rename for specific declarations is simple enough,
+sometimes the same renaming rule needs to be applied to many, maybe all,
+identifiers in the SWIG input. For example, it may be necessary to apply some
+transformation to all the names in the target language to better follow its
+naming conventions, e.g. add a specific prefix to all the functions. Doing it
+for each function is impractical so SWIG supports applying a renaming rule to
+all declarations if the name of the identifier to be renamed is not specified:
+
+This also shows that the argument of %rename doesn't have to be a
+literal string but can be a printf()-like format string. In the
+simplest form, "%s" is replaced with the name of the original
+declaration, as shown above. However this is not always enough and SWIG
+provides extensions to the usual format string syntax to allow applying a
+(SWIG-defined) function to the argument. For example, to wrap all C functions
+do_something_long() as more Java-like doSomethingLong() you
+can use the "lowercamelcase" extended format specifier like this:
+
+Some functions can be parametrized, for example the "strip" one
+strips the provided prefix from its argument. The prefix is specified as part
+of the format string, following a colon after the function name:
+
+Here is the table summarizing all currently defined functions with an example
+of applying each one (notice that some of them have two names, a shorter one
+and a more descriptive one, but the two functions are otherwise equivalent):
+
+
+
+
Function
Returns
Example (in/out)
+
+
+
upper or uppercase
+
Upper-case version of the string.
+
Print
PRINT
+
+
+
lower or lowercase
+
Lower-case version of the string.
+
Print
print
+
+
+
title
+
String with first letter capitalized and the rest in lower case.
+
print
Print
+
+
+
firstuppercase
+
String with the first letter capitalized and the rest unchanged.
+
printIt
PrintIt
+
+
+
firstlowercase
+
String with the first letter in lower case and the rest unchanged.
+
PrintIt
printIt
+
+
+
ctitle or camelcase
+
String with capitalized first letter and any letter following an
+ underscore (which are removed in the process) and rest in lower case.
+
print_it
PrintIt
+
+
+
lctitle or lowercamelcase
+
String with every letter following an underscore (which is removed in
+ the process) capitalized and rest, including the first letter, in lower
+ case.
+
print_it
printIt
+
+
+
utitle or undercase
+
Lower case string with underscores inserted before every upper-case
+ letter in the original string and any number not at the end of string.
+ Logically, this is the reverse of ccase.
+
PrintIt
print_it
+
+
+
schemify
+
String with all underscores replaced with dashes, resulting in more
+ Lispers/Schemers-pleasing name.
+
print_it
print-it
+
+
+
strip:[prefix]
+
String without the given prefix or the original string if it doesn't
+ start with this prefix. Note that square brackets should be used
+ literally, e.g. %rename("strip:[wx]")
+
wxPrint
Print
+
+
+
command:cmd
+
Output of an external command cmd with the string passed to
+ it as input. Notice that this function is extremely slow compared to all
+ the other ones as it involves spawning a separate process and using it for
+ many declarations is not recommended. The cmd is not enclosed in
+ square brackets but must be terminated with a triple '<' sign,
+ e.g. %rename("command:tr -d aeiou <<<")
+ (nonsensical example removing all vowels)
+
Print
Prnt
+
+
+
+
+As before, everything that was said above about %rename also applies to
+%ignore. In fact, the latter is just a special case of the former and
+ignoring an identifier is the same as renaming it to the special
+"$ignore" value. So the following snippets
+
+
+
+
+%ignore print;
+
+
+
+
+and
+
+
+
+
+%rename("$ignore") print;
+
+
+
+
+are exactly equivalent and %rename can be used to selectively ignore
+multiple declarations using the previously described matching possibilities.
+
+
+
5.4.7.3 Limiting global renaming rules
+
+
+As explained in the previous sections, it is possible to either rename
+individual declarations or apply a rename rule to all of them at once. In
+practice, the latter is however rarely appropriate as there are always some
+exceptions to the general rules. To deal with them, the scope of an unnamed
+%rename can be limited using a second parameter.
+
+
+
+The simplest possibility is to match the declaration type, for example:
+
+
+
+%rename("%(title)s", %$isenumitem) "";
+
+
+
+will capitalize the names of all the enum elements but not change the case of
+the other declarations. Similarly, %$isclass, %$isfunction
+and %$isvariable can be used. Many other checks are possible and this
+documentation is not exhaustive, see "%rename predicates" section of
+Lib/swig.swg for the full list of supported match expressions.
+
+
+
+Finally, even more powerful variants of %rename and %ignore directives can be used to help
+wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
+Ambiguity resolution and renaming section in the C++ chapter.
+
+
+
5.4.8 Default/optional arguments
From 6399502719dcc04c816536d7a4231e0164b4402f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:00:16 +0000
Subject: [PATCH 0005/1045] Add a check for PCRE library to configure.
We use standard AX_PATH_GENERIC() macro from Autoconf archive to do the check
to keep our own code as simple as possible. Notice that this script must be
used, just adding the include and library directories to {C,LD}FLAGS is not
enough, notably -DPCRE_STATIC which is output by pcre-config for static builds
only is crucial. Also use LIBS instead of LDFLAGS to fix linking when using
static libraries.
Also note that this allows to pass PCRE_CONFIG variable value to configure to
force the use of the specified script (and not the one first found in PATH),
which is especially important when cross-compiling.
Finally, PCRE is required by default now, --without-pcre must be explicitly
used to build without it.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12169 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Tools/config/ax_compare_version.m4 | 177 +++++++++++++++++++++++++++++
Tools/config/ax_path_generic.m4 | 142 +++++++++++++++++++++++
configure.in | 26 ++++-
3 files changed, 344 insertions(+), 1 deletion(-)
create mode 100644 Tools/config/ax_compare_version.m4
create mode 100644 Tools/config/ax_path_generic.m4
diff --git a/Tools/config/ax_compare_version.m4 b/Tools/config/ax_compare_version.m4
new file mode 100644
index 000000000..74dc0fdd9
--- /dev/null
+++ b/Tools/config/ax_compare_version.m4
@@ -0,0 +1,177 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+#
+# DESCRIPTION
+#
+# This macro compares two version strings. Due to the various number of
+# minor-version numbers that can exist, and the fact that string
+# comparisons are not compatible with numeric comparisons, this is not
+# necessarily trivial to do in a autoconf script. This macro makes doing
+# these comparisons easy.
+#
+# The six basic comparisons are available, as well as checking equality
+# limited to a certain number of minor-version levels.
+#
+# The operator OP determines what type of comparison to do, and can be one
+# of:
+#
+# eq - equal (test A == B)
+# ne - not equal (test A != B)
+# le - less than or equal (test A <= B)
+# ge - greater than or equal (test A >= B)
+# lt - less than (test A < B)
+# gt - greater than (test A > B)
+#
+# Additionally, the eq and ne operator can have a number after it to limit
+# the test to that number of minor versions.
+#
+# eq0 - equal up to the length of the shorter version
+# ne0 - not equal up to the length of the shorter version
+# eqN - equal up to N sub-version levels
+# neN - not equal up to N sub-version levels
+#
+# When the condition is true, shell commands ACTION-IF-TRUE are run,
+# otherwise shell commands ACTION-IF-FALSE are run. The environment
+# variable 'ax_compare_version' is always set to either 'true' or 'false'
+# as well.
+#
+# Examples:
+#
+# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
+#
+# would both be true.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
+#
+# would both be false.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
+#
+# would be true because it is only comparing two minor versions.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
+#
+# would be true because it is only comparing the lesser number of minor
+# versions of the two values.
+#
+# Note: The characters that separate the version numbers do not matter. An
+# empty string is the same as version 0. OP is evaluated by autoconf, not
+# configure, so must be a string, not a variable.
+#
+# The author would like to acknowledge Guido Draheim whose advice about
+# the m4_case and m4_ifvaln functions make this macro only include the
+# portions necessary to perform the specific comparison specified by the
+# OP argument in the final configure script.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Tim Toolan
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 11
+
+dnl #########################################################################
+AC_DEFUN([AX_COMPARE_VERSION], [
+ AC_REQUIRE([AC_PROG_AWK])
+
+ # Used to indicate true or false condition
+ ax_compare_version=false
+
+ # Convert the two version strings to be compared into a format that
+ # allows a simple string comparison. The end result is that a version
+ # string of the form 1.12.5-r617 will be converted to the form
+ # 0001001200050617. In other words, each number is zero padded to four
+ # digits, and non digits are removed.
+ AS_VAR_PUSHDEF([A],[ax_compare_version_A])
+ A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ AS_VAR_PUSHDEF([B],[ax_compare_version_B])
+ B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
+ dnl # then the first line is used to determine if the condition is true.
+ dnl # The sed right after the echo is to remove any indented white space.
+ m4_case(m4_tolower($2),
+ [lt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [gt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [le],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],
+ [ge],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],[
+ dnl Split the operator from the subversion count if present.
+ m4_bmatch(m4_substr($2,2),
+ [0],[
+ # A count of zero means use the length of the shorter version.
+ # Determine the number of characters in A and B.
+ ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
+ ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
+
+ # Set A to no more than B's length and B to no more than A's length.
+ A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
+ ],
+ [[0-9]+],[
+ # A count greater than zero means use only that many subversions
+ A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ ],
+ [.+],[
+ AC_WARNING(
+ [illegal OP numeric parameter: $2])
+ ],[])
+
+ # Pad zeros at end of numbers to make same length.
+ ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
+ B="$B`echo $A | sed 's/./0/g'`"
+ A="$ax_compare_version_tmp_A"
+
+ # Check for equality or inequality as necessary.
+ m4_case(m4_tolower(m4_substr($2,0,2)),
+ [eq],[
+ test "x$A" = "x$B" && ax_compare_version=true
+ ],
+ [ne],[
+ test "x$A" != "x$B" && ax_compare_version=true
+ ],[
+ AC_WARNING([illegal OP parameter: $2])
+ ])
+ ])
+
+ AS_VAR_POPDEF([A])dnl
+ AS_VAR_POPDEF([B])dnl
+
+ dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
+ if test "$ax_compare_version" = "true" ; then
+ m4_ifvaln([$4],[$4],[:])dnl
+ m4_ifvaln([$5],[else $5])dnl
+ fi
+]) dnl AX_COMPARE_VERSION
diff --git a/Tools/config/ax_path_generic.m4 b/Tools/config/ax_path_generic.m4
new file mode 100644
index 000000000..4db2da11b
--- /dev/null
+++ b/Tools/config/ax_path_generic.m4
@@ -0,0 +1,142 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_path_generic.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PATH_GENERIC(LIBRARY,[MINIMUM-VERSION,[SED-EXPR-EXTRACTOR]],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[CONFIG-SCRIPTS],[CFLAGS-ARG],[LIBS-ARG])
+#
+# DESCRIPTION
+#
+# Runs the LIBRARY-config script and defines LIBRARY_CFLAGS and
+# LIBRARY_LIBS
+#
+# The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION
+# is specified, the script must also support the `--version' arg. If the
+# `--with-library-[exec-]prefix' arguments to ./configure are given, it
+# must also support `--prefix' and `--exec-prefix'. Prefereable use
+# CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and
+# LIBS-ARG instead of `--libs`, if given.
+#
+# The SED-EXPR-EXTRACTOR parameter representes the expression used in sed
+# to extract the version number. Use it if your 'foo-config --version'
+# dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'.
+#
+# Example:
+#
+# AX_PATH_GENERIC(Foo, 1.0.0)
+#
+# would run `foo-config --version' and check that it is at least 1.0.0, if
+# successful the following variables would be defined and substituted:
+#
+# FOO_CFLAGS to `foo-config --cflags`
+# FOO_LIBS to `foo-config --libs`
+#
+# Example:
+#
+# AX_PATH_GENERIC([Bar],,,[
+# AC_MSG_ERROR([Cannot find Bar library])
+# ])
+#
+# would check for bar-config program, defining and substituting the
+# following variables:
+#
+# BAR_CFLAGS to `bar-config --cflags`
+# BAR_LIBS to `bar-config --libs`
+#
+# This macro is a rearranged version of AC_PATH_GENERIC from Angus Lees.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Francesco Salvestrini
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 10
+
+AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC])
+AC_DEFUN([AX_PATH_GENERIC],[
+ AC_REQUIRE([AC_PROG_SED])
+
+ dnl we're going to need uppercase and lowercase versions of the
+ dnl string `LIBRARY'
+ pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
+ pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
+
+ AC_ARG_WITH(DOWN-prefix,[AS_HELP_STRING([--with-]DOWN[-prefix=PREFIX], [Prefix where $1 is installed (optional)])],
+ DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
+ AC_ARG_WITH(DOWN-exec-prefix,[AS_HELP_STRING([--with-]DOWN[-exec-prefix=EPREFIX], [Exec prefix where $1 is installed (optional)])],
+ DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
+
+ AC_ARG_VAR(UP[]_CONFIG, [config script used for $1])
+ AC_ARG_VAR(UP[]_CFLAGS, [CFLAGS used for $1])
+ AC_ARG_VAR(UP[]_LIBS, [LIBS used for $1])
+
+ AS_IF([test x$DOWN[]_config_exec_prefix != x],[
+ DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
+ AS_IF([test x${UP[]_CONFIG+set} != xset],[
+ UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
+ ])
+ ])
+ AS_IF([test x$DOWN[]_config_prefix != x],[
+ DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
+ AS_IF([test x${UP[]_CONFIG+set} != xset],[
+ UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
+ ])
+ ])
+
+ AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no])
+ AS_IF([test "$UP[]_CONFIG" == "no"],[
+ :
+ $5
+ ],[
+ dnl Get the CFLAGS from LIBRARY-config script
+ AS_IF([test x"$7" == x],[
+ UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
+ ],[
+ UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`"
+ ])
+
+ dnl Get the LIBS from LIBRARY-config script
+ AS_IF([test x"$8" == x],[
+ UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
+ ],[
+ UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`"
+ ])
+
+ AS_IF([test x"$2" != x],[
+ dnl Check for provided library version
+ AS_IF([test x"$3" != x],[
+ dnl Use provided sed expression
+ DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e $3`"
+ ],[
+ DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`"
+ ])
+
+ AC_MSG_CHECKING([for $1 ($DOWN[]_version) >= $2])
+ AX_COMPARE_VERSION($DOWN[]_version,[ge],[$2],[
+ AC_MSG_RESULT([yes])
+
+ AC_SUBST(UP[]_CFLAGS)
+ AC_SUBST(UP[]_LIBS)
+ :
+ $4
+ ],[
+ AC_MSG_RESULT([no])
+ :
+ $5
+ ])
+ ],[
+ AC_SUBST(UP[]_CFLAGS)
+ AC_SUBST(UP[]_LIBS)
+ :
+ $4
+ ])
+ ])
+
+ popdef([UP])
+ popdef([DOWN])
+])
diff --git a/configure.in b/configure.in
index f08ad4615..e5e2752d9 100644
--- a/configure.in
+++ b/configure.in
@@ -49,7 +49,31 @@ 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
+dnl PCRE
+AC_ARG_WITH([pcre],
+ [AS_HELP_STRING([--without-pcre],
+ [Disable support for regular expressions using PCRE])],
+ [],
+ [with_pcre=yes])
+
+AS_IF([test "x$with_pcre" != xno],
+ [AX_PATH_GENERIC([pcre],
+ [], dnl Minimal version of PCRE we need -- accept any
+ [], dnl custom sed script for version parsing is not needed
+ [AC_DEFINE([HAVE_PCRE], [1], [Define if you have PCRE library])
+ LIBS="$LIBS $PCRE_LIBS"
+ CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
+ ],
+ [AC_MSG_FAILURE(
+ Can't find pcre-config script from PCRE (Perl Compatible Regular
+ Expressions) library package. You need to either download PCRE from
+ www.pcre.org and install it or use --without-pcre configure option to
+ disable regular expressions support in SWIG.)
+ ])
+ ])
+
+
+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
From c4e9043288e2136dd7ae9e0515ad79164ad00d95 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:00:37 +0000
Subject: [PATCH 0006/1045] Add support for regex encoder for %rename.
This allows to write %rename("%(regex:/pattern/subst/)s") to apply a
regex-based replacement to a declaration name.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12170 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 12 +++++
Doc/Manual/SWIG.html | 12 +++++
Source/Swig/misc.c | 106 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 130 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index 63af7206d..9954ae05b 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -9,6 +9,18 @@ Version 2.0.1 (in progress)
Fix wrapping of function pointers and member function pointers when the function
returns by reference.
+2010-07-13: vadz
+ Add the new "regex" encoder that can be used in %rename, e.g.
+
+ %rename("regex:/(\\w+)_(.*)/\\2/") "";
+
+ to remove any alphabetical prefix from all identifiers. The syntax
+ of the regular expressions is Perl-like and PCRE library
+ (http://www.pcre.org/) is used to implement this feature but notice
+ that backslashes need to be escaped as usual inside C strings.
+
+ Original patch from Torsten Landschoff.
+
2010-07-08: wsfulton
Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
the "unref" feature when used on classes with non-public destructors.
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index e68003325..3fb1e86cc 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1871,6 +1871,18 @@ and a more descriptive one, but the two functions are otherwise equivalent):
literally, e.g. %rename("strip:[wx]")
wxPrint
Print
+
+
regex:/pattern/subst/
+
String after (Perl-like) regex substitution operation. This function
+ allows to apply arbitrary regular expressions to the identifier names. The
+ pattern part is a regular expression in Perl syntax (as supported
+ by PCRE) and the subst string
+ can contain back-references introduced by '\' or, as backslashes need
+ to be escaped in C strings, rather by "\\". For example, to remove
+ any alphabetic prefix before an underscore you could use the following directive:
+ %rename("regex:/(\\w+)_(.*)/\\2/")
+
Prefix_Print
Print
+
command:cmd
Output of an external command cmd with the string passed to
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index f0a9155eb..b23a99b60 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -1214,6 +1214,111 @@ String *Swig_string_rxspencer(String *s) {
}
#endif
+#ifdef HAVE_PCRE
+#include
+
+static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
+{
+ const char *pats, *pate;
+ const char *subs, *sube;
+
+ /* Locate the search pattern */
+ const char *p = Char(s);
+ if (*p++ != '/') goto err_out;
+ pats = p;
+ p = strchr(p, '/');
+ if (!p) goto err_out;
+ pate = p;
+
+ /* Locate the substitution string */
+ subs = ++p;
+ p = strchr(p, '/');
+ if (!p) goto err_out;
+ sube = p;
+
+ *pattern = NewStringWithSize(pats, pate - pats);
+ *subst = NewStringWithSize(subs, sube - subs);
+ *input = p + 1;
+ return 1;
+
+err_out:
+ Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
+ exit(1);
+}
+
+String *replace_captures(const char *input, String *subst, int captures[])
+{
+ String *result = NewStringEmpty();
+ const char *p = Char(subst);
+
+ while (*p) {
+ /* Copy part without substitutions */
+ const char *q = strchr(p, '\\');
+ if (!q) {
+ Write(result, p, strlen(p));
+ break;
+ }
+ Write(result, p, q - p);
+ p = q + 1;
+
+ /* Handle substitution */
+ if (*p == '\0') {
+ Putc('\\', result);
+ } else if (isdigit(*p)) {
+ int group = *p++ - '0';
+ int l = captures[group*2], r = captures[group*2 + 1];
+ if (l != -1) {
+ Write(result, input + l, r - l);
+ }
+ }
+ }
+
+ return result;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_string_regex()
+ *
+ * Executes a regexp substitution. For example:
+ *
+ * Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
+ * ----------------------------------------------------------------------------- */
+String *Swig_string_regex(String *s) {
+ const int pcre_options = 0;
+
+ String *res = 0;
+ pcre *compiled_pat = 0;
+ const char *pcre_error, *input;
+ int pcre_errorpos;
+ String *pattern = 0, *subst = 0;
+ int captures[30];
+
+ if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
+ compiled_pat = pcre_compile(
+ Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
+ if (!compiled_pat) {
+ Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
+ pcre_error, Char(pattern), pcre_errorpos);
+ exit(1);
+ }
+ pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
+ res = replace_captures(input, subst, captures);
+ }
+
+ DohDelete(pattern);
+ DohDelete(subst);
+ pcre_free(compiled_pat);
+ return res ? res : NewStringEmpty();
+}
+
+#else
+
+String *Swig_string_regex(String *s) {
+ Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
+ exit(1);
+}
+
+#endif
/* -----------------------------------------------------------------------------
* Swig_init()
@@ -1236,6 +1341,7 @@ void Swig_init() {
DohEncoding("rxspencer", Swig_string_rxspencer);
DohEncoding("schemify", Swig_string_schemify);
DohEncoding("strip", Swig_string_strip);
+ DohEncoding("regex", Swig_string_regex);
/* aliases for the case encoders */
DohEncoding("uppercase", Swig_string_upper);
From 0b2561f300484470478849a3aa5e1cb9d91b3942 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:00:59 +0000
Subject: [PATCH 0007/1045] Add a test case for the regex encoder inside
%rename.
Simple unit test checking that %rename("%(regex:...)") works as expected.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12171 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/common.mk | 1 +
.../python/rename_pcre_encoder_runme.py | 8 +++++++
Examples/test-suite/rename_pcre_encoder.i | 21 +++++++++++++++++++
3 files changed, 30 insertions(+)
create mode 100644 Examples/test-suite/python/rename_pcre_encoder_runme.py
create mode 100644 Examples/test-suite/rename_pcre_encoder.i
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index c1952543f..c7afb6647 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -284,6 +284,7 @@ CPP_TEST_CASES += \
rename4 \
rename_scope \
rename_strip_encoder \
+ rename_pcre_encoder \
restrict_cplusplus \
return_const_value \
return_value_scope \
diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py
new file mode 100644
index 000000000..f06c3d25a
--- /dev/null
+++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py
@@ -0,0 +1,8 @@
+from rename_pcre_encoder import *
+
+s = SomeWidget()
+a = AnotherWidget()
+a.DoSomething()
+
+evt = wxEVTSomeEvent()
+t = xUnchangedName()
diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i
new file mode 100644
index 000000000..568a2a82d
--- /dev/null
+++ b/Examples/test-suite/rename_pcre_encoder.i
@@ -0,0 +1,21 @@
+%module rename_pcre_encoder
+
+// strip the wx prefix from all identifiers except those starting with wxEVT
+%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") "";
+
+%inline %{
+
+class wxSomeWidget {
+};
+
+struct wxAnotherWidget {
+ void wxDoSomething() {}
+};
+
+class wxEVTSomeEvent {
+};
+
+class xUnchangedName {
+};
+
+%}
From 409ae85a745a68615778b0b5029b3ef933412f81 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:01:16 +0000
Subject: [PATCH 0008/1045] Improve %rename(match) documentation.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12172 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 38 +++++++++++++++++++++++++++++++++++---
1 file changed, 35 insertions(+), 3 deletions(-)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 3fb1e86cc..7ce49529a 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1931,14 +1931,30 @@ As explained in the previous sections, it is possible to either rename
individual declarations or apply a rename rule to all of them at once. In
practice, the latter is however rarely appropriate as there are always some
exceptions to the general rules. To deal with them, the scope of an unnamed
-%rename can be limited using a second parameter.
+%rename can be limited using subsequent match parameters.
+They can be applied to any of the attributes associated by SWIG with the
+declarations appearing in its input. One of them is the declaration name and
-
+
+
+%rename("foo", match$name="bar") "";
+
+
-The simplest possibility is to match the declaration type, for example:
+can be used to achieve the same effect as the simpler
+%rename("foo") bar;
+
+
+
+However match can also be applied to the declaration type, for
+example match="class" restricts the match to class declarations only
+(in C++) and match="enumitem" restricts it to the enum elements. SWIG
+also provides convenience macros for such match expressions, for example
+
+
%rename("%(title)s", %$isenumitem) "";
@@ -1950,6 +1966,22 @@ documentation is not exhaustive, see "%rename predicates" section of
Lib/swig.swg for the full list of supported match expressions.
+
+Another important feature of match is that it can be applied not
+only to the declaration itself but also to its enclosing declaration. So
+match$parentNode$name="SomeClass" would be true only for members of
+the C++ class with the specified name. This can, of course, be combined with
+more complicated matches making it possible to write
+
+to rename all enums nested in the given class to lower case.
+
+
Finally, even more powerful variants of %rename and %ignore directives can be used to help
wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
From 48a2e0bdea237f658507650e6b7233205385d72a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:01:36 +0000
Subject: [PATCH 0009/1045] Correct top_{src,build}dir definitions in csharp
and java test suite.
The ".." artificially appended to these variables was enough to make the build
work in the source directory but broke down when the build directory was
different from the source one. Remove this hack and use absolute path to the
build directory instead to ensure that it's still valid even when csharp/java
makefiles invoke swig_and_compile_{c,cpp} macros from a subdirectory.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12173 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/csharp/Makefile.in | 6 +++---
Examples/test-suite/java/Makefile.in | 4 ++--
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 5f50095a1..18718ffe8 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -8,8 +8,8 @@ INTERPRETER = @CSHARPCILINTERPRETER@
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
srcdir = @srcdir@
-top_srcdir = @top_srcdir@/..
-top_builddir = @top_builddir@/..
+top_srcdir = @top_srcdir@
+top_builddir = $(abspath @top_builddir@)
CPP_TEST_CASES = \
csharp_attributes \
@@ -66,7 +66,7 @@ setup = \
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index ba225f6e9..0fc8c0511 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -7,8 +7,8 @@ JAVA = java
JAVAC = javac
SCRIPTSUFFIX = _runme.java
srcdir = @srcdir@
-top_srcdir = @top_srcdir@/..
-top_builddir = @top_builddir@/..
+top_srcdir = @top_srcdir@
+top_builddir = $(abspath @top_builddir@)
C_TEST_CASES = \
java_lib_arrays \
From 70c5bb5a47d7380cf5b5371a2b84ad04f330053a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:02:10 +0000
Subject: [PATCH 0010/1045] Add support for "[not]regexmatch" and "regextarget"
to %rename.
"regexmatch" and "notregexmatch" can be used with anonymous %renames in the
same way as "match" and "notmatch" while "regextarget" specifies that the
argument of a non-anonymous %rename should be interpreted as a regular
expression.
Document the new functions.
Also add a new unit test for %regex also testing regexmatch &c and provide
test code for C# and Java verifying that it works as intended.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12174 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 18 ++++++
Doc/Manual/SWIG.html | 45 ++++++++++++--
Examples/test-suite/common.mk | 1 +
.../csharp/rename_pcre_enum_runme.cs | 24 ++++++++
.../java/rename_pcre_enum_runme.java | 26 ++++++++
Examples/test-suite/rename_pcre_enum.i | 49 +++++++++++++++
Source/Swig/naming.c | 61 ++++++++++++++++++-
7 files changed, 216 insertions(+), 8 deletions(-)
create mode 100644 Examples/test-suite/csharp/rename_pcre_enum_runme.cs
create mode 100644 Examples/test-suite/java/rename_pcre_enum_runme.java
create mode 100644 Examples/test-suite/rename_pcre_enum.i
diff --git a/CHANGES.current b/CHANGES.current
index 9954ae05b..8c8b426b1 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -9,6 +9,24 @@ Version 2.0.1 (in progress)
Fix wrapping of function pointers and member function pointers when the function
returns by reference.
+2010-07-13: vadz
+ Add "regexmatch", "regextarget" and "notregexmatch" which can be
+ used to apply %rename directives to the declarations matching the
+ specified regular expression only. The first two can be used
+ interchangeably, both of the %renames below do the same thing:
+
+ %rename("$ignore", regexmatch$name="Old$") "";
+ %rename("$ignore", regextarget=1) "Old$";
+
+ (namely ignore the declarations having "Old" suffix).
+
+ "notregexmatch" restricts the match to only the declarations which
+ do not match the regular expression, e.g. here is how to rename to
+ lower case versions all declarations except those consisting from
+ capital letters only:
+
+ %rename("$(lower)s", notregexmatch$name="^[A-Z]+$") "";
+
2010-07-13: vadz
Add the new "regex" encoder that can be used in %rename, e.g.
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 7ce49529a..1d8f28f1c 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1949,10 +1949,12 @@ can be used to achieve the same effect as the simpler
-However match can also be applied to the declaration type, for
-example match="class" restricts the match to class declarations only
-(in C++) and match="enumitem" restricts it to the enum elements. SWIG
-also provides convenience macros for such match expressions, for example
+and so is not very interesting on its own. However match can also be
+applied to the declaration type, for example match="class" restricts
+the match to class declarations only (in C++) and match="enumitem"
+restricts it to the enum elements. SWIG also provides convenience macros for
+such match expressions, for example
+
%rename("%(title)s", %$isenumitem) "";
@@ -1983,7 +1985,40 @@ to rename all enums nested in the given class to lower case.
-Finally, even more powerful variants of %rename and %ignore directives can be used to help
+And in addition to literally matching some string with match you can
+also use regexmatch or notregexmatchto match a string
+against a regular expression. For example, to ignore all functions having
+"Old" suffix you could use
+
+
+
+%rename("$ignore", regexmatch$name="Old$") "";
+
+
+
+For simple cases like this, specifying the regular expression for the
+declaration name directly can be preferable and can be done using
+regextarget:
+
+
+
+%rename("$ignore", regextarget=1) "Old$";
+
+
+
+
+As for notregexmatch, it restricts the match only to the strings not
+matching the specified regular expression. So to rename to lower case versions
+all declarations except those consisting from capital letters only:
+
+Finally, variants of %rename and %ignore directives can be used to help
wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
Ambiguity resolution and renaming section in the C++ chapter.
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index c7afb6647..af9316656 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -285,6 +285,7 @@ CPP_TEST_CASES += \
rename_scope \
rename_strip_encoder \
rename_pcre_encoder \
+ rename_pcre_enum \
restrict_cplusplus \
return_const_value \
return_value_scope \
diff --git a/Examples/test-suite/csharp/rename_pcre_enum_runme.cs b/Examples/test-suite/csharp/rename_pcre_enum_runme.cs
new file mode 100644
index 000000000..0143eda33
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_pcre_enum_runme.cs
@@ -0,0 +1,24 @@
+using System;
+using rename_pcre_enumNamespace;
+
+public class runme {
+ static void Main() {
+ Foo foo = Foo.First;
+ if ( foo == Foo.Second )
+ throw new Exception("Enum values should be different");
+
+ // Check that Foo_Max enum element was ignored.
+ int numFooEnumElements = Enum.GetValues(typeof(Foo)).Length;
+ if ( numFooEnumElements != 2 )
+ throw new Exception(String.Format("Enum should have 2 elements, not {0}",
+ numFooEnumElements));
+
+ BoundaryCondition bc = BoundaryCondition.MaxMax;
+ if ( (int)bc != 2 )
+ throw new Exception("Wrong enum value");
+
+ Colour c = Colour.red;
+ if ( c == Colour.blue )
+ throw new Exception("Enum values should be different");
+ }
+}
diff --git a/Examples/test-suite/java/rename_pcre_enum_runme.java b/Examples/test-suite/java/rename_pcre_enum_runme.java
new file mode 100644
index 000000000..a8bfef46a
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_enum_runme.java
@@ -0,0 +1,26 @@
+import rename_pcre_enum.*;
+
+public class rename_pcre_enum_runme {
+ static { System.loadLibrary("rename_pcre_enum"); }
+
+ public static void main(String argv[])
+ {
+ Foo foo = Foo.First;
+ if ( foo == Foo.Second )
+ throw new RuntimeException("Enum values should be different");
+
+ // Check that Foo_Max enum element was ignored.
+ int numFooEnumElements = Foo.values().length;
+ if ( numFooEnumElements != 2 )
+ throw new RuntimeException(String.format("Enum should have 2 elements, not %d",
+ numFooEnumElements));
+
+ BoundaryCondition bc = BoundaryCondition.MaxMax;
+ if ( bc.ordinal() != 2 )
+ throw new RuntimeException("Wrong enum value");
+
+ Colour c = Colour.red;
+ if ( c == Colour.blue )
+ throw new RuntimeException("Enum values should be different");
+ }
+}
diff --git a/Examples/test-suite/rename_pcre_enum.i b/Examples/test-suite/rename_pcre_enum.i
new file mode 100644
index 000000000..1bb7c1b8b
--- /dev/null
+++ b/Examples/test-suite/rename_pcre_enum.i
@@ -0,0 +1,49 @@
+%module rename_pcre_enum
+
+// This file is needed for proper enum support in C#/Java backends
+#if defined(SWIGCSHARP) || defined(SWIGJAVA)
+%include "enums.swg"
+#endif
+
+// Apply a rule for renaming the enum elements to avoid the common prefixes
+// redundant in C#/Java
+%rename("%(regex:/([A-Z][a-z]+)+_(.*)/\\2/)s",%$isenumitem) "";
+
+// Also don't export special end of enum markers which are often used in C++
+// code to just have a symbolic name for the number of enum elements but are
+// not needed in target language.
+%rename("$ignore", regexmatch$name="([A-Z][a-z]+)+_Max$",%$isenumitem) "";
+
+// Test another way of doing the same thing with regextarget:
+%rename("$ignore", %$isenumitem, regextarget=1) "([A-Z][a-z]+)+_Internal$";
+
+// Apply this renaming rule to all enum elements that don't contain more than
+// one capital letter.
+%rename("%(lower)s", notregexmatch$name="[A-Z]\\w*[A-Z]", %$isenumitem) "";
+
+%inline %{
+
+// Foo_Internal and Foo_Max won't be exported.
+enum Foo {
+ Foo_Internal = -1,
+ Foo_First,
+ Foo_Second,
+ Foo_Max
+};
+
+// All elements of this enum will be exported because they do not match the
+// excluding regex.
+enum BoundaryCondition {
+ BoundaryCondition_MinMax,
+ BoundaryCondition_MaxMin,
+ BoundaryCondition_MaxMax
+};
+
+// The elements of this enum will have lower-case names.
+enum Colour {
+ Red,
+ Blue,
+ Green
+};
+
+%}
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 07e42f2d4..44daf30c9 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1062,10 +1062,13 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
const char **rkey;
int isnotmatch = 0;
int isrxsmatch = 0;
+ int isregexmatch = 0;
if ((strncmp(ckey, "match", 5) == 0)
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
|| (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
- || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))) {
+ || (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
+ || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))
+ || (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
Hash *mi = NewHash();
List *attrlist = Swig_make_attrlist(ckey);
if (!matchlist)
@@ -1080,6 +1083,8 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
SetFlag(mi, "notmatch");
if (isrxsmatch)
SetFlag(mi, "rxsmatch");
+ if (isregexmatch)
+ SetFlag(mi, "regexmatch");
Delete(attrlist);
Append(matchlist, mi);
Delete(mi);
@@ -1155,6 +1160,51 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
return res;
}
+#ifdef HAVE_PCRE
+#include
+
+int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
+ pcre *compiled_pat;
+ const char *err;
+ int errpos;
+ int rc;
+
+ compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
+ if (!compiled_pat) {
+ Swig_error("SWIG", Getline(n),
+ "Invalid regex \"%s\": compilation failed at %d: %s\n",
+ Char(pattern), errpos, err);
+ exit(1);
+ }
+
+ rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
+ pcre_free(compiled_pat);
+
+ if (rc == PCRE_ERROR_NOMATCH)
+ return 0;
+
+ if (rc < 0 ) {
+ Swig_error("SWIG", Getline(n),
+ "Matching \"%s\" against regex \"%s\" failed: %d\n",
+ Char(s), Char(pattern), rc);
+ exit(1);
+ }
+
+ return 1;
+}
+
+#else /* !HAVE_PCRE */
+
+int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
+ (void)pattern;
+ (void)s;
+ Swig_error("SWIG", Getline(n),
+ "PCRE regex matching is not available in this SWIG build.\n");
+ exit(1);
+}
+
+#endif /* HAVE_PCRE/!HAVE_PCRE */
+
#if defined(HAVE_RXSPENCER)
#include
#include
@@ -1228,6 +1278,7 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
String *nval = Swig_get_lattr(n, lattr);
int notmatch = GetFlag(mi, "notmatch");
int rxsmatch = GetFlag(mi, "rxsmatch");
+ int regexmatch = GetFlag(mi, "regexmatch");
#ifdef SWIG_DEBUG
Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
if (rxsmatch) {
@@ -1238,6 +1289,7 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
if (nval) {
String *kwval = Getattr(mi, "value");
match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
+ : regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
: Swig_name_match_value(kwval, nval);
#ifdef SWIG_DEBUG
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
@@ -1278,6 +1330,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
String *sname = 0;
int fullname = GetFlag(rn, "fullname");
int rxstarget = GetFlag(rn, "rxstarget");
+ int regextarget = GetFlag(rn, "regextarget");
if (sfmt) {
if (fullname && prefix) {
String *pname = NewStringf("%s::%s", prefix, name);
@@ -1294,7 +1347,9 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
DohIncref(name);
}
}
- match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) : Swig_name_match_value(tname, sname);
+ match = rxstarget ? Swig_name_rxsmatch_value(tname, sname)
+ : regextarget ? Swig_name_regexmatch_value(n, tname, sname)
+ : Swig_name_match_value(tname, sname);
Delete(sname);
} else {
match = 1;
@@ -1393,7 +1448,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
ParmList *declparms = declaratorparms;
- const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", 0 };
+ const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", "regextarget", 0 };
Swig_name_object_attach_keys(rename_keys, newname);
/* Add the name */
From 587d8435211cddb1389733c462a7d1d02af17fea Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:02:35 +0000
Subject: [PATCH 0011/1045] Remove old experimental rxspencer encoder and
rxsmatch function.
They are replaced with the new, officially supported PCRE-based regex and
regexmatch.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12175 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 11 +++
Examples/test-suite/enum_rename.i | 2 +-
Examples/test-suite/rename_camel.i | 4 +-
Source/Swig/misc.c | 107 -----------------------------
Source/Swig/naming.c | 56 +--------------
configure.in | 18 -----
6 files changed, 17 insertions(+), 181 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 8c8b426b1..6cd13990c 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -9,6 +9,17 @@ Version 2.0.1 (in progress)
Fix wrapping of function pointers and member function pointers when the function
returns by reference.
+2010-07-13: vadz
+ Removed support for the old experimental "rxspencer" encoder and
+ "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and
+ officially supported "regex" encoder and "[not]regexmatch" checks
+ should be used instead (see the two previous entries). Please
+ replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s"
+ when upgrading. Notice that you will also need to replace the back-
+ references of form "@1" with the more standard "\\1" and may need to
+ adjust your regular expressions syntax as the new regex encoder uses
+ Perl-compatible syntax and not (extended) POSIX syntax as the old one.
+
2010-07-13: vadz
Add "regexmatch", "regextarget" and "notregexmatch" which can be
used to apply %rename directives to the declarations matching the
diff --git a/Examples/test-suite/enum_rename.i b/Examples/test-suite/enum_rename.i
index 455826f8b..0cab4d0d8 100644
--- a/Examples/test-suite/enum_rename.i
+++ b/Examples/test-suite/enum_rename.i
@@ -2,7 +2,7 @@
%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
-// %rename with rxspencer can do the equivalent of these two renames, which was resulting in uncompileable code
+// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code
%rename(May) M_May;
%rename(May) S_May;
diff --git a/Examples/test-suite/rename_camel.i b/Examples/test-suite/rename_camel.i
index 54f06f967..970bb9215 100644
--- a/Examples/test-suite/rename_camel.i
+++ b/Examples/test-suite/rename_camel.i
@@ -33,7 +33,7 @@
%rename(awk_cmd) "";
-%rename("%(title)s",rxsmatch$parentNode$type="enum .*") "";
+%rename("%(title)s",regexmatch$parentNode$type="enum .*") "";
%inline
{
@@ -59,7 +59,7 @@
}
-%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) "";
+%rename("%(lowercase)s",sourcefmt="%(regex:/GSL_(.*)/\\1/)s",%$isfunction) "";
%inline {
void GSL_Hello() {}
}
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index b23a99b60..14470485e 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -1108,112 +1108,6 @@ String *Swig_string_strip(String *s) {
}
-/* -----------------------------------------------------------------------------
- * Swig_string_rxspencer()
- *
- * Executes a regexp substitution via the RxSpencer library. For example:
- *
- * Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello
- * ----------------------------------------------------------------------------- */
-#if defined(HAVE_RXSPENCER)
-#include
-#include
-#define USE_RXSPENCER
-#endif
-
-const char *skip_delim(char pb, char pe, const char *ce) {
- int end = 0;
- int lb = 0;
- while (!end && *ce != '\0') {
- if (*ce == pb) {
- ++lb;
- }
- if (*ce == pe) {
- if (!lb) {
- end = 1;
- --ce;
- } else {
- --lb;
- }
- }
- ++ce;
- }
- return end ? ce : 0;
-}
-
-
-#if defined(USE_RXSPENCER)
-String *Swig_string_rxspencer(String *s) {
- String *res = 0;
- if (Len(s)) {
- const char *cs = Char(s);
- const char *cb;
- const char *ce;
- if (*cs == '[') {
- int retval;
- regex_t compiled;
- cb = ++cs;
- ce = skip_delim('[', ']', cb);
- if (ce) {
- char bregexp[512];
- strncpy(bregexp, cb, ce - cb);
- bregexp[ce - cb] = '\0';
- ++ce;
- retval = regcomp(&compiled, bregexp, REG_EXTENDED);
- if (retval == 0) {
- cs = ce;
- if (*cs == '[') {
- cb = ++cs;
- ce = skip_delim('[', ']', cb);
- if (ce) {
- const char *cvalue = ce + 1;
- int nsub = (int) compiled.re_nsub + 1;
- regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
- retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
- if (retval != REG_NOMATCH) {
- char *spos = 0;
- res = NewStringWithSize(cb, ce - cb);
- spos = Strchr(res, '@');
- while (spos) {
- char cd = *(++spos);
- if (isdigit(cd)) {
- char arg[8];
- size_t len;
- int i = cd - '0';
- sprintf(arg, "@%d", i);
- if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
- char value[256];
- strncpy(value, cvalue + pmatch[i].rm_so, len);
- value[len] = 0;
- Replaceall(res, arg, value);
- } else {
- Replaceall(res, arg, "");
- }
- spos = Strchr(res, '@');
- } else if (cd == '@') {
- spos = strchr(spos + 1, '@');
- }
- }
- }
- free(pmatch);
- }
- }
- }
- regfree(&compiled);
- }
- }
- }
- if (!res)
- res = NewStringEmpty();
- return res;
-}
-#else
-String *Swig_string_rxspencer(String *s) {
- (void) s;
- return NewStringEmpty();
-}
-#endif
-
#ifdef HAVE_PCRE
#include
@@ -1338,7 +1232,6 @@ void Swig_init() {
DohEncoding("typecode", Swig_string_typecode);
DohEncoding("mangle", Swig_string_emangle);
DohEncoding("command", Swig_string_command);
- DohEncoding("rxspencer", Swig_string_rxspencer);
DohEncoding("schemify", Swig_string_schemify);
DohEncoding("strip", Swig_string_strip);
DohEncoding("regex", Swig_string_regex);
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 44daf30c9..5bf42f7cc 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1061,13 +1061,10 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
if (ckey) {
const char **rkey;
int isnotmatch = 0;
- int isrxsmatch = 0;
int isregexmatch = 0;
if ((strncmp(ckey, "match", 5) == 0)
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
- || (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
- || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
Hash *mi = NewHash();
List *attrlist = Swig_make_attrlist(ckey);
@@ -1075,14 +1072,8 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
matchlist = NewList();
Setattr(mi, "value", Getattr(kw, "value"));
Setattr(mi, "attrlist", attrlist);
-#ifdef SWIG_DEBUG
- if (isrxsmatch)
- Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist);
-#endif
if (isnotmatch)
SetFlag(mi, "notmatch");
- if (isrxsmatch)
- SetFlag(mi, "rxsmatch");
if (isregexmatch)
SetFlag(mi, "regexmatch");
Delete(attrlist);
@@ -1205,37 +1196,6 @@ int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
#endif /* HAVE_PCRE/!HAVE_PCRE */
-#if defined(HAVE_RXSPENCER)
-#include
-#include
-#define USE_RXSPENCER
-#endif
-
-#if defined(USE_RXSPENCER)
-int Swig_name_rxsmatch_value(String *mvalue, String *value) {
- int match = 0;
- char *cvalue = Char(value);
- char *cmvalue = Char(mvalue);
- regex_t compiled;
- int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
- if (retval != 0)
- return 0;
- retval = regexec(&compiled, cvalue, 0, 0, 0);
- match = (retval == REG_NOMATCH) ? 0 : 1;
-#ifdef SWIG_DEBUG
- Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match);
-#endif
- regfree(&compiled);
- return match;
-}
-#else
-int Swig_name_rxsmatch_value(String *mvalue, String *value) {
- (void) mvalue;
- (void) value;
- return 0;
-}
-#endif
-
int Swig_name_match_value(String *mvalue, String *value) {
#if defined(SWIG_USE_SIMPLE_MATCHOR)
int match = 0;
@@ -1277,19 +1237,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
List *lattr = Getattr(mi, "attrlist");
String *nval = Swig_get_lattr(n, lattr);
int notmatch = GetFlag(mi, "notmatch");
- int rxsmatch = GetFlag(mi, "rxsmatch");
int regexmatch = GetFlag(mi, "regexmatch");
-#ifdef SWIG_DEBUG
- Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
- if (rxsmatch) {
- Printf(stdout, "rxsmatch %s\n", lattr);
- }
-#endif
match = 0;
if (nval) {
String *kwval = Getattr(mi, "value");
- match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
- : regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
+ match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
: Swig_name_match_value(kwval, nval);
#ifdef SWIG_DEBUG
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
@@ -1329,7 +1281,6 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
String *sfmt = Getattr(rn, "sourcefmt");
String *sname = 0;
int fullname = GetFlag(rn, "fullname");
- int rxstarget = GetFlag(rn, "rxstarget");
int regextarget = GetFlag(rn, "regextarget");
if (sfmt) {
if (fullname && prefix) {
@@ -1347,8 +1298,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
DohIncref(name);
}
}
- match = rxstarget ? Swig_name_rxsmatch_value(tname, sname)
- : regextarget ? Swig_name_regexmatch_value(n, tname, sname)
+ match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
: Swig_name_match_value(tname, sname);
Delete(sname);
} else {
@@ -1448,7 +1398,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
ParmList *declparms = declaratorparms;
- const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", "regextarget", 0 };
+ const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
Swig_name_object_attach_keys(rename_keys, newname);
/* Add the name */
diff --git a/configure.in b/configure.in
index e5e2752d9..1a6b37b57 100644
--- a/configure.in
+++ b/configure.in
@@ -73,24 +73,6 @@ AS_IF([test "x$with_pcre" != xno],
])
-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])
From 89a7ab06856f3f0d7e879d6c3df9c6db85792d6b Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:02:55 +0000
Subject: [PATCH 0012/1045] Include the values of configurable options in `swig
-version`.
Show the value of important compilation options in swig -version output.
Currently there is just one such option, for PCRE use, but more may be added
in the future.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12176 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/main.cxx | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index f0e941f22..3f2008d7d 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -622,7 +622,14 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-version") == 0) {
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM);
- fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
+ fprintf(stdout, "\nConfigured options: %cpcre\n",
+#ifdef HAVE_PCRE
+ '+'
+#else
+ '-'
+#endif
+ );
+ fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-copyright") == 0) {
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
From d2ad66a9a9aec4ed7bf96af716a8f87a57eb7a45 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 07:17:15 +0000
Subject: [PATCH 0013/1045] remove duplicate definition of %$isextend
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12178 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/swig.swg | 1 -
1 file changed, 1 deletion(-)
diff --git a/Lib/swig.swg b/Lib/swig.swg
index ec903533c..4ec3d35e6 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -269,7 +269,6 @@ static int NAME(TYPE x) {
%define %$isaccess "match"="access" %enddef
%define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef
%define %$isextend "match"="extend" %enddef
-%define %$isextend "match"="extend" %enddef
%define %$isconstructor "match"="constructor" %enddef
%define %$isdestructor "match"="destructor" %enddef
%define %$isnamespace "match"="namespace" %enddef
From f6346b3df1252b9745164d1759fab32e9e1cbea4 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 07:21:46 +0000
Subject: [PATCH 0014/1045] minor edits in %rename sections
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12179 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 48 ++++++++++++++++++++++----------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 1d8f28f1c..4ea55621e 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1765,7 +1765,7 @@ While writing %rename for specific declarations is simple enough,
sometimes the same renaming rule needs to be applied to many, maybe all,
identifiers in the SWIG input. For example, it may be necessary to apply some
transformation to all the names in the target language to better follow its
-naming conventions, e.g. add a specific prefix to all the functions. Doing it
+naming conventions, like adding a specific prefix to all wrapped functions. Doing it individually
for each function is impractical so SWIG supports applying a renaming rule to
all declarations if the name of the identifier to be renamed is not specified:
@@ -1799,28 +1799,28 @@ strips the provided prefix from its argument. The prefix is specified as part
of the format string, following a colon after the function name:
-Here is the table summarizing all currently defined functions with an example
-of applying each one (notice that some of them have two names, a shorter one
-and a more descriptive one, but the two functions are otherwise equivalent):
+Below is the table summarizing all currently defined functions with an example
+of applying each one. Note that some of them have two names, a shorter one
+and a more descriptive one, but the two functions are otherwise equivalent:
Function
Returns
Example (in/out)
-
upper or uppercase
-
Upper-case version of the string.
+
uppercase or upper
+
Upper case version of the string.
Print
PRINT
-
lower or lowercase
-
Lower-case version of the string.
+
lowercase or lower
+
Lower case version of the string.
Print
print
@@ -1839,23 +1839,23 @@ and a more descriptive one, but the two functions are otherwise equivalent):
PrintIt
printIt
-
ctitle or camelcase
+
camelcase or ctitle
String with capitalized first letter and any letter following an
underscore (which are removed in the process) and rest in lower case.
print_it
PrintIt
-
lctitle or lowercamelcase
+
lowercamelcase or lctitle
String with every letter following an underscore (which is removed in
the process) capitalized and rest, including the first letter, in lower
case.
print_it
printIt
-
utitle or undercase
-
Lower case string with underscores inserted before every upper-case
+
undercase or utitle
+
Lower case string with underscores inserted before every upper case
letter in the original string and any number not at the end of string.
- Logically, this is the reverse of ccase.
+ Logically, this is the reverse of camelcase.
PrintIt
print_it
@@ -1933,7 +1933,7 @@ practice, the latter is however rarely appropriate as there are always some
exceptions to the general rules. To deal with them, the scope of an unnamed
%rename can be limited using subsequent match parameters.
They can be applied to any of the attributes associated by SWIG with the
-declarations appearing in its input. One of them is the declaration name and
+declarations appearing in its input. For example:
@@ -1965,7 +1965,7 @@ will capitalize the names of all the enum elements but not change the case of
the other declarations. Similarly, %$isclass, %$isfunction
and %$isvariable can be used. Many other checks are possible and this
documentation is not exhaustive, see "%rename predicates" section of
-Lib/swig.swg for the full list of supported match expressions.
+swig.swg for the full list of supported match expressions.
@@ -1985,10 +1985,10 @@ to rename all enums nested in the given class to lower case.
-And in addition to literally matching some string with match you can
-also use regexmatch or notregexmatchto match a string
+In addition to literally matching some string with match you can
+also use regexmatch or notregexmatch to match a string
against a regular expression. For example, to ignore all functions having
-"Old" suffix you could use
+"Old" as a suffix you could use
@@ -1997,7 +1997,7 @@ against a regular expression. For example, to ignore all functions having
For simple cases like this, specifying the regular expression for the
-declaration name directly can be preferable and can be done using
+declaration name directly can be preferable and can also be done using
regextarget:
@@ -2008,8 +2008,8 @@ declaration name directly can be preferable and can be done using
As for notregexmatch, it restricts the match only to the strings not
-matching the specified regular expression. So to rename to lower case versions
-all declarations except those consisting from capital letters only:
+matching the specified regular expression. So to rename all declarations to lower case
+except those consisting of capital letters only:
@@ -2187,7 +2187,7 @@ normally, just use the original function name such as add().
SWIG provides a number of extensions to standard C printf formatting
that may be useful in this context. For instance, the following
-variation installs the callbacks as all upper-case constants such as
+variation installs the callbacks as all upper case constants such as
ADD, SUB, and MUL:
@@ -2201,7 +2201,7 @@ int mul(int,int);
-A format string of "%(lower)s" converts all characters to lower-case.
+A format string of "%(lower)s" converts all characters to lower case.
A string of "%(title)s" capitalizes the first character and converts the
rest to lower case.
From c6c2c87e2ac9a9816ab056c1b90b1d9f119e0526 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 07:23:10 +0000
Subject: [PATCH 0015/1045] Add message about whether pcre is enabled or not
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12180 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
configure.in | 2 ++
1 file changed, 2 insertions(+)
diff --git a/configure.in b/configure.in
index 1a6b37b57..1e51956d9 100644
--- a/configure.in
+++ b/configure.in
@@ -56,6 +56,8 @@ AC_ARG_WITH([pcre],
[],
[with_pcre=yes])
+AC_MSG_CHECKING([whether to enable PCRE support])
+AC_MSG_RESULT([$with_pcre])
AS_IF([test "x$with_pcre" != xno],
[AX_PATH_GENERIC([pcre],
[], dnl Minimal version of PCRE we need -- accept any
From af96789c14eb45eb874996a603eb8a1eab960244 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 19:34:17 +0000
Subject: [PATCH 0016/1045] Minor comment changes and html changes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12181 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 +++-
Doc/Manual/Contents.html | 5 +++++
Doc/Manual/SWIG.html | 23 ++++++++++++++++-------
Source/Swig/misc.c | 2 +-
4 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 6cd13990c..3dc3556a1 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -20,6 +20,8 @@ Version 2.0.1 (in progress)
adjust your regular expressions syntax as the new regex encoder uses
Perl-compatible syntax and not (extended) POSIX syntax as the old one.
+ *** POTENTIAL INCOMPATIBILITY ***
+
2010-07-13: vadz
Add "regexmatch", "regextarget" and "notregexmatch" which can be
used to apply %rename directives to the declarations matching the
@@ -36,7 +38,7 @@ Version 2.0.1 (in progress)
lower case versions all declarations except those consisting from
capital letters only:
- %rename("$(lower)s", notregexmatch$name="^[A-Z]+$") "";
+ %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") "";
2010-07-13: vadz
Add the new "regex" encoder that can be used in %rename, e.g.
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 66bf41264..ec99a6511 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -152,6 +152,11 @@
Pointers to functions and callbacks
@@ -1661,7 +1666,9 @@ generate a warning message. Simply change the directives to %immutable;5.4.7 Renaming and ignoring declarations
-
5.4.7.1 Simple renaming of specific identifiers
+
+
5.4.7.1 Simple renaming of specific identifiers
+
Normally, the name of a C declaration is used when that declaration is
@@ -1758,7 +1765,8 @@ This directive is still supported, but it is deprecated and should probably be a
directive is more powerful and better supports wrapping of raw header file information.
-
5.4.7.2 Advanced renaming support
+
5.4.7.2 Advanced renaming support
+
While writing %rename for specific declarations is simple enough,
@@ -1797,12 +1805,12 @@ can use the "lowercamelcase" extended format specifier like this:
Some functions can be parametrized, for example the "strip" one
strips the provided prefix from its argument. The prefix is specified as part
of the format string, following a colon after the function name:
+
Below is the table summarizing all currently defined functions with an example
@@ -1924,7 +1932,8 @@ are exactly equivalent and %rename can be used to selectively ignore
multiple declarations using the previously described matching possibilities.
-
5.4.7.3 Limiting global renaming rules
+
5.4.7.3 Limiting global renaming rules
+
As explained in the previous sections, it is possible to either rename
@@ -1977,7 +1986,7 @@ more complicated matches making it possible to write
@@ -2193,7 +2202,7 @@ variation installs the callbacks as all upper case constants such as
/* Some callback functions */
-%callback("%(upper)s");
+%callback("%(uppercase)s");
int add(int,int);
int sub(int,int);
int mul(int,int);
@@ -2201,7 +2210,7 @@ int mul(int,int);
-A format string of "%(lower)s" converts all characters to lower case.
+A format string of "%(lowercase)s" converts all characters to lower case.
A string of "%(title)s" capitalizes the first character and converts the
rest to lower case.
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index 14470485e..b3c647546 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -1173,7 +1173,7 @@ String *replace_captures(const char *input, String *subst, int captures[])
/* -----------------------------------------------------------------------------
* Swig_string_regex()
*
- * Executes a regexp substitution. For example:
+ * Executes a regular expression substitution. For example:
*
* Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
* ----------------------------------------------------------------------------- */
From 70b4d1231743911806b8a9625926187ce914560b Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 28 Jul 2010 05:53:17 +0000
Subject: [PATCH 0017/1045] Restore in source and out of source builds for the
test-suite. Note that configure must be invoked using a relative path for out
of source builds
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12186 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 7 +++++++
Examples/test-suite/csharp/Makefile.in | 6 +++---
Examples/test-suite/java/Makefile.in | 4 ++--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 3dc3556a1..8fbb9a47f 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-07-28: wsfulton
+ Restore configuring out of source for the test-suite since it broke in 1.3.37.
+ As previously, if running 'make check-test-suite' out of source, it needs to be
+ done by invoking configure with a relative path. Invoking configure with an
+ absolute path will not work. Running the full 'make check' still needs to be
+ done in the source tree.
+
2010-07-16: wsfulton
Fix wrapping of function pointers and member function pointers when the function
returns by reference.
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 18718ffe8..48731f82b 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -8,8 +8,8 @@ INTERPRETER = @CSHARPCILINTERPRETER@
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = $(abspath @top_builddir@)
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
CPP_TEST_CASES = \
csharp_attributes \
@@ -66,7 +66,7 @@ setup = \
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
- $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 0fc8c0511..1ba888fc1 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -7,8 +7,8 @@ JAVA = java
JAVAC = javac
SCRIPTSUFFIX = _runme.java
srcdir = @srcdir@
-top_srcdir = @top_srcdir@
-top_builddir = $(abspath @top_builddir@)
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
C_TEST_CASES = \
java_lib_arrays \
From 024ed6ce2a3191c57c5c030dd133bf0e9e2a1971 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Sat, 14 Aug 2010 14:12:23 +0000
Subject: [PATCH 0018/1045] Fix bug in applying regex replacement to
non-matching strings.
We didn't handle pcre_exec() return code properly and so the replacement could
be still done even if there was no match if the replacement part contained
anything else than back-references (in this, the only tested so far, case the
replacement was still done but the result turned out to be empty and the
calling code assumed the regex didn't match).
Do check for PCRE_ERROR_NOMATCH now and also give an error message if another
error unexpectedly occurred.
Add a test case for the bug that was fixed.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12187 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/rename_pcre_encoder.i | 7 ++++++-
Source/Swig/misc.c | 13 +++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i
index 568a2a82d..1bee1dca8 100644
--- a/Examples/test-suite/rename_pcre_encoder.i
+++ b/Examples/test-suite/rename_pcre_encoder.i
@@ -3,9 +3,14 @@
// strip the wx prefix from all identifiers except those starting with wxEVT
%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") "";
+// Replace "Set" prefix with "put" in all functions
+%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) "";
+
%inline %{
-class wxSomeWidget {
+struct wxSomeWidget {
+ void SetBorderWidth(int);
+ void SetSize(int, int);
};
struct wxAnotherWidget {
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index b3c647546..2105f0c51 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -1188,6 +1188,8 @@ String *Swig_string_regex(String *s) {
int captures[30];
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
+ int rc;
+
compiled_pat = pcre_compile(
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
if (!compiled_pat) {
@@ -1195,8 +1197,15 @@ String *Swig_string_regex(String *s) {
pcre_error, Char(pattern), pcre_errorpos);
exit(1);
}
- pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
- res = replace_captures(input, subst, captures);
+ rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
+ if (rc >= 0) {
+ res = replace_captures(input, subst, captures);
+ }
+ else if (rc != PCRE_ERROR_NOMATCH) {
+ Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" in \"%s\".\n",
+ rc, Char(pattern), input);
+ exit(1);
+ }
}
DohDelete(pattern);
From 9b097847158aea3429cdf555dd40961133bffb52 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Sat, 14 Aug 2010 14:12:39 +0000
Subject: [PATCH 0019/1045] Add more regex function usage examples in %rename
section.
Mention the examples from the test suite and the change log file in the manual
as well.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12188 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 32fbe3815..bdd0edb8b 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1904,6 +1904,28 @@ and a more descriptive one, but the two functions are otherwise equivalent:
+
+The most general function of all of the above ones (not counting
+command which is even more powerful in principle but which should
+generally be avoided because of performance considerations) is the
+regex one. Here are some more examples of its use:
+
+
+// Strip the wx prefix from all identifiers except those starting with wxEVT
+%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // wxSomeWidget -> SomeWidget
+ // wxEVT_PAINT -> wxEVT_PAINT
+
+// Apply a rule for renaming the enum elements to avoid the common prefixes
+// which are redundant in C#/Java
+%rename("%(regex:/^([A-Z][a-z]+)+_(.*)/\\2/)s", %$isenumitem) ""; // Colour_Red -> Red
+
+// Remove all "Set/Get" prefixes.
+%rename("%(regex:/^(Set|Get)(.*)/\\2/)s") ""; // SetValue -> Value
+ // GetValue -> Value
+
+
+
+
As before, everything that was said above about %rename also applies to
%ignore. In fact, the latter is just a special case of the former and
From 1c8618d6355f3d246dd7b7b986454672d1092430 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 Aug 2010 18:40:14 +0000
Subject: [PATCH 0020/1045] Modified patch from Torsten Landschoff for fixing
make distclean when the target languages that have no examples are detected -
the default target was erroneously being run for clean and check of the
examples
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12189 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Makefile.in | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index 8fbb9a47f..d24f6c312 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-08-17: wsfulton
+ Fix make distclean when some of the more obscure languages are detected by
+ configure - fixes from Torsten Landschoff.
+
2010-07-28: wsfulton
Restore configuring out of source for the test-suite since it broke in 1.3.37.
As previously, if running 'make check-test-suite' out of source, it needs to be
diff --git a/Makefile.in b/Makefile.in
index 180ad3451..e1f06d0c5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -160,7 +160,7 @@ clisp_examples :=
uffi_examples :=
cffi_examples :=
r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list)
-go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list)
+go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list)
# all examples
check-%-examples :
@@ -170,6 +170,8 @@ check-%-examples :
fi
@if $(skip-$*); then \
echo skipping $* $(ACTION); \
+ elif test -z "$($(strip $*_examples))"; then \
+ echo empty $* $(ACTION); \
else \
$(MAKE) -k -s $($*_examples:=.actionexample) LANGUAGE=$* ACTION=$(ACTION); \
fi
From 8f8804b7a1b949786c6366494786efb14ea8713a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 Aug 2010 19:10:14 +0000
Subject: [PATCH 0021/1045] Fix corner case marshalling of doubles - errno was
not being correctly set before calling strtod - patch from Justin Vallon
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12190 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Lib/perl5/perlprimtypes.swg | 1 +
2 files changed, 5 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index d24f6c312..e4022a642 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-08-17: wsfulton
+ [Perl] Fix corner case marshalling of doubles - errno was not being correctly
+ set before calling strtod - patch from Justin Vallon.
+
2010-08-17: wsfulton
Fix make distclean when some of the more obscure languages are detected by
configure - fixes from Torsten Landschoff.
diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg
index ae7bb3886..f2a614030 100644
--- a/Lib/perl5/perlprimtypes.swg
+++ b/Lib/perl5/perlprimtypes.swg
@@ -311,6 +311,7 @@ SWIG_AsVal_dec(double)(SV *obj, double *val)
const char *nptr = SvPV_nolen(obj);
if (nptr) {
char *endptr;
+ errno = 0;
double v = strtod(nptr, &endptr);
if (errno == ERANGE) {
errno = 0;
From 69af82caa4c0207cdc150f92cac1f0498ea91928 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 26 Aug 2010 18:06:02 +0000
Subject: [PATCH 0022/1045] Fix __LINE__ and __FILE__ expansion. Mostly this
did not work at all.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12192 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 6 ++-
Examples/test-suite/common.mk | 1 +
.../java/preproc_line_file_runme.java | 41 ++++++++++++++++
Examples/test-suite/preproc_line_file.i | 33 +++++++++++++
Source/Preprocessor/cpp.c | 48 ++++++++++++++-----
5 files changed, 116 insertions(+), 13 deletions(-)
create mode 100644 Examples/test-suite/java/preproc_line_file_runme.java
create mode 100644 Examples/test-suite/preproc_line_file.i
diff --git a/CHANGES.current b/CHANGES.current
index e4022a642..aaaf2254b 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,9 +5,13 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-08-26: wsfulton
+ Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this
+ did not work at all.
+
2010-08-17: wsfulton
[Perl] Fix corner case marshalling of doubles - errno was not being correctly
- set before calling strtod - patch from Justin Vallon.
+ set before calling strtod - patch from Justin Vallon - SF Bug #3038936.
2010-08-17: wsfulton
Fix make distclean when some of the more obscure languages are detected by
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index af9316656..e385b11dd 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -486,6 +486,7 @@ C_TEST_CASES += \
overload_extendc \
preproc \
preproc_constants_c \
+ preproc_line_file \
ret_by_value \
simple_array \
sizeof_pointer \
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
new file mode 100644
index 000000000..6550e4a78
--- /dev/null
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -0,0 +1,41 @@
+import preproc_line_file.*;
+
+public class preproc_line_file_runme {
+
+ static {
+ try {
+ System.loadLibrary("preproc_line_file");
+ } 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[]) throws Throwable
+ {
+ int myline = preproc_line_file.MYLINE;
+ int myline_adjusted = preproc_line_file.MYLINE_ADJUSTED;
+ if (myline != 4)
+ throw new RuntimeException("preproc failure");
+ if (myline + 100 + 1 != myline_adjusted)
+ throw new RuntimeException("preproc failure");
+
+ String myfile = preproc_line_file.MYFILE;
+ String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED;
+ if (!(myfile.equals("../../../../Examples/test-suite/preproc_line_file.i") || myfile.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i")))
+ throw new RuntimeException("preproc failure");
+
+ if (!(myfile_adjusted.equals("../../../../Examples/test-suite/preproc_line_file.i.bak") || myfile_adjusted.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i.bak")))
+ throw new RuntimeException("preproc failure");
+
+ if (!preproc_line_file.MY_STRINGNUM_A.equals("my15"))
+ throw new RuntimeException("preproc failed MY_STRINGNUM_A");
+
+ if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
+ throw new RuntimeException("preproc failed MY_STRINGNUM_B");
+
+ int myline2 = preproc_line_file.MYLINE2;
+ if (myline2 != 23)
+ throw new RuntimeException("preproc failure");
+ }
+}
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
new file mode 100644
index 000000000..11465e0d0
--- /dev/null
+++ b/Examples/test-suite/preproc_line_file.i
@@ -0,0 +1,33 @@
+%module preproc_line_file
+%javaconst(1);
+// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying)
+#define MYLINE __LINE__
+#define MYLINE_ADJUSTED __LINE__ + 100
+
+#define MYFILE __FILE__
+#define MYFILE_ADJUSTED __FILE__ ".bak"
+
+
+#define STRINGNUM_HELP(a,b) #a#b
+#define STRINGNUM(a,b) STRINGNUM_HELP(a,b)
+#define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__)
+
+#define MY_STRINGNUM_A STRINGNUM_UNIQUE(my)
+#define MY_STRINGNUM_B STRINGNUM_UNIQUE(my)
+
+
+#define NUMBER_HELP(a,b) a##b
+#define NUMBER(a,b) NUMBER_HELP(a,b)
+#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
+
+#define MYLINE2 __LINE__
+
+/*
+TODO: __LINE__ is wrong
+struct Struct {
+ static const int line_num = __LINE__;
+};
+const int NUMBER_UNIQUE(thing) = 0;
+const int NUMBER_UNIQUE(thingamebob) = 0;
+#define MYLINE3 __LINE__
+*/
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 5dd320994..63e6ab547 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -33,6 +33,9 @@ static Hash *included_files = 0;
static List *dependencies = 0;
static Scanner *id_scan = 0;
static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */
+static int macro_level = 0;
+static int macro_start_line = 0;
+static const String * macro_start_file = 0;
/* Test a character to see if it starts an identifier */
#define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$'))
@@ -40,7 +43,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe
/* Test a character to see if it valid in an identifier (after the first letter) */
#define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$'))
-DOH *Preprocessor_replace(DOH *);
+static DOH *Preprocessor_replace(DOH *);
/* Skip whitespace */
static void skip_whitespace(String *s, String *out) {
@@ -499,6 +502,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Setattr(macro, kpp_varargs, "1");
}
}
+ Setline(macrovalue, line);
+ Setfile(macrovalue, file);
+ Setline(macroname, line);
+ Setfile(macroname, file);
Setattr(macro, kpp_value, macrovalue);
Setline(macro, line);
Setfile(macro, file);
@@ -710,6 +717,14 @@ static String *expand_macro(String *name, List *args) {
macro = Getattr(symbols, name);
if (!macro)
return 0;
+
+ if (macro_level == 0) {
+ /* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */
+ macro_start_line = Getline(args);
+ macro_start_file = Getfile(args);
+ }
+ macro_level++;
+
if (Getattr(macro, kpp_expanded)) {
ns = NewStringEmpty();
Append(ns, name);
@@ -725,6 +740,7 @@ static String *expand_macro(String *name, List *args) {
if (i)
Putc(')', ns);
}
+ macro_level--;
return ns;
}
@@ -764,11 +780,13 @@ static String *expand_macro(String *name, List *args) {
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name);
else
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name);
+ macro_level--;
return 0;
}
/* If the macro expects arguments, but none were supplied, we leave it in place */
if (!args && (margs) && Len(margs) > 0) {
+ macro_level--;
return NewString(name);
}
@@ -922,6 +940,7 @@ static String *expand_macro(String *name, List *args) {
Delete(e);
e = f;
}
+ macro_level--;
Delete(temp);
Delete(tempa);
return e;
@@ -954,7 +973,7 @@ List *evaluate_args(List *x) {
/* #define SWIG_PUT_BUFF */
-DOH *Preprocessor_replace(DOH *s) {
+static DOH *Preprocessor_replace(DOH *s) {
DOH *ns, *symbols, *m;
int c, i, state = 0;
@@ -999,7 +1018,7 @@ DOH *Preprocessor_replace(DOH *s) {
if (Equal(kpp_defined, id)) {
int lenargs = 0;
DOH *args = 0;
- /* See whether or not a paranthesis has been used */
+ /* See whether or not a parenthesis has been used */
skip_whitespace(s, 0);
c = Getc(s);
if (c == '(') {
@@ -1042,22 +1061,19 @@ DOH *Preprocessor_replace(DOH *s) {
Delete(args);
state = 0;
break;
- }
- if (Equal(kpp_LINE, id)) {
- Printf(ns, "%d", Getline(s));
+ } else if (Equal(kpp_LINE, id)) {
+ Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
state = 0;
break;
- }
- if (Equal(kpp_FILE, id)) {
- String *fn = Copy(Getfile(s));
+ } else if (Equal(kpp_FILE, id)) {
+ String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
Replaceall(fn, "\\", "\\\\");
Printf(ns, "\"%s\"", fn);
Delete(fn);
state = 0;
break;
- }
- /* See if the macro is defined in the preprocessor symbol table */
- if ((m = Getattr(symbols, id))) {
+ } else if ((m = Getattr(symbols, id))) {
+ /* See if the macro is defined in the preprocessor symbol table */
DOH *args = 0;
DOH *e;
/* See if the macro expects arguments */
@@ -1123,6 +1139,13 @@ DOH *Preprocessor_replace(DOH *s) {
/* See if this is the special "defined" macro */
if (Equal(kpp_defined, id)) {
Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n");
+ } else if (Equal(kpp_LINE, id)) {
+ Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
+ } else if (Equal(kpp_FILE, id)) {
+ String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
+ Replaceall(fn, "\\", "\\\\");
+ Printf(ns, "\"%s\"", fn);
+ Delete(fn);
} else if ((m = Getattr(symbols, id))) {
DOH *e;
/* Yes. There is a macro here */
@@ -1457,6 +1480,7 @@ String *Preprocessor_parse(String *s) {
m = Preprocessor_define(value, 0);
if ((m) && !(Getattr(m, kpp_args))) {
v = Copy(Getattr(m, kpp_value));
+ copy_location(m, v);
if (Len(v)) {
Swig_error_silent(1);
v1 = Preprocessor_replace(v);
From 13d18e4c3f094f7464530d205faae71c2da47a86 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 26 Aug 2010 18:18:11 +0000
Subject: [PATCH 0023/1045] Fix test for non Java langs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12193 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/preproc_line_file.i | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index 11465e0d0..9da137e94 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -1,5 +1,5 @@
%module preproc_line_file
-%javaconst(1);
+
// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying)
#define MYLINE __LINE__
#define MYLINE_ADJUSTED __LINE__ + 100
From 5a6443ebcfaf0865b347d24704b3acb06b4f20d9 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 29 Aug 2010 22:11:03 +0000
Subject: [PATCH 0024/1045] Fix some more instances of __LINE__ and __FILE__
numbering
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12194 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
.../java/preproc_line_file_runme.java | 12 +++++++--
Examples/test-suite/preproc_line_file.i | 27 ++++++++++++-------
Source/Preprocessor/cpp.c | 12 ++++-----
3 files changed, 33 insertions(+), 18 deletions(-)
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
index 6550e4a78..e390b0c19 100644
--- a/Examples/test-suite/java/preproc_line_file_runme.java
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -34,8 +34,16 @@ public class preproc_line_file_runme {
if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
throw new RuntimeException("preproc failed MY_STRINGNUM_B");
- int myline2 = preproc_line_file.MYLINE2;
- if (myline2 != 23)
+ if (preproc_line_file.getThing27() != -1)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.getThing28() != -2)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.MYLINE2 != 30)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyStruct.LINE_NUMBER != 41)
throw new RuntimeException("preproc failure");
}
}
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index 9da137e94..1a75be83a 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -1,6 +1,6 @@
%module preproc_line_file
-// Test __LINE__ and __FILE__ (don't change line numbers in here else runtime tests will need modifying)
+// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying)
#define MYLINE __LINE__
#define MYLINE_ADJUSTED __LINE__ + 100
@@ -20,14 +20,23 @@
#define NUMBER(a,b) NUMBER_HELP(a,b)
#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
+%{
+const int thing27 = -1;
+const int thing28 = -2;
+%}
+const int NUMBER_UNIQUE(thing) = -1; /* resolves to thing27 */
+const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */
+
#define MYLINE2 __LINE__
-/*
-TODO: __LINE__ is wrong
-struct Struct {
- static const int line_num = __LINE__;
+%javaconst(1);
+%{
+struct SillyStruct {
+ int num;
+ /* static const int line_num = __LINE__; */
+};
+%}
+struct SillyStruct {
+ int num;
+ static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */
};
-const int NUMBER_UNIQUE(thing) = 0;
-const int NUMBER_UNIQUE(thingamebob) = 0;
-#define MYLINE3 __LINE__
-*/
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 63e6ab547..32f3a3bd4 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -353,8 +353,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
break;
}
} else {
- /*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n");
- goto macro_error; */
Ungetc(c, str);
break;
}
@@ -1287,8 +1285,8 @@ String *Preprocessor_parse(String *s) {
case 0: /* Initial state - in first column */
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
if (c == '#') {
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
cpp_lines = 1;
state = 40;
} else if (isspace(c)) {
@@ -1682,8 +1680,8 @@ String *Preprocessor_parse(String *s) {
/* %{,%} block */
if (c == '{') {
start_line = Getline(s);
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
Putc('%', chunk);
Putc(c, chunk);
state = 105;
@@ -1759,8 +1757,8 @@ String *Preprocessor_parse(String *s) {
s1 = cpp_include(fn, sysfile);
if (s1) {
char *dirname;
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
if (Equal(decl, kpp_dimport)) {
push_imported();
@@ -1793,8 +1791,8 @@ String *Preprocessor_parse(String *s) {
} else if (Equal(decl, kpp_ddefine)) {
/* Got a define directive */
dlevel++;
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
Clear(value);
copy_location(s, value);
state = 150;
@@ -1868,8 +1866,8 @@ String *Preprocessor_parse(String *s) {
if ((state >= 30) && (state < 40)) {
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
}
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
/* DelScope(scp); */
Delete(decl);
From 31b5f36b741f2eaaa44c52d0e21cd6598e8cc73f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 29 Aug 2010 23:32:49 +0000
Subject: [PATCH 0025/1045] Fix line number and file name reporting for some
macro preprocessor warnings. The line number of the macro argument has been
corrected and the line number of the start of the macro instead of one past
the end is used. Some examples: file.h:11: Error: Illegal macro argument
name '..' file.h:19: Error: Macro 'DUPLICATE' redefined, file.h:15:
Error: previous definition of 'DUPLICATE'. file.h:25: Error:
Variable-length macro argument must be last parameter file.h:32: Error:
Illegal character in macro argument name file.i:37: Error: Macro 'SIT'
expects 2 arguments
Code used for testing:
// file.h
%define SIT(ax,b)
abc(
%enddef
%define MISSING_DOT1(a,
b,
..)
xxx
%enddef
%define MISSING_DOT2(..)
xxx
%enddef
%define DUPLICATE(a,b)
abc
%enddef
%define DUPLICATE(b)
xxx
%enddef
%define VARARGS_WRONG(a,
x,
...,
b)
xxx
%enddef
%define BAD_ARGNAME(
a,
b{c
)
xxx
%enddef
SIT(1)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12195 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Preprocessor/cpp.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 32f3a3bd4..38a52dc3f 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -337,7 +337,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argstr);
}
if (c != ')') {
- Swig_error(Getfile(str), Getline(str), "Missing \')\' in macro parameters\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n");
goto macro_error;
}
break;
@@ -372,10 +372,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
argname = NewStringEmpty();
while ((c = Getc(argstr)) != EOF) {
if (c == ',') {
- varargname = Macro_vararg_name(argname, str);
+ varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Delete(varargname);
- Swig_error(Getfile(str), Getline(str), "Variable-length macro argument must be last parameter\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n");
} else {
Append(arglist, argname);
}
@@ -385,13 +385,13 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argname);
} else if (!(isspace(c) || (c == '\\'))) {
Delete(argname);
- Swig_error(Getfile(str), Getline(str), "Illegal character in macro argument name\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n");
goto macro_error;
}
}
if (Len(argname)) {
/* Check for varargs */
- varargname = Macro_vararg_name(argname, str);
+ varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Append(arglist, varargname);
Delete(varargname);
@@ -513,7 +513,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
symbols = Getattr(cpp, kpp_symbols);
if ((m1 = Getattr(symbols, macroname))) {
if (!Checkattr(m1, kpp_value, macrovalue)) {
- Swig_error(Getfile(str), Getline(str), "Macro '%s' redefined,\n", macroname);
+ Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname);
Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname);
goto macro_error;
}
From 41bc29c9f0b09247e34d9a3f6314975f0bd8d7e5 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 31 Aug 2010 06:02:10 +0000
Subject: [PATCH 0026/1045] Add missing changes documentation for rev 12195
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12196 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index aaaf2254b..90391fbfb 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,9 +5,20 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-08-30: wsfulton
+ Fix line number and file name reporting for some macro preprocessor warnings.
+ The line number of the macro argument has been corrected and the line number
+ of the start of the macro instead of one past the end is used. Some examples:
+ file.h:11: Error: Illegal macro argument name '..'
+ file.h:19: Error: Macro 'DUPLICATE' redefined,
+ file.h:15: Error: previous definition of 'DUPLICATE'.
+ file.h:25: Error: Variable-length macro argument must be last parameter
+ file.h:32: Error: Illegal character in macro argument name
+ file.i:37: Error: Macro 'SIT' expects 2 arguments
+
2010-08-26: wsfulton
Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this
- did not work at all.
+ did not work at all. Also fixes SF #2822822.
2010-08-17: wsfulton
[Perl] Fix corner case marshalling of doubles - errno was not being correctly
From aa728ece671c7e135d6d6dc7ab299dc6bfc78308 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 1 Sep 2010 21:06:10 +0000
Subject: [PATCH 0027/1045] Fix __LINE__ and __FILE__ expansion in macros with
no arguments
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12197 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
.../test-suite/java/preproc_line_file_runme.java | 3 +++
Examples/test-suite/preproc_line_file.i | 10 ++++++++++
Source/Preprocessor/cpp.c | 16 ++++++++++------
3 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
index e390b0c19..7200e4a53 100644
--- a/Examples/test-suite/java/preproc_line_file_runme.java
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -45,5 +45,8 @@ public class preproc_line_file_runme {
if (SillyStruct.LINE_NUMBER != 41)
throw new RuntimeException("preproc failure");
+
+ if (SillyMacroClass.LINE_NUM != 45)
+ throw new RuntimeException("preproc failure");
}
}
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index 1a75be83a..2ef43b017 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -40,3 +40,13 @@ struct SillyStruct {
int num;
static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */
};
+
+#define SILLY_CLASS struct SillyMacroClass { int num; static const int LINE_NUM = __LINE__; };
+SILLY_CLASS
+
+%{
+#define SILLY_CLASS struct SillyMacroClass { int num; };
+SILLY_CLASS
+%}
+
+
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 38a52dc3f..f044e344c 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -699,9 +699,12 @@ static String *get_options(String *str) {
*
* Perform macro expansion and return a new string. Returns NULL if some sort
* of error occurred.
+ * name - name of the macro
+ * args - arguments passed to the macro
+ * line_file - only used for line/file name when reporting errors
* ----------------------------------------------------------------------------- */
-static String *expand_macro(String *name, List *args) {
+static String *expand_macro(String *name, List *args, String *line_file) {
String *ns;
DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e;
int i, l;
@@ -718,8 +721,8 @@ static String *expand_macro(String *name, List *args) {
if (macro_level == 0) {
/* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */
- macro_start_line = Getline(args);
- macro_start_file = Getfile(args);
+ macro_start_line = Getline(args ? args : line_file);
+ macro_start_file = Getfile(args ? args : line_file);
}
macro_level++;
@@ -1085,7 +1088,7 @@ static DOH *Preprocessor_replace(DOH *s) {
} else {
args = 0;
}
- e = expand_macro(id, args);
+ e = expand_macro(id, args, s);
if (e) {
Append(ns, e);
}
@@ -1151,8 +1154,9 @@ static DOH *Preprocessor_replace(DOH *s) {
/* if (Getattr(m,"args")) {
Swig_error(Getfile(id),Getline(id),"Macro arguments expected.\n");
} */
- e = expand_macro(id, 0);
- Append(ns, e);
+ e = expand_macro(id, 0, s);
+ if (e)
+ Append(ns, e);
Delete(e);
} else {
Append(ns, id);
From 1e6ed0843fdc303abffab1e117b062e6c26de4fa Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 1 Sep 2010 21:11:09 +0000
Subject: [PATCH 0028/1045] minor clarification in test comment
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12198 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/varargs.i | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Examples/test-suite/varargs.i b/Examples/test-suite/varargs.i
index 41e4903f0..c7931fed2 100644
--- a/Examples/test-suite/varargs.i
+++ b/Examples/test-suite/varargs.i
@@ -1,4 +1,5 @@
-// Tests SWIG's *default* handling of varargs. The default behavior is to simply ignore the varargs.
+// Tests SWIG's *default* handling of varargs (function varargs, not preprocessor varargs).
+// The default behavior is to simply ignore the varargs.
%module varargs
%varargs(int mode = 0) test_def;
From a44f83cf0538c48c47ebae71545269fa0fa04a64 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 3 Sep 2010 06:03:48 +0000
Subject: [PATCH 0029/1045] Fix line numbers in error and warning messages
which were accumulately one less than they should have been after parsing
each %include/%import - bug introduced in swig-1.3.32. Also fix line numbers
in error and warning messages when new line characters appear between the
%include / %import statement and the filename.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12199 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 12 ++++++++++--
Source/CParse/parser.y | 2 +-
Source/Preprocessor/cpp.c | 13 ++++++++-----
3 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 90391fbfb..7213a66c0 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,10 +5,18 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-02: wsfulton
+ Fix line numbers in error and warning messages which were accumulately one
+ less than they should have been after parsing each %include/%import - bug
+ introduced in swig-1.3.32. Also fix line numbers in error and warning messages
+ when new line characters appear between the %include / %import statement and
+ the filename.
+
2010-08-30: wsfulton
Fix line number and file name reporting for some macro preprocessor warnings.
The line number of the macro argument has been corrected and the line number
- of the start of the macro instead of one past the end is used. Some examples:
+ of the start of the macro instead of one past the end of the macro is used.
+ Some examples:
file.h:11: Error: Illegal macro argument name '..'
file.h:19: Error: Macro 'DUPLICATE' redefined,
file.h:15: Error: previous definition of 'DUPLICATE'.
@@ -50,7 +58,7 @@ Version 2.0.1 (in progress)
adjust your regular expressions syntax as the new regex encoder uses
Perl-compatible syntax and not (extended) POSIX syntax as the old one.
- *** POTENTIAL INCOMPATIBILITY ***
+ *** POTENTIAL INCOMPATIBILITY ***
2010-07-13: vadz
Add "regexmatch", "regextarget" and "notregexmatch" which can be
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 6e41fa565..f0df6684d 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -2121,7 +2121,7 @@ include_directive: includetype options string LBRACKET {
} interface RBRACKET {
String *mname = 0;
$$ = $6;
- scanner_set_location($1.filename,$1.line);
+ scanner_set_location($1.filename,$1.line+1);
if (strcmp($1.type,"include") == 0) set_nodeType($$,"include");
if (strcmp($1.type,"import") == 0) {
mname = $2 ? Getattr($2,"module") : 0;
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index f044e344c..83ccdfca9 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -642,7 +642,6 @@ static String *get_filename(String *str, int *sysfile) {
String *fn;
int c;
- skip_whitespace(str, 0);
fn = NewStringEmpty();
copy_location(str, fn);
c = Getc(str);
@@ -668,9 +667,7 @@ static String *get_filename(String *str, int *sysfile) {
}
static String *get_options(String *str) {
-
int c;
- skip_whitespace(str, 0);
c = Getc(str);
if (c == '(') {
String *opt;
@@ -1648,8 +1645,8 @@ String *Preprocessor_parse(String *s) {
pop_imported();
}
Delete(s2);
+ Delete(s1);
}
- Delete(s1);
Delete(fn);
}
} else if (Equal(id, kpp_pragma)) {
@@ -1749,6 +1746,8 @@ String *Preprocessor_parse(String *s) {
/* Got some kind of file inclusion directive */
if (allow) {
DOH *s1, *s2, *fn, *opt;
+ String *options_whitespace = NewString("");
+ String *filename_whitespace = NewString("");
int sysfile = 0;
if (Equal(decl, kpp_dextern)) {
@@ -1756,14 +1755,16 @@ String *Preprocessor_parse(String *s) {
Clear(decl);
Append(decl, "%%import");
}
+ skip_whitespace(s, options_whitespace);
opt = get_options(s);
+ skip_whitespace(s, filename_whitespace);
fn = get_filename(s, &sysfile);
s1 = cpp_include(fn, sysfile);
if (s1) {
char *dirname;
copy_location(s, chunk);
add_chunk(ns, chunk, allow);
- Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
+ Printf(ns, "%sfile%s%s%s\"%s\" [\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
if (Equal(decl, kpp_dimport)) {
push_imported();
}
@@ -1787,6 +1788,8 @@ String *Preprocessor_parse(String *s) {
Delete(s1);
}
Delete(fn);
+ Delete(filename_whitespace);
+ Delete(options_whitespace);
}
state = 1;
} else if (Equal(decl, kpp_dline)) {
From 45601f24b4209b1f00b6897a01afc3ecfcf07b40 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 3 Sep 2010 17:47:12 +0000
Subject: [PATCH 0030/1045] Fix line numbers in error and warning messages for
preprocessor messages within %inline. Also fixes __LINE__ within %inline
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12200 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 9 +++++++
.../java/preproc_line_file_runme.java | 16 ++++++++++--
Examples/test-suite/preproc_line_file.i | 26 +++++++++++++++++++
Source/CParse/parser.y | 3 +--
4 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 7213a66c0..6d5cc9327 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,15 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-02: wsfulton
+ Fix line numbers in error and warning messages for preprocessor messages within
+ %inline, for example:
+
+ %inline %{
+ #define FOOBAR 1
+ #define FOOBAR "hi"
+ %}
+
2010-09-02: wsfulton
Fix line numbers in error and warning messages which were accumulately one
less than they should have been after parsing each %include/%import - bug
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
index 7200e4a53..8119824e9 100644
--- a/Examples/test-suite/java/preproc_line_file_runme.java
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -11,6 +11,8 @@ public class preproc_line_file_runme {
}
}
+ public static String FILENAME_WINDOWS = "..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i";
+ public static String FILENAME_UNIX = "../../../../Examples/test-suite/preproc_line_file.i";
public static void main(String argv[]) throws Throwable
{
int myline = preproc_line_file.MYLINE;
@@ -22,10 +24,10 @@ public class preproc_line_file_runme {
String myfile = preproc_line_file.MYFILE;
String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED;
- if (!(myfile.equals("../../../../Examples/test-suite/preproc_line_file.i") || myfile.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i")))
+ if (!(myfile.equals(FILENAME_UNIX) || myfile.equals(FILENAME_WINDOWS)))
throw new RuntimeException("preproc failure");
- if (!(myfile_adjusted.equals("../../../../Examples/test-suite/preproc_line_file.i.bak") || myfile_adjusted.equals("..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i.bak")))
+ if (!(myfile_adjusted.equals(FILENAME_UNIX + ".bak") || myfile_adjusted.equals(FILENAME_WINDOWS + ".bak")))
throw new RuntimeException("preproc failure");
if (!preproc_line_file.MY_STRINGNUM_A.equals("my15"))
@@ -48,5 +50,15 @@ public class preproc_line_file_runme {
if (SillyMacroClass.LINE_NUM != 45)
throw new RuntimeException("preproc failure");
+
+ if (SillyMultipleMacroStruct.LINE_NUM != 70)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.INLINE_LINE != 76)
+ throw new RuntimeException("preproc failure");
+
+ String inlineFile = preproc_line_file.INLINE_FILE;
+ if (!(inlineFile.equals(FILENAME_UNIX) || inlineFile.equals(FILENAME_WINDOWS)))
+ throw new RuntimeException("preproc failure");
}
}
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index 2ef43b017..5b75d0a20 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -50,3 +50,29 @@ SILLY_CLASS
%}
+%inline %{
+#ifdef SWIG
+%define BODY
+ int num;
+ static const int LINE_NUM = __LINE__;
+%enddef
+%define KLASS(NAME)
+struct NAME {
+ BODY
+};
+%enddef
+#else
+#define KLASS(NAME) \
+struct NAME { \
+ int num; \
+};
+#endif
+KLASS(SillyMultipleMacroStruct)
+%}
+
+%inline %{
+
+#define INLINE_FILE __FILE__
+#define INLINE_LINE __LINE__
+%}
+
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index f0df6684d..09ed9bcf2 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -2176,15 +2176,14 @@ inline_directive : INLINE HBLOCK {
String *cpps;
if (Namespaceprefix) {
Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n");
-
$$ = 0;
} else {
$$ = new_node("insert");
Setattr($$,"code",$2);
/* Need to run through the preprocessor */
+ Seek($2,0,SEEK_SET);
Setline($2,cparse_start_line);
Setfile($2,cparse_file);
- Seek($2,0,SEEK_SET);
cpps = Preprocessor_parse($2);
start_inline(Char(cpps), cparse_start_line);
Delete($2);
From 197c8e899d8d3bf16bf696728cfe8edcd7829a8f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 3 Sep 2010 18:44:01 +0000
Subject: [PATCH 0031/1045] Fix erroneous line numbers in argument count error
messages for macro expansions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12201 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 10 ++++++++++
Source/Preprocessor/cpp.c | 6 +++---
2 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 6d5cc9327..c09ff3409 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-03: wsfulton
+ Fix erroneous line numbers in error messages for macro expansions, for example,
+ the error message now points to instantation of the macro, ie the last line here:
+
+ #define MACRO2(a, b)
+
+ #define MACRO1(NAME) MACRO2(NAME,2,3)
+
+ MACRO1(abc)
+
2010-09-02: wsfulton
Fix line numbers in error and warning messages for preprocessor messages within
%inline, for example:
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 83ccdfca9..16a9ce1d3 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -773,11 +773,11 @@ static String *expand_macro(String *name, List *args, String *line_file) {
/* If there are arguments, see if they match what we were given */
if (args && (margs) && (Len(margs) != Len(args))) {
if (Len(margs) > (1 + isvarargs))
- Swig_error(Getfile(args), Getline(args), "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
+ Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
else if (Len(margs) == (1 + isvarargs))
- Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name);
+ Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects 1 argument\n", name);
else
- Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name);
+ Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects no arguments\n", name);
macro_level--;
return 0;
}
From 04c3e6b7d33663b8976251a6a6a48421c7227d19 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 17:30:18 +0000
Subject: [PATCH 0032/1045] Fix line numbering for 'Unterminated call invoking
macro' error
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12202 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
.../errors/pp_macro_defined_unterminated.i | 6 ++++++
Source/Preprocessor/cpp.c | 17 +++++++++--------
2 files changed, 15 insertions(+), 8 deletions(-)
create mode 100644 Examples/test-suite/errors/pp_macro_defined_unterminated.i
diff --git a/Examples/test-suite/errors/pp_macro_defined_unterminated.i b/Examples/test-suite/errors/pp_macro_defined_unterminated.i
new file mode 100644
index 000000000..bc44d07c6
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_defined_unterminated.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+#if defined(a
+#endif
+
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 16a9ce1d3..b4866ee9c 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -325,6 +325,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
/* Now look for a macro name */
macroname = NewStringEmpty();
+ copy_location(str, macroname);
while ((c = Getc(str)) != EOF) {
if (c == '(') {
argstr = NewStringEmpty();
@@ -360,6 +361,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
if (!swigmacro)
skip_whitespace(str, 0);
macrovalue = NewStringEmpty();
+ copy_location(str, macrovalue);
while ((c = Getc(str)) != EOF) {
Putc(c, macrovalue);
}
@@ -500,10 +502,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Setattr(macro, kpp_varargs, "1");
}
}
- Setline(macrovalue, line);
- Setfile(macrovalue, file);
- Setline(macroname, line);
- Setfile(macroname, file);
Setattr(macro, kpp_value, macrovalue);
Setline(macro, line);
Setfile(macro, file);
@@ -556,7 +554,7 @@ void Preprocessor_undef(const_String_or_char_ptr str) {
* Isolates macro arguments and returns them in a list. For each argument,
* leading and trailing whitespace is stripped (ala K&R, pg. 230).
* ----------------------------------------------------------------------------- */
-static List *find_args(String *s) {
+static List *find_args(String *s, int ismacro, String *macro_name) {
List *args;
String *str;
int c, level;
@@ -627,7 +625,10 @@ static List *find_args(String *s) {
c = Getc(s);
}
unterm:
- Swig_error(Getfile(args), Getline(args), "Unterminated macro call.\n");
+ if (ismacro)
+ Swig_error(Getfile(args), Getline(args), "Unterminated call invoking macro '%s'\n", macro_name);
+ else
+ Swig_error(Getfile(args), Getline(args), "Unterminated call to '%s'\n", macro_name);
return args;
}
@@ -1021,7 +1022,7 @@ static DOH *Preprocessor_replace(DOH *s) {
c = Getc(s);
if (c == '(') {
Ungetc(c, s);
- args = find_args(s);
+ args = find_args(s, 0, kpp_defined);
} else if (isidchar(c)) {
DOH *arg = NewStringEmpty();
args = NewList();
@@ -1077,7 +1078,7 @@ static DOH *Preprocessor_replace(DOH *s) {
/* See if the macro expects arguments */
if (Getattr(m, kpp_args)) {
/* Yep. We need to go find the arguments and do a substitution */
- args = find_args(s);
+ args = find_args(s, 1, id);
if (!Len(args)) {
Delete(args);
args = 0;
From b0609c3be210925c543633ec558cde312e3d2fc4 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 18:10:43 +0000
Subject: [PATCH 0033/1045] Add some more preprocessor tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12203 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/errors/make.sh | 7 ++++++-
Examples/test-suite/errors/pp_deprecated.i | 9 +++++++++
.../test-suite/errors/pp_illegal_argument.i | 20 +++++++++++++++++++
Examples/test-suite/errors/pp_pragma.i | 6 ++++++
Examples/test-suite/errors/pp_variable_args.i | 10 ++++++++++
5 files changed, 51 insertions(+), 1 deletion(-)
create mode 100644 Examples/test-suite/errors/pp_deprecated.i
create mode 100644 Examples/test-suite/errors/pp_illegal_argument.i
create mode 100644 Examples/test-suite/errors/pp_pragma.i
create mode 100644 Examples/test-suite/errors/pp_variable_args.i
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index ae38ca879..e50fd22dc 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -24,9 +24,12 @@ c_missing_semi
c_redefine
c_varargs
c_varargs_neg
-nomodule
+nomodule
pp_badeval
+pp_deprecated
pp_defined
+pp_macro_defined_unterminated
+pp_illegal_argument
pp_macro_args
pp_macro_badchar
pp_macro_nargs
@@ -39,9 +42,11 @@ pp_missing_enddef
pp_missing_endif
pp_missing_file
pp_missing_rblock
+pp_pragma
pp_unterm_char
pp_unterm_comment
pp_unterm_string
+pp_variable_args
swig_apply_nargs
swig_identifier
swig_insert_bad
diff --git a/Examples/test-suite/errors/pp_deprecated.i b/Examples/test-suite/errors/pp_deprecated.i
new file mode 100644
index 000000000..68f81317b
--- /dev/null
+++ b/Examples/test-suite/errors/pp_deprecated.i
@@ -0,0 +1,9 @@
+%module xxx
+
+
+%extern ext;
+
+#warning Print this warning
+
+#error This is an error
+
diff --git a/Examples/test-suite/errors/pp_illegal_argument.i b/Examples/test-suite/errors/pp_illegal_argument.i
new file mode 100644
index 000000000..13ffa4559
--- /dev/null
+++ b/Examples/test-suite/errors/pp_illegal_argument.i
@@ -0,0 +1,20 @@
+%module xxx
+
+
+%define MISSING_DOT1(a,
+b,
+..)
+xxx
+%enddef
+
+%define MISSING_DOT2(..)
+xxx
+%enddef
+
+%define BAD_ARGNAME(
+a,
+b{c
+)
+xxx
+%enddef
+
diff --git a/Examples/test-suite/errors/pp_pragma.i b/Examples/test-suite/errors/pp_pragma.i
new file mode 100644
index 000000000..8d928690c
--- /dev/null
+++ b/Examples/test-suite/errors/pp_pragma.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+#pragma SWIG rubbish()
+
+
diff --git a/Examples/test-suite/errors/pp_variable_args.i b/Examples/test-suite/errors/pp_variable_args.i
new file mode 100644
index 000000000..c5f72fff9
--- /dev/null
+++ b/Examples/test-suite/errors/pp_variable_args.i
@@ -0,0 +1,10 @@
+%module xxx
+
+
+%define VARARGS_WRONG(a,
+x,
+...,
+ b)
+xxx
+%enddef
+
From 46bd4a26c673babd36a551191c596cac300d8992 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 18:12:13 +0000
Subject: [PATCH 0034/1045] Add expected error/warning messages log
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12204 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/errors/expected.log | 241 ++++++++++++++++++++++++
1 file changed, 241 insertions(+)
create mode 100644 Examples/test-suite/errors/expected.log
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
new file mode 100644
index 000000000..ff56d9b2b
--- /dev/null
+++ b/Examples/test-suite/errors/expected.log
@@ -0,0 +1,241 @@
+SWIG error and warning test. opts=
+-----------------------------------------------------------
+
+:::::::::::::::::::::::::::::::: c_bad_name.i :::::::::::::::::::::::::::::::::::
+c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead.
+c_bad_name.i:3: Error: Missing argument to %name directive.
+
+:::::::::::::::::::::::::::::::: c_bad_native.i :::::::::::::::::::::::::::::::::::
+c_bad_native.i:3: Error: %native declaration 'foo' is not a function.
+
+:::::::::::::::::::::::::::::::: c_class.i :::::::::::::::::::::::::::::::::::
+c_class.i:3: Warning 301: class keyword used, but not in C++ mode.
+
+:::::::::::::::::::::::::::::::: c_default_error.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: c_deprecated.i :::::::::::::::::::::::::::::::::::
+c_deprecated.i:3: Warning 102: %val directive deprecated (ignored).
+c_deprecated.i:3: Warning 103: %out directive deprecated (ignored).
+
+:::::::::::::::::::::::::::::::: c_empty_char.i :::::::::::::::::::::::::::::::::::
+c_empty_char.i:3: Error: Empty character constant
+0
+
+:::::::::::::::::::::::::::::::: c_enum_badvalue.i :::::::::::::::::::::::::::::::::::
+c_enum_badvalue.i:6: Error: Type error. Expecting an integral type
+
+:::::::::::::::::::::::::::::::: c_extra_rblock.i :::::::::::::::::::::::::::::::::::
+c_extra_rblock.i:5: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: c_extra_rbrace.i :::::::::::::::::::::::::::::::::::
+c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}'
+
+:::::::::::::::::::::::::::::::: c_extra_unsigned.i :::::::::::::::::::::::::::::::::::
+c_extra_unsigned.i:3: Error: Extra unsigned specifier.
+c_extra_unsigned.i:4: Error: Extra signed specifier.
+c_extra_unsigned.i:5: Error: Extra signed specifier.
+
+:::::::::::::::::::::::::::::::: c_insert_missing.i :::::::::::::::::::::::::::::::::::
+c_insert_missing.i:3: Error: Couldn't find 'missing_file.i'.
+
+:::::::::::::::::::::::::::::::: c_long_short.i :::::::::::::::::::::::::::::::::::
+c_long_short.i:3: Error: Extra long specifier.
+c_long_short.i:4: Error: Extra short specifier.
+c_long_short.i:5: Error: Extra long specifier.
+c_long_short.i:6: Error: Extra short specifier.
+
+:::::::::::::::::::::::::::::::: c_missing_rbrace.i :::::::::::::::::::::::::::::::::::
+:168430090: Error: Missing '}'. Reached end of input.
+c_missing_rbrace.i:3: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: c_missing_semi.i :::::::::::::::::::::::::::::::::::
+c_missing_semi.i:3: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: c_redefine.i :::::::::::::::::::::::::::::::::::
+c_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored),
+c_redefine.i:3: Warning 302: previous definition of 'foo'.
+c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored),
+c_redefine.i:6: Warning 302: previous definition of 'bar'.
+c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'),
+c_redefine.i:6: Warning 322: previous declaration of 'bar'.
+
+:::::::::::::::::::::::::::::::: c_varargs.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: c_varargs_neg.i :::::::::::::::::::::::::::::::::::
+c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
+
+:::::::::::::::::::::::::::::::: nomodule.i :::::::::::::::::::::::::::::::::::
+No module name specified using %module or -module.
+
+:::::::::::::::::::::::::::::::: pp_badeval.i :::::::::::::::::::::::::::::::::::
+pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+'
+pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
+
+:::::::::::::::::::::::::::::::: pp_deprecated.i :::::::::::::::::::::::::::::::::::
+pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
+pp_deprecated.i:4: Error: Unable to find 'ext;'
+pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning
+pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
+
+:::::::::::::::::::::::::::::::: pp_defined.i :::::::::::::::::::::::::::::::::::
+pp_defined.i:6: Error: No arguments given to defined()
+pp_defined.i:6: Warning 202: Could not evaluate 'defined'
+pp_defined.i:6: Warning 202: Error: 'Expected an expression'
+
+:::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i :::::::::::::::::::::::::::::::::::
+pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined'
+
+:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
+pp_illegal_argument.i:6: Error: Illegal macro argument name '..'
+pp_illegal_argument.i:10: Error: Illegal macro argument name '..'
+pp_illegal_argument.i:16: Error: Illegal character in macro argument name
+
+:::::::::::::::::::::::::::::::: pp_macro_args.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: pp_macro_badchar.i :::::::::::::::::::::::::::::::::::
+pp_macro_badchar.i:4: Error: Illegal character in macro argument name
+
+:::::::::::::::::::::::::::::::: pp_macro_nargs.i :::::::::::::::::::::::::::::::::::
+pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
+pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments
+pp_macro_nargs.i:10: Error: Macro 'bar' expects 1 argument
+pp_macro_nargs.i:11: Error: Macro 'spam' expects no arguments
+
+:::::::::::::::::::::::::::::::: pp_macro_redef.i :::::::::::::::::::::::::::::::::::
+pp_macro_redef.i:4: Error: Macro 'foo' redefined,
+pp_macro_redef.i:3: Error: previous definition of 'foo'.
+pp_macro_redef.i:7: Error: Macro 'foo' redefined,
+pp_macro_redef.i:3: Error: previous definition of 'foo'.
+
+:::::::::::::::::::::::::::::::: pp_macro_rparen.i :::::::::::::::::::::::::::::::::::
+pp_macro_rparen.i:3: Error: Missing ')' in macro parameters
+
+:::::::::::::::::::::::::::::::: pp_macro_unterminated.i :::::::::::::::::::::::::::::::::::
+pp_macro_unterminated.i:5: Error: Unterminated call invoking macro 'foo'
+
+:::::::::::::::::::::::::::::::: pp_misplaced_elif.i :::::::::::::::::::::::::::::::::::
+pp_misplaced_elif.i:4: Error: Misplaced #elif.
+pp_misplaced_elif.i:6: Error: Extraneous #endif.
+
+:::::::::::::::::::::::::::::::: pp_misplaced_else.i :::::::::::::::::::::::::::::::::::
+pp_misplaced_else.i:4: Error: Misplaced #else.
+pp_misplaced_else.i:6: Error: Extraneous #endif.
+
+:::::::::::::::::::::::::::::::: pp_missing_enddef.i :::::::::::::::::::::::::::::::::::
+pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_missing_endif.i :::::::::::::::::::::::::::::::::::
+pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_missing_file.i :::::::::::::::::::::::::::::::::::
+pp_missing_file.i:3: Error: Unable to find 'missing_filename.i'
+
+:::::::::::::::::::::::::::::::: pp_missing_rblock.i :::::::::::::::::::::::::::::::::::
+pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_pragma.i :::::::::::::::::::::::::::::::::::
+pp_pragma.i:4: Error: Unknown SWIG pragma: rubbish()
+
+:::::::::::::::::::::::::::::::: pp_unterm_char.i :::::::::::::::::::::::::::::::::::
+pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
+
+:::::::::::::::::::::::::::::::: pp_unterm_comment.i :::::::::::::::::::::::::::::::::::
+pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_unterm_string.i :::::::::::::::::::::::::::::::::::
+pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
+
+:::::::::::::::::::::::::::::::: pp_variable_args.i :::::::::::::::::::::::::::::::::::
+pp_variable_args.i:6: Error: Variable length macro argument must be last parameter
+
+:::::::::::::::::::::::::::::::: swig_apply_nargs.i :::::::::::::::::::::::::::::::::::
+swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match.
+
+:::::::::::::::::::::::::::::::: swig_identifier.i :::::::::::::::::::::::::::::::::::
+swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier.
+
+:::::::::::::::::::::::::::::::: swig_insert_bad.i :::::::::::::::::::::::::::::::::::
+swig_insert_bad.i:5: Error: Unknown target 'foobar' for %insert directive.
+
+:::::::::::::::::::::::::::::::: swig_typemap_copy.i :::::::::::::::::::::::::::::::::::
+swig_typemap_copy.i:3: Error: Can't copy typemap (in) blah = int
+
+:::::::::::::::::::::::::::::::: swig_typemap_old.i :::::::::::::::::::::::::::::::::::
+swig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target).
+swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated.
+For typemaps related to argument input (in,ignore,default,arginit,check), replace
+$source by $input and $target by $1. For typemaps related to return values (out,
+argout,ret,except), replace $source by $1 and $target by $result. See the file
+Doc/Manual/Typemaps.html for complete details.
+
+:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
+cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
+cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
+
+:::::::::::::::::::::::::::::::: cpp_extend_redefine.i :::::::::::::::::::::::::::::::::::
+cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
+cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
+cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam',
+cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'.
+
+:::::::::::::::::::::::::::::::: cpp_extend_undefined.i :::::::::::::::::::::::::::::::::::
+cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo.
+
+:::::::::::::::::::::::::::::::: cpp_inline_namespace.i :::::::::::::::::::::::::::::::::::
+cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed.
+
+:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
+cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: cpp_namespace_alias.i :::::::::::::::::::::::::::::::::::
+cpp_namespace_alias.i:8: Warning 308: Namespace alias 'B' not allowed here. Assuming 'blah'
+
+:::::::::::::::::::::::::::::::: cpp_namespace_aliasnot.i :::::::::::::::::::::::::::::::::::
+cpp_namespace_aliasnot.i:4: Error: 'blah' is not a namespace
+
+:::::::::::::::::::::::::::::::: cpp_namespace_aliasundef.i :::::::::::::::::::::::::::::::::::
+cpp_namespace_aliasundef.i:3: Error: Unknown namespace 'blah'
+
+:::::::::::::::::::::::::::::::: cpp_nested.i :::::::::::::::::::::::::::::::::::
+cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored)
+cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored)
+
+:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
+cpp_no_access.i:3: Warning 319: No access specifier given for base class foo (ignored).
+
+:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
+cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
+cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored.
+cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using %template.
+
+:::::::::::::::::::::::::::::::: cpp_overload.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
+cpp_private_inherit.i:6: Warning 309: private inheritance ignored.
+cpp_private_inherit.i:9: Warning 309: protected inheritance ignored.
+
+:::::::::::::::::::::::::::::::: cpp_template_argname.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_template_nargs.i :::::::::::::::::::::::::::::::::::
+cpp_template_nargs.i:5: Error: Template 'blah' undefined.
+cpp_template_nargs.i:6: Error: Template 'blah' undefined.
+
+:::::::::::::::::::::::::::::::: cpp_template_not.i :::::::::::::::::::::::::::::::::::
+cpp_template_not.i:5: Error: 'blah' is not defined as a template. (cdecl)
+
+:::::::::::::::::::::::::::::::: cpp_template_partial.i :::::::::::::::::::::::::::::::::::
+cpp_template_partial.i:3: Warning 317: Specialization of non-template 'vector'.
+
+:::::::::::::::::::::::::::::::: cpp_template_repeat.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_template_undef.i :::::::::::::::::::::::::::::::::::
+cpp_template_undef.i:3: Error: Template 'blah' undefined.
+
+:::::::::::::::::::::::::::::::: cpp_using_not.i :::::::::::::::::::::::::::::::::::
+cpp_using_not.i:4: Error: 'blah' is not a namespace.
+
+:::::::::::::::::::::::::::::::: cpp_using_undef.i :::::::::::::::::::::::::::::::::::
+cpp_using_undef.i:4: Error: Nothing known about namespace 'foo'
+cpp_using_undef.i:3: Warning 315: Nothing known about 'foo::bar'.
From b2e2cb8f6607ae29ef78e59390aa05c4ab354440 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 18:25:22 +0000
Subject: [PATCH 0035/1045] Add test for line number reporting for multiple
macro expansions
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12205 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/errors/make.sh | 1 +
Examples/test-suite/errors/pp_macro_expansion.i | 10 ++++++++++
2 files changed, 11 insertions(+)
create mode 100644 Examples/test-suite/errors/pp_macro_expansion.i
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index e50fd22dc..3b58d6ab0 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -32,6 +32,7 @@ pp_macro_defined_unterminated
pp_illegal_argument
pp_macro_args
pp_macro_badchar
+pp_macro_expansion
pp_macro_nargs
pp_macro_redef
pp_macro_rparen
diff --git a/Examples/test-suite/errors/pp_macro_expansion.i b/Examples/test-suite/errors/pp_macro_expansion.i
new file mode 100644
index 000000000..e23a0da01
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_expansion.i
@@ -0,0 +1,10 @@
+%module xxx
+
+/* Test line number reporting for multiple macro expansions */
+
+#define MACRO2(a, b)
+
+#define MACRO1(NAME) MACRO2(NAME,2,3)
+
+MACRO1(abc)
+
From 547019e0d457fe9427ff716737b8fdb82eab1cd8 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Wed, 8 Sep 2010 00:54:31 +0000
Subject: [PATCH 0036/1045] Change HTML to be more suitable for human edits.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12207 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Ruby.html | 249 ++++++++++++++++++++++++++++++++++---------
1 file changed, 201 insertions(+), 48 deletions(-)
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index b61ded8e5..736b6137d 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -1,30 +1,11 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
SWIG and Ruby
-
-
-
-
-
-
+
33 SWIG and Ruby
@@ -255,7 +236,9 @@ header file. This file is usually contained in a directory such as
@@ -456,7 +441,12 @@ module is imported by requiring the etc feature:
-
# The feature name begins with a lowercase letter... require 'etc'
# ... but the module name begins with an uppercase letter puts "Your login name: #{Etc.getlogin}"
+
# The feature name begins with a lowercase letter...
+require 'etc'
+
+# ... but the module name begins with an uppercase letter
+puts "Your login name: #{Etc.getlogin}"
+
@@ -2733,7 +2723,7 @@ i
->> [3, 4, 5 ]
+>> [3, 4, 5 ]
@@ -10098,7 +10088,38 @@ classes is:
-
/* File RubyOwnershipExample.i */
%module RubyOwnershipExample
%{ #include "RubyOwnershipExample.h" %}
class Foo { public: Foo(); ~Foo(); };
class Bar { Foo *foo_; public: Bar(); ~Bar(); Foo* get_foo();
@@ -10512,14 +10570,22 @@ directive, let's slightly change our example. Assume that the zoo
object is responsible for freeing animal that it contains. This means
that the Zoo::add_animal
function should be marked with a DISOWN typemap
-and the destructor should be updated as below::
+and the destructor should be updated as below:
-
Zoo::~Zoo() { IterType iter = this->animals.begin(); IterType end = this->animals.end();
/* Loop over each animal */ int count = zoo->get_num_animals();
for(int i = 0; i < count; ++i) { /* Get an animal */ Animal* animal = zoo->get_animal(i);
/* Unlink the Ruby object from the C++ object */ SWIG_RubyUnlinkObjects(animal);
/* Now remove the tracking for this animal */ SWIG_RubyRemoveTracking(animal); }
/* Now call SWIG_RubyRemoveTracking for the zoo */ SWIG_RubyRemoveTracking(ptr);
/* Now free the zoo which will free the animals it contains */ delete zoo; } %}
+
%module example
+
+%{
+#include "example.h"
+%}
+
+/* Specify that ownership is transferred to the zoo
+ when calling add_animal */
+%apply SWIGTYPE *DISOWN { Animal* animal };
+
+/* Track objects */
+%trackobjects;
+
+/* Specify the mark function */
+%freefunc Zoo "free_Zoo";
+
+%include "example.h"
+
+%header %{
+ static void free_Zoo(void* ptr) {
+ Zoo* zoo = (Zoo*) ptr;
+
+ /* Loop over each animal */
+ int count = zoo->get_num_animals();
+
+ for(int i = 0; i < count; ++i) {
+ /* Get an animal */
+ Animal* animal = zoo->get_animal(i);
+
+ /* Unlink the Ruby object from the C++ object */
+ SWIG_RubyUnlinkObjects(animal);
+
+ /* Now remove the tracking for this animal */
+ SWIG_RubyRemoveTracking(animal);
+ }
+
+ /* Now call SWIG_RubyRemoveTracking for the zoo */
+ SWIG_RubyRemoveTracking(ptr);
+
+ /* Now free the zoo which will free the animals it contains */
+ delete zoo;
+ }
+%}
@@ -10590,7 +10720,30 @@ existing Ruby object to the destroyed C++ object and raise an exception.
-Warning. Debugging SWIG is for the very patient.
+
+
+The DOH types used in the SWIG source code are all typedefined to void.
+Consequently, it is impossible for debuggers to automatically extract any information about DOH objects.
+The easiest approach to debugging and viewing the contents of DOH objects is to make a call into one of the family of SWIG print functions from the debugger.
+The "Debugging Functions" section in SWIG Parse Tree Handling lists them.
+It is sometimes easier to debug by placing a few calls to these functions in code of interest and recompile, especially if your debugger cannot easily make calls into functions within a debugged binary.
+
+
+
+The SWIG distribution comes with some additional support for the gdb debugger in the Tools/swig.gdb file.
+Follow the instructions in this file for 'installing'.
+This support file provides an easy way to call into some of the family of SWIG print functions via additional user-defined gdb commands.
+Some usage of the swigprint and locswigprint user-defined commands are demonstrated below.
+
+
+
+More often than not, a parse tree node needs to be examined.
+The session below displays the node n in one of the Java language module wrapper functions.
+The swigprint method is used to show the symbol name (symname - a DOH String type) and the node (n - a DOH Hash type).
+
+Note that all the attributes in the Hash are shown, including the 'sym:name' attribute which was assigned to the symname variable.
+
+
+
+Hash types can be shown either expanded or collapsed.
+When a Hash is shown expanded, all the attributes are displayed along with their values, otherwise a '.' replaces each attribute when collapsed.
+Therefore a count of the dots provides the number of attributes within an unexpanded Hash.
+Below shows the 'parms' Hash being displayed with the default Hash expansion of 1, then with 2 provided as the second argument to swigprint to expand to two Hash levels in order to view the contents of the collapsed 'nextSibling' Hash.
+
+Tip: Commands in gdb can be shortened with whatever makes them unique and can be command completed with the tab key.
+Thus swigprint can usually be shortened to sw and locswigprint to loc.
+The help for each command can also be obtained within the debugging session, for example, 'help swigprint'.
+
+
+
+The sub-section below gives pointers for debugging DOH objects using casts and provides an insight into why it can be hard to debug SWIG without the family of print functions.
-The DOH types are all typedefined to void.
-Consequently, it is impossible for debuggers to extract any information about DOH objects.
-Most debuggers will be able to display useful variable information when an object is cast to the appropriate type.
-Below are some tips for displaying some of the DOH objects.
-Be sure to compile with compiler optimisations turned off before attempting the casts shown in a debugger window else they are unlikely to work.
-Even displaying the underlying string in a String* doesn't work straight off in all debuggers due to the multiple definition of String as a struct and a void.
+
+
+
+The DOH types used in SWIG are all typedefined to void and hence the lack of type information for inspecting types within a debugger.
+Most debuggers will however be able to display useful variable information when an object is cast to the appropriate type.
+Getting at the underlying C string within DOH types is cumbersome, but possible with appropriate casts.
+The casts below can be used in a debugger windows, but be sure to compile with compiler optimisations turned off before attempting the casts else they are unlikely to work.
+Even displaying the underlying string in a String * doesn't work straight off in all debuggers due to the multiple definitions of String as a struct and a void.
Below are a list of common SWIG types.
@@ -1033,36 +1155,30 @@ With each is the cast that can be used in the debugger to extract the underlying
String *s;
-
-(struct String *)((DohBase *)s)->data
+(struct String *)((DohBase *)s)->data
The underlying char * string can be displayed with
-(*(struct String *)(((DohBase *)s)->data)).str
+(*(struct String *)(((DohBase *)s)->data)).str
SwigType *t;
-
-(struct String *)((DohBase *)t)->data
+(struct String *)((DohBase *)t)->data
The underlying char * string can be displayed with
-(*(struct String *)(((DohBase *)t)->data)).str
+(*(struct String *)(((DohBase *)t)->data)).str
const_String_or_char_ptr sc;
Either
-(*(struct String *)(((DohBase *)sc)->data)).str
+(*(struct String *)(((DohBase *)sc)->data)).str or
-(char *)sc
+(char *)sc will work depending on whether the underlying type is really a String * or char *.
-
-Please also read the Debugging Functions section in SWIG Parse Tree Handling for the Swig_print_node(), Swig_print_tree() and Swig_print_tags() functions for displaying node contents. It is often easier to place a few calls to these functions in code of interest and recompile than use the debugger.
-
-
Copyright (C) 1999-2010 SWIG Development Team.
diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html
index 43ad191f6..db3c6fee4 100644
--- a/Doc/Devel/tree.html
+++ b/Doc/Devel/tree.html
@@ -6,13 +6,6 @@
SWIG Parse Tree Handling
-
-
-David M. Beazley
-dave-swig@dabeaz.com
-December, 2006
-
-
Introduction
@@ -210,7 +203,33 @@ This function restores a node to the state it was in prior to the last Swig_
Debugging Functions
-The following functions are used to help debug SWIG parse trees.
+
+The following functions can be used to help debug any SWIG DOH object.
+
+
+void Swig_print(DOH *object, int count = -1)
+
+
+Prints to stdout a string representation of any DOH type.
+The number of nested Hash types to expand is set by count (default is 1 if count<0). See Swig_set_max_hash_expand() to change default.
+
+
+
+
+void Swig_print_with_location(DOH *object, int count = -1)
+
+
+Prints to stdout a string representation of any DOH type, within [] brackets
+for Hash and List types, prefixed by line and file information.
+The number of nested Hash types to expand is set by count (default is 1 if count<0). See Swig_set_max_hash_expand() to change default.
+
+
+
+
+
+
+The following functions can be used to help debug SWIG parse trees.
+
void Swig_print_tags(Node *node, String_or_char *prefix)
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index e46d103de..6fa352547 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -267,6 +267,8 @@ extern int DohIsSequence(const DOH *obj);
extern int DohIsString(const DOH *obj);
extern int DohIsFile(const DOH *obj);
+extern void DohSetMaxHashExpand(int count);
+extern int DohGetMaxHashExpand(void);
extern void DohSetmark(DOH *obj, int x);
extern int DohGetmark(DOH *obj);
@@ -424,6 +426,8 @@ extern void DohMemoryDebug(void);
#define SplitLines DohSplitLines
#define Setmark DohSetmark
#define Getmark DohGetmark
+#define SetMaxHashExpand DohSetMaxHashExpand
+#define GetMaxHashExpand DohGetMaxHashExpand
#define None DohNone
#define Call DohCall
#define First DohFirst
diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c
index 87f8e3c40..48afd2e54 100644
--- a/Source/DOH/hash.c
+++ b/Source/DOH/hash.c
@@ -42,6 +42,7 @@ typedef struct KeyValue {
} KeyValue;
static KeyValue *root = 0;
+static int max_expand = 1;
/* Find or create a key in the interned key table */
static DOH *find_key(DOH *doh_c) {
@@ -378,6 +379,26 @@ static DOH *Hash_keys(DOH *so) {
return keys;
}
+/* -----------------------------------------------------------------------------
+ * DohSetMaxHashExpand()
+ *
+ * Controls how many Hash objects are displayed in full in Hash_str
+ * ----------------------------------------------------------------------------- */
+
+void DohSetMaxHashExpand(int count) {
+ max_expand = count;
+}
+
+/* -----------------------------------------------------------------------------
+ * DohGetMaxHashExpand()
+ *
+ * Returns how many Hash objects are displayed in full in Hash_str
+ * ----------------------------------------------------------------------------- */
+
+int DohGetMaxHashExpand(void) {
+ return max_expand;
+}
+
/* -----------------------------------------------------------------------------
* Hash_str()
*
@@ -388,7 +409,8 @@ static DOH *Hash_str(DOH *ho) {
int i, j;
HashNode *n;
DOH *s;
- static int indent = 4;
+ static int expanded = 0;
+ static const char *tab = " ";
Hash *h = (Hash *) ObjData(ho);
s = NewStringEmpty();
@@ -396,22 +418,35 @@ static DOH *Hash_str(DOH *ho) {
Printf(s, "Hash(0x%x)", ho);
return s;
}
+ if (expanded >= max_expand) {
+ /* replace each hash attribute with a '.' */
+ Printf(s, "Hash(0x%x) {", ho);
+ for (i = 0; i < h->hashsize; i++) {
+ n = h->hashtable[i];
+ while (n) {
+ Putc('.', s);
+ n = n->next;
+ }
+ }
+ Putc('}', s);
+ return s;
+ }
ObjSetMark(ho, 1);
- Printf(s, "Hash {\n");
+ Printf(s, "Hash(0x%x) {\n", ho);
for (i = 0; i < h->hashsize; i++) {
n = h->hashtable[i];
while (n) {
- for (j = 0; j < indent; j++)
- Putc(' ', s);
- indent += 4;
+ for (j = 0; j < expanded + 1; j++)
+ Printf(s, tab);
+ expanded += 1;
Printf(s, "'%s' : %s, \n", n->key, n->object);
- indent -= 4;
+ expanded -= 1;
n = n->next;
}
}
- for (j = 0; j < (indent - 4); j++)
- Putc(' ', s);
- Printf(s, "}\n");
+ for (j = 0; j < expanded; j++)
+ Printf(s, tab);
+ Printf(s, "}");
ObjSetMark(ho, 0);
return s;
}
diff --git a/Source/DOH/list.c b/Source/DOH/list.c
index a08cadb5a..d5b532409 100644
--- a/Source/DOH/list.c
+++ b/Source/DOH/list.c
@@ -252,7 +252,7 @@ static DOH *List_str(DOH *lo) {
if ((i + 1) < l->nitems)
Printf(s, ", ");
}
- Printf(s, " ]\n");
+ Printf(s, " ]");
ObjSetMark(lo, 0);
return s;
}
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index e28fcbb89..6ec0463fa 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -52,7 +52,7 @@ extern "C" {
return all_protected_mode;
}
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
- Language::instance()->replaceSpecialVariables(method, tm, parm);
+ Language::instance()->replaceSpecialVariables(method, tm, parm);
}
}
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index b0b488d6f..d3074105f 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -380,9 +380,15 @@ void Wrapper_fast_dispatch_mode_set(int);
void Wrapper_cast_dispatch_mode_set(int);
void Wrapper_naturalvar_mode_set(int);
-
void clean_overloaded(Node *n);
+extern "C" {
+ const char *Swig_to_string(DOH *object, int count = -1);
+ const char *Swig_to_string_with_location(DOH *object, int count = -1);
+ void Swig_print(DOH *object, int count = -1);
+ void Swig_print_with_location(DOH *object, int count = -1);
+}
+
/* Contracts */
void Swig_contracts(Node *n);
@@ -395,5 +401,4 @@ void Swig_browser(Node *n, int);
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
-
#endif
diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx
index 3fe7a2709..13a504bcf 100644
--- a/Source/Modules/utils.cxx
+++ b/Source/Modules/utils.cxx
@@ -100,3 +100,116 @@ void clean_overloaded(Node *n) {
Delattr(n, "sym:overloaded");
}
}
+
+/* -----------------------------------------------------------------------------
+ * Swig_set_max_hash_expand()
+ *
+ * Controls how many Hash objects are displayed when displaying nested Hash objects.
+ * Makes DohSetMaxHashExpand an externally callable function (for debugger).
+ * ----------------------------------------------------------------------------- */
+
+void Swig_set_max_hash_expand(int count) {
+ SetMaxHashExpand(count);
+}
+
+extern "C" {
+
+/* -----------------------------------------------------------------------------
+ * Swig_get_max_hash_expand()
+ *
+ * Returns how many Hash objects are displayed when displaying nested Hash objects.
+ * Makes DohGetMaxHashExpand an externally callable function (for debugger).
+ * ----------------------------------------------------------------------------- */
+
+int Swig_get_max_hash_expand() {
+ return GetMaxHashExpand();
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_doh_string()
+ *
+ * DOH version of Swig_to_string()
+ * ----------------------------------------------------------------------------- */
+
+static String *Swig_to_doh_string(DOH *object, int count) {
+ int old_count = Swig_get_max_hash_expand();
+ if (count >= 0)
+ Swig_set_max_hash_expand(count);
+
+ String *debug_string = object ? NewStringf("%s", object) : NewString("NULL");
+
+ Swig_set_max_hash_expand(old_count);
+ return debug_string;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_doh_string_with_location()
+ *
+ * DOH version of Swig_to_string_with_location()
+ * ----------------------------------------------------------------------------- */
+
+static String *Swig_to_doh_string_with_location(DOH *object, int count) {
+ int old_count = Swig_get_max_hash_expand();
+ if (count >= 0)
+ Swig_set_max_hash_expand(count);
+
+ String *debug_string = Swig_stringify_with_location(object);
+
+ Swig_set_max_hash_expand(old_count);
+ return debug_string;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_string()
+ *
+ * Swig debug - return C string representation of any DOH type.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * Note: leaks memory.
+ * ----------------------------------------------------------------------------- */
+
+const char *Swig_to_string(DOH *object, int count) {
+ return Char(Swig_to_doh_string(object, count));
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_string_with_location()
+ *
+ * Swig debug - return C string representation of any DOH type, within [] brackets
+ * for Hash and List types, prefixed by line and file information.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * Note: leaks memory.
+ * ----------------------------------------------------------------------------- */
+
+const char *Swig_to_string_with_location(DOH *object, int count) {
+ return Char(Swig_to_doh_string_with_location(object, count));
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_print()
+ *
+ * Swig debug - display string representation of any DOH type.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * ----------------------------------------------------------------------------- */
+
+void Swig_print(DOH *object, int count) {
+ String *output = Swig_to_doh_string(object, count);
+ Printf(stdout, "%s\n", output);
+ Delete(output);
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_string_with_location()
+ *
+ * Swig debug - display string representation of any DOH type, within [] brackets
+ * for Hash and List types, prefixed by line and file information.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * ----------------------------------------------------------------------------- */
+
+void Swig_print_with_location(DOH *object, int count) {
+ String *output = Swig_to_doh_string_with_location(object, count);
+ Printf(stdout, "%s\n", output);
+ Delete(output);
+}
+
+} // extern "C"
+
diff --git a/Source/Swig/error.c b/Source/Swig/error.c
index fa82ad8d9..5dfcf605b 100644
--- a/Source/Swig/error.c
+++ b/Source/Swig/error.c
@@ -284,6 +284,41 @@ static String *format_filename(const_String_or_char_ptr filename) {
return formatted_filename;
}
+/* -----------------------------------------------------------------------------
+ * Swig_stringify_with_location()
+ *
+ * Return a string representation of any DOH object with line and file location
+ * information in the appropriate error message format. The string representation
+ * is enclosed within [] brackets after the line and file information.
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_stringify_with_location(DOH *object) {
+ String *str = NewStringEmpty();
+
+ if (!init_fmt)
+ Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
+
+ if (object) {
+ int line = Getline(object);
+ String *formatted_filename = format_filename(Getfile(object));
+ if (line > 0) {
+ Printf(str, diag_line_fmt, formatted_filename, line);
+ } else {
+ Printf(str, diag_eof_fmt, formatted_filename);
+ }
+ if (Len(object) == 0) {
+ Printf(str, "[EMPTY]");
+ } else {
+ Printf(str, "[%s]", object);
+ }
+ Delete(formatted_filename);
+ } else {
+ Printf(str, "[NULL]");
+ }
+
+ return str;
+}
+
/* -----------------------------------------------------------------------------
* Swig_diagnostic()
*
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index 2105f0c51..a57c7cf33 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -527,7 +527,6 @@ String *Swig_string_schemify(String *s) {
return ns;
}
-
/* -----------------------------------------------------------------------------
* Swig_string_typecode()
*
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index f90a5ffb1..021c5611f 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -319,7 +319,6 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
-
extern void Swig_init(void);
extern int Swig_value_wrapper_mode(int mode);
@@ -334,6 +333,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...);
+ extern String *Swig_stringify_with_location(DOH *object);
/* --- C Wrappers --- */
extern String *Swig_cparm_name(Parm *p, int i);
@@ -408,6 +408,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Wrapper_director_protected_mode_set(int);
extern void Wrapper_all_protected_mode_set(int);
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
+ extern void Swig_print(DOH *object, int count);
+ extern void Swig_print_with_location(DOH *object, int count);
/* -- template init -- */
diff --git a/Tools/swig.gdb b/Tools/swig.gdb
new file mode 100644
index 000000000..195032955
--- /dev/null
+++ b/Tools/swig.gdb
@@ -0,0 +1,41 @@
+# User-defined commands for easier debugging of SWIG in gdb
+#
+# This file can be "included" into your main .gdbinit file using:
+# source swig.gdb
+# or otherwise paste the contents into .gdbinit
+#
+# Note all user defined commands can be seen using:
+# (gdb) show user
+# The documentation for each command can be easily viewed, for example:
+# (gdb) help swigprint
+
+define swigprint
+ if ($argc == 2)
+ set $expand_count = $arg1
+ else
+ set $expand_count = -1
+ end
+ call Swig_print($arg0, $expand_count)
+end
+document swigprint
+Displays any SWIG DOH object
+Usage: swigprint swigobject [hashexpandcount]
+ swigobject - The object to display.
+ hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default.
+end
+
+
+define locswigprint
+ if ($argc == 2)
+ set $expand_count = $arg1
+ else
+ set $expand_count = -1
+ end
+ call Swig_print_with_location($arg0, $expand_count)
+end
+document locswigprint
+Displays any SWIG DOH object prefixed with file and line location
+Usage: locswigprint swigobject [hashexpandcount]
+ swigobject - The object to display.
+ hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default.
+end
From 8b31a92f6168b1bb1e17ca64aebbe6e29c5fc24a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 15 Sep 2010 22:26:34 +0000
Subject: [PATCH 0051/1045] Add missing typemap debug options to docs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12222 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Extending.html | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index c554d9f05..072f28963 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -3609,6 +3609,8 @@ There are various command line options which can aid debugging a SWIG interface
-debug-top <n> - Display entire parse tree at stages 1-4, <n> is a csv list of stages
-debug-typedef - Display information about the types and typedefs in the interface
-debug-typemap - Display information for debugging typemaps
+-debug-tmsearch - Display typemap search debugging information
+-debug-tmused - Display typemaps used debugging information
From b01277a19be53421d66f800c942e5b8663100a46 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 18 Sep 2010 01:14:21 +0000
Subject: [PATCH 0052/1045] Various inherited class warning/error line number
fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12223 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++
Examples/test-suite/errors/cpp_inherit.i | 47 ++++++++++++++++++++++++
Examples/test-suite/errors/expected.log | 24 ++++++++++--
Examples/test-suite/errors/make.sh | 1 +
Source/CParse/cscanner.c | 6 +--
Source/CParse/parser.y | 40 ++++++++++++--------
Source/Modules/typepass.cxx | 17 ++++-----
7 files changed, 108 insertions(+), 31 deletions(-)
create mode 100644 Examples/test-suite/errors/cpp_inherit.i
diff --git a/CHANGES.current b/CHANGES.current
index ff5b40fb6..d98b99f1a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-18: wsfulton
+ More file and line error/warning reporting fixes for various inherited
+ class problems.
+
2010-09-15: wsfulton
A much improved debugging of SWIG source experience is now available and
documented in the "Debugging SWIG" section in the Doc/Devel/internals.html
diff --git a/Examples/test-suite/errors/cpp_inherit.i b/Examples/test-suite/errors/cpp_inherit.i
new file mode 100644
index 000000000..fdc77d1d5
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit.i
@@ -0,0 +1,47 @@
+%module xxx
+
+%inline %{
+struct A5;
+int A6;
+template struct A7
+{
+};
+template struct A8
+{
+};
+
+struct A0
+:
+ public A1
+ ,
+ A2,
+ private A3
+ ,
+ private A4
+ ,
+ A5
+ ,
+ A6
+ ,
+ A7
+ ,
+ protected A8
+{
+};
+
+struct A1
+{
+};
+
+class B1 {};
+
+class B0 :
+ B1,
+ B2
+{
+};
+
+struct Recursive : Recursive
+{
+};
+%}
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index 1fd592f04..7cbce4c30 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -207,6 +207,24 @@ cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class f
:::::::::::::::::::::::::::::::: cpp_inline_namespace.i :::::::::::::::::::::::::::::::::::
cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed.
+:::::::::::::::::::::::::::::::: cpp_inherit.i :::::::::::::::::::::::::::::::::::
+cpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored).
+cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored).
+cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored).
+cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored).
+cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored).
+cpp_inherit.i:15: Warning 401: Base class 'A1' undefined.
+cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class.
+cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored.
+cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete.
+cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found.
+cpp_inherit.i:24: Error: 'A6' is not a valid base class.
+cpp_inherit.i:5: Error: See definition of 'A6'.
+cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
+cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
+cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
+cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
+
:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
@@ -224,7 +242,7 @@ cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored)
cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored)
:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
-cpp_no_access.i:3: Warning 319: No access specifier given for base class foo (ignored).
+cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored).
:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
@@ -236,8 +254,8 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
-cpp_private_inherit.i:6: Warning 309: private inheritance ignored.
-cpp_private_inherit.i:9: Warning 309: protected inheritance ignored.
+cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored).
+cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored).
:::::::::::::::::::::::::::::::: cpp_template_argname.i :::::::::::::::::::::::::::::::::::
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index 0fb3e14a4..0a81254f4 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -64,6 +64,7 @@ cpp_bad_extern
cpp_extend_redefine
cpp_extend_undefined
cpp_inline_namespace
+cpp_inherit
cpp_missing_rtemplate
cpp_namespace_alias
cpp_namespace_aliasnot
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index f88841c09..7d848878c 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -791,7 +791,7 @@ int yylex(void) {
if (strcmp(yytext, "typename") == 0)
return (TYPENAME);
if (strcmp(yytext, "template") == 0) {
- yylval.ivalue = cparse_line;
+ yylval.intvalue = cparse_line;
return (TEMPLATE);
}
if (strcmp(yytext, "delete") == 0) {
@@ -833,7 +833,7 @@ int yylex(void) {
return (SIZEOF);
if (strcmp(yytext, "typedef") == 0) {
- yylval.ivalue = 0;
+ yylval.intvalue = 0;
return (TYPEDEF);
}
@@ -875,7 +875,7 @@ int yylex(void) {
if (strcmp(yytext, "%constant") == 0)
return (CONSTANT);
if (strcmp(yytext, "%typedef") == 0) {
- yylval.ivalue = 1;
+ yylval.intvalue = 1;
return (TYPEDEF);
}
if (strcmp(yytext, "%native") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 09ed9bcf2..d792021c6 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1628,7 +1628,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
String *str;
Parm *p;
ParmList *pl;
- int ivalue;
+ int intvalue;
Node *node;
};
@@ -1639,7 +1639,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token INCLUDE IMPORT INSERT
%token CHARCONST
%token NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
-%token TYPEDEF
+%token TYPEDEF
%token TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
@@ -1657,7 +1657,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token QUESTIONMARK
%token TYPES PARMS
%token NONID DSTAR DCNOT
-%token TEMPLATE
+%token TEMPLATE
%token OPERATOR
%token COPERATOR
%token PARSETYPE PARSEPARM PARSEPARMS
@@ -1728,7 +1728,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type string stringnum ;
%type template_parms;
%type cpp_end cpp_vend;
-%type rename_namewarn;
+%type rename_namewarn;
%type type_specifier primitive_type_list ;
%type fname stringtype;
%type featattr;
@@ -4540,7 +4540,8 @@ cpp_protection_decl : PUBLIC COLON {
------------------------------------------------------------ */
cpp_nested : storage_class cpptype idcolon inherit LBRACE {
- cparse_start_line = cparse_line; skip_balanced('{','}');
+ cparse_start_line = cparse_line;
+ skip_balanced('{','}');
$$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@@ -4565,7 +4566,8 @@ cpp_nested : storage_class cpptype idcolon inherit LBRACE {
------------------------------------------------------------ */
| storage_class cpptype inherit LBRACE {
- cparse_start_line = cparse_line; skip_balanced('{','}');
+ cparse_start_line = cparse_line;
+ skip_balanced('{','}');
$$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@@ -5883,28 +5885,34 @@ base_list : base_specifier {
}
;
-base_specifier : opt_virtual idcolon {
+base_specifier : opt_virtual {
+ $$ = cparse_line;
+ } idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
- Setline($$,cparse_line);
- Setattr($$,"name",$2);
+ Setline($$,$2);
+ Setattr($$,"name",$3);
+ Setfile($3,cparse_file);
+ Setline($3,$2);
if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) {
Setattr($$,"access","private");
- Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line,
- "No access specifier given for base class %s (ignored).\n",$2);
+ Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3));
} else {
Setattr($$,"access","public");
}
}
- | opt_virtual access_specifier opt_virtual idcolon {
+ | opt_virtual access_specifier {
+ $$ = cparse_line;
+ } opt_virtual idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
- Setline($$,cparse_line);
- Setattr($$,"name",$4);
+ Setline($$,$3);
+ Setattr($$,"name",$5);
+ Setfile($5,cparse_file);
+ Setline($5,$3);
Setattr($$,"access",$2);
if (Strcmp($2,"public") != 0) {
- Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file,
- cparse_line,"%s inheritance ignored.\n", $2);
+ Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
}
}
;
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index e0e06d54e..438b66617 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -175,10 +175,10 @@ class TypePass:private Dispatcher {
}
}
if (Strcmp(nodeType(bcls), "classforward") != 0) {
- Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
- Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
+ Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
+ Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
} else {
- Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
clsforward = 1;
}
@@ -189,7 +189,7 @@ class TypePass:private Dispatcher {
ilist = alist = NewList();
Append(ilist, bcls);
} else {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
}
}
@@ -202,10 +202,9 @@ class TypePass:private Dispatcher {
if (!bcls) {
if (!clsforward) {
if (ispublic && !Getmeta(bname, "already_warned")) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
if (Strchr(bname, '<')) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
- SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
}
Setmeta(bname, "already_warned", "1");
}
@@ -259,7 +258,7 @@ class TypePass:private Dispatcher {
Delete(bsmart);
Delete(smart);
} else {
- Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
+ Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
}
}
if (!importmode) {
@@ -275,7 +274,7 @@ class TypePass:private Dispatcher {
Symtab *st = Getattr(cls, "symtab");
Symtab *bst = Getattr(bclass, "symtab");
if (st == bst) {
- Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
+ Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
continue;
}
Symtab *s = Swig_symbol_current();
From 6c094629cbd6df08a20c68656a487965b7072d30 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 20 Sep 2010 19:11:55 +0000
Subject: [PATCH 0053/1045] File and line number corrections for warnings
WARN_JAVA_MULTIPLE_INHERITANCE WARN_MODULA3_MULTIPLE_INHERITANCE
WARN_CSHARP_MULTIPLE_INHERITANCE and errors 'The javabase typemap for proxy'
'No methodname attribute...' 'No methodmodifiers attribute...' 'The csbase
typemap for proxy...'
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12224 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/csharp.cxx | 16 ++++++++--------
Source/Modules/java.cxx | 18 ++++++++----------
Source/Modules/modula3.cxx | 11 ++++-------
3 files changed, 20 insertions(+), 25 deletions(-)
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 8ffd9768a..e0c4a4332 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -1640,10 +1640,10 @@ public:
base = Next(base);
continue;
}
- String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
- String *baseclassname = SwigType_str(Getattr(base.item, "name"), 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#.\n", proxyclassname, baseclassname);
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ String *baseclassname = Getattr(base.item, "name");
+ Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@@ -1661,9 +1661,9 @@ public:
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);
+ Swig_error(Getfile(n), Getline(n), "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,
+ Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"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);
}
@@ -1704,10 +1704,10 @@ public:
}
if (tm && *Char(tm)) {
if (!destruct_methodname) {
- Swig_error(input_file, line_number, "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
- Swig_error(input_file, line_number,
+ Swig_error(Getfile(n), Getline(n),
"No methodmodifiers attribute defined in csdestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
}
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 4a6abd569..c8769a876 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -1714,10 +1714,10 @@ public:
base = Next(base);
continue;
}
- String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
- String *baseclassname = SwigType_str(Getattr(base.item, "name"), 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.\n", proxyclassname, baseclassname);
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ String *baseclassname = Getattr(base.item, "name");
+ Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@@ -1735,9 +1735,9 @@ public:
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);
+ Swig_error(Getfile(n), Getline(n), "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,
+ Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"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);
}
@@ -1772,12 +1772,10 @@ public:
}
if (tm && *Char(tm)) {
if (!destruct_methodname) {
- Swig_error(input_file, line_number,
- "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
- Swig_error(input_file, line_number,
- "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
}
// Emit the finalize and delete methods
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index edd6690ce..ede63f802 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -2222,8 +2222,7 @@ MODULA3():
}
base = Next(base);
if (base.item != NIL) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
- line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
classDeclarationName, Getattr(base.item, "name"));
}
@@ -2236,8 +2235,7 @@ MODULA3():
// Inheritance from pure Modula 3 classes
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
- line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
}
// Pure Modula 3 interfaces
@@ -2273,7 +2271,7 @@ MODULA3():
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
}
if (!destruct_methodname) {
- Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
// Emit the Finalize and Dispose methods
if (tm) {
@@ -2466,8 +2464,7 @@ MODULA3():
Append(baseclassname, Getattr(base.item, "sym:name"));
base = Next(base);
if (base.item != NIL) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
- line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file, line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
proxy_class_name, Getattr(base.item, "name"));
}
From 1e051820ec601ca34bbd8abc4926193319708e3e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 21 Sep 2010 06:07:06 +0000
Subject: [PATCH 0054/1045] Line/file reporting corrections for warnings:
WARN_RUBY_MULTIPLE_INHERITANCE, WARN_TYPE_UNDEFINED_CLASS,
WARN_MODULA3_MULTIPLE_INHERITANCE
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12225 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/modula3.cxx | 2 +-
Source/Modules/python.cxx | 2 +-
Source/Modules/ruby.cxx | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index ede63f802..45ceba1a4 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -2464,7 +2464,7 @@ MODULA3():
Append(baseclassname, Getattr(base.item, "sym:name"));
base = Next(base);
if (base.item != NIL) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file, line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
proxy_class_name, Getattr(base.item, "name"));
}
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index fed5205e1..b807cc627 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -2866,7 +2866,7 @@ public:
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,
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n),
"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);
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index bcdfd69d3..ab1210a79 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2395,7 +2395,7 @@ public:
}
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
- Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number,
+ Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
base = Next(base);
}
From ea9275ca08756f6cf886d6f083ee94eda3b57156 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 21 Sep 2010 18:09:20 +0000
Subject: [PATCH 0055/1045] html fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12226 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Ruby.html | 2 +-
Doc/Manual/SWIG.html | 3 ++-
Doc/Manual/chapters | 1 -
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index 736b6137d..bda2af60c 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -5,7 +5,7 @@
-
+
33 SWIG and Ruby
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index bdd0edb8b..52b9db339 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1909,6 +1909,8 @@ The most general function of all of the above ones (not counting
command which is even more powerful in principle but which should
generally be avoided because of performance considerations) is the
regex one. Here are some more examples of its use:
+
+
// Strip the wx prefix from all identifiers except those starting with wxEVT
@@ -1924,7 +1926,6 @@ generally be avoided because of performance considerations) is the
// GetValue -> Value
-
As before, everything that was said above about %rename also applies to
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index cd399996b..014029c74 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -34,4 +34,3 @@ Ruby.html
Tcl.html
R.html
Extending.html
-
From 31af118c41b44a74244613b4eb8e54d06d5cee6a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 24 Sep 2010 22:13:13 +0000
Subject: [PATCH 0056/1045] Move Swig_locator from scanner.c to cscanner.c. Fix
file and line error/warning reporting fixes where SWIG macros are used within
{} braces (where the preprocessor expands macros), for example macros within
%inline {...} and %fragment(...) {...} and nested structs. Basically anything
that results ina call to skip_balanced() in the parser/preprocessor.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12227 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 6 +
.../test-suite/errors/cpp_macro_locator.i | 103 ++++++++++++
Examples/test-suite/errors/expected.log | 23 +++
Examples/test-suite/errors/make.sh | 1 +
Source/CParse/cscanner.c | 99 +----------
Source/Swig/scanner.c | 159 ++++++++++++++++--
Source/Swig/swigscan.h | 2 +-
7 files changed, 284 insertions(+), 109 deletions(-)
create mode 100644 Examples/test-suite/errors/cpp_macro_locator.i
diff --git a/CHANGES.current b/CHANGES.current
index d98b99f1a..a227d8e66 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-24: wsfulton
+ More file and line error/warning reporting fixes where SWIG macros
+ are used within {} braces (where the preprocessor expands macros),
+ for example macros within %inline {...} and %fragment(...) {...}
+ and nested structs.
+
2010-09-18: wsfulton
More file and line error/warning reporting fixes for various inherited
class problems.
diff --git a/Examples/test-suite/errors/cpp_macro_locator.i b/Examples/test-suite/errors/cpp_macro_locator.i
new file mode 100644
index 000000000..bd441a121
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_macro_locator.i
@@ -0,0 +1,103 @@
+%module xxx
+
+// Test the SWIG preprocessor locator effects on reporting line numbers in warnings when processing SWIG (multiline) macros
+
+// The ignored overloaded methods warnings should have the correct line number reporting
+// {} blocks are tested, where the preprocessor expands the macros
+
+%define CLASSMACRO(KLASS)
+class KLASS
+{
+public:
+ KLASS() {}
+ void methodX(int *) {}
+ void methodX(const int *) {}
+};
+%enddef
+
+%{
+#define CLASSMACRO(KLASS) \
+class KLASS \
+{ \
+public: \
+ KLASS() {} \
+ void methodX(int *) {} \
+ void methodX(const int *) {} \
+};
+%}
+
+%{
+#define VARIABLEMACRO(NAME) double NAME;
+struct Outer {
+ struct Inner {
+ VARIABLEMACRO(MyInnerVar)
+ };
+};
+void overload1(int *) {}
+void overload1(const int *) {}
+void overload2(int *) {}
+void overload2(const int *) {}
+void overload3(int *) {}
+void overload3(const int *) {}
+%}
+
+%define VARIABLEMACRO(NAME)
+double NAME;
+%enddef
+struct Outer {
+ struct Inner {
+ VARIABLEMACRO(MyInnerVar)
+ };
+};
+void overload1(int *) {}
+void overload1(const int *) {}
+
+%fragment("FragmentMethod", "header") {
+void fragmentMethod() {
+}
+VARIABLEMACRO(fragVar)
+}
+void overload2(int *) {}
+void overload2(const int *) {}
+
+%inline {
+CLASSMACRO(Klass1)
+}
+#warning inline warning message one
+void overload3(int *) {}
+void overload3(const int *) {}
+
+%{
+struct Classic {
+ Classic() {
+ VARIABLEMACRO(inconstructor)
+ }
+ double value;
+};
+void overload4(int *) {}
+void overload4(const int *) {}
+void overload5(int *) {}
+void overload5(const int *) {}
+%}
+
+struct Classic {
+ Classic() {
+ VARIABLEMACRO(inconstructor)
+ }
+ double value;
+};
+void overload4(int *) {}
+void overload4(const int *) {}
+
+%inline {
+void overloadinline1(int *) {}
+void overloadinline1(const int *) {}
+CLASSMACRO(Klass2)
+#warning an inline warning message 2
+void overloadinline2(int *) {}
+void overloadinline2(const int *) {}
+}
+void overload5(int *) {}
+void overload5(const int *) {}
+
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index 7cbce4c30..06942064f 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -225,6 +225,29 @@ cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignor
cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
+:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
+cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one
+cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2
+cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
+cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
+cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).
+cpp_macro_locator.i:61: Warning 509: Overloaded method overload2(int const *) effectively ignored,
+cpp_macro_locator.i:60: Warning 509: as it is shadowed by overload2(int *).
+cpp_macro_locator.i:64: Warning 509: Overloaded method Klass1::methodX(int const *) effectively ignored,
+cpp_macro_locator.i:64: Warning 509: as it is shadowed by Klass1::methodX(int *).
+cpp_macro_locator.i:68: Warning 509: Overloaded method overload3(int const *) effectively ignored,
+cpp_macro_locator.i:67: Warning 509: as it is shadowed by overload3(int *).
+cpp_macro_locator.i:90: Warning 509: Overloaded method overload4(int const *) effectively ignored,
+cpp_macro_locator.i:89: Warning 509: as it is shadowed by overload4(int *).
+cpp_macro_locator.i:94: Warning 509: Overloaded method overloadinline1(int const *) effectively ignored,
+cpp_macro_locator.i:93: Warning 509: as it is shadowed by overloadinline1(int *).
+cpp_macro_locator.i:95: Warning 509: Overloaded method Klass2::methodX(int const *) effectively ignored,
+cpp_macro_locator.i:95: Warning 509: as it is shadowed by Klass2::methodX(int *).
+cpp_macro_locator.i:98: Warning 509: Overloaded method overloadinline2(int const *) effectively ignored,
+cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *).
+cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored,
+cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *).
+
:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index 0a81254f4..52d6c8967 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -65,6 +65,7 @@ cpp_extend_redefine
cpp_extend_undefined
cpp_inline_namespace
cpp_inherit
+cpp_macro_locator
cpp_missing_rtemplate
cpp_namespace_alias
cpp_namespace_aliasnot
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index 7d848878c..bf684c4cc 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -45,8 +45,6 @@ static int num_brace = 0;
static int last_brace = 0;
static int last_id = 0;
static int rename_active = 0;
-static int expanding_macro = 0;
-static int follow_locators = 0;
/* -----------------------------------------------------------------------------
* Swig_cparse_cplusplus()
@@ -56,101 +54,6 @@ void Swig_cparse_cplusplus(int v) {
cparse_cplusplus = v;
}
-/* ----------------------------------------------------------------------
- * locator()
- *
- * Support for locator strings. These are strings of the form
- * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
- * are primarily used for macro line number reporting
- * ---------------------------------------------------------------------- */
-
-typedef struct Locator {
- String *filename;
- int line_number;
- struct Locator *next;
-} Locator;
-
-static Locator *locs = 0;
-
-/* we just use the locator to mark when active/deactive the linecounting */
-
-static void scanner_locator(String *loc) {
- if (!follow_locators) {
- if (Equal(loc, "/*@SWIG@*/")) {
- /* End locator. */
- if (expanding_macro)
- --expanding_macro;
- } else {
- /* Begin locator. */
- ++expanding_macro;
- }
- /* Freeze line number processing in Scanner */
- Scanner_freeze_line(scan,expanding_macro);
- } else {
- int c;
- Locator *l;
- Seek(loc, 7, SEEK_SET);
- c = Getc(loc);
- if (c == '@') {
- /* Empty locator. We pop the last location off */
- if (locs) {
- Scanner_set_location(scan,locs->filename,locs->line_number);
- cparse_file = locs->filename;
- cparse_line = locs->line_number;
- l = locs->next;
- free(locs);
- locs = l;
- }
- return;
- }
-
- /* We're going to push a new location */
- l = (Locator *) malloc(sizeof(Locator));
- l->filename = cparse_file;
- l->line_number = cparse_line;
- l->next = locs;
- locs = l;
-
- /* Now, parse the new location out of the locator string */
- {
- String *fn = NewStringEmpty();
- /* Putc(c, fn); */
-
- while ((c = Getc(loc)) != EOF) {
- if ((c == '@') || (c == ','))
- break;
- Putc(c, fn);
- }
- cparse_file = Swig_copy_string(Char(fn));
- Clear(fn);
- cparse_line = 1;
- /* Get the line number */
- while ((c = Getc(loc)) != EOF) {
- if ((c == '@') || (c == ','))
- break;
- Putc(c, fn);
- }
- cparse_line = atoi(Char(fn));
- Clear(fn);
-
- /* Get the rest of it */
- while ((c = Getc(loc)) != EOF) {
- if (c == '@')
- break;
- Putc(c, fn);
- }
- /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
- Scanner_set_location(scan,cparse_file,cparse_line);
- Delete(fn);
- }
- }
-}
-
-void Swig_cparse_follow_locators(int v) {
- follow_locators = v;
-}
-
-
/* ----------------------------------------------------------------------------
* scanner_init()
*
@@ -432,7 +335,7 @@ static int yylook(void) {
String *cmt = Scanner_text(scan);
char *loc = Char(cmt);
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
- scanner_locator(cmt);
+ Scanner_locator(scan, cmt);
}
}
break;
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 9b5b35f96..0cdadaa7f 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -20,6 +20,7 @@ char cvsroot_scanner_c[] = "$Id$";
#include
extern String *cparse_file;
+extern int cparse_line;
extern int cparse_cplusplus;
extern int cparse_start_line;
@@ -38,6 +39,13 @@ struct Scanner {
int freeze_line; /* Suspend line number updates */
};
+typedef struct Locator {
+ String *filename;
+ int line_number;
+ struct Locator *next;
+} Locator;
+static int follow_locators = 0;
+
/* -----------------------------------------------------------------------------
* NewScanner()
*
@@ -230,8 +238,7 @@ static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) {
* Returns error information (if any)
* ----------------------------------------------------------------------------- */
-String *
-Scanner_errmsg(Scanner *s) {
+String *Scanner_errmsg(Scanner *s) {
return s->error;
}
@@ -241,13 +248,12 @@ Scanner_errline(Scanner *s) {
}
/* -----------------------------------------------------------------------------
- * Scanner_freeze_line()
+ * freeze_line()
*
* Freezes the current line number.
* ----------------------------------------------------------------------------- */
-void
-Scanner_freeze_line(Scanner *s, int val) {
+static void freeze_line(Scanner *s, int val) {
s->freeze_line = val;
}
@@ -1153,6 +1159,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
int l;
int state = 0;
char temp[2] = { 0, 0 };
+ String *locator = 0;
l = s->line;
temp[0] = (char) startchar;
Clear(s->text);
@@ -1162,6 +1169,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
Append(s->text, temp);
while (num_levels > 0) {
if ((c = nextchar(s)) == 0) {
+ Delete(locator);
return -1;
}
switch (state) {
@@ -1195,17 +1203,25 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
else
state = 11;
break;
- case 12:
+ case 12: /* first character inside C comment */
if (c == '*')
+ state = 14;
+ else if (c == '@')
+ state = 40;
+ else
state = 13;
break;
case 13:
if (c == '*')
- state = 13;
+ state = 14;
+ break;
+ case 14: /* possible end of C comment */
+ if (c == '*')
+ state = 14;
else if (c == '/')
state = 0;
else
- state = 12;
+ state = 13;
break;
case 20:
if (c == '\"')
@@ -1225,10 +1241,43 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
case 31:
state = 30;
break;
+ /* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */
+ case 40:
+ state = (c == 'S') ? 41 : (c == '*') ? 14 : 13;
+ break;
+ case 41:
+ state = (c == 'W') ? 42 : (c == '*') ? 14 : 13;
+ break;
+ case 42:
+ state = (c == 'I') ? 43 : (c == '*') ? 14 : 13;
+ break;
+ case 43:
+ state = (c == 'G') ? 44 : (c == '*') ? 14 : 13;
+ if (c == 'G') {
+ Delete(locator);
+ locator = NewString("/*@SWIG");
+ }
+ break;
+ case 44:
+ if (c == '*')
+ state = 45;
+ Putc(c, locator);
+ break;
+ case 45: /* end of SWIG locator in C comment */
+ if (c == '/') {
+ state = 0;
+ Putc(c, locator);
+ Scanner_locator(s, locator);
+ } else {
+ /* malformed locator */
+ state = (c == '*') ? 14 : 13;
+ }
+ break;
default:
break;
}
}
+ Delete(locator);
return 0;
}
@@ -1239,8 +1288,98 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
* operator.
* ----------------------------------------------------------------------------- */
-int
-Scanner_isoperator(int tokval) {
+int Scanner_isoperator(int tokval) {
if (tokval >= 100) return 1;
return 0;
}
+
+/* ----------------------------------------------------------------------
+ * locator()
+ *
+ * Support for locator strings. These are strings of the form
+ * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
+ * are primarily used for macro line number reporting.
+ * We just use the locator to mark when to activate/deactivate linecounting.
+ * ---------------------------------------------------------------------- */
+
+
+void Scanner_locator(Scanner *s, String *loc) {
+ static Locator *locs = 0;
+ static int expanding_macro = 0;
+
+ if (!follow_locators) {
+ if (Equal(loc, "/*@SWIG@*/")) {
+ /* End locator. */
+ if (expanding_macro)
+ --expanding_macro;
+ } else {
+ /* Begin locator. */
+ ++expanding_macro;
+ }
+ /* Freeze line number processing in Scanner */
+ freeze_line(s,expanding_macro);
+ } else {
+ int c;
+ Locator *l;
+ Seek(loc, 7, SEEK_SET);
+ c = Getc(loc);
+ if (c == '@') {
+ /* Empty locator. We pop the last location off */
+ if (locs) {
+ Scanner_set_location(s, locs->filename, locs->line_number);
+ cparse_file = locs->filename;
+ cparse_line = locs->line_number;
+ l = locs->next;
+ free(locs);
+ locs = l;
+ }
+ return;
+ }
+
+ /* We're going to push a new location */
+ l = (Locator *) malloc(sizeof(Locator));
+ l->filename = cparse_file;
+ l->line_number = cparse_line;
+ l->next = locs;
+ locs = l;
+
+ /* Now, parse the new location out of the locator string */
+ {
+ String *fn = NewStringEmpty();
+ /* Putc(c, fn); */
+
+ while ((c = Getc(loc)) != EOF) {
+ if ((c == '@') || (c == ','))
+ break;
+ Putc(c, fn);
+ }
+ cparse_file = Swig_copy_string(Char(fn));
+ Clear(fn);
+ cparse_line = 1;
+ /* Get the line number */
+ while ((c = Getc(loc)) != EOF) {
+ if ((c == '@') || (c == ','))
+ break;
+ Putc(c, fn);
+ }
+ cparse_line = atoi(Char(fn));
+ Clear(fn);
+
+ /* Get the rest of it */
+ while ((c = Getc(loc)) != EOF) {
+ if (c == '@')
+ break;
+ Putc(c, fn);
+ }
+ /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
+ Scanner_set_location(s, cparse_file, cparse_line);
+ Delete(fn);
+ }
+ }
+}
+
+void Swig_cparse_follow_locators(int v) {
+ follow_locators = v;
+}
+
+
diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
index b07812fbe..a2d5911bd 100644
--- a/Source/Swig/swigscan.h
+++ b/Source/Swig/swigscan.h
@@ -30,7 +30,7 @@ extern void Scanner_idstart(Scanner *, const char *idchar);
extern String *Scanner_errmsg(Scanner *);
extern int Scanner_errline(Scanner *);
extern int Scanner_isoperator(int tokval);
-extern void Scanner_freeze_line(Scanner *s, int val);
+extern void Scanner_locator(Scanner *, String *loc);
/* Note: Tokens in range 100+ are for C/C++ operators */
From e1ddf0ea3a778bf5bac48009004f2a4a7ac9d9ea Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 25 Sep 2010 17:08:13 +0000
Subject: [PATCH 0057/1045] Apply SF patch #3075150 - Java directors using
static variables in named namespace
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12228 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Source/Modules/java.cxx | 6 ++++--
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index a227d8e66..2767abb7a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-25: wsfulton
+ Apply SF patch #3075150 - Java directors using static variables in
+ named namespace.
+
2010-09-24: wsfulton
More file and line error/warning reporting fixes where SWIG macros
are used within {} braces (where the preprocessor expands macros),
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index c8769a876..1d4e522c6 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -3324,8 +3324,10 @@ public:
}
Printf(f_runtime, "namespace Swig {\n");
- Printf(f_runtime, " static jclass jclass_%s = NULL;\n", imclass_name);
- Printf(f_runtime, " static jmethodID director_methids[%d];\n", n_methods);
+ Printf(f_runtime, " namespace {\n");
+ Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name);
+ Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods);
+ Printf(f_runtime, " }\n");
Printf(f_runtime, "}\n");
Printf(w->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls) {", jnipackage, jni_imclass_name, swig_module_init_jni);
From 5437d71d73569400cc2f544a7934f2c768efa8f5 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Mon, 27 Sep 2010 01:16:29 +0000
Subject: [PATCH 0058/1045] [Python] Improve error message given when a
parameter of the wrong type is passed to an overloaded method (SF#3027355).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12229 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/python.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index b807cc627..80f2e68df 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -1799,7 +1799,7 @@ public:
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Append(f->code, "fail:\n");
Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError,"
- "\"Wrong number of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
+ "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
Append(f->code, "return NULL;\n");
Delete(protoTypes);
}
From 40e64b14f148b3d58dc13cca7df59a0193926e68 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 27 Sep 2010 05:40:14 +0000
Subject: [PATCH 0059/1045] Allocate warnings 700-799 for languages modules.
Note 900-999 was and is documented as reserved for user defined warnings.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12230 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Warnings.html | 2 +-
Source/Include/swigwarn.h | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 96e35902a..4bbf18205 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -515,7 +515,7 @@ example.i(4) : Syntax error in input.
519. %template() contains no name. Template method ignored: declaration
-
14.9.6 Language module specific (800-899)
+
14.9.6 Language module specific (700-899)
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index 46f5b79a5..5db30e6e9 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -196,11 +196,16 @@
/* -- Reserved (600-799) -- */
-/* -- Language module specific warnings (800 - 999) -- */
+/* -- Language module specific warnings (700 - 899) -- */
+
+/* Feel free to claim any number in this space that's not currently being used. Just make sure you
+ add an entry here */
#define WARN_RUBY_WRONG_NAME 801
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
+/* please leave 800-809 free for Ruby */
+
#define WARN_JAVA_TYPEMAP_JNI_UNDEF 810
#define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811
#define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812
@@ -262,7 +267,6 @@
/* please leave 890-899 free for Go */
-/* Feel free to claim any number in this space that's not currently being used. Just make sure you
- add an entry here */
+/* -- User defined warnings (900 - 999) -- */
#endif
From 8a05a236124fc511d8559a37fa36d5aa96b9b818 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 28 Sep 2010 06:36:42 +0000
Subject: [PATCH 0060/1045] Apply patch from Tomas Dirvanauskas for std::map
wrappers to avoid throwing exceptions with normal usage of iterators.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12231 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Lib/csharp/std_map.i | 24 +++++++++++++-----------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 2767abb7a..b0647a336 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-09-28: wsfulton
+ [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
+ throwing exceptions with normal usage of iterators.
+
2010-09-25: wsfulton
Apply SF patch #3075150 - Java directors using static variables in
named namespace.
diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i
index 2db6ddf5b..a4bf02397 100644
--- a/Lib/csharp/std_map.i
+++ b/Lib/csharp/std_map.i
@@ -67,12 +67,13 @@
public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
get {
System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>();
- IntPtr iter = create_iterator_begin();
- try {
- while (true) {
+ int size = this.Count;
+ if (size > 0) {
+ IntPtr iter = create_iterator_begin();
+ for (int i = 0; i < size; i++) {
keys.Add(get_next_key(iter));
}
- } catch (ArgumentOutOfRangeException) {
+ destroy_iterator(iter);
}
return keys;
}
@@ -258,7 +259,7 @@
return false;
}
- // create_iterator_begin() and get_next_key() work together to provide a collection of keys to C#
+ // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C#
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
@@ -266,15 +267,15 @@
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) {
+ const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
std::map< K, T >::iterator iter = *swigiterator;
- if (iter == $self->end()) {
- delete swigiterator;
- throw std::out_of_range("no more map elements");
- }
- (*swigiterator)++;
+ swigiterator++;
return (*iter).first;
}
+
+ void destroy_iterator(std::map< K, T >::iterator *swigiterator) {
+ delete swigiterator;
+ }
}
@@ -285,6 +286,7 @@
%csmethodmodifiers std::map::setitem "private"
%csmethodmodifiers std::map::create_iterator_begin "private"
%csmethodmodifiers std::map::get_next_key "private"
+%csmethodmodifiers std::map::destroy_iterator "private"
// Default implementation
namespace std {
From 5ff65533190a31afd5d5fdcf1c485c4ed3a3c376 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 28 Sep 2010 17:37:33 +0000
Subject: [PATCH 0061/1045] testcase warning suppression
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12232 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/constant_pointers.i | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i
index 7d46cdb31..394c0e5ec 100644
--- a/Examples/test-suite/constant_pointers.i
+++ b/Examples/test-suite/constant_pointers.i
@@ -6,6 +6,8 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */
+
%inline %{
From 9f41fa27cb9eee42c0fc003139ce9a6fdc485031 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 28 Sep 2010 17:56:48 +0000
Subject: [PATCH 0062/1045] remove latin-1 characters
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12233 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Java.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index d014feef6..d32a7fb9a 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -363,7 +363,7 @@ To load your shared native library module in Java, simply use Java's System.
public class runme {
static {
- System.loadLibrary("example");
+Â System.loadLibrary("example");
}
public static void main(String argv[]) {
@@ -6234,7 +6234,7 @@ public class runme {
static {
try {
- System.loadLibrary("example");
+Â System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. " + e);
System.exit(1);
@@ -6453,7 +6453,7 @@ public class runme {
static {
try {
- System.loadLibrary("example");
+Â System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. " + e);
System.exit(1);
From 83f17b43ce2049cc1a36237d7930d0507c46cbc6 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 03:16:56 +0000
Subject: [PATCH 0063/1045] Add entry corresponding to r12229 which I failed to
commit before.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12234 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index b0647a336..a281023b6 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -9,6 +9,10 @@ Version 2.0.1 (in progress)
[C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
throwing exceptions with normal usage of iterators.
+2010-09-27: olly
+ [Python] Improve error message given when a parameter of the wrong
+ type is passed to an overloaded method (SF#3027355).
+
2010-09-25: wsfulton
Apply SF patch #3075150 - Java directors using static variables in
named namespace.
From c636855bcc31ae71e8303cbfad46466508707a1c Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 04:01:08 +0000
Subject: [PATCH 0064/1045] [Python] Allow reinitialisation to work with an
embedded Python interpreter (patch from Jim Carroll in SF#3075178).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12235 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Lib/python/pyrun.swg | 6 +++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index a281023b6..c2d2d52f2 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-10-01: olly
+ [Python] Allow reinitialisation to work with an embedded Python
+ interpreter (patch from Jim Carroll in SF#3075178).
+
2010-09-28: wsfulton
[C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
throwing exceptions with normal usage of iterators.
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index d46628551..5043e6ec0 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -979,10 +979,13 @@ _SWIG_This(void)
return SWIG_Python_str_FromChar("this");
}
+static PyObject *swig_this = NULL;
+
SWIGRUNTIME PyObject *
SWIG_This(void)
{
- static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+ if (swig_this == NULL)
+ swig_this = _SWIG_This();
return swig_this;
}
@@ -1413,6 +1416,7 @@ SWIG_Python_DestroyModule(void *vptr)
}
}
Py_DECREF(SWIG_This());
+ swig_this = NULL;
}
SWIGRUNTIME void
From 045066e802dd3c56e0e3c6e91fb078ecc75a8d42 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 04:17:55 +0000
Subject: [PATCH 0065/1045] Fix typo in comment
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12236 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/ruby/rubyerrors.swg | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Lib/ruby/rubyerrors.swg b/Lib/ruby/rubyerrors.swg
index e2564980f..434544bc9 100644
--- a/Lib/ruby/rubyerrors.swg
+++ b/Lib/ruby/rubyerrors.swg
@@ -9,7 +9,7 @@
/* Define custom exceptions for errors that do not map to existing Ruby
exceptions. Note this only works for C++ since a global cannot be
- initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
+ initialized by a function in C. For C, fallback to rb_eRuntimeError.*/
SWIGINTERN VALUE
getNullReferenceError(void) {
From eaada32f264f828ec326f4c91f5c1a73399a8897 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 04:42:29 +0000
Subject: [PATCH 0066/1045] [Ruby] Avoid segfault when a method node has no
parentNode (SF#3034054).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12237 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Source/Modules/ruby.cxx | 11 +++++++++--
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index c2d2d52f2..d3c8c21d0 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-10-01: olly
+ [Ruby] Avoid segfault when a method node has no parentNode
+ (SF#3034054).
+
2010-10-01: olly
[Python] Allow reinitialisation to work with an embedded Python
interpreter (patch from Jim Carroll in SF#3075178).
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index ab1210a79..8461b8bef 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2054,8 +2054,15 @@ public:
// Construct real method name
String* methodName = NewString("");
- if ( isMethod )
- Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL );
+ if ( isMethod ) {
+ // Sometimes a method node has no parent (SF#3034054).
+ // This value is used in an exception message, so just skip the class
+ // name in this case so at least we don't segfault. This is probably
+ // just working around a problem elsewhere though.
+ Node *parent_node = parentNode(sibl);
+ if (parent_node)
+ Printv( methodName, Getattr(parent_node,"sym:name"), ".", NIL );
+ }
Append( methodName, Getattr(sibl,"sym:name" ) );
if ( isCtor ) Append( methodName, ".new" );
From db6bf51067db6beb701f4e9f5b25e14acf360c2d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 1 Oct 2010 22:46:22 +0000
Subject: [PATCH 0067/1045] Add pcre-build.sh script for easier building of
pcre and configuring with SWIG if PCRE not installed
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12238 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
README | 3 +++
Tools/mkwindows.sh | 14 ++++++++++--
Tools/pcre-build.sh | 53 +++++++++++++++++++++++++++++++++++++++++++++
configure.in | 30 ++++++++++++++++++++-----
4 files changed, 93 insertions(+), 7 deletions(-)
create mode 100755 Tools/pcre-build.sh
diff --git a/README b/README
index 3c6ee27a0..b5379d84d 100644
--- a/README
+++ b/README
@@ -57,6 +57,9 @@ You must use GNU `make' to build SWIG.
http://www.gnu.org/software/make/
+PCRE needs to be installed on your system to build SWIG. The configure
+script will provide instructions for obtaining PCRE if it cannot be found.
+
To build and install SWIG, simply type the following:
% ./configure
diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh
index 869fce01a..6042361b3 100755
--- a/Tools/mkwindows.sh
+++ b/Tools/mkwindows.sh
@@ -43,7 +43,7 @@ else
if test x$zip = x; then
zip=zip
fi
- extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux CXXFLAGS=-O2 CFLAGS=-O2"
+ extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
else
if test "$cygwin"; then
echo "Building native Windows executable on Cygwin"
@@ -61,6 +61,13 @@ fi
swigbasename=swig-$version
swigwinbasename=swigwin-$version
tarball=$swigbasename.tar.gz
+pcre_tarball=`ls pcre-*.tar.*`
+
+if ! test -f "$pcre_tarball"; then
+ echo "Could not find PCRE tarball. Please download a PCRE source tarball from http://www.pcre.org"
+ echo "and place in the same directory as the SWIG tarball."
+ exit 1
+fi
if test -f "$tarball"; then
builddir=build-$version
@@ -78,8 +85,11 @@ if test -f "$tarball"; then
mv $swigbasename $swigwinbasename
tar -zxf ../$tarball
cd $swigbasename
+ (cd ../.. && cp $pcre_tarball $builddir/$swigbasename)
+ echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
+ ./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
echo Running: ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
- ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
+ ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
echo "Compiling (quietly)..."
make > build.log
echo "Simple check to see if swig.exe runs..."
diff --git a/Tools/pcre-build.sh b/Tools/pcre-build.sh
new file mode 100755
index 000000000..876a58a7e
--- /dev/null
+++ b/Tools/pcre-build.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+pcre_subdir=pcre/pcre-swig-install
+pcre_install_dir=`pwd`/$pcre_subdir
+
+usage() {
+ echo "Helper script to build PCRE as a static library from a tarball just for use during the"
+ echo "SWIG build. It does not install PCRE for global use on your system."
+ echo "Usage: pcre-build.sh [--help] [args]"
+ echo " args - optional additional arguments passed on to the PCRE configure script (leave out"
+ echo " unless you are an expert at configure)"
+ echo " --help - Display this help information."
+ echo "Instructions:"
+ echo " - Download the latest PCRE source tarball from http://www.pcre.org and place in the"
+ echo " directory that you will configure and build SWIG."
+ echo " - Run this script in the same directory that you intend to configure and build SWIG in."
+ echo " - Afterwards run the SWIG configure scrip which will then find and use the PCRE static"
+ echo " libraries in the $pcre_subdir subdirectory."
+ exit 0
+}
+
+bail() {
+ echo $1 >&2
+ exit 1
+}
+
+if test "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ; then
+ usage
+fi
+
+if test -f "pcre-build.sh" ; then
+ echo "Error: this script should not be run in the Tools directory" >&2
+ echo ""
+ usage
+fi
+
+echo "Looking for PCRE tarball..."
+rm -rf pcre
+pcre_tarball=`ls pcre-*.tar.*`
+test -f "$pcre_tarball" || bail "Could not find tarball"
+
+echo "Extracting tarball: $pcre_tarball"
+tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball"
+pcre_dir=`echo $pcre_tarball | sed -e "s/\.tar.*//"`
+echo "Configuring PCRE in directory: pcre"
+mv $pcre_dir pcre || bail "Could not create pcre directory"
+cd pcre && ./configure --prefix=$pcre_install_dir --disable-shared $* || bail "PCRE configure failed"
+echo "Building PCRE..."
+make -s || bail "Could not build PCRE"
+echo "Installing PCRE locally to $pcre_install_dir..."
+make -s install || bail "Could not install PCRE"
+echo ""
+echo "The SWIG configure script can now be run, whereupon PCRE will automatically be detected and used from $pcre_install_dir/bin/pcre-config."
diff --git a/configure.in b/configure.in
index 856d02d4a..2976aca66 100644
--- a/configure.in
+++ b/configure.in
@@ -67,6 +67,19 @@ AC_ARG_WITH([pcre],
AC_MSG_CHECKING([whether to enable PCRE support])
AC_MSG_RESULT([$with_pcre])
+
+dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script
+if test x"${with_pcre}" = xyes ; then
+ AC_MSG_CHECKING([whether to use local PCRE])
+ local_pcre_config=no
+ if test -z $PCRE_CONFIG; then
+ if test -f `pwd`/pcre/pcre-swig-install/bin/pcre-config; then
+ PCRE_CONFIG=`pwd`/pcre/pcre-swig-install/bin/pcre-config
+ local_pcre_config=$PCRE_CONFIG
+ fi
+ fi
+ AC_MSG_RESULT([$local_pcre_config])
+fi
AS_IF([test "x$with_pcre" != xno],
[AX_PATH_GENERIC([pcre],
[], dnl Minimal version of PCRE we need -- accept any
@@ -75,11 +88,18 @@ AS_IF([test "x$with_pcre" != xno],
LIBS="$LIBS $PCRE_LIBS"
CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
],
- [AC_MSG_FAILURE(
- Can't find pcre-config script from PCRE (Perl Compatible Regular
- Expressions) library package. You need to either download PCRE from
- www.pcre.org and install it or use --without-pcre configure option to
- disable regular expressions support in SWIG.)
+ [AC_MSG_FAILURE([
+ Can't find pcre-config script from PCRE (Perl Compatible Regular Expressions)
+ library package. This dependency is needed for configure to complete,
+ Either:
+ - Install the PCRE developer package on your system (preferred approach).
+ - Download the PCRE source tarball, build and install on your system
+ as you would for any package built from source distribution.
+ - Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically
+ link against. Run 'Tools/pcre-build.sh --help' for instructions.
+ (quite easy and does not require privileges to install PCRE on your system)
+ - Use configure --without-pcre to disable regular expressions support in SWIG
+ (not recommended).])
])
])
From 766ed8db375f47ef0ed4751bcd28eba31e40f3d7 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 1 Oct 2010 23:52:46 +0000
Subject: [PATCH 0068/1045] Add -pcreversion option to display PCRE version
information
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12239 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
Doc/Manual/SWIG.html | 1 +
Source/Modules/main.cxx | 7 +++++++
Source/Swig/misc.c | 8 ++++++++
Source/Swig/swig.h | 1 +
5 files changed, 20 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index d3c8c21d0..f312793e4 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,9 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-10-01: wsfulton
+ Add -pcreversion option to display PCRE version information.
+
2010-10-01: olly
[Ruby] Avoid segfault when a method node has no parentNode
(SF#3034054).
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 52b9db339..23a5e1643 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -147,6 +147,7 @@ can be obtained by typing swig -help or swig
-o outfile Name of output file
-outcurrentdir Set default output dir to current dir instead of input file's path
-outdir dir Set language specific files output directory
+-pcreversion Display PCRE version information
-swiglib Show location of SWIG library
-version Show SWIG version number
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index 3f2008d7d..95327018d 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -129,6 +129,7 @@ static const char *usage3 = (const char *) "\
-oh - Set name of the output header file to \n\
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
-outdir - Set language specific files output directory to \n\
+ -pcreversion - Display PCRE version information\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\
@@ -515,6 +516,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-nodirprot") == 0) {
Wrapper_director_protected_mode_set(0);
Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-pcreversion") == 0) {
+ String *version = Swig_pcre_version();
+ Printf(stdout, "%s\n", version);
+ Delete(version);
+ Swig_mark_arg(i);
+ SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-small") == 0) {
Wrapper_compact_print_mode_set(1);
Wrapper_virtual_elimination_mode_set(1);
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index a57c7cf33..73510b513 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -1213,6 +1213,10 @@ String *Swig_string_regex(String *s) {
return res ? res : NewStringEmpty();
}
+String *Swig_pcre_version(void) {
+ return NewStringf("PCRE Version: %s", pcre_version());
+}
+
#else
String *Swig_string_regex(String *s) {
@@ -1220,6 +1224,10 @@ String *Swig_string_regex(String *s) {
exit(1);
}
+String *Swig_pcre_version(void) {
+ return NewStringf("PCRE not used");
+}
+
#endif
/* -----------------------------------------------------------------------------
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 021c5611f..0194664fc 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -319,6 +319,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
+ extern String *Swig_pcre_version(void);
extern void Swig_init(void);
extern int Swig_value_wrapper_mode(int mode);
From 3219746776bb1bcb9f46f895c68040303f0d4b33 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 13:12:00 +0000
Subject: [PATCH 0069/1045] Apply patch #3066958 from Mikael Johansson to fix
default smart pointer handling when the smart pointer contains both a const
and non-const operator->.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12240 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 +
Examples/test-suite/common.mk | 1 +
.../smart_pointer_const_overload_runme.java | 99 ++++++++++++++
.../smart_pointer_const_overload_runme.py | 123 ++++++++++++++++++
.../test-suite/smart_pointer_const_overload.i | 74 +++++++++++
Source/Modules/allocate.cxx | 6 +-
Source/Modules/lang.cxx | 7 +-
Source/Swig/cwrap.c | 40 ++++--
Source/Swig/swig.h | 1 +
9 files changed, 343 insertions(+), 12 deletions(-)
create mode 100644 Examples/test-suite/java/smart_pointer_const_overload_runme.java
create mode 100644 Examples/test-suite/python/smart_pointer_const_overload_runme.py
create mode 100644 Examples/test-suite/smart_pointer_const_overload.i
diff --git a/CHANGES.current b/CHANGES.current
index f312793e4..18694e492 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.1 (in progress)
===========================
+2010-10-03: wsfulton
+ Apply patch #3066958 from Mikael Johansson to fix default smart pointer
+ handling when the smart pointer contains both a const and non-const operator->.
+
2010-10-01: wsfulton
Add -pcreversion option to display PCRE version information.
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index e385b11dd..026612db5 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -294,6 +294,7 @@ CPP_TEST_CASES += \
sizet \
smart_pointer_const \
smart_pointer_const2 \
+ smart_pointer_const_overload \
smart_pointer_extend \
smart_pointer_member \
smart_pointer_multi \
diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
new file mode 100644
index 000000000..bb4ae2c8f
--- /dev/null
+++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
@@ -0,0 +1,99 @@
+import smart_pointer_const_overload.*;
+
+public class smart_pointer_const_overload_runme {
+ static int CONST_ACCESS = 1;
+ static int MUTABLE_ACCESS = 2;
+
+ static {
+ System.loadLibrary("smart_pointer_const_overload");
+ }
+
+ public static void test(Bar b, Foo f) {
+ Assert(f.getX() == 0);
+
+ // Test member variable get
+ Assert(b.getX() == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test member variable set
+ b.setX(1);
+ Assert(f.getX() == 1);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test const method
+ Assert(b.getx() == 1);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test mutable method
+ b.setx(2);
+
+ Assert(f.getX() == 2);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test extended const method
+ Assert(b.getx2() == 2);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test extended mutable method
+ b.setx2(3);
+
+ Assert(f.getX() == 3);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test static method
+ b.stat();
+
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test const member
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(b.getY() == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test get through mutable pointer to const member
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(smart_pointer_const_overload.get_int(b.getYp()) == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test get through const pointer to mutable member
+ f.setX(4);
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(smart_pointer_const_overload.get_int(b.getXp()) == 4);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test set through const pointer to mutable member
+ f.setAccess(MUTABLE_ACCESS);
+ smart_pointer_const_overload.set_int(b.getXp(), 5);
+
+ Assert(f.getX() == 5);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test set pointer to const member
+ b.setYp(smart_pointer_const_overload.new_int(6));
+
+ Assert(f.getY() == 0);
+ Assert(smart_pointer_const_overload.get_int(f.getYp()) == 6);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ smart_pointer_const_overload.delete_int(f.getYp());
+ }
+
+ public static void main(String argv[]) {
+ Foo f = new Foo();
+ Bar b = new Bar(f);
+
+ //Foo f2 = new Foo();
+ //Bar b2 = new Bar2(f2);
+
+ test(b, f);
+ //test(b2, f2);
+ }
+
+ public static void Assert(boolean b) {
+ if (!b)
+ throw new RuntimeException("Assertion failed");
+ }
+}
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
new file mode 100644
index 000000000..f1be315a5
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -0,0 +1,123 @@
+from smart_pointer_const_overload import *
+
+CONST_ACCESS = 1
+MUTABLE_ACCESS = 2
+
+def test(b, f):
+ if f.x != 0:
+ raise RuntimeError
+
+ # Test member variable get
+ if b.x != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test member variable set
+ b.x = 1
+
+ if f.x != 1:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test const method
+ if b.getx() != 1:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test mutable method
+ b.setx(2)
+
+ if f.x != 2:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test extended const method
+ if b.getx2() != 2:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test extended mutable method
+ b.setx2(3)
+
+ if f.x != 3:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test static method
+ b.stat()
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test const member
+ f.access = MUTABLE_ACCESS
+
+ if b.y != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test get through mutable pointer to const member
+ f.access = MUTABLE_ACCESS
+
+ if get_int(b.yp) != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test get through const pointer to mutable member
+ f.x = 4
+ f.access = MUTABLE_ACCESS
+
+ if get_int(b.xp) != 4:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test set through const pointer to mutable member
+ f.access = MUTABLE_ACCESS
+ set_int(b.xp, 5)
+
+ if f.x != 5:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test set pointer to const member
+ b.yp = new_int(6)
+
+ if f.y != 0:
+ raise RuntimeError
+
+ if get_int(f.yp) != 6:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ delete_int(f.yp);
+
+f = Foo()
+b = Bar(f)
+
+f2 = Foo()
+b2 = Bar2(f2)
+
+test(b, f)
+test(b2, f2)
diff --git a/Examples/test-suite/smart_pointer_const_overload.i b/Examples/test-suite/smart_pointer_const_overload.i
new file mode 100644
index 000000000..e3b000b52
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_const_overload.i
@@ -0,0 +1,74 @@
+%module smart_pointer_const_overload
+
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar::operator->; // Overloaded method Bar::operator ->() ignored
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar2::operator->; // Overloaded method Bar2::operator ->() ignored
+
+%inline %{
+int CONST_ACCESS = 1;
+int MUTABLE_ACCESS = 2;
+
+int *new_int(int ivalue) {
+ int *i = (int *) malloc(sizeof(ivalue));
+ *i = ivalue;
+ return i;
+}
+
+int get_int(int *i) {
+ return *i;
+}
+
+void set_int(int *i, int ivalue) {
+ *i = ivalue;
+}
+
+void delete_int(int *i) {
+ free(i);
+}
+
+struct Foo {
+ int x;
+ int * const xp;
+ const int y;
+ const int *yp;
+ int access;
+ Foo() : x(0), xp(&x), y(0), yp(&y), access(0) { }
+ int getx() const { return x; }
+ void setx(int x_) { x = x_; }
+ static void stat() {}
+};
+%}
+
+%extend Foo {
+ int getx2() const { return self->x; }
+ void setx2(int x_) { self->x = x_; }
+};
+
+%inline %{
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ const Foo *operator->() const {
+ f->access = CONST_ACCESS;
+ return f;
+ }
+ Foo *operator->() {
+ f->access = MUTABLE_ACCESS;
+ return f;
+ }
+};
+
+class Bar2 {
+ Foo *f;
+public:
+ Bar2(Foo *f) : f(f) { }
+ Foo *operator->() {
+ f->access = MUTABLE_ACCESS;
+ return f;
+ }
+ const Foo *operator->() const {
+ f->access = CONST_ACCESS;
+ return f;
+ }
+};
+%}
diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
index 2e05fd190..31f7c20ae 100644
--- a/Source/Modules/allocate.cxx
+++ b/Source/Modules/allocate.cxx
@@ -824,9 +824,12 @@ Allocate():
int isconst = 0;
Delete(SwigType_pop(type));
if (SwigType_isconst(type)) {
- isconst = 1;
+ isconst = !Getattr(inclass, "allocate:smartpointermutable");
Setattr(inclass, "allocate:smartpointerconst", "1");
}
+ else {
+ Setattr(inclass, "allocate:smartpointermutable", "1");
+ }
List *methods = smart_pointer_methods(sc, 0, isconst);
Setattr(inclass, "allocate:smartpointer", methods);
Setattr(inclass, "allocate:smartpointerbase", base);
@@ -834,7 +837,6 @@ Allocate():
/* Hmmm. The return value is not a pointer. If the type is a value
or reference. We're going to chase it to see if another operator->()
can be found */
-
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
if (nn) {
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 6ec0463fa..0110b6ea1 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -1344,7 +1344,7 @@ int Language::variableHandler(Node *n) {
Swig_save("variableHandler", n, "feature:immutable", NIL);
if (SmartPointer) {
/* If a smart-pointer and it's a constant access, we have to set immutable */
- if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
+ if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
SetFlag(n, "feature:immutable");
}
}
@@ -1391,7 +1391,7 @@ int Language::membervariableHandler(Node *n) {
int assignable = is_assignable(n);
if (SmartPointer) {
- if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
+ if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
assignable = 0;
}
}
@@ -2443,6 +2443,9 @@ int Language::classHandler(Node *n) {
List *methods = Getattr(n, "allocate:smartpointer");
cplus_mode = PUBLIC;
SmartPointer = CWRAP_SMART_POINTER;
+ if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) {
+ SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD;
+ }
Iterator c;
for (c = First(methods); c.item; c = Next(c)) {
emit_one(c.item);
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index b8812563e..799d434a6 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -783,15 +783,32 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
* ----------------------------------------------------------------------------- */
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
- String *name, *qualifier;
+ String *name;
ParmList *parms;
SwigType *type;
Parm *p;
String *self = 0;
-
- /* If smart pointer, change self dereferencing */
+ int is_smart_pointer_overload = 0;
+ String *qualifier = Getattr(n, "qualifier");
+
+ /* If smart pointer without const overload or mutable method, change self dereferencing */
if (flags & CWRAP_SMART_POINTER) {
- self = NewString("(*this)->");
+ if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
+ String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
+ if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) {
+ self = NewString("(*(this))->");
+ is_smart_pointer_overload = 1;
+ }
+ else if (Cmp(Getattr(n, "storage"), "static") == 0) {
+ self = NewStringf("(*(%s const *)this)->", cname);
+ is_smart_pointer_overload = 1;
+ }
+ else {
+ self = NewString("(*this)->");
+ }
+ } else {
+ self = NewString("(*this)->");
+ }
}
/* If node is a member template expansion, we don't allow added code */
@@ -799,7 +816,6 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
flags &= ~(CWRAP_EXTEND);
name = Getattr(n, "name");
- qualifier = Getattr(n, "qualifier");
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
type = NewString(classname);
@@ -921,10 +937,16 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
if (Cmp(Getattr(n, "storage"), "static") != 0) {
String *pname = Swig_cparm_name(pp, i);
- String *ctname = SwigType_namestr(cname);
- String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
+ String *ctname = SwigType_namestr(cname);
+ String *fadd = 0;
+ if (is_smart_pointer_overload) {
+ fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, classname, pname);
+ }
+ else {
+ fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
+ }
Append(func, fadd);
- Delete(ctname);
+ Delete(ctname);
Delete(fadd);
Delete(pname);
pp = nextSibling(pp);
@@ -1310,6 +1332,8 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
Node *sn = Getattr(n, "cplus:staticbase");
String *base = Getattr(sn, "name");
self = NewStringf("%s::", base);
+ } else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
+ self = NewStringf("(*(%s const *)this)->", classname);
} else {
self = NewString("(*this)->");
}
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index 0194664fc..8058216c3 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -370,6 +370,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
#define CWRAP_DIRECTOR_ONE_CALL 0x08
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
#define CWRAP_ALL_PROTECTED_ACCESS 0x20
+#define CWRAP_SMART_POINTER_OVERLOAD 0x40
/* --- Director Helpers --- */
extern Node *Swig_methodclass(Node *n);
From 70c9dc5dcc532b104861962c170b2bf94ac2fd57 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 15:01:24 +0000
Subject: [PATCH 0070/1045] Fix warning running under Go
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12241 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/constant_pointers.i | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i
index 394c0e5ec..388970c4d 100644
--- a/Examples/test-suite/constant_pointers.i
+++ b/Examples/test-suite/constant_pointers.i
@@ -5,7 +5,6 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%module constant_pointers
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
-%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */
@@ -52,7 +51,7 @@ public:
private:
MemberVariablesTest& operator=(const MemberVariablesTest&);
};
-void foo(const int *const i) {}
+void foofunction(const int *const i) {}
typedef int *typedef1, typedef2, *const typedef3;
int int1, int2=2, *int3, *const int4 = &GlobalInt;
From 378ce60b495f2a8fba61cc5034ed072d434b2d55 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 15:08:03 +0000
Subject: [PATCH 0071/1045] Lua warning fix since previous commit changed max
to maximum
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12242 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/wrapmacro.i | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Examples/test-suite/wrapmacro.i b/Examples/test-suite/wrapmacro.i
index bd5e48b15..4d2cd67be 100644
--- a/Examples/test-suite/wrapmacro.i
+++ b/Examples/test-suite/wrapmacro.i
@@ -1,7 +1,7 @@
%module wrapmacro
#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
-%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_max;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_maximum;
#endif
/* Testing technique for wrapping macros */
From 77a45b263102a22bb6d854760e8ecef32f956d1e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 16:42:22 +0000
Subject: [PATCH 0072/1045] visual c++ warning fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12243 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/go.cxx | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index f62586b92..4b1d05b92 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -1945,7 +1945,7 @@ private:
String *ty = NewString(Getattr(ni, "type"));
SwigType_push(ty, Getattr(ni, "decl"));
String *fullty = SwigType_typedef_resolve_all(ty);
- bool is_function = SwigType_isfunction(fullty);
+ bool is_function = SwigType_isfunction(fullty) ? true : false;
Delete(ty);
Delete(fullty);
@@ -2426,7 +2426,7 @@ private:
* ------------------------------------------------------------ */
int classDirectorConstructor(Node *n) {
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
String *name = Getattr(n, "sym:name");
if (!name) {
@@ -2667,7 +2667,7 @@ private:
return SWIG_OK;
}
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
if (!is_ignored) {
String *fnname = NewString("DeleteDirector");
@@ -2781,7 +2781,7 @@ private:
int classDirectorMethod(Node *n, Node *parent, String *super) {
(void) super;
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
// We don't need explicit calls.
@@ -2869,7 +2869,7 @@ private:
* ------------------------------------------------------------ */
int oneClassDirectorMethod(Node *n, Node *parent) {
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
String *name = Getattr(n, "sym:name");
@@ -3782,7 +3782,7 @@ private:
int num_required = emit_num_required(pi);
int num_arguments = emit_num_arguments(pi);
- bool varargs = emit_isvarargs(pi);
+ bool varargs = emit_isvarargs(pi) ? true : false;
if (varargs) {
Printf(f_go_wrappers, "\tif argc >= %d {\n", num_required);
@@ -4138,7 +4138,7 @@ private:
n1, name, n2);
return false;
}
- bool r = addSymbol(name, n, scope);
+ bool r = addSymbol(name, n, scope) ? true : false;
assert(r);
return true;
}
From c7b4336a6cb9e22bd779c9cad7cd02839927343e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 16:47:30 +0000
Subject: [PATCH 0073/1045] add missing return to testcase
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12244 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/csharp_attributes.i | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Examples/test-suite/csharp_attributes.i b/Examples/test-suite/csharp_attributes.i
index bca595d9a..f679d8c08 100644
--- a/Examples/test-suite/csharp_attributes.i
+++ b/Examples/test-suite/csharp_attributes.i
@@ -56,7 +56,7 @@ double MoreStations::WestonSuperMare = 0.0;
%inline %{
struct YetMoreStations {
- virtual int Slough(int x) {}
+ virtual int Slough(int x) { return x; }
virtual ~YetMoreStations() {}
};
%}
From 22dd2292cadd62b0e8d88fc89da584efcfceb5d2 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 16:58:51 +0000
Subject: [PATCH 0074/1045] Fix for compiling as C code
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12245 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/perl5/perlprimtypes.swg | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg
index f2a614030..86a78c5bf 100644
--- a/Lib/perl5/perlprimtypes.swg
+++ b/Lib/perl5/perlprimtypes.swg
@@ -311,8 +311,9 @@ SWIG_AsVal_dec(double)(SV *obj, double *val)
const char *nptr = SvPV_nolen(obj);
if (nptr) {
char *endptr;
+ double v;
errno = 0;
- double v = strtod(nptr, &endptr);
+ v = strtod(nptr, &endptr);
if (errno == ERANGE) {
errno = 0;
return SWIG_OverflowError;
From 61e9073e0777c7b2d35c9a1d4591058755ee9590 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 20:47:45 +0000
Subject: [PATCH 0075/1045] Add missing return value in testcase
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12246 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/return_const_value.i | 1 +
1 file changed, 1 insertion(+)
diff --git a/Examples/test-suite/return_const_value.i b/Examples/test-suite/return_const_value.i
index 473878521..6be5760c1 100644
--- a/Examples/test-suite/return_const_value.i
+++ b/Examples/test-suite/return_const_value.i
@@ -42,6 +42,7 @@ public:
_ptr = f._ptr;
_own = f._own;
f._own = 0;
+ return *this;
}
~Foo_ptr() {
From 22a12bf08fab301446fe9bfeea6ada9a6a47570e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 05:34:54 +0000
Subject: [PATCH 0076/1045] Add 2.0.1 release notes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12247 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
ANNOUNCE | 2 +-
CHANGES.current | 4 ++--
Doc/Manual/SWIG.html | 3 ++-
Doc/Manual/Sections.html | 2 +-
README | 2 +-
RELEASENOTES | 9 +++++++++
6 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/ANNOUNCE b/ANNOUNCE
index ad3e8f8d6..d14a77042 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,4 +1,4 @@
-*** ANNOUNCE: SWIG 2.0.1 (in progress) ***
+*** ANNOUNCE: SWIG 2.0.1 (4 October 2010) ***
http://www.swig.org
diff --git a/CHANGES.current b/CHANGES.current
index 18694e492..9b02c475f 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,8 +2,8 @@ This file contains the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
-Version 2.0.1 (in progress)
-===========================
+Version 2.0.1 (4 October 2010)
+==============================
2010-10-03: wsfulton
Apply patch #3066958 from Mikael Johansson to fix default smart pointer
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index 23a5e1643..e45fc5f9f 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1885,7 +1885,8 @@ and a more descriptive one, but the two functions are otherwise equivalent:
String after (Perl-like) regex substitution operation. This function
allows to apply arbitrary regular expressions to the identifier names. The
pattern part is a regular expression in Perl syntax (as supported
- by PCRE) and the subst string
+ by the Perl Compatible Regular Expressions (PCRE))
+ library and the subst string
can contain back-references introduced by '\' or, as backslashes need
to be escaped in C strings, rather by "\\". For example, to remove
any alphabetic prefix before an underscore you could use the following directive:
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 8693adc07..74d821b17 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
SWIG-2.0 Documentation
-Last update : SWIG-2.0.1 (in progress)
+Last update : SWIG-2.0.1 (4 October 2010)
Sections
diff --git a/README b/README
index b5379d84d..085fafd7e 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 2.0.1 (in progress)
+Version: 2.0.1 (4 October 2010)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua,
diff --git a/RELEASENOTES b/RELEASENOTES
index 5f41df04f..e8ff30285 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -5,6 +5,15 @@ and CHANGES files.
Release Notes
=============
+SWIG-2.0.1 summary:
+- New language module: Go
+- New regular expression (regex) encoder for renaming symbols based on
+ the Perl Compatible Regular Expressions (PCRE) library.
+- Numerous fixes in reporting file and line numbers in error and warning
+ messages.
+- Various bug fixes and improvements in the C#, Lua, Perl, PHP, Ruby
+ and Python language modules.
+
SWIG-2.0.0 summary:
- License changes, see LICENSE file and http://www.swig.org/legal.html.
- Much better nested class/struct support.
From 2e28d85e5dd71cb75388ca6a93df459ac3db1105 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 05:36:49 +0000
Subject: [PATCH 0077/1045] Warning section doc update
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12248 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Contents.html | 2 +-
Doc/Manual/Warnings.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index ec99a6511..5b18d38de 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -494,7 +494,7 @@
History
From 197b25147e120dc5403a2f948707e4362d463488 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 05:46:42 +0000
Subject: [PATCH 0078/1045] html fixes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12249 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index e45fc5f9f..e51e55986 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -1881,7 +1881,7 @@ and a more descriptive one, but the two functions are otherwise equivalent:
wxPrint
Print
-
regex:/pattern/subst/
+
regex:/pattern/subst/
String after (Perl-like) regex substitution operation. This function
allows to apply arbitrary regular expressions to the identifier names. The
pattern part is a regular expression in Perl syntax (as supported
From eff2a7f9e9f22b4c47a82a16386a4edc8b84e52e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 06:10:41 +0000
Subject: [PATCH 0079/1045] dependency fix for the .book files generation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12250 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 69d361f07..2e50b7767 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -38,13 +38,13 @@ generate: swightml.book swigpdf.book
htmldoc --batch swigpdf.book || true
python fixstyle.py SWIGDocumentation.html
-swigpdf.book:
+swigpdf.book chapters Sections.html:
echo "#HTMLDOC 1.8.24" > swigpdf.book
echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book
echo "Sections.html" >> swigpdf.book
cat chapters >> swigpdf.book
-swightml.book:
+swightml.book chapters Sections.html:
echo "#HTMLDOC 1.8.24" > swightml.book
echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book
echo "Sections.html" >> swightml.book
From 13f861220a0dc8c12512f8bf82c07083b53812f6 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 06:15:53 +0000
Subject: [PATCH 0080/1045] dependency fix for the .book files generation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12251 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Makefile | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 2e50b7767..011261e76 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -15,7 +15,7 @@
# Note the # and " are escaped
HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Contents\" --title --titleimage swig16.png --linkcolor \#0000ff --linkstyle underline --size Universal --left 0.50in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --nup 1 --tocheader .t. --tocfooter ..i --portrait --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=0 --fontsize 10.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 10.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password \"\" --user-password \"\" --browserwidth 680"
-.PHONY: maketoc check generate all clean validate test
+.PHONY: maketoc check generate all maintainer-clean validate test
all: maketoc check generate
@@ -38,13 +38,13 @@ generate: swightml.book swigpdf.book
htmldoc --batch swigpdf.book || true
python fixstyle.py SWIGDocumentation.html
-swigpdf.book chapters Sections.html:
+swigpdf.book: chapters Sections.html
echo "#HTMLDOC 1.8.24" > swigpdf.book
echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book
echo "Sections.html" >> swigpdf.book
cat chapters >> swigpdf.book
-swightml.book chapters Sections.html:
+swightml.book: chapters Sections.html
echo "#HTMLDOC 1.8.24" > swightml.book
echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book
echo "Sections.html" >> swightml.book
From 29b4dbdac1098bbdaf1500a3eb8fb677c0f99db5 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 06:16:21 +0000
Subject: [PATCH 0081/1045] Not all languages were not in alphabetical order
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12252 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Contents.html | 36 +++----
Doc/Manual/R.html | 16 ++--
Doc/Manual/Ruby.html | 196 +++++++++++++++++++--------------------
Doc/Manual/Sections.html | 6 +-
Doc/Manual/Tcl.html | 92 +++++++++---------
Doc/Manual/chapters | 2 +-
6 files changed, 174 insertions(+), 174 deletions(-)
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 5b18d38de..f4fdb9d24 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -1360,7 +1360,23 @@
-
@@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
-
35.1 Bugs
+
33.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
35.2 Using R and SWIG
+
33.2 Using R and SWIG
@@ -119,7 +119,7 @@ Without it, inheritance of wrapped objects may fail.
These two files can be loaded in any order
-
35.3 Precompiling large R files
+
33.3 Precompiling large R files
In cases where the R file is large, one make save a lot of loading
@@ -137,7 +137,7 @@ will save a large amount of loading time.
-
35.4 General policy
+
33.4 General policy
@@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
35.5 Language conventions
+
33.5 Language conventions
@@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
35.6 C++ classes
+
33.6 C++ classes
@@ -167,7 +167,7 @@ keep track of the pointer object which removes the necessity for a lot
of the proxy class baggage you see in other languages.
SWIG 1.3 is known to work with Ruby versions 1.6 and later.
@@ -171,7 +171,7 @@ of Ruby.
-
33.1.1 Running SWIG
+
34.1.1 Running SWIG
To build a Ruby module, run SWIG using the -ruby
@@ -225,7 +225,7 @@ to compile this file and link it with the rest of your program.
-
33.1.2 Getting the right header files
+
34.1.2 Getting the right header files
In order to compile the wrapper code, the compiler needs the ruby.h
@@ -274,7 +274,7 @@ installed, you can run Ruby to find out. For example:
-
33.1.3 Compiling a dynamic module
+
34.1.3 Compiling a dynamic module
Ruby extension modules are typically compiled into shared
@@ -428,7 +428,7 @@ manual pages for your compiler and linker to determine the correct set
of options. You might also check the SWIG Wiki
for additional information.
-
33.1.4 Using your module
+
34.1.4 Using your module
Ruby module names must be capitalized,
@@ -488,7 +488,7 @@ begins with:
-
33.1.5 Static linking
+
34.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -509,7 +509,7 @@ finally rebuilding Ruby.
-
33.1.6 Compilation of C++ extensions
+
34.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -561,7 +561,7 @@ extension, e.g.
-
33.2 Building Ruby Extensions under Windows 95/NT
+
34.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -600,7 +600,7 @@ files.
-
33.2.1 Running SWIG from Developer Studio
+
34.2.1 Running SWIG from Developer Studio
If you are developing your application within Microsoft
@@ -742,7 +742,7 @@ directory, then run the Ruby script from the DOS/Command prompt:
-
33.3 The Ruby-to-C/C++ Mapping
+
34.3 The Ruby-to-C/C++ Mapping
This section describes the basics of how SWIG maps C or C++
@@ -752,7 +752,7 @@ declarations in your SWIG interface files to Ruby constructs.
There are three ways to raise exceptions from C++ code to
@@ -4615,7 +4615,7 @@ the built-in Ruby exception types.
-
33.6.4 Exception classes
+
34.6.4 Exception classes
Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass
@@ -4673,7 +4673,7 @@ providing for a more natural integration between C++ code and Ruby code.
-
33.7 Typemaps
+
34.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4696,7 +4696,7 @@ of the primitive C-Ruby interface.
-
33.7.1 What is a typemap?
+
34.7.1 What is a typemap?
A typemap is nothing more than a code generation rule that is
@@ -4958,7 +4958,7 @@ to be used as follows (notice how the length parameter is omitted):
-
33.7.2 Typemap scope
+
34.7.2 Typemap scope
Once defined, a typemap remains in effect for all of the
@@ -5006,7 +5006,7 @@ where the class itself is defined. For example:
-
33.7.3 Copying a typemap
+
34.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5108,7 +5108,7 @@ rules as for
-
33.7.4 Deleting a typemap
+
34.7.4 Deleting a typemap
A typemap can be deleted by simply defining no code. For
@@ -5160,7 +5160,7 @@ typemaps immediately after the clear operation.
-
33.7.5 Placement of typemaps
+
34.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5244,7 +5244,7 @@ string
-
33.7.6 Ruby typemaps
+
34.7.6 Ruby typemaps
The following list details all of the typemap methods that
@@ -5254,7 +5254,7 @@ can be used by the Ruby module:
-
33.7.6.1 "in" typemap
+
34.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5497,7 +5497,7 @@ arguments to be specified. For example:
-
33.7.6.2 "typecheck" typemap
+
34.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5538,7 +5538,7 @@ on "Typemaps and Overloading."
-
33.7.6.3 "out" typemap
+
34.7.6.3 "out" typemap
Converts return value of a C function
@@ -5770,7 +5770,7 @@ version of the C datatype matched by the typemap.
-
33.7.6.4 "arginit" typemap
+
34.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5795,7 +5795,7 @@ applications. For example:
-
33.7.6.5 "default" typemap
+
34.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5837,7 +5837,7 @@ default argument wrapping.
-
33.7.6.6 "check" typemap
+
34.7.6.6 "check" typemap
The "check" typemap is used to supply value checking code
@@ -5861,7 +5861,7 @@ arguments have been converted. For example:
-
33.7.6.7 "argout" typemap
+
34.7.6.7 "argout" typemap
The "argout" typemap is used to return values from arguments.
@@ -6019,7 +6019,7 @@ some function like SWIG_Ruby_AppendOutput.
-
33.7.6.8 "freearg" typemap
+
34.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6055,7 +6055,7 @@ abort prematurely.
-
33.7.6.9 "newfree" typemap
+
34.7.6.9 "newfree" typemap
The "newfree" typemap is used in conjunction with the %newobject
@@ -6086,7 +6086,7 @@ ownership and %newobject for further details.
-
33.7.6.10 "memberin" typemap
+
34.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6119,7 +6119,7 @@ other objects.
-
33.7.6.11 "varin" typemap
+
34.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6130,7 +6130,7 @@ This is implementation specific.
-
33.7.6.12 "varout" typemap
+
34.7.6.12 "varout" typemap
The "varout" typemap is used to convert a C/C++ object to an
@@ -6141,7 +6141,7 @@ This is implementation specific.
-
33.7.6.13 "throws" typemap
+
34.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6200,7 +6200,7 @@ handling with %exception section.
-
33.7.6.14 directorin typemap
+
34.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6454,7 +6454,7 @@ referring to the class itself.
-
33.7.6.15 directorout typemap
+
34.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6714,7 +6714,7 @@ exception.
-
33.7.6.16 directorargout typemap
+
34.7.6.16 directorargout typemap
Output argument processing in director
@@ -6954,7 +6954,7 @@ referring to the instance of the class itself
-
33.7.6.17 ret typemap
+
34.7.6.17 ret typemap
Cleanup of function return values
@@ -6964,7 +6964,7 @@ referring to the instance of the class itself
-
33.7.6.18 globalin typemap
+
34.7.6.18 globalin typemap
Setting of C global variables
@@ -6974,7 +6974,7 @@ referring to the instance of the class itself
-
33.7.7 Typemap variables
+
34.7.7 Typemap variables
@@ -7084,7 +7084,7 @@ being created.
-
33.7.8 Useful Functions
+
34.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7108,7 +7108,7 @@ across multiple languages.
-
33.7.8.1 C Datatypes to Ruby Objects
+
34.7.8.1 C Datatypes to Ruby Objects
@@ -7164,7 +7164,7 @@ SWIG_From_float(float)
-
33.7.8.2 Ruby Objects to C Datatypes
+
34.7.8.2 Ruby Objects to C Datatypes
Here, while the Ruby versions return the value directly, the SWIG
@@ -7253,7 +7253,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-
The Ruby language doesn't support multiple inheritance, but
@@ -9796,7 +9796,7 @@ Features") for more details).
-
33.10 Memory Management
+
34.10 Memory Management
One of the most common issues in generating SWIG bindings for
@@ -9843,7 +9843,7 @@ understanding of how the underlying library manages memory.
-
33.10.1 Mark and Sweep Garbage Collector
+
34.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9891,7 +9891,7 @@ this memory.
-
33.10.2 Object Ownership
+
34.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10149,7 +10149,7 @@ public:
-
33.10.3 Object Tracking
+
34.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10400,7 +10400,7 @@ methods.
-
33.10.4 Mark Functions
+
34.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10518,7 +10518,7 @@ test suite.
-
33.10.5 Free Functions
+
34.10.5 Free Functions
By default, SWIG creates a "free" function that is called when
@@ -10768,7 +10768,7 @@ been freed, and thus raises a runtime exception.
-
33.10.6 Embedded Ruby and the C++ Stack
+
34.10.6 Embedded Ruby and the C++ Stack
As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 74d821b17..05282f40c 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -19,7 +19,7 @@ Last update : SWIG-2.0.1 (4 October 2010)
@@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
34.1 Preliminaries
+
35.1 Preliminaries
@@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
-
34.1.1 Getting the right header files
+
35.1.1 Getting the right header files
@@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
34.1.2 Compiling a dynamic module
+
35.1.2 Compiling a dynamic module
@@ -162,7 +162,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
-
34.1.3 Static linking
+
35.1.3 Static linking
@@ -228,7 +228,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
-
34.1.4 Using your module
+
35.1.4 Using your module
@@ -356,7 +356,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
-
34.1.5 Compilation of C++ extensions
+
35.1.5 Compilation of C++ extensions
@@ -439,7 +439,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
34.1.6 Compiling for 64-bit platforms
+
35.1.6 Compiling for 64-bit platforms
@@ -466,7 +466,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
34.1.7 Setting a package prefix
+
35.1.7 Setting a package prefix
@@ -485,7 +485,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
-
34.1.8 Using namespaces
+
35.1.8 Using namespaces
@@ -507,7 +507,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
-
34.2 Building Tcl/Tk Extensions under Windows 95/NT
+
35.2 Building Tcl/Tk Extensions under Windows 95/NT
@@ -518,7 +518,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
-
34.2.1 Running SWIG from Developer Studio
+
35.2.1 Running SWIG from Developer Studio
@@ -576,7 +576,7 @@ MSDOS > tclsh80
%
-
34.2.2 Using NMAKE
+
35.2.2 Using NMAKE
@@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
34.3 A tour of basic C/C++ wrapping
+
35.3 A tour of basic C/C++ wrapping
@@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
34.3.1 Modules
+
35.3.1 Modules
@@ -684,7 +684,7 @@ To fix this, supply an extra argument to load like this:
-
@@ -873,7 +873,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
-
34.3.5 Pointers
+
35.3.5 Pointers
@@ -969,7 +969,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
34.3.6 Structures
+
35.3.6 Structures
@@ -1251,7 +1251,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
-
34.3.7 C++ classes
+
35.3.7 C++ classes
@@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows:
-
34.3.8 C++ inheritance
+
35.3.8 C++ inheritance
@@ -1367,7 +1367,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
34.3.9 Pointers, references, values, and arrays
+
35.3.9 Pointers, references, values, and arrays
@@ -1421,7 +1421,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
-
34.3.10 C++ overloaded functions
+
35.3.10 C++ overloaded functions
@@ -1544,7 +1544,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
34.3.11 C++ operators
+
35.3.11 C++ operators
@@ -1646,7 +1646,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
-
34.3.12 C++ namespaces
+
35.3.12 C++ namespaces
@@ -1710,7 +1710,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -2434,7 +2434,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
-
34.7 Typemaps
+
35.7 Typemaps
@@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
34.7.1 What is a typemap?
+
35.7.1 What is a typemap?
@@ -2568,7 +2568,7 @@ parameter is omitted):
-
34.7.2 Tcl typemaps
+
35.7.2 Tcl typemaps
@@ -2706,7 +2706,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
-
34.7.3 Typemap variables
+
35.7.3 Typemap variables
@@ -2777,7 +2777,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
34.7.4 Converting a Tcl list to a char **
+
35.7.4 Converting a Tcl list to a char **
@@ -2839,7 +2839,7 @@ argv[2] = Larry
3
-
34.7.5 Returning values in arguments
+
35.7.5 Returning values in arguments
@@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
34.7.6 Useful functions
+
35.7.6 Useful functions
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
34.7.7 Standard typemaps
+
35.7.7 Standard typemaps
@@ -3042,7 +3042,7 @@ work)
-
34.7.8 Pointer handling
+
35.7.8 Pointer handling
@@ -3118,7 +3118,7 @@ For example:
-
34.8 Turning a SWIG module into a Tcl Package.
+
35.8 Turning a SWIG module into a Tcl Package.
@@ -3190,7 +3190,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
-
34.9 Building new kinds of Tcl interfaces (in Tcl)
+
35.9 Building new kinds of Tcl interfaces (in Tcl)
@@ -3289,7 +3289,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
-
34.9.1 Proxy classes
+
35.9.1 Proxy classes
@@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
-
34.10 Tcl/Tk Stubs
+
35.10 Tcl/Tk Stubs
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 014029c74..e918e234a 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -30,7 +30,7 @@ Perl5.html
Php.html
Pike.html
Python.html
+R.html
Ruby.html
Tcl.html
-R.html
Extending.html
From 0d49656a54ebb80d488b1d60c702b10c857b3340 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 18:44:38 +0000
Subject: [PATCH 0082/1045] minor tweak to release notes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12253 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
RELEASENOTES | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/RELEASENOTES b/RELEASENOTES
index e8ff30285..e07b8a14a 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -6,7 +6,7 @@ Release Notes
=============
SWIG-2.0.1 summary:
-- New language module: Go
+- Go language added to list of supported languages.
- New regular expression (regex) encoder for renaming symbols based on
the Perl Compatible Regular Expressions (PCRE) library.
- Numerous fixes in reporting file and line numbers in error and warning
From 2e4cff569953a1eefd4e47d80ca1b1e10afd643b Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 19:16:12 +0000
Subject: [PATCH 0083/1045] minor tweak to release notes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12254 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
RELEASENOTES | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/RELEASENOTES b/RELEASENOTES
index e07b8a14a..829cd4d03 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -6,7 +6,7 @@ Release Notes
=============
SWIG-2.0.1 summary:
-- Go language added to list of supported languages.
+- Support for the Go language has been added.
- New regular expression (regex) encoder for renaming symbols based on
the Perl Compatible Regular Expressions (PCRE) library.
- Numerous fixes in reporting file and line numbers in error and warning
From 9b3d2ec9b0c7a02b9e85058821cb820057544851 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 19:30:15 +0000
Subject: [PATCH 0084/1045] Add missing Go language CHANGES entry
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12255 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index 9b02c475f..bbaf8443a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -175,6 +175,9 @@ Version 2.0.1 (4 October 2010)
Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
the "unref" feature when used on classes with non-public destructors.
+2010-06-17: ianlancetaylor
+ [Go] Add the Go language module.
+
2010-06-10: wsfulton
[Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
modules and wrapping strings. Patch from 'Number Cruncher'.
From aabd75f3d83b365850e3c1c4fa77a471b2231914 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 19:30:53 +0000
Subject: [PATCH 0085/1045] New major contributors
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12256 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
COPYRIGHT | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/COPYRIGHT b/COPYRIGHT
index 40d09a1d6..1e5d080d4 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -42,7 +42,7 @@ Past SWIG developers and major contributors include:
Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core)
Mark Rose (mrose@stm.lbl.gov) (Directors)
Jonah Beckford (beckford@usermail.com) (CHICKEN)
- Ahmon Dancy (dancy@franz.com) (Allegro CL)
+ Ahmon Dancy (dancy@franz.com) (Allegro CL)
Dirk Gerrits (Allegro CL)
Neil Cawse (C#)
Harco de Hilster (Java)
@@ -55,6 +55,8 @@ Past SWIG developers and major contributors include:
Mark Gossage (mark@gossage.cjb.net) (Lua)
Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
+ Ian Lance Taylor (Go)
+ Vadim Zeitlin (PCRE)
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
From a56ee9cb1bcdea85480e2678aff97c14c9aa1856 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 5 Oct 2010 06:11:50 +0000
Subject: [PATCH 0086/1045] Bump version to 2.0.2 and move CHANGES.current to
CHANGES
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12260 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
ANNOUNCE | 2 +-
CHANGES | 189 +++++++++++++++++++++++++++++++++++++++
CHANGES.current | 189 +--------------------------------------
Doc/Manual/Sections.html | 2 +-
README | 2 +-
configure.in | 2 +-
6 files changed, 195 insertions(+), 191 deletions(-)
diff --git a/ANNOUNCE b/ANNOUNCE
index d14a77042..cdf246e07 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,4 +1,4 @@
-*** ANNOUNCE: SWIG 2.0.1 (4 October 2010) ***
+*** ANNOUNCE: SWIG 2.0.2 (in progress) ***
http://www.swig.org
diff --git a/CHANGES b/CHANGES
index f243ff7c6..bf5e20da1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,195 @@ SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
+Version 2.0.1 (4 October 2010)
+==============================
+
+2010-10-03: wsfulton
+ Apply patch #3066958 from Mikael Johansson to fix default smart pointer
+ handling when the smart pointer contains both a const and non-const operator->.
+
+2010-10-01: wsfulton
+ Add -pcreversion option to display PCRE version information.
+
+2010-10-01: olly
+ [Ruby] Avoid segfault when a method node has no parentNode
+ (SF#3034054).
+
+2010-10-01: olly
+ [Python] Allow reinitialisation to work with an embedded Python
+ interpreter (patch from Jim Carroll in SF#3075178).
+
+2010-09-28: wsfulton
+ [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
+ throwing exceptions with normal usage of iterators.
+
+2010-09-27: olly
+ [Python] Improve error message given when a parameter of the wrong
+ type is passed to an overloaded method (SF#3027355).
+
+2010-09-25: wsfulton
+ Apply SF patch #3075150 - Java directors using static variables in
+ named namespace.
+
+2010-09-24: wsfulton
+ More file and line error/warning reporting fixes where SWIG macros
+ are used within {} braces (where the preprocessor expands macros),
+ for example macros within %inline {...} and %fragment(...) {...}
+ and nested structs.
+
+2010-09-18: wsfulton
+ More file and line error/warning reporting fixes for various inherited
+ class problems.
+
+2010-09-15: wsfulton
+ A much improved debugging of SWIG source experience is now available and
+ documented in the "Debugging SWIG" section in the Doc/Devel/internals.html
+ file, including a swig.dbg support file for the gdb debugger.
+
+2010-09-11: wsfulton
+ Fix incorrect line number reporting in errors/warnings when a macro
+ definition ends with '/' and it is not the end of a C comment.
+
+2010-09-11: wsfulton
+ Fix incorrect line number reporting in errors/warnings after parsing
+ macro invocations with parameters given over more than one line.
+
+2010-09-10: wsfulton
+ Remove extraneous extra line in preprocessed output after including files
+ which would sometimes lead to error/warning messages two lines after the
+ end of the file.
+
+2010-09-10: wsfulton
+ Fix #2149523 - Incorrect line number reporting in errors after parsing macros
+ containing C++ comments.
+
+2010-09-08: olly
+ [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394).
+
+2010-09-03: wsfulton
+ Fix erroneous line numbers in error messages for macro expansions, for example,
+ the error message now points to instantiation of the macro, ie the last line here:
+
+ #define MACRO2(a, b)
+
+ #define MACRO1(NAME) MACRO2(NAME,2,3)
+
+ MACRO1(abc)
+
+2010-09-02: wsfulton
+ Fix line numbers in error and warning messages for preprocessor messages within
+ %inline, for example:
+
+ %inline %{
+ #define FOOBAR 1
+ #define FOOBAR "hi"
+ %}
+
+2010-09-02: wsfulton
+ Fix line numbers in error and warning messages which were cumulatively one
+ less than they should have been after parsing each %include/%import - bug
+ introduced in swig-1.3.32. Also fix line numbers in error and warning messages
+ when new line characters appear between the %include / %import statement and
+ the filename.
+
+2010-08-30: wsfulton
+ Fix line number and file name reporting for some macro preprocessor warnings.
+ The line number of the macro argument has been corrected and the line number
+ of the start of the macro instead of one past the end of the macro is used.
+ Some examples:
+ file.h:11: Error: Illegal macro argument name '..'
+ file.h:19: Error: Macro 'DUPLICATE' redefined,
+ file.h:15: Error: previous definition of 'DUPLICATE'.
+ file.h:25: Error: Variable-length macro argument must be last parameter
+ file.h:32: Error: Illegal character in macro argument name
+ file.i:37: Error: Macro 'SIT' expects 2 arguments
+
+2010-08-26: wsfulton
+ Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this
+ did not work at all. Also fixes SF #2822822.
+
+2010-08-17: wsfulton
+ [Perl] Fix corner case marshalling of doubles - errno was not being correctly
+ set before calling strtod - patch from Justin Vallon - SF Bug #3038936.
+
+2010-08-17: wsfulton
+ Fix make distclean when some of the more obscure languages are detected by
+ configure - fixes from Torsten Landschoff.
+
+2010-07-28: wsfulton
+ Restore configuring out of source for the test-suite since it broke in 1.3.37.
+ As previously, if running 'make check-test-suite' out of source, it needs to be
+ done by invoking configure with a relative path. Invoking configure with an
+ absolute path will not work. Running the full 'make check' still needs to be
+ done in the source tree.
+
+2010-07-16: wsfulton
+ Fix wrapping of function pointers and member function pointers when the function
+ returns by reference.
+
+2010-07-13: vadz
+ Removed support for the old experimental "rxspencer" encoder and
+ "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and
+ officially supported "regex" encoder and "[not]regexmatch" checks
+ should be used instead (see the two previous entries). Please
+ replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s"
+ when upgrading. Notice that you will also need to replace the back-
+ references of form "@1" with the more standard "\\1" and may need to
+ adjust your regular expressions syntax as the new regex encoder uses
+ Perl-compatible syntax and not (extended) POSIX syntax as the old one.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2010-07-13: vadz
+ Add "regexmatch", "regextarget" and "notregexmatch" which can be
+ used to apply %rename directives to the declarations matching the
+ specified regular expression only. The first two can be used
+ interchangeably, both of the %renames below do the same thing:
+
+ %rename("$ignore", regexmatch$name="Old$") "";
+ %rename("$ignore", regextarget=1) "Old$";
+
+ (namely ignore the declarations having "Old" suffix).
+
+ "notregexmatch" restricts the match to only the declarations which
+ do not match the regular expression, e.g. here is how to rename to
+ lower case versions all declarations except those consisting from
+ capital letters only:
+
+ %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") "";
+
+2010-07-13: vadz
+ Add the new "regex" encoder that can be used in %rename, e.g.
+
+ %rename("regex:/(\\w+)_(.*)/\\2/") "";
+
+ to remove any alphabetical prefix from all identifiers. The syntax
+ of the regular expressions is Perl-like and PCRE library
+ (http://www.pcre.org/) is used to implement this feature but notice
+ that backslashes need to be escaped as usual inside C strings.
+
+ Original patch from Torsten Landschoff.
+
+2010-07-08: wsfulton
+ Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
+ the "unref" feature when used on classes with non-public destructors.
+
+2010-06-17: ianlancetaylor
+ [Go] Add the Go language module.
+
+2010-06-10: wsfulton
+ [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
+ modules and wrapping strings. Patch from 'Number Cruncher'.
+
+2010-06-10: olly
+ [PHP] Fix directors to correctly call a method with has a
+ different name in PHP to C++ (we were always using the C++ name
+ in this case).
+
+2010-06-03: wsfulton
+ Fix uncompileable code when %rename results in two enum items
+ with the same name. Reported by Vadim Zeitlin.
+
Version 2.0.0 (2 June 2010)
===========================
diff --git a/CHANGES.current b/CHANGES.current
index bbaf8443a..26977a25d 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,191 +2,6 @@ This file contains the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
-Version 2.0.1 (4 October 2010)
-==============================
+Version 2.0.2 (in progress)
+===========================
-2010-10-03: wsfulton
- Apply patch #3066958 from Mikael Johansson to fix default smart pointer
- handling when the smart pointer contains both a const and non-const operator->.
-
-2010-10-01: wsfulton
- Add -pcreversion option to display PCRE version information.
-
-2010-10-01: olly
- [Ruby] Avoid segfault when a method node has no parentNode
- (SF#3034054).
-
-2010-10-01: olly
- [Python] Allow reinitialisation to work with an embedded Python
- interpreter (patch from Jim Carroll in SF#3075178).
-
-2010-09-28: wsfulton
- [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
- throwing exceptions with normal usage of iterators.
-
-2010-09-27: olly
- [Python] Improve error message given when a parameter of the wrong
- type is passed to an overloaded method (SF#3027355).
-
-2010-09-25: wsfulton
- Apply SF patch #3075150 - Java directors using static variables in
- named namespace.
-
-2010-09-24: wsfulton
- More file and line error/warning reporting fixes where SWIG macros
- are used within {} braces (where the preprocessor expands macros),
- for example macros within %inline {...} and %fragment(...) {...}
- and nested structs.
-
-2010-09-18: wsfulton
- More file and line error/warning reporting fixes for various inherited
- class problems.
-
-2010-09-15: wsfulton
- A much improved debugging of SWIG source experience is now available and
- documented in the "Debugging SWIG" section in the Doc/Devel/internals.html
- file, including a swig.dbg support file for the gdb debugger.
-
-2010-09-11: wsfulton
- Fix incorrect line number reporting in errors/warnings when a macro
- definition ends with '/' and it is not the end of a C comment.
-
-2010-09-11: wsfulton
- Fix incorrect line number reporting in errors/warnings after parsing
- macro invocations with parameters given over more than one line.
-
-2010-09-10: wsfulton
- Remove extraneous extra line in preprocessed output after including files
- which would sometimes lead to error/warning messages two lines after the
- end of the file.
-
-2010-09-10: wsfulton
- Fix #2149523 - Incorrect line number reporting in errors after parsing macros
- containing C++ comments.
-
-2010-09-08: olly
- [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394).
-
-2010-09-03: wsfulton
- Fix erroneous line numbers in error messages for macro expansions, for example,
- the error message now points to instantiation of the macro, ie the last line here:
-
- #define MACRO2(a, b)
-
- #define MACRO1(NAME) MACRO2(NAME,2,3)
-
- MACRO1(abc)
-
-2010-09-02: wsfulton
- Fix line numbers in error and warning messages for preprocessor messages within
- %inline, for example:
-
- %inline %{
- #define FOOBAR 1
- #define FOOBAR "hi"
- %}
-
-2010-09-02: wsfulton
- Fix line numbers in error and warning messages which were cumulatively one
- less than they should have been after parsing each %include/%import - bug
- introduced in swig-1.3.32. Also fix line numbers in error and warning messages
- when new line characters appear between the %include / %import statement and
- the filename.
-
-2010-08-30: wsfulton
- Fix line number and file name reporting for some macro preprocessor warnings.
- The line number of the macro argument has been corrected and the line number
- of the start of the macro instead of one past the end of the macro is used.
- Some examples:
- file.h:11: Error: Illegal macro argument name '..'
- file.h:19: Error: Macro 'DUPLICATE' redefined,
- file.h:15: Error: previous definition of 'DUPLICATE'.
- file.h:25: Error: Variable-length macro argument must be last parameter
- file.h:32: Error: Illegal character in macro argument name
- file.i:37: Error: Macro 'SIT' expects 2 arguments
-
-2010-08-26: wsfulton
- Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this
- did not work at all. Also fixes SF #2822822.
-
-2010-08-17: wsfulton
- [Perl] Fix corner case marshalling of doubles - errno was not being correctly
- set before calling strtod - patch from Justin Vallon - SF Bug #3038936.
-
-2010-08-17: wsfulton
- Fix make distclean when some of the more obscure languages are detected by
- configure - fixes from Torsten Landschoff.
-
-2010-07-28: wsfulton
- Restore configuring out of source for the test-suite since it broke in 1.3.37.
- As previously, if running 'make check-test-suite' out of source, it needs to be
- done by invoking configure with a relative path. Invoking configure with an
- absolute path will not work. Running the full 'make check' still needs to be
- done in the source tree.
-
-2010-07-16: wsfulton
- Fix wrapping of function pointers and member function pointers when the function
- returns by reference.
-
-2010-07-13: vadz
- Removed support for the old experimental "rxspencer" encoder and
- "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and
- officially supported "regex" encoder and "[not]regexmatch" checks
- should be used instead (see the two previous entries). Please
- replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s"
- when upgrading. Notice that you will also need to replace the back-
- references of form "@1" with the more standard "\\1" and may need to
- adjust your regular expressions syntax as the new regex encoder uses
- Perl-compatible syntax and not (extended) POSIX syntax as the old one.
-
- *** POTENTIAL INCOMPATIBILITY ***
-
-2010-07-13: vadz
- Add "regexmatch", "regextarget" and "notregexmatch" which can be
- used to apply %rename directives to the declarations matching the
- specified regular expression only. The first two can be used
- interchangeably, both of the %renames below do the same thing:
-
- %rename("$ignore", regexmatch$name="Old$") "";
- %rename("$ignore", regextarget=1) "Old$";
-
- (namely ignore the declarations having "Old" suffix).
-
- "notregexmatch" restricts the match to only the declarations which
- do not match the regular expression, e.g. here is how to rename to
- lower case versions all declarations except those consisting from
- capital letters only:
-
- %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") "";
-
-2010-07-13: vadz
- Add the new "regex" encoder that can be used in %rename, e.g.
-
- %rename("regex:/(\\w+)_(.*)/\\2/") "";
-
- to remove any alphabetical prefix from all identifiers. The syntax
- of the regular expressions is Perl-like and PCRE library
- (http://www.pcre.org/) is used to implement this feature but notice
- that backslashes need to be escaped as usual inside C strings.
-
- Original patch from Torsten Landschoff.
-
-2010-07-08: wsfulton
- Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
- the "unref" feature when used on classes with non-public destructors.
-
-2010-06-17: ianlancetaylor
- [Go] Add the Go language module.
-
-2010-06-10: wsfulton
- [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
- modules and wrapping strings. Patch from 'Number Cruncher'.
-
-2010-06-10: olly
- [PHP] Fix directors to correctly call a method with has a
- different name in PHP to C++ (we were always using the C++ name
- in this case).
-
-2010-06-03: wsfulton
- Fix uncompileable code when %rename results in two enum items
- with the same name. Reported by Vadim Zeitlin.
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 05282f40c..855244790 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
SWIG-2.0 Documentation
-Last update : SWIG-2.0.1 (4 October 2010)
+Last update : SWIG-2.0.2 (in progress)
Sections
diff --git a/README b/README
index 085fafd7e..975870626 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 2.0.1 (4 October 2010)
+Version: 2.0.2 (in progress)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua,
diff --git a/configure.in b/configure.in
index 2976aca66..36337b41d 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],[2.0.1],[http://www.swig.org])
+AC_INIT([swig],[2.0.2],[http://www.swig.org])
dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
dnl definition below can be removed
From a4a56acd33cae770a6aacba0df72a6147b611aa1 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 7 Oct 2010 06:06:12 +0000
Subject: [PATCH 0087/1045] dos to unix fileformatting
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12261 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/csharp/wchar.i | 204 ++++++++++++++++++++++-----------------------
1 file changed, 102 insertions(+), 102 deletions(-)
diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i
index f02c09a53..1d95edded 100644
--- a/Lib/csharp/wchar.i
+++ b/Lib/csharp/wchar.i
@@ -1,102 +1,102 @@
-/* -----------------------------------------------------------------------------
- * wchar.i
- *
- * Typemaps for the wchar_t type
- * These are mapped to a C# String and are passed around by value.
- *
- * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER
- *
- * ----------------------------------------------------------------------------- */
-
-#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER)
-#if !defined(SWIG_CSHARP_WSTRING_HELPER_)
-#define SWIG_CSHARP_WSTRING_HELPER_
-%insert(runtime) %{
-/* Callback for returning strings to C# without leaking memory */
-typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *);
-static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
-%}
-
-%pragma(csharp) imclasscode=%{
- protected class SWIGWStringHelper {
-
- public delegate string SWIGWStringDelegate(IntPtr message);
- static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
-
- [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
- public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate);
-
- static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) {
- return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
- }
-
- static SWIGWStringHelper() {
- SWIGRegisterWStringCallback_$module(wstringDelegate);
- }
- }
-
- static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper();
-%}
-
-%insert(runtime) %{
-#ifdef __cplusplus
-extern "C"
-#endif
-SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) {
- SWIG_csharp_wstring_callback = callback;
-}
-%}
-#endif // SWIG_CSHARP_WSTRING_HELPER_
-#endif // SWIG_CSHARP_NO_WSTRING_HELPER
-
-
-// wchar_t
-%typemap(ctype) wchar_t "wchar_t"
-%typemap(imtype) wchar_t "char"
-%typemap(cstype) wchar_t "char"
-
-%typemap(csin) wchar_t "$csinput"
-%typemap(csout, excode=SWIGEXCODE) wchar_t {
- char ret = $imcall;$excode
- return ret;
- }
-%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{
- set {
- $imcall;$excode
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{
- get {
- char ret = $imcall;$excode
- return ret;
- } %}
-
-%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %}
-%typemap(out) wchar_t %{ $result = (wchar_t)$1; %}
-
-%typemap(typecheck) wchar_t = char;
-
-// wchar_t *
-%typemap(ctype) wchar_t * "wchar_t *"
-%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string"
-%typemap(cstype) wchar_t * "string"
-
-%typemap(csin) wchar_t * "$csinput"
-%typemap(csout, excode=SWIGEXCODE) wchar_t * {
- string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
- return ret;
- }
-%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{
- set {
- $imcall;$excode
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
- get {
- string ret = $imcall;$excode
- return ret;
- } %}
-
-%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %}
-%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %}
-
-%typemap(typecheck) wchar_t * = char *;
-
+/* -----------------------------------------------------------------------------
+ * wchar.i
+ *
+ * Typemaps for the wchar_t type
+ * These are mapped to a C# String and are passed around by value.
+ *
+ * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER
+ *
+ * ----------------------------------------------------------------------------- */
+
+#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER)
+#if !defined(SWIG_CSHARP_WSTRING_HELPER_)
+#define SWIG_CSHARP_WSTRING_HELPER_
+%insert(runtime) %{
+/* Callback for returning strings to C# without leaking memory */
+typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *);
+static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
+%}
+
+%pragma(csharp) imclasscode=%{
+ protected class SWIGWStringHelper {
+
+ public delegate string SWIGWStringDelegate(IntPtr message);
+ static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
+
+ [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
+ public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate);
+
+ static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) {
+ return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
+ }
+
+ static SWIGWStringHelper() {
+ SWIGRegisterWStringCallback_$module(wstringDelegate);
+ }
+ }
+
+ static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper();
+%}
+
+%insert(runtime) %{
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) {
+ SWIG_csharp_wstring_callback = callback;
+}
+%}
+#endif // SWIG_CSHARP_WSTRING_HELPER_
+#endif // SWIG_CSHARP_NO_WSTRING_HELPER
+
+
+// wchar_t
+%typemap(ctype) wchar_t "wchar_t"
+%typemap(imtype) wchar_t "char"
+%typemap(cstype) wchar_t "char"
+
+%typemap(csin) wchar_t "$csinput"
+%typemap(csout, excode=SWIGEXCODE) wchar_t {
+ char ret = $imcall;$excode
+ return ret;
+ }
+%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{
+ set {
+ $imcall;$excode
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{
+ get {
+ char ret = $imcall;$excode
+ return ret;
+ } %}
+
+%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %}
+%typemap(out) wchar_t %{ $result = (wchar_t)$1; %}
+
+%typemap(typecheck) wchar_t = char;
+
+// wchar_t *
+%typemap(ctype) wchar_t * "wchar_t *"
+%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string"
+%typemap(cstype) wchar_t * "string"
+
+%typemap(csin) wchar_t * "$csinput"
+%typemap(csout, excode=SWIGEXCODE) wchar_t * {
+ string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
+ return ret;
+ }
+%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{
+ set {
+ $imcall;$excode
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
+ get {
+ string ret = $imcall;$excode
+ return ret;
+ } %}
+
+%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %}
+%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %}
+
+%typemap(typecheck) wchar_t * = char *;
+
From c9ede7e62278085ce4560f8ff1ff227d11e6d4a6 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 13 Oct 2010 05:48:59 +0000
Subject: [PATCH 0088/1045] Fix unary scope operator (::) (global scope)
regression introduced in 2.0.0. The mangled symbol names were incorrect,
sometimes resulting in types being incorrectly treated as opaque types.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12264 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++
Examples/test-suite/global_namespace.i | 22 ++++++++++
.../java/global_namespace_runme.java | 34 +++++++++++++++-
.../python/global_namespace_runme.py | 40 +++++++++++++++++++
Source/Swig/stype.c | 11 ++---
5 files changed, 104 insertions(+), 7 deletions(-)
create mode 100644 Examples/test-suite/python/global_namespace_runme.py
diff --git a/CHANGES.current b/CHANGES.current
index 26977a25d..2a9de5cf1 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,3 +5,7 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.2 (in progress)
===========================
+2010-10-12: wsfulton
+ Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
+ Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
+ incorrectly treated as opaque types.
diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i
index 7b575614f..37195c76b 100644
--- a/Examples/test-suite/global_namespace.i
+++ b/Examples/test-suite/global_namespace.i
@@ -58,3 +58,25 @@ struct TheEnumMethods {
}
%}
+%inline %{
+Klass1 getKlass1A() { return ::Klass1(); }
+::Klass1 getKlass1B() { return ::Klass1(); }
+
+Klass2 getKlass2A() { return ::Klass2(); }
+::Klass2 getKlass2B() { return ::Klass2(); }
+
+Klass3 getKlass3A() { return ::Klass3(); }
+::Klass3 getKlass3B() { return ::Klass3(); }
+
+Klass4 getKlass4A() { return ::Klass4(); }
+::Klass4 getKlass4B() { return ::Klass4(); }
+
+Klass5 getKlass5A() { return ::Klass5(); }
+::Klass5 getKlass5B() { return ::Klass5(); }
+
+Klass6 getKlass6A() { return ::Klass6(); }
+::Klass6 getKlass6B() { return ::Klass6(); }
+
+Klass7 getKlass7A() { return ::Klass7(); }
+::Klass7 getKlass7B() { return ::Klass7(); }
+%}
diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java
index faab7d4ba..205e149b0 100644
--- a/Examples/test-suite/java/global_namespace_runme.java
+++ b/Examples/test-suite/java/global_namespace_runme.java
@@ -13,8 +13,38 @@ public class global_namespace_runme {
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());
+ Klass1 k1 = new Klass1();
+ Klass2 k2 = new Klass2();
+ Klass3 k3 = new Klass3();
+ Klass4 k4 = new Klass4();
+ Klass5 k5 = new Klass5();
+ Klass6 k6 = new Klass6();
+ Klass7 k7 = new Klass7();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
+
+ k1 = global_namespace.getKlass1A();
+ k2 = global_namespace.getKlass2A();
+ k3 = global_namespace.getKlass3A();
+ k4 = global_namespace.getKlass4A();
+ k5 = global_namespace.getKlass5A();
+ k6 = global_namespace.getKlass6A();
+ k7 = global_namespace.getKlass7A();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
+
+ k1 = global_namespace.getKlass1B();
+ k2 = global_namespace.getKlass2B();
+ k3 = global_namespace.getKlass3B();
+ k4 = global_namespace.getKlass4B();
+ k5 = global_namespace.getKlass5B();
+ k6 = global_namespace.getKlass6B();
+ k7 = global_namespace.getKlass7B();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
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());
diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py
new file mode 100644
index 000000000..b64e75ca1
--- /dev/null
+++ b/Examples/test-suite/python/global_namespace_runme.py
@@ -0,0 +1,40 @@
+from global_namespace import *
+
+k1 = Klass1()
+k2 = Klass2()
+k3 = Klass3()
+k4 = Klass4()
+k5 = Klass5()
+k6 = Klass6()
+k7 = Klass7()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+k1 = getKlass1A()
+k2 = getKlass2A()
+k3 = getKlass3A()
+k4 = getKlass4A()
+k5 = getKlass5A()
+k6 = getKlass6A()
+k7 = getKlass7A()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+k1 = getKlass1B()
+k2 = getKlass2B()
+k3 = getKlass3B()
+k4 = getKlass4B()
+k5 = getKlass5B()
+k6 = getKlass6B()
+k7 = getKlass7B()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+
+TheEnumMethods.methodA(theenum1, theenum2, theenum3)
+TheEnumMethods.methodA(theenum1, theenum2, theenum3)
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index dd2aea688..a13f87cfc 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -906,8 +906,9 @@ String *SwigType_manglestr_default(SwigType *s) {
String *result = 0;
String *base = 0;
SwigType *lt;
- SwigType *sr = SwigType_typedef_qualified(s);
- SwigType *ss = SwigType_typedef_resolve_all(sr);
+ SwigType *sr = SwigType_typedef_resolve_all(s);
+ SwigType *sq = SwigType_typedef_qualified(sr);
+ SwigType *ss = SwigType_remove_global_scope_prefix(sq);
s = ss;
@@ -917,7 +918,6 @@ String *SwigType_manglestr_default(SwigType *s) {
ss = ty;
s = ss;
}
- Delete(sr);
lt = SwigType_ltype(s);
result = SwigType_prefix(lt);
@@ -966,8 +966,9 @@ String *SwigType_manglestr_default(SwigType *s) {
Insert(result, 0, "_");
Delete(lt);
Delete(base);
- if (ss)
- Delete(ss);
+ Delete(ss);
+ Delete(sq);
+ Delete(sr);
return result;
}
From 9eaf5ba1be143ea16eb7bfc096122be3c7bead19 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Thu, 14 Oct 2010 05:13:09 +0000
Subject: [PATCH 0089/1045] [PHP] Allow compilation on non-conforming Microsoft
C++ compilers which don't accept: return function_returning_void(); Reported
by Frank Vanden Berghen on the SWIG mailing list.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12265 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 5 +++++
Source/Modules/php.cxx | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index 2a9de5cf1..5a7493206 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.2 (in progress)
===========================
+2010-10-14: olly
+ [PHP] Allow compilation on non-conforming Microsoft C++ compilers
+ which don't accept: return function_returning_void();
+ Reported by Frank Vanden Berghen on the SWIG mailing list.
+
2010-10-12: wsfulton
Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 89204d7bf..05f2082c2 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -666,7 +666,7 @@ public:
/* We have an extra 'this' parameter. */
SetFlag(n, "wrap:this");
}
- String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs);
+ String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs);
/* Generate a dispatch wrapper for all overloaded functions */
From 2453aee4e7345c28df8baca801b1f1c69b9810b5 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru
Date: Thu, 14 Oct 2010 12:43:15 +0000
Subject: [PATCH 0090/1045] 2010-10-14: Sylvestre Ledru Fails the
configure if cannot find a yacc implementation (like bison)
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12269 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
configure.in | 14 ++++++++++++++
2 files changed, 18 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index 5a7493206..a5f149421 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -14,3 +14,7 @@ Version 2.0.2 (in progress)
Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
incorrectly treated as opaque types.
+
+2010-10-14: Sylvestre Ledru
+ Fails the configure if cannot find a yacc implementation
+ (like bison)
diff --git a/configure.in b/configure.in
index 36337b41d..7f584e5d6 100644
--- a/configure.in
+++ b/configure.in
@@ -122,6 +122,20 @@ echo "Note : None of the following packages are required for users to compile an
echo ""
AC_PROG_YACC
+echo "YACC $YACC"
+if test -z "$YACC"; then
+ AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected.])
+fi
+# Actually, AC_PROG_YACC is lying. It sometimes put yacc into $YACC even it
+# hasn't been able to find it.
+# AC_CHECK_PROG(YACC_PRESENT, $YACC, AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)]) )
+
+AC_CHECK_PROG(yacc_present, $YACC, "yes","no")
+if test "x$yacc_present" != "xyes"; then
+ AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)])
+fi
+
+
AC_PROG_RANLIB
AC_CHECK_PROGS(AR, ar aal, ar)
AC_SUBST(AR)
From 98441fc6ad6d6097c98baf28b54c7059045806b6 Mon Sep 17 00:00:00 2001
From: Joseph Wang
Date: Sun, 17 Oct 2010 07:33:58 +0000
Subject: [PATCH 0091/1045] [R] Fix failure in overloaded functions which was
breaking QuantLib-SWIG
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12282 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Source/Modules/r.cxx | 14 +++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index a5f149421..65489354c 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.2 (in progress)
===========================
+2010-10-17: drjoe
+ [R] Fix failure in overloaded functions which was breaking
+ QuantLib-SWIG
+
2010-10-14: olly
[PHP] Allow compilation on non-conforming Microsoft C++ compilers
which don't accept: return function_returning_void();
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 749797c78..61cbcdd79 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -1603,6 +1603,16 @@ void R::dispatchFunction(Node *n) {
j == 0 ? "" : " && ",
j+1);
}
+ else if (DohStrcmp(tm,"integer")==0) {
+ Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
+ j == 0 ? "" : " && ",
+ j+1, j+1);
+ }
+ else if (DohStrcmp(tm,"character")==0) {
+ Printf(f->code, "%sis.character(argv[[%d]])",
+ j == 0 ? "" : " && ",
+ j+1);
+ }
else {
Printf(f->code, "%sextends(argtypes[%d], '%s')",
j == 0 ? "" : " && ",
@@ -1617,7 +1627,9 @@ void R::dispatchFunction(Node *n) {
}
}
if (cur_args != -1) {
- Printv(f->code, "}", NIL);
+ Printf(f->code, "} else {\n"
+ "stop(\"cannot find overloaded function for %s\");\n"
+ "}", sfname);
}
Printv(f->code, ";\nf(...)", NIL);
Printv(f->code, ";\n}", NIL);
From f77ccd81d5c0b09ba0d99833e60945edf381f2f5 Mon Sep 17 00:00:00 2001
From: Joseph Wang
Date: Sun, 17 Oct 2010 09:35:34 +0000
Subject: [PATCH 0092/1045] [R] Improve error message for missing argtypes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12283 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/r.cxx | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 61cbcdd79..8eb784c68 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -1628,7 +1628,8 @@ void R::dispatchFunction(Node *n) {
}
if (cur_args != -1) {
Printf(f->code, "} else {\n"
- "stop(\"cannot find overloaded function for %s\");\n"
+ "stop(\"cannot find overloaded function for %s with argtypes (\","
+ "toString(argtypes),\")\");\n"
"}", sfname);
}
Printv(f->code, ";\nf(...)", NIL);
From 383230d734280c8cbd8ca159d30fe5677134883d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 18 Oct 2010 18:59:57 +0000
Subject: [PATCH 0093/1045] minor clarification about %{ %} blocks
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12284 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Introduction.html | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 3bac9484e..24579d946 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -195,9 +195,9 @@ extern int my_mod(int n, int m);
The interface file contains ANSI C function prototypes and variable
declarations. The %module directive defines the name of the
-module that will be created by SWIG. The %{,%} block
-provides a location for inserting additional code such as C header
-files or additional C declarations.
+module that will be created by SWIG. The %{ %} block
+provides a location for inserting additional code, such as C header
+files or additional C declarations, into the generated C wrapper code.
2.3.2 The swig command
From 28e277f8c59322fd1041bb3cc68c5ed779bff407 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Tue, 19 Oct 2010 06:31:31 +0000
Subject: [PATCH 0094/1045] Fix typo "the the" -> "the"
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12285 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/octave/octcontainer.swg | 3 +--
Lib/python/pycontainer.swg | 3 +--
Lib/ruby/rubycontainer.swg | 3 +--
Source/Swig/cwrap.c | 2 +-
Source/Swig/stype.c | 2 +-
5 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 6613fcfff..4f14ccef1 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -4,8 +4,7 @@
* Octave cell <-> C++ container wrapper
*
* This wrapper, and its iterator, allows a general use (and reuse) of
- * the the mapping between C++ and Octave, thanks to the C++
- * templates.
+ * the mapping between C++ and Octave, thanks to the C++ templates.
*
* Of course, it needs the C++ compiler to support templates, but
* since we will use this wrapper with the STL containers, that should
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index efca86cf1..40506e15b 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -4,8 +4,7 @@
* Python sequence <-> C++ container wrapper
*
* This wrapper, and its iterator, allows a general use (and reuse) of
- * the the mapping between C++ and Python, thanks to the C++
- * templates.
+ * the mapping between C++ and Python, thanks to the C++ templates.
*
* Of course, it needs the C++ compiler to support templates, but
* since we will use this wrapper with the STL containers, that should
diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
index fa4b619f9..f643e84b3 100644
--- a/Lib/ruby/rubycontainer.swg
+++ b/Lib/ruby/rubycontainer.swg
@@ -4,8 +4,7 @@
* Ruby sequence <-> C++ container wrapper
*
* This wrapper, and its iterator, allows a general use (and reuse) of
- * the the mapping between C++ and Ruby, thanks to the C++
- * templates.
+ * the mapping between C++ and Ruby, thanks to the C++ templates.
*
* Of course, it needs the C++ compiler to support templates, but
* since we will use this wrapper with the STL containers, that should
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index 799d434a6..28401f89f 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -216,7 +216,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
SwigType_del_reference(tvalue);
tycode = SwigType_type(tvalue);
if (tycode != T_USER) {
- /* plain primitive type, we copy the the def value */
+ /* plain primitive type, we copy the def value */
String *lstr = SwigType_lstr(tvalue, defname);
defvalue = NewStringf("%s = %s", lstr, qvalue);
Delete(lstr);
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index a13f87cfc..742b6232a 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -366,7 +366,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
* SwigType_default_create() before calling this function.
*
* Example deductions (matching the examples described in SwigType_default_create),
- * where the the most specialized matches are highest in the list:
+ * where the most specialized matches are highest in the list:
*
* a(ANY).a(ANY).SWIGTYPE
* a(ANY).a().SWIGTYPE
From 43794d90cdcaa6a4c477ef331c37e3076951c800 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru
Date: Fri, 29 Oct 2010 10:22:03 +0000
Subject: [PATCH 0095/1045] Revert of commit 12269 see:
http://sourceforge.net/mailarchive/forum.php?thread_name=4CC08FAA.5050009%40fultondesigns.co.uk&forum_name=swig-devel
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12286 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ----
configure.in | 14 --------------
2 files changed, 18 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 65489354c..ebfb2cb81 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -18,7 +18,3 @@ Version 2.0.2 (in progress)
Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
incorrectly treated as opaque types.
-
-2010-10-14: Sylvestre Ledru
- Fails the configure if cannot find a yacc implementation
- (like bison)
diff --git a/configure.in b/configure.in
index 7f584e5d6..36337b41d 100644
--- a/configure.in
+++ b/configure.in
@@ -122,20 +122,6 @@ echo "Note : None of the following packages are required for users to compile an
echo ""
AC_PROG_YACC
-echo "YACC $YACC"
-if test -z "$YACC"; then
- AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected.])
-fi
-# Actually, AC_PROG_YACC is lying. It sometimes put yacc into $YACC even it
-# hasn't been able to find it.
-# AC_CHECK_PROG(YACC_PRESENT, $YACC, AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)]) )
-
-AC_CHECK_PROG(yacc_present, $YACC, "yes","no")
-if test "x$yacc_present" != "xyes"; then
- AC_MSG_ERROR([No implementation of Yacc (bison, yacc) detected. Please install it (package bison)])
-fi
-
-
AC_PROG_RANLIB
AC_CHECK_PROGS(AR, ar aal, ar)
AC_SUBST(AR)
From 77b87aa9196c226b8625218b8608b5696b335d06 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 11 Nov 2010 19:30:44 +0000
Subject: [PATCH 0096/1045] typo fix in help message
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12288 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/python.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index 80f2e68df..6d5f500a4 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -130,7 +130,7 @@ static const char *usage2 = (char *) "\
-nofastproxy - Use traditional proxy mechanism for member methods (default) \n\
-nofastquery - Use traditional query mechanism for types (default) \n\
-noh - Don't generate the output header file\n\
- -nomodern - Don't use modern python features which are not back compatible \n\
+ -nomodern - Don't use modern python features which are not backwards compatible \n\
-nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n";
static const char *usage3 = (char *) "\
-noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\
From 580f2549582602399553fded9e12bca6f9746143 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Fri, 12 Nov 2010 16:43:03 +0000
Subject: [PATCH 0097/1045] Update for recent runtime name changes (a better
mechanism is clearly needed here).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12290 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/go/cdata.i | 4 ++--
Lib/go/goruntime.swg | 12 ++++++------
Source/Modules/go.cxx | 6 +++---
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i
index decf297c1..6cfdffea1 100644
--- a/Lib/go/cdata.i
+++ b/Lib/go/cdata.i
@@ -59,8 +59,8 @@ void _swig_gc_makegobyteslice(void *a, int32 n) {
cgocallback(·_swig_internal_makegobyteslice, a, n);
}
void ·_swig_allocategobyteslice(byte *data, int32 len, swigcdata ret) {
- ret.data = mal(len);
- mcpy(ret.data, data, len);
+ ret.data = runtime·mal(len);
+ runtime·mcpy(ret.data, data, len);
ret.len = len;
FLUSH(&ret);
}
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index 057f81d01..6cde68f55 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -109,23 +109,23 @@ static void _swig_gopanic(const char *p) {
extern void ·_swig_internal_allocate(void);
#pragma dynexport _swig_gc_allocate _swig_gc_allocate
void _swig_gc_allocate(void *a, int32 n) {
- cgocallback(·_swig_internal_allocate, a, n);
+ runtime·cgocallback(·_swig_internal_allocate, a, n);
}
void ·_swig_allocatememory(int32 len, byte *ret) {
- ret = mal(len);
+ ret = runtime·mal(len);
FLUSH(&ret);
}
extern void ·_swig_internal_makegostring(void);
#pragma dynexport _swig_gc_makegostring _swig_gc_makegostring
void _swig_gc_makegostring(void *a, int32 n) {
- cgocallback(·_swig_internal_makegostring, a, n);
+ runtime·cgocallback(·_swig_internal_makegostring, a, n);
}
void ·_swig_allocatestring(byte *p, int32 l, String ret) {
- ret.str = mal(l+1);
- mcpy(ret.str, p, l);
+ ret.str = runtime·mal(l+1);
+ runtime·mcpy(ret.str, p, l);
ret.len = l;
FLUSH(&ret);
}
@@ -133,7 +133,7 @@ void ·_swig_allocatestring(byte *p, int32 l, String ret) {
extern void ·_swig_internal_gopanic(void);
#pragma dynexport _swig_gc_gopanic _swig_gc_gopanic
void _swig_gc_gopanic(void *a, int32 n) {
- cgocallback(·_swig_internal_gopanic, a, n);
+ runtime·cgocallback(·_swig_internal_gopanic, a, n);
}
%}
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index 4b1d05b92..d3de53f8f 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -1068,7 +1068,7 @@ private:
Delete(parm_size);
Printv(f->code, "{\n", NULL);
- Printv(f->code, "\tcgocall(", wname, ", &p);\n", NULL);
+ Printv(f->code, "\truntime\xc2\xb7" "cgocall(", wname, ", &p);\n", NULL);
Printv(f->code, "}\n", NULL);
Printv(f->code, "\n", NULL);
@@ -2749,7 +2749,7 @@ private:
Printv(f_gc_wrappers, "void\n", NULL);
Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL);
Printv(f_gc_wrappers, "{\n", NULL);
- Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL);
+ Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL);
Printv(f_gc_wrappers, "}\n\n", NULL);
} else {
Printv(f_c_directors, " ", wname, "(go_val);\n", NULL);
@@ -3475,7 +3475,7 @@ private:
Printv(f_gc_wrappers, "void\n", NULL);
Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL);
Printv(f_gc_wrappers, "{\n", NULL);
- Printv(f_gc_wrappers, "\tcgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL);
+ Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL);
Printv(f_gc_wrappers, "}\n\n", NULL);
} else {
if (SwigType_type(result) != T_VOID) {
From e30befd13806fb89c1591c56a7a66a5c24d1a14e Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Nov 2010 14:08:50 +0000
Subject: [PATCH 0098/1045] Correct explanation of how to match on class name
in %rename.
Replace incorrect documentation of $parentNode from %rename discussion: it
advised using match$parentNode but this doesn't work because the parent node
is not yet set when %rename is parsed.
Document the "fullname" attribute of %rename which can be used to restrict the
match to the given full name of a declaration only.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12291 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 24 ++++++++----------------
1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index e51e55986..b8e3e2260 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -2002,22 +2002,6 @@ documentation is not exhaustive, see "%rename predicates" section of
swig.swg for the full list of supported match expressions.
-
-Another important feature of match is that it can be applied not
-only to the declaration itself but also to its enclosing declaration. So
-match$parentNode$name="SomeClass" would be true only for members of
-the C++ class with the specified name. This can, of course, be combined with
-more complicated matches making it possible to write
-
-to rename all enums nested in the given class to lower case.
-
-
In addition to literally matching some string with match you can
also use regexmatch or notregexmatch to match a string
@@ -2039,6 +2023,14 @@ declaration name directly can be preferable and can also be done using
%rename("$ignore", regextarget=1) "Old$";
+Notice that the check is done only against the name of the declaration
+itself, if you need to match the full name of a C++ declaration you
+must use fullname attribute:
+
As for notregexmatch, it restricts the match only to the strings not
From 953c4abacaad7c8cab4eb5c5f87e5164c7e414c8 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Nov 2010 14:09:09 +0000
Subject: [PATCH 0099/1045] Use rename list and not hash for renames with
regextarget attribute.
Renames which are regular expressions can't be put in the regex hash as they
don't literally match the real declarations names. Instead, put them in the
rename list against which we will match the declarations names later.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12292 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Swig/naming.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 5bf42f7cc..70744586c 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1110,7 +1110,7 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
}
if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */
- Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist")) {
+ Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
if (decl)
Setattr(nameobj, "decl", decl);
if (nname && Len(nname))
From f6cab0170abdb69b1ac562b223d101bf55e5700f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Nov 2010 14:09:39 +0000
Subject: [PATCH 0100/1045] Ignore non-matching regex renames when searching
renames list.
Skip over %renames with non-matching %(regex)s expansion when looking for the
one to apply to the given name. This allows to have multiple anonymous renames
using regex as now the first _matching_ one will be used instead of always
using the first one and ignoring all the rest of them.
Extend unit tests to verify that applying two anonymous %renames does work as
expected.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12293 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 10 ++++++++++
.../test-suite/csharp/rename_pcre_encoder_runme.cs | 12 ++++++++++++
.../test-suite/java/rename_pcre_encoder_runme.java | 14 ++++++++++++++
.../test-suite/python/rename_pcre_encoder_runme.py | 3 +++
Examples/test-suite/rename_pcre_encoder.i | 9 +++++++--
Source/Swig/naming.c | 8 +++++++-
6 files changed, 53 insertions(+), 3 deletions(-)
create mode 100644 Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
create mode 100644 Examples/test-suite/java/rename_pcre_encoder_runme.java
diff --git a/CHANGES.current b/CHANGES.current
index ebfb2cb81..f18011e1a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,16 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.2 (in progress)
===========================
+2010-11-12: vadz
+ Fix handling of multiple regex-using %renames attached to the same
+ declaration. For example, now
+
+ %rename("%(regex/^Set(.*)/put\\1/)s") "";
+ %rename("%(regex/^Get(.*)/get\\1/)s") "";
+
+ works as expected whereas before only the last anonymous rename was
+ taken into account.
+
2010-10-17: drjoe
[R] Fix failure in overloaded functions which was breaking
QuantLib-SWIG
diff --git a/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
new file mode 100644
index 000000000..f6289e7e2
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
@@ -0,0 +1,12 @@
+using System;
+using rename_pcre_encoderNamespace;
+
+public class runme {
+ static void Main() {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new Exception(String.Format("Border with should be 17, not {0}",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/java/rename_pcre_encoder_runme.java b/Examples/test-suite/java/rename_pcre_encoder_runme.java
new file mode 100644
index 000000000..cb843338b
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_encoder_runme.java
@@ -0,0 +1,14 @@
+import rename_pcre_encoder.*;
+
+public class rename_pcre_encoder_runme {
+ static { System.loadLibrary("rename_pcre_encoder"); }
+
+ public static void main(String argv[])
+ {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new RuntimeException(String.format("Border with should be 17, not %d",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py
index ed7ca48b1..1186703a0 100644
--- a/Examples/test-suite/python/rename_pcre_encoder_runme.py
+++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py
@@ -2,6 +2,9 @@ from rename_pcre_encoder import *
s = SomeWidget()
s.putBorderWidth(3)
+if s.getBorderWidth() != 3:
+ raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),))
+
s.putSize(4, 5)
a = AnotherWidget()
a.DoSomething()
diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i
index c90af164d..66f30c7bc 100644
--- a/Examples/test-suite/rename_pcre_encoder.i
+++ b/Examples/test-suite/rename_pcre_encoder.i
@@ -3,14 +3,19 @@
// strip the wx prefix from all identifiers except those starting with wxEVT
%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") "";
-// Replace "Set" prefix with "put" in all functions
+// Replace "Set" and "Get" prefixes with "put" and "get" respectively.
%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) "";
+%rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) "";
%inline %{
struct wxSomeWidget {
- void SetBorderWidth(int) {}
+ void SetBorderWidth(int width) { m_width = width; }
+ int GetBorderWidth() const { return m_width; }
+
void SetSize(int, int) {}
+
+ int m_width;
};
struct wxAnotherWidget {
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 70744586c..6beecc130 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1302,7 +1302,13 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
: Swig_name_match_value(tname, sname);
Delete(sname);
} else {
- match = 1;
+ /* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
+ String *sname = NewStringf(Getattr(rn, "name"), name);
+ if (sname) {
+ if (Len(sname))
+ match = 1;
+ Delete(sname);
+ }
}
}
if (match) {
From ee1c2f3ef086080a54cf5aec99f8b46e3f4d910d Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Thu, 18 Nov 2010 00:15:13 +0000
Subject: [PATCH 0101/1045] Renamed 'immutable' test-case to
'immutable_values'.
This is a part of the pending merge of the D module, where 'immutable' is a keyword (and thus not a valid module name).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12294 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/common.mk | 2 +-
Examples/test-suite/{immutable.i => immutable_values.i} | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
rename Examples/test-suite/{immutable.i => immutable_values.i} (90%)
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 026612db5..05d2f80c8 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -466,7 +466,7 @@ C_TEST_CASES += \
extern_declaration \
funcptr \
function_typedef \
- immutable \
+ immutable_values \
inctest \
integers \
keyword_rename \
diff --git a/Examples/test-suite/immutable.i b/Examples/test-suite/immutable_values.i
similarity index 90%
rename from Examples/test-suite/immutable.i
rename to Examples/test-suite/immutable_values.i
index ff5081e9c..1c1978661 100644
--- a/Examples/test-suite/immutable.i
+++ b/Examples/test-suite/immutable_values.i
@@ -1,6 +1,6 @@
// test to make sure setters are not generated for constants
-%module immutable
+%module immutable_values
%immutable;
From 0fb77ce2068128e02217cdddd6a388e6c6d30d9f Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Thu, 18 Nov 2010 00:15:41 +0000
Subject: [PATCH 0102/1045] Renamed 'template' test-case to 'template_basic'.
This is a part of the pending merge of the D module, where 'template' is a keyword (and thus not a valid module name).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12295 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/common.mk | 2 +-
Examples/test-suite/{template.i => template_basic.i} | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
rename Examples/test-suite/{template.i => template_basic.i} (89%)
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 05d2f80c8..f0fe4af1c 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -318,11 +318,11 @@ CPP_TEST_CASES += \
struct_initialization_cpp \
struct_value \
symbol_clash \
- template \
template_arg_replace \
template_arg_scope \
template_arg_typename \
template_array_numeric \
+ template_basic \
template_base_template \
template_classes \
template_const_ref \
diff --git a/Examples/test-suite/template.i b/Examples/test-suite/template_basic.i
similarity index 89%
rename from Examples/test-suite/template.i
rename to Examples/test-suite/template_basic.i
index d2c7a91ed..570392bf6 100644
--- a/Examples/test-suite/template.i
+++ b/Examples/test-suite/template_basic.i
@@ -1,5 +1,5 @@
-/* File : example.i */
-%module "template"
+/* File: template_basic.i */
+%module "template_basic"
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
@@ -31,7 +31,7 @@ template class vector {
void set(int index, T &val) {
v[index] = val;
}
- // This really doesn't do anything except test const handling
+ // This really doesn't do anything except test const handling
void testconst(const T x) { }
};
From 4d09774cefd745dc6a0e38db0a3ab320d79c992c Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Thu, 18 Nov 2010 00:16:02 +0000
Subject: [PATCH 0103/1045] Minor rename in the 'smart_pointer_templatemethods'
test-case to avoid special casing for D.
This is a part of the pending merge of the D module, where 'Object' is a keyword.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12296 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/smart_pointer_templatemethods.i | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/Examples/test-suite/smart_pointer_templatemethods.i b/Examples/test-suite/smart_pointer_templatemethods.i
index 7baa6386a..f79bbcc9d 100644
--- a/Examples/test-suite/smart_pointer_templatemethods.i
+++ b/Examples/test-suite/smart_pointer_templatemethods.i
@@ -1,4 +1,3 @@
-
%module smart_pointer_templatemethods
%inline %{
@@ -29,21 +28,21 @@ public:
void DisposeObjekt (void) {}
};
-class Object
+class Objct
{
public:
- Object () {}
- virtual ~Object () {}
+ Objct () {}
+ virtual ~Objct () {}
template Ptr QueryInterface (InterfaceId iid) const { return Ptr(); }
- void DisposeObject (void) {}
+ void DisposeObjct (void) {}
};
#ifdef SWIG
-%template(PtrObject) Ptr