From fb1a1c12dc808580f9246861262f22e454334b8e Mon Sep 17 00:00:00 2001 From: Olivier Aubert Date: Thu, 10 Dec 2009 15:59:17 +0100 Subject: [PATCH] python-ctypes: define a .value() method for enums in java code ATM, java bindings use Enum.ordinal() to convert the enum name to its value. However, this approach is broken in the case of discontinuous enums such as libvlc_media_option_t. Java bindings maintainers should convert their code to use the enum.value() method. --- bindings/python-ctypes/generate.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bindings/python-ctypes/generate.py b/bindings/python-ctypes/generate.py index 15397021e6..f3b53d1bb3 100755 --- a/bindings/python-ctypes/generate.py +++ b/bindings/python-ctypes/generate.py @@ -854,7 +854,11 @@ public enum %s # FIXME: write comment for k, v in values: - self.output(fd, " %s, // %s," % (k, v)) + self.output(fd, " %s (%s)," % (k, v)) + self.output(fd, ""); + self.output(fd, " private final int _value;"); + self.output(fd, " %s(int value) { this._value = value; }" % javaname); + self.output(fd, " public int value() { return this._value; }"); self.output(fd, "}") fd.close() -- 2.39.2