Merged trunk through revision 12591

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/szager-python-builtin@12592 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Stefan Zager 2011-04-03 03:14:19 +00:00
commit f759999f40
38 changed files with 521 additions and 112 deletions

View file

@ -1,8 +1,8 @@
*** ANNOUNCE: SWIG 2.0.3 (in progress) *** *** ANNOUNCE: SWIG 2.0.4 (29 March 2011) ***
http://www.swig.org http://www.swig.org
We're pleased to announce SWIG-2.0.3, the latest SWIG release. We're pleased to announce SWIG-2.0.4, the latest SWIG release.
What is SWIG? What is SWIG?
============= =============
@ -21,11 +21,11 @@ Availability
============ ============
The release is available for download on Sourceforge at The release is available for download on Sourceforge at
http://prdownloads.sourceforge.net/swig/swig-2.0.3.tar.gz http://prdownloads.sourceforge.net/swig/swig-2.0.4.tar.gz
A Windows version is also available at A Windows version is also available at
http://prdownloads.sourceforge.net/swig/swigwin-2.0.3.zip http://prdownloads.sourceforge.net/swig/swigwin-2.0.4.zip
Please report problems with this release to the swig-devel mailing list, Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html. details at http://www.swig.org/mail.html.

72
CHANGES
View file

@ -3,6 +3,78 @@ SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version. See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release. See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.3 (29 March 2011)
=============================
2011-03-29: wsfulton
[R] Apply patch #3239076 from Marie White fixing strings for R >= 2.7.0
2011-03-29: wsfulton
[Tcl] Apply patch #3248280 from Christian Delbaere which adds better error messages when
the incorrect number or type of arguments are passed to overloaded methods.
2011-03-29: wsfulton
[Tcl] Apply patch #3224663 from Christian Delbaere.
1. Fix when function returns a NULL value, a "NULL" command will be created in the Tcl interpreter
and calling this command will cause a segmentation fault.
2. Previous implementation searches for class methods using a linear search causing performance issues
in wrappers for classes with many member functions. The patch adds a method hash table to classes and
changes method name lookup to use the hash table instead of doing a linear search.
2011-03-26: wsfulton
[C#, Java] SF bug #3195112 - fix wrapping of enums that are type char, for example:
enum { X = 'X'; }
2011-03-21: vadz
Allow setting PCRE_CFLAGS and PCRE_LIBS during configuration to override the values returned by
pcre-config, e.g. to allow using a static version of PCRE library.
2011-03-17: wsfulton
[UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6.
2011-03-17: wsfulton
Fix regression introduced in swig-2.0.2 where filenames with spaces were not found
when used with %include and %import. Reported by Shane Liesegang.
2011-03-15: wsfulton
[UTL] Fix overloading when using const char[], problem reported by David Maxwell.
Similarly for char[ANY] and const char[ANY].
2011-03-15: wsfulton
[C#] Apply patch #3212624 fixing std::map Keys property.
2011-03-14: olly
[PHP] Fix handling of overloaded methods/functions where some
return void and others don't - whether this worked or not depended
on the order they were encountered in (SF#3208299).
2011-03-13: klickverbot
[D] Extended support for C++ namespaces (nspace feature).
2011-03-12: olly
[PHP] Fix sharing of type information between multiple SWIG-wrapped
modules (SF#3202463).
2011-03-09: wsfulton
[Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value
for a primitive type parameter in a method declaration.
2011-03-07: olly
[PHP] Don't use zend_error_noreturn() for cases where the function
returns void - now this issue can only matter if you have a function
or method which is directed and returns non-void.
2011-03-06: olly
[PHP] Add casts to the typemaps for long long and unsigned long
long to avoid issues when they are used with shorter types via
%apply.
2011-03-02: wsfulton
Templated smart pointers overloaded with both const and non const operator-> generated uncompilable
code when the pointee was a class with either public member variables or static methods.
Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list.
Version 2.0.2 (20 February 2011) Version 2.0.2 (20 February 2011)
================================ ================================

View file

@ -2,55 +2,10 @@ This file contains the changes for the current release.
See the CHANGES file for changes in older releases. See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release. See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.3 (in progress) Version 2.0.4 (in progress)
=========================== ===========================
2011-03-21: vadz 2011-04-01: wsfulton
[build] Allow setting PCRE_CFLAGS and PCRE_LIBS to override the values returned by Add in missing wrappers for friend functions for some target languages, mostly
pcre-config, e.g. to allow using a static version of PCRE library. the non-scripting languages like Java and C#.
2011-03-17: wsfulton
[UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6.
2011-03-17: wsfulton
Fix regression introduced in swig-2.0.2 where filenames with spaces were not found
when used with %include and %import. Reported by Shane Liesegang.
2011-03-15: wsfulton
[UTL] Fix overloading when using const char[], problem reported by David Maxwell.
Similarly for char[ANY] and const char[ANY].
2011-03-15: wsfulton
[C#] Apply patch #3212624 fixing std::map Keys property.
2011-03-14: olly
[PHP] Fix handling of overloaded methods/functions where some
return void and others don't - whether this worked or not depended
on the order they were encountered in (SF#3208299).
2011-03-13: klickverbot
[D] Extended support for C++ namespaces (nspace feature).
2011-03-12: olly
[PHP] Fix sharing of type information between multiple SWIG-wrapped
modules (SF#3202463).
2011-03-09: wsfulton
[Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value
for a primitive type parameter in a method declaration.
2011-03-07: olly
[PHP] Don't use zend_error_noreturn() for cases where the function
returns void - now this issue can only matter if you have a function
or method which is directed and returns non-void.
2011-03-06: olly
[PHP] Add casts to the typemaps for long long and unsigned long
long to avoid issues when they are used with shorter types via
%apply.
2011-03-02: wsfulton
Templated smart pointers overloaded with both const and non const operator-> generated uncompilable
code when the pointee was a class with either public member variables or static methods.
Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list.

View file

@ -729,6 +729,7 @@
<li><a href="D.html#D_directors">D Directors</a> <li><a href="D.html#D_directors">D Directors</a>
<li><a href="D.html#D_other_features">Other features</a> <li><a href="D.html#D_other_features">Other features</a>
<ul> <ul>
<li><a href="D.html#D_nspace">Extended namespace support (<tt>nspace</tt>)</a>
<li><a href="D.html#D_native_pointer_support">Native pointer support</a> <li><a href="D.html#D_native_pointer_support">Native pointer support</a>
<li><a href="D.html#D_operator_overloading">Operator overloading</a> <li><a href="D.html#D_operator_overloading">Operator overloading</a>
<li><a href="D.html#D_test_suite">Running the test-suite</a> <li><a href="D.html#D_test_suite">Running the test-suite</a>

View file

@ -28,7 +28,7 @@
<li><a href="#D_directors">D Directors</a> <li><a href="#D_directors">D Directors</a>
<li><a href="#D_other_features">Other features</a> <li><a href="#D_other_features">Other features</a>
<ul> <ul>
<li><a href="#D_nspace">Extended namespace support (<tt>nspace</tt>)</a></li> <li><a href="#D_nspace">Extended namespace support (<tt>nspace</tt>)</a>
<li><a href="#D_native_pointer_support">Native pointer support</a> <li><a href="#D_native_pointer_support">Native pointer support</a>
<li><a href="#D_operator_overloading">Operator overloading</a> <li><a href="#D_operator_overloading">Operator overloading</a>
<li><a href="#D_test_suite">Running the test-suite</a> <li><a href="#D_test_suite">Running the test-suite</a>

View file

@ -6,7 +6,7 @@
<body bgcolor="#ffffff"> <body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-2.0 Documentation</H1> <H1><a name="Sections"></a>SWIG-2.0 Documentation</H1>
Last update : SWIG-2.0.3 (in progress) Last update : SWIG-2.0.4 (in progress)
<H2>Sections</H2> <H2>Sections</H2>

View file

@ -5,6 +5,7 @@
LANGUAGE = csharp LANGUAGE = csharp
SCRIPTSUFFIX = _runme.cs SCRIPTSUFFIX = _runme.cs
INTERPRETER = @CSHARPCILINTERPRETER@ INTERPRETER = @CSHARPCILINTERPRETER@
INTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@" CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@ CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
srcdir = @srcdir@ srcdir = @srcdir@
@ -68,13 +69,13 @@ setup = \
run_testcase = \ run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \ $(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \ CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \ 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" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) $*_runme.exe; \
else \ else \
cd $* && \ cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \ CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \ CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
fi fi

View file

@ -405,6 +405,28 @@ public class runme {
if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed"); if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed"); if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
} }
// different types
{
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
int global_enum = enum_thorough.global_typeint;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
global_enum = enum_thorough.global_typeboolfalse;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
global_enum = enum_thorough.global_typebooltrue;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
global_enum = enum_thorough.global_typebooltwo;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
global_enum = enum_thorough.global_typechar;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough.global_typedefaultint;
if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
}
} }
} }

View file

@ -405,6 +405,28 @@ public class runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
} }
// different types
{
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
int global_enum = enum_thorough_simple.global_typeint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
global_enum = enum_thorough_simple.global_typeboolfalse;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
global_enum = enum_thorough_simple.global_typebooltrue;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
global_enum = enum_thorough_simple.global_typebooltwo;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
global_enum = enum_thorough_simple.global_typechar;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough_simple.global_typedefaultint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
}
} }
} }

