C# attribute support added - %csattributes feature, %csattributes typemap

and inattributes & outattributes typemap attributes for the imtype and cstype typemaps.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@7184 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2005-05-12 20:19:47 +00:00
commit 43a6363856
7 changed files with 367 additions and 18 deletions

View file

@ -13,6 +13,7 @@ top_srcdir = @top_srcdir@/..
top_builddir = @top_builddir@../
CPP_TEST_CASES = \
csharp_attributes \
csharp_exceptions \
csharp_typemaps \
enum_thorough_simple \

View file

@ -0,0 +1,246 @@
using System;
using System.Reflection;
using csharp_attributesNamespace;
public class runme
{
static void Main()
{
// Custom attributes typemap tests
//
// cstype typemap attributechecks
//
// Global function cstype typemap attributes check
csharp_attributes csharpattributes = new csharp_attributes();
Type globaltype = csharpattributes.GetType();
{
MethodInfo member = (MethodInfo)globaltype.GetMember("GlobalFunction")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
// Constant - cstype typemap attributes check
{
MemberInfo member = (MemberInfo)globaltype.GetMember("TESTMACRO")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
}
// Non-static method cstype typemap attributes check
Stations testClass = new Stations(20);
Type type = testClass.GetType();
{
MethodInfo member = (MethodInfo)type.GetMember("Reading")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
// Static method cstype typemap attributes check
{
MethodInfo member = (MethodInfo)type.GetMember("Swindon")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntOutAttribute)) == null)
throw new Exception("No IntOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
// Constructor cstype typemap attributes check
{
ConstructorInfo member = (ConstructorInfo)type.GetConstructors()[0];
ParameterInfo parameter = member.GetParameters()[0]; // expecting one parameter
if (parameter.Name != "myInt")
throw new Exception("Incorrect parameter name");
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntInAttribute))
throw new Exception("Expecting IntIn attribute");
}
//
// imtype typemap attributechecks
//
// Global function imtype typemap attributes check
csharp_attributesPINVOKE csPinvoke = new csharp_attributesPINVOKE();
Type imclasstype = csPinvoke.GetType();
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("GlobalFunction")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntegerInAttribute))
throw new Exception("Expecting IntegerIn attribute");
}
// Constant - imtype typemap attributes check
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("get_TESTMACRO")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
}
// Non-static method imtype typemap attributes check
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Reading")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[1]; // checking 2nd parameter
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntegerInAttribute))
throw new Exception("Expecting IntegerIn attribute");
}
// Static method imtype typemap attributes check
{
MethodInfo member = (MethodInfo)imclasstype.GetMember("Stations_Swindon")[0];
if (Attribute.GetCustomAttribute(member, typeof(IntegerOutAttribute)) == null)
throw new Exception("No IntegerOut attribute for " + member.Name);
ParameterInfo parameter = member.GetParameters()[0]; // checking 1st parameter
Attribute attribute = Attribute.GetCustomAttributes(parameter)[0];
if (attribute.GetType() != typeof(IntegerInAttribute))
throw new Exception("Expecting IntegerIn attribute");
}
//
// attributes feature
//
MoreStations moreStations = new MoreStations();
Type moretype = moreStations.GetType();
// Constructor attributes feature check
{
ConstructorInfo member = (ConstructorInfo)moretype.GetConstructors()[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity1Attribute)) == null)
throw new Exception("MoreStations::MoreStations attribute failed");
}
// Non-static method attributes feature check
{
MethodInfo member = (MethodInfo)moretype.GetMember("Chippenham")[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity2Attribute)) == null)
throw new Exception("MoreStations::Chippenham attribute failed");
}
// Static method attributes feature check
{
MethodInfo member = (MethodInfo)moretype.GetMember("Bath")[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity3Attribute)) == null)
throw new Exception("MoreStations::Bath attribute failed");
}
// Non-static member variable attributes feature check
{
PropertyInfo member = (PropertyInfo)moretype.GetProperty("Bristol");
if (Attribute.GetCustomAttribute(member, typeof(InterCity4Attribute)) == null)
throw new Exception("MoreStations::Bristol attribute failed");
}
// Static member variable attributes feature check
{
PropertyInfo member = (PropertyInfo)moretype.GetProperty("WestonSuperMare");
if (Attribute.GetCustomAttribute(member, typeof(InterCity5Attribute)) == null)
throw new Exception("MoreStations::Bristol attribute failed");
}
// Global function attributes feature check
{
MethodInfo member = (MethodInfo)globaltype.GetMember("Paddington")[0];
if (Attribute.GetCustomAttribute(member, typeof(InterCity7Attribute)) == null)
throw new Exception("MoreStations::Paddington attribute failed");
}
// Global variables attributes feature check
{
PropertyInfo member = (PropertyInfo)globaltype.GetProperty("DidcotParkway");
if (Attribute.GetCustomAttribute(member, typeof(InterCity8Attribute)) == null)
throw new Exception("MoreStations::Paddington attribute failed");
}
//
// csattribute typemaps
//
// Class csattribute typemap
{
Object[] attribs = moretype.GetCustomAttributes(true);
Eurostar1Attribute tgv = (Eurostar1Attribute)attribs[0];
if (tgv == null)
throw new Exception("No attribute for MoreStations");
}
// Nested enum csattribute typemap
{
MemberInfo member = (MemberInfo)moretype.GetMember("Wales")[0];
if (Attribute.GetCustomAttribute(member, typeof(Eurostar2Attribute)) == null)
throw new Exception("No attribute for " + member.Name);
}
// Enum csattribute typemap
{
/* TODO
Cymru cymru = new Cymru();
Type cymrutype = Cymru.GetType();
Object[] attribs = cymrutype.GetCustomAttributes(true);
Eurostar3Attribute tgv = (Eurostar3Attribute)attribs[0];
if (tgv == null)
throw new Exception("No attribute for Cymru");
*/
}
}
}
// Custom attribute classes
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntInAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntOutAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntegerInAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class IntegerOutAttribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity1Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity2Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity3Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity4Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity5Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity6Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity7Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class InterCity8Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class Eurostar1Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class Eurostar2Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class Eurostar3Attribute : Attribute {}
[AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)]
public class ThreadSafeAttribute : Attribute {
public ThreadSafeAttribute(bool safe) {}
public ThreadSafeAttribute() {}
}

