[vlc-devel] commit: python-ctypes: define a .value() method for enums in java code ( Olivier Aubert )
git version control
git at videolan.org
Thu Dec 10 15:59:44 CET 2009
vlc | branch: master | Olivier Aubert <olivier.aubert at liris.cnrs.fr> | Thu Dec 10 15:59:17 2009 +0100| [fb1a1c12dc808580f9246861262f22e454334b8e] | committer: Olivier Aubert
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.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fb1a1c12dc808580f9246861262f22e454334b8e
---
bindings/python-ctypes/generate.py | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/bindings/python-ctypes/generate.py b/bindings/python-ctypes/generate.py
index 1539702..f3b53d1 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()
More information about the vlc-devel
mailing list