View file

@ -405,6 +405,28 @@ public class runme {
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed"); if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed"); if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
} }
// different types
{
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
int global_enum = enum_thorough_typesafe.global_typeint;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
global_enum = enum_thorough_typesafe.global_typeboolfalse;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
global_enum = enum_thorough_typesafe.global_typebooltrue;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
global_enum = enum_thorough_typesafe.global_typebooltwo;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
global_enum = enum_thorough_typesafe.global_typechar;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
global_enum = enum_thorough_typesafe.global_typedefaultint;
if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
}
} }
} }

View file

@ -0,0 +1,43 @@
using System;
using friendsNamespace;
public class friends_runme {
public static void Main() {
A a = new A(2);
if (friends.get_val1(a) != 2)
throw new Exception("failed");
if (friends.get_val2(a) != 4)
throw new Exception("failed");
if (friends.get_val3(a) != 6)
throw new Exception("failed");
// nice overload working fine
if (friends.get_val1(1,2,3) != 1)
throw new Exception("failed");
B b = new B(3);
// David's case
if (friends.mix(a,b) != 5)
throw new Exception("failed");
D_d di = new D_d(2);
D_d dd = new D_d(3.3);
// incredible template overloading working just fine
if (friends.get_val1(di) != 2)
throw new Exception("failed");
if (friends.get_val1(dd) != 3.3)
throw new Exception("failed");
friends.set(di, 4);
friends.set(dd, 1.3);
if (friends.get_val1(di) != 4)
throw new Exception("failed");
if (friends.get_val1(dd) != 1.3)
throw new Exception("failed");
}
}