View file

@ -22,6 +22,7 @@ public class runme
if (csharp_typemaps.go != "zzz")
throw new Exception("go variable failed");
// Eager garbage collector test
{
const int NUM_THREADS = 8;
@ -45,6 +46,7 @@ public class runme
}
}
public class TestThread {
private int threadId;
public bool Failed;

View file

@ -0,0 +1,48 @@
%module csharp_attributes
// Test the inattributes and outattributes typemaps
%typemap(cstype, outattributes="[IntOut]", inattributes="[IntIn]") int "int"
%typemap(imtype, outattributes="[IntegerOut]", inattributes="[IntegerIn]") int "int"
%inline %{
class Stations {
public:
Stations(int myInt) { }
int Reading(int myInt) { return myInt; }
static int Swindon(int myInt) { return myInt; }
};
#define TESTMACRO 10
int GlobalFunction(int myInt) { return myInt; }
%}
// Test the attributes feature
%csattributes MoreStations::MoreStations() "[InterCity1]"
%csattributes MoreStations::Chippenham() "[InterCity2]"
%csattributes MoreStations::Bath() "[InterCity3]"
%csattributes Bristol "[InterCity4]"
%csattributes WestonSuperMare "[InterCity5]"
%csattributes Wales "[InterCity6]"
%csattributes Paddington() "[InterCity7]"
%csattributes DidcotParkway "[InterCity8]"
%typemap(csattributes) MoreStations "[Eurostar1]"
%typemap(csattributes) MoreStations::Wales "[Eurostar2]"
%typemap(csattributes) Cymru "[Eurostar3]"
%inline %{
struct MoreStations {
MoreStations() : Bristol(0) {}
void Chippenham() {}
static void Bath() {}
int Bristol;
static double WestonSuperMare;
enum Wales { Cardiff = 1, Swansea };
};
void Paddington() {}
float DidcotParkway;
enum Cymru { Llanelli };
double MoreStations::WestonSuperMare = 0.0;
%}

View file

@ -625,6 +625,7 @@ $1 = &temp; %}
#define %csenum(wrapapproach) %feature("cs:enum","wrapapproach")
#define %csmethodmodifiers %feature("cs:methodmodifiers")
#define %csnothrowexception %feature("except")
#define %csattributes %feature("cs:attributes")
%pragma(csharp) imclassclassmodifiers="class"
%pragma(csharp) moduleclassmodifiers="public class"

View file

