New default C/C++ enum wrapping approach which uses the type safe enum pattern for Java and C#

Also tests for Java and C# simple enums (enum items mapped to integers)
Also proper Java (J2SDK1.5) enums


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5919 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2004-05-24 20:05:40 +00:00
commit c88daea001
6 changed files with 41 additions and 5 deletions

View file

@ -3,7 +3,9 @@
%module java_enums
// Some pragmas to add in an interface to the module class - checks that the java_enumsConstants interface class is also 'implemented'
%include "enumtypeunsafe.swg"
// Some pragmas to add in an interface to the module class
%pragma(java) moduleinterfaces="Serializable"
%pragma(java) moduleimports=%{
import java.io.*; // For Serializable
@ -12,6 +14,9 @@ import java.io.*; // For Serializable
// Set default Java const code generation
%javaconst(1);
// Change the default generation so that these enums are generated into an interface instead of a class
%typemap(javaclassmodifiers) enum stuff "public interface"
%inline %{
enum stuff { FIDDLE = 2*100, STICKS = 5+8, BONGO, DRUMS };
%}
@ -28,7 +33,6 @@ enum stuff { FIDDLE = 2*100, STICKS = 5+8, BONGO, DRUMS };
return $jnicall;
}
%inline %{
enum nonsense { POPPYCOCK, JUNK };
nonsense test1(nonsense n) { return n; }