aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-08-08 07:44:21 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-08-08 07:44:21 +0100
commitfb776e19009c7b61c38939e3b95ed56962afb1f6 (patch)
treedd275dac38d5562afe59fcf6371f6bd5e9b11b97
parent87bf8ae7aa25bdd024ca7c5f8f4216926393fa3c (diff)
parent06345e2aa5724879df00edf9fa87fdd034a7c641 (diff)
downloadswig-fb776e19009c7b61c38939e3b95ed56962afb1f6.tar.gz
Merge branch 'cshar-fix-enum-constants'
* cshar-fix-enum-constants: Fix invalid code generated for "%constant enum EnumType ..." and add a test.
-rw-r--r--Examples/test-suite/constant_directive.i6
-rw-r--r--Source/Modules/csharp.cxx2
-rw-r--r--Source/Modules/java.cxx2
3 files changed, 8 insertions, 2 deletions
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
index b102ffea2..3e4775df1 100644
--- a/Examples/test-suite/constant_directive.i
+++ b/Examples/test-suite/constant_directive.i
@@ -14,6 +14,11 @@ struct Type1 {
Type1(int val = 0) : val(val) {}
int val;
};
+enum EnumType
+{
+ EnumValue
+};
+EnumType enumValue = EnumValue;
/* Typedefs for const Type and its pointer */
typedef const Type1 Type1Const;
typedef const Type1* Type1Cptr;
@@ -46,3 +51,4 @@ Type1 getType1Instance() { return Type1(111); }
%constant Type1Cfptr TYPE1CFPTR1DEF_CONSTANT1 = getType1Instance;
/* Regular constant */
%constant int TYPE_INT = 0;
+%constant enum EnumType newValue = enumValue;
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 76ec6a4fb..17100b330 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -1533,7 +1533,7 @@ public:
if (classname_substituted_flag) {
if (SwigType_isenum(t)) {
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
- Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
+ Printf(constants_code, "(%s)%s.%s();\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
} else {
// This handles function pointers using the %constant directive
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 259f23f8e..fcc83819d 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -1633,7 +1633,7 @@ public:
if (classname_substituted_flag) {
if (SwigType_isenum(t)) {
// This handles wrapping of inline initialised const enum static member variables (not when wrapping enum items - ignored later on)
- Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name, Swig_name_get(getNSpace(), symname));
+ Printf(constants_code, "%s.swigToEnum(%s.%s());\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));
} else {
// This handles function pointers using the %constant directive
Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, full_imclass_name ? full_imclass_name : imclass_name, Swig_name_get(getNSpace(), symname));