minor rewrite of enum value handling
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11690 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
7df94f65e5
commit
4ebb9b0db2
3 changed files with 30 additions and 27 deletions
|
|
@ -1267,6 +1267,9 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *value = Getattr(n, "value");
|
||||
String *name = Getattr(n, "name");
|
||||
Node *parent = parentNode(n);
|
||||
int unnamedinstance = GetFlag(parent, "unnamedinstance");
|
||||
String *parent_name = Getattr(parent, "name");
|
||||
String *tmpValue;
|
||||
|
||||
// Strange hack from parent method
|
||||
|
|
@ -1278,9 +1281,9 @@ public:
|
|||
Setattr(n, "value", tmpValue);
|
||||
|
||||
{
|
||||
EnumFeature enum_feature = decodeEnumFeature(parentNode(n));
|
||||
EnumFeature enum_feature = decodeEnumFeature(parent);
|
||||
|
||||
if ((enum_feature == ProperEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
|
||||
if ((enum_feature == ProperEnum) && parent_name && !unnamedinstance) {
|
||||
// Wrap (non-anonymous) C/C++ enum with a proper Java enum
|
||||
// Emit the enum item.
|
||||
if (!GetFlag(n, "firstenumitem"))
|
||||
|
|
@ -1293,18 +1296,16 @@ public:
|
|||
}
|
||||
} else {
|
||||
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
|
||||
const String *parent_name = Getattr(parentNode(n), "name");
|
||||
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
|
||||
String *type = Getattr(n, "type"); /* should be int unless explicitly specified in a C++0x enum class */
|
||||
SwigType *typemap_lookup_type = parent_name ? parent_name : type;
|
||||
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
|
||||
String *return_type = Copy(tm);
|
||||
Delete(typemap_lookup_type);
|
||||
typemap_lookup_type = NULL;
|
||||
|
||||
String *return_type = Copy(tm);
|
||||
const String *methodmods = Getattr(n, "feature:java:methodmodifiers");
|
||||
methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
|
||||
|
||||
if ((enum_feature == TypesafeEnum) && Getattr(parentNode(n), "sym:name") && !Getattr(parentNode(n), "unnamedinstance")) {
|
||||
// Wrap (non-anonymouse) enum using the typesafe enum pattern
|
||||
if ((enum_feature == TypesafeEnum) && parent_name && !unnamedinstance) {
|
||||
// Wrap (non-anonymous) enum using the typesafe enum pattern
|
||||
if (Getattr(n, "enumvalue")) {
|
||||
String *value = enumValue(n);
|
||||
Printf(enum_code, " %s final static %s %s = new %s(\"%s\", %s);\n", methodmods, return_type, symname, return_type, symname, value);
|
||||
|
|
@ -1323,9 +1324,9 @@ public:
|
|||
}
|
||||
|
||||
// Add the enum value to the comma separated list being constructed in the enum declaration.
|
||||
String *enumvalues = Getattr(parentNode(n), "enumvalues");
|
||||
String *enumvalues = Getattr(parent, "enumvalues");
|
||||
if (!enumvalues)
|
||||
Setattr(parentNode(n), "enumvalues", Copy(symname));
|
||||
Setattr(parent, "enumvalues", Copy(symname));
|
||||
else
|
||||
Printv(enumvalues, ", ", symname, NIL);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue