mirror of https://github.com/swig/swig
Add more missing primary template definition testing
This commit is contained in:
parent
1e6ba9f05b
commit
3556c41b98
|
@ -0,0 +1,28 @@
|
|||
import template_specialization.*;
|
||||
|
||||
public class template_specialization_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("template_specialization");
|
||||
} 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[]) {
|
||||
UnaryFunction_double ufd = new UnaryFunction_double();
|
||||
ufd.negate();
|
||||
|
||||
UnaryFunction_bool ufb = new UnaryFunction_bool();
|
||||
ufb.foo(ufb);
|
||||
ufb.not1();
|
||||
|
||||
OnlySpecialized_int osi = new OnlySpecialized_int();
|
||||
osi.bar(osi);
|
||||
|
||||
// Type wrapper class not proxy class is returned as primary template definition is not seen by SWIG
|
||||
SWIGTYPE_p_vfncs__OnlySpecializedT_double_t osd = template_specialization.factory(null);
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
};
|
||||
|
||||
// Also test specialization without the primary template.
|
||||
// Also test specialization with only primary template forward declaration
|
||||
template <typename T> struct OnlySpecialized;
|
||||
|
||||
template <> struct OnlySpecialized<int>
|
||||
|
@ -41,5 +41,28 @@ namespace vfncs {
|
|||
%template(UnaryFunction_double) UnaryFunction<double>;
|
||||
%template(UnaryFunction_bool) UnaryFunction<bool>;
|
||||
|
||||
// Specialized instantiation with only primary template forward declaration
|
||||
%template(OnlySpecialized_int) OnlySpecialized<int>;
|
||||
|
||||
// Primary instantiation with only primary template forward declaration
|
||||
%template(OnlySpecialized_double) OnlySpecialized<double>; // silently ignored - probably should warn
|
||||
}
|
||||
|
||||
%{
|
||||
namespace vfncs {
|
||||
template <typename T> struct OnlySpecialized {
|
||||
int primary() const { return 0; }
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
namespace vfncs {
|
||||
// Use primary template with only primary template forward declaration (for SWIG, but full declaration seen by compiler)
|
||||
OnlySpecialized<double> factory(OnlySpecialized<double>* os) {
|
||||
OnlySpecialized<double> ret = os ? *os : OnlySpecialized<double>();
|
||||
ret.primary();
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
|
Loading…
Reference in New Issue