From a615d8dd1d27bcd0df78c90c15fc8cce4290360e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 20 Jul 2010 22:58:37 +0000
Subject: 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.
--
cgit v1.2.1
From 1f939323a4e0700172db875ebd3ef9c9a7b4c33a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 16:59:08 +0000
Subject: 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)
--
cgit v1.2.1
From ac5ddb03150577ab5d7f53bde0c1aa801e975855 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 16:59:29 +0000
Subject: 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;
--
cgit v1.2.1
From f2a5ef0c57767d972edc583c66ef31cb32a53b1c Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 16:59:45 +0000
Subject: 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
--
cgit v1.2.1
From 6399502719dcc04c816536d7a4231e0164b4402f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:00:16 +0000
Subject: 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
--
cgit v1.2.1
From c4e9043288e2136dd7ae9e0515ad79164ad00d95 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:00:37 +0000
Subject: 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);
--
cgit v1.2.1
From 0b2561f300484470478849a3aa5e1cb9d91b3942 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:00:59 +0000
Subject: 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 +
.../test-suite/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 {
+};
+
+%}
--
cgit v1.2.1
From 409ae85a745a68615778b0b5029b3ef933412f81 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:01:16 +0000
Subject: 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
--
cgit v1.2.1
From 48a2e0bdea237f658507650e6b7233205385d72a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:01:36 +0000
Subject: 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 \
--
cgit v1.2.1
From 70c5bb5a47d7380cf5b5371a2b84ad04f330053a Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:02:10 +0000
Subject: 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 +
.../test-suite/csharp/rename_pcre_enum_runme.cs | 24 +++++++++
.../test-suite/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 */
--
cgit v1.2.1
From 587d8435211cddb1389733c462a7d1d02af17fea Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:02:35 +0000
Subject: 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])
--
cgit v1.2.1
From 89a7ab06856f3f0d7e879d6c3df9c6db85792d6b Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Thu, 22 Jul 2010 17:02:55 +0000
Subject: 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());
--
cgit v1.2.1
From d2ad66a9a9aec4ed7bf96af716a8f87a57eb7a45 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 07:17:15 +0000
Subject: 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
--
cgit v1.2.1
From f6346b3df1252b9745164d1759fab32e9e1cbea4 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 07:21:46 +0000
Subject: 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.
--
cgit v1.2.1
From c6c2c87e2ac9a9816ab056c1b90b1d9f119e0526 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 07:23:10 +0000
Subject: 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
--
cgit v1.2.1
From af96789c14eb45eb874996a603eb8a1eab960244 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 23 Jul 2010 19:34:17 +0000
Subject: 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
* ----------------------------------------------------------------------------- */
--
cgit v1.2.1
From 70b4d1231743911806b8a9625926187ce914560b Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 28 Jul 2010 05:53:17 +0000
Subject: 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 \
--
cgit v1.2.1
From 024ed6ce2a3191c57c5c030dd133bf0e9e2a1971 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Sat, 14 Aug 2010 14:12:23 +0000
Subject: 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);
--
cgit v1.2.1
From 9b097847158aea3429cdf555dd40961133bffb52 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Sat, 14 Aug 2010 14:12:39 +0000
Subject: 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
--
cgit v1.2.1
From 1c8618d6355f3d246dd7b7b986454672d1092430 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 Aug 2010 18:40:14 +0000
Subject: 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
--
cgit v1.2.1
From 8f8804b7a1b949786c6366494786efb14ea8713a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 17 Aug 2010 19:10:14 +0000
Subject: 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;
--
cgit v1.2.1
From 69af82caa4c0207cdc150f92cac1f0498ea91928 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 26 Aug 2010 18:06:02 +0000
Subject: 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 +
.../test-suite/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);
--
cgit v1.2.1
From 13d18e4c3f094f7464530d205faae71c2da47a86 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 26 Aug 2010 18:18:11 +0000
Subject: 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
--
cgit v1.2.1
From 5a6443ebcfaf0865b347d24704b3acb06b4f20d9 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 29 Aug 2010 22:11:03 +0000
Subject: 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
---
.../test-suite/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);
--
cgit v1.2.1
From 31b5f36b741f2eaaa44c52d0e21cd6598e8cc73f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 29 Aug 2010 23:32:49 +0000
Subject: 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;
}
--
cgit v1.2.1
From 41bc29c9f0b09247e34d9a3f6314975f0bd8d7e5 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 31 Aug 2010 06:02:10 +0000
Subject: 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
--
cgit v1.2.1
From aa728ece671c7e135d6d6dc7ab299dc6bfc78308 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 1 Sep 2010 21:06:10 +0000
Subject: 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
---
Examples/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);
--
cgit v1.2.1
From 1e6ed0843fdc303abffab1e117b062e6c26de4fa Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 1 Sep 2010 21:11:09 +0000
Subject: 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;
--
cgit v1.2.1
From a44f83cf0538c48c47ebae71545269fa0fa04a64 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 3 Sep 2010 06:03:48 +0000
Subject: 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)) {
--
cgit v1.2.1
From 45601f24b4209b1f00b6897a01afc3ecfcf07b40 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 3 Sep 2010 17:47:12 +0000
Subject: 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 ++++++++
.../test-suite/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);
--
cgit v1.2.1
From 197c8e899d8d3bf16bf696728cfe8edcd7829a8f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 3 Sep 2010 18:44:01 +0000
Subject: 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;
}
--
cgit v1.2.1
From 04c3e6b7d33663b8976251a6a6a48421c7227d19 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 17:30:18 +0000
Subject: 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
---
.../test-suite/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;
--
cgit v1.2.1
From b0609c3be210925c543633ec558cde312e3d2fc4 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 18:10:43 +0000
Subject: 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 +++++++++
Examples/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
+
--
cgit v1.2.1
From 46bd4a26c673babd36a551191c596cac300d8992 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 18:12:13 +0000
Subject: 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'.
--
cgit v1.2.1
From b2e2cb8f6607ae29ef78e59390aa05c4ab354440 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 6 Sep 2010 18:25:22 +0000
Subject: 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)
+
--
cgit v1.2.1
From 547019e0d457fe9427ff716737b8fdb82eab1cd8 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Wed, 8 Sep 2010 00:54:31 +0000
Subject: 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.
+
-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.
+
+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 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
--
cgit v1.2.1
From 8b31a92f6168b1bb1e17ca64aebbe6e29c5fc24a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 15 Sep 2010 22:26:34 +0000
Subject: 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
--
cgit v1.2.1
From b01277a19be53421d66f800c942e5b8663100a46 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 18 Sep 2010 01:14:21 +0000
Subject: 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();
--
cgit v1.2.1
From 6c094629cbd6df08a20c68656a487965b7072d30 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 20 Sep 2010 19:11:55 +0000
Subject: 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"));
}
--
cgit v1.2.1
From 1e051820ec601ca34bbd8abc4926193319708e3e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 21 Sep 2010 06:07:06 +0000
Subject: 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);
}
--
cgit v1.2.1
From ea9275ca08756f6cf886d6f083ee94eda3b57156 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 21 Sep 2010 18:09:20 +0000
Subject: 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
-
--
cgit v1.2.1
From 31af118c41b44a74244613b4eb8e54d06d5cee6a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 24 Sep 2010 22:13:13 +0000
Subject: 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 +
Examples/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 */
--
cgit v1.2.1
From e1ddf0ea3a778bf5bac48009004f2a4a7ac9d9ea Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 25 Sep 2010 17:08:13 +0000
Subject: 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);
--
cgit v1.2.1
From 5437d71d73569400cc2f544a7934f2c768efa8f5 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Mon, 27 Sep 2010 01:16:29 +0000
Subject: [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);
}
--
cgit v1.2.1
From 40e64b14f148b3d58dc13cca7df59a0193926e68 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 27 Sep 2010 05:40:14 +0000
Subject: 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
--
cgit v1.2.1
From 8a05a236124fc511d8559a37fa36d5aa96b9b818 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 28 Sep 2010 06:36:42 +0000
Subject: 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 {
--
cgit v1.2.1
From 5ff65533190a31afd5d5fdcf1c485c4ed3a3c376 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 28 Sep 2010 17:37:33 +0000
Subject: 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 %{
--
cgit v1.2.1
From 9f41fa27cb9eee42c0fc003139ce9a6fdc485031 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 28 Sep 2010 17:56:48 +0000
Subject: 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);
--
cgit v1.2.1
From 83f17b43ce2049cc1a36237d7930d0507c46cbc6 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 03:16:56 +0000
Subject: 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.
--
cgit v1.2.1
From c636855bcc31ae71e8303cbfad46466508707a1c Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 04:01:08 +0000
Subject: [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
--
cgit v1.2.1
From 045066e802dd3c56e0e3c6e91fb078ecc75a8d42 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 04:17:55 +0000
Subject: 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) {
--
cgit v1.2.1
From eaada32f264f828ec326f4c91f5c1a73399a8897 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Fri, 1 Oct 2010 04:42:29 +0000
Subject: [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" );
--
cgit v1.2.1
From db6bf51067db6beb701f4e9f5b25e14acf360c2d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 1 Oct 2010 22:46:22 +0000
Subject: 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).])
])
])
--
cgit v1.2.1
From 766ed8db375f47ef0ed4751bcd28eba31e40f3d7 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 1 Oct 2010 23:52:46 +0000
Subject: 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);
--
cgit v1.2.1
From 3219746776bb1bcb9f46f895c68040303f0d4b33 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 13:12:00 +0000
Subject: 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 +
.../java/smart_pointer_const_overload_runme.java | 99 +++++++++++++++++
.../python/smart_pointer_const_overload_runme.py | 123 +++++++++++++++++++++
Examples/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);
--
cgit v1.2.1
From 70c9dc5dcc532b104861962c170b2bf94ac2fd57 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 15:01:24 +0000
Subject: 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;
--
cgit v1.2.1
From 378ce60b495f2a8fba61cc5034ed072d434b2d55 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 15:08:03 +0000
Subject: 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 */
--
cgit v1.2.1
From 77a45b263102a22bb6d854760e8ecef32f956d1e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 16:42:22 +0000
Subject: 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;
}
--
cgit v1.2.1
From c7b4336a6cb9e22bd779c9cad7cd02839927343e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 16:47:30 +0000
Subject: 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() {}
};
%}
--
cgit v1.2.1
From 22dd2292cadd62b0e8d88fc89da584efcfceb5d2 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 16:58:51 +0000
Subject: 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;
--
cgit v1.2.1
From 61e9073e0777c7b2d35c9a1d4591058755ee9590 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 3 Oct 2010 20:47:45 +0000
Subject: 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() {
--
cgit v1.2.1
From 22a12bf08fab301446fe9bfeea6ada9a6a47570e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 05:34:54 +0000
Subject: 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.
--
cgit v1.2.1
From 2e28d85e5dd71cb75388ca6a93df459ac3db1105 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 05:36:49 +0000
Subject: 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
--
cgit v1.2.1
From 197b25147e120dc5403a2f948707e4362d463488 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 05:46:42 +0000
Subject: 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
--
cgit v1.2.1
From eff2a7f9e9f22b4c47a82a16386a4edc8b84e52e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 06:10:41 +0000
Subject: 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
--
cgit v1.2.1
From 13f861220a0dc8c12512f8bf82c07083b53812f6 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 06:15:53 +0000
Subject: 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
--
cgit v1.2.1
From 29b4dbdac1098bbdaf1500a3eb8fb677c0f99db5 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 06:16:21 +0000
Subject: 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
--
cgit v1.2.1
From 0d49656a54ebb80d488b1d60c702b10c857b3340 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 18:44:38 +0000
Subject: 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
--
cgit v1.2.1
From 2e4cff569953a1eefd4e47d80ca1b1e10afd643b Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 19:16:12 +0000
Subject: 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
--
cgit v1.2.1
From 9b3d2ec9b0c7a02b9e85058821cb820057544851 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 19:30:15 +0000
Subject: 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'.
--
cgit v1.2.1
From aabd75f3d83b365850e3c1c4fa77a471b2231914 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 4 Oct 2010 19:30:53 +0000
Subject: 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
--
cgit v1.2.1
From a56ee9cb1bcdea85480e2678aff97c14c9aa1856 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 5 Oct 2010 06:11:50 +0000
Subject: 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
--
cgit v1.2.1
From a4a56acd33cae770a6aacba0df72a6147b611aa1 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 7 Oct 2010 06:06:12 +0000
Subject: 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 *;
+
--
cgit v1.2.1
From c9ede7e62278085ce4560f8ff1ff227d11e6d4a6 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Wed, 13 Oct 2010 05:48:59 +0000
Subject: 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 ++++++++++++
.../test-suite/java/global_namespace_runme.java | 34 ++++++++++++++++--
.../test-suite/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;
}
--
cgit v1.2.1
From 9eaf5ba1be143ea16eb7bfc096122be3c7bead19 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Thu, 14 Oct 2010 05:13:09 +0000
Subject: [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 */
--
cgit v1.2.1
From 2453aee4e7345c28df8baca801b1f1c69b9810b5 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru
Date: Thu, 14 Oct 2010 12:43:15 +0000
Subject: 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)
--
cgit v1.2.1
From 98441fc6ad6d6097c98baf28b54c7059045806b6 Mon Sep 17 00:00:00 2001
From: Joseph Wang
Date: Sun, 17 Oct 2010 07:33:58 +0000
Subject: [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);
--
cgit v1.2.1
From f77ccd81d5c0b09ba0d99833e60945edf381f2f5 Mon Sep 17 00:00:00 2001
From: Joseph Wang
Date: Sun, 17 Oct 2010 09:35:34 +0000
Subject: [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);
--
cgit v1.2.1
From 383230d734280c8cbd8ca159d30fe5677134883d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 18 Oct 2010 18:59:57 +0000
Subject: 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
--
cgit v1.2.1
From 28e277f8c59322fd1041bb3cc68c5ed779bff407 Mon Sep 17 00:00:00 2001
From: Olly Betts
Date: Tue, 19 Oct 2010 06:31:31 +0000
Subject: 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
--
cgit v1.2.1
From 43794d90cdcaa6a4c477ef331c37e3076951c800 Mon Sep 17 00:00:00 2001
From: Sylvestre Ledru
Date: Fri, 29 Oct 2010 10:22:03 +0000
Subject: 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)
--
cgit v1.2.1
From 77b87aa9196c226b8625218b8608b5696b335d06 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 11 Nov 2010 19:30:44 +0000
Subject: 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\
--
cgit v1.2.1
From 580f2549582602399553fded9e12bca6f9746143 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Fri, 12 Nov 2010 16:43:03 +0000
Subject: 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) {
--
cgit v1.2.1
From e30befd13806fb89c1591c56a7a66a5c24d1a14e Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Nov 2010 14:08:50 +0000
Subject: 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
--
cgit v1.2.1
From 953c4abacaad7c8cab4eb5c5f87e5164c7e414c8 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Nov 2010 14:09:09 +0000
Subject: 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))
--
cgit v1.2.1
From f6cab0170abdb69b1ac562b223d101bf55e5700f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin
Date: Tue, 16 Nov 2010 14:09:39 +0000
Subject: 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 ++++++++++
Examples/test-suite/csharp/rename_pcre_encoder_runme.cs | 12 ++++++++++++
Examples/test-suite/java/rename_pcre_encoder_runme.java | 14 ++++++++++++++
Examples/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) {
--
cgit v1.2.1
From ee1c2f3ef086080a54cf5aec99f8b46e3f4d910d Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Thu, 18 Nov 2010 00:15:13 +0000
Subject: 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 | 20 --------------------
Examples/test-suite/immutable_values.i | 20 ++++++++++++++++++++
3 files changed, 21 insertions(+), 21 deletions(-)
delete mode 100644 Examples/test-suite/immutable.i
create mode 100644 Examples/test-suite/immutable_values.i
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.i
deleted file mode 100644
index ff5081e9c..000000000
--- a/Examples/test-suite/immutable.i
+++ /dev/null
@@ -1,20 +0,0 @@
-// test to make sure setters are not generated for constants
-
-%module immutable
-
-
-%immutable;
-%mutable;
-
-%inline %{
-#define ABC -11
-enum count {Zero, One, Two}; %}
-
-
-%clearimmutable;
-
-%inline %{
-#define XYZ -22
-enum backwards {Tre=3, Duo=2, Uno=1};
-%}
-
diff --git a/Examples/test-suite/immutable_values.i b/Examples/test-suite/immutable_values.i
new file mode 100644
index 000000000..1c1978661
--- /dev/null
+++ b/Examples/test-suite/immutable_values.i
@@ -0,0 +1,20 @@
+// test to make sure setters are not generated for constants
+
+%module immutable_values
+
+
+%immutable;
+%mutable;
+
+%inline %{
+#define ABC -11
+enum count {Zero, One, Two}; %}
+
+
+%clearimmutable;
+
+%inline %{
+#define XYZ -22
+enum backwards {Tre=3, Duo=2, Uno=1};
+%}
+
--
cgit v1.2.1
From 0fb77ce2068128e02217cdddd6a388e6c6d30d9f Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Thu, 18 Nov 2010 00:15:41 +0000
Subject: 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 | 52 ------------------------------------
Examples/test-suite/template_basic.i | 52 ++++++++++++++++++++++++++++++++++++
3 files changed, 53 insertions(+), 53 deletions(-)
delete mode 100644 Examples/test-suite/template.i
create mode 100644 Examples/test-suite/template_basic.i
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.i
deleted file mode 100644
index d2c7a91ed..000000000
--- a/Examples/test-suite/template.i
+++ /dev/null
@@ -1,52 +0,0 @@
-/* File : example.i */
-%module "template"
-
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
-%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
-
-/* Let's just grab the original header file here */
-
-%{
-#ifdef max
-#undef max
-#endif
-%}
-
-%inline %{
-
-template T max(const T a, const T b) { return a>b ? a : b; }
-
-template class vector {
- T *v;
- int sz;
- public:
- vector(int _sz) {
- v = new T[_sz];
- sz = _sz;
- }
- T &get(int index) {
- return v[index];
- }
- void set(int index, T &val) {
- v[index] = val;
- }
- // This really doesn't do anything except test const handling
- void testconst(const T x) { }
-};
-
-%}
-
-/* Now instantiate some specific template declarations */
-
-%template(maxint) max;
-%template(maxdouble) max;
-%template(vecint) vector;
-%template(vecdouble) vector;
-
-/* Now try to break constness */
-
-%template(maxintp) max;
-%template(vecintp) vector;
-
-
diff --git a/Examples/test-suite/template_basic.i b/Examples/test-suite/template_basic.i
new file mode 100644
index 000000000..570392bf6
--- /dev/null
+++ b/Examples/test-suite/template_basic.i
@@ -0,0 +1,52 @@
+/* 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 */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector; /* Ruby, wrong class name */
+
+/* Let's just grab the original header file here */
+
+%{
+#ifdef max
+#undef max
+#endif
+%}
+
+%inline %{
+
+template T max(const T a, const T b) { return a>b ? a : b; }
+
+template class vector {
+ T *v;
+ int sz;
+ public:
+ vector(int _sz) {
+ v = new T[_sz];
+ sz = _sz;
+ }
+ T &get(int index) {
+ return v[index];
+ }
+ void set(int index, T &val) {
+ v[index] = val;
+ }
+ // This really doesn't do anything except test const handling
+ void testconst(const T x) { }
+};
+
+%}
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max;
+%template(maxdouble) max;
+%template(vecint) vector;
+%template(vecdouble) vector;
+
+/* Now try to break constness */
+
+%template(maxintp) max;
+%template(vecintp) vector;
+
+
--
cgit v1.2.1
From 4d09774cefd745dc6a0e38db0a3ab320d79c992c Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Thu, 18 Nov 2010 00:16:02 +0000
Subject: 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
-
36.10.8 Configuration files
+
37.10.8 Configuration files
@@ -3193,7 +3193,7 @@ politely displays the ignoring language message.
-
36.10.9 Runtime support
+
37.10.9 Runtime support
@@ -3202,7 +3202,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
36.10.10 Standard library files
+
37.10.10 Standard library files
@@ -3221,7 +3221,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
36.10.11 User examples
+
37.10.11 User examples
@@ -3250,7 +3250,7 @@ during this process, see the section on .
-
36.10.12 Test driven development and the test-suite
+
37.10.12 Test driven development and the test-suite
@@ -3309,7 +3309,7 @@ It is therefore essential that the runtime tests are written in a manner that di
but error/exception out with an error message on stderr on failure.
-
36.10.12.1 Running the test-suite
+
37.10.12.1 Running the test-suite
@@ -3495,7 +3495,7 @@ The syntax for setting environment variables varies from one shell to the next,
make ret_by_value.ctest SWIG_FEATURES="-debug-tmsearch"
-
36.10.13 Documentation
+
37.10.13 Documentation
@@ -3527,7 +3527,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
36.10.14 Prerequisites for adding a new language module to the SWIG distribution
+
37.10.14 Prerequisites for adding a new language module to the SWIG distribution
@@ -3584,7 +3584,7 @@ should be added should there be an area not already covered by
the existing tests.
-
36.10.15 Coding style guidelines
+
37.10.15 Coding style guidelines
@@ -3608,7 +3608,7 @@ The generated C/C++ code should also follow this style as close as possible. How
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
-
36.11 Debugging Options
+
37.11 Debugging Options
@@ -3635,7 +3635,7 @@ There are various command line options which can aid debugging a SWIG interface
The complete list of command line options for SWIG are available by running swig -help.
@@ -41,7 +41,7 @@ the Go programming language
see golang.org.
-
20.1 Overview
+
21.1 Overview
@@ -65,7 +65,7 @@ checking and runtime library are not used with Go. This should be
borne in mind when reading the rest of the SWIG documentation.
-
20.2 Running SWIG with Go
+
21.2 Running SWIG with Go
@@ -74,7 +74,7 @@ default SWIG will generate code for the gc compilers. To generate
code for gccgo, you should also use the -gccgo option.
-
20.2.1 Additional Commandline Options
+
21.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -go -help
-
20.2.2 Go Output Files
+
21.2.2 Go Output Files
When generating Go code, SWIG will generate the following
@@ -163,7 +163,7 @@ A typical command sequence would look like this:
% 6l main.6
-
20.3 A tour of basic C/C++ wrapping
+
21.3 A tour of basic C/C++ wrapping
@@ -173,7 +173,7 @@ modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
-
20.3.1 Go Package Name
+
21.3.1 Go Package Name
@@ -183,7 +183,7 @@ directive. You may override this by using SWIG's -package
command line option.
-
20.3.2 Go Names
+
21.3.2 Go Names
@@ -215,7 +215,7 @@ followed by that name, and the destructor will be
named Delete followed by that name.
-
20.3.3 Go Constants
+
21.3.3 Go Constants
@@ -223,7 +223,7 @@ C/C++ constants created via #define or the %constant
directive become Go constants, declared with a const
declaration.
-
20.3.4 Go Enumerations
+
21.3.4 Go Enumerations
@@ -233,7 +233,7 @@ usual). The values of the enumeration will become variables in Go;
code should avoid modifying those variables.
-
20.3.5 Go Classes
+
21.3.5 Go Classes
@@ -280,7 +280,7 @@ to reinterpret_cast. This should only be used for very
special cases, such as where C++ would use a dynamic_cast.
-
20.3.5.1 Go Class Inheritance
+
21.3.5.1 Go Class Inheritance
@@ -292,7 +292,7 @@ Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
-
20.3.6 Go Templates
+
21.3.6 Go Templates
@@ -300,7 +300,7 @@ In order to use C++ templates in Go, you must tell SWIG to create
wrappers for a particular template instantation. To do this, use
the %template directive.
-
20.3.7 Go Director Classes
+
21.3.7 Go Director Classes
@@ -343,7 +343,7 @@ method defined in Go. The Go code may of course call other methods on
itself, and those methods may be defined either in Go or in C++.
This section details guile-specific support in SWIG.
-
21.1 Meaning of "Module"
+
22.1 Meaning of "Module"
@@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined
separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
we explicitly prefix the context, e.g., "guile-module".
-
21.2 Using the SCM or GH Guile API
+
22.2 Using the SCM or GH Guile API
The guile module can currently export wrapper files that use the guile GH interface or the
@@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma
but there is no reason other languages (like mzscheme or chicken) couldn't also use this.
If that happens, there is A LOT less code duplication in the standard typemaps.
-
21.3 Linkage
+
22.3 Linkage
@@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness,
which manifests in multiple shared-library usage conventions. A set of
policies implementing a usage convention is called a linkage.
-
21.3.1 Simple Linkage
+
22.3.1 Simple Linkage
@@ -206,7 +206,7 @@ placed between the define-module form and the
SWIG_init via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
-
21.3.2 Passive Linkage
+
22.3.2 Passive Linkage
Passive linkage is just like simple linkage, but it generates an
@@ -216,7 +216,7 @@ package name (see below).
You should use passive linkage rather than simple linkage when you
are using multiple modules.
-
21.3.3 Native Guile Module Linkage
+
22.3.3 Native Guile Module Linkage
SWIG can also generate wrapper code that does all the Guile module
@@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:
-
21.3.4 Old Auto-Loading Guile Module Linkage
+
22.3.4 Old Auto-Loading Guile Module Linkage
Guile used to support an autoloading facility for object-code
@@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with
an appropriate name.
-
21.3.5 Hobbit4D Linkage
+
22.3.5 Hobbit4D Linkage
@@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
experimental; the (hobbit4d link) conventions are not well understood.
-
21.4 Underscore Folding
+
22.4 Underscore Folding
@@ -320,7 +320,7 @@ complained so far.
%rename to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-
21.5 Typemaps
+
22.5 Typemaps
@@ -412,7 +412,7 @@ constant will appear as a scheme variable. See
Features and the %feature directive
for info on how to apply the %feature.
-
21.6 Representation of pointers as smobs
+
22.6 Representation of pointers as smobs
@@ -433,7 +433,7 @@ representing the expected pointer type. See also
If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a wrong-type-arg exception is raised.
-
21.6.1 GH Smobs
+
22.6.1 GH Smobs
@@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct.
Once we have a swig_type_info structure, we loop through the linked list of
casts, using pointer comparisons.
-
21.6.2 SCM Smobs
+
22.6.2 SCM Smobs
The SCM interface (using the "-scm" argument to swig) uses swigrun.swg.
@@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra
GOOPS class.
-
21.6.3 Garbage Collection
+
22.6.3 Garbage Collection
Garbage collection is a feature of the new SCM interface, and it is automatically included
@@ -491,7 +491,7 @@ is exactly like described in 21.7 Exception Handling
+
22.7 Exception Handling
@@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
-
21.8 Procedure documentation
+
22.8 Procedure documentation
If invoked with the command-line option -procdoc
@@ -553,7 +553,7 @@ like this:
typemap argument doc. See Lib/guile/typemaps.i for
details.
-
21.9 Procedures with setters
+
22.9 Procedures with setters
For global variables, SWIG creates a single wrapper procedure
@@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get
pointer) and (struct-member-set pointer
value) are not generated.
-
21.10 GOOPS Proxy Classes
+
22.10 GOOPS Proxy Classes
SWIG can also generate classes and generic functions for use with
@@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th
%import "foo.h" before the %inline block.
-
21.10.1 Naming Issues
+
22.10.1 Naming Issues
As you can see in the example above, there are potential naming conflicts. The default exported
@@ -767,7 +767,7 @@ guile-modules. For example,
The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index d32a7fb9a..a27d9adbb 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -5,7 +5,7 @@
-
22 SWIG and Java
+
23 SWIG and Java
@@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less
-
22.1 Overview
+
23.1 Overview
@@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered.
The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.
-
22.2 Preliminaries
+
23.2 Preliminaries
@@ -205,7 +205,7 @@ Run make -k check from the SWIG root directory after installing SWIG on
The Java module requires your system to support shared libraries and dynamic loading.
This is the commonly used method to load JNI code so your system will more than likely support this.
-
22.2.1 Running SWIG
+
23.2.1 Running SWIG
@@ -264,7 +264,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
-
22.2.2 Additional Commandline Options
+
23.2.2 Additional Commandline Options
@@ -301,7 +301,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
-
22.2.3 Getting the right header files
+
23.2.3 Getting the right header files
@@ -316,7 +316,7 @@ They are usually in directories like this:
The exact location may vary on your machine, but the above locations are typical.
-
22.2.4 Compiling a dynamic module
+
23.2.4 Compiling a dynamic module
@@ -352,7 +352,7 @@ The name of the shared library output file is important.
If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information).
The name of the module is specified using the %module directive or -module command line option.
-
22.2.5 Using your module
+
23.2.5 Using your module
@@ -387,7 +387,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
-
22.2.6 Dynamic linking problems
+
23.2.6 Dynamic linking problems
@@ -474,7 +474,7 @@ The following section also contains some C++ specific linking problems and solut
-
22.2.7 Compilation problems and compiling with C++
+
23.2.7 Compilation problems and compiling with C++
@@ -527,7 +527,7 @@ Finally make sure the version of JDK header files matches the version of Java th
-
22.2.8 Building on Windows
+
23.2.8 Building on Windows
@@ -536,7 +536,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine.
This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers.
In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.
-
22.2.8.1 Running SWIG from Visual Studio
+
23.2.8.1 Running SWIG from Visual Studio
@@ -575,7 +575,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa
If the library fails to load have a look at Dynamic linking problems.
-
22.2.8.2 Using NMAKE
+
23.2.8.2 Using NMAKE
@@ -634,7 +634,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
-
22.3 A tour of basic C/C++ wrapping
+
23.3 A tour of basic C/C++ wrapping
@@ -644,7 +644,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
-
22.3.1 Modules, packages and generated Java classes
+
23.3.1 Modules, packages and generated Java classes
@@ -680,7 +680,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
SWIG won't create the directory, so make sure it exists beforehand.
@@ -941,7 +941,7 @@ Or if you decide this practice isn't so bad and your own class implements ex
-
22.3.5 Enumerations
+
23.3.5 Enumerations
@@ -955,7 +955,7 @@ The final two approaches use simple integers for each enum item.
Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.
-
22.3.5.1 Anonymous enums
+
23.3.5.1 Anonymous enums
@@ -1018,7 +1018,7 @@ As in the case of constants, you can access them through either the module class
-
22.3.5.2 Typesafe enums
+
23.3.5.2 Typesafe enums
@@ -1112,7 +1112,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit
The following section details proper Java enum generation.
@@ -1213,7 +1213,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff
Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.
-
22.3.5.5 Simple enums
+
23.3.5.5 Simple enums
@@ -1232,7 +1232,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach.
The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.
-
22.3.6 Pointers
+
23.3.6 Pointers
@@ -1320,7 +1320,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
a NULL pointer if the conversion can't be performed.
-
22.3.7 Structures
+
23.3.7 Structures
@@ -1488,7 +1488,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
-
22.3.8 C++ classes
+
23.3.8 C++ classes
@@ -1551,7 +1551,7 @@ int bar = Spam.getBar();
-
22.3.9 C++ inheritance
+
23.3.9 C++ inheritance
@@ -1612,7 +1612,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance
A warning is given when multiple inheritance is detected and only the first base class is used.
-
22.3.10 Pointers, references, arrays and pass by value
+
23.3.10 Pointers, references, arrays and pass by value
@@ -1667,7 +1667,7 @@ to hold the result and a pointer is returned (Java will release this memory
when the returned object's finalizer is run by the garbage collector).
-
22.3.10.1 Null pointers
+
23.3.10.1 Null pointers
@@ -1691,7 +1691,7 @@ For spam1 and spam4 above the Java null gets translat
The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.
22.4 Further details on the generated Java classes
+
23.4 Further details on the generated Java classes
@@ -2075,7 +2075,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
-
22.4.1 The intermediary JNI class
+
23.4.1 The intermediary JNI class
@@ -2195,7 +2195,7 @@ If name is the same as modulename then the module class name g
from modulename to modulenameModule.
-
22.4.1.1 The intermediary JNI class pragmas
+
23.4.1.1 The intermediary JNI class pragmas
@@ -2274,7 +2274,7 @@ For example, let's change the intermediary JNI class access to just the default
All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.
-
22.4.2 The Java module class
+
23.4.2 The Java module class
@@ -2305,7 +2305,7 @@ example.egg(new Foo());
The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.
@@ -3090,7 +3090,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
-
22.4.5 Enum classes
+
23.4.5 Enum classes
@@ -3099,7 +3099,7 @@ The Enumerations section discussed these but om
The following sub-sections detail the various types of enum classes that can be generated.
-
22.4.5.1 Typesafe enum classes
+
23.4.5.1 Typesafe enum classes
@@ -3183,7 +3183,7 @@ The swigValue method is used for marshalling in the other direction.
The toString method is overridden so that the enum name is available.
-
22.4.5.2 Proper Java enum classes
+
23.4.5.2 Proper Java enum classes
@@ -3261,7 +3261,7 @@ These needn't be generated if the enum being wrapped does not have any initializ
Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.
-
22.4.5.3 Type unsafe enum classes
+
23.4.5.3 Type unsafe enum classes
@@ -3292,7 +3292,7 @@ public final class Beverage {
-
22.5 Cross language polymorphism using directors
+
23.5 Cross language polymorphism using directors
@@ -3314,7 +3314,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens
Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.
-
22.5.1 Enabling directors
+
23.5.1 Enabling directors
@@ -3385,7 +3385,7 @@ public:
-
22.5.2 Director classes
+
23.5.2 Director classes
@@ -3412,7 +3412,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
-
22.5.3 Overhead and code bloat
+
23.5.3 Overhead and code bloat
@@ -3430,7 +3430,7 @@ This situation can be optimized by selectively enabling director methods (using
@@ -3515,7 +3515,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
-
22.6 Accessing protected members
+
23.6 Accessing protected members
@@ -3611,7 +3611,7 @@ class MyProtectedBase extends ProtectedBase
-
22.7 Common customization features
+
23.7 Common customization features
@@ -3623,7 +3623,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
-
22.7.1 C/C++ helper functions
+
23.7.1 C/C++ helper functions
@@ -3689,7 +3689,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps,
customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.
-
22.7.2 Class extension with %extend
+
23.7.2 Class extension with %extend
@@ -3752,7 +3752,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
-
22.7.3 Exception handling with %exception and %javaexception
+
23.7.3 Exception handling with %exception and %javaexception
@@ -3947,7 +3947,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
-
22.8.1 Input and output parameters using primitive pointers and references
+
23.8.1 Input and output parameters using primitive pointers and references
@@ -4121,7 +4121,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
22.8.2 Simple pointers
+
23.8.2 Simple pointers
@@ -4187,7 +4187,7 @@ System.out.println("3 + 4 = " + result);
See the SWIG Library chapter for further details.
-
22.8.3 Wrapping C arrays with Java arrays
+
23.8.3 Wrapping C arrays with Java arrays
@@ -4254,7 +4254,7 @@ Please be aware that the typemaps in this library are not efficient as all the e
There is an alternative approach using the SWIG array library and this is covered in the next section.
-
22.8.4 Unbounded C Arrays
+
23.8.4 Unbounded C Arrays
@@ -4399,7 +4399,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
22.8.5 Overriding new and delete to allocate from Java heap
+
23.8.5 Overriding new and delete to allocate from Java heap
@@ -4516,7 +4516,7 @@ model and use these functions in place of malloc and free in your own
code.
-
22.9 Java typemaps
+
23.9 Java typemaps
@@ -4537,7 +4537,7 @@ Before proceeding, it should be stressed that typemaps are not a required
part of using SWIG---the default wrapping behavior is enough in most cases.
Typemaps are only used if you want to change some aspect of the generated code.
-
22.9.1 Default primitive type mappings
+
23.9.1 Default primitive type mappings
@@ -4689,7 +4689,7 @@ However, the mappings allow the full range of values for each C type from Java.
-
22.9.2 Default typemaps for non-primitive types
+
23.9.2 Default typemaps for non-primitive types
@@ -4704,7 +4704,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit
The Java type is either the proxy class or type wrapper class.
-
22.9.3 Sixty four bit JVMs
+
23.9.3 Sixty four bit JVMs
@@ -4717,7 +4717,7 @@ Unfortunately it won't of course hold true for JNI code.
-
22.9.4 What is a typemap?
+
23.9.4 What is a typemap?
@@ -4840,7 +4840,7 @@ int c = example.count('e',"Hello World");
-
22.9.5 Typemaps for mapping C/C++ types to Java types
+
23.9.5 Typemaps for mapping C/C++ types to Java types
@@ -5100,7 +5100,7 @@ These are listed below:
-
22.9.6 Java typemap attributes
+
23.9.6 Java typemap attributes
@@ -5146,7 +5146,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes.
Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.
-
22.9.7 Java special variables
+
23.9.7 Java special variables
@@ -5297,7 +5297,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the %module directive.
-
22.9.8 Typemaps for both C and C++ compilation
+
23.9.8 Typemaps for both C and C++ compilation
@@ -5334,7 +5334,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
-
22.9.9 Java code typemaps
+
23.9.9 Java code typemaps
@@ -5540,7 +5540,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "java.swg", barring the method modifier for getCPtr.
-
22.9.10 Director specific typemaps
+
23.9.10 Director specific typemaps
@@ -5765,7 +5765,7 @@ The basic strategy here is to provide a default package typemap for the majority
-
22.10 Typemap Examples
+
23.10 Typemap Examples
@@ -5775,7 +5775,7 @@ the SWIG library.
-
22.10.1 Simpler Java enums for enums without initializers
+
23.10.1 Simpler Java enums for enums without initializers
@@ -5854,7 +5854,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
-
22.10.2 Handling C++ exception specifications as Java exceptions
+
23.10.2 Handling C++ exception specifications as Java exceptions
@@ -5979,7 +5979,7 @@ We could alternatively have used %rename to rename what() into
-
22.10.3 NaN Exception - exception handling for a particular type
+
23.10.3 NaN Exception - exception handling for a particular type
@@ -6134,7 +6134,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
-
22.10.4 Converting Java String arrays to char **
+
23.10.4 Converting Java String arrays to char **
@@ -6278,7 +6278,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
-
22.10.5 Expanding a Java object to multiple arguments
+
23.10.5 Expanding a Java object to multiple arguments
22.10.7 Adding Java downcasts to polymorphic return types
+
23.10.7 Adding Java downcasts to polymorphic return types
@@ -6684,7 +6684,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
-
22.10.8 Adding an equals method to the Java classes
+
23.10.8 Adding an equals method to the Java classes
22.10.9 Void pointers and a common Java base class
+
23.10.9 Void pointers and a common Java base class
@@ -6787,7 +6787,7 @@ This example contains some useful functionality which you may want in your code.
It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.
-
22.10.10 Struct pointer to pointer
+
23.10.10 Struct pointer to pointer
@@ -6967,7 +6967,7 @@ The C functional interface has been completely morphed into an object-oriented i
the Butler class would behave much like any pure Java class and feel more natural to Java users.
-
22.10.11 Memory management when returning references to member variables
+
23.10.11 Memory management when returning references to member variables
@@ -7090,7 +7090,7 @@ public class Bike {
Note the addReference call.
-
22.10.12 Memory management for objects passed to the C++ layer
+
23.10.12 Memory management for objects passed to the C++ layer
@@ -7206,7 +7206,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
-
22.10.13 Date marshalling using the javain typemap and associated attributes
+
23.10.13 Date marshalling using the javain typemap and associated attributes
@@ -7383,7 +7383,7 @@ A few things to note:
-
22.11 Living with Java Directors
+
23.11 Living with Java Directors
@@ -7564,10 +7564,10 @@ public abstract class UserVisibleFoo extends Foo {
-
22.12 Odds and ends
+
23.12 Odds and ends
-
22.12.1 JavaDoc comments
+
23.12.1 JavaDoc comments
@@ -7623,7 +7623,7 @@ public class Barmy {
-
22.12.2 Functional interface without proxy classes
+
23.12.2 Functional interface without proxy classes
@@ -7684,7 +7684,7 @@ All destructors have to be called manually for example the delete_Foo(foo)
-
22.12.3 Using your own JNI functions
+
23.12.3 Using your own JNI functions
@@ -7734,7 +7734,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
-
22.12.4 Performance concerns and hints
+
23.12.4 Performance concerns and hints
@@ -7755,7 +7755,7 @@ However, you will have to be careful about memory management and make sure that
This method normally calls the C++ destructor or free() for C code.
-
22.12.5 Debugging
+
23.12.5 Debugging
@@ -7777,7 +7777,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
@@ -77,7 +77,7 @@ swig -cffi -module module-namefile-name
files and the various things which you can do with them.
-
23.2.1 Additional Commandline Options
+
24.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -cffi -help
-
23.2.2 Generating CFFI bindings
+
24.2.2 Generating CFFI bindings
As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
-
23.2.3 Generating CFFI bindings for C++ code
+
24.2.3 Generating CFFI bindings for C++ code
This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
module feel free to contact us on the SWIG mailing list, and
also please add a "[CFFI]" tag in the subject line.
-
23.2.4 Inserting user code into generated files
+
24.2.4 Inserting user code into generated files
@@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for
-
23.3 CLISP
+
24.3 CLISP
@@ -638,7 +638,7 @@ swig -clisp -module module-namefile-name
interface file for the CLISP module. The CLISP module tries to
produce code which is both human readable and easily modifyable.
-
23.3.1 Additional Commandline Options
+
24.3.1 Additional Commandline Options
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
-
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org
-
24.1 Preliminaries
+
25.1 Preliminaries
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).
-
24.2 Running SWIG
+
25.2 Running SWIG
@@ -105,7 +105,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx
The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.
@@ -220,7 +220,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-
24.2.3 Using your module
+
25.2.3 Using your module
@@ -238,19 +238,19 @@ $ ./my_lua
>
-
24.3 A tour of basic C/C++ wrapping
+
25.3 A tour of basic C/C++ wrapping
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
-
24.3.1 Modules
+
25.3.1 Modules
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
-
24.3.2 Functions
+
25.3.2 Functions
@@ -288,7 +288,7 @@ It is also possible to rename the module with an assignment.
24
-
24.3.3 Global variables
+
25.3.3 Global variables
@@ -362,7 +362,7 @@ nil
3.142
-
24.3.4 Constants and enums
+
25.3.4 Constants and enums
@@ -385,7 +385,7 @@ example.SUNDAY=0
Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.
-
24.3.5 Pointers
+
25.3.5 Pointers
@@ -423,7 +423,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
-
24.3.6 Structures
+
25.3.6 Structures
@@ -509,7 +509,7 @@ Because the pointer points inside the structure, you can modify the contents and
> x.a = 3 -- Modifies the same structure
-
24.3.7 C++ classes
+
25.3.7 C++ classes
@@ -570,7 +570,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
-
24.3.8 C++ inheritance
+
25.3.8 C++ inheritance
@@ -595,7 +595,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-
24.3.9 Pointers, references, values, and arrays
+
25.3.9 Pointers, references, values, and arrays
@@ -626,7 +626,7 @@ Foo spam7();
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
-
24.3.10 C++ overloaded functions
+
25.3.10 C++ overloaded functions
@@ -712,7 +712,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
-
24.3.11 C++ operators
+
25.3.11 C++ operators
@@ -824,7 +824,7 @@ It is also possible to overload the operator[], but currently this cann
};
-
24.3.12 Class extension with %extend
+
25.3.12 Class extension with %extend
@@ -879,7 +879,7 @@ true
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
-
24.3.13 C++ templates
+
25.3.13 C++ templates
@@ -914,7 +914,7 @@ In Lua:
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
-
24.3.14 C++ Smart Pointers
+
25.3.14 C++ Smart Pointers
@@ -966,7 +966,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-
24.3.15 C++ Exceptions
+
25.3.15 C++ Exceptions
@@ -1110,12 +1110,12 @@ add exception specification to functions or globally (respectively).
-
24.4 Typemaps
+
25.4 Typemaps
This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect
-
24.4.1 What is a typemap?
+
25.4.1 What is a typemap?
A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:
@@ -1143,7 +1143,7 @@ Received an integer : 6
720
-
24.4.2 Using typemaps
+
25.4.2 Using typemaps
There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.
@@ -1196,7 +1196,7 @@ void swap(int *sx, int *sy);
Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).
-
24.4.3 Typemaps and arrays
+
25.4.3 Typemaps and arrays
Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
@@ -1260,7 +1260,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In
Note: SWIG also can support arrays of pointers in a similar manner.
-
24.4.4 Typemaps and pointer-pointer functions
+
25.4.4 Typemaps and pointer-pointer functions
Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:
@@ -1294,7 +1294,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
ptr=nil -- the iMath* will be GC'ed as normal
-
24.5 Writing typemaps
+
25.5 Writing typemaps
This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.
@@ -1303,7 +1303,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).
-
24.5.1 Typemaps you can write
+
25.5.1 Typemaps you can write
There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.
@@ -1316,7 +1316,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
(the syntax for the typecheck is different from the typemap, see typemaps for details).
-
24.5.2 SWIG's Lua-C API
+
25.5.2 SWIG's Lua-C API
This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.
@@ -1365,7 +1365,7 @@ This macro, when called within the context of a SWIG wrappered function, will di
Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
-
24.6 Customization of your Bindings
+
25.6 Customization of your Bindings
@@ -1374,7 +1374,7 @@ This section covers adding of some small extra bits to your module to add the la
-
24.6.1 Writing your own custom wrappers
+
25.6.1 Writing your own custom wrappers
@@ -1393,7 +1393,7 @@ int native_function(lua_State*L) // my native code
The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-
24.6.2 Adding additional Lua code
+
25.6.2 Adding additional Lua code
@@ -1431,7 +1431,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
-
24.7 Details on the Lua binding
+
25.7 Details on the Lua binding
@@ -1442,7 +1442,7 @@ See Examples/lua/arrays for an example of this code.
-
24.7.1 Binding global data into the module.
+
25.7.1 Binding global data into the module.
@@ -1502,7 +1502,7 @@ end
That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
-
24.7.2 Userdata and Metatables
+
25.7.2 Userdata and Metatables
@@ -1582,7 +1582,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
The Ocaml Website.
-
27.1 Preliminaries
+
28.1 Preliminaries
@@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
-
27.1.1 Running SWIG
+
28.1.1 Running SWIG
@@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or
the resulting .ml and .mli files as well, and do the final link with -custom
(not needed for native link).
-
27.1.2 Compiling the code
+
28.1.2 Compiling the code
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
-
27.1.3 The camlp4 module
+
28.1.3 The camlp4 module
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
-
27.1.4 Using your module
+
28.1.4 Using your module
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom
option is not needed when you build native code.
-
27.1.5 Compilation problems and compiling with C++
+
28.1.5 Compilation problems and compiling with C++
@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler.
Most code meant to be compiled as C++ will not have problems.
-
27.2 The low-level Ocaml/C interface
+
28.2 The low-level Ocaml/C interface
@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a
signature for a function that uses value in this way.
-
27.2.1 The generated module
+
28.2.1 The generated module
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
-
27.2.2 Enums
+
28.2.2 Enums
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
-
27.2.2.1 Enum typing in Ocaml
+
28.2.2.1 Enum typing in Ocaml
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master
values using the swig_val function before sharing them with another module.
-
27.2.3 Arrays
+
28.2.3 Arrays
-
27.2.3.1 Simple types of bounded arrays
+
28.2.3.1 Simple types of bounded arrays
@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works
for arrays whose bounds are completely specified.
-
27.2.3.2 Complex and unbounded arrays
+
28.2.3.2 Complex and unbounded arrays
@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array,
so you have to specify it for yourself in the form of a typemap.
-
27.2.3.3 Using an object
+
28.2.3.3 Using an object
@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex,
such as using a required sentinel, etc.
-
27.2.3.4 Example typemap for a function taking float * and int
+
28.2.3.4 Example typemap for a function taking float * and int
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
-
27.2.4 C++ Classes
+
28.2.4 C++ Classes
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
returned value for the same object.
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
containing the string "hi" in a button.
-
27.2.5 Director Classes
+
28.2.5 Director Classes
-
27.2.5.1 Director Introduction
+
28.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo {
};
-
27.2.5.2 Overriding Methods in Ocaml
+
28.2.5.2 Overriding Methods in Ocaml
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing
an overloaded class. This example is contained in Examples/ocaml/shapes.
-
27.2.5.3 Director Usage Example
+
28.2.5.3 Director Usage Example
@@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
program in C++.
-
27.2.5.4 Creating director objects
+
28.2.5.4 Creating director objects
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
-
27.2.5.5 Typemaps for directors, directorin, directorout, directorargout
+
28.2.5.5 Typemaps for directors, directorin, directorout, directorargout
@@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments,
and to receive arguments the same way you normally receive function returns.
-
27.2.5.6 directorin typemap
+
28.2.5.6 directorin typemap
@@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ
can use the same body as a simple out typemap.
-
27.2.5.7 directorout typemap
+
28.2.5.7 directorout typemap
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
-
27.2.5.8 directorargout typemap
+
28.2.5.8 directorargout typemap
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
The SWIG implemention was first based on Octave 2.9.12, so this is the minimum version required. Testing has only been done on Linux.
-
28.2 Running SWIG
+
29.2 Running SWIG
@@ -97,7 +97,7 @@ This creates a C++ source file example_wrap.cxx. A C++ file is generate
The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.
@@ -326,7 +326,7 @@ octave:2> f=example.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2
-
28.3.6 Structures and C++ classes
+
29.3.6 Structures and C++ classes
@@ -461,7 +461,7 @@ ans = 1
Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
-
28.3.7 C++ inheritance
+
29.3.7 C++ inheritance
@@ -470,7 +470,7 @@ This information contains the full class hierarchy. When an indexing operation (
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.
-
28.3.8 C++ overloaded functions
+
29.3.8 C++ overloaded functions
@@ -480,7 +480,7 @@ The dispatch function selects which overload to call (if any) based on the passe
typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
-
28.3.9 C++ operators
+
29.3.9 C++ operators
@@ -580,7 +580,7 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
-
C++ smart pointers are fully supported as in other modules.
-
28.3.13 Directors (calling Octave from C++ code)
+
29.3.13 Directors (calling Octave from C++ code)
@@ -774,14 +774,14 @@ c-side routine called
octave-side routine called
-
28.3.14 Threads
+
29.3.14 Threads
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
-
28.3.15 Memory management
+
29.3.15 Memory management
@@ -815,14 +815,14 @@ The %newobject directive may be used to control this behavior for pointers retur
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).
-
28.3.16 STL support
+
29.3.16 STL support
Various STL library files are provided for wrapping STL containers.
@@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions
may not compile or run correctly.
-
29.1 Overview
+
30.1 Overview
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
-
29.2 Preliminaries
+
30.2 Preliminaries
@@ -133,7 +133,7 @@ To build the module, you will need to compile the file
example_wrap.c and link it with the rest of your program.
-
29.2.1 Getting the right header files
+
30.2.1 Getting the right header files
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
-
29.2.2 Compiling a dynamic module
+
30.2.2 Compiling a dynamic module
@@ -198,7 +198,7 @@ the target should be named `example.so',
`example.sl', or the appropriate dynamic module name on your system.
-
29.2.3 Building a dynamic module with MakeMaker
+
30.2.3 Building a dynamic module with MakeMaker
@@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
and Randal Schwartz.
-
29.2.4 Building a static version of Perl
+
30.2.4 Building a static version of Perl
@@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with
additional libraries such as -lsocket, -lnsl, -ldl, etc.
-
29.2.5 Using the module
+
30.2.5 Using the module
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
29.2.6 Compilation problems and compiling with C++
+
30.2.6 Compilation problems and compiling with C++
@@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
any conflicting macros you find to swig-user mailing list.
-
29.2.7 Compiling for 64-bit platforms
+
30.2.7 Compiling for 64-bit platforms
@@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
29.3 Building Perl Extensions under Windows
+
30.3 Building Perl Extensions under Windows
@@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++
although the procedure may be similar with other compilers.
-
29.3.1 Running SWIG from Developer Studio
+
30.3.1 Running SWIG from Developer Studio
@@ -700,7 +700,7 @@ print "$a\n";
-
29.3.2 Using other compilers
+
30.3.2 Using other compilers
@@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
For general hints and suggestions refer to the Windows chapter.
-
29.4 The low-level interface
+
30.4 The low-level interface
@@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to
construct more user-friendly proxy classes as described in the next section.
-
29.4.1 Functions
+
30.4.1 Functions
@@ -741,7 +741,7 @@ use example;
$a = &example::fact(2);
-
29.4.2 Global variables
+
30.4.2 Global variables
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
-
29.4.3 Constants
+
30.4.3 Constants
@@ -851,7 +851,7 @@ print example::FOO,"\n";
-
29.4.4 Pointers
+
30.4.4 Pointers
@@ -960,7 +960,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the
SWIG and XS, this is no longer supported.
@@ -1159,7 +1159,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
can be built using these low-level accessors. This is described shortly.
-
29.4.7 C++ classes and type-checking
+
30.4.7 C++ classes and type-checking
@@ -1195,7 +1195,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
multiple inheritance is used).
-
29.4.8 C++ overloaded functions
+
30.4.8 C++ overloaded functions
@@ -1239,7 +1239,7 @@ example::Spam_foo_d($s,3.14);
Please refer to the "SWIG Basics" chapter for more information.
-
29.4.9 Operators
+
30.4.9 Operators
@@ -1266,7 +1266,7 @@ The following C++ operators are currently supported by the Perl module:
operator or
-
29.4.10 Modules and packages
+
30.4.10 Modules and packages
@@ -1361,7 +1361,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
-->
-
29.5 Input and output parameters
+
30.5 Input and output parameters
@@ -1580,7 +1580,7 @@ print "$c\n";
Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).
-
29.6 Exception handling
+
30.6 Exception handling
@@ -1745,7 +1745,7 @@ This is still supported, but it is deprecated. The newer %exception di
functionality, but it has additional capabilities that make it more powerful.
-
29.7 Remapping datatypes with typemaps
+
30.7 Remapping datatypes with typemaps
@@ -1762,7 +1762,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Perl interface.
@@ -2358,7 +2358,7 @@ the "in" typemap in the previous section would be used to convert an
to copy the converted array into a C data structure.
-
29.8.5 Turning Perl references into C pointers
+
30.8.5 Turning Perl references into C pointers
@@ -2423,7 +2423,7 @@ print "$c\n";
-
29.8.6 Pointer handling
+
30.8.6 Pointer handling
@@ -2502,7 +2502,7 @@ For example:
-
29.9 Proxy classes
+
30.9 Proxy classes
@@ -2518,7 +2518,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
-
29.9.1 Preliminaries
+
30.9.1 Preliminaries
@@ -2540,7 +2540,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
-
29.9.2 Structure and class wrappers
+
30.9.2 Structure and class wrappers
@@ -2666,7 +2666,7 @@ $v->DESTROY();
-
29.9.3 Object Ownership
+
30.9.3 Object Ownership
@@ -2753,7 +2753,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
@@ -75,7 +75,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
-
30.1 Generating PHP Extensions
+
31.1 Generating PHP Extensions
@@ -122,7 +122,7 @@ and it doesn't play nicely with package system. We don't recommend
this approach, or provide explicit support for it.
-
30.1.1 Building a loadable extension
+
31.1.1 Building a loadable extension
@@ -137,7 +137,7 @@ least work for Linux though):
gcc -shared example_wrap.o -o example.so
-
30.1.2 Using PHP Extensions
+
31.1.2 Using PHP Extensions
@@ -168,7 +168,7 @@ attempts to do the dl() call for you:
include("example.php");
-
30.2 Basic PHP interface
+
31.2 Basic PHP interface
@@ -178,7 +178,7 @@ possible for names of symbols in one extension module to clash with
other symbols unless care is taken to %rename them.
-
30.2.1 Constants
+
31.2.1 Constants
@@ -303,7 +303,7 @@ both point to the same value, without the case test taking place. (
Apologies, this paragraph needs rewriting to make some sense. )
-
30.2.2 Global Variables
+
31.2.2 Global Variables
@@ -352,7 +352,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
-
30.2.3 Functions
+
31.2.3 Functions
@@ -405,7 +405,7 @@ print $s; # The value of $s was not changed.
-->
-
30.2.4 Overloading
+
31.2.4 Overloading
@@ -461,7 +461,7 @@ taking the integer argument.
-->
-
30.2.5 Pointers and References
+
31.2.5 Pointers and References
@@ -593,7 +593,7 @@ PHP in a number of ways: by using unset on an existing
variable, or assigning NULL to a variable.
-
30.2.6 Structures and C++ classes
+
31.2.6 Structures and C++ classes
@@ -652,7 +652,7 @@ Would be used in the following way from PHP5:
Member variables and methods are accessed using the -> operator.
@@ -719,7 +719,7 @@ the programmer can either reassign the variable or call
unset($v)
-
30.2.6.3 Static Member Variables
+
31.2.6.3 Static Member Variables
@@ -762,7 +762,7 @@ Ko::threats(10);
echo "There has now been " . Ko::threats() . " threats\n";
-
30.2.6.4 Static Member Functions
+
31.2.6.4 Static Member Functions
@@ -784,7 +784,7 @@ Ko::threats();
-
30.2.7 PHP Pragmas, Startup and Shutdown code
+
31.2.7 PHP Pragmas, Startup and Shutdown code
@@ -872,7 +872,7 @@ The %rinit and %rshutdown statements are very similar but inse
into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.
-
30.3 Cross language polymorphism
+
31.3 Cross language polymorphism
@@ -907,7 +907,7 @@ wrapper functions takes care of all the cross-language method routing
transparently.
-
30.3.1 Enabling directors
+
31.3.1 Enabling directors
@@ -999,7 +999,7 @@ class MyFoo extends Foo {
-
30.3.2 Director classes
+
31.3.2 Director classes
@@ -1079,7 +1079,7 @@ so there is no need for the extra overhead involved with routing the
calls through PHP.
-
30.3.3 Ownership and object destruction
+
31.3.3 Ownership and object destruction
@@ -1135,7 +1135,7 @@ In this example, we are assuming that FooContainer will take care of
deleting all the Foo pointers it contains at some point.
-
30.3.4 Exception unrolling
+
31.3.4 Exception unrolling
@@ -1194,7 +1194,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception
as soon as the C wrapper function returns.
-
30.3.5 Overhead and code bloat
+
31.3.5 Overhead and code bloat
@@ -1227,7 +1227,7 @@ optimized by selectively enabling director methods (using the %feature
directive) for only those methods that are likely to be extended in PHP.
-
30.3.6 Typemaps
+
31.3.6 Typemaps
@@ -1241,7 +1241,7 @@ need to be supported.
-
30.3.7 Miscellaneous
+
31.3.7 Miscellaneous
Director typemaps for STL classes are mostly in place, and hence you
diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
index 8f9e43735..8bd6b410f 100644
--- a/Doc/Manual/Pike.html
+++ b/Doc/Manual/Pike.html
@@ -6,7 +6,7 @@
-
31 SWIG and Pike
+
32 SWIG and Pike
@@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics"
chapter.
-
31.1 Preliminaries
+
32.1 Preliminaries
-
31.1.1 Running SWIG
+
32.1.1 Running SWIG
@@ -94,7 +94,7 @@ can use the -o option:
$ swig -pike -o pseudonym.c example.i
-
31.1.2 Getting the right header files
+
32.1.2 Getting the right header files
@@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h
and so on.
@@ -128,7 +128,7 @@ very least, make sure you read the "SWIG
Basics" chapter.
-
32.1 Overview
+
33.1 Overview
@@ -155,10 +155,10 @@ described followed by a discussion of low-level implementation
details.
-
32.2 Preliminaries
+
33.2 Preliminaries
-
32.2.1 Running SWIG
+
33.2.1 Running SWIG
@@ -256,7 +256,7 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
-
32.2.2 Using distutils
+
33.2.2 Using distutils
@@ -348,7 +348,7 @@ This same approach works on all platforms if the appropriate compiler is install
can even build extensions to the standard Windows Python using MingGW)
-
32.2.3 Hand compiling a dynamic module
+
33.2.3 Hand compiling a dynamic module
@@ -396,7 +396,7 @@ module actually consists of two files; socket.py and
-
32.2.4 Static linking
+
33.2.4 Static linking
@@ -475,7 +475,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
-
32.2.5 Using your module
+
33.2.5 Using your module
@@ -632,7 +632,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
32.2.6 Compilation of C++ extensions
+
33.2.6 Compilation of C++ extensions
@@ -724,7 +724,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
32.2.7 Compiling for 64-bit platforms
+
33.2.7 Compiling for 64-bit platforms
@@ -761,7 +761,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
-
32.2.8 Building Python Extensions under Windows
+
33.2.8 Building Python Extensions under Windows
@@ -870,7 +870,7 @@ SWIG Wiki.
-
32.3 A tour of basic C/C++ wrapping
+
33.3 A tour of basic C/C++ wrapping
@@ -879,7 +879,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as
This section briefly covers the essential aspects of this wrapping.
-
32.3.1 Modules
+
33.3.1 Modules
@@ -892,7 +892,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
-
32.3.2 Functions
+
33.3.2 Functions
@@ -916,7 +916,7 @@ like you think it does:
>>>
-
32.3.3 Global variables
+
33.3.3 Global variables
@@ -1054,7 +1054,7 @@ that starts with a leading underscore. SWIG does not create cvar
if there are no global variables in a module.
-
32.3.4 Constants and enums
+
33.3.4 Constants and enums
@@ -1094,7 +1094,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
-
32.3.5 Pointers
+
33.3.5 Pointers
@@ -1235,7 +1235,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.
-
32.3.6 Structures
+
33.3.6 Structures
@@ -1424,7 +1424,7 @@ everything works just like you would expect. For example:
-
32.3.7 C++ classes
+
33.3.7 C++ classes
@@ -1513,7 +1513,7 @@ they are accessed through cvar like this:
-
32.3.8 C++ inheritance
+
33.3.8 C++ inheritance
@@ -1568,7 +1568,7 @@ then the function spam() accepts Foo * or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
-
32.3.9 Pointers, references, values, and arrays
+
33.3.9 Pointers, references, values, and arrays
@@ -1629,7 +1629,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
-
32.3.10 C++ overloaded functions
+
33.3.10 C++ overloaded functions
@@ -1752,7 +1752,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
32.3.11 C++ operators
+
33.3.11 C++ operators
@@ -1841,7 +1841,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance
overloaded assignment operators don't map to Python semantics and will be ignored.
-
32.3.12 C++ namespaces
+
33.3.12 C++ namespaces
@@ -1908,7 +1908,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
-
32.3.13 C++ templates
+
33.3.13 C++ templates
@@ -1962,7 +1962,7 @@ Some more complicated
examples will appear later.
-
32.3.14 C++ Smart Pointers
+
33.3.14 C++ Smart Pointers
@@ -2047,7 +2047,7 @@ simply use the __deref__() method. For example:
-
32.3.15 C++ Reference Counted Objects (ref/unref)
+
33.3.15 C++ Reference Counted Objects (ref/unref)
@@ -2190,7 +2190,7 @@ python releases the proxy instance.
-
32.4 Further details on the Python class interface
+
33.4 Further details on the Python class interface
@@ -2203,7 +2203,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
-
32.4.1 Proxy classes
+
33.4.1 Proxy classes
@@ -2292,7 +2292,7 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-
32.4.2 Memory management
+
33.4.2 Memory management
@@ -2484,7 +2484,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
-
32.4.3 Python 2.2 and classic classes
+
33.4.3 Python 2.2 and classic classes
@@ -2521,7 +2521,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
-
32.5 Cross language polymorphism
+
33.5 Cross language polymorphism
@@ -2555,7 +2555,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
-
32.5.1 Enabling directors
+
33.5.1 Enabling directors
@@ -2648,7 +2648,7 @@ class MyFoo(mymodule.Foo):
-
32.5.2 Director classes
+
33.5.2 Director classes
@@ -2730,7 +2730,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
-
32.5.3 Ownership and object destruction
+
33.5.3 Ownership and object destruction
@@ -2797,7 +2797,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
-
32.5.4 Exception unrolling
+
33.5.4 Exception unrolling
@@ -2856,7 +2856,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
-
32.5.5 Overhead and code bloat
+
33.5.5 Overhead and code bloat
@@ -2890,7 +2890,7 @@ directive) for only those methods that are likely to be extended in
Python.
-
32.5.6 Typemaps
+
33.5.6 Typemaps
@@ -2904,7 +2904,7 @@ need to be supported.
-
32.5.7 Miscellaneous
+
33.5.7 Miscellaneous
@@ -2951,7 +2951,7 @@ methods that return const references.
-
32.6 Common customization features
+
33.6 Common customization features
@@ -2964,7 +2964,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
-
32.6.1 C/C++ helper functions
+
33.6.1 C/C++ helper functions
@@ -3045,7 +3045,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
-
32.6.2 Adding additional Python code
+
33.6.2 Adding additional Python code
@@ -3194,7 +3194,7 @@ public:
-
32.6.3 Class extension with %extend
+
33.6.3 Class extension with %extend
@@ -3283,7 +3283,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
-
32.6.4 Exception handling with %exception
+
33.6.4 Exception handling with %exception
@@ -3409,7 +3409,7 @@ The language-independent exception.i library file can also be used
to raise exceptions. See the SWIG Library chapter.
-
32.7 Tips and techniques
+
33.7 Tips and techniques
@@ -3419,7 +3419,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
-
32.7.1 Input and output parameters
+
33.7.1 Input and output parameters
@@ -3632,7 +3632,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
32.7.2 Simple pointers
+
33.7.2 Simple pointers
@@ -3701,7 +3701,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.
-
32.7.3 Unbounded C Arrays
+
33.7.3 Unbounded C Arrays
@@ -3763,7 +3763,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
32.7.4 String handling
+
33.7.4 String handling
@@ -3832,7 +3832,7 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-
32.8 Typemaps
+
33.8 Typemaps
@@ -3849,7 +3849,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Python interface or if you want to elevate your guru status.
-
32.8.1 What is a typemap?
+
33.8.1 What is a typemap?
@@ -3965,7 +3965,7 @@ parameter is omitted):
-
32.8.2 Python typemaps
+
33.8.2 Python typemaps
@@ -4006,7 +4006,7 @@ a look at the SWIG library version 1.3.20 or so.
-
32.8.3 Typemap variables
+
33.8.3 Typemap variables
@@ -4077,7 +4077,7 @@ properly assigned.
The Python name of the wrapper function being created.
-
32.8.4 Useful Python Functions
+
33.8.4 Useful Python Functions
@@ -4205,7 +4205,7 @@ write me
-
32.9 Typemap Examples
+
33.9 Typemap Examples
@@ -4214,7 +4214,7 @@ might look at the files "python.swg" and "typemaps.i" in
the SWIG library.
-
32.9.1 Converting Python list to a char **
+
33.9.1 Converting Python list to a char **
@@ -4294,7 +4294,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
-
32.9.2 Expanding a Python object into multiple arguments
+
33.9.2 Expanding a Python object into multiple arguments
@@ -4373,7 +4373,7 @@ to supply the argument count. This is automatically set by the typemap code. F
-
32.9.3 Using typemaps to return arguments
+
33.9.3 Using typemaps to return arguments
@@ -4462,7 +4462,7 @@ function can now be used as follows:
>>>
-
32.9.4 Mapping Python tuples into small arrays
+
33.9.4 Mapping Python tuples into small arrays
@@ -4511,7 +4511,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
-
32.9.5 Mapping sequences to C arrays
+
33.9.5 Mapping sequences to C arrays
@@ -4600,7 +4600,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
-
32.9.6 Pointer handling
+
33.9.6 Pointer handling
@@ -4697,7 +4697,7 @@ class object (if applicable).
-
32.10 Docstring Features
+
33.10 Docstring Features
@@ -4725,7 +4725,7 @@ of your users much simpler.
-
32.10.1 Module docstring
+
33.10.1 Module docstring
@@ -4759,7 +4759,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
-
32.10.2 %feature("autodoc")
+
33.10.2 %feature("autodoc")
@@ -4786,7 +4786,7 @@ names, default values if any, and return type if any. There are also
three options for autodoc controlled by the value given to the
feature, described below.
-
@@ -4918,7 +4918,7 @@ and also in base class declarations, etc. if the package name is
different than its own.
-
32.12 Python 3 Support
+
33.12 Python 3 Support
@@ -4945,7 +4945,7 @@ The following are Python 3.0 new features that are currently supported by
SWIG.
-
32.12.1 Function annotation
+
33.12.1 Function annotation
@@ -4977,7 +4977,7 @@ all overloaded functions share the same function in SWIG generated proxy class.
For detailed usage of function annotation, see PEP 3107.
@@ -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++.
-
33.1 Bugs
+
34.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
33.2 Using R and SWIG
+
34.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
-
33.3 Precompiling large R files
+
34.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.
-
33.4 General policy
+
34.4 General policy
@@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
33.5 Language conventions
+
34.5 Language conventions
@@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
33.6 C++ classes
+
34.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.
-
34.1.1 Running SWIG
+
35.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.
-
34.1.2 Getting the right header files
+
35.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:
-
34.1.3 Compiling a dynamic module
+
35.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.
-
34.1.4 Using your module
+
35.1.4 Using your module
Ruby module names must be capitalized,
@@ -488,7 +488,7 @@ begins with:
-
34.1.5 Static linking
+
35.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -509,7 +509,7 @@ finally rebuilding Ruby.
-
34.1.6 Compilation of C++ extensions
+
35.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -561,7 +561,7 @@ extension, e.g.
-
34.2 Building Ruby Extensions under Windows 95/NT
+
35.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -600,7 +600,7 @@ files.
-
34.2.1 Running SWIG from Developer Studio
+
35.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:
-
34.3 The Ruby-to-C/C++ Mapping
+
35.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.
-
34.6.4 Exception classes
+
35.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.
-
34.7 Typemaps
+
35.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4696,7 +4696,7 @@ of the primitive C-Ruby interface.
-
34.7.1 What is a typemap?
+
35.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):
-
34.7.2 Typemap scope
+
35.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:
-
34.7.3 Copying a typemap
+
35.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5108,7 +5108,7 @@ rules as for
-
34.7.4 Deleting a typemap
+
35.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.
-
34.7.5 Placement of typemaps
+
35.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5244,7 +5244,7 @@ string
-
34.7.6 Ruby typemaps
+
35.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:
-
34.7.6.1 "in" typemap
+
35.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5497,7 +5497,7 @@ arguments to be specified. For example:
-
34.7.6.2 "typecheck" typemap
+
35.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5538,7 +5538,7 @@ on "Typemaps and Overloading."
-
34.7.6.3 "out" typemap
+
35.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.
-
34.7.6.4 "arginit" typemap
+
35.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5795,7 +5795,7 @@ applications. For example:
-
34.7.6.5 "default" typemap
+
35.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5837,7 +5837,7 @@ default argument wrapping.
-
34.7.6.6 "check" typemap
+
35.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:
-
34.7.6.7 "argout" typemap
+
35.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.
-
34.7.6.8 "freearg" typemap
+
35.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6055,7 +6055,7 @@ abort prematurely.
-
34.7.6.9 "newfree" typemap
+
35.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.
-
34.7.6.10 "memberin" typemap
+
35.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6119,7 +6119,7 @@ other objects.
-
34.7.6.11 "varin" typemap
+
35.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6130,7 +6130,7 @@ This is implementation specific.
-
34.7.6.12 "varout" typemap
+
35.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.
-
34.7.6.13 "throws" typemap
+
35.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6200,7 +6200,7 @@ handling with %exception section.
-
34.7.6.14 directorin typemap
+
35.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6454,7 +6454,7 @@ referring to the class itself.
-
34.7.6.15 directorout typemap
+
35.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6714,7 +6714,7 @@ exception.
-
34.7.6.16 directorargout typemap
+
35.7.6.16 directorargout typemap
Output argument processing in director
@@ -6954,7 +6954,7 @@ referring to the instance of the class itself
-
34.7.6.17 ret typemap
+
35.7.6.17 ret typemap
Cleanup of function return values
@@ -6964,7 +6964,7 @@ referring to the instance of the class itself
-
34.7.6.18 globalin typemap
+
35.7.6.18 globalin typemap
Setting of C global variables
@@ -6974,7 +6974,7 @@ referring to the instance of the class itself
-
34.7.7 Typemap variables
+
35.7.7 Typemap variables
@@ -7084,7 +7084,7 @@ being created.
-
34.7.8 Useful Functions
+
35.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7108,7 +7108,7 @@ across multiple languages.
-
34.7.8.1 C Datatypes to Ruby Objects
+
35.7.8.1 C Datatypes to Ruby Objects
@@ -7164,7 +7164,7 @@ SWIG_From_float(float)
-
34.7.8.2 Ruby Objects to C Datatypes
+
35.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).
-
34.10 Memory Management
+
35.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.
-
34.10.1 Mark and Sweep Garbage Collector
+
35.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9891,7 +9891,7 @@ this memory.
-
34.10.2 Object Ownership
+
35.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10149,7 +10149,7 @@ public:
-
34.10.3 Object Tracking
+
35.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10400,7 +10400,7 @@ methods.
-
34.10.4 Mark Functions
+
35.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10518,7 +10518,7 @@ test suite.
-
34.10.5 Free Functions
+
35.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.
-
34.10.6 Embedded Ruby and the C++ Stack
+
35.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/Tcl.html b/Doc/Manual/Tcl.html
index 7a4a85de9..c677f6eed 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
-
35 SWIG and Tcl
+
36 SWIG and Tcl
@@ -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.
-
35.1 Preliminaries
+
36.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.
-
35.1.1 Getting the right header files
+
36.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
-
35.1.2 Compiling a dynamic module
+
36.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.
-
35.1.3 Static linking
+
36.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).
-
35.1.4 Using your module
+
36.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).
-
35.1.5 Compilation of C++ extensions
+
36.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.
-
35.1.6 Compiling for 64-bit platforms
+
36.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).
-
35.1.7 Setting a package prefix
+
36.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".
-
35.1.8 Using namespaces
+
36.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.
-
35.2 Building Tcl/Tk Extensions under Windows 95/NT
+
36.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.
-
35.2.1 Running SWIG from Developer Studio
+
36.2.1 Running SWIG from Developer Studio
@@ -576,7 +576,7 @@ MSDOS > tclsh80
%
-
35.2.2 Using NMAKE
+
36.2.2 Using NMAKE
@@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
35.3 A tour of basic C/C++ wrapping
+
36.3 A tour of basic C/C++ wrapping
@@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
35.3.1 Modules
+
36.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.
-
35.3.5 Pointers
+
36.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.
-
35.3.6 Structures
+
36.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.
-
35.3.7 C++ classes
+
36.3.7 C++ classes
@@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows:
-
35.3.8 C++ inheritance
+
36.3.8 C++ inheritance
@@ -1367,7 +1367,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
35.3.9 Pointers, references, values, and arrays
+
36.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).
-
35.3.10 C++ overloaded functions
+
36.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.
-
35.3.11 C++ operators
+
36.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.
-
35.3.12 C++ namespaces
+
36.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.
-
35.7 Typemaps
+
36.7 Typemaps
@@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
35.7.1 What is a typemap?
+
36.7.1 What is a typemap?
@@ -2568,7 +2568,7 @@ parameter is omitted):
-
35.7.2 Tcl typemaps
+
36.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.
-
35.7.3 Typemap variables
+
36.7.3 Typemap variables
@@ -2777,7 +2777,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
35.7.4 Converting a Tcl list to a char **
+
36.7.4 Converting a Tcl list to a char **
@@ -2839,7 +2839,7 @@ argv[2] = Larry
3
-
35.7.5 Returning values in arguments
+
36.7.5 Returning values in arguments
@@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
35.7.6 Useful functions
+
36.7.6 Useful functions
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
35.7.7 Standard typemaps
+
36.7.7 Standard typemaps
@@ -3042,7 +3042,7 @@ work)
-
35.7.8 Pointer handling
+
36.7.8 Pointer handling
@@ -3118,7 +3118,7 @@ For example:
-
35.8 Turning a SWIG module into a Tcl Package.
+
36.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.
-
35.9 Building new kinds of Tcl interfaces (in Tcl)
+
36.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).
-
35.9.1 Proxy classes
+
36.9.1 Proxy classes
@@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
-
35.10 Tcl/Tk Stubs
+
36.10 Tcl/Tk Stubs
--
cgit v1.2.1
From 0892ef8496bddd14b2067793357dbc71d1998f94 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 7 Jan 2011 20:26:21 +0000
Subject: Fix most of the html errors in D.html
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12377 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/D.html | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
index 47a8f0e6f..dbc505d1e 100644
--- a/Doc/Manual/D.html
+++ b/Doc/Manual/D.html
@@ -43,7 +43,7 @@
20.1 Introduction
-
From the D Programming Language web site: »D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. […] The D language is statically typed and compiles directly to machine code.« As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?
+
From the D Programming Language web site: »D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.« As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?
Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to \0-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.
@@ -182,7 +182,7 @@
$dclassname (C#: $csclassname)
-
This special variable works similar to $n_type in that it returns the name of a type – it expands to the D proxy class name of the type being wrapped. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_p_SomeCppClass is generated when wrapping SomeCppClass **.
+
This special variable works similar to $n_type in that it returns the name of a type - it expands to the D proxy class name of the type being wrapped. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_p_SomeCppClass is generated when wrapping SomeCppClass **.
There are two other variants available, $&dclassname and $*dclassname. The former adds a level of indirection, while the latter removes one. For instance, when wrapping Foo **, $*dclassname would be replaced by the proxy class name corresponding to Foo *.
@@ -264,7 +264,7 @@ SomeClass bar() {
This causes SWIG to add AnInterface and AnotherInterface to the base class list of SomeClass:
For this to work, AnInterface and AnotherInterface have to be in scope. If SWIG is not in split proxy mode, this is already the case, but it it is, they have to be added to the import list via the dimports typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.
@@ -360,7 +360,7 @@ struct A {
Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.
-
The implementation details of this are a bit crude, but the SWIG D module automatically takes care of this, as long as it is able to detect that an exception could potentially be thrown (e.g. because the C++ method has a throw(…) exception specification).
+
The implementation details of this are a bit crude, but the SWIG D module automatically takes care of this, as long as it is able to detect that an exception could potentially be thrown (e.g. because the C++ method has a throw(...) exception specification).
As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.
@@ -377,7 +377,7 @@ struct A {
20.8 Other features
-
The nspace feature of SWIG is not yet supported for D – all class modules are written to the same package, regardless of which C++ namespace they are in.
+
The nspace feature of SWIG is not yet supported for D - all class modules are written to the same package, regardless of which C++ namespace they are in.
20.8.1 Native pointer support
@@ -385,7 +385,7 @@ struct A {
Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a »primtive type« below.
-
Central to this custom pointer handling scheme are two typemap attributes: the cprimitive attribute on the dtype typemap and the nativepointer attribute on all the typemaps which influence the D side of the code (dtype, din, dout, …). When a D typemap is looked up, the following happens behind the scenes:
+
Central to this custom pointer handling scheme are two typemap attributes: the cprimitive attribute on the dtype typemap and the nativepointer attribute on all the typemaps which influence the D side of the code (dtype, din, dout, ...). When a D typemap is looked up, the following happens behind the scenes:
First, the matching typemap is determined by the usual typemap lookup rules. Then, it is checked if the result has the nativepointer attribute set. If it is present, it means that its value should replace the typemap value if and only if the actual type the typemap is looked up for is a primitive type, a pointer to a primitive type (through an arbitrary level of indirections), or a function pointer with only primitive types in its signature.
@@ -399,9 +399,9 @@ struct A {
The first key difference is that C++ supports free functions as operators (along with argument-dependent lookup), while D requires operators to be member functions of the class they are operating on. SWIG can only automatically generate wrapping code for member function operators; if you want to use operators defined as free functions in D, you need to handle them manually.
-
Another set of differences between C++ and D concerns individual operators. For example, there are quite a few operators which are overloadable in C++, but not in D, for example && and ||, but also !, and prefix increment/decrement operators in D1 resp. their postfix pendants in D2.
+
Another set of differences between C++ and D concerns individual operators. For example, there are quite a few operators which are overloadable in C++, but not in D, for example && and ||, but also !, and prefix increment/decrement operators in D1 resp. their postfix pendants in D2.
-
There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments – while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method –, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.
+
There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.
20.8.3 Running the test-suite
@@ -409,7 +409,7 @@ struct A {
As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.
-
Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib,…) statement.
+
Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib,...) statement.
20.9 D Typemap examples
--
cgit v1.2.1
From 916e4644b62ba5c3e05549758c579514a1612a56 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 8 Jan 2011 00:19:58 +0000
Subject: fixes for html tidy in D.html
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12378 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/D.html | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
index dbc505d1e..1db6569a5 100644
--- a/Doc/Manual/D.html
+++ b/Doc/Manual/D.html
@@ -143,15 +143,15 @@
The full chain of type conversions when a director callback is invoked looks like this:
type CPPClass::method(type a)
- ↑ ↓
+ ↑ ↓
<directorout> <directorin>
- ↑ ↓
+ ↑ ↓
ctype methodCallback(ctype a) C++
::::::::::::::::::::::::::::::::::::::::::
imtype methodCallback(imtype a) D
- ↑ ↓
+ ↑ ↓
<ddirectorout> <ddirectorin>
- ↑ ↓
+ ↑ ↓
dtype DClass.method(dtype a)
--
cgit v1.2.1
From 25c8689226f86efe43dcfbaa04f268ad0d9ef451 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 8 Jan 2011 01:28:09 +0000
Subject: Use htmldoc's new --overflow option and fix overflow warnings in the
pdf documentation generation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12379 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/CSharp.html | 29 +++++++++++++++++------------
Doc/Manual/D.html | 3 ++-
Doc/Manual/Java.html | 6 ++++--
Doc/Manual/Library.html | 3 ++-
Doc/Manual/Modules.html | 3 ++-
Doc/Manual/Octave.html | 3 ++-
Doc/Manual/SWIGPlus.html | 17 +++++++++--------
Doc/Manual/Typemaps.html | 16 ++++++++++------
Source/Swig/typemap.c | 4 ++--
9 files changed, 50 insertions(+), 34 deletions(-)
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 909357f37..94a3b5f47 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -575,7 +575,8 @@ marshalling for the arrays:
[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy([In, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
- [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+ [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
+ int jarg3);
@@ -624,7 +625,8 @@ and intermediate class method
[DllImport("example", EntryPoint="CSharp_myArraySwap")]
public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
- [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+ [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
+ int jarg3);
@@ -696,7 +698,8 @@ As a result, we get the following method in the module class:
fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
fixed ( int *swig_ptrTo_targetArray = targetArray ) {
{
- examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray, nitems);
+ examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray,
+ nitems);
}
}
}
@@ -2109,7 +2112,8 @@ public class example {
try {
examplePINVOKE.addYears(CDate.getCPtr(temppDate), years);
} finally {
- pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
+ 0, 0, 0);
}
}
...
@@ -2126,13 +2130,13 @@ The subtractYears method is nearly identical to the above addYears<
%typemap(csin,
- pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
- post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
- " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- terminator=" } // terminate temp$csinput using block",
- cshin="ref $csinput"
- ) CDate *
- "$csclassname.getCPtr(temp$csinput)"
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
void subtractYears(CDate *pDate, int years) {
*pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
@@ -2152,7 +2156,8 @@ public class example {
try {
examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
} finally {
- pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
+ 0, 0, 0);
}
} // terminate temppDate using block
}
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
index 1db6569a5..8ce709432 100644
--- a/Doc/Manual/D.html
+++ b/Doc/Manual/D.html
@@ -248,7 +248,8 @@ SomeClass bar() {
This macro is only valid inside the dconstructor typemap and contains the value of the dconstructor typemap attribute if the currently wrapped class has directors enabled.
This is how the default dconstructor typemap looks like (you usually do not want to specify a custom one):
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index a27d9adbb..05c5b3114 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -1922,8 +1922,10 @@ So if SWIG is run using the -package com.myco option, a wrapped class,
-example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless a package is specified
-with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.
+example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless
+a package is specified
+with -package - Java does not support types declared in a named package accessing types declared
+in an unnamed package.
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 285192d5e..1f465dab5 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -1809,7 +1809,8 @@ For example if the above %shared_ptr(DerivedIntValue) is omitted, the f
-example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*, _jclass*, jlong)':
+example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*,
+_jclass*, jlong)':
example_wrap.cxx:3169: error: 'smartarg1' was not declared in this scope
diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
index 69cc58c30..70b0f1181 100644
--- a/Doc/Manual/Modules.html
+++ b/Doc/Manual/Modules.html
@@ -138,7 +138,8 @@ base class's methods. Typically you will get a warning when the module name is m
-derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either import
+derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either
+import
the appropriate module interface file or specify the name of the module in the %import directive.
diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html
index 2ceb75ff9..548b518bd 100644
--- a/Doc/Manual/Octave.html
+++ b/Doc/Manual/Octave.html
@@ -755,7 +755,8 @@ Note that you have to enable directors via the %feature directive (see other mod
subclass() will accept any number of C++ bases or other subclass()'ed objects, (string,octave_value) pairs, and function_handles. In the first case, these are taken as base classes; in the second case, as named members (either variables or functions, depending on whether the given value is a function handle); in the third case, as member functions whose name is taken from the given function handle. E.g.,
You can also assign non-C++ member variables and functions after construct time. There is no support for non-C++ static members.
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index f9bfc8ec6..c8e5ee870 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -4192,8 +4192,9 @@ In the example below, the generic template type is used to rename to bbb
-%rename(bbb) Space::ABC::aaa(T t); // will match but with lower precedence than ccc
-%rename(ccc) Space::ABC<Space::XYZ>::aaa(Space::XYZ t); // will match but with higher precedence than bbb
+%rename(bbb) Space::ABC::aaa(T t); // will match but with lower precedence than ccc
+%rename(ccc) Space::ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence
+ // than bbb
namespace Space {
class XYZ {};
@@ -4214,9 +4215,9 @@ Below shows how %rename can be placed inside a namespace.
namespace Space {
- %rename(bbb) ABC::aaa(T t); // will match but with lower precedence than ccc
- %rename(ccc) ABC<Space::XYZ>::aaa(Space::XYZ t); // will match but with higher precedence than bbb
- %rename(ddd) ABC<Space::XYZ>::aaa(XYZ t); // will not match
+ %rename(bbb) ABC::aaa(T t); // will match but with lower precedence than ccc
+ %rename(ccc) ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence than bbb
+ %rename(ddd) ABC<Space::XYZ>::aaa(XYZ t); // will not match
}
namespace Space {
@@ -4238,11 +4239,11 @@ The following example shows how %rename can be placed within %extend.
namespace Space {
%extend ABC {
- %rename(bbb) aaa(T t); // will match but with lower precedence than ccc
+ %rename(bbb) aaa(T t); // will match but with lower precedence than ccc
}
%extend ABC<Space::XYZ> {
- %rename(ccc) aaa(Space::XYZ t); // will match but with higher precedence than bbb
- %rename(ddd) aaa(XYZ t); // will not match
+ %rename(ccc) aaa(Space::XYZ t);// will match but with higher precedence than bbb
+ %rename(ddd) aaa(XYZ t); // will not match
}
}
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 1568c082e..6331aa1ac 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -1711,7 +1711,8 @@ you'll find the full typemap contents (example shown below for Python):
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | 0 );
if (!SWIG_IsOK(res)) {
- SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'");
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument "
+ "$argnum"" of type '" "$type""'");
}
$1 = ($ltype)(argp);
}
@@ -1732,7 +1733,8 @@ SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
...
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_a_4__int, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument " "1"" of type '" "int [10][4]""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument "
+ "1"" of type '" "int [10][4]""'");
}
arg1 = (int (*)[4])(argp1);
...
@@ -1791,7 +1793,8 @@ void set_value(const char* val) {}
}
}
-%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
+// use default pointer handling instead of strings
+%apply SWIGTYPE * { const char* val, const char* another_value }
%typemap(check) const char* val = char* NON_NULL;
@@ -3296,7 +3299,8 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
example.i:28: Warning 474: Method XX::create() usage of the optimal attribute ignored
-example.i:14: Warning 474: in the out typemap as the following cannot be used to generate optimal code:
+example.i:14: Warning 474: in the out typemap as the following cannot be used to generate
+optimal code:
try {
result = XX::create();
} catch(const std::exception &e) {
@@ -3317,8 +3321,8 @@ In fact SWIG attempts to detect this and will issue a warning something like:
-example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to optimal attribute usage in
-example.i:7: Warning 475: the out typemap.
+example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to
+example.i:7: Warning 475: optimal attribute usage in the out typemap.
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index 1062e0969..fe6a33641 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -1440,8 +1440,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
}
if (optimal_substitution && num_substitutions > 1) {
- Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in\n", Swig_name_decl(node));
- Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "the out typemap.\n");
+ Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
+ Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n");
}
if (locals && f) {
--
cgit v1.2.1
From 892caec201744b4af004ecaa5db18a60c3dbc2dc Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 8 Jan 2011 21:05:49 +0000
Subject: [D] Fixed a bug in the loop breaking code for directors leading to a
superclass implementation erroneously being called.
The situation in which this would previously happen is illustrated in the new "director_alternating" test case. Currently broken for C# and Java.
Thanks to Jimmy Cao for reporting this.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12380 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/common.mk | 1 +
.../test-suite/d/director_alternating_runme.2.d | 7 +++++
Examples/test-suite/director_alternating.i | 36 ++++++++++++++++++++++
Examples/test-suite/director_alternating_runme.1.d | 7 +++++
.../python/director_alternating_runme.py | 5 +++
Source/Modules/d.cxx | 17 +++++++---
6 files changed, 69 insertions(+), 4 deletions(-)
create mode 100644 Examples/test-suite/d/director_alternating_runme.2.d
create mode 100644 Examples/test-suite/director_alternating.i
create mode 100644 Examples/test-suite/director_alternating_runme.1.d
create mode 100644 Examples/test-suite/python/director_alternating_runme.py
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index f25238382..d2b9bc254 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -154,6 +154,7 @@ CPP_TEST_CASES += \
derived_nested \
destructor_reprotected \
director_abstract \
+ director_alternating \
director_basic \
director_classes \
director_classic \
diff --git a/Examples/test-suite/d/director_alternating_runme.2.d b/Examples/test-suite/d/director_alternating_runme.2.d
new file mode 100644
index 000000000..27bd262fd
--- /dev/null
+++ b/Examples/test-suite/d/director_alternating_runme.2.d
@@ -0,0 +1,7 @@
+module director_alternating_runme;
+
+import director_alternating.director_alternating;
+
+void main() {
+ assert(getBar().id() == idFromGetBar());
+}
diff --git a/Examples/test-suite/director_alternating.i b/Examples/test-suite/director_alternating.i
new file mode 100644
index 000000000..6e3ef4f24
--- /dev/null
+++ b/Examples/test-suite/director_alternating.i
@@ -0,0 +1,36 @@
+// Checks if calls to a method being defined in the base class, not
+// overridden in the subclass, but again overridden in a class derived from
+// the first subclass are dispatched correctly.
+%module(directors="1") director_alternating;
+
+%feature("director") Foo;
+
+%inline %{
+struct Foo {
+ virtual ~Foo() {}
+ virtual int id() {
+ return 0;
+ }
+};
+
+struct Bar : Foo {};
+
+struct Baz : Bar {
+ virtual int id() {
+ return 2;
+ }
+};
+
+// Note that even though the return value is of type Bar*, it really points to
+// an instance of Baz (in which id() has been overridden).
+Bar *getBar() {
+ static Baz baz;
+ return &baz;
+}
+
+// idFromGetBar() obviously is equivalent to getBar()->id() in C++ – this
+// should be true from the target language as well.
+int idFromGetBar() {
+ return getBar()->id();
+}
+%}
diff --git a/Examples/test-suite/director_alternating_runme.1.d b/Examples/test-suite/director_alternating_runme.1.d
new file mode 100644
index 000000000..27bd262fd
--- /dev/null
+++ b/Examples/test-suite/director_alternating_runme.1.d
@@ -0,0 +1,7 @@
+module director_alternating_runme;
+
+import director_alternating.director_alternating;
+
+void main() {
+ assert(getBar().id() == idFromGetBar());
+}
diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py
new file mode 100644
index 000000000..a92ae1c5c
--- /dev/null
+++ b/Examples/test-suite/python/director_alternating_runme.py
@@ -0,0 +1,5 @@
+from director_alternating import *
+
+id = getBar().id()
+if id != idFromGetBar():
+ raise RuntimeError, "Got wrong id: " + str(id)
diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
index 4fdc25fac..9937452a9 100644
--- a/Source/Modules/d.cxx
+++ b/Source/Modules/d.cxx
@@ -2630,6 +2630,8 @@ private:
if (!static_flag) {
Printf(imcall, "cast(void*)swigCPtr");
}
+
+ String *proxy_param_types = NewString("");
// Write the parameter list for the proxy function declaration and the
// wrapper function call.
@@ -2704,10 +2706,13 @@ private:
"No dtype typemap defined for %s\n", SwigType_str(pt, 0));
}
- if (gencomma >= 2)
+ if (gencomma >= 2) {
Printf(function_code, ", ");
+ Printf(proxy_param_types, ", ");
+ }
gencomma = 2;
Printf(function_code, "%s %s", proxy_type, param_name);
+ Append(proxy_param_types, proxy_type);
Delete(proxy_type);
}
@@ -2772,9 +2777,11 @@ private:
String *excode = NewString("");
if (!Cmp(return_type, "void"))
- Printf(excode, "if (this.classinfo == %s.classinfo) %s; else %s", proxy_class_name, imcall, ex_imcall);
+ Printf(excode, "if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) %s; else %s",
+ return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall);
else
- Printf(excode, "((this.classinfo == %s.classinfo) ? %s : %s)", proxy_class_name, imcall, ex_imcall);
+ Printf(excode, "((swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) ? %s : %s)",
+ return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall);
Clear(imcall);
Printv(imcall, excode, NIL);
@@ -2788,6 +2795,8 @@ private:
Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
"No dout typemap defined for %s\n", SwigType_str(t, 0));
}
+
+ Delete(proxy_param_types);
// The whole function body is now in stored tm (if there was a matching type
// map, of course), so simply append it to the code buffer. The braces are
@@ -3418,7 +3427,7 @@ private:
// Only emit it if the proxy class has at least one method.
if (first_class_dmethod < curr_class_dmethod) {
Printf(proxy_class_body_code, "\n");
- Printf(proxy_class_body_code, "private bool swigIsMethodOverridden(DelegateType, FunctionType, alias fn)() {\n");
+ Printf(proxy_class_body_code, "private bool swigIsMethodOverridden(DelegateType, FunctionType, alias fn)() %s{\n", (d_version > 1) ? "const " : "");
Printf(proxy_class_body_code, " DelegateType dg = &fn;\n");
Printf(proxy_class_body_code, " return dg.funcptr != SwigNonVirtualAddressOf!(FunctionType, fn);\n");
Printf(proxy_class_body_code, "}\n");
--
cgit v1.2.1
From 162ced78f42760515136afa1c8ed9677a5119c71 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 8 Jan 2011 23:17:23 +0000
Subject: Better linkchecker configuration for checking html links. Fix broken
links and update redirected links.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12381 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/CSharp.html | 2 +-
Doc/Manual/Contents.html | 2 +-
Doc/Manual/Guile.html | 2 +-
Doc/Manual/Introduction.html | 6 +++---
Doc/Manual/Java.html | 2 +-
Doc/Manual/Makefile | 7 +++++--
Doc/Manual/Modula3.html | 13 ++++---------
Doc/Manual/Ocaml.html | 2 +-
Doc/Manual/Octave.html | 2 +-
Doc/Manual/Python.html | 2 +-
Doc/Manual/Sections.html | 2 +-
Doc/Manual/linkchecker.config | 5 +++++
Doc/Manual/maketoc.py | 2 +-
13 files changed, 26 insertions(+), 23 deletions(-)
create mode 100644 Doc/Manual/linkchecker.config
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 94a3b5f47..6691400b7 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -57,7 +57,7 @@ PInvoke is part of the ECMA/ISO C# specification.
It is also better suited for robust production environments due to the Managed C++ flaw called the
Mixed DLL Loading Problem.
SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
-Mono and Portable.NET.
+Mono and Portable.NET.
diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html
index da0b11dd8..111c48214 100644
--- a/Doc/Manual/Guile.html
+++ b/Doc/Manual/Guile.html
@@ -429,7 +429,7 @@ upper half of the CAR is read from this struct.
To get the pointer represented by a smob, the wrapper code calls the
function SWIG_ConvertPtr(), passing a pointer to a struct
representing the expected pointer type. See also
-The run-time type checker.
+The run-time type checker.
If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a wrong-type-arg exception is raised.
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 24579d946..a8d15a5c2 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -372,9 +372,9 @@ Microsoft Visual Studio.
If you are using the GNU Autotools
-(Autoconf/
-Automake/
-Libtool)
+(Autoconf/
+Automake/
+Libtool)
to configure SWIG use in your project, the SWIG Autoconf macros can be used.
The primary macro is ax_pkg_swig, see
http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig.
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index 05c5b3114..ef5604a05 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -2745,7 +2745,7 @@ Call the System.runFinalizersOnExit(true) or Runtime.getRuntime().r
This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
In many cases you will be lucky and find that it works, but it is not to be advocated.
-Have a look at Sun's Java web site and search for runFinalizersOnExit.
+Have a look at Java web site and search for runFinalizersOnExit.
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 011261e76..42149ba3a 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -69,7 +69,10 @@ test:
validate:
all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done;
-# Link checking using linkchecker (can take a while - 30 mins)
+# Link checking using linkchecker
linkchecker:
- linkchecker --anchors Contents.html
+ @echo -----------------------------------------------------------------------
+ @echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
+ @echo -----------------------------------------------------------------------
+ linkchecker --config=./linkchecker.config index.html
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index 1fd82b459..f9400abee 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -142,7 +142,7 @@ Modula-3 has integrated support for calling C functions.
This is also extensively used by the standard Modula-3 libraries
to call OS functions.
The Modula-3 part of SWIG and the corresponding SWIG library
-modula3.swg
+modula3.swg
contain code that uses these features.
Because of the built-in support there is no need
for calling the SWIG kernel to generate wrappers written in C.
@@ -394,8 +394,7 @@ so I'm not sure if this is possible or sensible, yet.
There are different Modula-3 compilers around:
cm3, pm3, ezm3, Klagenfurth Modula-3, Cambridge Modula-3.
SWIG itself does not contain compiler specific code
-but the library file
-modula3.swg
+but the modula3.swg library file
may do so.
For testing examples I use Critical Mass cm3.
@@ -499,9 +498,7 @@ or for a return value.
A further typemap may specify
the direction that is used for certain parameters.
I have chosen this separation
-in order to be able to write general typemaps for the typemap library
-modula3.swg
-.
+in order to be able to write general typemaps for the modula3.swg typemap library.
In the library code the final usage of the type is not known.
Using separate typemaps for each possible use
allows appropriate definitions for each case.
@@ -782,9 +779,7 @@ Unqualified import is not supported.
It is cumbersome to add this typemap to each piece of Modula-3 code.
It is especially useful when writing general typemaps
-for the typemap library
-modula3.swg
-.
+for the modula3.swg typemap library.
For a monolithic module you might be better off
if you add the imports directly:
diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html
index 1a7c4c97c..56c3db142 100644
--- a/Doc/Manual/Ocaml.html
+++ b/Doc/Manual/Ocaml.html
@@ -93,7 +93,7 @@ examples and test-suite which come with SWIG. You can do this by running
The Ocaml module has been tested using the system's dynamic linking (the
usual -lxxx against libxxx.so, as well as with Gerd Stolpmann's
Dl package
+ href="http://download.camlcity.org/download/">Dl package
. The ocaml_dynamic and ocaml_dynamic_cpp targets in the
file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html
index 548b518bd..3c08d849b 100644
--- a/Doc/Manual/Octave.html
+++ b/Doc/Manual/Octave.html
@@ -46,7 +46,7 @@
Octave is a high-level language intended for numerical programming that is mostly compatible with MATLAB.
-More information can be found at www.octave.org.
+More information can be found at Octave web site.
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index cacb9a368..1b8a3f671 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -262,7 +262,7 @@ how you might go about compiling and using the generated files.
The preferred approach to building an extension module for python is to compile it with
distutils, which comes with all recent versions of python
-(Distutils Docs).
+(Distutils Docs).
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index e41954b1c..8f171b985 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -43,7 +43,7 @@ Last update : SWIG-2.0.2 (in progress)
The full chain of type conversions when a director callback is invoked looks like this:
-
type CPPClass::method(type a)
+
+ type CPPClass::method(type a)
+ ↑ ↓
+ <directorout> <directorin>
↑ ↓
- <directorout> <directorin>
- ↑ ↓
- ctype methodCallback(ctype a) C++
- ::::::::::::::::::::::::::::::::::::::::::
- imtype methodCallback(imtype a) D
- ↑ ↓
- <ddirectorout> <ddirectorin>
- ↑ ↓
- dtype DClass.method(dtype a)
+ ctype methodCallback(ctype a) C++
+ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ imtype methodCallback(imtype a) D
+ ↑ ↓
+ <ddirectorout> <ddirectorin>
+ ↑ ↓
+ dtype DClass.method(dtype a)
+By default SWIG handles char * as a string but there is a handy multi-argument typemap available as mentioned in Passing binary data.
+The following simple example demonstrates using a byte array instead of passing the default string type and length to the wrapped function.
+
+Calling from Java requires just the byte array to be passed in as the multi-argument typemap being applied reduces the number of arguments in the target language to one, from the original two:
+
+
+
+
+byte[] data = "hi\0jk".getBytes();
+example.binaryChar1(data);
+
+
+
+
+resulting in the output
+
+
+
+$ java runme
+len: 5 data: 68 69 0 6a 6b
+
+
+
23.8.5 Overriding new and delete to allocate from Java heap
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 1f465dab5..31f8c47b7 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -824,20 +824,20 @@ If you have a function that expects binary data,
-int parity(char *str, int len, int initial);
+size_t parity(char *str, size_t len, size_t initial);
-you can wrap the parameters (char *str, int len) as a single
+you can wrap the parameters (char *str, size_t len) as a single
argument using a typemap. Just do this:
-%apply (char *STRING, int LENGTH) { (char *str, int len) };
+%apply (char *STRING, size_t LENGTH) { (char *str, size_t len) };
...
-int parity(char *str, int len, int initial);
+size_t parity(char *str, size_t len, size_t initial);
@@ -854,6 +854,7 @@ Now, in the target language, you can use binary string data like this:
In the wrapper function, the passed string will be expanded to a pointer and length parameter.
+The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).
8.3.3 Using %newobject to release memory
diff --git a/Examples/test-suite/char_binary.i b/Examples/test-suite/char_binary.i
new file mode 100644
index 000000000..778792946
--- /dev/null
+++ b/Examples/test-suite/char_binary.i
@@ -0,0 +1,29 @@
+/*
+A test case for testing non null terminated char pointers.
+*/
+
+%module char_binary
+
+%apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) }
+
+%inline %{
+struct Test {
+ size_t strlen(const char *str, size_t len) {
+ return len;
+ }
+};
+
+typedef char namet[5];
+namet var_namet;
+
+typedef char* pchar;
+pchar var_pchar;
+%}
+
+// Remove string handling typemaps and treat as pointer
+%typemap(freearg) SWIGTYPE * ""
+%apply SWIGTYPE * { char * }
+
+%include "carrays.i"
+%array_functions(char, pchar);
+
diff --git a/Examples/test-suite/java/char_binary_runme.java b/Examples/test-suite/java/char_binary_runme.java
new file mode 100644
index 000000000..9227f8617
--- /dev/null
+++ b/Examples/test-suite/java/char_binary_runme.java
@@ -0,0 +1,24 @@
+import char_binary.*;
+
+public class char_binary_runme {
+
+ static {
+ try {
+ System.loadLibrary("char_binary");
+ } 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[]) {
+ Test t = new Test();
+ byte[] hile = "hile".getBytes();
+ byte[] hil0 = "hil\0".getBytes();
+ if (t.strlen(hile) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+
+ if (t.strlen(hil0) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+ }
+}
diff --git a/Examples/test-suite/perl5/char_binary_runme.pl b/Examples/test-suite/perl5/char_binary_runme.pl
new file mode 100755
index 000000000..4c50ee700
--- /dev/null
+++ b/Examples/test-suite/perl5/char_binary_runme.pl
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('char_binary') }
+require_ok('char_binary');
+
+my $t = char_binary::Test->new();
+
+is($t->strlen('hile'), 4, "string typemap");
+
+is($t->strlen("hil\0"), 4, "string typemap");
+
+#
+# creating a raw char*
+#
+my $pc = char_binary::new_pchar(5);
+char_binary::pchar_setitem($pc, 0, 'h');
+char_binary::pchar_setitem($pc, 1, 'o');
+char_binary::pchar_setitem($pc, 2, 'l');
+char_binary::pchar_setitem($pc, 3, 'a');
+char_binary::pchar_setitem($pc, 4, 0);
+
+
+is($t->strlen($pc), 4, "string typemap");
+
+$char_binary::var_pchar = $pc;
+is($char_binary::var_pchar, "hola", "pointer case");
+
+$char_binary::var_namet = $pc;
+is($char_binary::var_namet, "hola", "pointer case");
+
+char_binary::delete_pchar($pc);
diff --git a/Examples/test-suite/perl5/primitive_types_runme.pl b/Examples/test-suite/perl5/primitive_types_runme.pl
index 6d7b05d8d..31604ad06 100755
--- a/Examples/test-suite/perl5/primitive_types_runme.pl
+++ b/Examples/test-suite/perl5/primitive_types_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 54;
+use Test::More tests => 51;
BEGIN { use_ok('primitive_types') }
require_ok('primitive_types');
@@ -179,11 +179,6 @@ $t->{var_namet} = 'hol';
is($t->{var_namet}, 'hol', "namet");
-is($t->strlen('hile'), 4, "string typemap");
-
-is($t->strlen("hil\0"), 4, "string typemap");
-
-
$primitive_types::var_char = "\0";
is($primitive_types::var_char, "\0", "char '0' case");
@@ -220,8 +215,6 @@ primitive_types::pchar_setitem($pc, 3, 'a');
primitive_types::pchar_setitem($pc, 4, 0);
-is($t->strlen($pc), 4, "string typemap");
-
$primitive_types::var_pchar = $pc;
is($primitive_types::var_pchar, "hola", "pointer case");
diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
index e00108b93..f912bd77c 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -355,8 +355,6 @@ macro(size_t, pfx, sizet)
%enddef
-%apply (char *STRING, int LENGTH) { (const char *str, size_t len) }
-
%inline {
struct Foo
{
@@ -464,15 +462,8 @@ macro(size_t, pfx, sizet)
%test_prim_types_ovr(ovr_decl, ovr)
- size_t strlen(const char *str, size_t len)
- {
- return len;
- }
-
static const double stc_double;
static const double stc_float;
-
-
};
struct TestDirector
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
new file mode 100644
index 000000000..b6d9c81c8
--- /dev/null
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -0,0 +1,36 @@
+from char_binary import *
+
+t = Test()
+if t.strlen('hile') != 4:
+ print t.strlen('hile')
+ raise RuntimeError, "bad multi-arg typemap"
+
+if t.strlen('hil\0') != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+#
+# creating a raw char*
+#
+pc = new_pchar(5)
+pchar_setitem(pc, 0, 'h')
+pchar_setitem(pc, 1, 'o')
+pchar_setitem(pc, 2, 'l')
+pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 4, 0)
+
+
+if t.strlen(pc) != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+cvar.var_pchar = pc
+if cvar.var_pchar != "hola":
+ print cvar.var_pchar
+ raise RuntimeError, "bad pointer case"
+
+cvar.var_namet = pc
+#if cvar.var_namet != "hola\0":
+if cvar.var_namet != "hola":
+ raise RuntimeError, "bad pointer case"
+
+delete_pchar(pc)
+
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index 02cc21763..2495cd60d 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -188,14 +188,6 @@ if t.var_namet != 'hol':
raise RuntimeError
-if t.strlen('hile') != 4:
- print t.strlen('hile')
- raise RuntimeError, "bad string typemap"
-
-if t.strlen('hil\0') != 4:
- raise RuntimeError, "bad string typemap"
-
-
cvar.var_char = '\0'
if cvar.var_char != '\0':
raise RuntimeError, "bad char '0' case"
@@ -244,9 +236,6 @@ pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
-if t.strlen(pc) != 4:
- raise RuntimeError, "bad string typemap"
-
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg
index 112780499..525c1a64c 100644
--- a/Lib/chicken/chicken.swg
+++ b/Lib/chicken/chicken.swg
@@ -538,7 +538,7 @@ $result = C_SCHEME_UNDEFINED;
* String & length
* ------------------------------------------------------------ */
-%typemap(in) (char *STRING, int LENGTH) {
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
if ($input == C_SCHEME_FALSE) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments");
}
diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i
index c194d4bc9..c31f1463f 100644
--- a/Lib/guile/typemaps.i
+++ b/Lib/guile/typemaps.i
@@ -348,7 +348,7 @@ typedef unsigned long SCM;
* String & length
* ------------------------------------------------------------ */
-%typemap(in) (char *STRING, int LENGTH) {
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
size_t temp;
$1 = ($1_ltype) gh_scm2newstr($input, &temp);
$2 = ($2_ltype) temp;
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 44e1337bc..159aafb17 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -1290,6 +1290,21 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
+/* String & length */
+%typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray"
+%typemap(jtype) (char *STRING, size_t LENGTH) "byte[]"
+%typemap(jstype) (char *STRING, size_t LENGTH) "byte[]"
+%typemap(javain) (char *STRING, size_t LENGTH) "$javainput"
+%typemap(freearg) (char *STRING, size_t LENGTH) ""
+%typemap(in) (char *STRING, size_t LENGTH) {
+ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
+ $2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
+}
+%typemap(argout) (char *STRING, size_t LENGTH) {
+ JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
+}
+%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
+
/* java keywords */
%include
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index f4cc8d2b2..ed336d6d2 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -76,8 +76,7 @@
$1 = ($1_ltype) Z_STRVAL_PP($input);
}
-%typemap(in) (char *STRING, int LENGTH)
-{
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
convert_to_string_ex($input);
$1 = ($1_ltype) Z_STRVAL_PP($input);
$2 = ($2_ltype) Z_STRLEN_PP($input);
diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg
index 0cfec52b0..130af1346 100644
--- a/Lib/pike/pike.swg
+++ b/Lib/pike/pike.swg
@@ -185,7 +185,7 @@ extern "C" {
* String & length
* ------------------------------------------------------------ */
-%typemap(in, pikedesc="tStr") (char *STRING, int LENGTH) {
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1 = ($1_ltype) STR0($input.u.string);
--
cgit v1.2.1
From ef3644f052850c970b107961562204d9321a23a6 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Fri, 14 Jan 2011 21:31:36 +0000
Subject: Add string & length typemap for Go.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12394 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/go/char_binary_runme.go | 25 +++++++++++++++++++++++++
Lib/go/go.swg | 23 +++++++++++++++++++++++
2 files changed, 48 insertions(+)
create mode 100644 Examples/test-suite/go/char_binary_runme.go
diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go
new file mode 100644
index 000000000..50f2e121d
--- /dev/null
+++ b/Examples/test-suite/go/char_binary_runme.go
@@ -0,0 +1,25 @@
+package main
+
+import . "./char_binary"
+
+func main() {
+ t := NewTest()
+ if t.Strlen("hile") != 4 {
+ print(t.Strlen("hile"))
+ panic("bad multi-arg typemap")
+ }
+
+ if t.Strlen("hil\000") != 4 {
+ panic("bad multi-arg typemap")
+ }
+
+ // creating a raw char*
+ pc := New_pchar(5)
+ Pchar_setitem(pc, 0, 'h')
+ Pchar_setitem(pc, 1, 'o')
+ Pchar_setitem(pc, 2, 'l')
+ Pchar_setitem(pc, 3, 'a')
+ Pchar_setitem(pc, 4, 0)
+
+ Delete_pchar(pc)
+}
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index 53a910221..587d219be 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -333,6 +333,28 @@
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
%{ $result = ($1_ltype)$input.p; %}
+/* String & length */
+
+%typemap(gotype) (char *STRING, size_t LENGTH) "string"
+
+%typemap(in) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
+%typemap(out) (char *STRING, size_t LENGTH)
+%{ $result = _swig_makegostring((char*)$1, (size_t)$2); %}
+
+%typemap(directorin) (char *STRING, size_t LENGTH)
+%{ $input = _swig_makegostring((char*)$1_name, $2_name); %}
+
+%typemap(directorout) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
/* Enums. We can't do the right thing for enums in typemap(gotype) so
we deliberately don't define them. The right thing would be to
capitalize the name. This is instead done in go.cxx. */
@@ -500,6 +522,7 @@
SWIGTYPE [],
SWIGTYPE (CLASS::*)
""
+
/* Go keywords. */
%include
--
cgit v1.2.1
From 3d7799fe0d519c05817392678974555c09b629c6 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 17 Jan 2011 21:12:35 +0000
Subject: New warning when the smartptr feature is missing in some classes in
an inheritance chain. Errors test-suite now uses Python instead of Tcl as
testing language
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12395 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 9 +++++
Doc/Manual/Library.html | 61 +++++++++++++++++++++++------
Doc/Manual/Warnings.html | 1 +
Examples/test-suite/errors/cpp_shared_ptr.i | 29 ++++++++++++++
Examples/test-suite/errors/expected.log | 6 +++
Examples/test-suite/errors/make.sh | 5 ++-
Source/Include/swigwarn.h | 1 +
Source/Modules/typepass.cxx | 5 +++
8 files changed, 104 insertions(+), 13 deletions(-)
create mode 100644 Examples/test-suite/errors/cpp_shared_ptr.i
diff --git a/CHANGES.current b/CHANGES.current
index 20524df69..57b639421 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.2 (in progress)
===========================
+2010-01-17: wsfulton
+ New warning for smart pointers if only some of the classes in the inheritance
+ chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
+ in an inheritance hierarchy, so this new warning highlights code where this is
+ not the case.
+
+ example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
+ example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
+
2010-01-14: wsfulton
Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
(char *STRING, int LENGTH). Documentation for this updated. Java patch from
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 31f8c47b7..02b8e53bd 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -1803,28 +1803,67 @@ struct DerivedIntValue : IntValue {
-Note that if the %shared_ptr macro is omitted for any class in the inheritance hierarchy, it will
-result in a C++ compiler error.
-For example if the above %shared_ptr(DerivedIntValue) is omitted, the following is typical of the compiler error that will result:
+A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:
+
+
+
+
+DerivedIntValue div = new DerivedIntValue(5678);
+int val3 = example.extractValue(div);
+int val4 = example.extractValueSmart(div);
+
+
+
+
+If the %shared_ptr macro is omitted for any class in the inheritance hierarchy, SWIG will warn about this and the generated code may or may not result in a C++ compilation error.
+For example, the following input:
+
+warns about the missing smart pointer information:
-example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*,
-_jclass*, jlong)':
-example_wrap.cxx:3169: error: 'smartarg1' was not declared in this scope
+example.i:12: Warning 520: Base class 'GrandParent' of 'Parent' is not similarly marked as a smart pointer.
+example.i:16: Warning 520: Derived class 'Child' of 'Parent' is not similarly marked as a smart pointer.
-A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:
+Adding the missing %shared_ptr macros will fix this:
-
+
-DerivedIntValue div = new DerivedIntValue(5678);
-int val3 = example.extractValue(div);
-int val4 = example.extractValueSmart(div);
+%include "boost_shared_ptr.i"
+%shared_ptr(GrandParent);
+%shared_ptr(Parent);
+%shared_ptr(Child);
+
+... as before ...
518. Portability warning: File file1 will be overwritten by file2 on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
519. %template() contains no name. Template method ignored: declaration
+
520. Base/Derived class 'classname1' of 'classname2' is not similarly marked as a smart pointer.
14.9.6 Language module specific (700-899)
diff --git a/Examples/test-suite/errors/cpp_shared_ptr.i b/Examples/test-suite/errors/cpp_shared_ptr.i
new file mode 100644
index 000000000..edbd0cf87
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_shared_ptr.i
@@ -0,0 +1,29 @@
+%module cpp_shared_ptr
+
+%include
+
+%shared_ptr(B);
+%shared_ptr(C);
+
+%inline %{
+ #include
+ #include
+
+ struct A {
+ virtual ~A() {}
+ };
+
+ struct B {
+ virtual ~B() {}
+ };
+
+ struct C : B, A {
+ virtual ~C() {}
+ };
+
+ struct D : C {
+ virtual ~D() {}
+ };
+%}
+
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index 06942064f..e6430293b 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -10,6 +10,7 @@ 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_class.i:3: Warning 314: 'class' is a python keyword, renaming to '_class'
:::::::::::::::::::::::::::::::: c_default_error.i :::::::::::::::::::::::::::::::::::
@@ -280,6 +281,11 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
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_shared_ptr.i :::::::::::::::::::::::::::::::::::
+cpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer.
+cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer.
+cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'B' is not similarly marked as a smart pointer.
+
:::::::::::::::::::::::::::::::: cpp_template_argname.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_template_nargs.i :::::::::::::::::::::::::::::::::::
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index 52d6c8967..875d1ecbe 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -76,6 +76,7 @@ cpp_nobase
cpp_overload
cpp_private_defvalue
cpp_private_inherit
+cpp_shared_ptr
cpp_template_argname
cpp_template_nargs
cpp_template_not
@@ -98,14 +99,14 @@ for i in ${CFILES}; do
echo " Testing : ${i}.i";
echo "" >> ${LOGFILE};
echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
- ${SWIG} -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+ ${SWIG} -python -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
done
for i in ${CPPFILES}; do
echo " Testing : ${i}.i";
echo "" >> ${LOGFILE}
echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
- ${SWIG} -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+ ${SWIG} -python -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
done
echo ""
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index b13015994..9c5c3be74 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -193,6 +193,7 @@
#define WARN_LANG_DIRECTOR_ABSTRACT 517
#define WARN_LANG_PORTABILITY_FILENAME 518
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
+#define WARN_LANG_SMARTPTR_MISSING 520
/* -- Reserved (600-799) -- */
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 438b66617..8751b1e67 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -254,12 +254,17 @@ class TypePass:private Dispatcher {
Delete(smartnamestr);
/* setup inheritance relationship between smart pointer templates */
SwigType_inherit(smart, bsmart, 0, convcode);
+ if (!GetFlag(bclass, "feature:smartptr"))
+ Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
Delete(convcode);
Delete(bsmart);
Delete(smart);
} else {
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
}
+ } else {
+ if (GetFlag(bclass, "feature:smartptr"))
+ Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
}
if (!importmode) {
String *btype = Copy(bname);
--
cgit v1.2.1
From 5d99aa78646ac65ce36fc0fd1aa0c06a246c9d5d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 17 Jan 2011 21:20:29 +0000
Subject: Remove svn:executable property
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12396 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/threads_exception.i | 0
1 file changed, 0 insertions(+), 0 deletions(-)
mode change 100755 => 100644 Examples/test-suite/threads_exception.i
diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i
old mode 100755
new mode 100644
--
cgit v1.2.1
From a440369e35fac6b4deb6757ed84e6e4f0bfc41d2 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 17 Jan 2011 21:25:04 +0000
Subject: Move a couple of runme files which into the correct directories
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12397 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/d/director_alternating_runme.1.d | 7 +++++++
Examples/test-suite/director_alternating_runme.1.d | 7 -------
Examples/test-suite/octave/samename_runme.m | 1 +
Examples/test-suite/samename_runme.m | 1 -
4 files changed, 8 insertions(+), 8 deletions(-)
create mode 100644 Examples/test-suite/d/director_alternating_runme.1.d
delete mode 100644 Examples/test-suite/director_alternating_runme.1.d
create mode 100644 Examples/test-suite/octave/samename_runme.m
delete mode 100644 Examples/test-suite/samename_runme.m
diff --git a/Examples/test-suite/d/director_alternating_runme.1.d b/Examples/test-suite/d/director_alternating_runme.1.d
new file mode 100644
index 000000000..27bd262fd
--- /dev/null
+++ b/Examples/test-suite/d/director_alternating_runme.1.d
@@ -0,0 +1,7 @@
+module director_alternating_runme;
+
+import director_alternating.director_alternating;
+
+void main() {
+ assert(getBar().id() == idFromGetBar());
+}
diff --git a/Examples/test-suite/director_alternating_runme.1.d b/Examples/test-suite/director_alternating_runme.1.d
deleted file mode 100644
index 27bd262fd..000000000
--- a/Examples/test-suite/director_alternating_runme.1.d
+++ /dev/null
@@ -1,7 +0,0 @@
-module director_alternating_runme;
-
-import director_alternating.director_alternating;
-
-void main() {
- assert(getBar().id() == idFromGetBar());
-}
diff --git a/Examples/test-suite/octave/samename_runme.m b/Examples/test-suite/octave/samename_runme.m
new file mode 100644
index 000000000..a3864cfc8
--- /dev/null
+++ b/Examples/test-suite/octave/samename_runme.m
@@ -0,0 +1 @@
+samename
diff --git a/Examples/test-suite/samename_runme.m b/Examples/test-suite/samename_runme.m
deleted file mode 100644
index a3864cfc8..000000000
--- a/Examples/test-suite/samename_runme.m
+++ /dev/null
@@ -1 +0,0 @@
-samename
--
cgit v1.2.1
From 53bb72333dca1b33e6a6c8b3cfcaf933bf9a0a90 Mon Sep 17 00:00:00 2001
From: Ian Lance Taylor
Date: Mon, 17 Jan 2011 23:41:33 +0000
Subject: Document current required Go version.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12398 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CHANGES.current b/CHANGES.current
index 57b639421..db28fbc2c 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -19,6 +19,9 @@ Version 2.0.2 (in progress)
(char *STRING, int LENGTH). Documentation for this updated. Java patch from
Volker Grabsch.
+2010-01-11: iant
+ Require Go version 7077 or later.
+
2010-12-30: klickverbot
[C#, D, Java] Check for collision of parameter names with target
language keywords when generating the director glue code.
--
cgit v1.2.1
From 2a449306f18ec59c81d06072a5a3ab4799029ec1 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 18 Jan 2011 06:53:59 +0000
Subject: Fix D test-suite clean
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12399 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/d/Makefile.in | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
index ec13fede3..0f5bf8cbb 100644
--- a/Examples/test-suite/d/Makefile.in
+++ b/Examples/test-suite/d/Makefile.in
@@ -76,6 +76,6 @@ run_testcase = \
# Clean: remove testcase directories
%.clean:
- @if [ -d $* ]; then \
- rm -rf $*; \
+ @if [ -d $*$(VERSIONSUFFIX) ]; then \
+ rm -rf $*$(VERSIONSUFFIX); \
fi
--
cgit v1.2.1
From 2f0dc16b2e011edcc3427c660a89a055d3e4ad4e Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Mon, 24 Jan 2011 19:27:06 +0000
Subject: Fix C# typemaps.i so that %apply works doesn't break function returns
using the same types, for example, %apply int &INPUT { int & } won't break
'int &foo(int &x);'
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12400 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/li_typemaps_apply.i | 46 +++++++++++++++++++++++++++++++++
Lib/csharp/typemaps.i | 21 +++++++--------
2 files changed, 55 insertions(+), 12 deletions(-)
create mode 100644 Examples/test-suite/li_typemaps_apply.i
diff --git a/Examples/test-suite/li_typemaps_apply.i b/Examples/test-suite/li_typemaps_apply.i
new file mode 100644
index 000000000..ecb3f87b6
--- /dev/null
+++ b/Examples/test-suite/li_typemaps_apply.i
@@ -0,0 +1,46 @@
+%module li_typemaps_apply
+
+// Test %apply to global primitive type references/pointers to make sure the return types are still okay... mainly for the strongly typed languages.
+
+%include "typemaps.i"
+
+#if !defined(SWIGJAVA) // Needs asymmetric type marshalling support for this testcase to work
+
+%define TMAPS(PRIMTYPE, NAME)
+%apply PRIMTYPE *INPUT { PRIMTYPE * }
+%apply PRIMTYPE &INPUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *input_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; return &stat; }
+PRIMTYPE &input_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; return stat; }
+%}
+
+%apply PRIMTYPE *OUTPUT { PRIMTYPE * }
+%apply PRIMTYPE &OUTPUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *output_ptr_##NAME(PRIMTYPE x, PRIMTYPE *v) { static PRIMTYPE stat; stat = x; *v = x; return &stat; }
+PRIMTYPE &output_ref_##NAME(PRIMTYPE x, PRIMTYPE &v) { static PRIMTYPE stat; stat = x; v = x; return stat; }
+%}
+
+%apply PRIMTYPE *INOUT { PRIMTYPE * }
+%apply PRIMTYPE &INOUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *inout_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; *v = *v; return &stat; }
+PRIMTYPE &inout_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; v = v; return stat; }
+%}
+%enddef
+
+TMAPS(bool, bool)
+TMAPS(int, int)
+TMAPS(short, short)
+TMAPS(long, long)
+TMAPS(unsigned int, uint)
+TMAPS(unsigned short, ushort)
+TMAPS(unsigned long, ulong)
+TMAPS(unsigned char, uchar)
+TMAPS(signed char, schar)
+TMAPS(float, float)
+TMAPS(double, double)
+TMAPS(long long, longlong)
+TMAPS(unsigned long long, ulonglong)
+
+#endif
diff --git a/Lib/csharp/typemaps.i b/Lib/csharp/typemaps.i
index d50e5c46d..7bca83c12 100644
--- a/Lib/csharp/typemaps.i
+++ b/Lib/csharp/typemaps.i
@@ -51,13 +51,12 @@ or you can use the %apply directive :
In C# you could then use it like this:
double answer = modulename.fadd(10.0, 20.0);
-
*/
%define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE)
-%typemap(ctype) TYPE *INPUT, TYPE &INPUT "CTYPE"
-%typemap(imtype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
-%typemap(cstype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
+%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
+%typemap(imtype, out="IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE"
+%typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE"
%typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput"
%typemap(csdirectorin) TYPE *INPUT, TYPE &INPUT "$iminput"
%typemap(csdirectorout) TYPE *INPUT, TYPE &INPUT "$cscall"
@@ -143,18 +142,16 @@ value returned in the second output parameter. In C# you would use it like this:
double dptr;
double fraction = modulename.modf(5, out dptr);
-
*/
%define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
-%typemap(ctype) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
-%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
-%typemap(cstype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
+%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
+%typemap(imtype, out="IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
+%typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
%typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput"
%typemap(csdirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$iminput"
%typemap(csdirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$cscall"
-
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
%{ $1 = ($1_ltype)$input; %}
@@ -250,9 +247,9 @@ of the function return value.
*/
%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
-%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *"
-%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
-%typemap(cstype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
+%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
+%typemap(imtype, out="IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
+%typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
%typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput"
%typemap(csdirectorin) TYPE *INOUT, TYPE &INOUT "$iminput"
%typemap(csdirectorout) TYPE *INOUT, TYPE &INOUT "$cscall"
--
cgit v1.2.1
From 3d822b60323378a59ed19ed02c9f21764d77cf7f Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 28 Jan 2011 19:50:57 +0000
Subject: expand protected using testcase
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12404 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/using_protected.i | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/Examples/test-suite/using_protected.i b/Examples/test-suite/using_protected.i
index 23adfdbba..402a7c8da 100644
--- a/Examples/test-suite/using_protected.i
+++ b/Examples/test-suite/using_protected.i
@@ -3,14 +3,23 @@
%inline %{
class Foo {
protected:
- int x;
- int blah(int xx) { return xx; }
+ int x;
+ int blah(int xx) { return xx; }
+ virtual int vmethod(int xx) { return xx; }
};
class FooBar : public Foo {
public:
- using Foo::blah;
- using Foo::x;
+ using Foo::blah;
+ using Foo::x;
+ using Foo::vmethod;
+};
+
+class FooBaz : public Foo {
+protected:
+ using Foo::blah;
+ using Foo::x;
+ using Foo::vmethod;
};
%}
--
cgit v1.2.1
From 85ed05c24142a61974c16c8ebaf83170c8b7b141 Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 21:31:40 +0000
Subject: [D] Tiny typo fix.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12405 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Source/Modules/d.cxx | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
index 9937452a9..cc1bd2365 100644
--- a/Source/Modules/d.cxx
+++ b/Source/Modules/d.cxx
@@ -3661,7 +3661,7 @@ private:
String *getPrimitiveDptype(Node *node, SwigType *type) {
SwigType *stripped_type = SwigType_typedef_resolve_all(type);
- // A reference can only be the »outermost element« of a typ.
+ // A reference can only be the »outermost element« of a type.
bool mutable_ref = false;
if (SwigType_isreference(stripped_type)) {
SwigType_del_reference(stripped_type);
--
cgit v1.2.1
From 160ee9c937dc0a987f2783dd4a231db1349ae9b6 Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 21:31:53 +0000
Subject: [D] Support for C++ references to primitive types.
I am not sure why these typemaps were missing before since I included code for this in the C++ part of the feature, but please let me know if I missed some case where this could break generated code.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12406 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/d/dswigtype.swg | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg
index 5bb0bd951..41336dc91 100644
--- a/Lib/d/dswigtype.swg
+++ b/Lib/d/dswigtype.swg
@@ -18,7 +18,7 @@
%typemap(ctype) SWIGTYPE & "void *"
%typemap(imtype) SWIGTYPE & "void*"
-%typemap(dtype) SWIGTYPE & "$dclassname"
+%typemap(dtype, nativepointer="$dtype") SWIGTYPE & "$dclassname"
%typemap(ctype) SWIGTYPE *const& "void *"
%typemap(imtype) SWIGTYPE *const& "void*"
@@ -131,11 +131,18 @@
}
$result = ($1_ltype)$input; %}
-%typemap(ddirectorin) SWIGTYPE & "new $dclassname($winput, false)"
-%typemap(ddirectorout) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)"
+%typemap(ddirectorin,
+ nativepointer="cast($dtype)$winput"
+) SWIGTYPE & "new $dclassname($winput, false)"
+%typemap(ddirectorout,
+ nativepointer="cast(void*)$dcall"
+) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)"
-%typemap(din) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)"
-%typemap(dout, excode=SWIGEXCODE) SWIGTYPE & {
+%typemap(din,
+ nativepointer="cast(void*)$dinput"
+) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)"
+%typemap(dout, excode=SWIGEXCODE,
+ nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE & {
$dclassname ret = new $dclassname($imcall, $owner);$excode
return ret;
}
--
cgit v1.2.1
From b9d12afa7cd4696fcaf6be562ddebe6058a0a297 Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 21:32:11 +0000
Subject: =?UTF-8?q?[D]=20Test=20C++=20references=20in=20=C2=BBd=5Fnativepo?=
=?UTF-8?q?inters=C2=AB;=20normalized=20indentation.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12407 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/d/d_nativepointers_runme.1.d | 33 +++++++++++++++++-------
Examples/test-suite/d/d_nativepointers_runme.2.d | 33 +++++++++++++++++-------
Examples/test-suite/d_nativepointers.i | 3 +++
3 files changed, 49 insertions(+), 20 deletions(-)
diff --git a/Examples/test-suite/d/d_nativepointers_runme.1.d b/Examples/test-suite/d/d_nativepointers_runme.1.d
index 00407c1db..797c057d3 100644
--- a/Examples/test-suite/d/d_nativepointers_runme.1.d
+++ b/Examples/test-suite/d/d_nativepointers_runme.1.d
@@ -7,17 +7,30 @@ import d_nativepointers.SWIGTYPE_p_p_SomeClass;
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
void main() {
- check!(a, int*);
- check!(b, float**);
- check!(c, char***);
- check!(d, SomeClass);
- check!(e, SWIGTYPE_p_p_SomeClass);
- check!(f, SWIGTYPE_p_OpaqueClass);
- check!(g, void function(int**, char***));
- check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
+ check!(a, int*);
+ check!(b, float**);
+ check!(c, char***);
+ check!(d, SomeClass);
+ check!(e, SWIGTYPE_p_p_SomeClass);
+ check!(f, SWIGTYPE_p_OpaqueClass);
+ check!(g, void function(int**, char***));
+ check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
+
+ {
+ static assert(is(int* function(int*) == typeof(&refA)));
+ int v = 2;
+ assert(*refA(&v) == 2);
+ }
+
+ {
+ static assert(is(float** function(float**) == typeof(&refB)));
+ float v = 1.0;
+ float* p = &v;
+ assert(**refB(&p) == 1.0);
+ }
}
void check(alias F, T)() {
- static assert(is(T function(T) == typeof(&F)));
- assert(F(null) is null);
+ static assert(is(T function(T) == typeof(&F)));
+ assert(F(null) is null);
}
diff --git a/Examples/test-suite/d/d_nativepointers_runme.2.d b/Examples/test-suite/d/d_nativepointers_runme.2.d
index 00407c1db..797c057d3 100644
--- a/Examples/test-suite/d/d_nativepointers_runme.2.d
+++ b/Examples/test-suite/d/d_nativepointers_runme.2.d
@@ -7,17 +7,30 @@ import d_nativepointers.SWIGTYPE_p_p_SomeClass;
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
void main() {
- check!(a, int*);
- check!(b, float**);
- check!(c, char***);
- check!(d, SomeClass);
- check!(e, SWIGTYPE_p_p_SomeClass);
- check!(f, SWIGTYPE_p_OpaqueClass);
- check!(g, void function(int**, char***));
- check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
+ check!(a, int*);
+ check!(b, float**);
+ check!(c, char***);
+ check!(d, SomeClass);
+ check!(e, SWIGTYPE_p_p_SomeClass);
+ check!(f, SWIGTYPE_p_OpaqueClass);
+ check!(g, void function(int**, char***));
+ check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
+
+ {
+ static assert(is(int* function(int*) == typeof(&refA)));
+ int v = 2;
+ assert(*refA(&v) == 2);
+ }
+
+ {
+ static assert(is(float** function(float**) == typeof(&refB)));
+ float v = 1.0;
+ float* p = &v;
+ assert(**refB(&p) == 1.0);
+ }
}
void check(alias F, T)() {
- static assert(is(T function(T) == typeof(&F)));
- assert(F(null) is null);
+ static assert(is(T function(T) == typeof(&F)));
+ assert(F(null) is null);
}
diff --git a/Examples/test-suite/d_nativepointers.i b/Examples/test-suite/d_nativepointers.i
index b681844f5..fdf3f1669 100644
--- a/Examples/test-suite/d_nativepointers.i
+++ b/Examples/test-suite/d_nativepointers.i
@@ -15,4 +15,7 @@
OpaqueClass *f( OpaqueClass *value ){ return value; }
FuncA g( FuncA value ){ return value; }
FuncB* h( FuncB* value ){ return value; }
+
+ int &refA( int &value ){ return value; }
+ float *&refB( float *&value ){ return value; }
%}
--
cgit v1.2.1
From de53ede68136bcb49c96525d0ef7e34bfef5c500 Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 21:32:23 +0000
Subject: [D] Fix byte/ubyte confusion in typemaps.i.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12408 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/d/typemaps.i | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/Lib/d/typemaps.i b/Lib/d/typemaps.i
index dcbd7a1cb..6206c6027 100644
--- a/Lib/d/typemaps.i
+++ b/Lib/d/typemaps.i
@@ -176,8 +176,8 @@ value returned in the second output parameter. In D you would use it like this:
OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
//OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) // Why was this commented out?
-OUTPUT_TYPEMAP(signed char, signed char, ubyte, INT8_PTR)
-OUTPUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR)
+OUTPUT_TYPEMAP(signed char, signed char, byte, INT8_PTR)
+OUTPUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR)
OUTPUT_TYPEMAP(short, short, short, INT16_PTR)
OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
OUTPUT_TYPEMAP(int, int, int, INT32_PTR)
@@ -279,8 +279,8 @@ of the function return value.
INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
//INOUT_TYPEMAP(char, char, char, CHAR_PTR)
-INOUT_TYPEMAP(signed char, signed char, ubyte, INT8_PTR)
-INOUT_TYPEMAP(unsigned char, unsigned char, byte, UINT8_PTR)
+INOUT_TYPEMAP(signed char, signed char, byte, INT8_PTR)
+INOUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR)
INOUT_TYPEMAP(short, short, short, INT16_PTR)
INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
INOUT_TYPEMAP(int, int, int, INT32_PTR)
--
cgit v1.2.1
From 828fac25cb9ff62e0742490ec89c82565ce32f55 Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 21:32:36 +0000
Subject: [D] Don't break function return types in typemaps.i.
This fixes the new "li_typemaps_apply" testcase as done for C# in r12400.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12409 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Lib/d/typemaps.i | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/Lib/d/typemaps.i b/Lib/d/typemaps.i
index 6206c6027..21cd848af 100644
--- a/Lib/d/typemaps.i
+++ b/Lib/d/typemaps.i
@@ -54,9 +54,9 @@ In D you could then use it like this:
*/
%define INPUT_TYPEMAP(TYPE, CTYPE, DTYPE)
-%typemap(ctype) TYPE *INPUT, TYPE &INPUT "CTYPE"
-%typemap(imtype) TYPE *INPUT, TYPE &INPUT "DTYPE"
-%typemap(dtype) TYPE *INPUT, TYPE &INPUT "DTYPE"
+%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
+%typemap(imtype, out="void*") TYPE *INPUT, TYPE &INPUT "DTYPE"
+%typemap(dtype, out="DTYPE*") TYPE *INPUT, TYPE &INPUT "DTYPE"
%typemap(din) TYPE *INPUT, TYPE &INPUT "$dinput"
%typemap(ddirectorin) TYPE *INPUT, TYPE &INPUT "$winput"
%typemap(ddirectorout) TYPE *INPUT, TYPE &INPUT "$dcall"
@@ -149,9 +149,9 @@ value returned in the second output parameter. In D you would use it like this:
*/
%define OUTPUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
-%typemap(ctype) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
-%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
-%typemap(dtype) TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
+%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
+%typemap(imtype, out="void*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
+%typemap(dtype, out="DTYPE*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
%typemap(din) TYPE *OUTPUT, TYPE &OUTPUT "$dinput"
%typemap(ddirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$winput"
%typemap(ddirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$dcall"
@@ -254,9 +254,9 @@ of the function return value.
*/
%define INOUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
-%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *"
-%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref DTYPE"
-%typemap(dtype) TYPE *INOUT, TYPE &INOUT "ref DTYPE"
+%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
+%typemap(imtype, out="void*") TYPE *INOUT, TYPE &INOUT "ref DTYPE"
+%typemap(dtype, out="DTYPE*") TYPE *INOUT, TYPE &INOUT "ref DTYPE"
%typemap(din) TYPE *INOUT, TYPE &INOUT "$dinput"
%typemap(ddirectorin) TYPE *INOUT, TYPE &INOUT "$winput"
%typemap(ddirectorout) TYPE *INOUT, TYPE &INOUT "$dcall"
--
cgit v1.2.1
From 17ad1105437d3d79b7e8a92c8a27760cde2966cb Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 29 Jan 2011 21:53:16 +0000
Subject: Add li_typemaps_apply to tests
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12410 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/common.mk | 1 +
1 file changed, 1 insertion(+)
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index d2b9bc254..a0ae5e4ff 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -230,6 +230,7 @@ CPP_TEST_CASES += \
li_cpointer \
li_stdint \
li_typemaps \
+ li_typemaps_apply \
li_windows \
long_long_apply \
memberin_extend \
--
cgit v1.2.1
From 0efe5294ed6d3e3ef84407c7d5fba1fcc8c2e397 Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 23:03:51 +0000
Subject: [D] Docs: Cosmetic fix to $imcall HTML anchor name.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12411 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/D.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
index f6f87d2a4..747275753 100644
--- a/Doc/Manual/D.html
+++ b/Doc/Manual/D.html
@@ -136,7 +136,7 @@
The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced).
-
The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).
+
The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).
The code from the ddirectorin and ddirectorout typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from ddirectorin, the proxy class method return value is converted to the type the C++ code expects via the ddirectorout typemap (the $dcall and $winput macros are replaced).
These variables are used in dout typemaps. $imcall contains the call to the intermediary module which provides the value to be used, and $owner signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via %newobject).
Consider the following example:
--
cgit v1.2.1
From 0731ad0a6a4398139147d6836364f078a67c639a Mon Sep 17 00:00:00 2001
From: David Nadlinger
Date: Sat, 29 Jan 2011 23:04:06 +0000
Subject: [D] Docs: Mention the "pre", "post" and "terminator" din typemap
attributes.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12412 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/D.html | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
index 747275753..6f65db1e4 100644
--- a/Doc/Manual/D.html
+++ b/Doc/Manual/D.html
@@ -134,7 +134,7 @@
Typemaps for code generation in D proxy and type wrapper classes.
-
The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced).
+
The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the pre, post and terminator attributes can be used (please refer to the C# date marshalling example for more information on these).
The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).
@@ -146,7 +146,7 @@
type CPPClass::method(type a)
↑ ↓
<directorout> <directorin>
- ↑ ↓
+ ↑ ↓
ctype methodCallback(ctype a) C++
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
imtype methodCallback(imtype a) D
--
cgit v1.2.1
From 640cce2c50ac3fa86f8575fe5262c1fd257dbb44 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 30 Jan 2011 00:42:27 +0000
Subject: Fix typecheck typemaps for SWIGTYPE *const&
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12413 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 10 +++++++---
Examples/test-suite/csharp/pointer_reference_runme.cs | 3 +++
Examples/test-suite/java/pointer_reference_runme.java | 3 +++
Examples/test-suite/lua/pointer_reference_runme.lua | 2 ++
Examples/test-suite/php/pointer_reference_runme.php | 3 +++
Examples/test-suite/pointer_reference.i | 6 ++++++
Examples/test-suite/python/pointer_reference_runme.py | 16 ++++++++++++++++
Lib/php/php.swg | 6 ++++++
Lib/typemaps/swigtype.swg | 2 +-
9 files changed, 47 insertions(+), 4 deletions(-)
create mode 100644 Examples/test-suite/python/pointer_reference_runme.py
diff --git a/CHANGES.current b/CHANGES.current
index db28fbc2c..fda995085 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,7 +5,11 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.2 (in progress)
===========================
-2010-01-17: wsfulton
+2011-01-30: wsfulton
+ Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
+ number of scripting languages.
+
+2011-01-17: wsfulton
New warning for smart pointers if only some of the classes in the inheritance
chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
in an inheritance hierarchy, so this new warning highlights code where this is
@@ -14,12 +18,12 @@ Version 2.0.2 (in progress)
example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
-2010-01-14: wsfulton
+2011-01-14: wsfulton
Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
(char *STRING, int LENGTH). Documentation for this updated. Java patch from
Volker Grabsch.
-2010-01-11: iant
+2011-01-11: iant
Require Go version 7077 or later.
2010-12-30: klickverbot
diff --git a/Examples/test-suite/csharp/pointer_reference_runme.cs b/Examples/test-suite/csharp/pointer_reference_runme.cs
index d00555199..2b9f526af 100644
--- a/Examples/test-suite/csharp/pointer_reference_runme.cs
+++ b/Examples/test-suite/csharp/pointer_reference_runme.cs
@@ -12,6 +12,9 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.instance.value != 20) throw new Exception("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new Exception("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new Exception("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/java/pointer_reference_runme.java b/Examples/test-suite/java/pointer_reference_runme.java
index e8bd6800e..284951611 100644
--- a/Examples/test-suite/java/pointer_reference_runme.java
+++ b/Examples/test-suite/java/pointer_reference_runme.java
@@ -19,5 +19,8 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.getInstance().getValue() != 20) throw new RuntimeException("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new RuntimeException("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new RuntimeException("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/lua/pointer_reference_runme.lua b/Examples/test-suite/lua/pointer_reference_runme.lua
index 959d5a2a3..428c76998 100644
--- a/Examples/test-suite/lua/pointer_reference_runme.lua
+++ b/Examples/test-suite/lua/pointer_reference_runme.lua
@@ -9,3 +9,5 @@ ss = pointer_reference.Struct(20);
pointer_reference.set(ss);
assert(pointer_reference.Struct_instance.value == 20)
+assert(pointer_reference.overloading(1) == 111)
+assert(pointer_reference.overloading(ss) == 222)
diff --git a/Examples/test-suite/php/pointer_reference_runme.php b/Examples/test-suite/php/pointer_reference_runme.php
index 782760a37..52946177e 100644
--- a/Examples/test-suite/php/pointer_reference_runme.php
+++ b/Examples/test-suite/php/pointer_reference_runme.php
@@ -11,5 +11,8 @@ pointer_reference::set($ss);
$i = Struct::instance();
check::equal($i->value, 20, "pointer_reference::set() failed");
+check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed");
+check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed");
+
check::done();
?>
diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i
index c57a32374..b9e126fd4 100644
--- a/Examples/test-suite/pointer_reference.i
+++ b/Examples/test-suite/pointer_reference.i
@@ -35,6 +35,12 @@ void set(Struct *const& s) {
Struct *const& get() {
return Struct::pInstance;
}
+int overloading(int i) {
+ return 111;
+}
+int overloading(Struct *const& s) {
+ return 222;
+}
%}
%{
diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py
new file mode 100644
index 000000000..e1a1a1f4b
--- /dev/null
+++ b/Examples/test-suite/python/pointer_reference_runme.py
@@ -0,0 +1,16 @@
+import pointer_reference
+
+s = pointer_reference.get()
+if s.value != 10:
+ raise RuntimeError, "get test failed"
+
+ss = pointer_reference.Struct(20)
+pointer_reference.set(ss)
+if pointer_reference.cvar.Struct_instance.value != 20:
+ raise RuntimeError, "set test failed"
+
+if pointer_reference.overloading(1) != 111:
+ raise RuntimeError, "overload test 1 failed"
+
+if pointer_reference.overloading(ss) != 222:
+ raise RuntimeError, "overload test 2 failed"
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index ed336d6d2..db3b3ed09 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -446,6 +446,12 @@
_v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
}
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
+{
+ void *tmp;
+ _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $*1_descriptor, 0) >= 0);
+}
+
%typecheck(SWIG_TYPECHECK_VOIDPTR) void *
{
void *tmp;
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index f57766962..bd113e278 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -301,7 +301,7 @@
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& {
void *vptr = 0;
- int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ int res = SWIG_ConvertPtr($input, &vptr, $*descriptor, 0);
$1 = SWIG_CheckState(res);
}
--
cgit v1.2.1
From 96609f350e9d895f4c8f844b0b7cacfd8ca95feb Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sun, 30 Jan 2011 00:46:31 +0000
Subject: Document behaviour of --without- options
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12414 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
README | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/README b/README
index 975870626..818eb0ff7 100644
--- a/README
+++ b/README
@@ -88,6 +88,10 @@ uses. Don't panic if you get 'not found' messages--SWIG does not need these
packages to compile or run. The configure script is actually looking for
these packages so that you can try out the SWIG examples contained
in the 'Examples' directory without having to hack Makefiles.
+Note that the --without-xxx options, where xxx is a target language, have
+minimal effect. All they do is reduce the amount of testing done with
+'make check'. The SWIG executable and library files installed cannot currently
+be configured with a subset of target languages.
Please see the Documentation section below on installing documentation as
none is installed by default.
--
cgit v1.2.1
From 4a73d986ddc26fd8eab62219090a4bc4bb55a453 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 1 Feb 2011 07:02:50 +0000
Subject: Any 'using' statements in the protected section of a class were
previously ignored with dirprot mode, certainly with Java and C#. Also
directors - a call to a method being defined in the base class, not
overridden in a subcalss, but again overridden in a class derived from the
first subclass was not being dispatched correcly to the most derived class -
affecting non-scripting languages. Fix for C# is based on recent fix for D.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12419 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 10 +++++
.../csharp/director_alternating_runme.cs | 11 ++++++
.../test-suite/csharp/director_protected_runme.cs | 28 ++++++++++++++
Examples/test-suite/director_protected.i | 13 +++++++
Examples/test-suite/director_using.i | 15 +++++++-
.../test-suite/java/director_protected_runme.java | 32 +++++++++++++++-
.../test-suite/php/director_protected_runme.php | 21 ++++++++++-
.../test-suite/python/director_protected_runme.py | 43 +++++++++++++++++++++-
Source/Modules/csharp.cxx | 27 ++++++++++----
Source/Modules/lang.cxx | 25 +++++++++----
Source/Modules/typepass.cxx | 1 +
Source/Swig/naming.c | 4 +-
12 files changed, 209 insertions(+), 21 deletions(-)
create mode 100644 Examples/test-suite/csharp/director_alternating_runme.cs
diff --git a/CHANGES.current b/CHANGES.current
index fda995085..216484693 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)
===========================
+2011-02-01: wsfulton
+ [C#] Directors - a call to a method being defined in the base class, not
+ overridden in a subclass, but again overridden in a class derived from
+ the first subclass was not being dispatched correctly to the most derived class.
+ See director_alternating.i for an example.
+
+2011-02-01: wsfulton
+ [C#, Java] Any 'using' statements in the protected section of a class were previously
+ ignored with director protected (dirprot) mode.
+
2011-01-30: wsfulton
Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
number of scripting languages.
diff --git a/Examples/test-suite/csharp/director_alternating_runme.cs b/Examples/test-suite/csharp/director_alternating_runme.cs
new file mode 100644
index 000000000..19365217a
--- /dev/null
+++ b/Examples/test-suite/csharp/director_alternating_runme.cs
@@ -0,0 +1,11 @@
+
+using System;
+using director_alternatingNamespace;
+
+public class director_alternating_runme {
+ public static void Main() {
+ if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
+ throw new Exception("idFromGetBar failed");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/director_protected_runme.cs b/Examples/test-suite/csharp/director_protected_runme.cs
index ee4697b0e..b44c3b7e9 100644
--- a/Examples/test-suite/csharp/director_protected_runme.cs
+++ b/Examples/test-suite/csharp/director_protected_runme.cs
@@ -16,6 +16,7 @@ public class runme
Foo f = b.create();
FooBar fb = new FooBar();
FooBar2 fb2 = new FooBar2();
+ FooBar3 fb3 = new FooBar3();
String s;
s = fb.used();
@@ -37,6 +38,21 @@ public class runme
s = fb.pong();
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
throw new Exception("bad FooBar::pong");
+
+// if (fb3.cheer() != "FooBar3::cheer();")
+// throw new Exception("bad fb3::cheer");
+
+ if (fb2.callping() != "FooBar2::ping();")
+ throw new Exception("bad fb2.callping");
+
+ if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
+ throw new Exception("bad fb2.callcheer");
+
+ if (fb3.callping() != "Bar::ping();")
+ throw new Exception("bad fb3.callping");
+
+ if (fb3.callcheer() != "FooBar3::cheer();")
+ throw new Exception("bad fb3.callcheer");
}
}
@@ -69,4 +85,16 @@ class FooBar2 : Bar
}
}
+class FooBar3 : Bar
+{
+ public FooBar3() : base()
+ {
+ }
+
+ protected override String cheer()
+ {
+ return "FooBar3::cheer();";
+ }
+}
+
}
diff --git a/Examples/test-suite/director_protected.i b/Examples/test-suite/director_protected.i
index fee45b4a6..0299b238d 100644
--- a/Examples/test-suite/director_protected.i
+++ b/Examples/test-suite/director_protected.i
@@ -53,6 +53,10 @@ protected:
virtual std::string used() {
return pang() + pong();
}
+
+ virtual std::string cheer() {
+ return pang() + pong();
+ }
};
class Bar : public Foo
@@ -63,6 +67,14 @@ public:
return new Bar();
}
+ std::string callping() {
+ return ping();
+ }
+
+ std::string callcheer() {
+ return cheer();
+ }
+
std::string pong() {
return "Bar::pong();" + Foo::pong();
}
@@ -75,6 +87,7 @@ protected:
std::string ping() {
return "Bar::ping();";
};
+ using Foo::cheer;
enum Hello {hola, chao};
diff --git a/Examples/test-suite/director_using.i b/Examples/test-suite/director_using.i
index 9001ffbb9..d86546e86 100644
--- a/Examples/test-suite/director_using.i
+++ b/Examples/test-suite/director_using.i
@@ -59,9 +59,22 @@
public:
virtual C get_value() const = 0;
using Bar::do_advance;
-
};
+
}
%template(FooBar_int) FooBar;
+%inline %{
+ struct SomeBase {
+ virtual ~SomeBase() {}
+ virtual void method1() {}
+ virtual void method2() {}
+ };
+
+ struct PrivateDerived : SomeBase {
+ private:
+ virtual void method1() {}
+ using SomeBase::method2;
+ };
+%}
diff --git a/Examples/test-suite/java/director_protected_runme.java b/Examples/test-suite/java/director_protected_runme.java
index 464b4d4d9..63ac03502 100644
--- a/Examples/test-suite/java/director_protected_runme.java
+++ b/Examples/test-suite/java/director_protected_runme.java
@@ -19,6 +19,7 @@ public class director_protected_runme {
Foo f = b.create();
director_protected_FooBar fb = new director_protected_FooBar();
director_protected_FooBar2 fb2 = new director_protected_FooBar2();
+ director_protected_FooBar3 fb3 = new director_protected_FooBar3();
{
String s = fb.used();
@@ -60,11 +61,34 @@ public class director_protected_runme {
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::ping should be protected" );
+ method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Bar::cheer should be protected" );
+
+ method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Foo::cheer should be protected" );
+
} catch (NoSuchMethodException n) {
- throw new RuntimeException("NoSuchmethodException caught. Test failed.");
+ throw new RuntimeException(n);
} catch (SecurityException s) {
throw new RuntimeException("SecurityException caught. Test failed.");
}
+
+ if (!fb3.cheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3::cheer");
+
+ if (!fb2.callping().equals("director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callping");
+
+ if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callcheer");
+
+ if (!fb3.callping().equals("Bar::ping();"))
+ throw new RuntimeException("bad fb3.callping");
+
+ if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3.callcheer");
}
}
@@ -83,3 +107,9 @@ class director_protected_FooBar2 extends Bar {
}
}
+class director_protected_FooBar3 extends Bar {
+ public String cheer() {
+ return "director_protected_FooBar3::cheer();";
+ }
+}
+
diff --git a/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php
index 73bcba1fd..9d47ef658 100644
--- a/Examples/test-suite/php/director_protected_runme.php
+++ b/Examples/test-suite/php/director_protected_runme.php
@@ -26,10 +26,17 @@ class FooBar2 extends Bar {
}
}
+class FooBar3 extends Bar {
+ function cheer() {
+ return "FooBar3::cheer();";
+ }
+}
+
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
+$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
@@ -42,7 +49,7 @@ check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
-check::equal($method->isProtected(), true, "Boo::ping should be protected");
+check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
@@ -50,5 +57,17 @@ check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
+$method = new ReflectionMethod('Bar', 'cheer');
+check::equal($method->isProtected(), true, "Bar::cheer should be protected");
+
+$method = new ReflectionMethod('Foo', 'cheer');
+check::equal($method->isProtected(), true, "Foo::cheer should be protected");
+
+check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
+check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
+check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
+check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
+check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
+
check::done();
?>
diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py
index 9d565a1b4..fd3c868a1 100644
--- a/Examples/test-suite/python/director_protected_runme.py
+++ b/Examples/test-suite/python/director_protected_runme.py
@@ -12,11 +12,16 @@ class FooBar2(Bar):
def pang(self):
return "FooBar2::pang();"
+class FooBar3(Bar):
+ def cheer(self):
+ return "FooBar3::cheer();"
+
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
+fb3 = FooBar3()
try:
@@ -66,7 +71,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError,"Boo::ping is protected"
+ raise RuntimeError,"Foo::ping is protected"
protected=1
try:
@@ -86,3 +91,39 @@ except:
pass
if not protected:
raise RuntimeError,"FooBar::pang is protected"
+
+
+protected=1
+try:
+ b.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Bar::cheer is protected"
+
+protected=1
+try:
+ f.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Foo::cheer is protected"
+
+if fb3.cheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3::cheer"
+
+if fb2.callping() != "FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callping"
+
+if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callcheer"
+
+if fb3.callping() != "Bar::ping();":
+ raise RuntimeError, "bad fb3.callping"
+
+if fb3.callcheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3.callcheer"
+
+
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 6d0896b16..1444dbd87 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -2292,17 +2292,24 @@ public:
String *ex_imcall = Copy(imcall);
Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
Replaceall(imcall, "$imfuncname", intermediary_function_name);
-
String *excode = NewString("");
- if (!Cmp(return_type, "void"))
- Printf(excode, "if (this.GetType() == typeof(%s)) %s; else %s", proxy_class_name, imcall, ex_imcall);
- else
- Printf(excode, "((this.GetType() == typeof(%s)) ? %s : %s)", proxy_class_name, imcall, ex_imcall);
+ Node *directorNode = Getattr(n, "directorNode");
+ if (directorNode) {
+ UpcallData *udata = Getattr(directorNode, "upcalldata");
+ String *methid = Getattr(udata, "class_methodidx");
- Clear(imcall);
- Printv(imcall, excode, NIL);
- Delete(ex_overloaded_name);
+ if (!Cmp(return_type, "void"))
+ Printf(excode, "if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s)) %s; else %s", proxy_function_name, methid, ex_imcall, imcall);
+ else
+ Printf(excode, "(SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s) ? %s : %s)", proxy_function_name, methid, ex_imcall, imcall);
+
+ Clear(imcall);
+ Printv(imcall, excode, NIL);
+ } else {
+ // probably an ignored method or nodirector
+ }
Delete(excode);
+ Delete(ex_overloaded_name);
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
@@ -3869,6 +3876,10 @@ public:
/* Emit the actual upcall through */
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name);
String *methid = Getattr(udata, "class_methodidx");
+ Setattr(n, "upcalldata", udata);
+ /*
+ Printf(stdout, "setting upcalldata, nodeType: %s %s::%s %p\n", nodeType(n), classname, Getattr(n, "name"), n);
+ */
Printf(director_callback_typedefs, " typedef %s (SWIGSTDCALL* SWIG_Callback%s_t)(", c_ret_type, methid);
Printf(director_callback_typedefs, "%s);\n", callback_typedef_parms);
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index 7f96007e3..82af250f7 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -1806,17 +1806,25 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
classname = Getattr(n, "name");
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
/* we only need to check the virtual members */
- if (!checkAttribute(ni, "storage", "virtual"))
- continue;
nodeType = Getattr(ni, "nodeType");
+ int is_using = (Cmp(nodeType, "using") == 0);
+ Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
+ if (is_using) {
+ if (nn)
+ nodeType = Getattr(nn, "nodeType");
+ else
+ continue; // A private "using" node
+ }
+ if (!checkAttribute(nn, "storage", "virtual"))
+ continue;
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
int is_destructor = (Cmp(nodeType, "destructor") == 0);
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
- decl = Getattr(ni, "decl");
+ decl = Getattr(nn, "decl");
/* extra check for function type and proper access */
- if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(ni)) || need_nonpublic_member(ni))) {
- String *name = Getattr(ni, "name");
- Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(ni);
+ if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
+ String *name = Getattr(nn, "name");
+ Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
/* Make sure that the new method overwrites the existing: */
int len = Len(vm);
const int DO_NOT_REPLACE = -1;
@@ -1834,7 +1842,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
String *fqdname = NewStringf("%s::%s", classname, name);
Hash *item = NewHash();
Setattr(item, "fqdname", fqdname);
- Node *m = Copy(ni);
+ Node *m = Copy(nn);
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
SwigType *ty = NewString(Getattr(m, "type"));
@@ -1854,6 +1862,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
Append(vm, item);
else
Setitem(vm, replace, item);
+ Setattr(nn, "directorNode", m);
Delete(mname);
}
@@ -2806,7 +2815,7 @@ int Language::validIdentifier(String *s) {
* ----------------------------------------------------------------------------- */
int Language::usingDeclaration(Node *n) {
- if ((cplus_mode == PUBLIC)) {
+ if ((cplus_mode == PUBLIC) || (!is_public(n) && dirprot_mode())) {
Node *np = Copy(n);
Node *c;
for (c = firstChild(np); c; c = nextSibling(c)) {
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index 8751b1e67..3e2c9ca1e 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -999,6 +999,7 @@ class TypePass:private Dispatcher {
}
Node *nn = copyNode(c);
Delattr(nn, "access"); // access might be different from the method in the base class
+ Setattr(nn, "access", Getattr(n, "access"));
if (!Getattr(nn, "sym:name"))
Setattr(nn, "sym:name", symname);
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 6beecc130..d4a7adf84 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1000,7 +1000,7 @@ int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
* This is basically any protected members when the allprotected mode is set.
* Otherwise we take just the protected virtual methods and non-static methods
* (potentially virtual methods) as well as constructors/destructors.
- *
+ * Also any "using" statements in a class may potentially be virtual.
* ----------------------------------------------------------------------------- */
int Swig_need_protected(Node *n) {
@@ -1017,6 +1017,8 @@ int Swig_need_protected(Node *n) {
}
} else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) {
return 1;
+ } else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) {
+ return 1;
}
}
return 0;
--
cgit v1.2.1
From af4873f879ed760d3ad6971571d0efecadb9eb9b Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 1 Feb 2011 07:17:51 +0000
Subject: Linker errors fixed for member_funcptr_galore testcase
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12420 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/member_funcptr_galore.i | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Examples/test-suite/member_funcptr_galore.i b/Examples/test-suite/member_funcptr_galore.i
index ce0dacf51..cc626bfc4 100644
--- a/Examples/test-suite/member_funcptr_galore.i
+++ b/Examples/test-suite/member_funcptr_galore.i
@@ -18,8 +18,8 @@ public:
double *z;
void move(double dx, double dy);
- virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int));
- virtual double abc(Thing ts, Thing< const Space::Shape * > tda[]);
+ virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)) { return 0.0; }
+ virtual double abc(Thing ts, Thing< const Space::Shape * > tda[]) { return 0.0; }
};
}
--
cgit v1.2.1
From e7e542ffc9db43d5c3b87935c1dc766c0a8540ec Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 1 Feb 2011 19:14:14 +0000
Subject: li_boost_shared_ptr.i testcase - fix for missing %shared_ptr
highlighted by new smart pointer warning 520
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12421 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/li_boost_shared_ptr.i | 1 +
1 file changed, 1 insertion(+)
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index fc51e7b5a..3d474ec00 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -45,6 +45,7 @@
%shared_ptr(Space::KlassDerived)
%shared_ptr(Space::Klass2ndDerived)
%shared_ptr(Space::Klass3rdDerived)
+%shared_ptr(IgnoredMultipleInheritBase) // IgnoredMultipleInheritBase not actually used in any wrapped functions, so this isn't entirely necessary and warning 520 could instead have been suppressed.
#endif
--
cgit v1.2.1
From a0b869da381a1e0a33720fdb6d299bbcc98e06d2 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Tue, 1 Feb 2011 19:58:44 +0000
Subject: Remove runtime warnings in overloading php example
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12422 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/php/overloading/runme.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/Examples/php/overloading/runme.php b/Examples/php/overloading/runme.php
index 01044445f..56d515138 100644
--- a/Examples/php/overloading/runme.php
+++ b/Examples/php/overloading/runme.php
@@ -35,11 +35,10 @@ print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
-print "\nHere are some properties of the shapes:\n";
+print "\nCall some overloaded methods:\n";
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
- print " ".get_class($o)." \$o\n";
- print " overloaded = " . overloaded($o) . "\n";
- }
+ print " overloaded = " . overloaded($o) . "\n";
+}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
--
cgit v1.2.1
From 0be280bf72c1957c4be9ab5f71264b116c35004d Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Thu, 3 Feb 2011 07:20:34 +0000
Subject: Add link to runtime information developer doc
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12424 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Devel/index.html | 1 +
1 file changed, 1 insertion(+)
diff --git a/Doc/Devel/index.html b/Doc/Devel/index.html
index 55c612ec3..4ddc63a76 100644
--- a/Doc/Devel/index.html
+++ b/Doc/Devel/index.html
@@ -21,6 +21,7 @@ The following documentation describe the internal APIs used by SWIG. These may
SWIG Runtime.
--
cgit v1.2.1
From 867e6a9986ce3a6ebfdb90148a0fb5e0c78a6192 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 4 Feb 2011 19:43:24 +0000
Subject: [clisp] SF #3148200 Fix segfault parsing nested unions.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12428 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
Source/Modules/clisp.cxx | 16 +++++++++-------
2 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 216484693..14e662774 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.2 (in progress)
===========================
+2011-02-04: wsfulton
+ [clisp] SF #3148200 Fix segfault parsing nested unions.
+
2011-02-01: wsfulton
[C#] Directors - a call to a method being defined in the base class, not
overridden in a subclass, but again overridden in a class derived from
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index b1a6f5610..d26df36c2 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -293,16 +293,18 @@ int CLISP::classDeclaration(Node *n) {
}
String *temp = Copy(Getattr(c, "decl"));
- Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
- String *lisp_type = get_ffi_type(n, temp);
- Delete(temp);
+ if (temp) {
+ Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
+ String *lisp_type = get_ffi_type(n, temp);
+ Delete(temp);
- String *slot_name = Getattr(c, "sym:name");
- Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
+ String *slot_name = Getattr(c, "sym:name");
+ Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
- Append(entries, NewStringf("%s-%s", name, slot_name));
+ Append(entries, NewStringf("%s-%s", name, slot_name));
- Delete(lisp_type);
+ Delete(lisp_type);
+ }
}
Printf(f_cl, ")\n");
--
cgit v1.2.1
From 7fe18eaacbdc70b1c1ce53d3421cbd28441fdeef Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 4 Feb 2011 19:50:55 +0000
Subject: SF #3141139 better callback documentation
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12429 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/SWIG.html | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index b8e3e2260..fd510f2a4 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -2236,7 +2236,8 @@ rest to lower case.
And now, a final note about function pointer support. Although SWIG
does not normally allow callback functions to be written in the target language, this
can be accomplished with the use of typemaps and other advanced SWIG features.
-This is described in a later chapter.
+See the Typemaps chapter for more about typemaps
+and individual target language chapters for more on callbacks and the 'director' feature.
5.5 Structures and unions
--
cgit v1.2.1
From 74883f1dd7b22fdca609787300460f5550aec095 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 4 Feb 2011 20:25:59 +0000
Subject: [PHP] SF #3166423 Recent PHP versions no longer define
zend_error_noreturn - calls to this have been replaced with zend_error.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12430 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Source/Modules/php.cxx | 6 +++---
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 14e662774..11e9ff71e 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)
===========================
+2011-02-04: wsfulton
+ [PHP] SF #3166423 Recent PHP versions no longer define zend_error_noreturn - calls to this
+ have been replaced with zend_error.
+
2011-02-04: wsfulton
[clisp] SF #3148200 Fix segfault parsing nested unions.
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 43eee9ae6..554e40bb8 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -976,7 +976,7 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
- Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
+ Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
Printf(f->code, "}\n");
@@ -2290,7 +2290,7 @@ done:
Append(f->code, "return;\n");
Append(f->code, "fail:\n");
- Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
+ Append(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
Printf(f->code, "}\n");
Wrapper_print(f, s_wrappers);
@@ -2665,7 +2665,7 @@ done:
}
Append(w->code, "fail:\n");
- Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
+ Append(w->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
Append(w->code, "}\n");
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
--
cgit v1.2.1
From 1918e2a8442ef35c75304e8ce3b33b7a0717591a Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 4 Feb 2011 23:40:06 +0000
Subject: Make R unittests pass failure to the Make system, otherwise failures
are masked and won't be seen
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12431 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Examples/test-suite/r/unittest.R | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/Examples/test-suite/r/unittest.R b/Examples/test-suite/r/unittest.R
index 81c590a3f..0633c7715 100644
--- a/Examples/test-suite/r/unittest.R
+++ b/Examples/test-suite/r/unittest.R
@@ -1,9 +1,17 @@
unittest <- function (x,y) {
-if (x==y) print("PASS")
-else print("FAIL")
+ if (x==y) {
+ print("PASS")
+ } else {
+ print("FAIL")
+ stop("Test failed")
+ }
}
unittesttol <- function(x,y,z) {
-if (abs(x-y) < z) print("PASS")
-else print("FAIL")
-}
\ No newline at end of file
+ if (abs(x-y) < z) {
+ print("PASS")
+ } else {
+ print("FAIL")
+ stop("Test failed")
+ }
+}
--
cgit v1.2.1
From f4c74bc500195797d41fad5d1203a0c109ab00e7 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Fri, 4 Feb 2011 23:42:06 +0000
Subject: R - SF #3168676 Fix %rename not working for member variables and
methods. Add new simple rename testcase with runtime tests for C# and R
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12432 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
Examples/test-suite/common.mk | 1 +
Examples/test-suite/csharp/rename_simple_runme.cs | 30 +++++++++++++++++++++++
Examples/test-suite/r/rename_simple_runme.R | 20 +++++++++++++++
Examples/test-suite/rename_simple.i | 24 ++++++++++++++++++
Source/Modules/r.cxx | 2 +-
6 files changed, 79 insertions(+), 1 deletion(-)
create mode 100644 Examples/test-suite/csharp/rename_simple_runme.cs
create mode 100644 Examples/test-suite/r/rename_simple_runme.R
create mode 100644 Examples/test-suite/rename_simple.i
diff --git a/CHANGES.current b/CHANGES.current
index 11e9ff71e..1522866e3 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.2 (in progress)
===========================
+2011-02-04: wsfulton
+ [R] SF #3168676 Fix %rename not working for member variables and methods.
+
2011-02-04: wsfulton
[PHP] SF #3166423 Recent PHP versions no longer define zend_error_noreturn - calls to this
have been replaced with zend_error.
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index a0ae5e4ff..734b556f3 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -287,6 +287,7 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
+ rename_simple \
rename_strip_encoder \
rename_pcre_encoder \
rename_pcre_enum \
diff --git a/Examples/test-suite/csharp/rename_simple_runme.cs b/Examples/test-suite/csharp/rename_simple_runme.cs
new file mode 100644
index 000000000..edf05ad24
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_simple_runme.cs
@@ -0,0 +1,30 @@
+
+using System;
+using rename_simpleNamespace;
+
+public class rename_simple_runme {
+
+ public static void Main() {
+ NewStruct s = new NewStruct();
+ check(111, s.NewInstanceVariable, "NewInstanceVariable");
+ check(222, s.NewInstanceMethod(), "NewInstanceMethod");
+ check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
+ check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
+ check(555, rename_simple.NewFunction(), "NewFunction");
+ check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
+
+ s.NewInstanceVariable = 1111;
+ NewStruct.NewStaticVariable = 4444;
+ rename_simple.NewGlobalVariable = 6666;
+
+ check(1111, s.NewInstanceVariable, "NewInstanceVariable");
+ check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
+ check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
+ }
+
+ public static void check(int expected, int actual, string msg) {
+ if (expected != actual)
+ throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
+ }
+}
+
diff --git a/Examples/test-suite/r/rename_simple_runme.R b/Examples/test-suite/r/rename_simple_runme.R
new file mode 100644
index 000000000..b25aeb844
--- /dev/null
+++ b/Examples/test-suite/r/rename_simple_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep=""))
+source("rename_simple.R")
+cacheMetaData(1)
+
+s <- NewStruct();
+unittest(111, s$NewInstanceVariable)
+unittest(222, s$NewInstanceMethod())
+unittest(333, NewStruct_NewStaticMethod())
+unittest(444, NewStruct_NewStaticVariable())
+unittest(555, NewFunction())
+unittest(666, NewGlobalVariable())
+
+s$NewInstanceVariable <- 1111
+NewStruct_NewStaticVariable(4444)
+NewGlobalVariable(6666)
+
+unittest(1111, s$NewInstanceVariable)
+unittest(4444, NewStruct_NewStaticVariable())
+unittest(6666, NewGlobalVariable())
diff --git a/Examples/test-suite/rename_simple.i b/Examples/test-suite/rename_simple.i
new file mode 100644
index 000000000..feba53fa1
--- /dev/null
+++ b/Examples/test-suite/rename_simple.i
@@ -0,0 +1,24 @@
+%module rename_simple
+
+%rename(NewStruct) OldStruct;
+%rename(NewVariable) OldVariable;
+%rename(NewInstanceMethod) OldInstanceMethod;
+%rename(NewInstanceVariable) OldInstanceVariable;
+%rename(NewStaticMethod) OldStaticMethod;
+%rename(NewStaticVariable) OldStaticVariable;
+%rename(NewFunction) OldFunction;
+%rename(NewGlobalVariable) OldGlobalVariable;
+
+%inline %{
+struct OldStruct {
+ OldStruct() : OldInstanceVariable(111) {}
+ int OldInstanceVariable;
+ int OldInstanceMethod() { return 222; }
+ static int OldStaticVariable;
+ static int OldStaticMethod() { return 333; }
+};
+int OldStruct::OldStaticVariable = 444;
+
+int OldFunction() { return 555; }
+int OldGlobalVariable = 666;
+%}
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 8eb784c68..64583175b 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -300,7 +300,7 @@ public:
Printf(stderr, " %s %s\n",
Getattr(n, "name"),
Getattr(n, "type"));
- member_name = Getattr(n, "name");
+ member_name = Getattr(n, "sym:name");
processing_class_member_function = 1;
int status = Language::memberfunctionHandler(n);
processing_class_member_function = 0;
--
cgit v1.2.1
From 4f616b5942604fc1bad90a7fff5d57bb206d7353 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 5 Feb 2011 01:09:40 +0000
Subject: SF #3127633 Fix infinite loop in recursive typedef resolution.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12433 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 3 +++
Examples/test-suite/errors/cpp_recursive_typedef.i | 4 ++++
Examples/test-suite/errors/expected.log | 3 +++
Examples/test-suite/errors/make.sh | 1 +
Source/Swig/typesys.c | 7 ++++++-
5 files changed, 17 insertions(+), 1 deletion(-)
create mode 100644 Examples/test-suite/errors/cpp_recursive_typedef.i
diff --git a/CHANGES.current b/CHANGES.current
index 1522866e3..082f20763 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.2 (in progress)
===========================
+2011-02-05: wsfulton
+ SF #3127633 Fix infinite loop in recursive typedef resolution.
+
2011-02-04: wsfulton
[R] SF #3168676 Fix %rename not working for member variables and methods.
diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.i b/Examples/test-suite/errors/cpp_recursive_typedef.i
new file mode 100644
index 000000000..3d65a8817
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_recursive_typedef.i
@@ -0,0 +1,4 @@
+%module cpp_recursive_typedef
+
+typedef std::set pds;
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index e6430293b..f9210226d 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -281,6 +281,9 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
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_recursive_typedef.i :::::::::::::::::::::::::::::::::::
+:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
+
:::::::::::::::::::::::::::::::: cpp_shared_ptr.i :::::::::::::::::::::::::::::::::::
cpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer.
cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer.
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index 875d1ecbe..474c79b2d 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -76,6 +76,7 @@ cpp_nobase
cpp_overload
cpp_private_defvalue
cpp_private_inherit
+cpp_recursive_typedef
cpp_shared_ptr
cpp_template_argname
cpp_template_nargs
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index ec4376af4..a1445f200 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -107,7 +107,7 @@ static Typetab *global_scope = 0; /* The global scope
static Hash *scopes = 0; /* Hash table containing fully qualified scopes */
/* Performance optimization */
-#define SWIG_TYPEDEF_RESOLVE_CACHE
+#define SWIG_TYPEDEF_RESOLVE_CACHE
static Hash *typedef_resolve_cache = 0;
static Hash *typedef_all_cache = 0;
static Hash *typedef_qualified_cache = 0;
@@ -809,6 +809,7 @@ return_result:
SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
SwigType *n;
SwigType *r;
+ int count = 0;
/* Check to see if the typedef resolve has been done before by checking the cache */
if (!typedef_all_cache) {
@@ -824,6 +825,10 @@ SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
while ((n = SwigType_typedef_resolve(r))) {
Delete(r);
r = n;
+ if (++count >= 512) {
+ Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0));
+ break;
+ }
}
/* Add the typedef to the cache for next time it is looked up */
--
cgit v1.2.1
From ae0683a2d3b4c209a3be2bc325892f96ff807762 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 5 Feb 2011 12:47:56 +0000
Subject: SF #3173367 Better information during configure about Boost
prerequisite for running the test-suite. BOOST_CPPFLAGS can only be used
though once common.mk is created at configure time.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12434 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 +
README | 6 +-
Tools/config/ax_boost_base.m4 | 258 ++++++++++++++++++++++++++++++++++++++++++
configure.in | 10 +-
4 files changed, 273 insertions(+), 5 deletions(-)
create mode 100644 Tools/config/ax_boost_base.m4
diff --git a/CHANGES.current b/CHANGES.current
index 082f20763..92b0cf5e8 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)
===========================
+2011-02-05: wsfulton
+ SF #3173367 Better information during configure about Boost prerequisite for running
+ the test-suite.
+
2011-02-05: wsfulton
SF #3127633 Fix infinite loop in recursive typedef resolution.
diff --git a/README b/README
index 818eb0ff7..2eb8ae339 100644
--- a/README
+++ b/README
@@ -142,6 +142,8 @@ incorrectly configured. It may also fail due to compiler issues such
as broken C++ compiler. Even if 'make -k check' fails, there is a
pretty good chance SWIG still works correctly---you will just have to
mess around with one of the examples and some makefiles to get it to work.
+Some tests may also fail due to missing dependency packages, eg PCRE
+or Boost, but this will require careful analysis of the configure output.
The testing suite executed by 'make -k check' is designed to stress-test
many parts of the implementation including obscure corner cases. If some
@@ -149,8 +151,8 @@ of these tests fail or generate warning messages, there is no reason for
alarm---the test may be related to some new SWIG feature or a difficult bug
that we're trying to resolve. Chances are that SWIG will work just fine
for you. Note that if you have more than one CPU/core, then you can use
-parallel make can be used to speed up the check as it does take quite some
-time to run, for example:
+parallel make to speed up the check as it does take quite some time to run,
+for example:
% make -j2 -k check
diff --git a/Tools/config/ax_boost_base.m4 b/Tools/config/ax_boost_base.m4
new file mode 100644
index 000000000..54a2a1bee
--- /dev/null
+++ b/Tools/config/ax_boost_base.m4
@@ -0,0 +1,258 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# DESCRIPTION
+#
+# Test for the Boost C++ libraries of a particular version (or newer)
+#
+# If no path to the installed boost library is given the macro searchs
+# under /usr, /usr/local, /opt and /opt/local and evaluates the
+# $BOOST_ROOT environment variable. Further documentation is available at
+# .
+#
+# This macro calls:
+#
+# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+#
+# And sets:
+#
+# HAVE_BOOST
+#
+# LICENSE
+#
+# Copyright (c) 2008 Thomas Porschberg
+# Copyright (c) 2009 Peter Adolphs
+#
+# 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 20
+
+AC_DEFUN([AX_BOOST_BASE],
+[
+AC_ARG_WITH([boost],
+ [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
+ [use Boost library from a standard location (ARG=yes),
+ from the specified location (ARG=),
+ or disable it (ARG=no)
+ @<:@ARG=yes@:>@ ])],
+ [
+ if test "$withval" = "no"; then
+ want_boost="no"
+ elif test "$withval" = "yes"; then
+ want_boost="yes"
+ ac_boost_path=""
+ else
+ want_boost="yes"
+ ac_boost_path="$withval"
+ fi
+ ],
+ [want_boost="yes"])
+
+
+AC_ARG_WITH([boost-libdir],
+ AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
+ [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
+ [
+ if test -d "$withval"
+ then
+ ac_boost_lib_path="$withval"
+ else
+ AC_MSG_ERROR(--with-boost-libdir expected directory name)
+ fi
+ ],
+ [ac_boost_lib_path=""]
+)
+
+if test "x$want_boost" = "xyes"; then
+ boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
+ boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
+ boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
+ boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+ boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+ if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+ boost_lib_version_req_sub_minor="0"
+ fi
+ WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+ AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
+ succeeded=no
+
+ dnl On 64-bit systems check for system libraries in both lib64 and lib.
+ dnl The former is specified by FHS, but e.g. Debian does not adhere to
+ dnl this (as it rises problems for generic multi-arch support).
+ dnl The last entry in the list is chosen by default when no libraries
+ dnl are found, e.g. when only header-only libraries are installed!
+ libsubdirs="lib"
+ ax_arch=`uname -m`
+ if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then
+ libsubdirs="lib64 lib lib64"
+ fi
+
+ dnl first we check the system location for boost libraries
+ dnl this location ist chosen if boost libraries are installed with the --layout=system option
+ dnl or if you install boost with RPM
+ if test "$ac_boost_path" != ""; then
+ BOOST_CPPFLAGS="-I$ac_boost_path/include"
+ for ac_boost_path_tmp in $libsubdirs; do
+ if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
+ BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
+ break
+ fi
+ done
+ elif test "$cross_compiling" != yes; then
+ for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+ if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+ for libsubdir in $libsubdirs ; do
+ if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+ done
+ BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
+ BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+ break;
+ fi
+ done
+ fi
+
+ dnl overwrite ld flags if we have required special directory with
+ dnl --with-boost-libdir parameter
+ if test "$ac_boost_lib_path" != ""; then
+ BOOST_LDFLAGS="-L$ac_boost_lib_path"
+ fi
+
+ CPPFLAGS_SAVED="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+ export CPPFLAGS
+
+ LDFLAGS_SAVED="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+ export LDFLAGS
+
+ AC_REQUIRE([AC_PROG_CXX])
+ AC_LANG_PUSH(C++)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ @%:@include
+ ]], [[
+ #if BOOST_VERSION >= $WANT_BOOST_VERSION
+ // Everything is okay
+ #else
+ # error Boost version is too old
+ #endif
+ ]])],[
+ AC_MSG_RESULT(yes)
+ succeeded=yes
+ found_system=yes
+ ],[
+ ])
+ AC_LANG_POP([C++])
+
+
+
+ dnl if we found no boost with system layout we search for boost libraries
+ dnl built and installed without the --layout=system option or for a staged(not installed) version
+ if test "x$succeeded" != "xyes"; then
+ _version=0
+ if test "$ac_boost_path" != ""; then
+ if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+ for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+ _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+ V_CHECK=`expr $_version_tmp \> $_version`
+ if test "$V_CHECK" = "1" ; then
+ _version=$_version_tmp
+ fi
+ VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+ BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+ done
+ fi
+ else
+ if test "$cross_compiling" != yes; then
+ for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+ if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+ for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+ _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+ V_CHECK=`expr $_version_tmp \> $_version`
+ if test "$V_CHECK" = "1" ; then
+ _version=$_version_tmp
+ best_path=$ac_boost_path
+ fi
+ done
+ fi
+ done
+
+ VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+ BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+ if test "$ac_boost_lib_path" = ""; then
+ for libsubdir in $libsubdirs ; do
+ if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+ done
+ BOOST_LDFLAGS="-L$best_path/$libsubdir"
+ fi
+ fi
+
+ if test "x$BOOST_ROOT" != "x"; then
+ for libsubdir in $libsubdirs ; do
+ if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+ done
+ if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
+ version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+ stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+ stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
+ V_CHECK=`expr $stage_version_shorten \>\= $_version`
+ if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+ AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
+ BOOST_CPPFLAGS="-I$BOOST_ROOT"
+ BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
+ fi
+ fi
+ fi
+ fi
+
+ CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+ export CPPFLAGS
+ LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+ export LDFLAGS
+
+ AC_LANG_PUSH(C++)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ @%:@include
+ ]], [[
+ #if BOOST_VERSION >= $WANT_BOOST_VERSION
+ // Everything is okay
+ #else
+ # error Boost version is too old
+ #endif
+ ]])],[
+ AC_MSG_RESULT(yes)
+ succeeded=yes
+ found_system=yes
+ ],[
+ ])
+ AC_LANG_POP([C++])
+ fi
+
+ if test "$succeeded" != "yes" ; then
+ if test "$_version" = "0" ; then
+ AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]])
+ else
+ AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
+ fi
+ # execute ACTION-IF-NOT-FOUND (if present):
+ ifelse([$3], , :, [$3])
+ else
+ AC_SUBST(BOOST_CPPFLAGS)
+ AC_SUBST(BOOST_LDFLAGS)
+ AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+ # execute ACTION-IF-FOUND (if present):
+ ifelse([$2], , :, [$2])
+ fi
+
+ CPPFLAGS="$CPPFLAGS_SAVED"
+ LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
diff --git a/configure.in b/configure.in
index e783c7d3c..052bf07c1 100644
--- a/configure.in
+++ b/configure.in
@@ -19,7 +19,7 @@ AH_BOTTOM([
/* Default language */
#define SWIG_LANG "-tcl"
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+/* Deal with Microsofts attempt at deprecating C standard runtime functions */
#if defined(_MSC_VER)
# define _CRT_SECURE_NO_DEPRECATE
#endif
@@ -89,7 +89,7 @@ AS_IF([test "x$with_pcre" != xno],
CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
],
[AC_MSG_FAILURE([
- Can't find pcre-config script from PCRE (Perl Compatible Regular Expressions)
+ Cannot 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).
@@ -130,10 +130,14 @@ AC_CHECK_PROGS(YODL2HTML, yodl2html)
echo ""
-echo "Checking for installed target languages and other information in order to compile and run the examples."
+echo "Checking for installed target languages and other information in order to compile and run"
+echo "the examples and test-suite invoked by 'make check'."
echo "Note : None of the following packages are required for users to compile and install SWIG"
echo ""
+dnl Some test cases require Boost
+AX_BOOST_BASE(,,,)
+AC_SUBST(BOOST_CPPFLAGS)
dnl How to specify include directories that may be system directories.
# -I should not be used on system directories (GCC)
--
cgit v1.2.1
From a5837dd7e61007d7a4849ef9fd59506bdac42bda Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 5 Feb 2011 12:58:29 +0000
Subject: [C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12435 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++++
Examples/test-suite/csharp/Makefile.in | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/CHANGES.current b/CHANGES.current
index 92b0cf5e8..4a1c3f8e9 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)
===========================
+
+2011-02-05: wsfulton
+ [C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
+
2011-02-05: wsfulton
SF #3173367 Better information during configure about Boost prerequisite for running
the test-suite.
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 48731f82b..18f10c567 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -64,12 +64,13 @@ setup = \
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
+# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(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; \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
--
cgit v1.2.1
From 1f46e842122735c61bc22b8ca0ea6f194471ecd7 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 5 Feb 2011 14:30:36 +0000
Subject: SF #2942899 Add user supplied documentation to help getting started
with MzScheme. Update chapter name to MzScheme/Racket accounting for the
rename of MzScheme to Racket.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12436 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
CHANGES.current | 4 ++
Doc/Manual/Mzscheme.html | 117 ++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 115 insertions(+), 6 deletions(-)
diff --git a/CHANGES.current b/CHANGES.current
index 4a1c3f8e9..729a04217 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -6,6 +6,10 @@ Version 2.0.2 (in progress)
===========================
+2011-02-05: wsfulton
+ [MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme.
+ Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket.
+
2011-02-05: wsfulton
[C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
index 257e58b95..eb6b00dd0 100644
--- a/Doc/Manual/Mzscheme.html
+++ b/Doc/Manual/Mzscheme.html
@@ -2,17 +2,19 @@
-SWIG and MzScheme
+SWIG and MzScheme/Racket
-
-This section contains information on SWIG's support of MzScheme.
+This section contains information on SWIG's support of Racket, formally known as MzScheme.
-
27.1 Creating native MzScheme structures
+
27.1 Creating native structures
@@ -63,8 +65,111 @@ Then in scheme, you can use regular struct access procedures like
+
27.2 Simple example
+
+
+
+A few examples are available in the Examples/mzscheme directory.
+The code and log of a session using SWIG below should help getting started.
+
+
+
+C header file:
+
+
+
+
+// example.h
+int fact(int n);
+
+
+
+
+C source code:
+
+
+
+
+// File: example.c
+#include "example.h"
+
+int fact(int n) {
+ if (n < 0) { /* This should probably return an error, but this is simpler */
+ return 0;
+ }
+ if (n == 0) {
+ return 1;
+ }
+ else {
+ /* testing for overflow would be a good idea here */
+ return n * fact(n-1);
+ }
+}
+
+The session below using the above files is on an OS X machine, but the points to be made are more general. On OS X, libtool is the tool which creates libraries, which are named .dylib, rather than .so on other unixes, or .dll on Windows.
+
+
+
+
+% swig -mzscheme -declaremodule example.i
+% gcc -c -m32 -o example.o example.c # force 32-bit object file (mzscheme is 32-bit only)
+% libtool -dynamic -o libexample.dylib example.o # make it into a library
+% ls # what've we got so far?
+example.c example.o
+example.h example_wrap.c
+example.i libexample.dylib*
+% mzc --cgc --cc example_wrap.c # compile the wrapping code
+% LDFLAGS="-L. -lexample" mzc --ld example_wrap.dylib example_wrap.o # ...and link it
+% mzscheme -e '(path->string (build-path "compiled" "native" (system-library-subpath)))'
+"compiled/native/i386-macosx/3m"
+% mkdir -p compiled/native/i386-macosx/3m # move the extension library to a magic place
+% mv example_wrap.dylib compiled/native/i386-macosx/3m/example_ss.dylib
+% mzscheme
+Welcome to MzScheme v4.2.4 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
+> (require "example.ss")
+> (fact 5)
+120
+> ^D
+% echo 'It works!'
+
+
+
+
+
+Some points of interest:
+
+
+
This is on a 64-bit machine, so we have to include the -m32 option when building the object file
+
If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
+
Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
+
Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
+
+
+
27.3 External documentation
+
+
-That's pretty much it. It works with nested structs as well.
+See the C API for more description of using the mechanism for adding extensions. The main documentation is here.
--
cgit v1.2.1
From 00fadeebdcb31748262c60ef185bafecedcc4755 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 5 Feb 2011 14:35:16 +0000
Subject: SF #2942899 Add user supplied documentation to help getting started
with MzScheme.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12437 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Mzscheme.html | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
index eb6b00dd0..f003a0a17 100644
--- a/Doc/Manual/Mzscheme.html
+++ b/Doc/Manual/Mzscheme.html
@@ -14,7 +14,7 @@
If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
+
The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
-
27.3 External documentation
+
27.3 External documentation
--
cgit v1.2.1
From 9ad833abedd656b0eefb604437632ca2a8126b51 Mon Sep 17 00:00:00 2001
From: William S Fulton
Date: Sat, 5 Feb 2011 15:45:36 +0000
Subject: Add mzscheme tip from bug #2942899
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12438 626c5289-ae23-0410-ae9c-e8d60b6d4f22
---
Doc/Manual/Mzscheme.html | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
index f003a0a17..984b2dded 100644
--- a/Doc/Manual/Mzscheme.html
+++ b/Doc/Manual/Mzscheme.html
@@ -173,5 +173,9 @@ Some points of interest:
See the C API for more description of using the mechanism for adding extensions. The main documentation is here.
+
+Tip: mzc's --vv option is very useful for debugging the inevitable library problems you'll encounter.
+