View file

@ -537,7 +537,6 @@ IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; }
%} %}
%inline %{ %inline %{
namespace RepeatSpace { namespace RepeatSpace {
typedef enum typedef enum
{ {
@ -550,6 +549,58 @@ typedef enum
} repeat; } repeat;
repeat repeatTest(repeat e) { return e; } repeat repeatTest(repeat e) { return e; }
} }
%}
%inline %{
namespace DifferentSpace {
enum DifferentTypes {
typeint = 10,
typeboolfalse = false,
typebooltrue = true,
typebooltwo,
typechar = 'C',
typedefaultint
};
DifferentTypes differentTypesTest(DifferentTypes n) { return n; }
enum {
global_typeint = 10,
global_typeboolfalse = false,
global_typebooltrue = true,
global_typebooltwo,
global_typechar = 'C',
global_typedefaultint
};
int globalDifferentTypesTest(int n) { return n; }
}
%} %}
#if defined(SWIGJAVA)
%javaconst(0);
#elif defined(SWIGCSHARP)
%csconst(0);
#endif
%inline %{
namespace DifferentSpace {
enum DifferentTypesNoConst {
typeint_noconst = 10,
typeboolfalse_noconst = false,
typebooltrue_noconst = true,
typebooltwo_noconst,
typechar_noconst = 'C',
typedefaultint_noconst
};
enum {
global_typeint_noconst = 10,
global_typeboolfalse_noconst = false,
global_typebooltrue_noconst = true,
global_typebooltwo_noconst,
global_typechar_noconst = 'C',
global_typedefaultint_noconst
};
}
%}

View file

@ -416,6 +416,28 @@ public class enum_thorough_proper_runme {
if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed"); if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
} }
// different types
{
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough_proper.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough_proper.global_typeint;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough_proper.global_typeboolfalse;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough_proper.global_typebooltrue;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough_proper.global_typebooltwo;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough_proper.global_typechar;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough_proper.global_typedefaultint;
if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
} }
} }

View file

@ -416,6 +416,28 @@ public class enum_thorough_runme {
if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed"); if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
} }
// different types
{
if (enum_thorough.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough.global_typeint;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough.global_typeboolfalse;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough.global_typebooltrue;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough.global_typebooltwo;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough.global_typechar;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough.global_typedefaultint;
if (enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
} }
} }

View file

@ -416,6 +416,28 @@ public class enum_thorough_simple_runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed"); if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
} }
// different types
{
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough_simple.global_typeint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough_simple.global_typeboolfalse;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough_simple.global_typebooltrue;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough_simple.global_typebooltwo;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough_simple.global_typechar;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough_simple.global_typedefaultint;
if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
} }
} }

View file

@ -416,6 +416,28 @@ public class enum_thorough_typeunsafe_runme {
if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed"); if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
} }
// different types
{
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
int global_enum = enum_thorough_typeunsafe.global_typeint;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
global_enum = enum_thorough_typeunsafe.global_typeboolfalse;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
global_enum = enum_thorough_typeunsafe.global_typebooltrue;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
global_enum = enum_thorough_typeunsafe.global_typebooltwo;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
global_enum = enum_thorough_typeunsafe.global_typechar;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
global_enum = enum_thorough_typeunsafe.global_typedefaultint;
if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
}
} }
} }

View file

@ -0,0 +1,53 @@
import friends.*;
public class friends_runme {
static {
try {
System.loadLibrary("friends");
} 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
{
A a = new A(2);
if (friends.get_val1(a) != 2)
throw new RuntimeException("failed");
if (friends.get_val2(a) != 4)
throw new RuntimeException("failed");
if (friends.get_val3(a) != 6)
throw new RuntimeException("failed");
// nice overload working fine
if (friends.get_val1(1,2,3) != 1)
throw new RuntimeException("failed");
B b = new B(3);
// David's case
if (friends.mix(a,b) != 5)
throw new RuntimeException("failed");
D_d di = new D_d(2);
D_d dd = new D_d(3.3);
// incredible template overloading working just fine
if (friends.get_val1(di) != 2)
throw new RuntimeException("failed");
if (friends.get_val1(dd) != 3.3)
throw new RuntimeException("failed");
friends.set(di, 4);
friends.set(dd, 1.3);
if (friends.get_val1(di) != 4)
throw new RuntimeException("failed");
if (friends.get_val1(dd) != 1.3)
throw new RuntimeException("failed");
}
}

View file

@ -8,5 +8,9 @@
bool func(A* a) { bool func(A* a) {
return !a; return !a;
} }
A* getnull() {
return 0;
}
} }

View file

@ -13,9 +13,9 @@
class FooImplementation { class FooImplementation {
public: public:
int mingy() {} int mingy() { return 0; }
int constmingy() const {} int constmingy() const { return 0; }
static int thingy() {} static int thingy() { return 0; }
static int svariable; static int svariable;
static const int constsvariable; static const int constsvariable;
int normalvariable; int normalvariable;

View file

@ -0,0 +1,21 @@
if [ catch { load ./null_pointer[info sharedlibextension] null_pointer} err_msg ] {
puts stderr "Could not load shared object:\n$err_msg"
}
set a [A]
if {[func $a] != 0} {
puts stderr "null_pointer test 1 failed"
exit 1
}
set null [getnull]
if {$null != "NULL"} {
puts stderr "null_pointer test 2 failed"
exit 1
}
if {[llength [info commands "NULL"]] != 0} {
puts stderr "null_pointer test 3 failed"
exit 1
}

View file

@ -170,12 +170,12 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
order to allow for use of CHARSXP caches. */ order to allow for use of CHARSXP caches. */
Rf_protect(t = Rf_allocVector(STRSXP, 1)); Rf_protect(t = Rf_allocVector(STRSXP, 1));
#if R_VERSION >= R_Version(2,7,0) %#if R_VERSION >= R_Version(2,7,0)
c = Rf_mkCharLen(carray, size); c = Rf_mkCharLen(carray, size);
#else %#else
c = Rf_allocVector(CHARSXP, size); c = Rf_allocVector(CHARSXP, size);
strncpy((char *)CHAR(c), carray, size); strncpy((char *)CHAR(c), carray, size);
#endif %#endif
SET_STRING_ELT(t, 0, c); SET_STRING_ELT(t, 0, c);
Rf_unprotect(1); Rf_unprotect(1);
return t; return t;

View file

@ -49,6 +49,7 @@ typedef struct swig_class {
struct swig_class **bases; struct swig_class **bases;
const char **base_names; const char **base_names;
swig_module_info *module; swig_module_info *module;
Tcl_HashTable hashtable;
} swig_class; } swig_class;
typedef struct swig_instance { typedef struct swig_instance {

View file

@ -67,6 +67,28 @@ SWIG_Tcl_InstallConstants(Tcl_Interp *interp, swig_const_info constants[]) {
} }
} }
/* Create fast method lookup tables */
SWIGINTERN void
SWIG_Tcl_InstallMethodLookupTables(Tcl_Interp *interp) {
int i;
for (i = 0; i < swig_module.size; ++i) {
swig_type_info *type = swig_module.type_initial[i];
if (type->clientdata) {
swig_class* klass = (swig_class*) type->clientdata;
Tcl_InitHashTable(&(klass->hashtable), TCL_STRING_KEYS);
swig_method* meth = klass->methods;
while (meth && meth->name) {
int newEntry;
Tcl_HashEntry* hashentry = Tcl_CreateHashEntry(&(klass->hashtable), meth->name, &newEntry);
Tcl_SetHashValue(hashentry, (ClientData)meth->method);
++meth;
}
}
}
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
@ -113,6 +135,7 @@ SWIGEXPORT int SWIG_init(Tcl_Interp *interp) {
} }
SWIG_Tcl_InstallConstants(interp, swig_constants); SWIG_Tcl_InstallConstants(interp, swig_constants);
SWIG_Tcl_InstallMethodLookupTables(interp);
%} %}

