D: Emit empty enums as int aliases instead of omitting them.

This fixes test-suite/enum_forward.i.
This commit is contained in:
David Nadlinger 2014-10-30 08:30:29 +01:00
commit a8cdd1798e

View file

@ -803,12 +803,7 @@ public:
// Emit each enum item. // Emit each enum item.
Language::enumDeclaration(n); Language::enumDeclaration(n);
if (!GetFlag(n, "nonempty")) { if (GetFlag(n, "nonempty")) {
// Do not wrap empty enums; the resulting D code would be illegal.
Delete(proxy_enum_code);
return SWIG_NOWRAP;
}
// Finish the enum. // Finish the enum.
if (typemap_lookup_type) { if (typemap_lookup_type) {
Printv(proxy_enum_code, Printv(proxy_enum_code,
@ -818,8 +813,13 @@ public:
// Handle anonymous enums. // Handle anonymous enums.
Printv(proxy_enum_code, "\n}\n", NIL); Printv(proxy_enum_code, "\n}\n", NIL);
} }
Replaceall(proxy_enum_code, "$dclassname", symname); Replaceall(proxy_enum_code, "$dclassname", symname);
} else {
// D enum declarations must have at least one member to be legal, so emit
// an alias to int instead (their ctype/imtype is always int).
Delete(proxy_enum_code);
proxy_enum_code = NewStringf("\nalias int %s;\n", symname);
}
const String* imports = const String* imports =
lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE); lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE);