[vlc-commits] add constness information to Par class

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


vlc/python | branch: master | Alberto Invernizzi <alby.inve at gmail.com> | Sun Mar 29 21:01:44 2020 +0200| [ed7e13e5df3c9ae519ef7424ff1fafed2196e9d9] | committer: Alberto Invernizzi

add constness information to Par class

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

 generator/generate.py | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/generator/generate.py b/generator/generate.py
index 3dbb9e6..bf7f399 100755
--- a/generator/generate.py
+++ b/generator/generate.py
@@ -389,9 +389,10 @@ class Func(_Source):
 class Par(object):
     """C function parameter.
     """
-    def __init__(self, name, type):
+    def __init__(self, name, type, constness):
         self.name = name
         self.type = type  # C type
+        self.constness = constness
 
     def __repr__(self):
         return "%s (%s)" % (self.name, self.type)
@@ -728,6 +729,8 @@ class Parser(object):
             # ASSUMPTION
             # just indirection level 0 and 1 can be const
             for deref_level_constness in constness[2:]: assert(not deref_level_constness)
+
+            param_constness = constness[:2]
         # ... or is it a simple variable?
         else:
             # WARNING: workaround for "union { struct {"
@@ -742,7 +745,7 @@ class Parser(object):
 
             # normalize spaces
             param_raw = re.sub('\s+', ' ', param_raw)
-            # TODO remove struct and const
+
             try:
                 split_value = param_raw.split(' ')
                 if len(split_value) > 1:
@@ -754,7 +757,9 @@ class Parser(object):
             except:
                 param_name = ''
 
-        return Par(param_name.strip(), param_type.strip())
+            param_constness = [False]
+
+        return Par(param_name.strip(), param_type.strip(), param_constness)
 
     def parse_version(self, h_files):
         """Get the libvlc version from the C header files:



More information about the vlc-commits mailing list