summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2011-03-26 15:28:31 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2011-03-26 15:28:31 +0000
commitb13ec94386c8055e9dcc0fb6338b2e3e1e4048d4 (patch)
treed2a80e3e742305f7e94d5a6601c73aca3955daf4 /Examples
parentae6aef5d8f7831cc68326f5934c861f08eb7767c (diff)
downloadswig-b13ec94386c8055e9dcc0fb6338b2e3e1e4048d4.tar.gz
SF bug #3195112 - fix wrapping of enums that are type char
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12557 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Examples')
-rw-r--r--Examples/test-suite/csharp/enum_thorough_runme.cs22
-rw-r--r--Examples/test-suite/csharp/enum_thorough_simple_runme.cs22
-rw-r--r--Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs22
-rw-r--r--Examples/test-suite/enum_thorough.i53
-rw-r--r--Examples/test-suite/java/enum_thorough_proper_runme.java22
-rw-r--r--Examples/test-suite/java/enum_thorough_runme.java22
-rw-r--r--Examples/test-suite/java/enum_thorough_simple_runme.java22
-rw-r--r--Examples/test-suite/java/enum_thorough_typeunsafe_runme.java22
8 files changed, 206 insertions, 1 deletions
diff --git a/Examples/test-suite/csharp/enum_thorough_runme.cs b/Examples/test-suite/csharp/enum_thorough_runme.cs
index 144736f2b..854c8dbb5 100644
--- a/Examples/test-suite/csharp/enum_thorough_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_runme.cs
@@ -405,6 +405,28 @@ public class runme {
if ((int)enum_thorough.repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
if ((int)enum_thorough.repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
}
+ // different types
+ {
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeint) != 10) throw new Exception("differentTypes 1 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typechar) != 'C') throw new Exception("differentTypes 5 failed");
+ if ((int)enum_thorough.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
+
+ int global_enum = enum_thorough.global_typeint;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
+ global_enum = enum_thorough.global_typeboolfalse;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
+ global_enum = enum_thorough.global_typebooltrue;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
+ global_enum = enum_thorough.global_typebooltwo;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
+ global_enum = enum_thorough.global_typechar;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
+ global_enum = enum_thorough.global_typedefaultint;
+ if ((int)enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
index d5bba1b7d..0c22d8e3f 100644
--- a/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_simple_runme.cs
@@ -405,6 +405,28 @@ public class runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simple.llast) != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simple.end) != 3) throw new Exception("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeint) != 10) throw new Exception("differentTypes 1 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typeboolfalse) != 0) throw new Exception("differentTypes 2 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltrue) != 1) throw new Exception("differentTypes 3 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typebooltwo) != 2) throw new Exception("differentTypes 4 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typechar) != 'C') throw new Exception("differentTypes 5 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simple.typedefaultint) != 'D') throw new Exception("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_simple.global_typeint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
+ global_enum = enum_thorough_simple.global_typeboolfalse;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
+ global_enum = enum_thorough_simple.global_typebooltrue;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
+ global_enum = enum_thorough_simple.global_typebooltwo;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
+ global_enum = enum_thorough_simple.global_typechar;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
+ global_enum = enum_thorough_simple.global_typedefaultint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
index 3606d1137..86179dcf4 100644
--- a/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
+++ b/Examples/test-suite/csharp/enum_thorough_typesafe_runme.cs
@@ -405,6 +405,28 @@ public class runme {
if (enum_thorough_typesafe.repeatTest(repeat.llast).swigValue != 3) throw new Exception("repeatTest 5 failed");
if (enum_thorough_typesafe.repeatTest(repeat.end).swigValue != 3) throw new Exception("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeint).swigValue != 10) throw new Exception("differentTypes 1 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltrue).swigValue != 1) throw new Exception("differentTypes 2 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typebooltwo).swigValue != 2) throw new Exception("differentTypes 3 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typeboolfalse).swigValue != 0) throw new Exception("differentTypes 4 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typechar).swigValue != (int)'C') throw new Exception("differentTypes 5 failed");
+ if (enum_thorough_typesafe.differentTypesTest(DifferentTypes.typedefaultint).swigValue != (int)'D') throw new Exception("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_typesafe.global_typeint;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 10) throw new Exception("global differentTypes 1 failed");
+ global_enum = enum_thorough_typesafe.global_typeboolfalse;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 0) throw new Exception("global differentTypes 2 failed");
+ global_enum = enum_thorough_typesafe.global_typebooltrue;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 1) throw new Exception("global differentTypes 3 failed");
+ global_enum = enum_thorough_typesafe.global_typebooltwo;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 2) throw new Exception("global differentTypes 4 failed");
+ global_enum = enum_thorough_typesafe.global_typechar;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'C') throw new Exception("global differentTypes 5 failed");
+ global_enum = enum_thorough_typesafe.global_typedefaultint;
+ if (enum_thorough_typesafe.globalDifferentTypesTest(global_enum) != 'D') throw new Exception("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/enum_thorough.i b/Examples/test-suite/enum_thorough.i
index cb2288574..ec31c2787 100644
--- a/Examples/test-suite/enum_thorough.i
+++ b/Examples/test-suite/enum_thorough.i
@@ -537,7 +537,6 @@ IgnoreTest::IgnoreE ignoreETest(IgnoreTest::IgnoreE n) { return n; }
%}
%inline %{
-
namespace RepeatSpace {
typedef enum
{
@@ -550,6 +549,58 @@ typedef enum
} repeat;
repeat repeatTest(repeat e) { return e; }
}
+%}
+
+%inline %{
+namespace DifferentSpace {
+enum DifferentTypes {
+ typeint = 10,
+ typeboolfalse = false,
+ typebooltrue = true,
+ typebooltwo,
+ typechar = 'C',
+ typedefaultint
+};
+DifferentTypes differentTypesTest(DifferentTypes n) { return n; }
+
+enum {
+ global_typeint = 10,
+ global_typeboolfalse = false,
+ global_typebooltrue = true,
+ global_typebooltwo,
+ global_typechar = 'C',
+ global_typedefaultint
+};
+int globalDifferentTypesTest(int n) { return n; }
+}
%}
+#if defined(SWIGJAVA)
+%javaconst(0);
+#elif defined(SWIGCSHARP)
+%csconst(0);
+#endif
+
+%inline %{
+namespace DifferentSpace {
+enum DifferentTypesNoConst {
+ typeint_noconst = 10,
+ typeboolfalse_noconst = false,
+ typebooltrue_noconst = true,
+ typebooltwo_noconst,
+ typechar_noconst = 'C',
+ typedefaultint_noconst
+};
+
+enum {
+ global_typeint_noconst = 10,
+ global_typeboolfalse_noconst = false,
+ global_typebooltrue_noconst = true,
+ global_typebooltwo_noconst,
+ global_typechar_noconst = 'C',
+ global_typedefaultint_noconst
+};
+}
+
+%}
diff --git a/Examples/test-suite/java/enum_thorough_proper_runme.java b/Examples/test-suite/java/enum_thorough_proper_runme.java
index 66968060d..391dfff04 100644
--- a/Examples/test-suite/java/enum_thorough_proper_runme.java
+++ b/Examples/test-suite/java/enum_thorough_proper_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_proper_runme {
if (enum_thorough_proper.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_proper.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough_proper.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_proper.global_typeint;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough_proper.global_typeboolfalse;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough_proper.global_typebooltrue;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough_proper.global_typebooltwo;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough_proper.global_typechar;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough_proper.global_typedefaultint;
+ if (enum_thorough_proper.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/enum_thorough_runme.java b/Examples/test-suite/java/enum_thorough_runme.java
index 79c902ccf..2f4d3c2ca 100644
--- a/Examples/test-suite/java/enum_thorough_runme.java
+++ b/Examples/test-suite/java/enum_thorough_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_runme {
if (enum_thorough.repeatTest(repeat.llast).swigValue() != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough.repeatTest(repeat.end).swigValue() != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough.differentTypesTest(DifferentTypes.typeint).swigValue() != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typeboolfalse).swigValue() != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typebooltrue).swigValue() != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typebooltwo).swigValue() != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typechar).swigValue() != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough.differentTypesTest(DifferentTypes.typedefaultint).swigValue() != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough.global_typeint;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough.global_typeboolfalse;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough.global_typebooltrue;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough.global_typebooltwo;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough.global_typechar;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough.global_typedefaultint;
+ if (enum_thorough.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/enum_thorough_simple_runme.java b/Examples/test-suite/java/enum_thorough_simple_runme.java
index e54acda70..1e94d2988 100644
--- a/Examples/test-suite/java/enum_thorough_simple_runme.java
+++ b/Examples/test-suite/java/enum_thorough_simple_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_simple_runme {
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_simple.repeatTest(enum_thorough_simpleConstants.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough_simple.differentTypesTest(enum_thorough_simpleConstants.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_simple.global_typeint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough_simple.global_typeboolfalse;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough_simple.global_typebooltrue;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough_simple.global_typebooltwo;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough_simple.global_typechar;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough_simple.global_typedefaultint;
+ if (enum_thorough_simple.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}
diff --git a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
index b00788911..1b0851e53 100644
--- a/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
+++ b/Examples/test-suite/java/enum_thorough_typeunsafe_runme.java
@@ -416,6 +416,28 @@ public class enum_thorough_typeunsafe_runme {
if (enum_thorough_typeunsafe.repeatTest(repeat.llast) != 3) throw new RuntimeException("repeatTest 5 failed");
if (enum_thorough_typeunsafe.repeatTest(repeat.end) != 3) throw new RuntimeException("repeatTest 6 failed");
}
+ // different types
+ {
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeint) != 10) throw new RuntimeException("differentTypes 1 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typeboolfalse) != 0) throw new RuntimeException("differentTypes 2 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltrue) != 1) throw new RuntimeException("differentTypes 3 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typebooltwo) != 2) throw new RuntimeException("differentTypes 4 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typechar) != 'C') throw new RuntimeException("differentTypes 5 failed");
+ if (enum_thorough_typeunsafe.differentTypesTest(DifferentTypes.typedefaultint) != 'D') throw new RuntimeException("differentTypes 6 failed");
+
+ int global_enum = enum_thorough_typeunsafe.global_typeint;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 10) throw new RuntimeException("global differentTypes 1 failed");
+ global_enum = enum_thorough_typeunsafe.global_typeboolfalse;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 0) throw new RuntimeException("global differentTypes 2 failed");
+ global_enum = enum_thorough_typeunsafe.global_typebooltrue;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 1) throw new RuntimeException("global differentTypes 3 failed");
+ global_enum = enum_thorough_typeunsafe.global_typebooltwo;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 2) throw new RuntimeException("global differentTypes 4 failed");
+ global_enum = enum_thorough_typeunsafe.global_typechar;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'C') throw new RuntimeException("global differentTypes 5 failed");
+ global_enum = enum_thorough_typeunsafe.global_typedefaultint;
+ if (enum_thorough_typeunsafe.globalDifferentTypesTest(global_enum) != 'D') throw new RuntimeException("global differentTypes 6 failed");
+ }
}
}