]> git.sesse.net Git - vlc/commitdiff
python-ctypes: define a .value() method for enums in java code
authorOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Thu, 10 Dec 2009 14:59:17 +0000 (15:59 +0100)
committerOlivier Aubert <olivier.aubert@liris.cnrs.fr>
Thu, 10 Dec 2009 14:59:31 +0000 (15:59 +0100)
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

index 15397021e62cafcb3cdc9826ef6aa6bbe96635ac..f3b53d1bb3b7963e1ee38202344602bcf7c6608f 100755 (executable)
@@ -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()