[vlc-commits] python bindings generator: handle bitshifted chars in enums
    Olivier Aubert 
    git at videolan.org
       
    Thu Sep 28 21:14:32 CEST 2017
    
    
  
vlc/python | branch: master | Olivier Aubert <contact at olivieraubert.net> | Tue Sep 19 11:57:09 2017 +0200| [10254685cf7785c58fe9beef3a84ed75074d4c1a] | committer: Olivier Aubert
python bindings generator: handle bitshifted chars in enums
> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=10254685cf7785c58fe9beef3a84ed75074d4c1a
---
 generator/generate.py | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/generator/generate.py b/generator/generate.py
index 6f864ec..7ee4638 100755
--- a/generator/generate.py
+++ b/generator/generate.py
@@ -492,6 +492,10 @@ class Parser(object):
                 n = t.split('/*')[0].strip()
                 if '=' in n:  # has value
                     n, v = enum_pair_re.split(n)
+                    # Bit-shifted characters cannot be directly evaluated in python
+                    m = re.search("'(.)'\s*(<<|>>)\s*(.+)", v.strip())
+                    if m:
+                        v = "%s %s %s" % (ord(m.group(1)), m.group(2), m.group(3))
                     try:  # handle expressions
                         e = eval(v, locs)
                     except (SyntaxError, TypeError, ValueError):
    
    
More information about the vlc-commits
mailing list