summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2009-04-30 06:12:32 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2009-04-30 06:12:32 +0000
commit90b1578d65491cac9b50626ca92fbae1d7fa2450 (patch)
tree70ba03bc251f535165b9fbd5e9228235fb3cd20e
parent81f2687f6028fcaf2525a9bc33446cb2a3315526 (diff)
downloadswig-90b1578d65491cac9b50626ca92fbae1d7fa2450.tar.gz
add test for optimal attribute in out typemap
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11199 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--Examples/test-suite/common.mk1
-rwxr-xr-xExamples/test-suite/csharp/typemap_out_optimal_runme.cs13
-rw-r--r--Examples/test-suite/java/typemap_out_optimal_runme.java21
-rw-r--r--Examples/test-suite/python/typemap_out_optimal_runme.py5
-rw-r--r--Examples/test-suite/typemap_out_optimal.i38
5 files changed, 78 insertions, 0 deletions
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index afcb87159..5c6a332a4 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -371,6 +371,7 @@ CPP_TEST_CASES += \
typemap_namespace \
typemap_ns_using \
typemap_numinputs \
+ typemap_out_optimal \
typemap_variables \
typemap_various \
typename \
diff --git a/Examples/test-suite/csharp/typemap_out_optimal_runme.cs b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs
new file mode 100755
index 000000000..5bc1d14be
--- /dev/null
+++ b/Examples/test-suite/csharp/typemap_out_optimal_runme.cs
@@ -0,0 +1,13 @@
+using System;
+using typemap_out_optimalNamespace;
+
+public class typemap_out_optimal_runme {
+
+ public static XX x = null;
+ public static void Main() {
+ XX.debug = false;
+ x = XX.create();
+ }
+
+}
+
diff --git a/Examples/test-suite/java/typemap_out_optimal_runme.java b/Examples/test-suite/java/typemap_out_optimal_runme.java
new file mode 100644
index 000000000..8a87f0c4b
--- /dev/null
+++ b/Examples/test-suite/java/typemap_out_optimal_runme.java
@@ -0,0 +1,21 @@
+
+import typemap_out_optimal.*;
+
+public class typemap_out_optimal_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_out_optimal");
+ } 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 XX x = null;
+ public static void main(String argv[]) {
+ XX.setDebug(false);
+ x = XX.create();
+ }
+}
+
diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py
new file mode 100644
index 000000000..b148f2d06
--- /dev/null
+++ b/Examples/test-suite/python/typemap_out_optimal_runme.py
@@ -0,0 +1,5 @@
+from typemap_out_optimal import *
+
+cvar.XX_debug = False
+x = XX.create()
+
diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i
new file mode 100644
index 000000000..8bac2fa89
--- /dev/null
+++ b/Examples/test-suite/typemap_out_optimal.i
@@ -0,0 +1,38 @@
+// Test the optimal attribute in the out typemap
+%module typemap_out_optimal
+
+// Just the following languages tested
+#if defined (SWIGCSHARP)
+%typemap(out, optimal="1") SWIGTYPE %{
+ $result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGJAVA)
+%typemap(out, optimal="1") SWIGTYPE %{
+ *($&1_ltype*)&$result = new $1_ltype((const $1_ltype &)$1);
+%}
+#elif defined (SWIGUTL)
+%typemap(out,noblock="1", optimal="1") SWIGTYPE {
+ %set_output(SWIG_NewPointerObj(%new_copy($1, $ltype), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags));
+}
+#endif
+
+%ignore XX::operator=;
+
+%inline %{
+#include <iostream>
+using namespace std;
+
+struct XX {
+ XX() { cout << "XX()" << endl; }
+ XX(int i) { if (debug) cout << "XX(" << i << ")" << endl; }
+ XX(const XX &other) { cout << "XX(const XX &)" << endl; }
+ XX& operator =(const XX &other) { cout << "operator=(const XX &)" << endl; return *this; }
+ ~XX() { if (debug) cout << "~XX()" << endl; }
+ static XX create() {
+ return XX(123);
+ }
+ static bool debug;
+};
+bool XX::debug = true;
+%}
+