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
This commit is contained in:
parent
81f2687f60
commit
90b1578d65
5 changed files with 78 additions and 0 deletions
|
|
@ -371,6 +371,7 @@ CPP_TEST_CASES += \
|
|||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
typemap_numinputs \
|
||||
typemap_out_optimal \
|
||||
typemap_variables \
|
||||
typemap_various \
|
||||
typename \
|
||||
|
|
|
|||
13
Examples/test-suite/csharp/typemap_out_optimal_runme.cs
Executable file
13
Examples/test-suite/csharp/typemap_out_optimal_runme.cs
Executable file
|
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
21
Examples/test-suite/java/typemap_out_optimal_runme.java
Normal file
21
Examples/test-suite/java/typemap_out_optimal_runme.java
Normal file
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
5
Examples/test-suite/python/typemap_out_optimal_runme.py
Normal file
5
Examples/test-suite/python/typemap_out_optimal_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
from typemap_out_optimal import *
|
||||
|
||||
cvar.XX_debug = False
|
||||
x = XX.create()
|
||||
|
||||
38
Examples/test-suite/typemap_out_optimal.i
Normal file
38
Examples/test-suite/typemap_out_optimal.i
Normal file
|
|
@ -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;
|
||||
%}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue