mirror of https://github.com/swig/swig
Fix %rename override of wildcard %rename for templates
%rename(GlobalIntOperator) *::operator bool; // wildcard %rename %rename(XIntOperator) X::operator bool; // fix now overrides first %rename above OR %rename(XIntOperator) X<int>::operator bool; // fix now overrides first %rename above template<typename T> struct X { operator bool(); ... }; %template(Xint) X<int>;
This commit is contained in:
parent
5d50ebc769
commit
7268f58c4c
|
@ -5,6 +5,21 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 3.0.11 (in progress)
|
Version 3.0.11 (in progress)
|
||||||
============================
|
============================
|
||||||
|
|
||||||
|
2016-11-28: wsfulton
|
||||||
|
Fix %rename override of wildcard %rename for templates. For example:
|
||||||
|
|
||||||
|
%rename(GlobalIntOperator) *::operator bool; // wildcard %rename
|
||||||
|
|
||||||
|
%rename(XIntOperator) X::operator bool; // fix now overrides first %rename above
|
||||||
|
OR
|
||||||
|
%rename(XIntOperator) X<int>::operator bool; // fix now overrides first %rename above
|
||||||
|
|
||||||
|
template<typename T> struct X {
|
||||||
|
operator bool();
|
||||||
|
...
|
||||||
|
};
|
||||||
|
%template(Xint) X<int>;
|
||||||
|
|
||||||
2016-11-26: m7thon
|
2016-11-26: m7thon
|
||||||
[Python] Issue #709 - improved wrapping of division operators
|
[Python] Issue #709 - improved wrapping of division operators
|
||||||
'from __future__ import division' now works in Python 2 whether or not the
|
'from __future__ import division' now works in Python 2 whether or not the
|
||||||
|
|
|
@ -353,6 +353,7 @@ CPP_TEST_CASES += \
|
||||||
rename_pcre_encoder \
|
rename_pcre_encoder \
|
||||||
rename_pcre_enum \
|
rename_pcre_enum \
|
||||||
rename_predicates \
|
rename_predicates \
|
||||||
|
rename_wildcard \
|
||||||
restrict_cplusplus \
|
restrict_cplusplus \
|
||||||
return_const_value \
|
return_const_value \
|
||||||
return_value_scope \
|
return_value_scope \
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
|
||||||
|
import rename_wildcard.*;
|
||||||
|
|
||||||
|
public class rename_wildcard_runme {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("rename_wildcard");
|
||||||
|
} 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[]) {
|
||||||
|
// Wildcard check
|
||||||
|
{
|
||||||
|
new GlobalWildStruct().mm1();
|
||||||
|
new GlobalWildTemplateStructInt().mm1();
|
||||||
|
new SpaceWildStruct().mm1();
|
||||||
|
new SpaceWildTemplateStructInt().mm1();
|
||||||
|
}
|
||||||
|
// No declaration
|
||||||
|
{
|
||||||
|
new GlobalWildStruct().mm2a();
|
||||||
|
new GlobalWildTemplateStructInt().mm2b();
|
||||||
|
new SpaceWildStruct().mm2c();
|
||||||
|
new SpaceWildTemplateStructInt().mm2d();
|
||||||
|
|
||||||
|
new GlobalWildTemplateStructInt().tt2b();
|
||||||
|
new SpaceWildTemplateStructInt().tt2d();
|
||||||
|
}
|
||||||
|
// With declaration
|
||||||
|
{
|
||||||
|
new GlobalWildStruct().mm3a();
|
||||||
|
new GlobalWildTemplateStructInt().mm3b();
|
||||||
|
new SpaceWildStruct().mm3c();
|
||||||
|
new SpaceWildTemplateStructInt().mm3d();
|
||||||
|
|
||||||
|
new GlobalWildTemplateStructInt().tt3b();
|
||||||
|
new SpaceWildTemplateStructInt().tt3d();
|
||||||
|
}
|
||||||
|
// Global override too
|
||||||
|
{
|
||||||
|
new GlobalWildStruct().mm4a();
|
||||||
|
new GlobalWildTemplateStructInt().mm4b();
|
||||||
|
new SpaceWildStruct().mm4c();
|
||||||
|
new SpaceWildTemplateStructInt().mm4d();
|
||||||
|
|
||||||
|
new GlobalWildTemplateStructInt().tt4b();
|
||||||
|
new SpaceWildTemplateStructInt().tt4d();
|
||||||
|
}
|
||||||
|
// %extend renames
|
||||||
|
{
|
||||||
|
new GlobalWildStruct().mm5a();
|
||||||
|
new GlobalWildTemplateStructInt().mm5b();
|
||||||
|
new SpaceWildStruct().mm5c();
|
||||||
|
new SpaceWildTemplateStructInt().mm5d();
|
||||||
|
|
||||||
|
new GlobalWildTemplateStructInt().tt5b();
|
||||||
|
new SpaceWildTemplateStructInt().tt5d();
|
||||||
|
}
|
||||||
|
// operators
|
||||||
|
{
|
||||||
|
new GlobalWildStruct().opinta();
|
||||||
|
new GlobalWildTemplateStructInt().opintb();
|
||||||
|
new SpaceWildStruct().opintc();
|
||||||
|
new SpaceWildTemplateStructInt().opintd();
|
||||||
|
|
||||||
|
new GlobalWildTemplateStructInt().opdoubleb();
|
||||||
|
new SpaceWildTemplateStructInt().opdoubled();
|
||||||
|
}
|
||||||
|
// Wildcard renames expected for these
|
||||||
|
{
|
||||||
|
new NoChangeStruct().mm1();
|
||||||
|
new NoChangeStruct().mm2();
|
||||||
|
new NoChangeStruct().mm3();
|
||||||
|
new NoChangeStruct().mm4();
|
||||||
|
new NoChangeStruct().mm5();
|
||||||
|
new NoChangeStruct().opint();
|
||||||
|
new SpaceNoChangeStruct().mm1();
|
||||||
|
new SpaceNoChangeStruct().mm2();
|
||||||
|
new SpaceNoChangeStruct().mm3();
|
||||||
|
new SpaceNoChangeStruct().mm4();
|
||||||
|
new SpaceNoChangeStruct().mm5();
|
||||||
|
new SpaceNoChangeStruct().opint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
// Test rename overriding a wildcard rename
|
||||||
|
%module rename_wildcard
|
||||||
|
|
||||||
|
%rename(mm1) *::m1;
|
||||||
|
%rename(mm2) *::m2;
|
||||||
|
%rename(tt2) *::t2;
|
||||||
|
%rename(mm3) *::m3();
|
||||||
|
%rename(tt3) *::t3();
|
||||||
|
%rename(m_4) m4;
|
||||||
|
%rename(t_4) t4;
|
||||||
|
%rename(mm4) *::m4;
|
||||||
|
%rename(tt4) *::t4;
|
||||||
|
%rename(mm5) *::m5;
|
||||||
|
%rename(tt5) *::t5;
|
||||||
|
%rename(opint) *::operator int;
|
||||||
|
%rename(opdouble) *::operator double;
|
||||||
|
|
||||||
|
// No declaration
|
||||||
|
%rename(mm2a) GlobalWildStruct::m2;
|
||||||
|
%rename(mm2b) GlobalWildTemplateStruct::m2;
|
||||||
|
%rename(mm2c) Space::SpaceWildStruct::m2;
|
||||||
|
%rename(mm2d) Space::SpaceWildTemplateStruct::m2;
|
||||||
|
%rename(tt2b) GlobalWildTemplateStruct<int>::t2;
|
||||||
|
%rename(tt2d) Space::SpaceWildTemplateStruct<int>::t2;
|
||||||
|
|
||||||
|
// With declaration
|
||||||
|
%rename(mm3a) GlobalWildStruct::m3;
|
||||||
|
%rename(mm3b) GlobalWildTemplateStruct::m3;
|
||||||
|
%rename(mm3c) Space::SpaceWildStruct::m3;
|
||||||
|
%rename(mm3d) Space::SpaceWildTemplateStruct::m3;
|
||||||
|
%rename(tt3b) GlobalWildTemplateStruct<int>::t3;
|
||||||
|
%rename(tt3d) Space::SpaceWildTemplateStruct<int>::t3;
|
||||||
|
|
||||||
|
// Global override too
|
||||||
|
%rename(mm4a) GlobalWildStruct::m4;
|
||||||
|
%rename(mm4b) GlobalWildTemplateStruct::m4;
|
||||||
|
%rename(mm4c) Space::SpaceWildStruct::m4;
|
||||||
|
%rename(mm4d) Space::SpaceWildTemplateStruct::m4;
|
||||||
|
%rename(tt4b) GlobalWildTemplateStruct<int>::t4;
|
||||||
|
%rename(tt4d) Space::SpaceWildTemplateStruct<int>::t4;
|
||||||
|
|
||||||
|
// %extend renames
|
||||||
|
%extend GlobalWildStruct {
|
||||||
|
%rename(mm5a) m5;
|
||||||
|
}
|
||||||
|
%extend GlobalWildTemplateStruct {
|
||||||
|
%rename(mm5b) m5;
|
||||||
|
}
|
||||||
|
%extend GlobalWildTemplateStruct<int> {
|
||||||
|
%rename(tt5b) t5;
|
||||||
|
}
|
||||||
|
namespace Space {
|
||||||
|
%extend SpaceWildStruct {
|
||||||
|
%rename(mm5c) m5;
|
||||||
|
}
|
||||||
|
%extend SpaceWildTemplateStruct {
|
||||||
|
%rename(mm5d) m5;
|
||||||
|
}
|
||||||
|
%extend SpaceWildTemplateStruct<int> {
|
||||||
|
%rename(tt5d) t5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// operators
|
||||||
|
%rename(opinta) GlobalWildStruct::operator int;
|
||||||
|
%rename(opintb) GlobalWildTemplateStruct::operator int;
|
||||||
|
%rename(opintc) Space::SpaceWildStruct::operator int;
|
||||||
|
%rename(opintd) Space::SpaceWildTemplateStruct::operator int;
|
||||||
|
%rename(opdoubleb) GlobalWildTemplateStruct<int>::operator double;
|
||||||
|
%rename(opdoubled) Space::SpaceWildTemplateStruct<int>::operator double;
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
struct GlobalWildStruct {
|
||||||
|
void m1() {}
|
||||||
|
void m2() {}
|
||||||
|
void m3() {}
|
||||||
|
void m4() {}
|
||||||
|
void m5() {}
|
||||||
|
operator int() { return 0; }
|
||||||
|
};
|
||||||
|
template<typename T> struct GlobalWildTemplateStruct {
|
||||||
|
void m1() {}
|
||||||
|
void m2() {}
|
||||||
|
void t2() {}
|
||||||
|
void m3() {}
|
||||||
|
void t3() {}
|
||||||
|
void m4() {}
|
||||||
|
void t4() {}
|
||||||
|
void m5() {}
|
||||||
|
void t5() {}
|
||||||
|
operator int() { return 0; }
|
||||||
|
operator double() { return 0.0; }
|
||||||
|
};
|
||||||
|
namespace Space {
|
||||||
|
struct SpaceWildStruct {
|
||||||
|
void m1() {}
|
||||||
|
void m2() {}
|
||||||
|
void m3() {}
|
||||||
|
void m4() {}
|
||||||
|
void m5() {}
|
||||||
|
operator int() { return 0; }
|
||||||
|
};
|
||||||
|
template<typename T> struct SpaceWildTemplateStruct {
|
||||||
|
void m1() {}
|
||||||
|
void m2() {}
|
||||||
|
void t2() {}
|
||||||
|
void m3() {}
|
||||||
|
void t3() {}
|
||||||
|
void m4() {}
|
||||||
|
void t4() {}
|
||||||
|
void m5() {}
|
||||||
|
void t5() {}
|
||||||
|
operator int() { return 0; }
|
||||||
|
operator double() { return 0.0; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wild card renames expected for these
|
||||||
|
struct NoChangeStruct {
|
||||||
|
void m1() {}
|
||||||
|
void m2() {}
|
||||||
|
void m3() {}
|
||||||
|
void m4() {}
|
||||||
|
void m5() {}
|
||||||
|
operator int() { return 0; }
|
||||||
|
};
|
||||||
|
namespace Space {
|
||||||
|
struct SpaceNoChangeStruct {
|
||||||
|
void m1() {}
|
||||||
|
void m2() {}
|
||||||
|
void m3() {}
|
||||||
|
void m4() {}
|
||||||
|
void m5() {}
|
||||||
|
operator int() { return 0; }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
||||||
|
%template(GlobalWildTemplateStructInt) GlobalWildTemplateStruct<int>;
|
||||||
|
%template(SpaceWildTemplateStructInt) Space::SpaceWildTemplateStruct<int>;
|
|
@ -404,7 +404,17 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
|
||||||
}
|
}
|
||||||
Delete(cls);
|
Delete(cls);
|
||||||
}
|
}
|
||||||
/* A template-based class lookup, check name first */
|
/* Lookup a name within a templated-based class */
|
||||||
|
if (!rn) {
|
||||||
|
String *t_name = SwigType_istemplate_templateprefix(prefix);
|
||||||
|
if (t_name) {
|
||||||
|
Clear(tname);
|
||||||
|
Printf(tname, "%s::%s", t_name, name);
|
||||||
|
rn = name_object_get(namehash, tname, decl, ncdecl);
|
||||||
|
Delete(t_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Lookup a template-based name within a class */
|
||||||
if (!rn) {
|
if (!rn) {
|
||||||
String *t_name = SwigType_istemplate_templateprefix(name);
|
String *t_name = SwigType_istemplate_templateprefix(name);
|
||||||
if (t_name)
|
if (t_name)
|
||||||
|
|
Loading…
Reference in New Issue