@ -455,6 +455,7 @@ class CSHARP : public Language {
String *cleanup = NewString("");
String *outarg = NewString("");
String *body = NewString("");
String *im_outattribute = 0;
int num_arguments = 0;
int num_required = 0;
bool is_void_return;
@ -496,6 +497,7 @@ class CSHARP : public Language {
if (imtypeout)
tm = imtypeout;
Printf(im_return_type,"%s", tm);
im_outattribute = Getattr(n,"tmap:imtype:outattributes");
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number,
"No imtype typemap defined for %s\n", SwigType_str(t,0));
@ -528,6 +530,9 @@ class CSHARP : public Language {
Printv(imclass_class_code,
"\n [DllImport(\"", dllimport, "\", EntryPoint=\"CSharp_", overloaded_name, "\")]\n", NIL);
if (im_outattribute)
Printf(imclass_class_code, " %s\n", im_outattribute);
Printf(imclass_class_code, " public static extern %s %s(", im_return_type, overloaded_name);
@ -561,7 +566,8 @@ class CSHARP : public Language {
/* Get the intermediary class parameter types of the parameter */
if ((tm = Getattr(p,"tmap:imtype"))) {
Printv(im_param_type, tm, NIL);
String *inattributes = Getattr(p,"tmap:imtype:inattributes");
Printf(im_param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF, input_file, line_number,
"No imtype typemap defined for %s\n", SwigType_str(pt,0));
@ -849,6 +855,11 @@ class CSHARP : public Language {
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup("csinterfaces", typemap_lookup_type, WARN_NONE);
// Class attributes
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(enum_code, "%s\n", csattributes);
// Emit the enum
Printv(enum_code,
typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
@ -882,8 +893,7 @@ class CSHARP : public Language {
"\n" :
typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"}\n",
"\n",
"}",
NIL);
Replaceall(enum_code, "$csclassname", symname);
@ -898,10 +908,9 @@ class CSHARP : public Language {
// Enums defined within the C++ class are defined within the proxy class
// Add extra indentation
Replaceall(enum_code, "\n ", "\n ");
Replaceall(enum_code, "\n}\n", "\n }\n");
Replaceall(enum_code, "\n", "\n ");
Printv(proxy_class_constants_code, " ", enum_code, NIL);
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
} else {
// Global enums are defined in their own file
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), symname);
@ -922,9 +931,10 @@ class CSHARP : public Language {
typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n",
enum_code,
"\n",
NIL);
Printf(f_enum, Len(namespce) > 0 ? "\n}\n" : "\n");
Printf(f_enum, Len(namespce) > 0 ? "\n}\n" : "");
Close(f_enum);
}
} else {
@ -1088,8 +1098,11 @@ class CSHARP : public Language {
Setattr(n, "value", new_value);
}
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
Printf(constants_code, " public %s %s %s = ", (const_feature_flag ? "const" : "static readonly"), return_type, itemname);
const String *outattributes = Getattr(n,"tmap:cstype:outattributes");
if (outattributes)
Printf(constants_code, " %s\n", outattributes);
const String *itemname = (proxy_flag && wrapping_member_flag) ? variable_name : symname;
Printf(constants_code, " public %s %s %s = ", (const_feature_flag ? "const" : "static readonly"), return_type, itemname);
// Check for the %csconstvalue feature
String *value = Getattr(n,"feature:cs:constvalue");
@ -1263,11 +1276,18 @@ class CSHARP : public Language {
// Pure C# interfaces
const String *pure_interfaces = typemapLookup(derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def,
typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n",
NIL);
// Class attributes
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
if (csattributes)
Printf(proxy_class_def, "%s\n", csattributes);
Printv(proxy_class_def,
typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ?
@ -1541,6 +1561,12 @@ class CSHARP : public Language {
}
/* Start generating the proxy function */
const String *outattributes = Getattr(n,"tmap:cstype:outattributes");
if (outattributes)
Printf(function_code, " %s\n", outattributes);
const String *csattributes = Getattr(n,"feature:cs:attributes");
if (csattributes)
Printf(function_code, " %s\n", csattributes);
const String *methodmods = Getattr(n,"feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (!is_public(n) ? protected_string : public_string);
Printf(function_code, " %s ", methodmods);
@ -1586,7 +1612,8 @@ class CSHARP : public Language {
/* Get the C# parameter type */
if ((tm = Getattr(p,"tmap:cstype"))) {
substituteClassname(pt, tm);
Printf(param_type, "%s", tm);
String *inattributes = Getattr(p,"tmap:cstype:inattributes");
Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number,
"No cstype typemap defined for %s\n", SwigType_str(pt,0));
@ -1652,6 +1679,9 @@ class CSHARP : public Language {
"No csvarin typemap defined for %s\n", SwigType_str(pt,0));
}
}
const String *csattributes = Getattr(n,"feature:cs:attributes");
if (csattributes)
Printf(proxy_class_code, " %s\n", csattributes);
Printf(proxy_class_code, " public %s%s %s {", static_flag ? "static " : "", variable_type, variable_name);
}
generate_property_declaration_flag = false;
@ -1721,6 +1751,9 @@ class CSHARP : public Language {
String *mangled_overname = Swig_name_construct(overloaded_name);
String *imcall = NewString("");
const String *csattributes = Getattr(n,"feature:cs:attributes");
if (csattributes)
Printf(function_code, " %s\n", csattributes);
const String *methodmods = Getattr(n,"feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (!is_public(n) ? protected_string : public_string);
Printf(function_code, " %s %s(", methodmods, proxy_class_name);
@ -1756,7 +1789,8 @@ class CSHARP : public Language {
/* Get the C# parameter type */
if ((tm = Getattr(p,"tmap:cstype"))) {
substituteClassname(pt, tm);
Printf(param_type, "%s", tm);
String *inattributes = Getattr(p,"tmap:cstype:inattributes");
Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number,
"No cstype typemap defined for %s\n", SwigType_str(pt,0));
@ -1951,6 +1985,12 @@ class CSHARP : public Language {
}
/* Start generating the function */
const String *outattributes = Getattr(n,"tmap:cstype:outattributes");
if (outattributes)
Printf(function_code, " %s\n", outattributes);
const String *csattributes = Getattr(n,"feature:cs:attributes");
if (csattributes)
Printf(function_code, " %s\n", csattributes);
const String *methodmods = Getattr(n,"feature:cs:methodmodifiers");
methodmods = methodmods ? methodmods : (!is_public(n) ? protected_string : public_string);
Printf(function_code, " %s static %s %s(", methodmods, return_type, func_name);
@ -1977,7 +2017,8 @@ class CSHARP : public Language {
/* Get the C# parameter type */
if ((tm = Getattr(p,"tmap:cstype"))) {
substituteClassname(pt, tm);
Printf(param_type, "%s", tm);
String *inattributes = Getattr(p,"tmap:cstype:inattributes");
Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CSWTYPE_UNDEF, input_file, line_number,
"No cstype typemap defined for %s\n", SwigType_str(pt,0));
@ -2042,6 +2083,9 @@ class CSHARP : public Language {
"No csvarin typemap defined for %s\n", SwigType_str(pt,0));
}
}
const String *csattributes = Getattr(n,"feature:cs:attributes");
if (csattributes)
Printf(module_class_code, " %s\n", csattributes);
Printf(module_class_code, " public static %s %s {", variable_type, variable_name);
}
generate_property_declaration_flag = false;
@ -2316,6 +2360,14 @@ class CSHARP : public Language {
Printv(swigtype,
typemapLookup("csimports", type, WARN_NONE), // Import statements
"\n",
NIL);
// Class attributes
const String *csattributes = typemapLookup("csattributes", type, WARN_NONE);
if (csattributes)
Printf(swigtype, "%s\n", csattributes);
Printv(swigtype,
typemapLookup("csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(*Char(pure_baseclass) || *Char(pure_interfaces)) ?

View file

@ -1106,8 +1106,7 @@ class JAVA : public Language {
"",
typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"}\n",
"\n",
"}",
NIL);
Replaceall(enum_code, "$javaclassname", symname);
@ -1122,10 +1121,9 @@ class JAVA : public Language {
// Enums defined within the C++ class are defined within the proxy class
// Add extra indentation
Replaceall(enum_code, "\n ", "\n ");
Replaceall(enum_code, "\n}\n", "\n }\n");
Replaceall(enum_code, "\n", "\n ");
Printv(proxy_class_constants_code, " ", enum_code, NIL);
Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL);
} else {
// Global enums are defined in their own file
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), symname);
@ -1146,6 +1144,7 @@ class JAVA : public Language {
typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n",
enum_code,
"\n",
NIL);
Printf(f_enum, "\n");