View file

@ -367,20 +367,18 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
} }
cls_stack_bi[cls_stack_top]++; cls_stack_bi[cls_stack_top]++;
meth = cls->methods; Tcl_HashEntry* hashentry = Tcl_FindHashEntry(&(cls->hashtable), method);
/* Check for methods */ if (hashentry) {
while (meth && meth->name) { ClientData cd = Tcl_GetHashValue(hashentry);
if (strcmp(meth->name,method) == 0) { swig_wrapper method_wrapper = (swig_wrapper)cd;
oldarg = objv[1]; oldarg = objv[1];
objv[1] = inst->thisptr; objv[1] = inst->thisptr;
Tcl_IncrRefCount(inst->thisptr); Tcl_IncrRefCount(inst->thisptr);
rcode = (*meth->method)(clientData,interp,objc,objv); rcode = (method_wrapper)(clientData,interp,objc,objv);
objv[1] = oldarg; objv[1] = oldarg;
Tcl_DecrRefCount(inst->thisptr); Tcl_DecrRefCount(inst->thisptr);
return rcode; return rcode;
} }
meth++;
}
/* Check class methods for a match */ /* Check class methods for a match */
if (strcmp(method,"cget") == 0) { if (strcmp(method,"cget") == 0) {
if (objc < 3) { if (objc < 3) {
@ -486,7 +484,7 @@ SWIGRUNTIME Tcl_Obj *
SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) { SWIG_Tcl_NewInstanceObj(Tcl_Interp *interp, void *thisvalue, swig_type_info *type, int flags) {
Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0); Tcl_Obj *robj = SWIG_NewPointerObj(thisvalue, type,0);
/* Check to see if this pointer belongs to a class or not */ /* Check to see if this pointer belongs to a class or not */
if ((type->clientdata) && (interp)) { if (thisvalue && (type->clientdata) && (interp)) {
Tcl_CmdInfo ci; Tcl_CmdInfo ci;
char *name; char *name;
name = Tcl_GetStringFromObj(robj,NULL); name = Tcl_GetStringFromObj(robj,NULL);

2
README
View file

@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator) SWIG (Simplified Wrapper and Interface Generator)
Version: 2.0.3 (in progress) Version: 2.0.4 (in progress)
Tagline: SWIG is a compiler that integrates C and C++ with languages Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua, including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua,

View file

@ -4,6 +4,10 @@ and CHANGES files.
Release Notes Release Notes
============= =============
SWIG-2.0.3 summary:
- A bug fix release including a couple of fixes for regressions in the
2.0 series.
SWIG-2.0.2 summary: SWIG-2.0.2 summary:
- Support for the D language has been added. - Support for the D language has been added.
- Various bug fixes and minor enhancements. - Various bug fixes and minor enhancements.

View file

@ -5591,21 +5591,14 @@ edecl : ID {
Delete(type); Delete(type);
} }
| ID EQUAL etype { | ID EQUAL etype {
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : ($3.type == T_CHAR ? T_CHAR : T_INT));
$$ = new_node("enumitem"); $$ = new_node("enumitem");
Setattr($$,"name",$1); Setattr($$,"name",$1);
Setattr($$,"enumvalue", $3.val);
if ($3.type == T_CHAR) {
SwigType *type = NewSwigType(T_CHAR);
Setattr($$,"value",NewStringf("\'%(escape)s\'", $3.val));
Setattr($$,"type",type); Setattr($$,"type",type);
Delete(type);
} else {
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : T_INT);
Setattr($$,"value",$1);
Setattr($$,"type",type);
Delete(type);
}
SetFlag($$,"feature:immutable"); SetFlag($$,"feature:immutable");
Setattr($$,"enumvalue", $3.val);
Setattr($$,"value",$1);
Delete(type);
} }
| empty { $$ = 0; } | empty { $$ = 0; }
; ;
@ -5619,7 +5612,6 @@ etype : expr {
($$.type != T_CHAR) && ($$.type != T_BOOL)) { ($$.type != T_CHAR) && ($$.type != T_BOOL)) {
Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n"); Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n");
} }
if ($$.type == T_CHAR) $$.type = T_INT;
} }
; ;

