merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11821 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2010-01-11 00:59:12 +00:00
commit d8a371808a
190 changed files with 5425 additions and 2040 deletions

View file

@ -1,10 +1,10 @@
*** ANNOUNCE: SWIG 1.3.40 (in progress) ***
*** ANNOUNCE: SWIG 1.3.41 (in progress) ***
http://www.swig.org
We're pleased to announce SWIG-1.3.40, the latest installment in the
SWIG development effort. SWIG-1.3.40 includes a number of bug fixes
We're pleased to announce SWIG-1.3.41, the latest installment in the
SWIG development effort. SWIG-1.3.41 includes a number of bug fixes
and enhancements.
What is SWIG?
@ -24,11 +24,11 @@ Availability:
-------------
The release is available for download on Sourceforge at
http://prdownloads.sourceforge.net/swig/swig-1.3.40.tar.gz
http://prdownloads.sourceforge.net/swig/swig-1.3.41.tar.gz
A Windows version is also available at
http://prdownloads.sourceforge.net/swig/swigwin-1.3.40.zip
http://prdownloads.sourceforge.net/swig/swigwin-1.3.41.zip
Please report problems with this release to the swig-dev mailing list,
details at http://www.swig.org/mail.html.

View file

@ -37,7 +37,6 @@ $(PACKAGE_NAME).1: ccache.yo
-yodl2man -o $(PACKAGE_NAME).1 ccache.yo
web/ccache-man.html: ccache.yo
mkdir -p man
yodl2html -o web/ccache-man.html ccache.yo
install: $(PACKAGE_NAME)$(EXEEXT) $(PACKAGE_NAME).1
@ -64,8 +63,11 @@ test: test.sh
check: test
distclean: clean distclean-docs
/bin/rm -f Makefile config.h config.sub config.log build-stamp config.status configure config.h
/bin/rm -f Makefile config.h config.sub config.log build-stamp config.status config.h.in ccache_swig_config.h
maintainer-clean: distclean
/bin/rm -f configure
# FIXME: To fix this, test.sh needs to be able to take ccache from the
# installed prefix, not from the source dir.
installcheck:

258
CHANGES
View file

