// 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::operator Another() const; %rename(opAnother3) XYZ::operator Another() const; %rename(opAnother4) XYZ::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); %rename(tMethodXYZ2) templateXYZ(XYZ); %rename(opT2) operator int(); %rename(opNotXYZ2) operator NotXYZ() const; %rename(tMethod3) templateT(Space::Klass i); %rename(tMethodNotXYZ3) templateNotXYZ(NotXYZ); %rename(tMethodXYZ3) templateXYZ(XYZ); %rename(opT3) operator Space::Klass(); %rename(opNotXYZ3) operator NotXYZ() const; %rename(tMethod4) templateT(Space::Enu i); %rename(tMethodNotXYZ4) templateNotXYZ(NotXYZ); %rename(tMethodXYZ4) templateXYZ(XYZ); %rename(opT4) operator Space::Enu(); %rename(opNotXYZ4) operator NotXYZ() const; namespace Space { using namespace AnotherSpace; enum Enu { En1, En2, En3 }; template struct NotXYZ {}; template class XYZ { // Test %rename within the class %rename(opIntPtrA) operator NotXYZ*() const; %rename(opIntPtrB) operator XYZ*() const; %rename(tMethod1) templateT(T i); %rename(tMethodNotXYZ1) templateNotXYZ(NotXYZ); %rename(tMethodXYZ1) templateXYZ(XYZ); %rename(opT1) operator T(); %rename(opNotXYZ1) operator NotXYZ() const; NotXYZ *m_int; T m_t; NotXYZ m_notxyz; public: operator NotXYZ*() const { return m_int; } operator XYZ*() const { return 0; } operator Another() const { Another an; return an; } void templateT(T i) {} void templateNotXYZ(NotXYZ i) {} void templateXYZ(XYZ i) {} operator T() { return m_t; } operator NotXYZ() const { return m_notxyz; } }; } %exception Space::ABC::operator ABC %{ #if defined(__clang__) // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used result = *arg1; #else $action #endif %} 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 { return new ABC(); } operator Klass() const { Klass k; return k; } }; } %template(XYZInt) Space::XYZ; %template(XYZDouble) Space::XYZ; %template(XYZKlass) Space::XYZ; %template(XYZEnu) Space::XYZ; %template(NotXYZInt) Space::NotXYZ; %template(NotXYZDouble) Space::NotXYZ; %template(NotXYZKlass) Space::NotXYZ; %template(NotXYZEnu) Space::NotXYZ;