View file

@ -863,9 +863,10 @@ int CHICKEN::constantWrapper(Node *n) {
Delete(SwigType_pop(nctype)); Delete(SwigType_pop(nctype));
} }
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if (SwigType_type(nctype) == T_STRING) { if (SwigType_type(nctype) == T_STRING) {
rvalue = NewStringf("\"%s\"", value); rvalue = NewStringf("\"%s\"", value);
} else if (SwigType_type(nctype) == T_CHAR) { } else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
rvalue = NewStringf("\'%s\'", value); rvalue = NewStringf("\'%s\'", value);
} else { } else {
rvalue = NewString(value); rvalue = NewString(value);

View file

@ -1274,11 +1274,15 @@ public:
// Note that this is used in enumValue() amongst other places // Note that this is used in enumValue() amongst other places
Setattr(n, "value", tmpValue); Setattr(n, "value", tmpValue);
// Deal with enum values that are bools // Deal with enum values that are not int
if (SwigType_type(Getattr(n, "type")) == T_BOOL) { int swigtype = SwigType_type(Getattr(n, "type"));
String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue")); if (swigtype == T_BOOL) {
Setattr(n, "enumvalue", boolValue); const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Delete(boolValue); Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
} }
{ {
@ -1329,11 +1333,12 @@ public:
} }
} else { } else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern // Wrap C/C++ enums with constant integers or use the typesafe enum pattern
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */ SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum ");
SwigType *typemap_lookup_type = parent_name ? parent_name : type; Setattr(n, "type", typemap_lookup_type);
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF); const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
String *return_type = Copy(tm); String *return_type = Copy(tm);
substituteClassname(typemap_lookup_type, return_type);
const String *methodmods = Getattr(n, "feature:cs:methodmodifiers"); const String *methodmods = Getattr(n, "feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
@ -1362,6 +1367,7 @@ public:
Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value); Printf(enum_code, " %s %s %s %s = %s;\n", methodmods, const_readonly, return_type, symname, value);
Delete(value); Delete(value);
} }
Delete(return_type);
} }
// Add the enum value to the comma separated list being constructed in the enum declaration. // Add the enum value to the comma separated list being constructed in the enum declaration.
@ -1396,6 +1402,7 @@ public:
String *tm; String *tm;
String *return_type = NewString(""); String *return_type = NewString("");
String *constants_code = NewString(""); String *constants_code = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
@ -1444,7 +1451,6 @@ public:
// Add the stripped quotes back in // Add the stripped quotes back in
String *new_value = NewString(""); String *new_value = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
if (SwigType_type(t) == T_STRING) { if (SwigType_type(t) == T_STRING) {
Printf(new_value, "\"%s\"", Copy(Getattr(n, "value"))); Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
Setattr(n, "value", new_value); Setattr(n, "value", new_value);

View file

@ -1393,9 +1393,10 @@ public:
} }
// See if there's a typemap // See if there's a typemap
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if (SwigType_type(nctype) == T_STRING) { if (SwigType_type(nctype) == T_STRING) {
rvalue = NewStringf("\"%s\"", value); rvalue = NewStringf("\"%s\"", value);
} else if (SwigType_type(nctype) == T_CHAR) { } else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
rvalue = NewStringf("\'%s\'", value); rvalue = NewStringf("\'%s\'", value);
} else { } else {
rvalue = NewString(value); rvalue = NewString(value);

View file

@ -1349,11 +1349,15 @@ public:
// Note that this is used in enumValue() amongst other places // Note that this is used in enumValue() amongst other places
Setattr(n, "value", tmpValue); Setattr(n, "value", tmpValue);
// Deal with enum values that are bools // Deal with enum values that are not int
if (SwigType_type(Getattr(n, "type")) == T_BOOL) { int swigtype = SwigType_type(Getattr(n, "type"));
String *boolValue = NewStringf("%s ? 1 : 0", Getattr(n, "enumvalue")); if (swigtype == T_BOOL) {
Setattr(n, "enumvalue", boolValue); const char *val = Equal(Getattr(n, "enumvalue"), "true") ? "1" : "0";
Delete(boolValue); Setattr(n, "enumvalue", val);
} else if (swigtype == T_CHAR) {
String *val = NewStringf("'%s'", Getattr(n, "enumvalue"));
Setattr(n, "enumvalue", val);
Delete(val);
} }
{ {
@ -1394,11 +1398,12 @@ public:
} }
} else { } else {
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern // Wrap C/C++ enums with constant integers or use the typesafe enum pattern
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */ SwigType *typemap_lookup_type = parent_name ? parent_name : NewString("enum ");
SwigType *typemap_lookup_type = parent_name ? parent_name : type; Setattr(n, "type", typemap_lookup_type);
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF); const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
String *return_type = Copy(tm); String *return_type = Copy(tm);
substituteClassname(typemap_lookup_type, return_type);
const String *methodmods = Getattr(n, "feature:java:methodmodifiers"); const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string); methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
@ -1419,6 +1424,7 @@ public:
Printf(enum_code, " %s final static %s %s = %s;\n", methodmods, return_type, symname, value); Printf(enum_code, " %s final static %s %s = %s;\n", methodmods, return_type, symname, value);
Delete(value); Delete(value);
} }
Delete(return_type);
} }
// Add the enum value to the comma separated list being constructed in the enum declaration. // Add the enum value to the comma separated list being constructed in the enum declaration.
@ -1453,6 +1459,7 @@ public:
String *tm; String *tm;
String *return_type = NewString(""); String *return_type = NewString("");
String *constants_code = NewString(""); String *constants_code = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0); bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
@ -1498,7 +1505,6 @@ public:
// Add the stripped quotes back in // Add the stripped quotes back in
String *new_value = NewString(""); String *new_value = NewString("");
Swig_save("constantWrapper", n, "value", NIL);
if (SwigType_type(t) == T_STRING) { if (SwigType_type(t) == T_STRING) {
Printf(new_value, "\"%s\"", Copy(Getattr(n, "value"))); Printf(new_value, "\"%s\"", Copy(Getattr(n, "value")));
Setattr(n, "value", new_value); Setattr(n, "value", new_value);

View file

@ -1044,7 +1044,10 @@ int Language::functionHandler(Node *n) {
if (isstatic) { if (isstatic) {
staticmemberfunctionHandler(n); staticmemberfunctionHandler(n);
} else if (isfriend) { } else if (isfriend) {
int oldInClass = InClass;
InClass = 0;
globalfunctionHandler(n); globalfunctionHandler(n);
InClass = oldInClass;
} else { } else {
Node *explicit_n = 0; Node *explicit_n = 0;
if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) { if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) {

View file

@ -637,9 +637,10 @@ public:
// Create variable and assign it a value // Create variable and assign it a value
Printf(f_header, "static %s = ", SwigType_lstr(type, var_name)); Printf(f_header, "static %s = ", SwigType_lstr(type, var_name));
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if ((SwigType_type(type) == T_STRING)) { if ((SwigType_type(type) == T_STRING)) {
Printf(f_header, "\"%s\";\n", value); Printf(f_header, "\"%s\";\n", value);
} else if (SwigType_type(type) == T_CHAR) { } else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
Printf(f_header, "\'%s\';\n", value); Printf(f_header, "\'%s\';\n", value);
} else { } else {
Printf(f_header, "%s;\n", value); Printf(f_header, "%s;\n", value);

View file

@ -927,9 +927,10 @@ public:
// Create variable and assign it a value // Create variable and assign it a value
Printf(f_header, "static %s = ", SwigType_lstr(type, name)); Printf(f_header, "static %s = ", SwigType_lstr(type, name));
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
if ((SwigType_type(type) == T_STRING)) { if ((SwigType_type(type) == T_STRING)) {
Printf(f_header, "\"%s\";\n", value); Printf(f_header, "\"%s\";\n", value);
} else if (SwigType_type(type) == T_CHAR) { } else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
Printf(f_header, "\'%s\';\n", value); Printf(f_header, "\'%s\';\n", value);
} else { } else {
Printf(f_header, "%s;\n", value); Printf(f_header, "%s;\n", value);

View file

@ -578,12 +578,16 @@ public:
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
SwigType *type = Getattr(n, "type"); SwigType *type = Getattr(n, "type");
String *value = Getattr(n, "value"); String *value = Getattr(n, "value");
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
/* Special hook for member pointer */
if (SwigType_type(type) == T_MPOINTER) { if (SwigType_type(type) == T_MPOINTER) {
/* Special hook for member pointer */
String *wname = Swig_name_wrapper(symname); String *wname = Swig_name_wrapper(symname);
Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value); Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value);
value = wname; value = wname;
} else if (SwigType_type(type) == T_CHAR && is_enum_item) {
type = NewSwigType(T_INT);
Setattr(n, "type", type);
} }
/* Perform constant typemap substitution */ /* Perform constant typemap substitution */

View file

@ -531,7 +531,17 @@ public:
Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n"); Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n");
Printf(df->code, "int argc = objc-1;\n"); Printf(df->code, "int argc = objc-1;\n");
Printv(df->code, dispatch, "\n", NIL); Printv(df->code, dispatch, "\n", NIL);
Printf(df->code, "Tcl_SetResult(interp,(char *) \"No matching function for overloaded '%s'\", TCL_STATIC);\n", iname); Node *sibl = n;
while (Getattr(sibl, "sym:previousSibling"))
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
String *protoTypes = NewString("");
do {
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Printf(df->code, "Tcl_SetResult(interp,(char *) "
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\""
"\n\" Possible C/C++ prototypes are:\\n\"%s, TCL_STATIC);\n", iname, protoTypes);
Delete(protoTypes);
Printf(df->code, "return TCL_ERROR;\n"); Printf(df->code, "return TCL_ERROR;\n");
Printv(df->code, "}\n", NIL); Printv(df->code, "}\n", NIL);
Wrapper_print(df, f_wrappers); Wrapper_print(df, f_wrappers);

View file

@ -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 The macros which aren't shipped with the autotools are stored in the
dnl Tools/config directory in .m4 files. dnl Tools/config directory in .m4 files.
AC_INIT([swig],[2.0.3],[http://www.swig.org]) AC_INIT([swig],[2.0.4],[http://www.swig.org])
dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
dnl definition below can be removed dnl definition below can be removed
@ -1741,6 +1741,7 @@ CSHARPPATHSEPARATOR="/"
CSHARPCYGPATH_W=echo CSHARPCYGPATH_W=echo
if test -z "$CSHARPBIN" ; then if test -z "$CSHARPBIN" ; then
CSHARPCILINTERPRETER="" CSHARPCILINTERPRETER=""
CSHARPCILINTERPRETER_FLAGS=""
if test "cscc" = "$CSHARPCOMPILER" ; then if test "cscc" = "$CSHARPCOMPILER" ; then
AC_CHECK_PROGS(CSHARPCILINTERPRETER, ilrun) AC_CHECK_PROGS(CSHARPCILINTERPRETER, ilrun)
else else
@ -1761,6 +1762,7 @@ if test -z "$CSHARPBIN" ; then
fi fi
if test "mcs" = "$CSHARPCOMPILER" || test "gmcs" = "$CSHARPCOMPILER"; then if test "mcs" = "$CSHARPCOMPILER" || test "gmcs" = "$CSHARPCOMPILER"; then
AC_CHECK_PROGS(CSHARPCILINTERPRETER, mono) # Mono JIT AC_CHECK_PROGS(CSHARPCILINTERPRETER, mono) # Mono JIT
CSHARPCILINTERPRETER_FLAGS="--debug"
else else
if test "csc" = "$CSHARPCOMPILER"; then if test "csc" = "$CSHARPCOMPILER"; then
CSHARPPATHSEPARATOR="\\\\" CSHARPPATHSEPARATOR="\\\\"
@ -1805,6 +1807,7 @@ case $host in
esac esac
fi fi
AC_SUBST(CSHARPCILINTERPRETER_FLAGS)
AC_SUBST(CSHARPCILINTERPRETER) AC_SUBST(CSHARPCILINTERPRETER)
AC_SUBST(CSHARPPATHSEPARATOR) AC_SUBST(CSHARPPATHSEPARATOR)
AC_SUBST(CSHARPCYGPATH_W) AC_SUBST(CSHARPCYGPATH_W)