parent
678937db24
commit
117f6d0026
5 changed files with 72 additions and 2 deletions
|
|
@ -543,6 +543,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_template_explicit \
|
||||
cpp11_template_typedefs \
|
||||
cpp11_type_traits \
|
||||
cpp11_type_aliasing \
|
||||
cpp11_uniform_initialization \
|
||||
cpp11_unrestricted_unions \
|
||||
cpp11_userdefined_literals \
|
||||
|
|
|
|||
46
Examples/test-suite/cpp11_type_aliasing.i
Normal file
46
Examples/test-suite/cpp11_type_aliasing.i
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
%module cpp11_type_aliasing
|
||||
|
||||
// Type aliasing seg fault : Github issue #424
|
||||
|
||||
%warnfilter(SWIGWARN_CPP11_ALIAS_DECLARATION) Target;
|
||||
|
||||
%inline %{
|
||||
|
||||
namespace Halide {
|
||||
|
||||
struct Target {
|
||||
int bits;
|
||||
Target(int bits=32) : bits(bits) {}
|
||||
};
|
||||
|
||||
class NamesInterface {
|
||||
public:
|
||||
using Target = Halide::Target;
|
||||
};
|
||||
|
||||
Target get_host_target() {
|
||||
return Target();
|
||||
}
|
||||
|
||||
namespace Internal {
|
||||
|
||||
template <typename T> class GeneratorParam {
|
||||
T value;
|
||||
public:
|
||||
GeneratorParam(const char *name, const T &v) : value(v) {}
|
||||
|
||||
T getValue() {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
class GeneratorBase : public NamesInterface {
|
||||
public:
|
||||
GeneratorParam<Target> target{ "target", Halide::get_host_target() };
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
||||
%template(Halide_Target) Halide::Internal::GeneratorParam<Halide::Target>;
|
||||
20
Examples/test-suite/java/cpp11_type_aliasing_runme.java
Normal file
20
Examples/test-suite/java/cpp11_type_aliasing_runme.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import cpp11_type_aliasing.*;
|
||||
|
||||
public class cpp11_type_aliasing_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_type_aliasing");
|
||||
} 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[]) {
|
||||
Halide_Target ht = new GeneratorBase().getTarget();
|
||||
Target x = ht.getValue();
|
||||
if (x.getBits() != 32)
|
||||
throw new RuntimeException("Incorrect bits");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue