From 152a5661a46e87cd9ecc866e5d30cb73be89552c Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 9 Apr 2004 19:37:33 +0000 Subject: [PATCH] Mods for enumvalue being split into enumvalue and enumvalueex. enumvalue contains the enum value for an enum item (if one given/parsed) enumvalueex fills in the missing enum values, eg enumvalueex is set to 0 if no enum value given for the first enum item, otherwise, contains the previous enum value + 1. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5850 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Source/Modules/java.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SWIG/Source/Modules/java.cxx b/SWIG/Source/Modules/java.cxx index 74a6348d4..8d8570490 100644 --- a/SWIG/Source/Modules/java.cxx +++ b/SWIG/Source/Modules/java.cxx @@ -1101,8 +1101,8 @@ class JAVA : public Language { // Other constants are wrapped using a public final static [jstype] in Java. Printf(constants_code, " public final static %s %s = ", return_type, ((proxy_flag && wrapping_member_flag) ? variable_name : symname)); - if ((is_enum_item && Getattr(n,"enumvalue") == 0) || !const_feature_flag) { - // Enums without value and default constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call. + if (!const_feature_flag) { + // Default enum and constant handling will work with any type of C constant and initialises the Java variable from C through a JNI call. if(classname_substituted_flag) // This handles function pointers using the %constant directive Printf(constants_code, "new %s(%s.%s(), false);\n", return_type, imclass_name, Swig_name_get(symname)); @@ -1115,7 +1115,8 @@ class JAVA : public Language { enum_constant_flag = false; } else if (is_enum_item) { // Alternative enum item handling will use the explicit value of the enum item and hope that it compiles as Java code - Printf(constants_code, "%s;\n", Getattr(n,"enumvalue")); + const String *enumvalue = Getattr(n,"enumvalue") ? Getattr(n,"enumvalue") : Getattr(n,"enumvalueex"); + Printf(constants_code, "%s;\n", enumvalue); } else { // Alternative constant handling will use the C syntax to make a true Java constant and hope that it compiles as Java code Printf(constants_code, "%s;\n", Getattr(n,"value"));