Fix typemap matching to expand template parameters when the name contains template parameters.
In the %typemap below the type is T and the name is X<T>::make
which now expands correctly to X< int >::make
template<typename T> struct X {
%typemap(out) T X<T>::make "..."
T make();
};
%template(Xint) X<int>;
This commit is contained in:
parent
024eaeaacf
commit
b9350614b5
5 changed files with 66 additions and 0 deletions
|
|
@ -7,6 +7,18 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
||||||
Version 4.0.0 (in progress)
|
Version 4.0.0 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2019-02-17: wsfulton
|
||||||
|
Fix typemap matching to expand template parameters when the name contains
|
||||||
|
template parameters. In the %typemap below the type is T and the name is X<T>::make
|
||||||
|
and the name now expands correctly to X< int >::make
|
||||||
|
|
||||||
|
template<typename T> struct X {
|
||||||
|
%typemap(out) T X<T>::make "..."
|
||||||
|
T make();
|
||||||
|
};
|
||||||
|
|
||||||
|
%template(Xint) X<int>;
|
||||||
|
|
||||||
2019-02-16: wsfulton
|
2019-02-16: wsfulton
|
||||||
Fix parser error containing multiple #define statements inside an enum.
|
Fix parser error containing multiple #define statements inside an enum.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -522,6 +522,7 @@ CPP_TEST_CASES += \
|
||||||
typemap_numinputs \
|
typemap_numinputs \
|
||||||
typemap_template \
|
typemap_template \
|
||||||
typemap_template_parm_typedef \
|
typemap_template_parm_typedef \
|
||||||
|
typemap_template_parms \
|
||||||
typemap_template_typedef \
|
typemap_template_typedef \
|
||||||
typemap_out_optimal \
|
typemap_out_optimal \
|
||||||
typemap_qualifier_strip \
|
typemap_qualifier_strip \
|
||||||
|
|
|
||||||
23
Examples/test-suite/java/typemap_template_parms_runme.java
Normal file
23
Examples/test-suite/java/typemap_template_parms_runme.java
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import typemap_template_parms.*;
|
||||||
|
|
||||||
|
public class typemap_template_parms_runme {
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
System.loadLibrary("typemap_template_parms");
|
||||||
|
} 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[]) {
|
||||||
|
Xint xint = new Xint();
|
||||||
|
int i = 0;
|
||||||
|
i = xint.bake();
|
||||||
|
i = xint.make();
|
||||||
|
i = xint.lake();
|
||||||
|
i = xint.rake();
|
||||||
|
i = xint.take();
|
||||||
|
}
|
||||||
|
}
|
||||||
28
Examples/test-suite/typemap_template_parms.i
Normal file
28
Examples/test-suite/typemap_template_parms.i
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
%module typemap_template_parms
|
||||||
|
|
||||||
|
%typemap(ret) int "_this_will_not_compile_int_$symname"
|
||||||
|
|
||||||
|
%extend X {
|
||||||
|
%typemap(ret) T lake "/* ret lake X<T> */"
|
||||||
|
%typemap(ret) T X<T>::rake "/* ret rake X<T> */"
|
||||||
|
|
||||||
|
// Overrides below: %typemap(ret) T take
|
||||||
|
%typemap(ret) T X<T>::take "/* ret take X<T> */"
|
||||||
|
}
|
||||||
|
|
||||||
|
%inline %{
|
||||||
|
template<typename T> struct X {
|
||||||
|
#if defined(SWIG)
|
||||||
|
%typemap(ret) T bake "/* ret bake X<T> */"
|
||||||
|
%typemap(ret) T X<T>::make "/* ret make X<T> */"
|
||||||
|
%typemap(ret) T take "_rake_T_this_will_not_compile_"
|
||||||
|
#endif
|
||||||
|
T bake() { return T(); }
|
||||||
|
T make() { return T(); }
|
||||||
|
T lake() { return T(); }
|
||||||
|
T rake() { return T(); }
|
||||||
|
T take() { return T(); }
|
||||||
|
};
|
||||||
|
%}
|
||||||
|
|
||||||
|
%template(Xint) X<int>;
|
||||||
|
|
@ -30,8 +30,10 @@ static void add_parms(ParmList *p, List *patchlist, List *typelist) {
|
||||||
while (p) {
|
while (p) {
|
||||||
SwigType *ty = Getattr(p, "type");
|
SwigType *ty = Getattr(p, "type");
|
||||||
SwigType *val = Getattr(p, "value");
|
SwigType *val = Getattr(p, "value");
|
||||||
|
SwigType *name = Getattr(p, "name");
|
||||||
Append(typelist, ty);
|
Append(typelist, ty);
|
||||||
Append(typelist, val);
|
Append(typelist, val);
|
||||||
|
Append(typelist, name);
|
||||||
Append(patchlist, val);
|
Append(patchlist, val);
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue