[vlc-commits] extract and improve function pointer regex

Alberto Invernizzi git at videolan.org
Wed Apr 29 13:12:36 CEST 2020


vlc/python | branch: master | Alberto Invernizzi <alby.inve at gmail.com> | Thu Apr  2 18:45:46 2020 +0200| [394d13d0f469d621e90da47df08b58385c9b2110] | committer: Alberto Invernizzi

extract and improve function pointer regex

> http://git.videolan.org/gitweb.cgi/vlc/python.git/?a=commit;h=394d13d0f469d621e90da47df08b58385c9b2110
---

 generator/generate.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/generator/generate.py b/generator/generate.py
index 11048f7..be160b6 100755
--- a/generator/generate.py
+++ b/generator/generate.py
@@ -156,6 +156,7 @@ callback_type_re = re.compile(r'^typedef\s+\w+(\s*\*)?\s*\(\s*\*')
 callback_re  = re.compile(r'typedef\s+\*?(\w+\s*\*?)\s*\(\s*\*\s*(\w+)\s*\)\s*\((.+)\);')
 struct_type_re = re.compile(r'^typedef\s+struct\s*(\S+)\s*$')
 struct_re    = re.compile(r'typedef\s+(struct)\s*(\S+)?\s*\{\s*(.+)\s*\}\s*(?:\S+)?\s*;')
+func_pointer_re = re.compile(r'(\(?[^\(]+)\s+\((\*\s*\S*)\)(\(.*\))') # (ret_type, *pointer_name, ([params]))
 typedef_re   = re.compile(r'^typedef\s+(?:struct\s+)?(\S+)\s+(\S+);')
 forward_re   = re.compile(r'.+\(\s*(.+?)\s*\)(\s*\S+)')
 libvlc_re    = re.compile(r'libvlc_[a-z_]+')
@@ -713,8 +714,7 @@ class Parser(object):
             param_raw = m.group(1) + m.group(2)
 
         # is this a function pointer?
-        RE_FUNC_POINTER = r'\(.+\)\s*\(.+\)'
-        if re.search(RE_FUNC_POINTER, param_raw):
+        if func_pointer_re.search(param_raw):
             return None
 
         # is this parameter a pointer?



More information about the vlc-commits mailing list