From: Olivier Aubert Date: Thu, 10 Dec 2009 14:59:17 +0000 (+0100) Subject: python-ctypes: define a .value() method for enums in java code X-Git-Tag: 1.1.0-ff~2043 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=fb1a1c12dc808580f9246861262f22e454334b8e;p=vlc 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. --- 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()