Merge branch 'alexey-pelykh-cpp11_strongly_typed_enums__direct_inject_in_java'
* alexey-pelykh-cpp11_strongly_typed_enums__direct_inject_in_java: Enhance cpp11_strongly_typed_enumerations testcase and turn it on Simplify/improve strongly typed enum implementation for Java Rewrite some Java director nested class support code for strongly typed enums Expand director_nested_class test to test more than one level of nesting Add director_nested_class testcase Removed useless code (it does not affect output, at least on our testcases) Java/Fix: swig_connect_director used not-fully-qualified classname (proper) Java/Fix: swig_connect_director used not-fully-qualified classname Java: fix generation of ProxyName when JNI descriptor is requested - for inner classes '$' should be used as separator instead of '/' Java: fix invalid director 'self' variable type name (wasn't fully qualified) Clean-up test suite and fix issue with nspace, as well as keep the fix for Class::Struct::EnumClass being JNI-referenced as Struct_EnumClass C++11 strongly-typed enums fix for Java only (proper) Revert "C++11 strongly-typed enums fix for Java only" Additional test cases for C++11 strongly-typed enums C++11 strongly-typed enums fix for Java only
This commit is contained in:
commit
296d45aec5
7 changed files with 245 additions and 34 deletions
|
|
@ -527,6 +527,7 @@ CPP11_TEST_CASES = \
|
|||
cpp11_rvalue_reference3 \
|
||||
cpp11_sizeof_object \
|
||||
cpp11_static_assert \
|
||||
cpp11_strongly_typed_enumerations \
|
||||
cpp11_thread_local \
|
||||
cpp11_template_double_brackets \
|
||||
cpp11_template_explicit \
|
||||
|
|
@ -539,7 +540,6 @@ CPP11_TEST_CASES = \
|
|||
# Broken C++11 test cases.
|
||||
CPP11_TEST_BROKEN = \
|
||||
# cpp11_hash_tables \ # not fully implemented yet
|
||||
# cpp11_strongly_typed_enumerations \ # SWIG not quite getting this right yet in all langs
|
||||
# cpp11_variadic_templates \ # Broken for some languages (such as Java)
|
||||
# cpp11_reference_wrapper \ # No typemaps
|
||||
|
||||
|
|
|
|||
|
|
@ -2,10 +2,6 @@
|
|||
strongly typed enums. Enums with the same type are comparable. Enum classes
|
||||
require support for nested classes. */
|
||||
%module cpp11_strongly_typed_enumerations
|
||||
%warnfilter(302) Val1;
|
||||
%warnfilter(302) Val2;
|
||||
%warnfilter(302) Val3;
|
||||
%warnfilter(302) Val4;
|
||||
|
||||
/* Forward declarations (illegally accepted by SWIG - oh well!) */
|
||||
enum Enum1 : short;
|
||||
|
|
@ -17,14 +13,14 @@ enum : unsigned short;
|
|||
enum class Enum1 {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3 = 100,
|
||||
Val4 /* = 101 */
|
||||
Val3 = 13,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum class Enum2 : short {
|
||||
Val1,
|
||||
Val2,
|
||||
Val3 = 100,
|
||||
Val3 = 23,
|
||||
Val4
|
||||
};
|
||||
%}
|
||||
|
|
@ -39,24 +35,24 @@ enum class Enum5; // Legal in C++11, because enum class declarati
|
|||
enum class Enum6 : unsigned int; // Legal C++11.
|
||||
|
||||
enum Enum4 : unsigned int {
|
||||
Val1, Val2, Val3 = 100, Val4
|
||||
Val1, Val2, Val3 = 43, Val4
|
||||
};
|
||||
|
||||
enum class Enum5 {
|
||||
Val1, Val2, Val3 = 100, Val4
|
||||
Val1, Val2, Val3 = 53, Val4
|
||||
};
|
||||
|
||||
enum class Enum6 : unsigned int {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 63, Val4
|
||||
};
|
||||
|
||||
typedef enum class Enum7 : unsigned int {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 73, Val4
|
||||
} Enum7td;
|
||||
|
||||
// enum inherits from non-primitive type
|
||||
enum class Enum8 : size_t {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 83, Val4
|
||||
};
|
||||
|
||||
template <typename T> struct TType {
|
||||
|
|
@ -64,7 +60,7 @@ template <typename T> struct TType {
|
|||
};
|
||||
|
||||
enum class Enum10 : TType<int>::type_name {
|
||||
Val1, Val2, Val3 = 300, Val4
|
||||
Val1, Val2, Val3 = 103, Val4
|
||||
};
|
||||
|
||||
// forward declaration, no definition of enum
|
||||
|
|
@ -73,6 +69,116 @@ struct UseEnum11 {
|
|||
Enum11 myenum11;
|
||||
};
|
||||
|
||||
class Class1
|
||||
{
|
||||
public:
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 1121,
|
||||
Val2 = 1122,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 1131,
|
||||
Val2 = 1132,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 1141,
|
||||
Val2 = 1142,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
struct Struct1
|
||||
{
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 3121,
|
||||
Val2 = 3122,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 3131,
|
||||
Val2 = 3132,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 3141,
|
||||
Val2 = 3142,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
class Class2
|
||||
{
|
||||
public:
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 2121,
|
||||
Val2 = 2122,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 2131,
|
||||
Val2 = 2132,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 2141,
|
||||
Val2 = 2142,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
struct Struct1
|
||||
{
|
||||
enum class Enum12
|
||||
{
|
||||
Val1 = 4121,
|
||||
Val2 = 4122,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum Enum13
|
||||
{
|
||||
Val1 = 4131,
|
||||
Val2 = 4132,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
|
||||
enum class Enum14
|
||||
{
|
||||
Val1 = 4141,
|
||||
Val2 = 4142,
|
||||
Val3,
|
||||
Val4
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
TODO
|
||||
enum class MyClass {AAA, BBB, CCC};
|
||||
|
|
|
|||
25
Examples/test-suite/director_nested_class.i
Normal file
25
Examples/test-suite/director_nested_class.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%module(directors="1") director_nested_class
|
||||
|
||||
|
||||
%feature("director") DirectorOuter::DirectorInner;
|
||||
%feature("director") DirectorOuter::DirectorInner::DirectorInnerInner;
|
||||
|
||||
%inline %{
|
||||
struct DirectorOuter {
|
||||
struct DirectorInner {
|
||||
virtual ~DirectorInner() {}
|
||||
virtual int vmethod(int input) const = 0;
|
||||
struct DirectorInnerInner {
|
||||
DirectorInnerInner(DirectorInner *din = 0) {}
|
||||
virtual ~DirectorInnerInner() {}
|
||||
virtual int innervmethod(int input) const = 0;
|
||||
};
|
||||
};
|
||||
static int callMethod(const DirectorInner &di, int value) {
|
||||
return di.vmethod(value);
|
||||
}
|
||||
static int callInnerInnerMethod(const DirectorInner::DirectorInnerInner &di, int value) {
|
||||
return di.innervmethod(value);
|
||||
}
|
||||
};
|
||||
%}
|
||||
41
Examples/test-suite/java/director_nested_class_runme.java
Normal file
41
Examples/test-suite/java/director_nested_class_runme.java
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
|
||||
import director_nested_class.*;
|
||||
|
||||
public class director_nested_class_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("director_nested_class");
|
||||
} 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[]) {
|
||||
|
||||
director_nested_class_Derived d = new director_nested_class_Derived();
|
||||
|
||||
if (DirectorOuter.callMethod(d, 999) != 9990) {
|
||||
throw new RuntimeException("callMethod(999) failed");
|
||||
}
|
||||
|
||||
director_nested_class_DerivedInnerInner dinner = new director_nested_class_DerivedInnerInner();
|
||||
|
||||
if (DirectorOuter.callInnerInnerMethod(dinner, 999) != 999000) {
|
||||
throw new RuntimeException("callMethod(999) failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class director_nested_class_Derived extends DirectorOuter.DirectorInner {
|
||||
public int vmethod(int input) {
|
||||
return input * 10;
|
||||
}
|
||||
}
|
||||
|
||||
class director_nested_class_DerivedInnerInner extends DirectorOuter.DirectorInner.DirectorInnerInner {
|
||||
public int innervmethod(int input) {
|
||||
return input * 1000;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue