diff --git a/SWIG/Examples/java/enum/example.h b/SWIG/Examples/java/enum/example.h index 525d62afc..9119cd9fc 100644 --- a/SWIG/Examples/java/enum/example.h +++ b/SWIG/Examples/java/enum/example.h @@ -5,7 +5,7 @@ enum color { RED, BLUE, GREEN }; class Foo { public: Foo() { } - enum speed { IMPULSE, WARP, LUDICROUS }; + enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 }; void enum_test(speed s); }; diff --git a/SWIG/Examples/java/enum/index.html b/SWIG/Examples/java/enum/index.html index cd81244e3..6179f9f97 100644 --- a/SWIG/Examples/java/enum/index.html +++ b/SWIG/Examples/java/enum/index.html @@ -14,9 +14,11 @@ $Header$

-This example tests SWIG's ability to wrap enumerations. By default, SWIG -converts enumeration specifications into integer constants. Further use -of enumerated types are handled as integers. +This example tests SWIG's ability to wrap enumerations. +SWIG wraps enums in numerous different ways. The default approach is to wrap +each enum with the typesafe enum pattern. Enums are handled as integers in the JNI layer. +See the documentation for the other approaches for wrapping enums. +

-

Notes

- - -
diff --git a/SWIG/Examples/java/enum/main.java b/SWIG/Examples/java/enum/main.java index b1098c7b1..8646e0087 100644 --- a/SWIG/Examples/java/enum/main.java +++ b/SWIG/Examples/java/enum/main.java @@ -13,27 +13,26 @@ public class main { { // Print out the value of some enums System.out.println("*** color ***"); - System.out.println(" RED = " + example.RED); - System.out.println(" BLUE = " + example.BLUE); - System.out.println(" GREEN = " + example.GREEN); + System.out.println(" " + color.RED + " = " + color.RED.swigValue()); + System.out.println(" " + color.BLUE + " = " + color.BLUE.swigValue()); + System.out.println(" " + color.GREEN + " = " + color.GREEN.swigValue()); System.out.println("\n*** Foo::speed ***"); - System.out.println(" Foo::IMPULSE = " + Foo.IMPULSE); - System.out.println(" Foo::WARP = " + Foo.WARP); - System.out.println(" Foo::LUDICROUS = " + Foo.LUDICROUS); + System.out.println(" Foo::" + Foo.speed.IMPULSE + " = " + Foo.speed.IMPULSE.swigValue()); + System.out.println(" Foo::" + Foo.speed.WARP + " = " + Foo.speed.WARP.swigValue()); + System.out.println(" Foo::" + Foo.speed.LUDICROUS + " = " + Foo.speed.LUDICROUS.swigValue()); System.out.println("\nTesting use of enums with functions\n"); - example.enum_test(example.RED, Foo.IMPULSE); - example.enum_test(example.BLUE, Foo.WARP); - example.enum_test(example.GREEN, Foo.LUDICROUS); - example.enum_test(1234,5678); + example.enum_test(color.RED, Foo.speed.IMPULSE); + example.enum_test(color.BLUE, Foo.speed.WARP); + example.enum_test(color.GREEN, Foo.speed.LUDICROUS); System.out.println( "\nTesting use of enum with class method" ); Foo f = new Foo(); - f.enum_test(Foo.IMPULSE); - f.enum_test(Foo.WARP); - f.enum_test(Foo.LUDICROUS); + f.enum_test(Foo.speed.IMPULSE); + f.enum_test(Foo.speed.WARP); + f.enum_test(Foo.speed.LUDICROUS); } }