@ -2,6 +2,264 @@ SWIG (Simplified Wrapper and Interface Generator)
See CHANGES.current for current version.
Version 1.3.40 (18 August 2009)
===============================
2009-08-17: olly
[Perl] Add "#undef do_exec" to our clean up of Perl global
namespace pollution.
2009-08-17: olly
[PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217).
2009-08-17: wsfulton
Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html
is not available.
2009-08-16: wsfulton
[Octave] Caught exceptions display the type of the C++ exception instead of the
generic "c++-side threw an exception" message.
2009-08-16: wsfulton
[Java] When %catches is used, fix so that any classes specified in the "throws"
attribute of the "throws" typemap are generated into the Java method's throws clause.
2009-08-16: wsfulton
[C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez.
2009-08-15: wsfulton
Fix %template seg fault on some cases of overloading the templated method.
Bug reported by Jan Kupec.
2009-08-15: wsfulton
[Ruby] Add numerous missing wrapped methods for std::vector<bool> specialization
as reported by Youssef Jones.
2009-08-14: wsfulton
[Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
memory ownership control. shared_ptr support still to be added. Patch from
David Fletcher.
2009-08-14: olly
[PHP] PHP5 now wraps static member variables as documented.
2009-08-14: olly
[PHP] Update the PHP "class" example to work with PHP5 and use
modern wrapping features.
2009-08-13: wsfulton
[PHP] std::vector wrappers overhaul. They no longer require the
specialize_std_vector() macro. Added wrappers for capacity() and reserve().
2009-08-13: wsfulton
[PHP] Add const reference typemaps. const reference primitive types are
now passed by value rather than pointer like the other target languages.
Fixes SF#2524029.
2009-08-08: wsfulton
[Python] More user friendly AttributeError is raised when there are
no constructors generated for the proxy class in the event that the
class is abstract - the error message is now
"No constructor defined - class is abstract" whereas if there are no
public constructors for any other reason and the class is not abstract,
the message remains
"No constructor defined".
[tcl] Similarly for tcl when using -itcl.
2009-08-04: olly
[PHP] Fix generated code to work with PHP 5.3.
2009-08-04: vmiklos
[PHP] Various mathematical functions (which would conflict
with the built-in PHP ones) are now automatically handled by
adding a 'c_' prefix.
2009-08-03: wsfulton
[C#] The std::vector<T> implementation is improved and now uses $typemap such
that the proxy class for T no longer has to be specified in some macros
for correct C# compilation; the following macros are deprecated, where
CSTYPE was the C# type for the C++ class CTYPE:
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE)
usage should be removed altogether
SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE)
should be replaced with:
SWIG_STD_VECTOR_ENHANCED(CTYPE)
Some more details in csharp/std_vector.i
*** POTENTIAL INCOMPATIBILITY ***
2009-07-31: olly
[Python] Fix indentation so that we give a useful error if the
module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.
2009-07-29: wsfulton
Add $typemap(method, typelist) special variable macro. This allows
the contents of a typemap to be inserted within another typemap.
Fully documented in Typemaps.html.
2009-07-29: vmiklos
[PHP] Static member variables are now prefixed with the
class name. This allows static member variables with the
same name in different classes.
2009-07-29: olly
[Python] Add missing locks to std::map wrappers. Patch from
Paul Hampson in SF#2813836.
2009-07-29: olly
[PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi
Amano in SF#2826322.
2009-07-29: olly
[PHP] Fix memory leak in PHP resource destructor for classes
without a destructor and non-class types. Patch from Hitoshi Amano
in SF#2825303.
2009-07-28: olly
[PHP] Update warnings about clashes between identifiers and PHP
keywords and automatic renaming to work with the PHP5 class
wrappers. Fixes SF#1613679.
2009-07-28: vmiklos
[PHP] If a member function is not public but it has a base
which is public, then now a warning is issued and the member
function will be public, as PHP requires this.
2009-07-21: vmiklos
[PHP] Director support added.
2009-07-15: olly
[Perl] Don't specify Perl prototype "()" for a constructor with a
different name to the class, as such constructors can still take
parameters.
2009-07-12: xavier98
[Octave] Add support for Octave 3.2 API
2009-07-05: olly
[PHP] Update the list of PHP keywords - "cfunction" is no longer a
keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
and "__NAMESPACE__".
2009-07-03: olly
[Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS
and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter
of the manual. Based on patch from SF#2810380 by Christian
Gollwitzer.
2009-07-02: vmiklos
[PHP] Added factory.i for PHP, see the li_factory testcase
for more info on how to use it.
2009-07-02: wsfulton
Fix -Wallkw option as reported by Solomon Gibbs.
2009-07-02: wsfulton
Fix syntax error when a nested struct contains a comment containing a * followed
eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs.
2009-07-01: vmiklos
[PHP] Unknown properties are no longer ignored in proxy
classes.
2009-07-01: vmiklos
[PHP] Fixed %newobject behaviour, previously any method
marked with %newobject was handled as a constructor.
2009-06-30: olly
[Ruby] Undefine close and connect macros defined by Ruby API
headers as we don't need them and they can clash with C++ methods
being wrapped. Patch from Vit Ondruch in SF#2814430.
2009-06-26: olly
[Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a
double parameter.
2009-06-24: wsfulton
Fix wrapping methods with default arguments and the compactdefaultargs feature
where a class is passed by value and is assigned a default value. The SwigValueWrapper
template workaround for a missing default constructor is no longer used as the code
generated does not call the default constructor.
2009-06-16: wsfulton
[Java,C#] Fix enum marshalling when %ignore is used on one of the enum items.
Incorrect enum values were being passed to the C++ layer or compilation errors resulted.
2009-06-02: talby
[Perl] Resolved reference.i overload support problem
identified by John Potowsky.
2009-05-26: wsfulton
[C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy
now implements System.Collections.Generic.IDictionary<>.
These std:map wrappers have a non-backwards compatible overhaul to make them
like a .NET IDictionary. Some method names have changed as following:
set -> setitem (use this[] property now)
get -> getitem (use this[] property now)
has_key -> ContainsKey
del -> Remove
clear -> Clear
The following macros used for std::map wrappers are deprecated and will no longer work:
specialize_std_map_on_key
specialize_std_map_on_value
specialize_std_map_on_both
*** POTENTIAL INCOMPATIBILITY ***
2009-05-20: vmiklos
[PHP] Add the 'thisown' member to classes. The usage of it
is the same as the Python thisown one: it's 1 by default and
you can set it to 0 if you want to prevent freeing it. (For
example to prevent a double free.)
2009-05-14: bhy
[Python] Fix the wrong pointer value returned by SwigPyObject_repr().
2009-05-13: mutandiz (Mikel Bancroft)
[allegrocl] Minor tweak when wrapping in -nocwrap mode.
2009-05-11: wsfulton
[C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These
implement IList<> instead of IEnumerable<> where possible.
2009-04-29: wsfulton
[Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps.
When this attribute is set, the typemap will not apply to classes that are derived
from a C++ base class, eg
%typemap(csbase, notderived="1") SWIGTYPE "CommonBase"
2009-04-29: olly
[Python] Don't attempt to acquire the GIL in situations where we
know that it will already be locked. This avoids some dead-locks
with mod_python (due to mod_python bugs which are apparently
unlikely to ever be fixed), and results in smaller wrappers which
run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04,
the stripped wrapper library was 11% smaller and ran 2.7% faster).
2009-04-21: wsfulton
[C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation.
2009-04-09: wsfulton
Fix #2746858 - C macro expression using floating point numbers
2009-03-30: olly
[PHP] The default out typemap for char[ANY] now returns the string up to a
zero byte, or the end of the array if there is no zero byte. This
is the same as Python does, and seems more generally useful than
the previous behaviour of returning the whole contents of the array
including any zero bytes. If you want the old behaviour, you can provide
your own typemap to do this:
%typemap(out) char [ANY]
%{
RETVAL_STRINGL($1, $1_dim0, 1);
%}
Version 1.3.39 (21 March 2009)
==============================

View file

@ -1,257 +1,295 @@
Version 1.3.40 (in progress)
Version 1.3.41 (in progress)
============================
2009-08-17: olly
[Perl] Add "#undef do_exec" to our clean up of Perl global
namespace pollution.
2010-01-11: wsfulton
Slight change to warning, error and diagnostic reporting. The warning number is no
longer shown within brackets. This is to help default parsing of warning messages by
other tools, vim on Unix in particular.
2009-08-17: olly
[PHP] Fix to wrap a resource returned by __get() in a PHP object (SF#2549217).
Example original display using -Fstandard:
example.i:20: Warning(401): Nothing known about base class 'B'. Ignored.
New display:
example.i:20: Warning 401: Nothing known about base class 'B'. Ignored.
2009-08-17: wsfulton
Fix #2797485 After doing a 'make clean', install fails if yodl2man or yodl2html
is not available.
Also subtle fix to -Fmicrosoft format adding in missing space. Example original display:
example.i(20): Warning(401): Nothing known about base class 'Base'. Ignored.
New display:
example.i(20) : Warning 401: Nothing known about base class 'Base'. Ignored.
2009-08-16: wsfulton
[Octave] Caught exceptions display the type of the C++ exception instead of the
generic "c++-side threw an exception" message.
2010-01-10: wsfulton
Fix a few inconsistencies in reporting of file/line numberings including modifying
the overload warnings 509, 512, 516, 474, 475 to now be two line warnings.
2009-08-16: wsfulton
[Java] When %catches is used, fix so that any classes specified in the "throws"
attribute of the "throws" typemap are generated into the Java method's throws clause.
2010-01-10: wsfulton
Modify -debug-tags output to use standard file name/line reporting so that editors
can easily navigate to the appropriate lines.
Was typically:
. top . include . include (/usr/share/swig/temp/trunk/Lib/swig.swg:312)
. top . include . include . include (/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39)
now:
/usr/share/swig/temp/trunk/Lib/swig.swg:312: . top . include . include
/usr/share/swig/temp/trunk/Lib/swigwarnings.swg:39: . top . include . include . include
2009-08-16: wsfulton
[C#] Fix exception handling when %catches is used, reported by Juan Manuel Alvarez.
2010-01-03: wsfulton
Fix missing file/line numbers for typemap warnings and in output from the
-debug-tmsearch/-debug-tmused options.
2009-08-15: wsfulton
Fix %template seg fault on some cases of overloading the templated method.
Bug reported by Jan Kupec.
2010-01-03: wsfulton
Add typemaps used debugging option (-debug-tmused). When used each line displays
the typemap used for each type for which code is being generated including the file
and line number related to the type. This is effectively a condensed form of the
-debug-tmsearch option. Documented in Typemaps.html.
2009-08-15: wsfulton
[Ruby] Add numerous missing wrapped methods for std::vector<bool> specialization
as reported by Youssef Jones.
2009-12-23: wsfulton
Fix for %javaexception and directors so that all the appropriate throws clauses
are generated. Problem reported by Peter Greenwood.
2009-08-14: wsfulton
[Perl] Add SWIG_ConvertPtrAndOwn() method into the runtime for smart pointer
memory ownership control. shared_ptr support still to be added. Patch from
David Fletcher.
2009-12-20: wsfulton
Add -debug-tmsearch option for debugging the typemap pattern matching rules.
Documented in Typemaps.html.
2009-08-14: olly
[PHP] PHP5 now wraps static member variables as documented.
2009-12-12: wsfulton
[Octave] Remove the -api option and use the new OCTAVE_API_VERSION_NUMBER
macro provided in the octave headers for determining the api version instead.
2009-08-14: olly
[PHP] Update the PHP "class" example to work with PHP5 and use
modern wrapping features.
2009-12-04: olly
[Ruby] Improve support for Ruby 1.9 under GCC. Addresses part of
SF#2859614.
2009-08-13: wsfulton
[PHP] std::vector wrappers overhaul. They no longer require the
specialize_std_vector() macro. Added wrappers for capacity() and reserve().
2009-12-04: olly
Fix handling of modulo operator (%) in constant expressions
(SF#2818562).
2009-08-13: wsfulton
[PHP] Add const reference typemaps. const reference primitive types are
now passed by value rather than pointer like the other target languages.
Fixes SF#2524029.
2009-12-04: olly
[PHP] "empty" is a reserved word in PHP, so rename empty() method
on STL classes to "is_empty()" (previously this was automatically
renamed to "c_empty()").
*** POTENTIAL INCOMPATIBILITY ***
2009-08-08: wsfulton
[Python] More user friendly AttributeError is raised when there are
no constructors generated for the proxy class in the event that the
class is abstract - the error message is now
"No constructor defined - class is abstract" whereas if there are no
public constructors for any other reason and the class is not abstract,
the message remains
"No constructor defined".
[tcl] Similarly for tcl when using -itcl.
2009-12-03: olly
[PHP] Add typemaps for long long and unsigned long long, and for
pointer to method.
2009-08-04: olly
[PHP] Fix generated code to work with PHP 5.3.
2009-12-02: olly
[PHP] Fix warning and rename of reserved class name to be case
insensitive.
2009-08-04: vmiklos
[PHP] Various mathematical functions (which would conflict
with the built-in PHP ones) are now automatically handled by
adding a 'c_' prefix.
2009-12-01: wsfulton
Revert support for %extend and memberin typemaps added in swig-1.3.39. The
memberin typemaps are ignored again for member variables within a %extend block.
Documentation inconsistency reported by Torsten Landschoff.
2009-08-03: wsfulton
[C#] The std::vector<T> implementation is improved and now uses $typemap such
that the proxy class for T no longer has to be specified in some macros
for correct C# compilation; the following macros are deprecated, where
CSTYPE was the C# type for the C++ class CTYPE:
2009-11-29: wsfulton
[Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for
static const char member variables.
SWIG_STD_VECTOR_SPECIALIZE_MINIMUM(CSTYPE, CTYPE)
usage should be removed altogether
%javaconst(1) A;
%csconst(1) A;
struct X {
static const char A = 'A';
};
SWIG_STD_VECTOR_SPECIALIZE(CSTYPE, CTYPE)
should be replaced with:
SWIG_STD_VECTOR_ENHANCED(CTYPE)
2009-11-26: wsfulton
[Java, C#] Fix %javaconst(1)/%csconst(1) for static const member variables to
use the actual constant value if it is specified, rather than the C++ code to
access the member.
Some more details in csharp/std_vector.i
%javaconst(1) EN;
%csconst(1) EN;
struct X {
static const int EN = 2;
};
2009-11-23: wsfulton
C++ nested typedef classes can now be handled too, for example:
struct Outer {
typedef Foo { } FooTypedef1, FooTypedef2;
};
2009-11-18: wsfulton
The wrappers for C nested structs are now generated in the same order as declared
in the parsed code.
2009-11-18: wsfulton
Fix #491476 - multiple declarations of nested structs, for example:
struct Outer {
struct {
int val;
} inner1, inner2, *inner3, inner4[1];
} outer;
2009-11-17: wsfulton
Fix parsing of enum declaration and initialization, for example:
enum ABC {
a,
b,
c
} A = a, *pC = &C, array[3] = {a, b, c};
2009-11-17: wsfulton
Fix parsing of struct declaration and initialization, for example:
struct S {
int x;
} instance = { 10 };
2009-11-15: wsfulton
Fix #1960977 - Syntax error parsing derived nested class declaration and member
variable instance.
2009-11-14: wsfulton
Fix #2310483 - function pointer typedef within extern "C" block.
2009-11-13: wsfulton
Fix usage of nested template classes within templated classes so that compileable code
is generated.
2009-11-13: olly
[php] Fix place where class prefix (as specified with -prefix)
wasn't being used. Patch from gverbruggen in SF#2892647.
2009-11-12: wsfulton
Fix usage of nested template classes so that compileable code is generated - the nested
template class is now treated like a normal nested classes, that is, as an opaque type
unless the nestedworkaround feature is used.
2009-11-12: wsfulton
Replace SWIGWARN_PARSE_NESTED_CLASS with SWIGWARN_PARSE_NAMED_NESTED_CLASS and
SWIGWARN_PARSE_UNNAMED_NESTED_CLASS for named and unnamed nested classes respectively.
Named nested class ignored warnings can now be suppressed by name using %warnfilter, eg:
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
but clearly unnamed nested classes cannot and the global suppression is still required, eg:
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
2009-11-11: wsfulton
Added the nestedworkaround feature as a way to use the full functionality of a nested class
(C++ mode only). It removes the nested class from SWIG's type information so it is as if SWIG
had never parsed the nested class. The documented nested class workarounds using a global
fake class stopped working when SWIG treated the nested class as an opaque pointer, and
this feature reverts this behaviour. The documentation has been updated with details of how
to use and implement it, see the "Nested classes" section in SWIGPlus.html.
2009-11-11: wsfulton
There were a number of C++ cases where nested classes/structs/unions were being handled
as if C code was being parsed which would oftentimes lead to uncompileable code as an
attempt was made to wrap the nested structs like it is documented for C code. Now all
nested structs/classes/unions are ignored in C++ mode, as was always documented. However,
there is an improvement as usage of nested structs/classes/unions is now always treated
as an opaque type by default, resulting in generated code that should always compile.
*** POTENTIAL INCOMPATIBILITY ***
2009-07-31: olly
[Python] Fix indentation so that we give a useful error if the
module can't be loaded. Patch from Gaetan Lehmann in SF#2829853.
2009-11-09: drjoe
Fix R for -fcompact and add std_map.i
2009-07-29: wsfulton
Add $typemap(method, typelist) special variable macro. This allows
the contents of a typemap to be inserted within another typemap.
Fully documented in Typemaps.html.
2009-11-08: wsfulton
Fix inconsistency for nested structs/unions/classes. Uncompileable code was being
generated when inner struct and union declarations were used as types within the
inner struct. The inner struct/union is now treated as a forward declaration making the
behaviour the same as an inner class. (C++ code), eg:
2009-07-29: vmiklos
[PHP] Static member variables are now prefixed with the
class name. This allows static member variables with the
same name in different classes.
struct Outer {
struct InnerStruct { int x; };
InnerStruct* getInnerStruct();
};
2009-07-29: olly
[Python] Add missing locks to std::map wrappers. Patch from
Paul Hampson in SF#2813836.
2009-11-08: wsfulton
Ignored nested class/struct warnings now display the name of the ignored class/struct.
2009-07-29: olly
[PHP] Fix memory leak in PHP OUTPUT typemaps. Reported by Hitoshi
Amano in SF#2826322.
2009-11-07: wsfulton
Bug #1514681 - Fix nested template classes within a namespace generated uncompileable
code and introduced strange side effects to other wrapper code especially code
after the nested template class. Note that nested template classes are still ignored.
2009-07-29: olly
[PHP] Fix memory leak in PHP resource destructor for classes
without a destructor and non-class types. Patch from Hitoshi Amano
in SF#2825303.
2009-11-07: wsfulton
Add new debug options:
-debug-symtabs - Display symbol tables information
-debug-symbols - Display target language symbols in the symbol tables
-debug-csymbols - Display C symbols in the symbol tables
2009-07-28: olly
[PHP] Update warnings about clashes between identifiers and PHP
keywords and automatic renaming to work with the PHP5 class
wrappers. Fixes SF#1613679.
2009-11-03: wsfulton
Fix some usage of global scope operator, for example:
2009-07-28: vmiklos
[PHP] If a member function is not public but it has a base
which is public, then now a warning is issued and the member
function will be public, as PHP requires this.
namespace AA { /* ... */ }
using namespace ::AA;
2009-07-21: vmiklos
[PHP] Director support added.
and bug #1816802 - SwigValueWrapper should be used:
2009-07-15: olly
[Perl] Don't specify Perl prototype "()" for a constructor with a
different name to the class, as such constructors can still take
parameters.
struct CC {
CC(int); // no default constructor
};
::CC x();
2009-07-12: xavier98
[Octave] Add support for Octave 3.2 API
and in template parameter specializations:
2009-07-05: olly
[PHP] Update the list of PHP keywords - "cfunction" is no longer a
keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
and "__NAMESPACE__".
struct S {};
template <typename T> struct X { void a() {}; };
template <> struct X<S> { void b() {}; };
%template(MyTConcrete) X< ::S >;
2009-07-03: olly
[Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS
and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter
of the manual. Based on patch from SF#2810380 by Christian
Gollwitzer.
plus probably some other corner case usage of ::.
2009-07-02: vmiklos
[PHP] Added factory.i for PHP, see the li_factory testcase
for more info on how to use it.
2009-11-02: olly
[Python] Fix potential memory leak in initialisation code for the
generated module.
2009-07-02: wsfulton
Fix -Wallkw option as reported by Solomon Gibbs.
2009-10-23: wsfulton
Fix seg fault when using a named nested template instantiation using %template(name)
within a class. A warning that these are not supported is now issued plus processing
continues as if no name was given.
2009-07-02: wsfulton
Fix syntax error when a nested struct contains a comment containing a * followed
eventually by a /. Regression from 1.3.37, reported by Solomon Gibbs.
2009-10-20: wsfulton
[Python] Fix std::vector<const T*>. This would previously compile, but not run correctly.
2009-07-01: vmiklos
[PHP] Unknown properties are no longer ignored in proxy
classes.
2009-10-20: wsfulton
Fixed previously fairly poor template partial specialization and explicit
specialization support. Numerous bugs in this area have been fixed including:
2009-07-01: vmiklos
[PHP] Fixed %newobject behaviour, previously any method
marked with %newobject was handled as a constructor.
- Template argument deduction implemented for template type arguments, eg this now
works:
template<typename T> class X {};
template<typename T> class X<T *> {};
%template(X1) X<const int *>; // Chooses T * specialization
2009-06-30: olly
[Ruby] Undefine close and connect macros defined by Ruby API
headers as we don't need them and they can clash with C++ methods
being wrapped. Patch from Vit Ondruch in SF#2814430.
and more complex cases with multiple parameters and a mix of template argument
deduction and explicitly specialised parameters, eg:
template <typename T1, typename T2> struct TwoParm { void a() {} };
template <typename T1> struct TwoParm<T1 *, int *> { void e() {} };
%template(E) TwoParm<int **, int *>;
2009-06-26: olly
[Ruby] Fix to handle FIXNUM values greater than MAXINT passed for a
double parameter.
2009-06-24: wsfulton
Fix wrapping methods with default arguments and the compactdefaultargs feature
where a class is passed by value and is assigned a default value. The SwigValueWrapper
template workaround for a missing default constructor is no longer used as the code
generated does not call the default constructor.
2009-06-16: wsfulton
[Java,C#] Fix enum marshalling when %ignore is used on one of the enum items.
Incorrect enum values were being passed to the C++ layer or compilation errors resulted.
2009-06-02: talby
[Perl] Resolved reference.i overload support problem
identified by John Potowsky.
2009-05-26: wsfulton
[C#] Improved std::map wrappers based on patch from Yuval Baror. The C# proxy
now implements System.Collections.Generic.IDictionary<>.
These std:map wrappers have a non-backwards compatible overhaul to make them
like a .NET IDictionary. Some method names have changed as following:
set -> setitem (use this[] property now)
get -> getitem (use this[] property now)
has_key -> ContainsKey
del -> Remove
clear -> Clear
The following macros used for std::map wrappers are deprecated and will no longer work:
specialize_std_map_on_key
specialize_std_map_on_value
specialize_std_map_on_both
Note that the primary template must now be in scope, like in C++, when
an explicit or partial specialization is instantiated with %template.
*** POTENTIAL INCOMPATIBILITY ***
2009-05-20: vmiklos
[PHP] Add the 'thisown' member to classes. The usage of it
is the same as the Python thisown one: it's 1 by default and
you can set it to 0 if you want to prevent freeing it. (For
example to prevent a double free.)
2009-09-14: wsfulton
[C#] Add %csattributes for adding C# attributes to enum values, see docs for example.
2009-05-14: bhy
[Python] Fix the wrong pointer value returned by SwigPyObject_repr().
2009-09-11: wsfulton
Fix memmove regression in cdata.i as reported by Adriaan Renting.
2009-05-13: mutandiz (Mikel Bancroft)
[allegrocl] Minor tweak when wrapping in -nocwrap mode.
2009-09-07: wsfulton
Fix constant expressions containing <= or >=.
2009-05-11: wsfulton
[C#] Improved std::vector wrappers on the C# proxy side from Yuval Baror. These
implement IList<> instead of IEnumerable<> where possible.
2009-09-02: wsfulton
The following operators in constant expressions now result in type bool for C++
wrappers and remain as type int for C wrappers, as per each standard:
2009-04-29: wsfulton
[Java, C#] Add the 'notderived' attribute to the javabase and csbase typemaps.
When this attribute is set, the typemap will not apply to classes that are derived
from a C++ base class, eg
%typemap(csbase, notderived="1") SWIGTYPE "CommonBase"
&& || == != < > <= >= (Actually the last 4 are still broken). For example:
2009-04-29: olly
[Python] Don't attempt to acquire the GIL in situations where we
know that it will already be locked. This avoids some dead-locks
with mod_python (due to mod_python bugs which are apparently
unlikely to ever be fixed), and results in smaller wrappers which
run a little faster (in tests with Xapian on x86-64 Ubuntu 9.04,
the stripped wrapper library was 11% smaller and ran 2.7% faster).
#define A 10
#define B 10
#define A_EQ_B A == B // now wrapped as type bool for C++
#define A_AND_B A && B // now wrapped as type bool for C++
2009-04-21: wsfulton
[C#] Fix #2753469 - bool &OUTPUT and bool *OUTPUT typemaps initialisation.
2009-09-02: wsfulton
Fix #2845746. true and false are now recognised keywords (only when wrapping C++).
Constants such as the following are now wrapped (as type bool):
#define FOO true
#define BAR FOO && false
2009-04-09: wsfulton
Fix #2746858 - C macro expression using floating point numbers
2009-03-30: olly
[PHP] The default out typemap for char[ANY] now returns the string up to a
zero byte, or the end of the array if there is no zero byte. This
is the same as Python does, and seems more generally useful than
the previous behaviour of returning the whole contents of the array
including any zero bytes. If you want the old behaviour, you can provide
your own typemap to do this:
%typemap(out) char [ANY]
%{
RETVAL_STRINGL($1, $1_dim0, 1);
%}

View file

@ -1070,31 +1070,35 @@ With each is the cast that can be used in the debugger to extract the underlying
<p>
<li>String *s;</li>
<br>
(String *)((DohBase *)s)-&gt;data
(struct String *)((DohBase *)s)-&gt;data
<br>
The underlying char * string can be displayed with
<br>
((String *)((DohBase *)s)-&gt;data)-&gt;str
(*(struct String *)(((DohBase *)s)-&gt;data)).str
<p>
<li>SwigType *t;</li>
<br>
(String *)((DohBase *)t)-&gt;data
(struct String *)((DohBase *)t)-&gt;data
<br>
The underlying char * string can be displayed with
<br>
((String *)((DohBase *)t)-&gt;data)-&gt;str
(*(struct String *)(((DohBase *)t)-&gt;data)).str
<p>
<li>String_or_char *sc;</li>
<li>const_String_or_char_ptr sc;</li>
Either <br>
((String *)((DohBase *)sc)-&gt;data)-&gt;str
(*(struct String *)(((DohBase *)sc)-&gt;data)).str
<br> or <br>
(char *)sc
<br> will work depending on whether the underlying type is really a String * or char *.
</ul>
<p>
Please also read the Debugging Functions section in <a href="tree.html">SWIG Parse Tree Handling</a> for the <tt>Swig_print_node()</tt>, <tt>Swig_print_tree()</tt> and <tt>Swig_print_tags()</tt> 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.
</p>
<hr>
Copyright (C) 1999-2004 SWIG Development Team.

View file

@ -218,10 +218,10 @@ The following functions are used to help debug SWIG parse trees.
<blockquote>
Prints the tag-structure of the parse tree to standard output. <tt>node</tt> is the top-level parse tree node. <tt>prefix</tt> is
a string prefix thats added to the start of each line. Normally, you would specify the empty string or NIL for <tt>prefix</tt>.
This function is called by the <tt>-dump_tags</tt> option to SWIG.
This function is called by the <tt>-debug-tags</tt> option to SWIG.
<pre>
% swig -dump_tags -python example.i
% swig -debug-tags -python example.i
. top (:1)
. top . include (/Users/beazley/Projects/share/swig/1.3.31/swig.swg:0)
. top . include . include (/Users/beazley/Projects/share/swig/1.3.31/swigwarnings.swg:0)
@ -243,7 +243,7 @@ Since many language modules include hundreds of typemaps and other information,
<blockquote>
Prints the contents of a parse tree node, including all children, to standard output. The output includes all attributes
and other details. The command line option <tt>-dump_tree</tt> produces output generated by this function.
and other details.
</blockquote>
<p>
@ -251,8 +251,8 @@ and other details. The command line option <tt>-dump_tree</tt> produces output
<blockquote>
Prints the same output as <tt>Swig_print_node()</tt> except that it also processes all of the siblings of <tt>node</tt>. This can
be used to dump the entire parse tree to standard output. Use the command line option <tt>-dump_tree</tt> to get
the output of this function for a SWIG input file.
be used to dump the entire parse tree to standard output. The command line options <tt>-debug-module</tt>
and <tt>-debug-top</tt> use this function to display the parse tree for a SWIG input file.
</blockquote>

View file

@ -14,7 +14,7 @@
<ul>
<li><a href="#Allegrocl_nn2">Basics</a>
<ul>
<li><a href="#Allegrocl_nn3">Running Swig</a>
<li><a href="#Allegrocl_nn3">Running SWIG</a>
<li><a href="#Allegrocl_nn4">Command Line Options</a>
<li><a href="#Allegrocl_nn5">Inserting user code into generated files</a>
</ul>
@ -138,7 +138,7 @@ to it.
<H2><a name="Allegrocl_nn2"></a>17.1 Basics</H2>
<H3><a name="Allegrocl_nn3"></a>17.1.1 Running Swig</H3>
<H3><a name="Allegrocl_nn3"></a>17.1.1 Running SWIG</H3>
<p>

View file

@ -30,8 +30,6 @@
<b>Disclaimer: This chapter is under construction.</b>
<p>
In Chapter 3, SWIG's treatment of basic datatypes and pointers was
described. In particular, primitive types such as <tt>int</tt> and

View file

@ -55,7 +55,7 @@ The PInvoke interface has been chosen over Microsoft's Managed C++ interface as
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
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vcconMixedDLLLoadingProblem.asp">Mixed DLL Loading Problem</a>.
Swig C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
<a href="http://www.mono-project.com/">Mono</a> and <a href="http://www.dotgnu.org/pnet.html">Portable.NET</a>.
</p>
@ -249,7 +249,9 @@ public static extern IntPtr function(string jarg1);
<p>
Support for type attributes.
The 'imtype' and 'cstype' typemaps can have an optional <tt>inattributes</tt> and <tt>outattributes</tt> typemap attribute.
There are C# attributes and typemap attributes, don't get confused!!
The 'imtype' typemap can also have an optional <tt>directorinattributes</tt> and <tt>directoroutattributes</tt>
typemap attribute which attaches to director delegates, an implementation detail of directors, see <a href="#csharp_directors_implementation">directors implementation</a>.
Note that there are C# attributes and typemap attributes, don't get confused between the two!!
The C# attributes specified in these typemap attributes are generated wherever the type is used in the C# wrappers.
These can be used to specify any C# attribute associated with a C/C++ type, but are more typically used for the C# <tt>MarshalAs</tt> attribute.
For example:
@ -293,11 +295,16 @@ These attributes are associated with the C/C++ parameter type or return type, wh
the attribute features and typemaps covered next.
Note that all these different C# attributes can be combined so that a method has more than one attribute.
</p>
<p>
The <tt>directorinattributes</tt> and <tt>directoroutattributes</tt> typemap attribute are attached to the delegates in the director class, for example, the SwigDelegateBase_0
</p>
</li>
<li>
<p>
Support for attaching C# attributes to wrapped methods and variables.
Support for attaching C# attributes to wrapped methods, variables and enum values.
This is done using the <tt>%csattributes</tt> feature, see <a href="Customization.html#features">%feature directives</a>.
Note that C# attributes are attached to proxy classes and enums using the <tt>csattributes</tt> typemap.
For example, imagine we have a custom attribute class, <tt>ThreadSafeAttribute</tt>, for labelling thread safety.
@ -344,6 +351,38 @@ they can be added using the 'csvarin' and 'csvarout' typemaps respectively.
Note that the type used for the property is specified in the 'cstype' typemap.
If the 'out' attribute exists in this typemap, then the type used is from the 'out' attribute.
</p>
<p>
An example for attaching attributes to the enum and enum values is shown below.
</p>
<div class="code">
<pre>
%typemap(csattributes) Couleur "[System.ComponentModel.Description(\"Colours\")]"
%csattributes Rouge "[System.ComponentModel.Description(\"Red\")]"
%csattributes Vert "[System.ComponentModel.Description(\"Green\")]"
%inline %{
enum Couleur { Rouge, Orange, Vert };
%}
</pre>
</div>
<p>
which will result in the following C# enum:
</p>
<div class="code">
<pre>
[System.ComponentModel.Description("Colours")]
public enum Couleur {
[System.ComponentModel.Description("Red")]
Rouge,
Orange,
[System.ComponentModel.Description("Green")]
Vert
}
</pre>
</div>
</li>
<li>
@ -948,7 +987,7 @@ without setting the <tt>canthrow</tt> attribute you will get a warning message s
<div class="code">
<pre>
example.i:21: Warning(845): Unmanaged code contains a call to a SWIG_CSharpSetPendingException
example.i:21: Warning 845: Unmanaged code contains a call to a SWIG_CSharpSetPendingException
method and C# code does not handle pending exceptions via the canthrow attribute.
</pre>
</div>

View file

@ -346,10 +346,11 @@
<li><a href="Typemaps.html#Typemaps_pattern_matching">Pattern matching rules</a>
<ul>
<li><a href="Typemaps.html#Typemaps_nn17">Basic matching rules</a>
<li><a href="Typemaps.html#Typemaps_nn18">Typedef reductions</a>
<li><a href="Typemaps.html#Typemaps_typedef_reductions">Typedef reductions</a>
<li><a href="Typemaps.html#Typemaps_nn19">Default typemaps</a>
<li><a href="Typemaps.html#Typemaps_mixed_default">Mixed default typemaps</a>
<li><a href="Typemaps.html#Typemaps_nn20">Multi-arguments typemaps</a>
<li><a href="Typemaps.html#Typemaps_debugging_search">Debugging typemap pattern matching</a>
</ul>
<li><a href="Typemaps.html#Typemaps_nn21">Code generation rules</a>
<ul>
@ -383,7 +384,7 @@
<li><a href="Typemaps.html#Typemaps_nn40">Typemaps for arrays</a>
<li><a href="Typemaps.html#Typemaps_nn41">Implementing constraints with typemaps</a>
</ul>
<li><a href="Typemaps.html#Typemaps_nn43">Typemaps for multiple languages</a>
<li><a href="Typemaps.html#Typemaps_nn43">Typemaps for multiple target languages</a>
<li><a href="Typemaps.html#Typemaps_optimal">Optimal code generation when returning by value</a>
<li><a href="Typemaps.html#Typemaps_multi_argument_typemaps">Multi-argument typemaps</a>
<li><a href="Typemaps.html#runtime_type_checker">The run-time type checker</a>
@ -537,7 +538,7 @@
<ul>
<li><a href="Allegrocl.html#Allegrocl_nn2">Basics</a>
<ul>
<li><a href="Allegrocl.html#Allegrocl_nn3">Running Swig</a>
<li><a href="Allegrocl.html#Allegrocl_nn3">Running SWIG</a>
<li><a href="Allegrocl.html#Allegrocl_nn4">Command Line Options</a>
<li><a href="Allegrocl.html#Allegrocl_nn5">Inserting user code into generated files</a>
</ul>
@ -1280,9 +1281,6 @@
<li><a href="Python.html#Python_nn47">Simple pointers</a>
<li><a href="Python.html#Python_nn48">Unbounded C Arrays</a>
<li><a href="Python.html#Python_nn49">String handling</a>
<li><a href="Python.html#Python_nn50">Arrays</a>
<li><a href="Python.html#Python_nn51">String arrays</a>
<li><a href="Python.html#Python_nn52">STL wrappers</a>
</ul>
<li><a href="Python.html#Python_nn53">Typemaps</a>
<ul>
@ -1581,7 +1579,7 @@
<li><a href="Extending.html#Extending_nn31">Writing a Language Module</a>
<ul>
<li><a href="Extending.html#Extending_nn32">Execution model</a>
<li><a href="Extending.html#Extending_nn33">Starting out</a>
<li><a href="Extending.html#Extending_starting_out">Starting out</a>
<li><a href="Extending.html#Extending_nn34">Command line options</a>
<li><a href="Extending.html#Extending_nn35">Configuration and preprocessing</a>
<li><a href="Extending.html#Extending_nn36">Entry point to code generation</a>
@ -1590,16 +1588,18 @@
<li><a href="Extending.html#Extending_nn39">Configuration files</a>
<li><a href="Extending.html#Extending_nn40">Runtime support</a>
<li><a href="Extending.html#Extending_nn41">Standard library files</a>
<li><a href="Extending.html#Extending_nn42">Examples and test cases</a>
<li><a href="Extending.html#Extending_nn42">User examples</a>
<li><a href="Extending.html#Extending_test_suite">Test driven development and the test-suite</a>
<ul>
<li><a href="Extending.html#Extending_running_test_suite">Running the test-suite</a>
</ul>
<li><a href="Extending.html#Extending_nn43">Documentation</a>
<li><a href="Extending.html#Extending_prerequisites">Prerequisites for adding a new language module to the SWIG distribution</a>
<li><a href="Extending.html#Extending_coding_style_guidelines">Coding style guidelines</a>
</ul>
<li><a href="Extending.html#Extending_nn44">Typemaps</a>
<ul>
<li><a href="Extending.html#Extending_nn45">Proxy classes</a>
</ul>
<li><a href="Extending.html#Extending_debugging_options">Debugging Options</a>
<li><a href="Extending.html#Extending_nn46">Guide to parse tree nodes</a>
<li><a href="Extending.html#Extending_further_info">Further Development Information</a>
</ul>
</div>
<!-- INDEX -->

View file

@ -53,6 +53,21 @@ The <tt>%exception</tt> directive allows you to define a general purpose excepti
handler. For example, you can specify the following:
</p>
<div class="code"><pre>
%exception {
try {
$action
}
catch (RangeError) {
... handle error ...
}
}
</pre></div>
<p>
How the exception is handled depends on the target language, for example, Python:
</p>
<div class="code"><pre>
%exception {
try {
@ -60,7 +75,7 @@ handler. For example, you can specify the following:
}
catch (RangeError) {
PyErr_SetString(PyExc_IndexError,"index out-of-bounds");
return NULL;
SWIG_fail;
}
}
</pre></div>

View file

@ -48,7 +48,7 @@
<li><a href="#Extending_nn31">Writing a Language Module</a>
<ul>
<li><a href="#Extending_nn32">Execution model</a>
<li><a href="#Extending_nn33">Starting out</a>
<li><a href="#Extending_starting_out">Starting out</a>
<li><a href="#Extending_nn34">Command line options</a>
<li><a href="#Extending_nn35">Configuration and preprocessing</a>
<li><a href="#Extending_nn36">Entry point to code generation</a>
@ -57,16 +57,18 @@
<li><a href="#Extending_nn39">Configuration files</a>
<li><a href="#Extending_nn40">Runtime support</a>
<li><a href="#Extending_nn41">Standard library files</a>
<li><a href="#Extending_nn42">Examples and test cases</a>
<li><a href="#Extending_nn42">User examples</a>
<li><a href="#Extending_test_suite">Test driven development and the test-suite</a>
<ul>
<li><a href="#Extending_running_test_suite">Running the test-suite</a>
</ul>
<li><a href="#Extending_nn43">Documentation</a>
<li><a href="#Extending_prerequisites">Prerequisites for adding a new language module to the SWIG distribution</a>
<li><a href="#Extending_coding_style_guidelines">Coding style guidelines</a>
</ul>
<li><a href="#Extending_nn44">Typemaps</a>
<ul>
<li><a href="#Extending_nn45">Proxy classes</a>
</ul>
<li><a href="#Extending_debugging_options">Debugging Options</a>
<li><a href="#Extending_nn46">Guide to parse tree nodes</a>
<li><a href="#Extending_further_info">Further Development Information</a>
</ul>
</div>
<!-- INDEX -->
@ -2471,7 +2473,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the <tt>Language</tt> that must be defined by your module.
</p>
<H3><a name="Extending_nn33"></a>35.10.2 Starting out</H3>
<H3><a name="Extending_starting_out"></a>35.10.2 Starting out</H3>
<p>
@ -2602,24 +2604,24 @@ void Language::main(int argc, char *argv[]) {
} else {
Swig_arg_error();
}
} else if (strcmp(argv[i],"-globals") == 0) {
if (argv[i+1]) {
global_name = NewString(argv[i+1]);
Swig_mark_arg(i);
Swig_mark_arg(i+1);
i++;
} else {
Swig_arg_error();
}
} else if ( (strcmp(argv[i],"-proxy") == 0)) {
proxy_flag = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-keyword") == 0) {
use_kw = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
}
} else if (strcmp(argv[i],"-globals") == 0) {
if (argv[i+1]) {
global_name = NewString(argv[i+1]);
Swig_mark_arg(i);
Swig_mark_arg(i+1);
i++;
} else {
Swig_arg_error();
}
} else if ( (strcmp(argv[i],"-proxy") == 0)) {
proxy_flag = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-keyword") == 0) {
use_kw = 1;
Swig_mark_arg(i);
} else if (strcmp(argv[i],"-help") == 0) {
fputs(usage,stderr);
}
...
}
}
@ -3053,7 +3055,7 @@ but without the typemaps, there is still work to do.
<!-- please report bugs in this section to ttn -->
<p>
At the time of this writing, SWIG supports nearly a dozen languages,
At the time of this writing, SWIG supports nearly twenty languages,
which means that for continued sanity in maintaining the configuration
files, the language modules need to follow some conventions. These are
outlined here along with the admission that, yes it is ok to violate
@ -3225,7 +3227,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
</p>
<H3><a name="Extending_nn42"></a>35.10.11 Examples and test cases</H3>
<H3><a name="Extending_nn42"></a>35.10.11 User examples</H3>
<p>
@ -3254,7 +3256,226 @@ during this process, see the section on <a href="#n37a">configuration
files</a>.
</p>
<H3><a name="Extending_nn43"></a>35.10.12 Documentation</H3>
<H3><a name="Extending_test_suite"></a>35.10.12 Test driven development and the test-suite</H3>
<p>
A test driven development approach is central to the improvement and development of SWIG.
Most modifications to SWIG are accompanied by additional regression tests and checking all
tests to ensure that no regressions have been introduced.
</p>
<p>
The regression testing is carried out by the SWIG <i>test-suite</i>.
The test-suite consists of numerous testcase interface files in the <tt>Examples/test-suite</tt> directory
as well as target language specific runtime tests in the <tt>Examples/test-suite/[lang]</tt> directory.
When a testcase is run, it will execute the following steps for each testcase:
</p>
<ol>
<li>Execute SWIG passing it the testcase interface file.</li>
<li>Compile the resulting generated C/C++ code with either the C or C++ compiler into object files.</li>
<li>Link the object files into a dynamic library (dll/shared object).</li>
<li>Compile any generated and any runtime test target language code with the target language compiler, if the target language supports compilation. This step thus does not apply to the interpreted languages.</li>
<li>Execute a runtime test if one exists.</li>
</ol>
<p>
For example, the <i>ret_by_value</i> testcase consists of two components.
The first component is the <tt>Examples/test-suite/ret_by_value.i</tt> interface file.
The name of the SWIG module <b>must</b> always be the name of the testcase, so the <tt>ret_by_value.i</tt> interface file thus begins with:
</p>
<div class="code">
<pre>
%module ret_by_value
</pre>
</div>
<p>
The testcase code will then follow the module declaration,
usually within a <tt>%inline %{ ... %}</tt> section for the majority of the tests.
</p>
<p>
The second component is the optional runtime tests.
Any runtime tests are named using the following convention: <tt>[testcase]_runme.[ext]</tt>,
where <tt>[testcase]</tt> is the testcase name and <tt>[ext]</tt> is the normal extension for the target language file.
In this case, the Java and Python target languages implement a runtime test, so their files are respectively,
<tt>Examples/test-suite/java/ret_by_value_runme.java</tt> and
<tt>Examples/test-suite/python/ret_by_value_runme.py</tt>.
</p>
<p>
The goal of the test-suite is to test as much as possible in a <b>silent</b> manner.
This way any SWIG or compiler errors or warnings are easily visible.
Should there be any warnings, changes must be made to either fix them (preferably) or suppress them.
Compilation or runtime errors result in a testcase failure and will be immediately visible.
It is therefore essential that the runtime tests are written in a manner that displays nothing to stdout/stderr on success
but error/exception out with an error message on stderr on failure.
</p>
<H4><a name="Extending_running_test_suite"></a>35.10.12.1 Running the test-suite</H4>
<p>
In order for the test-suite to work for a particular target language, the language must be correctly detected
and configured during the configure stage so that the correct Makefiles are generated.
Most development occurs on Linux, so usually it is a matter of installing the development packages for the target language
and simply configuring as outlined <a href="#Extending_starting_out">earlier</a>.
</p>
<p>
If when running the test-suite commands that follow, you get a message that the test was skipped, it indicates that the
configure stage is missing information in order to compile and run everything for that language.
</p>
<p>
The test-suite can be run in a number of ways.
The first group of commands are for running multiple testcases in one run and should be executed in the top level directory.
To run the entire test-suite (can take a long time):
</p>
<div class="shell"><pre>
make -k check-test-suite
</pre></div>
<p>
To run the test-suite just for target language [lang], replace [lang] with one of csharp, java, perl5, python, ruby, tcl etc:
</p>
<div class="shell"><pre>
make check-[lang]-test-suite
</pre></div>
<p>
Note that if a runtime test is available, a message "(with run test)" is displayed when run. For example:
</p>
<div class="shell"><pre>
$ make check-python-test-suite
checking python test-suite
checking testcase argcargvtest (with run test) under python
checking testcase python_autodoc under python
checking testcase python_append (with run test) under python
checking testcase callback (with run test) under python
</pre></div>
<p>
The files generated on a previous run can be deleted using the clean targets, either the whole test-suite or for a particular language:
</p>
<div class="shell"><pre>
make clean-test-suite
make clean-[lang]-test-suite
</pre></div>
<p>
The test-suite can be run in a <i>partialcheck</i> mode where just SWIG is executed, that is, the compile,
link and running of the testcases is not performed.
Note that the partialcheck does not require the target language to be correctly configured and detected and unlike the other test-suite make targets, is never skipped. Once again, either all the languages can be executed or just a chosen language:
</p>
<div class="shell"><pre>
make partialcheck-test-suite
make partialcheck-[lang]-test-suite
</pre></div>
<p>
If your computer has more than one CPU, you are strongly advised to use parallel make to speed up the execution speed.
This can be done with any of the make targets that execute more than one testcase.
For example, a dual core processor can efficiently use 2 parallel jobs:
</p>
<div class="shell"><pre>
make -j2 check-test-suite
make -j2 check-python-test-suite
make -j2 partialcheck-java-test-suite
</pre></div>
<p>
The second group of commands are for running individual testcases and should be executed in the appropriate
target language directory, <tt>Examples/test-suite/[lang]</tt>.
Testcases can contain either C or C++ code and when one is written, a decision must be made as to which of these input
languages is to be used.
Replace <tt>[testcase]</tt> in the commands below with the name of the testcase.
</p>
<p>
For a C language testcase, add the testcase under the C_TEST_CASES list in <tt>Examples/test-suite/common.mk</tt> and
execute individually as:
</p>
<div class="shell"><pre>
make -s [testcase].ctest
</pre></div>
<p>
For a C++ language testcase, add the testcase under the CPP_TEST_CASES list in <tt>Examples/test-suite/common.mk</tt> and
execute individually as:
</p>
<div class="shell"><pre>
make -s [testcase].cpptest
</pre></div>
<p>
A third category of tests are C++ language testcases testing multiple modules (the %import directive).
These require more than one shared library (dll/shared object) to be built and so are separated out from the normal C++ testcases.
Add the testcase under the MULTI_CPP_TEST_CASES list in <tt>Examples/test-suite/common.mk</tt> and
execute individually as:
</p>
<div class="shell"><pre>
make -s [testcase].multicpptest
</pre></div>
<p>
To delete the generated files, execute:
</p>
<div class="shell"><pre>
make -s [testcase].clean
</pre></div>
<p>
If you would like to see the exact commands being executed, drop the -s option:
</p>
<div class="shell"><pre>
make [testcase].ctest
make [testcase].cpptest
make [testcase].multicpptest
</pre></div>
<p>
Some real examples of each:
</p>
<div class="shell"><pre>
make -s ret_by_value.clean
make -s ret_by_value.ctest
make -s bools.cpptest
make -s imports.multicpptest
</pre></div>
<p>
Advanced usage of the test-suite facilitates running tools on some of the five stages.
The make variables <tt>SWIGTOOL</tt> and <tt>RUNTOOL</tt> are used to specify a tool to respectively, invoke SWIG
and the execution of the runtime test.
You are advised to view the <tt>Examples/test-suite/common.mk</tt> file for details but for a short summary,
the classic usage is to use <a href="http://valgrind.org/">Valgrind</a> for memory checking.
For example, checking for memory leaks when running the runtime test in the target language interpreter:
</p>
<div class="shell"><pre>
make ret_by_value.ctest RUNTOOL="valgrind --leak-check=full"
</pre></div>
<p>
This will probably make more sense if you look at the output of the above as it will show the exact commands being executed.
SWIG can be analyzed for bad memory accesses using:
</p>
<div class="shell"><pre>
make ret_by_value.ctest SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
</pre></div>
<H3><a name="Extending_nn43"></a>35.10.13 Documentation</H3>
<p>
@ -3286,7 +3507,7 @@ Some topics that you'll want to be sure to address include:
if available.
</ul>
<H3><a name="Extending_prerequisites"></a>35.10.13 Prerequisites for adding a new language module to the SWIG distribution</H3>
<H3><a name="Extending_prerequisites"></a>35.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
<p>
@ -3343,7 +3564,7 @@ should be added should there be an area not already covered by
the existing tests.
</p>
<H3><a name="Extending_coding_style_guidelines"></a>35.10.14 Coding style guidelines</H3>
<H3><a name="Extending_coding_style_guidelines"></a>35.10.15 Coding style guidelines</H3>
<p>
@ -3367,11 +3588,29 @@ 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.
</p>
<H2><a name="Extending_nn44"></a>35.11 Typemaps</H2>
<H2><a name="Extending_debugging_options"></a>35.11 Debugging Options</H2>
<H3><a name="Extending_nn45"></a>35.11.1 Proxy classes</H3>
<p>
There are various command line options which can aid debugging a SWIG interface as well as debugging the development of a language module. These are as follows:
</p>
<div class="shell"><pre>
-debug-classes - Display information about the classes found in the interface
-debug-module &lt;n&gt; - Display module parse tree at stages 1-4, &lt;n&gt; is a csv list of stages
-debug-symtabs - Display symbol tables information
-debug-symbols - Display target language symbols in the symbol tables
-debug-csymbols - Display C symbols in the symbol tables
-debug-tags - Display information about the tags found in the interface
-debug-template - Display information for debugging templates
-debug-top &lt;n&gt; - Display entire parse tree at stages 1-4, &lt;n&gt; 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
</pre></div>
<p>
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
</p>
<H2><a name="Extending_nn46"></a>35.12 Guide to parse tree nodes</H2>
@ -3781,6 +4020,13 @@ extern "X" { ... } declaration.
</pre>
</div>
<H2><a name="Extending_further_info"></a>35.13 Further Development Information</H2>
<p>
There is further documentation available on the internals of SWIG, API documentation and debugging information.
This is shipped with SWIG in the <tt>Doc/Devel</tt> directory.
</P>

View file

@ -814,7 +814,7 @@ Produces the following code at the top of the generated GOOPS guile-module
<code>Module-primitive.scm</code> (with <i>primitive</i> replaced with whatever is given with the <code>-primsuffix</code>
argument. The code to load the <code>.so</code> library should be located in the <code>%scheme</code> directive,
which will then be added to the scmstub file.
Swig will automatically generate the line <code>(use-modules (<i>Package</i> <i>Module-primitive</i>))</code>
SWIG will automatically generate the line <code>(use-modules (<i>Package</i> <i>Module-primitive</i>))</code>
into the GOOPS guile-module. So if <i>Module-primitive.scm</i> is on the autoload path for guile, the
<code>%goops</code> directive can be empty. Otherwise, the <code>%goops</code> directive should contain
whatever code is needed to load the <i>Module-primitive.scm</i> file into guile.</p>
@ -848,7 +848,7 @@ Produces the following code at the top of the generated GOOPS guile-module
</li>
<li><p><b>Module Linkage</b>: This is very similar to passive linkage with a scmstub file.
Swig will also automatically generate the line <code>(use-modules
SWIG will also automatically generate the line <code>(use-modules
(<i>Package</i> <i>Module-primitive</i>))</code> into the GOOPS guile-module. Again the <code>%goops</code>
directive should contain whatever code is needed to get that module loaded into guile.</p>

View file

@ -334,7 +334,7 @@ major features include:
<p>
Currently, the only major C++ feature not supported is nested classes--a limitation
that will be removed in a future release.
that should be removed in a future release, but has some workarounds for the moment.
</p>
<p>

View file

@ -1772,7 +1772,7 @@ If declarations such as these appear, you will get a warning message like this:
<div class="code">
<pre>
example.i:12: Warning(515): Overloaded method spam(unsigned short) ignored.
example.i:12: Warning 515: Overloaded method spam(unsigned short) ignored.
Method spam(int) at example.i:11 used.
</pre>
</div>

View file

@ -667,7 +667,7 @@ in order for this to work.
</p>
<p>
<b><tt>char *cdata(void *ptr, int nbytes)</tt></b>
<b><tt>const char *cdata(void *ptr, size_t nbytes)</tt></b>
</p>
<div class="indent"><p>
@ -676,7 +676,7 @@ pointer.
</p></div>
<p>
<b><tt>void memmove(void *ptr, char *s)</tt></b>
<b><tt>void memmove(void *ptr, const char *s)</tt></b>
</p>
<div class="indent"><p>
@ -890,7 +890,10 @@ char *foo();
</div>
<p>
This will release the result.
This will release the result if the appropriate target language support is available.
SWIG provides the appropriate "newfree" typemap for <tt>char *</tt> so that the memory is released,
however, you may need to provide your own "newfree" typemap for other types.
See <a href="Customization.html#ownership">Object ownership and %newobject</a> for more details.
</p>
<H3><a name="Library_nn12"></a>8.3.4 cstring.i</H3>

View file

@ -684,8 +684,8 @@ void foo(Bar &amp;b);
If declarations such as these appear, you will get a warning message like this:
</p>
<div class="shell"><pre>
example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
at example.i:11.
example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).
</pre></div>
<p>
To fix this, you either need to ignore or rename one of the methods. For example:

View file

@ -138,7 +138,7 @@ base class's methods. Typically you will get a warning when the module name is m
</p>
<div class="shell"> <pre>
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.
</pre></div>

View file

@ -112,7 +112,7 @@ options are found near the end of the chapter.
<p>
To build a Perl5 module, run Swig using the <tt>-perl</tt> option as
To build a Perl5 module, run SWIG using the <tt>-perl</tt> option as
follows :
</p>

View file

@ -48,10 +48,6 @@
<p>
<b>Caution: This chapter (and module!) is still under construction</b>
</p>
<p>
SWIG supports generating wrappers for PHP5. Support for PHP4 has been removed
as of SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases,
@ -105,7 +101,7 @@ also contain PHP5 class wrappers.
</p>
<p>
Swig can generate PHP extensions from C++ libraries as well when
SWIG can generate PHP extensions from C++ libraries as well when
given the <tt>-c++</tt> option. The support for C++ is discussed in
more detail in <a href="#Php_nn2_6">section 27.2.6</a>.
</p>

View file

@ -102,8 +102,6 @@ by SWIG when it is parsing the interface:
<div class="code"><pre>
SWIG Always defined when SWIG is processing a file
SWIGIMPORTED Defined when SWIG is importing a file with <tt>%import</tt>
SWIGMAC Defined when running SWIG on the Macintosh
SWIGWIN Defined when running SWIG under Windows
SWIG_VERSION Hexadecimal number containing SWIG version,
such as 0x010311 (corresponding to SWIG-1.3.11).

View file

@ -69,9 +69,6 @@
<li><a href="#Python_nn47">Simple pointers</a>
<li><a href="#Python_nn48">Unbounded C Arrays</a>
<li><a href="#Python_nn49">String handling</a>
<li><a href="#Python_nn50">Arrays</a>
<li><a href="#Python_nn51">String arrays</a>
<li><a href="#Python_nn52">STL wrappers</a>
</ul>
<li><a href="#Python_nn53">Typemaps</a>
<ul>
@ -1137,7 +1134,7 @@ simply represented as opaque values using an especial python container object:
<div class="targetlang"><pre>
&gt;&gt;&gt; print f
&lt;Swig Object at _08a71808_p_FILE&gt;
&lt;Swig Object of type 'FILE *' at 0xb7d6f470&gt;
</pre></div>
<p>
@ -1147,7 +1144,7 @@ dereference the pointer from Python. Of course, that isn't much of a concern in
</p>
<p>
In older versions of Swig (1.3.22 or older), pointers were represented
In older versions of SWIG (1.3.22 or older), pointers were represented
using a plain string object. If you have an old package that still
requires that representation, or you just feel nostalgic, you can
always retrieve it by casting the pointer object to a string:
@ -1171,7 +1168,7 @@ integer:
<p>
However, the inverse operation is not possible, i.e., you can't build
a Swig pointer object from a raw integer value.
a SWIG pointer object from a raw integer value.
</p>
<p>
@ -1713,8 +1710,8 @@ If declarations such as these appear, you will get a warning message like this:
<div class="shell">
<pre>
example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
at example.i:11.
example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).
</pre>
</div>
@ -3854,15 +3851,6 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
</p>
<H3><a name="Python_nn50"></a>31.7.5 Arrays</H3>
<H3><a name="Python_nn51"></a>31.7.6 String arrays</H3>
<H3><a name="Python_nn52"></a>31.7.7 STL wrappers</H3>
<H2><a name="Python_nn53"></a>31.8 Typemaps</H2>

View file

@ -1559,7 +1559,7 @@ you'll see a warning message like: </p>
<div class="code shell">
<pre>example.i:5: Warning(802): Warning for Derived: Base Base2 ignored.<br>Multiple inheritance is not supported in Ruby.<br></pre>
<pre>example.i:5: Warning 802: Warning for Derived: Base Base2 ignored.<br>Multiple inheritance is not supported in Ruby.<br></pre>
@ -1810,7 +1810,11 @@ message like this: </p>
<div class="code shell">
<pre>example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)<br>at example.i:11.<br> </pre>
<pre>
example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).
<br>
</pre>
@ -7097,7 +7101,7 @@ being created. </div>
with Ruby objects. The following functions may prove to be useful.
(These functions plus many more can be found in <a href="http://www.rubycentral.com/book"><em>Programming
Ruby</em></a>, by David Thomas and Andrew Hunt.)&nbsp;</p>
<p>In addition, we list equivalent functions that Swig defines, which
<p>In addition, we list equivalent functions that SWIG defines, which
provide a language neutral conversion (these functions are defined for
each swig language supported). &nbsp;If you are trying to create a swig
file that will work under multiple languages, it is recommended you
@ -7123,7 +7127,7 @@ across multiple languages.</p>
<tbody>
<tr>
<th style="font-weight: bold;">RUBY</th>
<th style="font-weight: bold;">Swig</th>
<th style="font-weight: bold;">SWIG</th>
<td></td>
</tr>
<tr>

View file

@ -330,10 +330,13 @@ currently supported:
</p>
<ul>
<li>Non-conventional type declarations.
<li>
<p>
Non-conventional type declarations.
For example, SWIG does not support declarations such as the following
(even though this is legal C):
</p>
<div class="code">
<pre>
/* Non-conventional placement of storage specifier (extern) */
@ -355,15 +358,19 @@ if you're feeling particularly obfuscated, you can certainly break SWIG (althoug
</p>
</li>
<li>Running SWIG on C++ source files (what would appear in a .C or .cxx file)
is not recommended. Even though SWIG can parse C++ class declarations,
it ignores declarations that are decoupled from their
original class definition (the declarations are parsed, but a lot of warning
messages may be generated). For example:
<li>
<p>
Running SWIG on C++ source files (the code in a .C, .cpp or .cxx file) is not recommended.
The usual approach is to feed SWIG header files for parsing C++ definitions and declarations.
The main reason is if SWIG parses a scoped definition or declaration (as is normal for C++ source files),
it is ignored, unless a declaration for the symbol was parsed earlier.
For example
</p>
<div class="code">
<pre>
/* Not supported by SWIG */
/* bar not wrapped unless foo has been defined and
the declaration of bar within foo has already been parsed */
int foo::bar(int) {
... whatever ...
}
@ -371,9 +378,12 @@ int foo::bar(int) {
</div>
</li>
<li>Certain advanced features of C++ such as nested classes
are not yet supported. Please see the section on using SWIG
with C++ for more information.
<li>
<p>
Certain advanced features of C++ such as nested classes
are not yet fully supported. Please see the C++ <a href="SWIGPlus.html#SWIGPlus_nested_classes">Nested classes</a> section
for more information.
</p>
</ul>
<p>
@ -787,6 +797,12 @@ In this case, the pointer <tt>e</tt> can change---it's only the value
being pointed to that is read-only.
</p>
<p>
Please note that for const parameters or return types used in a function, SWIG pretty much ignores
the fact that these are const, see the section on <a href="SWIGPlus.html#SWIGPlus_const">const-correctness</a>
for more information.
</p>
<p>
<b>Compatibility Note:</b> One reason for changing SWIG to handle
<tt>const</tt> declarations as read-only variables is that there are
@ -2489,7 +2505,7 @@ instead of a method. To do this, you might write some code like this:
// Now supply the implementation of the Vector_magnitude_get function
%{
const double Vector_magnitude_get(Vector *v) {
return (const double) return sqrt(v-&gt;x*v-&gt;x+v-&gt;y*v-&gt;y+v-&gt;z*v-&gt;z);
return (const double) sqrt(v-&gt;x*v-&gt;x+v-&gt;y*v-&gt;y+v-&gt;z*v-&gt;z);
}
%}
@ -2502,41 +2518,53 @@ of the object.
</p>
<p>
A similar technique can also be used to work with problematic data members.
A similar technique can also be used to work with data members that you want to process.
For example, consider this interface:
</p>
<div class="code">
<pre>
struct Person {
char name[50];
...
}
typedef struct {
char name[50];
...
} Person;
</pre>
</div>
<p>
By default, the <tt>name</tt> attribute is read-only because SWIG does not
normally know how to modify arrays. However, you can rewrite the interface
as follows to change this:
Say you wanted to ensure <tt>name</tt> was always upper case, you can rewrite
the interface as follows to ensure this occurs whenever a name is read or written to:
</p>
<div class="code">
<pre>
struct Person {
%extend {
char *name;
}
...
typedef struct {
%extend {
char name[50];
}
...
} Person;
%{
#include &lt;string.h&gt;
#include &lt;ctype.h&gt;
void make_upper(char *name) {
char *c;
for (c = name; *c; ++c)
*c = (char)toupper((int)*c);
}
// Specific implementation of set/get functions
%{
/* Specific implementation of set/get functions forcing capitalization */
char *Person_name_get(Person *p) {
return p-&gt;name;
make_upper(p-&gt;name);
return p-&gt;name;
}
void Person_name_set(Person *p, char *val) {
strncpy(p-&gt;name,val,50);
strncpy(p-&gt;name,val,50);
make_upper(p-&gt;name);
}
%}
</pre>
@ -2546,7 +2574,7 @@ void Person_name_set(Person *p, char *val) {
Finally, it should be stressed that even though <tt>%extend</tt>
can be used to add new data members, these new members can not require
the allocation of additional storage in the object (e.g., their values must
be entirely synthesized from existing attributes of the structure).
be entirely synthesized from existing attributes of the structure or obtained elsewhere).
</p>
<p>
@ -2629,10 +2657,16 @@ $o-&gt;{intRep}-&gt;{ivalue} = 7 # Change value of o.intRep.ivalue
</pre></div>
<p>
If you have a lot nested structure declarations, it is
If you have a lot of nested structure declarations, it is
advisable to double-check them after running SWIG. Although,
there is a good chance that they will work, you may have to
modify the interface file in certain cases.
</p>
<p>
Finally, note that nesting is handled differently in C++ mode,
see <a href="SWIGPlus.html#SWIGPlus_nested_classes">Nested classes</a>.
</p>
<H3><a name="SWIG_nn39"></a>5.5.8 Other things to note about structure wrapping</H3>

View file

@ -56,7 +56,7 @@
<li><a href="#SWIGPlus_nn34">Smart pointers and operator-&gt;()</a>
<li><a href="#SWIGPlus_nn35">Using declarations and inheritance</a>
<li><a href="#SWIGPlus_nested_classes">Nested classes</a>
<li><a href="#SWIGPlus_nn37">A brief rant about const-correctness</a>
<li><a href="#SWIGPlus_const">A brief rant about const-correctness</a>
<li><a href="#SWIGPlus_nn42">Where to go for more information</a>
</ul>
</div>
@ -1616,7 +1616,7 @@ warning message like this:
<div class="shell">
<pre>
example.i:18: Warning(401): Nothing known about base class 'Foo'. Ignored.
example.i:18: Warning 401: Nothing known about base class 'Foo'. Ignored.
</pre>
</div>
@ -2031,7 +2031,8 @@ Therefore, when SWIG encounters this situation, it may generate a warning messag
<div class="shell">
<pre>
example.i:4: Warning(509): Overloaded foo(long) is shadowed by foo(int) at example.i:3.
example.i:4: Warning 509: Overloaded method foo(long) effectively ignored,
example.i:3: Warning 509: as it is shadowed by foo(int).
</pre>
</div>
@ -2041,7 +2042,8 @@ or for statically typed languages like Java:
<div class="shell">
<pre>
example.i:4: Warning(516): Overloaded method foo(long) ignored. Method foo(int)
example.i:4: Warning 516: Overloaded method foo(long) ignored,
example.i:3: Warning 516: using foo(int) instead.
at example.i:3 used.
</pre>
</div>
@ -2091,7 +2093,7 @@ When wrapping an overloaded function, there is a chance that you will get an err
<div class="shell">
<pre>
example.i:3: Warning(467): Overloaded foo(int) not supported (no type checking
example.i:3: Warning 467: Overloaded foo(int) not supported (no type checking
rule for 'int').
</pre>
</div>
@ -3246,22 +3248,39 @@ public:
</div>
<p>
SWIG should be able to handle most simple uses of partial specialization. However, it may fail
to match templates properly in more complicated cases. For example, if you have this code,
SWIG supports both template explicit specialization and partial specialization. Consider:
</p>
<div class="code">
<pre>
template&lt;class T1, class T2&gt; class Foo&lt;T1, T2 *&gt; { };
template&lt;class T1, class T2&gt; class Foo { }; // (1) primary template
template&lt;&gt; class Foo&lt;double *, int *&gt; { }; // (2) explicit specialization
template&lt;class T1, class T2&gt; class Foo&lt;T1, T2 *&gt; { }; // (3) partial specialization
</pre>
</div>
<p>
SWIG isn't able to match it properly for instantiations like <tt>Foo&lt;int *, int *&gt;</tt>.
This problem is not due to parsing, but due to the fact that SWIG does not currently implement all
of the C++ argument deduction rules.
SWIG is able to properly match explicit instantiations:
</p>
<div class="code">
<pre>
<tt>Foo&lt;double *, int *&gt;</tt> // explicit specialization matching (2)
</pre>
</div>
<p>
SWIG implements template argument deduction so that the following partial specialization examples work just like they would with a C++ compiler:
</p>
<div class="code">
<pre>
<tt>Foo&lt;int *, int *&gt;</tt> // partial specialization matching (3)
<tt>Foo&lt;int *, const int *&gt;</tt> // partial specialization matching (3)
<tt>Foo&lt;int *, int **&gt;</tt> // partial specialization matching (3)
</pre>
</div>
<p>
Member function templates are supported. The underlying principle is the same
as for normal templates--SWIG can't create a wrapper unless you provide
@ -3471,7 +3490,7 @@ instead:
<p>
In this case, the default and conversion constructors have the same
name. Hence, Swig will overload them and define an unique visible
name. Hence, SWIG will overload them and define an unique visible
constructor, that will dispatch the proper call depending on the argument
type.
</p>
@ -4678,37 +4697,50 @@ public:
<p>
There is limited support for nested structs and unions when wrapping C code, see <a href="SWIG.html#SWIG_nested_structs">Nested structures</a> for further details.
However, there is no nested class/struct/union support when wrapping C++ code (using the -c++ commandline option).
This may be added at a future date, however, until then some of the following workarounds can be applied.
There is some support for nested structs and unions when wrapping C code,
see <a href="SWIG.html#SWIG_nested_structs">Nested structures</a> for further details.
The added complexity of C++ compared to C means this approach does not work well for
C++ code (when using the -c++ command line option).
For C++, a nested class is treated much like an opaque pointer, so anything useful within the nested class, such as its
methods and variables, are not accessible from the target language.
True nested class support may be added to SWIG in the future, however,
until then some of the following workarounds can be applied to improve the situation.
</p>
<p>
It might be possible to use partial class information. Since
SWIG does not need the entire class specification to work, conditional
compilation can be used to comment out the problematic nested class definition, you might do this:
It might be possible to use partial class information as often you can accept that the nested class is not needed,
especially if it is not actually used in any methods you need from the target language.
Imagine you are wrapping the following <tt>Outer</tt> class which contains a nested class <tt>Inner</tt>.
The easiest thing to do is turn a blind eye to the warning that SWIG generates, or simply suppress it:
</p>
<div class="code">
<pre>
class Foo {
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::Inner;
class Outer {
public:
#ifndef SWIG
class Bar {
public:
...
};
#endif
Foo();
~Foo();
...
class Inner {
public:
...
};
Inner getInner();
void useInner(const Inner&amp; inner);
...
};
</pre>
</div>
<p>
The next workaround assumes you cannot modify the source code as was done above and it provides a solution for methods that use nested class types.
Imagine we are wrapping the <tt>Outer</tt> class which contains a nested class <tt>Inner</tt>:
Note that if <tt>Inner</tt> can be used as an opaque type, the default wrapping approach suffices.
For example, if the nested class does not need to be created from the target language, but can be obtained via a method
call, such as the <tt>getInner()</tt> method above, the returned value can then be passed around, such as passed into the
<tt>useInner()</tt> method.
</p>
<p>
With some more effort the above situation can be improved somewhat and a nested class can be constructed and used
from the target language much like any other non-nested class. Assuming we have the <tt>Outer</tt> class in a header file:
</p>
<div class="code">
@ -4721,14 +4753,18 @@ public:
int var;
Inner(int v = 0) : var(v) {}
};
void method(Inner inner);
Inner getInner();
void useInner(const Inner&amp; inner);
};
</pre>
</div>
<p>
The following interface file works around SWIG nested class limitations by redefining the nested class as a global class.
A typedef for the compiler is also required in order for the generated wrappers to compile.
The following interface file works around the nested class limitations by redefining the nested class as a global class.
A typedef for the compiler and the <tt>nestedworkaround</tt>
<a href="Customization.html#Customization_feature_flags">feature flag</a> is also required in
order for the generated wrappers to compile. This flag simply removes all the type information from SWIG, so SWIG treats
the nested class as if it had not been parsed at all.
</p>
<div class="code">
@ -4736,9 +4772,6 @@ A typedef for the compiler is also required in order for the generated wrappers
// File : example.i
%module example
// Suppress SWIG warning
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
// Redefine nested class in global scope in order for SWIG to generate
// a proxy class. Only SWIG parses this definition.
class Inner {
@ -4747,25 +4780,64 @@ class Inner {
Inner(int v = 0) : var(v) {}
};
%nestedworkaround Outer::Inner;
%{
#include "outer.h"
%}
%include "outer.h"
// We've fooled SWIG into thinking that Inner is a global class, so now we need
// to trick the C++ compiler into understanding this apparent global type.
%{
// SWIG thinks that Inner is a global class, so we need to trick the C++
// compiler into understanding this so called global type.
typedef Outer::Inner Inner;
%}
</pre>
</div>
<p>
The downside to this approach is having to maintain two definitions of <tt>Inner</tt>, the real one and the one in the interface file that SWIG parses.
The downside to this approach is a more complex interface file and having to maintain two definitions of <tt>Inner</tt>,
the real one and the one in the interface file that SWIG parses.
However, the upside is that all the methods/variables in the nested class are available from the target language
as a proxy class is generated instead of treating the nested class as an opaque type.
The proxy class can be constructed from the target language and passed into any methods accepting the nested class.
Also note that the original header file is parsed unmodified.
</p>
<H2><a name="SWIGPlus_nn37"></a>6.27 A brief rant about const-correctness</H2>
<p>
Finally, conditional compilation can be used as a workaround to comment out nested class definitions in the actual headers,
assuming you are able to modify them.
</p>
<div class="code">
<pre>
// File outer.h
class Outer {
public:
#ifndef SWIG
class Inner {
public:
...
};
#endif
...
};
</pre>
</div>
<p>
This workaround used to be common when SWIG could not deal with nested classes particulary well.
This should just be a last resort for unusual corner cases now as SWIG can parse nested classes and even handle nested template classes fairly well.
</p>
<p>
<b>Compatibility Note:</b> SWIG-1.3.40 and earlier versions did not have the <tt>nestedworkaround</tt> feature
and the generated code resulting from parsing nested classes did not always compile.
Nested class warnings could also not be suppressed using %warnfilter.
</p>
<H2><a name="SWIGPlus_const"></a>6.27 A brief rant about const-correctness</H2>
<p>

View file

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

View file

@ -1502,8 +1502,8 @@ If declarations such as these appear, you will get a warning message like this:
<div class="code">
<pre>
example.i:12: Warning(509): Overloaded spam(short) is shadowed by spam(int)
at example.i:11.
example.i:12: Warning 509: Overloaded method spam(short) effectively ignored,
example.i:11: Warning 509: as it is shadowed by spam(int).
</pre>
</div>

View file

@ -31,10 +31,11 @@
<li><a href="#Typemaps_pattern_matching">Pattern matching rules</a>
<ul>
<li><a href="#Typemaps_nn17">Basic matching rules</a>
<li><a href="#Typemaps_nn18">Typedef reductions</a>
<li><a href="#Typemaps_typedef_reductions">Typedef reductions</a>
<li><a href="#Typemaps_nn19">Default typemaps</a>
<li><a href="#Typemaps_mixed_default">Mixed default typemaps</a>
<li><a href="#Typemaps_nn20">Multi-arguments typemaps</a>
<li><a href="#Typemaps_debugging_search">Debugging typemap pattern matching</a>
</ul>
<li><a href="#Typemaps_nn21">Code generation rules</a>
<ul>
@ -68,7 +69,7 @@
<li><a href="#Typemaps_nn40">Typemaps for arrays</a>
<li><a href="#Typemaps_nn41">Implementing constraints with typemaps</a>
</ul>
<li><a href="#Typemaps_nn43">Typemaps for multiple languages</a>
<li><a href="#Typemaps_nn43">Typemaps for multiple target languages</a>
<li><a href="#Typemaps_optimal">Optimal code generation when returning by value</a>
<li><a href="#Typemaps_multi_argument_typemaps">Multi-argument typemaps</a>
<li><a href="#runtime_type_checker">The run-time type checker</a>
@ -88,10 +89,6 @@
<p>
<b>Disclaimer: This chapter is under construction!</b>
</p>
<H2><a name="Typemaps_nn2"></a>10.1 Introduction</H2>
@ -230,14 +227,17 @@ At first glance, this code will look a little confusing.
However, there is really not much to it. The first typemap (the "in"
typemap) is used to convert a value from the target language to C. The second
typemap (the "out" typemap) is used to convert in the other
direction. The content of each typemap is a small fragment of C code
that is inserted directly into the SWIG generated wrapper functions. Within
this code, a number of special variables prefixed with a $ are expanded. These are
really just placeholders for C variables that are generated in the course
direction. The content of each typemap is a small fragment of code
that is inserted directly into the SWIG generated wrapper functions.
The code is usually C or C++ code which will be generated into the C/C++ wrapper functions.
Note that this isn't always the case as some target language modules allow target language
code within the typemaps which gets generated into target language specific files.
Within this code, a number of special variables prefixed with a $ are expanded. These are
really just placeholders for C/C++ variables that are generated in the course
of creating the wrapper function. In this case, <tt>$input</tt> refers to an
input object that needs to be converted to C and <tt>$result</tt>
input object that needs to be converted to C/C++ and <tt>$result</tt>
refers to an object that is going to be returned by a wrapper
function. <tt>$1</tt> refers to a C variable that has the same type as
function. <tt>$1</tt> refers to a C/C++ variable that has the same type as
specified in the typemap declaration (an <tt>int</tt> in this
example).
</p>
@ -681,8 +681,9 @@ these methods is described later.
</p>
<p>
<em>modifiers</em> is an optional comma separated list of <tt>name="value"</tt> values. These
are sometimes to attach extra information to a typemap and is often target-language dependent.
<em>modifiers</em> is an optional comma separated list of <tt>name="value"</tt> values.
These are sometimes to attach extra information to a typemap and is often target-language dependent.
They are also known as typemap attributes.
</p>
<p>
@ -1091,7 +1092,7 @@ void F(int x[1000]); // int [ANY] rule (typemap 5)
</pre>
</div>
<H3><a name="Typemaps_nn18"></a>10.3.2 Typedef reductions</H3>
<H3><a name="Typemaps_typedef_reductions"></a>10.3.2 Typedef reductions</H3>
<p>
@ -1246,6 +1247,26 @@ is rather esoteric--there's little practical reason to write a typemap quite lik
to confuse your coworkers even more.
</p>
<p>
As a point of clarification, it is worth emphasizing that typedef matching is a typedef <b>reduction</b> process only, that is, SWIG does not search for every single possible typedef.
Given a type in a declaration, it will only reduce the type, it won't build it up looking for typedefs.
For example, given the type <tt>Struct</tt>, the typemap below will not be used for the <tt>aStruct</tt> parameter,
because <tt>Struct</tt> is fully reduced:
</p>
<div class="code">
<pre>
struct Struct {...};
typedef Struct StructTypedef;
%typemap(in) StructTypedef {
...
}
void go(Struct aStruct);
</pre>
</div>
<H3><a name="Typemaps_nn19"></a>10.3.3 Default typemaps</H3>
@ -1383,7 +1404,7 @@ Expect to see them being used more and more within the various libraries in late
</p>
<H3><a name="Typemaps_nn20"></a>10.3.5 Multi-arguments typemaps</H3>
<H3><a name="Typemaps_multi_argument_typemaps"></a>10.3.5 Multi-arguments typemaps</H3>
<p>
@ -1413,6 +1434,205 @@ but all subsequent arguments must match exactly.
</p>
<H3><a name="Typemaps_debugging_search"></a>10.3.6 Debugging typemap pattern matching</H3>
<p>
There are two useful debug command line options available for debugging typemaps, <tt>-debug-tmsearch</tt> and <tt>-debug-tmused</tt>.
</p>
<p>
The <tt>-debug-tmsearch</tt> option is a verbose option for debugging typemap searches.
This can be very useful for watching the pattern matching process in action and for debugging which typemaps are used.
The option displays all the typemaps and types that are looked for until a successful pattern match is made.
As the display includes searches for each and every type needed for wrapping, the amount of information displayed can be large.
Normally you would manually search through the displayed information for the particular type that you are interested in.
</p>
<p>
For example, consider some of the code used in the <a href="#Typemaps_typedef_reductions">Typedef reductions</a> section already covered:
</p>
<div class="code">
<pre>
typedef int Integer;
typedef Integer Row4[4];
void foo(Row4 rows[10]);
</pre>
</div>
<p>
A sample of the debugging output is shown below for the "in" typemap:
</p>
<div class="shell">
<pre>
swig -perl -debug-tmsearch example.i
...
example.h:3: Searching for a suitable 'in' typemap for: Row4 rows[10]
Looking for: Row4 rows[10]
Looking for: Row4 [10]
Looking for: Row4 rows[ANY]
Looking for: Row4 [ANY]
Looking for: Integer rows[10][4]
Looking for: Integer [10][4]
Looking for: Integer rows[ANY][ANY]
Looking for: Integer [ANY][ANY]
Looking for: int rows[10][4]
Looking for: int [10][4]
Looking for: int rows[ANY][ANY]
Looking for: int [ANY][ANY]
Looking for: SWIGTYPE rows[ANY][ANY]
Looking for: SWIGTYPE [ANY][ANY]
Looking for: SWIGTYPE rows[ANY][]
Looking for: SWIGTYPE [ANY][]
Looking for: SWIGTYPE *rows[ANY]
Looking for: SWIGTYPE *[ANY]
Looking for: SWIGTYPE rows[ANY]
Looking for: SWIGTYPE [ANY]
Looking for: SWIGTYPE rows[]
Looking for: SWIGTYPE []
Using: %typemap(in) SWIGTYPE []
...
</pre>
</div>
<p>
showing that the best default match supplied by SWIG is the <tt>SWIGTYPE []</tt> typemap.
As the example shows, the successful match displays just the typemap method name and type in this format: <tt>%typemap(method) type</tt>.
This information might meet your debugging needs, however, you might want to analyze further.
If you next invoke SWIG with the <tt>-E</tt> option to display the preprocessed output, and search for this particular typemap,
you'll find the full typemap contents (example shown below for Python):
</p>
<div class="code">
<pre>
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr($input, &amp;argp,$descriptor, $disown | 0 );
if (!SWIG_IsOK(res)) {
SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'");
}
$1 = ($ltype)(argp);
}
</pre>
</div>
<p>
The generated code for the <tt>foo</tt> wrapper will then contain the snippets of the typemap with the special variables expanded.
The rest of this chapter will need reading though to fully understand all of this, however, the relevant parts of the generated code for the above typemap can be seen below:
</p>
<div class="code">
<pre>
SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
...
void *argp1 = 0 ;
int res1 = 0 ;
...
res1 = SWIG_ConvertPtr(obj0, &amp;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]""'");
}
arg1 = (int (*)[4])(argp1);
...
}
</pre>
</div>
<p>
Searches for multi-argument typemaps are not mentioned unless a matching multi-argument typemap does actually exist.
For example, the output for the code in the <a href="#Typemaps_multi_argument_typemaps">previous section</a> is as follows:
</p>
<div class="shell">
<pre>
...
example.h:39: Searching for a suitable 'in' typemap for: char *buffer
Looking for: char *buffer
Multi-argument typemap found...
Using: %typemap(in) (char *buffer,int len)
...
</pre>
</div>
<p>
The second option for debugging is <tt>-debug-tmused</tt> and this displays the typemaps used.
This option is a less verbose version of the <tt>-debug-tmsearch</tt> option as it only displays each successfully found typemap on a separate single line.
The output displays the type, and name if present, the typemap method in brackets and then the actual typemap used.
Below is the output for the example code at the start of this section on debugging.
</p>
<div class="shell">
<pre>
$ swig -perl -debug-tmused example.i
example.h:3: Typemap for Row4 rows[10] (in) : %typemap(in) SWIGTYPE []
example.h:3: Typemap for Row4 rows[10] (typecheck) : %typemap(typecheck) SWIGTYPE *
example.h:3: Typemap for Row4 rows[10] (freearg) : %typemap(freearg) SWIGTYPE []
example.h:3: Typemap for void foo (out) : %typemap(out) void
</pre>
</div>
<p>
Now, consider the following interface file:
</p>
<div class="code">
<pre>
%module example
%{
void set_value(const char* val) {}
%}
%typemap(check) char *NON_NULL {
if (!$1) {
/* ... error handling ... */
}
}
%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
%typemap(check) const char* val = char* NON_NULL;
%typemap(arginit, noblock=1) const char* val {
$1 = "";
}
void set_value(const char* val);
</pre>
</div>
<p>
and the output debug:
</p>
<div class="shell">
<pre>
swig -perl5 -debug-tmused example.i
example.i:21: Typemap for char const *val (arginit) : %typemap(arginit) char const *val
example.i:21: Typemap for char const *val (in) : %apply SWIGTYPE * { char const *val }
example.i:21: Typemap for char const *val (typecheck) : %apply SWIGTYPE * { char const *val }
example.i:21: Typemap for char const *val (check) : %typemap(check) char const *val = char *NON_NULL
example.i:21: Typemap for char const *val (freearg) : %apply SWIGTYPE * { char const *val }
example.i:21: Typemap for void set_value (out) : %typemap(out) void
</pre>
</div>
<p>
The following observations about what is displayed can be noted (the same applies for <tt>-debug-tmsearch</tt>):
<li>
The relevant typemap is shown, but for typemap copying, the appropriate <tt>%typemap</tt> or <tt>%apply</tt> is displayed, for example, the "check" and "in" typemaps.
</li>
<li>
The typemap modifiers are not shown, eg the <tt>noblock=1</tt> modifier in the "arginit" typemap.
</li>
<li>
The exact <tt>%apply</tt> statement might look different to what is in the actual code. For example, the <tt>const char* another_value</tt> is not shown as it is not relevant here.
Also the types may be displayed slightly differently - <tt>char const *</tt> and not <tt>const char*</tt>.
</li>
</p>
<H2><a name="Typemaps_nn21"></a>10.4 Code generation rules</H2>
@ -2686,12 +2906,12 @@ rather than blindly passing values to the underlying C/C++ program.</p>
Note: A more advanced constraint checking system is in development. Stay tuned.
</p>
<H2><a name="Typemaps_nn43"></a>10.7 Typemaps for multiple languages</H2>
<H2><a name="Typemaps_nn43"></a>10.7 Typemaps for multiple target languages</H2>
<p>
The code within typemaps is usually language dependent,
however, many languages support the same typemaps.
however, many target languages support the same typemaps.
In order to distinguish typemaps across different languages, the preprocessor should be used.
For example, the "in" typemap for Perl and Ruby could be written as:
</p>
@ -2873,8 +3093,8 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
<div class="targetlang">
<pre>
example.i:28: Warning(474): Method XX::create() usage of the optimal attribute in the out
typemap at example.i:14 ignored as the following cannot be used to generate optimal code:
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:
try {
result = XX::create();
} catch(const std::exception &amp;e) {
@ -2895,8 +3115,8 @@ In fact SWIG attempts to detect this and will issue a warning something like:
<div class="targetlang">
<pre>
example.i:21: Warning(475): Multiple calls to XX::create() might be generated due to
optimal attribute usage in the out typemap at example.i:7.
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.
</pre>
</div>
@ -3201,7 +3421,7 @@ language modules.</li>
<p>
The run-time type checker is used by many, but not all, of SWIG's supported target languages.
The run-time type checker features
are not required and are thus not used for strongly typed languages such as Java and C#.
are not required and are thus not used for statically typed languages such as Java and C#.
The scripting and scheme based languages rely on it and it forms
a critical part of SWIG's operation for these languages.
</p>
@ -4060,6 +4280,7 @@ numerous examples. You should look at these files to get a feel
for how to define typemaps of your own.
Some of the language modules support additional typemaps and further
information is available in the individual chapters for each target language.
There you may also find more hands-on practical examples.
</p>
</body>

View file

@ -270,21 +270,37 @@ traceprintf(arg1, NULL);
<p>
Arguably, this approach seems to defeat the whole point of variable length arguments. However,
this actually provides enough support for many simple kinds of varargs functions to still be useful. For
instance, you could make function calls like this (in Python):
this actually provides enough support for many simple kinds of varargs functions to still be useful, however it does come with a caveat.
For instance, you could make function calls like this (in Python):
</p>
<div class="targetlang">
<pre>
&gt;&gt;&gt; traceprintf("Hello World")
&gt;&gt;&gt; traceprintf("Hello %s. Your number is %d\n" % (name, num))
&gt;&gt;&gt; traceprintf("Your result is 90%%.")
</pre>
</div>
<p>
Notice how string formatting is being done in Python instead of C.
The caveat is the strings passed must be safe to use in C though.
For example if name was to contain a "%" it should be double escaped in order to avoid unpredictable
behaviour:
</p>
<div class="targetlang">
<pre>
&gt;&gt;&gt; traceprintf("Your result is 90%.\n") # unpredictable behaviour
&gt;&gt;&gt; traceprintf("Your result is 90%%.\n") # good
</pre>
</div>
<p>
Read on for further solutions.
</p>
<H2><a name="Varargs_nn5"></a>13.4 Argument replacement using %varargs</H2>

View file

@ -44,8 +44,8 @@ During compilation, SWIG may generate a variety of warning messages. For exampl
<div class="shell">
<pre>
example.i:16: Warning(501): Overloaded declaration ignored. bar(double)
example.i:15: Warning(501): Previous declaration is bar(int)
example.i:16: Warning 501: Overloaded declaration ignored. bar(double)
example.i:15: Warning 501: Previous declaration is bar(int)
</pre>
</div>
@ -344,7 +344,7 @@ These can be overridden using command line options, for example:
$ swig -python -Fstandard example.i
example.i:4: Syntax error in input.
$ swig -python -Fmicrosoft example.i
example.i(4): Syntax error in input.
example.i(4) : Syntax error in input.
</pre></div>
<H2><a name="Warnings_nn9"></a>14.9 Warning number reference</H2>
@ -399,18 +399,20 @@ example.i(4): Syntax error in input.
<li>308. Namespace alias '<em>name</em>' not allowed here. Assuming '<em>name</em>'
<li>309. [private | protected] inheritance ignored.
<li>310. Template '<em>name</em>' was already wrapped as '<em>name</em>' (ignored)
<li>311. Template partial specialization not supported.
<li>312. Nested classes not currently supported (ignored).
<li>312. Unnamed nested class not currently supported (ignored).
<li>313. Unrecognized extern type "<em>name</em>" (ignored).
<li>314. '<em>identifier</em>' is a <em>lang</em> keyword.
<li>315. Nothing known about '<em>identifier</em>'.
<li>316. Repeated %module directive.
<li>317. Specialization of non-template '<em>name</em>'.
<li>318. Instantiation of template <em>name</em> is ambiguous. Using <em>templ</em> at <em>file</em>:<em>line</em>
<li>318. Instantiation of template '<em>name</em>' is ambiguous, instantiation <em>templ</em> used, instantiation <em>templ</em> ignored.
<li>319. No access specifier given for base class <em>name</em> (ignored).
<li>320. Explicit template instantiation ignored.
<li>321. <em>identifier</em> conflicts with a built-in name.
<li>322. Redundant redeclaration of '<em>name</em>'.
<li>323. Recursive scope inheritance of '<em>name</em>'.
<li>324. Named nested template instantiations not supported. Processing as if no name was given to %template().
<li>325. Nested class not currently supported (<em>name</em> ignored).
<li>350. operator new ignored.
<li>351. operator delete ignored.
<li>352. operator+ ignored.
@ -482,8 +484,8 @@ example.i(4): Syntax error in input.
<li>469. No or improper directorin typemap defined for <em>type</em>
<li>470. Thread/reentrant unsafe wrapping, consider returning by value instead.
<li>471. Unable to use return type <em>type</em> in director method
<li>474. Method <em>method</em> usage of the optimal attribute in the out typemap at <em>file</em>:<em>line</em> ignored as the following cannot be used to generate optimal code: <em>code</em>
<li>475. Multiple calls to <em>method</em> might be generated due to optimal attribute usage in the out typemap at <em>file</em>:<em>line</em>.
<li>474. Method <em>method</em> usage of the optimal attribute ignored in the out typemap as the following cannot be used to generate optimal code: <em>code</em>
<li>475. Multiple calls to <em>method</em> might be generated due to optimal attribute usage in the out typemap.
</ul>
@ -492,22 +494,22 @@ example.i(4): Syntax error in input.
<ul>
<li>501. Overloaded declaration ignored. <em>decl</em>
<li>502. Overloaded constructor ignored. <em>decl</em>
<li>501. Overloaded declaration ignored. <em>decl</em>. Previous declaration is <em>decl</em>.
<li>502. Overloaded constructor ignored. <em>decl</em>. Previous declaration is <em>decl</em>.
<li>503. Can't wrap '<em>identifier</em>' unless renamed to a valid identifier.
<li>504. Function <em>name</em> must have a return type.
<li>505. Variable length arguments discarded.
<li>506. Can't wrap varargs with keyword arguments enabled.
<li>507. Adding native function <em>name</em> not supported (ignored).
<li>508. Declaration of '<em>name</em>' shadows declaration accessible via operator-&gt;() at <em>file:line</em>.
<li>509. Overloaded <em>declaration</em> is shadowed by <em>declaration</em> at <em>file</em>:<em>line</em>.
<li>508. Declaration of '<em>name</em>' shadows declaration accessible via operator-&gt;(), previous declaration of'<em>declaration</em>'.
<li>509. Overloaded method <em>declaration</em> effectively ignored, as it is shadowed by <em>declaration</em>.
<li>510. Friend function '<em>name</em>' ignored.
<li>511. Can't use keyword arguments with overloaded functions.
<li>512. Overloaded <em>declaration</em> const ignored. Non-const method at <em>file</em>:<em>line</em> used.
<li>512. Overloaded method <em>declaration</em> ignored, using non-const method <em>declaration</em> instead.
<li>513. Can't generate wrappers for unnamed struct/class.
<li>514.
<li>515.
<li>516. Overloaded method <em>declaration</em> ignored. Method <em>declaration</em> at <em>file</em>:<em>line</em> used.
<li>516. Overloaded method <em>declaration</em> ignored, using <em>declaration</em> instead.
<li>517.
<li>518. Portability warning: File <em>file1</em> will be overwritten by <em>file2</em> on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
<li>519. %template() contains no name. Template method ignored: <em>declaration</em>

View file

@ -1124,11 +1124,11 @@ RRSRC = $(INTERFACE:.i=.R)
r: $(SRCS)
$(SWIG) -r $(SWIGOPT) $(INTERFACEPATH)
+( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) )
+( PKG_LIBS="$(SRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) )
r_cpp: $(CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
+( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) )
+( PKG_LIBS="$(CXXSRCS)" PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -fPIC -o $(LIBPREFIX)$(TARGET)$(SO) $(RCXXSRCS) )
r_clean:
rm -f *_wrap* *~ .~*

View file

@ -143,7 +143,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
<li> <a href="example.i">example.i</a> (SWIG interface)
<li> <a href="runme.java">runme.java</a> (Java program)
</ul>

View file

@ -144,7 +144,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
<li> <a href="example.i">example.i</a> (SWIG interface)
<li> <a href="runme.pl">runme.pl</a> (Perl Script)
</ul>

View file

@ -22,7 +22,7 @@
# Now get the result
$r = intp_value($c);
print " 38 + 42 = $r\n";
print " 37 + 42 = $r\n";
# Clean up the pointers
delete_intp($a);

View file

@ -1,10 +1,4 @@
/* File : example.i */
%module example
%{
#include "example.h"
%}
/* Let's just grab the original header file here */
%include "example.h"
int printf(const char *fmt, ...);

View file

@ -1,51 +1,10 @@
# file: runme.py
# This file illustrates the proxy class C++ interface generated
# by SWIG.
from example import *
import example
# ----- Object creation -----
print "Creating some objects:"
c = example.Circle(10)
print " Created circle", c
s = example.Square(10)
print " Created square", s
# ----- Access a static member -----
print "\nA total of", example.cvar.Shape_nshapes,"shapes were created"
# ----- Member data access -----
# Set the location of the object
c.x = 20
c.y = 30
s.x = -10
s.y = 5
print "\nHere is their current position:"
print " Circle = (%f, %f)" % (c.x,c.y)
print " Square = (%f, %f)" % (s.x,s.y)
# ----- Call some methods -----
print "\nHere are some properties of the shapes:"
for o in [c,s]:
print " ", o
print " area = ", o.area()
print " perimeter = ", o.perimeter()
print "\nGuess I'll clean up now"
# Note: this invokes the virtual destructor
del c
del s
s = 3
print example.cvar.Shape_nshapes,"shapes remain"
print "Goodbye"
printf("hello\n")
name = "%shoot"
num = 22
printf("Hello %s. Your number is %d\n" % (name, num))
print("hello there %s." % name);
printf("Your result is 90%.\n")

View file

@ -144,7 +144,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
<li> <a href="example.i">example.i</a> (SWIG interface)
<li> <a href="example.py">example.py</a> (Python Script)
</ul>

View file

@ -144,7 +144,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
<li> <a href="example.i">example.i</a> (SWIG interface)
<li> <a href="runme.rb">runme.rb</a> (Ruby Script)
</ul>

View file

@ -144,7 +144,7 @@ extraction.
<ul>
<li> <a href="example.c">example.c</a> (C Source)
<li> <a href="example.i">example.i</a> (Swig interface)
<li> <a href="example.i">example.i</a> (SWIG interface)
<li> <a href="runme.tcl">runme.tcl</a> (Tcl Script)
</ul>

View file

@ -28,12 +28,14 @@
# The 'clean' target cleans up.
#
# Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used
# for # invoking tools for the runtime tests and target language
# for invoking tools for the runtime tests and target language
# compiler (eg javac) respectively. For example, valgrind can be used
# for memory checking of the runtime tests using:
# make RUNTOOL="valgrind --leak-check-full"
# make RUNTOOL="valgrind --leak-check=full"
# and valgrind can be used when invoking SWIG using:
# make SWIGTOOL="valgrind --tool=memcheck"
# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
# Note: trace-children needed because of preinst-swig shell wrapper
# to the swig executable.
#
# The variables below can be overridden after including this makefile
#######################################################################
@ -78,8 +80,6 @@ CPP_TEST_BROKEN += \
exception_partial_info \
extend_variable \
li_std_vector_ptr \
namespace_union \
nested_structs \
overload_complicated \
template_default_pointer \
template_expr
@ -189,6 +189,7 @@ CPP_TEST_CASES += \
extend_placement \
extend_template \
extend_template_ns \
extern_c \
extern_namespace \
extern_throws \
features \
@ -238,9 +239,12 @@ CPP_TEST_CASES += \
namespace_template \
namespace_typedef_class \
namespace_typemap \
namespace_union \
namespace_virtual_method \
naturalvar \
nested_class \
nested_comment \
nested_workaround \
newobject1 \
null_pointer \
operator_overload \
@ -255,6 +259,7 @@ CPP_TEST_CASES += \
overload_template \
overload_template_fast \
pointer_reference \
preproc_constants \
primitive_ref \
private_assign \
protected_rename \
@ -297,6 +302,7 @@ CPP_TEST_CASES += \
static_array_member \
static_const_member \
static_const_member_2 \
struct_initialization_cpp \
struct_value \
template \
template_arg_replace \
@ -327,6 +333,8 @@ CPP_TEST_CASES += \
template_inherit_abstract \
template_int_const \
template_methods \
template_nested \
template_nested_typemaps \
template_ns \
template_ns2 \
template_ns3 \
@ -336,6 +344,8 @@ CPP_TEST_CASES += \
template_ns_inherit \
template_ns_scope \
template_partial_arg \
template_partial_specialization \
template_partial_specialization_typedef \
template_qualifier \
template_qualifier \
template_ref_type \
@ -409,6 +419,7 @@ CPP_STD_TEST_CASES += \
li_std_combinations \
li_std_deque \
li_std_except \
li_std_map \
li_std_pair \
li_std_string \
li_std_vector \
@ -430,6 +441,7 @@ C_TEST_CASES += \
arrays \
char_constant \
const_const \
constant_expr \
empty \
enums \
extern_declaration \
@ -447,17 +459,21 @@ C_TEST_CASES += \
li_cpointer \
li_math \
long_long \
memberin_extend_c \
name \
nested \
nested_structs \
newobject2 \
overload_extend \
overload_extendc \
preproc \
preproc_constants_c \
ret_by_value \
simple_array \
sizeof_pointer \
sneaky1 \
struct_rename \
struct_initialization \
typedef_struct \
typemap_subst \
union_parameter \

View file

@ -0,0 +1,11 @@
%module constant_expr;
/* Tests of constant expressions. */
%inline %{
/* % didn't work in SWIG 1.3.40 and earlier. */
const int X = 123%7;
#define FOO 12 % 6
double d_array[12 % 6];
%}

View file

@ -1,36 +1,6 @@
%module cpp_broken
// bug #1060789
%inline %{
#define MASK(shift, size) (((1 << (size)) - 1) << (shift))
#define SOME_MASK_DEF (80*MASK(8, 10))
%}
// bug #1060079
%inline %{
#define FIELD(name, width) unsigned int name:width
#define SOME_CONST 2
#define NEXT_CONST (2 * SOME_CONST)
typedef struct {
FIELD(a, SOME_CONST);
FIELD(b, NEXT_CONST);
} MyStruct_t;
%}
%{
#ifdef max
#undef max
#endif
%}
// bug #994301
%inline %{
#define max(a,b) ((a) > (b) ? (a) : (b))
%}
// bug #940318
%inline %{
typedef enum {
@ -40,36 +10,3 @@ eZero = 0
%}
// bug #754443
%inline %{
#define MAG_STYLE_BORDER_OFFS 0
#define MAG_STYLE_BORDER_BITS 3
#define MAG_STYLE_BORDER_MASK (((1UL<<MAG_STYLE_BORDER_BITS)-1)<<MAG_STYLE_BORDER_OFFS)
/* these CANNOT be combined */
#define MAG_STYLE_BORDER_NONE (1 << MAG_STYLE_BORDER_OFFS)
#define MAG_STYLE_BORDER_STATIC (2 << MAG_STYLE_BORDER_OFFS)
#define MAG_STYLE_BORDER_SIMPLE (3 << MAG_STYLE_BORDER_OFFS)
#define MAG_STYLE_BORDER_RAISED (4 << MAG_STYLE_BORDER_OFFS)
#define MAG_STYLE_BORDER_DOUBLE (5 << MAG_STYLE_BORDER_OFFS)
#define MAG_STYLE_BORDER_DEFAULT MAG_STYLE_BORDER_SIMPLE
#define MAG_STYLE_CAPTION_OFFS ( MAG_STYLE_BORDER_OFFS + MAG_STYLE_BORDER_BITS )
#define MAG_STYLE_CAPTION_BITS 8
#define MAG_STYLE_CAPTION_MASK (((1UL<<MAG_STYLE_CAPTION_BITS)-1)<<MAG_STYLE_CAPTION_OFFS)
/* these CAN be combined */
#define MAG_STYLE_CAPTION_NONE ( 1 << ( 0 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_PRESENT ( 1 << ( 1 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_SYSMENU ( 1 << ( 2 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_MINIMIZE ( 1 << ( 3 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_MAXIMIZE ( 1 << ( 4 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_RESIZE ( 1 << ( 5 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_TINYHOR ( 1 << ( 6 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_TINYVER ( 1 << ( 7 + MAG_STYLE_CAPTION_OFFS ))
#define MAG_STYLE_CAPTION_DEFAULT ( MAG_STYLE_CAPTION_RESIZE + MAG_STYLE_CAPTION_MAXIMIZE + MAG_STYLE_CAPTION_MINIMIZE + MAG_STYLE_CAPTION_SYSMENU + MAG_STYLE_CAPTION_PRESENT )
%}

View file

@ -1,5 +1,6 @@
using System;
using System.Reflection;
using System.ComponentModel;
using csharp_attributesNamespace;
public class runme
@ -171,6 +172,24 @@ public class runme
if (Attribute.GetCustomAttribute(member, typeof(Eurostar2Attribute)) == null)
throw new Exception("No attribute for " + member.Name);
}
// Enum value attributes
Type walesType = typeof(MoreStations.Wales);
{
MemberInfo member = (MemberInfo)walesType.GetMember("Cardiff")[0];
DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
if (attribute == null)
throw new Exception("No attribute for " + member.Name);
if (attribute.Description != "Cardiff city station")
throw new Exception("Incorrect attribute value for " + member.Name);
}
{
MemberInfo member = (MemberInfo)walesType.GetMember("Swansea")[0];
DescriptionAttribute attribute = (DescriptionAttribute)Attribute.GetCustomAttribute(member, typeof(System.ComponentModel.DescriptionAttribute));
if (attribute == null)
throw new Exception("No attribute for " + member.Name);
if (attribute.Description != "Swansea city station")
throw new Exception("Incorrect attribute value for " + member.Name);
}
// Enum csattribute typemap
{
Type cymrutype = typeof(Cymru);
@ -179,6 +198,8 @@ public class runme
if (tgv == null)
throw new Exception("No attribute for Cymru");
}
// No runtime test for directorinattributes and directoroutattributes
}
}
@ -237,3 +258,9 @@ public class ThreadSafeAttribute : Attribute {
public ThreadSafeAttribute() {}
}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class DirectorIntegerOutAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class DirectorIntegerInAttribute : Attribute {}

View file

@ -158,7 +158,8 @@ public class li_std_vector_runme {
} catch (ArgumentNullException) {
}
{
myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
// Collection initializer test, requires C# 3.0
// myDoubleVector = new DoubleVector() { 123.4, 567.8, 901.2 };
}
// IndexOf() test
@ -542,8 +543,8 @@ public class li_std_vector_runme {
// Dispose()
{
using (StructVector vs = new StructVector() { new Struct(0.0), new Struct(11.1) } )
using (DoubleVector vd = new DoubleVector() { 0.0, 11.1 } ) {
using (StructVector vs = new StructVector( new Struct[] { new Struct(0.0), new Struct(11.1) } ) )
using (DoubleVector vd = new DoubleVector( new double[] { 0.0, 11.1 } ) ) {
}
}

View file

@ -0,0 +1,70 @@
using System;
using System.Reflection;
using preproc_constants_cNamespace;
// Same as preproc_constants_c.i testcase, but bool types are int instead
public class runme {
static void Main() {
assert( typeof(int) == preproc_constants_c.CONST_INT1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_INT2.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT1.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT2.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT3.GetType() );
assert( typeof(uint) == preproc_constants_c.CONST_UINT4.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG2.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG3.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_LONG4.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG1.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG2.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG3.GetType() );
assert( typeof(long) == preproc_constants_c.CONST_LLONG4.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG1.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG2.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG3.GetType() );
assert( typeof(ulong) == preproc_constants_c.CONST_ULLONG4.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE1.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE2.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE3.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE4.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE5.GetType() );
assert( typeof(double) == preproc_constants_c.CONST_DOUBLE6.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_BOOL1.GetType() );
assert( typeof(int) == preproc_constants_c.CONST_BOOL2.GetType() );
assert( typeof(char) == preproc_constants_c.CONST_CHAR.GetType() );
assert( typeof(string) == preproc_constants_c.CONST_STRING1.GetType() );
assert( typeof(string) == preproc_constants_c.CONST_STRING2.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_BOOL.GetType() );
// assert( typeof(int) == preproc_constants_c.INT_AND_CHAR.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_INT.GetType() );
assert( typeof(uint) == preproc_constants_c.INT_AND_UINT.GetType() );
assert( typeof(int) == preproc_constants_c.INT_AND_LONG.GetType() );
assert( typeof(uint) == preproc_constants_c.INT_AND_ULONG.GetType() );
assert( typeof(long) == preproc_constants_c.INT_AND_LLONG.GetType() );
assert( typeof(ulong) == preproc_constants_c.INT_AND_ULLONG.GetType() );
assert( typeof(int ) == preproc_constants_c.BOOL_AND_BOOL.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_MULTIPLY.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_DIVIDE.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_PLUS.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_MINUS.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LSHIFT.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_RSHIFT.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LTE.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_GTE.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_INEQUALITY.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_EQUALITY.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_AND.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_XOR.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_OR.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LAND.GetType() );
assert( typeof(int) == preproc_constants_c.EXPR_LOR.GetType() );
assert( typeof(double) == preproc_constants_c.EXPR_CONDITIONAL.GetType() );
}
static void assert(bool assertion) {
if (!assertion)
throw new ApplicationException("test failed");
}
}

View file

@ -0,0 +1,69 @@
using System;
using System.Reflection;
using preproc_constantsNamespace;
public class runme {
static void Main() {
assert( typeof(int) == preproc_constants.CONST_INT1.GetType() );
assert( typeof(int) == preproc_constants.CONST_INT2.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT1.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT2.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT3.GetType() );
assert( typeof(uint) == preproc_constants.CONST_UINT4.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG1.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG2.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG3.GetType() );
assert( typeof(int) == preproc_constants.CONST_LONG4.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG1.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG2.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG3.GetType() );
assert( typeof(long) == preproc_constants.CONST_LLONG4.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG1.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG2.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG3.GetType() );
assert( typeof(ulong) == preproc_constants.CONST_ULLONG4.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE1.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE2.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE3.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE4.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE5.GetType() );
assert( typeof(double) == preproc_constants.CONST_DOUBLE6.GetType() );
assert( typeof(bool) == preproc_constants.CONST_BOOL1.GetType() );
assert( typeof(bool) == preproc_constants.CONST_BOOL2.GetType() );
assert( typeof(char) == preproc_constants.CONST_CHAR.GetType() );
assert( typeof(string) == preproc_constants.CONST_STRING1.GetType() );
assert( typeof(string) == preproc_constants.CONST_STRING2.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_BOOL.GetType() );
// assert( typeof(int) == preproc_constants.INT_AND_CHAR.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_INT.GetType() );
assert( typeof(uint) == preproc_constants.INT_AND_UINT.GetType() );
assert( typeof(int) == preproc_constants.INT_AND_LONG.GetType() );
assert( typeof(uint) == preproc_constants.INT_AND_ULONG.GetType() );
assert( typeof(long) == preproc_constants.INT_AND_LLONG.GetType() );
assert( typeof(ulong) == preproc_constants.INT_AND_ULLONG.GetType() );
assert( typeof(int ) == preproc_constants.BOOL_AND_BOOL.GetType() );
assert( typeof(int) == preproc_constants.EXPR_MULTIPLY.GetType() );
assert( typeof(int) == preproc_constants.EXPR_DIVIDE.GetType() );
assert( typeof(int) == preproc_constants.EXPR_PLUS.GetType() );
assert( typeof(int) == preproc_constants.EXPR_MINUS.GetType() );
assert( typeof(int) == preproc_constants.EXPR_LSHIFT.GetType() );
assert( typeof(int) == preproc_constants.EXPR_RSHIFT.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LTE.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_GTE.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_INEQUALITY.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_EQUALITY.GetType() );
assert( typeof(int) == preproc_constants.EXPR_AND.GetType() );
assert( typeof(int) == preproc_constants.EXPR_XOR.GetType() );
assert( typeof(int) == preproc_constants.EXPR_OR.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LAND.GetType() );
assert( typeof(bool) == preproc_constants.EXPR_LOR.GetType() );
assert( typeof(double) == preproc_constants.EXPR_CONDITIONAL.GetType() );
}
static void assert(bool assertion) {
if (!assertion)
throw new ApplicationException("test failed");
}
}

View file

@ -1,4 +1,4 @@
%module csharp_attributes
%module(directors="1") csharp_attributes
// Test the inattributes and outattributes typemaps
%typemap(cstype, outattributes="[IntOut]", inattributes="[IntIn]") int "int"
@ -15,6 +15,8 @@ public:
int GlobalFunction(int myInt) { return myInt; }
%}
//%include "enumsimple.swg"
//%include "enumtypesafe.swg"
// Test the attributes feature
%csattributes MoreStations::MoreStations() "[InterCity1]"
@ -25,6 +27,8 @@ int GlobalFunction(int myInt) { return myInt; }
%csattributes Wales "[InterCity6]"
%csattributes Paddington() "[InterCity7]"
%csattributes DidcotParkway "[InterCity8]"
%csattributes MoreStations::Cardiff "[System.ComponentModel.Description(\"Cardiff city station\")]"
%csattributes Swansea "[System.ComponentModel.Description(\"Swansea city station\")]"
%typemap(csattributes) MoreStations "[Eurostar1]"
%typemap(csattributes) MoreStations::Wales "[Eurostar2]"
@ -46,3 +50,13 @@ enum Cymru { Llanelli };
double MoreStations::WestonSuperMare = 0.0;
%}
// Test directorinattributes and directoroutattributes
%typemap(imtype, directoroutattributes="[DirectorIntegerOut]", directorinattributes="[DirectorIntegerIn]") int "int"
%feature("director") YetMoreStations;
%inline %{
struct YetMoreStations {
virtual int Slough(int x) {}
virtual ~YetMoreStations() {}
};
%}

View file

@ -3,6 +3,11 @@ This was reported in bug #909389 */
%module derived_nested
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::CC;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::DD;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::EE;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) BB::FF;
%inline %{
class A { int x; };
@ -11,5 +16,12 @@ class B {
class D : public A { int z; }; //ok
};
struct BB {
class CC { int y; };
class DD : public A { int z; };
struct EE : public A { int z; };
struct FF : public A { int z; } ff_instance; // Bug 1960977
void useEE(const EE& e) {}
};
%}

View file

@ -8,6 +8,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance1;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance2;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) globalinstance3;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
%inline %{
@ -64,7 +65,7 @@ typedef struct _iFoo
enum {
Phoo = +50,
Char = 'a'
} e;
} e;
} iFoo;
%}
#else
@ -77,5 +78,20 @@ struct iFoo
};
};
%}
#endif
// enum declaration and initialization
%inline %{
enum Exclamation {
goodness,
gracious,
me
} enumInstance = me;
enum ContainYourself {
slap = 10,
my,
thigh
} Slap = slap, My = my, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, my, thigh};
%}

View file

@ -0,0 +1,16 @@
%module extern_c
%inline %{
extern "C" {
void RealFunction(int value);
typedef void Function1(int value); // Fails
typedef int Integer1;
}
typedef void Function2(int value); // Works
typedef int Integer2;
%}
%{
void RealFunction(int value) {}
%}

View file

@ -34,6 +34,12 @@ public class java_director_runme {
System.gc();
System.runFinalization();
// Give the finalizers a chance to run
try {
Thread.sleep(50);
} catch (InterruptedException e) {
}
/* Watch the Quux objects formerly in the QuuxContainer object
get reaped */
System.gc();
@ -73,3 +79,14 @@ class java_director_MyQuux extends Quux {
return "java_director_MyQuux:" + member();
}
}
class java_director_JavaExceptionTest extends JavaExceptionTest {
public java_director_JavaExceptionTest() {
super();
}
public void etest() throws Exception {
super.etest();
}
}

View file

@ -28,7 +28,7 @@ public class java_jnitypes_runme {
double doubleArray[] = new double[] {10.0, 20.0};
Test objectArray[] = new Test[] {new Test(), test};
if (java_jnitypes.jnifunc(true) != true) testFailed("jboolean");
if (java_jnitypes.jnifunc_bool(true) != true) testFailed("jboolean");
if (java_jnitypes.jnifunc('A') != 'A') testFailed("jchar");
if (java_jnitypes.jnifunc((byte)100) != (byte)100) testFailed("jbyte");
if (java_jnitypes.jnifunc((short)100) != (short)100) testFailed("jshort");

View file

@ -0,0 +1,72 @@
import nested_class.*;
public class nested_class_runme {
static {
try {
System.loadLibrary("nested_class");
} 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[]) {
Outer outer = new Outer();
SWIGTYPE_p_Outer__InnerStruct1 is1 = outer.makeInnerStruct1();
SWIGTYPE_p_Outer__InnerClass1 ic1 = outer.makeInnerClass1();
SWIGTYPE_p_Outer__InnerUnion1 iu1 = outer.makeInnerUnion1();
SWIGTYPE_p_Outer__InnerStruct2 is2 = outer.makeInnerStruct2();
SWIGTYPE_p_Outer__InnerClass2 ic2 = outer.makeInnerClass2();
SWIGTYPE_p_Outer__InnerUnion2 iu2 = outer.makeInnerUnion2();
SWIGTYPE_p_Outer__InnerClass4Typedef ic4 = outer.makeInnerClass4Typedef();
SWIGTYPE_p_Outer__InnerStruct4Typedef is4 = outer.makeInnerStruct4Typedef();
SWIGTYPE_p_Outer__InnerUnion4Typedef iu4 = outer.makeInnerUnion4Typedef();
SWIGTYPE_p_Outer__InnerClass5 ic5 = outer.makeInnerClass5();
SWIGTYPE_p_Outer__InnerStruct5 is5 = outer.makeInnerStruct5();
SWIGTYPE_p_Outer__InnerUnion5 iu5 = outer.makeInnerUnion5();
ic5 = outer.makeInnerClass5Typedef();
is5 = outer.makeInnerStruct5Typedef();
iu5 = outer.makeInnerUnion5Typedef();
{
SWIGTYPE_p_Outer__InnerMultiple im1 = outer.getMultipleInstance1();
SWIGTYPE_p_Outer__InnerMultiple im2 = outer.getMultipleInstance2();
SWIGTYPE_p_Outer__InnerMultiple im3 = outer.getMultipleInstance3();
SWIGTYPE_p_Outer__InnerMultiple im4 = outer.getMultipleInstance4();
}
{
SWIGTYPE_p_Outer__InnerMultipleDerived im1 = outer.getMultipleDerivedInstance1();
SWIGTYPE_p_Outer__InnerMultipleDerived im2 = outer.getMultipleDerivedInstance2();
SWIGTYPE_p_Outer__InnerMultipleDerived im3 = outer.getMultipleDerivedInstance3();
SWIGTYPE_p_Outer__InnerMultipleDerived im4 = outer.getMultipleDerivedInstance4();
}
{
SWIGTYPE_p_Outer__InnerMultipleDerived im1 = outer.getMultipleDerivedInstance1();
SWIGTYPE_p_Outer__InnerMultipleDerived im2 = outer.getMultipleDerivedInstance2();
SWIGTYPE_p_Outer__InnerMultipleDerived im3 = outer.getMultipleDerivedInstance3();
SWIGTYPE_p_Outer__InnerMultipleDerived im4 = outer.getMultipleDerivedInstance4();
}
{
SWIGTYPE_p_Outer__InnerMultipleAnonTypedef1 mat1 = outer.makeInnerMultipleAnonTypedef1();
SWIGTYPE_p_Outer__InnerMultipleAnonTypedef2 mat2 = outer.makeInnerMultipleAnonTypedef2();
SWIGTYPE_p_Outer__InnerMultipleAnonTypedef3 mat3 = outer.makeInnerMultipleAnonTypedef3();
SWIGTYPE_p_Outer__InnerMultipleNamedTypedef mnt = outer.makeInnerMultipleNamedTypedef();
SWIGTYPE_p_Outer__InnerMultipleNamedTypedef mnt1 = outer.makeInnerMultipleNamedTypedef1();
SWIGTYPE_p_Outer__InnerMultipleNamedTypedef mnt2 = outer.makeInnerMultipleNamedTypedef2();
SWIGTYPE_p_p_Outer__InnerMultipleNamedTypedef mnt3 = outer.makeInnerMultipleNamedTypedef3();
}
{
SWIGTYPE_p_Outer__InnerSameName isn = outer.makeInnerSameName();
}
}
}

View file

@ -0,0 +1,37 @@
import nested_structs.*;
public class nested_structs_runme {
static {
try {
System.loadLibrary("nested_structs");
} 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[]) {
Outer outer = new Outer();
nested_structs.setValues(outer, 10);
Outer_inner1 inner1 = outer.getInner1();
Outer_inner2 inner2 = outer.getInner2();
Outer_inner3 inner3 = outer.getInner3();
Outer_inner4 inner4 = outer.getInner4();
if (inner1.getVal() != 10) throw new RuntimeException("failed inner1");
if (inner2.getVal() != 20) throw new RuntimeException("failed inner2");
if (inner3.getVal() != 20) throw new RuntimeException("failed inner3");
if (inner4.getVal() != 40) throw new RuntimeException("failed inner4");
Outer_inside1 inside1 = outer.getInside1();
Outer_inside2 inside2 = outer.getInside2();
Outer_inside3 inside3 = outer.getInside3();
Outer_inside4 inside4 = outer.getInside4();
if (inside1.getVal() != 100) throw new RuntimeException("failed inside1");
if (inside2.getVal() != 200) throw new RuntimeException("failed inside2");
if (inside3.getVal() != 200) throw new RuntimeException("failed inside3");
if (inside4.getVal() != 400) throw new RuntimeException("failed inside4");
}
}

View file

@ -0,0 +1,31 @@
import nested_workaround.*;
public class nested_workaround_runme {
static {
try {
System.loadLibrary("nested_workaround");
} 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[]) {
{
Inner inner = new Inner(5);
Outer outer = new Outer();
Inner newInner = outer.doubleInnerValue(inner);
if (newInner.getValue() != 10)
throw new RuntimeException("inner failed");
}
{
Outer outer = new Outer();
Inner inner = outer.createInner(3);
Inner newInner = outer.doubleInnerValue(inner);
if (outer.getInnerValue(newInner) != 6)
throw new RuntimeException("inner failed");
}
}
}

View file

@ -0,0 +1,30 @@
import template_nested.*;
public class template_nested_runme {
static {
try {
System.loadLibrary("template_nested");
} 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[]) {
new T_NormalTemplateNormalClass().tmethod(new NormalClass());
new OuterClass().T_OuterTMethodNormalClass(new NormalClass());
TemplateFuncs tf = new TemplateFuncs();
if (tf.T_TemplateFuncs1Int(-10) != -10)
throw new RuntimeException("it failed");
if (tf.T_TemplateFuncs2Double(-12.3) != -12.3)
throw new RuntimeException("it failed");
T_NestedOuterTemplateDouble tn = new T_NestedOuterTemplateDouble();
if (tn.hohum(-12.3) != -12.3)
throw new RuntimeException("it failed");
}
}

View file

@ -0,0 +1,39 @@
import template_nested_typemaps.*;
public class template_nested_typemaps_runme {
static {
try {
System.loadLibrary("template_nested_typemaps");
} 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[]) {
BreezeString b = new BreezeString();
{
int v = 88;
short vTypemap = -99;
if (b.methodInt1(v) != v) throw new RuntimeException("failed");
if (b.methodInt2(v) != vTypemap) throw new RuntimeException("failed");
if (template_nested_typemaps.globalInt1(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalInt2(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalInt3(v) != vTypemap) throw new RuntimeException("failed");
}
{
short v = 88;
short vTypemap = -77;
if (b.methodShort1(v) != v) throw new RuntimeException("failed");
if (b.methodShort2(v) != vTypemap) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort1(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort2(v) != v) throw new RuntimeException("failed");
if (template_nested_typemaps.globalShort3(v) != vTypemap) throw new RuntimeException("failed");
}
}
}

View file

@ -0,0 +1,59 @@
import template_partial_specialization.*;
public class template_partial_specialization_runme {
static {
try {
System.loadLibrary("template_partial_specialization");
} 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[]) {
// One parameter tests
new A().a();
new B().b();
new C().c();
new D().d();
new E().e();
new F().f();
new G().g();
new H().h();
new I().i();
new J().j();
new K().k();
new L().l();
new BB().b();
new BBB().b();
new BBBB().b();
new BBBBB().b();
new B1().b();
new B2().b();
new B3().b();
new B4().b();
// Two parameter tests
new A_().a();
new B_().b();
new C_().c();
new D_().d();
new E_().e();
new F_().f();
new G_().g();
new C1_().c();
new C2_().c();
new C3_().c();
new C4_().c();
new B1_().b();
new E1_().e();
new E2_().e();
}
}

View file

@ -0,0 +1,59 @@
import template_partial_specialization_typedef.*;
public class template_partial_specialization_typedef_runme {
static {
try {
System.loadLibrary("template_partial_specialization_typedef");
} 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[]) {
// One parameter tests
new A().a();
new B().b();
new C().c();
new D().d();
new E().e();
new F().f();
new G().g();
new H().h();
new I().i();
new J().j();
new K().k();
new L().l();
new BB().b();
new BBB().b();
new BBBB().b();
new BBBBB().b();
new B1().b();
new B2().b();
new B3().b();
new B4().b();
// Two parameter tests
new A_().a();
new B_().b();
new C_().c();
new D_().d();
new E_().e();
new F_().f();
new G_().g();
new C1_().c();
new C2_().c();
new C3_().c();
new C4_().c();
new B1_().b();
new E1_().e();
new E2_().e();
}
}

View file

@ -122,3 +122,11 @@ struct JObjectTest {
%}
%javaexception("Exception") etest "$action"
%inline %{
struct JavaExceptionTest {
virtual ~JavaExceptionTest() {}
virtual void etest() {}
};
%}

View file

@ -5,7 +5,7 @@
%inline %{
jboolean jnifunc(jboolean in) { return in; }
jboolean jnifunc_bool(jboolean in) { return in; } /* some JVM implementations won't allow overloading of the jboolean type with some of the others on the c++ level */
jchar jnifunc(jchar in) { return in; }
jbyte jnifunc(jbyte in) { return in; }
jshort jnifunc(jshort in) { return in; }

View file

@ -5,4 +5,4 @@
%cdata(int);
%cdata(double);
void *malloc(size_t size);

View file

@ -10,43 +10,43 @@
void RDouble(double &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
void PFloat(float *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (float)(FrVal + t); }
void RFloat(float &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (float)(FrVal + t); }
void PInt(int *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (int)(FrVal + t); }
void RInt(int &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (int)(FrVal + t); }
void PShort(short *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (short)(FrVal + t); }
void RShort(short &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (short)(FrVal + t); }
void PLong(long *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (long)(FrVal + t); }
void RLong(long &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (long)(FrVal + t); }
void PUInt(unsigned int *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (unsigned int)(FrVal + t); }
void RUInt(unsigned int &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (unsigned int)(FrVal + t); }
void PUShort(unsigned short *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (unsigned short)(FrVal + t); }
void RUShort(unsigned short &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (unsigned short)(FrVal + t); }
void PULong(unsigned long *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (unsigned long)(FrVal + t); }
void RULong(unsigned long &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (unsigned long)(FrVal + t); }
void PUChar(unsigned char *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (unsigned char)(FrVal + t); }
void RUChar(unsigned char &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (unsigned char)(FrVal + t); }
void PChar(signed char *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (signed char)(FrVal + t); }
void RChar(signed char &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (signed char)(FrVal + t); }
void PBool(bool *REFERENCE, int t = 0)
{ ToVal = *REFERENCE; *REFERENCE = FrVal + t; }
{ ToVal = *REFERENCE; *REFERENCE = (FrVal + t) ? true : false; }
void RBool(bool &REFERENCE, int t = 0)
{ ToVal = REFERENCE; REFERENCE = FrVal + t; }
{ ToVal = REFERENCE; REFERENCE = (FrVal + t) ? true : false; }
%}

View file

@ -125,15 +125,16 @@ std::vector<std::string> vecStr(std::vector<std::string> v) {
%inline %{
int *makeIntPtr(int v) { return new int(v); }
const short *makeConstShortPtr(int v) { return new short(v); }
double *makeDoublePtr(double v) { return new double(v); }
int extractInt(int *p) { return *p; }
short extractConstShort(const short *p) { return *p; }
%}
%template(pyvector) std::vector<swig::SwigPtr_PyObject>;
namespace std {
%template(ConstShortVector) vector<const short *>;
// %template(ConstIntVector) vector<const int *>; // interferes with vector<int *>... see new testcase li_std_vector_ptr
%template(ConstShortPtrVector) vector<const short *>;
}
%inline %{

View file

@ -1,3 +1,4 @@
// Bug 2359417
%module li_std_vector_ptr
%include "std_vector.i"

View file

@ -2,12 +2,12 @@ require("import") -- the import fn
import("overload_template_fast") -- import code
for k,v in pairs(overload_template_fast) do _G[k]=v end -- move to global
-- lua has only one numeric type, so max(int,int) and max(double,double) are the same
-- lua has only one numeric type, so maximum(int,int) and maximum(double,double) are the same
-- whichever one was wrapper first will be used (which is int)
f = foo()
a = max(3,4)
a = maximum(3,4)
-- mix 1
assert(mix1("hi") == 101)

View file

@ -1,6 +1,6 @@
%module memberin_extend
// Tests memberin typemap. The default char * memberin typemap will be used.
// Tests memberin typemap is not used for %extend.
// The test extends the struct with a pseudo member variable
%inline %{
@ -12,8 +12,19 @@ struct ExtendMe {
%{
#include <map>
std::map<ExtendMe*, char *> ExtendMeStringMap;
#define ExtendMe_thing_set(self_, val_) ExtendMeStringMap[self_]
#define ExtendMe_thing_get(self_) ExtendMeStringMap[self_]
void ExtendMe_thing_set(ExtendMe *self, const char *val) {
char *old_val = ExtendMeStringMap[self];
delete [] old_val;
if (val) {
ExtendMeStringMap[self] = new char[strlen(val)+1];
strcpy(ExtendMeStringMap[self], val);
} else {
ExtendMeStringMap[self] = 0;
}
}
char * ExtendMe_thing_get(ExtendMe *self) {
return ExtendMeStringMap[self];
}
%}
%extend ExtendMe {

View file

@ -0,0 +1,38 @@
%module memberin_extend_c
/* Example from the Manual, section 5.5.6: "Adding member functions to C structures" */
%{
typedef struct {
char name[50];
} Person;
%}
typedef struct {
%extend {
char name[50];
}
} Person;
%{
#include <ctype.h>
#include <string.h>
void make_upper(char *name) {
char *c;
for (c = name; *c; ++c)
*c = (char)toupper((int)*c);
}
/* Specific implementation of set/get functions forcing capitalization */
char *Person_name_get(Person *p) {
make_upper(p->name);
return p->name;
}
void Person_name_set(Person *p, char *val) {
strncpy(p->name,val,50);
make_upper(p->name);
}
%}

View file

@ -1,5 +1,7 @@
%module namespace_class
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola;
%inline %{
template<class T> void foobar(T t) {}
namespace test {
@ -210,7 +212,6 @@ namespace a
%}
#pragma SWIG nowarn=SWIGWARN_PARSE_NESTED_CLASS
// %copyctor doesn't work with nested class workaround
%nocopyctor;

View file

@ -1,4 +1,7 @@
%module namespace_union
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
%inline %{
namespace SpatialIndex
{

View file

@ -12,6 +12,27 @@ struct TestStruct {
int a;
};
struct OuterStructNamed {
struct InnerStructNamed {
double dd;
} inner_struct_named;
union InnerUnionNamed {
double ee;
int ff;
} inner_union_named;
};
struct OuterStructUnnamed {
struct {
double xx;
} inner_struct_unnamed;
union {
double yy;
int zz;
} inner_union_unnamed;
};
typedef struct OuterStruct {
union {

View file

@ -0,0 +1,206 @@
%module nested_class
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass2;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct2;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion2;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass4Typedef;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct4Typedef;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion4Typedef;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass5;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct5;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerUnion5;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultiple;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleDerived;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleAnonTypedef1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerMultipleNamedTypedef;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerSameName;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer2::IgnoreMe;
%inline %{
struct Outer {
typedef int Integer;
///////////////////////////////////////////
struct InnerStruct1 {
Integer x;
};
class InnerClass1 {
public:
Integer x;
};
union InnerUnion1 {
Integer x;
double y;
};
///////////////////////////////////////////
class {
public:
Integer a;
};
struct {
Integer b;
};
union {
Integer c;
double d;
};
///////////////////////////////////////////
class InnerClass2 {
public:
Integer x;
} InnerClass2Instance;
struct InnerStruct2 {
Integer x;
} InnerStruct2Instance;
union InnerUnion2 {
Integer x;
double y;
} InnerUnion2Instance;
///////////////////////////////////////////
class {
public:
Integer x;
} InnerClass3Instance;
struct {
Integer x;
} InnerStruct3Instance;
union {
Integer x;
double y;
} InnerUnion3Instance;
///////////////////////////////////////////
typedef class {
public:
Integer x;
} InnerClass4Typedef;
typedef struct {
Integer x;
} InnerStruct4Typedef;
typedef union {
Integer x;
double y;
} InnerUnion4Typedef;
///////////////////////////////////////////
typedef class InnerClass5 {
public:
Integer x;
} InnerClass5Typedef;
typedef struct InnerStruct5 {
Integer x;
} InnerStruct5Typedef;
typedef union InnerUnion5 {
Integer x;
double y;
} InnerUnion5Typedef;
// bug #909387 - inner declared types are treated as forward declarations
InnerStruct1* makeInnerStruct1() { return 0; }
InnerClass1* makeInnerClass1() { return 0; }
InnerUnion1* makeInnerUnion1() { return 0; }
InnerStruct2* makeInnerStruct2() { return 0; }
InnerClass2* makeInnerClass2() { return 0; }
InnerUnion2* makeInnerUnion2() { return 0; }
InnerStruct4Typedef* makeInnerStruct4Typedef() { return 0; }
InnerClass4Typedef* makeInnerClass4Typedef() { return 0; }
InnerUnion4Typedef* makeInnerUnion4Typedef() { return 0; }
InnerStruct5* makeInnerStruct5() { return 0; }
InnerClass5* makeInnerClass5() { return 0; }
InnerUnion5* makeInnerUnion5() { return 0; }
InnerStruct5Typedef* makeInnerStruct5Typedef() { return 0; }
InnerClass5Typedef* makeInnerClass5Typedef() { return 0; }
InnerUnion5Typedef* makeInnerUnion5Typedef() { return 0; }
///////////////////////////////////////////
struct InnerMultiple {
Integer x;
} MultipleInstance1, MultipleInstance2, *MultipleInstance3, MultipleInstance4[2];
struct InnerMultipleDerived : public InnerMultiple {
Integer xx;
} MultipleDerivedInstance1, MultipleDerivedInstance2, *MultipleDerivedInstance3, MultipleDerivedInstance4[2];
struct {
Integer x;
} MultipleInstanceAnon1, MultipleInstanceAnon2, *MultipleInstanceAnon3, MultipleInstanceAnon4[2];
struct : public InnerMultiple {
Integer xx;
} MultipleInstanceAnonDerived1, MultipleInstanceAnonDerived2, *MultipleInstanceAnonDerived3, MultipleInstanceAnonDerived4[2];
struct : public InnerMultiple {
Integer xx;
};
class : public InnerMultiple {
public:
Integer yy;
};
///////////////////////////////////////////
typedef struct {
Integer x;
} InnerMultipleAnonTypedef1, InnerMultipleAnonTypedef2, *InnerMultipleAnonTypedef3;
InnerMultipleAnonTypedef1* makeInnerMultipleAnonTypedef1() { return 0; }
InnerMultipleAnonTypedef2* makeInnerMultipleAnonTypedef2() { return 0; }
InnerMultipleAnonTypedef3* makeInnerMultipleAnonTypedef3() { return 0; }
typedef struct InnerMultipleNamedTypedef {
Integer x;
} InnerMultipleNamedTypedef1, InnerMultipleNamedTypedef2, *InnerMultipleNamedTypedef3;
InnerMultipleNamedTypedef* makeInnerMultipleNamedTypedef() { return 0; }
InnerMultipleNamedTypedef1* makeInnerMultipleNamedTypedef1() { return 0; }
InnerMultipleNamedTypedef2* makeInnerMultipleNamedTypedef2() { return 0; }
InnerMultipleNamedTypedef3* makeInnerMultipleNamedTypedef3() { return 0; }
///////////////////////////////////////////
typedef struct InnerSameName {
Integer x;
} InnerSameName;
InnerSameName* makeInnerSameName() { return 0; }
};
%}
// Ignore nested struct instance
%ignore Outer2::IgnoreMeInstance;
%{
struct Outer2 {
struct IgnoreMe {
int xx;
};
};
%}
struct Outer2 {
struct IgnoreMe {
int xx;
} IgnoreMeInstance;
};

View file

@ -1,23 +1,25 @@
%module nested_comment
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
// this example shows a problem with 'dump_nested' (parser.y).
// bug #949654
%inline %{
typedef struct s1 {
union {
int fsc; /* genie structure hiding - Conductor
*/
int fso; /* genie structure hiding - FSOptions
*/
struct {
double *vals;
int size;
} vector_val; /* matrix values are mainly used
in rlgc models */
char *name;
} n ;
} s2;
typedef struct s1 {
union {
int fsc; /* genie structure hiding - Conductor
*/
int fso; /* genie structure hiding - FSOptions
*/
struct {
double *vals;
int size;
} vector_val; /* matrix values are mainly used
in rlgc models */
char *name;
} n ;
} s2;
%}
// comment in nested struct

View file

@ -2,21 +2,26 @@
// bug #491476
%inline %{
struct {
struct {
int a;
} a, b;
} a;
struct Outer {
struct {
int val;
} inner1, inner2, *inner3, inner4[1];
struct Named {
int val;
} inside1, inside2, *inside3, inside4[1];
} outer;
%}
// bug #909387
%inline %{
struct foo {
struct happy; // no warning
struct sad { int x; }; // warning
happy *good(); // produces good code
sad *bad(); // produces bad code
};
void setValues(struct Outer *outer, int val) {
outer->inner1.val = val;
outer->inner2.val = val * 2;
outer->inner3 = &outer->inner2;
outer->inner4[0].val = val * 4;
val = val * 10;
outer->inside1.val = val;
outer->inside2.val = val * 2;
outer->inside3 = &outer->inside2;
outer->inside4[0].val = val * 4;
}
%}

View file

@ -0,0 +1,38 @@
%module nested_workaround
// Similar to "Nested classes" documentation example.
class Inner {
int val;
public:
Inner(int v = 0) : val(v) {}
void setValue(int v) { val = v; }
int getValue() const { return val; }
};
%nestedworkaround Outer::Inner;
%inline %{
class Outer {
public:
class Inner {
int val;
public:
Inner(int v = 0) : val(v) {}
void setValue(int v) { val = v; }
int getValue() const { return val; }
};
Inner createInner(int v) const { return Inner(v); }
int getInnerValue(const Inner& i) const { return i.getValue(); }
Inner doubleInnerValue(Inner inner) {
inner.setValue(inner.getValue() * 2);
return inner;
}
};
%}
// We've fooled SWIG into thinking that Inner is a global class, so now we need
// to trick the C++ compiler into understanding this apparent global type.
%{
typedef Outer::Inner Inner;
%}

View file

@ -17,7 +17,6 @@ CPP_TEST_CASES += \
CPP_TEST_BROKEN += \
implicittest \
li_implicit \
li_std_map \
li_std_set \
li_std_stream

View file

@ -5,3 +5,19 @@ enums.bar2(1)
enums.bar3(1)
enums.bar1(1)
if (enums.cvar.enumInstance != 2)
error
endif
if (enums.cvar.Slap != 10)
error
endif
if (enums.cvar.My != 11)
error
endif
if (enums.cvar.Thigh != 12)
error
endif

View file

@ -5,8 +5,8 @@ overload_template_fast
f = foo();
a = max(3,4);
b = max(3.4,5.2);
a = maximum(3,4);
b = maximum(3.4,5.2);
# mix 1
if (mix1("hi") != 101)

View file

@ -5,7 +5,7 @@ require "arrays_global.php";
check::functions(array(test_a,test_b,new_simplestruct,new_material));
check::classes(array(arrays_global,SimpleStruct,Material));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,beginstring_fix44a,beginstring_fix44b,beginstring_fix44c,beginstring_fix44d,beginstring_fix44e,beginstring_fix44f,chitmat,hitmat_val,hitmat,simplestruct_double_field));
// The size of array_c is 2, but the last byte is \0, so we can only store a
// single byte string in it.
check::set(array_c,"Z");

View file

@ -5,7 +5,7 @@ require "arrays_global_twodim.php";
check::functions(array(fn_taking_arrays,get_2d_array,new_simplestruct,new_material));
check::classes(array(arrays_global_twodim,SimpleStruct,Material));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,chitmat,hitmat_val,hitmat));
check::globals(array(array_c,array_sc,array_uc,array_s,array_us,array_i,array_ui,array_l,array_ul,array_ll,array_f,array_d,array_struct,array_structpointers,array_ipointers,array_enum,array_enumpointers,array_const_i,chitmat,hitmat_val,hitmat,simplestruct_double_field));
$a1=array(10,11,12,13);
$a2=array(14,15,16,17);
$a=array($a1,$a2);

View file

@ -4,15 +4,14 @@ require "arrays.php";
check::functions(array(fn_taking_arrays,newintpointer,setintfrompointer,getintfrompointer,array_pointer_func));
check::classes(array(arrays,SimpleStruct,ArrayStruct,CartPoseData_t));
// No new vars
check::globals(array());
check::globals(array(simplestruct_double_field,arraystruct_array_c,arraystruct_array_sc,arraystruct_array_uc,arraystruct_array_s,arraystruct_array_us,arraystruct_array_i,arraystruct_array_ui,arraystruct_array_l,arraystruct_array_ul,arraystruct_array_ll,arraystruct_array_f,arraystruct_array_d,arraystruct_array_struct,arraystruct_array_structpointers,arraystruct_array_ipointers,arraystruct_array_enum,arraystruct_array_enumpointers,arraystruct_array_const_i,cartposedata_t_p));
$ss=new simplestruct();
check::classname(simplestruct,$ss);
$as=new arraystruct();
$as->array_c="abc";
check::equal($as->array_c,"ab",'$as->array_c=="ab"');
check::equal($as->array_c,"a",'$as->array_c=="a"');
check::done();
?>

View file

@ -3,12 +3,12 @@
require "tests.php";
require "arrays_scope.php";
// No new functions
// New functions
check::functions(array(new_bar,bar_blah));
// No new classes
// New classes
check::classes(array(arrays_scope,Bar));
// now new vars
check::globals(array());
// New vars
check::globals(array(bar_adata,bar_bdata,bar_cdata));
$bar=new bar();

View file

@ -3,12 +3,12 @@
require "tests.php";
require "cpp_static.php";
// No new functions
check::functions(array());
// No new classes
// New functions
check::functions(array(staticfunctiontest_static_func,staticfunctiontest_static_func_2,staticfunctiontest_static_func_3));
// New classes
check::classes(array(StaticMemberTest,StaticFunctionTest));
// now new vars
check::globals(array());
// New vars
check::globals(array(staticmembertest_static_int));
check::done();
?>

View file

@ -11,11 +11,6 @@ check::classes(array(SpObject));
check::globals(array());
class MyObject extends SpObject{
function __construct() {
parent::__construct();
return;
}
function getFoo() {
return 123;
}

View file

@ -3,7 +3,7 @@ require "tests.php";
require "enum_scope_template.php";
check::classes(array("enum_scope_template", "TreeInt"));
check::functions("chops");
check::functions(array("chops","treeint_chops"));
check::equal(0,TreeInt_Oak,"0==TreeInt_Oak");
check::equal(1,TreeInt_Fir,"1==TreeInt_Fir");
check::equal(2,TreeInt_Cedar,"2==TreeInt_Cedar");

View file

@ -3,11 +3,11 @@
require "tests.php";
require "ignore_parameter.php";
// No new functions
check::functions(array(jaguar,lotus,tvr,ferrari));
// No new classes
check::classes(array(sportscars,minicooper,morrisminor,fordanglia,austinallegro));
// now new vars
// New functions
check::functions(array(jaguar,lotus,tvr,ferrari,sportscars_daimler,sportscars_astonmartin,sportscars_bugatti,sportscars_lamborghini));
// New classes
check::classes(array(ignore_parameter,SportsCars,MiniCooper,MorrisMinor,FordAnglia,AustinAllegro));
// No new vars
check::globals(array());
check::equal(jaguar(2,3.4),"hello",'jaguar(2,3.4)=="hello"');

View file

@ -3,14 +3,14 @@ require "tests.php";
require "li_carrays.php";
// Check functions.
check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem));
check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem));
// Check classes.
// NB An "li_carrays" class is created as a mock namespace.
check::classes(array(li_carrays,doubleArray,AB,XY,XYArray));
// No new global variables.
check::globals(array());
// Check global variables.
check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray));
$d = new doubleArray(10);

View file

@ -17,9 +17,9 @@ check::equal(ref_bool(true), true, "ref_bool failed");
check::equal(ref_float(3.5), 3.5, "ref_float failed");
check::equal(ref_double(3.5), 3.5, "ref_double failed");
check::equal(ref_char('x'), 'x', "ref_char failed");
//check::equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
//check::equal(ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
printf("TODO: long long and unsigned long long const reference typemaps\n");
check::equal(ref_longlong(0x123456789ABCDEF0), 0x123456789ABCDEF0, "ref_longlong failed");
# 0xF23456789ABCDEF0 won't fit in a long, so PHP makes it a double, but SWIG opts to return it as a string.
check::equal((double)ref_ulonglong(0xF23456789ABCDEF0), 0xF23456789ABCDEF0, "ref_ulonglong failed");
check::done();
?>

View file

@ -2,19 +2,25 @@
#ifdef SWIGPHP
%warnfilter(SWIGWARN_PARSE_KEYWORD) Empty();
// FIXME: this doesn't work for me:
%warnfilter(SWIGWARN_PARSE_KEYWORD) stdClass;
%warnfilter(SWIGWARN_PARSE_KEYWORD) directory;
%warnfilter(SWIGWARN_PARSE_KEYWORD) Hello::empty();
#endif
%inline %{
int Exception() { return 13; }
void Empty() {}
class stdClass
{
};
class directory
{
};
struct Hello
{
void empty() {}

View file

@ -0,0 +1,82 @@
%module preproc_constants
// Note: C types are slightly different to C++ types as (a && b) is int in C and bool in C++
// Simple constants
#define CONST_INT1 10
#define CONST_INT2 0xFF
#define CONST_UINT1 10u
#define CONST_UINT2 10U
#define CONST_UINT3 0xFFu
#define CONST_UINT4 0xFFU
#define CONST_LONG1 10l
#define CONST_LONG2 10L
#define CONST_LONG3 0xFFl
#define CONST_LONG4 0xFFL
#define CONST_LLONG1 10LL
#define CONST_LLONG2 10ll
#define CONST_LLONG3 0xFFll
#define CONST_LLONG4 0xFFLL
#define CONST_ULLONG1 10ull
#define CONST_ULLONG2 10ULL
#define CONST_ULLONG3 0xFFull
#define CONST_ULLONG4 0xFFULL
#define CONST_DOUBLE1 10e1
#define CONST_DOUBLE2 10E1
#define CONST_DOUBLE3 12.3
#define CONST_DOUBLE4 12.
#define CONST_DOUBLE5 12.3f
#define CONST_DOUBLE6 12.3F
#define CONST_BOOL1 true
#define CONST_BOOL2 false
#define CONST_CHAR 'x'
#define CONST_STRING1 "const string"
#define CONST_STRING2 "const" " string"
// Expressions - runtime tests check the type for any necessary type promotions of the expressions
#define INT_AND_BOOL 0xFF & true
//#define INT_AND_CHAR 0xFF & 'A' /* FIXME compile error */
#define INT_AND_INT 0xFF & 2
#define INT_AND_UINT 0xFF & 2u
#define INT_AND_LONG 0xFF & 2l
#define INT_AND_ULONG 0xFF & 2ul
#define INT_AND_LLONG 0xFF & 2ll
#define INT_AND_ULLONG 0xFF & 2ull
#define BOOL_AND_BOOL true & true // Note integral promotion to type int
//#define CHAR_AND_CHAR 'A' & 'B' // Note integral promotion to type int
/* FIXME ABOVE */
#define EXPR_MULTIPLY 0xFF * 2
#define EXPR_DIVIDE 0xFF / 2
//FIXME #define EXPR_MOD 0xFF % 2
#define EXPR_PLUS 0xFF + 2
#define EXPR_MINUS 0xFF + 2
#define EXPR_LSHIFT 0xFF << 2
#define EXPR_RSHIFT 0xFF >> 2
/* FIXME
#define EXPR_LT 0xFF < 255
#define EXPR_GT 0xFF > 255
*/
#define EXPR_LTE 0xFF <= 255
#define EXPR_GTE 0xFF >= 255
#define EXPR_INEQUALITY 0xFF != 255
#define EXPR_EQUALITY 0xFF == 255
#define EXPR_AND 0xFF & 1
#define EXPR_XOR 0xFF ^ 1
#define EXPR_OR 0xFF | 1
#define EXPR_LAND 0xFF && 1
#define EXPR_LOR 0xFF || 1
#define EXPR_CONDITIONAL true ? 2 : 2.2

View file

@ -0,0 +1,6 @@
%module preproc_constants_c
%define true 1 %enddef
%define false 0 %enddef
%include "preproc_constants.i"

View file

@ -49,7 +49,6 @@ CPP_TEST_CASES += \
li_implicit \
li_std_vectora \
li_std_vector_extra \
li_std_map \
li_std_multimap \
li_std_pair_extra \
li_std_set \

View file

@ -43,7 +43,7 @@ b = launder(a)
try:
b.pong()
except TypeError, e:
if str(e) == "Swig director type mismatch in output value of type 'std::string'":
if str(e) == "SWIG director type mismatch in output value of type 'std::string'":
ok = 1
else:
print "Unexpected error message: %s" % str(e)

View file

@ -5,3 +5,15 @@ _enums.bar2(1)
_enums.bar3(1)
_enums.bar1(1)
if _enums.cvar.enumInstance != 2:
raise RuntimeError
if _enums.cvar.Slap != 10:
raise RuntimeError
if _enums.cvar.My != 11:
raise RuntimeError
if _enums.cvar.Thigh != 12:
raise RuntimeError

View file

@ -0,0 +1,4 @@
import extern_c
extern_c.RealFunction(2)

View file

@ -0,0 +1,10 @@
from li_cdata import *
s = "ABC abc"
m = malloc(256)
memmove(m, s)
ss = cdata(m, 7)
if ss != "ABC abc":
raise "failed"

View file

@ -154,3 +154,23 @@ if extractInt(vi[0]) != 11:
if extractInt(vi[1]) != 22:
raise RuntimeError
# vector const pointer checks
csp = makeConstShortPtr(111)
error = 0
try:
vcs = ConstShortPtrVector((csp, dp)) # check vector<const unsigned short *> does not accept double * element
error = 1
except:
pass
if error:
raise RuntimeError
vcs = ConstShortPtrVector((csp, makeConstShortPtr(222)))
if extractConstShort(vcs[0]) != 111:
raise RuntimeError
if extractConstShort(vcs[1]) != 222:
raise RuntimeError

View file

@ -0,0 +1,6 @@
import memberin_extend_c
t = memberin_extend_c.Person()
t.name = "Fred Bloggs"
if t.name != "FRED BLOGGS":
raise RuntimeError("name wrong")

View file

@ -0,0 +1,13 @@
from nested_workaround import *
inner = Inner(5)
outer = Outer()
newInner = outer.doubleInnerValue(inner)
if newInner.getValue() != 10:
raise RuntimeError
outer = Outer()
inner = outer.createInner(3)
newInner = outer.doubleInnerValue(inner)
if outer.getInnerValue(newInner) != 6:
raise RuntimeError

View file

@ -1,8 +1,8 @@
from overload_template_fast import *
f = foo()
a = max(3,4)
b = max(3.4,5.2)
a = maximum(3,4)
b = maximum(3.4,5.2)
# mix 1
if (mix1("hi") != 101):

Some files were not shown because too many files have changed in this diff Show more