diff --git a/ANNOUNCE b/ANNOUNCE
index cdf246e07..1a13e074f 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 2.0.2 (in progress) ***
+*** ANNOUNCE: SWIG 2.0.4 (29 March 2011) ***
http://www.swig.org
-We're pleased to announce SWIG-2.0.1, the latest SWIG release.
+We're pleased to announce SWIG-2.0.4, the latest SWIG release.
What is SWIG?
=============
@@ -10,22 +10,22 @@ What is SWIG?
SWIG is a software development tool that reads C/C++ header files and
generates the wrapper code needed to make C and C++ code accessible
from other languages including Perl, Python, Tcl, Ruby, PHP, Java,
-Scheme (Guile, MzScheme, CHICKEN), Ocaml, Lua, Pike, C#, Modula-3, Octave, R,
-Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also export its parse
-tree in the form of XML and Lisp s-expressions. Major applications of
-SWIG include generation of scripting language extension modules, rapid
-prototyping, testing, and user interface development for large C/C++
-systems.
+Scheme (Guile, MzScheme, CHICKEN), D, Ocaml, Lua, Pike, C#, Modula-3,
+Octave, R, Common Lisp (CLISP, Allegro CL, CFFI, UFFI). SWIG can also
+export its parse tree in the form of XML and Lisp s-expressions. Major
+applications of SWIG include generation of scripting language extension
+modules, rapid prototyping, testing, and user interface development for
+large C/C++ systems.
Availability
============
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-2.0.1.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-2.0.4.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-2.0.1.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-2.0.4.zip
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CHANGES b/CHANGES
index bf5e20da1..7e930159e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,241 @@ SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
+Version 2.0.3 (29 March 2011)
+=============================
+
+2011-03-29: wsfulton
+ [R] Apply patch #3239076 from Marie White fixing strings for R >= 2.7.0
+
+2011-03-29: wsfulton
+ [Tcl] Apply patch #3248280 from Christian Delbaere which adds better error messages when
+ the incorrect number or type of arguments are passed to overloaded methods.
+
+2011-03-29: wsfulton
+ [Tcl] Apply patch #3224663 from Christian Delbaere.
+ 1. Fix when function returns a NULL value, a "NULL" command will be created in the Tcl interpreter
+ and calling this command will cause a segmentation fault.
+
+ 2. Previous implementation searches for class methods using a linear search causing performance issues
+ in wrappers for classes with many member functions. The patch adds a method hash table to classes and
+ changes method name lookup to use the hash table instead of doing a linear search.
+
+2011-03-26: wsfulton
+ [C#, Java] SF bug #3195112 - fix wrapping of enums that are type char, for example:
+ enum { X = 'X'; }
+
+2011-03-21: vadz
+ Allow setting PCRE_CFLAGS and PCRE_LIBS during configuration to override the values returned by
+ pcre-config, e.g. to allow using a static version of PCRE library.
+
+2011-03-17: wsfulton
+ [UTL] Add missing headers in generated STL wrappers to fix compilation with gcc-4.6.
+
+2011-03-17: wsfulton
+ Fix regression introduced in swig-2.0.2 where filenames with spaces were not found
+ when used with %include and %import. Reported by Shane Liesegang.
+
+2011-03-15: wsfulton
+ [UTL] Fix overloading when using const char[], problem reported by David Maxwell.
+ Similarly for char[ANY] and const char[ANY].
+
+2011-03-15: wsfulton
+ [C#] Apply patch #3212624 fixing std::map Keys property.
+
+2011-03-14: olly
+ [PHP] Fix handling of overloaded methods/functions where some
+ return void and others don't - whether this worked or not depended
+ on the order they were encountered in (SF#3208299).
+
+2011-03-13: klickverbot
+ [D] Extended support for C++ namespaces (nspace feature).
+
+2011-03-12: olly
+ [PHP] Fix sharing of type information between multiple SWIG-wrapped
+ modules (SF#3202463).
+
+2011-03-09: wsfulton
+ [Python] Fix SF #3194294 - corner case bug when 'NULL' is used as the default value
+ for a primitive type parameter in a method declaration.
+
+2011-03-07: olly
+ [PHP] Don't use zend_error_noreturn() for cases where the function
+ returns void - now this issue can only matter if you have a function
+ or method which is directed and returns non-void.
+
+2011-03-06: olly
+ [PHP] Add casts to the typemaps for long long and unsigned long
+ long to avoid issues when they are used with shorter types via
+ %apply.
+
+2011-03-02: wsfulton
+ Templated smart pointers overloaded with both const and non const operator-> generated uncompilable
+ code when the pointee was a class with either public member variables or static methods.
+ Regression in 2.0.x reported as working in 1.3.40 by xantares on swig-user mailing list.
+
+Version 2.0.2 (20 February 2011)
+================================
+
+2011-02-19: wsfulton
+ [PHP] Add missing INPUT, OUTPUT and INOUT typemaps in the typemaps.i library
+ for primitive reference types as well as signed char * and bool *.
+
+2011-02-19: olly
+ [PHP] Address bug in PHP on some platforms/architectures which
+ results in zend_error_noreturn() not being available using
+ SWIG_ZEND_ERROR_NORETURN which defaults to zend_error_noreturn but
+ can be overridden when building the module by passing
+ -DSWIG_ZEND_ERROR_NORETURN=zend_error to the compiler. This may
+ result in compiler warnings, but should at least allow a module
+ to be built on those platforms/architectures (SF#3166423).
+
+2011-02-18: wsfulton
+ Fix #3184549 - vararg functions and function overloading when using the -fastdispatch option.
+
+2011-02-18: olly
+ [PHP] An overloaded method which can return an object or a
+ primitive type no longer causes SWIG to segfault. Reported by Paul
+ Colby in SF#3168531.
+
+2011-02-18: olly
+ [PHP] Fix invalid erase during iteration of std::map in generated
+ director code. Reported by Cory Bennett in SF#3175820.
+
+2011-02-17: wsfulton
+ Preprocessing now warns if extra tokens appear after #else and #end.
+
+2011-02-16: wsfulton
+ Fix #1653092 Preprocessor does not error out when #elif is missing an expression.
+ This and other cases of missing preprocessor expressions now result in an error.
+
+2011-02-14: wsfulton
+ [Ocaml] Apply patch #3151788 from Joel Reymont. Brings Ocaml support up to date
+ (ver 3.11 and 3.12), including std::string.
+
+2011-02-13: wsfulton
+ [Ruby] Apply patch #3176274 from James Masters - typecheck typemap for time_t.
+
+2011-02-13: wsfulton
+ Apply patch #3171793 from szager - protected director methods failing when -fvirtual is used.
+
+2011-02-13: wsfulton
+ Fix #1927852 - #include directives don't preprocess the file passed to it. The fix is for
+ #include with -importall or -includeall, %include and %import, for example:
+ #define FILENAME "abc.h"
+ %include FILENAME
+
+2011-02-12: wsfulton
+ Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif
+ preprocessor directives.
+
+2011-02-05: wsfulton
+ [MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme.
+ Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket.
+
+2011-02-05: wsfulton
+ [C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
+
+2011-02-05: wsfulton
+ SF #3173367 Better information during configure about Boost prerequisite for running
+ the test-suite.
+
+2011-02-05: wsfulton
+ SF #3127633 Fix infinite loop in recursive typedef resolution.
+
+2011-02-04: wsfulton
+ [R] SF #3168676 Fix %rename not working for member variables and methods.
+
+2011-02-04: wsfulton
+ [clisp] SF #3148200 Fix segfault parsing nested unions.
+
+2011-02-01: wsfulton
+ [C#] Directors - a call to a method being defined in the base class, not
+ overridden in a subclass, but again overridden in a class derived from
+ the first subclass was not being dispatched correctly to the most derived class.
+ See director_alternating.i for an example.
+
+2011-02-01: wsfulton
+ [C#, Java] Any 'using' statements in the protected section of a class were previously
+ ignored with director protected (dirprot) mode.
+
+2011-01-30: wsfulton
+ Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
+ number of scripting languages.
+
+2011-01-17: wsfulton
+ New warning for smart pointers if only some of the classes in the inheritance
+ chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
+ in an inheritance hierarchy, so this new warning highlights code where this is
+ not the case.
+
+ example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
+ example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
+
+2011-01-14: wsfulton
+ Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
+ (char *STRING, int LENGTH). Documentation for this updated. Java patch from
+ Volker Grabsch.
+
+2011-01-11: iant
+ Require Go version 7077 or later.
+
+2010-12-30: klickverbot
+ [C#, D, Java] Check for collision of parameter names with target
+ language keywords when generating the director glue code.
+
+ The situation in which the generated could would previously be
+ invalid is illustrated in the new 'director_keywords' test case.
+
+2010-12-23: wsfulton
+ [C#] Fix $csinput special variable not being expanded for csvarin typemaps
+ when used for global variables. Reported by Vadim Zeitlin.
+
+2010-12-14: wsfulton
+ Fix $basemangle expansion in array typemaps. For example if type is int *[3],
+ $basemangle expands to _p_int.
+
+2010-12-07: iant
+ Check that we are using a sufficiently new version of the
+ 6g or 8g Go compiler during configure time. If not, disable Go.
+ Minimum version is now 6707.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2010-12-06: wsfulton
+ Fix #3127394 - use of network paths on Windows/MSys.
+
+2010-11-18: klickverbot
+ [D] Added the D language module.
+
+2010-11-12: vadz
+ Fix handling of multiple regex-using %renames attached to the same
+ declaration. For example, now
+
+ %rename("%(regex/^Set(.*)/put\\1/)s") "";
+ %rename("%(regex/^Get(.*)/get\\1/)s") "";
+
+ works as expected whereas before only the last anonymous rename was
+ taken into account.
+
+2010-10-17: drjoe
+ [R] Fix failure in overloaded functions which was breaking
+ QuantLib-SWIG
+
+2010-10-14: olly
+ [PHP] Allow compilation on non-conforming Microsoft C++ compilers
+ which don't accept: return function_returning_void();
+ Reported by Frank Vanden Berghen on the SWIG mailing list.
+
+2010-10-12: wsfulton
+ Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
+ Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
+ incorrectly treated as opaque types.
+
+ Also fixes #2958781 and some other type problems due to better typedef resolution, eg
+ std::vector::value_type didn't resolve to T * when it should have. The mangled type
+ was incorrectly SWIGTYPE_std__vectorT_Test_p_std__allocatorT_Test_p_t_t__value_type and now
+ it is correctly SWIGTYPE_p_Test.
+
Version 2.0.1 (4 October 2010)
==============================
diff --git a/CHANGES.current b/CHANGES.current
index a5f149421..f928203d8 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,19 +2,80 @@ This file contains the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
-Version 2.0.2 (in progress)
+Version 2.0.4 (in progress)
===========================
+2011-05-05: wsfulton
+ [Lua, Python, Tcl] C/C++ prototypes shown in error message when calling an overloaded
+ method with incorrect arguments improved to show always show fully qualified name
+ and if a const method.
-2010-10-14: olly
- [PHP] Allow compilation on non-conforming Microsoft C++ compilers
- which don't accept: return function_returning_void();
- Reported by Frank Vanden Berghen on the SWIG mailing list.
+ Also fixed other Lua error messages in generated code which weren't consistently
+ using the fully qualified C++ name - requested by Gedalia Pasternak.
-2010-10-12: wsfulton
- Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
- Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
- incorrectly treated as opaque types.
+2011-04-29: szager
+ Bug 2635919: Convenience method to convert std::map to a python dict.
-2010-10-14: Sylvestre Ledru
- Fails the configure if cannot find a yacc implementation
- (like bison)
+2011-04-29: szager
+ Fixed bug 2811549: return non-const iterators from STL
+ methods begin(), end(), rbegin(), rend().
+
+2011-04-25: szager
+ Fixed bug 1498929: Access to member fields in map elements
+
+2011-04-23: klickverbot
+ [D] nspace: Correctly generate identifiers for base classes when
+ not in split proxy mode.
+
+2011-04-13: szager
+ Fixed bug 3286333: infite recursion with mutual 'using namespace' clauses.
+
+2011-04-12: szager
+ Fixed bug 1163440: vararg typemaps.
+
+2011-04-12: szager
+ Fixed bug #3285386: parse error from 'operator T*&()'. Added operator_pointer_ref
+ test case to demonstrate.
+
+2011-04-11: szager
+ Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about
+ static initialization of struct members with pointers.
+
+2011-04-11: wsfulton
+ [Tcl] Apply patch #3284326 from Colin McDonald to fix some compiler warnings.
+
+2011-04-11: szager
+ Fixed PyVarObject_HEAD_INIT to eliminate VC++ compiler errors about
+ static initialization of struct members with pointers.
+
+2011-04-10: klickverbot
+ [D] Fixed wrapping of enums that are type char, for example:
+ enum { X = 'X'; } (this was already in 2.0.3 for C# and Java)
+
+2011-04-10: klickverbot
+ [D] nspace: Fixed referencing types in the root namespace when
+ not in split proxy mode.
+
+2011-04-09: szager
+ Applied patch #1932484: migrate PyCObject to PyCapsule.
+
+2011-04-09: szager
+ Added preprocessor guards for python functions PyUnicode_AsWideChar and
+ PySlice_GetIndices, which changed signatures in python3.2.
+
+2011-04-07: wsfulton
+ Fix wrapping of const array typedefs which were generating uncompileable code as
+ reported by Karl Wette.
+
+2011-04-03: szager
+ Fixed the behavior of %pythonnondynamic to conform to the spec in Lib/pyuserdir.swg.
+
+2011-04-03: szager
+ Merged in the szager-python-builtin branch, adding the -builtin feature
+ for python. The -builtin option may provide a significant performance gain
+ in python wrappers. For full details and limitations, refer to Doc/Manual/Python.html.
+ A small test suite designed to demonstrate the performance gain is in
+ Examples/python/performance.
+
+2011-04-01: wsfulton
+ Add in missing wrappers for friend functions for some target languages, mostly
+ the non-scripting languages like Java and C#.
diff --git a/COPYRIGHT b/COPYRIGHT
index 4e801e53e..855425431 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -1,7 +1,7 @@
SWIG Copyright and Authors
--------------------------
-Copyright (c) 1995-2010 The SWIG Developers
+Copyright (c) 1995-2011 The SWIG Developers
Copyright (c) 2005-2006 Arizona Board of Regents (University of Arizona).
Copyright (c) 1998-2005 University of Chicago.
Copyright (c) 1995-1998 The University of Utah and the Regents of the University of California
@@ -15,6 +15,7 @@ Active SWIG Developers:
Olly Betts (olly@survex.com) (PHP)
Joseph Wang (joequant@gmail.com) (R)
Xavier Delacour (xavier.delacour@gmail.com) (Octave)
+ David Nadlinger (code@klickverbot.at) (D)
Past SWIG developers and major contributors include:
Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
@@ -58,6 +59,7 @@ Past SWIG developers and major contributors include:
Baozeng Ding (Scilab)
Ian Lance Taylor (Go)
Vadim Zeitlin (PCRE)
+ Stefan Zager (szager@gmail.com) (Python)
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
@@ -68,7 +70,7 @@ Past contributors include:
Past students:
Songyan Feng (Chicago).
- Xinghua Shi (Chicago).
+ Xinghua Shi (Chicago).
Jing Cao (Chicago).
Aquinas Hobor (Chicago).
@@ -98,5 +100,5 @@ Mike Weiblen, Paul Brannan, Ram Bhamidipaty, Reinhard Fobbe, Rich Wales,
Richard Salz, Roy Lecates, Rudy Albachten, Scott Drummonds
Scott Michel, Shaun Lowry, Steve Galser, Tarn Weisner Burton,
Thomas Weidner, Tony Seward, Uwe Steinmann, Vadim Chugunov, Wyss Clemens,
-Zhong Ren.
+Zhong Ren.
diff --git a/Doc/Devel/index.html b/Doc/Devel/index.html
index 55c612ec3..4ddc63a76 100644
--- a/Doc/Devel/index.html
+++ b/Doc/Devel/index.html
@@ -21,6 +21,7 @@ The following documentation describe the internal APIs used by SWIG. These may
SWIG Runtime.
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 909357f37..6691400b7 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -57,7 +57,7 @@ PInvoke is part of the ECMA/ISO C# specification.
It is also better suited for robust production environments due to the Managed C++ flaw called the
Mixed DLL Loading Problem.
SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
-Mono and Portable.NET.
+Mono and Portable.NET.
@@ -575,7 +575,8 @@ marshalling for the arrays:
[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy([In, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
- [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+ [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
+ int jarg3);
@@ -624,7 +625,8 @@ and intermediate class method
[DllImport("example", EntryPoint="CSharp_myArraySwap")]
public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
- [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+ [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
+ int jarg3);
@@ -696,7 +698,8 @@ As a result, we get the following method in the module class:
fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
fixed ( int *swig_ptrTo_targetArray = targetArray ) {
{
- examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray, nitems);
+ examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray,
+ nitems);
}
}
}
@@ -2109,7 +2112,8 @@ public class example {
try {
examplePINVOKE.addYears(CDate.getCPtr(temppDate), years);
} finally {
- pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
+ 0, 0, 0);
}
}
...
@@ -2126,13 +2130,13 @@ The subtractYears method is nearly identical to the above addYears<
%typemap(csin,
- pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
- post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
- " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- terminator=" } // terminate temp$csinput using block",
- cshin="ref $csinput"
- ) CDate *
- "$csclassname.getCPtr(temp$csinput)"
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
void subtractYears(CDate *pDate, int years) {
*pDate = CDate(pDate->getYear() - years, pDate->getMonth(), pDate->getDay());
@@ -2152,7 +2156,8 @@ public class example {
try {
examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
} finally {
- pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
+ 0, 0, 0);
}
} // terminate temppDate using block
}
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index f4fdb9d24..74a201bc6 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -5,7 +5,7 @@
SWIG Users Manual
-
From the D Programming Language web site: »D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.« As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?
+
+
Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to \0-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.
+
+
While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if extern(C++) has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases.
+
+
To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on C# (and also on Java, since the C# module was in turn forked from it).
+
+
+
20.2 Command line invocation
+
+
+
To activate the D module, pass the -d option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:
+
+
+
-d2
+
+
By default, SWIG generates code for D1/Tango. Use the -d2 flag to target D2/Phobos instead.
+
+
+
-splitproxy
+
+
By default, SWIG generates two D modules: the proxy module, named like the source module (either specified via the %module directive or via the module command line switch), which contains all the proxy classes, functions, enums, etc., and the intermediary module (named like the proxy module, but suffixed with _im), which contains all the extern(C) function declarations and other private parts only used internally by the proxy module.
+
If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.
+
+
+
-package <pkg>
+
+
By default, the proxy D modules and the intermediary D module are written to the root package. Using this option, you can specify another target package instead.
+
+
+
-wrapperlibrary <wl>
+
+
The code SWIG generates to dynamically load the C/C++ wrapper layer looks for a library called $module_wrap by default. With this switch, you can override the name of the file the wrapper code loads at runtime (the lib prefix and the suffix for shared libraries are appended automatically, depending on the OS).
+
This might especially be useful if you want to invoke SWIG several times on separate modules, but compile the resulting code into a single shared library.
+
+
+
+
+
20.3 Typemaps
+
+
+
20.3.1 C# <-> D name comparison
+
+
+
If you already know the SWIG C# module, you might find the following name comparison table useful:
Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.
+
+
The ctype typemap is used to determine the types to use in the C wrapper functions. The types from the imtype typemap are used in the extern(C) declarations of these functions in the intermediary D module. The dtype typemap contains the D types used in the D proxy module/class.
+
+
+
20.3.3 in, out, directorin, directorout
+
+
+
Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).
+
+
The code from the in typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (ctype->original C++ type), the out typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type->ctype).
+
+
The directorin typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by directorout (see below).
+
+
+
20.3.4 din, dout, ddirectorin, ddirectorout
+
+
+
Typemaps for code generation in D proxy and type wrapper classes.
+
+
The din typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the $dinput macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the pre, post and terminator attributes can be used (please refer to the C# date marshalling example for more information on these).
+
+
The dout typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The $excode special variable in dout typemaps is replaced by the excode typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the $imcall and $owner macros are replaced).
+
+
The code from the ddirectorin and ddirectorout typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from ddirectorin, the proxy class method return value is converted to the type the C++ code expects via the ddirectorout typemap (the $dcall and $winput macros are replaced).
+
+
The full chain of type conversions when a director callback is invoked looks like this:
+
+
+ type CPPClass::method(type a)
+ ↑ ↓
+ <directorout> <directorin>
+ ↑ ↓
+ ctype methodCallback(ctype a) C++
+ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ imtype methodCallback(imtype a) D
+ ↑ ↓
+ <ddirectorout> <ddirectorin>
+ ↑ ↓
+ dtype DClass.method(dtype a)
+
+
+
20.3.5 typecheck typemaps
+
+
+
Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).
+
+
+
20.3.6 Code injection typemaps
+
+
+
These typemaps are used for generating the skeleton of proxy classes for C++ types.
+
+
By overriding dbase, dinterfaces or dinterfaces_derived, the inheritance chain of the generated proxy class for a type can be modified. dclassmodifiers allows you to add any custom modifiers around the class keyword.
+
+
Using dcode and dimports, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.
+
+
dconstructor, ddestructor, ddispose and ddispose_derived are used to generate the class constructor, destructor and dispose() method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in dbody and dbody_derived. You can override them for specific types.
+
+
+
20.3.7 Special variable macros
+
+
+
The standard SWIG special variables are available for use within typemaps as described in the Typemaps documentation, for example $1, $input, $result etc.
+
+
When generating D wrappers, a few additional macros are available:
+
+
$dclassname (C#: $csclassname)
+
+
This special variable works similar to $n_type in that it returns the name of a type - it expands to the D proxy class name of the type being wrapped. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, SWIGTYPE_p_p_SomeCppClass is generated when wrapping SomeCppClass **.
+
There are two other variants available, $&dclassname and $*dclassname. The former adds a level of indirection, while the latter removes one. For instance, when wrapping Foo **, $*dclassname would be replaced by the proxy class name corresponding to Foo *.
+
+
+
$dclazzname (C#: $csclazzname)
+
+
This special variable expands the fully qualified C++ class into the package name, if used by the nspace feature, and the proxy class name, mangled for use as a function name. For example, Namespace1::Namespace2::Klass is expanded into Namespace1_Namespace2_Klass_.
+
This special variable might be useful for calling certain functions in the wrapper layer (e.g. upcast wrappers) which are mangled like this.
+
+
+
$null
+
In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either 0 or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (return $null;).
+
+
$dinput (C#: $csinput)
+
+
This variable is used in din typemaps and is replaced by the expression which is to be passed to C/C++.
These variables are used in dout typemaps. $imcall contains the call to the intermediary module which provides the value to be used, and $owner signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via %newobject).
The code generated for foo() and bar() looks like this:
+
+SomeClass foo() {
+ return new SomeClass(example_im.foo(), false);
+}
+
+SomeClass bar() {
+ return new SomeClass(example_im.bar(), true);
+}
+
+
+
+
$dcall and $winput (C#: $cscall, $iminput)
+
These variables are used in the director-specific typemaps ddirectorin and ddirectorout. They are more or less the reverse of the $imcall and $dinput macros: $dcall contains the invocation of the D proxy method of which the return value is to be passed back to C++, $winput contains the parameter value from C++.
+
+
$excode
+
This variable is used in dout and dconstructor typemaps and is filled with the contents of the excode typemap attribute if an exception could be thrown from the C++ side. See the C# documentation for details.
+
+
$dbaseclass
+
Currently for internal use only, it contains the D name of the C++ base class (if any) inside proxy classes.
+
+
$directorconnect
+
+
This macro is only valid inside the dconstructor typemap and contains the value of the dconstructor typemap attribute if the currently wrapped class has directors enabled.
+
This is how the default dconstructor typemap looks like (you usually do not want to specify a custom one):
For this to work, AnInterface and AnotherInterface have to be in scope. If SWIG is not in split proxy mode, this is already the case, but it it is, they have to be added to the import list via the dimports typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.
+
The $importtype macro helps you to elegantly solve this problem:
If SWIG is in split proxy mode, it expands to an import statement for the specified type, to nothing if not.
+
+
+
$module
+
Expands to the name of the main proxy D module.
+
+
$imdmodule
+
Contains the fully qualified name of the intermediary D module.
+
+
+
+
20.4 %features
+
+
+
The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:
+
+
+
+
%dmanifestconst and %dconstvalue(value)
+
+
Out of the box, SWIG generates accessor methods for C #defines and C++ constants. The %dmanifestconst directive enables wrapping these constants as D manifest constants (const in D1, enum in D2).
+
For this to work, the C/C++ code for the constant value must directly compile as D code, though. If this is not the case, you can manually override the expression written to the D proxy module using the %dconstvalue directive, passing the new value as parameter.
+
For enums, again %dconstvalue can be used to override the value of an enum item if the initializer should not compile in D.
+
+
+
%dmethodmodifiers
+
+
This directive can be used to override the modifiers for a proxy function. For instance, you could make a public C++ member function private in D like this:
There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:
+
+
+
%pragma(d) imdmodulecode
+
The passed text (D code) is copied verbatim to the intermediary D module. For example, it can be (and is, internally) used to emit additional private helper code for the use by proxy typemaps.
+
+
%pragma(d) imdmoduleimports
+
Additional code to be emitted to the imports section of the intermediary D module (the $importtype macro can be used here). You probably want to use this in conjunction with the imdmodulecode pragma.
+
+
%pragma(d) proxydmodulecode
+
Just like proxydmodulecode, the argument is copied to the proxy D module (if SWIG is in split proxy mode and/or the nspace feature is used, it is emitted to the main proxy D module only).
+
+
%pragma(d) globalproxyimports
+
+
The D module currently does not support specifying dependencies on external modules (e.g. from the standard library) for the D typemaps. To add the import statements to the proxy modules (resp. to all proxy modules if in split proxy mode), you can use the globalproxyimports directive.
The D code for loading the wrapper library (it is copied to the intermediary D module). The $wrapperloaderbindcode variable is replaced by the list of commands for binding the functions from the wrapper library to the symbols in the intermediary D module.
+
Each time this pragma is specified, the previous value is overwritten.
+
+
+
%pragma(d) wrapperloaderbindcommand
+
+
The D command to use for binding the wrapper functions from the C/C++ library to the symbols in the intermediary D module. The $function variable contains the name of the D function in the wrap module, the $symbol variable is replaced by the name of the symbol in the library.
+
Each time this pragma is specified, the previous value is overwritten.
+
+
+
+
+
20.6 D Exceptions
+
+
+
Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.
+
+
The implementation details of this are a bit crude, but the SWIG D module automatically takes care of this, as long as it is able to detect that an exception could potentially be thrown (e.g. because the C++ method has a throw(...) exception specification).
+
+
As this feature is implemented in exactly the same way it is for C#, please see the C# documentation for a more detailed explanation.
+
+
+
20.7 D Directors
+
+
+
When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.
+
+
There is no D specific documentation yet, but the way the feature is implemented is very similar to how it is done in Java and C#.
+
+
+
+
20.8 Other features
+
+
+
20.8.1 Extended namespace support (nspace)
+
+
+
By default, SWIG flattens all C++ namespaces into a single target language namespace, but as for Java and C#, the nspace feature is supported for D. If it is active, C++ namespaces are mapped to D packages/modules. Note, however, that like for the other languages, free variables and functions are not supported yet; currently, they are all allows written to the main proxy D module.
+
+
+
20.8.2 Native pointer support
+
+
+
Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a »primtive type« below.
+
+
Central to this custom pointer handling scheme are two typemap attributes: the cprimitive attribute on the dtype typemap and the nativepointer attribute on all the typemaps which influence the D side of the code (dtype, din, dout, ...). When a D typemap is looked up, the following happens behind the scenes:
+
+
First, the matching typemap is determined by the usual typemap lookup rules. Then, it is checked if the result has the nativepointer attribute set. If it is present, it means that its value should replace the typemap value if and only if the actual type the typemap is looked up for is a primitive type, a pointer to a primitive type (through an arbitrary level of indirections), or a function pointer with only primitive types in its signature.
+
+
To determine if a type should be considered primitive, the cprimitive attribute on its dtype attribute is used. For example, the dtype typemap for float has cprimitive="1", so the code from the nativepointer attribute is taken into account e.g. for float ** or the function pointer float (*)(float *).
+
+
+
20.8.3 Operator overloading
+
+
+
The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:
+
+
The first key difference is that C++ supports free functions as operators (along with argument-dependent lookup), while D requires operators to be member functions of the class they are operating on. SWIG can only automatically generate wrapping code for member function operators; if you want to use operators defined as free functions in D, you need to handle them manually.
+
+
Another set of differences between C++ and D concerns individual operators. For example, there are quite a few operators which are overloadable in C++, but not in D, for example && and ||, but also !, and prefix increment/decrement operators in D1 resp. their postfix pendants in D2.
+
+
There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, [], in combination with assignments - while operator [] in C++ simply returns a reference which is then written to, D resorts to a separate opIndexAssign method -, or implicit casting (which was introduced in D2 via alias this). Despite the lack of automatic support, manually handling these cases should be perfectly possible.
+
+
+
20.8.4 Running the test-suite
+
+
+
As with any other language, the SWIG test-suite can be built for D using the *-d-test-suite targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional D_VERSION variable, e.g. make check-d-test-suite D_VERSION=2.
+
+
Note: If you want to use GDC on Linux or another platform which requires you to link libdl for dynamically loading the shared library, you might have to add -ldl manually to the d_compile target in Examples/Makefile, because GDC does not currently honor the pragma(lib,...) statement.
+
+
+
20.9 D Typemap examples
+
+
+
There are no D-specific typemap examples yet. However, with the above name comparison table, you should be able to get an idea what can be done by looking at the corresponding C# section.
+
+
+
+
20.10 Work in progress and planned features
+
+
+
There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:
+
+
+
Static linking: Currently, the C wrapper code is compiled into a dynamic library, out of which the symbol addresses are looked up at runtime by the D part. If statically linking the different languages into one binary was supported, a tool-chain capable of performing IPO at link time could inline the wrapping code, effectively reducing the overhead for simple calls to zero.
+
C array handling: Many data structures in some C/C++ libraries contain array containing of a pointer to the first element and the element count. Currently, one must manually writing wrapper code to be able to access these from D. It should be possible to add a set of SWIG macros to semi-automatically generate conversion code.
+
+
+
Some generated code might also be a bit rough around the edges, particularly in the following areas:
+
+
+
Memory management: Although the currently generated wrapper code works fine with regard to the GC for the test-suite, there might be issues coming up in real-world multi-threaded usage.
+
D2 support: Originally, the module has been developed for the use with D1, D2/Phobos support has been added in later. The basic features should work equally well for both, but there could be issues concerning const-correctness etc.
@@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
you should probably look at one of SWIG's existing modules.
-
36.2 Prerequisites
+
37.2 Prerequisites
@@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
-
36.3 The Big Picture
+
37.3 The Big Picture
@@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno
based on pattern matching and interact heavily with the underlying type system.
-
36.4 Execution Model
+
37.4 Execution Model
@@ -203,7 +203,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
-
36.4.1 Preprocessing
+
37.4.1 Preprocessing
@@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
-
36.4.2 Parsing
+
37.4.2 Parsing
@@ -385,7 +385,7 @@ returning a foo and taking types a and b as
arguments).
@@ -659,7 +659,7 @@ that matches the name of the target language. For example, python:fooperl:foo.
-
36.4.5 Symbol Tables
+
37.4.5 Symbol Tables
@@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )
-
36.4.6 The %feature directive
+
37.4.6 The %feature directive
@@ -806,7 +806,7 @@ For example, the exception code above is simply
stored without any modifications.
-
36.4.7 Code Generation
+
37.4.7 Code Generation
@@ -928,7 +928,7 @@ public :
The role of these functions is described shortly.
-
36.4.8 SWIG and XML
+
37.4.8 SWIG and XML
@@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
-
36.5 Primitive Data Structures
+
37.5 Primitive Data Structures
@@ -987,7 +987,7 @@ typedef Hash Typetab;
-
36.5.1 Strings
+
37.5.1 Strings
@@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
-
36.5.2 Hashes
+
37.5.2 Hashes
@@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
-
36.5.3 Lists
+
37.5.3 Lists
@@ -1294,7 +1294,7 @@ If t is not a standard object, it is assumed to be a char *
and is used to create a String object.
-
36.5.4 Common operations
+
37.5.4 Common operations
The following operations are applicable to all datatypes.
@@ -1349,7 +1349,7 @@ objects and report errors.
Gets the line number associated with x.
-
36.5.5 Iterating over Lists and Hashes
+
37.5.5 Iterating over Lists and Hashes
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) {
-
36.5.6 I/O
+
37.5.6 I/O
Special I/O functions are used for all internal I/O. These operations
@@ -1531,7 +1531,7 @@ Similarly, the preprocessor and parser all operate on string-files.
-
36.6 Navigating and manipulating parse trees
+
37.6 Navigating and manipulating parse trees
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1665,7 +1665,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
-
36.7 Working with attributes
+
37.7 Working with attributes
@@ -1782,7 +1782,7 @@ the attribute is optional. Swig_restore() must always be called after
function.
-
36.8 Type system
+
37.8 Type system
@@ -1791,7 +1791,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
-
36.8.1 String encoding of types
+
37.8.1 String encoding of types
@@ -1892,7 +1892,7 @@ make the final type, the two parts are just joined together using
string concatenation.
-
36.8.2 Type construction
+
37.8.2 Type construction
@@ -2061,7 +2061,7 @@ Returns the prefix of a type. For example, if ty is
ty is unmodified.
-
36.8.3 Type tests
+
37.8.3 Type tests
@@ -2148,7 +2148,7 @@ Checks if ty is a varargs type.
Checks if ty is a templatized type.
-
36.8.4 Typedef and inheritance
+
37.8.4 Typedef and inheritance
@@ -2250,7 +2250,7 @@ Fully reduces ty according to typedef rules. Resulting datatype
will consist only of primitive typenames.
-
@@ -2349,7 +2349,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., SWIGTYPE_p_double).
-
36.9 Parameters
+
37.9 Parameters
@@ -2448,7 +2448,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in p.
-
36.10 Writing a Language Module
+
37.10 Writing a Language Module
@@ -2463,7 +2463,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
-
36.10.1 Execution model
+
37.10.1 Execution model
@@ -2473,7 +2473,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the Language that must be defined by your module.
-
36.10.2 Starting out
+
37.10.2 Starting out
@@ -2581,7 +2581,7 @@ that activates your module. For example, swig -python foo.i. The
messages from your new module should appear.
-
36.10.3 Command line options
+
37.10.3 Command line options
@@ -2640,7 +2640,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
-
36.10.4 Configuration and preprocessing
+
37.10.4 Configuration and preprocessing
@@ -2689,7 +2689,7 @@ an implementation file python.cxx and a configuration file
python.swg.
-
36.10.5 Entry point to code generation
+
37.10.5 Entry point to code generation
@@ -2747,7 +2747,7 @@ int Python::top(Node *n) {
-
@@ -3049,7 +3049,7 @@ but without the typemaps, there is still work to do.
-
36.10.8 Configuration files
+
37.10.8 Configuration files
@@ -3193,7 +3193,7 @@ politely displays the ignoring language message.
-
36.10.9 Runtime support
+
37.10.9 Runtime support
@@ -3202,7 +3202,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
36.10.10 Standard library files
+
37.10.10 Standard library files
@@ -3221,7 +3221,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
36.10.11 User examples
+
37.10.11 User examples
@@ -3250,7 +3250,7 @@ during this process, see the section on .
-
36.10.12 Test driven development and the test-suite
+
37.10.12 Test driven development and the test-suite
@@ -3309,7 +3309,7 @@ It is therefore essential that the runtime tests are written in a manner that di
but error/exception out with an error message on stderr on failure.
-
36.10.12.1 Running the test-suite
+
37.10.12.1 Running the test-suite
@@ -3477,7 +3477,25 @@ A debugger can also be invoked easily on an individual test, for example gdb:
make ret_by_value.ctest RUNTOOL="gdb --args"
-
36.10.13 Documentation
+
+SWIG reads the SWIG_FEATURES environment variable to obtain options in addition to those passed on the command line.
+This is particularly useful as the entire test-suite or a particular testcase can be run customized by using additional
+arguments, for example the -O optimization flag can be added in, as shown below for the bash shell:
+
+
+
+env SWIG_FEATURES=-O make check-python-test-suite
+
+
+
+The syntax for setting environment variables varies from one shell to the next, but it also works as shown in the example below, where some typemap debugging is added in:
+
@@ -3509,7 +3527,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
36.10.14 Prerequisites for adding a new language module to the SWIG distribution
+
37.10.14 Prerequisites for adding a new language module to the SWIG distribution
@@ -3566,7 +3584,7 @@ should be added should there be an area not already covered by
the existing tests.
-
36.10.15 Coding style guidelines
+
37.10.15 Coding style guidelines
@@ -3590,7 +3608,7 @@ The generated C/C++ code should also follow this style as close as possible. How
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
-
36.11 Debugging Options
+
37.11 Debugging Options
@@ -3617,7 +3635,7 @@ There are various command line options which can aid debugging a SWIG interface
The complete list of command line options for SWIG are available by running swig -help.
@@ -41,7 +41,7 @@ the Go programming language
see golang.org.
-
20.1 Overview
+
21.1 Overview
@@ -65,7 +65,7 @@ checking and runtime library are not used with Go. This should be
borne in mind when reading the rest of the SWIG documentation.
-
20.2 Running SWIG with Go
+
21.2 Running SWIG with Go
@@ -74,7 +74,7 @@ default SWIG will generate code for the gc compilers. To generate
code for gccgo, you should also use the -gccgo option.
-
20.2.1 Additional Commandline Options
+
21.2.1 Additional Commandline Options
@@ -94,7 +94,7 @@ swig -go -help
-gccgo
Generate code for gccgo. The default is to generate code for
- 6g/8g/6g.
+ 6g/8g/5g.
@@ -103,6 +103,15 @@ swig -go -help
package name is the SWIG module name.
+
+
-soname %lt;name%gt;
+
Set the runtime name of the shared library that the dynamic linker
+ should include at runtime. The default is the package name with
+ ".so" appended. This is only used when generating code for
+ 6g/8g/5g; when using gccgo, the equivalent name will be taken from
+ the -soname option passed to the linker.
+
+
-go-prefix <prefix>
When generating code for gccgo, set the prefix to use. This
@@ -118,7 +127,7 @@ swig -go -help
-
20.2.2 Go Output Files
+
21.2.2 Go Output Files
When generating Go code, SWIG will generate the following
@@ -163,7 +172,7 @@ A typical command sequence would look like this:
% 6l main.6
-
20.3 A tour of basic C/C++ wrapping
+
21.3 A tour of basic C/C++ wrapping
@@ -173,7 +182,7 @@ modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
-
20.3.1 Go Package Name
+
21.3.1 Go Package Name
@@ -183,7 +192,7 @@ directive. You may override this by using SWIG's -package
command line option.
-
20.3.2 Go Names
+
21.3.2 Go Names
@@ -215,7 +224,7 @@ followed by that name, and the destructor will be
named Delete followed by that name.
-
20.3.3 Go Constants
+
21.3.3 Go Constants
@@ -223,7 +232,7 @@ C/C++ constants created via #define or the %constant
directive become Go constants, declared with a const
declaration.
-
20.3.4 Go Enumerations
+
21.3.4 Go Enumerations
@@ -233,7 +242,7 @@ usual). The values of the enumeration will become variables in Go;
code should avoid modifying those variables.
-
20.3.5 Go Classes
+
21.3.5 Go Classes
@@ -280,7 +289,7 @@ to reinterpret_cast. This should only be used for very
special cases, such as where C++ would use a dynamic_cast.
-
20.3.5.1 Go Class Inheritance
+
21.3.5.1 Go Class Inheritance
@@ -292,7 +301,7 @@ Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
-
20.3.6 Go Templates
+
21.3.6 Go Templates
@@ -300,7 +309,7 @@ In order to use C++ templates in Go, you must tell SWIG to create
wrappers for a particular template instantation. To do this, use
the %template directive.
-
20.3.7 Go Director Classes
+
21.3.7 Go Director Classes
@@ -343,7 +352,7 @@ method defined in Go. The Go code may of course call other methods on
itself, and those methods may be defined either in Go or in C++.
This section details guile-specific support in SWIG.
-
21.1 Meaning of "Module"
+
22.1 Meaning of "Module"
@@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined
separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
we explicitly prefix the context, e.g., "guile-module".
-
21.2 Using the SCM or GH Guile API
+
22.2 Using the SCM or GH Guile API
The guile module can currently export wrapper files that use the guile GH interface or the
@@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma
but there is no reason other languages (like mzscheme or chicken) couldn't also use this.
If that happens, there is A LOT less code duplication in the standard typemaps.
-
21.3 Linkage
+
22.3 Linkage
@@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness,
which manifests in multiple shared-library usage conventions. A set of
policies implementing a usage convention is called a linkage.
-
21.3.1 Simple Linkage
+
22.3.1 Simple Linkage
@@ -206,7 +206,7 @@ placed between the define-module form and the
SWIG_init via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
-
21.3.2 Passive Linkage
+
22.3.2 Passive Linkage
Passive linkage is just like simple linkage, but it generates an
@@ -216,7 +216,7 @@ package name (see below).
You should use passive linkage rather than simple linkage when you
are using multiple modules.
-
21.3.3 Native Guile Module Linkage
+
22.3.3 Native Guile Module Linkage
SWIG can also generate wrapper code that does all the Guile module
@@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:
-
21.3.4 Old Auto-Loading Guile Module Linkage
+
22.3.4 Old Auto-Loading Guile Module Linkage
Guile used to support an autoloading facility for object-code
@@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with
an appropriate name.
-
21.3.5 Hobbit4D Linkage
+
22.3.5 Hobbit4D Linkage
@@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
experimental; the (hobbit4d link) conventions are not well understood.
-
21.4 Underscore Folding
+
22.4 Underscore Folding
@@ -320,7 +320,7 @@ complained so far.
%rename to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-
21.5 Typemaps
+
22.5 Typemaps
@@ -412,7 +412,7 @@ constant will appear as a scheme variable. See
Features and the %feature directive
for info on how to apply the %feature.
-
21.6 Representation of pointers as smobs
+
22.6 Representation of pointers as smobs
@@ -429,11 +429,11 @@ upper half of the CAR is read from this struct.
To get the pointer represented by a smob, the wrapper code calls the
function SWIG_ConvertPtr(), passing a pointer to a struct
representing the expected pointer type. See also
-The run-time type checker.
+The run-time type checker.
If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a wrong-type-arg exception is raised.
-
21.6.1 GH Smobs
+
22.6.1 GH Smobs
@@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct.
Once we have a swig_type_info structure, we loop through the linked list of
casts, using pointer comparisons.
-
21.6.2 SCM Smobs
+
22.6.2 SCM Smobs
The SCM interface (using the "-scm" argument to swig) uses swigrun.swg.
@@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra
GOOPS class.
-
21.6.3 Garbage Collection
+
22.6.3 Garbage Collection
Garbage collection is a feature of the new SCM interface, and it is automatically included
@@ -491,7 +491,7 @@ is exactly like described in 21.7 Exception Handling
+
22.7 Exception Handling
@@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
-
21.8 Procedure documentation
+
22.8 Procedure documentation
If invoked with the command-line option -procdoc
@@ -553,7 +553,7 @@ like this:
typemap argument doc. See Lib/guile/typemaps.i for
details.
-
21.9 Procedures with setters
+
22.9 Procedures with setters
For global variables, SWIG creates a single wrapper procedure
@@ -581,7 +581,7 @@ struct members, the procedures (struct-member-get
pointer) and (struct-member-set pointer
value) are not generated.
-
21.10 GOOPS Proxy Classes
+
22.10 GOOPS Proxy Classes
SWIG can also generate classes and generic functions for use with
@@ -730,7 +730,7 @@ Notice that <Foo> is used before it is defined. The fix is to just put th
%import "foo.h" before the %inline block.
-
21.10.1 Naming Issues
+
22.10.1 Naming Issues
As you can see in the example above, there are potential naming conflicts. The default exported
@@ -767,7 +767,7 @@ guile-modules. For example,
The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 3bac9484e..a8d15a5c2 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -195,9 +195,9 @@ extern int my_mod(int n, int m);
The interface file contains ANSI C function prototypes and variable
declarations. The %module directive defines the name of the
-module that will be created by SWIG. The %{,%} block
-provides a location for inserting additional code such as C header
-files or additional C declarations.
+module that will be created by SWIG. The %{ %} block
+provides a location for inserting additional code, such as C header
+files or additional C declarations, into the generated C wrapper code.
Java typemaps
@@ -154,7 +155,7 @@ It covers most SWIG features, but certain low-level details are covered in less
-
22.1 Overview
+
23.1 Overview
@@ -189,7 +190,7 @@ Various customisation tips and techniques using SWIG directives are covered.
The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.
-
22.2 Preliminaries
+
23.2 Preliminaries
@@ -205,7 +206,7 @@ Run make -k check from the SWIG root directory after installing SWIG on
The Java module requires your system to support shared libraries and dynamic loading.
This is the commonly used method to load JNI code so your system will more than likely support this.
-
22.2.1 Running SWIG
+
23.2.1 Running SWIG
@@ -264,7 +265,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
-
22.2.2 Additional Commandline Options
+
23.2.2 Additional Commandline Options
@@ -301,7 +302,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
-
22.2.3 Getting the right header files
+
23.2.3 Getting the right header files
@@ -316,7 +317,7 @@ They are usually in directories like this:
The exact location may vary on your machine, but the above locations are typical.
-
22.2.4 Compiling a dynamic module
+
23.2.4 Compiling a dynamic module
@@ -352,7 +353,7 @@ The name of the shared library output file is important.
If the name of your SWIG module is "example", the name of the corresponding shared library file should be "libexample.so" (or equivalent depending on your machine, see Dynamic linking problems for more information).
The name of the module is specified using the %module directive or -module command line option.
-
22.2.5 Using your module
+
23.2.5 Using your module
@@ -387,7 +388,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
-
22.2.6 Dynamic linking problems
+
23.2.6 Dynamic linking problems
@@ -474,7 +475,7 @@ The following section also contains some C++ specific linking problems and solut
-
22.2.7 Compilation problems and compiling with C++
+
23.2.7 Compilation problems and compiling with C++
@@ -527,7 +528,7 @@ Finally make sure the version of JDK header files matches the version of Java th
-
22.2.8 Building on Windows
+
23.2.8 Building on Windows
@@ -536,7 +537,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine.
This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers.
In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.
-
22.2.8.1 Running SWIG from Visual Studio
+
23.2.8.1 Running SWIG from Visual Studio
@@ -575,7 +576,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa
If the library fails to load have a look at Dynamic linking problems.
-
22.2.8.2 Using NMAKE
+
23.2.8.2 Using NMAKE
@@ -634,7 +635,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
-
22.3 A tour of basic C/C++ wrapping
+
23.3 A tour of basic C/C++ wrapping
@@ -644,7 +645,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
-
22.3.1 Modules, packages and generated Java classes
+
23.3.1 Modules, packages and generated Java classes
@@ -680,7 +681,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
SWIG won't create the directory, so make sure it exists beforehand.
@@ -941,7 +942,7 @@ Or if you decide this practice isn't so bad and your own class implements ex
-
22.3.5 Enumerations
+
23.3.5 Enumerations
@@ -955,7 +956,7 @@ The final two approaches use simple integers for each enum item.
Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.
-
22.3.5.1 Anonymous enums
+
23.3.5.1 Anonymous enums
@@ -1018,7 +1019,7 @@ As in the case of constants, you can access them through either the module class
-
22.3.5.2 Typesafe enums
+
23.3.5.2 Typesafe enums
@@ -1112,7 +1113,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit
The following section details proper Java enum generation.
@@ -1213,7 +1214,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff
Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.
-
22.3.5.5 Simple enums
+
23.3.5.5 Simple enums
@@ -1232,7 +1233,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach.
The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.
-
22.3.6 Pointers
+
23.3.6 Pointers
@@ -1320,7 +1321,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
a NULL pointer if the conversion can't be performed.
-
22.3.7 Structures
+
23.3.7 Structures
@@ -1488,7 +1489,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
-
22.3.8 C++ classes
+
23.3.8 C++ classes
@@ -1551,7 +1552,7 @@ int bar = Spam.getBar();
-
22.3.9 C++ inheritance
+
23.3.9 C++ inheritance
@@ -1612,7 +1613,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance
A warning is given when multiple inheritance is detected and only the first base class is used.
-
22.3.10 Pointers, references, arrays and pass by value
+
23.3.10 Pointers, references, arrays and pass by value
@@ -1667,7 +1668,7 @@ to hold the result and a pointer is returned (Java will release this memory
when the returned object's finalizer is run by the garbage collector).
-
22.3.10.1 Null pointers
+
23.3.10.1 Null pointers
@@ -1691,7 +1692,7 @@ For spam1 and spam4 above the Java null gets translat
The converse also occurs, that is, NULL pointers are translated into null Java objects when returned from a C/C++ function.
@@ -1849,7 +1850,7 @@ Further details on default arguments and how to restore this approach are given
-
22.3.13 C++ namespaces
+
23.3.13 C++ namespaces
@@ -1922,12 +1923,14 @@ So if SWIG is run using the -package com.myco option, a wrapped class,
-example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless a package is specified
-with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.
+example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless
+a package is specified
+with -package - Java does not support types declared in a named package accessing types declared
+in an unnamed package.
-
22.3.14 C++ templates
+
23.3.14 C++ templates
@@ -1976,7 +1979,7 @@ Obviously, there is more to template wrapping than shown in this example.
More details can be found in the SWIG and C++ chapter.
22.4 Further details on the generated Java classes
+
23.4 Further details on the generated Java classes
@@ -2075,7 +2078,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
-
22.4.1 The intermediary JNI class
+
23.4.1 The intermediary JNI class
@@ -2195,7 +2198,7 @@ If name is the same as modulename then the module class name g
from modulename to modulenameModule.
-
22.4.1.1 The intermediary JNI class pragmas
+
23.4.1.1 The intermediary JNI class pragmas
@@ -2274,7 +2277,7 @@ For example, let's change the intermediary JNI class access to just the default
All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.
-
22.4.2 The Java module class
+
23.4.2 The Java module class
@@ -2305,7 +2308,7 @@ example.egg(new Foo());
The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a Foo can be passed to the egg function, whereas any long can be passed to the egg function in the intermediary JNI class.
@@ -2432,7 +2435,7 @@ int y = f.spam(5, new Foo());
-
22.4.3.1 Memory management
+
23.4.3.1 Memory management
@@ -2594,7 +2597,7 @@ and
-
22.4.3.2 Inheritance
+
23.4.3.2 Inheritance
@@ -2710,7 +2713,7 @@ However, true cross language polymorphism can be achieved using the 22.4.3.3 Proxy classes and garbage collection
+
23.4.3.3 Proxy classes and garbage collection
@@ -2743,7 +2746,7 @@ Call the System.runFinalizersOnExit(true) or Runtime.getRuntime().r
This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
In many cases you will be lucky and find that it works, but it is not to be advocated.
-Have a look at Sun's Java web site and search for runFinalizersOnExit.
+Have a look at Java web site and search for runFinalizersOnExit.
@@ -3090,7 +3093,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
-
22.4.5 Enum classes
+
23.4.5 Enum classes
@@ -3099,7 +3102,7 @@ The Enumerations section discussed these but om
The following sub-sections detail the various types of enum classes that can be generated.
-
22.4.5.1 Typesafe enum classes
+
23.4.5.1 Typesafe enum classes
@@ -3183,7 +3186,7 @@ The swigValue method is used for marshalling in the other direction.
The toString method is overridden so that the enum name is available.
-
22.4.5.2 Proper Java enum classes
+
23.4.5.2 Proper Java enum classes
@@ -3261,7 +3264,7 @@ These needn't be generated if the enum being wrapped does not have any initializ
Simpler Java enums for enums without initializers section describes how typemaps can be used to achieve this.
-
22.4.5.3 Type unsafe enum classes
+
23.4.5.3 Type unsafe enum classes
@@ -3292,7 +3295,7 @@ public final class Beverage {
-
22.5 Cross language polymorphism using directors
+
23.5 Cross language polymorphism using directors
@@ -3314,7 +3317,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens
Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.
-
22.5.1 Enabling directors
+
23.5.1 Enabling directors
@@ -3385,7 +3388,7 @@ public:
-
22.5.2 Director classes
+
23.5.2 Director classes
@@ -3412,7 +3415,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
-
22.5.3 Overhead and code bloat
+
23.5.3 Overhead and code bloat
@@ -3430,7 +3433,7 @@ This situation can be optimized by selectively enabling director methods (using
@@ -3515,7 +3518,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
-
22.6 Accessing protected members
+
23.6 Accessing protected members
@@ -3611,7 +3614,7 @@ class MyProtectedBase extends ProtectedBase
-
22.7 Common customization features
+
23.7 Common customization features
@@ -3623,7 +3626,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
-
22.7.1 C/C++ helper functions
+
23.7.1 C/C++ helper functions
@@ -3689,7 +3692,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps,
customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.
-
22.7.2 Class extension with %extend
+
23.7.2 Class extension with %extend
@@ -3752,7 +3755,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
-
22.7.3 Exception handling with %exception and %javaexception
+
23.7.3 Exception handling with %exception and %javaexception
@@ -3947,7 +3950,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
-
22.8.1 Input and output parameters using primitive pointers and references
+
23.8.1 Input and output parameters using primitive pointers and references
@@ -4121,7 +4124,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
22.8.2 Simple pointers
+
23.8.2 Simple pointers
@@ -4187,7 +4190,7 @@ System.out.println("3 + 4 = " + result);
See the SWIG Library chapter for further details.
-
22.8.3 Wrapping C arrays with Java arrays
+
23.8.3 Wrapping C arrays with Java arrays
@@ -4254,7 +4257,7 @@ Please be aware that the typemaps in this library are not efficient as all the e
There is an alternative approach using the SWIG array library and this is covered in the next section.
-
22.8.4 Unbounded C Arrays
+
23.8.4 Unbounded C Arrays
@@ -4399,7 +4402,51 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
22.8.5 Overriding new and delete to allocate from Java heap
+
23.8.5 Binary data vs Strings
+
+
+
+By default SWIG handles char * as a string but there is a handy multi-argument typemap available as mentioned in Passing binary data.
+The following simple example demonstrates using a byte array instead of passing the default string type and length to the wrapped function.
+
+Calling from Java requires just the byte array to be passed in as the multi-argument typemap being applied reduces the number of arguments in the target language to one, from the original two:
+
+
+
+
+byte[] data = "hi\0jk".getBytes();
+example.binaryChar1(data);
+
+
+
+
+resulting in the output
+
+
+
+$ java runme
+len: 5 data: 68 69 0 6a 6b
+
+
+
+
23.8.6 Overriding new and delete to allocate from Java heap
@@ -4516,7 +4563,7 @@ model and use these functions in place of malloc and free in your own
code.
-
22.9 Java typemaps
+
23.9 Java typemaps
@@ -4537,7 +4584,7 @@ Before proceeding, it should be stressed that typemaps are not a required
part of using SWIG---the default wrapping behavior is enough in most cases.
Typemaps are only used if you want to change some aspect of the generated code.
-
22.9.1 Default primitive type mappings
+
23.9.1 Default primitive type mappings
@@ -4689,7 +4736,7 @@ However, the mappings allow the full range of values for each C type from Java.
-
22.9.2 Default typemaps for non-primitive types
+
23.9.2 Default typemaps for non-primitive types
@@ -4704,7 +4751,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit
The Java type is either the proxy class or type wrapper class.
-
22.9.3 Sixty four bit JVMs
+
23.9.3 Sixty four bit JVMs
@@ -4717,7 +4764,7 @@ Unfortunately it won't of course hold true for JNI code.
-
22.9.4 What is a typemap?
+
23.9.4 What is a typemap?
@@ -4840,7 +4887,7 @@ int c = example.count('e',"Hello World");
-
22.9.5 Typemaps for mapping C/C++ types to Java types
+
23.9.5 Typemaps for mapping C/C++ types to Java types
@@ -5100,7 +5147,7 @@ These are listed below:
-
22.9.6 Java typemap attributes
+
23.9.6 Java typemap attributes
@@ -5146,7 +5193,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes.
Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a this call. In Java the this call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a Date marshalling example showing 'pre', 'post' and 'pgcppname' attributes in action.
-
22.9.7 Java special variables
+
23.9.7 Java special variables
@@ -5297,7 +5344,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the %module directive.
-
22.9.8 Typemaps for both C and C++ compilation
+
23.9.8 Typemaps for both C and C++ compilation
@@ -5334,7 +5381,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
-
22.9.9 Java code typemaps
+
23.9.9 Java code typemaps
@@ -5540,7 +5587,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "java.swg", barring the method modifier for getCPtr.
-
22.9.10 Director specific typemaps
+
23.9.10 Director specific typemaps
@@ -5765,7 +5812,7 @@ The basic strategy here is to provide a default package typemap for the majority
-
22.10 Typemap Examples
+
23.10 Typemap Examples
@@ -5775,7 +5822,7 @@ the SWIG library.
-
22.10.1 Simpler Java enums for enums without initializers
+
23.10.1 Simpler Java enums for enums without initializers
@@ -5854,7 +5901,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
-
22.10.2 Handling C++ exception specifications as Java exceptions
+
23.10.2 Handling C++ exception specifications as Java exceptions
@@ -5979,7 +6026,7 @@ We could alternatively have used %rename to rename what() into
-
22.10.3 NaN Exception - exception handling for a particular type
+
23.10.3 NaN Exception - exception handling for a particular type
@@ -6134,7 +6181,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
-
22.10.4 Converting Java String arrays to char **
+
23.10.4 Converting Java String arrays to char **
@@ -6278,7 +6325,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
-
22.10.5 Expanding a Java object to multiple arguments
+
23.10.5 Expanding a Java object to multiple arguments
22.10.7 Adding Java downcasts to polymorphic return types
+
23.10.7 Adding Java downcasts to polymorphic return types
@@ -6684,7 +6731,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
-
22.10.8 Adding an equals method to the Java classes
+
23.10.8 Adding an equals method to the Java classes
22.10.9 Void pointers and a common Java base class
+
23.10.9 Void pointers and a common Java base class
@@ -6787,7 +6834,7 @@ This example contains some useful functionality which you may want in your code.
It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.
-
22.10.10 Struct pointer to pointer
+
23.10.10 Struct pointer to pointer
@@ -6967,7 +7014,7 @@ The C functional interface has been completely morphed into an object-oriented i
the Butler class would behave much like any pure Java class and feel more natural to Java users.
-
22.10.11 Memory management when returning references to member variables
+
23.10.11 Memory management when returning references to member variables
@@ -7090,7 +7137,7 @@ public class Bike {
Note the addReference call.
-
22.10.12 Memory management for objects passed to the C++ layer
+
23.10.12 Memory management for objects passed to the C++ layer
@@ -7206,7 +7253,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
-
22.10.13 Date marshalling using the javain typemap and associated attributes
+
23.10.13 Date marshalling using the javain typemap and associated attributes
@@ -7383,7 +7430,7 @@ A few things to note:
-
22.11 Living with Java Directors
+
23.11 Living with Java Directors
@@ -7564,10 +7611,10 @@ public abstract class UserVisibleFoo extends Foo {
-
22.12 Odds and ends
+
23.12 Odds and ends
-
22.12.1 JavaDoc comments
+
23.12.1 JavaDoc comments
@@ -7623,7 +7670,7 @@ public class Barmy {
-
22.12.2 Functional interface without proxy classes
+
23.12.2 Functional interface without proxy classes
@@ -7684,7 +7731,7 @@ All destructors have to be called manually for example the delete_Foo(foo)
-
22.12.3 Using your own JNI functions
+
23.12.3 Using your own JNI functions
@@ -7734,7 +7781,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
-
22.12.4 Performance concerns and hints
+
23.12.4 Performance concerns and hints
@@ -7755,7 +7802,7 @@ However, you will have to be careful about memory management and make sure that
This method normally calls the C++ destructor or free() for C code.
-
22.12.5 Debugging
+
23.12.5 Debugging
@@ -7777,7 +7824,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
-
22.13 Examples
+
23.13 Examples
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 285192d5e..02b8e53bd 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -824,20 +824,20 @@ If you have a function that expects binary data,
-int parity(char *str, int len, int initial);
+size_t parity(char *str, size_t len, size_t initial);
-you can wrap the parameters (char *str, int len) as a single
+you can wrap the parameters (char *str, size_t len) as a single
argument using a typemap. Just do this:
-%apply (char *STRING, int LENGTH) { (char *str, int len) };
+%apply (char *STRING, size_t LENGTH) { (char *str, size_t len) };
...
-int parity(char *str, int len, int initial);
+size_t parity(char *str, size_t len, size_t initial);
@@ -854,6 +854,7 @@ Now, in the target language, you can use binary string data like this:
In the wrapper function, the passed string will be expanded to a pointer and length parameter.
+The (char *STRING, int LENGTH) multi-argument typemap is also available in addition to (char *STRING, size_t LENGTH).
-Note that if the %shared_ptr macro is omitted for any class in the inheritance hierarchy, it will
-result in a C++ compiler error.
-For example if the above %shared_ptr(DerivedIntValue) is omitted, the following is typical of the compiler error that will result:
-
-
-
-
-example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*, _jclass*, jlong)':
-example_wrap.cxx:3169: error: 'smartarg1' was not declared in this scope
-
-
-
A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:
@@ -1826,6 +1814,59 @@ int val4 = example.extractValueSmart(div);
+
+If the %shared_ptr macro is omitted for any class in the inheritance hierarchy, SWIG will warn about this and the generated code may or may not result in a C++ compilation error.
+For example, the following input:
+
+warns about the missing smart pointer information:
+
+
+
+
+example.i:12: Warning 520: Base class 'GrandParent' of 'Parent' is not similarly marked as a smart pointer.
+example.i:16: Warning 520: Derived class 'Child' of 'Parent' is not similarly marked as a smart pointer.
+
+
+
+
+Adding the missing %shared_ptr macros will fix this:
+
+
+
+
+%include "boost_shared_ptr.i"
+%shared_ptr(GrandParent);
+%shared_ptr(Parent);
+%shared_ptr(Child);
+
+... as before ...
+
@@ -77,7 +77,7 @@ swig -cffi -module module-namefile-name
files and the various things which you can do with them.
-
23.2.1 Additional Commandline Options
+
24.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -cffi -help
-
23.2.2 Generating CFFI bindings
+
24.2.2 Generating CFFI bindings
As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@ The feature intern_function ensures that all C names are
-
23.2.3 Generating CFFI bindings for C++ code
+
24.2.3 Generating CFFI bindings for C++ code
This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
module feel free to contact us on the SWIG mailing list, and
also please add a "[CFFI]" tag in the subject line.
-
23.2.4 Inserting user code into generated files
+
24.2.4 Inserting user code into generated files
@@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for
-
23.3 CLISP
+
24.3 CLISP
@@ -638,7 +638,7 @@ swig -clisp -module module-namefile-name
interface file for the CLISP module. The CLISP module tries to
produce code which is both human readable and easily modifyable.
-
23.3.1 Additional Commandline Options
+
24.3.1 Additional Commandline Options
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for
-
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a really tiny language, less than 6000 lines of code, which compiles to <100 kilobytes of binary code. It can be found at http://www.lua.org
-
24.1 Preliminaries
+
25.1 Preliminaries
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).
-
24.2 Running SWIG
+
25.2 Running SWIG
@@ -105,7 +105,7 @@ This creates a C/C++ source file example_wrap.c or example_wrap.cxx
The name of the wrapper file is derived from the name of the input file. For example, if the input file is example.i, the name of the wrapper file is example_wrap.c. To change this, you can use the -o option. The wrappered module will export one function "int luaopen_example(lua_State* L)" which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.
@@ -220,7 +220,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-
24.2.3 Using your module
+
25.2.3 Using your module
@@ -238,19 +238,19 @@ $ ./my_lua
>
-
24.3 A tour of basic C/C++ wrapping
+
25.3 A tour of basic C/C++ wrapping
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
-
24.3.1 Modules
+
25.3.1 Modules
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
-
24.3.2 Functions
+
25.3.2 Functions
@@ -288,7 +288,7 @@ It is also possible to rename the module with an assignment.
24
-
24.3.3 Global variables
+
25.3.3 Global variables
@@ -362,7 +362,7 @@ nil
3.142
-
24.3.4 Constants and enums
+
25.3.4 Constants and enums
@@ -385,7 +385,7 @@ example.SUNDAY=0
Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.
-
24.3.5 Pointers
+
25.3.5 Pointers
@@ -423,7 +423,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
-
24.3.6 Structures
+
25.3.6 Structures
@@ -509,7 +509,7 @@ Because the pointer points inside the structure, you can modify the contents and
> x.a = 3 -- Modifies the same structure
-
24.3.7 C++ classes
+
25.3.7 C++ classes
@@ -570,7 +570,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
-
24.3.8 C++ inheritance
+
25.3.8 C++ inheritance
@@ -595,7 +595,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-
24.3.9 Pointers, references, values, and arrays
+
25.3.9 Pointers, references, values, and arrays
@@ -626,7 +626,7 @@ Foo spam7();
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
-
24.3.10 C++ overloaded functions
+
25.3.10 C++ overloaded functions
@@ -712,7 +712,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
-
24.3.11 C++ operators
+
25.3.11 C++ operators
@@ -824,7 +824,7 @@ It is also possible to overload the operator[], but currently this cann
};
-
24.3.12 Class extension with %extend
+
25.3.12 Class extension with %extend
@@ -879,7 +879,7 @@ true
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
-
24.3.13 C++ templates
+
25.3.13 C++ templates
@@ -914,7 +914,7 @@ In Lua:
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
-
24.3.14 C++ Smart Pointers
+
25.3.14 C++ Smart Pointers
@@ -966,7 +966,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-
24.3.15 C++ Exceptions
+
25.3.15 C++ Exceptions
@@ -1110,12 +1110,12 @@ add exception specification to functions or globally (respectively).
-
24.4 Typemaps
+
25.4 Typemaps
This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect
-
24.4.1 What is a typemap?
+
25.4.1 What is a typemap?
A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:
@@ -1143,7 +1143,7 @@ Received an integer : 6
720
-
24.4.2 Using typemaps
+
25.4.2 Using typemaps
There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.
@@ -1196,7 +1196,7 @@ void swap(int *sx, int *sy);
Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a const int& as an input parameter (since that it obviously input).
-
24.4.3 Typemaps and arrays
+
25.4.3 Typemaps and arrays
Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
@@ -1260,7 +1260,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In
Note: SWIG also can support arrays of pointers in a similar manner.
-
24.4.4 Typemaps and pointer-pointer functions
+
25.4.4 Typemaps and pointer-pointer functions
Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:
@@ -1294,7 +1294,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
ptr=nil -- the iMath* will be GC'ed as normal
-
24.5 Writing typemaps
+
25.5 Writing typemaps
This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the %typemap directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "Typemaps" chapter.
@@ -1303,7 +1303,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).
-
24.5.1 Typemaps you can write
+
25.5.1 Typemaps you can write
There are many different types of typemap that can be written, the full list can be found in the "Typemaps" chapter. However the following are the most commonly used ones.
@@ -1316,7 +1316,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
(the syntax for the typecheck is different from the typemap, see typemaps for details).
-
24.5.2 SWIG's Lua-C API
+
25.5.2 SWIG's Lua-C API
This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.
@@ -1365,7 +1365,7 @@ This macro, when called within the context of a SWIG wrappered function, will di
Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.
-
24.6 Customization of your Bindings
+
25.6 Customization of your Bindings
@@ -1374,7 +1374,7 @@ This section covers adding of some small extra bits to your module to add the la
-
24.6.1 Writing your own custom wrappers
+
25.6.1 Writing your own custom wrappers
@@ -1393,7 +1393,7 @@ int native_function(lua_State*L) // my native code
The %native directive in the above example, tells SWIG that there is a function int native_function(lua_State*L); which is to be added into the module under the name 'my_func'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-
24.6.2 Adding additional Lua code
+
25.6.2 Adding additional Lua code
@@ -1431,7 +1431,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
-
24.7 Details on the Lua binding
+
25.7 Details on the Lua binding
@@ -1442,7 +1442,7 @@ See Examples/lua/arrays for an example of this code.
-
24.7.1 Binding global data into the module.
+
25.7.1 Binding global data into the module.
@@ -1502,7 +1502,7 @@ end
That way when you call 'a=example.Foo', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code 'example.Foo=10', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
-
24.7.2 Userdata and Metatables
+
25.7.2 Userdata and Metatables
@@ -1582,7 +1582,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' & '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
-
24.7.3 Memory management
+
25.7.3 Memory management
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 011261e76..42149ba3a 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -69,7 +69,10 @@ test:
validate:
all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done;
-# Link checking using linkchecker (can take a while - 30 mins)
+# Link checking using linkchecker
linkchecker:
- linkchecker --anchors Contents.html
+ @echo -----------------------------------------------------------------------
+ @echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
+ @echo -----------------------------------------------------------------------
+ linkchecker --config=./linkchecker.config index.html
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index 71611e3c5..f9400abee 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -5,7 +5,7 @@
@@ -131,10 +131,10 @@ functions), but it doesn't allow you to easily integrate a Module-3 module into
a C/C++ project.
-
25.2 Conception
+
26.2 Conception
-
25.2.1 Interfaces to C libraries
+
26.2.1 Interfaces to C libraries
@@ -142,7 +142,7 @@ Modula-3 has integrated support for calling C functions.
This is also extensively used by the standard Modula-3 libraries
to call OS functions.
The Modula-3 part of SWIG and the corresponding SWIG library
-modula3.swg
+modula3.swg
contain code that uses these features.
Because of the built-in support there is no need
for calling the SWIG kernel to generate wrappers written in C.
@@ -283,7 +283,7 @@ and the principal type must be renamed (%typemap).
-
25.2.2 Interfaces to C++ libraries
+
26.2.2 Interfaces to C++ libraries
@@ -384,24 +384,23 @@ There is no C++ library I wrote a SWIG interface for,
so I'm not sure if this is possible or sensible, yet.
-
25.3 Preliminaries
+
26.3 Preliminaries
-
25.3.1 Compilers
+
26.3.1 Compilers
There are different Modula-3 compilers around:
cm3, pm3, ezm3, Klagenfurth Modula-3, Cambridge Modula-3.
SWIG itself does not contain compiler specific code
-but the library file
-modula3.swg
+but the modula3.swg library file
may do so.
For testing examples I use Critical Mass cm3.
-
25.3.2 Additional Commandline Options
+
26.3.2 Additional Commandline Options
@@ -478,10 +477,10 @@ Instead generate templates for some basic typemaps.
-
25.4 Modula-3 typemaps
+
26.4 Modula-3 typemaps
-
25.4.1 Inputs and outputs
+
26.4.1 Inputs and outputs
@@ -499,9 +498,7 @@ or for a return value.
A further typemap may specify
the direction that is used for certain parameters.
I have chosen this separation
-in order to be able to write general typemaps for the typemap library
-modula3.swg
-.
+in order to be able to write general typemaps for the modula3.swg typemap library.
In the library code the final usage of the type is not known.
Using separate typemaps for each possible use
allows appropriate definitions for each case.
@@ -697,7 +694,7 @@ consist of the following parts:
-
25.4.2 Subranges, Enumerations, Sets
+
26.4.2 Subranges, Enumerations, Sets
@@ -749,7 +746,7 @@ that I'd like to automate.
-
25.4.3 Objects
+
26.4.3 Objects
@@ -762,7 +759,7 @@ is not really useful, yet.
-
25.4.4 Imports
+
26.4.4 Imports
@@ -782,9 +779,7 @@ Unqualified import is not supported.
It is cumbersome to add this typemap to each piece of Modula-3 code.
It is especially useful when writing general typemaps
-for the typemap library
-modula3.swg
-.
+for the modula3.swg typemap library.
For a monolithic module you might be better off
if you add the imports directly:
@@ -797,7 +792,7 @@ IMPORT M3toC;
-
25.4.5 Exceptions
+
26.4.5 Exceptions
@@ -821,7 +816,7 @@ you should declare
%typemap("m3wrapinconv:throws") blah * %{OSError.E%}.
-
25.4.6 Example
+
26.4.6 Example
@@ -868,10 +863,10 @@ where almost everything is generated by a typemap:
-
25.5 More hints to the generator
+
26.5 More hints to the generator
-
25.5.1 Features
+
26.5.1 Features
@@ -908,7 +903,7 @@ where almost everything is generated by a typemap:
-
25.5.2 Pragmas
+
26.5.2 Pragmas
@@ -931,7 +926,7 @@ where almost everything is generated by a typemap:
-
25.6 Remarks
+
26.6 Remarks
diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
index 69cc58c30..70b0f1181 100644
--- a/Doc/Manual/Modules.html
+++ b/Doc/Manual/Modules.html
@@ -138,7 +138,8 @@ base class's methods. Typically you will get a warning when the module name is m
-derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either import
+derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either
+import
the appropriate module interface file or specify the name of the module in the %import directive.
diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
index 4351e34a7..984b2dded 100644
--- a/Doc/Manual/Mzscheme.html
+++ b/Doc/Manual/Mzscheme.html
@@ -2,17 +2,19 @@
-SWIG and MzScheme
+SWIG and MzScheme/Racket
-
-This section contains information on SWIG's support of MzScheme.
+This section contains information on SWIG's support of Racket, formally known as MzScheme.
-
26.1 Creating native MzScheme structures
+
27.1 Creating native structures
@@ -63,8 +65,116 @@ Then in scheme, you can use regular struct access procedures like
+
27.2 Simple example
+
+
-That's pretty much it. It works with nested structs as well.
+A few examples are available in the Examples/mzscheme directory.
+The code and log of a session using SWIG below should help getting started.
+
+
+
+C header file:
+
+
+
+
+// example.h
+int fact(int n);
+
+
+
+
+C source code:
+
+
+
+
+// File: example.c
+#include "example.h"
+
+int fact(int n) {
+ if (n < 0) { /* This should probably return an error, but this is simpler */
+ return 0;
+ }
+ if (n == 0) {
+ return 1;
+ }
+ else {
+ /* testing for overflow would be a good idea here */
+ return n * fact(n-1);
+ }
+}
+
+The session below using the above files is on an OS X machine, but the points to be made are more general. On OS X, libtool is the tool which creates libraries, which are named .dylib, rather than .so on other unixes, or .dll on Windows.
+
+
+
+
+% swig -mzscheme -declaremodule example.i
+% gcc -c -m32 -o example.o example.c # force 32-bit object file (mzscheme is 32-bit only)
+% libtool -dynamic -o libexample.dylib example.o # make it into a library
+% ls # what've we got so far?
+example.c example.o
+example.h example_wrap.c
+example.i libexample.dylib*
+% mzc --cgc --cc example_wrap.c # compile the wrapping code
+% LDFLAGS="-L. -lexample" mzc --ld example_wrap.dylib example_wrap.o # ...and link it
+% mzscheme -e '(path->string (build-path "compiled" "native" (system-library-subpath)))'
+"compiled/native/i386-macosx/3m"
+% mkdir -p compiled/native/i386-macosx/3m # move the extension library to a magic place
+% mv example_wrap.dylib compiled/native/i386-macosx/3m/example_ss.dylib
+% mzscheme
+Welcome to MzScheme v4.2.4 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
+> (require "example.ss")
+> (fact 5)
+120
+> ^D
+% echo 'It works!'
+
+
+
+
+
+Some points of interest:
+
+
+
This is on a 64-bit machine, so we have to include the -m32 option when building the object file
+
If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
+
Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
+
Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
+
The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
+
+
+
27.3 External documentation
+
+
+
+See the C API for more description of using the mechanism for adding extensions. The main documentation is here.
+
+
+
+Tip: mzc's --vv option is very useful for debugging the inevitable library problems you'll encounter.
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
The Ocaml Website.
-
27.1 Preliminaries
+
28.1 Preliminaries
@@ -93,13 +93,13 @@ examples and test-suite which come with SWIG. You can do this by running
The Ocaml module has been tested using the system's dynamic linking (the
usual -lxxx against libxxx.so, as well as with Gerd Stolpmann's
Dl package
+ href="http://download.camlcity.org/download/">Dl package
. The ocaml_dynamic and ocaml_dynamic_cpp targets in the
file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
-
27.1.1 Running SWIG
+
28.1.1 Running SWIG
@@ -122,7 +122,7 @@ you will compile the file example_wrap.c with ocamlc or
the resulting .ml and .mli files as well, and do the final link with -custom
(not needed for native link).
-
27.1.2 Compiling the code
+
28.1.2 Compiling the code
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
-
27.1.3 The camlp4 module
+
28.1.3 The camlp4 module
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
-
27.1.4 Using your module
+
28.1.4 Using your module
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom
option is not needed when you build native code.
-
27.1.5 Compilation problems and compiling with C++
+
28.1.5 Compilation problems and compiling with C++
@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler.
Most code meant to be compiled as C++ will not have problems.
-
27.2 The low-level Ocaml/C interface
+
28.2 The low-level Ocaml/C interface
@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a
signature for a function that uses value in this way.
-
27.2.1 The generated module
+
28.2.1 The generated module
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
-
27.2.2 Enums
+
28.2.2 Enums
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
-
27.2.2.1 Enum typing in Ocaml
+
28.2.2.1 Enum typing in Ocaml
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master
values using the swig_val function before sharing them with another module.
-
27.2.3 Arrays
+
28.2.3 Arrays
-
27.2.3.1 Simple types of bounded arrays
+
28.2.3.1 Simple types of bounded arrays
@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works
for arrays whose bounds are completely specified.
-
27.2.3.2 Complex and unbounded arrays
+
28.2.3.2 Complex and unbounded arrays
@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array,
so you have to specify it for yourself in the form of a typemap.
-
27.2.3.3 Using an object
+
28.2.3.3 Using an object
@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex,
such as using a required sentinel, etc.
-
27.2.3.4 Example typemap for a function taking float * and int
+
28.2.3.4 Example typemap for a function taking float * and int
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
-
27.2.4 C++ Classes
+
28.2.4 C++ Classes
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
returned value for the same object.
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
containing the string "hi" in a button.
-
27.2.5 Director Classes
+
28.2.5 Director Classes
-
27.2.5.1 Director Introduction
+
28.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo {
};
-
27.2.5.2 Overriding Methods in Ocaml
+
28.2.5.2 Overriding Methods in Ocaml
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing
an overloaded class. This example is contained in Examples/ocaml/shapes.
-
27.2.5.3 Director Usage Example
+
28.2.5.3 Director Usage Example
@@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
program in C++.
-
27.2.5.4 Creating director objects
+
28.2.5.4 Creating director objects
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
-
27.2.5.5 Typemaps for directors, directorin, directorout, directorargout
+
28.2.5.5 Typemaps for directors, directorin, directorout, directorargout
@@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments,
and to receive arguments the same way you normally receive function returns.
-
27.2.5.6 directorin typemap
+
28.2.5.6 directorin typemap
@@ -950,7 +950,7 @@ code receives when you are called. In general, a simple directorin typ
can use the same body as a simple out typemap.
-
27.2.5.7 directorout typemap
+
28.2.5.7 directorout typemap
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
-
27.2.5.8 directorargout typemap
+
28.2.5.8 directorargout typemap
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
Octave is a high-level language intended for numerical programming that is mostly compatible with MATLAB.
-More information can be found at www.octave.org.
+More information can be found at Octave web site.
The SWIG implemention was first based on Octave 2.9.12, so this is the minimum version required. Testing has only been done on Linux.
-
28.2 Running SWIG
+
29.2 Running SWIG
@@ -97,7 +97,7 @@ This creates a C++ source file example_wrap.cxx. A C++ file is generate
The swig command line has a number of options you can use, like to redirect it's output. Use swig --help to learn about these.
@@ -326,7 +326,7 @@ octave:2> f=example.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2
-
28.3.6 Structures and C++ classes
+
29.3.6 Structures and C++ classes
@@ -461,7 +461,7 @@ ans = 1
Depending on the ownership setting of a swig_ref, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
-
28.3.7 C++ inheritance
+
29.3.7 C++ inheritance
@@ -470,7 +470,7 @@ This information contains the full class hierarchy. When an indexing operation (
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the swig_ref.
-
28.3.8 C++ overloaded functions
+
29.3.8 C++ overloaded functions
@@ -480,7 +480,7 @@ The dispatch function selects which overload to call (if any) based on the passe
typecheck typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
-
28.3.9 C++ operators
+
29.3.9 C++ operators
@@ -580,7 +580,7 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
-
C++ smart pointers are fully supported as in other modules.
-
28.3.13 Directors (calling Octave from C++ code)
+
29.3.13 Directors (calling Octave from C++ code)
@@ -755,7 +755,8 @@ Note that you have to enable directors via the %feature directive (see other mod
subclass() will accept any number of C++ bases or other subclass()'ed objects, (string,octave_value) pairs, and function_handles. In the first case, these are taken as base classes; in the second case, as named members (either variables or functions, depending on whether the given value is a function handle); in the third case, as member functions whose name is taken from the given function handle. E.g.,
You can also assign non-C++ member variables and functions after construct time. There is no support for non-C++ static members.
@@ -774,14 +775,14 @@ c-side routine called
octave-side routine called
-
28.3.14 Threads
+
29.3.14 Threads
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
-
28.3.15 Memory management
+
29.3.15 Memory management
@@ -815,14 +816,14 @@ The %newobject directive may be used to control this behavior for pointers retur
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/subclass()'ing).
-
28.3.16 STL support
+
29.3.16 STL support
Various STL library files are provided for wrapping STL containers.
@@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions
may not compile or run correctly.
-
29.1 Overview
+
30.1 Overview
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
-
29.2 Preliminaries
+
30.2 Preliminaries
@@ -133,7 +133,7 @@ To build the module, you will need to compile the file
example_wrap.c and link it with the rest of your program.
-
29.2.1 Getting the right header files
+
30.2.1 Getting the right header files
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
-
29.2.2 Compiling a dynamic module
+
30.2.2 Compiling a dynamic module
@@ -198,7 +198,7 @@ the target should be named `example.so',
`example.sl', or the appropriate dynamic module name on your system.
-
29.2.3 Building a dynamic module with MakeMaker
+
30.2.3 Building a dynamic module with MakeMaker
@@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
and Randal Schwartz.
-
29.2.4 Building a static version of Perl
+
30.2.4 Building a static version of Perl
@@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with
additional libraries such as -lsocket, -lnsl, -ldl, etc.
-
29.2.5 Using the module
+
30.2.5 Using the module
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
29.2.6 Compilation problems and compiling with C++
+
30.2.6 Compilation problems and compiling with C++
@@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
any conflicting macros you find to swig-user mailing list.
-
29.2.7 Compiling for 64-bit platforms
+
30.2.7 Compiling for 64-bit platforms
@@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
29.3 Building Perl Extensions under Windows
+
30.3 Building Perl Extensions under Windows
@@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++
although the procedure may be similar with other compilers.
-
29.3.1 Running SWIG from Developer Studio
+
30.3.1 Running SWIG from Developer Studio
@@ -700,7 +700,7 @@ print "$a\n";
-
29.3.2 Using other compilers
+
30.3.2 Using other compilers
@@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
For general hints and suggestions refer to the Windows chapter.
-
29.4 The low-level interface
+
30.4 The low-level interface
@@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to
construct more user-friendly proxy classes as described in the next section.
-
29.4.1 Functions
+
30.4.1 Functions
@@ -741,7 +741,7 @@ use example;
$a = &example::fact(2);
-
29.4.2 Global variables
+
30.4.2 Global variables
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
-
29.4.3 Constants
+
30.4.3 Constants
@@ -851,7 +851,7 @@ print example::FOO,"\n";
-
29.4.4 Pointers
+
30.4.4 Pointers
@@ -960,7 +960,7 @@ as XS and xsubpp. Given the advancement of the SWIG typesystem and the
SWIG and XS, this is no longer supported.
@@ -1159,7 +1159,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
can be built using these low-level accessors. This is described shortly.
-
29.4.7 C++ classes and type-checking
+
30.4.7 C++ classes and type-checking
@@ -1195,7 +1195,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
multiple inheritance is used).
-
29.4.8 C++ overloaded functions
+
30.4.8 C++ overloaded functions
@@ -1239,7 +1239,7 @@ example::Spam_foo_d($s,3.14);
Please refer to the "SWIG Basics" chapter for more information.
-
29.4.9 Operators
+
30.4.9 Operators
@@ -1266,7 +1266,7 @@ The following C++ operators are currently supported by the Perl module:
operator or
-
29.4.10 Modules and packages
+
30.4.10 Modules and packages
@@ -1361,7 +1361,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
-->
-
29.5 Input and output parameters
+
30.5 Input and output parameters
@@ -1580,7 +1580,7 @@ print "$c\n";
Note: The REFERENCE feature is only currently supported for numeric types (integers and floating point).
-
29.6 Exception handling
+
30.6 Exception handling
@@ -1745,7 +1745,7 @@ This is still supported, but it is deprecated. The newer %exception di
functionality, but it has additional capabilities that make it more powerful.
-
29.7 Remapping datatypes with typemaps
+
30.7 Remapping datatypes with typemaps
@@ -1762,7 +1762,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Perl interface.
@@ -2358,7 +2358,7 @@ the "in" typemap in the previous section would be used to convert an
to copy the converted array into a C data structure.
-
29.8.5 Turning Perl references into C pointers
+
30.8.5 Turning Perl references into C pointers
@@ -2423,7 +2423,7 @@ print "$c\n";
-
29.8.6 Pointer handling
+
30.8.6 Pointer handling
@@ -2502,7 +2502,7 @@ For example:
-
29.9 Proxy classes
+
30.9 Proxy classes
@@ -2518,7 +2518,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
-
29.9.1 Preliminaries
+
30.9.1 Preliminaries
@@ -2540,7 +2540,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
-
29.9.2 Structure and class wrappers
+
30.9.2 Structure and class wrappers
@@ -2666,7 +2666,7 @@ $v->DESTROY();
-
29.9.3 Object Ownership
+
30.9.3 Object Ownership
@@ -2753,7 +2753,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
@@ -75,7 +75,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
-
30.1 Generating PHP Extensions
+
31.1 Generating PHP Extensions
@@ -122,7 +122,7 @@ and it doesn't play nicely with package system. We don't recommend
this approach, or provide explicit support for it.
-
30.1.1 Building a loadable extension
+
31.1.1 Building a loadable extension
@@ -137,7 +137,7 @@ least work for Linux though):
gcc -shared example_wrap.o -o example.so
-
30.1.2 Using PHP Extensions
+
31.1.2 Using PHP Extensions
@@ -168,7 +168,7 @@ attempts to do the dl() call for you:
include("example.php");
-
30.2 Basic PHP interface
+
31.2 Basic PHP interface
@@ -178,7 +178,7 @@ possible for names of symbols in one extension module to clash with
other symbols unless care is taken to %rename them.
-
30.2.1 Constants
+
31.2.1 Constants
@@ -303,7 +303,7 @@ both point to the same value, without the case test taking place. (
Apologies, this paragraph needs rewriting to make some sense. )
-
30.2.2 Global Variables
+
31.2.2 Global Variables
@@ -352,7 +352,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
-
30.2.3 Functions
+
31.2.3 Functions
@@ -405,7 +405,7 @@ print $s; # The value of $s was not changed.
-->
-
30.2.4 Overloading
+
31.2.4 Overloading
@@ -461,7 +461,7 @@ taking the integer argument.
-->
-
30.2.5 Pointers and References
+
31.2.5 Pointers and References
@@ -593,7 +593,7 @@ PHP in a number of ways: by using unset on an existing
variable, or assigning NULL to a variable.
-
30.2.6 Structures and C++ classes
+
31.2.6 Structures and C++ classes
@@ -652,7 +652,7 @@ Would be used in the following way from PHP5:
Member variables and methods are accessed using the -> operator.
@@ -719,7 +719,7 @@ the programmer can either reassign the variable or call
unset($v)
-
30.2.6.3 Static Member Variables
+
31.2.6.3 Static Member Variables
@@ -762,7 +762,7 @@ Ko::threats(10);
echo "There has now been " . Ko::threats() . " threats\n";
-
30.2.6.4 Static Member Functions
+
31.2.6.4 Static Member Functions
@@ -784,7 +784,7 @@ Ko::threats();
-
30.2.7 PHP Pragmas, Startup and Shutdown code
+
31.2.7 PHP Pragmas, Startup and Shutdown code
@@ -872,7 +872,7 @@ The %rinit and %rshutdown statements are very similar but inse
into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.
-
30.3 Cross language polymorphism
+
31.3 Cross language polymorphism
@@ -907,7 +907,7 @@ wrapper functions takes care of all the cross-language method routing
transparently.
-
30.3.1 Enabling directors
+
31.3.1 Enabling directors
@@ -999,7 +999,7 @@ class MyFoo extends Foo {
-
30.3.2 Director classes
+
31.3.2 Director classes
@@ -1079,7 +1079,7 @@ so there is no need for the extra overhead involved with routing the
calls through PHP.
-
30.3.3 Ownership and object destruction
+
31.3.3 Ownership and object destruction
@@ -1135,7 +1135,7 @@ In this example, we are assuming that FooContainer will take care of
deleting all the Foo pointers it contains at some point.
-
30.3.4 Exception unrolling
+
31.3.4 Exception unrolling
@@ -1194,7 +1194,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception
as soon as the C wrapper function returns.
-
30.3.5 Overhead and code bloat
+
31.3.5 Overhead and code bloat
@@ -1227,7 +1227,7 @@ optimized by selectively enabling director methods (using the %feature
directive) for only those methods that are likely to be extended in PHP.
-
30.3.6 Typemaps
+
31.3.6 Typemaps
@@ -1241,7 +1241,7 @@ need to be supported.
-
30.3.7 Miscellaneous
+
31.3.7 Miscellaneous
Director typemaps for STL classes are mostly in place, and hence you
diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
index 8f9e43735..8bd6b410f 100644
--- a/Doc/Manual/Pike.html
+++ b/Doc/Manual/Pike.html
@@ -6,7 +6,7 @@
-
31 SWIG and Pike
+
32 SWIG and Pike
@@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics"
chapter.
-
31.1 Preliminaries
+
32.1 Preliminaries
-
31.1.1 Running SWIG
+
32.1.1 Running SWIG
@@ -94,7 +94,7 @@ can use the -o option:
$ swig -pike -o pseudonym.c example.i
-
31.1.2 Getting the right header files
+
32.1.2 Getting the right header files
@@ -114,7 +114,7 @@ You're looking for files with the names global.h, program.h
and so on.
@@ -128,7 +129,7 @@ very least, make sure you read the "SWIG
Basics" chapter.
-
32.1 Overview
+
33.1 Overview
@@ -155,10 +156,10 @@ described followed by a discussion of low-level implementation
details.
-
32.2 Preliminaries
+
33.2 Preliminaries
-
32.2.1 Running SWIG
+
33.2.1 Running SWIG
@@ -256,13 +257,13 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
-
32.2.2 Using distutils
+
33.2.2 Using distutils
The preferred approach to building an extension module for python is to compile it with
distutils, which comes with all recent versions of python
-(Distutils Docs).
+(Distutils Docs).
@@ -348,7 +349,7 @@ This same approach works on all platforms if the appropriate compiler is install
can even build extensions to the standard Windows Python using MingGW)
-
32.2.3 Hand compiling a dynamic module
+
33.2.3 Hand compiling a dynamic module
@@ -396,7 +397,7 @@ module actually consists of two files; socket.py and
-
32.2.4 Static linking
+
33.2.4 Static linking
@@ -475,7 +476,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
-
32.2.5 Using your module
+
33.2.5 Using your module
@@ -632,7 +633,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
32.2.6 Compilation of C++ extensions
+
33.2.6 Compilation of C++ extensions
@@ -724,7 +725,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
32.2.7 Compiling for 64-bit platforms
+
33.2.7 Compiling for 64-bit platforms
@@ -761,7 +762,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
-
32.2.8 Building Python Extensions under Windows
+
33.2.8 Building Python Extensions under Windows
@@ -870,7 +871,7 @@ SWIG Wiki.
-
32.3 A tour of basic C/C++ wrapping
+
33.3 A tour of basic C/C++ wrapping
@@ -879,7 +880,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as
This section briefly covers the essential aspects of this wrapping.
-
32.3.1 Modules
+
33.3.1 Modules
@@ -892,7 +893,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
-
32.3.2 Functions
+
33.3.2 Functions
@@ -916,7 +917,7 @@ like you think it does:
>>>
-
32.3.3 Global variables
+
33.3.3 Global variables
@@ -1054,7 +1055,7 @@ that starts with a leading underscore. SWIG does not create cvar
if there are no global variables in a module.
-
32.3.4 Constants and enums
+
33.3.4 Constants and enums
@@ -1094,7 +1095,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
-
32.3.5 Pointers
+
33.3.5 Pointers
@@ -1235,7 +1236,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
32.3.6 Structures
+
33.3.6 Structures
@@ -1424,7 +1425,7 @@ everything works just like you would expect. For example:
-
32.3.7 C++ classes
+
33.3.7 C++ classes
@@ -1513,7 +1514,7 @@ they are accessed through cvar like this:
-
32.3.8 C++ inheritance
+
33.3.8 C++ inheritance
@@ -1568,7 +1569,7 @@ then the function spam() accepts Foo * or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
-
32.3.9 Pointers, references, values, and arrays
+
33.3.9 Pointers, references, values, and arrays
@@ -1629,7 +1630,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
-
32.3.10 C++ overloaded functions
+
33.3.10 C++ overloaded functions
@@ -1752,7 +1753,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
32.3.11 C++ operators
+
33.3.11 C++ operators
@@ -1841,7 +1842,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance
overloaded assignment operators don't map to Python semantics and will be ignored.
-
32.3.12 C++ namespaces
+
33.3.12 C++ namespaces
@@ -1908,7 +1909,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
-
32.3.13 C++ templates
+
33.3.13 C++ templates
@@ -1962,7 +1963,7 @@ Some more complicated
examples will appear later.
-
32.3.14 C++ Smart Pointers
+
33.3.14 C++ Smart Pointers
@@ -2047,7 +2048,7 @@ simply use the __deref__() method. For example:
-
32.3.15 C++ Reference Counted Objects (ref/unref)
+
33.3.15 C++ Reference Counted Objects (ref/unref)
@@ -2190,7 +2191,7 @@ python releases the proxy instance.
-
32.4 Further details on the Python class interface
+
33.4 Further details on the Python class interface
@@ -2203,7 +2204,17 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
-
32.4.1 Proxy classes
+
New in SWIG version 2.0.4:
+The use of Python proxy classes has performance implications that may be
+unacceptable for a high-performance library. The new -builtin
+option instructs SWIG to forego the use of proxy classes, and instead
+create wrapped types as new built-in Python types. When this option is used,
+the following section ("Proxy classes") does not apply. Details on the use of
+the -builtin option are in the Built-in Classes
+section.
+
+
+
33.4.1 Proxy classes
@@ -2292,8 +2303,280 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
-
32.4.2 Memory management
+
33.4.2 Built-in Classes
+
+The -builtin option provides a significant performance improvement
+in the wrapped code. To understand the difference between proxy classes
+and built-in types, let's take a look at what a wrapped object looks like
+under both circumstances.
+
+
+
When proxy classes are used, each wrapped object in python is an instance
+of a pure python class. As a reminder, here is what the __init__ method looks
+like in a proxy class:
+
When a Foo instance is created, the call to _example.new_Foo()
+creates a new C++ Foo instance; wraps that C++ instance inside an instance of
+a python built-in type called SwigPyObject; and stores the SwigPyObject
+instance in the 'this' field of the python Foo object. Did you get all that? So, the
+python Foo object is composed of three parts:
+
+
+
The python Foo instance, which contains...
+
... an instance of struct SwigPyObject, which contains...
+
... a C++ Foo instance
+
+
+
When -builtin is used, the pure python layer is stripped off. Each
+wrapped class is turned into a new python built-in type which inherits from
+SwigPyObject, and SwigPyObject instances are returned directly
+from the wrapped methods. For more information about python built-in extensions,
+please refer to the python documentation:
Use of the -builtin option implies a couple of limitations:
+
+
python version support:
+
+
Versions 2.5 and up are fully supported
+
Versions 2.3 and 2.4 are mostly supported; there are problems with director classes and/or sub-classing a wrapped type in python.
+
Versions older than 2.3 are not supported.
+
+
Some legacy syntax is no longer supported; in particular:
+
+
The functional interface is no longer exposed. For example, you may no longer call Whizzo.new_CrunchyFrog(). Instead, you must use Whizzo.CrunchyFrog().
+
Static member variables are no longer accessed through the 'cvar' field (e.g., Dances.cvar.FishSlap).
+They are instead accessed in the idiomatic way (Dances.FishSlap).
+
+
Wrapped types may not be raised as python exceptions. Here's why: the python internals expect that all sub-classes of Exception will have this struct layout:
Reverse binary operators (e.g., __radd__) are not supported.
+
+
+
+
+To illustrate the last point, if you have a wrapped class called MyString,
+and you want to use instances of MyString interchangeably with native python
+strings, you can define an 'operator+ (const char*)' method :
+
+The above code fails, because the first operand -- a native python string --
+doesn't know how to add an instance of MyString to itself.
+
+
+
33.4.2.2 Operator overloads -- use them!
+
+
The entire justification for the -builtin option is improved
+performance. To that end, the best way to squeeze maximum performance out
+of your wrappers is to use operator overloads.
+Named method dispatch is slow in python, even when compared to other scripting languages.
+However, python built-in types have a large number of "slots",
+analogous to C++ operator overloads, which allow you to short-circuit named method dispatch
+for certain common operations.
+
+
+
By default, SWIG will translate most C++ arithmetic operator overloads into python
+slot entries. For example, suppose you have this class:
+
+
The last two lines of the python code are equivalent,
+but the line that uses the '+' operator is much faster.
+
+
+
In-place operators (e.g., operator+=) and comparison operators
+(operator==, operator<, etc.) are also converted to python
+slot operators. For a complete list of C++ operators that are
+automatically converted to python slot operators, refer to the file
+python/pyopers.swig in the SWIG library.
+
+
+
There are other very useful python slots that you
+may explicitly define using %feature directives. For example,
+suppose you want to use instances of a wrapped class as keys in a native python
+dict. That will work as long as you define a hash function for
+instances of your class, and use it to define the python tp_hash
+slot:
+
Because you defined the tp_hash slot, Cheese objects may
+be used as hash keys; and when the cheeseHashFunc method is invoked
+by a python dict, it will not go through named method dispatch.
+A more detailed discussion about %feature("python:slot") can be found
+in the file python/pyopers.swig in the SWIG library.
+You can read about all of the available python slots here:
You may override (almost) all of the slots defined in the PyTypeObject,
+PyNumberMethods, PyMappingMethods, PySequenceMethods, and PyBufferProcs
+structs.
+
+
+
+
33.4.3 Memory management
+
+
NOTE: Although this section refers to proxy objects, everything here also applies
+when the -builtin option is used.
Associated with proxy object, is an ownership flag .thisown The value of this
@@ -2484,7 +2767,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
-
32.4.3 Python 2.2 and classic classes
+
33.4.4 Python 2.2 and classic classes
@@ -2521,7 +2804,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
-
32.5 Cross language polymorphism
+
33.5 Cross language polymorphism
@@ -2555,7 +2838,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
-
32.5.1 Enabling directors
+
33.5.1 Enabling directors
@@ -2648,7 +2931,7 @@ class MyFoo(mymodule.Foo):
-
32.5.2 Director classes
+
33.5.2 Director classes
@@ -2730,7 +3013,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
-
32.5.3 Ownership and object destruction
+
33.5.3 Ownership and object destruction
@@ -2797,7 +3080,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
-
32.5.4 Exception unrolling
+
33.5.4 Exception unrolling
@@ -2856,7 +3139,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
-
32.5.5 Overhead and code bloat
+
33.5.5 Overhead and code bloat
@@ -2890,7 +3173,7 @@ directive) for only those methods that are likely to be extended in
Python.
-
32.5.6 Typemaps
+
33.5.6 Typemaps
@@ -2904,7 +3187,7 @@ need to be supported.
-
32.5.7 Miscellaneous
+
33.5.7 Miscellaneous
@@ -2951,7 +3234,7 @@ methods that return const references.
-
32.6 Common customization features
+
33.6 Common customization features
@@ -2964,7 +3247,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
-
32.6.1 C/C++ helper functions
+
33.6.1 C/C++ helper functions
@@ -3045,7 +3328,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
-
32.6.2 Adding additional Python code
+
33.6.2 Adding additional Python code
@@ -3194,7 +3477,7 @@ public:
-
32.6.3 Class extension with %extend
+
33.6.3 Class extension with %extend
@@ -3283,7 +3566,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
-
32.6.4 Exception handling with %exception
+
33.6.4 Exception handling with %exception
@@ -3409,7 +3692,7 @@ The language-independent exception.i library file can also be used
to raise exceptions. See the SWIG Library chapter.
-
32.7 Tips and techniques
+
33.7 Tips and techniques
@@ -3419,7 +3702,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
-
32.7.1 Input and output parameters
+
33.7.1 Input and output parameters
@@ -3632,7 +3915,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
32.7.2 Simple pointers
+
33.7.2 Simple pointers
@@ -3701,7 +3984,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.
-
32.7.3 Unbounded C Arrays
+
33.7.3 Unbounded C Arrays
@@ -3763,7 +4046,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
32.7.4 String handling
+
33.7.4 String handling
@@ -3832,7 +4115,7 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-
32.8 Typemaps
+
33.8 Typemaps
@@ -3849,7 +4132,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Python interface or if you want to elevate your guru status.
-
32.8.1 What is a typemap?
+
33.8.1 What is a typemap?
@@ -3965,7 +4248,7 @@ parameter is omitted):
-
32.8.2 Python typemaps
+
33.8.2 Python typemaps
@@ -4006,7 +4289,7 @@ a look at the SWIG library version 1.3.20 or so.
-
32.8.3 Typemap variables
+
33.8.3 Typemap variables
@@ -4077,7 +4360,7 @@ properly assigned.
The Python name of the wrapper function being created.
-
32.8.4 Useful Python Functions
+
33.8.4 Useful Python Functions
@@ -4205,7 +4488,7 @@ write me
-
32.9 Typemap Examples
+
33.9 Typemap Examples
@@ -4214,7 +4497,7 @@ might look at the files "python.swg" and "typemaps.i" in
the SWIG library.
-
32.9.1 Converting Python list to a char **
+
33.9.1 Converting Python list to a char **
@@ -4294,7 +4577,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
-
32.9.2 Expanding a Python object into multiple arguments
+
33.9.2 Expanding a Python object into multiple arguments
@@ -4373,7 +4656,7 @@ to supply the argument count. This is automatically set by the typemap code. F
-
32.9.3 Using typemaps to return arguments
+
33.9.3 Using typemaps to return arguments
@@ -4462,7 +4745,7 @@ function can now be used as follows:
>>>
-
32.9.4 Mapping Python tuples into small arrays
+
33.9.4 Mapping Python tuples into small arrays
@@ -4511,7 +4794,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
-
32.9.5 Mapping sequences to C arrays
+
33.9.5 Mapping sequences to C arrays
@@ -4592,7 +4875,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
%}
%typemap(in) double [ANY](double temp[$1_dim0]) {
- if (!convert_darray($input,temp,$1_dim0))) {
+ if (!convert_darray($input,temp,$1_dim0)) {
return NULL;
}
$1 = &temp[0];
@@ -4600,7 +4883,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
-
32.9.6 Pointer handling
+
33.9.6 Pointer handling
@@ -4697,7 +4980,7 @@ class object (if applicable).
-
32.10 Docstring Features
+
33.10 Docstring Features
@@ -4725,7 +5008,7 @@ of your users much simpler.
-
32.10.1 Module docstring
+
33.10.1 Module docstring
@@ -4759,7 +5042,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
-
32.10.2 %feature("autodoc")
+
33.10.2 %feature("autodoc")
@@ -4786,7 +5069,7 @@ names, default values if any, and return type if any. There are also
three options for autodoc controlled by the value given to the
feature, described below.
-
@@ -4918,7 +5201,7 @@ and also in base class declarations, etc. if the package name is
different than its own.
-
32.12 Python 3 Support
+
33.12 Python 3 Support
@@ -4945,7 +5228,7 @@ The following are Python 3.0 new features that are currently supported by
SWIG.
-
32.12.1 Function annotation
+
33.12.1 Function annotation
@@ -4977,7 +5260,7 @@ all overloaded functions share the same function in SWIG generated proxy class.
For detailed usage of function annotation, see PEP 3107.
@@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
-
33.1 Bugs
+
34.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
33.2 Using R and SWIG
+
34.2 Using R and SWIG
@@ -119,7 +119,7 @@ Without it, inheritance of wrapped objects may fail.
These two files can be loaded in any order
-
33.3 Precompiling large R files
+
34.3 Precompiling large R files
In cases where the R file is large, one make save a lot of loading
@@ -137,7 +137,7 @@ will save a large amount of loading time.
-
33.4 General policy
+
34.4 General policy
@@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
33.5 Language conventions
+
34.5 Language conventions
@@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
33.6 C++ classes
+
34.6 C++ classes
@@ -167,7 +167,7 @@ keep track of the pointer object which removes the necessity for a lot
of the proxy class baggage you see in other languages.
SWIG 1.3 is known to work with Ruby versions 1.6 and later.
@@ -171,7 +171,7 @@ of Ruby.
-
34.1.1 Running SWIG
+
35.1.1 Running SWIG
To build a Ruby module, run SWIG using the -ruby
@@ -225,7 +225,7 @@ to compile this file and link it with the rest of your program.
-
34.1.2 Getting the right header files
+
35.1.2 Getting the right header files
In order to compile the wrapper code, the compiler needs the ruby.h
@@ -274,7 +274,7 @@ installed, you can run Ruby to find out. For example:
-
34.1.3 Compiling a dynamic module
+
35.1.3 Compiling a dynamic module
Ruby extension modules are typically compiled into shared
@@ -428,7 +428,7 @@ manual pages for your compiler and linker to determine the correct set
of options. You might also check the SWIG Wiki
for additional information.
-
34.1.4 Using your module
+
35.1.4 Using your module
Ruby module names must be capitalized,
@@ -488,7 +488,7 @@ begins with:
-
34.1.5 Static linking
+
35.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -509,7 +509,7 @@ finally rebuilding Ruby.
-
34.1.6 Compilation of C++ extensions
+
35.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -561,7 +561,7 @@ extension, e.g.
-
34.2 Building Ruby Extensions under Windows 95/NT
+
35.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -600,7 +600,7 @@ files.
-
34.2.1 Running SWIG from Developer Studio
+
35.2.1 Running SWIG from Developer Studio
If you are developing your application within Microsoft
@@ -742,7 +742,7 @@ directory, then run the Ruby script from the DOS/Command prompt:
-
34.3 The Ruby-to-C/C++ Mapping
+
35.3 The Ruby-to-C/C++ Mapping
This section describes the basics of how SWIG maps C or C++
@@ -752,7 +752,7 @@ declarations in your SWIG interface files to Ruby constructs.
There are three ways to raise exceptions from C++ code to
@@ -4615,7 +4615,7 @@ the built-in Ruby exception types.
-
34.6.4 Exception classes
+
35.6.4 Exception classes
Starting with SWIG 1.3.28, the Ruby module supports the %exceptionclass
@@ -4673,7 +4673,7 @@ providing for a more natural integration between C++ code and Ruby code.
-
34.7 Typemaps
+
35.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4696,7 +4696,7 @@ of the primitive C-Ruby interface.
-
34.7.1 What is a typemap?
+
35.7.1 What is a typemap?
A typemap is nothing more than a code generation rule that is
@@ -4958,7 +4958,7 @@ to be used as follows (notice how the length parameter is omitted):
-
34.7.2 Typemap scope
+
35.7.2 Typemap scope
Once defined, a typemap remains in effect for all of the
@@ -5006,7 +5006,7 @@ where the class itself is defined. For example:
-
34.7.3 Copying a typemap
+
35.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5108,7 +5108,7 @@ rules as for
-
34.7.4 Deleting a typemap
+
35.7.4 Deleting a typemap
A typemap can be deleted by simply defining no code. For
@@ -5160,7 +5160,7 @@ typemaps immediately after the clear operation.
-
34.7.5 Placement of typemaps
+
35.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5244,7 +5244,7 @@ string
-
34.7.6 Ruby typemaps
+
35.7.6 Ruby typemaps
The following list details all of the typemap methods that
@@ -5254,7 +5254,7 @@ can be used by the Ruby module:
-
34.7.6.1 "in" typemap
+
35.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5497,7 +5497,7 @@ arguments to be specified. For example:
-
34.7.6.2 "typecheck" typemap
+
35.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5538,7 +5538,7 @@ on "Typemaps and Overloading."
-
34.7.6.3 "out" typemap
+
35.7.6.3 "out" typemap
Converts return value of a C function
@@ -5770,7 +5770,7 @@ version of the C datatype matched by the typemap.
-
34.7.6.4 "arginit" typemap
+
35.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5795,7 +5795,7 @@ applications. For example:
-
34.7.6.5 "default" typemap
+
35.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5837,7 +5837,7 @@ default argument wrapping.
-
34.7.6.6 "check" typemap
+
35.7.6.6 "check" typemap
The "check" typemap is used to supply value checking code
@@ -5861,7 +5861,7 @@ arguments have been converted. For example:
-
34.7.6.7 "argout" typemap
+
35.7.6.7 "argout" typemap
The "argout" typemap is used to return values from arguments.
@@ -6019,7 +6019,7 @@ some function like SWIG_Ruby_AppendOutput.
-
34.7.6.8 "freearg" typemap
+
35.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6055,7 +6055,7 @@ abort prematurely.
-
34.7.6.9 "newfree" typemap
+
35.7.6.9 "newfree" typemap
The "newfree" typemap is used in conjunction with the %newobject
@@ -6086,7 +6086,7 @@ ownership and %newobject for further details.
-
34.7.6.10 "memberin" typemap
+
35.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6119,7 +6119,7 @@ other objects.
-
34.7.6.11 "varin" typemap
+
35.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6130,7 +6130,7 @@ This is implementation specific.
-
34.7.6.12 "varout" typemap
+
35.7.6.12 "varout" typemap
The "varout" typemap is used to convert a C/C++ object to an
@@ -6141,7 +6141,7 @@ This is implementation specific.
-
34.7.6.13 "throws" typemap
+
35.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6200,7 +6200,7 @@ handling with %exception section.
-
34.7.6.14 directorin typemap
+
35.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6454,7 +6454,7 @@ referring to the class itself.
-
34.7.6.15 directorout typemap
+
35.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6714,7 +6714,7 @@ exception.
-
34.7.6.16 directorargout typemap
+
35.7.6.16 directorargout typemap
Output argument processing in director
@@ -6954,7 +6954,7 @@ referring to the instance of the class itself
-
34.7.6.17 ret typemap
+
35.7.6.17 ret typemap
Cleanup of function return values
@@ -6964,7 +6964,7 @@ referring to the instance of the class itself
-
34.7.6.18 globalin typemap
+
35.7.6.18 globalin typemap
Setting of C global variables
@@ -6974,7 +6974,7 @@ referring to the instance of the class itself
-
34.7.7 Typemap variables
+
35.7.7 Typemap variables
@@ -7084,7 +7084,7 @@ being created.
-
34.7.8 Useful Functions
+
35.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7108,7 +7108,7 @@ across multiple languages.
-
34.7.8.1 C Datatypes to Ruby Objects
+
35.7.8.1 C Datatypes to Ruby Objects
@@ -7164,7 +7164,7 @@ SWIG_From_float(float)
-
34.7.8.2 Ruby Objects to C Datatypes
+
35.7.8.2 Ruby Objects to C Datatypes
Here, while the Ruby versions return the value directly, the SWIG
@@ -7253,7 +7253,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-
The Ruby language doesn't support multiple inheritance, but
@@ -9796,7 +9796,7 @@ Features") for more details).
-
34.10 Memory Management
+
35.10 Memory Management
One of the most common issues in generating SWIG bindings for
@@ -9843,7 +9843,7 @@ understanding of how the underlying library manages memory.
-
34.10.1 Mark and Sweep Garbage Collector
+
35.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9891,7 +9891,7 @@ this memory.
-
34.10.2 Object Ownership
+
35.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10149,7 +10149,7 @@ public:
-
34.10.3 Object Tracking
+
35.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10400,7 +10400,7 @@ methods.
-
34.10.4 Mark Functions
+
35.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10518,7 +10518,7 @@ test suite.
-
34.10.5 Free Functions
+
35.10.5 Free Functions
By default, SWIG creates a "free" function that is called when
@@ -10768,7 +10768,7 @@ been freed, and thus raises a runtime exception.
-
34.10.6 Embedded Ruby and the C++ Stack
+
35.10.6 Embedded Ruby and the C++ Stack
As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index e51e55986..fd510f2a4 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -2002,22 +2002,6 @@ documentation is not exhaustive, see "%rename predicates" section of
swig.swg for the full list of supported match expressions.
-
-Another important feature of match is that it can be applied not
-only to the declaration itself but also to its enclosing declaration. So
-match$parentNode$name="SomeClass" would be true only for members of
-the C++ class with the specified name. This can, of course, be combined with
-more complicated matches making it possible to write
-
-to rename all enums nested in the given class to lower case.
-
-
In addition to literally matching some string with match you can
also use regexmatch or notregexmatch to match a string
@@ -2039,6 +2023,14 @@ declaration name directly can be preferable and can also be done using
%rename("$ignore", regextarget=1) "Old$";
+Notice that the check is done only against the name of the declaration
+itself, if you need to match the full name of a C++ declaration you
+must use fullname attribute:
+
As for notregexmatch, it restricts the match only to the strings not
@@ -2244,7 +2236,8 @@ rest to lower case.
And now, a final note about function pointer support. Although SWIG
does not normally allow callback functions to be written in the target language, this
can be accomplished with the use of typemaps and other advanced SWIG features.
-This is described in a later chapter.
+See the Typemaps chapter for more about typemaps
+and individual target language chapters for more on callbacks and the 'director' feature.
5.5 Structures and unions
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index f9bfc8ec6..c8e5ee870 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -4192,8 +4192,9 @@ In the example below, the generic template type is used to rename to bbb
-%rename(bbb) Space::ABC::aaa(T t); // will match but with lower precedence than ccc
-%rename(ccc) Space::ABC<Space::XYZ>::aaa(Space::XYZ t); // will match but with higher precedence than bbb
+%rename(bbb) Space::ABC::aaa(T t); // will match but with lower precedence than ccc
+%rename(ccc) Space::ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence
+ // than bbb
namespace Space {
class XYZ {};
@@ -4214,9 +4215,9 @@ Below shows how %rename can be placed inside a namespace.
namespace Space {
- %rename(bbb) ABC::aaa(T t); // will match but with lower precedence than ccc
- %rename(ccc) ABC<Space::XYZ>::aaa(Space::XYZ t); // will match but with higher precedence than bbb
- %rename(ddd) ABC<Space::XYZ>::aaa(XYZ t); // will not match
+ %rename(bbb) ABC::aaa(T t); // will match but with lower precedence than ccc
+ %rename(ccc) ABC<Space::XYZ>::aaa(Space::XYZ t);// will match but with higher precedence than bbb
+ %rename(ddd) ABC<Space::XYZ>::aaa(XYZ t); // will not match
}
namespace Space {
@@ -4238,11 +4239,11 @@ The following example shows how %rename can be placed within %extend.
namespace Space {
%extend ABC {
- %rename(bbb) aaa(T t); // will match but with lower precedence than ccc
+ %rename(bbb) aaa(T t); // will match but with lower precedence than ccc
}
%extend ABC<Space::XYZ> {
- %rename(ccc) aaa(Space::XYZ t); // will match but with higher precedence than bbb
- %rename(ddd) aaa(XYZ t); // will not match
+ %rename(ccc) aaa(Space::XYZ t);// will match but with higher precedence than bbb
+ %rename(ddd) aaa(XYZ t); // will not match
}
}
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 855244790..62305b9ed 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
SWIG-2.0 Documentation
-Last update : SWIG-2.0.2 (in progress)
+Last update : SWIG-2.0.4 (in progress)
Sections
@@ -36,13 +36,14 @@ Last update : SWIG-2.0.2 (in progress)
@@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
-
35.1 Preliminaries
+
36.1 Preliminaries
@@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
-
35.1.1 Getting the right header files
+
36.1.1 Getting the right header files
@@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that tcl.h
-
35.1.2 Compiling a dynamic module
+
36.1.2 Compiling a dynamic module
@@ -162,7 +162,7 @@ The name of the module is specified using the %module directive or the
-module command line option.
-
35.1.3 Static linking
+
36.1.3 Static linking
@@ -228,7 +228,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
-
35.1.4 Using your module
+
36.1.4 Using your module
@@ -356,7 +356,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
-
35.1.5 Compilation of C++ extensions
+
36.1.5 Compilation of C++ extensions
@@ -439,7 +439,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
35.1.6 Compiling for 64-bit platforms
+
36.1.6 Compiling for 64-bit platforms
@@ -466,7 +466,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
-
35.1.7 Setting a package prefix
+
36.1.7 Setting a package prefix
@@ -485,7 +485,7 @@ option will append the prefix to the name when creating a command and
call it "Foo_bar".
-
35.1.8 Using namespaces
+
36.1.8 Using namespaces
@@ -507,7 +507,7 @@ When the -namespace option is used, objects in the module
are always accessed with the namespace name such as Foo::bar.
-
35.2 Building Tcl/Tk Extensions under Windows 95/NT
+
36.2 Building Tcl/Tk Extensions under Windows 95/NT
@@ -518,7 +518,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
-
35.2.1 Running SWIG from Developer Studio
+
36.2.1 Running SWIG from Developer Studio
@@ -576,7 +576,7 @@ MSDOS > tclsh80
%
-
35.2.2 Using NMAKE
+
36.2.2 Using NMAKE
@@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
35.3 A tour of basic C/C++ wrapping
+
36.3 A tour of basic C/C++ wrapping
@@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
35.3.1 Modules
+
36.3.1 Modules
@@ -684,7 +684,7 @@ To fix this, supply an extra argument to load like this:
@@ -873,7 +873,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the global statement to be omitted.
-
35.3.5 Pointers
+
36.3.5 Pointers
@@ -969,7 +969,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
None if the conversion can't be performed.
-
35.3.6 Structures
+
36.3.6 Structures
@@ -1251,7 +1251,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
-
35.3.7 C++ classes
+
36.3.7 C++ classes
@@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows:
-
35.3.8 C++ inheritance
+
36.3.8 C++ inheritance
@@ -1367,7 +1367,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
35.3.9 Pointers, references, values, and arrays
+
36.3.9 Pointers, references, values, and arrays
@@ -1421,7 +1421,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
-
35.3.10 C++ overloaded functions
+
36.3.10 C++ overloaded functions
@@ -1544,7 +1544,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
35.3.11 C++ operators
+
36.3.11 C++ operators
@@ -1646,7 +1646,7 @@ There are ways to make this operator appear as part of the class using the %
Keep reading.
-
35.3.12 C++ namespaces
+
36.3.12 C++ namespaces
@@ -1710,7 +1710,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
@@ -2434,7 +2434,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "Customization Features" for more examples.
-
35.7 Typemaps
+
36.7 Typemaps
@@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
35.7.1 What is a typemap?
+
36.7.1 What is a typemap?
@@ -2568,7 +2568,7 @@ parameter is omitted):
-
35.7.2 Tcl typemaps
+
36.7.2 Tcl typemaps
@@ -2706,7 +2706,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
-
35.7.3 Typemap variables
+
36.7.3 Typemap variables
@@ -2777,7 +2777,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
35.7.4 Converting a Tcl list to a char **
+
36.7.4 Converting a Tcl list to a char **
@@ -2839,7 +2839,7 @@ argv[2] = Larry
3
-
35.7.5 Returning values in arguments
+
36.7.5 Returning values in arguments
@@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
35.7.6 Useful functions
+
36.7.6 Useful functions
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
35.7.7 Standard typemaps
+
36.7.7 Standard typemaps
@@ -3042,7 +3042,7 @@ work)
-
35.7.8 Pointer handling
+
36.7.8 Pointer handling
@@ -3118,7 +3118,7 @@ For example:
-
35.8 Turning a SWIG module into a Tcl Package.
+
36.8 Turning a SWIG module into a Tcl Package.
@@ -3190,7 +3190,7 @@ As a final note, most SWIG examples do not yet use the
to use the load command instead.
-
35.9 Building new kinds of Tcl interfaces (in Tcl)
+
36.9 Building new kinds of Tcl interfaces (in Tcl)
@@ -3289,7 +3289,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
-
35.9.1 Proxy classes
+
36.9.1 Proxy classes
@@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
-
35.10 Tcl/Tk Stubs
+
36.10 Tcl/Tk Stubs
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 1568c082e..6331aa1ac 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -1711,7 +1711,8 @@ you'll find the full typemap contents (example shown below for Python):
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr($input, &argp,$descriptor, $disown | 0 );
if (!SWIG_IsOK(res)) {
- SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'");
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument "
+ "$argnum"" of type '" "$type""'");
}
$1 = ($ltype)(argp);
}
@@ -1732,7 +1733,8 @@ SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
...
res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_a_4__int, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument " "1"" of type '" "int [10][4]""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument "
+ "1"" of type '" "int [10][4]""'");
}
arg1 = (int (*)[4])(argp1);
...
@@ -1791,7 +1793,8 @@ void set_value(const char* val) {}
}
}
-%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
+// use default pointer handling instead of strings
+%apply SWIGTYPE * { const char* val, const char* another_value }
%typemap(check) const char* val = char* NON_NULL;
@@ -3296,7 +3299,8 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
example.i:28: Warning 474: Method XX::create() usage of the optimal attribute ignored
-example.i:14: Warning 474: in the out typemap as the following cannot be used to generate optimal code:
+example.i:14: Warning 474: in the out typemap as the following cannot be used to generate
+optimal code:
try {
result = XX::create();
} catch(const std::exception &e) {
@@ -3317,8 +3321,8 @@ In fact SWIG attempts to detect this and will issue a warning something like:
-example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to optimal attribute usage in
-example.i:7: Warning 475: the out typemap.
+example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to
+example.i:7: Warning 475: optimal attribute usage in the out typemap.
203. Both includeall and importall are defined: using includeall.
+
204. CPP #warning, "warning".
+
205. CPP #error, "error".
+
206. Unexpected tokens after #directive directive.
14.9.3 C/C++ Parser (300-399)
@@ -513,6 +517,7 @@ example.i(4) : Syntax error in input.
517.
518. Portability warning: File file1 will be overwritten by file2 on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
519. %template() contains no name. Template method ignored: declaration
+
520. Base/Derived class 'classname1' of 'classname2' is not similarly marked as a smart pointer.
14.9.6 Language module specific (700-899)
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index e918e234a..924c8cfde 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -17,6 +17,7 @@ CCache.html
Allegrocl.html
CSharp.html
Chicken.html
+D.html
Go.html
Guile.html
Java.html
diff --git a/Doc/Manual/linkchecker.config b/Doc/Manual/linkchecker.config
new file mode 100644
index 000000000..a947b278a
--- /dev/null
+++ b/Doc/Manual/linkchecker.config
@@ -0,0 +1,5 @@
+[checking]
+anchors=1
+
+[filtering]
+ignorewarnings=http-robots-denied
diff --git a/Doc/Manual/makechap.py b/Doc/Manual/makechap.py
index 4dd048c36..8225bfc79 100644
--- a/Doc/Manual/makechap.py
+++ b/Doc/Manual/makechap.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/env python
###############################################################################
# Takes a chapter as input and adds internal links and numbering to all
diff --git a/Doc/Manual/maketoc.py b/Doc/Manual/maketoc.py
index c78bcfd13..d8c4aa759 100644
--- a/Doc/Manual/maketoc.py
+++ b/Doc/Manual/maketoc.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/env python
import sys
import os
@@ -12,7 +12,7 @@ print >>f, """
SWIG Users Manual
-
SWIG Users Manual
+
SWIG Users Manual
"""
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 83bf34a46..62ed3cbb9 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -69,7 +69,7 @@ IOBJS = $(IWRAP:.i=.@OBJEXT@)
CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
-# Solaris workshop 5.0
+# Solaris workshop 5.0
# CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
# Symbols used for using shared libraries
@@ -159,7 +159,7 @@ tcl_cpp: $(SRCS)
# -----------------------------------------------------------------
tcl_clean:
- rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
+ rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -296,9 +296,9 @@ python_static_cpp: $(SRCS)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
-# -----------------------------------------------------------------
+# -----------------------------------------------------------------
# Running a Python example
-# -----------------------------------------------------------------
+# -----------------------------------------------------------------
ifeq (,$(PY3))
PYSCRIPT = runme.py
@@ -313,7 +313,7 @@ python_run: $(PYSCRIPT)
runme3.py: runme.py
cp $< $@
- $(PY2TO3) -w $@ >/dev/null 2>&1
+ $(PY2TO3) -w $@ >/dev/null 2>&1
# -----------------------------------------------------------------
# Cleaning the python examples
@@ -332,7 +332,7 @@ python_clean:
# Make sure these locate your Octave installation
OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@
-OCTAVE_LIB =
+OCTAVE_LIB =
# Extra Octave specific dynamic linking options
OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@
@@ -548,14 +548,14 @@ mzscheme: $(SRCS)
mzscheme_cpp: $(SRCS)
$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
- $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
+ $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
# -----------------------------------------------------------------
# Cleaning the mzscheme examples
# -----------------------------------------------------------------
mzscheme_clean:
- rm -f *_wrap* *~ .~*
+ rm -f *_wrap* *~ .~*
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -632,7 +632,7 @@ ocaml_static_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -643,13 +643,13 @@ ocaml_static_cpp: $(SRCS)
$(INTERFACE:%.i=%.cmo) \
$(PROGFILE:%.ml=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX)'
+ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_static_cpp_toplevel: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -657,17 +657,17 @@ ocaml_static_cpp_toplevel: $(SRCS)
$(OCC) $(OCAMLPP) -c $(PROGFILE)
$(NOLINK) || $(OCAMLMKTOP) \
swig.cmo \
- -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
+ -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
$(INTERFACE:%.i=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX)'
+ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_dynamic_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
@@ -684,7 +684,7 @@ ocaml_dynamic_cpp: $(SRCS)
$(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
-o $(TARGET) \
-package dl -linkpkg \
- $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
+ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
ocaml_clean:
rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
@@ -781,7 +781,7 @@ PHP=@PHP@
PHPSCRIPT ?= runme.php
php_run:
- env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
+ $(RUNTOOL) $(PHP) -n -q -d extension_dir=. -d safe_mode=Off $(PHPSCRIPT)
# -----------------------------------------------------------------
# Cleaning the PHP examples
@@ -844,7 +844,7 @@ pike_cpp_static: $(SRCS)
# -----------------------------------------------------------------
pike_clean:
- rm -f *_wrap* *~ .~* mypike@EXEEXT@
+ rm -f *_wrap* *~ .~* mypike@EXEEXT@
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -861,7 +861,7 @@ CHICKEN_CFLAGS = @CHICKENOPTS@
CHICKENOPTS = -quiet
CHICKEN_MAIN =
-# SWIG produces $(ISRCS) (the C wrapper file)
+# SWIG produces $(ISRCS) (the C wrapper file)
# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file):
CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm)
CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c)
@@ -1053,12 +1053,12 @@ lua_clean:
allegrocl: $(SRCS)
$(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
allegrocl_cpp: $(SRCS)
$(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
allegrocl_clean:
@@ -1087,12 +1087,12 @@ clisp_clean:
cffi: $(SRCS)
$(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH)
-# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
cffi_cpp: $(SRCS)
$(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
cffi_clean:
@@ -1106,12 +1106,12 @@ cffi_clean:
uffi: $(SRCS)
$(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH)
-# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
uffi_cpp: $(SRCS)
$(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
-# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
# $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
uffi_clean:
@@ -1255,3 +1255,69 @@ go_clean:
rm -f *_wrap* *_gc* .~* runme
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *.[568] *.a *@SO@
+
+##################################################################
+##### D ######
+##################################################################
+
+DLIBPREFIX = @DLIBPREFIX@
+
+ifeq (,$(D_VERSION))
+ D_VERSION = @DDEFAULTVERSION@
+endif
+
+ifeq (2,$(D_VERSION))
+ SWIGD = $(SWIG) -d -d2
+ DCOMPILER = @D2COMPILER@
+else
+ SWIGD = $(SWIG) -d
+ DCOMPILER = @D1COMPILER@
+endif
+
+ifeq (dmd,$(DCOMPILER))
+ # DMD is 32bit only by now
+ DCFLAGS = -m32
+endif
+
+# ----------------------------------------------------------------
+# Build a dynamically loadable D wrapper for a C module
+# ----------------------------------------------------------------
+
+d: $(SRCS)
+ $(SWIGD) $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
+ $(LDSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a dynamically loadable D wrapper for a C++ module
+# ----------------------------------------------------------------
+
+d_cpp: $(SRCS)
+ $(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Compile D files
+# ----------------------------------------------------------------
+
+# Clear the DFLAGS environment variable for the compiler call itself
+# to work around a discrepancy in argument handling between DMD and LDC.
+d_compile: $(SRCS)
+ DFLAGS="" $(COMPILETOOL) $(DCOMPILER) $(DFLAGS) $(DSRCS)
+
+# -----------------------------------------------------------------
+# Run D example
+# -----------------------------------------------------------------
+
+d_run:
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme
+
+# -----------------------------------------------------------------
+# Clean the D examples
+# -----------------------------------------------------------------
+
+d_clean:
+ rm -f *_wrap* *~ .~* runme runme.exe `find . -name \*.d | grep -v runme.d`
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
diff --git a/Examples/d/callback/Makefile b/Examples/d/callback/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/callback/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/callback/d1/runme.d b/Examples/d/callback/d1/runme.d
new file mode 100644
index 000000000..e34e09603
--- /dev/null
+++ b/Examples/d/callback/d1/runme.d
@@ -0,0 +1,36 @@
+module runme;
+
+import tango.io.Stdout;
+import example;
+
+public class DCallback : Callback {
+ public override void run() {
+ Stdout( "DCallback.run()" ).newline;
+ }
+}
+
+void main() {
+ auto caller = new Caller();
+
+ Stdout( "Adding and calling a normal C++ callback" ).newline;
+ Stdout( "----------------------------------------" ).newline;
+ {
+ scope auto callback = new Callback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ Stdout.newline;
+ Stdout( "Adding and calling a D callback" ).newline;
+ Stdout( "-------------------------------" ).newline;
+ {
+ scope auto callback = new DCallback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ Stdout.newline;
+ Stdout( "D exit" ).newline;
+}
diff --git a/Examples/d/callback/d2/runme.d b/Examples/d/callback/d2/runme.d
new file mode 100644
index 000000000..88ffcdefd
--- /dev/null
+++ b/Examples/d/callback/d2/runme.d
@@ -0,0 +1,36 @@
+module runme;
+
+import std.stdio;
+import example;
+
+public class DCallback : Callback {
+ public override void run() {
+ writeln( "DCallback.run()" );
+ }
+}
+
+void main() {
+ auto caller = new Caller();
+
+ writeln( "Adding and calling a normal C++ callback" );
+ writeln( "----------------------------------------" );
+ {
+ scope auto callback = new Callback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ writeln();
+ writeln( "Adding and calling a D callback" );
+ writeln( "-------------------------------" );
+ {
+ scope auto callback = new DCallback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ writeln();
+ writeln( "D exit" );
+}
diff --git a/Examples/d/callback/example.cxx b/Examples/d/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/Examples/d/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/Examples/d/callback/example.h b/Examples/d/callback/example.h
new file mode 100644
index 000000000..38d25a043
--- /dev/null
+++ b/Examples/d/callback/example.h
@@ -0,0 +1,24 @@
+/* File : example.h */
+
+#include
+#include
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void resetCallback() { _callback = 0; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/Examples/d/callback/example.i b/Examples/d/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/Examples/d/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/Examples/d/check.list b/Examples/d/check.list
new file mode 100644
index 000000000..010e7bbfc
--- /dev/null
+++ b/Examples/d/check.list
@@ -0,0 +1,9 @@
+# See top-level Makefile.in.
+callback
+class
+constants
+enum
+extend
+funcptr
+simple
+variables
diff --git a/Examples/d/class/Makefile b/Examples/d/class/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/class/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/class/d1/runme.d b/Examples/d/class/d1/runme.d
new file mode 100644
index 000000000..b0c4263a2
--- /dev/null
+++ b/Examples/d/class/d1/runme.d
@@ -0,0 +1,58 @@
+// This example illustrates how C++ classes can be used from D using SWIG.
+// The D class gets mapped onto the C++ class and behaves as if it is a D class.
+module runme;
+
+import tango.io.Stdout;
+import example;
+
+void main() {
+ // ----- Object creation -----
+
+ Stdout( "Creating some objects:" ).newline;
+
+ {
+ scope Square s = new Square(10);
+ scope Circle c = new Circle(10);
+
+ // ----- Access a static member -----
+ Stdout.format( "{} shapes were created.", Shape.nshapes ).newline;
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.x = 20;
+ c.y = 30;
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.x = -10;
+ shape.y = 5;
+
+ Stdout( "\nHere is their current position:" ).newline;
+ Stdout.format( " Circle = ( {}, {} )", c.x, c.y ).newline;
+ Stdout.format( " Square = ( {}, {} )", s.x, s.y ).newline;
+
+ // ----- Call some methods -----
+
+ Stdout( "\nHere are some properties of the shapes:" ).newline;
+ Shape[] shapes = [ cast(Shape) c, cast(Shape) s ];
+ foreach ( currentShape; shapes )
+ {
+ Stdout.format( " {}", currentShape.classinfo.name ).newline;
+ Stdout.format( " area = {}", currentShape.area() ).newline;
+ Stdout.format( " perimeter = {}", currentShape.perimeter() ).newline;
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+ Stdout( "\nGuess I'll clean up now:" ).newline;
+ // Note: when this using scope is exited the D destructors are called which
+ // in turn call the C++ destructors.
+ }
+
+ Stdout.format( "{} shapes remain", Shape.nshapes ).newline;
+ Stdout( "\nGoodbye!" ).newline;
+}
diff --git a/Examples/d/class/d2/runme.d b/Examples/d/class/d2/runme.d
new file mode 100644
index 000000000..2e86c5fc7
--- /dev/null
+++ b/Examples/d/class/d2/runme.d
@@ -0,0 +1,58 @@
+// This example illustrates how C++ classes can be used from D using SWIG.
+// The D class gets mapped onto the C++ class and behaves as if it is a D class.
+module runme;
+
+import std.stdio;
+import example;
+
+void main() {
+ // ----- Object creation -----
+
+ writeln( "Creating some objects:" );
+
+ {
+ scope Square s = new Square(10);
+ scope Circle c = new Circle(10);
+
+ // ----- Access a static member -----
+ writefln( "%s shapes were created.", Shape.nshapes );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.x = 20;
+ c.y = 30;
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.x = -10;
+ shape.y = 5;
+
+ writeln( "\nHere is their current position:" );
+ writefln( " Circle = ( %s, %s )", c.x, c.y );
+ writefln( " Square = ( %s, %s )", s.x, s.y );
+
+ // ----- Call some methods -----
+
+ writeln( "\nHere are some properties of the shapes:" );
+ Shape[] shapes = [ cast(Shape) c, cast(Shape) s ];
+ foreach ( currentShape; shapes )
+ {
+ writefln( " %s", currentShape.classinfo.name );
+ writefln( " area = %s", currentShape.area() );
+ writefln( " perimeter = %s", currentShape.perimeter() );
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+ writeln( "\nGuess I'll clean up now:" );
+ // Note: when this using scope is exited the D destructors are called which
+ // in turn call the C++ destructors.
+ }
+
+ writefln( "%s shapes remain", Shape.nshapes );
+ writeln( "\nGoodbye!" );
+}
diff --git a/Examples/d/class/example.cxx b/Examples/d/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/Examples/d/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/Examples/d/class/example.h b/Examples/d/class/example.h
new file mode 100644
index 000000000..0d4527e92
--- /dev/null
+++ b/Examples/d/class/example.h
@@ -0,0 +1,34 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ };
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
diff --git a/Examples/d/class/example.i b/Examples/d/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/Examples/d/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/d/constants/Makefile b/Examples/d/constants/Makefile
new file mode 100644
index 000000000..412055243
--- /dev/null
+++ b/Examples/d/constants/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ example_wrap.c
+EXTRA_LDFLAGS = example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/constants/d1/runme.d b/Examples/d/constants/d1/runme.d
new file mode 100644
index 000000000..47362cbf3
--- /dev/null
+++ b/Examples/d/constants/d1/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+void main() {
+ Stdout.formatln("ICONST = {} (should be 42)", example.ICONST);
+ Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST);
+ Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST);
+ Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2);
+ Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST);
+ Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2);
+ Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR);
+ Stdout.formatln("iconst = {} (should be 37)", example.iconst);
+ Stdout.formatln("fconst = {} (should be 3.14)", example.fconst);
+
+ static if (is(typeof(example.EXTERN))) {
+ Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN );
+ } else {
+ Stdout.formatln("EXTERN isn't defined (good)");
+ }
+
+ static if (is(typeof(example.FOO))) {
+ Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO);
+ } else {
+ Stdout.formatln("FOO isn't defined (good)");
+ }
+}
diff --git a/Examples/d/constants/d2/runme.d b/Examples/d/constants/d2/runme.d
new file mode 100644
index 000000000..4be510d16
--- /dev/null
+++ b/Examples/d/constants/d2/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import std.stdio;
+static import example;
+
+void main() {
+ writefln("ICONST = %s (should be 42)", example.ICONST);
+ writefln("FCONST = %s (should be 2.1828)", example.FCONST);
+ writefln("CCONST = %s (should be 'x')", example.CCONST);
+ writefln("CCONST2 = %s (this should be on a new line)", example.CCONST2);
+ writefln("SCONST = %s (should be 'Hello World')", example.SCONST);
+ writefln("SCONST2 = %s (should be '\"Hello World\"')", example.SCONST2);
+ writefln("EXPR = %s (should be 48.5484)", example.EXPR);
+ writefln("iconst = %s (should be 37)", example.iconst);
+ writefln("fconst = %s (should be 3.14)", example.fconst);
+
+ static if (is(typeof(example.EXTERN))) {
+ writefln("EXTERN should not be defined, but is: %s.", example.EXTERN );
+ } else {
+ writeln("EXTERN isn't defined (good)");
+ }
+
+ static if (is(typeof(example.FOO))) {
+ writefln("FOO should not be defined, but is: %s.", example.FOO);
+ } else {
+ writeln("FOO isn't defined (good)");
+ }
+}
diff --git a/Examples/d/constants/example.d b/Examples/d/constants/example.d
new file mode 100644
index 000000000..7448d0ad9
--- /dev/null
+++ b/Examples/d/constants/example.d
@@ -0,0 +1,23 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.41
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+module example;
+
+static import example_wrap;
+
+static import tango.stdc.stringz;
+
+public const int ICONST = 42;
+public const double FCONST = 2.1828;
+public const char CCONST = 'x';
+public const char CCONST2 = '\n';
+public const char[] SCONST = "Hello World";
+public const char[] SCONST2 = "\"Hello World\"";
+public const double EXPR = 42+3*(2.1828);
+public const int iconst = 37;
+public const double fconst = 3.14;
diff --git a/Examples/d/constants/example.i b/Examples/d/constants/example.i
new file mode 100644
index 000000000..edeb258cd
--- /dev/null
+++ b/Examples/d/constants/example.i
@@ -0,0 +1,32 @@
+/* File : example.i */
+%module example
+
+/* Force the generated D code to use the C constant values rather than
+ retrieving them at runtime. You can also try disabling the feature and
+ compare the generated code. */
+%dmanifestconst;
+
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
diff --git a/Examples/d/enum/Makefile b/Examples/d/enum/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/enum/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/enum/d1/runme.d b/Examples/d/enum/d1/runme.d
new file mode 100644
index 000000000..d986986d1
--- /dev/null
+++ b/Examples/d/enum/d1/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import tango.io.Stdout;
+import example;
+
+void main() {
+ Stdout( "Printing out some enum values:" ).newline;
+ Stdout(" color:").newline;
+ Stdout.formatln(" {} = {}", color.RED, cast(int)color.RED);
+ Stdout.formatln(" {} = {}", color.BLUE, cast(int)color.BLUE);
+ Stdout.formatln(" {} = {}", color.GREEN, cast(int)color.GREEN);
+
+ Stdout("\n Foo.speed:").newline;
+ Stdout.formatln(" Foo.{} = {}", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE);
+ Stdout.formatln(" Foo.{} = {}", Foo.speed.WARP, cast(int)Foo.speed.WARP);
+ Stdout.formatln(" Foo.{} = {}", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS);
+
+ Stdout("\nTesting use of enums with functions:").newline;
+ example.enum_test(color.RED, Foo.speed.IMPULSE);
+ example.enum_test(color.BLUE, Foo.speed.WARP);
+ example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
+
+ Stdout( "\nTesting use of enum with class method:" ).newline;
+ scope f = new Foo();
+ f.enum_test(Foo.speed.IMPULSE);
+ f.enum_test(Foo.speed.WARP);
+ f.enum_test(Foo.speed.LUDICROUS);
+}
diff --git a/Examples/d/enum/d2/runme.d b/Examples/d/enum/d2/runme.d
new file mode 100644
index 000000000..acaec8ae8
--- /dev/null
+++ b/Examples/d/enum/d2/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import std.stdio;
+import example;
+
+void main() {
+ writeln( "Printing out some enum values:" );
+ writeln(" color:");
+ writefln(" %s = %s", color.RED, cast(int)color.RED);
+ writefln(" %s = %s", color.BLUE, cast(int)color.BLUE);
+ writefln(" %s = %s", color.GREEN, cast(int)color.GREEN);
+
+ writeln("\n Foo.speed:");
+ writefln(" Foo.%s = %s", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE);
+ writefln(" Foo.%s = %s", Foo.speed.WARP, cast(int)Foo.speed.WARP);
+ writefln(" Foo.%s = %s", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS);
+
+ writeln("\nTesting use of enums with functions:");
+ example.enum_test(color.RED, Foo.speed.IMPULSE);
+ example.enum_test(color.BLUE, Foo.speed.WARP);
+ example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
+
+ writeln( "\nTesting use of enum with class method:" );
+ scope f = new Foo();
+ f.enum_test(Foo.speed.IMPULSE);
+ f.enum_test(Foo.speed.WARP);
+ f.enum_test(Foo.speed.LUDICROUS);
+}
diff --git a/Examples/d/enum/example.cxx b/Examples/d/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/Examples/d/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.cxx */
+
+#include "example.h"
+#include
+
+void Foo::enum_test(speed s) {
+ if (s == IMPULSE) {
+ printf("IMPULSE speed\n");
+ } else if (s == WARP) {
+ printf("WARP speed\n");
+ } else if (s == LUDICROUS) {
+ printf("LUDICROUS speed\n");
+ } else {
+ printf("Unknown speed\n");
+ }
+}
+
+void enum_test(color c, Foo::speed s) {
+ if (c == RED) {
+ printf("color = RED, ");
+ } else if (c == BLUE) {
+ printf("color = BLUE, ");
+ } else if (c == GREEN) {
+ printf("color = GREEN, ");
+ } else {
+ printf("color = Unknown color!, ");
+ }
+ if (s == Foo::IMPULSE) {
+ printf("speed = IMPULSE speed\n");
+ } else if (s == Foo::WARP) {
+ printf("speed = WARP speed\n");
+ } else if (s == Foo::LUDICROUS) {
+ printf("speed = LUDICROUS speed\n");
+ } else {
+ printf("speed = Unknown speed!\n");
+ }
+}
diff --git a/Examples/d/enum/example.h b/Examples/d/enum/example.h
new file mode 100644
index 000000000..9119cd9fc
--- /dev/null
+++ b/Examples/d/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/Examples/d/enum/example.i b/Examples/d/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/Examples/d/enum/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/Examples/d/extend/Makefile b/Examples/d/extend/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/extend/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/extend/d1/runme.d b/Examples/d/extend/d1/runme.d
new file mode 100644
index 000000000..96501d1a4
--- /dev/null
+++ b/Examples/d/extend/d1/runme.d
@@ -0,0 +1,75 @@
+/// This file illustrates the cross language polymorphism using directors.
+module runme;
+
+import example;
+import tango.io.Stdout;
+
+// CEO class, which overrides Employee.getPosition().
+class CEO : Manager {
+public:
+ this( char[] name ) {
+ super( name );
+ }
+
+ override char[] getPosition() {
+ return "CEO";
+ }
+
+ // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
+ void disownMemory() {
+ swigCMemOwn = false;
+ }
+}
+
+void main() {
+ // Create an instance of CEO, a class derived from the D proxy of the
+ // underlying C++ class. The calls to getName() and getPosition() are standard,
+ // the call to getTitle() uses the director wrappers to call CEO.getPosition().
+
+ auto e = new CEO( "Alice" );
+ Stdout.formatln( "{} is a {}.", e.getName(), e.getPosition() );
+ Stdout.formatln( "Just call her '{}'.", e.getTitle() );
+ Stdout( "----------------------" ).newline;
+
+ {
+ // Create a new EmployeeList instance. This class does not have a C++
+ // director wrapper, but can be used freely with other classes that do.
+ scope auto list = new EmployeeList();
+
+ // EmployeeList owns its items, so we must surrender ownership of objects we add.
+ e.disownMemory();
+ list.addEmployee(e);
+ Stdout( "----------------------" ).newline;
+
+ // Now we access the first four items in list (three are C++ objects that
+ // EmployeeList's constructor adds, the last is our CEO). The virtual
+ // methods of all these instances are treated the same. For items 0, 1, and
+ // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
+ // getPosition which resolves in D. The call to getPosition is
+ // slightly different, however, because of the overidden getPosition() call, since
+ // now the object reference has been "laundered" by passing through
+ // EmployeeList as an Employee*. Previously, D resolved the call
+ // immediately in CEO, but now D thinks the object is an instance of
+ // class Employee. So the call passes through the
+ // Employee proxy class and on to the C wrappers and C++ director,
+ // eventually ending up back at the D CEO implementation of getPosition().
+ // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+ // method, which in turn calls getPosition(). This virtual method call
+ // passes down through the C++ director class to the D implementation
+ // in CEO. All this routing takes place transparently.
+
+ Stdout( "(position, title) for items 0-3:" ).newline;
+ Stdout.formatln( " {}, '{}'", list.getItem(0).getPosition(), list.getItem(0).getTitle() );
+ Stdout.formatln( " {}, '{}'", list.getItem(1).getPosition(), list.getItem(1).getTitle() );
+ Stdout.formatln( " {}, '{}'", list.getItem(2).getPosition(), list.getItem(2).getTitle() );
+ Stdout.formatln( " {}, '{}'", list.getItem(3).getPosition(), list.getItem(3).getTitle() );
+ Stdout( "----------------------" ).newline;
+
+ // All Employees will be destroyed when the EmployeeList goes out of scope,
+ // including the CEO instance.
+ }
+ Stdout( "----------------------" ).newline;
+
+ // All done.
+ Stdout( "Exiting cleanly from D code." ).newline;
+}
diff --git a/Examples/d/extend/d2/runme.d b/Examples/d/extend/d2/runme.d
new file mode 100644
index 000000000..1ea6dfd21
--- /dev/null
+++ b/Examples/d/extend/d2/runme.d
@@ -0,0 +1,75 @@
+/// This file illustrates the cross language polymorphism using directors.
+module runme;
+
+import std.stdio;
+import example;
+
+// CEO class, which overrides Employee.getPosition().
+class CEO : Manager {
+public:
+ this( string name ) {
+ super( name );
+ }
+
+ override string getPosition() const {
+ return "CEO";
+ }
+
+ // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
+ void disownMemory() {
+ swigCMemOwn = false;
+ }
+}
+
+void main() {
+ // Create an instance of CEO, a class derived from the D proxy of the
+ // underlying C++ class. The calls to getName() and getPosition() are standard,
+ // the call to getTitle() uses the director wrappers to call CEO.getPosition().
+
+ auto e = new CEO( "Alice" );
+ writefln( "%s is a %s.", e.getName(), e.getPosition() );
+ writefln( "Just call her '%s'.", e.getTitle() );
+ writeln( "----------------------" );
+
+ {
+ // Create a new EmployeeList instance. This class does not have a C++
+ // director wrapper, but can be used freely with other classes that do.
+ scope auto list = new EmployeeList();
+
+ // EmployeeList owns its items, so we must surrender ownership of objects we add.
+ e.disownMemory();
+ list.addEmployee(e);
+ writeln( "----------------------" );
+
+ // Now we access the first four items in list (three are C++ objects that
+ // EmployeeList's constructor adds, the last is our CEO). The virtual
+ // methods of all these instances are treated the same. For items 0, 1, and
+ // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
+ // getPosition which resolves in D. The call to getPosition is
+ // slightly different, however, because of the overidden getPosition() call, since
+ // now the object reference has been "laundered" by passing through
+ // EmployeeList as an Employee*. Previously, D resolved the call
+ // immediately in CEO, but now D thinks the object is an instance of
+ // class Employee. So the call passes through the
+ // Employee proxy class and on to the C wrappers and C++ director,
+ // eventually ending up back at the D CEO implementation of getPosition().
+ // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+ // method, which in turn calls getPosition(). This virtual method call
+ // passes down through the C++ director class to the D implementation
+ // in CEO. All this routing takes place transparently.
+
+ writeln( "(position, title) for items 0-3:" );
+ writefln( " %s, '%s'", list.getItem(0).getPosition(), list.getItem(0).getTitle() );
+ writefln( " %s, '%s'", list.getItem(1).getPosition(), list.getItem(1).getTitle() );
+ writefln( " %s, '%s'", list.getItem(2).getPosition(), list.getItem(2).getTitle() );
+ writefln( " %s, '%s'", list.getItem(3).getPosition(), list.getItem(3).getTitle() );
+ writeln( "----------------------" );
+
+ // All Employees will be destroyed when the EmployeeList goes out of scope,
+ // including the CEO instance.
+ }
+ writeln( "----------------------" );
+
+ // All done.
+ writeln( "Exiting cleanly from D code." );
+}
diff --git a/Examples/d/extend/example.cxx b/Examples/d/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/Examples/d/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/Examples/d/extend/example.h b/Examples/d/extend/example.h
new file mode 100644
index 000000000..7ad93fbc1
--- /dev/null
+++ b/Examples/d/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include
+#include
+#include
+#include
+#include
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *getItem(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/Examples/d/extend/example.i b/Examples/d/extend/example.i
new file mode 100644
index 000000000..0647e1319
--- /dev/null
+++ b/Examples/d/extend/example.i
@@ -0,0 +1,14 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/Examples/d/funcptr/Makefile b/Examples/d/funcptr/Makefile
new file mode 100644
index 000000000..09efa8d88
--- /dev/null
+++ b/Examples/d/funcptr/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/funcptr/d1/runme.d b/Examples/d/funcptr/d1/runme.d
new file mode 100644
index 000000000..1461c1546
--- /dev/null
+++ b/Examples/d/funcptr/d1/runme.d
@@ -0,0 +1,42 @@
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+extern(C) int add(int a, int b) {
+ return a + b;
+}
+
+extern(C) int sub(int a, int b) {
+ return a - b;
+}
+
+extern(C) int mul(int a, int b) {
+ return a * b;
+}
+
+void main() {
+ int a = 37;
+ int b = 42;
+
+ Stdout( "a = " )( a ).newline;
+ Stdout( "b = " )( b ).newline;
+
+ Stdout( "Trying some C callback functions:" ).newline;
+ Stdout( " ADD(a,b) = " )( example.do_op( a, b, example.ADD ) ).newline;
+ Stdout( " SUB(a,b) = " )( example.do_op( a, b, example.SUB ) ).newline;
+ Stdout( " MUL(a,b) = " )( example.do_op( a, b, example.MUL ) ).newline;
+
+ version (LDC) {
+ // Currently, there is no way to specify the calling convention for
+ // function pointer parameters in D, but LDC does strict typechecking for
+ // them (which is reasonable, but not covered by the language spec yet).
+ // As a result, there is no way to make the code below compile with LDC at
+ // the moment, so just skip it.
+ } else {
+ Stdout( "Now the same with callback functions defined in D:" ).newline;
+ Stdout( " add(a,b) = " )( example.do_op( a, b, &add ) ).newline;
+ Stdout( " sub(a,b) = " )( example.do_op( a, b, &sub ) ).newline;
+ Stdout( " mul(a,b) = " )( example.do_op( a, b, &mul ) ).newline;
+ }
+}
diff --git a/Examples/d/funcptr/d2/runme.d b/Examples/d/funcptr/d2/runme.d
new file mode 100644
index 000000000..929911d6c
--- /dev/null
+++ b/Examples/d/funcptr/d2/runme.d
@@ -0,0 +1,34 @@
+module runme;
+
+import std.stdio;
+static import example;
+
+extern(C) int add(int a, int b) {
+ return a + b;
+}
+
+extern(C) int sub(int a, int b) {
+ return a - b;
+}
+
+extern(C) int mul(int a, int b) {
+ return a * b;
+}
+
+void main() {
+ int a = 37;
+ int b = 42;
+
+ writefln( "a = %s", a );
+ writefln( "b = %s", b );
+
+ writeln( "Trying some C callback functions:" );
+ writefln( " ADD(a,b) = %s", example.do_op( a, b, example.ADD ) );
+ writefln( " SUB(a,b) = %s", example.do_op( a, b, example.SUB ) );
+ writefln( " MUL(a,b) = %s", example.do_op( a, b, example.MUL ) );
+
+ writeln( "Now the same with callback functions defined in D:" );
+ writefln( " add(a,b) = %s", example.do_op( a, b, &add ) );
+ writefln( " sub(a,b) = %s", example.do_op( a, b, &sub ) );
+ writefln( " mul(a,b) = %s", example.do_op( a, b, &mul ) );
+}
diff --git a/Examples/d/funcptr/example.c b/Examples/d/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/Examples/d/funcptr/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int sub(int a, int b) {
+ return a-b;
+}
+
+int mul(int a, int b) {
+ return a*b;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/Examples/d/funcptr/example.h b/Examples/d/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/Examples/d/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/d/funcptr/example.i b/Examples/d/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/Examples/d/funcptr/example.i
@@ -0,0 +1,16 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Wrap a function taking a pointer to a function */
+extern int do_op(int a, int b, int (*op)(int, int));
+
+/* Now install a bunch of "ops" as constants */
+%constant int (*ADD)(int,int) = add;
+%constant int (*SUB)(int,int) = sub;
+%constant int (*MUL)(int,int) = mul;
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/d/simple/Makefile b/Examples/d/simple/Makefile
new file mode 100644
index 000000000..ae173a566
--- /dev/null
+++ b/Examples/d/simple/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/simple/d1/runme.d b/Examples/d/simple/d1/runme.d
new file mode 100644
index 000000000..1293f1839
--- /dev/null
+++ b/Examples/d/simple/d1/runme.d
@@ -0,0 +1,27 @@
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+void main() {
+ /*
+ * Call our gcd() function.
+ */
+ int x = 42;
+ int y = 105;
+ int g = example.gcd( x, y );
+ Stdout.format( "The gcd of {} and {} is {}.", x, y, g ).newline;
+
+ /*
+ * Manipulate the Foo global variable.
+ */
+
+ // Output its current value
+ Stdout.format( "Foo = {}", example.Foo ).newline;
+
+ // Change its value
+ example.Foo = 3.1415926;
+
+ // See if the change took effect
+ Stdout.format( "Foo = {}", example.Foo ).newline;
+}
diff --git a/Examples/d/simple/d2/runme.d b/Examples/d/simple/d2/runme.d
new file mode 100644
index 000000000..7f278923b
--- /dev/null
+++ b/Examples/d/simple/d2/runme.d
@@ -0,0 +1,27 @@
+module runme;
+
+import std.stdio;
+static import example;
+
+void main() {
+ /*
+ * Call our gcd() function.
+ */
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x, y);
+ writefln("The gcd of %s and %s is %s.", x, y, g);
+
+ /*
+ * Manipulate the Foo global variable.
+ */
+
+ // Output its current value
+ writefln("Foo = %s", example.Foo);
+
+ // Change its value
+ example.Foo = 3.1415926;
+
+ // See if the change took effect
+ writefln("Foo = %s", example.Foo);
+}
diff --git a/Examples/d/simple/example.c b/Examples/d/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/d/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/Examples/d/simple/example.i b/Examples/d/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/d/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/Examples/d/variables/Makefile b/Examples/d/variables/Makefile
new file mode 100644
index 000000000..ae173a566
--- /dev/null
+++ b/Examples/d/variables/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/variables/d1/runme.d b/Examples/d/variables/d1/runme.d
new file mode 100644
index 000000000..35c896bdc
--- /dev/null
+++ b/Examples/d/variables/d1/runme.d
@@ -0,0 +1,71 @@
+// This example illustrates global variable access from C#.
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+void main() {
+ // Try to set the values of some global variables
+ example.ivar = 42;
+ example.svar = -31000;
+ example.lvar = 65537;
+ example.uivar = 123456;
+ example.usvar = 61000;
+ example.ulvar = 654321;
+ example.scvar = -13;
+ example.ucvar = 251;
+ example.cvar = 'S';
+ example.fvar = 3.14159f;
+ example.dvar = 2.1828;
+ example.strvar = "Hello World";
+ example.iptrvar = example.new_int(37);
+ example.ptptr = example.new_Point(37,42);
+ example.name = "Bill";
+
+ // Now print out the values of the variables
+ Stdout.formatln( "Variables (printed from D):" );
+ Stdout.formatln( "ivar = {}", example.ivar );
+ Stdout.formatln( "svar = {}", example.svar );
+ Stdout.formatln( "lvar = {}", example.lvar );
+ Stdout.formatln( "uivar = {}", example.uivar );
+ Stdout.formatln( "usvar = {}", example.usvar );
+ Stdout.formatln( "ulvar = {}", example.ulvar );
+ Stdout.formatln( "scvar = {}", example.scvar );
+ Stdout.formatln( "ucvar = {}", example.ucvar );
+ Stdout.formatln( "fvar = {}", example.fvar );
+ Stdout.formatln( "dvar = {}", example.dvar );
+ Stdout.formatln( "cvar = {}", example.cvar );
+ Stdout.formatln( "strvar = {}", example.strvar );
+ Stdout.formatln( "cstrvar = {}", example.cstrvar );
+ Stdout.formatln( "iptrvar = {}", example.iptrvar );
+ Stdout.formatln( "name = {}", example.name );
+ Stdout.formatln( "ptptr = {} {}", example.ptptr, example.Point_print(example.ptptr) );
+ Stdout.formatln( "pt = {} {}", example.pt, example.Point_print(example.pt) );
+ Stdout.formatln( "status = {}", example.status );
+
+ Stdout.formatln( "\nVariables (printed from the C library):" );
+ example.print_vars();
+
+ Stdout.formatln( "\nNow I'm going to try and modify some read only variables:" );
+ Stdout.formatln( "Checking that the read only variables are readonly..." );
+
+ Stdout( " 'path'..." );
+ static if ( is( typeof( example.path = "a" ) ) )
+ Stdout.formatln("Oh dear, this variable is not read only!");
+ else
+ Stdout.formatln("Good.");
+
+ Stdout( " 'status'..." );
+ static if ( is( typeof( example.status = 2 ) ) )
+ Stdout.formatln("Oh dear, this variable is not read only!");
+ else
+ Stdout.formatln("Good.");
+
+ Stdout.formatln( "\nI'm going to try and update a structure variable:" );
+
+ example.pt = example.ptptr;
+
+ Stdout( "The new value is " ).flush;
+ example.pt_print();
+ Stdout.formatln( "You should see the value {}", example.Point_print(example.ptptr) );
+}
diff --git a/Examples/d/variables/d2/runme.d b/Examples/d/variables/d2/runme.d
new file mode 100644
index 000000000..f80b81819
--- /dev/null
+++ b/Examples/d/variables/d2/runme.d
@@ -0,0 +1,71 @@
+// This example illustrates global variable access from C#.
+module runme;
+
+import std.stdio;
+static import example;
+
+void main() {
+ // Try to set the values of some global variables
+ example.ivar = 42;
+ example.svar = -31000;
+ example.lvar = 65537;
+ example.uivar = 123456;
+ example.usvar = 61000;
+ example.ulvar = 654321;
+ example.scvar = -13;
+ example.ucvar = 251;
+ example.cvar = 'S';
+ example.fvar = 3.14159f;
+ example.dvar = 2.1828;
+ example.strvar = "Hello World";
+ example.iptrvar = example.new_int(37);
+ example.ptptr = example.new_Point(37,42);
+ example.name = "Bill";
+
+ // Now print out the values of the variables
+ writefln( "Variables (printed from D):" );
+ writefln( "ivar = %s", example.ivar );
+ writefln( "svar = %s", example.svar );
+ writefln( "lvar = %s", example.lvar );
+ writefln( "uivar = %s", example.uivar );
+ writefln( "usvar = %s", example.usvar );
+ writefln( "ulvar = %s", example.ulvar );
+ writefln( "scvar = %s", example.scvar );
+ writefln( "ucvar = %s", example.ucvar );
+ writefln( "fvar = %s", example.fvar );
+ writefln( "dvar = %s", example.dvar );
+ writefln( "cvar = %s", example.cvar );
+ writefln( "strvar = %s", example.strvar );
+ writefln( "cstrvar = %s", example.cstrvar );
+ writefln( "iptrvar = %s", example.iptrvar );
+ writefln( "name = %s", example.name );
+ writefln( "ptptr = %s %s", example.ptptr, example.Point_print(example.ptptr) );
+ writefln( "pt = %s %s", example.pt, example.Point_print(example.pt) );
+ writefln( "status = %s", example.status );
+
+ writefln( "\nVariables (printed from the C library):" );
+ example.print_vars();
+
+ writefln( "\nNow I'm going to try and modify some read only variables:" );
+ writefln( "Checking that the read only variables are readonly..." );
+
+ writeln( " 'path'..." );
+ static if ( is( typeof( example.path = "a" ) ) )
+ writefln("Oh dear, this variable is not read only!");
+ else
+ writefln("Good.");
+
+ writeln( " 'status'..." );
+ static if ( is( typeof( example.status = 2 ) ) )
+ writefln("Oh dear, this variable is not read only!");
+ else
+ writefln("Good.");
+
+ writefln( "\nI'm going to try and update a structure variable:" );
+
+ example.pt = example.ptptr;
+
+ write( "The new value is " );
+ example.pt_print();
+ writefln( "You should see the value %s", example.Point_print(example.ptptr) );
+}
diff --git a/Examples/d/variables/example.c b/Examples/d/variables/example.c
new file mode 100644
index 000000000..1bf9c120f
--- /dev/null
+++ b/Examples/d/variables/example.c
@@ -0,0 +1,91 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include
+#include
+#include "example.h"
+
+int ivar = 0;
+short svar = 0;
+long lvar = 0;
+unsigned int uivar = 0;
+unsigned short usvar = 0;
+unsigned long ulvar = 0;
+signed char scvar = 0;
+unsigned char ucvar = 0;
+char cvar = 0;
+float fvar = 0;
+double dvar = 0;
+char *strvar = 0;
+const char cstrvar[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d, %d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/Examples/d/variables/example.h b/Examples/d/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/Examples/d/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/Examples/d/variables/example.i b/Examples/d/variables/example.i
new file mode 100644
index 000000000..591b871ed
--- /dev/null
+++ b/Examples/d/variables/example.i
@@ -0,0 +1,49 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/Examples/go/callback/example.go b/Examples/go/callback/example.go
deleted file mode 100644
index 5c0cfb051..000000000
--- a/Examples/go/callback/example.go
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type _swig_DirectorCallback struct {
- SwigcptrCallback
- v interface{}
-}
-
-func (p *_swig_DirectorCallback) Swigcptr() uintptr {
- return p.SwigcptrCallback.Swigcptr()
-}
-
-func (p *_swig_DirectorCallback) SwigIsCallback() {
-}
-
-func (p *_swig_DirectorCallback) DirectorInterface() interface{} {
- return p.v
-}
-
-func _swig_NewDirectorCallbackCallback(*_swig_DirectorCallback) SwigcptrCallback
-
-func NewDirectorCallback(v interface{}) Callback {
- p := &_swig_DirectorCallback{0, v}
- p.SwigcptrCallback = _swig_NewDirectorCallbackCallback(p)
- return p
-}
-
-func _swig_wrap_DeleteDirectorCallback(uintptr)
-
-func DeleteDirectorCallback(arg1 Callback) {
- _swig_wrap_DeleteDirectorCallback(arg1.Swigcptr())
-}
-
-func Swiggo_DeleteDirector_Callback(p *_swig_DirectorCallback) {
- p.SwigcptrCallback = 0
-}
-
-type _swig_DirectorInterfaceCallbackRun interface {
- Run()
-}
-
-func _swig_wrap__swig_DirectorCallback_upcall_Run(SwigcptrCallback)
-func (swig_p *_swig_DirectorCallback) Run() {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceCallbackRun); swig_ok {
- swig_g.Run()
- return
- }
- _swig_wrap__swig_DirectorCallback_upcall_Run(swig_p.SwigcptrCallback)
-}
-
-func DirectorCallbackRun(p Callback) {
- _swig_wrap__swig_DirectorCallback_upcall_Run(p.(*_swig_DirectorCallback).SwigcptrCallback)
-}
-
-func Swig_DirectorCallback_callback_run(p *_swig_DirectorCallback) {
- p.Run()
-}
-
-type SwigcptrCallback uintptr
-
-func (p SwigcptrCallback) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrCallback) SwigIsCallback() {
-}
-
-func (p SwigcptrCallback) DirectorInterface() interface{} {
- return nil
-}
-
-func _swig_wrap_delete_Callback(uintptr)
-
-func DeleteCallback(arg1 Callback) {
- _swig_wrap_delete_Callback(arg1.Swigcptr())
-}
-
-func _swig_wrap_Callback_run(SwigcptrCallback)
-
-func (arg1 SwigcptrCallback) Run() {
- _swig_wrap_Callback_run(arg1)
-}
-
-func _swig_wrap_new_Callback() SwigcptrCallback
-
-func NewCallback() Callback {
- return _swig_wrap_new_Callback()
-}
-
-type Callback interface {
- Swigcptr() uintptr
- SwigIsCallback()
- DirectorInterface() interface{}
- Run()
-}
-
-type SwigcptrCaller uintptr
-
-func (p SwigcptrCaller) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrCaller) SwigIsCaller() {
-}
-
-func _swig_wrap_new_Caller() SwigcptrCaller
-
-func NewCaller() Caller {
- return _swig_wrap_new_Caller()
-}
-
-func _swig_wrap_delete_Caller(uintptr)
-
-func DeleteCaller(arg1 Caller) {
- _swig_wrap_delete_Caller(arg1.Swigcptr())
-}
-
-func _swig_wrap_Caller_delCallback(SwigcptrCaller)
-
-func (arg1 SwigcptrCaller) DelCallback() {
- _swig_wrap_Caller_delCallback(arg1)
-}
-
-func _swig_wrap_Caller_setCallback(SwigcptrCaller, uintptr)
-
-func (arg1 SwigcptrCaller) SetCallback(arg2 Callback) {
- _swig_wrap_Caller_setCallback(arg1, arg2.Swigcptr())
-}
-
-func _swig_wrap_Caller_call(SwigcptrCaller)
-
-func (arg1 SwigcptrCaller) Call() {
- _swig_wrap_Caller_call(arg1)
-}
-
-type Caller interface {
- Swigcptr() uintptr
- SwigIsCaller()
- DelCallback()
- SetCallback(arg2 Callback)
- Call()
-}
-
-
-type SwigcptrSwigDirector_Callback uintptr
-type SwigDirector_Callback interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrSwigDirector_Callback) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/class/example.go b/Examples/go/class/example.go
deleted file mode 100644
index ec8113ad4..000000000
--- a/Examples/go/class/example.go
+++ /dev/null
@@ -1,284 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type SwigcptrShape uintptr
-
-func (p SwigcptrShape) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrShape) SwigIsShape() {
-}
-
-func _swig_wrap_delete_Shape(uintptr)
-
-func DeleteShape(arg1 Shape) {
- _swig_wrap_delete_Shape(arg1.Swigcptr())
-}
-
-func _swig_wrap_Shape_x_set(SwigcptrShape, float64)
-
-func (arg1 SwigcptrShape) SetX(arg2 float64) {
- _swig_wrap_Shape_x_set(arg1, arg2)
-}
-
-func _swig_wrap_Shape_x_get(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) GetX() float64 {
- return _swig_wrap_Shape_x_get(arg1)
-}
-
-func _swig_wrap_Shape_y_set(SwigcptrShape, float64)
-
-func (arg1 SwigcptrShape) SetY(arg2 float64) {
- _swig_wrap_Shape_y_set(arg1, arg2)
-}
-
-func _swig_wrap_Shape_y_get(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) GetY() float64 {
- return _swig_wrap_Shape_y_get(arg1)
-}
-
-func _swig_wrap_Shape_move(SwigcptrShape, float64, float64)
-
-func (arg1 SwigcptrShape) Move(arg2 float64, arg3 float64) {
- _swig_wrap_Shape_move(arg1, arg2, arg3)
-}
-
-func _swig_wrap_Shape_area(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) Area() float64 {
- return _swig_wrap_Shape_area(arg1)
-}
-
-func _swig_wrap_Shape_perimeter(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) Perimeter() float64 {
- return _swig_wrap_Shape_perimeter(arg1)
-}
-
-func _swig_wrap_Shape_nshapes_set(int)
-
-func SetShapeNshapes(arg1 int) {
- _swig_wrap_Shape_nshapes_set(arg1)
-}
-
-func GetShapeNshapes() int
-type Shape interface {
- Swigcptr() uintptr
- SwigIsShape()
- SetX(arg2 float64)
- GetX() float64
- SetY(arg2 float64)
- GetY() float64
- Move(arg2 float64, arg3 float64)
- Area() float64
- Perimeter() float64
-}
-
-type SwigcptrCircle uintptr
-
-func (p SwigcptrCircle) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrCircle) SwigIsCircle() {
-}
-
-func _swig_wrap_new_Circle(float64) SwigcptrCircle
-
-func NewCircle(arg1 float64) Circle {
- return _swig_wrap_new_Circle(arg1)
-}
-
-func _swig_wrap_Circle_area(SwigcptrCircle) float64
-
-func (arg1 SwigcptrCircle) Area() float64 {
- return _swig_wrap_Circle_area(arg1)
-}
-
-func _swig_wrap_Circle_perimeter(SwigcptrCircle) float64
-
-func (arg1 SwigcptrCircle) Perimeter() float64 {
- return _swig_wrap_Circle_perimeter(arg1)
-}
-
-func _swig_wrap_delete_Circle(uintptr)
-
-func DeleteCircle(arg1 Circle) {
- _swig_wrap_delete_Circle(arg1.Swigcptr())
-}
-
-func _swig_wrap_SetCircle_X(SwigcptrCircle, float64)
-
-func (_swig_base SwigcptrCircle) SetX(arg1 float64) {
- _swig_wrap_SetCircle_X(_swig_base, arg1)
-}
-
-func _swig_wrap_GetCircle_X(SwigcptrCircle) float64
-
-func (_swig_base SwigcptrCircle) GetX() float64 {
- return _swig_wrap_GetCircle_X(_swig_base)
-}
-
-func _swig_wrap_SetCircle_Y(SwigcptrCircle, float64)
-
-func (_swig_base SwigcptrCircle) SetY(arg1 float64) {
- _swig_wrap_SetCircle_Y(_swig_base, arg1)
-}
-
-func _swig_wrap_GetCircle_Y(SwigcptrCircle) float64
-
-func (_swig_base SwigcptrCircle) GetY() float64 {
- return _swig_wrap_GetCircle_Y(_swig_base)
-}
-
-func _swig_wrap_Circle_move(SwigcptrCircle, float64, float64)
-
-func (_swig_base SwigcptrCircle) Move(arg1 float64, arg2 float64) {
- _swig_wrap_Circle_move(_swig_base, arg1, arg2)
-}
-
-func (p SwigcptrCircle) SwigIsShape() {
-}
-
-func (p SwigcptrCircle) SwigGetShape() Shape {
- return SwigcptrShape(p.Swigcptr())
-}
-
-type Circle interface {
- Swigcptr() uintptr
- SwigIsCircle()
- Area() float64
- Perimeter() float64
- SetX(arg1 float64)
- GetX() float64
- SetY(arg1 float64)
- GetY() float64
- Move(arg1 float64, arg2 float64)
- SwigIsShape()
- SwigGetShape() Shape
-}
-
-type SwigcptrSquare uintptr
-
-func (p SwigcptrSquare) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrSquare) SwigIsSquare() {
-}
-
-func _swig_wrap_new_Square(float64) SwigcptrSquare
-
-func NewSquare(arg1 float64) Square {
- return _swig_wrap_new_Square(arg1)
-}
-
-func _swig_wrap_Square_area(SwigcptrSquare) float64
-
-func (arg1 SwigcptrSquare) Area() float64 {
- return _swig_wrap_Square_area(arg1)
-}
-
-func _swig_wrap_Square_perimeter(SwigcptrSquare) float64
-
-func (arg1 SwigcptrSquare) Perimeter() float64 {
- return _swig_wrap_Square_perimeter(arg1)
-}
-
-func _swig_wrap_delete_Square(uintptr)
-
-func DeleteSquare(arg1 Square) {
- _swig_wrap_delete_Square(arg1.Swigcptr())
-}
-
-func _swig_wrap_SetSquare_X(SwigcptrSquare, float64)
-
-func (_swig_base SwigcptrSquare) SetX(arg1 float64) {
- _swig_wrap_SetSquare_X(_swig_base, arg1)
-}
-
-func _swig_wrap_GetSquare_X(SwigcptrSquare) float64
-
-func (_swig_base SwigcptrSquare) GetX() float64 {
- return _swig_wrap_GetSquare_X(_swig_base)
-}
-
-func _swig_wrap_SetSquare_Y(SwigcptrSquare, float64)
-
-func (_swig_base SwigcptrSquare) SetY(arg1 float64) {
- _swig_wrap_SetSquare_Y(_swig_base, arg1)
-}
-
-func _swig_wrap_GetSquare_Y(SwigcptrSquare) float64
-
-func (_swig_base SwigcptrSquare) GetY() float64 {
- return _swig_wrap_GetSquare_Y(_swig_base)
-}
-
-func _swig_wrap_Square_move(SwigcptrSquare, float64, float64)
-
-func (_swig_base SwigcptrSquare) Move(arg1 float64, arg2 float64) {
- _swig_wrap_Square_move(_swig_base, arg1, arg2)
-}
-
-func (p SwigcptrSquare) SwigIsShape() {
-}
-
-func (p SwigcptrSquare) SwigGetShape() Shape {
- return SwigcptrShape(p.Swigcptr())
-}
-
-type Square interface {
- Swigcptr() uintptr
- SwigIsSquare()
- Area() float64
- Perimeter() float64
- SetX(arg1 float64)
- GetX() float64
- SetY(arg1 float64)
- GetY() float64
- Move(arg1 float64, arg2 float64)
- SwigIsShape()
- SwigGetShape() Shape
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/constants/example.go b/Examples/go/constants/example.go
deleted file mode 100644
index 0e5e66418..000000000
--- a/Examples/go/constants/example.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-const ICONST int = 42
-const FCONST float64 = 2.1828
-const CCONST byte = 'x'
-func _swig_getCCONST2() byte
-var CCONST2 byte = _swig_getCCONST2()
-const SCONST string = "Hello World"
-func _swig_getSCONST2() string
-var SCONST2 string = _swig_getSCONST2()
-func _swig_getEXPR() float64
-var EXPR float64 = _swig_getEXPR()
-const Iconst int = 37
-const Fconst float64 = 3.14
-
diff --git a/Examples/go/enum/example.go b/Examples/go/enum/example.go
deleted file mode 100644
index 4653ab57a..000000000
--- a/Examples/go/enum/example.go
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type Color int
-func _swig_getRED() Color
-var RED Color = _swig_getRED()
-func _swig_getBLUE() Color
-var BLUE Color = _swig_getBLUE()
-func _swig_getGREEN() Color
-var GREEN Color = _swig_getGREEN()
-type SwigcptrFoo uintptr
-
-func (p SwigcptrFoo) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrFoo) SwigIsFoo() {
-}
-
-func _swig_wrap_new_Foo() SwigcptrFoo
-
-func NewFoo() Foo {
- return _swig_wrap_new_Foo()
-}
-
-type FooSpeed int
-func _swig_getFoo_IMPULSE_Foo() FooSpeed
-var FooIMPULSE FooSpeed = _swig_getFoo_IMPULSE_Foo()
-func _swig_getFoo_WARP_Foo() FooSpeed
-var FooWARP FooSpeed = _swig_getFoo_WARP_Foo()
-func _swig_getFoo_LUDICROUS_Foo() FooSpeed
-var FooLUDICROUS FooSpeed = _swig_getFoo_LUDICROUS_Foo()
-func _swig_wrap_Foo_enum_test(SwigcptrFoo, FooSpeed)
-
-func (arg1 SwigcptrFoo) Enum_test(arg2 FooSpeed) {
- _swig_wrap_Foo_enum_test(arg1, arg2)
-}
-
-func _swig_wrap_delete_Foo(uintptr)
-
-func DeleteFoo(arg1 Foo) {
- _swig_wrap_delete_Foo(arg1.Swigcptr())
-}
-
-type Foo interface {
- Swigcptr() uintptr
- SwigIsFoo()
- Enum_test(arg2 FooSpeed)
-}
-
-func _swig_wrap_enum_test(Color, FooSpeed)
-
-func Enum_test(arg1 Color, arg2 FooSpeed) {
- _swig_wrap_enum_test(arg1, arg2)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/extend/example.go b/Examples/go/extend/example.go
deleted file mode 100644
index 08f21e6ab..000000000
--- a/Examples/go/extend/example.go
+++ /dev/null
@@ -1,397 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type _swig_DirectorEmployee struct {
- SwigcptrEmployee
- v interface{}
-}
-
-func (p *_swig_DirectorEmployee) Swigcptr() uintptr {
- return p.SwigcptrEmployee.Swigcptr()
-}
-
-func (p *_swig_DirectorEmployee) SwigIsEmployee() {
-}
-
-func (p *_swig_DirectorEmployee) DirectorInterface() interface{} {
- return p.v
-}
-
-func _swig_NewDirectorEmployeeEmployee(*_swig_DirectorEmployee, string) SwigcptrEmployee
-
-func NewDirectorEmployee(v interface{}, arg1 string) Employee {
- p := &_swig_DirectorEmployee{0, v}
- p.SwigcptrEmployee = _swig_NewDirectorEmployeeEmployee(p, arg1)
- return p
-}
-
-type _swig_DirectorInterfaceEmployeeGetTitle interface {
- GetTitle() string
-}
-
-func _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(SwigcptrEmployee) string
-func (swig_p *_swig_DirectorEmployee) GetTitle() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetTitle); swig_ok {
- return swig_g.GetTitle()
- }
- return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(swig_p.SwigcptrEmployee)
-}
-
-func DirectorEmployeeGetTitle(p Employee) string {
- return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
-}
-
-func Swig_DirectorEmployee_callback_getTitle(p *_swig_DirectorEmployee) (swig_result string) {
- return p.GetTitle()
-}
-
-type _swig_DirectorInterfaceEmployeeGetName interface {
- GetName() string
-}
-
-func _swig_wrap__swig_DirectorEmployee_upcall_GetName(SwigcptrEmployee) string
-func (swig_p *_swig_DirectorEmployee) GetName() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetName); swig_ok {
- return swig_g.GetName()
- }
- return _swig_wrap__swig_DirectorEmployee_upcall_GetName(swig_p.SwigcptrEmployee)
-}
-
-func DirectorEmployeeGetName(p Employee) string {
- return _swig_wrap__swig_DirectorEmployee_upcall_GetName(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
-}
-
-func Swig_DirectorEmployee_callback_getName(p *_swig_DirectorEmployee) (swig_result string) {
- return p.GetName()
-}
-
-type _swig_DirectorInterfaceEmployeeGetPosition interface {
- GetPosition() string
-}
-
-func _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(SwigcptrEmployee) string
-func (swig_p *_swig_DirectorEmployee) GetPosition() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetPosition); swig_ok {
- return swig_g.GetPosition()
- }
- return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(swig_p.SwigcptrEmployee)
-}
-
-func DirectorEmployeeGetPosition(p Employee) string {
- return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
-}
-
-func Swig_DirectorEmployee_callback_getPosition(p *_swig_DirectorEmployee) (swig_result string) {
- return p.GetPosition()
-}
-
-func _swig_wrap_DeleteDirectorEmployee(uintptr)
-
-func DeleteDirectorEmployee(arg1 Employee) {
- _swig_wrap_DeleteDirectorEmployee(arg1.Swigcptr())
-}
-
-func Swiggo_DeleteDirector_Employee(p *_swig_DirectorEmployee) {
- p.SwigcptrEmployee = 0
-}
-
-type SwigcptrEmployee uintptr
-
-func (p SwigcptrEmployee) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrEmployee) SwigIsEmployee() {
-}
-
-func (p SwigcptrEmployee) DirectorInterface() interface{} {
- return nil
-}
-
-func _swig_wrap_new_Employee(string) SwigcptrEmployee
-
-func NewEmployee(arg1 string) Employee {
- return _swig_wrap_new_Employee(arg1)
-}
-
-func _swig_wrap_Employee_getTitle(SwigcptrEmployee) string
-
-func (arg1 SwigcptrEmployee) GetTitle() string {
- return _swig_wrap_Employee_getTitle(arg1)
-}
-
-func _swig_wrap_Employee_getName(SwigcptrEmployee) string
-
-func (arg1 SwigcptrEmployee) GetName() string {
- return _swig_wrap_Employee_getName(arg1)
-}
-
-func _swig_wrap_Employee_getPosition(SwigcptrEmployee) string
-
-func (arg1 SwigcptrEmployee) GetPosition() string {
- return _swig_wrap_Employee_getPosition(arg1)
-}
-
-func _swig_wrap_delete_Employee(uintptr)
-
-func DeleteEmployee(arg1 Employee) {
- _swig_wrap_delete_Employee(arg1.Swigcptr())
-}
-
-type Employee interface {
- Swigcptr() uintptr
- SwigIsEmployee()
- DirectorInterface() interface{}
- GetTitle() string
- GetName() string
- GetPosition() string
-}
-
-type _swig_DirectorManager struct {
- SwigcptrManager
- v interface{}
-}
-
-func (p *_swig_DirectorManager) Swigcptr() uintptr {
- return p.SwigcptrManager.Swigcptr()
-}
-
-func (p *_swig_DirectorManager) SwigIsManager() {
-}
-
-func (p *_swig_DirectorManager) DirectorInterface() interface{} {
- return p.v
-}
-
-func _swig_NewDirectorManagerManager(*_swig_DirectorManager, string) SwigcptrManager
-
-func NewDirectorManager(v interface{}, arg1 string) Manager {
- p := &_swig_DirectorManager{0, v}
- p.SwigcptrManager = _swig_NewDirectorManagerManager(p, arg1)
- return p
-}
-
-type _swig_DirectorInterfaceManagerGetTitle interface {
- GetTitle() string
-}
-
-func _swig_wrap__swig_DirectorManager_upcall_GetTitle(SwigcptrManager) string
-func (swig_p *_swig_DirectorManager) GetTitle() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetTitle); swig_ok {
- return swig_g.GetTitle()
- }
- return _swig_wrap__swig_DirectorManager_upcall_GetTitle(swig_p.SwigcptrManager)
-}
-
-func DirectorManagerGetTitle(p Manager) string {
- return _swig_wrap__swig_DirectorManager_upcall_GetTitle(p.(*_swig_DirectorManager).SwigcptrManager)
-}
-
-func Swig_DirectorManager_callback_getTitle(p *_swig_DirectorManager) (swig_result string) {
- return p.GetTitle()
-}
-
-type _swig_DirectorInterfaceManagerGetName interface {
- GetName() string
-}
-
-func _swig_wrap__swig_DirectorManager_upcall_GetName(SwigcptrManager) string
-func (swig_p *_swig_DirectorManager) GetName() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetName); swig_ok {
- return swig_g.GetName()
- }
- return _swig_wrap__swig_DirectorManager_upcall_GetName(swig_p.SwigcptrManager)
-}
-
-func DirectorManagerGetName(p Manager) string {
- return _swig_wrap__swig_DirectorManager_upcall_GetName(p.(*_swig_DirectorManager).SwigcptrManager)
-}
-
-func Swig_DirectorManager_callback_getName(p *_swig_DirectorManager) (swig_result string) {
- return p.GetName()
-}
-
-type _swig_DirectorInterfaceManagerGetPosition interface {
- GetPosition() string
-}
-
-func _swig_wrap__swig_DirectorManager_upcall_GetPosition(SwigcptrManager) string
-func (swig_p *_swig_DirectorManager) GetPosition() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetPosition); swig_ok {
- return swig_g.GetPosition()
- }
- return _swig_wrap__swig_DirectorManager_upcall_GetPosition(swig_p.SwigcptrManager)
-}
-
-func DirectorManagerGetPosition(p Manager) string {
- return _swig_wrap__swig_DirectorManager_upcall_GetPosition(p.(*_swig_DirectorManager).SwigcptrManager)
-}
-
-func Swig_DirectorManager_callback_getPosition(p *_swig_DirectorManager) (swig_result string) {
- return p.GetPosition()
-}
-
-func _swig_wrap_DeleteDirectorManager(uintptr)
-
-func DeleteDirectorManager(arg1 Manager) {
- _swig_wrap_DeleteDirectorManager(arg1.Swigcptr())
-}
-
-func Swiggo_DeleteDirector_Manager(p *_swig_DirectorManager) {
- p.SwigcptrManager = 0
-}
-
-type SwigcptrManager uintptr
-
-func (p SwigcptrManager) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrManager) SwigIsManager() {
-}
-
-func (p SwigcptrManager) DirectorInterface() interface{} {
- return nil
-}
-
-func _swig_wrap_new_Manager(string) SwigcptrManager
-
-func NewManager(arg1 string) Manager {
- return _swig_wrap_new_Manager(arg1)
-}
-
-func _swig_wrap_Manager_getPosition(SwigcptrManager) string
-
-func (arg1 SwigcptrManager) GetPosition() string {
- return _swig_wrap_Manager_getPosition(arg1)
-}
-
-func _swig_wrap_delete_Manager(uintptr)
-
-func DeleteManager(arg1 Manager) {
- _swig_wrap_delete_Manager(arg1.Swigcptr())
-}
-
-func _swig_wrap_Manager_getTitle(SwigcptrManager) string
-
-func (_swig_base SwigcptrManager) GetTitle() string {
- return _swig_wrap_Manager_getTitle(_swig_base)
-}
-
-func _swig_wrap_Manager_getName(SwigcptrManager) string
-
-func (_swig_base SwigcptrManager) GetName() string {
- return _swig_wrap_Manager_getName(_swig_base)
-}
-
-func (p SwigcptrManager) SwigIsEmployee() {
-}
-
-func (p SwigcptrManager) SwigGetEmployee() Employee {
- return SwigcptrEmployee(p.Swigcptr())
-}
-
-type Manager interface {
- Swigcptr() uintptr
- SwigIsManager()
- DirectorInterface() interface{}
- GetPosition() string
- GetTitle() string
- GetName() string
- SwigIsEmployee()
- SwigGetEmployee() Employee
-}
-
-type SwigcptrEmployeeList uintptr
-
-func (p SwigcptrEmployeeList) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrEmployeeList) SwigIsEmployeeList() {
-}
-
-func _swig_wrap_new_EmployeeList() SwigcptrEmployeeList
-
-func NewEmployeeList() EmployeeList {
- return _swig_wrap_new_EmployeeList()
-}
-
-func _swig_wrap_EmployeeList_addEmployee(SwigcptrEmployeeList, uintptr)
-
-func (arg1 SwigcptrEmployeeList) AddEmployee(arg2 Employee) {
- _swig_wrap_EmployeeList_addEmployee(arg1, arg2.Swigcptr())
-}
-
-func _swig_wrap_EmployeeList_get_item(SwigcptrEmployeeList, int) SwigcptrEmployee
-
-func (arg1 SwigcptrEmployeeList) Get_item(arg2 int) Employee {
- return _swig_wrap_EmployeeList_get_item(arg1, arg2)
-}
-
-func _swig_wrap_delete_EmployeeList(uintptr)
-
-func DeleteEmployeeList(arg1 EmployeeList) {
- _swig_wrap_delete_EmployeeList(arg1.Swigcptr())
-}
-
-type EmployeeList interface {
- Swigcptr() uintptr
- SwigIsEmployeeList()
- AddEmployee(arg2 Employee)
- Get_item(arg2 int) Employee
-}
-
-
-type SwigcptrSwigDirector_Manager uintptr
-type SwigDirector_Manager interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrSwigDirector_Manager) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrSwigDirector_Employee uintptr
-type SwigDirector_Employee interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrSwigDirector_Employee) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/funcptr/example.go b/Examples/go/funcptr/example.go
deleted file mode 100644
index b059bae8d..000000000
--- a/Examples/go/funcptr/example.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Do_op(int, int, _swig_fnptr) int
-func _swig_getADD() _swig_fnptr
-var ADD _swig_fnptr = _swig_getADD()
-func _swig_getSUB() _swig_fnptr
-var SUB _swig_fnptr = _swig_getSUB()
-func _swig_getMUL() _swig_fnptr
-var MUL _swig_fnptr = _swig_getMUL()
-func _swig_wrap_funcvar_set(_swig_fnptr)
-
-func SetFuncvar(arg1 _swig_fnptr) {
- _swig_wrap_funcvar_set(arg1)
-}
-
-func GetFuncvar() _swig_fnptr
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/multimap/example.go b/Examples/go/multimap/example.go
deleted file mode 100644
index 59ed9eaad..000000000
--- a/Examples/go/multimap/example.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Gcd(int, int) int
-func Gcdmain([]string) int
-func Count(string, byte) int
-func _swig_wrap_capitalize([]string)
-
-func Capitalize(arg1 []string) {
- _swig_wrap_capitalize(arg1)
-}
-
-func _swig_wrap_circle(float64, float64)
-
-func Circle(arg1 float64, arg2 float64) {
- _swig_wrap_circle(arg1, arg2)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/pointer/example.go b/Examples/go/pointer/example.go
deleted file mode 100644
index 567c41c32..000000000
--- a/Examples/go/pointer/example.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func _swig_wrap_add(*int, *int, *int)
-
-func Add(arg1 *int, arg2 *int, arg3 *int) {
- _swig_wrap_add(arg1, arg2, arg3)
-}
-
-func New_intp() *int
-func Copy_intp(int) *int
-func _swig_wrap_delete_intp(*int)
-
-func Delete_intp(arg1 *int) {
- _swig_wrap_delete_intp(arg1)
-}
-
-func _swig_wrap_intp_assign(*int, int)
-
-func Intp_assign(arg1 *int, arg2 int) {
- _swig_wrap_intp_assign(arg1, arg2)
-}
-
-func Intp_value(*int) int
-func _swig_wrap_sub(int, int, []int)
-
-func Sub(arg1 int, arg2 int, arg3 []int) {
- _swig_wrap_sub(arg1, arg2, arg3)
-}
-
-func Divide(int, int, []int) int
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/pointer/runme.go b/Examples/go/pointer/runme.go
index 9cbcda489..63deb11b7 100644
--- a/Examples/go/pointer/runme.go
+++ b/Examples/go/pointer/runme.go
@@ -32,7 +32,7 @@ func main() {
// Now try the typemap library
// Now it is no longer necessary to manufacture pointers.
- // Instead we use a single element array which in Java is modifiable.
+ // Instead we use a single element slice which in Go is modifiable.
fmt.Println("Trying the typemap library")
r := []int{0}
diff --git a/Examples/go/reference/example.go b/Examples/go/reference/example.go
deleted file mode 100644
index fb98f8a18..000000000
--- a/Examples/go/reference/example.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type SwigcptrVector uintptr
-
-func (p SwigcptrVector) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVector) SwigIsVector() {
-}
-
-func _swig_wrap_new_Vector(float64, float64, float64) SwigcptrVector
-
-func NewVector(arg1 float64, arg2 float64, arg3 float64) Vector {
- return _swig_wrap_new_Vector(arg1, arg2, arg3)
-}
-
-func _swig_wrap_delete_Vector(uintptr)
-
-func DeleteVector(arg1 Vector) {
- _swig_wrap_delete_Vector(arg1.Swigcptr())
-}
-
-func _swig_wrap_Vector_print(SwigcptrVector) string
-
-func (arg1 SwigcptrVector) Print() string {
- return _swig_wrap_Vector_print(arg1)
-}
-
-type Vector interface {
- Swigcptr() uintptr
- SwigIsVector()
- Print() string
-}
-
-func _swig_wrap_addv(uintptr, uintptr) SwigcptrVector
-
-func Addv(arg1 Vector, arg2 Vector) Vector {
- return _swig_wrap_addv(arg1.Swigcptr(), arg2.Swigcptr())
-}
-
-type SwigcptrVectorArray uintptr
-
-func (p SwigcptrVectorArray) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVectorArray) SwigIsVectorArray() {
-}
-
-func _swig_wrap_new_VectorArray(int) SwigcptrVectorArray
-
-func NewVectorArray(arg1 int) VectorArray {
- return _swig_wrap_new_VectorArray(arg1)
-}
-
-func _swig_wrap_delete_VectorArray(uintptr)
-
-func DeleteVectorArray(arg1 VectorArray) {
- _swig_wrap_delete_VectorArray(arg1.Swigcptr())
-}
-
-func _swig_wrap_VectorArray_size(SwigcptrVectorArray) int
-
-func (arg1 SwigcptrVectorArray) Size() int {
- return _swig_wrap_VectorArray_size(arg1)
-}
-
-func _swig_wrap_VectorArray_get(SwigcptrVectorArray, int) SwigcptrVector
-
-func (arg1 SwigcptrVectorArray) Get(arg2 int) Vector {
- return _swig_wrap_VectorArray_get(arg1, arg2)
-}
-
-func _swig_wrap_VectorArray_set(SwigcptrVectorArray, int, uintptr)
-
-func (arg1 SwigcptrVectorArray) Set(arg2 int, arg3 Vector) {
- _swig_wrap_VectorArray_set(arg1, arg2, arg3.Swigcptr())
-}
-
-type VectorArray interface {
- Swigcptr() uintptr
- SwigIsVectorArray()
- Size() int
- Get(arg2 int) Vector
- Set(arg2 int, arg3 Vector)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/simple/example.go b/Examples/go/simple/example.go
deleted file mode 100644
index df0e70564..000000000
--- a/Examples/go/simple/example.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Gcd(int, int) int
-func _swig_wrap_Foo_set(float64)
-
-func SetFoo(arg1 float64) {
- _swig_wrap_Foo_set(arg1)
-}
-
-func GetFoo() float64
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/template/example.go b/Examples/go/template/example.go
deleted file mode 100644
index 671b5c2ba..000000000
--- a/Examples/go/template/example.go
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Maxint(int, int) int
-func Maxdouble(float64, float64) float64
-type SwigcptrVecint uintptr
-
-func (p SwigcptrVecint) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVecint) SwigIsVecint() {
-}
-
-func _swig_wrap_new_vecint(int) SwigcptrVecint
-
-func NewVecint(arg1 int) Vecint {
- return _swig_wrap_new_vecint(arg1)
-}
-
-func _swig_wrap_vecint_get(SwigcptrVecint, int) *int
-
-func (arg1 SwigcptrVecint) Get(arg2 int) *int {
- return _swig_wrap_vecint_get(arg1, arg2)
-}
-
-func _swig_wrap_vecint_set(SwigcptrVecint, int, *int)
-
-func (arg1 SwigcptrVecint) Set(arg2 int, arg3 *int) {
- _swig_wrap_vecint_set(arg1, arg2, arg3)
-}
-
-func _swig_wrap_vecint_getitem(SwigcptrVecint, int) int
-
-func (arg1 SwigcptrVecint) Getitem(arg2 int) int {
- return _swig_wrap_vecint_getitem(arg1, arg2)
-}
-
-func _swig_wrap_vecint_setitem(SwigcptrVecint, int, int)
-
-func (arg1 SwigcptrVecint) Setitem(arg2 int, arg3 int) {
- _swig_wrap_vecint_setitem(arg1, arg2, arg3)
-}
-
-func _swig_wrap_delete_vecint(uintptr)
-
-func DeleteVecint(arg1 Vecint) {
- _swig_wrap_delete_vecint(arg1.Swigcptr())
-}
-
-type Vecint interface {
- Swigcptr() uintptr
- SwigIsVecint()
- Get(arg2 int) *int
- Set(arg2 int, arg3 *int)
- Getitem(arg2 int) int
- Setitem(arg2 int, arg3 int)
-}
-
-type SwigcptrVecdouble uintptr
-
-func (p SwigcptrVecdouble) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVecdouble) SwigIsVecdouble() {
-}
-
-func _swig_wrap_new_vecdouble(int) SwigcptrVecdouble
-
-func NewVecdouble(arg1 int) Vecdouble {
- return _swig_wrap_new_vecdouble(arg1)
-}
-
-func _swig_wrap_vecdouble_get(SwigcptrVecdouble, int) *float64
-
-func (arg1 SwigcptrVecdouble) Get(arg2 int) *float64 {
- return _swig_wrap_vecdouble_get(arg1, arg2)
-}
-
-func _swig_wrap_vecdouble_set(SwigcptrVecdouble, int, *float64)
-
-func (arg1 SwigcptrVecdouble) Set(arg2 int, arg3 *float64) {
- _swig_wrap_vecdouble_set(arg1, arg2, arg3)
-}
-
-func _swig_wrap_vecdouble_getitem(SwigcptrVecdouble, int) float64
-
-func (arg1 SwigcptrVecdouble) Getitem(arg2 int) float64 {
- return _swig_wrap_vecdouble_getitem(arg1, arg2)
-}
-
-func _swig_wrap_vecdouble_setitem(SwigcptrVecdouble, int, float64)
-
-func (arg1 SwigcptrVecdouble) Setitem(arg2 int, arg3 float64) {
- _swig_wrap_vecdouble_setitem(arg1, arg2, arg3)
-}
-
-func _swig_wrap_delete_vecdouble(uintptr)
-
-func DeleteVecdouble(arg1 Vecdouble) {
- _swig_wrap_delete_vecdouble(arg1.Swigcptr())
-}
-
-type Vecdouble interface {
- Swigcptr() uintptr
- SwigIsVecdouble()
- Get(arg2 int) *float64
- Set(arg2 int, arg3 *float64)
- Getitem(arg2 int) float64
- Setitem(arg2 int, arg3 float64)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/variables/example.go b/Examples/go/variables/example.go
deleted file mode 100644
index f4f299b73..000000000
--- a/Examples/go/variables/example.go
+++ /dev/null
@@ -1,198 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func _swig_wrap_ivar_set(int)
-
-func SetIvar(arg1 int) {
- _swig_wrap_ivar_set(arg1)
-}
-
-func GetIvar() int
-func _swig_wrap_svar_set(int16)
-
-func SetSvar(arg1 int16) {
- _swig_wrap_svar_set(arg1)
-}
-
-func GetSvar() int16
-func _swig_wrap_lvar_set(int32)
-
-func SetLvar(arg1 int32) {
- _swig_wrap_lvar_set(arg1)
-}
-
-func GetLvar() int32
-func _swig_wrap_uivar_set(uint)
-
-func SetUivar(arg1 uint) {
- _swig_wrap_uivar_set(arg1)
-}
-
-func GetUivar() uint
-func _swig_wrap_usvar_set(uint16)
-
-func SetUsvar(arg1 uint16) {
- _swig_wrap_usvar_set(arg1)
-}
-
-func GetUsvar() uint16
-func _swig_wrap_ulvar_set(uint32)
-
-func SetUlvar(arg1 uint32) {
- _swig_wrap_ulvar_set(arg1)
-}
-
-func GetUlvar() uint32
-func _swig_wrap_scvar_set(int8)
-
-func SetScvar(arg1 int8) {
- _swig_wrap_scvar_set(arg1)
-}
-
-func GetScvar() int8
-func _swig_wrap_ucvar_set(byte)
-
-func SetUcvar(arg1 byte) {
- _swig_wrap_ucvar_set(arg1)
-}
-
-func GetUcvar() byte
-func _swig_wrap_cvar_set(byte)
-
-func SetCvar(arg1 byte) {
- _swig_wrap_cvar_set(arg1)
-}
-
-func GetCvar() byte
-func _swig_wrap_fvar_set(float32)
-
-func SetFvar(arg1 float32) {
- _swig_wrap_fvar_set(arg1)
-}
-
-func GetFvar() float32
-func _swig_wrap_dvar_set(float64)
-
-func SetDvar(arg1 float64) {
- _swig_wrap_dvar_set(arg1)
-}
-
-func GetDvar() float64
-func _swig_wrap_strvar_set(string)
-
-func SetStrvar(arg1 string) {
- _swig_wrap_strvar_set(arg1)
-}
-
-func GetStrvar() string
-func GetCstrvar() string
-func _swig_wrap_iptrvar_set(*int)
-
-func SetIptrvar(arg1 *int) {
- _swig_wrap_iptrvar_set(arg1)
-}
-
-func GetIptrvar() *int
-func _swig_wrap_name_set(string)
-
-func SetName(arg1 string) {
- _swig_wrap_name_set(arg1)
-}
-
-func GetName() string
-func _swig_wrap_ptptr_set(uintptr)
-
-func SetPtptr(arg1 Point) {
- _swig_wrap_ptptr_set(arg1.Swigcptr())
-}
-
-func _swig_wrap_ptptr_get() SwigcptrPoint
-
-func GetPtptr() Point {
- return _swig_wrap_ptptr_get()
-}
-
-func _swig_wrap_pt_set(uintptr)
-
-func SetPt(arg1 Point) {
- _swig_wrap_pt_set(arg1.Swigcptr())
-}
-
-func _swig_wrap_pt_get() SwigcptrPoint
-
-func GetPt() Point {
- return _swig_wrap_pt_get()
-}
-
-func GetStatus() int
-func GetPath() string
-func _swig_wrap_print_vars()
-
-func Print_vars() {
- _swig_wrap_print_vars()
-}
-
-func New_int(int) *int
-func _swig_wrap_new_Point(int, int) SwigcptrPoint
-
-func New_Point(arg1 int, arg2 int) Point {
- return _swig_wrap_new_Point(arg1, arg2)
-}
-
-func _swig_wrap_Point_print(uintptr) string
-
-func Point_print(arg1 Point) string {
- return _swig_wrap_Point_print(arg1.Swigcptr())
-}
-
-func _swig_wrap_pt_print()
-
-func Pt_print() {
- _swig_wrap_pt_print()
-}
-
-
-type SwigcptrPoint uintptr
-type Point interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrPoint) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i
index a0be05f24..5ea6777fb 100644
--- a/Examples/ocaml/argout_ref/example.i
+++ b/Examples/ocaml/argout_ref/example.i
@@ -1,4 +1,8 @@
/* File : example.i */
%module example
+%{
+extern "C" void factor(int &x, int &y);
+%}
+
extern "C" void factor(int &x, int &y);
diff --git a/Examples/ocaml/shapes/example.c b/Examples/ocaml/shapes/example.c
index bf0fff937..26c1b8098 100644
--- a/Examples/ocaml/shapes/example.c
+++ b/Examples/ocaml/shapes/example.c
@@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
}
double volume::depth( double x, double y ) { return 0.0; }
+
+volume::~volume() { }
diff --git a/Examples/ocaml/shapes/example.h b/Examples/ocaml/shapes/example.h
index 4b1644494..68cb6ee3e 100644
--- a/Examples/ocaml/shapes/example.h
+++ b/Examples/ocaml/shapes/example.h
@@ -9,7 +9,8 @@ public:
class volume {
public:
- virtual double depth( double x, double y );
+ virtual double depth( double x, double y );
+ virtual ~volume();
};
extern void draw_shape_coverage( shape *s, int div_x, int div_y );
diff --git a/Examples/ocaml/std_string/README b/Examples/ocaml/std_string/README
index 566553083..ccebecbaf 100644
--- a/Examples/ocaml/std_string/README
+++ b/Examples/ocaml/std_string/README
@@ -1,3 +1,9 @@
+--- New ---
+
+It's not possible to access std::(w)string at the moment as it breaks other string examples.
+
+--- Old ---
+
This example shows how to use both std::string and std::wstring in Ocaml,
and also demonstrates that one might use this to make a locale-obedient
Ocaml program.
diff --git a/Examples/ocaml/strings_test/example.h b/Examples/ocaml/strings_test/example.h
index 3417981f0..959404b5d 100644
--- a/Examples/ocaml/strings_test/example.h
+++ b/Examples/ocaml/strings_test/example.h
@@ -1,14 +1,18 @@
/* -*- mode: c++ -*- */
/* File : example.h -- Tests all string typemaps */
+#include
+#include
+
void takes_std_string( std::string in ) {
cout << "takes_std_string( \"" << in << "\" );" << endl;
}
std::string gives_std_string() {
- time_t t;
-
- return std::string( asctime( localtime( &t ) ) );
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ return std::string( asctime( localtime( &tv.tv_sec ) ) );
}
void takes_char_ptr( char *p ) {
@@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
inout.insert( inout.end(), ']' );
}
-void takes_and_gives_char_ptr( char *&ptr ) {
- char *pout = strchr( ptr, '.' );
- if( pout ) ptr = pout + 1;
- else ptr = "foo";
+void takes_and_gives_char_ptr( char *&inout ) {
+ char *pout = strchr( inout, '.' );
+ if( pout ) inout = pout + 1;
+ else inout = "foo";
}
/*
diff --git a/Examples/php/overloading/runme.php b/Examples/php/overloading/runme.php
index 01044445f..56d515138 100644
--- a/Examples/php/overloading/runme.php
+++ b/Examples/php/overloading/runme.php
@@ -35,11 +35,10 @@ print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
-print "\nHere are some properties of the shapes:\n";
+print "\nCall some overloaded methods:\n";
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
- print " ".get_class($o)." \$o\n";
- print " overloaded = " . overloaded($o) . "\n";
- }
+ print " overloaded = " . overloaded($o) . "\n";
+}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
diff --git a/Examples/python/performance/Makefile b/Examples/python/performance/Makefile
new file mode 100644
index 000000000..c580801b4
--- /dev/null
+++ b/Examples/python/performance/Makefile
@@ -0,0 +1,37 @@
+ifeq (,$(PY3))
+ PYSCRIPT = runme.py
+else
+ PYSCRIPT = runme3.py
+endif
+
+default : all
+
+include ../../Makefile
+
+SUBDIRS := constructor func hierarchy operator hierarchy_operator
+
+.PHONY : all $(SUBDIRS)
+
+all : $(SUBDIRS:%=%-build)
+ @for subdir in $(SUBDIRS); do \
+ echo Running $$subdir test... ; \
+ echo -------------------------------------------------------------------------------- ; \
+ cd $$subdir; \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT); \
+ cd ..; \
+ done
+
+$(SUBDIRS) :
+ $(MAKE) -C $@
+ @echo Running $$subdir test...
+ @echo --------------------------------------------------------------------------------
+ cd $@ && env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(PYTHON) $(PYSCRIPT)
+
+%-build :
+ $(MAKE) -C $*
+
+%-clean :
+ $(MAKE) -s -C $* clean
+
+clean : $(SUBDIRS:%=%-clean)
+ rm -f *.pyc
diff --git a/Examples/python/performance/constructor/Makefile b/Examples/python/performance/constructor/Makefile
new file mode 100644
index 000000000..48449875c
--- /dev/null
+++ b/Examples/python/performance/constructor/Makefile
@@ -0,0 +1,21 @@
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = Simple
+INTERFACE = Simple.i
+
+all :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
+
+static :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean :
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
diff --git a/Examples/python/performance/constructor/Simple.i b/Examples/python/performance/constructor/Simple.i
new file mode 100644
index 000000000..d642d15bf
--- /dev/null
+++ b/Examples/python/performance/constructor/Simple.i
@@ -0,0 +1,8 @@
+%inline %{
+class MyClass {
+public:
+ MyClass () {}
+ ~MyClass () {}
+ void func () {}
+};
+%}
diff --git a/Examples/python/performance/constructor/runme.py b/Examples/python/performance/constructor/runme.py
new file mode 100644
index 000000000..23577a14d
--- /dev/null
+++ b/Examples/python/performance/constructor/runme.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env
+
+import sys
+sys.path.append('..')
+import harness
+
+def proc (mod) :
+ for i in range(1000000) :
+ x = mod.MyClass()
+
+harness.run(proc)
diff --git a/Examples/python/performance/func/Makefile b/Examples/python/performance/func/Makefile
new file mode 100644
index 000000000..0df09d908
--- /dev/null
+++ b/Examples/python/performance/func/Makefile
@@ -0,0 +1,23 @@
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = Simple
+INTERFACE = Simple.i
+
+default : all
+
+all :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
+
+static :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean :
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
diff --git a/Examples/python/performance/func/Simple.i b/Examples/python/performance/func/Simple.i
new file mode 100644
index 000000000..d642d15bf
--- /dev/null
+++ b/Examples/python/performance/func/Simple.i
@@ -0,0 +1,8 @@
+%inline %{
+class MyClass {
+public:
+ MyClass () {}
+ ~MyClass () {}
+ void func () {}
+};
+%}
diff --git a/Examples/python/performance/func/runme.py b/Examples/python/performance/func/runme.py
new file mode 100644
index 000000000..fd2fb175b
--- /dev/null
+++ b/Examples/python/performance/func/runme.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env
+
+import sys
+sys.path.append('..')
+import harness
+
+def proc (mod) :
+ x = mod.MyClass()
+ for i in range(10000000) :
+ x.func()
+
+harness.run(proc)
diff --git a/Examples/python/performance/harness.py b/Examples/python/performance/harness.py
new file mode 100644
index 000000000..8e9b6041b
--- /dev/null
+++ b/Examples/python/performance/harness.py
@@ -0,0 +1,30 @@
+#!/usr/bin/env
+
+import sys
+import time
+import imp
+from subprocess import *
+
+def run (proc) :
+
+ try :
+ mod = imp.find_module(sys.argv[1])
+ mod = imp.load_module(sys.argv[1], *mod)
+
+ t1 = time.clock()
+ proc(mod)
+ t2 = time.clock()
+ print "%s took %f seconds" % (mod.__name__, t2 - t1)
+
+ except IndexError :
+ proc = Popen([sys.executable, 'runme.py', 'Simple_baseline'], stdout=PIPE)
+ (stdout, stderr) = proc.communicate()
+ print stdout
+
+ proc = Popen([sys.executable, 'runme.py', 'Simple_optimized'], stdout=PIPE)
+ (stdout, stderr) = proc.communicate()
+ print stdout
+
+ proc = Popen([sys.executable, 'runme.py', 'Simple_builtin'], stdout=PIPE)
+ (stdout, stderr) = proc.communicate()
+ print stdout
diff --git a/Examples/python/performance/hierarchy/Makefile b/Examples/python/performance/hierarchy/Makefile
new file mode 100644
index 000000000..0df09d908
--- /dev/null
+++ b/Examples/python/performance/hierarchy/Makefile
@@ -0,0 +1,23 @@
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = Simple
+INTERFACE = Simple.i
+
+default : all
+
+all :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
+
+static :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean :
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
diff --git a/Examples/python/performance/hierarchy/Simple.i b/Examples/python/performance/hierarchy/Simple.i
new file mode 100644
index 000000000..b4f43ec3e
--- /dev/null
+++ b/Examples/python/performance/hierarchy/Simple.i
@@ -0,0 +1,52 @@
+%inline %{
+
+class A {
+public:
+ A () {}
+ ~A () {}
+ void func () {}
+};
+
+class B : public A {
+public:
+ B () {}
+ ~B () {}
+};
+
+class C : public B {
+public:
+ C () {}
+ ~C () {}
+};
+
+class D : public C {
+public:
+ D () {}
+ ~D () {}
+};
+
+class E : public D {
+public:
+ E () {}
+ ~E () {}
+};
+
+class F : public E {
+public:
+ F () {}
+ ~F () {}
+};
+
+class G : public F {
+public:
+ G () {}
+ ~G () {}
+};
+
+class H : public G {
+public:
+ H () {}
+ ~H () {}
+};
+
+%}
diff --git a/Examples/python/performance/hierarchy/runme.py b/Examples/python/performance/hierarchy/runme.py
new file mode 100644
index 000000000..8a57da05e
--- /dev/null
+++ b/Examples/python/performance/hierarchy/runme.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env
+
+import sys
+sys.path.append('..')
+import harness
+
+def proc (mod) :
+ x = mod.H()
+ for i in range(10000000) :
+ x.func()
+
+harness.run(proc)
diff --git a/Examples/python/performance/hierarchy_operator/Makefile b/Examples/python/performance/hierarchy_operator/Makefile
new file mode 100644
index 000000000..0df09d908
--- /dev/null
+++ b/Examples/python/performance/hierarchy_operator/Makefile
@@ -0,0 +1,23 @@
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = Simple
+INTERFACE = Simple.i
+
+default : all
+
+all :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
+
+static :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean :
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
diff --git a/Examples/python/performance/hierarchy_operator/Simple.i b/Examples/python/performance/hierarchy_operator/Simple.i
new file mode 100644
index 000000000..b26bcf31d
--- /dev/null
+++ b/Examples/python/performance/hierarchy_operator/Simple.i
@@ -0,0 +1,53 @@
+%inline %{
+
+class A {
+public:
+ A () {}
+ ~A () {}
+ void func () {}
+ A& operator+= (int i) { return *this; }
+};
+
+class B : public A {
+public:
+ B () {}
+ ~B () {}
+};
+
+class C : public B {
+public:
+ C () {}
+ ~C () {}
+};
+
+class D : public C {
+public:
+ D () {}
+ ~D () {}
+};
+
+class E : public D {
+public:
+ E () {}
+ ~E () {}
+};
+
+class F : public E {
+public:
+ F () {}
+ ~F () {}
+};
+
+class G : public F {
+public:
+ G () {}
+ ~G () {}
+};
+
+class H : public G {
+public:
+ H () {}
+ ~H () {}
+};
+
+%}
diff --git a/Examples/python/performance/hierarchy_operator/runme.py b/Examples/python/performance/hierarchy_operator/runme.py
new file mode 100644
index 000000000..cf200362f
--- /dev/null
+++ b/Examples/python/performance/hierarchy_operator/runme.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env
+
+import sys
+sys.path.append('..')
+import harness
+
+def proc (mod) :
+ x = mod.H()
+ for i in range(10000000) :
+ x += i
+
+harness.run(proc)
diff --git a/Examples/python/performance/operator/Makefile b/Examples/python/performance/operator/Makefile
new file mode 100644
index 000000000..0df09d908
--- /dev/null
+++ b/Examples/python/performance/operator/Makefile
@@ -0,0 +1,23 @@
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = Simple
+INTERFACE = Simple.i
+
+default : all
+
+all :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -module Simple_baseline' \
+ TARGET='$(TARGET)_baseline' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -O -module Simple_optimized' \
+ TARGET='$(TARGET)_optimized' INTERFACE='$(INTERFACE)' python_cpp
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG) -builtin -O -module Simple_builtin' \
+ TARGET='$(TARGET)_builtin' INTERFACE='$(INTERFACE)' python_cpp
+
+static :
+ $(MAKE) -f $(TOP)/Makefile CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='mypython' INTERFACE='$(INTERFACE)' python_cpp_static
+
+clean :
+ $(MAKE) -f $(TOP)/Makefile python_clean
+ rm -f $(TARGET).py
diff --git a/Examples/python/performance/operator/Simple.i b/Examples/python/performance/operator/Simple.i
new file mode 100644
index 000000000..fb0dd992c
--- /dev/null
+++ b/Examples/python/performance/operator/Simple.i
@@ -0,0 +1,8 @@
+%inline %{
+class MyClass {
+public:
+ MyClass () {}
+ ~MyClass () {}
+ MyClass& operator+ (int i) { return *this; }
+};
+%}
diff --git a/Examples/python/performance/operator/runme.py b/Examples/python/performance/operator/runme.py
new file mode 100644
index 000000000..61a0e8edc
--- /dev/null
+++ b/Examples/python/performance/operator/runme.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env
+
+import sys
+sys.path.append('..')
+import harness
+
+def proc (mod) :
+ x = mod.MyClass()
+ for i in range(10000000) :
+ x = x + i
+
+harness.run(proc)
diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i
index 2e4d105b1..d8372c936 100644
--- a/Examples/test-suite/abstract_virtual.i
+++ b/Examples/test-suite/abstract_virtual.i
@@ -2,10 +2,12 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
%inline %{
#if defined(_MSC_VER)
diff --git a/Examples/test-suite/array_typedef_memberin.i b/Examples/test-suite/array_typedef_memberin.i
index 3a0cf2522..ed49543a3 100644
--- a/Examples/test-suite/array_typedef_memberin.i
+++ b/Examples/test-suite/array_typedef_memberin.i
@@ -1,12 +1,43 @@
%module array_typedef_memberin
%inline %{
-typedef short arr_short8[8];
+typedef short Eight[8];
+typedef const short ConstEight[8];
namespace ArrayExample
{
class ExampleDetail
{
public:
- arr_short8 node_list;
- };
+ Eight node_list;
+#ifndef _MSC_VER
+ const Eight node_list2;
+ ConstEight node_list3;
+#else
+ Eight node_list2;
+ Eight node_list3;
+#endif
+
+ void fn1(Eight a) {}
+ void fn2(const Eight a) {}
+ void fn3(ConstEight a) {}
+
+ void fn4(Eight* a) {}
+ void fn5(ConstEight* a) {}
+ void fn6(const ConstEight* a) {}
+
+ void fn7(Eight*& a) {}
+ void fn8(ConstEight*& a) {}
+ void fn9(const ConstEight*& a) {}
+ };
}
+
+typedef int Four[4];
+typedef const int ConstFour[4];
+
+void test_1(int (*v)[4]) {}
+void test_2(Four *v) {}
+void test_3(const Four *v) {}
+void test_4(ConstFour *v) {}
+void test_5(const int (*v)[4]) {}
+void test_3r(const Four *&v) {}
+void test_4r(ConstFour *&v) {}
%}
diff --git a/Examples/test-suite/char_binary.i b/Examples/test-suite/char_binary.i
new file mode 100644
index 000000000..778792946
--- /dev/null
+++ b/Examples/test-suite/char_binary.i
@@ -0,0 +1,29 @@
+/*
+A test case for testing non null terminated char pointers.
+*/
+
+%module char_binary
+
+%apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) }
+
+%inline %{
+struct Test {
+ size_t strlen(const char *str, size_t len) {
+ return len;
+ }
+};
+
+typedef char namet[5];
+namet var_namet;
+
+typedef char* pchar;
+pchar var_pchar;
+%}
+
+// Remove string handling typemaps and treat as pointer
+%typemap(freearg) SWIGTYPE * ""
+%apply SWIGTYPE * { char * }
+
+%include "carrays.i"
+%array_functions(char, pchar);
+
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 02548747c..107d99dfb 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -148,12 +148,14 @@ CPP_TEST_CASES += \
cpp_static \
cpp_typedef \
default_args \
+ default_arg_values \
default_constructor \
defvalue_constructor \
derived_byvalue \
derived_nested \
destructor_reprotected \
director_abstract \
+ director_alternating \
director_basic \
director_classes \
director_classic \
@@ -166,6 +168,7 @@ CPP_TEST_CASES += \
director_finalizer \
director_frob \
director_ignore \
+ director_keywords \
director_namespace_clash \
director_nested \
director_overload \
@@ -228,9 +231,11 @@ CPP_TEST_CASES += \
li_cpointer \
li_stdint \
li_typemaps \
+ li_typemaps_apply \
li_windows \
long_long_apply \
memberin_extend \
+ member_funcptr_galore \
member_pointer \
member_template \
minherit \
@@ -259,11 +264,13 @@ CPP_TEST_CASES += \
null_pointer \
operator_overload \
operator_overload_break \
+ operator_pointer_ref \
operbool \
ordering \
overload_copy \
overload_extend \
overload_rename \
+ overload_return_type \
overload_simple \
overload_subtype \
overload_template \
@@ -283,6 +290,7 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
+ rename_simple \
rename_strip_encoder \
rename_pcre_encoder \
rename_pcre_enum \
@@ -307,6 +315,7 @@ CPP_TEST_CASES += \
smart_pointer_rename \
smart_pointer_simple \
smart_pointer_static \
+ smart_pointer_template_const_overload \
smart_pointer_templatemethods \
smart_pointer_templatevariables \
smart_pointer_typedef \
@@ -318,11 +327,11 @@ CPP_TEST_CASES += \
struct_initialization_cpp \
struct_value \
symbol_clash \
- template \
template_arg_replace \
template_arg_scope \
template_arg_typename \
template_array_numeric \
+ template_basic \
template_base_template \
template_classes \
template_const_ref \
@@ -396,6 +405,7 @@ CPP_TEST_CASES += \
typedef_scope \
typedef_sizet \
typedef_struct \
+ typemap_arrays \
typemap_delete \
typemap_global_scope \
typemap_namespace \
@@ -415,6 +425,7 @@ CPP_TEST_CASES += \
using_extend \
using_inherit \
using_namespace \
+ using_namespace_loop \
using_pointers \
using_private \
using_protected \
@@ -423,6 +434,7 @@ CPP_TEST_CASES += \
valuewrapper_const \
valuewrapper_opaque \
varargs \
+ varargs_overload \
virtual_destructor \
virtual_poly \
voidtest \
@@ -466,7 +478,7 @@ C_TEST_CASES += \
extern_declaration \
funcptr \
function_typedef \
- immutable \
+ immutable_values \
inctest \
integers \
keyword_rename \
@@ -487,6 +499,8 @@ C_TEST_CASES += \
overload_extendc \
preproc \
preproc_constants_c \
+ preproc_defined \
+ preproc_include \
preproc_line_file \
ret_by_value \
simple_array \
@@ -504,6 +518,7 @@ C_TEST_CASES += \
MULTI_CPP_TEST_CASES += \
clientdata_prop \
imports \
+ import_stl \
packageoption \
mod \
template_typedef_import \
@@ -511,6 +526,7 @@ MULTI_CPP_TEST_CASES += \
# Custom tests - tests with additional commandline options
wallkw.cpptest: SWIGOPT += -Wallkw
+preproc_include.ctest: SWIGOPT += -includeall
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i
index b979ef19e..0ad7e8e7c 100644
--- a/Examples/test-suite/contract.i
+++ b/Examples/test-suite/contract.i
@@ -3,12 +3,17 @@
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, D, Java, PHP multiple inheritance */
#ifdef SWIGCSHARP
%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
#endif
+#ifdef SWIGD
+%ignore B::bar; // Prevents getting an error that C.bar does not override any function because multiple inheritance is not supported.
+#endif
+
%contract test_preassert(int a, int b) {
require:
a > 0;
diff --git a/Examples/test-suite/cpp_basic.i b/Examples/test-suite/cpp_basic.i
index a247dd268..bd1ec453a 100644
--- a/Examples/test-suite/cpp_basic.i
+++ b/Examples/test-suite/cpp_basic.i
@@ -8,6 +8,12 @@
%newobject Bar::testFoo;
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
+#endif
+%}
+
%inline %{
class Foo {
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 48731f82b..f9a4bd76f 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -5,6 +5,7 @@
LANGUAGE = csharp
SCRIPTSUFFIX = _runme.cs
INTERPRETER = @CSHARPCILINTERPRETER@
+INTERPRETER_FLAGS = @CSHARPCILINTERPRETER_FLAGS@
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
srcdir = @srcdir@
@@ -64,16 +65,17 @@ setup = \
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
+# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
- CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
+ CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
- env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $(INTERPRETER_FLAGS) $*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
- CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
+ CSHARPFLAGS='-nologo -debug+ $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
fi
diff --git a/Examples/test-suite/csharp/csharp_prepost_runme.cs b/Examples/test-suite/csharp/csharp_prepost_runme.cs
index d0bacdaba..f76dae38e 100644
--- a/Examples/test-suite/csharp/csharp_prepost_runme.cs
+++ b/Examples/test-suite/csharp/csharp_prepost_runme.cs
@@ -55,6 +55,43 @@ public class csharp_prepost_runme {
throw new Exception("Expecting CustomInt attribute");
}
}
+ // Dates
+ {
+ // pre post typemap attributes example
+ System.DateTime dateIn = new System.DateTime(2011, 4, 13);
+ System.DateTime dateOut = new System.DateTime();
+
+ // Note in calls below, dateIn remains unchanged and dateOut
+ // is set to a new value by the C++ call
+ csharp_prepostNamespace.Action action = new csharp_prepostNamespace.Action(dateIn, out dateOut);
+ if (dateOut != dateIn)
+ throw new Exception("dates wrong");
+
+ dateIn = new System.DateTime(2012, 7, 14);
+ action.doSomething(dateIn, out dateOut);
+ if (dateOut != dateIn)
+ throw new Exception("dates wrong");
+
+ System.DateTime refDate = new System.DateTime(1999, 12, 31);
+ if (csharp_prepost.ImportantDate != refDate)
+ throw new Exception("dates wrong");
+
+ refDate = new System.DateTime(1999, 12, 31);
+ csharp_prepost.ImportantDate = refDate;
+ System.DateTime importantDate = csharp_prepost.ImportantDate;
+ if (importantDate != refDate)
+ throw new Exception("dates wrong");
+
+ System.DateTime christmasEve = new System.DateTime(2000, 12, 24);
+ csharp_prepost.addYears(ref christmasEve, 10);
+ if (christmasEve != new System.DateTime(2010, 12, 24))
+ throw new Exception("dates wrong");
+
+ Person person = new Person();
+ person.Birthday = christmasEve;
+ if (person.Birthday != christmasEve)
+ throw new Exception("dates wrong");
+ }
}
private static void Assert(double d1, double d2) {
if (d1 != d2)
diff --git a/Examples/test-suite/csharp/director_alternating_runme.cs b/Examples/test-suite/csharp/director_alternating_runme.cs
new file mode 100644
index 000000000..19365217a
--- /dev/null
+++ b/Examples/test-suite/csharp/director_alternating_runme.cs
@@ -0,0 +1,11 @@
+
+using System;
+using director_alternatingNamespace;
+
+public class director_alternating_runme {
+ public static void Main() {
+ if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
+ throw new Exception("idFromGetBar failed");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/director_protected_runme.cs b/Examples/test-suite/csharp/director_protected_runme.cs
index ee4697b0e..b44c3b7e9 100644
--- a/Examples/test-suite/csharp/director_protected_runme.cs
+++ b/Examples/test-suite/csharp/director_protected_runme.cs
@@ -16,6 +16,7 @@ public class runme
Foo f = b.create();
FooBar fb = new FooBar();
FooBar2 fb2 = new FooBar2();
+ FooBar3 fb3 = new FooBar3();
String s;
s = fb.used();
@@ -37,6 +38,21 @@ public class runme
s = fb.pong();
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
throw new Exception("bad FooBar::pong");
+
+// if (fb3.cheer() != "FooBar3::cheer();")
+// throw new Exception("bad fb3::cheer");
+
+ if (fb2.callping() != "FooBar2::ping();")
+ throw new Exception("bad fb2.callping");
+
+ if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
+ throw new Exception("bad fb2.callcheer");
+
+ if (fb3.callping() != "Bar::ping();")
+ throw new Exception("bad fb3.callping");
+
+ if (fb3.callcheer() != "FooBar3::cheer();")
+ throw new Exception("bad fb3.callcheer");
}
}
@@ -69,4 +85,16 @@ class FooBar2 : Bar
}
}
+class FooBar3 : Bar
+{
+ public FooBar3() : base()
+ {
+ }
+
+ protected override String cheer()
+ {
+ return "FooBar3::cheer();";
+ }
+}
+
}
diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs
index 144736f2b..854c8dbb5 100644
--- a/Examples/test-suite/csharp/enum_thorough_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_runme.cs
@@ -405,6 +405,28 @@ public class runme {
if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
}
+ // different types
+ {
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
+
+ int global_enum = enum_thorough.global_typeint;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
+ global_enum = enum_thorough.global_typeboolfalse;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
+ global_enum = enum_thorough.global_typebooltrue;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
+ global_enum = enum_thorough.global_typebooltwo;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
+ global_enum = enum_thorough.global_typechar;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
+ global_enum = enum_thorough.global_typedefaultint;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
index d5bba1b7d..0c22d8e3f 100644
--- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
@@ -405,6 +405,28 @@ public class runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_simple.global_typeint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
+ global_enum = enum_thorough_simple.global_typeboolfalse;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
+ global_enum = enum_thorough_simple.global_typebooltrue;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
+ global_enum = enum_thorough_simple.global_typebooltwo;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
+ global_enum = enum_thorough_simple.global_typechar;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
+ global_enum = enum_thorough_simple.global_typedefaultint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
index 3606d1137..86179dcf4 100644
--- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
@@ -405,6 +405,28 @@ public class runme {
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_typesafe.global_typeint;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
+ global_enum = enum_thorough_typesafe.global_typeboolfalse;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
+ global_enum = enum_thorough_typesafe.global_typebooltrue;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
+ global_enum = enum_thorough_typesafe.global_typebooltwo;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
+ global_enum = enum_thorough_typesafe.global_typechar;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
+ global_enum = enum_thorough_typesafe.global_typedefaultint;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/csharp/friends_runme.cs b/Examples/test-suite/csharp/friends_runme.cs
new file mode 100644
index 000000000..ae3ffb64f
--- /dev/null
+++ b/Examples/test-suite/csharp/friends_runme.cs
@@ -0,0 +1,43 @@
+using System;
+using friendsNamespace;
+
+public class friends_runme {
+ public static void Main() {
+ A a = new A(2);
+
+ if (friends.get_val1(a) != 2)
+ throw new Exception("failed");
+ if (friends.get_val2(a) != 4)
+ throw new Exception("failed");
+ if (friends.get_val3(a) != 6)
+ throw new Exception("failed");
+
+ // nice overload working fine
+ if (friends.get_val1(1,2,3) != 1)
+ throw new Exception("failed");
+
+ B b = new B(3);
+
+ // David's case
+ if (friends.mix(a,b) != 5)
+ throw new Exception("failed");
+
+ D_d di = new D_d(2);
+ D_d dd = new D_d(3.3);
+
+ // incredible template overloading working just fine
+ if (friends.get_val1(di) != 2)
+ throw new Exception("failed");
+ if (friends.get_val1(dd) != 3.3)
+ throw new Exception("failed");
+
+ friends.set(di, 4);
+ friends.set(dd, 1.3);
+
+ if (friends.get_val1(di) != 4)
+ throw new Exception("failed");
+ if (friends.get_val1(dd) != 1.3)
+ throw new Exception("failed");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/li_std_map_runme.cs b/Examples/test-suite/csharp/li_std_map_runme.cs
index b0a5a78e4..551cf2dc1 100644
--- a/Examples/test-suite/csharp/li_std_map_runme.cs
+++ b/Examples/test-suite/csharp/li_std_map_runme.cs
@@ -68,6 +68,7 @@ public class li_std_map_runme {
{
IList keys = new List(simap.Keys);
IList values = new List(simap.Values);
+ Dictionary check = new Dictionary();
if (keys.Count != collectionSize)
throw new Exception("Keys count test failed");
@@ -78,6 +79,13 @@ public class li_std_map_runme {
{
if (simap[keys[i]] != values[i])
throw new Exception("Keys and values test failed for index " + i);
+ check.Add(keys[i], values[i]);
+ }
+
+ for (int i = 0; i < collectionSize; i++)
+ {
+ if (!check.ContainsKey(i.ToString()))
+ throw new Exception("Keys and Values ContainsKey test " + i + " failed");
}
}
diff --git a/Examples/test-suite/csharp/nspace_runme.cs b/Examples/test-suite/csharp/nspace_runme.cs
index 9cf593857..fb6462541 100644
--- a/Examples/test-suite/csharp/nspace_runme.cs
+++ b/Examples/test-suite/csharp/nspace_runme.cs
@@ -2,7 +2,7 @@ using System;
public class runme
{
- static void Main()
+ static void Main()
{
// constructors and destructors
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
@@ -62,7 +62,7 @@ public class runme
throw new ApplicationException("Transmission2 wrong");
// turn feature off / ignoring
- nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
+ nspaceNamespace.Outer.namespce ns = new nspaceNamespace.Outer.namespce();
ns.Dispose();
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
nons.Dispose();
diff --git a/Examples/test-suite/csharp/pointer_reference_runme.cs b/Examples/test-suite/csharp/pointer_reference_runme.cs
index d00555199..2b9f526af 100644
--- a/Examples/test-suite/csharp/pointer_reference_runme.cs
+++ b/Examples/test-suite/csharp/pointer_reference_runme.cs
@@ -12,6 +12,9 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.instance.value != 20) throw new Exception("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new Exception("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new Exception("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
new file mode 100644
index 000000000..f6289e7e2
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
@@ -0,0 +1,12 @@
+using System;
+using rename_pcre_encoderNamespace;
+
+public class runme {
+ static void Main() {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new Exception(String.Format("Border with should be 17, not {0}",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/csharp/rename_simple_runme.cs b/Examples/test-suite/csharp/rename_simple_runme.cs
new file mode 100644
index 000000000..edf05ad24
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_simple_runme.cs
@@ -0,0 +1,30 @@
+
+using System;
+using rename_simpleNamespace;
+
+public class rename_simple_runme {
+
+ public static void Main() {
+ NewStruct s = new NewStruct();
+ check(111, s.NewInstanceVariable, "NewInstanceVariable");
+ check(222, s.NewInstanceMethod(), "NewInstanceMethod");
+ check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
+ check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
+ check(555, rename_simple.NewFunction(), "NewFunction");
+ check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
+
+ s.NewInstanceVariable = 1111;
+ NewStruct.NewStaticVariable = 4444;
+ rename_simple.NewGlobalVariable = 6666;
+
+ check(1111, s.NewInstanceVariable, "NewInstanceVariable");
+ check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
+ check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
+ }
+
+ public static void check(int expected, int actual, string msg) {
+ if (expected != actual)
+ throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
+ }
+}
+
diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i
index 817f5b9b9..31e6ec753 100644
--- a/Examples/test-suite/csharp_prepost.i
+++ b/Examples/test-suite/csharp_prepost.i
@@ -79,7 +79,7 @@ struct PrePost2 {
// Check attributes in the typemaps
%typemap(cstype, inattributes="[CustomInt]") int val "int"
-%typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int "tmp_$csinput"
+%typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int val "tmp_$csinput"
%typemap(imtype, out="IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "HandleRef/*overridden*/"
%inline %{
@@ -188,5 +188,8 @@ void subtractYears(CDate *pDate, int years) {
%inline %{
CDate ImportantDate = CDate(1999, 12, 31);
+struct Person {
+ CDate Birthday;
+};
%}
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
new file mode 100644
index 000000000..53b9f2859
--- /dev/null
+++ b/Examples/test-suite/d/Makefile.in
@@ -0,0 +1,81 @@
+#######################################################################
+# Makefile for D test-suite
+#######################################################################
+
+LANGUAGE = d
+srcdir = @srcdir@
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
+
+ifeq (2,$(D_VERSION))
+ VERSIONSUFFIX = .2
+else
+ VERSIONSUFFIX = .1
+endif
+
+TESTSUFFIX = _runme$(VERSIONSUFFIX).d
+
+CPP_TEST_CASES = \
+ d_exception_name \
+ d_nativepointers \
+ exception_partial_info
+
+include $(srcdir)/../common.mk
+
+# Override some variables from common.mk:
+
+TARGETSUFFIX = _wrap
+
+SWIGOPT+=-splitproxy -package $*
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_cpp))
+ +$(run_testcase)
+
+%.ctest:
+ $(setup)
+ +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_c))
+ +$(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_multi_cpp))
+ +$(run_testcase)
+
+# Makes a directory for the testcase if it does not exist
+setup = \
+ if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi; \
+ if [ ! -d $*$(VERSIONSUFFIX) ]; then \
+ mkdir $*$(VERSIONSUFFIX); \
+ fi; \
+ if [ ! -d $*$(VERSIONSUFFIX)/$* ]; then \
+ mkdir $*$(VERSIONSUFFIX)/$*; \
+ fi
+
+# Compiles D files then runs the testcase. A testcase is only run if
+# a file is found which has _runme.d appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
+ cd $*$(VERSIONSUFFIX) && \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ DFLAGS='-of$*_runme' \
+ DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) `find $* -name *.d`' d_compile && \
+ env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \
+ else \
+ cd $*$(VERSIONSUFFIX) && \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ DFLAGS='-c' \
+ DSRCS='`find $* -name *.d`' d_compile && cd .. ; \
+ fi
+
+# Clean: remove testcase directories
+%.clean:
+ @if [ -d $*$(VERSIONSUFFIX) ]; then \
+ rm -rf $*$(VERSIONSUFFIX); \
+ fi
diff --git a/Examples/test-suite/d/README b/Examples/test-suite/d/README
new file mode 100644
index 000000000..bb5372882
--- /dev/null
+++ b/Examples/test-suite/d/README
@@ -0,0 +1,7 @@
+D language module testsuite
+---------------------------
+
+Please see ../README for the common readme file.
+
+By default the D1 version is built, set D_VERSION=2 (in the environment or at
+the make command line) to run it for D2 instead.
diff --git a/Examples/test-suite/d/aggregate_runme.1.d b/Examples/test-suite/d/aggregate_runme.1.d
new file mode 100644
index 000000000..a00d34c25
--- /dev/null
+++ b/Examples/test-suite/d/aggregate_runme.1.d
@@ -0,0 +1,25 @@
+module aggregate_runme;
+
+import aggregate.aggregate;
+
+void main() {
+ // Confirm that move() returns correct results under normal use.
+ int result = move(UP);
+ if (result != UP) throw new Exception("UP failed");
+
+ result = move(DOWN);
+ if (result != DOWN) throw new Exception("DOWN failed");
+
+ result = move(LEFT);
+ if (result != LEFT) throw new Exception("LEFT failed");
+
+ result = move(RIGHT);
+ if (result != RIGHT) throw new Exception("RIGHT failed");
+
+ // Confirm that move() raises an exception when the contract is violated.
+ try {
+ move(0);
+ throw new Exception("0 test failed");
+ }
+ catch (Exception e) {}
+}
diff --git a/Examples/test-suite/d/aggregate_runme.2.d b/Examples/test-suite/d/aggregate_runme.2.d
new file mode 100644
index 000000000..a00d34c25
--- /dev/null
+++ b/Examples/test-suite/d/aggregate_runme.2.d
@@ -0,0 +1,25 @@
+module aggregate_runme;
+
+import aggregate.aggregate;
+
+void main() {
+ // Confirm that move() returns correct results under normal use.
+ int result = move(UP);
+ if (result != UP) throw new Exception("UP failed");
+
+ result = move(DOWN);
+ if (result != DOWN) throw new Exception("DOWN failed");
+
+ result = move(LEFT);
+ if (result != LEFT) throw new Exception("LEFT failed");
+
+ result = move(RIGHT);
+ if (result != RIGHT) throw new Exception("RIGHT failed");
+
+ // Confirm that move() raises an exception when the contract is violated.
+ try {
+ move(0);
+ throw new Exception("0 test failed");
+ }
+ catch (Exception e) {}
+}
diff --git a/Examples/test-suite/d/allprotected_runme.1.d b/Examples/test-suite/d/allprotected_runme.1.d
new file mode 100644
index 000000000..82a180e66
--- /dev/null
+++ b/Examples/test-suite/d/allprotected_runme.1.d
@@ -0,0 +1,65 @@
+module allprotected_runme;
+
+import allprotected.Klass;
+import allprotected.ProtectedBase;
+
+void main() {
+ auto mpb = new MyProtectedBase("MyProtectedBase");
+ mpb.accessProtected();
+}
+
+class MyProtectedBase : ProtectedBase {
+public:
+ this(char[] name) {
+ super(name);
+ }
+
+ void accessProtected() {
+ char[] s = virtualMethod();
+ if (s != "ProtectedBase")
+ throw new Exception("Failed");
+
+ Klass k = instanceMethod(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticMethod(new Klass("abc"));
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ instanceMemberVariable = 30;
+ int i = instanceMemberVariable;
+ if (i != 30)
+ throw new Exception("Failed");
+
+ staticMemberVariable = 40;
+ i = staticMemberVariable;
+ if (i != 40)
+ throw new Exception("Failed");
+
+ i = staticConstMemberVariable;
+ if (i != 20)
+ throw new Exception("Failed");
+
+ anEnum = ProtectedBase.AnEnum.EnumVal1;
+ ProtectedBase.AnEnum ae = anEnum;
+ if (ae != ProtectedBase.AnEnum.EnumVal1)
+ throw new Exception("Failed");
+ }
+}
diff --git a/Examples/test-suite/d/allprotected_runme.2.d b/Examples/test-suite/d/allprotected_runme.2.d
new file mode 100644
index 000000000..799230291
--- /dev/null
+++ b/Examples/test-suite/d/allprotected_runme.2.d
@@ -0,0 +1,65 @@
+module allprotected_runme;
+
+import allprotected.Klass;
+import allprotected.ProtectedBase;
+
+void main() {
+ auto mpb = new MyProtectedBase("MyProtectedBase");
+ mpb.accessProtected();
+}
+
+class MyProtectedBase : ProtectedBase {
+public:
+ this(string name) {
+ super(name);
+ }
+
+ void accessProtected() {
+ string s = virtualMethod();
+ if (s != "ProtectedBase")
+ throw new Exception("Failed");
+
+ Klass k = instanceMethod(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticMethod(new Klass("abc"));
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ instanceMemberVariable = 30;
+ int i = instanceMemberVariable;
+ if (i != 30)
+ throw new Exception("Failed");
+
+ staticMemberVariable = 40;
+ i = staticMemberVariable;
+ if (i != 40)
+ throw new Exception("Failed");
+
+ i = staticConstMemberVariable;
+ if (i != 20)
+ throw new Exception("Failed");
+
+ anEnum = ProtectedBase.AnEnum.EnumVal1;
+ ProtectedBase.AnEnum ae = anEnum;
+ if (ae != ProtectedBase.AnEnum.EnumVal1)
+ throw new Exception("Failed");
+ }
+}
diff --git a/Examples/test-suite/d/apply_strings_runme.1.d b/Examples/test-suite/d/apply_strings_runme.1.d
new file mode 100644
index 000000000..960caa4ca
--- /dev/null
+++ b/Examples/test-suite/d/apply_strings_runme.1.d
@@ -0,0 +1,12 @@
+module apply_strings_runme;
+
+import apply_strings.apply_strings;
+
+const char[] TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+void main() {
+ if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
+ if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
+ auto pChar = CharFunction(null);
+ if (pChar !is null) throw new Exception("CharFunction failed");
+}
diff --git a/Examples/test-suite/d/apply_strings_runme.2.d b/Examples/test-suite/d/apply_strings_runme.2.d
new file mode 100644
index 000000000..86183f8a3
--- /dev/null
+++ b/Examples/test-suite/d/apply_strings_runme.2.d
@@ -0,0 +1,12 @@
+module apply_strings_runme;
+
+import apply_strings.apply_strings;
+
+enum string TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+void main() {
+ if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
+ if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
+ auto pChar = CharFunction(null);
+ if (pChar !is null) throw new Exception("CharFunction failed");
+}
diff --git a/Examples/test-suite/d/bools_runme.1.d b/Examples/test-suite/d/bools_runme.1.d
new file mode 100644
index 000000000..f501b0762
--- /dev/null
+++ b/Examples/test-suite/d/bools_runme.1.d
@@ -0,0 +1,20 @@
+/// This is the bool runtime testcase. It checks that the C++ bool type works.
+module bools_runme;
+
+import bools.bools;
+
+void main() {
+ bool t = true;
+ bool f = false;
+
+ check_bo(f);
+ check_bo(t);
+}
+
+void check_bo(bool input) {
+ for (int i = 0; i < 1000; ++i) {
+ if (bo(input) != input) {
+ throw new Exception("Runtime test check_bo failed.");
+ }
+ }
+}
diff --git a/Examples/test-suite/d/bools_runme.2.d b/Examples/test-suite/d/bools_runme.2.d
new file mode 100644
index 000000000..f501b0762
--- /dev/null
+++ b/Examples/test-suite/d/bools_runme.2.d
@@ -0,0 +1,20 @@
+/// This is the bool runtime testcase. It checks that the C++ bool type works.
+module bools_runme;
+
+import bools.bools;
+
+void main() {
+ bool t = true;
+ bool f = false;
+
+ check_bo(f);
+ check_bo(t);
+}
+
+void check_bo(bool input) {
+ for (int i = 0; i < 1000; ++i) {
+ if (bo(input) != input) {
+ throw new Exception("Runtime test check_bo failed.");
+ }
+ }
+}
diff --git a/Examples/test-suite/d/catches_runme.1.d b/Examples/test-suite/d/catches_runme.1.d
new file mode 100644
index 000000000..55b18132d
--- /dev/null
+++ b/Examples/test-suite/d/catches_runme.1.d
@@ -0,0 +1,33 @@
+module catches_runme;
+
+import catches.catches;
+
+void main() {
+ test({ test_catches(1); }, "C++ int exception thrown, value: 1");
+ test({ test_catches(2); }, "two");
+ test({ test_catches(3); }, "C++ ThreeException const & exception thrown");
+
+ test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1");
+ test({ test_exception_specification(2); }, "unknown exception");
+ test({ test_exception_specification(3); }, "unknown exception");
+
+ test({ test_catches_all(1); }, "unknown exception");
+}
+
+void test(void delegate() command, char[] expectedMessage) {
+ bool didntThrow;
+ try {
+ command();
+ didntThrow = true;
+ } catch (Exception e) {
+ if (e.msg != expectedMessage) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but received '" ~ e.msg ~ "'.");
+ }
+ }
+
+ if (didntThrow) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but no exception was thrown.");
+ }
+}
diff --git a/Examples/test-suite/d/catches_runme.2.d b/Examples/test-suite/d/catches_runme.2.d
new file mode 100644
index 000000000..508558485
--- /dev/null
+++ b/Examples/test-suite/d/catches_runme.2.d
@@ -0,0 +1,33 @@
+module catches_runme;
+
+import catches.catches;
+
+void main() {
+ test({ test_catches(1); }, "C++ int exception thrown, value: 1");
+ test({ test_catches(2); }, "two");
+ test({ test_catches(3); }, "C++ ThreeException const & exception thrown");
+
+ test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1");
+ test({ test_exception_specification(2); }, "unknown exception");
+ test({ test_exception_specification(3); }, "unknown exception");
+
+ test({ test_catches_all(1); }, "unknown exception");
+}
+
+void test(void delegate() command, string expectedMessage) {
+ bool didntThrow;
+ try {
+ command();
+ didntThrow = true;
+ } catch (Exception e) {
+ if (e.msg != expectedMessage) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but received '" ~ e.msg ~ "'.");
+ }
+ }
+
+ if (didntThrow) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but no exception was thrown.");
+ }
+}
diff --git a/Examples/test-suite/d/char_strings_runme.1.d b/Examples/test-suite/d/char_strings_runme.1.d
new file mode 100644
index 000000000..cde6fe0f7
--- /dev/null
+++ b/Examples/test-suite/d/char_strings_runme.1.d
@@ -0,0 +1,151 @@
+module char_strings_runme;
+
+import tango.text.convert.Integer;
+import char_strings.char_strings;
+
+const char[] CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+const char[] OTHERLAND_MSG = "Little message from the safe world.";
+
+void main() {
+ const uint count = 10000;
+ uint i = 0;
+
+ // get functions
+ for (i=0; i STARTED <---").newline;
+
+ debug_shared=TRACE;
+
+ // Change loop count to run for a long time to monitor memory
+ const int LOOP_COUNT = 1; // 50000;
+ for (int i = 0; i < LOOP_COUNT; ++i) {
+ runTest();
+ GC.collect();
+ }
+
+ if (TRACE)
+ Stdout("---> NEARLY FINISHED <---").newline;
+
+ // Try to get the GC to collect everything not referenced anymore.
+ int countdown = 100;
+ while (--countdown) {
+ GC.collect();
+ if (Klass.getTotal_count() == 1)
+ break;
+ Thread.sleep(0.01);
+ }
+
+ // A single remaining instance expected: the global variable (GlobalValue).
+ if (Klass.getTotal_count() != 1)
+ throw new Exception("Klass.total_count=" ~ toString(Klass.getTotal_count()));
+
+ // A single remaining instance expected: the global variable (GlobalSmartValue).
+ int wrapper_count = shared_ptr_wrapper_count();
+ if (wrapper_count != NOT_COUNTING)
+ if (wrapper_count != 1)
+ throw new Exception("shared_ptr wrapper count=" ~ toString(wrapper_count));
+
+ if (TRACE)
+ Stdout("---> FINISHED <---").newline;
+}
+
+void runTest() {
+ // simple shared_ptr usage - created in C++
+ {
+ auto k = new Klass("me oh my");
+ char[] val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ auto k = factorycreate();
+ char[] val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by value
+ {
+ auto k = new Klass("me oh my");
+ auto kret = valuetest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = reftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ // TODO: add in const versions too
+ if (smartpointertest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (smartpointerpointertest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (smartpointerreftest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (smartpointerpointerreftest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (nullsmartpointerpointertest(null) != "null pointer")
+ throw new Exception("not null smartpointer pointer");
+
+ try { valuetest(k); throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+
+ if (pointertest(k) !is null)
+ throw new Exception("return was not null");
+
+ try { reftest(k); throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+
+ // $owner
+ {
+ auto k = pointerownertest();
+ char[] val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ auto k = smartpointerpointerownertest();
+ char[] val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived pass by shared_ptr
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrtest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = valuetest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my valuetest", val); // note slicing
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = pointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = reftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // 3rd derived class
+ {
+ auto k = new Klass3rdDerived("me oh my");
+ char[] val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member value");
+ m.SmartMemberValue = k;
+ char[] val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ char[] val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member reference");
+ m.SmartMemberReference = k;
+ char[] val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ auto kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(4, kmemberVal);
+ verifyCount(4, kmember);
+ verifyCount(4, k);
+
+ delete m;
+
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+ }
+ // plain by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member value");
+ m.MemberValue = k;
+ char[] val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member pointer");
+ m.MemberPointer = k;
+ char[] val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member reference");
+ m.MemberReference = k;
+ char[] val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+
+ // null member variables
+ {
+ auto m = new MemberVariables();
+
+ // shared_ptr by value
+ auto k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ m.SmartMemberValue = null;
+ k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.MemberValue = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ auto kglobal = GlobalSmartValue;
+ if (kglobal !is null)
+ throw new Exception("expected null");
+
+ auto k = new Klass("smart global value");
+ GlobalSmartValue = k;
+ verifyCount(2, k);
+
+ kglobal = GlobalSmartValue;
+ char[] val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyCount(3, kglobal);
+ verifyCount(3, k);
+ verifyValue("smart global value", GlobalSmartValue.getValue());
+ GlobalSmartValue = null;
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global value");
+ GlobalValue = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalValue;
+ char[] val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", GlobalValue.getValue());
+
+ try { GlobalValue = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+ // plain pointer
+ {
+ auto kglobal = GlobalPointer;
+ if (kglobal !is null)
+ throw new Exception("expected null");
+
+ auto k = new Klass("global pointer");
+ GlobalPointer = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalPointer;
+ char[] val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ GlobalPointer = null;
+ }
+ // plain reference
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global reference");
+ GlobalReference = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalReference;
+ char[] val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { GlobalReference = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4)
+ throw new Exception("Base values wrong");
+ if (pid.val1 != 10 || pid.val2 != 20.2)
+ throw new Exception("Derived Values wrong");
+ }
+}
+
+private void verifyValue(char[] expected, char[] got) {
+ if (expected != got)
+ throw new Exception("verify value failed. Expected: " ~ expected ~ " Got: " ~ got);
+}
+
+private void verifyCount(int expected, Klass k) {
+ // We deliberately call the use_count(Klass) overload also for objects which
+ // are instances of a subclass of Klass (due to static dispatch); things still
+ // have to work.
+ int got = use_count(k);
+ if (expected != got)
+ throw new Exception("verify use_count failed. Expected: " ~ toString(expected) ~ " Got: " ~ toString(got));
+}
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
new file mode 100644
index 000000000..773ae74d5
--- /dev/null
+++ b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
@@ -0,0 +1,602 @@
+module li_boost_shared_ptr_runme;
+
+import core.memory;
+import core.thread;
+import std.conv;
+import std.exception;
+import std.stdio;
+import li_boost_shared_ptr.li_boost_shared_ptr;
+import li_boost_shared_ptr.Klass;
+import li_boost_shared_ptr.KlassDerived;
+import li_boost_shared_ptr.Klass3rdDerived;
+import li_boost_shared_ptr.MemberVariables;
+import li_boost_shared_ptr.PairIntDouble;
+
+// Debugging flag
+enum TRACE = false;
+
+void main() {
+ if (TRACE)
+ writeln("---> STARTED <---");
+
+ debug_shared = TRACE;
+
+ // Change loop count to run for a long time to monitor memory
+ enum LOOP_COUNT = 1; // 50000;
+ for (int i = 0; i < LOOP_COUNT; ++i) {
+ runTest();
+ GC.collect();
+ }
+
+ if (TRACE)
+ writeln("---> NEARLY FINISHED <---");
+
+ // Try to get the GC to collect everything not referenced anymore.
+ int countdown = 100;
+ while (--countdown) {
+ GC.collect();
+ if (Klass.getTotal_count() == 1)
+ break;
+ Thread.sleep(100);
+ }
+
+ // A single remaining instance expected: the global variable (GlobalValue).
+ if (Klass.getTotal_count() != 1)
+ throw new Exception("Klass.total_count=" ~ to!string(Klass.getTotal_count()));
+
+ // A single remaining instance expected: the global variable (GlobalSmartValue).
+ int wrapper_count = shared_ptr_wrapper_count();
+ if (wrapper_count != NOT_COUNTING)
+ if (wrapper_count != 1)
+ throw new Exception("shared_ptr wrapper count=" ~ to!string(wrapper_count));
+
+ if (TRACE)
+ writeln("---> FINISHED <---");
+}
+
+void runTest() {
+ // simple shared_ptr usage - created in C++
+ {
+ auto k = new Klass("me oh my");
+ string val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ auto k = factorycreate();
+ string val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by value
+ {
+ auto k = new Klass("me oh my");
+ auto kret = valuetest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = reftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ // TODO: add in const versions too
+ enforce(smartpointertest(k) is null, "return was not null");
+ enforce(smartpointerpointertest(k) is null, "return was not null");
+ enforce(smartpointerreftest(k) is null, "return was not null");
+ enforce(smartpointerpointerreftest(k) is null, "return was not null");
+ enforce(nullsmartpointerpointertest(null) == "null pointer",
+ "not null smartpointer pointer");
+
+ enforceThrows( (){ valuetest(k); }, "Failed to catch null pointer");
+ enforce(pointertest(k) is null, "return was not null");
+ enforceThrows( (){ reftest(k); }, "Failed to catch null pointer");
+ }
+
+ // $owner
+ {
+ auto k = pointerownertest();
+ string val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ auto k = smartpointerpointerownertest();
+ string val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived pass by shared_ptr
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrtest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = valuetest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my valuetest", val); // note slicing
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = pointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = reftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // 3rd derived class
+ {
+ auto k = new Klass3rdDerived("me oh my");
+ string val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member value");
+ m.SmartMemberValue = k;
+ string val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ string val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member reference");
+ m.SmartMemberReference = k;
+ string val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ auto kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(4, kmemberVal);
+ verifyCount(4, kmember);
+ verifyCount(4, k);
+
+ delete m;
+
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+ }
+ // plain by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member value");
+ m.MemberValue = k;
+ string val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member pointer");
+ m.MemberPointer = k;
+ string val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member reference");
+ m.MemberReference = k;
+ string val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+
+ // null member variables
+ {
+ auto m = new MemberVariables();
+
+ // shared_ptr by value
+ auto k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ m.SmartMemberValue = null;
+ k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ enforceThrows( (){ m.MemberValue = null; }, "Failed to catch null pointer");
+ }
+
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ auto kglobal = GlobalSmartValue;
+ enforce(kglobal is null, "expected null");
+
+ auto k = new Klass("smart global value");
+ GlobalSmartValue = k;
+ verifyCount(2, k);
+
+ kglobal = GlobalSmartValue;
+ string val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyCount(3, kglobal);
+ verifyCount(3, k);
+ verifyValue("smart global value", GlobalSmartValue.getValue());
+ GlobalSmartValue = null;
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global value");
+ GlobalValue = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalValue;
+ string val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", GlobalValue.getValue());
+
+ enforceThrows((){ GlobalValue = null; }, "Failed to catch null pointer");
+ }
+ // plain pointer
+ {
+ auto kglobal = GlobalPointer;
+ enforce(kglobal is null, "expected null");
+
+ auto k = new Klass("global pointer");
+ GlobalPointer = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalPointer;
+ string val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ GlobalPointer = null;
+ }
+ // plain reference
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global reference");
+ GlobalReference = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalReference;
+ string val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ enforceThrows((){ GlobalReference = null; }, "Failed to catch null pointer");
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ auto pid = new PairIntDouble(10, 20.2);
+ enforce(pid.baseVal1 == 20 && pid.baseVal2== 40.4, "Base values wrong");
+ enforce(pid.val1 == 10 && pid.val2 == 20.2, "Derived Values wrong");
+ }
+}
+
+private void verifyValue(string expected, string got) {
+ if (expected != got)
+ throw new Exception("verify value failed. Expected: " ~ expected ~ " Got: " ~ got);
+}
+
+private void verifyCount(int expected, Klass k) {
+ // We deliberately call the use_count(Klass) overload also for objects which
+ // are instances of a subclass of Klass (due to static dispatch); things still
+ // have to work.
+ int got = use_count(k);
+ if (expected != got)
+ throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got));
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ if (!hasThrown) {
+ throw new Exception(errorMessage);
+ }
+ }
+}
diff --git a/Examples/test-suite/d/li_std_except_runme.1.d b/Examples/test-suite/d/li_std_except_runme.1.d
new file mode 100644
index 000000000..39f3bb202
--- /dev/null
+++ b/Examples/test-suite/d/li_std_except_runme.1.d
@@ -0,0 +1,40 @@
+module li_std_except_runme;
+
+import tango.core.Exception;
+import tango.io.Console;
+import li_std_except.Test;
+
+void main() {
+ with (new Test()) {
+ mixin(test("Exception", "throw_bad_exception"));
+ mixin(test("Exception", "throw_domain_error"));
+ mixin(test("Exception", "throw_exception"));
+ mixin(test("IllegalArgumentException", "throw_invalid_argument"));
+ mixin(test("NoSuchElementException", "throw_length_error"));
+ mixin(test("Exception", "throw_logic_error"));
+ mixin(test("NoSuchElementException", "throw_out_of_range"));
+ mixin(test("Exception", "throw_overflow_error"));
+ mixin(test("Exception", "throw_range_error"));
+ mixin(test("Exception", "throw_runtime_error"));
+ mixin(test("Exception", "throw_underflow_error"));
+ }
+}
+
+char[] test(char[] e, char[] f) {
+ return "if (!works!(" ~ e ~ ")(&" ~ f ~ ")) {\n" ~
+ "throw new Exception(\"" ~ f ~ " failed\");\n" ~
+ "}";
+}
+
+bool works(alias E, F)(F f) {
+ try {
+ try {
+ f();
+ } catch(E) {
+ return true;
+ }
+ } catch(Exception e) {
+ Cerr( "Received wrong exception: " ~ e.classinfo.name ).newline;
+ }
+ return false;
+}
diff --git a/Examples/test-suite/d/li_std_except_runme.2.d b/Examples/test-suite/d/li_std_except_runme.2.d
new file mode 100644
index 000000000..f2b4b672c
--- /dev/null
+++ b/Examples/test-suite/d/li_std_except_runme.2.d
@@ -0,0 +1,34 @@
+module li_std_except_runme;
+
+import std.exception;
+import std.stdio;
+import li_std_except.Test;
+
+void main() {
+ with (new Test()) {
+ enforce(works!(Exception)(&throw_bad_exception));
+ enforce(works!(Exception)(&throw_domain_error));
+ enforce(works!(Exception)(&throw_exception));
+ enforce(works!(Exception)(&throw_invalid_argument));
+ enforce(works!(Exception)(&throw_length_error));
+ enforce(works!(Exception)(&throw_logic_error));
+ enforce(works!(Exception)(&throw_out_of_range));
+ enforce(works!(Exception)(&throw_overflow_error));
+ enforce(works!(Exception)(&throw_range_error));
+ enforce(works!(Exception)(&throw_runtime_error));
+ enforce(works!(Exception)(&throw_underflow_error));
+ }
+}
+
+bool works(alias E, F)(F f) {
+ try {
+ try {
+ f();
+ } catch(E) {
+ return true;
+ }
+ } catch(Exception e) {
+ writefln( "Received wrong exception: %s", e.classinfo.name );
+ }
+ return false;
+}
diff --git a/Examples/test-suite/d/li_std_string_runme.1.d b/Examples/test-suite/d/li_std_string_runme.1.d
new file mode 100644
index 000000000..b5bbb51c0
--- /dev/null
+++ b/Examples/test-suite/d/li_std_string_runme.1.d
@@ -0,0 +1,97 @@
+module li_std_string_runme;
+
+import tango.core.Exception;
+import li_std_string.li_std_string;
+import li_std_string.Structure;
+import li_std_string.SWIGTYPE_p_std__string;
+
+
+void main() {
+ // Checking expected use of %typemap(in) std::string {}
+ test_value("Fee");
+
+ // Checking expected result of %typemap(out) std::string {}
+ if (test_value("Fi") != "Fi")
+ throw new Exception("Test 1 failed");
+
+ // Verify type-checking for %typemap(in) std::string {}
+ try {
+ test_value(null);
+ throw new Exception("Test 2 failed");
+ } catch (IllegalArgumentException) {
+ }
+
+ // Checking expected use of %typemap(in) const std::string & {}
+ test_const_reference("Fo");
+
+ // Checking expected result of %typemap(out) const std::string& {}
+ if (test_const_reference("Fum") != "Fum")
+ throw new Exception("Test 3 failed");
+
+ // Verify type-checking for %typemap(in) const std::string & {}
+ try {
+ test_const_reference(null);
+ throw new Exception("Test 4 failed");
+ } catch (IllegalArgumentException) {
+ }
+
+ // Input and output typemaps for pointers and non-const references to
+ // std::string are *not* supported; the following tests confirm
+ // that none of these cases are slipping through.
+
+ SWIGTYPE_p_std__string stringPtr = null;
+
+ stringPtr = test_pointer_out();
+ test_pointer(stringPtr);
+
+ stringPtr = test_const_pointer_out();
+ test_const_pointer(stringPtr);
+
+ stringPtr = test_reference_out();
+ test_reference(stringPtr);
+
+ // Check throw exception specification
+ try {
+ test_throw();
+ throw new Exception("test 5 failed!");
+ } catch (Exception e) {
+ if (e.msg != "test_throw message")
+ throw new Exception("Test 5 string check: " ~ e.msg);
+ }
+ try {
+ test_const_reference_throw();
+ throw new Exception("test 6 failed!");
+ } catch (Exception e) {
+ if (e.msg != "test_const_reference_throw message")
+ throw new Exception("Test 6 string check: " ~ e.msg);
+ }
+
+ // Global variables.
+ const char[] s = "initial string";
+ if (GlobalString2 != "global string 2")
+ throw new Exception("GlobalString2 test 1");
+ GlobalString2 = s;
+ if (GlobalString2 != s)
+ throw new Exception("GlobalString2 test 2");
+ if (ConstGlobalString != "const global string")
+ throw new Exception("ConstGlobalString test");
+
+ // Member variables.
+ auto myStructure = new Structure();
+ if (myStructure.MemberString2 != "member string 2")
+ throw new Exception("MemberString2 test 1");
+ myStructure.MemberString2 = s;
+ if (myStructure.MemberString2 != s)
+ throw new Exception("MemberString2 test 2");
+ if (myStructure.ConstMemberString != "const member string")
+ throw new Exception("ConstMemberString test");
+
+ // Static member variables.
+ if (Structure.StaticMemberString2 != "static member string 2")
+ throw new Exception("StaticMemberString2 test 1");
+ Structure.StaticMemberString2 = s;
+ if (Structure.StaticMemberString2 != s)
+ throw new Exception("StaticMemberString2 test 2");
+ if (Structure.ConstStaticMemberString != "const static member string")
+ throw new Exception("ConstStaticMemberString test");
+}
diff --git a/Examples/test-suite/d/li_std_string_runme.2.d b/Examples/test-suite/d/li_std_string_runme.2.d
new file mode 100644
index 000000000..395c2f7ff
--- /dev/null
+++ b/Examples/test-suite/d/li_std_string_runme.2.d
@@ -0,0 +1,86 @@
+module li_std_string_runme;
+
+import std.exception;
+import li_std_string.li_std_string;
+import li_std_string.Structure;
+import li_std_string.SWIGTYPE_p_std__string;
+
+void main() {
+ // Checking expected use of %typemap(in) std::string {}
+ test_value("Fee");
+
+ // Checking expected result of %typemap(out) std::string {}
+ enforce(test_value("Fi") == "Fi", "Test 1 failed");
+
+ // Verify type-checking for %typemap(in) std::string {}
+ enforceThrows( (){ test_value(null); }, "Test 2 failed.");
+
+ // Checking expected use of %typemap(in) const std::string & {}
+ test_const_reference("Fo");
+
+ // Checking expected result of %typemap(out) const std::string& {}
+ enforce(test_const_reference("Fum") == "Fum", "Test 3 failed");
+
+ // Verify type-checking for %typemap(in) const std::string & {}
+ enforceThrows( (){ test_const_reference(null); }, "Test 4 failed.");
+
+ // Input and output typemaps for pointers and non-const references to
+ // std::string are *not* supported; the following tests confirm
+ // that none of these cases are slipping through.
+
+ SWIGTYPE_p_std__string stringPtr = null;
+
+ stringPtr = test_pointer_out();
+ test_pointer(stringPtr);
+
+ stringPtr = test_const_pointer_out();
+ test_const_pointer(stringPtr);
+
+ stringPtr = test_reference_out();
+ test_reference(stringPtr);
+
+ // Check throw exception specification
+ try {
+ test_throw();
+ throw new Exception("test 5 failed!");
+ } catch (Exception e) {
+ enforce(e.msg == "test_throw message", "Test 5 string check: " ~ e.msg);
+ }
+ try {
+ test_const_reference_throw();
+ throw new Exception("test 6 failed!");
+ } catch (Exception e) {
+ enforce(e.msg == "test_const_reference_throw message", "Test 6 string check: " ~ e.msg);
+ }
+
+ // Global variables.
+ const string s = "initial string";
+ enforce(GlobalString2 == "global string 2", "GlobalString2 test 1");
+ GlobalString2 = s;
+ enforce(GlobalString2 == s, "GlobalString2 test 2");
+ enforce(ConstGlobalString == "const global string", "ConstGlobalString test");
+
+ // Member variables.
+ auto myStructure = new Structure();
+ enforce(myStructure.MemberString2 == "member string 2", "MemberString2 test 1");
+ myStructure.MemberString2 = s;
+ enforce(myStructure.MemberString2 == s, "MemberString2 test 2");
+ enforce(myStructure.ConstMemberString == "const member string", "ConstMemberString test");
+
+ // Static member variables.
+ enforce(Structure.StaticMemberString2 == "static member string 2", "StaticMemberString2 test 1");
+ Structure.StaticMemberString2 = s;
+ enforce(Structure.StaticMemberString2 == s, "StaticMemberString2 test 2");
+ enforce(Structure.ConstStaticMemberString == "const static member string", "ConstStaticMemberString test");
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ enforce(hasThrown, errorMessage);
+ }
+}
diff --git a/Examples/test-suite/d/li_std_vector_runme.1.d b/Examples/test-suite/d/li_std_vector_runme.1.d
new file mode 100644
index 000000000..895fb450f
--- /dev/null
+++ b/Examples/test-suite/d/li_std_vector_runme.1.d
@@ -0,0 +1,219 @@
+module li_std_vector_runme;
+
+import tango.core.Exception;
+import tango.io.Stdout;
+import Integer = tango.text.convert.Integer;
+import li_std_vector.li_std_vector;
+import li_std_vector.DoubleVector;
+import li_std_vector.IntVector;
+import li_std_vector.IntPtrVector;
+import li_std_vector.IntConstPtrVector;
+import li_std_vector.RealVector;
+import li_std_vector.Struct;
+import li_std_vector.StructVector;
+import li_std_vector.StructPtrVector;
+import li_std_vector.StructConstPtrVector;
+
+const size_t SIZE = 20;
+
+void main() {
+ // Basic functionality tests.
+ {
+ auto vector = new IntVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ vector ~= i * 10;
+ }
+
+ if (vector.length != SIZE) {
+ throw new Exception("length test failed.");
+ }
+
+ vector[0] = 200;
+ if (vector[0] != 200) {
+ throw new Exception("indexing test failed");
+ }
+ vector[0] = 0 * 10;
+
+ try {
+ vector[vector.length] = 777;
+ throw new Exception("out of range test failed");
+ } catch (NoSuchElementException) {
+ }
+
+ foreach (i, value; vector) {
+ if (value != (i * 10)) {
+ throw new Exception("foreach test failed, i: " ~ Integer.toString(i));
+ }
+ }
+
+ vector.clear();
+ if (vector.size != 0) {
+ throw new Exception("clear test failed");
+ }
+ }
+
+ // Slice tests.
+ {
+ auto dVector = new DoubleVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ dVector ~= i * 10.1f;
+ }
+
+ double[] dArray = dVector[];
+ foreach (i, value; dArray) {
+ if (dVector[i] != value) {
+ throw new Exception("slice test 1 failed, i: " ~ Integer.toString(i));
+ }
+ }
+
+
+ auto sVector = new StructVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ sVector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = sVector[];
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(sVector[i]);
+ if (aPtr != vPtr) {
+ throw new Exception("slice test 2 failed, i: " ~
+ Integer.toString(i));
+ }
+ }
+ }
+
+ // remove() tests.
+ {
+ auto iVector = new IntVector();
+ for (int i = 0; i < SIZE; i++) {
+ iVector ~= i;
+ }
+
+ iVector.remove(iVector.length - 1);
+ iVector.remove(SIZE / 2);
+ iVector.remove(0);
+
+ try {
+ iVector.remove(iVector.size);
+ throw new Exception("remove test failed");
+ } catch (NoSuchElementException) {
+ }
+ }
+
+ // Capacity tests.
+ {
+ auto dv = new DoubleVector(10);
+ if ((dv.capacity != 10) || (dv.length != 0)) {
+ throw new Exception("constructor setting capacity test failed");
+ }
+
+ // TODO: Is this really required (and spec'ed) behavior?
+ dv.capacity = 20;
+ if (dv.capacity != 20) {
+ throw new Exception("capacity test 1 failed");
+ }
+
+ dv ~= 1.11;
+ try {
+ dv.capacity = dv.length - 1;
+ throw new Exception("capacity test 2 failed");
+ } catch (IllegalArgumentException) {
+ }
+ }
+
+ // Test the methods being wrapped.
+ {
+ auto iv = new IntVector();
+ for (int i=0; i<4; i++) {
+ iv ~= i;
+ }
+
+ double x = average(iv);
+ x += average(new IntVector([1, 2, 3, 4]));
+ RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f]));
+
+ auto dv = new DoubleVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ dv ~= i / 2.0;
+ }
+ halve_in_place(dv);
+
+ RealVector v0 = vecreal(new RealVector());
+ float flo = 123.456f;
+ v0 ~= flo;
+ flo = v0[0];
+
+ IntVector v1 = vecintptr(new IntVector());
+ IntPtrVector v2 = vecintptr(new IntPtrVector());
+ IntConstPtrVector v3 = vecintconstptr(new IntConstPtrVector());
+
+ v1 ~= 123;
+ v2.clear();
+ v3.clear();
+
+ StructVector v4 = vecstruct(new StructVector());
+ StructPtrVector v5 = vecstructptr(new StructPtrVector());
+ StructConstPtrVector v6 = vecstructconstptr(new StructConstPtrVector());
+
+ v4 ~= new Struct(123);
+ v5 ~= new Struct(123);
+ v6 ~= new Struct(123);
+ }
+
+ // Test vectors of pointers.
+ {
+ auto vector = new StructPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = vector[];
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ if (aPtr != vPtr) {
+ throw new Exception("StructPtrVector test 1 failed, i: " ~
+ Integer.toString(i));
+ }
+ }
+ }
+
+ // Test vectors of const pointers.
+ {
+ auto vector = new StructConstPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = vector[];
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ if (aPtr != vPtr) {
+ throw new Exception("StructConstPtrVector test 1 failed, i: " ~
+ Integer.toString(i));
+ }
+ }
+ }
+
+ // Test vectors destroyed via dispose().
+ {
+ {
+ scope vector = new StructVector();
+ vector ~= new Struct(0.0);
+ vector ~= new Struct(11.1);
+ }
+ {
+ scope vector = new DoubleVector();
+ vector ~= 0.0;
+ vector ~= 11.1;
+ }
+ }
+}
diff --git a/Examples/test-suite/d/li_std_vector_runme.2.d b/Examples/test-suite/d/li_std_vector_runme.2.d
new file mode 100644
index 000000000..195ed8473
--- /dev/null
+++ b/Examples/test-suite/d/li_std_vector_runme.2.d
@@ -0,0 +1,207 @@
+module li_std_vector_runme;
+
+import std.algorithm;
+import std.array;
+import std.conv;
+import std.exception;
+import std.stdio;
+import li_std_vector.li_std_vector;
+import li_std_vector.DoubleVector;
+import li_std_vector.IntVector;
+import li_std_vector.IntPtrVector;
+import li_std_vector.IntConstPtrVector;
+import li_std_vector.RealVector;
+import li_std_vector.Struct;
+import li_std_vector.StructVector;
+import li_std_vector.StructPtrVector;
+import li_std_vector.StructConstPtrVector;
+
+const size_t SIZE = 20;
+
+void main() {
+ // Basic functionality tests.
+ {
+ auto vector = new IntVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ vector ~= i * 10;
+ }
+
+ enforce(vector.length == SIZE, "length test failed.");
+
+ vector[0] = 200;
+ enforce(vector[0] == 200, "indexing test failed");
+ vector[0] = 0 * 10;
+
+ enforceThrows((){ vector[vector.length] = 777; }, "out of range test failed" );
+
+ foreach (i, value; vector) {
+ enforce(value == (i * 10), "foreach test failed, i: " ~ to!string(i));
+ }
+
+ enforce(canFind!`a == 0 * 10`(vector[]), "canFind test 1 failed");
+ enforce(canFind!`a == 10 * 10`(vector[]), "canFind test 2 failed");
+ enforce(canFind!`a == 19 * 10`(vector[]), "canFind test 3 failed");
+ enforce(!canFind!`a == 20 * 10`(vector[]), "canFind test 4 failed");
+
+ foreach (i, _; vector) {
+ enforce(countUntil(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
+ }
+
+ enforce(countUntil(vector[], 42) == -1, "non-existant item indexOf test failed");
+
+ vector.clear();
+ enforce(vector.length == 0, "clear test failed");
+ }
+
+ // To array conversion tests.
+ {
+ auto dVector = new DoubleVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ dVector ~= i * 10.1f;
+ }
+
+ double[] dArray = array(dVector[]);
+ foreach (i, value; dArray) {
+ enforce(dVector[i] == value, "slice test 1 failed, i: " ~ to!string(i));
+ }
+
+
+ auto sVector = new StructVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ sVector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] sArray = array(sVector[]);
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(sArray[i]);
+ void* vPtr = Struct.swigGetCPtr(sVector[i]);
+ enforce(aPtr == vPtr, "slice test 2 failed, i: " ~ to!string(i));
+ }
+ }
+
+ // remove() tests.
+ {
+ auto iVector = new IntVector();
+ for (int i = 0; i < SIZE; i++) {
+ iVector ~= i;
+ }
+
+ iVector.remove(iVector.length - 1);
+ iVector.remove(SIZE / 2);
+ iVector.remove(0);
+
+ enforceThrows((){ iVector.remove(iVector.length); }, "remove test failed");
+ }
+
+ // Capacity tests.
+ {
+ auto dv = new DoubleVector(10);
+ enforce(dv.capacity == 10, "constructor setting capacity test failed (1)");
+ enforce(dv.length == 0, "constructor setting capacity test failed (1)");
+
+ dv.reserve(20);
+ enforce(dv.capacity == 20, "capacity test failed");
+ }
+
+ // Test the methods being wrapped.
+ {
+ auto iv = new IntVector();
+ for (int i=0; i<4; i++) {
+ iv ~= i;
+ }
+
+ double x = average(iv);
+ x += average(new IntVector([1, 2, 3, 4]));
+ RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f]));
+
+ auto dv = new DoubleVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ dv ~= i / 2.0;
+ }
+ halve_in_place(dv);
+
+ RealVector v0 = vecreal(new RealVector());
+ float flo = 123.456f;
+ v0 ~= flo;
+ flo = v0[0];
+
+ IntVector v1 = vecintptr(new IntVector());
+ IntPtrVector v2 = vecintptr(new IntPtrVector());
+ IntConstPtrVector v3 = vecintconstptr(new IntConstPtrVector());
+
+ v1 ~= 123;
+ v2.clear();
+ v3.clear();
+
+ StructVector v4 = vecstruct(new StructVector());
+ StructPtrVector v5 = vecstructptr(new StructPtrVector());
+ StructConstPtrVector v6 = vecstructconstptr(new StructConstPtrVector());
+
+ v4 ~= new Struct(123);
+ v5 ~= new Struct(123);
+ v6 ~= new Struct(123);
+ }
+
+ // Test vectors of pointers.
+ {
+ auto vector = new StructPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = array(vector[]);
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ enforce(aPtr == vPtr, "StructConstPtrVector test 1 failed, i: " ~ to!string(i));
+ }
+ }
+
+ // Test vectors of const pointers.
+ {
+ auto vector = new StructConstPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = array(vector[]);
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ enforce(aPtr == vPtr, "StructConstPtrVector test 1 failed, i: " ~ to!string(i));
+ }
+ }
+
+ // Test vectors destroyed via scope.
+ {
+ {
+ scope vector = new StructVector();
+ vector ~= new Struct(0.0);
+ vector ~= new Struct(11.1);
+ }
+ {
+ scope vector = new DoubleVector();
+ vector ~= 0.0;
+ vector ~= 11.1;
+ }
+ }
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ if (!hasThrown) {
+ throw new Exception(errorMessage);
+ }
+ }
+}
diff --git a/Examples/test-suite/d/li_typemaps_runme.1.d b/Examples/test-suite/d/li_typemaps_runme.1.d
new file mode 100644
index 000000000..e37b12bc2
--- /dev/null
+++ b/Examples/test-suite/d/li_typemaps_runme.1.d
@@ -0,0 +1,94 @@
+/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions.
+module li_typemaps_runme;
+
+import li_typemaps.li_typemaps;
+
+void main() {
+ // Check double INPUT typemaps
+ if (in_double(22.22) != 22.22) raiseError("in_double");
+ if (inr_double(22.22) != 22.22) raiseError("inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double var = 44.44;
+ out_double(22.22, var);
+ if (var != 22.22) raiseError("out_double");
+ }
+ {
+ double var = 44.44;
+ outr_double(22.22, var);
+ if (var != 22.22) raiseError("outr_double");
+ }
+
+ // Check double INOUT typemaps
+ {
+ double var = 44.44;
+ inout_double(var);
+ if (var != 44.44) raiseError("inout_double");
+ }
+ {
+ double var = 44.44;
+ inoutr_double(var);
+ if (var != 44.44) raiseError("inoutr_double");
+ }
+
+ // Check unsigned long long INPUT typemaps
+ if (in_ulonglong(20) != 20) raiseError("in_ulonglong");
+ if (inr_ulonglong(20) != 20) raiseError("inr_ulonglong");
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ ulong var = 40;
+ out_ulonglong(20, var);
+ if (var != 20) raiseError("out_ulonglong");
+ }
+ {
+ ulong var = 40;
+ outr_ulonglong(20, var);
+ if (var != 20) raiseError("outr_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ ulong var = 40;
+ inout_ulonglong(var);
+ if (var != 40) raiseError("inout_ulonglong");
+ }
+ {
+ ulong var = 40;
+ inoutr_ulonglong(var);
+ if (var != 40) raiseError("inoutr_ulonglong");
+ }
+
+ // Check unsigned bool INPUT typemaps
+ if (in_bool(false) != false) raiseError("in_bool");
+ if (inr_bool(false) != false) raiseError("inr_bool");
+
+ // Check unsigned bool OUTPUT typemaps
+ {
+ bool var = false;
+ out_bool(true, var);
+ if (var != true) raiseError("out_bool");
+ }
+ {
+ bool var = false;
+ outr_bool(true, var);
+ if (var != true) raiseError("outr_bool");
+ }
+
+ // Check unsigned bool INOUT typemaps
+ {
+ bool var = false;
+ inout_bool(var);
+ if (var != false) raiseError("inout_bool");
+ }
+ {
+ bool var = false;
+ inoutr_bool(var);
+ if (var != false) raiseError("inoutr_bool");
+ }
+}
+
+void raiseError(char[] funcName) {
+ throw new Exception("Test FAILED for function " ~ funcName);
+}
diff --git a/Examples/test-suite/d/li_typemaps_runme.2.d b/Examples/test-suite/d/li_typemaps_runme.2.d
new file mode 100644
index 000000000..de515b0ff
--- /dev/null
+++ b/Examples/test-suite/d/li_typemaps_runme.2.d
@@ -0,0 +1,91 @@
+/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions.
+module li_typemaps_runme;
+
+import std.exception;
+import li_typemaps.li_typemaps;
+
+void main() {
+ // Check double INPUT typemaps
+ enforce(in_double(22.22) == 22.22, "in_double");
+ enforce(inr_double(22.22) == 22.22, "inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double var = 44.44;
+ out_double(22.22, var);
+ enforce(var == 22.22, "out_double");
+ }
+ {
+ double var = 44.44;
+ outr_double(22.22, var);
+ enforce(var == 22.22, "outr_double");
+ }
+
+ // Check double INOUT typemaps
+ {
+ double var = 44.44;
+ inout_double(var);
+ enforce(var == 44.44, "inout_double");
+ }
+ {
+ double var = 44.44;
+ inoutr_double(var);
+ enforce(var == 44.44, "inoutr_double");
+ }
+
+ // Check unsigned long long INPUT typemaps
+ enforce(in_ulonglong(20) == 20, "in_ulonglong");
+ enforce(inr_ulonglong(20) == 20, "inr_ulonglong");
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ ulong var = 40;
+ out_ulonglong(20, var);
+ enforce(var == 20, "out_ulonglong");
+ }
+ {
+ ulong var = 40;
+ outr_ulonglong(20, var);
+ enforce(var == 20, "outr_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ ulong var = 40;
+ inout_ulonglong(var);
+ enforce(var == 40, "inout_ulonglong");
+ }
+ {
+ ulong var = 40;
+ inoutr_ulonglong(var);
+ enforce(var == 40, "inoutr_ulonglong");
+ }
+
+ // Check unsigned bool INPUT typemaps
+ enforce(in_bool(false) == false, "in_bool");
+ enforce(inr_bool(false) == false, "inr_bool");
+
+ // Check unsigned bool OUTPUT typemaps
+ {
+ bool var = false;
+ out_bool(true, var);
+ enforce(var == true, "out_bool");
+ }
+ {
+ bool var = false;
+ outr_bool(true, var);
+ enforce(var == true, "outr_bool");
+ }
+
+ // Check unsigned bool INOUT typemaps
+ {
+ bool var = false;
+ inout_bool(var);
+ enforce(var == false, "inout_bool");
+ }
+ {
+ bool var = false;
+ inoutr_bool(var);
+ enforce(var == false, "inoutr_bool");
+ }
+}
diff --git a/Examples/test-suite/d/long_long_runme.1.d b/Examples/test-suite/d/long_long_runme.1.d
new file mode 100644
index 000000000..a6d5448bc
--- /dev/null
+++ b/Examples/test-suite/d/long_long_runme.1.d
@@ -0,0 +1,35 @@
+// Checks if the long long and unsigned long long types work.
+module long_long_runme;
+
+import Integer = tango.text.convert.Integer;
+import long_long.long_long;
+
+void main() {
+ check_ll(0L);
+ check_ll(0x7FFFFFFFFFFFFFFFL);
+ check_ll(-10L);
+
+ check_ull(0u);
+ check_ull(127u);
+ check_ull(128u);
+ check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL
+ check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL
+}
+
+void check_ll(long value) {
+ ll = value;
+ long value_check = ll;
+ if (value != value_check) {
+ throw new Exception("Runtime test using long long failed: expected: " ~
+ Integer.toString(value) ~ ", got: " ~ Integer.toString(value_check));
+ }
+}
+
+void check_ull(ulong value) {
+ ull = value;
+ ulong value_check = ull;
+ if (value != value_check) {
+ throw new Exception( "Runtime test using unsigned long long failed: expected: " ~
+ Integer.toString(value) ~ ", ll_check=" ~ Integer.toString(value_check));
+ }
+}
diff --git a/Examples/test-suite/d/long_long_runme.2.d b/Examples/test-suite/d/long_long_runme.2.d
new file mode 100644
index 000000000..a082171b4
--- /dev/null
+++ b/Examples/test-suite/d/long_long_runme.2.d
@@ -0,0 +1,32 @@
+// Checks if the long long and unsigned long long types work.
+module long_long_runme;
+
+import std.conv;
+import std.exception;
+import long_long.long_long;
+
+void main() {
+ check_ll(0L);
+ check_ll(0x7FFFFFFFFFFFFFFFL);
+ check_ll(-10L);
+
+ check_ull(0u);
+ check_ull(127u);
+ check_ull(128u);
+ check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL
+ check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL
+}
+
+void check_ll(long value) {
+ ll = value;
+ long value_check = ll;
+ enforce(value == value_check, "Runtime test using long long failed: expected: " ~
+ to!string(value) ~ ", got: " ~ to!string(value_check));
+}
+
+void check_ull(ulong value) {
+ ull = value;
+ ulong value_check = ull;
+ enforce(value == value_check, "Runtime test using unsigned long long failed: expected: " ~
+ to!string(value) ~ ", ll_check=" ~ to!string(value_check));
+}
diff --git a/Examples/test-suite/d/member_pointer_runme.1.d b/Examples/test-suite/d/member_pointer_runme.1.d
new file mode 100644
index 000000000..c1f8d33b8
--- /dev/null
+++ b/Examples/test-suite/d/member_pointer_runme.1.d
@@ -0,0 +1,43 @@
+module member_pointer_runme;
+
+import Float = tango.text.convert.Float;
+import member_pointer.member_pointer;
+import member_pointer.Square;
+import member_pointer.SWIGTYPE_m_Shape__f_void__double;
+
+void main() {
+ auto s = new Square(10);
+
+ // Do some calculations
+ auto area_pt = areapt();
+ auto perim_pt = perimeterpt();
+ check("Square area ", 100.0, do_op(s, area_pt));
+ check("Square perim", 40.0, do_op(s, perim_pt));
+
+ SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+ memberPtr = areavar;
+ memberPtr = perimetervar;
+
+ // Try the variables
+ check("Square area ", 100.0, do_op(s, areavar));
+ check("Square perim", 40.0, do_op(s, perimetervar));
+
+ // Modify one of the variables
+ areavar = perim_pt;
+ check("Square perimeter", 40.0, do_op(s,areavar));
+
+ // Try the constants
+ memberPtr = AREAPT;
+ memberPtr = PERIMPT;
+ memberPtr = NULLPT;
+
+ check("Square area", 100.0, do_op(s, AREAPT));
+ check("Square perim", 40.0, do_op(s, PERIMPT));
+}
+
+void check(char[] what, double expected, double actual) {
+ if (expected != actual) {
+ throw new Exception("Failed: " ~ what ~ ": expected "
+ ~ Float.toString(expected) ~ ", but got " ~ Float.toString(actual));
+ }
+}
diff --git a/Examples/test-suite/d/member_pointer_runme.2.d b/Examples/test-suite/d/member_pointer_runme.2.d
new file mode 100644
index 000000000..a5c293cd0
--- /dev/null
+++ b/Examples/test-suite/d/member_pointer_runme.2.d
@@ -0,0 +1,42 @@
+module member_pointer_runme;
+
+import std.conv;
+import std.exception;
+import member_pointer.member_pointer;
+import member_pointer.Square;
+import member_pointer.SWIGTYPE_m_Shape__f_void__double;
+
+void main() {
+ auto s = new Square(10);
+
+ // Do some calculations
+ auto area_pt = areapt();
+ auto perim_pt = perimeterpt();
+ check("Square area", 100.0, do_op(s, area_pt));
+ check("Square perim", 40.0, do_op(s, perim_pt));
+
+ SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+ memberPtr = areavar;
+ memberPtr = perimetervar;
+
+ // Try the variables
+ check("Square area", 100.0, do_op(s, areavar));
+ check("Square perim", 40.0, do_op(s, perimetervar));
+
+ // Modify one of the variables
+ areavar = perim_pt;
+ check("Square perimeter", 40.0, do_op(s,areavar));
+
+ // Try the constants
+ memberPtr = AREAPT;
+ memberPtr = PERIMPT;
+ memberPtr = NULLPT;
+
+ check("Square area", 100.0, do_op(s, AREAPT));
+ check("Square perim", 40.0, do_op(s, PERIMPT));
+}
+
+void check(string what, double expected, double actual) {
+ enforce(expected == actual, "Failed: " ~ what ~ ": expected " ~
+ to!string(expected) ~ ", but got " ~ to!string(actual));
+}
diff --git a/Examples/test-suite/d/nspace_extend_runme.1.d b/Examples/test-suite/d/nspace_extend_runme.1.d
new file mode 100644
index 000000000..82ccfec90
--- /dev/null
+++ b/Examples/test-suite/d/nspace_extend_runme.1.d
@@ -0,0 +1,32 @@
+module nspace_extend_runme;
+
+static import oi1c = nspace_extend.Outer.Inner1.Color;
+static import oi2c = nspace_extend.Outer.Inner2.Color;
+
+void main() {
+ {
+ // constructors and destructors
+ scope color1 = new oi1c.Color();
+ scope color = new oi1c.Color(color1);
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ oi1c.Color.colorStaticMethod(20.0);
+ auto created = oi1c.Color.create();
+ }
+ {
+ // constructors and destructors
+ scope color2 = new oi2c.Color();
+ scope color = new oi2c.Color(color2);
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ oi2c.Color.colorStaticMethod(20.0);
+ auto created = oi2c.Color.create();
+
+ // Same class different namespaces
+ auto col1 = new oi1c.Color();
+ auto col2 = oi2c.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+ }
+}
diff --git a/Examples/test-suite/d/nspace_extend_runme.2.d b/Examples/test-suite/d/nspace_extend_runme.2.d
new file mode 100644
index 000000000..82ccfec90
--- /dev/null
+++ b/Examples/test-suite/d/nspace_extend_runme.2.d
@@ -0,0 +1,32 @@
+module nspace_extend_runme;
+
+static import oi1c = nspace_extend.Outer.Inner1.Color;
+static import oi2c = nspace_extend.Outer.Inner2.Color;
+
+void main() {
+ {
+ // constructors and destructors
+ scope color1 = new oi1c.Color();
+ scope color = new oi1c.Color(color1);
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ oi1c.Color.colorStaticMethod(20.0);
+ auto created = oi1c.Color.create();
+ }
+ {
+ // constructors and destructors
+ scope color2 = new oi2c.Color();
+ scope color = new oi2c.Color(color2);
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ oi2c.Color.colorStaticMethod(20.0);
+ auto created = oi2c.Color.create();
+
+ // Same class different namespaces
+ auto col1 = new oi1c.Color();
+ auto col2 = oi2c.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+ }
+}
diff --git a/Examples/test-suite/d/nspace_runme.1.d b/Examples/test-suite/d/nspace_runme.1.d
new file mode 100644
index 000000000..8d3b81f76
--- /dev/null
+++ b/Examples/test-suite/d/nspace_runme.1.d
@@ -0,0 +1,87 @@
+module nspace_runme;
+
+import nspace.nspace;
+static import nspace.NoNSpacePlease;
+static import nspace.Outer.namespce;
+static import nspace.Outer.Inner1.Channel;
+static import oi1c = nspace.Outer.Inner1.Color;
+static import nspace.Outer.Inner2.Channel;
+static import nspace.Outer.Inner2.Color;
+static import nspace.Outer.Inner3.Blue;
+static import nspace.Outer.Inner4.Blue;
+static import nspace.Outer.SomeClass;
+
+void main() {
+ // constructors and destructors
+ auto color1 = new oi1c.Color();
+ auto color = new oi1c.Color(color1);
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ oi1c.Color.colorStaticMethod(20.0);
+ auto created = oi1c.Color.create();
+
+ // class enums
+ auto someClass = new nspace.Outer.SomeClass.SomeClass();
+ auto channel = someClass.GetInner1ColorChannel();
+ if (channel != oi1c.Color.Channel.Transmission) {
+ throw new Exception("Transmission wrong");
+ }
+
+ // class anonymous enums
+ int val1 = oi1c.Color.ColorEnumVal1;
+ int val2 = oi1c.Color.ColorEnumVal2;
+ if (val1 != 0 || val2 != 0x22) {
+ throw new Exception("ColorEnumVal wrong");
+ }
+
+ // instance member variables
+ color.instanceMemberVariable = 123;
+ if (color.instanceMemberVariable != 123) {
+ throw new Exception("instance member variable failed");
+ }
+
+ // static member variables
+ oi1c.Color.staticMemberVariable = 789;
+ if (oi1c.Color.staticMemberVariable != 789) {
+ throw new Exception("static member variable failed");
+ }
+ if (oi1c.Color.staticConstMemberVariable != 222) {
+ throw new Exception("static const member variable failed");
+ }
+ if (oi1c.Color.staticConstEnumMemberVariable != oi1c.Color.Channel.Transmission) {
+ throw new Exception("static const enum member variable failed");
+ }
+
+ // check globals in a namespace don't get mangled with the nspace option
+ nspace.nspace.namespaceFunction(color);
+ nspace.nspace.namespaceVar = 111;
+ if (nspace.nspace.namespaceVar != 111) {
+ throw new Exception("global var failed");
+ }
+
+ // Same class different namespaces
+ auto col1 = new oi1c.Color();
+ auto col2 = nspace.Outer.Inner2.Color.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+
+ // global enums
+ auto outerChannel1 = someClass.GetInner1Channel();
+ if (outerChannel1 != nspace.Outer.Inner1.Channel.Channel.Transmission1) {
+ throw new Exception("Transmission1 wrong");
+ }
+ auto outerChannel2 = someClass.GetInner2Channel();
+ if (outerChannel2 != nspace.Outer.Inner2.Channel.Channel.Transmission2) {
+ throw new Exception("Transmission2 wrong");
+ }
+
+ // turn feature off / ignoring
+ auto ns = new nspace.Outer.namespce.namespce();
+ auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();
+
+ // Derived class
+ auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
+ blue3.blueInstanceMethod();
+ auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
+ blue4.blueInstanceMethod();
+}
diff --git a/Examples/test-suite/d/nspace_runme.2.d b/Examples/test-suite/d/nspace_runme.2.d
new file mode 100644
index 000000000..a86e4db9e
--- /dev/null
+++ b/Examples/test-suite/d/nspace_runme.2.d
@@ -0,0 +1,77 @@
+module nspace_runme;
+
+import std.exception;
+import nspace.nspace;
+static import nspace.NoNSpacePlease;
+static import nspace.Outer.namespce;
+static import nspace.Outer.Inner1.Channel;
+static import oi1c = nspace.Outer.Inner1.Color;
+static import nspace.Outer.Inner2.Channel;
+static import nspace.Outer.Inner2.Color;
+static import nspace.Outer.Inner3.Blue;
+static import nspace.Outer.Inner4.Blue;
+static import nspace.Outer.SomeClass;
+
+void main() {
+ // constructors and destructors
+ auto color1 = new oi1c.Color();
+ auto color = new oi1c.Color(color1);
+
+ // class methods
+ color.colorInstanceMethod(20.0);
+ oi1c.Color.colorStaticMethod(20.0);
+ auto created = oi1c.Color.create();
+
+ // class enums
+ auto someClass = new nspace.Outer.SomeClass.SomeClass();
+ auto channel = someClass.GetInner1ColorChannel();
+ enforce(channel == oi1c.Color.Channel.Transmission,
+ "Transmission wrong");
+
+ // class anonymous enums
+ int val1 = oi1c.Color.ColorEnumVal1;
+ int val2 = oi1c.Color.ColorEnumVal2;
+ enforce(val1 == 0 && val2 == 0x22, "ColorEnumVal wrong");
+
+ // instance member variables
+ color.instanceMemberVariable = 123;
+ enforce(color.instanceMemberVariable == 123,
+ "instance member variable failed");
+
+ // static member variables
+ oi1c.Color.staticMemberVariable = 789;
+ enforce(oi1c.Color.staticMemberVariable == 789,
+ "static member variable failed");
+ enforce(oi1c.Color.staticConstMemberVariable == 222,
+ "static const member variable failed");
+ enforce(oi1c.Color.staticConstEnumMemberVariable == oi1c.Color.Channel.Transmission,
+ "static const enum member variable failed");
+
+ // check globals in a namespace don't get mangled with the nspace option
+ nspace.nspace.namespaceFunction(color);
+ nspace.nspace.namespaceVar = 111;
+ enforce(nspace.nspace.namespaceVar == 111, "global var failed");
+
+ // Same class different namespaces
+ auto col1 = new oi1c.Color();
+ auto col2 = nspace.Outer.Inner2.Color.Color.create();
+ col2.colors(col1, col1, col2, col2, col2);
+
+ // global enums
+ auto outerChannel1 = someClass.GetInner1Channel();
+ enforce(outerChannel1 == nspace.Outer.Inner1.Channel.Channel.Transmission1,
+ "Transmission1 wrong");
+ auto outerChannel2 = someClass.GetInner2Channel();
+ enforce(outerChannel2 == nspace.Outer.Inner2.Channel.Channel.Transmission2,
+ "Transmission2 wrong");
+
+ // turn feature off / ignoring
+ auto ns = new nspace.Outer.namespce.namespce();
+ auto nons = new nspace.NoNSpacePlease.NoNSpacePlease();
+
+ // Derived class
+ auto blue3 = new nspace.Outer.Inner3.Blue.Blue();
+ blue3.blueInstanceMethod();
+ auto blue4 = new nspace.Outer.Inner4.Blue.Blue();
+ blue4.blueInstanceMethod();
+}
diff --git a/Examples/test-suite/d/operator_overload_runme.1.d b/Examples/test-suite/d/operator_overload_runme.1.d
new file mode 100644
index 000000000..18a24b91f
--- /dev/null
+++ b/Examples/test-suite/d/operator_overload_runme.1.d
@@ -0,0 +1,89 @@
+module operator_overload_runme;
+
+import operator_overload.Op;
+
+void main() {
+ // Invoke the C++ sanity check first.
+ Op.sanity_check();
+
+ auto a = new Op();
+ auto b = new Op(5);
+ auto c = b;
+ auto d = new Op(2);
+ auto dd = d;
+
+ // test equality
+ assert(a != b);
+ assert(b == c);
+ assert(a != d);
+ assert(d == dd);
+
+ // test <
+ assert(a < b);
+ assert(a <= b);
+ assert(b <= c);
+ assert(b >= c);
+ assert(b > d);
+ assert(b >= d);
+
+ // test +=
+ auto e = new Op(3);
+ e += d;
+ assert(e == b);
+ e -= c;
+ assert(e == a);
+ e = new Op(1);
+ e *= b;
+ assert(e == c);
+ e /= d;
+ assert(e == d);
+ e %= c;
+ assert(e == d);
+
+ // test +
+ auto f = new Op(1);
+ auto g = new Op(1);
+ assert(f + g == new Op(2));
+ assert(f - g == new Op(0));
+ assert(f * g == new Op(1));
+ assert(f / g == new Op(1));
+ assert(f % g == new Op(0));
+
+ // test unary operators
+ assert(-a == a);
+ assert(-b == new Op(-5));
+ // The unary ! operator is not overloadable in D1.
+
+ // test []
+ auto h = new Op(3);
+ assert(h[0]==3);
+ assert(h[1]==0);
+ // Generation of opIndexAssign is not supported yet.
+
+ // test ()
+ auto i = new Op(3);
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // test ++ and --
+ auto j = new Op(100);
+ int original = j.i;
+ {
+ Op newOp = j++;
+ int newInt = original++;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = j--;
+ int newInt = original--;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ // Prefix increment/decrement operators are lowered to (foo +=/-= 1) in D1,
+ // but the test case does not define an integer overload for operator +=
+ // respectively -=.
+
+ // Implicit casting is not overloadable in D1.
+}
\ No newline at end of file
diff --git a/Examples/test-suite/d/operator_overload_runme.2.d b/Examples/test-suite/d/operator_overload_runme.2.d
new file mode 100644
index 000000000..2ff61cd56
--- /dev/null
+++ b/Examples/test-suite/d/operator_overload_runme.2.d
@@ -0,0 +1,91 @@
+module operator_overload_runme;
+
+import operator_overload.Op;
+
+void main() {
+ // Invoke the C++ sanity check first.
+ Op.sanity_check();
+
+ auto a = new Op();
+ auto b = new Op(5);
+ auto c = b;
+ auto d = new Op(2);
+ auto dd = d;
+
+ // test equality
+ assert(a != b);
+ assert(b == c);
+ assert(a != d);
+ assert(d == dd);
+
+ // test <
+ assert(a < b);
+ assert(a <= b);
+ assert(b <= c);
+ assert(b >= c);
+ assert(b > d);
+ assert(b >= d);
+
+ // test +=
+ auto e = new Op(3);
+ e += d;
+ assert(e == b);
+ e -= c;
+ assert(e == a);
+ e = new Op(1);
+ e *= b;
+ assert(e == c);
+ e /= d;
+ assert(e == d);
+ e %= c;
+ assert(e == d);
+
+ // test +
+ auto f = new Op(1);
+ auto g = new Op(1);
+ assert(f + g == new Op(2));
+ assert(f - g == new Op(0));
+ assert(f * g == new Op(1));
+ assert(f / g == new Op(1));
+ assert(f % g == new Op(0));
+
+ // test unary operators
+ assert(-a == a);
+ assert(-b == new Op(-5));
+
+ // Unfortunaly, there is no way to override conversion to boolean for
+ // classes in D, opCast!("bool") is only used for structs.
+
+ // test []
+ auto h = new Op(3);
+ assert(h[0]==3);
+ assert(h[1]==0);
+ // Generation of opIndexAssign is not supported yet.
+
+ // test ()
+ auto i = new Op(3);
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // test ++ and --
+ auto j = new Op(100);
+ int original = j.i;
+ // The prefix increment/decrement operators are not directly overloadable in
+ // D2, and because the proxy classes are reference types, the lowering
+ // yields the same value as the postfix operators.
+ {
+ Op newOp = ++j;
+ int newInt = ++original;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = --j;
+ int newInt = --original;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+
+ // Implicit casting via alias this is not supported yet.
+}
\ No newline at end of file
diff --git a/Examples/test-suite/d/overload_complicated_runme.1.d b/Examples/test-suite/d/overload_complicated_runme.1.d
new file mode 100644
index 000000000..03d1bf1e6
--- /dev/null
+++ b/Examples/test-suite/d/overload_complicated_runme.1.d
@@ -0,0 +1,50 @@
+module overload_complicated_runme;
+
+import overload_complicated;
+
+void main() {
+ SWIGTYPE_p_int pInt = null;
+
+ // Check the correct constructors are available
+ Pop p = new Pop(pInt);
+
+ p = new Pop(pInt, false);
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ if (p.hip(false) != 701)
+ throw new Exception("Test 1 failed");
+
+ if (p.hip(pInt) != 702)
+ throw new Exception("Test 2 failed");
+
+ // Reverse the order for the above
+ if (p.hop(pInt) != 805)
+ throw new Exception("Test 3 failed");
+
+ if (p.hop(false) != 801)
+ throw new Exception("Test 4 failed");
+
+ // Few more variations and order shuffled
+ if (p.pop(false) != 901)
+ throw new Exception("Test 5 failed");
+
+ if (p.pop(pInt) != 902)
+ throw new Exception("Test 6 failed");
+
+ if (p.pop() != 905)
+ throw new Exception("Test 7 failed");
+
+ // Overload on const only
+ if (p.bop(pInt) != 1001)
+ throw new Exception("Test 8 failed");
+
+ if (p.bip(pInt) != 2001)
+ throw new Exception("Test 9 failed");
+
+ // Globals
+ if (muzak(false) != 3001)
+ throw new Exception("Test 10 failed");
+
+ if (muzak(pInt) != 3002)
+ throw new Exception("Test 11 failed");
+}
diff --git a/Examples/test-suite/d/overload_complicated_runme.2.d b/Examples/test-suite/d/overload_complicated_runme.2.d
new file mode 100644
index 000000000..9d03ec5e6
--- /dev/null
+++ b/Examples/test-suite/d/overload_complicated_runme.2.d
@@ -0,0 +1,34 @@
+module overload_complicated_runme;
+
+import std.exception;
+import overload_complicated.overload_complicated;
+import overload_complicated.Pop;
+
+void main() {
+ int* pInt = new int;
+
+ // Check the correct constructors are available
+ auto p = new Pop(pInt);
+ p = new Pop(pInt, false);
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ enforce(p.hip(false) == 701, "Test 1 failed");
+ enforce(p.hip(pInt) == 702, "Test 2 failed");
+
+ // Reverse the order for the above
+ enforce(p.hop(pInt) == 805, "Test 3 failed");
+ enforce(p.hop(false) == 801, "Test 4 failed");
+
+ // Few more variations and order shuffled
+ enforce(p.pop(false) == 901, "Test 5 failed");
+ enforce(p.pop(pInt) == 902, "Test 6 failed");
+ enforce(p.pop() == 905, "Test 7 failed");
+
+ // Overload on const only
+ enforce(p.bop(pInt) == 1001, "Test 8 failed");
+ enforce(p.bip(pInt) == 2001, "Test 9 failed");
+
+ // Globals
+ enforce(muzak(false) == 3001, "Test 10 failed");
+ enforce(muzak(pInt) == 3002, "Test 11 failed");
+}
diff --git a/Examples/test-suite/d/overload_template_runme.1.d b/Examples/test-suite/d/overload_template_runme.1.d
new file mode 100644
index 000000000..a1fe8012f
--- /dev/null
+++ b/Examples/test-suite/d/overload_template_runme.1.d
@@ -0,0 +1,146 @@
+module overload_template_runme;
+
+import overload_template.overload_template;
+import overload_template.Klass;
+
+void main() {
+ int f = foo();
+
+ f += maximum(3,4);
+ double b = maximum(3.4,5.2);
+ b++; // warning suppression
+
+ // mix 1
+ if (mix1("hi") != 101)
+ throw new Exception ("mix1(const char*)");
+
+ if (mix1(1.0, 1.0) != 102)
+ throw new Exception ("mix1(double, const double &)");
+
+ if (mix1(1.0) != 103)
+ throw new Exception ("mix1(double)");
+
+ // mix 2
+ if (mix2("hi") != 101)
+ throw new Exception ("mix2(const char*)");
+
+ if (mix2(1.0, 1.0) != 102)
+ throw new Exception ("mix2(double, const double &)");
+
+ if (mix2(1.0) != 103)
+ throw new Exception ("mix2(double)");
+
+ // mix 3
+ if (mix3("hi") != 101)
+ throw new Exception ("mix3(const char*)");
+
+ if (mix3(1.0, 1.0) != 102)
+ throw new Exception ("mix3(double, const double &)");
+
+ if (mix3(1.0) != 103)
+ throw new Exception ("mix3(double)");
+
+ // Combination 1
+ if (overtparams1(100) != 10)
+ throw new Exception ("overtparams1(int)");
+
+ if (overtparams1(100.0, 100) != 20)
+ throw new Exception ("overtparams1(double, int)");
+
+ // Combination 2
+ if (overtparams2(100.0, 100) != 40)
+ throw new Exception ("overtparams2(double, int)");
+
+ // Combination 3
+ if (overloaded() != 60)
+ throw new Exception ("overloaded()");
+
+ if (overloaded(100.0, 100) != 70)
+ throw new Exception ("overloaded(double, int)");
+
+ // Combination 4
+ if (overloadedagain("hello") != 80)
+ throw new Exception ("overloadedagain(const char *)");
+
+ if (overloadedagain() != 90)
+ throw new Exception ("overloadedagain(double)");
+
+ // specializations
+ if (specialization(10) != 202)
+ throw new Exception ("specialization(int)");
+
+ if (specialization(10.0) != 203)
+ throw new Exception ("specialization(double)");
+
+ if (specialization(10, 10) != 204)
+ throw new Exception ("specialization(int, int)");
+
+ if (specialization(10.0, 10.0) != 205)
+ throw new Exception ("specialization(double, double)");
+
+ if (specialization("hi", "hi") != 201)
+ throw new Exception ("specialization(const char *, const char *)");
+
+ // simple specialization
+ xyz();
+ xyz_int();
+ xyz_double();
+
+ // a bit of everything
+ if (overload("hi") != 0)
+ throw new Exception ("overload()");
+
+ if (overload(1) != 10)
+ throw new Exception ("overload(int t)");
+
+ if (overload(1, 1) != 20)
+ throw new Exception ("overload(int t, const int &)");
+
+ if (overload(1, "hello") != 30)
+ throw new Exception ("overload(int t, const char *)");
+
+ auto k = new Klass();
+ if (overload(k) != 10)
+ throw new Exception ("overload(Klass t)");
+
+ if (overload(k, k) != 20)
+ throw new Exception ("overload(Klass t, const Klass &)");
+
+ if (overload(k, "hello") != 30)
+ throw new Exception ("overload(Klass t, const char *)");
+
+ if (overload(10.0, "hi") != 40)
+ throw new Exception ("overload(double t, const char *)");
+
+ if (overload() != 50)
+ throw new Exception ("overload(const char *)");
+
+
+ // everything put in a namespace
+ if (nsoverload("hi") != 1000)
+ throw new Exception ("nsoverload()");
+
+ if (nsoverload(1) != 1010)
+ throw new Exception ("nsoverload(int t)");
+
+ if (nsoverload(1, 1) != 1020)
+ throw new Exception ("nsoverload(int t, const int &)");
+
+ if (nsoverload(1, "hello") != 1030)
+ throw new Exception ("nsoverload(int t, const char *)");
+
+ if (nsoverload(k) != 1010)
+ throw new Exception ("nsoverload(Klass t)");
+
+ if (nsoverload(k, k) != 1020)
+ throw new Exception ("nsoverload(Klass t, const Klass &)");
+
+ if (nsoverload(k, "hello") != 1030)
+ throw new Exception ("nsoverload(Klass t, const char *)");
+
+ if (nsoverload(10.0, "hi") != 1040)
+ throw new Exception ("nsoverload(double t, const char *)");
+
+ if (nsoverload() != 1050)
+ throw new Exception ("nsoverload(const char *)");
+}
diff --git a/Examples/test-suite/d/overload_template_runme.2.d b/Examples/test-suite/d/overload_template_runme.2.d
new file mode 100644
index 000000000..9fe6eb2cf
--- /dev/null
+++ b/Examples/test-suite/d/overload_template_runme.2.d
@@ -0,0 +1,80 @@
+module overload_template_runme;
+
+import std.exception;
+import overload_template.overload_template;
+import overload_template.Klass;
+
+void main() {
+ int f = foo();
+
+ f += maximum(3,4);
+ double b = maximum(3.4,5.2);
+ b++; // warning suppression
+
+ // mix 1
+ enforce(mix1("hi") == 101, "mix1(const char*)");
+ enforce(mix1(1.0, 1.0) == 102, "mix1(double, const double &)");
+ enforce(mix1(1.0) == 103, "mix1(double)");
+
+ // mix 2
+ enforce(mix2("hi") == 101, "mix2(const char*)");
+ enforce(mix2(1.0, 1.0) == 102, "mix2(double, const double &)");
+ enforce(mix2(1.0) == 103, "mix2(double)");
+
+ // mix 3
+ enforce(mix3("hi") == 101, "mix3(const char*)");
+ enforce(mix3(1.0, 1.0) == 102, "mix3(double, const double &)");
+ enforce(mix3(1.0) == 103, "mix3(double)");
+
+ // Combination 1
+ enforce(overtparams1(100) == 10, "overtparams1(int)");
+ enforce(overtparams1(100.0, 100) == 20, "overtparams1(double, int)");
+
+ // Combination 2
+ enforce(overtparams2(100.0, 100) == 40, "overtparams2(double, int)");
+
+ // Combination 3
+ enforce(overloaded() == 60, "overloaded()");
+ enforce(overloaded(100.0, 100) == 70, "overloaded(double, int)");
+
+ // Combination 4
+ enforce(overloadedagain("hello") == 80, "overloadedagain(const char *)");
+ enforce(overloadedagain() == 90, "overloadedagain(double)");
+
+ // specializations
+ enforce(specialization(10) == 202, "specialization(int)");
+ enforce(specialization(10.0) == 203, "specialization(double)");
+ enforce(specialization(10, 10) == 204, "specialization(int, int)");
+ enforce(specialization(10.0, 10.0) == 205, "specialization(double, double)");
+ enforce(specialization("hi", "hi") == 201, "specialization(const char *, const char *)");
+
+ // simple specialization
+ xyz();
+ xyz_int();
+ xyz_double();
+
+ // a bit of everything
+ enforce(overload("hi") == 0, "overload()");
+ enforce(overload(1) == 10, "overload(int t)");
+ enforce(overload(1, 1) == 20, "overload(int t, const int &)");
+ enforce(overload(1, "hello") == 30, "overload(int t, const char *)");
+
+ auto k = new Klass();
+ enforce(overload(k) == 10, "overload(Klass t)");
+ enforce(overload(k, k) == 20, "overload(Klass t, const Klass &)");
+ enforce(overload(k, "hello") == 30, "overload(Klass t, const char *)");
+ enforce(overload(10.0, "hi") == 40, "overload(double t, const char *)");
+ enforce(overload() == 50, "overload(const char *)");
+
+
+ // everything put in a namespace
+ enforce(nsoverload("hi") == 1000, "nsoverload()");
+ enforce(nsoverload(1) == 1010, "nsoverload(int t)");
+ enforce(nsoverload(1, 1) == 1020, "nsoverload(int t, const int &)");
+ enforce(nsoverload(1, "hello") == 1030, "nsoverload(int t, const char *)");
+ enforce(nsoverload(k) == 1010, "nsoverload(Klass t)");
+ enforce(nsoverload(k, k) == 1020, "nsoverload(Klass t, const Klass &)");
+ enforce(nsoverload(k, "hello") == 1030, "nsoverload(Klass t, const char *)");
+ enforce(nsoverload(10.0, "hi") == 1040, "nsoverload(double t, const char *)");
+ enforce(nsoverload() == 1050, "nsoverload(const char *)");
+}
diff --git a/Examples/test-suite/d/pointer_reference_runme.1.d b/Examples/test-suite/d/pointer_reference_runme.1.d
new file mode 100644
index 000000000..c593b939c
--- /dev/null
+++ b/Examples/test-suite/d/pointer_reference_runme.1.d
@@ -0,0 +1,13 @@
+module pointer_reference_runme;
+
+import pointer_reference.pointer_reference;
+import pointer_reference.Struct;
+
+void main() {
+ Struct s = get();
+ if (s.value != 10) throw new Exception("get test failed");
+
+ Struct ss = new Struct(20);
+ set(ss);
+ if (Struct.instance.value != 20) throw new Exception("set test failed");
+}
diff --git a/Examples/test-suite/d/pointer_reference_runme.2.d b/Examples/test-suite/d/pointer_reference_runme.2.d
new file mode 100644
index 000000000..8f287dfbd
--- /dev/null
+++ b/Examples/test-suite/d/pointer_reference_runme.2.d
@@ -0,0 +1,14 @@
+module pointer_reference_runme;
+
+import std.exception;
+import pointer_reference.pointer_reference;
+import pointer_reference.Struct;
+
+void main() {
+ Struct s = get();
+ enforce(s.value == 10, "get test failed");
+
+ auto ss = new Struct(20);
+ set(ss);
+ enforce(Struct.instance.value == 20, "set test failed");
+}
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.1.d b/Examples/test-suite/d/preproc_constants_c_runme.1.d
new file mode 100644
index 000000000..f25bbfdee
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_c_runme.1.d
@@ -0,0 +1,63 @@
+module preproc_constants_c_runme;
+
+import preproc_constants_c.preproc_constants_c;
+
+// Same as preproc_constants.i testcase, but bool types are int instead.
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(int == typeof(CONST_BOOL1())));
+ static assert(is(int == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(char[] == typeof(CONST_STRING1())));
+ static assert(is(char[] == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(int == typeof(EXPR_LTE())));
+ static assert(is(int == typeof(EXPR_GTE())));
+ static assert(is(int == typeof(EXPR_INEQUALITY())));
+ static assert(is(int == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(int == typeof(EXPR_LAND())));
+ static assert(is(int == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d
new file mode 100644
index 000000000..07d6ac53d
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d
@@ -0,0 +1,63 @@
+module preproc_constants_c_runme;
+
+import preproc_constants_c.preproc_constants_c;
+
+// Same as preproc_constants.i testcase, but bool types are int instead.
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(int == typeof(CONST_BOOL1())));
+ static assert(is(int == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(string == typeof(CONST_STRING1())));
+ static assert(is(string == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(int == typeof(EXPR_LTE())));
+ static assert(is(int == typeof(EXPR_GTE())));
+ static assert(is(int == typeof(EXPR_INEQUALITY())));
+ static assert(is(int == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(int == typeof(EXPR_LAND())));
+ static assert(is(int == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/preproc_constants_runme.1.d b/Examples/test-suite/d/preproc_constants_runme.1.d
new file mode 100644
index 000000000..a2aaa8fcd
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_runme.1.d
@@ -0,0 +1,62 @@
+module preproc_constants_runme;
+
+import preproc_constants.preproc_constants;
+
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(bool == typeof(CONST_BOOL1())));
+ static assert(is(bool == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(char[] == typeof(CONST_STRING1())));
+ static assert(is(char[] == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(bool == typeof(EXPR_LTE())));
+ static assert(is(bool == typeof(EXPR_GTE())));
+ static assert(is(bool == typeof(EXPR_INEQUALITY())));
+ static assert(is(bool == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(bool == typeof(EXPR_LAND())));
+ static assert(is(bool == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d
new file mode 100644
index 000000000..e2eab2c46
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_runme.2.d
@@ -0,0 +1,62 @@
+module preproc_constants_runme;
+
+import preproc_constants.preproc_constants;
+
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(bool == typeof(CONST_BOOL1())));
+ static assert(is(bool == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(string == typeof(CONST_STRING1())));
+ static assert(is(string == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(bool == typeof(EXPR_LTE())));
+ static assert(is(bool == typeof(EXPR_GTE())));
+ static assert(is(bool == typeof(EXPR_INEQUALITY())));
+ static assert(is(bool == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(bool == typeof(EXPR_LAND())));
+ static assert(is(bool == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/sizet_runme.1.d b/Examples/test-suite/d/sizet_runme.1.d
new file mode 100644
index 000000000..ae42e20e5
--- /dev/null
+++ b/Examples/test-suite/d/sizet_runme.1.d
@@ -0,0 +1,15 @@
+module sizet_runme;
+
+import sizet.sizet;
+
+void main() {
+ size_t s = 2000;
+ s = test1(s+1);
+ s = test2(s+1);
+ s = test3(s+1);
+ s = test4(s+1);
+
+ if (s != 2004) {
+ throw new Exception("failed");
+ }
+}
diff --git a/Examples/test-suite/d/sizet_runme.2.d b/Examples/test-suite/d/sizet_runme.2.d
new file mode 100644
index 000000000..63eb03b21
--- /dev/null
+++ b/Examples/test-suite/d/sizet_runme.2.d
@@ -0,0 +1,14 @@
+module sizet_runme;
+
+import std.exception;
+import sizet.sizet;
+
+void main() {
+ size_t s = 2000;
+ s = test1(s+1);
+ s = test2(s+1);
+ s = test3(s+1);
+ s = test4(s+1);
+
+ enforce(s == 2004, "failed");
+}
diff --git a/Examples/test-suite/d/sneaky1_runme.1.d b/Examples/test-suite/d/sneaky1_runme.1.d
new file mode 100644
index 000000000..b293b4972
--- /dev/null
+++ b/Examples/test-suite/d/sneaky1_runme.1.d
@@ -0,0 +1,21 @@
+module sneaky1_runme;
+
+import sneaky1.sneaky1;
+
+void main() {
+ if (add(30, 2) != 32) {
+ throw new Exception("add test failed");
+ }
+
+ if (subtract(20, 2) != 18) {
+ throw new Exception("subtract test failed");
+ }
+
+ if (mul(20, 2) != 40) {
+ throw new Exception("mul test failed");
+ }
+
+ if (divide(20, 2) != 10) {
+ throw new Exception("div test failed");
+ }
+}
diff --git a/Examples/test-suite/d/sneaky1_runme.2.d b/Examples/test-suite/d/sneaky1_runme.2.d
new file mode 100644
index 000000000..84e51e74d
--- /dev/null
+++ b/Examples/test-suite/d/sneaky1_runme.2.d
@@ -0,0 +1,11 @@
+module sneaky1_runme;
+
+import std.exception;
+import sneaky1.sneaky1;
+
+void main() {
+ enforce(add(30, 2) == 32, "add test failed");
+ enforce(subtract(20, 2) == 18, "subtract test failed");
+ enforce(mul(20, 2) == 40, "mul test failed");
+ enforce(divide(20, 2) == 10, "div test failed");
+}
diff --git a/Examples/test-suite/d/special_variable_macros_runme.1.d b/Examples/test-suite/d/special_variable_macros_runme.1.d
new file mode 100644
index 000000000..12491eef5
--- /dev/null
+++ b/Examples/test-suite/d/special_variable_macros_runme.1.d
@@ -0,0 +1,39 @@
+module special_variable_macros_runme;
+
+import special_variable_macros.special_variable_macros;
+import special_variable_macros.Name;
+import special_variable_macros.NewName;
+import special_variable_macros.PairIntBool;
+
+void main() {
+ auto name = new Name();
+
+ if (testFred(name) != "none") {
+ throw new Exception("test failed");
+ }
+
+ if (testJack(name) != "$specialname") {
+ throw new Exception("test failed");
+ }
+
+ if (testJill(name) != "jilly") {
+ throw new Exception("test failed");
+ }
+
+ if (testMary(name) != "SWIGTYPE_p_NameWrap") {
+ throw new Exception("test failed");
+ }
+
+ if (testJim(name) != "multiname num") {
+ throw new Exception("test failed");
+ }
+
+ if (testJohn(new PairIntBool(10, false)) != 123) {
+ throw new Exception("test failed");
+ }
+
+ auto newName = NewName.factory("factoryname");
+ if (newName.getStoredName().getName() != "factoryname") {
+ throw new Exception("test failed");
+ }
+}
diff --git a/Examples/test-suite/d/special_variable_macros_runme.2.d b/Examples/test-suite/d/special_variable_macros_runme.2.d
new file mode 100644
index 000000000..128e5870f
--- /dev/null
+++ b/Examples/test-suite/d/special_variable_macros_runme.2.d
@@ -0,0 +1,21 @@
+module special_variable_macros_runme;
+
+import std.exception;
+import special_variable_macros.special_variable_macros;
+import special_variable_macros.Name;
+import special_variable_macros.NewName;
+import special_variable_macros.PairIntBool;
+
+void main() {
+ auto name = new Name();
+ enforce(testFred(name) == "none");
+ enforce(testJack(name) == "$specialname");
+ enforce(testJill(name) == "jilly");
+ enforce(testMary(name) == "SWIGTYPE_p_NameWrap");
+ enforce(testJim(name) == "multiname num");
+
+ enforce(testJohn(new PairIntBool(10, false)) == 123);
+
+ auto newName = NewName.factory("factoryname");
+ enforce(newName.getStoredName().getName() == "factoryname");
+}
diff --git a/Examples/test-suite/d/threads_runme.1.d b/Examples/test-suite/d/threads_runme.1.d
new file mode 100644
index 000000000..206875824
--- /dev/null
+++ b/Examples/test-suite/d/threads_runme.1.d
@@ -0,0 +1,70 @@
+module threads_runme;
+
+import tango.core.Thread;
+import tango.io.Console;
+import Integer = tango.text.convert.Integer;
+import threads.Kerfuffle;
+
+// Spawn 8 threads.
+const uint NUM_THREADS = 8;
+
+// Run test for a few seconds on a 1GHz machine.
+const uint WORKER_LOOP_PASSES = 30000;
+
+void main() {
+ auto kerf = new Kerfuffle();
+ TestThread[] threads;
+
+ // Invoke the threads.
+ for (uint i = 0; i < NUM_THREADS; i++) {
+ auto thread = new TestThread(kerf);
+ threads ~= thread;
+ thread.name = Integer.toString(i);
+ thread.start();
+ }
+
+ // Wait for the threads to finish.
+ foreach(thread; threads) {
+ thread.join();
+ }
+
+ // Check if any thread has failed.
+ foreach(thread; threads) {
+ if (thread.failed) throw new Exception("Test failed.");
+ }
+}
+
+class TestThread : Thread {
+public:
+ this(Kerfuffle kerf) {
+ super(&run);
+ m_kerf = kerf;
+ }
+
+ void run() {
+ failed = false;
+ try {
+ for (uint i = 0; i < WORKER_LOOP_PASSES; i++) {
+ char[] given = "This is the test char[] that should come back. A number: " ~ Integer.toString(i);
+ char[] received = m_kerf.StdString(given);
+ if (received != given) {
+ throw new Exception("StdString char[] does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ }
+ for (uint i = 0; i < WORKER_LOOP_PASSES; i++) {
+ char[] given = "This is the test char[] that should come back. A number: " ~ Integer.toString(i);
+ char[] received = m_kerf.CharString(given);
+ if (received != given) {
+ throw new Exception("StdString char[] does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ }
+ } catch (Exception e) {
+ Cerr("Test failed (thread " ~ name() ~ "): " ~ e.msg).newline;
+ failed = true;
+ }
+ }
+
+ bool failed;
+private:
+ Kerfuffle m_kerf;
+}
diff --git a/Examples/test-suite/d/threads_runme.2.d b/Examples/test-suite/d/threads_runme.2.d
new file mode 100644
index 000000000..3ac27a5a8
--- /dev/null
+++ b/Examples/test-suite/d/threads_runme.2.d
@@ -0,0 +1,55 @@
+module threads_runme;
+
+import core.thread;
+import std.conv;
+import std.exception;
+import std.range;
+import std.stdio;
+import threads.Kerfuffle;
+
+// Spawn 8 threads.
+enum THREADS = iota(0, 9);
+
+// Run test for a few seconds on a 1GHz machine.
+enum WORK_RANGE = iota(0, 30000);
+
+void main() {
+ auto kerf = new Kerfuffle();
+ TestThread[] threads;
+
+ // Invoke the threads.
+ foreach (i; THREADS) {
+ auto thread = new TestThread(kerf);
+ threads ~= thread;
+ thread.name = to!string(i);
+ thread.start();
+ }
+
+ // Wait for the threads to finish.
+ foreach (i, thread; threads) {
+ thread.join(true);
+ }
+}
+
+class TestThread : Thread {
+ this(Kerfuffle kerf) {
+ super(&run);
+ m_kerf = kerf;
+ }
+
+ void run() {
+ foreach (i; WORK_RANGE) {
+ string given = "This is the test string that should come back. A number: " ~ to!string(i);
+ string received = m_kerf.StdString(given);
+ enforce(received == given, "StdString string does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ foreach (i; WORK_RANGE) {
+ string given = "This is the test string that should come back. A number: " ~ to!string(i);
+ string received = m_kerf.CharString(given);
+ enforce(received == given, "CharString string does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ }
+
+private:
+ Kerfuffle m_kerf;
+}
diff --git a/Examples/test-suite/d/throw_exception_runme.1.d b/Examples/test-suite/d/throw_exception_runme.1.d
new file mode 100644
index 000000000..f2397a202
--- /dev/null
+++ b/Examples/test-suite/d/throw_exception_runme.1.d
@@ -0,0 +1,30 @@
+module throw_exception_runme;
+
+import throw_exception.Foo;
+
+void main() {
+ test!("test_int");
+ test!("test_msg");
+ test!("test_cls");
+ test!("test_cls_ptr");
+ test!("test_cls_ref");
+ test!("test_cls_td");
+ test!("test_cls_ptr_td");
+ test!("test_cls_ref_td");
+ test!("test_array");
+ test!("test_enum");
+}
+
+void test(char[] methodName)() {
+ auto foo = new Foo();
+
+ bool didntThrow;
+ try {
+ mixin("foo." ~ methodName ~ "();");
+ didntThrow = true;
+ } catch (Exception) {}
+
+ if (didntThrow) {
+ throw new Exception(methodName ~ " failed");
+ }
+}
diff --git a/Examples/test-suite/d/throw_exception_runme.2.d b/Examples/test-suite/d/throw_exception_runme.2.d
new file mode 100644
index 000000000..6fc82a93d
--- /dev/null
+++ b/Examples/test-suite/d/throw_exception_runme.2.d
@@ -0,0 +1,30 @@
+module throw_exception_runme;
+
+import throw_exception.Foo;
+
+void main() {
+ test!("test_int");
+ test!("test_msg");
+ test!("test_cls");
+ test!("test_cls_ptr");
+ test!("test_cls_ref");
+ test!("test_cls_td");
+ test!("test_cls_ptr_td");
+ test!("test_cls_ref_td");
+ test!("test_array");
+ test!("test_enum");
+}
+
+void test(string methodName)() {
+ auto foo = new Foo();
+
+ bool didntThrow;
+ try {
+ mixin("foo." ~ methodName ~ "();");
+ didntThrow = true;
+ } catch (Exception) {}
+
+ if (didntThrow) {
+ throw new Exception(methodName ~ " failed");
+ }
+}
diff --git a/Examples/test-suite/d/typemap_namespace_runme.1.d b/Examples/test-suite/d/typemap_namespace_runme.1.d
new file mode 100644
index 000000000..3a5ca1a9f
--- /dev/null
+++ b/Examples/test-suite/d/typemap_namespace_runme.1.d
@@ -0,0 +1,13 @@
+module typemap_namespace_runme;
+
+import typemap_namespace.typemap_namespace;
+
+void main() {
+ if (test1("hello") != "hello") {
+ throw new Exception("test1 failed");
+ }
+
+ if (test2("hello") != "hello") {
+ throw new Exception("test2 failed");
+ }
+}
diff --git a/Examples/test-suite/d/typemap_namespace_runme.2.d b/Examples/test-suite/d/typemap_namespace_runme.2.d
new file mode 100644
index 000000000..2281e403b
--- /dev/null
+++ b/Examples/test-suite/d/typemap_namespace_runme.2.d
@@ -0,0 +1,9 @@
+module typemap_namespace_runme;
+
+import std.exception;
+import typemap_namespace.typemap_namespace;
+
+void main() {
+ enforce(test1("hello") == "hello", "test1 failed");
+ enforce(test2("hello") == "hello", "test2 failed");
+}
diff --git a/Examples/test-suite/d/typemap_out_optimal_runme.1.d b/Examples/test-suite/d/typemap_out_optimal_runme.1.d
new file mode 100644
index 000000000..16aab3cff
--- /dev/null
+++ b/Examples/test-suite/d/typemap_out_optimal_runme.1.d
@@ -0,0 +1,9 @@
+module typemap_out_optimal_runme;
+
+import typemap_out_optimal.XX;
+
+void main() {
+ XX x;
+ XX.trace = false;
+ x = XX.create();
+}
diff --git a/Examples/test-suite/d/typemap_out_optimal_runme.2.d b/Examples/test-suite/d/typemap_out_optimal_runme.2.d
new file mode 100644
index 000000000..16aab3cff
--- /dev/null
+++ b/Examples/test-suite/d/typemap_out_optimal_runme.2.d
@@ -0,0 +1,9 @@
+module typemap_out_optimal_runme;
+
+import typemap_out_optimal.XX;
+
+void main() {
+ XX x;
+ XX.trace = false;
+ x = XX.create();
+}
diff --git a/Examples/test-suite/d/varargs_runme.1.d b/Examples/test-suite/d/varargs_runme.1.d
new file mode 100644
index 000000000..53f76d075
--- /dev/null
+++ b/Examples/test-suite/d/varargs_runme.1.d
@@ -0,0 +1,20 @@
+module varargs_runme;
+
+import varargs.varargs;
+import varargs.Foo;
+
+void main() {
+ if (test("Hello") != "Hello") {
+ throw new Exception("Test 1 failed");
+ }
+
+ auto f = new Foo("Greetings");
+
+ if (f.str != "Greetings") {
+ throw new Exception("Test 2 failed");
+ }
+
+ if (f.test("Hello") != "Hello") {
+ throw new Exception("Test 3 failed");
+ }
+}
diff --git a/Examples/test-suite/d/varargs_runme.2.d b/Examples/test-suite/d/varargs_runme.2.d
new file mode 100644
index 000000000..b2b5ceddc
--- /dev/null
+++ b/Examples/test-suite/d/varargs_runme.2.d
@@ -0,0 +1,13 @@
+module varargs_runme;
+
+import std.exception;
+import varargs.varargs;
+import varargs.Foo;
+
+void main() {
+ enforce(test("Hello") == "Hello", "Test 1 failed");
+
+ auto f = new Foo("Greetings");
+ enforce(f.str == "Greetings", "Test 2 failed");
+ enforce(f.test("Hello") == "Hello", "Test 3 failed");
+}
diff --git a/Examples/test-suite/d/virtual_poly_runme.1.d b/Examples/test-suite/d/virtual_poly_runme.1.d
new file mode 100644
index 000000000..fb2e7814d
--- /dev/null
+++ b/Examples/test-suite/d/virtual_poly_runme.1.d
@@ -0,0 +1,27 @@
+module virtual_poly_runme;
+
+import virtual_poly.NDouble;
+import virtual_poly.NInt;
+import virtual_poly.NNumber;
+
+void main() {
+ // D supports covariant (polymorphic) return types, so this should work like
+ // in C++.
+ auto d = new NDouble(3.5);
+ NDouble dc = d.copy();
+ if (d.get() != dc.get()) {
+ throw new Exception("Test 1 failed.");
+ }
+
+ auto i = new NInt(2);
+ NInt ic = i.copy();
+ if (i.get() != ic.get()) {
+ throw new Exception("Test 2 failed.");
+ }
+
+ NNumber n = d;
+ auto nd = cast(NDouble) n.copy();
+ if (nd.get() != d.get()) {
+ throw new Exception("Test 3 failed.");
+ }
+}
diff --git a/Examples/test-suite/d/virtual_poly_runme.2.d b/Examples/test-suite/d/virtual_poly_runme.2.d
new file mode 100644
index 000000000..f749ee236
--- /dev/null
+++ b/Examples/test-suite/d/virtual_poly_runme.2.d
@@ -0,0 +1,22 @@
+module virtual_poly_runme;
+
+import std.exception;
+import virtual_poly.NDouble;
+import virtual_poly.NInt;
+import virtual_poly.NNumber;
+
+void main() {
+ // D supports covariant (polymorphic) return types, so this should work like
+ // in C++.
+ auto d = new NDouble(3.5);
+ NDouble dc = d.copy();
+ enforce(d.get() == dc.get(), "Test 1 failed.");
+
+ auto i = new NInt(2);
+ NInt ic = i.copy();
+ enforce(i.get() == ic.get(), "Test 2 failed.");
+
+ NNumber n = d;
+ auto nd = cast(NDouble) n.copy();
+ enforce(nd.get() == d.get(), "Test 3 failed.");
+}
diff --git a/Examples/test-suite/d_exception_name.i b/Examples/test-suite/d_exception_name.i
new file mode 100644
index 000000000..23f338a73
--- /dev/null
+++ b/Examples/test-suite/d_exception_name.i
@@ -0,0 +1,15 @@
+// Tests if exception handling still works in the presence of a wrapped C++
+// class called »Exception«, which could shadow the built-in Exception class.
+%module d_exception_name
+
+%inline %{
+ class Exception {
+ Exception(int i) {}
+ };
+
+ class Foo {
+ ~Foo() {}
+ public:
+ void bar(Exception *e) {}
+ };
+%}
diff --git a/Examples/test-suite/d_nativepointers.i b/Examples/test-suite/d_nativepointers.i
new file mode 100644
index 000000000..fdf3f1669
--- /dev/null
+++ b/Examples/test-suite/d_nativepointers.i
@@ -0,0 +1,21 @@
+%module d_nativepointers;
+
+%inline %{
+ class SomeClass {
+ };
+ class OpaqueClass;
+ typedef void (*FuncA)(int **x, char ***y);
+ typedef void (*FuncB)(int **x, SomeClass *y);
+
+ int *a( int *value ){ return value; }
+ float **b( float **value ){ return value; }
+ char ***c( char ***value ){ return value; }
+ SomeClass *d( SomeClass *value ){ return value; }
+ SomeClass **e( SomeClass **value ){ return value; }
+ OpaqueClass *f( OpaqueClass *value ){ return value; }
+ FuncA g( FuncA value ){ return value; }
+ FuncB* h( FuncB* value ){ return value; }
+
+ int &refA( int &value ){ return value; }
+ float *&refB( float *&value ){ return value; }
+%}
diff --git a/Examples/test-suite/default_arg_values.i b/Examples/test-suite/default_arg_values.i
new file mode 100644
index 000000000..47ca2d12f
--- /dev/null
+++ b/Examples/test-suite/default_arg_values.i
@@ -0,0 +1,18 @@
+%module default_arg_values
+
+%{
+struct Display {
+ // Some compilers warn about 'float v = NULL', so only SWIG sees this peculiarity
+ // Bad Python wrappers were being generated when NULL used for primitive type
+ float draw1(float v = 0) { return v; }
+ float draw2(float *v = 0) { return v ? *v : 0; }
+};
+float* createPtr(float v) { static float val; val = v; return &val; }
+%}
+
+struct Display {
+ // Bad Python wrappers were being generated when NULL used for primitive type
+ float draw1(float v = NULL) { return v; }
+ float draw2(float *v = NULL) { return v ? *v : 0; }
+};
+float* createPtr(float v) { static float val; val = v; return &val; }
diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i
index ff22c7834..091adff20 100644
--- a/Examples/test-suite/default_constructor.i
+++ b/Examples/test-suite/default_constructor.i
@@ -5,11 +5,13 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
diff --git a/Examples/test-suite/director_alternating.i b/Examples/test-suite/director_alternating.i
new file mode 100644
index 000000000..6e3ef4f24
--- /dev/null
+++ b/Examples/test-suite/director_alternating.i
@@ -0,0 +1,36 @@
+// Checks if calls to a method being defined in the base class, not
+// overridden in the subclass, but again overridden in a class derived from
+// the first subclass are dispatched correctly.
+%module(directors="1") director_alternating;
+
+%feature("director") Foo;
+
+%inline %{
+struct Foo {
+ virtual ~Foo() {}
+ virtual int id() {
+ return 0;
+ }
+};
+
+struct Bar : Foo {};
+
+struct Baz : Bar {
+ virtual int id() {
+ return 2;
+ }
+};
+
+// Note that even though the return value is of type Bar*, it really points to
+// an instance of Baz (in which id() has been overridden).
+Bar *getBar() {
+ static Baz baz;
+ return &baz;
+}
+
+// idFromGetBar() obviously is equivalent to getBar()->id() in C++ – this
+// should be true from the target language as well.
+int idFromGetBar() {
+ return getBar()->id();
+}
+%}
diff --git a/Examples/test-suite/director_classes.i b/Examples/test-suite/director_classes.i
index 5d0a67d00..5581c755f 100644
--- a/Examples/test-suite/director_classes.i
+++ b/Examples/test-suite/director_classes.i
@@ -10,6 +10,12 @@
%include "std_string.i"
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, hidevf)
+#endif
+%}
+
%inline %{
#include
#include
diff --git a/Examples/test-suite/director_keywords.i b/Examples/test-suite/director_keywords.i
new file mode 100644
index 000000000..473786c00
--- /dev/null
+++ b/Examples/test-suite/director_keywords.i
@@ -0,0 +1,13 @@
+// Checks if collisions of argument names with target language keywords are
+// resolved properly when directors are used (currently only »abstract« for
+// C#, D and Java is checked).
+%module(directors="1") director_keywords
+
+%feature("director") Foo;
+
+%inline %{
+struct Foo {
+ virtual ~Foo() {}
+ virtual void bar(int abstract) {}
+};
+%}
diff --git a/Examples/test-suite/director_protected.i b/Examples/test-suite/director_protected.i
index fee45b4a6..0299b238d 100644
--- a/Examples/test-suite/director_protected.i
+++ b/Examples/test-suite/director_protected.i
@@ -53,6 +53,10 @@ protected:
virtual std::string used() {
return pang() + pong();
}
+
+ virtual std::string cheer() {
+ return pang() + pong();
+ }
};
class Bar : public Foo
@@ -63,6 +67,14 @@ public:
return new Bar();
}
+ std::string callping() {
+ return ping();
+ }
+
+ std::string callcheer() {
+ return cheer();
+ }
+
std::string pong() {
return "Bar::pong();" + Foo::pong();
}
@@ -75,6 +87,7 @@ protected:
std::string ping() {
return "Bar::ping();";
};
+ using Foo::cheer;
enum Hello {hola, chao};
diff --git a/Examples/test-suite/director_using.i b/Examples/test-suite/director_using.i
index 9001ffbb9..d86546e86 100644
--- a/Examples/test-suite/director_using.i
+++ b/Examples/test-suite/director_using.i
@@ -59,9 +59,22 @@
public:
virtual C get_value() const = 0;
using Bar::do_advance;
-
};
+
}
%template(FooBar_int) FooBar;
+%inline %{
+ struct SomeBase {
+ virtual ~SomeBase() {}
+ virtual void method1() {}
+ virtual void method2() {}
+ };
+
+ struct PrivateDerived : SomeBase {
+ private:
+ virtual void method1() {}
+ using SomeBase::method2;
+ };
+%}
diff --git a/Examples/test-suite/dynamic_cast.i b/Examples/test-suite/dynamic_cast.i
index ccbaa5b47..392b3bfd1 100644
--- a/Examples/test-suite/dynamic_cast.i
+++ b/Examples/test-suite/dynamic_cast.i
@@ -1,7 +1,7 @@
/* File : example.i */
%module dynamic_cast
-#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD)
%apply SWIGTYPE *DYNAMIC { Foo * };
#endif
@@ -17,7 +17,7 @@ public:
};
%}
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO) || defined(SWIGD)
%typemap(out) Foo *blah {
Bar *downcast = dynamic_cast($1);
*(Bar **)&$result = downcast;
@@ -37,6 +37,13 @@ public:
}
#endif
+#if defined(SWIGD)
+%typemap(dout, excode=SWIGEXCODE) Foo * {
+ Bar ret = new Bar($imcall, $owner);$excode
+ return ret;
+}
+#endif
+
#if defined(SWIGGO)
%insert(go_runtime) %{
func FooToBar(f Foo) Bar {
@@ -62,7 +69,7 @@ char *do_test(Bar *b) {
}
%}
-#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD)
// A general purpose function for dynamic casting of a Foo *
%{
static swig_type_info *
diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i
index cb2288574..ec31c2787 100644
--- a/Examples/test-suite/enum_thorough.i
+++ b/Examples/test-suite/enum_thorough.i
@@ -537,7 +537,6 @@ IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; }
%}
%inline %{
-
namespace RepeatSpace {
typedef enum
{
@@ -550,6 +549,58 @@ typedef enum
} repeat;
repeat repeatTest(repeat e) { return e; }
}
+%}
+
+%inline %{
+namespace DifferentSpace {
+enum DifferentTypes {
+ typeint = 10,
+ typeboolfalse = false,
+ typebooltrue = true,
+ typebooltwo,
+ typechar = 'C',
+ typedefaultint
+};
+DifferentTypes differentTypesTest(DifferentTypes n) { return n; }
+
+enum {
+ global_typeint = 10,
+ global_typeboolfalse = false,
+ global_typebooltrue = true,
+ global_typebooltwo,
+ global_typechar = 'C',
+ global_typedefaultint
+};
+int globalDifferentTypesTest(int n) { return n; }
+}
%}
+#if defined(SWIGJAVA)
+%javaconst(0);
+#elif defined(SWIGCSHARP)
+%csconst(0);
+#endif
+
+%inline %{
+namespace DifferentSpace {
+enum DifferentTypesNoConst {
+ typeint_noconst = 10,
+ typeboolfalse_noconst = false,
+ typebooltrue_noconst = true,
+ typebooltwo_noconst,
+ typechar_noconst = 'C',
+ typedefaultint_noconst
+};
+
+enum {
+ global_typeint_noconst = 10,
+ global_typeboolfalse_noconst = false,
+ global_typebooltrue_noconst = true,
+ global_typebooltwo_noconst,
+ global_typechar_noconst = 'C',
+ global_typedefaultint_noconst
+};
+}
+
+%}
diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i
index 5632b5e97..14c6efbba 100644
--- a/Examples/test-suite/enums.i
+++ b/Examples/test-suite/enums.i
@@ -58,6 +58,11 @@ typedef struct _Foo {
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) _iFoo;
+#ifdef SWIGD
+/* Work around missing support for proper char quoting due to parser shortcomings. */
+%dconstvalue("'a'") _iFoo::Char;
+#endif
+
#ifndef __cplusplus
%inline %{
typedef struct _iFoo
diff --git a/Examples/test-suite/errors/cpp_overload_const.i b/Examples/test-suite/errors/cpp_overload_const.i
new file mode 100644
index 000000000..0fe8d33ec
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_overload_const.i
@@ -0,0 +1,13 @@
+%module xxx
+
+void check(const int *v) {}
+void check(int *v) {}
+void check(int &v) {}
+void check(const int &v) {} // note: no warning as marshalled by value
+
+struct OverStruct {};
+void check(const OverStruct *v) {}
+void check(OverStruct *v) {}
+void check(OverStruct &v) {}
+void check(const OverStruct &v) {}
+
diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.i b/Examples/test-suite/errors/cpp_recursive_typedef.i
new file mode 100644
index 000000000..3d65a8817
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_recursive_typedef.i
@@ -0,0 +1,4 @@
+%module cpp_recursive_typedef
+
+typedef std::set pds;
+
diff --git a/Examples/test-suite/errors/cpp_shared_ptr.i b/Examples/test-suite/errors/cpp_shared_ptr.i
new file mode 100644
index 000000000..edbd0cf87
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_shared_ptr.i
@@ -0,0 +1,29 @@
+%module cpp_shared_ptr
+
+%include
+
+%shared_ptr(B);
+%shared_ptr(C);
+
+%inline %{
+ #include
+ #include
+
+ struct A {
+ virtual ~A() {}
+ };
+
+ struct B {
+ virtual ~B() {}
+ };
+
+ struct C : B, A {
+ virtual ~C() {}
+ };
+
+ struct D : C {
+ virtual ~D() {}
+ };
+%}
+
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index 06942064f..8ac1534cb 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -10,6 +10,7 @@ c_bad_native.i:3: Error: %native declaration 'foo' is not a function.
:::::::::::::::::::::::::::::::: c_class.i :::::::::::::::::::::::::::::::::::
c_class.i:3: Warning 301: class keyword used, but not in C++ mode.
+c_class.i:3: Warning 314: 'class' is a python keyword, renaming to '_class'
:::::::::::::::::::::::::::::::: c_default_error.i :::::::::::::::::::::::::::::::::::
@@ -68,7 +69,7 @@ c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
No module name specified using %module or -module.
:::::::::::::::::::::::::::::::: pp_badeval.i :::::::::::::::::::::::::::::::::::
-pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+'
+pp_badeval.i:4: Warning 202: Could not evaluate expression 'FOO==4+'
pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
:::::::::::::::::::::::::::::::: pp_constant.i :::::::::::::::::::::::::::::::::::
@@ -83,13 +84,12 @@ pp_constant.i:49: Warning 305: Bad constant value (ignored).
:::::::::::::::::::::::::::::::: pp_defined.i :::::::::::::::::::::::::::::::::::
pp_defined.i:6: Error: No arguments given to defined()
-pp_defined.i:6: Warning 202: Could not evaluate 'defined'
-pp_defined.i:6: Warning 202: Error: 'Expected an expression'
+pp_defined.i:6: Error: Missing expression for #if.
:::::::::::::::::::::::::::::::: pp_deprecated.i :::::::::::::::::::::::::::::::::::
pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
pp_deprecated.i:4: Error: Unable to find 'ext;'
-pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning
+pp_deprecated.i:6: Warning 204: CPP #warning, "Print this warning".
pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
@@ -118,6 +118,20 @@ pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *).
pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo'
pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3).
+:::::::::::::::::::::::::::::::: pp_macro_missing_expression.i :::::::::::::::::::::::::::::::::::
+pp_macro_missing_expression.i:4: Error: Missing identifier for #ifdef.
+pp_macro_missing_expression.i:7: Error: Missing identifier for #ifndef.
+pp_macro_missing_expression.i:10: Error: Missing expression for #if.
+pp_macro_missing_expression.i:14: Error: Missing expression for #elif.
+pp_macro_missing_expression.i:21: Error: Missing expression for #elif.
+
+:::::::::::::::::::::::::::::::: pp_macro_unexpected_tokens.i :::::::::::::::::::::::::::::::::::
+pp_macro_unexpected_tokens.i:5: Warning 206: Unexpected tokens after #endif directive.
+pp_macro_unexpected_tokens.i:8: Warning 206: Unexpected tokens after #endif directive.
+pp_macro_unexpected_tokens.i:11: Warning 206: Unexpected tokens after #else directive.
+pp_macro_unexpected_tokens.i:18: Warning 206: Unexpected tokens after #endif directive.
+pp_macro_unexpected_tokens.i:21: Warning 206: Unexpected tokens after #else directive.
+
:::::::::::::::::::::::::::::::: pp_macro_nargs.i :::::::::::::::::::::::::::::::::::
pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments
@@ -226,8 +240,8 @@ cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using
cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
-cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one
-cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2
+cpp_macro_locator.i:66: Warning 204: CPP #warning, "inline warning message one".
+cpp_macro_locator.i:96: Warning 204: CPP #warning, "an inline warning message 2".
cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).
@@ -274,12 +288,32 @@ cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using
:::::::::::::::::::::::::::::::: cpp_overload.i :::::::::::::::::::::::::::::::::::
+:::::::::::::::::::::::::::::::: cpp_overload_const.i :::::::::::::::::::::::::::::::::::
+cpp_overload_const.i:4: Warning 509: Overloaded method check(int *) effectively ignored,
+cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *).
+cpp_overload_const.i:5: Warning 509: Overloaded method check(int &) effectively ignored,
+cpp_overload_const.i:3: Warning 509: as it is shadowed by check(int const *).
+cpp_overload_const.i:10: Warning 509: Overloaded method check(OverStruct *) effectively ignored,
+cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
+cpp_overload_const.i:11: Warning 509: Overloaded method check(OverStruct &) effectively ignored,
+cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
+cpp_overload_const.i:12: Warning 509: Overloaded method check(OverStruct const &) effectively ignored,
+cpp_overload_const.i:9: Warning 509: as it is shadowed by check(OverStruct const *).
+
:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored).
cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored).
+:::::::::::::::::::::::::::::::: cpp_recursive_typedef.i :::::::::::::::::::::::::::::::::::
+:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
+
+:::::::::::::::::::::::::::::::: cpp_shared_ptr.i :::::::::::::::::::::::::::::::::::
+cpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer.
+cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer.
+cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'B' is not similarly marked as a smart pointer.
+
:::::::::::::::::::::::::::::::: cpp_template_argname.i :::::::::::::::::::::::::::::::::::
:::::::::::::::::::::::::::::::: cpp_template_nargs.i :::::::::::::::::::::::::::::::::::
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index 52d6c8967..f45f435aa 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -36,6 +36,8 @@ pp_macro_defined_unterminated
pp_macro_expansion
pp_macro_expansion_multiline
pp_macro_inline_unterminated
+pp_macro_missing_expression
+pp_macro_unexpected_tokens
pp_macro_nargs
pp_macro_redef
pp_macro_rparen
@@ -74,8 +76,11 @@ cpp_nested
cpp_no_access
cpp_nobase
cpp_overload
+cpp_overload_const
cpp_private_defvalue
cpp_private_inherit
+cpp_recursive_typedef
+cpp_shared_ptr
cpp_template_argname
cpp_template_nargs
cpp_template_not
@@ -98,14 +103,14 @@ for i in ${CFILES}; do
echo " Testing : ${i}.i";
echo "" >> ${LOGFILE};
echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
- ${SWIG} -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+ ${SWIG} -python -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
done
for i in ${CPPFILES}; do
echo " Testing : ${i}.i";
echo "" >> ${LOGFILE}
echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
- ${SWIG} -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+ ${SWIG} -python -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
done
echo ""
diff --git a/Examples/test-suite/errors/pp_macro_missing_expression.i b/Examples/test-suite/errors/pp_macro_missing_expression.i
new file mode 100644
index 000000000..2c7c9855d
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_missing_expression.i
@@ -0,0 +1,22 @@
+// Test "Missing identifier for ..." errrors
+%module xxx
+
+#ifdef
+#endif
+
+#ifndef
+#endif
+
+#if
+#endif
+
+#if defined(AAA)
+#elif
+#endif
+
+
+#define BBB
+
+#if !defined(BBB)
+#elif
+#endif
diff --git a/Examples/test-suite/errors/pp_macro_unexpected_tokens.i b/Examples/test-suite/errors/pp_macro_unexpected_tokens.i
new file mode 100644
index 000000000..97b73f9bc
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_unexpected_tokens.i
@@ -0,0 +1,23 @@
+// Test "Unexpected tokens after ..." errors
+%module xxx
+
+#ifndef AAA
+#endif rubbish
+
+#ifdef AAA
+#endif rubbish
+
+#ifdef AAA
+#else rubbish
+#endif
+
+#define BBB
+
+#ifdef BBB
+#else
+#endif rubbish
+
+#if !defined(BBB)
+#else rubbish
+#endif
+
diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i
index 7b2e9152f..a8d48b30b 100644
--- a/Examples/test-suite/evil_diamond.i
+++ b/Examples/test-suite/evil_diamond.i
@@ -6,7 +6,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance
%inline %{
diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i
index 515044007..0227b31ee 100644
--- a/Examples/test-suite/evil_diamond_ns.i
+++ b/Examples/test-suite/evil_diamond_ns.i
@@ -6,7 +6,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance
%inline %{
namespace Blah {
diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i
index 804ea66b4..2dac6eab7 100644
--- a/Examples/test-suite/evil_diamond_prop.i
+++ b/Examples/test-suite/evil_diamond_prop.i
@@ -6,6 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
%inline %{
diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i
index 45a87e0c5..4dd13858a 100644
--- a/Examples/test-suite/exception_order.i
+++ b/Examples/test-suite/exception_order.i
@@ -2,6 +2,14 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+#if defined(SWIGGO) && defined(SWIGGO_GCCGO)
+%{
+#ifdef __GNUC__
+#include
+#endif
+%}
+#endif
+
%include "exception.i"
%{
@@ -23,6 +31,18 @@
SWIG_exception_fail(SWIG_RuntimeError,"postcatch unknown");
}
}
+#elif defined(SWIGGO) && defined(SWIGGO_GCCGO)
+%exception %{
+ try {
+ $action
+#ifdef __GNUC__
+ } catch (__cxxabiv1::__foreign_exception&) {
+ throw;
+#endif
+ } catch(...) {
+ SWIG_exception(SWIG_RuntimeError,"postcatch unknown");
+ }
+%}
#else
%exception {
try {
diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i
index d59f970ee..a3d46ea39 100644
--- a/Examples/test-suite/funcptr_cpp.i
+++ b/Examples/test-suite/funcptr_cpp.i
@@ -1,5 +1,11 @@
%module funcptr_cpp
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
+#endif
+%}
+
%inline %{
int addByValue(const int &a, int b) { return a+b; }
diff --git a/Examples/test-suite/global_ns_arg.i b/Examples/test-suite/global_ns_arg.i
index 3554fd814..8bdb7e512 100644
--- a/Examples/test-suite/global_ns_arg.i
+++ b/Examples/test-suite/global_ns_arg.i
@@ -8,7 +8,7 @@ typedef int Integer;
return x;
}
-::Integer bar() {
+::Integer bar_fn() {
return 1;
}
diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go
new file mode 100644
index 000000000..50f2e121d
--- /dev/null
+++ b/Examples/test-suite/go/char_binary_runme.go
@@ -0,0 +1,25 @@
+package main
+
+import . "./char_binary"
+
+func main() {
+ t := NewTest()
+ if t.Strlen("hile") != 4 {
+ print(t.Strlen("hile"))
+ panic("bad multi-arg typemap")
+ }
+
+ if t.Strlen("hil\000") != 4 {
+ panic("bad multi-arg typemap")
+ }
+
+ // creating a raw char*
+ pc := New_pchar(5)
+ Pchar_setitem(pc, 0, 'h')
+ Pchar_setitem(pc, 1, 'o')
+ Pchar_setitem(pc, 2, 'l')
+ Pchar_setitem(pc, 3, 'a')
+ Pchar_setitem(pc, 4, 0)
+
+ Delete_pchar(pc)
+}
diff --git a/Examples/test-suite/go/compactdefaultargs_runme.go b/Examples/test-suite/go/compactdefaultargs_runme.go
index 8818dce07..46f3ff3f9 100644
--- a/Examples/test-suite/go/compactdefaultargs_runme.go
+++ b/Examples/test-suite/go/compactdefaultargs_runme.go
@@ -6,9 +6,9 @@ func main() {
defaults1 := NewDefaults1(1000)
defaults1 = NewDefaults1()
- if defaults1.Ret(float64(10.0)) != 10.0 {
- println(1, defaults1.Ret(float64(10.0)))
- panic(defaults1.Ret(float64(10.0)))
+ if defaults1.Ret(10.0) != 10.0 {
+ println(1, defaults1.Ret(10.0))
+ panic(defaults1.Ret(10.0))
}
if defaults1.Ret() != -1.0 {
@@ -19,8 +19,8 @@ func main() {
defaults2 := NewDefaults2(1000)
defaults2 = NewDefaults2()
- if defaults2.Ret(float64(10.0)) != 10.0 {
- panic(defaults2.Ret(float64(10.0)))
+ if defaults2.Ret(10.0) != 10.0 {
+ panic(defaults2.Ret(10.0))
}
if defaults2.Ret() != -1.0 {
diff --git a/Examples/test-suite/go/director_alternating_runme.go b/Examples/test-suite/go/director_alternating_runme.go
new file mode 100644
index 000000000..10f6774a3
--- /dev/null
+++ b/Examples/test-suite/go/director_alternating_runme.go
@@ -0,0 +1,10 @@
+package main
+
+import . "./director_alternating"
+
+func main() {
+ id := GetBar().Id()
+ if id != IdFromGetBar() {
+ panic(id)
+ }
+}
diff --git a/Examples/test-suite/go/director_protected_runme.go b/Examples/test-suite/go/director_protected_runme.go
index 3ffc1fbfa..24adfe7bd 100644
--- a/Examples/test-suite/go/director_protected_runme.go
+++ b/Examples/test-suite/go/director_protected_runme.go
@@ -15,11 +15,17 @@ func (p *FooBar2) Pang() string {
return "FooBar2::pang();"
}
+type FooBar3 struct{} // From Bar
+func (p *FooBar3) Cheer() string {
+ return "FooBar3::cheer();"
+}
+
func main() {
b := NewBar()
f := b.Create()
fb := NewDirectorBar(&FooBar{})
fb2 := NewDirectorBar(&FooBar2{})
+ fb3 := NewDirectorBar(&FooBar3{})
s := fb.Used()
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" {
@@ -45,4 +51,23 @@ func main() {
if s != "Bar::pong();Foo::pong();FooBar::ping();" {
panic(0)
}
+
+ s = fb3.DirectorInterface().(*FooBar3).Cheer()
+ if s != "FooBar3::cheer();" {
+ panic(s)
+ }
+ if fb2.Callping() != "FooBar2::ping();" {
+ panic("bad fb2.callping")
+ }
+ if fb2.Callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" {
+ panic("bad fb2.callcheer")
+ }
+
+ if fb3.Callping() != "Bar::ping();" {
+ panic("bad fb3.callping")
+ }
+
+ if fb3.Callcheer() != "FooBar3::cheer();" {
+ panic("bad fb3.callcheer")
+ }
}
diff --git a/Examples/test-suite/go/extend_placement_runme.go b/Examples/test-suite/go/extend_placement_runme.go
index f74831c7d..efa776e31 100644
--- a/Examples/test-suite/go/extend_placement_runme.go
+++ b/Examples/test-suite/go/extend_placement_runme.go
@@ -12,7 +12,7 @@ func main() {
foo.Spam(1, 1)
foo.Spam(1, 1, 1)
foo.Spam(extend_placement.NewFoo())
- foo.Spam(extend_placement.NewFoo(), float64(1.0))
+ foo.Spam(extend_placement.NewFoo(), 1.0)
bar := extend_placement.NewBar()
bar = extend_placement.NewBar(1)
@@ -22,7 +22,7 @@ func main() {
bar.Spam(1, 1)
bar.Spam(1, 1, 1)
bar.Spam(extend_placement.NewBar())
- bar.Spam(extend_placement.NewBar(), float64(1.0))
+ bar.Spam(extend_placement.NewBar(), 1.0)
footi := extend_placement.NewFooTi()
footi = extend_placement.NewFooTi(1)
@@ -33,7 +33,7 @@ func main() {
footi.Spam(1, 1)
footi.Spam(1, 1, 1)
footi.Spam(extend_placement.NewFoo())
- footi.Spam(extend_placement.NewFoo(), float64(1.0))
+ footi.Spam(extend_placement.NewFoo(), 1.0)
barti := extend_placement.NewBarTi()
barti = extend_placement.NewBarTi(1)
@@ -43,5 +43,5 @@ func main() {
barti.Spam(1, 1)
barti.Spam(1, 1, 1)
barti.Spam(extend_placement.NewBar())
- barti.Spam(extend_placement.NewBar(), float64(1.0))
+ barti.Spam(extend_placement.NewBar(), 1.0)
}
diff --git a/Examples/test-suite/go/friends_runme.go b/Examples/test-suite/go/friends_runme.go
index 80177bae8..9f223fcac 100644
--- a/Examples/test-suite/go/friends_runme.go
+++ b/Examples/test-suite/go/friends_runme.go
@@ -38,8 +38,8 @@ func main() {
panic(0)
}
- friends.Set(di, float64(4.0))
- friends.Set(dd, float64(1.3))
+ friends.Set(di, 4.0)
+ friends.Set(dd, 1.3)
if friends.Get_val1(di).(float64) != 4 {
panic(0)
diff --git a/Examples/test-suite/go/global_ns_arg_runme.go b/Examples/test-suite/go/global_ns_arg_runme.go
index f4c8a7ed5..ece779c9c 100644
--- a/Examples/test-suite/go/global_ns_arg_runme.go
+++ b/Examples/test-suite/go/global_ns_arg_runme.go
@@ -4,5 +4,5 @@ import . "./global_ns_arg"
func main() {
Foo(1)
- Bar()
+ Bar_fn()
}
diff --git a/Examples/test-suite/go/namespace_typemap_runme.go b/Examples/test-suite/go/namespace_typemap_runme.go
index 95311a37a..056da1567 100644
--- a/Examples/test-suite/go/namespace_typemap_runme.go
+++ b/Examples/test-suite/go/namespace_typemap_runme.go
@@ -51,7 +51,7 @@ func main() {
panic(0)
}
- c := cmplx(float64(2), float64(3))
+ c := complex(2, 3)
r := real(c)
if Ctest1(c) != r {
diff --git a/Examples/test-suite/go/overload_extend_runme.go b/Examples/test-suite/go/overload_extend_runme.go
index 228dfe89c..1ba541f13 100644
--- a/Examples/test-suite/go/overload_extend_runme.go
+++ b/Examples/test-suite/go/overload_extend_runme.go
@@ -16,7 +16,7 @@ func main() {
if f.Test(float64(3), float64(2)).(float64) != 5 {
panic(0)
}
- if f.Test(float64(3.0)).(float64) != 1003 {
+ if f.Test(3.0).(float64) != 1003 {
panic(0)
}
}
diff --git a/Examples/test-suite/go/overload_extendc_runme.go b/Examples/test-suite/go/overload_extendc_runme.go
index aec8935f5..1bdba7509 100644
--- a/Examples/test-suite/go/overload_extendc_runme.go
+++ b/Examples/test-suite/go/overload_extendc_runme.go
@@ -10,7 +10,7 @@ func main() {
if f.Test("hello") != 2 {
panic(0)
}
- if f.Test(float64(3.5), float64(2.5)) != 3 {
+ if f.Test(3.5, 2.5) != 3 {
panic(0)
}
if f.Test("hello", 20) != 1020 {
diff --git a/Examples/test-suite/go/overload_simple_runme.go b/Examples/test-suite/go/overload_simple_runme.go
index 9fca9061a..5f6d0558b 100644
--- a/Examples/test-suite/go/overload_simple_runme.go
+++ b/Examples/test-suite/go/overload_simple_runme.go
@@ -7,7 +7,7 @@ func main() {
panic("foo(int)")
}
- if Foo(float64(3.0)) != "foo:double" {
+ if Foo(3.0) != "foo:double" {
panic("foo(double)")
}
@@ -37,7 +37,7 @@ func main() {
panic("Spam::foo(int)")
}
- if s.Foo(float64(3.0)) != "foo:double" {
+ if s.Foo(3.0) != "foo:double" {
panic("Spam::foo(double)")
}
@@ -61,7 +61,7 @@ func main() {
panic("Spam::bar(int)")
}
- if SpamBar(float64(3.0)) != "bar:double" {
+ if SpamBar(3.0) != "bar:double" {
panic("Spam::bar(double)")
}
@@ -93,7 +93,7 @@ func main() {
panic("Spam(int)")
}
- s = NewSpam(float64(3.4))
+ s = NewSpam(3.4)
if s.GetXtype() != "double" {
panic("Spam(double)")
}
diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go
index 8fc7c364c..4ecf4157a 100644
--- a/Examples/test-suite/go/overload_template_fast_runme.go
+++ b/Examples/test-suite/go/overload_template_fast_runme.go
@@ -6,18 +6,18 @@ func main() {
_ = Foo()
_ = Maximum(3, 4)
- _ = Maximum(float64(3.4), float64(5.2))
+ _ = Maximum(3.4, 5.2)
// mix 1
if Mix1("hi") != 101 {
panic("mix1(const char*)")
}
- if Mix1(float64(1.0), float64(1.0)) != 102 {
+ if Mix1(1.0, 1.0) != 102 {
panic("mix1(double, const double &)")
}
- if Mix1(float64(1.0)) != 103 {
+ if Mix1(1.0) != 103 {
panic("mix1(double)")
}
@@ -26,11 +26,11 @@ func main() {
panic("mix2(const char*)")
}
- if Mix2(float64(1.0), float64(1.0)) != 102 {
+ if Mix2(1.0, 1.0) != 102 {
panic("mix2(double, const double &)")
}
- if Mix2(float64(1.0)) != 103 {
+ if Mix2(1.0) != 103 {
panic("mix2(double)")
}
@@ -39,11 +39,11 @@ func main() {
panic("mix3(const char*)")
}
- if Mix3(float64(1.0), float64(1.0)) != 102 {
+ if Mix3(1.0, 1.0) != 102 {
panic("mix3(double, const double &)")
}
- if Mix3(float64(1.0)) != 103 {
+ if Mix3(1.0) != 103 {
panic("mix3(double)")
}
@@ -52,12 +52,12 @@ func main() {
panic("overtparams1(int)")
}
- if Overtparams1(float64(100.0), 100) != 20 {
+ if Overtparams1(100.0, 100) != 20 {
panic("overtparams1(double, int)")
}
// Combination 2
- if Overtparams2(float64(100.0), 100) != 40 {
+ if Overtparams2(100.0, 100) != 40 {
panic("overtparams2(double, int)")
}
@@ -66,7 +66,7 @@ func main() {
panic("overloaded()")
}
- if Overloaded(float64(100.0), 100) != 70 {
+ if Overloaded(100.0, 100) != 70 {
panic("overloaded(double, int)")
}
@@ -84,7 +84,7 @@ func main() {
panic("specialization(int)")
}
- if Specialization(float64(10.0)) != 203 {
+ if Specialization(10.0) != 203 {
panic("specialization(double)")
}
@@ -92,7 +92,7 @@ func main() {
panic("specialization(int, int)")
}
- if Specialization(float64(10.0), float64(10.0)) != 205 {
+ if Specialization(10.0, 10.0) != 205 {
panic("specialization(double, double)")
}
@@ -135,7 +135,7 @@ func main() {
panic("overload(Klass t, const char *)")
}
- if Overload(float64(10.0), "hi") != 40 {
+ if Overload(10.0, "hi") != 40 {
panic("overload(double t, const char *)")
}
@@ -173,7 +173,7 @@ func main() {
panic("nsoverload(Klass t, const char *)")
}
- if Nsoverload(float64(10.0), "hi") != 1040 {
+ if Nsoverload(10.0, "hi") != 1040 {
panic("nsoverload(double t, const char *)")
}
diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go
index 124402f37..279e43de6 100644
--- a/Examples/test-suite/go/overload_template_runme.go
+++ b/Examples/test-suite/go/overload_template_runme.go
@@ -6,18 +6,18 @@ func main() {
_ = Foo()
_ = Maximum(3, 4)
- _ = Maximum(float64(3.4), float64(5.2))
+ _ = Maximum(3.4, 5.2)
// mix 1
if Mix1("hi") != 101 {
panic("mix1(const char*)")
}
- if Mix1(float64(1.0), float64(1.0)) != 102 {
+ if Mix1(1.0, 1.0) != 102 {
panic("mix1(double, const double &)")
}
- if Mix1(float64(1.0)) != 103 {
+ if Mix1(1.0) != 103 {
panic("mix1(double)")
}
@@ -26,11 +26,11 @@ func main() {
panic("mix2(const char*)")
}
- if Mix2(float64(1.0), float64(1.0)) != 102 {
+ if Mix2(1.0, 1.0) != 102 {
panic("mix2(double, const double &)")
}
- if Mix2(float64(1.0)) != 103 {
+ if Mix2(1.0) != 103 {
panic("mix2(double)")
}
@@ -39,11 +39,11 @@ func main() {
panic("mix3(const char*)")
}
- if Mix3(float64(1.0), float64(1.0)) != 102 {
+ if Mix3(1.0, 1.0) != 102 {
panic("mix3(double, const double &)")
}
- if Mix3(float64(1.0)) != 103 {
+ if Mix3(1.0) != 103 {
panic("mix3(double)")
}
@@ -52,12 +52,12 @@ func main() {
panic("overtparams1(int)")
}
- if Overtparams1(float64(100.0), 100) != 20 {
+ if Overtparams1(100.0, 100) != 20 {
panic("overtparams1(double, int)")
}
// Combination 2
- if Overtparams2(float64(100.0), 100) != 40 {
+ if Overtparams2(100.0, 100) != 40 {
panic("overtparams2(double, int)")
}
@@ -66,7 +66,7 @@ func main() {
panic("overloaded()")
}
- if Overloaded(float64(100.0), 100) != 70 {
+ if Overloaded(100.0, 100) != 70 {
panic("overloaded(double, int)")
}
@@ -84,7 +84,7 @@ func main() {
panic("specialization(int)")
}
- if Specialization(float64(10.0)) != 203 {
+ if Specialization(10.0) != 203 {
panic("specialization(double)")
}
@@ -92,7 +92,7 @@ func main() {
panic("specialization(int, int)")
}
- if Specialization(float64(10.0), float64(10.0)) != 205 {
+ if Specialization(10.0, 10.0) != 205 {
panic("specialization(double, double)")
}
@@ -136,7 +136,7 @@ func main() {
panic("overload(Klass t, const char *)")
}
- if Overload(float64(10.0), "hi") != 40 {
+ if Overload(10.0, "hi") != 40 {
panic("overload(double t, const char *)")
}
@@ -174,7 +174,7 @@ func main() {
panic("nsoverload(Klass t, const char *)")
}
- if Nsoverload(float64(10.0), "hi") != 1040 {
+ if Nsoverload(10.0, "hi") != 1040 {
panic("nsoverload(double t, const char *)")
}
diff --git a/Examples/test-suite/go/rename_simple_runme.go b/Examples/test-suite/go/rename_simple_runme.go
new file mode 100644
index 000000000..a63023bd1
--- /dev/null
+++ b/Examples/test-suite/go/rename_simple_runme.go
@@ -0,0 +1,29 @@
+package main
+
+import "fmt"
+import . "./rename_simple"
+
+func main() {
+ s := NewNewStruct()
+ check(111, s.GetNewInstanceVariable(), "NewInstanceVariable")
+ check(222, s.NewInstanceMethod(), "NewInstanceMethod")
+ check(333, NewStructNewStaticMethod(), "NewStaticMethod")
+ check(444, GetNewStructNewStaticVariable(), "NewStaticVariable")
+ check(555, NewFunction(), "NewFunction")
+ check(666, GetNewGlobalVariable(), "NewGlobalVariable")
+
+ s.SetNewInstanceVariable(1111)
+ SetNewStructNewStaticVariable(4444)
+ SetNewGlobalVariable(6666)
+
+ check(1111, s.GetNewInstanceVariable(), "NewInstanceVariable")
+ check(4444, GetNewStructNewStaticVariable(), "NewStaticVariable")
+ check(6666, GetNewGlobalVariable(), "NewGlobalVariable")
+}
+
+func check(expected, actual int, msg string) {
+ if expected != actual {
+ panic("Failed: Expected: " + fmt.Sprint(expected) +
+ " actual: " + fmt.Sprint(actual) + " " + msg)
+ }
+}
diff --git a/Examples/test-suite/go/smart_pointer_overload_runme.go b/Examples/test-suite/go/smart_pointer_overload_runme.go
index 0a06aa080..5ffeae17c 100644
--- a/Examples/test-suite/go/smart_pointer_overload_runme.go
+++ b/Examples/test-suite/go/smart_pointer_overload_runme.go
@@ -9,7 +9,7 @@ func main() {
if f.Test(3) != 1 {
panic(0)
}
- if f.Test(float64(3.5)) != 2 {
+ if f.Test(3.5) != 2 {
panic(0)
}
if f.Test("hello") != 3 {
@@ -19,7 +19,7 @@ func main() {
if b.Test(3) != 1 {
panic(0)
}
- if b.Test(float64(3.5)) != 2 {
+ if b.Test(3.5) != 2 {
panic(0)
}
if b.Test("hello") != 3 {
diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go
index 5be7f6d56..18412cd89 100644
--- a/Examples/test-suite/go/template_default_arg_runme.go
+++ b/Examples/test-suite/go/template_default_arg_runme.go
@@ -7,7 +7,7 @@ func main() {
helloInt.Foo(template_default_arg.Hello_intHi)
x := template_default_arg.NewX_int()
- if x.Meth(float64(20.0), 200).(int) != 200 {
+ if x.Meth(20.0, 200).(int) != 200 {
panic("X_int test 1 failed")
}
if x.Meth(20).(int) != 20 {
@@ -18,7 +18,7 @@ func main() {
}
y := template_default_arg.NewY_unsigned()
- if y.Meth(float64(20.0), uint(200)).(uint) != 200 {
+ if y.Meth(20.0, uint(200)).(uint) != 200 {
panic("Y_unsigned test 1 failed")
}
if y.Meth(uint(20)).(uint) != 20 {
@@ -29,19 +29,19 @@ func main() {
}
_ = template_default_arg.NewX_longlong()
- _ = template_default_arg.NewX_longlong(float64(20.0))
- _ = template_default_arg.NewX_longlong(float64(20.0), int64(200))
+ _ = template_default_arg.NewX_longlong(20.0)
+ _ = template_default_arg.NewX_longlong(20.0, int64(200))
_ = template_default_arg.NewX_int()
- _ = template_default_arg.NewX_int(float64(20.0))
- _ = template_default_arg.NewX_int(float64(20.0), 200)
+ _ = template_default_arg.NewX_int(20.0)
+ _ = template_default_arg.NewX_int(20.0, 200)
_ = template_default_arg.NewX_hello_unsigned()
- _ = template_default_arg.NewX_hello_unsigned(float64(20.0))
- _ = template_default_arg.NewX_hello_unsigned(float64(20.0), template_default_arg.NewHello_int())
+ _ = template_default_arg.NewX_hello_unsigned(20.0)
+ _ = template_default_arg.NewX_hello_unsigned(20.0, template_default_arg.NewHello_int())
yy := template_default_arg.NewY_hello_unsigned()
- yy.Meth(float64(20.0), template_default_arg.NewHello_int())
+ yy.Meth(20.0, template_default_arg.NewHello_int())
yy.Meth(template_default_arg.NewHello_int())
yy.Meth()
@@ -97,7 +97,7 @@ func main() {
}
// %template(ott) ott
- if template_default_arg.Ott(template_default_arg.NewHello_int(), float64(1.0)) != 60 {
+ if template_default_arg.Ott(template_default_arg.NewHello_int(), 1.0) != 60 {
panic("ott test 12 failed")
}
diff --git a/Examples/test-suite/go/template_ns_runme.go b/Examples/test-suite/go/template_ns_runme.go
index 5d463f814..6385eccf9 100644
--- a/Examples/test-suite/go/template_ns_runme.go
+++ b/Examples/test-suite/go/template_ns_runme.go
@@ -13,7 +13,7 @@ func main() {
panic(0)
}
- p3 := NewPairdd(float64(3.5), float64(2.5))
+ p3 := NewPairdd(3.5, 2.5)
p4 := NewPairdd(p3)
if p4.GetFirst() != 3.5 {
diff --git a/Examples/test-suite/go/using_composition_runme.go b/Examples/test-suite/go/using_composition_runme.go
index 1602e9627..47e245719 100644
--- a/Examples/test-suite/go/using_composition_runme.go
+++ b/Examples/test-suite/go/using_composition_runme.go
@@ -8,7 +8,7 @@ func main() {
panic("FooBar::blah(int)")
}
- if f.Blah(float64(3.5)).(float64) != 3.5 {
+ if f.Blah(3.5) != 3.5 {
panic("FooBar::blah(double)")
}
@@ -21,7 +21,7 @@ func main() {
panic("FooBar2::blah(int)")
}
- if f2.Blah(float64(3.5)).(float64) != 3.5 {
+ if f2.Blah(3.5) != 3.5 {
panic("FooBar2::blah(double)")
}
@@ -34,7 +34,7 @@ func main() {
panic("FooBar3::blah(int)")
}
- if f3.Blah(float64(3.5)).(float64) != 3.5 {
+ if f3.Blah(3.5) != 3.5 {
panic("FooBar3::blah(double)")
}
diff --git a/Examples/test-suite/go/using_extend_runme.go b/Examples/test-suite/go/using_extend_runme.go
index 144fac47d..830c958e5 100644
--- a/Examples/test-suite/go/using_extend_runme.go
+++ b/Examples/test-suite/go/using_extend_runme.go
@@ -8,7 +8,7 @@ func main() {
panic("blah(int)")
}
- if f.Blah(float64(3.5)).(float64) != 3.5 {
+ if f.Blah(3.5) != 3.5 {
panic("blah(double)")
}
@@ -20,7 +20,7 @@ func main() {
panic("blah(int,int)")
}
- if f.Blah(float64(3.5), float64(7.5)).(float64) != (3.5 + 7.5) {
+ if f.Blah(3.5, 7.5) != (3.5 + 7.5) {
panic("blah(double,double)")
}
diff --git a/Examples/test-suite/go/using_inherit_runme.go b/Examples/test-suite/go/using_inherit_runme.go
index 669ed4d5f..db29efb64 100644
--- a/Examples/test-suite/go/using_inherit_runme.go
+++ b/Examples/test-suite/go/using_inherit_runme.go
@@ -8,7 +8,7 @@ func main() {
panic("Bar::test(int)")
}
- if b.Test(float64(3.5)).(float64) != 3.5 {
+ if b.Test(3.5).(float64) != 3.5 {
panic("Bar::test(double)")
}
@@ -17,7 +17,7 @@ func main() {
panic("Bar2::test(int)")
}
- if b2.Test(float64(3.5)).(float64) != 7.0 {
+ if b2.Test(3.5).(float64) != 7.0 {
panic("Bar2::test(double)")
}
@@ -26,7 +26,7 @@ func main() {
panic("Bar3::test(int)")
}
- if b3.Test(float64(3.5)).(float64) != 7.0 {
+ if b3.Test(3.5).(float64) != 7.0 {
panic("Bar3::test(double)")
}
@@ -35,7 +35,7 @@ func main() {
panic("Bar4::test(int)")
}
- if b4.Test(float64(3.5)).(float64) != 7.0 {
+ if b4.Test(3.5).(float64) != 7.0 {
panic("Bar4::test(double)")
}
@@ -44,7 +44,7 @@ func main() {
panic("Fred1::test(int)")
}
- if bf1.Test(float64(3.5)).(float64) != 7.0 {
+ if bf1.Test(3.5).(float64) != 7.0 {
panic("Fred1::test(double)")
}
@@ -53,7 +53,7 @@ func main() {
panic("Fred2::test(int)")
}
- if bf2.Test(float64(3.5)).(float64) != 7.0 {
+ if bf2.Test(3.5).(float64) != 7.0 {
panic("Fred2::test(double)")
}
}
diff --git a/Examples/test-suite/go/varargs_overload_runme.go b/Examples/test-suite/go/varargs_overload_runme.go
new file mode 100644
index 000000000..52fc1b0e9
--- /dev/null
+++ b/Examples/test-suite/go/varargs_overload_runme.go
@@ -0,0 +1,38 @@
+package main
+
+import "./varargs_overload"
+
+func main() {
+ if varargs_overload.Vararg_over1("Hello") != "Hello" {
+ panic(0)
+ }
+ if varargs_overload.Vararg_over1(2) != "2" {
+ panic(1)
+ }
+
+ if varargs_overload.Vararg_over2("Hello") != "Hello" {
+ panic(2)
+ }
+ if varargs_overload.Vararg_over2(2, 2.2) != "2 2.2" {
+ panic(3)
+ }
+
+ if varargs_overload.Vararg_over3("Hello") != "Hello" {
+ panic(4)
+ }
+ if varargs_overload.Vararg_over3(2, 2.2, "hey") != "2 2.2 hey" {
+ panic(5)
+ }
+
+ if varargs_overload.Vararg_over4("Hello") != "Hello" {
+ panic(6)
+ }
+
+ if varargs_overload.Vararg_over4(123) != "123" {
+ panic(7)
+ }
+
+ if varargs_overload.Vararg_over4("Hello", 123) != "Hello" {
+ panic(8)
+ }
+}
diff --git a/Examples/test-suite/guilescm/ext_test_external.cxx b/Examples/test-suite/guilescm/ext_test_external.cxx
index 4b65f4953..713e5d2d0 100644
--- a/Examples/test-suite/guilescm/ext_test_external.cxx
+++ b/Examples/test-suite/guilescm/ext_test_external.cxx
@@ -10,7 +10,7 @@ SCM test_create()
newobj = new A();
type = SWIG_TypeQuery("A *");
- result = SWIG_NewPointerObj(result, type, 1);
+ result = SWIG_NewPointerObj(newobj, type, 1);
return result;
#undef FUNC_NAME
diff --git a/Examples/test-suite/immutable.i b/Examples/test-suite/immutable_values.i
similarity index 90%
rename from Examples/test-suite/immutable.i
rename to Examples/test-suite/immutable_values.i
index ff5081e9c..1c1978661 100644
--- a/Examples/test-suite/immutable.i
+++ b/Examples/test-suite/immutable_values.i
@@ -1,6 +1,6 @@
// test to make sure setters are not generated for constants
-%module immutable
+%module immutable_values
%immutable;
diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i
index a1ba9ad7a..4fd5cbf65 100644
--- a/Examples/test-suite/import_nomodule.i
+++ b/Examples/test-suite/import_nomodule.i
@@ -8,16 +8,16 @@
%import "import_nomodule.h"
-#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP)
+#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD)
/**
* The proxy class does not have Bar derived from Foo, yet an instance of Bar
* can successfully be passed to a proxy function taking a Foo pointer (for some
* language modules).
*
- * This violation of the type system is not possible in Java and C# due to static
- * type checking. It's also not (currently) possible in Ruby, but this may be
- * fixable (needs more investigation).
+ * This violation of the type system is not possible in Java, C# and D due to
+ * static type checking. It's also not (currently) possible in Ruby, but this may
+ * be fixable (needs more investigation).
*/
%newobject create_Foo;
diff --git a/Examples/test-suite/import_stl.list b/Examples/test-suite/import_stl.list
new file mode 100644
index 000000000..2265dab02
--- /dev/null
+++ b/Examples/test-suite/import_stl.list
@@ -0,0 +1,2 @@
+import_stl_a
+import_stl_b
diff --git a/Examples/test-suite/import_stl_a.i b/Examples/test-suite/import_stl_a.i
new file mode 100644
index 000000000..bda2cd447
--- /dev/null
+++ b/Examples/test-suite/import_stl_a.i
@@ -0,0 +1,5 @@
+%module import_stl_a
+
+%include
+%template(VectorInt) std::vector;
+
diff --git a/Examples/test-suite/import_stl_b.i b/Examples/test-suite/import_stl_b.i
new file mode 100644
index 000000000..9b7320916
--- /dev/null
+++ b/Examples/test-suite/import_stl_b.i
@@ -0,0 +1,13 @@
+%module import_stl_b
+
+%import "import_stl_a.i"
+
+%inline %{
+#include
+std::vector process_vector(const std::vector& v) {
+ std::vector v_new = v;
+ v_new.push_back(4);
+ return v_new;
+}
+%}
+
diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i
index 20fb93fda..88801f3f6 100644
--- a/Examples/test-suite/inherit_target_language.i
+++ b/Examples/test-suite/inherit_target_language.i
@@ -1,4 +1,4 @@
-// Test using a target language specified base class, primarily for Java/C# and possibly other single inheritance languages
+// Test using a target language specified base class, primarily for Java/C#/D and possibly other single inheritance languages
// Note the multiple inheritance warnings don't appear because of the two techniques used in here: typemaps and %ignore
@@ -6,6 +6,8 @@
#if defined(SWIGJAVA)
# define csbase javabase
+#elif defined(SWIGD)
+# define csbase dbase
#endif
%pragma(csharp) moduleimports=%{
@@ -20,6 +22,10 @@ class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
class TargetLanguageBase2 { public void targetLanguageBase2Method() {} };
%}
+%pragma(d) globalproxyimports=%{
+private class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
+private class TargetLanguageBase2 { public void targetLanguageBase2Method() {} };
+%}
%typemap(csbase) SWIGTYPE "TargetLanguageBase"
diff --git a/Examples/test-suite/java/char_binary_runme.java b/Examples/test-suite/java/char_binary_runme.java
new file mode 100644
index 000000000..9227f8617
--- /dev/null
+++ b/Examples/test-suite/java/char_binary_runme.java
@@ -0,0 +1,24 @@
+import char_binary.*;
+
+public class char_binary_runme {
+
+ static {
+ try {
+ System.loadLibrary("char_binary");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ Test t = new Test();
+ byte[] hile = "hile".getBytes();
+ byte[] hil0 = "hil\0".getBytes();
+ if (t.strlen(hile) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+
+ if (t.strlen(hil0) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+ }
+}
diff --git a/Examples/test-suite/java/director_protected_runme.java b/Examples/test-suite/java/director_protected_runme.java
index 464b4d4d9..63ac03502 100644
--- a/Examples/test-suite/java/director_protected_runme.java
+++ b/Examples/test-suite/java/director_protected_runme.java
@@ -19,6 +19,7 @@ public class director_protected_runme {
Foo f = b.create();
director_protected_FooBar fb = new director_protected_FooBar();
director_protected_FooBar2 fb2 = new director_protected_FooBar2();
+ director_protected_FooBar3 fb3 = new director_protected_FooBar3();
{
String s = fb.used();
@@ -60,11 +61,34 @@ public class director_protected_runme {
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::ping should be protected" );
+ method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Bar::cheer should be protected" );
+
+ method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Foo::cheer should be protected" );
+
} catch (NoSuchMethodException n) {
- throw new RuntimeException("NoSuchmethodException caught. Test failed.");
+ throw new RuntimeException(n);
} catch (SecurityException s) {
throw new RuntimeException("SecurityException caught. Test failed.");
}
+
+ if (!fb3.cheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3::cheer");
+
+ if (!fb2.callping().equals("director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callping");
+
+ if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callcheer");
+
+ if (!fb3.callping().equals("Bar::ping();"))
+ throw new RuntimeException("bad fb3.callping");
+
+ if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3.callcheer");
}
}
@@ -83,3 +107,9 @@ class director_protected_FooBar2 extends Bar {
}
}
+class director_protected_FooBar3 extends Bar {
+ public String cheer() {
+ return "director_protected_FooBar3::cheer();";
+ }
+}
+
diff --git a/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java
index 66968060d..391dfff04 100644
--- a/Examples/test-suite/java/enum_thorough_proper_runme.java
+++ b/Examples/test-suite/java/enum_thorough_proper_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_proper_runme {
if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_proper.global_typeint;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough_proper.global_typeboolfalse;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough_proper.global_typebooltrue;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough_proper.global_typebooltwo;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough_proper.global_typechar;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough_proper.global_typedefaultint;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java
index 79c902ccf..2f4d3c2ca 100644
--- a/Examples/test-suite/java/enum_thorough_runme.java
+++ b/Examples/test-suite/java/enum_thorough_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_runme {
if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough.global_typeint;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough.global_typeboolfalse;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough.global_typebooltrue;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough.global_typebooltwo;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough.global_typechar;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough.global_typedefaultint;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java
index e54acda70..1e94d2988 100644
--- a/Examples/test-suite/java/enum_thorough_simple_runme.java
+++ b/Examples/test-suite/java/enum_thorough_simple_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_simple_runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_simple.global_typeint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough_simple.global_typeboolfalse;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough_simple.global_typebooltrue;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough_simple.global_typebooltwo;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough_simple.global_typechar;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough_simple.global_typedefaultint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
index b00788911..1b0851e53 100644
--- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
+++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_typeunsafe_runme {
if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_typeunsafe.global_typeint;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough_typeunsafe.global_typeboolfalse;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough_typeunsafe.global_typebooltrue;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough_typeunsafe.global_typebooltwo;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough_typeunsafe.global_typechar;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough_typeunsafe.global_typedefaultint;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/friends_runme.java b/Examples/test-suite/java/friends_runme.java
new file mode 100644
index 000000000..2dced9efa
--- /dev/null
+++ b/Examples/test-suite/java/friends_runme.java
@@ -0,0 +1,53 @@
+import friends.*;
+
+public class friends_runme {
+
+ static {
+ try {
+ System.loadLibrary("friends");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) throws Throwable
+ {
+ A a = new A(2);
+
+ if (friends.get_val1(a) != 2)
+ throw new RuntimeException("failed");
+ if (friends.get_val2(a) != 4)
+ throw new RuntimeException("failed");
+ if (friends.get_val3(a) != 6)
+ throw new RuntimeException("failed");
+
+ // nice overload working fine
+ if (friends.get_val1(1,2,3) != 1)
+ throw new RuntimeException("failed");
+
+ B b = new B(3);
+
+ // David's case
+ if (friends.mix(a,b) != 5)
+ throw new RuntimeException("failed");
+
+ D_d di = new D_d(2);
+ D_d dd = new D_d(3.3);
+
+ // incredible template overloading working just fine
+ if (friends.get_val1(di) != 2)
+ throw new RuntimeException("failed");
+ if (friends.get_val1(dd) != 3.3)
+ throw new RuntimeException("failed");
+
+ friends.set(di, 4);
+ friends.set(dd, 1.3);
+
+ if (friends.get_val1(di) != 4)
+ throw new RuntimeException("failed");
+ if (friends.get_val1(dd) != 1.3)
+ throw new RuntimeException("failed");
+ }
+}
+
diff --git a/Examples/test-suite/java/nspace_runme.java b/Examples/test-suite/java/nspace_runme.java
index 9800e79cd..4b58c6b54 100644
--- a/Examples/test-suite/java/nspace_runme.java
+++ b/Examples/test-suite/java/nspace_runme.java
@@ -68,7 +68,7 @@ public class nspace_runme {
throw new RuntimeException("Transmission2 wrong");
// turn feature off / ignoring
- nspacePackage.Outer.nspace ns = new nspacePackage.Outer.nspace();
+ nspacePackage.Outer.namespce ns = new nspacePackage.Outer.namespce();
nspacePackage.NoNSpacePlease nons = new nspacePackage.NoNSpacePlease();
// Derived class
diff --git a/Examples/test-suite/java/pointer_reference_runme.java b/Examples/test-suite/java/pointer_reference_runme.java
index e8bd6800e..284951611 100644
--- a/Examples/test-suite/java/pointer_reference_runme.java
+++ b/Examples/test-suite/java/pointer_reference_runme.java
@@ -19,5 +19,8 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.getInstance().getValue() != 20) throw new RuntimeException("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new RuntimeException("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new RuntimeException("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/java/rename_pcre_encoder_runme.java b/Examples/test-suite/java/rename_pcre_encoder_runme.java
new file mode 100644
index 000000000..cb843338b
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_encoder_runme.java
@@ -0,0 +1,14 @@
+import rename_pcre_encoder.*;
+
+public class rename_pcre_encoder_runme {
+ static { System.loadLibrary("rename_pcre_encoder"); }
+
+ public static void main(String argv[])
+ {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new RuntimeException(String.format("Border with should be 17, not %d",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/java/rname_runme.java b/Examples/test-suite/java/rname_runme.java
index 7f2ab2f75..dac0a1ecf 100644
--- a/Examples/test-suite/java/rname_runme.java
+++ b/Examples/test-suite/java/rname_runme.java
@@ -30,7 +30,7 @@ public class rname_runme {
throw new RuntimeException("base.newname");
RenamedDerived derived = new RenamedDerived();
- derived.func(base, base, base);
+ derived.Xfunc(base, base, base);
if (!derived.newname(10.0).equals("Derived"))
throw new RuntimeException("derived.newname");
}
diff --git a/Examples/test-suite/java/typemap_arrays_runme.java b/Examples/test-suite/java/typemap_arrays_runme.java
new file mode 100644
index 000000000..1ca062f78
--- /dev/null
+++ b/Examples/test-suite/java/typemap_arrays_runme.java
@@ -0,0 +1,19 @@
+import typemap_arrays.*;
+
+public class typemap_arrays_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_arrays");
+ } 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[]) {
+ if (typemap_arrays.sumA(null) != 60)
+ throw new RuntimeException("Sum is wrong");
+ }
+}
+
diff --git a/Examples/test-suite/java/wallkw_runme.java b/Examples/test-suite/java/wallkw_runme.java
index 028c2a32f..7695cda24 100644
--- a/Examples/test-suite/java/wallkw_runme.java
+++ b/Examples/test-suite/java/wallkw_runme.java
@@ -19,7 +19,9 @@ public class wallkw_runme {
throw new RuntimeException("delegate keyword fail");
if (!wallkw._pass().equals("pass"))
throw new RuntimeException("pass keyword fail");
- if (!wallkw.C_alias().equals("alias"))
+ if (!wallkw._alias().equals("alias"))
throw new RuntimeException("alias keyword fail");
+ if (!wallkw.C_rescue().equals("rescue"))
+ throw new RuntimeException("rescue keyword fail");
}
}
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index f92df23a9..3d474ec00 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -34,7 +34,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
@@ -45,6 +45,7 @@
%shared_ptr(Space::KlassDerived)
%shared_ptr(Space::Klass2ndDerived)
%shared_ptr(Space::Klass3rdDerived)
+%shared_ptr(IgnoredMultipleInheritBase) // IgnoredMultipleInheritBase not actually used in any wrapped functions, so this isn't entirely necessary and warning 520 could instead have been suppressed.
#endif
diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i
index 610edb4b4..2232b6cf6 100644
--- a/Examples/test-suite/li_boost_shared_ptr_bits.i
+++ b/Examples/test-suite/li_boost_shared_ptr_bits.i
@@ -1,6 +1,6 @@
%module li_boost_shared_ptr_bits
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i
index 9acc8f23d..57f945bcd 100644
--- a/Examples/test-suite/li_std_combinations.i
+++ b/Examples/test-suite/li_std_combinations.i
@@ -14,7 +14,7 @@
%template(VectorVectorString) std::vector< std::vector >;
%template(PairIntPairIntString) std::pair< int, std::pair >;
-#if defined(SWIGCSHARP)
+#if defined(SWIGCSHARP) || defined(SWIGD)
// Checks macro containing a type with a comma
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
#endif
diff --git a/Examples/test-suite/li_std_map_member.i b/Examples/test-suite/li_std_map_member.i
new file mode 100644
index 000000000..adaddbd2e
--- /dev/null
+++ b/Examples/test-suite/li_std_map_member.i
@@ -0,0 +1,20 @@
+%module li_std_map_member
+
+%inline %{
+int i;
+class TestA {
+public:
+TestA() { i = 1; }
+int i;
+};
+%}
+%include std_pair.i
+%include std_map.i
+
+namespace std
+{
+%template(pairii) pair;
+%template(mapii) map;
+%template(pairita) pair;
+%template(mapita) map;
+}
diff --git a/Examples/test-suite/li_std_stream.i b/Examples/test-suite/li_std_stream.i
index 0a999ddbf..35014baaa 100644
--- a/Examples/test-suite/li_std_stream.i
+++ b/Examples/test-suite/li_std_stream.i
@@ -1,5 +1,11 @@
%module li_std_stream
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
+#endif
+%}
+
%inline %{
struct A;
%}
diff --git a/Examples/test-suite/li_std_wstream.i b/Examples/test-suite/li_std_wstream.i
index e4d725f10..7945b701d 100644
--- a/Examples/test-suite/li_std_wstream.i
+++ b/Examples/test-suite/li_std_wstream.i
@@ -1,5 +1,11 @@
%module li_std_wstream
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
+#endif
+%}
+
%inline %{
struct A;
%}
@@ -49,6 +55,7 @@
%}
%extend std::basic_ostream{
+ extern "C"
std::basic_ostream&
operator<<(const A& a)
{
diff --git a/Examples/test-suite/li_typemaps_apply.i b/Examples/test-suite/li_typemaps_apply.i
new file mode 100644
index 000000000..ecb3f87b6
--- /dev/null
+++ b/Examples/test-suite/li_typemaps_apply.i
@@ -0,0 +1,46 @@
+%module li_typemaps_apply
+
+// Test %apply to global primitive type references/pointers to make sure the return types are still okay... mainly for the strongly typed languages.
+
+%include "typemaps.i"
+
+#if !defined(SWIGJAVA) // Needs asymmetric type marshalling support for this testcase to work
+
+%define TMAPS(PRIMTYPE, NAME)
+%apply PRIMTYPE *INPUT { PRIMTYPE * }
+%apply PRIMTYPE &INPUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *input_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; return &stat; }
+PRIMTYPE &input_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; return stat; }
+%}
+
+%apply PRIMTYPE *OUTPUT { PRIMTYPE * }
+%apply PRIMTYPE &OUTPUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *output_ptr_##NAME(PRIMTYPE x, PRIMTYPE *v) { static PRIMTYPE stat; stat = x; *v = x; return &stat; }
+PRIMTYPE &output_ref_##NAME(PRIMTYPE x, PRIMTYPE &v) { static PRIMTYPE stat; stat = x; v = x; return stat; }
+%}
+
+%apply PRIMTYPE *INOUT { PRIMTYPE * }
+%apply PRIMTYPE &INOUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *inout_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; *v = *v; return &stat; }
+PRIMTYPE &inout_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; v = v; return stat; }
+%}
+%enddef
+
+TMAPS(bool, bool)
+TMAPS(int, int)
+TMAPS(short, short)
+TMAPS(long, long)
+TMAPS(unsigned int, uint)
+TMAPS(unsigned short, ushort)
+TMAPS(unsigned long, ulong)
+TMAPS(unsigned char, uchar)
+TMAPS(signed char, schar)
+TMAPS(float, float)
+TMAPS(double, double)
+TMAPS(long long, longlong)
+TMAPS(unsigned long long, ulonglong)
+
+#endif
diff --git a/Examples/test-suite/lua/pointer_reference_runme.lua b/Examples/test-suite/lua/pointer_reference_runme.lua
index 959d5a2a3..428c76998 100644
--- a/Examples/test-suite/lua/pointer_reference_runme.lua
+++ b/Examples/test-suite/lua/pointer_reference_runme.lua
@@ -9,3 +9,5 @@ ss = pointer_reference.Struct(20);
pointer_reference.set(ss);
assert(pointer_reference.Struct_instance.value == 20)
+assert(pointer_reference.overloading(1) == 111)
+assert(pointer_reference.overloading(ss) == 222)
diff --git a/Examples/test-suite/member_funcptr_galore.i b/Examples/test-suite/member_funcptr_galore.i
new file mode 100644
index 000000000..962a8bd0e
--- /dev/null
+++ b/Examples/test-suite/member_funcptr_galore.i
@@ -0,0 +1,95 @@
+%module member_funcptr_galore
+
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
+#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
+#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
+#endif
+%}
+
+%inline %{
+
+namespace FunkSpace {
+struct Funktions {
+ int addByValue(const int &a, int b) { return a+b; }
+ int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; }
+ int & addByReference(const int &a, int b) { static int val; val = a+b; return val; }
+};
+}
+
+template struct Thing {};
+namespace Space {
+class Shape {
+public:
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)) { return 0.0; }
+ virtual double abc(Thing ts, Thing< const Space::Shape * > tda[]) { return 0.0; }
+};
+}
+
+extern double do_op(Space::Shape *s, double (Space::Shape::*m)(void));
+
+/* Functions that return member pointers */
+
+extern double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int));
+extern double (Space::Shape::*abcpt())(Thing, Thing< const Space::Shape * > tda[]);
+
+/* Global variables that are member pointers */
+extern double (Space::Shape::*areavar)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int));
+extern double (Space::Shape::*abcvar)(Thing, Thing< const Space::Shape * >[]);
+
+%}
+
+%{
+void Space::Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+double do_op(Space::Shape *s, double (Space::Shape::*m)(void)) {
+ return (s->*m)();
+}
+
+double (Space::Shape::*areapt(Space::Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)))(Space::Shape &, int & (FunkSpace::Funktions::*d)(const int &, int)) {
+ return &Space::Shape::area;
+}
+
+double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) {
+ return 0;
+}
+
+double (Space::Shape::*abcpt())(Thing, Thing< const Space::Shape * >[]) {
+ return &Space::Shape::abc;
+}
+
+/* Member pointer variables */
+double (Space::Shape::*areavar)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area;
+double (Space::Shape::*abcvar)(Thing, Thing< const Space::Shape * >[]) = &Space::Shape::abc;
+%}
+
+
+/* Some constants */
+%constant double (Space::Shape::*AREAPT)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area;
+%constant double (Space::Shape::*PERIMPT)(Thing, Thing< const Space::Shape * >[]) = &Space::Shape::abc;
+%constant double (Space::Shape::*NULLPT)(void) = 0;
+
+%inline %{
+
+int call1(int (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return (f.*d)(a, b); }
+int call2(int * (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return *(f.*d)(a, b); }
+int call3(int & (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return (f.*d)(a, b); }
+%}
+
+%constant int (FunkSpace::Funktions::*ADD_BY_VALUE)(const int &, int) = &FunkSpace::Funktions::addByValue;
+%constant int * (FunkSpace::Funktions::*ADD_BY_POINTER)(const int &, int) = &FunkSpace::Funktions::addByPointer;
+%constant int & (FunkSpace::Funktions::*ADD_BY_REFERENCE)(const int &, int) = &FunkSpace::Funktions::addByReference;
+
+%inline %{
+// parameter that is a member pointer containing a function ptr, urgh :)
+int unreal1(double (Space::Shape::*memptr)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int))) { return 0; }
+int unreal2(double (Space::Shape::*memptr)(Thing)) { return 0; }
+%}
diff --git a/Examples/test-suite/member_pointer.i b/Examples/test-suite/member_pointer.i
index d9d5cbef5..fe454302a 100644
--- a/Examples/test-suite/member_pointer.i
+++ b/Examples/test-suite/member_pointer.i
@@ -1,5 +1,13 @@
%module member_pointer
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
+#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
+#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
+#endif
+%}
+
%inline %{
class Shape {
public:
diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i
index 1bca4fc48..7d470d30e 100644
--- a/Examples/test-suite/minherit2.i
+++ b/Examples/test-suite/minherit2.i
@@ -1,16 +1,18 @@
%module minherit2
-// A multiple inheritance example, mainly for Java and C#.
-// The example shows how it is possible to turn C++ abstract base classes into Java/C# interface.
+// A multiple inheritance example, mainly for Java, C# and D.
+// The example shows how it is possible to turn C++ abstract base classes into
+// Java/C#/D interfaces.
// In the future, all this trouble might be more automated.
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe;
-#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
#if defined(SWIGCSHARP)
#define javaclassmodifiers csclassmodifiers
@@ -22,6 +24,21 @@
#define javabase csbase
#endif
+#if defined(SWIGD)
+#define javaclassmodifiers dclassmodifiers
+#define javabody dbody
+#define javafinalize ddestructor
+#define javadestruct ddispose
+#define javaout dout
+#define javainterfaces dinterfaces
+#define javabase dbase
+
+%typemap(dimports) RemoteMpe %{
+$importtype(IRemoteSyncIO)
+$importtype(IRemoteAsyncIO)
+%}
+#endif
+
// Modify multiple inherited base classes into inheriting interfaces
%typemap(javainterfaces) RemoteMpe "IRemoteSyncIO, IRemoteAsyncIO";
%typemap(javabase, replace="1") RemoteMpe "";
@@ -51,6 +68,12 @@
// Features are inherited by derived classes, so override this
%csmethodmodifiers RemoteMpe::syncmethod "public"
%csmethodmodifiers RemoteMpe::asyncmethod "public"
+#elif defined(SWIGD)
+%dmethodmodifiers IRemoteSyncIO::syncmethod "";
+%dmethodmodifiers IRemoteAsyncIO::asyncmethod "";
+// Features are inherited by derived classes, so override this
+%dmethodmodifiers RemoteMpe::syncmethod "public"
+%dmethodmodifiers RemoteMpe::asyncmethod "public"
#endif
#endif
diff --git a/Examples/test-suite/multiple_inheritance.i b/Examples/test-suite/multiple_inheritance.i
index 1fc68eef9..044345020 100644
--- a/Examples/test-suite/multiple_inheritance.i
+++ b/Examples/test-suite/multiple_inheritance.i
@@ -5,11 +5,13 @@ It tests basic multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, D, Java, PHP multiple inheritance */
%inline %{
diff --git a/Examples/test-suite/namespace_class.i b/Examples/test-suite/namespace_class.i
index 7dc9139cd..aea5362d1 100644
--- a/Examples/test-suite/namespace_class.i
+++ b/Examples/test-suite/namespace_class.i
@@ -2,6 +2,10 @@
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola;
+#ifdef SWIGD
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_LT);
+#endif
+
%inline %{
template void foobar(T t) {}
namespace test {
diff --git a/Examples/test-suite/namespace_spaces.i b/Examples/test-suite/namespace_spaces.i
index 981916142..86b21e221 100644
--- a/Examples/test-suite/namespace_spaces.i
+++ b/Examples/test-suite/namespace_spaces.i
@@ -1,4 +1,11 @@
%module namespace_spaces
+
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, wbadasg) /* Assigning extern "C" ... */
+#endif
+%}
+
%inline %{
class Foo {
diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i
index 71d91f022..d67440ac9 100644
--- a/Examples/test-suite/nested_class.i
+++ b/Examples/test-suite/nested_class.i
@@ -39,6 +39,8 @@ struct Outer {
};
///////////////////////////////////////////
+#ifdef SWIG
+/* some compilers do not accept these */
class {
public:
Integer a;
@@ -47,6 +49,7 @@ struct Outer {
struct {
Integer b;
};
+#endif
union {
Integer c;
@@ -151,6 +154,8 @@ struct Outer {
Integer xx;
} MultipleInstanceAnonDerived1, MultipleInstanceAnonDerived2, *MultipleInstanceAnonDerived3, MultipleInstanceAnonDerived4[2];
+#ifdef SWIG
+/* some compilers do not accept these */
struct : public InnerMultiple {
Integer xx;
};
@@ -159,6 +164,7 @@ struct Outer {
public:
Integer yy;
};
+#endif
///////////////////////////////////////////
typedef struct {
diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i
index 4e4e461c0..89009b939 100644
--- a/Examples/test-suite/nspace.i
+++ b/Examples/test-suite/nspace.i
@@ -2,7 +2,7 @@
%module nspace
// nspace feature only supported by these languages
-#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
%nspace;
%nonspace Outer::Inner2::NoNSpacePlease;
@@ -15,7 +15,7 @@
%inline %{
namespace Outer {
- class nspace {
+ class namespce {
};
namespace Inner1 {
enum Channel { Diffuse, Specular = 0x10, Transmission1 };
@@ -33,12 +33,12 @@ namespace Outer {
static const Channel staticConstEnumMemberVariable = Transmission;
void colorInstanceMethod(double d) {}
static void colorStaticMethod(double d) {}
- }; // Color
+ }; // Color
int Color::staticMemberVariable = 0;
Color namespaceFunction(Color k) { return k; }
int namespaceVar = 0;
- } // Inner1
+ } // Inner1
namespace Inner2 {
enum Channel { Diffuse, Specular = 0x30, Transmission2 };
@@ -56,12 +56,12 @@ namespace Outer {
static const Channel staticConstEnumMemberVariable = Transmission;
void colorInstanceMethod(double d) {}
static void colorStaticMethod(double d) {}
- void colors(const Inner1::Color& col1a,
- const Outer::Inner1::Color& col1b,
- const Color &col2a,
- const Inner2::Color& col2b,
+ void colors(const Inner1::Color& col1a,
+ const Outer::Inner1::Color& col1b,
+ const Color &col2a,
+ const Inner2::Color& col2b,
const Outer::Inner2::Color& col2c) {}
- }; // Color
+ }; // Color
int Color::staticMemberVariable = 0;
class NoNSpacePlease {};
} // Inner2
diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i
index 88f40bc69..47ede95d0 100644
--- a/Examples/test-suite/nspace_extend.i
+++ b/Examples/test-suite/nspace_extend.i
@@ -2,7 +2,7 @@
%module nspace_extend
// nspace feature only supported by these languages
-#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
%nspace;
@@ -39,10 +39,10 @@ namespace Outer {
void colorInstanceMethod(double d) {}
static void colorStaticMethod(double d) {}
- void colors(const Inner1::Color& col1a,
- const Outer::Inner1::Color& col1b,
- const Color &col2a,
- const Inner2::Color& col2b,
+ void colors(const Inner1::Color& col1a,
+ const Outer::Inner1::Color& col1b,
+ const Color &col2a,
+ const Inner2::Color& col2b,
const Outer::Inner2::Color& col2c) {}
}
diff --git a/Examples/test-suite/null_pointer.i b/Examples/test-suite/null_pointer.i
index 0bd7a9b92..0da827f99 100644
--- a/Examples/test-suite/null_pointer.i
+++ b/Examples/test-suite/null_pointer.i
@@ -8,5 +8,9 @@
bool func(A* a) {
return !a;
}
+
+ A* getnull() {
+ return 0;
+ }
}
diff --git a/Examples/test-suite/octave/exception_order_runme.m b/Examples/test-suite/octave/exception_order_runme.m
index 3fb2b9a50..5ef85f46c 100644
--- a/Examples/test-suite/octave/exception_order_runme.m
+++ b/Examples/test-suite/octave/exception_order_runme.m
@@ -1,44 +1,42 @@
exception_order
+function check_lasterror(expected)
+ if (!strcmp(lasterror.message, expected))
+ # Take account of older versions prefixing with "error: " and adding a newline at the end
+ if (!strcmp(regexprep(lasterror.message, 'error: (.*)\n$', '$1'), expected))
+ error(["Bad exception order. Expected: \"", expected, "\" Got: \"", lasterror.message, "\""])
+ endif
+ endif
+endfunction
a = A();
try
a.foo()
catch
- if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
- error("bad exception order")
- endif
+ check_lasterror("C++ side threw an exception of type E1")
end_try_catch
try
a.bar()
catch
- if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2\n"))
- error("bad exception order")
- endif
+ check_lasterror("C++ side threw an exception of type E2")
end_try_catch
try
a.foobar()
catch
- if (!strcmp(lasterror.message, "error: postcatch unknown (SWIG_RuntimeError)\n"))
- error("bad exception order")
- endif
+ check_lasterror("postcatch unknown (SWIG_RuntimeError)")
end_try_catch
try
a.barfoo(1)
catch
- if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E1\n"))
- error("bad exception order")
- endif
+ check_lasterror("C++ side threw an exception of type E1")
end_try_catch
try
a.barfoo(2)
catch
- if (!strcmp(lasterror.message, "error: C++ side threw an exception of type E2 *\n"))
- error("bad exception order")
- endif
+ check_lasterror("C++ side threw an exception of type E2 *")
end_try_catch
diff --git a/Examples/test-suite/octave/global_ns_arg_runme.m b/Examples/test-suite/octave/global_ns_arg_runme.m
index fa3625ef1..b8f7cfa31 100644
--- a/Examples/test-suite/octave/global_ns_arg_runme.m
+++ b/Examples/test-suite/octave/global_ns_arg_runme.m
@@ -1,5 +1,5 @@
global_ns_arg
a = foo(1);
-b = bar();
+b = bar_fn();
diff --git a/Examples/test-suite/octave/preproc_constants_runme.m b/Examples/test-suite/octave/preproc_constants_runme.m
new file mode 100644
index 000000000..0199a8446
--- /dev/null
+++ b/Examples/test-suite/octave/preproc_constants_runme.m
@@ -0,0 +1,24 @@
+preproc_constants
+
+assert(CONST_INT1, 10)
+assert(CONST_DOUBLE3, 12.3)
+assert(CONST_BOOL1, true)
+assert(CONST_CHAR, 'x')
+assert(CONST_STRING1, "const string")
+
+# Test global constants can be seen within functions
+function test_global()
+global CONST_INT1
+global CONST_DOUBLE3
+global CONST_BOOL1
+global CONST_CHAR
+global CONST_STRING1
+
+assert(CONST_INT1, 10)
+assert(CONST_DOUBLE3, 12.3)
+assert(CONST_BOOL1, true)
+assert(CONST_CHAR, 'x')
+assert(CONST_STRING1, "const string")
+endfunction
+
+test_global
diff --git a/Examples/test-suite/octave/primitive_types_runme.m b/Examples/test-suite/octave/primitive_types_runme.m
deleted file mode 100644
index 568e3511e..000000000
--- a/Examples/test-suite/octave/primitive_types_runme.m
+++ /dev/null
@@ -1,402 +0,0 @@
-primitive_types
-
-var_init();
-
-# assigning globals calls
-cvar.var_bool = sct_bool;
-cvar.var_schar = sct_schar;
-cvar.var_uchar = sct_uchar;
-cvar.var_int = sct_int;
-cvar.var_uint = sct_uint;
-cvar.var_short = sct_short;
-cvar.var_ushort = sct_ushort;
-cvar.var_long = sct_long;
-cvar.var_ulong = sct_ulong;
-cvar.var_llong = sct_llong;
-cvar.var_ullong = sct_ullong;
-cvar.var_char = sct_char;
-cvar.var_pchar = sct_pchar;
-cvar.var_pcharc = sct_pcharc;
-cvar.var_pint = sct_pint;
-cvar.var_sizet = sct_sizet;
-cvar.var_hello = sct_hello;
-cvar.var_myint = sct_myint;
-cvar.var_namet = def_namet;
-cvar.var_parami = sct_parami;
-cvar.var_paramd = sct_paramd;
-cvar.var_paramc = sct_paramc;
-
-v_check();
-
-function octerror(name, val, cte)
- name, val, cte
- error
-endfunction
-
-if cvar.var_bool != cct_bool:
-octerror("bool", cvar.var_bool, cct_bool)
-endif
-if cvar.var_schar != cct_schar:
-octerror("schar", cvar.var_schar, cct_schar)
-endif
-if cvar.var_uchar != cct_uchar:
- octerror("uchar", cvar.var_uchar, cct_uchar)
-endif
-if cvar.var_int != cct_int:
- octerror("int", cvar.var_int, cct_int)
-endif
-if cvar.var_uint != cct_uint:
- octerror("uint", cvar.var_uint, cct_uint)
-endif
-if cvar.var_short != cct_short:
- octerror("short", cvar.var_short, cct_short)
-endif
-if cvar.var_ushort != cct_ushort:
- octerror("ushort", cvar.var_ushort, cct_ushort)
-endif
-if cvar.var_long != cct_long:
- octerror("long", cvar.var_long, cct_long)
-endif
-if cvar.var_ulong != cct_ulong:
- octerror("ulong", cvar.var_ulong, cct_ulong)
-endif
-if cvar.var_llong != cct_llong:
- octerror("llong", cvar.var_llong, cct_llong)
-endif
-if cvar.var_ullong != cct_ullong:
- octerror("ullong", cvar.var_ullong, cct_ullong)
-endif
-if cvar.var_char != cct_char:
- octerror("char", cvar.var_char, cct_char)
-endif
-if cvar.var_pchar != cct_pchar:
- octerror("pchar", cvar.var_pchar, cct_pchar)
-endif
-if cvar.var_pcharc != cct_pcharc:
- octerror("pchar", cvar.var_pcharc, cct_pcharc)
-endif
-if cvar.var_pint != cct_pint:
- octerror("pint", cvar.var_pint, cct_pint)
-endif
-if cvar.var_sizet != cct_sizet:
- octerror("sizet", cvar.var_sizet, cct_sizet)
-endif
-if cvar.var_hello != cct_hello:
- octerror("hello", cvar.var_hello, cct_hello)
-endif
-if cvar.var_myint != cct_myint:
- octerror("myint", cvar.var_myint, cct_myint)
-endif
-if cvar.var_namet != def_namet:
- octerror("name", cvar.var_namet, def_namet)
-endif
-
-
-function OctTest()
- self=subclass(TestDirector);
- self.ident=@(self,x) x;
-
- self.vval_bool=@(self, x) self.ident(x);
- self.vval_schar=@(self, x) self.ident(x);
- self.vval_uchar=@(self, x) self.ident(x);
- self.vval_int=@(self, x) self.ident(x);
- self.vval_uint=@(self, x) self.ident(x);
- self.vval_short=@(self, x) self.ident(x);
- self.vval_ushort=@(self, x) self.ident(x);
- self.vval_long=@(self, x) self.ident(x);
- self.vval_ulong=@(self, x) self.ident(x);
- self.vval_llong=@(self, x) self.ident(x);
- self.vval_ullong=@(self, x) self.ident(x);
- self.vval_float=@(self, x) self.ident(x);
- self.vval_double=@(self, x) self.ident(x);
- self.vval_char=@(self, x) self.ident(x);
- self.vval_pchar=@(self, x) self.ident(x);
- self.vval_pcharc=@(self, x) self.ident(x);
- self.vval_pint=@(self, x) self.ident(x);
- self.vval_sizet=@(self, x) self.ident(x);
- self.vval_hello=@(self, x) self.ident(x);
- self.vval_myint=@(self, x) self.ident(x);
-
- self.vref_bool=@(self, x) self.ident(x);
- self.vref_schar=@(self, x) self.ident(x);
- self.vref_uchar=@(self, x) self.ident(x);
- self.vref_int=@(self, x) self.ident(x);
- self.vref_uint=@(self, x) self.ident(x);
- self.vref_short=@(self, x) self.ident(x);
- self.vref_ushort=@(self, x) self.ident(x);
- self.vref_long=@(self, x) self.ident(x);
- self.vref_ulong=@(self, x) self.ident(x);
- self.vref_llong=@(self, x) self.ident(x);
- self.vref_ullong=@(self, x) self.ident(x);
- self.vref_float=@(self, x) self.ident(x);
- self.vref_double=@(self, x) self.ident(x);
- self.vref_char=@(self, x) self.ident(x);
- self.vref_pchar=@(self, x) self.ident(x);
- self.vref_pcharc=@(self, x) self.ident(x);
- self.vref_pint=@(self, x) self.ident(x);
- self.vref_sizet=@(self, x) self.ident(x);
- self.vref_hello=@(self, x) self.ident(x);
- self.vref_myint=@(self, x) self.ident(x);
-endfunction
-
-
-t = Test();
-p = OctTest();
-
-
-# internal call check
-if (t.c_check() != p.c_check())
- error, "bad director"
-endif
-
-p.var_bool = p.stc_bool;
-p.var_schar = p.stc_schar;
-p.var_uchar = p.stc_uchar;
-p.var_int = p.stc_int;
-p.var_uint = p.stc_uint;
-p.var_short = p.stc_short;
-p.var_ushort = p.stc_ushort;
-p.var_long = p.stc_long;
-p.var_ulong = p.stc_ulong;
-p.var_llong = p.stc_llong;
-p.var_ullong = p.stc_ullong;
-p.var_char = p.stc_char;
-p.var_pchar = sct_pchar;
-p.var_pcharc = sct_pcharc;
-p.var_pint = sct_pint;
-p.var_sizet = sct_sizet;
-p.var_hello = sct_hello;
-p.var_myint = sct_myint;
-p.var_namet = def_namet;
-p.var_parami = sct_parami;
-p.var_paramd = sct_paramd;
-p.var_paramc = sct_paramc;
-
-p.v_check();
-
-t.var_bool = t.stc_bool;
-t.var_schar = t.stc_schar;
-t.var_uchar = t.stc_uchar;
-t.var_int = t.stc_int;
-t.var_uint = t.stc_uint;
-t.var_short = t.stc_short;
-t.var_ushort = t.stc_ushort;
-t.var_long = t.stc_long;
-t.var_ulong = t.stc_ulong;
-t.var_llong = t.stc_llong;
-t.var_ullong = t.stc_ullong;
-t.var_char = t.stc_char;
-t.var_pchar = sct_pchar;
-t.var_pcharc = sct_pcharc;
-t.var_pint = sct_pint;
-t.var_sizet = sct_sizet;
-t.var_hello = sct_hello;
-t.var_myint = sct_myint;
-t.var_namet = def_namet;
-t.var_parami = sct_parami;
-t.var_paramd = sct_paramd;
-t.var_paramc = sct_paramc;
-
-t.v_check();
-
-# this value contains a '0' char!
-if (def_namet != 'ho\0la')
- error
-endif
-
-t.var_namet = def_namet;
-if (t.var_namet != def_namet)
- error
-endif
-
-t.var_namet = 'holac';
-
-if (t.var_namet != 'holac')
- error
-endif
-
-t.var_namet = 'hol';
-
-if (t.var_namet != 'hol')
- error
-endif
-
-if (t.strlen('hile') != 4)
- error
-endif
-
-if (t.strlen('hil\0') != 4)
- error
-endif
-
-cvar.var_char = '\0';
-if (cvar.var_char != '\0')
- error
-endif
-
-cvar.var_char = 0;
-if (cvar.var_char != '\0')
- error
-endif
-
-cvar.var_namet = '\0';
-if (cvar.var_namet != '')
- error
-endif
-
-cvar.var_namet = '';
-if (cvar.var_namet != '')
- error, "bad char empty case"
-endif
-
-cvar.var_pchar = None;
-if (cvar.var_pchar != None)
- error, "bad None case"
-endif
-
-cvar.var_pchar = '';
-if (cvar.var_pchar != '')
- error
-endif
-
-cvar.var_pcharc = None;
-if (cvar.var_pcharc != None)
- error
-endif
-
-cvar.var_pcharc = '';
-if (cvar.var_pcharc != '')
- error
-endif
-
-#
-# creating a raw char*
-#
-pc = new_pchar(5);
-pchar_setitem(pc, 0, 'h');
-pchar_setitem(pc, 1, 'o');
-pchar_setitem(pc, 2, 'l');
-pchar_setitem(pc, 3, 'a');
-pchar_setitem(pc, 4, 0);
-
-
-if (t.strlen(pc) != 4)
- error
-endif
-
-cvar.var_pchar = pc;
-if (cvar.var_pchar != "hola")
- error
-endif
-
-cvar.var_namet = pc;
-if (cvar.var_namet != "hola")
- error
-endif
-
-delete_pchar(pc);
-
-#
-# Now when things should fail
-#
-
-try
- error = 0;
- a = t.var_uchar;
- t.var_uchar = 10000;
- err = 1;
-catch
- if (a != t.var_uchar)
- err = 1;
- endif
-end_try_catch
-
-if (err)
- error
-endif
-
-try
- err = 0;
- a = t.var_char;
- t.var_char = '23';
- err = 1;
-catch
- if (a != t.var_char)
- error = 1
- endif
-end_try_catch
-if (err)
- error
-endif
-
-try
- err = 0
- a = t.var_uint
- t.var_uint = -1
- err = 1;
-catch
- if a != t.var_uint:
- err = 1;
- endif
-end_try_catch
-if (err)
- error
-endif
-
-#
-#
-try
- err = 0;
- a = t.var_namet;
- t.var_namet = '123456';
- err = 1;
-catch
- if (a != t.var_namet)
- err = 1;
- endif
-end_try_catch
-if (err)
- error
-endif
-
-#
-#
-#
-t2 = p.vtest(t);
-if (t.var_namet != t2.var_namet)
- error
-endif
-
-
-if (cvar.fixsize != 'ho\0la\0\0\0')
- error
-endif
-
-cvar.fixsize = 'ho';
-if (cvar.fixsize != 'ho\0\0\0\0\0\0')
- error
-endif
-
-
-f = Foo(3);
-f1 = fptr_val(f);
-f2 = fptr_ref(f);
-if (f1._a != f2._a)
- error
-endif
-
-v = char_foo(1,3);
-if (v !=3)
- error
-endif
-
-s = char_foo(1,"hello");
-if (s !="hello")
- error
-endif
-
-
-v = SetPos(1,3);
-if (v !=4)
- error
-endif
diff --git a/Examples/test-suite/samename_runme.m b/Examples/test-suite/octave/samename_runme.m
similarity index 100%
rename from Examples/test-suite/samename_runme.m
rename to Examples/test-suite/octave/samename_runme.m
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 80facff76..006662109 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -79,6 +79,12 @@ see bottom for a set of possible tests
%}
#endif
+#ifdef SWIGD
+// Due to the way operator overloading is implemented in D1 and D2, the prefix
+// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_PLUSPLUS, SWIGWARN_IGNORE_OPERATOR_MINUSMINUS);
+#endif
+
%rename(IntCast) operator int();
%rename(DoubleCast) operator double();
diff --git a/Examples/test-suite/operator_overload_break.i b/Examples/test-suite/operator_overload_break.i
index 9c6927bb0..f5f3c1a46 100644
--- a/Examples/test-suite/operator_overload_break.i
+++ b/Examples/test-suite/operator_overload_break.i
@@ -1,6 +1,6 @@
%module operator_overload_break
-#if defined(SWIGPYTHON)
+#if defined(SWIGPYTHON) || defined(SWIGD)
%warnfilter(SWIGWARN_IGNORE_OPERATOR_PLUSPLUS);
#endif
diff --git a/Examples/test-suite/operator_pointer_ref.i b/Examples/test-suite/operator_pointer_ref.i
new file mode 100644
index 000000000..1541adbcf
--- /dev/null
+++ b/Examples/test-suite/operator_pointer_ref.i
@@ -0,0 +1,21 @@
+%module operator_pointer_ref
+
+%rename(AsCharStarRef) operator char*&;
+
+%inline %{
+class MyClass {
+public:
+ MyClass (const char *s_ = "")
+ : s(strdup(s_ ? s_ : ""))
+ { }
+
+ ~MyClass ()
+ { free(s); }
+
+ operator char*&()
+ { return s; }
+
+private:
+ char *s;
+};
+%}
diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i
index 793c0174e..ee8c889e9 100644
--- a/Examples/test-suite/operbool.i
+++ b/Examples/test-suite/operbool.i
@@ -1,6 +1,6 @@
%module operbool
-%rename(operbool) operator bool();
+%rename(operator_bool) operator bool();
%inline %{
class Test {
diff --git a/Examples/test-suite/overload_extend.i b/Examples/test-suite/overload_extend.i
index c32a07f57..acabdd5e8 100644
--- a/Examples/test-suite/overload_extend.i
+++ b/Examples/test-suite/overload_extend.i
@@ -8,11 +8,12 @@
%typemap(default) double y "$1=1000;";
#endif
-#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
-%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) test;
-#endif
-
+#ifdef SWIGLUA
+// lua only has one numeric type, so some overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_PARSE_REDEFINED, SWIGWARN_LANG_OVERLOAD_SHADOW) Foo::test;
+#else
%warnfilter(SWIGWARN_PARSE_REDEFINED) Foo::test;
+#endif
diff --git a/Examples/test-suite/overload_return_type.i b/Examples/test-suite/overload_return_type.i
new file mode 100644
index 000000000..aa387a108
--- /dev/null
+++ b/Examples/test-suite/overload_return_type.i
@@ -0,0 +1,23 @@
+%module overload_return_type
+
+// Regression test for PHP from SF#3168531 (SWIG <= 2.0.1 segfaults).
+
+%inline %{
+
+class A { };
+class B {
+ public:
+ int foo(int x) { return 0; }
+ A foo(const char * y) { return A(); }
+};
+
+// Regression test for PHP from SF#3208299 (there bar()'s return type wa
+// treated as always void).
+
+void foo(int i) {}
+int foo() { return 1; }
+
+int bar() { return 1; }
+void bar(int i) {}
+
+%}
diff --git a/Examples/test-suite/perl5/char_binary_runme.pl b/Examples/test-suite/perl5/char_binary_runme.pl
new file mode 100755
index 000000000..4c50ee700
--- /dev/null
+++ b/Examples/test-suite/perl5/char_binary_runme.pl
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('char_binary') }
+require_ok('char_binary');
+
+my $t = char_binary::Test->new();
+
+is($t->strlen('hile'), 4, "string typemap");
+
+is($t->strlen("hil\0"), 4, "string typemap");
+
+#
+# creating a raw char*
+#
+my $pc = char_binary::new_pchar(5);
+char_binary::pchar_setitem($pc, 0, 'h');
+char_binary::pchar_setitem($pc, 1, 'o');
+char_binary::pchar_setitem($pc, 2, 'l');
+char_binary::pchar_setitem($pc, 3, 'a');
+char_binary::pchar_setitem($pc, 4, 0);
+
+
+is($t->strlen($pc), 4, "string typemap");
+
+$char_binary::var_pchar = $pc;
+is($char_binary::var_pchar, "hola", "pointer case");
+
+$char_binary::var_namet = $pc;
+is($char_binary::var_namet, "hola", "pointer case");
+
+char_binary::delete_pchar($pc);
diff --git a/Examples/test-suite/perl5/primitive_types_runme.pl b/Examples/test-suite/perl5/primitive_types_runme.pl
index 6d7b05d8d..31604ad06 100755
--- a/Examples/test-suite/perl5/primitive_types_runme.pl
+++ b/Examples/test-suite/perl5/primitive_types_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 54;
+use Test::More tests => 51;
BEGIN { use_ok('primitive_types') }
require_ok('primitive_types');
@@ -179,11 +179,6 @@ $t->{var_namet} = 'hol';
is($t->{var_namet}, 'hol', "namet");
-is($t->strlen('hile'), 4, "string typemap");
-
-is($t->strlen("hil\0"), 4, "string typemap");
-
-
$primitive_types::var_char = "\0";
is($primitive_types::var_char, "\0", "char '0' case");
@@ -220,8 +215,6 @@ primitive_types::pchar_setitem($pc, 3, 'a');
primitive_types::pchar_setitem($pc, 4, 0);
-is($t->strlen($pc), 4, "string typemap");
-
$primitive_types::var_pchar = $pc;
is($primitive_types::var_pchar, "hola", "pointer case");
diff --git a/Examples/test-suite/php/Makefile.in b/Examples/test-suite/php/Makefile.in
index 5340751e7..d4f9ac9b5 100644
--- a/Examples/test-suite/php/Makefile.in
+++ b/Examples/test-suite/php/Makefile.in
@@ -50,7 +50,7 @@ missingtests: missingcpptests missingctests
$(MAKE) $*.ctest
@echo ' $(CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.cpptest
- @echo ' $(MULTICPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
+ @echo ' $(MULTI_CPP_TEST_CASES) '|grep -F -v ' $* ' >/dev/null ||\
$(MAKE) $*.multicpptest
# Runs the testcase. Tries to run testcase_runme.php, and if that's not
diff --git a/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php
index 73bcba1fd..9d47ef658 100644
--- a/Examples/test-suite/php/director_protected_runme.php
+++ b/Examples/test-suite/php/director_protected_runme.php
@@ -26,10 +26,17 @@ class FooBar2 extends Bar {
}
}
+class FooBar3 extends Bar {
+ function cheer() {
+ return "FooBar3::cheer();";
+ }
+}
+
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
+$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
@@ -42,7 +49,7 @@ check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
-check::equal($method->isProtected(), true, "Boo::ping should be protected");
+check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
@@ -50,5 +57,17 @@ check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
+$method = new ReflectionMethod('Bar', 'cheer');
+check::equal($method->isProtected(), true, "Bar::cheer should be protected");
+
+$method = new ReflectionMethod('Foo', 'cheer');
+check::equal($method->isProtected(), true, "Foo::cheer should be protected");
+
+check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
+check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
+check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
+check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
+check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
+
check::done();
?>
diff --git a/Examples/test-suite/php/overload_return_type_runme.php b/Examples/test-suite/php/overload_return_type_runme.php
new file mode 100644
index 000000000..4fa19d22a
--- /dev/null
+++ b/Examples/test-suite/php/overload_return_type_runme.php
@@ -0,0 +1,13 @@
+foo(1), 0, "");
+check::classname("A", $b->foo("test"));
+
+check::equal(overload_return_type::foo(), 1, "overload_return_type::foo() should be 1");
+check::equal(overload_return_type::bar(), 1, "overload_return_type::bar() should be 1");
+
+?>
diff --git a/Examples/test-suite/php/pointer_reference_runme.php b/Examples/test-suite/php/pointer_reference_runme.php
index 782760a37..52946177e 100644
--- a/Examples/test-suite/php/pointer_reference_runme.php
+++ b/Examples/test-suite/php/pointer_reference_runme.php
@@ -11,5 +11,8 @@ pointer_reference::set($ss);
$i = Struct::instance();
check::equal($i->value, 20, "pointer_reference::set() failed");
+check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed");
+check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed");
+
check::done();
?>
diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i
index c57a32374..b9e126fd4 100644
--- a/Examples/test-suite/pointer_reference.i
+++ b/Examples/test-suite/pointer_reference.i
@@ -35,6 +35,12 @@ void set(Struct *const& s) {
Struct *const& get() {
return Struct::pInstance;
}
+int overloading(int i) {
+ return 111;
+}
+int overloading(Struct *const& s) {
+ return 222;
+}
%}
%{
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i
index fec4daeba..e052bff28 100644
--- a/Examples/test-suite/preproc.i
+++ b/Examples/test-suite/preproc.i
@@ -6,8 +6,10 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_CONST; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_PROTOTYPES; /* Ruby, wrong constant name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
+%warnfilter(SWIGWARN_RUBY_WRONG_NAME) __GMP_HAVE_TOKEN_PASTE; /* Ruby, wrong constant name */
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
+#pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */
/* check __cplusplus case */
%header
diff --git a/Examples/test-suite/preproc_defined.i b/Examples/test-suite/preproc_defined.i
new file mode 100644
index 000000000..617e84f61
--- /dev/null
+++ b/Examples/test-suite/preproc_defined.i
@@ -0,0 +1,109 @@
+%module preproc_defined
+
+// Check 'defined' passes through the preprocessor without being processed like '#if defined(ABC)' would be (SF bug #1940536)
+
+%define DEFINED_MACRO
+%{
+ int defined(int b) {
+ return b > 10;
+ }
+ int vvv = -1;
+ void fn(int val) {
+ if (defined(val))
+ vvv = 1;
+ else
+ vvv = 0;
+ }
+%}
+%enddef
+
+DEFINED_MACRO
+
+%{
+int checking(void) {
+ int okay;
+ fn(11);
+ okay = (vvv == 1);
+ fn(9);
+ okay = okay && (vvv == 0);
+ return okay; /* should be 1 */
+}
+%}
+
+%inline %{
+int call_checking(void) {
+ return checking();
+}
+%}
+
+/*****************************************************************************/
+/* Check #if/#elif defined() macro expansions
+ Also checks #if/#elif defined() works correctly within macros... this is not
+ standard C, but is now relied on in the SWIG library. */
+/*****************************************************************************/
+
+#define AAA
+#define BBB
+#define CCC
+
+#if defined(AAA)\
+&& defined(BBB) \
+&& defined(CCC)
+%{
+void thing(int i) {}
+void stuff(int i) {}
+struct Defined {
+ int defined;
+};
+void bumpf(int i) {}
+%}
+#else
+#endif
+
+%define ANOTHER_MACRO(TYPE)
+
+#if defined(AAA) && defined(BBB) && defined(CCC)
+void thing(TYPE) {}
+#else
+void thing_not(TYPE) {}
+#endif
+
+#if defined(AAA) &&\
+ defined(BBB) \\
+&& defined(CCC)
+void stuff(TYPE) {}
+#else
+void stuff_not(TYPE);
+#endif
+
+#if defined(0)
+void defined_not(TYPE);
+#elif defined(AAA) && defined( BBB ) && defined(CCC)
+struct Defined {
+ int defined;
+};
+#else
+void defined_not(TYPE);
+#endif
+
+#if !( defined(AAA) \
+ defined(BBB) \\
+&& defined(CCC) )
+void bumpf_not(TYPE);
+#else
+void bumpf(TYPE) {}
+#endif
+
+%enddef
+
+ANOTHER_MACRO(int)
+
+%{
+void another_macro_checking(void) {
+ struct Defined d;
+ d.defined = 10;
+ thing(10);
+ stuff(10);
+ bumpf(10);
+}
+%}
diff --git a/Examples/test-suite/preproc_include.i b/Examples/test-suite/preproc_include.i
new file mode 100644
index 000000000..86c5f71f4
--- /dev/null
+++ b/Examples/test-suite/preproc_include.i
@@ -0,0 +1,37 @@
+%module preproc_include
+
+%{
+#include "preproc_include_a.h"
+#include "preproc_include_b.h"
+int multiply10(int a) { return a*10; }
+int multiply20(int a) { return a*20; }
+int multiply30(int a) { return a*30; }
+int multiply40(int a) { return a*40; }
+int multiply50(int a) { return a*50; }
+%}
+
+#define INCLUDE_B preproc_include_b.h
+#define FILE_INCLUDE(FNAME) #FNAME
+
+%include FILE_INCLUDE(preproc_include_a.h)
+
+// Note that this test uses -includeall, so including preproc_include_b.h also includes preproc_include_c.h
+%include INCLUDE_B
+
+%include"preproc_include_d withspace.h"
+
+#define INCLUDE_E "preproc_include_e withspace.h"
+
+%include INCLUDE_E
+
+%inline %{
+#define INCLUDE_F /*comments*/ "preproc_include_f withspace.h"/*testing*/
+#include INCLUDE_F
+#include /*oooo*/"preproc_include_g.h"/*ahhh*/
+%}
+
+%{
+int multiply60(int a) { return a*60; }
+int multiply70(int a) { return a*70; }
+%}
+
diff --git a/Examples/test-suite/preproc_include_a.h b/Examples/test-suite/preproc_include_a.h
new file mode 100644
index 000000000..b6b55d90d
--- /dev/null
+++ b/Examples/test-suite/preproc_include_a.h
@@ -0,0 +1,3 @@
+
+int multiply10(int a);
+
diff --git a/Examples/test-suite/preproc_include_b.h b/Examples/test-suite/preproc_include_b.h
new file mode 100644
index 000000000..b7cfd530e
--- /dev/null
+++ b/Examples/test-suite/preproc_include_b.h
@@ -0,0 +1,7 @@
+
+int multiply20(int a);
+
+#define PREPROC_INCLUDE_C "preproc_include_c.h"
+
+#include PREPROC_INCLUDE_C
+
diff --git a/Examples/test-suite/preproc_include_c.h b/Examples/test-suite/preproc_include_c.h
new file mode 100644
index 000000000..18f9084a4
--- /dev/null
+++ b/Examples/test-suite/preproc_include_c.h
@@ -0,0 +1,3 @@
+
+int multiply30(int a);
+
diff --git a/Examples/test-suite/preproc_include_d withspace.h b/Examples/test-suite/preproc_include_d withspace.h
new file mode 100644
index 000000000..142ddd507
--- /dev/null
+++ b/Examples/test-suite/preproc_include_d withspace.h
@@ -0,0 +1,3 @@
+
+int multiply40(int a);
+
diff --git a/Examples/test-suite/preproc_include_e withspace.h b/Examples/test-suite/preproc_include_e withspace.h
new file mode 100644
index 000000000..d7497650e
--- /dev/null
+++ b/Examples/test-suite/preproc_include_e withspace.h
@@ -0,0 +1,3 @@
+
+int multiply50(int a);
+
diff --git a/Examples/test-suite/preproc_include_f withspace.h b/Examples/test-suite/preproc_include_f withspace.h
new file mode 100644
index 000000000..8a39a340f
--- /dev/null
+++ b/Examples/test-suite/preproc_include_f withspace.h
@@ -0,0 +1,3 @@
+
+int multiply60(int a);
+
diff --git a/Examples/test-suite/preproc_include_g.h b/Examples/test-suite/preproc_include_g.h
new file mode 100644
index 000000000..db4f9147e
--- /dev/null
+++ b/Examples/test-suite/preproc_include_g.h
@@ -0,0 +1,3 @@
+
+int multiply70(int a);
+
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index 353aa999f..b221b7728 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -33,12 +33,12 @@ const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */
%javaconst(1);
#elif defined(SWIGCSHARP)
%csconst(1);
+#elif defined(SWIGD)
+%dmanifestconst;
#else
%ignore LINE_NUMBER;
%ignore LINE_NUM;
/* spare space */
-
-
#endif
%{
diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
index e00108b93..f912bd77c 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -355,8 +355,6 @@ macro(size_t, pfx, sizet)
%enddef
-%apply (char *STRING, int LENGTH) { (const char *str, size_t len) }
-
%inline {
struct Foo
{
@@ -464,15 +462,8 @@ macro(size_t, pfx, sizet)
%test_prim_types_ovr(ovr_decl, ovr)
- size_t strlen(const char *str, size_t len)
- {
- return len;
- }
-
static const double stc_double;
static const double stc_float;
-
-
};
struct TestDirector
diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i
index 5bda283cf..9e345e2a4 100644
--- a/Examples/test-suite/pure_virtual.i
+++ b/Examples/test-suite/pure_virtual.i
@@ -9,7 +9,8 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
%nodefaultctor C;
%nodefaultdtor C;
@@ -65,7 +66,7 @@ public:
%}
/* Fill in method from AA. This class should be constructable */
-#ifdef SWIGCSHARP
+#if defined(SWIGCSHARP) || defined(SWIGD)
%ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored.
#endif
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index a05542b70..06ae7ef24 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -49,6 +49,7 @@ CPP_TEST_CASES += \
li_implicit \
li_std_vectora \
li_std_vector_extra \
+ li_std_map_member \
li_std_multimap \
li_std_pair_extra \
li_std_set \
@@ -61,6 +62,7 @@ CPP_TEST_CASES += \
python_kwargs \
python_nondynamic \
python_overload_simple_cast \
+ python_richcompare \
std_containers \
swigobject \
template_matrix \
@@ -74,7 +76,8 @@ C_TEST_CASES += \
file_test \
li_cstring \
li_cwstring \
- python_nondynamic
+ python_nondynamic \
+ python_varargs_typemap
#
# This test only works with modern C compilers
@@ -84,6 +87,18 @@ C_TEST_CASES += \
include $(srcdir)/../common.mk
+BUILTIN_BROKEN = \
+ li_std_string_extra.cpptest \
+ li_std_wstring.cpptest \
+ default_constructor.cpptest \
+ director_exception.cpptest \
+ exception_order.cpptest \
+ threads_exception.cpptest
+
+BUILTIN_NOT_BROKEN = $(filter-out $(BUILTIN_BROKEN),$(NOT_BROKEN_TEST_CASES))
+
+builtin-check : $(BUILTIN_NOT_BROKEN)
+
# Overridden variables here
LIBS = -L.
VALGRIND_OPT += --suppressions=pythonswig.supp
diff --git a/Examples/test-suite/python/argcargvtest_runme.py b/Examples/test-suite/python/argcargvtest_runme.py
index 584a19f6e..047ea9551 100644
--- a/Examples/test-suite/python/argcargvtest_runme.py
+++ b/Examples/test-suite/python/argcargvtest_runme.py
@@ -2,16 +2,16 @@ from argcargvtest import *
largs=['hi','hola','hello']
if mainc(largs) != 3:
- raise RuntimeError, "bad main typemap"
+ raise RuntimeError("bad main typemap")
targs=('hi','hola')
if mainv(targs,1) != 'hola':
- print mainv(targs,1)
- raise RuntimeError, "bad main typemap"
+ print(mainv(targs,1))
+ raise RuntimeError("bad main typemap")
targs=('hi', 'hola')
if mainv(targs,1) != 'hola':
- raise RuntimeError, "bad main typemap"
+ raise RuntimeError("bad main typemap")
try:
error = 0
@@ -20,7 +20,7 @@ try:
except TypeError:
pass
if error:
- raise RuntimeError, "bad main typemap"
+ raise RuntimeError("bad main typemap")
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
new file mode 100644
index 000000000..b6d9c81c8
--- /dev/null
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -0,0 +1,36 @@
+from char_binary import *
+
+t = Test()
+if t.strlen('hile') != 4:
+ print t.strlen('hile')
+ raise RuntimeError, "bad multi-arg typemap"
+
+if t.strlen('hil\0') != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+#
+# creating a raw char*
+#
+pc = new_pchar(5)
+pchar_setitem(pc, 0, 'h')
+pchar_setitem(pc, 1, 'o')
+pchar_setitem(pc, 2, 'l')
+pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 4, 0)
+
+
+if t.strlen(pc) != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+cvar.var_pchar = pc
+if cvar.var_pchar != "hola":
+ print cvar.var_pchar
+ raise RuntimeError, "bad pointer case"
+
+cvar.var_namet = pc
+#if cvar.var_namet != "hola\0":
+if cvar.var_namet != "hola":
+ raise RuntimeError, "bad pointer case"
+
+delete_pchar(pc)
+
diff --git a/Examples/test-suite/python/default_arg_values_runme.py b/Examples/test-suite/python/default_arg_values_runme.py
new file mode 100644
index 000000000..44e9a3b5e
--- /dev/null
+++ b/Examples/test-suite/python/default_arg_values_runme.py
@@ -0,0 +1,17 @@
+from default_arg_values import *
+
+d = Display()
+
+if d.draw1() != 0:
+ raise RuntimeError
+
+if d.draw1(12) != 12:
+ raise RuntimeError
+
+p = createPtr(123);
+if d.draw2() != 0:
+ raise RuntimeError
+
+if d.draw2(p) != 123:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/default_constructor_runme.py b/Examples/test-suite/python/default_constructor_runme.py
index 334eaa8af..59b130559 100644
--- a/Examples/test-suite/python/default_constructor_runme.py
+++ b/Examples/test-suite/python/default_constructor_runme.py
@@ -1,3 +1,7 @@
+# This test is expected to fail with -builtin option.
+# It uses the old static syntax (e.g., dc.new_A() rather than dc.A()),
+# which is not provided with the -builtin option.
+
import _default_constructor
dc = _default_constructor
diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py
new file mode 100644
index 000000000..a92ae1c5c
--- /dev/null
+++ b/Examples/test-suite/python/director_alternating_runme.py
@@ -0,0 +1,5 @@
+from director_alternating import *
+
+id = getBar().id()
+if id != idFromGetBar():
+ raise RuntimeError, "Got wrong id: " + str(id)
diff --git a/Examples/test-suite/python/director_exception_runme.py b/Examples/test-suite/python/director_exception_runme.py
index 82be1289b..510845a5a 100644
--- a/Examples/test-suite/python/director_exception_runme.py
+++ b/Examples/test-suite/python/director_exception_runme.py
@@ -66,11 +66,15 @@ except MyException, e:
if not ok:
raise RuntimeError
+# This is expected to fail with -builtin option
+# Throwing builtin classes as exceptions not supported
try:
raise Exception2()
except Exception2:
pass
+# This is expected to fail with -builtin option
+# Throwing builtin classes as exceptions not supported
try:
raise Exception1()
except Exception1:
diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py
index 9d565a1b4..fd3c868a1 100644
--- a/Examples/test-suite/python/director_protected_runme.py
+++ b/Examples/test-suite/python/director_protected_runme.py
@@ -12,11 +12,16 @@ class FooBar2(Bar):
def pang(self):
return "FooBar2::pang();"
+class FooBar3(Bar):
+ def cheer(self):
+ return "FooBar3::cheer();"
+
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
+fb3 = FooBar3()
try:
@@ -66,7 +71,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError,"Boo::ping is protected"
+ raise RuntimeError,"Foo::ping is protected"
protected=1
try:
@@ -86,3 +91,39 @@ except:
pass
if not protected:
raise RuntimeError,"FooBar::pang is protected"
+
+
+protected=1
+try:
+ b.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Bar::cheer is protected"
+
+protected=1
+try:
+ f.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Foo::cheer is protected"
+
+if fb3.cheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3::cheer"
+
+if fb2.callping() != "FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callping"
+
+if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callcheer"
+
+if fb3.callping() != "Bar::ping();":
+ raise RuntimeError, "bad fb3.callping"
+
+if fb3.callcheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3.callcheer"
+
+
diff --git a/Examples/test-suite/python/exception_order_runme.py b/Examples/test-suite/python/exception_order_runme.py
index 0b0b1c08d..38b53eb0c 100644
--- a/Examples/test-suite/python/exception_order_runme.py
+++ b/Examples/test-suite/python/exception_order_runme.py
@@ -1,5 +1,7 @@
from exception_order import *
+# This test is expected to fail with -builtin option.
+# Throwing builtin classes as exceptions not supported
a = A()
diff --git a/Examples/test-suite/python/global_ns_arg_runme.py b/Examples/test-suite/python/global_ns_arg_runme.py
index e597db5f8..cf1915648 100644
--- a/Examples/test-suite/python/global_ns_arg_runme.py
+++ b/Examples/test-suite/python/global_ns_arg_runme.py
@@ -1,5 +1,5 @@
from global_ns_arg import *
a = foo(1)
-b = bar()
+b = bar_fn()
diff --git a/Examples/test-suite/python/grouping_runme.py b/Examples/test-suite/python/grouping_runme.py
index 13f8c8c92..36f9b38de 100644
--- a/Examples/test-suite/python/grouping_runme.py
+++ b/Examples/test-suite/python/grouping_runme.py
@@ -11,3 +11,4 @@ if x != -37:
raise RuntimeError
grouping.cvar.test3 = 42
+grouping.test3 = 42
diff --git a/Examples/test-suite/python/import_stl_runme.py b/Examples/test-suite/python/import_stl_runme.py
new file mode 100644
index 000000000..90c411455
--- /dev/null
+++ b/Examples/test-suite/python/import_stl_runme.py
@@ -0,0 +1,7 @@
+import import_stl_b
+import import_stl_a
+
+v_new = import_stl_b.process_vector([1,2,3])
+if v_new != (1,2,3,4):
+ raise RuntimeError, v_new
+
diff --git a/Examples/test-suite/python/li_std_map_member_runme.py b/Examples/test-suite/python/li_std_map_member_runme.py
new file mode 100644
index 000000000..8b5877dae
--- /dev/null
+++ b/Examples/test-suite/python/li_std_map_member_runme.py
@@ -0,0 +1,11 @@
+import li_std_map_member
+
+a = li_std_map_member.mapita()
+a[1] = li_std_map_member.TestA()
+
+if (a[1].i != 1) :
+ raise RuntimeError("a[1] != 1")
+
+a[1].i = 2
+if (a[1].i != 2) :
+ raise RuntimeError("a[1] != 2")
diff --git a/Examples/test-suite/python/li_std_set_runme.py b/Examples/test-suite/python/li_std_set_runme.py
index 6d8963138..449333e73 100644
--- a/Examples/test-suite/python/li_std_set_runme.py
+++ b/Examples/test-suite/python/li_std_set_runme.py
@@ -92,5 +92,5 @@ sum = ()
for i in s:
sum = sum + (i,)
-if sum != (1, 'hello', (1, 2)):
+if (len(sum) != 3 or (not 1 in sum) or (not 'hello' in sum) or (not (1, 2) in sum)) :
raise RuntimeError
diff --git a/Examples/test-suite/python/li_std_string_extra_runme.py b/Examples/test-suite/python/li_std_string_extra_runme.py
index cef5921b0..9e9e3d2c3 100644
--- a/Examples/test-suite/python/li_std_string_extra_runme.py
+++ b/Examples/test-suite/python/li_std_string_extra_runme.py
@@ -54,9 +54,13 @@ if a + b != "hello world":
if a + " world" != "hello world":
raise RuntimeError, "bad string mapping"
+# This is expected to fail with -builtin option
+# Reverse operators not supported in builtin types
if "hello" + b != "hello world":
raise RuntimeError, "bad string mapping"
+# This is expected to fail with -builtin option
+# Reverse operators not supported in builtin types
c = "hello" + b
if c.find_last_of("l") != 9:
raise RuntimeError, "bad string mapping"
diff --git a/Examples/test-suite/python/li_std_wstring_runme.py b/Examples/test-suite/python/li_std_wstring_runme.py
index a4b9d3ee2..a2d419a0a 100644
--- a/Examples/test-suite/python/li_std_wstring_runme.py
+++ b/Examples/test-suite/python/li_std_wstring_runme.py
@@ -4,21 +4,21 @@ x=u"h"
if li_std_wstring.test_wcvalue(x) != x:
print li_std_wstring.test_wcvalue(x)
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
x=u"hello"
if li_std_wstring.test_ccvalue(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_wstring.test_cvalue(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_wstring.test_value(x) != x:
print x, li_std_wstring.test_value(x)
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_wstring.test_const_reference(x) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
s = li_std_wstring.wstring(u"he")
@@ -26,39 +26,41 @@ s = s + u"llo"
if s != x:
print s, x
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if s[1:4] != x[1:4]:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_wstring.test_value(s) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_wstring.test_const_reference(s) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
a = li_std_wstring.A(s)
if li_std_wstring.test_value(a) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if li_std_wstring.test_const_reference(a) != x:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
b = li_std_wstring.wstring(" world")
if a + b != "hello world":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
if a + " world" != "hello world":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
+# This is expected to fail if -builtin is used
if "hello" + b != "hello world":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
+# This is expected to fail if -builtin is used
c = "hello" + b
if c.find_last_of("l") != 9:
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
s = "hello world"
@@ -66,11 +68,11 @@ b = li_std_wstring.B("hi")
b.name = li_std_wstring.wstring(u"hello")
if b.name != "hello":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
b.a = li_std_wstring.A("hello")
if b.a != u"hello":
- raise RuntimeError, "bad string mapping"
+ raise RuntimeError("bad string mapping")
diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py
new file mode 100644
index 000000000..e1a1a1f4b
--- /dev/null
+++ b/Examples/test-suite/python/pointer_reference_runme.py
@@ -0,0 +1,16 @@
+import pointer_reference
+
+s = pointer_reference.get()
+if s.value != 10:
+ raise RuntimeError, "get test failed"
+
+ss = pointer_reference.Struct(20)
+pointer_reference.set(ss)
+if pointer_reference.cvar.Struct_instance.value != 20:
+ raise RuntimeError, "set test failed"
+
+if pointer_reference.overloading(1) != 111:
+ raise RuntimeError, "overload test 1 failed"
+
+if pointer_reference.overloading(ss) != 222:
+ raise RuntimeError, "overload test 2 failed"
diff --git a/Examples/test-suite/python/preproc_defined_runme.py b/Examples/test-suite/python/preproc_defined_runme.py
new file mode 100644
index 000000000..9a295533a
--- /dev/null
+++ b/Examples/test-suite/python/preproc_defined_runme.py
@@ -0,0 +1,11 @@
+import preproc_defined
+
+if preproc_defined.call_checking() != 1:
+ raise RuntimeError
+
+d = preproc_defined.Defined()
+d.defined = 10
+
+preproc_defined.thing(10)
+preproc_defined.stuff(10)
+preproc_defined.bumpf(10)
diff --git a/Examples/test-suite/python/preproc_include_runme.py b/Examples/test-suite/python/preproc_include_runme.py
new file mode 100644
index 000000000..778de3c87
--- /dev/null
+++ b/Examples/test-suite/python/preproc_include_runme.py
@@ -0,0 +1,23 @@
+import preproc_include
+
+if preproc_include.multiply10(10) != 100:
+ raise RuntimeError
+
+if preproc_include.multiply20(10) != 200:
+ raise RuntimeError
+
+if preproc_include.multiply30(10) != 300:
+ raise RuntimeError
+
+if preproc_include.multiply40(10) != 400:
+ raise RuntimeError
+
+if preproc_include.multiply50(10) != 500:
+ raise RuntimeError
+
+if preproc_include.multiply60(10) != 600:
+ raise RuntimeError
+
+if preproc_include.multiply70(10) != 700:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index 02cc21763..2495cd60d 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -188,14 +188,6 @@ if t.var_namet != 'hol':
raise RuntimeError
-if t.strlen('hile') != 4:
- print t.strlen('hile')
- raise RuntimeError, "bad string typemap"
-
-if t.strlen('hil\0') != 4:
- raise RuntimeError, "bad string typemap"
-
-
cvar.var_char = '\0'
if cvar.var_char != '\0':
raise RuntimeError, "bad char '0' case"
@@ -244,9 +236,6 @@ pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
-if t.strlen(pc) != 4:
- raise RuntimeError, "bad string typemap"
-
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
diff --git a/Examples/test-suite/python/python_abstractbase_runme3.py b/Examples/test-suite/python/python_abstractbase_runme3.py
index e34777558..b7593f109 100644
--- a/Examples/test-suite/python/python_abstractbase_runme3.py
+++ b/Examples/test-suite/python/python_abstractbase_runme3.py
@@ -1,5 +1,9 @@
from python_abstractbase import *
from collections import *
+
+# This is expected to fail with -builtin option
+# Builtin types can't inherit from pure-python abstract bases
+
assert issubclass(Mapii, MutableMapping)
assert issubclass(Multimapii, MutableMapping)
assert issubclass(IntSet, MutableSet)
diff --git a/Examples/test-suite/python/python_nondynamic_runme.py b/Examples/test-suite/python/python_nondynamic_runme.py
index 27755db9c..b860ba0d7 100644
--- a/Examples/test-suite/python/python_nondynamic_runme.py
+++ b/Examples/test-suite/python/python_nondynamic_runme.py
@@ -13,7 +13,6 @@ except:
if not err:
raise RuntimeError, "A is not static"
-
class B(python_nondynamic.A):
c = 4
def __init__(self):
@@ -21,10 +20,19 @@ class B(python_nondynamic.A):
pass
pass
-
-
bb = B()
-bb.c = 3
+
+try:
+ bb.c = 3
+ err = 0
+except:
+ err = 1
+
+if not err:
+ print "bb.c = %d" % bb.c
+ print "B.c = %d" % B.c
+ raise RuntimeError, "B.c class variable messes up nondynamic-ness of B"
+
try:
bb.d = 2
err = 0
@@ -33,7 +41,6 @@ except:
if not err:
raise RuntimeError, "B is not static"
-
cc = python_nondynamic.C()
cc.d = 3
diff --git a/Examples/test-suite/python/python_richcompare_runme.py b/Examples/test-suite/python/python_richcompare_runme.py
new file mode 100644
index 000000000..e077989cc
--- /dev/null
+++ b/Examples/test-suite/python/python_richcompare_runme.py
@@ -0,0 +1,100 @@
+import python_richcompare
+
+base1 = python_richcompare.BaseClass(1)
+base2 = python_richcompare.BaseClass(2)
+base3 = python_richcompare.BaseClass(3)
+a1 = python_richcompare.SubClassA(1)
+a2 = python_richcompare.SubClassA(2)
+a3 = python_richcompare.SubClassA(3)
+b1 = python_richcompare.SubClassB(1)
+b2 = python_richcompare.SubClassB(2)
+b3 = python_richcompare.SubClassB(3)
+
+# Check == and != within a single type
+#-------------------------------------------------------------------------------
+
+if not (base1 == base1) :
+ raise RuntimeError("Object not == to itself")
+
+if not (base1 == python_richcompare.BaseClass(1)) :
+ raise RuntimeError("Object not == to an equivalent object")
+
+if (base1 == base2) :
+ raise RuntimeError("Comparing non-equivalent objects of the same type, == returned True")
+
+if (base1 != base1) :
+ raise RuntimeError("Object is != itself")
+
+if (base1 != python_richcompare.BaseClass(1)) :
+ raise RuntimeError("Object is != an equivalent object")
+
+if not (base1 != base2) :
+ raise RuntimeError("Comparing non-equivalent objects of the same type, != returned False")
+
+
+# Check redefined operator== in SubClassA
+#-------------------------------------------------------------------------------
+
+if (a2 == base2) :
+ raise RuntimeError("Redefined operator== in SubClassA failed")
+
+if (a2 == b2) :
+ raise RuntimeError("Redefined operator== in SubClassA failed")
+
+if not (a1 == a2) :
+ raise RuntimeError("Redefined operator== in SubClassA failed")
+
+# Check up-casting of subclasses
+#-------------------------------------------------------------------------------
+
+if (base2 != a2) :
+ raise RuntimeError("Comparing equivalent base and subclass instances, != returned True")
+
+if (a2 == base2) :
+ raise RuntimeError("Comparing non-equivalent base and subclass instances, == returned True")
+
+if (a1 == b1) :
+ raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True")
+
+if (b1 == a1) :
+ raise RuntimeError("Comparing equivalent instances of different subclasses, == returned True")
+
+# Check inequalities
+#-------------------------------------------------------------------------------
+
+if (a2 > b2) :
+ raise RuntimeError("operator> failed")
+
+if (a2 < b2) :
+ raise RuntimeError("operator< failed")
+
+if not (a2 >= b2) :
+ raise RuntimeError("operator>= failed")
+
+if not (a2 <= b2) :
+ raise RuntimeError("operator<= failed")
+
+# Check inequalities used for ordering
+#-------------------------------------------------------------------------------
+
+x = sorted([a2, a3, a1])
+
+if not (x[0] is a1) :
+ raise RuntimeError("Ordering failed")
+
+if not (x[1] is a2) :
+ raise RuntimeError("Ordering failed")
+
+if not (x[2] is a3) :
+ raise RuntimeError("Ordering failed")
+
+x = sorted([base2, a3, b1])
+
+if not (x[0] is b1) :
+ raise RuntimeError("Ordering failed")
+
+if not (x[1] is base2) :
+ raise RuntimeError("Ordering failed")
+
+if not (x[2] is a3) :
+ raise RuntimeError("Ordering failed")
diff --git a/Examples/test-suite/python/python_varargs_typemap_runme.py b/Examples/test-suite/python/python_varargs_typemap_runme.py
new file mode 100644
index 000000000..3c3f042eb
--- /dev/null
+++ b/Examples/test-suite/python/python_varargs_typemap_runme.py
@@ -0,0 +1,4 @@
+import python_varargs_typemap
+
+if (python_varargs_typemap.testfunc(1, 2.0, "three") != "three") :
+ raise RuntimeError("testfunc failed!")
diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py
index ed7ca48b1..1186703a0 100644
--- a/Examples/test-suite/python/rename_pcre_encoder_runme.py
+++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py
@@ -2,6 +2,9 @@ from rename_pcre_encoder import *
s = SomeWidget()
s.putBorderWidth(3)
+if s.getBorderWidth() != 3:
+ raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),))
+
s.putSize(4, 5)
a = AnotherWidget()
a.DoSomething()
diff --git a/Examples/test-suite/python/threads_exception_runme.py b/Examples/test-suite/python/threads_exception_runme.py
index 9fbc6a9b2..f9b0fddc0 100644
--- a/Examples/test-suite/python/threads_exception_runme.py
+++ b/Examples/test-suite/python/threads_exception_runme.py
@@ -18,6 +18,8 @@ except RuntimeError,e:
if e.args[0] != "I died.":
raise RuntimeError
+# This is expected fail with -builtin option
+# Throwing builtin classes as exceptions not supported
try:
t.hosed()
except threads_exception.Exc,e:
diff --git a/Examples/test-suite/python/typemap_arrays_runme.py b/Examples/test-suite/python/typemap_arrays_runme.py
new file mode 100644
index 000000000..c23222c63
--- /dev/null
+++ b/Examples/test-suite/python/typemap_arrays_runme.py
@@ -0,0 +1,5 @@
+from typemap_arrays import *
+
+if sumA(None) != 60:
+ raise RuntimeError, "Sum is wrong"
+
diff --git a/Examples/test-suite/python/varargs_overload_runme.py b/Examples/test-suite/python/varargs_overload_runme.py
new file mode 100644
index 000000000..a3b2068b5
--- /dev/null
+++ b/Examples/test-suite/python/varargs_overload_runme.py
@@ -0,0 +1,31 @@
+import varargs_overload
+
+if varargs_overload.vararg_over1("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs_overload.vararg_over1(2) != "2":
+ raise RuntimeError, "Failed"
+
+
+if varargs_overload.vararg_over2("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs_overload.vararg_over2(2, 2.2) != "2 2.2":
+ raise RuntimeError, "Failed"
+
+
+if varargs_overload.vararg_over3("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs_overload.vararg_over3(2, 2.2, "hey") != "2 2.2 hey":
+ raise RuntimeError, "Failed"
+
+if varargs_overload.vararg_over4("Hello") != "Hello":
+ raise RuntimeError, "Failed"
+
+if varargs_overload.vararg_over4(123) != "123":
+ raise RuntimeError, "Failed"
+
+if varargs_overload.vararg_over4("Hello", 123) != "Hello":
+ raise RuntimeError, "Failed"
+
diff --git a/Examples/test-suite/python_richcompare.i b/Examples/test-suite/python_richcompare.i
new file mode 100644
index 000000000..142d0594b
--- /dev/null
+++ b/Examples/test-suite/python_richcompare.i
@@ -0,0 +1,60 @@
+/* Test the tp_richcompare functions generated with the -builtin option */
+
+%module python_richcompare
+
+%inline {
+
+class BaseClass {
+public:
+ BaseClass (int i_) : i(i_) {}
+ ~BaseClass () {}
+
+ int getValue () const
+ { return i; }
+
+ bool operator< (const BaseClass& x) const
+ { return this->i < x.i; }
+
+ bool operator> (const BaseClass& x) const
+ { return this->i > x.i; }
+
+ bool operator<= (const BaseClass& x) const
+ { return this->i <= x.i; }
+
+ bool operator>= (const BaseClass& x) const
+ { return this->i >= x.i; }
+
+ bool operator== (const BaseClass& x) const
+ { return this->i == x.i; }
+
+ bool operator!= (const BaseClass& x) const
+ { return this->i != x.i; }
+
+ int i;
+};
+
+class SubClassA : public BaseClass {
+public:
+ SubClassA (int i_) : BaseClass(i_) {}
+ ~SubClassA () {}
+
+ bool operator== (const SubClassA& x) const
+ { return true; }
+
+ bool operator== (const BaseClass& x) const
+ { return false; }
+};
+
+class SubClassB : public BaseClass {
+public:
+ SubClassB (int i_) : BaseClass(i_) {}
+ ~SubClassB () {}
+
+ bool operator== (const SubClassB& x) const
+ { return true; }
+
+ bool operator== (const SubClassA& x) const
+ { return false; }
+};
+
+}
diff --git a/Examples/test-suite/python_varargs_typemap.i b/Examples/test-suite/python_varargs_typemap.i
new file mode 100644
index 000000000..3fdf8d4d5
--- /dev/null
+++ b/Examples/test-suite/python_varargs_typemap.i
@@ -0,0 +1,43 @@
+%module python_varargs_typemap
+
+ /* The typemap and action are taken from the "Variable length arguments"
+ * chapter of the SWIG manual.
+ */
+
+%typemap(in) (...)(char *args[10]) {
+ int i;
+ int argc;
+ for (i = 0; i < 10; i++) args[i] = 0;
+ argc = PyTuple_Size(varargs);
+ if (argc > 10) {
+ PyErr_SetString(PyExc_ValueError,"Too many arguments");
+ return NULL;
+ }
+ for (i = 0; i < argc; i++) {
+ PyObject *o = PyTuple_GetItem(varargs,i);
+ if (!PyString_Check(o)) {
+ PyErr_SetString(PyExc_ValueError,"Expected a string");
+ return NULL;
+ }
+ args[i] = PyString_AsString(o);
+ }
+ $1 = (void *) args;
+}
+
+%feature("action") testfunc {
+ char **args = (char **) arg3;
+ result = testfunc(arg1, arg2, args[0], args[1], args[2], args[3], args[4],
+ args[5],args[6],args[7],args[8],args[9], NULL);
+}
+
+%inline {
+char* testfunc (int arg1, double arg2, ...)
+{
+ va_list ap;
+ char *c;
+ va_start(ap, arg2);
+ c = va_arg(ap, char*);
+ va_end(ap);
+ return c;
+}
+}
diff --git a/Examples/test-suite/r/rename_simple_runme.R b/Examples/test-suite/r/rename_simple_runme.R
new file mode 100644
index 000000000..b25aeb844
--- /dev/null
+++ b/Examples/test-suite/r/rename_simple_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep=""))
+source("rename_simple.R")
+cacheMetaData(1)
+
+s <- NewStruct();
+unittest(111, s$NewInstanceVariable)
+unittest(222, s$NewInstanceMethod())
+unittest(333, NewStruct_NewStaticMethod())
+unittest(444, NewStruct_NewStaticVariable())
+unittest(555, NewFunction())
+unittest(666, NewGlobalVariable())
+
+s$NewInstanceVariable <- 1111
+NewStruct_NewStaticVariable(4444)
+NewGlobalVariable(6666)
+
+unittest(1111, s$NewInstanceVariable)
+unittest(4444, NewStruct_NewStaticVariable())
+unittest(6666, NewGlobalVariable())
diff --git a/Examples/test-suite/r/unittest.R b/Examples/test-suite/r/unittest.R
index 81c590a3f..0633c7715 100644
--- a/Examples/test-suite/r/unittest.R
+++ b/Examples/test-suite/r/unittest.R
@@ -1,9 +1,17 @@
unittest <- function (x,y) {
-if (x==y) print("PASS")
-else print("FAIL")
+ if (x==y) {
+ print("PASS")
+ } else {
+ print("FAIL")
+ stop("Test failed")
+ }
}
unittesttol <- function(x,y,z) {
-if (abs(x-y) < z) print("PASS")
-else print("FAIL")
-}
\ No newline at end of file
+ if (abs(x-y) < z) {
+ print("PASS")
+ } else {
+ print("FAIL")
+ stop("Test failed")
+ }
+}
diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i
index c90af164d..66f30c7bc 100644
--- a/Examples/test-suite/rename_pcre_encoder.i
+++ b/Examples/test-suite/rename_pcre_encoder.i
@@ -3,14 +3,19 @@
// strip the wx prefix from all identifiers except those starting with wxEVT
%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") "";
-// Replace "Set" prefix with "put" in all functions
+// Replace "Set" and "Get" prefixes with "put" and "get" respectively.
%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) "";
+%rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) "";
%inline %{
struct wxSomeWidget {
- void SetBorderWidth(int) {}
+ void SetBorderWidth(int width) { m_width = width; }
+ int GetBorderWidth() const { return m_width; }
+
void SetSize(int, int) {}
+
+ int m_width;
};
struct wxAnotherWidget {
diff --git a/Examples/test-suite/rename_simple.i b/Examples/test-suite/rename_simple.i
new file mode 100644
index 000000000..feba53fa1
--- /dev/null
+++ b/Examples/test-suite/rename_simple.i
@@ -0,0 +1,24 @@
+%module rename_simple
+
+%rename(NewStruct) OldStruct;
+%rename(NewVariable) OldVariable;
+%rename(NewInstanceMethod) OldInstanceMethod;
+%rename(NewInstanceVariable) OldInstanceVariable;
+%rename(NewStaticMethod) OldStaticMethod;
+%rename(NewStaticVariable) OldStaticVariable;
+%rename(NewFunction) OldFunction;
+%rename(NewGlobalVariable) OldGlobalVariable;
+
+%inline %{
+struct OldStruct {
+ OldStruct() : OldInstanceVariable(111) {}
+ int OldInstanceVariable;
+ int OldInstanceMethod() { return 222; }
+ static int OldStaticVariable;
+ static int OldStaticMethod() { return 333; }
+};
+int OldStruct::OldStaticVariable = 444;
+
+int OldFunction() { return 555; }
+int OldGlobalVariable = 666;
+%}
diff --git a/Examples/test-suite/restrict_cplusplus.i b/Examples/test-suite/restrict_cplusplus.i
index 4e4bfc277..62abffa52 100644
--- a/Examples/test-suite/restrict_cplusplus.i
+++ b/Examples/test-suite/restrict_cplusplus.i
@@ -1,7 +1,15 @@
%module restrict_cplusplus
-%inline %{
+%{
+// For PHP 5.3 / gcc-4.4
+#ifdef restrict
+#undef restrict
+#endif
struct Foo {
int restrict;
};
%}
+
+struct Foo {
+ int restrict;
+};
diff --git a/Examples/test-suite/rname.i b/Examples/test-suite/rname.i
index 31b99833d..09d6e3e3b 100644
--- a/Examples/test-suite/rname.i
+++ b/Examples/test-suite/rname.i
@@ -15,19 +15,14 @@
%rename(foo_u) *::foo(unsigned);
/* Rename classes in a class hierarchy */
-%rename (RenamedBase) Base;
-%rename (RenamedDerived) Derived;
+%rename (RenamedBase) Space::Base;
+%rename (RenamedDerived) Space::Derived;
/* Rename base class method applies to derived classes too */#
-%rename (newname) Base::oldname(double d) const;
+%rename (newname) Space::Base::oldname(double d) const;
/* Rename derived class method only */
-#ifndef SWIGGO
-%rename (func) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
-#else
-/* func is a keyword in Go. */
-%rename (Xfunc) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
-#endif
+%rename (Xfunc) Space::Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
%inline %{
class Bar {
@@ -43,20 +38,22 @@ char *foo(double) { return (char *) "foo-double"; }
char *foo(short) { return (char *) "foo-short"; }
char *foo(unsigned) { return (char *) "foo-unsigned"; }
+namespace Space {
class Base {
public:
Base(){};
virtual ~Base(){};
void fn(Base baseValue, Base* basePtr, Base& baseRef){}
- virtual const char * oldname(double d) const { return (char*) "Base"; }
+ virtual const char * oldname(double d) const { return "Base"; }
};
class Derived : public Base {
public:
Derived(){}
~Derived(){}
void fn(Base baseValue, Base* basePtr, Base& baseRef){}
- virtual const char * oldname(double d) const { return (char*) "Derived"; }
+ virtual const char * oldname(double d) const { return "Derived"; }
};
+}
%}
diff --git a/Examples/test-suite/samename.i b/Examples/test-suite/samename.i
index 819cb4abd..cc03995bc 100644
--- a/Examples/test-suite/samename.i
+++ b/Examples/test-suite/samename.i
@@ -1,6 +1,6 @@
%module samename
-#if !(defined(SWIGCSHARP) || defined(SWIGJAVA))
+#if !(defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGD))
class samename {
public:
void do_something() {
diff --git a/Examples/test-suite/smart_pointer_not.i b/Examples/test-suite/smart_pointer_not.i
index 712aa48fb..a02478bae 100644
--- a/Examples/test-suite/smart_pointer_not.i
+++ b/Examples/test-suite/smart_pointer_not.i
@@ -1,6 +1,12 @@
// Test cases for classes that do *NOT* result in smart-pointer wrapping
%module smart_pointer_not
+%{
+#if defined(__SUNPRO_CC)
+#pragma error_messages (off, arrowrtn) /* Questionable return type for ... */
+#endif
+%}
+
%inline %{
struct Foo {
int x;
diff --git a/Examples/test-suite/smart_pointer_template_const_overload.i b/Examples/test-suite/smart_pointer_template_const_overload.i
new file mode 100644
index 000000000..831e3f2fe
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_template_const_overload.i
@@ -0,0 +1,37 @@
+%module smart_pointer_template_const_overload
+
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) SmartPointer::operator->; // Overloaded method SmartPointer< FooImplementation >::operator ->() ignored
+
+%inline %{
+ template class SmartPointer {
+ T *ptr;
+ public:
+ SmartPointer(T *t = 0) : ptr(t) {}
+ inline const T * operator->() const { return ptr; }
+ inline T * operator->() { return ptr; }
+ };
+
+ class FooImplementation {
+ public:
+ int mingy() { return 0; }
+ int constmingy() const { return 0; }
+ static int thingy() { return 0; }
+ static int svariable;
+ static const int constsvariable;
+ int normalvariable;
+ };
+ int FooImplementation::svariable = 0;
+ const int FooImplementation::constsvariable = 2;
+
+ void tester() {
+ SmartPointer p;
+ p->mingy();
+ p->constmingy();
+ p->thingy();
+ int a = p->svariable;
+ a = p->constsvariable;
+ a = p->normalvariable;
+ }
+%}
+
+%template(FooSmartPointer) SmartPointer;
diff --git a/Examples/test-suite/smart_pointer_templatemethods.i b/Examples/test-suite/smart_pointer_templatemethods.i
index 7baa6386a..f79bbcc9d 100644
--- a/Examples/test-suite/smart_pointer_templatemethods.i
+++ b/Examples/test-suite/smart_pointer_templatemethods.i
@@ -1,4 +1,3 @@
-
%module smart_pointer_templatemethods
%inline %{
@@ -29,21 +28,21 @@ public:
void DisposeObjekt (void) {}
};
-class Object
+class Objct
{
public:
- Object () {}
- virtual ~Object () {}
+ Objct () {}
+ virtual ~Objct () {}
template Ptr QueryInterface (InterfaceId iid) const { return Ptr(); }
- void DisposeObject (void) {}
+ void DisposeObjct (void) {}
};
#ifdef SWIG
-%template(PtrObject) Ptr