mirror of https://github.com/swig/swig
more thorough %rename tests including conversion operator %rename
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9836 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
d53ef0a8c4
commit
ec8d13b467
|
@ -219,6 +219,10 @@ CPP_TEST_CASES += \
|
|||
refcount \
|
||||
reference_global_vars \
|
||||
register_par \
|
||||
rename1 \
|
||||
rename2 \
|
||||
rename3 \
|
||||
rename4 \
|
||||
rename_scope \
|
||||
restrict_cplusplus \
|
||||
return_const_value \
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
%module conversion_namespace
|
||||
%rename(toFoo) oss::Bar::operator oss::Foo();
|
||||
%rename(toFoo) oss::Bar::operator Foo();
|
||||
|
||||
%inline %{
|
||||
namespace oss
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
import rename1.*;
|
||||
|
||||
public class rename1_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("rename1");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
// The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
|
||||
public static void main(String argv[]) {
|
||||
{
|
||||
XYZInt xyz = new XYZInt();
|
||||
NotXYZInt notxyz = new NotXYZInt();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother2();
|
||||
xyz.opT2();
|
||||
xyz.tMethod2(0);
|
||||
xyz.tMethodNotXYZ2(notxyz);
|
||||
xyz.opNotXYZ2();
|
||||
xyz.opXYZ2();
|
||||
}
|
||||
{
|
||||
XYZDouble xyz = new XYZDouble();
|
||||
NotXYZDouble notxyz = new NotXYZDouble();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother1();
|
||||
xyz.opT1();
|
||||
xyz.tMethod1(0);
|
||||
xyz.tMethodNotXYZ1(notxyz);
|
||||
xyz.opNotXYZ1();
|
||||
xyz.opXYZ1();
|
||||
}
|
||||
{
|
||||
XYZKlass xyz = new XYZKlass();
|
||||
NotXYZKlass notxyz = new NotXYZKlass();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother3();
|
||||
xyz.opT3();
|
||||
xyz.tMethod3(new Klass());
|
||||
xyz.tMethodNotXYZ3(notxyz);
|
||||
xyz.opNotXYZ3();
|
||||
xyz.opXYZ3();
|
||||
}
|
||||
{
|
||||
XYZEnu xyz = new XYZEnu();
|
||||
NotXYZEnu notxyz = new NotXYZEnu();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother4();
|
||||
xyz.opT4();
|
||||
xyz.tMethod4(Enu.En1);
|
||||
xyz.tMethodNotXYZ4(notxyz);
|
||||
xyz.opNotXYZ4();
|
||||
xyz.opXYZ4();
|
||||
}
|
||||
{
|
||||
ABC abc = new ABC();
|
||||
abc.methodABC(abc);
|
||||
Klass k = new Klass();
|
||||
abc.methodKlass(k);
|
||||
ABC a = abc.opABC();
|
||||
k = abc.opKlass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
import rename2.*;
|
||||
|
||||
public class rename2_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("rename2");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
// The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
|
||||
public static void main(String argv[]) {
|
||||
{
|
||||
XYZInt xyz = new XYZInt();
|
||||
NotXYZInt notxyz = new NotXYZInt();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother2();
|
||||
xyz.opT2();
|
||||
xyz.tMethod2(0);
|
||||
xyz.tMethodNotXYZ2(notxyz);
|
||||
xyz.opNotXYZ2();
|
||||
xyz.opXYZ2();
|
||||
}
|
||||
{
|
||||
XYZDouble xyz = new XYZDouble();
|
||||
NotXYZDouble notxyz = new NotXYZDouble();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother1();
|
||||
xyz.opT1();
|
||||
xyz.tMethod1(0);
|
||||
xyz.tMethodNotXYZ1(notxyz);
|
||||
xyz.opNotXYZ1();
|
||||
xyz.opXYZ1();
|
||||
}
|
||||
{
|
||||
XYZKlass xyz = new XYZKlass();
|
||||
NotXYZKlass notxyz = new NotXYZKlass();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother3();
|
||||
xyz.opT3();
|
||||
xyz.tMethod3(new Klass());
|
||||
xyz.tMethodNotXYZ3(notxyz);
|
||||
xyz.opNotXYZ3();
|
||||
xyz.opXYZ3();
|
||||
}
|
||||
{
|
||||
XYZEnu xyz = new XYZEnu();
|
||||
NotXYZEnu notxyz = new NotXYZEnu();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother4();
|
||||
xyz.opT4();
|
||||
xyz.tMethod4(Enu.En1);
|
||||
xyz.tMethodNotXYZ4(notxyz);
|
||||
xyz.opNotXYZ4();
|
||||
xyz.opXYZ4();
|
||||
}
|
||||
{
|
||||
ABC abc = new ABC();
|
||||
abc.methodABC(abc);
|
||||
Klass k = new Klass();
|
||||
abc.methodKlass(k);
|
||||
ABC a = abc.opABC();
|
||||
k = abc.opKlass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
import rename3.*;
|
||||
|
||||
public class rename3_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("rename3");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
// The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
|
||||
public static void main(String argv[]) {
|
||||
{
|
||||
XYZInt xyz = new XYZInt();
|
||||
NotXYZInt notxyz = new NotXYZInt();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother2();
|
||||
xyz.opT2();
|
||||
xyz.tMethod2(0);
|
||||
xyz.tMethodNotXYZ2(notxyz);
|
||||
xyz.opNotXYZ2();
|
||||
xyz.opXYZ2();
|
||||
}
|
||||
{
|
||||
XYZDouble xyz = new XYZDouble();
|
||||
NotXYZDouble notxyz = new NotXYZDouble();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother1();
|
||||
xyz.opT1();
|
||||
xyz.tMethod1(0);
|
||||
xyz.tMethodNotXYZ1(notxyz);
|
||||
xyz.opNotXYZ1();
|
||||
xyz.opXYZ1();
|
||||
}
|
||||
{
|
||||
XYZKlass xyz = new XYZKlass();
|
||||
NotXYZKlass notxyz = new NotXYZKlass();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother3();
|
||||
xyz.opT3();
|
||||
xyz.tMethod3(new Klass());
|
||||
xyz.tMethodNotXYZ3(notxyz);
|
||||
xyz.opNotXYZ3();
|
||||
xyz.opXYZ3();
|
||||
}
|
||||
{
|
||||
XYZEnu xyz = new XYZEnu();
|
||||
NotXYZEnu notxyz = new NotXYZEnu();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother4();
|
||||
xyz.opT4();
|
||||
xyz.tMethod4(Enu.En1);
|
||||
xyz.tMethodNotXYZ4(notxyz);
|
||||
xyz.opNotXYZ4();
|
||||
xyz.opXYZ4();
|
||||
}
|
||||
{
|
||||
ABC abc = new ABC();
|
||||
abc.methodABC(abc);
|
||||
Klass k = new Klass();
|
||||
abc.methodKlass(k);
|
||||
ABC a = abc.opABC();
|
||||
k = abc.opKlass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
|
||||
import rename4.*;
|
||||
|
||||
public class rename4_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("rename4");
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
// The code in main is the same for rename1_runme, rename2_runme, rename3_runme and renam4_runme
|
||||
public static void main(String argv[]) {
|
||||
{
|
||||
XYZInt xyz = new XYZInt();
|
||||
NotXYZInt notxyz = new NotXYZInt();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother2();
|
||||
xyz.opT2();
|
||||
xyz.tMethod2(0);
|
||||
xyz.tMethodNotXYZ2(notxyz);
|
||||
xyz.opNotXYZ2();
|
||||
xyz.opXYZ2();
|
||||
}
|
||||
{
|
||||
XYZDouble xyz = new XYZDouble();
|
||||
NotXYZDouble notxyz = new NotXYZDouble();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother1();
|
||||
xyz.opT1();
|
||||
xyz.tMethod1(0);
|
||||
xyz.tMethodNotXYZ1(notxyz);
|
||||
xyz.opNotXYZ1();
|
||||
xyz.opXYZ1();
|
||||
}
|
||||
{
|
||||
XYZKlass xyz = new XYZKlass();
|
||||
NotXYZKlass notxyz = new NotXYZKlass();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother3();
|
||||
xyz.opT3();
|
||||
xyz.tMethod3(new Klass());
|
||||
xyz.tMethodNotXYZ3(notxyz);
|
||||
xyz.opNotXYZ3();
|
||||
xyz.opXYZ3();
|
||||
}
|
||||
{
|
||||
XYZEnu xyz = new XYZEnu();
|
||||
NotXYZEnu notxyz = new NotXYZEnu();
|
||||
xyz.opIntPtrA();
|
||||
xyz.opIntPtrB();
|
||||
xyz.opAnother4();
|
||||
xyz.opT4();
|
||||
xyz.tMethod4(Enu.En1);
|
||||
xyz.tMethodNotXYZ4(notxyz);
|
||||
xyz.opNotXYZ4();
|
||||
xyz.opXYZ4();
|
||||
}
|
||||
{
|
||||
ABC abc = new ABC();
|
||||
abc.methodABC(abc);
|
||||
Klass k = new Klass();
|
||||
abc.methodKlass(k);
|
||||
ABC a = abc.opABC();
|
||||
k = abc.opKlass();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
|
||||
namespace Space {
|
||||
struct Klass {
|
||||
Klass(int i) {}
|
||||
Klass() {}
|
||||
};
|
||||
}
|
||||
|
||||
namespace AnotherSpace {
|
||||
class Another {};
|
||||
}
|
||||
|
||||
namespace Space {
|
||||
using namespace AnotherSpace;
|
||||
enum Enu { En1, En2, En3 };
|
||||
template<typename T> struct NotXYZ {};
|
||||
template<typename T> class XYZ {
|
||||
NotXYZ<int> *m_int;
|
||||
T m_t;
|
||||
NotXYZ<T> m_notxyz;
|
||||
public:
|
||||
operator NotXYZ<int>*() const { return m_int; }
|
||||
operator XYZ<int>*() const { return 0; }
|
||||
operator Another() const { Another an; return an; }
|
||||
void templateT(T i) {}
|
||||
void templateNotXYZ(NotXYZ<T> i) {}
|
||||
void templateXYZ(XYZ<T> i) {}
|
||||
operator T() { return m_t; }
|
||||
operator NotXYZ<T>() const { return m_notxyz; }
|
||||
operator XYZ<T>() const { XYZ<T> xyz; return xyz; }
|
||||
};
|
||||
}
|
||||
|
||||
namespace Space {
|
||||
// non-templated class using itself in method and operator
|
||||
class ABC {
|
||||
public:
|
||||
void method(ABC a) const {}
|
||||
void method(Klass k) const {}
|
||||
operator ABC() const { ABC a; return a; }
|
||||
operator Klass() const { Klass k; return k; }
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
// Test %rename directive in global namespace by fully qualifying types
|
||||
%module rename1
|
||||
|
||||
// Note: Space:: qualifier
|
||||
%rename(opIntPtrA) Space::XYZ::operator NotXYZ<int>*() const;
|
||||
%rename(opIntPtrB) Space::XYZ::operator XYZ<int>*() const;
|
||||
|
||||
%rename(opAnother1) Space::XYZ::operator Another() const;
|
||||
%rename(opAnother2) Space::XYZ<int>::operator Another() const;
|
||||
%rename(opAnother3) Space::XYZ<Space::Klass>::operator Another() const;
|
||||
%rename(opAnother4) Space::XYZ<Space::Enu>::operator Another() const;
|
||||
|
||||
%rename(tMethod1) Space::XYZ::templateT(T i);
|
||||
%rename(tMethod2) Space::XYZ<int>::templateT(int i);
|
||||
%rename(tMethod3) Space::XYZ<Space::Klass>::templateT(Space::Klass i);
|
||||
%rename(tMethod4) Space::XYZ<Space::Enu>::templateT(Space::Enu i);
|
||||
|
||||
%rename(tMethodNotXYZ1) Space::XYZ::templateNotXYZ(NotXYZ<T>);
|
||||
%rename(tMethodNotXYZ2) Space::XYZ<int>::templateNotXYZ(NotXYZ<int>);
|
||||
%rename(tMethodNotXYZ3) Space::XYZ<Space::Klass>::templateNotXYZ(NotXYZ<Space::Klass>);
|
||||
%rename(tMethodNotXYZ4) Space::XYZ<Space::Enu>::templateNotXYZ(NotXYZ<Space::Enu>);
|
||||
|
||||
%rename(tMethodXYZ1) Space::XYZ::templateXYZ(XYZ<T>);
|
||||
%rename(tMethodXYZ2) Space::XYZ<int>::templateXYZ(XYZ<int>);
|
||||
%rename(tMethodXYZ3) Space::XYZ<Space::Klass>::templateXYZ(XYZ<Space::Klass>);
|
||||
%rename(tMethodXYZ4) Space::XYZ<Space::Enu>::templateXYZ(XYZ<Space::Enu>);
|
||||
|
||||
%rename(opT1) Space::XYZ::operator T();
|
||||
%rename(opT2) Space::XYZ<int>::operator int();
|
||||
%rename(opT3) Space::XYZ<Space::Klass>::operator Space::Klass();
|
||||
%rename(opT4) Space::XYZ<Space::Enu>::operator Space::Enu();
|
||||
|
||||
%rename(opNotXYZ1) Space::XYZ::operator NotXYZ<T>() const;
|
||||
%rename(opNotXYZ2) Space::XYZ<int>::operator NotXYZ<int>() const;
|
||||
%rename(opNotXYZ3) Space::XYZ<Space::Klass>::operator NotXYZ<Space::Klass>() const;
|
||||
%rename(opNotXYZ4) Space::XYZ<Space::Enu>::operator NotXYZ<Space::Enu>() const;
|
||||
|
||||
%rename(opXYZ1) Space::XYZ::operator XYZ<T>() const;
|
||||
%rename(opXYZ2) Space::XYZ<int>::operator XYZ<int>() const;
|
||||
%rename(opXYZ3) Space::XYZ<Space::Klass>::operator XYZ<Space::Klass>() const;
|
||||
%rename(opXYZ4) Space::XYZ<Space::Enu>::operator XYZ<Space::Enu>() const;
|
||||
|
||||
|
||||
%rename(methodABC) Space::ABC::method(ABC a) const;
|
||||
%rename(opABC) Space::ABC::operator ABC() const;
|
||||
%rename(methodKlass) Space::ABC::method(Klass k) const;
|
||||
%rename(opKlass) Space::ABC::operator Klass() const;
|
||||
|
||||
%{
|
||||
#include "rename.h"
|
||||
%}
|
||||
%include "rename.h"
|
||||
|
||||
%template(XYZInt) Space::XYZ<int>;
|
||||
%template(XYZDouble) Space::XYZ<double>;
|
||||
%template(XYZKlass) Space::XYZ<Space::Klass>;
|
||||
%template(XYZEnu) Space::XYZ<Space::Enu>;
|
||||
|
||||
%template(NotXYZInt) Space::NotXYZ<int>;
|
||||
%template(NotXYZDouble) Space::NotXYZ<double>;
|
||||
%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
|
||||
%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
// Test %rename directive in the Space namespace
|
||||
%module rename2
|
||||
|
||||
namespace Space {
|
||||
// Note: no Space:: qualifier
|
||||
%rename(opIntPtrA) XYZ::operator NotXYZ<int>*() const;
|
||||
%rename(opIntPtrB) XYZ::operator XYZ<int>*() const;
|
||||
|
||||
%rename(opAnother1) XYZ::operator Another() const;
|
||||
%rename(opAnother2) XYZ<int>::operator Another() const;
|
||||
%rename(opAnother3) XYZ<Space::Klass>::operator Another() const;
|
||||
%rename(opAnother4) XYZ<Space::Enu>::operator Another() const;
|
||||
|
||||
%rename(tMethod1) XYZ::templateT(T i);
|
||||
%rename(tMethod2) XYZ<int>::templateT(int i);
|
||||
%rename(tMethod3) XYZ<Space::Klass>::templateT(Space::Klass i);
|
||||
%rename(tMethod4) XYZ<Space::Enu>::templateT(Space::Enu i);
|
||||
|
||||
%rename(tMethodNotXYZ1) XYZ::templateNotXYZ(NotXYZ<T>);
|
||||
%rename(tMethodNotXYZ2) XYZ<int>::templateNotXYZ(NotXYZ<int>);
|
||||
%rename(tMethodNotXYZ3) XYZ<Space::Klass>::templateNotXYZ(NotXYZ<Space::Klass>);
|
||||
%rename(tMethodNotXYZ4) XYZ<Space::Enu>::templateNotXYZ(NotXYZ<Space::Enu>);
|
||||
|
||||
%rename(tMethodXYZ1) XYZ::templateXYZ(XYZ<T>);
|
||||
%rename(tMethodXYZ2) XYZ<int>::templateXYZ(XYZ<int>);
|
||||
%rename(tMethodXYZ3) XYZ<Space::Klass>::templateXYZ(XYZ<Space::Klass>);
|
||||
%rename(tMethodXYZ4) XYZ<Space::Enu>::templateXYZ(XYZ<Space::Enu>);
|
||||
|
||||
%rename(opT1) XYZ::operator T();
|
||||
%rename(opT2) XYZ<int>::operator int();
|
||||
%rename(opT3) XYZ<Space::Klass>::operator Space::Klass();
|
||||
%rename(opT4) XYZ<Space::Enu>::operator Space::Enu();
|
||||
|
||||
%rename(opNotXYZ1) XYZ::operator NotXYZ<T>() const;
|
||||
%rename(opNotXYZ2) XYZ<int>::operator NotXYZ<int>() const;
|
||||
%rename(opNotXYZ3) XYZ<Space::Klass>::operator NotXYZ<Space::Klass>() const;
|
||||
%rename(opNotXYZ4) XYZ<Space::Enu>::operator NotXYZ<Space::Enu>() const;
|
||||
|
||||
%rename(opXYZ1) XYZ::operator XYZ<T>() const;
|
||||
%rename(opXYZ2) XYZ<int>::operator XYZ<int>() const;
|
||||
%rename(opXYZ3) XYZ<Space::Klass>::operator XYZ<Space::Klass>() const;
|
||||
%rename(opXYZ4) XYZ<Space::Enu>::operator XYZ<Space::Enu>() const;
|
||||
|
||||
|
||||
%rename(methodABC) ABC::method(ABC a) const;
|
||||
%rename(opABC) ABC::operator ABC() const;
|
||||
%rename(methodKlass) ABC::method(Klass k) const;
|
||||
%rename(opKlass) ABC::operator Klass() const;
|
||||
}
|
||||
|
||||
%{
|
||||
#include "rename.h"
|
||||
%}
|
||||
%include "rename.h"
|
||||
|
||||
%template(XYZInt) Space::XYZ<int>;
|
||||
%template(XYZDouble) Space::XYZ<double>;
|
||||
%template(XYZKlass) Space::XYZ<Space::Klass>;
|
||||
%template(XYZEnu) Space::XYZ<Space::Enu>;
|
||||
|
||||
%template(NotXYZInt) Space::NotXYZ<int>;
|
||||
%template(NotXYZDouble) Space::NotXYZ<double>;
|
||||
%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
|
||||
%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
// Test %rename directive within %extend
|
||||
%module rename3
|
||||
|
||||
namespace Space {
|
||||
// Note no namespace nor class qualification
|
||||
%extend XYZ {
|
||||
%rename(opIntPtrA) operator NotXYZ<int>*() const;
|
||||
%rename(opIntPtrB) operator XYZ<int>*() const;
|
||||
}
|
||||
|
||||
%extend XYZ {
|
||||
// Note use of type T
|
||||
%rename(opAnother1) operator Another() const;
|
||||
%rename(tMethod1) templateT(T i);
|
||||
%rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ<T>);
|
||||
%rename(tMethodXYZ1) templateXYZ(XYZ<T>);
|
||||
%rename(opT1) operator T();
|
||||
%rename(opNotXYZ1) operator NotXYZ<T>() const;
|
||||
%rename(opXYZ1) operator XYZ<T>() const;
|
||||
}
|
||||
|
||||
%extend XYZ<int> {
|
||||
%rename(opAnother2) operator Another() const;
|
||||
%rename(tMethod2) templateT(int i);
|
||||
%rename(tMethodNotXYZ2) templateNotXYZ(NotXYZ<int>);
|
||||
%rename(tMethodXYZ2) templateXYZ(XYZ<int>);
|
||||
%rename(opT2) operator int();
|
||||
%rename(opNotXYZ2) operator NotXYZ<int>() const;
|
||||
%rename(opXYZ2) operator XYZ<int>() const;
|
||||
}
|
||||
|
||||
%extend XYZ<Space::Klass> {
|
||||
%rename(opAnother3) operator Another() const;
|
||||
%rename(tMethod3) templateT(Space::Klass i);
|
||||
%rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ<Space::Klass>);
|
||||
%rename(tMethodXYZ3) templateXYZ(XYZ<Space::Klass>);
|
||||
%rename(opT3) operator Space::Klass();
|
||||
%rename(opNotXYZ3) operator NotXYZ<Space::Klass>() const;
|
||||
%rename(opXYZ3) operator XYZ<Space::Klass>() const;
|
||||
}
|
||||
|
||||
%extend XYZ<Space::Enu> {
|
||||
%rename(opAnother4 )operator Another() const;
|
||||
%rename(tMethod4) templateT(Space::Enu i);
|
||||
%rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ<Space::Enu>);
|
||||
%rename(tMethodXYZ4) templateXYZ(XYZ<Space::Enu>);
|
||||
%rename(opT4) operator Space::Enu();
|
||||
%rename(opNotXYZ4) operator NotXYZ<Space::Enu>() const;
|
||||
%rename(opXYZ4) operator XYZ<Space::Enu>() const;
|
||||
}
|
||||
|
||||
|
||||
%extend ABC {
|
||||
%rename(methodABC) method(ABC a) const;
|
||||
%rename(opABC) operator ABC() const;
|
||||
%rename(methodKlass) method(Klass k) const;
|
||||
%rename(opKlass) operator Klass() const;
|
||||
}
|
||||
}
|
||||
|
||||
%{
|
||||
#include "rename.h"
|
||||
%}
|
||||
%include "rename.h"
|
||||
|
||||
%template(XYZInt) Space::XYZ<int>;
|
||||
%template(XYZDouble) Space::XYZ<double>;
|
||||
%template(XYZKlass) Space::XYZ<Space::Klass>;
|
||||
%template(XYZEnu) Space::XYZ<Space::Enu>;
|
||||
|
||||
%template(NotXYZInt) Space::NotXYZ<int>;
|
||||
%template(NotXYZDouble) Space::NotXYZ<double>;
|
||||
%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
|
||||
%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
|
||||
|
|
@ -0,0 +1,108 @@
|
|||
// Test %rename directive with the 'using' keyword and within the class definition
|
||||
%module rename4
|
||||
|
||||
%{
|
||||
#include "rename.h"
|
||||
%}
|
||||
|
||||
namespace Space {
|
||||
struct Klass {
|
||||
Klass(int i) {}
|
||||
Klass() {}
|
||||
};
|
||||
}
|
||||
|
||||
namespace AnotherSpace {
|
||||
class Another {};
|
||||
}
|
||||
|
||||
namespace Space {
|
||||
%rename(opAnother1) XYZ::operator Another() const;
|
||||
%rename(opAnother2) XYZ<int>::operator Another() const;
|
||||
%rename(opAnother3) XYZ<Space::Klass>::operator Another() const;
|
||||
%rename(opAnother4) XYZ<Space::Enu>::operator Another() const;
|
||||
}
|
||||
|
||||
// Test %rename - no namespace, but specific templated type in the parameter, is used over the generic type T
|
||||
%rename(tMethod2) templateT(int i);
|
||||
%rename(tMethodNotXYZ2) templateNotXYZ(NotXYZ<int>);
|
||||
%rename(tMethodXYZ2) templateXYZ(XYZ<int>);
|
||||
%rename(opT2) operator int();
|
||||
%rename(opNotXYZ2) operator NotXYZ<int>() const;
|
||||
%rename(opXYZ2) operator XYZ<int>() const;
|
||||
|
||||
%rename(tMethod3) templateT(Space::Klass i);
|
||||
%rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ<Space::Klass>);
|
||||
%rename(tMethodXYZ3) templateXYZ(XYZ<Space::Klass>);
|
||||
%rename(opT3) operator Space::Klass();
|
||||
%rename(opNotXYZ3) operator NotXYZ<Space::Klass>() const;
|
||||
%rename(opXYZ3) operator XYZ<Space::Klass>() const;
|
||||
|
||||
%rename(tMethod4) templateT(Space::Enu i);
|
||||
%rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ<Space::Enu>);
|
||||
%rename(tMethodXYZ4) templateXYZ(XYZ<Space::Enu>);
|
||||
%rename(opT4) operator Space::Enu();
|
||||
%rename(opNotXYZ4) operator NotXYZ<Space::Enu>() const;
|
||||
%rename(opXYZ4) operator XYZ<Space::Enu>() const;
|
||||
|
||||
namespace Space {
|
||||
using namespace AnotherSpace;
|
||||
enum Enu { En1, En2, En3 };
|
||||
template<typename T> struct NotXYZ {};
|
||||
template<typename T> class XYZ {
|
||||
|
||||
// Test %rename within the class
|
||||
%rename(opIntPtrA) operator NotXYZ<int>*() const;
|
||||
%rename(opIntPtrB) operator XYZ<int>*() const;
|
||||
|
||||
%rename(tMethod1) templateT(T i);
|
||||
%rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ<T>);
|
||||
%rename(tMethodXYZ1) templateXYZ(XYZ<T>);
|
||||
%rename(opT1) operator T();
|
||||
%rename(opNotXYZ1) operator NotXYZ<T>() const;
|
||||
%rename(opXYZ1) operator XYZ<T>() const;
|
||||
|
||||
NotXYZ<int> *m_int;
|
||||
T m_t;
|
||||
NotXYZ<T> m_notxyz;
|
||||
public:
|
||||
operator NotXYZ<int>*() const { return m_int; }
|
||||
operator XYZ<int>*() const { return 0; }
|
||||
operator Another() const { Another an; return an; }
|
||||
void templateT(T i) {}
|
||||
void templateNotXYZ(NotXYZ<T> i) {}
|
||||
void templateXYZ(XYZ<T> i) {}
|
||||
operator T() { return m_t; }
|
||||
operator NotXYZ<T>() const { return m_notxyz; }
|
||||
operator XYZ<T>() const { XYZ<T> xyz; return xyz; }
|
||||
};
|
||||
}
|
||||
|
||||
namespace Space {
|
||||
// non-templated class using itself in method and operator
|
||||
class ABC {
|
||||
public:
|
||||
|
||||
%rename(methodABC) method(ABC a) const;
|
||||
%rename(opABC) operator ABC() const;
|
||||
%rename(methodKlass) method(Klass k) const;
|
||||
%rename(opKlass) operator Klass() const;
|
||||
|
||||
void method(ABC a) const {}
|
||||
void method(Klass k) const {}
|
||||
operator ABC() const { ABC a; return a; }
|
||||
operator Klass() const { Klass k; return k; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
%template(XYZInt) Space::XYZ<int>;
|
||||
%template(XYZDouble) Space::XYZ<double>;
|
||||
%template(XYZKlass) Space::XYZ<Space::Klass>;
|
||||
%template(XYZEnu) Space::XYZ<Space::Enu>;
|
||||
|
||||
%template(NotXYZInt) Space::NotXYZ<int>;
|
||||
%template(NotXYZDouble) Space::NotXYZ<double>;
|
||||
%template(NotXYZKlass) Space::NotXYZ<Space::Klass>;
|
||||
%template(NotXYZEnu) Space::NotXYZ<Space::Enu>;
|
||||
|
Loading…
Reference in New Issue