diff --git a/CHANGES.current b/CHANGES.current
index 3fab761b8..5bd6e6910 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -5,6 +5,384 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 2.0.5 (in progress)
===========================
+2012-01-24: wsfulton
+ Fix crash with bad regex - bug #3474250.
+
+2012-01-24: wsfulton
+ [Python] Add Python stepped slicing support to the STL wrappers (std::vector, std::list).
+ Assigning to a slice, reading a slice and deleting a slice with steps now work.
+ For example:
+
+ %template(vector_i) std::vector
+
+ vi = vector_i(range(10))
+ print list(vi)
+ vi[1:4:2] = [111, 333]
+ print list(vi)
+ del vi[3:10:3]
+ print list(vi)
+ print list(vi[::-1])
+
+ gives (same behaviour as native Python sequences such as list):
+
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
+ [0, 111, 2, 333, 4, 5, 6, 7, 8, 9]
+ [0, 111, 2, 4, 5, 7, 8]
+ [8, 7, 5, 4, 2, 111, 0]
+
+2012-01-23: klickverbot
+ [D] Correctly annotate function pointers with C linkage.
+ [D] Exception and Error have become blessed names; removed d_exception_name test case.
+
+2012-01-20: wsfulton
+ [Python] Fix some indexing bugs in Python STL wrappers when the index is negative, eg:
+
+ %template(vector_i) std::vector
+
+ iv=vector_i([0,1,2,3,4,5])
+ iv[-7:]
+
+ now returns [0, 1, 2, 3, 4, 5] instead of [5].
+
+ vv[7:9] = [22,33]
+
+ now returns [0, 1, 2, 3, 4, 5, 22, 33] instead of "index out range" error.
+
+ Also fix some segfaults when replacing ranges, eg when il is a std::list wrapper:
+
+ il[0:2] = [11]
+
+2012-01-17: wsfulton
+ [Go] Fix forward class declaration within a class when used as a base.
+
+2012-01-07: wsfulton
+ [C#] Add support for %nspace when using directors.
+
+2012-01-06: wsfulton
+ [Java] Patch #3452560 from Brant Kyser - add support for %nspace when using directors.
+
+2011-12-21: wsfulton
+ The 'directorin' typemap now accepts $1, $2 etc expansions instead of having to use workarounds -
+ $1_name, $2_name etc.
+
+2011-12-20: wsfulton
+ [Java] Add (char *STRING, size_t LENGTH) director typemaps.
+
+2011-12-20: wsfulton
+ [C#, Go, Java, D] Add support for the 'directorargout' typemap.
+
+2011-12-20: wsfulton
+ [Ocaml, Octave, PHP, Python, Ruby] Correct special variables in 'directorargout' typemap.
+ This change will break any 'directorargout' typemaps you may have written. Please change:
+ $result to $1
+ $input to $result
+
+ Also fix the named 'directorargout' DIRECTOROUT typemaps for these languages which didn't
+ previously compile and add in $1, $2 etc expansion.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2011-12-10: talby
+ [perl5] SWIG_error() now gets decorated with perl source file/line number.
+ [perl5] error handling now conforms to public XS api (fixes perl v5.14 issue).
+
+2011-12-10: wsfulton
+ [Android/Java] Fix directors to compile on Android.
+
+ Added documentation and examples for Android.
+
+2011-12-08: vadz
+ Bug fix: Handle methods renamed or ignored in the base class correctly in the derived classes
+ (they could be sometimes mysteriously not renamed or ignored there before).
+
+2011-12-03: klickverbot
+ [D] Fix exception glue code for newer DMD 2 versions.
+ [D] Do not default to 32 bit glue code for DMD anymore.
+ [D] Use stdc.config.c_long/c_ulong to represent C long types.
+
+2011-12-01: szager
+ [python] Fixed bug 3447426: memory leak in vector.__getitem__.
+
+2011-11-30: wsfulton
+ [R] Remove C++ comments from generated C code.
+
+2011-11-27: olly
+ [Python] Fix some warnings when compiling generated wrappers with
+ certain GCC warning options (Debian bug #650246).
+
+2011-11-28: wsfulton
+ Fix #3433541 %typemap(in, numinputs=0) with 10+ arguments.
+
+2011-11-28: olly
+ [Perl] Fix warnings when compiling generated wrappers with certain
+ GCC warning options (Debian bug #436711).
+
+2011-11-28: olly
+ [PHP] Update keyword list to include keywords added in PHP releases up to 5.3.
+
+2011-11-25: wsfulton
+ [C#] Provide an easy way to override the default visibility for the proxy class pointer
+ constructors and getCPtr() method. The visibility is 'internal' by default and if multiple
+ SWIG modules are being used and compiled into different assemblies, then they need to be
+ 'public' in order to use the constructor or getCPtr() method from a different assembly.
+ Use the following macros to change the visibilities in the proxy and type wrapper class:
+
+ SWIG_CSBODY_PROXY(public, public, SWIGTYPE)
+ SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
+
+ [Java] Provide an easy way to override the default visibility for the proxy class pointer
+ constructors and getCPtr() method. The visibility is 'protected' by default and if multiple
+ SWIG modules are being used and compiled into different packages, then they need to be
+ 'public' in order to use the constructor or getCPtr() method from a different package.
+ Use the following macros to change the visibilities in the proxy and type wrapper class:
+
+ SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
+ SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
+
+ The default for Java has changed from public to protected for the proxy classes. Use the
+ SWIG_JAVABODY_PROXY macro above to restore to the previous visibilities.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2011-11-22: szager
+ [python] Bug 3440044: #ifdef out SWIG_Python_NonDynamicSetAttr if -builtin
+ isn't being used, to avoid unnecessary binary incompatibilities between
+ python installations.
+
+2011-11-17: wsfulton
+ Bug fix: Remove root directory from directory search list in Windows.
+
+2011-11-13: wsfulton
+ [Ruby] Apply patch #3421876 from Robin Stocker to fix #3416818 - same class name in
+ different namespaces confusion when using multiple modules.
+
+2011-11-11: wsfulton
+ Fix pcre-build.sh to work with non-compressed tarballs - problem reported by Adrian Blakely.
+
+2011-11-04: szager
+ [python] Bug 3429388: python unsigned integer handling on 32-bit architectures.
+
+2011-11-03: wsfulton
+ Expand special variables in typemap warnings, eg:
+
+ %typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name") int "..."
+
+2011-11-01: wsfulton
+ Fix named output typemaps not being used when the symbol uses a qualifier and contains
+ a number, eg:
+
+ %typemap(out) double ABC::m1 "..."
+
+2011-10-24: talby
+ [perl5] SF bug #3423119 - overload dispatch stack corruption fix. Better, but more research
+ is needed on a stable path for tail calls in XS.
+
+ Also, fix for large long longs in 32 bit perl.
+
+2011-10-13: xavier98
+ [octave] Allow Octave modules to be re-loaded after a "clear all".
+
+2011-09-19: wsfulton
+ Fix regression introduced in swig-2.0.1 reported by Teemu Ikonone leading to uncompilable code
+ when using typedef and function pointer references, for example:
+
+ typedef int FN(const int &a, int b);
+ void *typedef_call1(FN *& precallback, FN * postcallback);
+
+2011-09-14: wsfulton
+ [Lua] Patch #3408012 from Raman Gopalan - add support for embedded Lua (eLua)
+ including options for targeting Lua Tiny RAM (LTR).
+
+2011-09-14: wsfulton
+ [C#] Add boost_intrusive_ptr.i library contribution from patch #3401571.
+
+2011-09-13: wsfulton
+ Add warnings for badly named destructors, eg:
+
+ struct KStruct {
+ ~NOT_KStruct() {}
+ };
+
+ cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored.
+
+2011-09-13: wsfulton
+ Fix %extend and destructors for templates. The destructor in %extend was not always wrapped,
+ for example:
+
+ %extend FooT {
+ ~FooT() { delete $self; } // was not wrapped as expected
+ };
+ template class FooT {};
+ %template(FooTi) FooT;
+
+2011-09-13: wsfulton
+ Fix special variables such as "$decl" and "$fulldecl" in destructors to include the ~ character.
+
+2011-09-10: talby
+ [perl5] SF bug #1481958 - Improve range checking for integer types.
+ Enhance li_typemaps_runme.pl
+
+2011-09-08: wsfulton
+ Fix %extend on typedef classes in a namespace using the typedef name, for example:
+ namespace Space {
+ %extend CStruct {
+ ...
+ }
+ typedef struct tagCStruct { ... } CStruct;
+ }
+
+2011-08-31: xavier98
+ [octave] patches from Karl Wette: improvements to module loading behavior;
+ added example of friend operator to operator example; fixed octave panic/crash in 3.0.5;
+ documentation improvements
+
+2011-08-30: szager
+ [python] Bug 3400486, fix error signalling for built-in constructors.
+
+2011-08-26: wsfulton
+ [Go] Fix file/line number display for "gotype" when using typemap debugging options
+ -tmsearch and -tmused.
+
+2011-08-26: wsfulton
+ [C#, D] Fix %callback which was generating uncompileable code.
+
+2011-08-25: wsfulton
+ Fix constructors in named typedef class declarations as reported by Gregory Bronner:
+
+ typedef struct A {
+ A(){} // Constructor which was not accepted by SWIG
+ B(){} // NOT a constructor --illegal, but was accepted by SWIG
+ } B;
+
+ For C code, the fix now results in the use of 'struct A *' instead of just 'B *' in
+ the generated code when wrapping members in A, but ultimately this does not matter, as
+ they are the same thing.
+
+2011-08-23: wsfulton
+ Fix %newobject when used in conjunction with %feature("ref") as reported by Jan Becker. The
+ code from the "ref" feature was not always being generated for the function specified by %newobject.
+ Documentation for "ref" and "unref" moved from Python to the C++ chapter.
+
+2011-08-22: szager
+ [python] Fixed memory leak with --builtin option (bug 3385089).
+
+2011-08-22: wsfulton
+ [Lua] SF patch #3394339 from Torsten Landschoff - new option -nomoduleglobal to disable installing
+ the module table into the global namespace. Require call also returns the module table instead
+ of a string.
+
+2011-08-12: wsfulton
+ SF bug # 3333549 - %shared_ptr fixes when the type is a template using template parameters
+ that are typedef'd to another type.
+
+ Also fixed %shared_ptr when template parameters have default values.
+
+2011-08-09: xavier98
+ Fix bug 3387394; Octave patches for 3.4.0 compatibility, etc. (from Karl Wette)
+
+2011-08-04: wsfulton
+ Add in $symname expansion for director methods.
+
+2011-07-29: olly
+ [PHP] Don't generate "return $r;" in cases where $r hasn't been set.
+ This was basically harmless, except it generated a PHP E_NOTICE if
+ the calling code had enabled them.
+
+2011-07-26: wsfulton
+ Fix scoping of forward class declarations nested within a class (for C++). Previously the symbol
+ was incorrectly put into the outer namespace, eg
+
+ namespace std {
+ template struct map {
+ class iterator;
+ }
+ }
+
+ iterator was scoped as std::iterator, but now it is correctly std::map::iterator;
+
+ Also fixed is %template and template parameters that are a typedef when the template contains
+ default template parameters, eg:
+
+ namespace Std {
+ template struct Map {
+ typedef Key key_type;
+ typedef T mapped_type;
+ }
+ }
+ tyepdef double DOUBLE;
+ %typemap(MM) Std::Map;
+
+ All symbols within Map will be resolved correctly, eg key_type and mapped_type no matter if the
+ wrapped code uses Std::Map or std::Map or Std::Map
+
+ Also fixes bug #3378145 - regression introduced in 2.0.4 - %template using traits.
+
+2011-07-20 szager
+ [python] Fix closure for tp_call slot.
+
+2011-07-16: wsfulton
+ [python] Fix director typemap using PyObject *.
+
+2011-07-13: szager
+ [python] SF patch #3365908 - Add all template parameters to map support code in std_map.i
+
+2011-07-13: szager
+ [python] Fix for bug 3324753: %rename member variables with -builtin.
+
+2011-07-01: wsfulton
+ Fix some scope and symbol lookup problems when template default parameters are being
+ used with typedef. For example:
+
+ template struct Foo {
+ typedef XX X;
+ typedef TT T;
+ };
+ template struct UsesFoo {
+ void x(typename Foo::T, typename Foo::X);
+ };
+
+ Also fixes use of std::vector::size_type for Python as reported by Aubrey Barnard.
+
+2011-06-23: olly
+ [PHP] Fix director code to work when PHP is built with ZTS enabled,
+ which is the standard configuration on Microsoft Windows.
+
+2011-06-21: mutandiz
+ [allegrocl]
+ - various small tweaks and bug fixes.
+ - Avoid name conflicts between smart pointer wrappers and the wrappers for
+ the actual class.
+ - Fix default typemaps for C bindings, which were incorrectly attempting to
+ call non-existent destructors on user-defined types.
+ - New feature, feature:aclmixins, for adding superclass to the foreign class
+ wrappers.
+ - Improve longlong typemaps.
+
+2011-06-19: wsfulton
+ Fix incorrect typemaps being used for a symbol within a templated type, eg:
+ A::value_type would incorrectly use a typemap for type A.
+
+2011-06-18: olly
+ [Tcl] Fix variable declarations in middle of blocks which isn't
+ permitted in C90 (issue probably introduced in 2.0.3 by patch #3224663).
+ Reported by Paul Obermeier in SF#3288586.
+
+2011-06-17: wsfulton
+ [Java] SF #3312505 - slightly easier to wrap char[] or char[ANY] with a Java byte[]
+ using arrays_java.i.
+
+2011-06-13: wsfulton
+ [Ruby, Octave] SF #3310528 Autodoc fixes similar to those described below for Python.
+
+2011-06-10: wsfulton
+ [Python] Few subtle bugfixes in autodoc documentation generation,
+ - Unnamed argument names fix for autodoc levels > 0.
+ - Display of template types fixed for autodoc levels > 1.
+ - Fix SF #3310528 - display of typedef structs for autodoc levels > 1.
+ - Add missing type for self for autodoc levels 1 and 3.
+ - autodoc levels 2 and 3 documented.
+ - Minor tweaks to autodoc style to conform with PEP8.
+
2011-05-30: olly
[PHP] Fix handling of directors when -prefix is used.
diff --git a/COPYRIGHT b/COPYRIGHT
index 855425431..e86a994fa 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -54,6 +54,7 @@ Past SWIG developers and major contributors include:
Duncan Temple Lang (R)
Miklos Vajna (PHP directors)
Mark Gossage (mark@gossage.cjb.net) (Lua)
+ Raman Gopalan (ramangopalan@gmail.com) (eLua)
Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
Baozeng Ding (Scilab)
diff --git a/Doc/Manual/Android.html b/Doc/Manual/Android.html
new file mode 100644
index 000000000..443d77691
--- /dev/null
+++ b/Doc/Manual/Android.html
@@ -0,0 +1,749 @@
+
+
+
+SWIG and Android
+
+
+
+
+This chapter describes SWIG's support of Android.
+
+
+
+
+
18.1 Overview
+
+
+
+The Android chapter is fairly short as support for Android is the same as for Java, where the Java Native Interface (JNI) is
+used to call from Android Java into C or C++ compiled code.
+Everything in the Java chapter applies to generating code for access from Android Java code.
+This chapter contains a few Android specific notes and examples.
+
+
+
18.2 Android examples
+
+
+
18.2.1 Examples introduction
+
+
+
+The examples require the the Android SDK and Android NDK which can be installed as per instructions in the links.
+The Eclipse version is not required for these examples as just the command line tools are used (shown for Linux as the host, but Windows will be very similar, if not identical in most places).
+Add the SDK tools and NDK tools to your path and create a directory somewhere for your Android projects (adjust PATH as necessary to where you installed the tools):
+
+
+
+
+$ export PATH=$HOME/android/android-sdk-linux_x86/tools:$HOME/android/android-sdk-linux_x86/platform-tools:$HOME/android/android-ndk-r6b:$PATH
+$ mkdir AndroidApps
+$ cd AnrdoidApps
+
+
+
+
+The examples use a target id of 1. This might need changing depending on your setup.
+After installation of the Android SDK, the available target ids can be viewed by running the command below.
+Please adjust the id to suit your target device.
+
+
+
+
+$ android list targets
+
+
+
+
+The following examples are shipped with SWIG under the Examples/android directory and include a Makefile to build and install each example.
+
+
+
18.2.2 Simple C example
+
+
+
+This simple C example shows how to call a C function as well as read and modify a global variable.
+First we'll create and build a pure Java Android app. Afterwards the JNI code will be generated by SWIG and built into the app.
+First create and build an app called SwigSimple in a subdirectory called simple using the commands below.
+Adjust the --target id as mentioned earlier in the Examples introduction.
+Managing Projects from the Command Line on the Android developer's site is a useful reference for these steps.
+
+Modify src/org/swig/simple/SwigSimple.java from the default to:
+
+
+
+
+package org.swig.simple;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.text.method.ScrollingMovementMethod;
+
+public class SwigSimple extends Activity
+{
+ TextView outputText = null;
+ ScrollView scroller = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ outputText = (TextView)findViewById(R.id.OutputText);
+ outputText.setText("Press 'Run' to start...\n");
+ outputText.setMovementMethod(new ScrollingMovementMethod());
+
+ scroller = (ScrollView)findViewById(R.id.Scroller);
+ }
+
+ public void onRunButtonClick(View view)
+ {
+ outputText.append("Started...\n");
+ nativeCall();
+ outputText.append("Finished!\n");
+
+ // Ensure scroll to end of text
+ scroller.post(new Runnable() {
+ public void run() {
+ scroller.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ });
+ }
+
+ /** Calls into C/C++ code */
+ public void nativeCall()
+ {
+ // TODO
+ }
+}
+
+
+
+
+The above simply adds a Run button and scrollable text view as the GUI aspects of the program.
+The associated resources need to be created, modify res/layout/main.xml as follows:
+
+Although there are no native function calls in the code, yet, you may want to check that this simple pure
+Java app runs before adding in the native calls.
+First, set up your Android device for hardware debugging, see Using hardware devices on the Android developer's site.
+When complete your device should be listed in those attached, something like:
+
+
+
+
+$ adb devices
+List of devices attached
+A32-6DBE0001-9FF80000-015D62C3-02018028 device
+
+
+
+
+This means you are now ready to install the application...
+
+The newly installed 'SwigSimple' app will be amongst all your other applications on the home screen. Run the app and it will show a Run button text box below it.
+Press the Run button to see the simple text output.
+
+
+
+The application can be uninstalled like any other application and in fact must be uninstalled before installing an updated version. Uninstalling is quite easy too from your host computer:
+
+
+
+
+$ adb uninstall org.swig.simple
+Success
+
+
+
+
+Now that you have a pure Java Android app working, let's add some JNI code generated from SWIG.
+
+
+
+First create a jni subdirectory and then create some C source code in jni/example.c:
+
+
+
+
+/* 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;
+}
+
+
+
+
+Create a SWIG interface file for this C code, jni/example.i:
+
+
+
+
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
+
+See the Android NDK documentation for more on the NDK build system and getting started with the NDK.
+A simple invocation of ndk-build will compile the .c files and generate a shared object/system library. Output will be similar to:
+
+
+
+
+$ ndk-build
+Compile thumb : example <= example_wrap.c
+Compile thumb : example <= example.c
+SharedLibrary : libexample.so
+Install : libexample.so => libs/armeabi/libexample.so
+
+
+
+
+Now that the C JNI layer has been built, we can write Java code to call into the this layer.
+Modify the nativeCall method in src/org/swig/simple/SwigSimple.java to call the JNI code as follows and add the static constructor to load the system library containing the compiled JNI C code:
+
+
+
+
+ /** Calls into C/C++ code */
+ public void nativeCall()
+ {
+ // Call our gcd() function
+
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x,y);
+ outputText.append("The greatest common divisor of " + x + " and " + y + " is " + g + "\n");
+
+ // Manipulate the Foo global variable
+
+ // Output its current value
+ double foo = example.getFoo();
+ outputText.append("Foo = " + foo + "\n");
+
+ // Change its value
+ example.setFoo(3.1415926);
+
+ // See if the change took effect
+ outputText.append("Foo = " + example.getFoo() + "\n");
+
+ // Restore value
+ example.setFoo(foo);
+ }
+
+ /** static constructor */
+ static {
+ System.loadLibrary("example");
+ }
+
+
+
+
+Compile the Java code as usual, uninstall the old version of the app if still installed and re-install the new app:
+
+Run the app again and this time you will see the output pictured below, showing the result of calls into the C code:
+
+
+
+
+
+
18.2.3 C++ class example
+
+
+
+The steps for calling C++ code are almost identical to those in the previous C code example.
+All the steps required to compile and use a simple hierarchy of classes for shapes are shown in this example.
+
+
+
+First create an Android project called SwigClass in a subdirectory called class.
+The steps below create and build a the JNI C++ app.
+Adjust the --target id as mentioned earlier in the Examples introduction.
+
+
+
+
+$ android create project --target 1 --name SwigClass --path ./class --activity SwigClass --package org.swig.classexample
+$ cd class
+
+
+
+
+Now create a jni subdirectory and then create a C++ header file jni/example.h which defines our
+hierarchy of shape classes:
+
+Next we need to create an Android NDK build system file for compiling the C++ code jni/Android.mk.
+The -frtti compiler flag isn't strictly needed for this example, but is needed for any code that uses C++ RTTI:
+
+A simple invocation of ndk-build will compile the .cpp files and generate a shared object/system library. Output will be similar to:
+
+
+
+
+$ ndk-build
+Compile++ thumb : example <= example_wrap.cpp
+Compile++ thumb : example <= example.cpp
+StaticLibrary : libstdc++.a
+SharedLibrary : libexample.so
+Install : libexample.so => libs/armeabi/libexample.so
+
+
+
+
+Now that the C JNI layer has been built, we can write Java code to call into this layer.
+Modify src/org/swig/classexample/SwigClass.java from the default to:
+
+
+
+
+package org.swig.classexample;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.text.method.ScrollingMovementMethod;
+
+public class SwigClass extends Activity
+{
+ TextView outputText = null;
+ ScrollView scroller = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ outputText = (TextView)findViewById(R.id.OutputText);
+ outputText.setText("Press 'Run' to start...\n");
+ outputText.setMovementMethod(new ScrollingMovementMethod());
+
+ scroller = (ScrollView)findViewById(R.id.Scroller);
+ }
+
+ public void onRunButtonClick(View view)
+ {
+ outputText.append("Started...\n");
+ nativeCall();
+ outputText.append("Finished!\n");
+
+ // Ensure scroll to end of text
+ scroller.post(new Runnable() {
+ public void run() {
+ scroller.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ });
+ }
+
+ /** Calls into C/C++ code */
+ public void nativeCall()
+ {
+ // ----- Object creation -----
+
+ outputText.append( "Creating some objects:\n" );
+ Circle c = new Circle(10);
+ outputText.append( " Created circle " + c + "\n");
+ Square s = new Square(10);
+ outputText.append( " Created square " + s + "\n");
+
+ // ----- Access a static member -----
+
+ outputText.append( "\nA total of " + Shape.getNshapes() + " shapes were created\n" );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.setX(20);
+ c.setY(30);
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.setX(-10);
+ shape.setY(5);
+
+ outputText.append( "\nHere is their current position:\n" );
+ outputText.append( " Circle = (" + c.getX() + " " + c.getY() + ")\n" );
+ outputText.append( " Square = (" + s.getX() + " " + s.getY() + ")\n" );
+
+ // ----- Call some methods -----
+
+ outputText.append( "\nHere are some properties of the shapes:\n" );
+ Shape[] shapes = {c,s};
+ for (int i=0; i<shapes.length; i++)
+ {
+ outputText.append( " " + shapes[i].toString() + "\n" );
+ outputText.append( " area = " + shapes[i].area() + "\n" );
+ outputText.append( " perimeter = " + shapes[i].perimeter() + "\n" );
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+
+ outputText.append( "\nGuess I'll clean up now\n" );
+
+ // Note: this invokes the virtual destructor
+ // You could leave this to the garbage collector
+ c.delete();
+ s.delete();
+
+ outputText.append( Shape.getNshapes() + " shapes remain\n" );
+ outputText.append( "Goodbye\n" );
+ }
+
+ /** static constructor */
+ static {
+ System.loadLibrary("example");
+ }
+}
+
+
+
+
+Note the static constructor and the interesting JNI code is in the nativeCall method.
+The remaining code deals with the GUI aspects which are identical to the previous C simple example. Modify res/layout/main.xml to contain the xml for the 'Run' button and scrollable text view:
+
@@ -455,7 +465,25 @@ Windows users can also get the examples working using a
Cygwin or MinGW environment for automatic configuration of the example makefiles.
Any one of the three C# compilers (Portable.NET, Mono or Microsoft) can be detected from within a Cygwin or Mingw environment if installed in your path.
-
18.3 C# Arrays
+
19.3 Void pointers
+
+
+
+By default SWIG treats void * as any other pointer and hence marshalls it as a type wrapper class called SWIGTYPE_p_void.
+If you want to marshall with the .NET System.IntPtr type instead, there is a simple set of named typemaps called
+void *VOID_INT_PTR that can be used.
+They can be applied like any other named typemaps:
+
@@ -467,7 +495,7 @@ with one of the following three approaches; namely the SWIG C arrays library, P/
pinned arrays.
-
18.3.1 The SWIG C arrays library
+
19.4.1 The SWIG C arrays library
@@ -504,7 +532,7 @@ example.print_array(c.cast()); // Pass to C
-
18.3.2 Managed arrays using P/Invoke default array marshalling
+
19.4.2 Managed arrays using P/Invoke default array marshalling
@@ -618,7 +646,7 @@ This results in the module class method
-and intermediate class method
+and intermediary class method
@@ -631,7 +659,7 @@ and intermediate class method
-
18.3.3 Managed arrays using pinning
+
19.4.3 Managed arrays using pinning
@@ -713,7 +741,7 @@ marshalling is the "unsafe" quantifier, which is required because we are handlin
-Also the intermediate class method looks a little different from the default marshalling
+Also the intermediary class method looks a little different from the default marshalling
example - the method is expecting an IntPtr as the parameter type.
@@ -726,7 +754,7 @@ public static extern void myArrayCopy(IntPtr jarg1, IntPtr jarg2, int jarg3);
-
18.4 C# Exceptions
+
19.5 C# Exceptions
@@ -823,7 +851,7 @@ set so should only be used when a C# exception is not created.
-
18.4.1 C# exception example using "check" typemap
+
19.5.1 C# exception example using "check" typemap
@@ -1005,7 +1033,7 @@ method and C# code does not handle pending exceptions via the canthrow attribute
Actually it will issue this warning for any function beginning with SWIG_CSharpSetPendingException.
-
18.4.2 C# exception example using %exception
+
19.5.2 C# exception example using %exception
@@ -1070,7 +1098,7 @@ The managed code generated does check for the pending exception as mentioned ear
-
18.4.3 C# exception example using exception specifications
+
19.5.3 C# exception example using exception specifications
@@ -1127,7 +1155,7 @@ SWIGEXPORT void SWIGSTDCALL CSharp_evensonly(int jarg1) {
Multiple catch handlers are generated should there be more than one exception specifications declared.
-
18.4.4 Custom C# ApplicationException example
+
19.5.4 Custom C# ApplicationException example
@@ -1261,7 +1289,7 @@ try {
-
18.5 C# Directors
+
19.6 C# Directors
@@ -1274,7 +1302,7 @@ The following sections provide information on the C# director implementation and
However, the Java directors section should also be read in order to gain more insight into directors.
@@ -1629,7 +1657,42 @@ However, a call from C# to CSharpDefaults.DefaultMethod() will of cours
should pass the call on to CSharpDefaults.DefaultMethod(int)using the C++ default value, as shown above.
-
18.6 C# Typemap examples
+
19.7 Multiples modules
+
+
+
+When using multiple modules it is is possible to compile each SWIG generated wrapper
+into a different assembly.
+However, by default the generated code may not compile if
+generated classes in one assembly use generated classes in another assembly.
+The visibility of the
+getCPtr() and pointer constructor generated from the csbody typemaps needs changing.
+The default visibility is internal but it needs to be public for access from a different assembly.
+Just changing 'internal' to 'public' in the typemap achieves this.
+Two macros are available in csharp.swg to make this easier and using them is the preferred approach
+over simply copying the typemaps and modifying as this is forward compatible with any changes in
+the csbody typemap in future versions of SWIG.
+The macros are for the proxy and typewrapper classes and can respectively be used to
+to make the method and constructor public:
+
+Alternatively, instead of exposing these as public, consider
+using the [assembly:InternalsVisibleTo("Name")] attribute available in the .NET framework when you
+know which assemblies these can be exposed to.
+Another approach would be to make these public, but also to hide them from intellisense by using
+the [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] attribute
+if you don't want users to easily stumble upon these so called 'internal workings' of the wrappers.
+
+
+
19.8 C# Typemap examples
This section includes a few examples of typemaps. For more examples, you
@@ -1637,7 +1700,7 @@ might look at the files "csharp.swg" and "typemaps.i" in
the SWIG library.
-
18.6.1 Memory management when returning references to member variables
+
19.8.1 Memory management when returning references to member variables
@@ -1761,7 +1824,7 @@ public class Bike : IDisposable {
Note the addReference call.
-
18.6.2 Memory management for objects passed to the C++ layer
+
19.8.2 Memory management for objects passed to the C++ layer
@@ -1880,7 +1943,7 @@ The 'cscode' typemap simply adds in the specified code into the C# proxy class.
-
18.6.3 Date marshalling using the csin typemap and associated attributes
+
19.8.3 Date marshalling using the csin typemap and associated attributes
@@ -2166,7 +2229,7 @@ public class example {
-
18.6.4 A date example demonstrating marshalling of C# properties
+
19.8.4 A date example demonstrating marshalling of C# properties
@@ -2267,7 +2330,7 @@ Some points to note:
-
18.6.5 Turning wrapped classes into partial classes
+
19.8.5 Turning wrapped classes into partial classes
@@ -2367,7 +2430,7 @@ demonstrating that the class contains methods calling both unmanaged code -
The following example is an alternative approach to adding managed code to the generated proxy class.
-
18.6.6 Extending proxy classes with additional C# code
+
19.8.6 Extending proxy classes with additional C# code
@@ -2406,7 +2469,7 @@ public class ExtendMe : IDisposable {
-
@@ -229,7 +229,7 @@
for info on how to apply the %feature.
-
19.2.4 Functions
+
20.2.4 Functions
@@ -248,7 +248,7 @@
parameters). The return values can then be accessed with (call-with-values).
-
19.2.5 Exceptions
+
20.2.5 Exceptions
The SWIG chicken module has support for exceptions thrown from
@@ -290,7 +290,7 @@
-
19.3 TinyCLOS
+
20.3 TinyCLOS
@@ -333,7 +333,7 @@
-
19.4 Linkage
+
20.4 Linkage
@@ -354,7 +354,7 @@
-
19.4.1 Static binary or shared library linked at compile time
+
20.4.1 Static binary or shared library linked at compile time
We can easily use csc to build a static binary.
@@ -395,7 +395,7 @@ in which case the test script does not need to be linked with example.so. The t
be run with csi.
-
19.4.2 Building chicken extension libraries
+
20.4.2 Building chicken extension libraries
Building a shared library like in the above section only works if the library
@@ -453,7 +453,7 @@ distributed and used by anyone, even if SWIG is not installed.
See the Examples/chicken/egg directory in the SWIG source for an example that builds
two eggs, one using the first method and one using the second method.
-
19.4.3 Linking multiple SWIG modules with TinyCLOS
+
20.4.3 Linking multiple SWIG modules with TinyCLOS
Linking together multiple modules that share type information using the %import
@@ -477,7 +477,7 @@ with (declare (uses ...)).
To create an extension library or an egg, just create a module_load.scm file that (declare (uses ...))
all the modules.
-
19.5 Typemaps
+
20.5 Typemaps
@@ -486,7 +486,7 @@ all the modules.
Lib/chicken/chicken.swg.
-
19.6 Pointers
+
20.6 Pointers
@@ -519,7 +519,7 @@ all the modules.
type. flags is either zero or SWIG_POINTER_DISOWN (see below).
-
19.6.1 Garbage collection
+
20.6.1 Garbage collection
If the owner flag passed to SWIG_NewPointerObj is 1, NewPointerObj will add a
@@ -550,7 +550,7 @@ all the modules.
19.7.1 TinyCLOS problems with Chicken version <= 1.92
+
20.7.1 TinyCLOS problems with Chicken version <= 1.92
In Chicken versions equal to or below 1.92, TinyCLOS has a limitation such that generic methods do not properly work on methods
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index b53923c17..7cae25e7f 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -242,6 +242,7 @@
@@ -1691,3 +1716,4 @@
+
diff --git a/Doc/Manual/Customization.html b/Doc/Manual/Customization.html
index 7f164ac57..b98fbfc88 100644
--- a/Doc/Manual/Customization.html
+++ b/Doc/Manual/Customization.html
@@ -704,6 +704,11 @@ depends on the target language on implementing the 'disown' mechanism
properly.
+
+The use of %newobject is also integrated with reference counting and is covered in the
+C++ reference counted objects section.
+
+
Compatibility note: Previous versions of SWIG had a special %new directive. However, unlike %newobject,
it only applied to the next declaration. For example:
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
index abcffa58e..43fa69196 100644
--- a/Doc/Manual/D.html
+++ b/Doc/Manual/D.html
@@ -6,7 +6,7 @@
-
20 SWIG and D
+
21 SWIG and D
@@ -41,10 +41,10 @@
-
20.1 Introduction
+
21.1 Introduction
-
From the D Programming Language web site: »D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.« As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?
+
From the D Programming Language web site: D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code. As such, it is not very surprising that D is able to directly interface with C libraries. Why would a SWIG module for D be needed then in the first place?
Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to \0-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.
@@ -53,7 +53,7 @@
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
+
21.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:
@@ -83,10 +83,10 @@
-
20.3 Typemaps
+
21.3 Typemaps
-
20.3.1 C# <-> D name comparison
+
21.3.1 C# <-> D name comparison
If you already know the SWIG C# module, you might find the following name comparison table useful:
@@ -112,7 +112,7 @@
-
20.3.2 ctype, imtype, dtype
+
21.3.2 ctype, imtype, dtype
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.
@@ -120,7 +120,7 @@
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
+
21.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).
@@ -130,7 +130,7 @@
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
+
21.3.4 din, dout, ddirectorin, ddirectorout
Typemaps for code generation in D proxy and type wrapper classes.
@@ -157,13 +157,13 @@
dtype DClass.method(dtype a)
-
20.3.5 typecheck typemaps
+
21.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
+
21.3.6 Code injection typemaps
These typemaps are used for generating the skeleton of proxy classes for C++ types.
@@ -175,7 +175,7 @@
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
+
21.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.
The D module defines a number of directives which modify the SWIG features set globally or for a specific declaration:
@@ -325,7 +325,7 @@ struct A {
-
20.5 Pragmas
+
21.5 Pragmas
There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:
@@ -364,7 +364,7 @@ struct A {
-
20.6 D Exceptions
+
21.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.
@@ -374,7 +374,7 @@ struct A {
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
+
21.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++.
@@ -383,19 +383,19 @@ struct A {
-
20.8 Other features
+
21.8 Other features
-
20.8.1 Extended namespace support (nspace)
+
21.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
+
21.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.
+
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 primitive 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:
@@ -404,7 +404,7 @@ struct A {
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
+
21.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:
@@ -416,7 +416,7 @@ struct A {
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
+
21.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.
@@ -424,14 +424,14 @@ struct A {
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
+
21.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
+
21.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:
@@ -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.
-
37.2 Prerequisites
+
38.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.
-
37.3 The Big Picture
+
38.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.
-
37.4 Execution Model
+
38.4 Execution Model
@@ -203,7 +203,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
-
37.4.1 Preprocessing
+
38.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.
-
37.4.2 Parsing
+
38.4.2 Parsing
@@ -385,7 +385,7 @@ returning a foo and taking types a and b as
arguments).
@@ -806,7 +806,7 @@ For example, the exception code above is simply
stored without any modifications.
-
37.4.7 Code Generation
+
38.4.7 Code Generation
@@ -928,7 +928,7 @@ public :
The role of these functions is described shortly.
-
37.4.8 SWIG and XML
+
38.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.
-
37.5 Primitive Data Structures
+
38.5 Primitive Data Structures
@@ -987,7 +987,7 @@ typedef Hash Typetab;
-
37.5.1 Strings
+
38.5.1 Strings
@@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
-
37.5.2 Hashes
+
38.5.2 Hashes
@@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
-
37.5.3 Lists
+
38.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.
-
37.5.4 Common operations
+
38.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.
-
37.5.5 Iterating over Lists and Hashes
+
38.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)) {
-
37.5.6 I/O
+
38.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.
-
37.6 Navigating and manipulating parse trees
+
38.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.
-
37.7 Working with attributes
+
38.7 Working with attributes
@@ -1782,7 +1782,7 @@ the attribute is optional. Swig_restore() must always be called after
function.
-
37.8 Type system
+
38.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.
-
37.8.1 String encoding of types
+
38.8.1 String encoding of types
@@ -1892,7 +1892,7 @@ make the final type, the two parts are just joined together using
string concatenation.
-
37.8.2 Type construction
+
38.8.2 Type construction
@@ -2061,7 +2061,7 @@ Returns the prefix of a type. For example, if ty is
ty is unmodified.
-
37.8.3 Type tests
+
38.8.3 Type tests
@@ -2148,7 +2148,7 @@ Checks if ty is a varargs type.
Checks if ty is a templatized type.
-
37.8.4 Typedef and inheritance
+
38.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).
-
37.9 Parameters
+
38.9 Parameters
@@ -2448,7 +2448,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in p.
-
37.10 Writing a Language Module
+
38.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.
-
37.10.1 Execution model
+
38.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.
-
37.10.2 Starting out
+
38.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.
-
37.10.3 Command line options
+
38.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.
-
37.10.4 Configuration and preprocessing
+
38.10.4 Configuration and preprocessing
@@ -2689,7 +2689,7 @@ an implementation file python.cxx and a configuration file
python.swg.
-
37.10.5 Entry point to code generation
+
38.10.5 Entry point to code generation
@@ -2747,7 +2747,7 @@ int Python::top(Node *n) {
-
@@ -3050,7 +3050,7 @@ but without the typemaps, there is still work to do.
-
37.10.8 Configuration files
+
38.10.8 Configuration files
@@ -3194,7 +3194,7 @@ politely displays the ignoring language message.
-
37.10.9 Runtime support
+
38.10.9 Runtime support
@@ -3203,7 +3203,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
-
37.10.10 Standard library files
+
38.10.10 Standard library files
@@ -3222,7 +3222,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
-
37.10.11 User examples
+
38.10.11 User examples
@@ -3251,7 +3251,7 @@ during this process, see the section on .
-
37.10.12 Test driven development and the test-suite
+
38.10.12 Test driven development and the test-suite
@@ -3310,7 +3310,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.
-
37.10.12.1 Running the test-suite
+
38.10.12.1 Running the test-suite
@@ -3496,7 +3496,7 @@ The syntax for setting environment variables varies from one shell to the next,
make ret_by_value.ctest SWIG_FEATURES="-debug-tmsearch"
-
37.10.13 Documentation
+
38.10.13 Documentation
@@ -3528,7 +3528,7 @@ Some topics that you'll want to be sure to address include:
if available.
-
37.10.14 Prerequisites for adding a new language module to the SWIG distribution
+
38.10.14 Prerequisites for adding a new language module to the SWIG distribution
@@ -3585,7 +3585,7 @@ should be added should there be an area not already covered by
the existing tests.
-
37.10.15 Coding style guidelines
+
38.10.15 Coding style guidelines
@@ -3609,7 +3609,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.
-
37.11 Debugging Options
+
38.11 Debugging Options
@@ -3636,7 +3636,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.
@@ -43,7 +43,7 @@ the Go programming language
see golang.org.
-
21.1 Overview
+
22.1 Overview
@@ -67,7 +67,7 @@ checking and runtime library are not used with Go. This should be
borne in mind when reading the rest of the SWIG documentation.
-
21.2 Running SWIG with Go
+
22.2 Running SWIG with Go
@@ -76,7 +76,7 @@ default SWIG will generate code for the gc compilers. To generate
code for gccgo, you should also use the -gccgo option.
-
21.2.1 Additional Commandline Options
+
22.2.1 Additional Commandline Options
@@ -129,7 +129,7 @@ swig -go -help
-
21.2.2 Go Output Files
+
22.2.2 Go Output Files
When generating Go code, SWIG will generate the following
@@ -174,7 +174,7 @@ A typical command sequence would look like this:
% 6l main.6
-
21.3 A tour of basic C/C++ wrapping
+
22.3 A tour of basic C/C++ wrapping
@@ -184,7 +184,7 @@ modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
-
21.3.1 Go Package Name
+
22.3.1 Go Package Name
@@ -194,7 +194,7 @@ directive. You may override this by using SWIG's -package
command line option.
-
21.3.2 Go Names
+
22.3.2 Go Names
@@ -226,7 +226,7 @@ followed by that name, and the destructor will be
named Delete followed by that name.
-
21.3.3 Go Constants
+
22.3.3 Go Constants
@@ -234,7 +234,7 @@ C/C++ constants created via #define or the %constant
directive become Go constants, declared with a const
declaration.
-
21.3.4 Go Enumerations
+
22.3.4 Go Enumerations
@@ -244,7 +244,7 @@ usual). The values of the enumeration will become variables in Go;
code should avoid modifying those variables.
-
21.3.5 Go Classes
+
22.3.5 Go Classes
@@ -322,7 +322,7 @@ returns a go interface. If the returned pointer can be null, you can check
for this by calling the Swigcptr() method.
-
21.3.5.1 Go Class Inheritance
+
22.3.5.1 Go Class Inheritance
@@ -334,7 +334,7 @@ Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
-
21.3.6 Go Templates
+
22.3.6 Go Templates
@@ -342,7 +342,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.
-
21.3.7 Go Director Classes
+
22.3.7 Go Director Classes
@@ -385,7 +385,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++.
-
21.3.8 Default Go primitive type mappings
+
22.3.8 Default Go primitive type mappings
@@ -492,7 +492,7 @@ that typemap, or add new values, to control how C/C++ types are mapped
into Go types.
-
21.3.9 Output arguments
+
22.3.9 Output arguments
Because of limitations in the way output arguments are processed in swig,
@@ -503,7 +503,7 @@ argument.
For example, suppose you were trying to wrap the modf() function in the
C math library which splits x into integral and fractional parts (and
-returns the integer part in one of its parameters):
+returns the integer part in one of its parameters):
Often the APIs generated by swig are not very natural in go, especially if
there are output arguments. You can
diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html
index 111c48214..6f1300492 100644
--- a/Doc/Manual/Guile.html
+++ b/Doc/Manual/Guile.html
@@ -8,7 +8,7 @@
-
22 SWIG and Guile
+
23 SWIG and Guile
@@ -47,7 +47,7 @@
This section details guile-specific support in SWIG.
-
22.1 Meaning of "Module"
+
23.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".
-
22.2 Using the SCM or GH Guile API
+
23.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.
-
22.3 Linkage
+
23.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.
-
22.3.1 Simple Linkage
+
23.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.
-
22.3.2 Passive Linkage
+
23.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.
-
22.3.3 Native Guile Module Linkage
+
23.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:
-
22.3.4 Old Auto-Loading Guile Module Linkage
+
23.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.
-
22.3.5 Hobbit4D Linkage
+
23.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.
-
22.4 Underscore Folding
+
23.4 Underscore Folding
@@ -320,7 +320,7 @@ complained so far.
%rename to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-
22.5 Typemaps
+
23.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.
-
22.6 Representation of pointers as smobs
+
23.6 Representation of pointers as smobs
@@ -433,7 +433,7 @@ representing the expected pointer type. See also
If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a wrong-type-arg exception is raised.
-
22.6.1 GH Smobs
+
23.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.
-
22.6.2 SCM Smobs
+
23.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.
-
22.6.3 Garbage Collection
+
23.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 22.7 Exception Handling
+
23.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.
-
22.8 Procedure documentation
+
23.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.
-
22.9 Procedures with setters
+
23.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.
-
22.10 GOOPS Proxy Classes
+
23.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.
-
22.10.1 Naming Issues
+
23.10.1 Naming Issues
As you can see in the example above, there are potential naming conflicts. The default exported
@@ -767,7 +767,7 @@ guile-modules. For example,
The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index 2ae9f7b95..76e147be5 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -5,7 +5,7 @@
@@ -155,7 +155,7 @@ It covers most SWIG features, but certain low-level details are covered in less
-
23.1 Overview
+
24.1 Overview
@@ -190,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.
-
23.2 Preliminaries
+
24.2 Preliminaries
@@ -206,7 +206,11 @@ 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.
-
23.2.1 Running SWIG
+
+Android uses Java JNI and also works with SWIG. Please read the Android chapter in conjunction with this one if you are targeting Android.
+
+
+
24.2.1 Running SWIG
@@ -265,7 +269,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
-
23.2.2 Additional Commandline Options
+
24.2.2 Additional Commandline Options
@@ -302,7 +306,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
-
23.2.3 Getting the right header files
+
24.2.3 Getting the right header files
@@ -317,7 +321,7 @@ They are usually in directories like this:
The exact location may vary on your machine, but the above locations are typical.
-
23.2.4 Compiling a dynamic module
+
24.2.4 Compiling a dynamic module
@@ -353,7 +357,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.
-
23.2.5 Using your module
+
24.2.5 Using your module
@@ -364,7 +368,7 @@ To load your shared native library module in Java, simply use Java's System.
public class runme {
static {
-Â System.loadLibrary("example");
+ System.loadLibrary("example");
}
public static void main(String argv[]) {
@@ -388,7 +392,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
-
23.2.6 Dynamic linking problems
+
24.2.6 Dynamic linking problems
@@ -475,7 +479,7 @@ The following section also contains some C++ specific linking problems and solut
-
23.2.7 Compilation problems and compiling with C++
+
24.2.7 Compilation problems and compiling with C++
@@ -528,7 +532,7 @@ Finally make sure the version of JDK header files matches the version of Java th
-
23.2.8 Building on Windows
+
24.2.8 Building on Windows
@@ -537,7 +541,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.
-
23.2.8.1 Running SWIG from Visual Studio
+
24.2.8.1 Running SWIG from Visual Studio
@@ -576,7 +580,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.
-
23.2.8.2 Using NMAKE
+
24.2.8.2 Using NMAKE
@@ -635,7 +639,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
-
23.3 A tour of basic C/C++ wrapping
+
24.3 A tour of basic C/C++ wrapping
@@ -645,7 +649,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
-
23.3.1 Modules, packages and generated Java classes
+
24.3.1 Modules, packages and generated Java classes
@@ -681,7 +685,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.
@@ -942,7 +946,7 @@ Or if you decide this practice isn't so bad and your own class implements ex
-
23.3.5 Enumerations
+
24.3.5 Enumerations
@@ -956,7 +960,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.
-
23.3.5.1 Anonymous enums
+
24.3.5.1 Anonymous enums
@@ -1019,7 +1023,7 @@ As in the case of constants, you can access them through either the module class
-
23.3.5.2 Typesafe enums
+
24.3.5.2 Typesafe enums
@@ -1113,7 +1117,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.
@@ -1214,7 +1218,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.
-
23.3.5.5 Simple enums
+
24.3.5.5 Simple enums
@@ -1233,7 +1237,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.
-
23.3.6 Pointers
+
24.3.6 Pointers
@@ -1321,7 +1325,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.
-
23.3.7 Structures
+
24.3.7 Structures
@@ -1489,7 +1493,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
-
23.3.8 C++ classes
+
24.3.8 C++ classes
@@ -1552,7 +1556,7 @@ int bar = Spam.getBar();
-
23.3.9 C++ inheritance
+
24.3.9 C++ inheritance
@@ -1613,7 +1617,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.
-
23.3.10 Pointers, references, arrays and pass by value
+
24.3.10 Pointers, references, arrays and pass by value
@@ -1668,7 +1672,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).
-
23.3.10.1 Null pointers
+
24.3.10.1 Null pointers
@@ -1692,7 +1696,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.
@@ -1850,7 +1854,7 @@ Further details on default arguments and how to restore this approach are given
-
23.3.13 C++ namespaces
+
24.3.13 C++ namespaces
@@ -1930,7 +1934,12 @@ in an unnamed package.
-
23.3.14 C++ templates
+
+If the resulting use of the nspace feature and hence packages results in a proxy class in one package deriving or using a proxy class from another package,
+you will need to open up the visibility for the pointer constructor and getCPtr method from the default 'protected' to 'public' with the SWIG_JAVABODY_PROXY macro. See Java code typemaps.
+
+
+
24.3.14 C++ templates
@@ -1979,7 +1988,7 @@ Obviously, there is more to template wrapping than shown in this example.
More details can be found in the SWIG and C++ chapter.
23.4 Further details on the generated Java classes
+
24.4 Further details on the generated Java classes
@@ -2078,7 +2087,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
-
23.4.1 The intermediary JNI class
+
24.4.1 The intermediary JNI class
@@ -2198,7 +2207,7 @@ If name is the same as modulename then the module class name g
from modulename to modulenameModule.
-
23.4.1.1 The intermediary JNI class pragmas
+
24.4.1.1 The intermediary JNI class pragmas
@@ -2277,7 +2286,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.
-
23.4.2 The Java module class
+
24.4.2 The Java module class
@@ -2308,7 +2317,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.
@@ -2379,7 +2388,7 @@ public class Foo {
swigCPtr = cPtr;
}
- public static long getCPtr(Foo obj) {
+ protected static long getCPtr(Foo obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
@@ -2435,7 +2444,7 @@ int y = f.spam(5, new Foo());
-
23.4.3.1 Memory management
+
24.4.3.1 Memory management
@@ -2597,7 +2606,7 @@ and
-
23.4.3.2 Inheritance
+
24.4.3.2 Inheritance
@@ -2630,7 +2639,7 @@ public class Base {
swigCPtr = cPtr;
}
- public static long getCPtr(Base obj) {
+ protected static long getCPtr(Base obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
@@ -2670,7 +2679,7 @@ public class Derived extends Base {
swigCPtr = cPtr;
}
- public static long getCPtr(Derived obj) {
+ protected static long getCPtr(Derived obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
@@ -2713,7 +2722,7 @@ However, true cross language polymorphism can be achieved using the 23.4.3.3 Proxy classes and garbage collection
+
23.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling
+
24.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling
@@ -2918,7 +2927,7 @@ For example:
Compatibility note: The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.
-
23.4.3.5 Single threaded applications and thread safety
+
24.4.3.5 Single threaded applications and thread safety
@@ -2949,7 +2958,7 @@ public class Test {
swigCPtr = cPtr;
}
- public static long getCPtr(Test obj) {
+ protected static long getCPtr(Test obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
@@ -3006,7 +3015,7 @@ for (int i=0; i<100000; i++) {
-
23.4.4 Type wrapper classes
+
24.4.4 Type wrapper classes
@@ -3093,7 +3102,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
-
23.4.5 Enum classes
+
24.4.5 Enum classes
@@ -3102,7 +3111,7 @@ The Enumerations section discussed these but om
The following sub-sections detail the various types of enum classes that can be generated.
-
23.4.5.1 Typesafe enum classes
+
24.4.5.1 Typesafe enum classes
@@ -3186,7 +3195,7 @@ The swigValue method is used for marshalling in the other direction.
The toString method is overridden so that the enum name is available.
-
23.4.5.2 Proper Java enum classes
+
24.4.5.2 Proper Java enum classes
@@ -3264,7 +3273,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.
-
23.4.5.3 Type unsafe enum classes
+
24.4.5.3 Type unsafe enum classes
@@ -3295,7 +3304,7 @@ public final class Beverage {
-
23.5 Cross language polymorphism using directors
+
24.5 Cross language polymorphism using directors
@@ -3317,7 +3326,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.
-
23.5.1 Enabling directors
+
24.5.1 Enabling directors
@@ -3388,7 +3397,7 @@ public:
-
23.5.2 Director classes
+
24.5.2 Director classes
@@ -3415,7 +3424,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
-
23.5.3 Overhead and code bloat
+
24.5.3 Overhead and code bloat
@@ -3433,7 +3442,7 @@ This situation can be optimized by selectively enabling director methods (using
The following DirectorDerived Java class is derived from the Java proxy class DirectorBase and overrides upcall_method().
When C++ code invokes upcall_method(), the SWIG-generated C++ code redirects the call via JNI to the Java DirectorDerived subclass.
-Naturally, the SWIG generated C++ code and the generated Java intermediate class marshal and convert arguments between C++ and Java when needed.
+Naturally, the SWIG generated C++ code and the generated Java intermediary class marshal and convert arguments between C++ and Java when needed.
@@ -3518,7 +3527,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
-
23.6 Accessing protected members
+
24.6 Accessing protected members
@@ -3614,7 +3623,7 @@ class MyProtectedBase extends ProtectedBase
-
23.7 Common customization features
+
24.7 Common customization features
@@ -3626,7 +3635,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
-
23.7.1 C/C++ helper functions
+
24.7.1 C/C++ helper functions
@@ -3692,7 +3701,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.
-
23.7.2 Class extension with %extend
+
24.7.2 Class extension with %extend
@@ -3755,7 +3764,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
-
23.7.3 Exception handling with %exception and %javaexception
+
24.7.3 Exception handling with %exception and %javaexception
@@ -3950,7 +3959,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
-
23.8.1 Input and output parameters using primitive pointers and references
+
24.8.1 Input and output parameters using primitive pointers and references
@@ -4124,7 +4133,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
23.8.2 Simple pointers
+
24.8.2 Simple pointers
@@ -4190,7 +4199,7 @@ System.out.println("3 + 4 = " + result);
See the SWIG Library chapter for further details.
-
23.8.3 Wrapping C arrays with Java arrays
+
24.8.3 Wrapping C arrays with Java arrays
@@ -4257,7 +4266,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.
-
23.8.4 Unbounded C Arrays
+
24.8.4 Unbounded C Arrays
@@ -4402,7 +4411,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
23.8.6 Overriding new and delete to allocate from Java heap
+
24.8.6 Overriding new and delete to allocate from Java heap
@@ -4563,7 +4572,7 @@ model and use these functions in place of malloc and free in your own
code.
-
23.9 Java typemaps
+
24.9 Java typemaps
@@ -4584,7 +4593,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.
-
23.9.1 Default primitive type mappings
+
24.9.1 Default primitive type mappings
@@ -4736,7 +4745,7 @@ However, the mappings allow the full range of values for each C type from Java.
-
23.9.2 Default typemaps for non-primitive types
+
24.9.2 Default typemaps for non-primitive types
@@ -4751,7 +4760,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.
-
23.9.3 Sixty four bit JVMs
+
24.9.3 Sixty four bit JVMs
@@ -4764,7 +4773,7 @@ Unfortunately it won't of course hold true for JNI code.
-
23.9.4 What is a typemap?
+
24.9.4 What is a typemap?
@@ -4887,7 +4896,7 @@ int c = example.count('e',"Hello World");
-
23.9.5 Typemaps for mapping C/C++ types to Java types
+
24.9.5 Typemaps for mapping C/C++ types to Java types
@@ -5147,7 +5156,7 @@ These are listed below:
-
23.9.6 Java typemap attributes
+
24.9.6 Java typemap attributes
@@ -5193,7 +5202,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.
-
23.9.7 Java special variables
+
24.9.7 Java special variables
@@ -5344,7 +5353,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the %module directive.
-
23.9.8 Typemaps for both C and C++ compilation
+
24.9.8 Typemaps for both C and C++ compilation
@@ -5381,7 +5390,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
-interfaces (extends) for Java class: empty default
+interfaces (implements) for Java class: empty default
%typemap(javafinalize)
@@ -5550,15 +5559,8 @@ The typemap code is the same that is in "java.swg", barring the last tw
Note that SWIGTYPE will target all proxy classes, but not the type wrapper classes.
Also the above typemap is only used for proxy classes that are potential base classes.
To target proxy classes that are derived from a wrapped class as well, the "javabody_derived" typemap should also be overridden.
-There is a macro in java.swg that implements this and the above can instead be implemented using:
-
For the typemap to be used in all type wrapper classes, all the different types that type wrapper classes could be used for should be targeted:
@@ -5568,7 +5570,7 @@ For the typemap to be used in all type wrapper classes, all the different types
%typemap(javabody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) %{
private long swigCPtr;
- public $javaclassname(long cPtr, boolean bFutureUse) {
+ protected $javaclassname(long cPtr, boolean bFutureUse) {
swigCPtr = cPtr;
}
@@ -5576,7 +5578,7 @@ For the typemap to be used in all type wrapper classes, all the different types
swigCPtr = 0;
}
- public static long getCPtr($javaclassname obj) {
+ protected static long getCPtr($javaclassname obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
%}
@@ -5587,7 +5589,30 @@ 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.
-
23.9.10 Director specific typemaps
+
+When using multiple modules or the nspace feature it is common to invoke SWIG with a different -package
+command line option for each module.
+However, by default the generated code may not compile if
+generated classes in one package use generated classes in another package.
+The visibility of the
+getCPtr() and pointer constructor generated from the javabody typemaps needs changing.
+The default visibility is protected but it needs to be public for access from a different package.
+Just changing 'protected' to 'public' in the typemap achieves this.
+Two macros are available in java.swg to make this easier and using them is the preferred approach
+over simply copying the typemaps and modifying as this is forward compatible with any changes in
+the javabody typemap in future versions of SWIG.
+The macros are for the proxy and typewrapper classes and can respectively be used to
+to make the method and constructor public:
+
@@ -5812,7 +5837,7 @@ The basic strategy here is to provide a default package typemap for the majority
-
23.10 Typemap Examples
+
24.10 Typemap Examples
@@ -5822,7 +5847,7 @@ the SWIG library.
-
23.10.1 Simpler Java enums for enums without initializers
+
24.10.1 Simpler Java enums for enums without initializers
@@ -5901,7 +5926,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
-
23.10.2 Handling C++ exception specifications as Java exceptions
+
24.10.2 Handling C++ exception specifications as Java exceptions
@@ -6026,7 +6051,7 @@ We could alternatively have used %rename to rename what() into
-
23.10.3 NaN Exception - exception handling for a particular type
+
24.10.3 NaN Exception - exception handling for a particular type
@@ -6181,7 +6206,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.
-
23.10.4 Converting Java String arrays to char **
+
24.10.4 Converting Java String arrays to char **
@@ -6281,7 +6306,7 @@ public class runme {
static {
try {
-Â System.loadLibrary("example");
+ System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. " + e);
System.exit(1);
@@ -6325,7 +6350,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
-
23.10.5 Expanding a Java object to multiple arguments
+
24.10.5 Expanding a Java object to multiple arguments
23.10.7 Adding Java downcasts to polymorphic return types
+
24.10.7 Adding Java downcasts to polymorphic return types
@@ -6731,7 +6756,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.
-
23.10.8 Adding an equals method to the Java classes
+
24.10.8 Adding an equals method to the Java classes
23.10.9 Void pointers and a common Java base class
+
24.10.9 Void pointers and a common Java base class
@@ -6834,7 +6859,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.
-
23.10.10 Struct pointer to pointer
+
24.10.10 Struct pointer to pointer
@@ -7014,7 +7039,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.
-
23.10.11 Memory management when returning references to member variables
+
24.10.11 Memory management when returning references to member variables
@@ -7137,7 +7162,7 @@ public class Bike {
Note the addReference call.
-
23.10.12 Memory management for objects passed to the C++ layer
+
24.10.12 Memory management for objects passed to the C++ layer
@@ -7253,7 +7278,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
-
23.10.13 Date marshalling using the javain typemap and associated attributes
+
24.10.13 Date marshalling using the javain typemap and associated attributes
@@ -7430,7 +7455,7 @@ A few things to note:
-
23.11 Living with Java Directors
+
24.11 Living with Java Directors
@@ -7611,10 +7636,10 @@ public abstract class UserVisibleFoo extends Foo {
-
23.12 Odds and ends
+
24.12 Odds and ends
-
23.12.1 JavaDoc comments
+
24.12.1 JavaDoc comments
@@ -7670,7 +7695,7 @@ public class Barmy {
-
23.12.2 Functional interface without proxy classes
+
24.12.2 Functional interface without proxy classes
@@ -7731,7 +7756,7 @@ All destructors have to be called manually for example the delete_Foo(foo)
-
23.12.3 Using your own JNI functions
+
24.12.3 Using your own JNI functions
@@ -7781,7 +7806,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
-
23.12.4 Performance concerns and hints
+
24.12.4 Performance concerns and hints
@@ -7802,7 +7827,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.
-
23.12.5 Debugging
+
24.12.5 Debugging
@@ -7824,7 +7849,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
Copies all of the string data in s into the memory pointed to by
-ptr. The string may contain embedded NULL bytes. The length of
-the string is implicitly determined in the underlying wrapper code.
+ptr. The string may contain embedded NULL bytes.
+This is actually a wrapper to the standard C library memmove function, which is
+declared as
+void memmove(void *ptr, const void *src, size_t n).
+The src and length n parameters are
+extracted from the language specific string s in the underlying wrapper code.
@@ -77,7 +77,7 @@ swig -cffi -module module-namefile-name
files and the various things which you can do with them.
-
24.2.1 Additional Commandline Options
+
25.2.1 Additional Commandline Options
@@ -118,7 +118,7 @@ swig -cffi -help
-
24.2.2 Generating CFFI bindings
+
25.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
-
24.2.3 Generating CFFI bindings for C++ code
+
25.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.
-
24.2.4 Inserting user code into generated files
+
25.2.4 Inserting user code into generated files
@@ -608,7 +608,7 @@ Note that the block %{ ... %} is effectively a shortcut for
-
24.3 CLISP
+
25.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.
-
24.3.1 Additional Commandline Options
+
25.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
-
25.1 Preliminaries
+
+eLua stands for Embedded Lua (can be thought of as a flavor of Lua) and offers the full implementation of the Lua programming language to the embedded world, extending it with specific features for efficient and portable software embedded development. eLua runs on smaller devices like microcontrollers and provides the full features of the regular Lua desktop version. More information on eLua can be found here: http://www.eluaproject.net
+
+
+
26.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).
+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). SWIG also supports eLua and works with eLua 0.8. SWIG generated code for eLua has been tested on Stellaris ARM Cortex-M3 LM3S and Infineon TriCore.
-
25.2 Running SWIG
+
26.2 Running SWIG
@@ -105,7 +111,56 @@ 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.
-
25.2.1 Compiling and Linking and Interpreter
+
+To build an eLua module, run SWIG using -lua and add either -elua or -eluac.
+
+
+$ swig -lua -elua example.i
+
+
+or
+
+
+$ swig -lua -eluac example.i
+
+
+The -elua option puts all the C function wrappers and variable get/set wrappers in rotables. It also generates a metatable which will control the access to these variables from eLua. It also offers a significant amount of module size compression. On the other hand, the -eluac option puts all the wrappers in a single rotable. With this option, no matter how huge the module, it will consume no additional microcontroller SRAM (crass compression). There is a catch though: Metatables are not generated with -eluac. To access any value from eLua, one must directly call the wrapper function associated with that value.
+
+
+
26.2.1 Additional command line options
+
+
+
+The following table list the additional commandline options available for the Lua module. They can also be seen by using:
+
+
+
+swig -lua -help
+
+
+
+
+
Lua specific options
+
+
+
+
-elua
+
Generates LTR compatible wrappers for smaller devices running elua.
+
+
+
+
-eluac
+
LTR compatible wrappers in "crass compress" mode for elua.
+
+
+
+
-nomoduleglobal
+
Do not register the module name as a global variable but return the module table from calls to require.
+For eLua, the source must be built along with the wrappers generated by SWIG. Make sure the eLua source files platform_conf.h and auxmods.h are updated with the entries of your new module. Please note: "mod" is the module name.
+
@@ -220,7 +300,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-
25.2.3 Using your module
+
26.2.4 Using your module
@@ -238,19 +318,19 @@ $ ./my_lua
>
-
25.3 A tour of basic C/C++ wrapping
+
26.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.
-
25.3.1 Modules
+
26.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.
-
25.3.2 Functions
+
26.3.2 Functions
@@ -288,7 +368,7 @@ It is also possible to rename the module with an assignment.
24
-
+If you have used the -eluac option for your eLua module, you will have to follow a different approach while manipulating global variables. (This is not applicable for wrappers generated with -elua)
+
+
+> -- Applicable only with -eluac. (num is defined)
+> print(example.num_get())
+20
+> example.num_set(50) -- new value added
+> print(example.num_get())
+50
+
+
+In general, functions of the form "variable_get()" and "variable_set()" are automatically generated by SWIG for use with -eluac.
+
-
25.3.4 Constants and enums
+
26.3.4 Constants and enums
@@ -385,7 +479,18 @@ 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.
-
25.3.5 Pointers
+
+If you're using eLua and have used -elua or -eluac to generate your wrapper, macro constants and enums should be accessed through a rotable called "const". In eLua, macro constants and enums are guaranteed to remain constants since they are all contained within a rotable. A regular C constant is accessed from eLua just as if it were a regular global variable, just that the property of value immutability is demonstrated if an attempt at modifying a C constant is made.
+
@@ -423,7 +528,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
-
25.3.6 Structures
+
26.3.6 Structures
@@ -508,8 +613,26 @@ Because the pointer points inside the structure, you can modify the contents and
> x = b.f
> x.a = 3 -- Modifies the same structure
+
+For eLua with the -eluac option, structure manipulation has to be performed with specific structure functions generated by SWIG. Let's say you have the following structure definition:
+
+In general, functions of the form "new_struct()", "struct_member_get()", "struct_member_set()" and "free_struct()" are automatically generated by SWIG for each structure defined in C. (Please note: This doesn't apply for modules generated with the -elua option)
+
+
+
26.3.7 C++ classes
@@ -570,7 +693,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
-
25.3.8 C++ inheritance
+
26.3.8 C++ inheritance
@@ -595,7 +718,7 @@ then the function spam() accepts a Foo pointer or a pointer to any clas
It is safe to use multiple inheritance with SWIG.
-
25.3.9 Pointers, references, values, and arrays
+
26.3.9 Pointers, references, values, and arrays
@@ -626,7 +749,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.
-
25.3.10 C++ overloaded functions
+
26.3.10 C++ overloaded functions
@@ -712,7 +835,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.
-
25.3.11 C++ operators
+
26.3.11 C++ operators
@@ -824,7 +947,7 @@ It is also possible to overload the operator[], but currently this cann
};
-
25.3.12 Class extension with %extend
+
26.3.12 Class extension with %extend
@@ -879,7 +1002,32 @@ 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).
-
25.3.13 C++ templates
+
+
26.3.13 Using %newobject to release memory
+
+
+
If you have a function that allocates memory like this,
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.
-
25.3.14 C++ Smart Pointers
+
26.3.15 C++ Smart Pointers
@@ -966,7 +1114,7 @@ If you ever need to access the underlying pointer returned by operator->(
> f = p:__deref__() -- Returns underlying Foo *
-
25.3.15 C++ Exceptions
+
26.3.16 C++ Exceptions
@@ -985,13 +1133,13 @@ SWIG will automatically convert this to a Lua error.
-> message()
+> message()
I died.
stack traceback:
[C]: in function 'message'
stdin:1: in main chunk
[C]: ?
->
+>
@@ -1000,13 +1148,13 @@ Using xpcall will allow you to obtain additional debug information (such as a st
-> function a() b() end -- function a() calls function b()
-> function b() message() end -- function b() calls C++ function message(), which throws
-> ok,res=pcall(a) -- call the function
-> print(ok,res)
+> function a() b() end -- function a() calls function b()
+> function b() message() end -- function b() calls C++ function message(), which throws
+> ok,res=pcall(a) -- call the function
+> print(ok,res)
false I died.
-> ok,res=xpcall(a,debug.traceback) -- call the function
-> print(ok,res)
+> ok,res=xpcall(a,debug.traceback) -- call the function
+> print(ok,res)
false I died.
stack traceback:
[C]: in function 'message'
@@ -1018,7 +1166,7 @@ stack traceback:
-SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into and error string.
+SWIG is able to throw numeric types, enums, chars, char*'s and std::string's without problem. It has also written typemaps for std::exception and its derived classes, which convert the exception into an error string.
However its not so simple for to throw other types of objects.
Thrown objects are not valid outside the 'catch' block. Therefore they cannot be
@@ -1041,13 +1189,13 @@ SWIG will just convert it (poorly) to a string and use that as its error. (Yes i
-> throw_A()
+> throw_A()
object exception:A *
stack traceback:
[C]: in function 'unknown'
stdin:1: in main chunk
[C]: ?
->
+>
To get a more useful behaviour out of SWIG you must either: provide a way to convert your exceptions into strings, or
@@ -1088,14 +1236,14 @@ void throw_exc() throw(Exc) {
Then the following code can be used (note: we use pcall to catch the error so we can process the exception).
@@ -1110,12 +1258,12 @@ add exception specification to functions or globally (respectively).
-
25.4 Typemaps
+
26.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
+
This section explains what typemaps are and the usage of them. The default wrapping 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 wrapping. This section will be explaining how to use typemaps to best effect
-
25.4.1 What is a typemap?
+
26.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 +1291,7 @@ Received an integer : 6
720
-
25.4.2 Using typemaps
+
26.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 +1344,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).
-
25.4.3 Typemaps and arrays
+
26.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 +1408,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.
-
25.4.4 Typemaps and pointer-pointer functions
+
26.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:
SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrappering as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:
+
SWIG has a ready written typemap to deal with such a kind of function in <typemaps.i>. It provides the correct wrapping as well as setting the flag to inform Lua that the object in question should be garbage collected. Therefore the code is simply:
%include <typemaps.i>
%apply SWIGTYPE** OUTPUT{iMath **pptr }; // tell SWIG its an output
@@ -1294,16 +1442,16 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
ptr=nil -- the iMath* will be GC'ed as normal
-
25.5 Writing typemaps
+
26.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.
-
Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrappering, or to achieve an effect which in not available with the default bindings.
+
Before proceeding, it should be stressed that writing typemaps is rarely needed unless you want to change some aspect of the wrapping, or to achieve an effect which in not available with the default bindings.
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).
-
25.5.1 Typemaps you can write
+
26.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 +1464,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).
-
25.5.2 SWIG's Lua-C API
+
26.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.
@@ -1324,7 +1472,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
int SWIG_ConvertPtr(lua_State* L,int index,void** ptr,swig_type_info *type,int flags);
-This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the neccesary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer.
+This is the standard function used for converting a Lua userdata to a void*. It takes the value at the given index in the Lua state and converts it to a userdata. It will then provide the necessary type checks, confirming that the pointer is compatible with the type given in 'type'. Then finally setting '*ptr' to the pointer.
If flags is set to SWIG_POINTER_DISOWN, this is will clear any ownership flag set on the object.
The returns a value which can be checked with the macro SWIG_IsOK()
@@ -1345,7 +1493,7 @@ This function is a version of SWIG_ConvertPtr(), except that it will either work
SWIG_fail
-This macro, when called within the context of a SWIG wrappered function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.
+This macro, when called within the context of a SWIG wrapped function, will jump to the error handler code. This will call any cleanup code (freeing any temp variables) and then triggers a lua_error.
A common use for this code is:
if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
lua_pushstring(L,"something bad happened");
@@ -1355,7 +1503,7 @@ if (!SWIG_IsOK(SWIG_ConvertPtr( .....)){
-This macro, when called within the context of a SWIG wrappered function, will display the error message and jump to the error handler code. The error message is of the form
+This macro, when called within the context of a SWIG wrapped function, will display the error message and jump to the error handler code. The error message is of the form
"Error in func_name (arg argnum), expected 'type' got 'whatever the type was'"
@@ -1365,7 +1513,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.
-
25.6 Customization of your Bindings
+
26.6 Customization of your Bindings
@@ -1374,11 +1522,11 @@ This section covers adding of some small extra bits to your module to add the la
-
25.6.1 Writing your own custom wrappers
+
26.6.1 Writing your own custom wrappers
-Sometimes, it may be neccesary to add your own special functions, which bypass the normal SWIG wrappering method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows:
+Sometimes, it may be necessary to add your own special functions, which bypass the normal SWIG wrapper method, and just use the native Lua API calls. These 'native' functions allow direct adding of your own code into the module. This is performed with the %native directive as follows:
%native(my_func) int native_function(lua_State*L); // registers native_function() with SWIG
...
@@ -1390,10 +1538,10 @@ 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.
+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 wrapper for this function, beyond adding it into the function table. How you write your code is entirely up to you.
-
25.6.2 Adding additional Lua code
+
26.6.2 Adding additional Lua code
@@ -1431,18 +1579,18 @@ 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.
-
25.7 Details on the Lua binding
+
26.7 Details on the Lua binding
In the previous section, a high-level view of Lua wrapping was presented. Obviously a lot of stuff happens behind the scenes to make this happen. This section will explain some of the low-level details on how this is achieved.
- If you just want to use SWIG and don't care how it works, then stop reading here. This is going into the guts of the code and how it works. Its mainly for people who need to know whats going on within the code.
+ If you just want to use SWIG and don't care how it works, then stop reading here. This is going into the guts of the code and how it works. It's mainly for people who need to know what's going on within the code.
-
25.7.1 Binding global data into the module.
+
26.7.1 Binding global data into the module.
@@ -1502,7 +1650,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)'.
-
25.7.2 Userdata and Metatables
+
26.7.2 Userdata and Metatables
@@ -1577,16 +1725,16 @@ So when 'p:Print()' is called, the __index looks on the object metatable for a '
In theory, you can play with this usertable & add new features, but remember that it is a shared table between all instances of one class, and you could very easily corrupt the functions in all the instances.
-Note: Both the opaque structures (like the FILE*) and normal wrappered classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them.
+Note: Both the opaque structures (like the FILE*) and normal wrapped classes/structs use the same 'swig_lua_userdata' structure. Though the opaque structures has do not have a metatable attached, or any information on how to dispose of them when the interpreter has finished with them.
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.
-
25.7.3 Memory management
+
26.7.3 Memory management
-Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully managed by the interpreter itself. This means that neither the C code nor the Lua code can damage it. Once a piece of userdata has no references to it, it is not instantly collected, but will be collected when Lua deems is necessary. (You can force collection by calling the Lua function collectgarbage()). Once the userdata is about to be free'ed, the interpreter will check the userdata for a metatable and for a function '__gc'. If this exists this is called. For all complete types (ie normal wrappered classes & structs) this should exist. The '__gc' function will check the 'swig_lua_userdata' to check for the 'own' field and if this is true (which is will be for all owned data's) it will then call the destructor on the pointer.
+Lua is very helpful with the memory management. The 'swig_lua_userdata' is fully managed by the interpreter itself. This means that neither the C code nor the Lua code can damage it. Once a piece of userdata has no references to it, it is not instantly collected, but will be collected when Lua deems is necessary. (You can force collection by calling the Lua function collectgarbage()). Once the userdata is about to be free'ed, the interpreter will check the userdata for a metatable and for a function '__gc'. If this exists this is called. For all complete types (ie normal wrapped classes & structs) this should exist. The '__gc' function will check the 'swig_lua_userdata' to check for the 'own' field and if this is true (which is will be for all owned data) it will then call the destructor on the pointer.
It is currently not recommended to edit this field or add some user code, to change the behaviour. Though for those who wish to try, here is where to look.
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index f9400abee..065313fa2 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -5,7 +5,7 @@
This section contains information on SWIG's support of Racket, formally known as MzScheme.
-
27.1 Creating native structures
+
28.1 Creating native structures
@@ -65,7 +65,7 @@ Then in scheme, you can use regular struct access procedures like
-
27.2 Simple example
+
28.2 Simple example
@@ -166,7 +166,7 @@ Some points of interest:
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.
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
The Ocaml Website.
-
28.1 Preliminaries
+
29.1 Preliminaries
@@ -99,7 +99,7 @@ file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
-
28.1.1 Running SWIG
+
29.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).
-
28.1.2 Compiling the code
+
29.1.2 Compiling the code
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
-
28.1.3 The camlp4 module
+
29.1.3 The camlp4 module
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
-
28.1.4 Using your module
+
29.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.
-
28.1.5 Compilation problems and compiling with C++
+
29.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.
-
28.2 The low-level Ocaml/C interface
+
29.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.
-
28.2.1 The generated module
+
29.2.1 The generated module
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
-
28.2.2 Enums
+
29.2.2 Enums
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
-
28.2.2.1 Enum typing in Ocaml
+
29.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.
-
28.2.3 Arrays
+
29.2.3 Arrays
-
28.2.3.1 Simple types of bounded arrays
+
29.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.
-
28.2.3.2 Complex and unbounded arrays
+
29.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.
-
28.2.3.3 Using an object
+
29.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.
-
28.2.3.4 Example typemap for a function taking float * and int
+
29.2.3.4 Example typemap for a function taking float * and int
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
-
28.2.4 C++ Classes
+
29.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.
-
28.2.5 Director Classes
+
29.2.5 Director Classes
-
28.2.5.1 Director Introduction
+
29.2.5.1 Director Introduction
@@ -800,7 +800,7 @@ class foo {
};
-
28.2.5.2 Overriding Methods in Ocaml
+
29.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.
-
28.2.5.3 Director Usage Example
+
29.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++.
-
28.2.5.4 Creating director objects
+
29.2.5.4 Creating director objects
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
-
28.2.5.5 Typemaps for directors, directorin, directorout, directorargout
+
29.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.
-
28.2.5.6 directorin typemap
+
29.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.
-
28.2.5.7 directorout typemap
+
29.2.5.7 directorout typemap
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
-
28.2.5.8 directorargout typemap
+
29.2.5.8 directorargout typemap
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
The SWIG implemention was first based on Octave 2.9.12, so this is the minimum version required. Testing has only been done on Linux.
-
29.2 Running SWIG
+
+As of SWIG 2.0.5, the Octave module should work with Octave versions 3.0.5, 3.2.4, and 3.4.0.
+
+
+
30.2 Running SWIG
@@ -80,24 +85,44 @@ extern double Foo;
To build an Octave module when wrapping C code, run SWIG using the -octave option:
-
$ swig -octave example.i
+
$ swig -octave -o example_wrap.cpp example.i
The -c++ option is also required when wrapping C++ code:
-
$ swig -octave -c++ example.i
+
$ swig -octave -c++ -o example_wrap.cpp example.i
-This creates a C++ source file example_wrap.cxx. A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.
+This creates a C++ source file example_wrap.cpp. A C++ file is generated even when wrapping C code as Octave is itself written in C++ and requires wrapper code to be in the same language. The generated C++ source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application (in this case, the gcd implementation) to create an extension module.
+
30.2.1 Command-line options
+
+
-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.
+The swig command line has a number of options you can use, like to redirect its output. Use swig -help to learn about these.
+Options specific to the Octave module are:
-
29.2.1 Compiling a dynamic module
+
+
$ swig -octave -help
+...
+Octave Options (available with -octave)
+ -global - Load all symbols into the global namespace [default]
+ -globals name - Set name used to access C global variables [default: 'cvar']
+ -noglobal - Do not load all symbols into the global namespace
+ -opprefix str - Prefix str for global operator functions [default: 'op_']
+
+
+
+The -global and -noglobal options determine whether the Octave module will load all symbols into the global namespace in addition to the global namespace.
+The -globals option sets the name of the variable which is the namespace for C global variables exported by the module.
+The -opprefix options sets the prefix of the names of global/friend operator functions.
+
+
+
30.2.2 Compiling a dynamic module
@@ -106,8 +131,8 @@ Building an oct file is usually done with the mkoctfile command (either within O
@@ -157,37 +182,73 @@ When Octave is asked to invoke example, it will try to find the .m or .
-Giving this function a parameter "global" will cause it to load all symbols into the global namespace in addition to the example namespace. For example:
+An Octave module takes three options, -global, -noglobal, and -globals, which behave the same as the corresponding swig command-line options.
+Here are some example usages:
+octave:1> example -help
+usage: example [-global|-noglobal] [-globals <name>]
+octave:2> example -global
+octave:3> gcd(4,6)
ans = 2
-octave:3> cvar.Foo
+octave:4> cvar.Foo
ans = 3
-octave:4> cvar.Foo=4;
-octave:5> cvar.Foo
-ans = 4
+octave:5> cvar.Foo=4;
+octave:6> cvar.Foo
+ans = 4
+
+
+octave:1> example -noglobal
+octave:2> gcd(6,9)
+ans = 3
+octave:3> cvar.Foo
+error: `cvar' undefined near line 3 column 1
+octave:3> example.cvar.Foo
+ans = 3
+
+
+
+octave:1> example -globals mycvar
+octave:2> cvar.Foo
+error: `cvar' undefined near line 2 column 1
+octave:2> mycvar.Foo
+ans = 3
+
+
- It is also possible to rename the module namespace with an assignment, as in:
-
octave:1> example;
+ It is also possible to rename the module / global variables namespaces with an assignment, as in:
+
+octave:1> example
octave:2> c=example;
octave:3> c.gcd(10,4)
-ans = 2
-
-
-All global variables are put into the cvar namespace object. This is accessible either as my_module.cvar, or just cvar (if the module is imported into the global namespace).
-
-
-One can also rename it by simple assignment, e.g.,
-
+Modules can also be loaded from within functions, even before being loaded in the base context.
+If the module is also used in the base context, however, it must first be loaded again:
+
+
+
+octave:1> function l = my_lcm(a,b)
+> example
+> l = abs(a*b)/example.gcd(a,b);
+> endfunction
+octave:2> my_lcm(4,6)
+ans = 12
+octave:3> example.gcd(4,6)
+error: can't perform indexing operations for <unknown type> type
+octave:3> example;
+octave:4> example.gcd(4,6)
+ans = 2
+
@@ -326,7 +387,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
-
29.3.6 Structures and C++ classes
+
30.3.6 Structures and C++ classes
@@ -461,7 +522,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.
-
29.3.7 C++ inheritance
+
30.3.7 C++ inheritance
@@ -470,7 +531,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.
-
29.3.8 C++ overloaded functions
+
30.3.8 C++ overloaded functions
@@ -480,7 +541,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.
-
29.3.9 C++ operators
+
30.3.9 C++ operators
@@ -580,7 +641,11 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
-
29.3.10 Class extension with %extend
+
+Octave can also utilise friend (i.e. non-member) operators with a simple %rename: see the example in the Examples/octave/operator directory.
+
C++ smart pointers are fully supported as in other modules.
-
29.3.13 Directors (calling Octave from C++ code)
+
30.3.13 Directors (calling Octave from C++ code)
@@ -775,14 +840,14 @@ c-side routine called
octave-side routine called
-
29.3.14 Threads
+
30.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.
-
29.3.15 Memory management
+
30.3.15 Memory management
@@ -816,14 +881,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).
-
29.3.16 STL support
+
30.3.16 STL support
Various STL library files are provided for wrapping STL containers.
@@ -82,12 +82,12 @@
This chapter describes SWIG's support of Perl5. Although the Perl5
module is one of the earliest SWIG modules, it has continued to evolve
and has been improved greatly with the help of SWIG users. For the
-best results, it is recommended that SWIG be used with Perl5.003 or
-later. Earlier versions are problematic and SWIG generated extensions
-may not compile or run correctly.
+best results, it is recommended that SWIG be used with Perl 5.8 or
+later. We're no longer testing regularly with older versions, but
+Perl 5.6 seems to mostly work, while older versions don't.
-
30.1 Overview
+
31.1 Overview
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
-
30.2 Preliminaries
+
31.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.
-
30.2.1 Getting the right header files
+
31.2.1 Getting the right header files
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
-
30.2.2 Compiling a dynamic module
+
31.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.
-
30.2.3 Building a dynamic module with MakeMaker
+
31.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.
-
30.2.4 Building a static version of Perl
+
31.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.
-
30.2.5 Using the module
+
31.2.5 Using the module
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
30.2.6 Compilation problems and compiling with C++
+
31.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.
-
30.2.7 Compiling for 64-bit platforms
+
31.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).
-
30.3 Building Perl Extensions under Windows
+
31.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.
-
30.3.1 Running SWIG from Developer Studio
+
31.3.1 Running SWIG from Developer Studio
@@ -700,7 +700,7 @@ print "$a\n";
-
30.3.2 Using other compilers
+
31.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.
-
30.4 The low-level interface
+
31.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.
-
30.4.1 Functions
+
31.4.1 Functions
@@ -741,7 +741,7 @@ use example;
$a = &example::fact(2);
-
30.4.2 Global variables
+
31.4.2 Global variables
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
-
30.4.3 Constants
+
31.4.3 Constants
@@ -851,7 +851,7 @@ print example::FOO,"\n";
-
30.4.4 Pointers
+
31.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.
-
30.4.7 C++ classes and type-checking
+
31.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).
-
30.4.8 C++ overloaded functions
+
31.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.
-
30.4.9 Operators
+
31.4.9 Operators
@@ -1266,7 +1266,7 @@ The following C++ operators are currently supported by the Perl module:
operator or
-
30.4.10 Modules and packages
+
31.4.10 Modules and packages
@@ -1361,7 +1361,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
-->
-
30.5 Input and output parameters
+
31.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).
-
30.6 Exception handling
+
31.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.
-
30.7 Remapping datatypes with typemaps
+
31.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.
-
30.8.5 Turning Perl references into C pointers
+
31.8.5 Turning Perl references into C pointers
@@ -2423,7 +2423,7 @@ print "$c\n";
-
30.8.6 Pointer handling
+
31.8.6 Pointer handling
@@ -2502,7 +2502,7 @@ For example:
-
30.9 Proxy classes
+
31.9 Proxy classes
@@ -2518,7 +2518,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
-
30.9.1 Preliminaries
+
31.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.
-
30.9.2 Structure and class wrappers
+
31.9.2 Structure and class wrappers
@@ -2666,7 +2666,7 @@ $v->DESTROY();
-
30.9.3 Object Ownership
+
31.9.3 Object Ownership
@@ -2753,7 +2753,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
-SWIG supports generating wrappers for PHP5. Support for PHP4 has been removed
-as of SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases,
+SWIG supports generating wrappers for PHP5. Support for PHP4 was removed
+in SWIG 1.3.37. The PHP developers are no longer making new PHP4 releases,
and won't even be patching critical security issues after 2008-08-08, so it
-doesn't make much sense for SWIG to continue to support PHP4 at this point.
-If you need to continue to use PHP4, stick with SWIG 1.3.36.
+doesn't make much sense for SWIG to continue to support PHP4 now. If you
+really need to continue to use PHP4, just stick with SWIG 1.3.36.
+
+
+
+Currently any PHP5 release should work, but we don't regularly test with
+PHP < 5.3.
In this chapter, we discuss SWIG's support of PHP. The PHP module
was extensively rewritten in release 1.3.26, and support for generating
-OO wrappers for PHP5 was added in 1.3.30. The PHP module works fairly
-well, but currently does not implement all the
-features available in some of the other languages.
+OO wrappers for PHP5 was added in 1.3.30. The PHP module now supports most
+of the features available in some of the other languages.
@@ -75,7 +79,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
-
31.1 Generating PHP Extensions
+
32.1 Generating PHP Extensions
@@ -122,7 +126,7 @@ and it doesn't play nicely with package system. We don't recommend
this approach, or provide explicit support for it.
-
31.1.1 Building a loadable extension
+
32.1.1 Building a loadable extension
@@ -137,7 +141,7 @@ least work for Linux though):
gcc -shared example_wrap.o -o example.so
-
31.1.2 Using PHP Extensions
+
32.1.2 Using PHP Extensions
@@ -168,21 +172,22 @@ attempts to do the dl() call for you:
include("example.php");
-
31.2 Basic PHP interface
+
32.2 Basic PHP interface
It is important to understand that PHP uses a single global namespace
into which all symbols from extension modules are loaded. It is quite
possible for names of symbols in one extension module to clash with
-other symbols unless care is taken to %rename them.
+other symbols unless care is taken to %rename them. At present
+SWIG doesn't have support for the namespace feature added in PHP 5.3.
-
31.2.1 Constants
+
32.2.1 Constants
-These work in much the same way as in C/C++, constants can be defined
+These work in much the same way as in C/C++. Constants can be defined
by using either the normal C pre-processor declarations, or the
%constant SWIG directive. These will then be available from
your PHP script as a PHP constant, (i.e. no dollar sign is needed to
@@ -199,7 +204,7 @@ access them.) For example, with a swig interface file like this,
-you can access the constants in your php script like this,
+you can access the constants in your PHP script like this,
@@ -213,9 +218,16 @@ echo "E = " . E . "\n";
-There are two peculiarities with using constants in PHP. The first is that
-if you try to use an undeclared constant, it will evaluate to a string
-set to the constant's name. For example,
+There's one peculiarity of how constants work in PHP which it is useful
+to note (this is not specific to SWIG though) - if you try to use an undeclared
+constant, PHP will issue a warning and then expand the constant to a string
+version of the constant's name. The warning will often be missed though as
+if you're using PHP in a webserver, it will probably end up in error.log or
+similar.
+
+
+
+For example,
@@ -243,67 +255,12 @@ if(EASY_TO_MISPEL) {
-will issue a warning about the undeclared constant, but will then
-evaluate it and turn it into a string ('EASY_TO_MISPEL'), which
-evaluates to true, rather than the value of the constant which would
-be false. This is a feature!
+The mis-spelled constant will become the string 'EASY_TO_MISPEL', which
+is treated as true by the if test, when the value of the intended constant
+would be treated as false!
-
-The second 'feature' is that although constants are case sensitive (by
-default), you cannot declare a constant twice with alternative
-cases. E.g.,
-
-
-
-
-%module example
-
-#define TEST Hello
-#define Test World
-
-
-
-
-accessed from PHP,
-
-
-
-
-include("example.php");
-
-echo TEST, Test;
-
-
-
-
-will output "Hello Test" rather than "Hello World". This is because
-internally, all constants are stored in a hash table by their lower
-case name, so 'TEST' and 'Test' will map to the same hash element
-('Test'). But, because we declared them case sensitive, the Zend
-engine will test if the case matches with the case the constant was
-declared with first.
-
-
-
-So, in the example above, the TEST constant was declared first, and
-will be stored under the hash element 'test'. The 'Test' constant will
-also map to the same hash element 'test', but will not overwrite
-it. When called from the script, the TEST constant will again be
-mapped to the hash element 'test' so the constant will be
-retrieved. The case will then be checked, and will match up, so the
-value ('Hello') will be returned. When 'Test' is evaluated, it will
-also map to the same hash element 'test'. The same constant will be
-retrieved, this time though the case check will fail as 'Test' !=
-'TEST'. So PHP will assume that Test is a undeclared constant, and as
-explained above, will return it as a string set to the constant name
-('Test'). Hence the script above will print 'Hello Test'. If they were
-declared non-case sensitive, the output would be 'Hello Hello', as
-both point to the same value, without the case test taking place. (
-Apologies, this paragraph needs rewriting to make some sense. )
-
-
-
31.2.2 Global Variables
+
32.2.2 Global Variables
@@ -352,7 +309,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
-
31.2.3 Functions
+
32.2.3 Functions
@@ -405,7 +362,7 @@ print $s; # The value of $s was not changed.
-->
-
31.2.4 Overloading
+
32.2.4 Overloading
@@ -461,7 +418,7 @@ taking the integer argument.
-->
-
31.2.5 Pointers and References
+
32.2.5 Pointers and References
@@ -593,13 +550,15 @@ PHP in a number of ways: by using unset on an existing
variable, or assigning NULL to a variable.
-
31.2.6 Structures and C++ classes
+
32.2.6 Structures and C++ classes
-SWIG defaults to wrapping C++ structs and classes with PHP classes
-unless "-noproxy" is specified. For PHP5, a PHP wrapper
-class is generated which calls a set of flat functions wrapping the C++ class.
+SWIG defaults to wrapping C++ structs and classes with PHP classes - this
+is done by generating a PHP wrapper script which defines proxy classes
+which calls a set of flat functions which actually wrap the C++ class.
+You can disable this wrapper layer by passing the command-line option
+"-noproxy" in which case you'll just get the flat functions.
@@ -652,7 +611,7 @@ Would be used in the following way from PHP5:
Member variables and methods are accessed using the -> operator.
@@ -719,7 +678,7 @@ the programmer can either reassign the variable or call
unset($v)
-
31.2.6.3 Static Member Variables
+
32.2.6.3 Static Member Variables
@@ -762,7 +721,7 @@ Ko::threats(10);
echo "There has now been " . Ko::threats() . " threats\n";
-
31.2.6.4 Static Member Functions
+
32.2.6.4 Static Member Functions
@@ -784,7 +743,7 @@ Ko::threats();
-
31.2.7 PHP Pragmas, Startup and Shutdown code
+
32.2.7 PHP Pragmas, Startup and Shutdown code
@@ -872,7 +831,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.
-
31.3 Cross language polymorphism
+
32.3 Cross language polymorphism
@@ -907,7 +866,7 @@ wrapper functions takes care of all the cross-language method routing
transparently.
-
31.3.1 Enabling directors
+
32.3.1 Enabling directors
@@ -999,7 +958,7 @@ class MyFoo extends Foo {
-
31.3.2 Director classes
+
32.3.2 Director classes
@@ -1079,7 +1038,7 @@ so there is no need for the extra overhead involved with routing the
calls through PHP.
-
31.3.3 Ownership and object destruction
+
32.3.3 Ownership and object destruction
@@ -1135,7 +1094,7 @@ In this example, we are assuming that FooContainer will take care of
deleting all the Foo pointers it contains at some point.
-
31.3.4 Exception unrolling
+
32.3.4 Exception unrolling
@@ -1194,7 +1153,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception
as soon as the C wrapper function returns.
-
31.3.5 Overhead and code bloat
+
32.3.5 Overhead and code bloat
@@ -1227,7 +1186,7 @@ optimized by selectively enabling director methods (using the %feature
directive) for only those methods that are likely to be extended in PHP.
-
31.3.6 Typemaps
+
32.3.6 Typemaps
@@ -1241,7 +1200,7 @@ need to be supported.
-
31.3.7 Miscellaneous
+
32.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 8bd6b410f..8c1eb2d36 100644
--- a/Doc/Manual/Pike.html
+++ b/Doc/Manual/Pike.html
@@ -6,7 +6,7 @@
-
32 SWIG and Pike
+
33 SWIG and Pike
@@ -46,10 +46,10 @@ least, make sure you read the "SWIG Basics"
chapter.
-
32.1 Preliminaries
+
33.1 Preliminaries
-
32.1.1 Running SWIG
+
33.1.1 Running SWIG
@@ -94,7 +94,7 @@ can use the -o option:
$ swig -pike -o pseudonym.c example.i
-
32.1.2 Getting the right header files
+
33.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.
@@ -160,10 +162,10 @@ described followed by a discussion of low-level implementation
details.
-
33.2 Preliminaries
+
34.2 Preliminaries
-
33.2.1 Running SWIG
+
34.2.1 Running SWIG
@@ -261,7 +263,7 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
-
33.2.2 Using distutils
+
34.2.2 Using distutils
@@ -353,7 +355,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)
-
33.2.3 Hand compiling a dynamic module
+
34.2.3 Hand compiling a dynamic module
@@ -401,7 +403,7 @@ module actually consists of two files; socket.py and
-
33.2.4 Static linking
+
34.2.4 Static linking
@@ -480,7 +482,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
-
33.2.5 Using your module
+
34.2.5 Using your module
@@ -637,7 +639,7 @@ system configuration (this requires root access and you will need to
read the man pages).
-
33.2.6 Compilation of C++ extensions
+
34.2.6 Compilation of C++ extensions
@@ -729,7 +731,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
-
33.2.7 Compiling for 64-bit platforms
+
34.2.7 Compiling for 64-bit platforms
@@ -766,7 +768,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
-
33.2.8 Building Python Extensions under Windows
+
34.2.8 Building Python Extensions under Windows
@@ -875,7 +877,7 @@ SWIG Wiki.
-
33.3 A tour of basic C/C++ wrapping
+
34.3 A tour of basic C/C++ wrapping
@@ -884,7 +886,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.
-
33.3.1 Modules
+
34.3.1 Modules
@@ -897,7 +899,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
-
33.3.2 Functions
+
34.3.2 Functions
@@ -921,7 +923,7 @@ like you think it does:
>>>
-
33.3.3 Global variables
+
34.3.3 Global variables
@@ -1059,7 +1061,7 @@ that starts with a leading underscore. SWIG does not create cvar
if there are no global variables in a module.
-
33.3.4 Constants and enums
+
34.3.4 Constants and enums
@@ -1099,7 +1101,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
-
33.3.5 Pointers
+
34.3.5 Pointers
@@ -1240,7 +1242,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.
-
33.3.6 Structures
+
34.3.6 Structures
@@ -1429,7 +1431,7 @@ everything works just like you would expect. For example:
-
33.3.7 C++ classes
+
34.3.7 C++ classes
@@ -1518,7 +1520,7 @@ they are accessed through cvar like this:
-
33.3.8 C++ inheritance
+
34.3.8 C++ inheritance
@@ -1573,7 +1575,7 @@ then the function spam() accepts Foo * or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
-
33.3.9 Pointers, references, values, and arrays
+
34.3.9 Pointers, references, values, and arrays
@@ -1634,7 +1636,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
-
33.3.10 C++ overloaded functions
+
34.3.10 C++ overloaded functions
@@ -1757,7 +1759,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
-
33.3.11 C++ operators
+
34.3.11 C++ operators
@@ -1846,7 +1848,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.
-
33.3.12 C++ namespaces
+
34.3.12 C++ namespaces
@@ -1913,7 +1915,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
-
33.3.13 C++ templates
+
34.3.13 C++ templates
@@ -1967,7 +1969,7 @@ Some more complicated
examples will appear later.
-
33.3.14 C++ Smart Pointers
+
34.3.14 C++ Smart Pointers
@@ -2051,151 +2053,16 @@ simply use the __deref__() method. For example:
-
-
33.3.15 C++ Reference Counted Objects (ref/unref)
+
34.3.15 C++ reference counted objects
-Another usual idiom in C++ is the use of reference counted
-objects. Consider for example:
-
-
-
-class RCObj {
- // implement the ref counting mechanism
- int add_ref();
- int del_ref();
- int ref_count();
-
-public:
- virtual ~RCObj() = 0;
-
- int ref() const {
- return add_ref();
- }
-
- int unref() const {
- if (ref_count() == 0 || del_ref() == 0 ) {
- delete this;
- return 0;
- }
- return ref_count();
- }
-};
-
-
-class A : RCObj {
-public:
- A();
- int foo();
-};
-
-
-class B {
- A *_a;
-
-public:
- B(A *a) : _a(a) {
- a->ref();
- }
-
- ~B() {
- a->unref();
- }
-};
-
-int main() {
- A *a = new A();
- a->ref(); // 'a' is ref here
-
- B *b1 = new B(a); // 'a' is ref here
- if (1 + 1 == 2) {
- B *b2 = new B(a); // 'a' is ref here
- delete b2; // 'a' is unref, but not deleted
- }
-
- delete b1; // 'a' is unref, but not deleted
- a->unref(); // 'a' is unref and deleted
-}
-
-
-
-
-In the example above, the 'A' class instance 'a' is a reference counted
-object, which can't be deleted arbitrarily since it is shared between
-the objects 'b1' and 'b2'. 'A' is derived from an Reference Counted
-Object 'RCObj', which implements the ref/unref idiom.
-
-
-
-To tell SWIG that 'RCObj' and all its derived classes are reference
-counted objects, you use the "ref" and "unref" features.
-For example:
+The C++ reference counted objects section contains
+Python examples of memory management using referencing counting.
-where the code passed to the "ref" and "unref" features will be
-executed as needed whenever a new object is passed to python, or when
-python tries to release the shadow object instance, respectively.
-
-
-
-In the python side, the use of a reference counted object is not
-different than any other regular instance:
-
-
-
-
-def create_A():
- a = A() # SWIG ref 'a' (new object is passed to python)
- b1 = B(a) # C++ ref 'a'
- if 1 + 1 == 2:
- b2 = B(a) # C++ ref 'a'
- return a # 'b1' and 'b2' are released, C++ unref 'a' twice
-
-a = create_A()
-exit # 'a' is released, SWIG unref 'a'
-
-
-
-
-Note that the user doesn't explicitly need to call 'a->ref()' nor 'a->unref()'
-(as neither 'delete a'). Instead, SWIG take cares of executing the "ref"
-and "unref" codes as needed. If the user doesn't specify the
-"ref/unref" features, SWIG will produce a code equivalent to define
-them as:
-
-In other words, SWIG will not do anything special when a new object
-is passed to python, and it will always 'delete' the object when
-python releases the proxy instance.
-
-
-
-
33.4 Further details on the Python class interface
+
34.4 Further details on the Python class interface
Use of the -builtin option implies a couple of limitations:
@@ -2519,7 +2386,7 @@ assert(issubclass(B.Derived, A.Base))
-
33.4.2.2 Operator overloads -- use them!
+
34.4.2.2 Operator overloads -- use them!
The entire justification for the -builtin option is improved
@@ -2620,7 +2487,7 @@ structs.
-
33.4.3 Memory management
+
34.4.3 Memory management
NOTE: Although this section refers to proxy objects, everything here also applies
@@ -2815,7 +2682,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
-
33.4.4 Python 2.2 and classic classes
+
34.4.4 Python 2.2 and classic classes
@@ -2852,7 +2719,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).
-
33.5 Cross language polymorphism
+
34.5 Cross language polymorphism
@@ -2886,7 +2753,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
-
33.5.1 Enabling directors
+
34.5.1 Enabling directors
@@ -2979,7 +2846,7 @@ class MyFoo(mymodule.Foo):
-
33.5.2 Director classes
+
34.5.2 Director classes
@@ -3061,7 +2928,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
-
33.5.3 Ownership and object destruction
+
34.5.3 Ownership and object destruction
@@ -3128,7 +2995,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
-
33.5.4 Exception unrolling
+
34.5.4 Exception unrolling
@@ -3187,7 +3054,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
-
33.5.5 Overhead and code bloat
+
34.5.5 Overhead and code bloat
@@ -3221,7 +3088,7 @@ directive) for only those methods that are likely to be extended in
Python.
-
33.5.6 Typemaps
+
34.5.6 Typemaps
@@ -3235,7 +3102,7 @@ need to be supported.
-
33.5.7 Miscellaneous
+
34.5.7 Miscellaneous
@@ -3282,7 +3149,7 @@ methods that return const references.
-
33.6 Common customization features
+
34.6 Common customization features
@@ -3295,7 +3162,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
-
33.6.1 C/C++ helper functions
+
34.6.1 C/C++ helper functions
@@ -3376,7 +3243,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
-
33.6.2 Adding additional Python code
+
34.6.2 Adding additional Python code
@@ -3525,7 +3392,7 @@ public:
-
33.6.3 Class extension with %extend
+
34.6.3 Class extension with %extend
@@ -3614,7 +3481,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
-
33.6.4 Exception handling with %exception
+
34.6.4 Exception handling with %exception
@@ -3740,7 +3607,7 @@ The language-independent exception.i library file can also be used
to raise exceptions. See the SWIG Library chapter.
-
33.7 Tips and techniques
+
34.7 Tips and techniques
@@ -3750,7 +3617,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
-
33.7.1 Input and output parameters
+
34.7.1 Input and output parameters
@@ -3963,7 +3830,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since typemaps.i does not define an OUTPUT rule for Bar.
-
33.7.2 Simple pointers
+
34.7.2 Simple pointers
@@ -4032,7 +3899,7 @@ If you replace %pointer_functions() by %pointer_class(type,name)SWIG Library chapter for further details.
-
33.7.3 Unbounded C Arrays
+
34.7.3 Unbounded C Arrays
@@ -4094,7 +3961,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
-
33.7.4 String handling
+
34.7.4 String handling
@@ -4163,7 +4030,7 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
-
33.8 Typemaps
+
34.8 Typemaps
@@ -4180,7 +4047,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.
-
33.8.1 What is a typemap?
+
34.8.1 What is a typemap?
@@ -4296,7 +4163,7 @@ parameter is omitted):
-
33.8.2 Python typemaps
+
34.8.2 Python typemaps
@@ -4337,7 +4204,7 @@ a look at the SWIG library version 1.3.20 or so.
-
33.8.3 Typemap variables
+
34.8.3 Typemap variables
@@ -4408,7 +4275,7 @@ properly assigned.
The Python name of the wrapper function being created.
-
33.8.4 Useful Python Functions
+
34.8.4 Useful Python Functions
@@ -4536,7 +4403,7 @@ write me
-
33.9 Typemap Examples
+
34.9 Typemap Examples
@@ -4545,7 +4412,7 @@ might look at the files "python.swg" and "typemaps.i" in
the SWIG library.
-
33.9.1 Converting Python list to a char **
+
34.9.1 Converting Python list to a char **
@@ -4625,7 +4492,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
-
33.9.2 Expanding a Python object into multiple arguments
+
34.9.2 Expanding a Python object into multiple arguments
@@ -4704,7 +4571,7 @@ to supply the argument count. This is automatically set by the typemap code. F
-
33.9.3 Using typemaps to return arguments
+
34.9.3 Using typemaps to return arguments
@@ -4793,7 +4660,7 @@ function can now be used as follows:
>>>
-
33.9.4 Mapping Python tuples into small arrays
+
34.9.4 Mapping Python tuples into small arrays
@@ -4842,7 +4709,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
-
33.9.5 Mapping sequences to C arrays
+
34.9.5 Mapping sequences to C arrays
@@ -4931,7 +4798,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
-
33.9.6 Pointer handling
+
34.9.6 Pointer handling
@@ -5028,7 +4895,7 @@ class object (if applicable).
-
33.10 Docstring Features
+
34.10 Docstring Features
@@ -5056,7 +4923,7 @@ of your users much simpler.
-
33.10.1 Module docstring
+
34.10.1 Module docstring
@@ -5090,7 +4957,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
-
33.10.2 %feature("autodoc")
+
34.10.2 %feature("autodoc")
@@ -5114,14 +4981,15 @@ introspection, then life is good once more.
which when attached to a node in the parse tree will cause a docstring
to be generated that includes the name of the function, parameter
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.
+four levels for autodoc controlled by the value given to the
+feature, %feature("autodoc", "level").
+The four values for level are covered in the following sub-sections.
-
33.10.2.1 %feature("autodoc", "0")
+
34.10.2.1 %feature("autodoc", "0")
-When the "0" option is given then the types of the parameters will
+When level "0" is used then the types of the parameters will
not be included in the autodoc string. For example, given
this function prototype:
-When the "1" option is used then the parameter types will be
+When level "1" is used then the parameter types will be
used in the autodoc string. In addition, an attempt is made to
simplify the type name such that it makes more sense to the Python
-user. Pointer, reference and const info is removed,
-%rename's are evaluated, etc. (This is not always
-successful, but works most of the time. See the next section for what
-to do when it doesn't.) Given the example above, then turning on the
-parameter types with the "1" option will result in Python code like
+user. Pointer, reference and const info is removed if the associated type
+is has an associated Python type (%rename's are thus shown correctly).
+This works most of the time, otherwise a C/C++ type will be used.
+See the next section for the "docstring" feature for tweaking the docstrings to your liking.
+Given the example above, then turning on the
+parameter types with level "1" will result in Python code like
this:
+Level "2" results in the function prototype as per level "0". In addition, a line of
+documentation is generated for each parameter. Using the previous example, the generated
+code will be:
+
+
+
+
+def function_name(*args, **kwargs):
+ """
+ function_name(x, y, foo=None, bar=None) -> bool
+
+ Parameters:
+ x: int
+ y: int
+ foo: Foo *
+ bar: Bar *
+
+ """
+ ...
+
+
+
+
+Note that the documentation for each parameter is sourced from the "doc" typemap which by default shows the
+C/C++ type rather than the simplified Python type name described earlier for level "1".
+Typemaps can of course change the output for any particular type, for example the int x parameter:
+
+
+
+
+%feature("autodoc", "2");
+%typemap("doc") int x "$1_name (C++ type: $1_type) -- Input $1_name dimension"
+bool function_name(int x, int y, Foo* foo=NULL, Bar* bar=NULL);
+
+
+
+
+resulting in
+
+
+
+
+def function_name(*args, **kwargs):
+ """
+ function_name(x, y, foo=None, bar=None) -> bool
+
+ Parameters:
+ x (C++ type: int) -- Input x dimension
+ y: int
+ foo: Foo *
+ bar: Bar *
+
+ """
+
+
+
+
34.10.2.4 %feature("autodoc", "3")
+
+
+
+Level "3" results in the function prototype as per level "1" but also contains the same additional line of documentation for each parameter as per level "2". Using our earlier example again, the generated code will be:
+
+
+
+
+def function_name(*args, **kwargs):
+ """
+ function_name(int x, int y, Foo foo=None, Bar bar=None) -> bool
+
+ Parameters:
+ x: int
+ y: int
+ foo: Foo *
+ bar: Bar *
+
+ """
+ ...
+
@@ -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++.
-
34.1 Bugs
+
35.1 Bugs
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
C Array wrappings
-
34.2 Using R and SWIG
+
35.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
-
34.3 Precompiling large R files
+
35.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.
-
34.4 General policy
+
35.4 General policy
@@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
-
34.5 Language conventions
+
35.5 Language conventions
@@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
-
34.6 C++ classes
+
35.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.
-
35.1.1 Running SWIG
+
36.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.
-
35.1.2 Getting the right header files
+
36.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:
-
35.1.3 Compiling a dynamic module
+
36.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.
-
35.1.4 Using your module
+
36.1.4 Using your module
Ruby module names must be capitalized,
@@ -488,7 +488,7 @@ begins with:
-
35.1.5 Static linking
+
36.1.5 Static linking
An alternative approach to dynamic linking is to rebuild the
@@ -509,7 +509,7 @@ finally rebuilding Ruby.
-
35.1.6 Compilation of C++ extensions
+
36.1.6 Compilation of C++ extensions
On most machines, C++ extension modules should be linked
@@ -561,7 +561,7 @@ extension, e.g.
-
35.2 Building Ruby Extensions under Windows 95/NT
+
36.2 Building Ruby Extensions under Windows 95/NT
Building a SWIG extension to Ruby under Windows 95/NT is
@@ -600,7 +600,7 @@ files.
-
35.2.1 Running SWIG from Developer Studio
+
36.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:
-
35.3 The Ruby-to-C/C++ Mapping
+
36.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.
-
35.6.4 Exception classes
+
36.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.
-
35.7 Typemaps
+
36.7 Typemaps
This section describes how you can modify SWIG's default
@@ -4696,7 +4696,7 @@ of the primitive C-Ruby interface.
-
35.7.1 What is a typemap?
+
36.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):
-
35.7.2 Typemap scope
+
36.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:
-
35.7.3 Copying a typemap
+
36.7.3 Copying a typemap
A typemap is copied by using assignment. For example:
@@ -5108,7 +5108,7 @@ rules as for
-
35.7.4 Deleting a typemap
+
36.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.
-
35.7.5 Placement of typemaps
+
36.7.5 Placement of typemaps
Typemap declarations can be declared in the global scope,
@@ -5244,7 +5244,7 @@ string
-
35.7.6 Ruby typemaps
+
36.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:
-
35.7.6.1 "in" typemap
+
36.7.6.1 "in" typemap
Converts Ruby objects to input
@@ -5497,7 +5497,7 @@ arguments to be specified. For example:
-
35.7.6.2 "typecheck" typemap
+
36.7.6.2 "typecheck" typemap
The "typecheck" typemap is used to support overloaded
@@ -5538,7 +5538,7 @@ on "Typemaps and Overloading."
-
35.7.6.3 "out" typemap
+
36.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.
-
35.7.6.4 "arginit" typemap
+
36.7.6.4 "arginit" typemap
The "arginit" typemap is used to set the initial value of a
@@ -5795,7 +5795,7 @@ applications. For example:
-
35.7.6.5 "default" typemap
+
36.7.6.5 "default" typemap
The "default" typemap is used to turn an argument into a
@@ -5837,7 +5837,7 @@ default argument wrapping.
-
35.7.6.6 "check" typemap
+
36.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:
-
35.7.6.7 "argout" typemap
+
36.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.
-
35.7.6.8 "freearg" typemap
+
36.7.6.8 "freearg" typemap
The "freearg" typemap is used to cleanup argument data. It is
@@ -6055,7 +6055,7 @@ abort prematurely.
-
35.7.6.9 "newfree" typemap
+
36.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.
-
35.7.6.10 "memberin" typemap
+
36.7.6.10 "memberin" typemap
The "memberin" typemap is used to copy data from an
@@ -6119,7 +6119,7 @@ other objects.
-
35.7.6.11 "varin" typemap
+
36.7.6.11 "varin" typemap
The "varin" typemap is used to convert objects in the target
@@ -6130,7 +6130,7 @@ This is implementation specific.
-
35.7.6.12 "varout" typemap
+
36.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.
-
35.7.6.13 "throws" typemap
+
36.7.6.13 "throws" typemap
The "throws" typemap is only used when SWIG parses a C++
@@ -6200,7 +6200,7 @@ handling with %exception section.
-
35.7.6.14 directorin typemap
+
36.7.6.14 directorin typemap
Converts C++ objects in director
@@ -6454,7 +6454,7 @@ referring to the class itself.
-
35.7.6.15 directorout typemap
+
36.7.6.15 directorout typemap
Converts Ruby objects in director
@@ -6517,49 +6517,16 @@ typemap.
-
-
-
-
-
-
$symname
-
-
-
-
-
-
Name of
-function/method being wrapped
-
-
-
-
-
+
$input
+
Ruby object being sent to the function
+
+
+
$symname
+
Name of function/method being wrapped
-
-
-
-
-
-
-
-
-
-
$1...n
-
-
-
-
-
-
Argument being
-sent to the function
-
-
-
-
-
+
Argument being sent to the function
@@ -6714,7 +6681,7 @@ exception.
-
35.7.6.16 directorargout typemap
+
36.7.6.16 directorargout typemap
Output argument processing in director
@@ -6763,80 +6730,21 @@ $result = output_helper( $result, NUM2INT($1) );
-
-
-
-
-
$result
-
-
-
-
-
-
Result that the
-director function returns
-
-
-
-
-
+
Result that the director function returns
+
+
+
$input
+
Ruby object being sent to the function
-
-
-
-
-
-
-
-
-
-
$symname
-
-
-
-
-
-
name of the
-function/method being wrapped
-
-
-
-
-
+
name of the function/method being wrapped
-
-
-
-
-
-
-
-
-
-
$1...n
-
-
-
-
-
-
Argument being
-sent to the function
-
-
-
-
-
+
Argument being sent to the function
-
-
-
-
-
@@ -6954,7 +6862,7 @@ referring to the instance of the class itself
-
35.7.6.17 ret typemap
+
36.7.6.17 ret typemap
Cleanup of function return values
@@ -6964,7 +6872,7 @@ referring to the instance of the class itself
-
35.7.6.18 globalin typemap
+
36.7.6.18 globalin typemap
Setting of C global variables
@@ -6974,7 +6882,7 @@ referring to the instance of the class itself
-
35.7.7 Typemap variables
+
36.7.7 Typemap variables
@@ -7084,7 +6992,7 @@ being created.
-
35.7.8 Useful Functions
+
36.7.8 Useful Functions
When you write a typemap, you usually have to work directly
@@ -7108,7 +7016,7 @@ across multiple languages.
-
35.7.8.1 C Datatypes to Ruby Objects
+
36.7.8.1 C Datatypes to Ruby Objects
@@ -7164,7 +7072,7 @@ SWIG_From_float(float)
-
35.7.8.2 Ruby Objects to C Datatypes
+
36.7.8.2 Ruby Objects to C Datatypes
Here, while the Ruby versions return the value directly, the SWIG
@@ -7253,7 +7161,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-
The Ruby language doesn't support multiple inheritance, but
@@ -9796,7 +9704,7 @@ Features") for more details).
-
35.10 Memory Management
+
36.10 Memory Management
One of the most common issues in generating SWIG bindings for
@@ -9843,7 +9751,7 @@ understanding of how the underlying library manages memory.
-
35.10.1 Mark and Sweep Garbage Collector
+
36.10.1 Mark and Sweep Garbage Collector
Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9891,7 +9799,7 @@ this memory.
-
35.10.2 Object Ownership
+
36.10.2 Object Ownership
As described above, memory management depends on clearly
@@ -10149,7 +10057,7 @@ public:
-
35.10.3 Object Tracking
+
36.10.3 Object Tracking
The remaining parts of this section will use the class library
@@ -10400,7 +10308,7 @@ methods.
-
35.10.4 Mark Functions
+
36.10.4 Mark Functions
With a bit more testing, we see that our class library still
@@ -10518,7 +10426,7 @@ test suite.
-
35.10.5 Free Functions
+
36.10.5 Free Functions
By default, SWIG creates a "free" function that is called when
@@ -10768,7 +10676,7 @@ been freed, and thus raises a runtime exception.
-
35.10.6 Embedded Ruby and the C++ Stack
+
36.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/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index c8e5ee870..b4baca6ae 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -57,6 +57,7 @@
In this case, the %extend directive is not needed, and
-%template does the exactly same job, i.e., it adds two new
+%template does exactly the same job, i.e., it adds two new
methods to the Foo class.
@@ -4618,8 +4619,179 @@ p = f.__deref__() # Raw pointer from operator->
Note: Smart pointer support was first added in SWIG-1.3.14.
+
6.25 C++ reference counted objects - ref/unref feature
-
6.25 Using declarations and inheritance
+
+
+Another similar idiom in C++ is the use of reference counted objects. Consider for example:
+
+
+
+class RCObj {
+ // implement the ref counting mechanism
+ int add_ref();
+ int del_ref();
+ int ref_count();
+
+public:
+ virtual ~RCObj() = 0;
+
+ int ref() const {
+ return add_ref();
+ }
+
+ int unref() const {
+ if (ref_count() == 0 || del_ref() == 0 ) {
+ delete this;
+ return 0;
+ }
+ return ref_count();
+ }
+};
+
+
+class A : RCObj {
+public:
+ A();
+ int foo();
+};
+
+
+class B {
+ A *_a;
+
+public:
+ B(A *a) : _a(a) {
+ a->ref();
+ }
+
+ ~B() {
+ a->unref();
+ }
+};
+
+int main() {
+ A *a = new A(); // (count: 0)
+ a->ref(); // 'a' ref here (count: 1)
+
+ B *b1 = new B(a); // 'a' ref here (count: 2)
+ if (1 + 1 == 2) {
+ B *b2 = new B(a); // 'a' ref here (count: 3)
+ delete b2; // 'a' unref, but not deleted (count: 2)
+ }
+
+ delete b1; // 'a' unref, but not deleted (count: 1)
+ a->unref(); // 'a' unref and deleted (count: 0)
+}
+
+
+
+
+In the example above, the 'A' class instance 'a' is a reference counted
+object, which can't be deleted arbitrarily since it is shared between
+the objects 'b1' and 'b2'. 'A' is derived from a Reference Counted
+ Object 'RCObj', which implements the ref/unref idiom.
+
+
+
+To tell SWIG that 'RCObj' and all its derived classes are reference
+counted objects, use the "ref" and "unref" features.
+These are also available as %refobject and %unrefobject, respectively.
+For example:
+
+where the code passed to the "ref" and "unref" features will be
+executed as needed whenever a new object is passed to python, or when
+python tries to release the proxy object instance, respectively.
+
+
+
+On the python side, the use of a reference counted object is no
+different to any other regular instance:
+
+
+
+
+def create_A():
+ a = A() # SWIG ref 'a' - new object is passed to python (count: 1)
+ b1 = B(a) # C++ ref 'a (count: 2)
+ if 1 + 1 == 2:
+ b2 = B(a) # C++ ref 'a' (count: 3)
+ return a # 'b1' and 'b2' are released and deleted, C++ unref 'a' twice (count: 1)
+
+a = create_A() # (count: 1)
+exit # 'a' is released, SWIG unref 'a' called in the destructor wrapper (count: 0)
+
+
+
+
+Note that the user doesn't explicitly need to call 'a->ref()' nor 'a->unref()'
+(and neither 'delete a'). Instead, SWIG takes cares of executing the "ref"
+and "unref" calls as needed. If the user doesn't specify the
+"ref/unref" feature for a type, SWIG will produce code equivalent to defining these
+features:
+
+In other words, SWIG will not do anything special when a new object
+is passed to python, and it will always 'delete' the underlying object when
+python releases the proxy instance.
+
+
+
+The %newobject feature is designed to indicate to
+the target language that it should take ownership of the returned object.
+When used in conjunction with a type that has the "ref" feature associated with it, it additionally emits the
+code in the "ref" feature into the C++ wrapper.
+Consider wrapping the following factory function in addition to the above:
+
@@ -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.
-
36.1 Preliminaries
+
37.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.
-
36.1.1 Getting the right header files
+
37.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
-
36.1.2 Compiling a dynamic module
+
37.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.
-
36.1.3 Static linking
+
37.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).
-
36.1.4 Using your module
+
37.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).
-
36.1.5 Compilation of C++ extensions
+
37.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.
-
36.1.6 Compiling for 64-bit platforms
+
37.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).
-
36.1.7 Setting a package prefix
+
37.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".
-
36.1.8 Using namespaces
+
37.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.
-
36.2 Building Tcl/Tk Extensions under Windows 95/NT
+
37.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.
-
36.2.1 Running SWIG from Developer Studio
+
37.2.1 Running SWIG from Developer Studio
@@ -576,7 +576,7 @@ MSDOS > tclsh80
%
-
36.2.2 Using NMAKE
+
37.2.2 Using NMAKE
@@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
-
36.3 A tour of basic C/C++ wrapping
+
37.3 A tour of basic C/C++ wrapping
@@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
-
36.3.1 Modules
+
37.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.
-
36.3.5 Pointers
+
37.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.
-
36.3.6 Structures
+
37.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.
-
36.3.7 C++ classes
+
37.3.7 C++ classes
@@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows:
-
36.3.8 C++ inheritance
+
37.3.8 C++ inheritance
@@ -1367,7 +1367,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
-
36.3.9 Pointers, references, values, and arrays
+
37.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).
-
36.3.10 C++ overloaded functions
+
37.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.
-
36.3.11 C++ operators
+
37.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.
-
36.3.12 C++ namespaces
+
37.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.
-
36.7 Typemaps
+
37.7 Typemaps
@@ -2451,7 +2451,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
-
36.7.1 What is a typemap?
+
37.7.1 What is a typemap?
@@ -2568,7 +2568,7 @@ parameter is omitted):
-
36.7.2 Tcl typemaps
+
37.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.
-
36.7.3 Typemap variables
+
37.7.3 Typemap variables
@@ -2777,7 +2777,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
-
36.7.4 Converting a Tcl list to a char **
+
37.7.4 Converting a Tcl list to a char **
@@ -2839,7 +2839,7 @@ argv[2] = Larry
3
-
36.7.5 Returning values in arguments
+
37.7.5 Returning values in arguments
@@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this :
%
-
36.7.6 Useful functions
+
37.7.6 Useful functions
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
-
36.7.7 Standard typemaps
+
37.7.7 Standard typemaps
@@ -3042,7 +3042,7 @@ work)
-
36.7.8 Pointer handling
+
37.7.8 Pointer handling
@@ -3118,7 +3118,7 @@ For example:
-
36.8 Turning a SWIG module into a Tcl Package.
+
37.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.
-
36.9 Building new kinds of Tcl interfaces (in Tcl)
+
37.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).
-
36.9.1 Proxy classes
+
37.9.1 Proxy classes
@@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
Fragment type specialization
@@ -3597,7 +3598,16 @@ with non-consecutive C/C++ arguments; a workaround such as a helper function re-
the arguments to make them consecutive will need to be written.
-
10.10 Typemap fragments
+
10.10 Typemap warnings
+
+
+
+Warnings can be added to typemaps so that SWIG generates a warning message whenever the typemap is used.
+See the information in the issuing warnings section.
+
+
+
+
10.11 Typemap fragments
@@ -3846,7 +3856,7 @@ fragment usage unless a desire to really get to grips
with some powerful but tricky macro and fragment usage that is used in parts of the SWIG typemap library.
-
10.10.1 Fragment type specialization
+
10.11.1 Fragment type specialization
@@ -3879,7 +3889,7 @@ struct A {
-
10.10.2 Fragments and automatic typemap specialization
+
10.11.2 Fragments and automatic typemap specialization
@@ -3925,7 +3935,7 @@ The interested (or very brave) reader can take a look at the fragments.swg file
-
10.11 The run-time type checker
+
10.12 The run-time type checker
@@ -3951,7 +3961,7 @@ language modules.
Modules can be unloaded from the type system.
-
10.11.1 Implementation
+
10.12.1 Implementation
@@ -4137,7 +4147,7 @@ structures rather than creating new ones. These swig_module_info
structures are chained together in a circularly linked list.
-
10.11.2 Usage
+
10.12.2 Usage
This section covers how to use these functions from typemaps. To learn how to
@@ -4231,7 +4241,7 @@ probably just look at the output of SWIG to get a better sense for how types are
managed.
-
10.12 Typemaps and overloading
+
10.13 Typemaps and overloading
@@ -4542,7 +4552,7 @@ Subsequent "in" typemaps would then perform more extensive type-checking.
-
10.13 More about %apply and %clear
+
10.14 More about %apply and %clear
@@ -4628,7 +4638,7 @@ example:
-
10.14 Passing data between typemaps
+
10.15 Passing data between typemaps
@@ -4665,7 +4675,7 @@ sure that the typemaps sharing information have exactly the same types and names
-
10.15 C++ "this" pointer
+
10.16 C++ "this" pointer
@@ -4725,7 +4735,7 @@ will also match the typemap. One work around is to create an interface file tha
the method, but gives the argument a name other than self.
-
10.16 Where to go for more information?
+
10.17 Where to go for more information?
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 60552b97a..2a3ce560d 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -257,16 +257,23 @@ Warning messages can be associated with typemaps using the
-%typemap(in, warning="901:You are really going to regret this") blah * {
+%typemap(in, warning="901:You are really going to regret this usage of $1_type $1_name") blah * {
...
}
-In this case, the warning message will be printed whenever the typemap is actually used.
+In this case, the warning message will be printed whenever the typemap is actually used and the special variables will be expanded as appropriate, for example:
+
+
+example.i:23: Warning 901: You are really going to regret this usage of blah * self
+example.i:24: Warning 901: You are really going to regret this usage of blah * stuff
+
+
+
14.5 Symbolic symbols
@@ -501,7 +508,7 @@ example.i(4) : Syntax error in input.
501. Overloaded declaration ignored. decl. Previous declaration is decl.
502. Overloaded constructor ignored. decl. Previous declaration is decl.
503. Can't wrap 'identifier' unless renamed to a valid identifier.
-
504. Function name must have a return type.
+
504. Function name must have a return type. Ignored.
505. Variable length arguments discarded.
506. Can't wrap varargs with keyword arguments enabled.
507. Adding native function name not supported (ignored).
@@ -518,6 +525,7 @@ example.i(4) : Syntax error in input.
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.
+
521. Illegal destructor name name. Ignored.
14.9.6 Language module specific (700-899)
diff --git a/Doc/Manual/Windows.html b/Doc/Manual/Windows.html
index da8a5d6bf..6349f355a 100644
--- a/Doc/Manual/Windows.html
+++ b/Doc/Manual/Windows.html
@@ -313,6 +313,18 @@ If you want to check out SWIG to a different folder to the proposed
the autotools will fail miserably on those.
+
+The PCRE third party library needs to be built next.
+Download the latest PCRE source tarball, such as pcre-8.10.tar.bz2, from
+PCRE and place in the /usr/src/swig directory.
+Build PCRE as a static library using the Tools/pcre-build.sh script as follows:
+
+
+cd /usr/src/swig
+Tools/pcre-build.sh
+
+
+
You are now ready to build SWIG. Execute the following commands to build swig.exe:
diff --git a/Doc/Manual/android-class.png b/Doc/Manual/android-class.png
new file mode 100644
index 000000000..f7061cb3a
Binary files /dev/null and b/Doc/Manual/android-class.png differ
diff --git a/Doc/Manual/android-simple.png b/Doc/Manual/android-simple.png
new file mode 100644
index 000000000..234674cba
Binary files /dev/null and b/Doc/Manual/android-simple.png differ
diff --git a/Doc/Manual/ch11.1.png b/Doc/Manual/ch11.1.png
deleted file mode 100644
index 2cc2becd4..000000000
Binary files a/Doc/Manual/ch11.1.png and /dev/null differ
diff --git a/Doc/Manual/ch11.2.png b/Doc/Manual/ch11.2.png
deleted file mode 100644
index e6d1b55ea..000000000
Binary files a/Doc/Manual/ch11.2.png and /dev/null differ
diff --git a/Doc/Manual/ch11.3.png b/Doc/Manual/ch11.3.png
deleted file mode 100644
index 54ee72442..000000000
Binary files a/Doc/Manual/ch11.3.png and /dev/null differ
diff --git a/Doc/Manual/ch12.1.png b/Doc/Manual/ch12.1.png
deleted file mode 100644
index 2072f06a4..000000000
Binary files a/Doc/Manual/ch12.1.png and /dev/null differ
diff --git a/Doc/Manual/ch9.table.2.png b/Doc/Manual/ch9.table.2.png
deleted file mode 100644
index ac6647e17..000000000
Binary files a/Doc/Manual/ch9.table.2.png and /dev/null differ
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 924c8cfde..40e227164 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -15,6 +15,7 @@ Warnings.html
Modules.html
CCache.html
Allegrocl.html
+Android.html
CSharp.html
Chicken.html
D.html
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 180ab90ed..2530c2c20 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -12,7 +12,7 @@
# certain packages have been installed. Set the prefixes
# accordingly.
#
-# 2. To use this makefile, set required varibles, eg SRCS, INTERFACE,
+# 2. To use this makefile, set required variables, eg SRCS, INTERFACE,
# INTERFACEDIR, INCLUDES, LIBS, TARGET, and do a
# $(MAKE) -f Makefile.template.in SRCS='$(SRCS)' \
# INCLUDES='$(INCLUDES) LIBS='$(LIBS)' INTERFACE='$(INTERFACE)' \
@@ -333,6 +333,7 @@ python_clean:
# Make sure these locate your Octave installation
OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@
OCTAVE_LIB =
+OCTAVE = @OCTAVE@ -qf
# Extra Octave specific dynamic linking options
OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@
@@ -358,6 +359,17 @@ octave_cpp: $(SRCS)
$(CXX) -g -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) -I$(OCTAVE_INCLUDE)
$(CXXSHARED) -g $(CFLAGS) $(OBJS) $(IOBJS) $(OCTAVE_DLNK) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(OCTAVE_SO)
+# -----------------------------------------------------------------
+# Running an Octave example
+# -----------------------------------------------------------------
+
+OCTSCRIPT = runme.m
+
+octave_run: $(OCTSCRIPT)
+ for file in $(OCTSCRIPT); do \
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVEPATH=$(srcdir):$$OCTAVEPATH $(OCTAVE) $$file >/dev/null || break; \
+ done
+
# -----------------------------------------------------------------
# Cleaning the octave examples
# -----------------------------------------------------------------
@@ -1298,11 +1310,6 @@ else
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
# ----------------------------------------------------------------
diff --git a/Examples/android/check.list b/Examples/android/check.list
new file mode 100644
index 000000000..69d56a4f6
--- /dev/null
+++ b/Examples/android/check.list
@@ -0,0 +1,3 @@
+# see top-level Makefile.in
+class
+simple
diff --git a/Examples/android/class/AndroidManifest.xml b/Examples/android/class/AndroidManifest.xml
new file mode 100644
index 000000000..45c1fb1c7
--- /dev/null
+++ b/Examples/android/class/AndroidManifest.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/android/class/Makefile b/Examples/android/class/Makefile
new file mode 100644
index 000000000..7de95f559
--- /dev/null
+++ b/Examples/android/class/Makefile
@@ -0,0 +1,29 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = example
+INTERFACE = example.i
+PACKAGEDIR = src/org/swig
+PACKAGENAME= org.swig.classexample
+SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/classexample
+PROJECTNAME= SwigClass
+TARGETID = 1
+
+all:: android
+
+android::
+ android update project --target $(TARGETID) --name $(PROJECTNAME) --path .
+ $(SWIG) -c++ -java $(SWIGOPT) -o jni/$(TARGET)_wrap.cpp jni/$(INTERFACE)
+ ndk-build
+ ant debug
+
+install::
+ -adb uninstall $(PACKAGENAME)
+ adb install bin/$(PROJECTNAME)-debug.apk
+
+clean::
+ ant clean
+ rm -f jni/$(TARGET)_wrap.cpp
+ rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java`
+
+
+check: all
diff --git a/Examples/android/class/ant.properties b/Examples/android/class/ant.properties
new file mode 100644
index 000000000..ee52d86d9
--- /dev/null
+++ b/Examples/android/class/ant.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
diff --git a/Examples/android/class/build.xml b/Examples/android/class/build.xml
new file mode 100644
index 000000000..fe06943a9
--- /dev/null
+++ b/Examples/android/class/build.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/android/class/jni/Android.mk b/Examples/android/class/jni/Android.mk
new file mode 100644
index 000000000..25d42b541
--- /dev/null
+++ b/Examples/android/class/jni/Android.mk
@@ -0,0 +1,10 @@
+# File: Android.mk
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := example
+LOCAL_SRC_FILES := example_wrap.cpp example.cpp
+LOCAL_CFLAGS := -frtti
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/Examples/android/class/jni/example.cpp b/Examples/android/class/jni/example.cpp
new file mode 100644
index 000000000..d59cc7c32
--- /dev/null
+++ b/Examples/android/class/jni/example.cpp
@@ -0,0 +1,28 @@
+/* File : example.cpp */
+
+#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/android/class/jni/example.h b/Examples/android/class/jni/example.h
new file mode 100644
index 000000000..64b7684fa
--- /dev/null
+++ b/Examples/android/class/jni/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/android/class/jni/example.i b/Examples/android/class/jni/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Examples/android/class/jni/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Examples/android/class/local.properties b/Examples/android/class/local.properties
new file mode 100644
index 000000000..14b8d63b4
--- /dev/null
+++ b/Examples/android/class/local.properties
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked in Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/home/william/android/android-sdk-linux_x86
diff --git a/Examples/android/class/proguard.cfg b/Examples/android/class/proguard.cfg
new file mode 100644
index 000000000..b1cdf17b5
--- /dev/null
+++ b/Examples/android/class/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native ;
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/Examples/android/class/project.properties b/Examples/android/class/project.properties
new file mode 100644
index 000000000..ea89160e0
--- /dev/null
+++ b/Examples/android/class/project.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/Examples/android/class/res/layout/main.xml b/Examples/android/class/res/layout/main.xml
new file mode 100644
index 000000000..d4e5d7fe8
--- /dev/null
+++ b/Examples/android/class/res/layout/main.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
diff --git a/Examples/android/class/res/values/strings.xml b/Examples/android/class/res/values/strings.xml
new file mode 100644
index 000000000..72910f9d7
--- /dev/null
+++ b/Examples/android/class/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+
+ SwigClass
+
diff --git a/Examples/android/class/src/org/swig/classexample/SwigClass.java b/Examples/android/class/src/org/swig/classexample/SwigClass.java
new file mode 100644
index 000000000..2860cdd9d
--- /dev/null
+++ b/Examples/android/class/src/org/swig/classexample/SwigClass.java
@@ -0,0 +1,106 @@
+package org.swig.classexample;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.text.method.ScrollingMovementMethod;
+
+public class SwigClass extends Activity
+{
+ TextView outputText = null;
+ ScrollView scroller = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ outputText = (TextView)findViewById(R.id.OutputText);
+ outputText.setText("Press 'Run' to start...\n");
+ outputText.setMovementMethod(new ScrollingMovementMethod());
+
+ scroller = (ScrollView)findViewById(R.id.Scroller);
+ }
+
+ public void onRunButtonClick(View view)
+ {
+ outputText.append("Started...\n");
+ nativeCall();
+ outputText.append("Finished!\n");
+
+ // Ensure scroll to end of text
+ scroller.post(new Runnable() {
+ public void run() {
+ scroller.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ });
+ }
+
+ /** Calls into C/C++ code */
+ public void nativeCall()
+ {
+ // ----- Object creation -----
+
+ outputText.append( "Creating some objects:\n" );
+ Circle c = new Circle(10);
+ outputText.append( " Created circle " + c + "\n");
+ Square s = new Square(10);
+ outputText.append( " Created square " + s + "\n");
+
+ // ----- Access a static member -----
+
+ outputText.append( "\nA total of " + Shape.getNshapes() + " shapes were created\n" );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.setX(20);
+ c.setY(30);
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.setX(-10);
+ shape.setY(5);
+
+ outputText.append( "\nHere is their current position:\n" );
+ outputText.append( " Circle = (" + c.getX() + " " + c.getY() + ")\n" );
+ outputText.append( " Square = (" + s.getX() + " " + s.getY() + ")\n" );
+
+ // ----- Call some methods -----
+
+ outputText.append( "\nHere are some properties of the shapes:\n" );
+ Shape[] shapes = {c,s};
+ for (int i=0; i
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/android/simple/Makefile b/Examples/android/simple/Makefile
new file mode 100644
index 000000000..1e95de6e3
--- /dev/null
+++ b/Examples/android/simple/Makefile
@@ -0,0 +1,29 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+TARGET = example
+INTERFACE = example.i
+PACKAGEDIR = src/org/swig
+PACKAGENAME= org.swig.simple
+SWIGOPT = -package $(PACKAGENAME) -outdir $(PACKAGEDIR)/simple
+PROJECTNAME= SwigSimple
+TARGETID = 1
+
+all:: android
+
+android::
+ android update project --target $(TARGETID) --name $(PROJECTNAME) --path .
+ $(SWIG) -java $(SWIGOPT) -o jni/$(TARGET)_wrap.c jni/$(INTERFACE)
+ ndk-build
+ ant debug
+
+install::
+ -adb uninstall $(PACKAGENAME)
+ adb install bin/$(PROJECTNAME)-debug.apk
+
+clean::
+ ant clean
+ rm -f jni/$(TARGET)_wrap.c
+ rm -f `find $(PACKAGEDIR) -name \*.java | grep -v $(PROJECTNAME).java`
+
+
+check: all
diff --git a/Examples/android/simple/ant.properties b/Examples/android/simple/ant.properties
new file mode 100644
index 000000000..ee52d86d9
--- /dev/null
+++ b/Examples/android/simple/ant.properties
@@ -0,0 +1,17 @@
+# This file is used to override default values used by the Ant build system.
+#
+# This file must be checked in Version Control Systems, as it is
+# integral to the build system of your project.
+
+# This file is only used by the Ant script.
+
+# You can use this to override default values such as
+# 'source.dir' for the location of your java source folder and
+# 'out.dir' for the location of your output folder.
+
+# You can also use it define how the release builds are signed by declaring
+# the following properties:
+# 'key.store' for the location of your keystore and
+# 'key.alias' for the name of the key to use.
+# The password will be asked during the build when you use the 'release' target.
+
diff --git a/Examples/android/simple/build.xml b/Examples/android/simple/build.xml
new file mode 100644
index 000000000..09a0bff37
--- /dev/null
+++ b/Examples/android/simple/build.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/android/simple/jni/Android.mk b/Examples/android/simple/jni/Android.mk
new file mode 100644
index 000000000..b2f2dadb5
--- /dev/null
+++ b/Examples/android/simple/jni/Android.mk
@@ -0,0 +1,9 @@
+# File: Android.mk
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := example
+LOCAL_SRC_FILES := example_wrap.c example.c
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/Examples/android/simple/jni/example.c b/Examples/android/simple/jni/example.c
new file mode 100644
index 000000000..9325fd70c
--- /dev/null
+++ b/Examples/android/simple/jni/example.c
@@ -0,0 +1,17 @@
+/* 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/android/simple/jni/example.i b/Examples/android/simple/jni/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/android/simple/jni/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/android/simple/local.properties b/Examples/android/simple/local.properties
new file mode 100644
index 000000000..14b8d63b4
--- /dev/null
+++ b/Examples/android/simple/local.properties
@@ -0,0 +1,10 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must *NOT* be checked in Version Control Systems,
+# as it contains information specific to your local configuration.
+
+# location of the SDK. This is only used by Ant
+# For customization when using a Version Control System, please read the
+# header note.
+sdk.dir=/home/william/android/android-sdk-linux_x86
diff --git a/Examples/android/simple/proguard.cfg b/Examples/android/simple/proguard.cfg
new file mode 100644
index 000000000..b1cdf17b5
--- /dev/null
+++ b/Examples/android/simple/proguard.cfg
@@ -0,0 +1,40 @@
+-optimizationpasses 5
+-dontusemixedcaseclassnames
+-dontskipnonpubliclibraryclasses
+-dontpreverify
+-verbose
+-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
+
+-keep public class * extends android.app.Activity
+-keep public class * extends android.app.Application
+-keep public class * extends android.app.Service
+-keep public class * extends android.content.BroadcastReceiver
+-keep public class * extends android.content.ContentProvider
+-keep public class * extends android.app.backup.BackupAgentHelper
+-keep public class * extends android.preference.Preference
+-keep public class com.android.vending.licensing.ILicensingService
+
+-keepclasseswithmembernames class * {
+ native ;
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet);
+}
+
+-keepclasseswithmembers class * {
+ public (android.content.Context, android.util.AttributeSet, int);
+}
+
+-keepclassmembers class * extends android.app.Activity {
+ public void *(android.view.View);
+}
+
+-keepclassmembers enum * {
+ public static **[] values();
+ public static ** valueOf(java.lang.String);
+}
+
+-keep class * implements android.os.Parcelable {
+ public static final android.os.Parcelable$Creator *;
+}
diff --git a/Examples/android/simple/project.properties b/Examples/android/simple/project.properties
new file mode 100644
index 000000000..ea89160e0
--- /dev/null
+++ b/Examples/android/simple/project.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/Examples/android/simple/res/layout/main.xml b/Examples/android/simple/res/layout/main.xml
new file mode 100644
index 000000000..d4e5d7fe8
--- /dev/null
+++ b/Examples/android/simple/res/layout/main.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
diff --git a/Examples/android/simple/res/values/strings.xml b/Examples/android/simple/res/values/strings.xml
new file mode 100644
index 000000000..881c19c8d
--- /dev/null
+++ b/Examples/android/simple/res/values/strings.xml
@@ -0,0 +1,4 @@
+
+
+ SwigSimple
+
diff --git a/Examples/android/simple/src/org/swig/simple/SwigSimple.java b/Examples/android/simple/src/org/swig/simple/SwigSimple.java
new file mode 100644
index 000000000..575fdc5ce
--- /dev/null
+++ b/Examples/android/simple/src/org/swig/simple/SwigSimple.java
@@ -0,0 +1,75 @@
+package org.swig.simple;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.View;
+import android.widget.Button;
+import android.widget.TextView;
+import android.widget.ScrollView;
+import android.text.method.ScrollingMovementMethod;
+
+public class SwigSimple extends Activity
+{
+ TextView outputText = null;
+ ScrollView scroller = null;
+
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ outputText = (TextView)findViewById(R.id.OutputText);
+ outputText.setText("Press 'Run' to start...\n");
+ outputText.setMovementMethod(new ScrollingMovementMethod());
+
+ scroller = (ScrollView)findViewById(R.id.Scroller);
+ }
+
+ public void onRunButtonClick(View view)
+ {
+ outputText.append("Started...\n");
+ nativeCall();
+ outputText.append("Finished!\n");
+
+ // Ensure scroll to end of text
+ scroller.post(new Runnable() {
+ public void run() {
+ scroller.fullScroll(ScrollView.FOCUS_DOWN);
+ }
+ });
+ }
+
+ /** Calls into C/C++ code */
+ public void nativeCall()
+ {
+ // Call our gcd() function
+
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x,y);
+ outputText.append("The greatest common divisor of " + x + " and " + y + " is " + g + "\n");
+
+ // Manipulate the Foo global variable
+
+ // Output its current value
+ double foo = example.getFoo();
+ outputText.append("Foo = " + foo + "\n");
+
+ // Change its value
+ example.setFoo(3.1415926);
+
+ // See if the change took effect
+ outputText.append("Foo = " + example.getFoo() + "\n");
+
+ // Restore value
+ example.setFoo(foo);
+ }
+
+ /** static constructor */
+ static {
+ System.loadLibrary("example");
+ }
+}
+
diff --git a/Examples/csharp/callback/example-cs.csproj b/Examples/csharp/callback/example-cs.csproj
index 5fc34527f..ce5ccfd9a 100644
--- a/Examples/csharp/callback/example-cs.csproj
+++ b/Examples/csharp/callback/example-cs.csproj
@@ -1,99 +1,99 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/callback/example-vc.vcproj b/Examples/csharp/callback/example-vc.vcproj
index 7c0b8ef13..5788bc9c7 100644
--- a/Examples/csharp/callback/example-vc.vcproj
+++ b/Examples/csharp/callback/example-vc.vcproj
@@ -1,158 +1,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/callback/example.sln b/Examples/csharp/callback/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/callback/example.sln
+++ b/Examples/csharp/callback/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/class/example-cs.csproj b/Examples/csharp/class/example-cs.csproj
index 0b9ea2e05..8b105d7fc 100644
--- a/Examples/csharp/class/example-cs.csproj
+++ b/Examples/csharp/class/example-cs.csproj
@@ -1,104 +1,104 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/class/example-vc.vcproj b/Examples/csharp/class/example-vc.vcproj
index 7c0b8ef13..5788bc9c7 100644
--- a/Examples/csharp/class/example-vc.vcproj
+++ b/Examples/csharp/class/example-vc.vcproj
@@ -1,158 +1,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/class/example.sln b/Examples/csharp/class/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/class/example.sln
+++ b/Examples/csharp/class/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/enum/example-cs.csproj b/Examples/csharp/enum/example-cs.csproj
index 9d37ce2b4..44face8ed 100644
--- a/Examples/csharp/enum/example-cs.csproj
+++ b/Examples/csharp/enum/example-cs.csproj
@@ -1,99 +1,99 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/enum/example-vc.vcproj b/Examples/csharp/enum/example-vc.vcproj
index 7c0b8ef13..5788bc9c7 100644
--- a/Examples/csharp/enum/example-vc.vcproj
+++ b/Examples/csharp/enum/example-vc.vcproj
@@ -1,158 +1,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/enum/example.sln b/Examples/csharp/enum/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/enum/example.sln
+++ b/Examples/csharp/enum/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/extend/example-cs.csproj b/Examples/csharp/extend/example-cs.csproj
index 4e8874669..95923991b 100644
--- a/Examples/csharp/extend/example-cs.csproj
+++ b/Examples/csharp/extend/example-cs.csproj
@@ -1,104 +1,104 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/extend/example-vc.vcproj b/Examples/csharp/extend/example-vc.vcproj
index 7c0b8ef13..5788bc9c7 100644
--- a/Examples/csharp/extend/example-vc.vcproj
+++ b/Examples/csharp/extend/example-vc.vcproj
@@ -1,158 +1,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/extend/example.sln b/Examples/csharp/extend/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/extend/example.sln
+++ b/Examples/csharp/extend/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/funcptr/example-cs.csproj b/Examples/csharp/funcptr/example-cs.csproj
index 5ff0d9da9..5a107c528 100644
--- a/Examples/csharp/funcptr/example-cs.csproj
+++ b/Examples/csharp/funcptr/example-cs.csproj
@@ -1,94 +1,94 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/funcptr/example-vc.vcproj b/Examples/csharp/funcptr/example-vc.vcproj
index 03047bfb0..7ba8cbde1 100644
--- a/Examples/csharp/funcptr/example-vc.vcproj
+++ b/Examples/csharp/funcptr/example-vc.vcproj
@@ -1,160 +1,160 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/funcptr/example.sln b/Examples/csharp/funcptr/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/funcptr/example.sln
+++ b/Examples/csharp/funcptr/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/reference/example-cs.csproj b/Examples/csharp/reference/example-cs.csproj
index e55912bdc..a3efbe036 100644
--- a/Examples/csharp/reference/example-cs.csproj
+++ b/Examples/csharp/reference/example-cs.csproj
@@ -1,99 +1,99 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/reference/example-vc.vcproj b/Examples/csharp/reference/example-vc.vcproj
index 7c0b8ef13..5788bc9c7 100644
--- a/Examples/csharp/reference/example-vc.vcproj
+++ b/Examples/csharp/reference/example-vc.vcproj
@@ -1,158 +1,158 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/reference/example.sln b/Examples/csharp/reference/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/reference/example.sln
+++ b/Examples/csharp/reference/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/simple/example-cs.csproj b/Examples/csharp/simple/example-cs.csproj
index d801057d9..3d91f9a47 100644
--- a/Examples/csharp/simple/example-cs.csproj
+++ b/Examples/csharp/simple/example-cs.csproj
@@ -1,89 +1,89 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/simple/example-vc.vcproj b/Examples/csharp/simple/example-vc.vcproj
index 14f50049b..ec289c6eb 100644
--- a/Examples/csharp/simple/example-vc.vcproj
+++ b/Examples/csharp/simple/example-vc.vcproj
@@ -1,222 +1,222 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/simple/example.sln b/Examples/csharp/simple/example.sln
index 9967f7e20..3ebbba5c6 100644
--- a/Examples/csharp/simple/example.sln
+++ b/Examples/csharp/simple/example.sln
@@ -1,26 +1,26 @@
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual C++ Express 2005
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Win32 = Debug|Win32
- Release|Win32 = Release|Win32
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|Any CPU
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|Any CPU
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 9.00
+# Visual C++ Express 2005
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Win32 = Debug|Win32
+ Release|Win32 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug|Win32.ActiveCfg = Debug|Any CPU
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release|Win32.ActiveCfg = Release|Any CPU
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug|Win32.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release|Win32.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/template/example-cs.csproj b/Examples/csharp/template/example-cs.csproj
index b51122ba6..bf17c141f 100644
--- a/Examples/csharp/template/example-cs.csproj
+++ b/Examples/csharp/template/example-cs.csproj
@@ -1,109 +1,109 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/template/example-vc.vcproj b/Examples/csharp/template/example-vc.vcproj
index 867e694c1..f7bbbcb62 100644
--- a/Examples/csharp/template/example-vc.vcproj
+++ b/Examples/csharp/template/example-vc.vcproj
@@ -1,157 +1,157 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/template/example.sln b/Examples/csharp/template/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/template/example.sln
+++ b/Examples/csharp/template/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/csharp/variables/example-cs.csproj b/Examples/csharp/variables/example-cs.csproj
index f0e015929..a73c879fb 100644
--- a/Examples/csharp/variables/example-cs.csproj
+++ b/Examples/csharp/variables/example-cs.csproj
@@ -1,99 +1,99 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/variables/example-vc.vcproj b/Examples/csharp/variables/example-vc.vcproj
index be0dfc742..acd55a379 100644
--- a/Examples/csharp/variables/example-vc.vcproj
+++ b/Examples/csharp/variables/example-vc.vcproj
@@ -1,157 +1,157 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/csharp/variables/example.sln b/Examples/csharp/variables/example.sln
index 28b9851b0..88995ffd3 100644
--- a/Examples/csharp/variables/example.sln
+++ b/Examples/csharp/variables/example.sln
@@ -1,30 +1,30 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
- ProjectSection(ProjectDependencies) = postProject
- {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
- EndProjectSection
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
- ProjectSection(ProjectDependencies) = postProject
- EndProjectSection
-EndProject
-Global
- GlobalSection(SolutionConfiguration) = preSolution
- Debug = Debug
- Release = Release
- EndGlobalSection
- GlobalSection(ProjectConfiguration) = postSolution
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
- {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
- {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- EndGlobalSection
- GlobalSection(ExtensibilityAddIns) = postSolution
- EndGlobalSection
-EndGlobal
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "example-cs", "example-cs.csproj", "{C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}"
+ ProjectSection(ProjectDependencies) = postProject
+ {C2302635-D489-4678-96B4-70F5309DCBE6} = {C2302635-D489-4678-96B4-70F5309DCBE6}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example-vc", "example-vc.vcproj", "{C2302635-D489-4678-96B4-70F5309DCBE6}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.ActiveCfg = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Debug.Build.0 = Debug|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.ActiveCfg = Release|.NET
+ {C17D27DF-4C57-4625-AEE0-A40C4F48FF1A}.Release.Build.0 = Release|.NET
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.ActiveCfg = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Debug.Build.0 = Debug|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.ActiveCfg = Release|Win32
+ {C2302635-D489-4678-96B4-70F5309DCBE6}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/Examples/d/variables/d2/runme.d b/Examples/d/variables/d2/runme.d
index f80b81819..6e18d2d64 100644
--- a/Examples/d/variables/d2/runme.d
+++ b/Examples/d/variables/d2/runme.d
@@ -66,6 +66,7 @@ void main() {
example.pt = example.ptptr;
write( "The new value is " );
+ stdout.flush();
example.pt_print();
writefln( "You should see the value %s", example.Point_print(example.ptptr) );
}
diff --git a/Examples/go/extend/runme.go b/Examples/go/extend/runme.go
index 796c5ce68..187f1ce08 100644
--- a/Examples/go/extend/runme.go
+++ b/Examples/go/extend/runme.go
@@ -24,7 +24,6 @@ func main() {
fmt.Println("Just call her \"", e.GetTitle(), "\"")
fmt.Println("----------------------")
-
// Create a new EmployeeList instance. This class does not
// have a C++ director wrapper, but can be used freely with
// other classes that do.
diff --git a/Examples/octave/callback/Makefile b/Examples/octave/callback/Makefile
index 2bce9df5d..21fb21137 100644
--- a/Examples/octave/callback/Makefile
+++ b/Examples/octave/callback/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/check.list b/Examples/octave/check.list
index 1e6608151..e9c719231 100644
--- a/Examples/octave/check.list
+++ b/Examples/octave/check.list
@@ -9,6 +9,7 @@ funcptr
funcptr2
functor
operator
+module_load
pointer
reference
simple
diff --git a/Examples/octave/class/Makefile b/Examples/octave/class/Makefile
index 2bce9df5d..21fb21137 100644
--- a/Examples/octave/class/Makefile
+++ b/Examples/octave/class/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/constants/Makefile b/Examples/octave/constants/Makefile
index 4d80c6f19..3156eae84 100644
--- a/Examples/octave/constants/Makefile
+++ b/Examples/octave/constants/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/contract/Makefile b/Examples/octave/contract/Makefile
index 627b0a977..464b74122 100644
--- a/Examples/octave/contract/Makefile
+++ b/Examples/octave/contract/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/enum/Makefile b/Examples/octave/enum/Makefile
index 2bce9df5d..21fb21137 100644
--- a/Examples/octave/enum/Makefile
+++ b/Examples/octave/enum/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/extend/Makefile b/Examples/octave/extend/Makefile
index 2bce9df5d..21fb21137 100644
--- a/Examples/octave/extend/Makefile
+++ b/Examples/octave/extend/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/funcptr/Makefile b/Examples/octave/funcptr/Makefile
index 627b0a977..464b74122 100644
--- a/Examples/octave/funcptr/Makefile
+++ b/Examples/octave/funcptr/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/funcptr2/Makefile b/Examples/octave/funcptr2/Makefile
index 627b0a977..464b74122 100644
--- a/Examples/octave/funcptr2/Makefile
+++ b/Examples/octave/funcptr2/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/functor/Makefile b/Examples/octave/functor/Makefile
index d910de530..8f6dfc73e 100644
--- a/Examples/octave/functor/Makefile
+++ b/Examples/octave/functor/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/module_load/Makefile b/Examples/octave/module_load/Makefile
new file mode 100644
index 000000000..4266ec184
--- /dev/null
+++ b/Examples/octave/module_load/Makefile
@@ -0,0 +1,26 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+OCTSCRIPTS = \
+ runme_args.m \
+ runme_gl_func.m \
+ runme_gl_func_base.m \
+ runme_nogl_func.m \
+ runme_nogl_func_base.m
+
+all::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' octave
+
+static::
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='myoctave' INTERFACE='$(INTERFACE)' octave_static
+
+clean::
+ $(MAKE) -f $(TOP)/Makefile octave_clean
+ rm -f $(TARGET).m
+
+check: all
+ $(MAKE) -f $(TOP)/Makefile OCTSCRIPT="$(OCTSCRIPTS)" octave_run
diff --git a/Examples/octave/module_load/example.c b/Examples/octave/module_load/example.c
new file mode 100644
index 000000000..7fd2e4aa0
--- /dev/null
+++ b/Examples/octave/module_load/example.c
@@ -0,0 +1,9 @@
+/* File : example.c */
+
+#include "example.h"
+
+int ivar = 47;
+
+int ifunc() {
+ return ivar;
+}
diff --git a/Examples/octave/module_load/example.h b/Examples/octave/module_load/example.h
new file mode 100644
index 000000000..5cee24f9e
--- /dev/null
+++ b/Examples/octave/module_load/example.h
@@ -0,0 +1,5 @@
+/* File: example.h */
+
+extern int ivar;
+
+int ifunc();
diff --git a/Examples/octave/module_load/example.i b/Examples/octave/module_load/example.i
new file mode 100644
index 000000000..f5a50444d
--- /dev/null
+++ b/Examples/octave/module_load/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+extern "C" int ivar;
+
+int ifunc();
diff --git a/Examples/octave/module_load/runme_args.m b/Examples/octave/module_load/runme_args.m
new file mode 100644
index 000000000..271cdd289
--- /dev/null
+++ b/Examples/octave/module_load/runme_args.m
@@ -0,0 +1,40 @@
+# file: runme_args.m
+
+# test module loading with arguments
+
+##### BEGIN TEST #####
+# test help
+example -help
+assert(!isglobal("example"))
+
+# load module with custom cvar
+example -globals mycvar
+assert(!isglobal("cvar"))
+assert(mycvar.ivar == example.ifunc())
+##### END TEST #####
+
+# clearing a module results in a segfault for Octave <= 3.0.*
+# (tested on Octave 3.0.5), so skip the following test
+try
+ vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
+catch
+ vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
+end_try_catch
+assert(length(vers) >= 2);
+if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
+ disp("skipping 'clear all' test");
+ return
+endif
+
+clear all;
+
+##### BEGIN TEST #####
+# test help
+example -help
+assert(!isglobal("example"))
+
+# load module with custom cvar
+example -globals mycvar
+assert(!isglobal("cvar"))
+assert(mycvar.ivar == example.ifunc())
+##### END TEST #####
diff --git a/Examples/octave/module_load/runme_gl_func.m b/Examples/octave/module_load/runme_gl_func.m
new file mode 100644
index 000000000..1624cdd9a
--- /dev/null
+++ b/Examples/octave/module_load/runme_gl_func.m
@@ -0,0 +1,59 @@
+# file: runme_gl_func.m
+
+# test whether module can be loaded
+# in a function (global cvar)
+
+1;
+
+##### BEGIN TEST #####
+function func
+ example
+ global cvar
+ assert(cvar.ivar == example.ifunc())
+endfunction
+
+# test that everything works from the base context
+example
+global cvar
+assert(cvar.ivar == example.ifunc())
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+##### END TEST #####
+
+# clearing a module results in a segfault for Octave <= 3.0.*
+# (tested on Octave 3.0.5), so skip the following test
+try
+ vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
+catch
+ vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
+end_try_catch
+assert(length(vers) >= 2);
+if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
+ disp("skipping 'clear all' test");
+ return
+endif
+
+clear all;
+
+##### BEGIN TEST #####
+function func
+ example
+ global cvar
+ assert(cvar.ivar == example.ifunc())
+endfunction
+
+# test that everything works from the base context
+example
+global cvar
+assert(cvar.ivar == example.ifunc())
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+##### END TEST #####
diff --git a/Examples/octave/module_load/runme_gl_func_base.m b/Examples/octave/module_load/runme_gl_func_base.m
new file mode 100644
index 000000000..0e3eb6112
--- /dev/null
+++ b/Examples/octave/module_load/runme_gl_func_base.m
@@ -0,0 +1,59 @@
+# file: runme_gl_func_base.m
+
+# test whether module can be loaded in a function
+# before the base context (global cvar)
+
+1;
+
+##### BEGIN TEST #####
+function func
+ example
+ global cvar
+ assert(cvar.ivar == example.ifunc())
+endfunction
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+
+# test that everything works from the base context
+example
+global cvar
+assert(cvar.ivar == example.ifunc())
+##### END TEST #####
+
+# clearing a module results in a segfault for Octave <= 3.0.*
+# (tested on Octave 3.0.5), so skip the following test
+try
+ vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
+catch
+ vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
+end_try_catch
+assert(length(vers) >= 2);
+if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
+ disp("skipping 'clear all' test");
+ return
+endif
+
+clear all;
+
+##### BEGIN TEST #####
+function func
+ example
+ global cvar
+ assert(cvar.ivar == example.ifunc())
+endfunction
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+
+# test that everything works from the base context
+example
+global cvar
+assert(cvar.ivar == example.ifunc())
+##### END TEST #####
diff --git a/Examples/octave/module_load/runme_nogl_func.m b/Examples/octave/module_load/runme_nogl_func.m
new file mode 100644
index 000000000..fd8e19f37
--- /dev/null
+++ b/Examples/octave/module_load/runme_nogl_func.m
@@ -0,0 +1,55 @@
+# file: runme_nogl_func.m
+
+# test whether module can be loaded
+# in a function (no global cvar)
+
+1;
+
+##### BEGIN TEST #####
+function func
+ example -noglobal
+ assert(example.cvar.ivar == example.ifunc())
+endfunction
+
+# test that everything works from the base context
+example -noglobal
+assert(example.cvar.ivar == example.ifunc())
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+##### END TEST #####
+
+# clearing a module results in a segfault for Octave <= 3.0.*
+# (tested on Octave 3.0.5), so skip the following test
+try
+ vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
+catch
+ vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
+end_try_catch
+assert(length(vers) >= 2);
+if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
+ disp("skipping 'clear all' test");
+ return
+endif
+
+clear all;
+
+##### BEGIN TEST #####
+function func
+ example -noglobal
+ assert(example.cvar.ivar == example.ifunc())
+endfunction
+
+# test that everything works from the base context
+example -noglobal
+assert(example.cvar.ivar == example.ifunc())
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+##### END TEST #####
diff --git a/Examples/octave/module_load/runme_nogl_func_base.m b/Examples/octave/module_load/runme_nogl_func_base.m
new file mode 100644
index 000000000..bb8da9328
--- /dev/null
+++ b/Examples/octave/module_load/runme_nogl_func_base.m
@@ -0,0 +1,55 @@
+# file: runme_nogl_func_base.m
+
+# test whether module can be loaded in a function
+# before the base context (no global cvar)
+
+1;
+
+##### BEGIN TEST #####
+function func
+ example -noglobal
+ assert(example.cvar.ivar == example.ifunc())
+endfunction
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+
+# test that everything works from the base context
+example -noglobal
+assert(example.cvar.ivar == example.ifunc())
+##### END TEST #####
+
+# clearing a module results in a segfault for Octave <= 3.0.*
+# (tested on Octave 3.0.5), so skip the following test
+try
+ vers = cellfun("str2num", strsplit(OCTAVE_VERSION, "."));
+catch
+ vers = cellfun("str2num", cellstr(split(OCTAVE_VERSION, ".")));
+end_try_catch
+assert(length(vers) >= 2);
+if vers(1) < 3 || (vers(1) == 3 && vers(2) == 0)
+ disp("skipping 'clear all' test");
+ return
+endif
+
+clear all;
+
+##### BEGIN TEST #####
+function func
+ example -noglobal
+ assert(example.cvar.ivar == example.ifunc())
+endfunction
+
+# test loading in a function
+func
+
+# test a second time to check everything works
+func
+
+# test that everything works from the base context
+example -noglobal
+assert(example.cvar.ivar == example.ifunc())
+##### END TEST #####
diff --git a/Examples/octave/operator/Makefile b/Examples/octave/operator/Makefile
index 6e625d538..de818a41a 100644
--- a/Examples/octave/operator/Makefile
+++ b/Examples/octave/operator/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).m
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/operator/example.h b/Examples/octave/operator/example.h
index 526f262b9..a9b69e009 100644
--- a/Examples/octave/operator/example.h
+++ b/Examples/octave/operator/example.h
@@ -30,7 +30,6 @@ public:
double im() const { return ipart; }
};
-
-
-
-
+ComplexVal operator*(const double &s, const ComplexVal &c) {
+ return ComplexVal(s*c.re(), s*c.im());
+}
diff --git a/Examples/octave/operator/example.i b/Examples/octave/operator/example.i
index d4bba5c53..7b903e69b 100644
--- a/Examples/octave/operator/example.i
+++ b/Examples/octave/operator/example.i
@@ -5,20 +5,21 @@
#include "example.h"
%}
+/* Rename friend operator */
+%rename(op_scalar_mul_ComplexVal) operator*(const double&, const ComplexVal&);
+
/* Now grab the original header file */
%include "example.h"
/* An output method that turns a complex into a short string */
%extend ComplexVal {
- char *__str() {
+ char *__str__() {
static char temp[512];
sprintf(temp,"(%g,%g)", $self->re(), $self->im());
return temp;
}
- ComplexVal __paren(int j) {
+ ComplexVal __paren__(int j) {
return ComplexVal($self->re()*j,$self->im()*j);
}
};
-
-
diff --git a/Examples/octave/operator/runme.m b/Examples/octave/operator/runme.m
index e0f590694..85fd99ad4 100644
--- a/Examples/octave/operator/runme.m
+++ b/Examples/octave/operator/runme.m
@@ -4,21 +4,23 @@ example
a = example.ComplexVal(2,3);
b = example.ComplexVal(-5,10);
-printf("a = %s\n",a);
-printf("b = %s\n",b);
+printf("a = %s\n",disp(a));
+printf("b = %s\n",disp(b));
c = a + b;
-printf("c = %s\n",c);
-printf("a*b = %s\n",a*b);
-printf("a-c = %s\n",a-c);
+printf("c = %s\n",disp(c));
+printf("a*b = %s\n",disp(a*b));
+printf("a-c = %s\n",disp(a-c));
e = example.ComplexVal(a-c);
-printf("e = %s\n",e);
+printf("e = %s\n",disp(e));
# Big expression
f = ((a+b)*(c+b*e)) + (-a);
-printf("f = %s\n",f);
+printf("f = %s\n",disp(f));
# paren overloading
-printf("a(3)= %s\n",a(3));
+printf("a(3)= %s\n",disp(a(3)));
+# friend operator
+printf("2*a = %s\n",disp(2*a));
diff --git a/Examples/octave/pointer/Makefile b/Examples/octave/pointer/Makefile
index 627b0a977..464b74122 100644
--- a/Examples/octave/pointer/Makefile
+++ b/Examples/octave/pointer/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/reference/Makefile b/Examples/octave/reference/Makefile
index 2bce9df5d..21fb21137 100644
--- a/Examples/octave/reference/Makefile
+++ b/Examples/octave/reference/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/simple/Makefile b/Examples/octave/simple/Makefile
index 627b0a977..464b74122 100644
--- a/Examples/octave/simple/Makefile
+++ b/Examples/octave/simple/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/template/Makefile b/Examples/octave/template/Makefile
index 3d7445a66..d64487430 100644
--- a/Examples/octave/template/Makefile
+++ b/Examples/octave/template/Makefile
@@ -19,3 +19,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/octave/variables/Makefile b/Examples/octave/variables/Makefile
index 627b0a977..464b74122 100644
--- a/Examples/octave/variables/Makefile
+++ b/Examples/octave/variables/Makefile
@@ -17,3 +17,4 @@ clean::
rm -f $(TARGET).py
check: all
+ $(MAKE) -f $(TOP)/Makefile octave_run
diff --git a/Examples/test-suite/autodoc.i b/Examples/test-suite/autodoc.i
index c363e4384..599a3f12f 100644
--- a/Examples/test-suite/autodoc.i
+++ b/Examples/test-suite/autodoc.i
@@ -1,9 +1,9 @@
-%module(docstring="hello") python_autodoc
+%module(docstring="hello") autodoc
%feature("autodoc");
-// especial typemap and its docs
-%typemap(in) (int c, int d) "$1 =0; $2 = 0;";
+// special typemap and its docs
+%typemap(in) (int c, int d) "$1 = 0; $2 = 0;";
%typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
// testing for different documentation levels
@@ -12,7 +12,22 @@
%feature("autodoc","2") A::func2; // extended
%feature("autodoc","3") A::func3; // extended + types
-%feature("autodoc","just a string") A::func; // names
+%feature("autodoc","0") A::func0default; // names
+%feature("autodoc","1") A::func1default; // names + types
+%feature("autodoc","2") A::func2default; // extended
+%feature("autodoc","3") A::func3default; // extended + types
+
+%feature("autodoc","0") A::func0static; // names
+%feature("autodoc","1") A::func1static; // names + types
+%feature("autodoc","2") A::func2static; // extended
+%feature("autodoc","3") A::func3static; // extended + types
+
+%feature("autodoc","0") A::variable_a; // names
+%feature("autodoc","1") A::variable_b; // names + types
+%feature("autodoc","2") A::variable_c; // extended
+%feature("autodoc","3") A::variable_d; // extended + types
+
+%feature("autodoc","just a string") A::funk; // names
%inline {
@@ -20,36 +35,29 @@
hi, hello
};
- struct A
- {
- A(int a, short b, Hola h)
- {
- }
+ struct A {
+ A(int a, short b, Hola h) {}
+ int funk(int a) { return a; }
- int func(int a)
- {
- return a;
- }
+ int func0(short, int c, int d) { return c; }
+ int func1(short, int c, int d) { return c; }
+ int func2(short, int c, int d) { return c; }
+ int func3(short, int c, int d) { return c; }
- int func0(int c, int d)
- {
- return c;
- }
-
- int func1(int c, int d)
- {
- return c;
- }
+ int func0default(A *e, short, int c, int d, double f = 2) { return 0; }
+ int func1default(A *e, short, int c, int d, double f = 2) { return 0; }
+ int func2default(A *e, short, int c, int d, double f = 2) { return 0; }
+ int func3default(A *e, short, int c, int d, double f = 2) { return 0; }
- int func2(A* c, double d = 2)
- {
- return 2;
- }
+ static int func0static(A *e, short, int c, int d, double f = 2) { return 0; }
+ static int func1static(A *e, short, int c, int d, double f = 2) { return 0; }
+ static int func2static(A *e, short, int c, int d, double f = 2) { return 0; }
+ static int func3static(A *e, short, int c, int d, double f = 2) { return 0; }
- int func3(A* c, double d = 2)
- {
- return 2;
- }
+ int variable_a;
+ int variable_b;
+ int variable_c;
+ int variable_d;
};
}
@@ -62,34 +70,66 @@
%typemap(doc) int a "a: special comment for parameter a";
%typemap(doc) int b "b: another special comment for parameter b";
-%callback(1) func_cb;
+%feature("autodoc","0") C::C(int a, int b, Hola h); // names
+%feature("autodoc","1") D::D(int a, int b, Hola h); // names + types
+%feature("autodoc","2") E::E(int a, int b, Hola h); // extended
+%feature("autodoc","3") F::F(int a, int b, Hola h); // extended + types
%inline {
- struct B
- {
- B(int a, int b, Hola h)
- {
- }
-
-
- int func(int c, int d)
- {
- return c;
- }
-
+ struct B {
+ B(int a, int b, Hola h) {}
+ int funk(int c, int d) { return c; }
};
- int func(int c, int d) {
- return c;
- }
+ struct C {
+ C(int a, int b, Hola h) {}
+ };
+ struct D {
+ D(int a, int b, Hola h) {}
+ };
+ struct E {
+ E(int a, int b, Hola h) {}
+ };
+ struct F {
+ F(int a, int b, Hola h) {}
+ };
- int funcio(int *INOUT) {
+ int funk(A *e, short, int c, int d) { return c; }
+ int funkdefaults(A *e, short, int c, int d, double f = 2) { return c; }
+}
+
+%include
+%inline %{
+ int func_input(int *INPUT) {
return 1;
}
-
- int func_cb(int c, int d) {
- return c;
+ int func_output(int *OUTPUT) {
+ *OUTPUT = 2;
+ return 1;
}
-
+ int func_inout(int *INOUT) {
+ *INOUT += 1;
+ return 1;
+ }
+%}
+
+%callback("%(uppercase)s_CALLBACK") func_cb;
+
+%inline {
+ int func_cb(int c, int d) { return c; }
}
+
+// Bug 3310528
+%feature("autodoc","1") banana; // names + types
+%inline %{
+typedef struct tagS {
+ int a;
+ char b;
+} S;
+
+typedef int Integer;
+
+void banana(S *a, const struct tagS *b, int c, Integer d) {}
+%}
+
diff --git a/Examples/test-suite/class_forward.i b/Examples/test-suite/class_forward.i
new file mode 100644
index 000000000..f1c0a122f
--- /dev/null
+++ b/Examples/test-suite/class_forward.i
@@ -0,0 +1,10 @@
+%module class_forward
+
+%inline %{
+struct A {
+ class B;
+};
+class C : public A {
+};
+%}
+
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 10bc24309..08da73451 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -124,7 +124,9 @@ CPP_TEST_CASES += \
catches \
cast_operator \
casts \
+ char_binary \
char_strings \
+ class_forward \
class_ignore \
class_scope_weird \
compactdefaultargs \
@@ -158,6 +160,7 @@ CPP_TEST_CASES += \
director_abstract \
director_alternating \
director_basic \
+ director_binary_string \
director_classes \
director_classic \
director_constructor \
@@ -171,6 +174,7 @@ CPP_TEST_CASES += \
director_ignore \
director_keywords \
director_namespace_clash \
+ director_nspace \
director_nested \
director_overload \
director_primitives \
@@ -194,10 +198,12 @@ CPP_TEST_CASES += \
evil_diamond_prop \
exception_order \
extend \
+ extend_constructor_destructor \
extend_default \
extend_placement \
extend_template \
extend_template_ns \
+ extend_typedef_class \
extern_c \
extern_namespace \
extern_throws \
@@ -227,6 +233,7 @@ CPP_TEST_CASES += \
li_attribute \
li_boost_shared_ptr \
li_boost_shared_ptr_bits \
+ li_boost_shared_ptr_template \
li_carrays \
li_cdata \
li_cpointer \
@@ -283,6 +290,7 @@ CPP_TEST_CASES += \
protected_rename \
pure_virtual \
redefined \
+ redefined_not \
refcount \
reference_global_vars \
register_par \
@@ -341,6 +349,7 @@ CPP_TEST_CASES += \
template_default2 \
template_default_arg \
template_default_class_parms \
+ template_default_class_parms_typedef \
template_default_inherit \
template_default_qualify \
template_default_vw \
@@ -382,15 +391,20 @@ CPP_TEST_CASES += \
template_tbase_template \
template_template_parameters \
template_typedef \
+ template_typedef_class_template \
template_typedef_cplx \
template_typedef_cplx2 \
template_typedef_cplx3 \
template_typedef_cplx4 \
template_typedef_cplx5 \
template_typedef_funcptr \
+ template_typedef_inherit \
template_typedef_ns \
template_typedef_ptr \
template_typedef_rec \
+ template_typemaps \
+ template_typemaps_typedef \
+ template_typemaps_typedef2 \
template_using \
template_virtual \
template_whitespace \
@@ -409,6 +423,7 @@ CPP_TEST_CASES += \
typemap_arrays \
typemap_delete \
typemap_global_scope \
+ typemap_manyargs \
typemap_namespace \
typemap_ns_using \
typemap_numinputs \
@@ -450,6 +465,7 @@ CPP_STD_TEST_CASES += \
director_string \
ignore_template_constructor \
li_std_combinations \
+ li_std_containers_int \
li_std_deque \
li_std_except \
li_std_map \
diff --git a/Examples/test-suite/cpp_typedef.i b/Examples/test-suite/cpp_typedef.i
index f869f4d9c..b782a3bd3 100644
--- a/Examples/test-suite/cpp_typedef.i
+++ b/Examples/test-suite/cpp_typedef.i
@@ -26,9 +26,13 @@ public:
// Test that the correct types are used for typedef struct declarations
typedef struct {
+ int something;
+ void m() {}
} UnnamedStruct;
typedef struct NamedStruct {
+ int something;
+ void m() {}
} TypedefNamedStruct;
typedef TypedefNamedStruct DoubleTypedef;
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index f9a4bd76f..b89b50eb2 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -22,7 +22,8 @@ CPP_TEST_CASES = \
enum_thorough_simple \
enum_thorough_typesafe \
exception_partial_info \
- intermediary_classname
+ intermediary_classname \
+ li_boost_intrusive_ptr
include $(srcdir)/../common.mk
diff --git a/Examples/test-suite/csharp/director_nspace_runme.cs b/Examples/test-suite/csharp/director_nspace_runme.cs
new file mode 100644
index 000000000..8126535eb
--- /dev/null
+++ b/Examples/test-suite/csharp/director_nspace_runme.cs
@@ -0,0 +1,32 @@
+
+using System;
+using director_nspaceNamespace;
+
+public class bools_runme {
+
+ public static void Main() {
+ }
+}
+
+class director_nspace_MyBarFoo : director_nspaceNamespace.Bar.Foo {
+
+ public override String ping() {
+ return "director_nspace_MyBarFoo.ping();";
+ }
+
+ public override String pong() {
+ return "director_nspace_MyBarFoo.pong();" + ping();
+ }
+
+ public override String fooBar(director_nspaceNamespace.Bar.FooBar fooBar) {
+ return fooBar.FooBarDo();
+ }
+
+ public override director_nspaceNamespace.Bar.Foo makeFoo() {
+ return new director_nspaceNamespace.Bar.Foo();
+ }
+
+ public override director_nspaceNamespace.Bar.FooBar makeFooBar() {
+ return new director_nspaceNamespace.Bar.FooBar();
+ }
+}
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
index 53b9f2859..8128e4f7a 100644
--- a/Examples/test-suite/d/Makefile.in
+++ b/Examples/test-suite/d/Makefile.in
@@ -16,7 +16,6 @@ endif
TESTSUFFIX = _runme$(VERSIONSUFFIX).d
CPP_TEST_CASES = \
- d_exception_name \
d_nativepointers \
exception_partial_info
diff --git a/Examples/test-suite/d/allprotected_runme.2.d b/Examples/test-suite/d/allprotected_runme.2.d
index 799230291..f7c396d17 100644
--- a/Examples/test-suite/d/allprotected_runme.2.d
+++ b/Examples/test-suite/d/allprotected_runme.2.d
@@ -2,6 +2,8 @@ module allprotected_runme;
import allprotected.Klass;
import allprotected.ProtectedBase;
+import std.conv : text;
+import std.exception : enforce;
void main() {
auto mpb = new MyProtectedBase("MyProtectedBase");
@@ -16,50 +18,46 @@ public:
void accessProtected() {
string s = virtualMethod();
- if (s != "ProtectedBase")
- throw new Exception("Failed");
+ enforce(s == "ProtectedBase", "Failed, got '" ~ s ~ "'");
- Klass k = instanceMethod(new Klass("xyz"));
- if (k.getName() != "xyz")
- throw new Exception("Failed");
+ Klass k;
+ void expect(string name) {
+ auto kName = k.getName();
+ enforce(kName == name, "Failed, expected '" ~ name ~ "' instead of '" ~
+ kName ~ "'.");
+ }
+
+ k = instanceMethod(new Klass("xyz"));
+ expect("xyz");
k = instanceOverloaded(new Klass("xyz"));
- if (k.getName() != "xyz")
- throw new Exception("Failed");
+ expect("xyz");
k = instanceOverloaded(new Klass("xyz"), "abc");
- if (k.getName() != "abc")
- throw new Exception("Failed");
+ expect("abc");
k = staticMethod(new Klass("abc"));
- if (k.getName() != "abc")
- throw new Exception("Failed");
+ expect("abc");
k = staticOverloaded(new Klass("xyz"));
- if (k.getName() != "xyz")
- throw new Exception("Failed");
+ expect("xyz");
k = staticOverloaded(new Klass("xyz"), "abc");
- if (k.getName() != "abc")
- throw new Exception("Failed");
+ expect("abc");
instanceMemberVariable = 30;
int i = instanceMemberVariable;
- if (i != 30)
- throw new Exception("Failed");
+ enforce(i == 30, text("Failed, expected ", 30, "instead of ", i));
staticMemberVariable = 40;
i = staticMemberVariable;
- if (i != 40)
- throw new Exception("Failed");
+ enforce(i == 40, text("Failed, expected ", 40, "instead of ", i));
i = staticConstMemberVariable;
- if (i != 20)
- throw new Exception("Failed");
+ enforce(i == 20, text("Failed, expected ", 20, "instead of ", i));
anEnum = ProtectedBase.AnEnum.EnumVal1;
ProtectedBase.AnEnum ae = anEnum;
- if (ae != ProtectedBase.AnEnum.EnumVal1)
- throw new Exception("Failed");
+ enforce(ae == ProtectedBase.AnEnum.EnumVal1);
}
}
diff --git a/Examples/test-suite/d/d_nativepointers_runme.1.d b/Examples/test-suite/d/d_nativepointers_runme.1.d
index 797c057d3..dfafacca4 100644
--- a/Examples/test-suite/d/d_nativepointers_runme.1.d
+++ b/Examples/test-suite/d/d_nativepointers_runme.1.d
@@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
import d_nativepointers.SWIGTYPE_p_p_SomeClass;
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
+extern(C) alias void function(int**, char***) GType;
+
void main() {
check!(a, int*);
check!(b, float**);
@@ -13,7 +15,7 @@ void main() {
check!(d, SomeClass);
check!(e, SWIGTYPE_p_p_SomeClass);
check!(f, SWIGTYPE_p_OpaqueClass);
- check!(g, void function(int**, char***));
+ check!(g, GType);
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
{
diff --git a/Examples/test-suite/d/d_nativepointers_runme.2.d b/Examples/test-suite/d/d_nativepointers_runme.2.d
index 797c057d3..dfafacca4 100644
--- a/Examples/test-suite/d/d_nativepointers_runme.2.d
+++ b/Examples/test-suite/d/d_nativepointers_runme.2.d
@@ -6,6 +6,8 @@ import d_nativepointers.SWIGTYPE_p_OpaqueClass;
import d_nativepointers.SWIGTYPE_p_p_SomeClass;
import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
+extern(C) alias void function(int**, char***) GType;
+
void main() {
check!(a, int*);
check!(b, float**);
@@ -13,7 +15,7 @@ void main() {
check!(d, SomeClass);
check!(e, SWIGTYPE_p_p_SomeClass);
check!(f, SWIGTYPE_p_OpaqueClass);
- check!(g, void function(int**, char***));
+ check!(g, GType);
check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
{
diff --git a/Examples/test-suite/d/director_ignore_runme.2.d b/Examples/test-suite/d/director_ignore_runme.2.d
index b3e29b48d..0d9f7f733 100644
--- a/Examples/test-suite/d/director_ignore_runme.2.d
+++ b/Examples/test-suite/d/director_ignore_runme.2.d
@@ -19,7 +19,9 @@ public:
int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
int OverloadedMethod(int n, int xoffset) { return 0; }
int OverloadedMethod(int n) { return 0; }
+ alias super.OverloadedMethod OverloadedMethod;
+protected:
int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
int OverloadedProtectedMethod(int n) { return 0; }
@@ -31,7 +33,9 @@ public:
int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
int OverloadedMethod(int n, int xoffset) { return 0; }
int OverloadedMethod(int n) { return 0; }
+ alias super.OverloadedMethod OverloadedMethod;
+protected:
int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
int OverloadedProtectedMethod(int n) { return 0; }
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
index 773ae74d5..0027aad05 100644
--- a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
+++ b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
@@ -583,7 +583,7 @@ 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);
+ auto got = use_count(k);
if (expected != got)
throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got));
}
diff --git a/Examples/test-suite/d/li_std_vector_runme.2.d b/Examples/test-suite/d/li_std_vector_runme.2.d
index 195ed8473..f4a666716 100644
--- a/Examples/test-suite/d/li_std_vector_runme.2.d
+++ b/Examples/test-suite/d/li_std_vector_runme.2.d
@@ -22,7 +22,7 @@ void main() {
// Basic functionality tests.
{
auto vector = new IntVector();
- for (size_t i = 0; i < SIZE; ++i) {
+ foreach (int i; 0 .. SIZE) {
vector ~= i * 10;
}
@@ -56,7 +56,7 @@ void main() {
// To array conversion tests.
{
auto dVector = new DoubleVector();
- for (size_t i = 0; i < SIZE; ++i) {
+ foreach (i; 0 .. SIZE) {
dVector ~= i * 10.1f;
}
@@ -67,13 +67,13 @@ void main() {
auto sVector = new StructVector();
- for (size_t i = 0; i < SIZE; i++) {
+ foreach (i; 0 .. SIZE) {
sVector ~= new Struct(i / 10.0);
}
Struct[] sArray = array(sVector[]);
- for (size_t i = 0; i < SIZE; i++) {
+ foreach (i; 0 .. SIZE) {
// Make sure that a shallow copy has been made.
void* aPtr = Struct.swigGetCPtr(sArray[i]);
void* vPtr = Struct.swigGetCPtr(sVector[i]);
@@ -84,7 +84,7 @@ void main() {
// remove() tests.
{
auto iVector = new IntVector();
- for (int i = 0; i < SIZE; i++) {
+ foreach (int i; 0 .. SIZE) {
iVector ~= i;
}
@@ -108,7 +108,7 @@ void main() {
// Test the methods being wrapped.
{
auto iv = new IntVector();
- for (int i=0; i<4; i++) {
+ foreach (int i; 0 .. 4) {
iv ~= i;
}
@@ -117,7 +117,7 @@ void main() {
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++) {
+ foreach (i; 0 .. SIZE) {
dv ~= i / 2.0;
}
halve_in_place(dv);
@@ -147,13 +147,13 @@ void main() {
// Test vectors of pointers.
{
auto vector = new StructPtrVector();
- for (size_t i = 0; i < SIZE; i++) {
+ foreach (i; 0 .. SIZE) {
vector ~= new Struct(i / 10.0);
}
Struct[] array = array(vector[]);
- for (size_t i = 0; i < SIZE; i++) {
+ foreach (i; 0 .. SIZE) {
// Make sure that a shallow copy has been made.
void* aPtr = Struct.swigGetCPtr(array[i]);
void* vPtr = Struct.swigGetCPtr(vector[i]);
@@ -164,13 +164,13 @@ void main() {
// Test vectors of const pointers.
{
auto vector = new StructConstPtrVector();
- for (size_t i = 0; i < SIZE; i++) {
+ foreach (i; 0 .. SIZE) {
vector ~= new Struct(i / 10.0);
}
Struct[] array = array(vector[]);
- for (size_t i = 0; i < SIZE; i++) {
+ foreach (i; 0 .. SIZE) {
// Make sure that a shallow copy has been made.
void* aPtr = Struct.swigGetCPtr(array[i]);
void* vPtr = Struct.swigGetCPtr(vector[i]);
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.1.d b/Examples/test-suite/d/preproc_constants_c_runme.1.d
index f25bbfdee..d846c71ac 100644
--- a/Examples/test-suite/d/preproc_constants_c_runme.1.d
+++ b/Examples/test-suite/d/preproc_constants_c_runme.1.d
@@ -1,5 +1,6 @@
module preproc_constants_c_runme;
+import tango.stdc.config;
import preproc_constants_c.preproc_constants_c;
// Same as preproc_constants.i testcase, but bool types are int instead.
@@ -10,10 +11,10 @@ void main() {
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(c_long == typeof(CONST_LONG1())));
+ static assert(is(c_long == typeof(CONST_LONG2())));
+ static assert(is(c_long == typeof(CONST_LONG3())));
+ static assert(is(c_long == typeof(CONST_LONG4())));
static assert(is(long == typeof(CONST_LLONG1())));
static assert(is(long == typeof(CONST_LLONG2())));
static assert(is(long == typeof(CONST_LLONG3())));
@@ -38,8 +39,8 @@ void main() {
// 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(c_long == typeof(INT_AND_LONG())));
+ static assert(is(c_ulong == 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())));
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d
index 07d6ac53d..9bdbb9372 100644
--- a/Examples/test-suite/d/preproc_constants_c_runme.2.d
+++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d
@@ -1,5 +1,6 @@
module preproc_constants_c_runme;
+import core.stdc.config;
import preproc_constants_c.preproc_constants_c;
// Same as preproc_constants.i testcase, but bool types are int instead.
@@ -10,10 +11,10 @@ void main() {
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(c_long == typeof(CONST_LONG1())));
+ static assert(is(c_long == typeof(CONST_LONG2())));
+ static assert(is(c_long == typeof(CONST_LONG3())));
+ static assert(is(c_long == typeof(CONST_LONG4())));
static assert(is(long == typeof(CONST_LLONG1())));
static assert(is(long == typeof(CONST_LLONG2())));
static assert(is(long == typeof(CONST_LLONG3())));
@@ -38,8 +39,8 @@ void main() {
// 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(c_long == typeof(INT_AND_LONG())));
+ static assert(is(c_ulong == 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())));
diff --git a/Examples/test-suite/d/preproc_constants_runme.1.d b/Examples/test-suite/d/preproc_constants_runme.1.d
index a2aaa8fcd..009405fc7 100644
--- a/Examples/test-suite/d/preproc_constants_runme.1.d
+++ b/Examples/test-suite/d/preproc_constants_runme.1.d
@@ -1,5 +1,6 @@
module preproc_constants_runme;
+import tango.stdc.config;
import preproc_constants.preproc_constants;
void main() {
@@ -9,10 +10,10 @@ void main() {
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(c_long == typeof(CONST_LONG1())));
+ static assert(is(c_long == typeof(CONST_LONG2())));
+ static assert(is(c_long == typeof(CONST_LONG3())));
+ static assert(is(c_long == typeof(CONST_LONG4())));
static assert(is(long == typeof(CONST_LLONG1())));
static assert(is(long == typeof(CONST_LLONG2())));
static assert(is(long == typeof(CONST_LLONG3())));
@@ -37,8 +38,8 @@ void main() {
// 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(c_long == typeof(INT_AND_LONG())));
+ static assert(is(c_ulong == 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())));
diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d
index e2eab2c46..2d92ef052 100644
--- a/Examples/test-suite/d/preproc_constants_runme.2.d
+++ b/Examples/test-suite/d/preproc_constants_runme.2.d
@@ -1,5 +1,6 @@
module preproc_constants_runme;
+import core.stdc.config;
import preproc_constants.preproc_constants;
void main() {
@@ -9,10 +10,10 @@ void main() {
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(c_long == typeof(CONST_LONG1())));
+ static assert(is(c_long == typeof(CONST_LONG2())));
+ static assert(is(c_long == typeof(CONST_LONG3())));
+ static assert(is(c_long == typeof(CONST_LONG4())));
static assert(is(long == typeof(CONST_LLONG1())));
static assert(is(long == typeof(CONST_LLONG2())));
static assert(is(long == typeof(CONST_LLONG3())));
@@ -37,8 +38,8 @@ void main() {
// 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(c_long == typeof(INT_AND_LONG())));
+ static assert(is(c_ulong == 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())));
diff --git a/Examples/test-suite/d_exception_name.i b/Examples/test-suite/d_exception_name.i
deleted file mode 100644
index 23f338a73..000000000
--- a/Examples/test-suite/d_exception_name.i
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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/director_basic.i b/Examples/test-suite/director_basic.i
index 12cb0db65..56864f4a7 100644
--- a/Examples/test-suite/director_basic.i
+++ b/Examples/test-suite/director_basic.i
@@ -10,7 +10,7 @@
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
- static Foo* get_self(Foo *self) {return self;}
+ static Foo* get_self(Foo *slf) {return slf;}
};
@@ -27,7 +27,7 @@
virtual std::string ping();
virtual std::string pong();
- static Foo* get_self(Foo *self);
+ static Foo* get_self(Foo *slf);
};
diff --git a/Examples/test-suite/director_binary_string.i b/Examples/test-suite/director_binary_string.i
new file mode 100644
index 000000000..ec64bc4b4
--- /dev/null
+++ b/Examples/test-suite/director_binary_string.i
@@ -0,0 +1,50 @@
+%module(directors="1") director_binary_string;
+
+%feature("director") Callback;
+
+%apply (char *STRING, size_t LENGTH) { (char *dataBufferAA, int sizeAA) };
+%apply (char *STRING, size_t LENGTH) { (char *dataBufferBB, int sizeBB) };
+
+%inline %{
+#include
+
+#define BUFFER_SIZE_AA 8
+#define BUFFER_SIZE_BB 5
+
+class Callback {
+public:
+ virtual ~Callback() {}
+ virtual void run(char* dataBufferAA, int sizeAA, char* dataBufferBB, int sizeBB) {
+ memset(dataBufferAA, -1, sizeAA);
+ memset(dataBufferBB, -1, sizeBB);
+ }
+};
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ int call() {
+ if (_callback) {
+ char* aa = (char*)malloc(BUFFER_SIZE_AA);
+ memset(aa, 9, BUFFER_SIZE_AA);
+ char* bb = (char*)malloc(BUFFER_SIZE_BB);
+ memset(bb, 13, BUFFER_SIZE_BB);
+ int sum = 0;
+ _callback->run(aa, BUFFER_SIZE_AA, bb, BUFFER_SIZE_BB);
+ for (int i = 0; i < BUFFER_SIZE_AA; i++)
+ sum += aa[i];
+ for (int i = 0; i < BUFFER_SIZE_BB; i++)
+ sum += bb[i];
+ free(aa);
+ free(bb);
+ return sum;
+ }
+ }
+};
+
+%}
diff --git a/Examples/test-suite/director_nspace.i b/Examples/test-suite/director_nspace.i
new file mode 100644
index 000000000..f730592f3
--- /dev/null
+++ b/Examples/test-suite/director_nspace.i
@@ -0,0 +1,68 @@
+%module(directors="1") director_nspace
+
+#ifdef SWIGJAVA
+SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
+SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
+#endif
+
+%{
+#include
+
+namespace Bar
+{
+ class FooBar {
+ public:
+ FooBar() {}
+ FooBar(const FooBar&) {}
+ virtual ~FooBar() {}
+
+ std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
+ };
+
+ class Foo {
+ public:
+ virtual ~Foo() {}
+ virtual std::string ping() { return "Bar::Foo::ping()"; }
+ virtual std::string pong() { return "Bar::Foo::pong();" + ping(); }
+ virtual std::string fooBar(FooBar* fb) { return fb->FooBarDo(); }
+ virtual Foo makeFoo() { return Foo(); }
+ virtual FooBar makeFooBar() { return FooBar(); }
+
+ static Foo* get_self(Foo *self) {return self;}
+ };
+}
+
+%}
+
+%include
+
+%nspace Bar::Foo;
+%nspace Bar::FooBar;
+
+%feature("director") Bar::Foo;
+
+namespace Bar
+{
+ class FooBar {
+ public:
+ FooBar();
+ FooBar(const FooBar&);
+ virtual ~FooBar();
+
+ std::string FooBarDo();
+
+ };
+
+ class Foo
+ {
+ public:
+ virtual ~Foo();
+ virtual std::string ping();
+ virtual std::string pong();
+ virtual std::string fooBar(FooBar* fb);
+ virtual Foo makeFoo();
+ virtual FooBar makeFooBar();
+
+ static Foo* get_self(Foo *self);
+ };
+}
diff --git a/Examples/test-suite/errors/cpp_extend_destructors.i b/Examples/test-suite/errors/cpp_extend_destructors.i
new file mode 100644
index 000000000..56b46f9c9
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_extend_destructors.i
@@ -0,0 +1,104 @@
+%module xxx
+
+/////////////////////////////
+%extend AStruct {
+ ~AStruct() {}
+}
+struct AStruct {
+ ~AStruct() {}
+};
+
+/////////////////////////////
+struct BStruct {
+ ~BStruct() {}
+ ~BStruct() {}
+};
+
+/////////////////////////////
+struct CStruct {
+};
+
+%extend CStruct {
+ ~NOT_CStruct() {
+ delete $self;
+ }
+}
+
+%extend DStruct {
+ ~NOT_DStruct() {
+ delete $self;
+ }
+}
+
+struct DStruct {
+};
+
+/////////////////////////////
+struct EStruct {
+ ~EStruct() {}
+};
+
+%extend EStruct {
+ ~NOT_EStruct() {
+ delete $self;
+ }
+}
+
+%extend FStruct {
+ ~NOT_FStruct() {
+ delete $self;
+ }
+}
+
+struct FStruct {
+ ~FStruct() {}
+};
+
+/////////////////////////////
+struct GStruct {
+};
+
+%extend GStruct {
+ ~GStruct() {}
+ ~NOT_GStruct() {
+ delete $self;
+ }
+}
+
+%extend HStruct {
+ ~HStruct() {}
+ ~NOT_HStruct() {
+ delete $self;
+ }
+}
+
+struct HStruct {
+};
+
+/////////////////////////////
+struct IStruct {
+ ~IStruct() {}
+ ~NOT_IStruct() {}
+};
+
+struct JStruct {
+ ~JStruct() {}
+ ~NOT_JStruct() {}
+ ~JStruct() {}
+};
+
+/////////////////////////////
+struct KStruct {
+ ~NOT_KStruct() {}
+};
+
+/////////////////////////////
+template
+struct LStruct {
+ ~LStruct() {}
+ ~NOT_LStruct() {}
+ ~LStruct() {}
+};
+%template(LStructInt) LStruct;
+%template(LStructShort) LStruct;
+
diff --git a/Examples/test-suite/errors/cpp_no_return_type.i b/Examples/test-suite/errors/cpp_no_return_type.i
new file mode 100644
index 000000000..3327e1d0a
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_no_return_type.i
@@ -0,0 +1,12 @@
+%module xxx
+
+struct R {};
+
+struct S {
+ R() {}
+};
+
+typedef struct U {
+ UU() {}
+} UU;
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
index 8ac1534cb..b7883c403 100644
--- a/Examples/test-suite/errors/expected.log
+++ b/Examples/test-suite/errors/expected.log
@@ -205,10 +205,40 @@ $source by $input and $target by $1. For typemaps related to return values (ou
argout,ret,except), replace $source by $1 and $target by $result. See the file
Doc/Manual/Typemaps.html for complete details.
+:::::::::::::::::::::::::::::::: swig_typemap_warn.i :::::::::::::::::::::::::::::::::::
+swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
+swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int
+swig_typemap_warn.i:7: Warning 1001: Test warning for 'out' typemap for double mmm (result) - name: mmm symname: mmm &1_ltype: double * descriptor: SWIGTYPE_double
+swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
+swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int
+swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int abc (arg1) - argnum: 1 &1_ltype: int * descriptor: SWIGTYPE_int
+swig_typemap_warn.i:7: Warning 1000: Test warning for 'in' typemap for int arg3 (arg3) - argnum: 3 &1_ltype: int * descriptor: SWIGTYPE_int
+
:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
+:::::::::::::::::::::::::::::::: cpp_extend_destructors.i :::::::::::::::::::::::::::::::::::
+cpp_extend_destructors.i:8: Warning 302: Identifier '~AStruct' redefined by %extend (ignored),
+cpp_extend_destructors.i:5: Warning 302: %extend definition of '~AStruct'.
+cpp_extend_destructors.i:14: Warning 302: Identifier '~BStruct' redefined (ignored),
+cpp_extend_destructors.i:13: Warning 302: previous definition of '~BStruct'.
+cpp_extend_destructors.i:87: Warning 302: Identifier '~JStruct' redefined (ignored),
+cpp_extend_destructors.i:85: Warning 302: previous definition of '~JStruct'.
+cpp_extend_destructors.i:100: Warning 302: Identifier '~LStruct' redefined (ignored),
+cpp_extend_destructors.i:98: Warning 302: previous definition of '~LStruct'.
+cpp_extend_destructors.i:24: Warning 521: Illegal destructor name ~NOT_CStruct. Ignored.
+cpp_extend_destructors.i:30: Warning 521: Illegal destructor name ~NOT_DStruct. Ignored.
+cpp_extend_destructors.i:44: Warning 521: Illegal destructor name ~NOT_EStruct. Ignored.
+cpp_extend_destructors.i:50: Warning 521: Illegal destructor name ~NOT_FStruct. Ignored.
+cpp_extend_destructors.i:65: Warning 521: Illegal destructor name ~NOT_GStruct. Ignored.
+cpp_extend_destructors.i:72: Warning 521: Illegal destructor name ~NOT_HStruct. Ignored.
+cpp_extend_destructors.i:81: Warning 521: Illegal destructor name ~NOT_IStruct. Ignored.
+cpp_extend_destructors.i:86: Warning 521: Illegal destructor name ~NOT_JStruct. Ignored.
+cpp_extend_destructors.i:92: Warning 521: Illegal destructor name ~NOT_KStruct. Ignored.
+cpp_extend_destructors.i:99: Warning 521: Illegal destructor name ~NOT_LStruct< int >. Ignored.
+cpp_extend_destructors.i:99: Warning 521: Illegal destructor name ~NOT_LStruct< short >. Ignored.
+
:::::::::::::::::::::::::::::::: cpp_extend_redefine.i :::::::::::::::::::::::::::::::::::
cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
@@ -281,6 +311,10 @@ cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored
:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored).
+:::::::::::::::::::::::::::::::: cpp_no_return_type.i :::::::::::::::::::::::::::::::::::
+cpp_no_return_type.i:6: Warning 504: Function R must have a return type. Ignored.
+cpp_no_return_type.i:10: Warning 504: Function UU must have a return type. Ignored.
+
:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored.
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index f45f435aa..e243315ec 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -58,11 +58,13 @@ swig_identifier
swig_insert_bad
swig_typemap_copy
swig_typemap_old
+swig_typemap_warn
'
# Files run in C++ mode
CPPFILES='
cpp_bad_extern
+cpp_extend_destructors
cpp_extend_redefine
cpp_extend_undefined
cpp_inline_namespace
@@ -74,6 +76,7 @@ cpp_namespace_aliasnot
cpp_namespace_aliasundef
cpp_nested
cpp_no_access
+cpp_no_return_type
cpp_nobase
cpp_overload
cpp_overload_const
diff --git a/Examples/test-suite/errors/swig_typemap_warn.i b/Examples/test-suite/errors/swig_typemap_warn.i
new file mode 100644
index 000000000..f0545bca1
--- /dev/null
+++ b/Examples/test-suite/errors/swig_typemap_warn.i
@@ -0,0 +1,7 @@
+%module xxx
+
+%typemap(in, warning="1000:Test warning for 'in' typemap for $1_type $1_name ($1) - argnum: $argnum &1_ltype: $&1_ltype descriptor: $1_descriptor") int ""
+
+%typemap(out, warning="1001:Test warning for 'out' typemap for $1_type $1_name ($1) - name: $name symname: $symname &1_ltype: $&1_ltype descriptor: $1_descriptor") double ""
+
+double mmm(int abc, short def, int);
diff --git a/Examples/test-suite/extend_constructor_destructor.i b/Examples/test-suite/extend_constructor_destructor.i
new file mode 100644
index 000000000..a0ab1a0f6
--- /dev/null
+++ b/Examples/test-suite/extend_constructor_destructor.i
@@ -0,0 +1,125 @@
+%module extend_constructor_destructor
+
+%inline %{
+int globalVar = 0;
+
+namespace Space {
+ typedef struct tagAStruct {
+ int ivar;
+ } AStruct;
+
+ struct BStruct {
+ int ivar;
+ };
+
+ typedef struct tagCStruct {
+ int ivar;
+ } CStruct;
+
+ // Unnamed struct
+ typedef struct {
+ int ivar;
+ } DStruct;
+
+}
+
+typedef struct tagEStruct {
+ int ivar;
+} EStruct;
+
+namespace Space {
+ template
+ struct FFStruct {
+ int ivar;
+ };
+}
+%}
+
+namespace Space {
+
+%extend tagAStruct {
+ tagAStruct(int ivar0) {
+ Space::AStruct *s = new Space::AStruct();
+ s->ivar = ivar0;
+ globalVar = ivar0;
+ return s;
+ }
+ ~tagAStruct() {
+ globalVar = -$self->ivar;
+ delete $self;
+ }
+}
+
+%extend BStruct {
+ BStruct(int ivar0) {
+ Space::BStruct *s = new Space::BStruct();
+ s->ivar = ivar0;
+ globalVar = ivar0;
+ return s;
+ }
+ ~BStruct() {
+ globalVar = -$self->ivar;
+ delete $self;
+ }
+}
+
+%extend CStruct {
+ CStruct(int ivar0) {
+ Space::CStruct *s = new Space::CStruct();
+ s->ivar = ivar0;
+ globalVar = ivar0;
+ return s;
+ }
+ ~CStruct() {
+ globalVar = -$self->ivar;
+ delete $self;
+ }
+}
+
+%extend DStruct {
+ DStruct(int ivar0) {
+ Space::DStruct *s = new Space::DStruct();
+ s->ivar = ivar0;
+ globalVar = ivar0;
+ return s;
+ }
+ ~DStruct() {
+ globalVar = -$self->ivar;
+ delete $self;
+ }
+}
+
+}
+
+%extend EStruct {
+ EStruct(int ivar0) {
+ EStruct *s = new EStruct();
+ s->ivar = ivar0;
+ globalVar = ivar0;
+ return s;
+ }
+ ~EStruct() {
+ globalVar = -$self->ivar;
+ delete $self;
+ }
+}
+
+namespace Space {
+%extend FFStruct {
+ FFStruct(int ivar0) {
+ Space::FFStruct *s = new Space::FFStruct();
+ s->ivar = ivar0;
+ globalVar = ivar0;
+ return s;
+ }
+ ~FFStruct() {
+ globalVar = -$self->ivar;
+ delete $self;
+ }
+}
+
+}
+
+%template(FStruct) Space::FFStruct;
+%template(GStruct) Space::FFStruct;
+
diff --git a/Examples/test-suite/extend_typedef_class.i b/Examples/test-suite/extend_typedef_class.i
new file mode 100644
index 000000000..731802573
--- /dev/null
+++ b/Examples/test-suite/extend_typedef_class.i
@@ -0,0 +1,81 @@
+%module extend_typedef_class
+
+// classes in global namespace
+%inline %{
+ typedef struct tagAClass {
+ int membervar;
+ } AClass;
+
+ struct BClass {
+ int membervar;
+ };
+
+ typedef struct tagCClass {
+ int membervar;
+ } CClass;
+
+ // Unnamed struct
+ typedef struct {
+ int membervar;
+ } DClass;
+%}
+
+%extend tagAClass {
+ int getvar() { return $self->membervar; }
+}
+
+%extend BClass {
+ int getvar() { return $self->membervar; }
+}
+
+%extend CClass {
+ int getvar() { return $self->membervar; }
+}
+
+%extend DClass {
+ int getvar() { return $self->membervar; }
+}
+
+
+// classes in a namespace
+%inline %{
+namespace Space {
+ typedef struct tagAStruct {
+ int membervar;
+ } AStruct;
+
+ struct BStruct {
+ int membervar;
+ };
+
+ typedef struct tagCStruct {
+ int membervar;
+ } CStruct;
+
+ // Unnamed struct
+ typedef struct {
+ int membervar;
+ } DStruct;
+}
+%}
+
+namespace Space {
+
+%extend tagAStruct {
+ int getvar() { return $self->membervar; }
+}
+
+%extend BStruct {
+ int getvar() { return $self->membervar; }
+}
+
+%extend CStruct {
+ int getvar() { return $self->membervar; }
+}
+
+%extend DStruct {
+ int getvar() { return $self->membervar; }
+}
+
+}
+
diff --git a/Examples/test-suite/funcptr_cpp.i b/Examples/test-suite/funcptr_cpp.i
index a3d46ea39..015164ed9 100644
--- a/Examples/test-suite/funcptr_cpp.i
+++ b/Examples/test-suite/funcptr_cpp.i
@@ -20,3 +20,14 @@ int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
+
+
+%inline %{
+typedef int AddByValueTypedef(const int &a, int b);
+typedef int * AddByPointerTypedef(const int &a, int b);
+typedef int & AddByReferenceTypedef(const int &a, int b);
+void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; }
+void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; }
+void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; }
+%}
+
diff --git a/Examples/test-suite/go/director_basic_runme.go b/Examples/test-suite/go/director_basic_runme.go
index 1995452ce..0ce780bbd 100644
--- a/Examples/test-suite/go/director_basic_runme.go
+++ b/Examples/test-suite/go/director_basic_runme.go
@@ -107,7 +107,6 @@ func f3() {
p2.Vmethod(bc)
}
-
func main() {
f1()
f2()
diff --git a/Examples/test-suite/go/overload_template_fast_runme.go b/Examples/test-suite/go/overload_template_fast_runme.go
index 4ecf4157a..b80cb7dd4 100644
--- a/Examples/test-suite/go/overload_template_fast_runme.go
+++ b/Examples/test-suite/go/overload_template_fast_runme.go
@@ -143,7 +143,6 @@ func main() {
panic("overload(const char *)")
}
-
// everything put in a namespace
if Nsoverload("hi") != 1000 {
panic("nsoverload()")
diff --git a/Examples/test-suite/go/overload_template_runme.go b/Examples/test-suite/go/overload_template_runme.go
index 279e43de6..53e1def1b 100644
--- a/Examples/test-suite/go/overload_template_runme.go
+++ b/Examples/test-suite/go/overload_template_runme.go
@@ -100,7 +100,6 @@ func main() {
panic("specialization(const char *, const char *)")
}
-
// simple specialization
Xyz()
Xyz_int()
@@ -144,7 +143,6 @@ func main() {
panic("overload(const char *)")
}
-
// everything put in a namespace
if Nsoverload("hi") != 1000 {
panic("nsoverload()")
diff --git a/Examples/test-suite/go/template_default_arg_runme.go b/Examples/test-suite/go/template_default_arg_runme.go
index 18412cd89..3d9346b05 100644
--- a/Examples/test-suite/go/template_default_arg_runme.go
+++ b/Examples/test-suite/go/template_default_arg_runme.go
@@ -49,7 +49,6 @@ func main() {
xz := template_default_arg.NewX_Foo_Z_8()
_ = xz.Meth(fz)
-
// Templated functions
// plain function: int ott(Foo)
diff --git a/Examples/test-suite/go/virtual_poly_runme.go b/Examples/test-suite/go/virtual_poly_runme.go
index 7048ba8cf..487b371ba 100644
--- a/Examples/test-suite/go/virtual_poly_runme.go
+++ b/Examples/test-suite/go/virtual_poly_runme.go
@@ -29,7 +29,6 @@ func main() {
panic(0)
}
-
// 'narrowing' also works
ddc := virtual_poly.NDoubleNarrow(d.Nnumber())
if d.Get() != ddc.Get() {
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index 1ba888fc1..2f0b27ec2 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -43,6 +43,7 @@ SWIGOPT += -package $(JAVA_PACKAGE)
# Custom tests - tests with additional commandline options
nspace.%: JAVA_PACKAGE = $*Package
nspace_extend.%: JAVA_PACKAGE = $*Package
+director_nspace.%: JAVA_PACKAGE = $*Package
# Rules for the different types of tests
%.cpptest:
diff --git a/Examples/test-suite/java/director_binary_string_runme.java b/Examples/test-suite/java/director_binary_string_runme.java
new file mode 100644
index 000000000..e2bf4da40
--- /dev/null
+++ b/Examples/test-suite/java/director_binary_string_runme.java
@@ -0,0 +1,42 @@
+
+import director_binary_string.*;
+
+public class director_binary_string_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_binary_string");
+ } 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[]) {
+ Caller caller = new Caller();
+ Callback callback = new DirectorBinaryStringCallback();
+ caller.setCallback(callback);
+ int sum = caller.call();
+ caller.delCallback();
+
+ if (sum != 9*2*8 + 13*3*5)
+ throw new RuntimeException("Unexpected sum: " + sum);
+ }
+}
+
+class DirectorBinaryStringCallback extends Callback {
+ public DirectorBinaryStringCallback() {
+ super();
+ }
+
+ @Override
+ public void run(byte[] dataBufferAA, byte[] dataBufferBB)
+ {
+ for (int i = 0; i < dataBufferAA.length; i++)
+ dataBufferAA[i] = (byte)(dataBufferAA[i] * 2);
+
+ for (int i = 0; i < dataBufferBB.length; i++)
+ dataBufferBB[i] = (byte)(dataBufferBB[i] * 3);
+ }
+}
+
diff --git a/Examples/test-suite/java/director_nspace_runme.java b/Examples/test-suite/java/director_nspace_runme.java
new file mode 100644
index 000000000..4e56f91c2
--- /dev/null
+++ b/Examples/test-suite/java/director_nspace_runme.java
@@ -0,0 +1,48 @@
+// Make sure that directors are connected and disconnected when used inconjunction with
+// the %nspace feature
+
+public class director_nspace_runme {
+
+ static {
+ try {
+ System.loadLibrary("director_nspace");
+ } 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[]) {
+ director_nspace_MyBarFoo myBarFoo =
+ new director_nspace_MyBarFoo();
+ }
+
+}
+
+class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
+
+ @Override
+ public String ping() {
+ return "director_nspace_MyBarFoo.ping();";
+ }
+
+ @Override
+ public String pong() {
+ return "director_nspace_MyBarFoo.pong();" + ping();
+ }
+
+ @Override
+ public String fooBar(director_nspacePackage.Bar.FooBar fooBar) {
+ return fooBar.FooBarDo();
+ }
+
+ @Override
+ public director_nspacePackage.Bar.Foo makeFoo() {
+ return new director_nspacePackage.Bar.Foo();
+ }
+
+ @Override
+ public director_nspacePackage.Bar.FooBar makeFooBar() {
+ return new director_nspacePackage.Bar.FooBar();
+ }
+}
diff --git a/Examples/test-suite/java/extend_constructor_destructor_runme.java b/Examples/test-suite/java/extend_constructor_destructor_runme.java
new file mode 100644
index 000000000..db7a2bba3
--- /dev/null
+++ b/Examples/test-suite/java/extend_constructor_destructor_runme.java
@@ -0,0 +1,52 @@
+import extend_constructor_destructor.*;
+
+public class extend_constructor_destructor_runme {
+
+ static {
+ try {
+ System.loadLibrary("extend_constructor_destructor");
+ } 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[]) {
+ AStruct a = new AStruct(10);
+ checkGlobal(10);
+ BStruct b = new BStruct(20);
+ checkGlobal(20);
+ CStruct c = new CStruct(30);
+ checkGlobal(30);
+ DStruct d = new DStruct(40);
+ checkGlobal(40);
+ EStruct e = new EStruct(50);
+ checkGlobal(50);
+ FStruct f = new FStruct(60);
+ checkGlobal(60);
+ GStruct g = new GStruct(70);
+ checkGlobal(70);
+
+ a.delete();
+ checkGlobal(-10);
+ b.delete();
+ checkGlobal(-20);
+ c.delete();
+ checkGlobal(-30);
+ d.delete();
+ checkGlobal(-40);
+ e.delete();
+ checkGlobal(-50);
+ f.delete();
+ checkGlobal(-60);
+ g.delete();
+ checkGlobal(-70);
+ }
+
+ public static void checkGlobal(int val) {
+ int global = extend_constructor_destructor.getGlobalVar();
+ if (global != val)
+ throw new RuntimeException("global value incorrect. Expected: " + val + " got: " + global);
+ }
+}
+
diff --git a/Examples/test-suite/java/extend_typedef_class_runme.java b/Examples/test-suite/java/extend_typedef_class_runme.java
new file mode 100644
index 000000000..0f1de995a
--- /dev/null
+++ b/Examples/test-suite/java/extend_typedef_class_runme.java
@@ -0,0 +1,65 @@
+import extend_typedef_class.*;
+
+public class extend_typedef_class_runme {
+
+ static {
+ try {
+ System.loadLibrary("extend_typedef_class");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ // No namespace
+ {
+ AClass s = new AClass();
+ s.setMembervar(10);
+ checkMatch(s.getvar(), 10);
+ }
+ {
+ BClass s = new BClass();
+ s.setMembervar(20);
+ checkMatch(s.getvar(), 20);
+ }
+ {
+ CClass s = new CClass();
+ s.setMembervar(30);
+ checkMatch(s.getvar(), 30);
+ }
+ {
+ DClass s = new DClass();
+ s.setMembervar(40);
+ checkMatch(s.getvar(), 40);
+ }
+
+ // In namespace
+ {
+ AStruct s = new AStruct();
+ s.setMembervar(10);
+ checkMatch(s.getvar(), 10);
+ }
+ {
+ BStruct s = new BStruct();
+ s.setMembervar(20);
+ checkMatch(s.getvar(), 20);
+ }
+ {
+ CStruct s = new CStruct();
+ s.setMembervar(30);
+ checkMatch(s.getvar(), 30);
+ }
+ {
+ DStruct s = new DStruct();
+ s.setMembervar(40);
+ checkMatch(s.getvar(), 40);
+ }
+ }
+
+ public static void checkMatch(int expected, int got) {
+ if (expected != got)
+ throw new RuntimeException("Value incorrect. Expected: " + expected + " got: " + got);
+ }
+}
+
diff --git a/Examples/test-suite/java/java_lib_arrays_runme.java b/Examples/test-suite/java/java_lib_arrays_runme.java
index 9ee36210a..09a175ebb 100644
--- a/Examples/test-suite/java/java_lib_arrays_runme.java
+++ b/Examples/test-suite/java/java_lib_arrays_runme.java
@@ -23,6 +23,7 @@ public class java_lib_arrays_runme {
// Create arrays for all the array types that ArrayStruct can handle
String array_c = "X";
+ byte[] array_c_extra = {11, 22};
byte[] array_sc = {10, 20};
short[] array_uc = {101, 201};
short[] array_s = {1002, 2002};
@@ -105,6 +106,12 @@ public class java_lib_arrays_runme {
as.setArray_struct(array_struct);
check_struct_array(array_struct, as.getArray_struct());
+
+ // Extended element (for char[])
+ ArrayStructExtra ase = new ArrayStructExtra();
+ ase.setArray_c2(array_c_extra);
+ check_byte_array(array_c_extra, ase.getArray_c2());
+
}
// Functions to check that the array values were set correctly
diff --git a/Examples/test-suite/java/li_boost_shared_ptr_template_runme.java b/Examples/test-suite/java/li_boost_shared_ptr_template_runme.java
new file mode 100644
index 000000000..35f517a53
--- /dev/null
+++ b/Examples/test-suite/java/li_boost_shared_ptr_template_runme.java
@@ -0,0 +1,49 @@
+
+
+import li_boost_shared_ptr_template.*;
+
+public class li_boost_shared_ptr_template_runme {
+
+ static {
+ try {
+ System.loadLibrary("li_boost_shared_ptr_template");
+ } 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[]) {
+ {
+ BaseINTEGER b = new BaseINTEGER();
+ DerivedINTEGER d = new DerivedINTEGER();
+ if (b.bar() != 1)
+ throw new RuntimeException("test 1");
+ if (d.bar() != 2)
+ throw new RuntimeException("test 2");
+ if (li_boost_shared_ptr_template.bar_getter(b) != 1)
+ throw new RuntimeException("test 3");
+ if (li_boost_shared_ptr_template.bar_getter(d) != 2)
+ throw new RuntimeException("test 4");
+ }
+
+ {
+ BaseDefaultInt b = new BaseDefaultInt();
+ DerivedDefaultInt d = new DerivedDefaultInt();
+ DerivedDefaultInt2 d2 = new DerivedDefaultInt2();
+ if (b.bar2() != 3)
+ throw new RuntimeException("test 5");
+ if (d.bar2() != 4)
+ throw new RuntimeException("test 6");
+ if (d2.bar2() != 4)
+ throw new RuntimeException("test 6");
+ if (li_boost_shared_ptr_template.bar2_getter(b) != 3)
+ throw new RuntimeException("test 7");
+ if (li_boost_shared_ptr_template.bar2_getter(d) != 4)
+ throw new RuntimeException("test 8");
+ if (li_boost_shared_ptr_template.bar2_getter(d2) != 4)
+ throw new RuntimeException("test 8");
+ }
+ }
+}
+
diff --git a/Examples/test-suite/java/template_default_class_parms_runme.java b/Examples/test-suite/java/template_default_class_parms_runme.java
index 4c8010745..406915b82 100644
--- a/Examples/test-suite/java/template_default_class_parms_runme.java
+++ b/Examples/test-suite/java/template_default_class_parms_runme.java
@@ -17,8 +17,11 @@ public class template_default_class_parms_runme {
{
DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
double d = bar.getCType();
+ bar.setCType(d);
SomeType s = bar.getDType();
+ bar.setDType(s);
int i = bar.getEType();
+ bar.setEType(i);
d = bar.method(d, s, i);
}
{
@@ -29,13 +32,17 @@ public class template_default_class_parms_runme {
{
BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
AnotherType a = bar.getCType();
+ bar.setCType(a);
boolean b = bar.getDType();
+ bar.setDType(b);
int i = bar.getEType();
+ bar.setEType(i);
a = bar.method(a, b, i);
}
{
FooAnotherType foo = new FooAnotherType(new AnotherType());
AnotherType a = foo.getTType();
+ foo.setTType(a);
a = foo.method(a);
}
}
diff --git a/Examples/test-suite/java/template_default_class_parms_typedef_runme.java b/Examples/test-suite/java/template_default_class_parms_typedef_runme.java
new file mode 100644
index 000000000..2b57875b7
--- /dev/null
+++ b/Examples/test-suite/java/template_default_class_parms_typedef_runme.java
@@ -0,0 +1,86 @@
+
+
+import template_default_class_parms_typedef.*;
+
+public class template_default_class_parms_typedef_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_default_class_parms_typedef");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ {
+ DefaultBar bar = new DefaultBar(20.0, new SomeType(), 10);
+ double d = bar.getCType();
+ bar.setCType(d);
+ SomeType s = bar.getDType();
+ bar.setDType(s);
+ int i = bar.getEType();
+ bar.setEType(i);
+ d = bar.method(d, s, i);
+ d = bar.method_1(d, s, i);
+ d = bar.method_2(d, s, i);
+ d = bar.method_3(d, s, i);
+
+ bar = new DefaultBar(true, 20.0, new SomeType(), 10);
+ bar = new DefaultBar(true, true, 20.0, new SomeType(), 10);
+ bar = new DefaultBar(true, true, true, 20.0, new SomeType(), 10);
+ }
+ {
+ DefaultFoo foo = new DefaultFoo(new SomeType());
+ SomeType s = foo.getTType();
+ s = foo.method(s);
+ s = foo.method_A(s);
+ s = foo.method_B(s);
+ s = foo.method_C(s);
+
+ foo = new DefaultFoo(new SomeType(), new SomeType());
+ foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType());
+ foo = new DefaultFoo(new SomeType(), new SomeType(), new SomeType(), new SomeType());
+ }
+ {
+ BarAnotherTypeBool bar = new BarAnotherTypeBool(new AnotherType(), true, 10);
+ AnotherType a = bar.getCType();
+ bar.setCType(a);
+ boolean b = bar.getDType();
+ bar.setDType(b);
+ int i = bar.getEType();
+ bar.setEType(i);
+
+ a = bar.method(a, b, i);
+ a = bar.method_1(a, b, i);
+ a = bar.method_2(a, b, i);
+ a = bar.method_3(a, b, i);
+
+ bar = new BarAnotherTypeBool(true, new AnotherType(), true, 10);
+ bar = new BarAnotherTypeBool(true, true, new AnotherType(), true, 10);
+ bar = new BarAnotherTypeBool(true, true, true, new AnotherType(), true, 10);
+ }
+ {
+ FooAnotherType foo = new FooAnotherType(new AnotherType());
+ AnotherType a = foo.getTType();
+ foo.setTType(a);
+ a = foo.method(a);
+ a = foo.method_A(a);
+ a = foo.method_B(a);
+ a = foo.method_C(a);
+
+ foo = new FooAnotherType(new AnotherType(), new AnotherType());
+ foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType());
+ foo = new FooAnotherType(new AnotherType(), new AnotherType(), new AnotherType(), new AnotherType());
+ }
+ {
+ UsesBarDouble u = new UsesBarDouble();
+ u.use_A(10.1, new SomeType(), 10);
+ u.use_B(10.1, new SomeType(), 10);
+ u.use_C(10.1, new SomeType(), 10);
+ u.use_D(10.1, new SomeType(), 10);
+ }
+ }
+}
+
diff --git a/Examples/test-suite/java/template_typedef_inherit_runme.java b/Examples/test-suite/java/template_typedef_inherit_runme.java
new file mode 100644
index 000000000..72a72807a
--- /dev/null
+++ b/Examples/test-suite/java/template_typedef_inherit_runme.java
@@ -0,0 +1,24 @@
+
+
+import template_typedef_inherit.*;
+
+public class template_typedef_inherit_runme {
+
+ static {
+ try {
+ System.loadLibrary("template_typedef_inherit");
+ } 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[]) {
+ DescriptionImplementationTypedCollectionInterfaceObject d = new DescriptionImplementationTypedCollectionInterfaceObject();
+ d.add("a string");
+
+ StringPersistentCollection s = new StringPersistentCollection();
+ s.add("a string");
+ }
+}
+
diff --git a/Examples/test-suite/java_lib_arrays.i b/Examples/test-suite/java_lib_arrays.i
index 0551cd100..8f9b0fd65 100644
--- a/Examples/test-suite/java_lib_arrays.i
+++ b/Examples/test-suite/java_lib_arrays.i
@@ -8,6 +8,7 @@
JAVA_ARRAYSOFCLASSES(SimpleStruct)
%apply ARRAYSOFENUMS[ANY] { finger[ANY] }
+//%apply signed char[ANY] { char array_c2[ANY] }
%include "arrays.i"
@@ -54,3 +55,15 @@ typedef enum { Big, Little } toe;
void toestest(toe *t, toe tt[], toe ttt[2]) {}
%}
+
+JAVA_ARRAYS_IMPL(char, jbyte, Byte, Char)
+JAVA_ARRAYS_TYPEMAPS(char, byte, jbyte, Char, "[B")
+%typecheck(SWIG_TYPECHECK_INT8_ARRAY) /* Java byte[] */
+ signed char[ANY], signed char[]
+ ""
+
+%inline %{
+struct ArrayStructExtra {
+ char array_c2[ARRAY_LEN];
+};
+%}
diff --git a/Examples/test-suite/python_kwargs.i b/Examples/test-suite/kwargs_feature.i
similarity index 98%
rename from Examples/test-suite/python_kwargs.i
rename to Examples/test-suite/kwargs_feature.i
index 28089bbf1..87153109a 100644
--- a/Examples/test-suite/python_kwargs.i
+++ b/Examples/test-suite/kwargs_feature.i
@@ -1,4 +1,4 @@
-%module python_kwargs
+%module kwargs_feature
%nocopyctor;
%kwargs;
diff --git a/Examples/test-suite/li_boost_intrusive_ptr.i b/Examples/test-suite/li_boost_intrusive_ptr.i
index a84af4d45..a122dc26e 100644
--- a/Examples/test-suite/li_boost_intrusive_ptr.i
+++ b/Examples/test-suite/li_boost_intrusive_ptr.i
@@ -10,6 +10,8 @@
%module li_boost_intrusive_ptr
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerived;
+%warnfilter(SWIGWARN_LANG_SMARTPTR_MISSING) KlassDerivedDerived;
%inline %{
#include "boost/shared_ptr.hpp"
@@ -37,7 +39,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP)
#define INTRUSIVE_PTR_WRAPPERS_IMPLEMENTED
#endif
@@ -50,6 +52,7 @@
%intrusive_ptr(Space::KlassDerivedDerived)
//For the use_count shared_ptr functions
+#if defined(SWIGJAVA)
%typemap(in) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::Klass > & ($*1_ltype tempnull) %{
$1 = $input ? *($&1_ltype)&$input : &tempnull;
%}
@@ -74,6 +77,10 @@
%typemap (jstype) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived"
%typemap(javain) SWIG_INTRUSIVE_PTR_QNAMESPACE::shared_ptr< Space::KlassDerivedDerived > & "KlassDerivedDerived.getCPtr($javainput)"
+#elif defined(SWIGCSHARP)
+// TODO!
+#endif
+
#endif
// TODO:
diff --git a/Examples/test-suite/li_boost_shared_ptr_template.i b/Examples/test-suite/li_boost_shared_ptr_template.i
new file mode 100644
index 000000000..62086c99d
--- /dev/null
+++ b/Examples/test-suite/li_boost_shared_ptr_template.i
@@ -0,0 +1,99 @@
+%module li_boost_shared_ptr_template
+
+// First test- Bug 3333549 - using INTEGER typedef in %shared_ptr before typedef defined
+%{
+#include
+
+ typedef int INTEGER;
+
+ template
+ class Base {
+ public:
+ virtual T bar() {return 1;}
+ };
+
+ template
+ class Derived : public Base {
+ public:
+ virtual T bar() {return 2;}
+ };
+
+ INTEGER bar_getter(Base& foo) {
+ return foo.bar();
+ }
+
+%}
+
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
+#define SHARED_PTR_WRAPPERS_IMPLEMENTED
+#endif
+
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+%include
+%shared_ptr(Base)
+%shared_ptr(Derived)
+
+#endif
+
+typedef int INTEGER;
+
+template
+class Base {
+ public:
+ virtual T bar() {return 1;}
+};
+
+template
+class Derived : public Base {
+ public:
+ virtual T bar() {return 2;}
+};
+
+INTEGER bar_getter(Base& foo) {
+ return foo.bar();
+}
+
+%template(BaseINTEGER) Base;
+%template(DerivedINTEGER) Derived;
+
+
+// 2nd test - templates with default template parameters
+#if defined(SHARED_PTR_WRAPPERS_IMPLEMENTED)
+
+%shared_ptr(Space::BaseDefault)
+%shared_ptr(Space::DerivedDefault)
+%shared_ptr(Space::DerivedDefault2)
+
+#endif
+
+%inline %{
+namespace Space {
+typedef int INT_TYPEDEF;
+template
+class BaseDefault {
+ public:
+ virtual T bar2() {return 3;}
+};
+
+template
+class DerivedDefault : public BaseDefault {
+ public:
+ virtual T bar2() {return 4;}
+};
+template
+class DerivedDefault2 : public BaseDefault {
+ public:
+ virtual int bar2() {return 4;}
+};
+
+int bar2_getter(BaseDefault& foo) {
+ return foo.bar2();
+}
+}
+%}
+
+%template(BaseDefaultInt) Space::BaseDefault;
+%template(DerivedDefaultInt) Space::DerivedDefault;
+%template(DerivedDefaultInt2) Space::DerivedDefault2;
+
diff --git a/Examples/test-suite/li_std_containers_int.i b/Examples/test-suite/li_std_containers_int.i
new file mode 100644
index 000000000..d0c76d911
--- /dev/null
+++ b/Examples/test-suite/li_std_containers_int.i
@@ -0,0 +1,12 @@
+%module li_std_containers_int
+
+//
+// Test containers of type int
+//
+
+%include std_vector.i
+%include std_list.i
+
+%template(vector_int) std::vector;
+%template(list_int) std::list;
+
diff --git a/Examples/test-suite/li_std_vector.i b/Examples/test-suite/li_std_vector.i
index a58f97ff1..55e0f4f6d 100644
--- a/Examples/test-suite/li_std_vector.i
+++ b/Examples/test-suite/li_std_vector.i
@@ -27,6 +27,7 @@ namespace std {
%inline %{
typedef float Real;
+size_t typedef_test(std::vector::size_type s) { return s; }
%}
namespace std {
diff --git a/Examples/test-suite/lua/Makefile.in b/Examples/test-suite/lua/Makefile.in
index 0ddc86a7d..d6a6554f4 100644
--- a/Examples/test-suite/lua/Makefile.in
+++ b/Examples/test-suite/lua/Makefile.in
@@ -11,12 +11,12 @@ top_builddir = @top_builddir@
# sorry, currently very few test cases work/have been written
-#CPP_TEST_CASES += \
-# cnum
+CPP_TEST_CASES += \
+ lua_no_module_global \
-#C_TEST_CASES += \
-# file_test \
-# nondynamic
+
+C_TEST_CASES += \
+ lua_no_module_global \
include $(srcdir)/../common.mk
@@ -25,7 +25,7 @@ include $(srcdir)/../common.mk
LIBS = -L.
# Custom tests - tests with additional commandline options
-# none!
+lua_no_module_global.%: SWIGOPT += -nomoduleglobal
# Rules for the different types of tests
%.cpptest:
diff --git a/Examples/test-suite/lua/lua_no_module_global_runme.lua b/Examples/test-suite/lua/lua_no_module_global_runme.lua
new file mode 100644
index 000000000..9eb436c3f
--- /dev/null
+++ b/Examples/test-suite/lua/lua_no_module_global_runme.lua
@@ -0,0 +1,24 @@
+-- require is only available in Lua 5.1
+
+if string.sub(_VERSION,1,7)=='Lua 5.1' then
+
+ -- Initially the package should not be loaded
+ assert(package.loaded["lua_no_module_global"] == nil)
+
+ -- Load the module
+ the_module = require "lua_no_module_global"
+
+ -- require should return the module table
+ assert(the_module.hi_mom ~= nil)
+ assert(the_module.hi_mom() == "hi mom!")
+
+ -- But it should not end up in the global table _G, subject to
+ -- the -nomoduleglobal swig option.
+ assert(_G["lua_no_module_global"] == nil)
+
+ -- According to the Lua 5.1 reference manual, require should also
+ -- store the module table into package.loaded["name"]
+ assert(package.loaded["lua_no_module_global"] == the_module)
+ assert(package.loaded["lua_no_module_global"].hi_mom() == "hi mom!")
+
+end
diff --git a/Examples/test-suite/lua_no_module_global.i b/Examples/test-suite/lua_no_module_global.i
new file mode 100644
index 000000000..7f71788f5
--- /dev/null
+++ b/Examples/test-suite/lua_no_module_global.i
@@ -0,0 +1,5 @@
+%module lua_no_module_global
+%{
+ const char *hi_mom() { return "hi mom!"; }
+%}
+const char *hi_mom();
diff --git a/Examples/test-suite/nspace.i b/Examples/test-suite/nspace.i
index 89009b939..65c6aafa1 100644
--- a/Examples/test-suite/nspace.i
+++ b/Examples/test-suite/nspace.i
@@ -4,6 +4,10 @@
// nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
+#if defined(SWIGJAVA)
+SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
+#endif
+
%nspace;
%nonspace Outer::Inner2::NoNSpacePlease;
diff --git a/Examples/test-suite/nspace_extend.i b/Examples/test-suite/nspace_extend.i
index 47ede95d0..96e97a4ff 100644
--- a/Examples/test-suite/nspace_extend.i
+++ b/Examples/test-suite/nspace_extend.i
@@ -4,6 +4,9 @@
// nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
+#if defined(SWIGJAVA)
+SWIG_JAVABODY_PROXY(public, public, SWIGTYPE)
+#endif
%nspace;
%extend Outer::Inner1::Color {
diff --git a/Examples/test-suite/perl5/Test/Builder.pm b/Examples/test-suite/perl5/Test/Builder.pm
deleted file mode 100644
index 9f6a3a43d..000000000
--- a/Examples/test-suite/perl5/Test/Builder.pm
+++ /dev/null
@@ -1,1591 +0,0 @@
-package Test::Builder;
-
-use 5.004;
-
-# $^C was only introduced in 5.005-ish. We do this to prevent
-# use of uninitialized value warnings in older perls.
-$^C ||= 0;
-
-use strict;
-use vars qw($VERSION);
-$VERSION = '0.22';
-$VERSION = eval $VERSION; # make the alpha version come out as a number
-
-# Make Test::Builder thread-safe for ithreads.
-BEGIN {
- use Config;
- # Load threads::shared when threads are turned on
- if( $] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) {
- require threads::shared;
-
- # Hack around YET ANOTHER threads::shared bug. It would
- # occassionally forget the contents of the variable when sharing it.
- # So we first copy the data, then share, then put our copy back.
- *share = sub (\[$@%]) {
- my $type = ref $_[0];
- my $data;
-
- if( $type eq 'HASH' ) {
- %$data = %{$_[0]};
- }
- elsif( $type eq 'ARRAY' ) {
- @$data = @{$_[0]};
- }
- elsif( $type eq 'SCALAR' ) {
- $$data = ${$_[0]};
- }
- else {
- die "Unknown type: ".$type;
- }
-
- $_[0] = &threads::shared::share($_[0]);
-
- if( $type eq 'HASH' ) {
- %{$_[0]} = %$data;
- }
- elsif( $type eq 'ARRAY' ) {
- @{$_[0]} = @$data;
- }
- elsif( $type eq 'SCALAR' ) {
- ${$_[0]} = $$data;
- }
- else {
- die "Unknown type: ".$type;
- }
-
- return $_[0];
- };
- }
- # 5.8.0's threads::shared is busted when threads are off.
- # We emulate it here.
- else {
- *share = sub { return $_[0] };
- *lock = sub { 0 };
- }
-}
-
-
-=head1 NAME
-
-Test::Builder - Backend for building test libraries
-
-=head1 SYNOPSIS
-
- package My::Test::Module;
- use Test::Builder;
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT = qw(ok);
-
- my $Test = Test::Builder->new;
- $Test->output('my_logfile');
-
- sub import {
- my($self) = shift;
- my $pack = caller;
-
- $Test->exported_to($pack);
- $Test->plan(@_);
-
- $self->export_to_level(1, $self, 'ok');
- }
-
- sub ok {
- my($test, $name) = @_;
-
- $Test->ok($test, $name);
- }
-
-
-=head1 DESCRIPTION
-
-Test::Simple and Test::More have proven to be popular testing modules,
-but they're not always flexible enough. Test::Builder provides the a
-building block upon which to write your own test libraries I.
-
-=head2 Construction
-
-=over 4
-
-=item B
-
- my $Test = Test::Builder->new;
-
-Returns a Test::Builder object representing the current state of the
-test.
-
-Since you only run one test per program, there is B
-Test::Builder object. No matter how many times you call new(), you're
-getting the same object. (This is called a singleton).
-
-=cut
-
-my $Test = Test::Builder->new;
-sub new {
- my($class) = shift;
- $Test ||= bless ['Move along, nothing to see here'], $class;
- return $Test;
-}
-
-=item B
-
- $Test->reset;
-
-Reinitializes the Test::Builder singleton to its original state.
-Mostly useful for tests run in persistent environments where the same
-test might be run multiple times in the same process.
-
-=cut
-
-my $Test_Died;
-my $Have_Plan;
-my $No_Plan;
-my $Curr_Test; share($Curr_Test);
-use vars qw($Level);
-my $Original_Pid;
-my @Test_Results; share(@Test_Results);
-
-my $Exported_To;
-my $Expected_Tests;
-
-my $Skip_All;
-
-my $Use_Nums;
-
-my($No_Header, $No_Ending);
-
-$Test->reset;
-
-sub reset {
- my ($self) = @_;
-
- $Test_Died = 0;
- $Have_Plan = 0;
- $No_Plan = 0;
- $Curr_Test = 0;
- $Level = 1;
- $Original_Pid = $$;
- @Test_Results = ();
-
- $Exported_To = undef;
- $Expected_Tests = 0;
-
- $Skip_All = 0;
-
- $Use_Nums = 1;
-
- ($No_Header, $No_Ending) = (0,0);
-
- $self->_dup_stdhandles unless $^C;
-
- return undef;
-}
-
-=back
-
-=head2 Setting up tests
-
-These methods are for setting up tests and declaring how many there
-are. You usually only want to call one of these methods.
-
-=over 4
-
-=item B
-
- my $pack = $Test->exported_to;
- $Test->exported_to($pack);
-
-Tells Test::Builder what package you exported your functions to.
-This is important for getting TODO tests right.
-
-=cut
-
-sub exported_to {
- my($self, $pack) = @_;
-
- if( defined $pack ) {
- $Exported_To = $pack;
- }
- return $Exported_To;
-}
-
-=item B
-
- $Test->plan('no_plan');
- $Test->plan( skip_all => $reason );
- $Test->plan( tests => $num_tests );
-
-A convenient way to set up your tests. Call this and Test::Builder
-will print the appropriate headers and take the appropriate actions.
-
-If you call plan(), don't call any of the other methods below.
-
-=cut
-
-sub plan {
- my($self, $cmd, $arg) = @_;
-
- return unless $cmd;
-
- if( $Have_Plan ) {
- die sprintf "You tried to plan twice! Second plan at %s line %d\n",
- ($self->caller)[1,2];
- }
-
- if( $cmd eq 'no_plan' ) {
- $self->no_plan;
- }
- elsif( $cmd eq 'skip_all' ) {
- return $self->skip_all($arg);
- }
- elsif( $cmd eq 'tests' ) {
- if( $arg ) {
- return $self->expected_tests($arg);
- }
- elsif( !defined $arg ) {
- die "Got an undefined number of tests. Looks like you tried to ".
- "say how many tests you plan to run but made a mistake.\n";
- }
- elsif( !$arg ) {
- die "You said to run 0 tests! You've got to run something.\n";
- }
- }
- else {
- require Carp;
- my @args = grep { defined } ($cmd, $arg);
- Carp::croak("plan() doesn't understand @args");
- }
-
- return 1;
-}
-
-=item B
-
- my $max = $Test->expected_tests;
- $Test->expected_tests($max);
-
-Gets/sets the # of tests we expect this test to run and prints out
-the appropriate headers.
-
-=cut
-
-sub expected_tests {
- my $self = shift;
- my($max) = @_;
-
- if( @_ ) {
- die "Number of tests must be a postive integer. You gave it '$max'.\n"
- unless $max =~ /^\+?\d+$/ and $max > 0;
-
- $Expected_Tests = $max;
- $Have_Plan = 1;
-
- $self->_print("1..$max\n") unless $self->no_header;
- }
- return $Expected_Tests;
-}
-
-
-=item B
-
- $Test->no_plan;
-
-Declares that this test will run an indeterminate # of tests.
-
-=cut
-
-sub no_plan {
- $No_Plan = 1;
- $Have_Plan = 1;
-}
-
-=item B
-
- $plan = $Test->has_plan
-
-Find out whether a plan has been defined. $plan is either C (no plan has been set), C (indeterminate # of tests) or an integer (the number of expected tests).
-
-=cut
-
-sub has_plan {
- return($Expected_Tests) if $Expected_Tests;
- return('no_plan') if $No_Plan;
- return(undef);
-};
-
-
-=item B
-
- $Test->skip_all;
- $Test->skip_all($reason);
-
-Skips all the tests, using the given $reason. Exits immediately with 0.
-
-=cut
-
-sub skip_all {
- my($self, $reason) = @_;
-
- my $out = "1..0";
- $out .= " # Skip $reason" if $reason;
- $out .= "\n";
-
- $Skip_All = 1;
-
- $self->_print($out) unless $self->no_header;
- exit(0);
-}
-
-=back
-
-=head2 Running tests
-
-These actually run the tests, analogous to the functions in
-Test::More.
-
-$name is always optional.
-
-=over 4
-
-=item B
-
- $Test->ok($test, $name);
-
-Your basic test. Pass if $test is true, fail if $test is false. Just
-like Test::Simple's ok().
-
-=cut
-
-sub ok {
- my($self, $test, $name) = @_;
-
- # $test might contain an object which we don't want to accidentally
- # store, so we turn it into a boolean.
- $test = $test ? 1 : 0;
-
- unless( $Have_Plan ) {
- require Carp;
- Carp::croak("You tried to run a test without a plan! Gotta have a plan.");
- }
-
- lock $Curr_Test;
- $Curr_Test++;
-
- # In case $name is a string overloaded object, force it to stringify.
- $self->_unoverload(\$name);
-
- $self->diag(<caller;
-
- my $todo = $self->todo($pack);
- $self->_unoverload(\$todo);
-
- my $out;
- my $result = &share({});
-
- unless( $test ) {
- $out .= "not ";
- @$result{ 'ok', 'actual_ok' } = ( ( $todo ? 1 : 0 ), 0 );
- }
- else {
- @$result{ 'ok', 'actual_ok' } = ( 1, $test );
- }
-
- $out .= "ok";
- $out .= " $Curr_Test" if $self->use_numbers;
-
- if( defined $name ) {
- $name =~ s|#|\\#|g; # # in a name can confuse Test::Harness.
- $out .= " - $name";
- $result->{name} = $name;
- }
- else {
- $result->{name} = '';
- }
-
- if( $todo ) {
- $out .= " # TODO $todo";
- $result->{reason} = $todo;
- $result->{type} = 'todo';
- }
- else {
- $result->{reason} = '';
- $result->{type} = '';
- }
-
- $Test_Results[$Curr_Test-1] = $result;
- $out .= "\n";
-
- $self->_print($out);
-
- unless( $test ) {
- my $msg = $todo ? "Failed (TODO)" : "Failed";
- $self->_print_diag("\n") if $ENV{HARNESS_ACTIVE};
- $self->diag(" $msg test ($file at line $line)\n");
- }
-
- return $test ? 1 : 0;
-}
-
-
-sub _unoverload {
- my $self = shift;
-
- local($@,$!);
-
- eval { require overload } || return;
-
- foreach my $thing (@_) {
- eval {
- if( defined $$thing ) {
- if( my $string_meth = overload::Method($$thing, '""') ) {
- $$thing = $$thing->$string_meth();
- }
- }
- };
- }
-}
-
-
-=item B
-
- $Test->is_eq($got, $expected, $name);
-
-Like Test::More's is(). Checks if $got eq $expected. This is the
-string version.
-
-=item B
-
- $Test->is_num($got, $expected, $name);
-
-Like Test::More's is(). Checks if $got == $expected. This is the
-numeric version.
-
-=cut
-
-sub is_eq {
- my($self, $got, $expect, $name) = @_;
- local $Level = $Level + 1;
-
- if( !defined $got || !defined $expect ) {
- # undef only matches undef and nothing else
- my $test = !defined $got && !defined $expect;
-
- $self->ok($test, $name);
- $self->_is_diag($got, 'eq', $expect) unless $test;
- return $test;
- }
-
- return $self->cmp_ok($got, 'eq', $expect, $name);
-}
-
-sub is_num {
- my($self, $got, $expect, $name) = @_;
- local $Level = $Level + 1;
-
- if( !defined $got || !defined $expect ) {
- # undef only matches undef and nothing else
- my $test = !defined $got && !defined $expect;
-
- $self->ok($test, $name);
- $self->_is_diag($got, '==', $expect) unless $test;
- return $test;
- }
-
- return $self->cmp_ok($got, '==', $expect, $name);
-}
-
-sub _is_diag {
- my($self, $got, $type, $expect) = @_;
-
- foreach my $val (\$got, \$expect) {
- if( defined $$val ) {
- if( $type eq 'eq' ) {
- # quote and force string context
- $$val = "'$$val'"
- }
- else {
- # force numeric context
- $$val = $$val+0;
- }
- }
- else {
- $$val = 'undef';
- }
- }
-
- return $self->diag(sprintf <
-
- $Test->isnt_eq($got, $dont_expect, $name);
-
-Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
-the string version.
-
-=item B
-
- $Test->is_num($got, $dont_expect, $name);
-
-Like Test::More's isnt(). Checks if $got ne $dont_expect. This is
-the numeric version.
-
-=cut
-
-sub isnt_eq {
- my($self, $got, $dont_expect, $name) = @_;
- local $Level = $Level + 1;
-
- if( !defined $got || !defined $dont_expect ) {
- # undef only matches undef and nothing else
- my $test = defined $got || defined $dont_expect;
-
- $self->ok($test, $name);
- $self->_cmp_diag($got, 'ne', $dont_expect) unless $test;
- return $test;
- }
-
- return $self->cmp_ok($got, 'ne', $dont_expect, $name);
-}
-
-sub isnt_num {
- my($self, $got, $dont_expect, $name) = @_;
- local $Level = $Level + 1;
-
- if( !defined $got || !defined $dont_expect ) {
- # undef only matches undef and nothing else
- my $test = defined $got || defined $dont_expect;
-
- $self->ok($test, $name);
- $self->_cmp_diag($got, '!=', $dont_expect) unless $test;
- return $test;
- }
-
- return $self->cmp_ok($got, '!=', $dont_expect, $name);
-}
-
-
-=item B
-
- $Test->like($this, qr/$regex/, $name);
- $Test->like($this, '/$regex/', $name);
-
-Like Test::More's like(). Checks if $this matches the given $regex.
-
-You'll want to avoid qr// if you want your tests to work before 5.005.
-
-=item B
-
- $Test->unlike($this, qr/$regex/, $name);
- $Test->unlike($this, '/$regex/', $name);
-
-Like Test::More's unlike(). Checks if $this B the
-given $regex.
-
-=cut
-
-sub like {
- my($self, $this, $regex, $name) = @_;
-
- local $Level = $Level + 1;
- $self->_regex_ok($this, $regex, '=~', $name);
-}
-
-sub unlike {
- my($self, $this, $regex, $name) = @_;
-
- local $Level = $Level + 1;
- $self->_regex_ok($this, $regex, '!~', $name);
-}
-
-=item B
-
- $Test->maybe_regex(qr/$regex/);
- $Test->maybe_regex('/$regex/');
-
-Convenience method for building testing functions that take regular
-expressions as arguments, but need to work before perl 5.005.
-
-Takes a quoted regular expression produced by qr//, or a string
-representing a regular expression.
-
-Returns a Perl value which may be used instead of the corresponding
-regular expression, or undef if it's argument is not recognised.
-
-For example, a version of like(), sans the useful diagnostic messages,
-could be written as:
-
- sub laconic_like {
- my ($self, $this, $regex, $name) = @_;
- my $usable_regex = $self->maybe_regex($regex);
- die "expecting regex, found '$regex'\n"
- unless $usable_regex;
- $self->ok($this =~ m/$usable_regex/, $name);
- }
-
-=cut
-
-
-sub maybe_regex {
- my ($self, $regex) = @_;
- my $usable_regex = undef;
-
- return $usable_regex unless defined $regex;
-
- my($re, $opts);
-
- # Check for qr/foo/
- if( ref $regex eq 'Regexp' ) {
- $usable_regex = $regex;
- }
- # Check for '/foo/' or 'm,foo,'
- elsif( ($re, $opts) = $regex =~ m{^ /(.*)/ (\w*) $ }sx or
- (undef, $re, $opts) = $regex =~ m,^ m([^\w\s]) (.+) \1 (\w*) $,sx
- )
- {
- $usable_regex = length $opts ? "(?$opts)$re" : $re;
- }
-
- return $usable_regex;
-};
-
-sub _regex_ok {
- my($self, $this, $regex, $cmp, $name) = @_;
-
- local $Level = $Level + 1;
-
- my $ok = 0;
- my $usable_regex = $self->maybe_regex($regex);
- unless (defined $usable_regex) {
- $ok = $self->ok( 0, $name );
- $self->diag(" '$regex' doesn't look much like a regex to me.");
- return $ok;
- }
-
- {
- local $^W = 0;
- my $test = $this =~ /$usable_regex/ ? 1 : 0;
- $test = !$test if $cmp eq '!~';
- $ok = $self->ok( $test, $name );
- }
-
- unless( $ok ) {
- $this = defined $this ? "'$this'" : 'undef';
- my $match = $cmp eq '=~' ? "doesn't match" : "matches";
- $self->diag(sprintf <
-
- $Test->cmp_ok($this, $type, $that, $name);
-
-Works just like Test::More's cmp_ok().
-
- $Test->cmp_ok($big_num, '!=', $other_big_num);
-
-=cut
-
-sub cmp_ok {
- my($self, $got, $type, $expect, $name) = @_;
-
- my $test;
- {
- local $^W = 0;
- local($@,$!); # don't interfere with $@
- # eval() sometimes resets $!
- $test = eval "\$got $type \$expect";
- }
- local $Level = $Level + 1;
- my $ok = $self->ok($test, $name);
-
- unless( $ok ) {
- if( $type =~ /^(eq|==)$/ ) {
- $self->_is_diag($got, $type, $expect);
- }
- else {
- $self->_cmp_diag($got, $type, $expect);
- }
- }
- return $ok;
-}
-
-sub _cmp_diag {
- my($self, $got, $type, $expect) = @_;
-
- $got = defined $got ? "'$got'" : 'undef';
- $expect = defined $expect ? "'$expect'" : 'undef';
- return $self->diag(sprintf <
-
- $Test->BAILOUT($reason);
-
-Indicates to the Test::Harness that things are going so badly all
-testing should terminate. This includes running any additional test
-scripts.
-
-It will exit with 255.
-
-=cut
-
-sub BAILOUT {
- my($self, $reason) = @_;
-
- $self->_print("Bail out! $reason");
- exit 255;
-}
-
-=item B
-
- $Test->skip;
- $Test->skip($why);
-
-Skips the current test, reporting $why.
-
-=cut
-
-sub skip {
- my($self, $why) = @_;
- $why ||= '';
- $self->_unoverload(\$why);
-
- unless( $Have_Plan ) {
- require Carp;
- Carp::croak("You tried to run tests without a plan! Gotta have a plan.");
- }
-
- lock($Curr_Test);
- $Curr_Test++;
-
- $Test_Results[$Curr_Test-1] = &share({
- 'ok' => 1,
- actual_ok => 1,
- name => '',
- type => 'skip',
- reason => $why,
- });
-
- my $out = "ok";
- $out .= " $Curr_Test" if $self->use_numbers;
- $out .= " # skip";
- $out .= " $why" if length $why;
- $out .= "\n";
-
- $Test->_print($out);
-
- return 1;
-}
-
-
-=item B
-
- $Test->todo_skip;
- $Test->todo_skip($why);
-
-Like skip(), only it will declare the test as failing and TODO. Similar
-to
-
- print "not ok $tnum # TODO $why\n";
-
-=cut
-
-sub todo_skip {
- my($self, $why) = @_;
- $why ||= '';
-
- unless( $Have_Plan ) {
- require Carp;
- Carp::croak("You tried to run tests without a plan! Gotta have a plan.");
- }
-
- lock($Curr_Test);
- $Curr_Test++;
-
- $Test_Results[$Curr_Test-1] = &share({
- 'ok' => 1,
- actual_ok => 0,
- name => '',
- type => 'todo_skip',
- reason => $why,
- });
-
- my $out = "not ok";
- $out .= " $Curr_Test" if $self->use_numbers;
- $out .= " # TODO & SKIP $why\n";
-
- $Test->_print($out);
-
- return 1;
-}
-
-
-=begin _unimplemented
-
-=item B
-
- $Test->skip_rest;
- $Test->skip_rest($reason);
-
-Like skip(), only it skips all the rest of the tests you plan to run
-and terminates the test.
-
-If you're running under no_plan, it skips once and terminates the
-test.
-
-=end _unimplemented
-
-=back
-
-
-=head2 Test style
-
-=over 4
-
-=item B
-
- $Test->level($how_high);
-
-How far up the call stack should $Test look when reporting where the
-test failed.
-
-Defaults to 1.
-
-Setting $Test::Builder::Level overrides. This is typically useful
-localized:
-
- {
- local $Test::Builder::Level = 2;
- $Test->ok($test);
- }
-
-=cut
-
-sub level {
- my($self, $level) = @_;
-
- if( defined $level ) {
- $Level = $level;
- }
- return $Level;
-}
-
-
-=item B
-
- $Test->use_numbers($on_or_off);
-
-Whether or not the test should output numbers. That is, this if true:
-
- ok 1
- ok 2
- ok 3
-
-or this if false
-
- ok
- ok
- ok
-
-Most useful when you can't depend on the test output order, such as
-when threads or forking is involved.
-
-Test::Harness will accept either, but avoid mixing the two styles.
-
-Defaults to on.
-
-=cut
-
-sub use_numbers {
- my($self, $use_nums) = @_;
-
- if( defined $use_nums ) {
- $Use_Nums = $use_nums;
- }
- return $Use_Nums;
-}
-
-=item B
-
- $Test->no_header($no_header);
-
-If set to true, no "1..N" header will be printed.
-
-=item B
-
- $Test->no_ending($no_ending);
-
-Normally, Test::Builder does some extra diagnostics when the test
-ends. It also changes the exit code as described below.
-
-If this is true, none of that will be done.
-
-=cut
-
-sub no_header {
- my($self, $no_header) = @_;
-
- if( defined $no_header ) {
- $No_Header = $no_header;
- }
- return $No_Header;
-}
-
-sub no_ending {
- my($self, $no_ending) = @_;
-
- if( defined $no_ending ) {
- $No_Ending = $no_ending;
- }
- return $No_Ending;
-}
-
-
-=back
-
-=head2 Output
-
-Controlling where the test output goes.
-
-It's ok for your test to change where STDOUT and STDERR point to,
-Test::Builder's default output settings will not be affected.
-
-=over 4
-
-=item B
-
- $Test->diag(@msgs);
-
-Prints out the given @msgs. Like C, arguments are simply
-appended together.
-
-Normally, it uses the failure_output() handle, but if this is for a
-TODO test, the todo_output() handle is used.
-
-Output will be indented and marked with a # so as not to interfere
-with test output. A newline will be put on the end if there isn't one
-already.
-
-We encourage using this rather than calling print directly.
-
-Returns false. Why? Because diag() is often used in conjunction with
-a failing test (C) it "passes through" the failure.
-
- return ok(...) || diag(...);
-
-=for blame transfer
-Mark Fowler
-
-=cut
-
-sub diag {
- my($self, @msgs) = @_;
- return unless @msgs;
-
- # Prevent printing headers when compiling (i.e. -c)
- return if $^C;
-
- # Smash args together like print does.
- # Convert undef to 'undef' so its readable.
- my $msg = join '', map { defined($_) ? $_ : 'undef' } @msgs;
-
- # Escape each line with a #.
- $msg =~ s/^/# /gm;
-
- # Stick a newline on the end if it needs it.
- $msg .= "\n" unless $msg =~ /\n\Z/;
-
- local $Level = $Level + 1;
- $self->_print_diag($msg);
-
- return 0;
-}
-
-=begin _private
-
-=item B<_print>
-
- $Test->_print(@msgs);
-
-Prints to the output() filehandle.
-
-=end _private
-
-=cut
-
-sub _print {
- my($self, @msgs) = @_;
-
- # Prevent printing headers when only compiling. Mostly for when
- # tests are deparsed with B::Deparse
- return if $^C;
-
- my $msg = join '', @msgs;
-
- local($\, $", $,) = (undef, ' ', '');
- my $fh = $self->output;
-
- # Escape each line after the first with a # so we don't
- # confuse Test::Harness.
- $msg =~ s/\n(.)/\n# $1/sg;
-
- # Stick a newline on the end if it needs it.
- $msg .= "\n" unless $msg =~ /\n\Z/;
-
- print $fh $msg;
-}
-
-
-=item B<_print_diag>
-
- $Test->_print_diag(@msg);
-
-Like _print, but prints to the current diagnostic filehandle.
-
-=cut
-
-sub _print_diag {
- my $self = shift;
-
- local($\, $", $,) = (undef, ' ', '');
- my $fh = $self->todo ? $self->todo_output : $self->failure_output;
- print $fh @_;
-}
-
-=item B