[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH 3/3] Fix references to self.warning()



Only the class CParser declares a method warning(), but the other
classes still try to call their self.warning() method, which fails.

Move the warning() functions to its own base classe and inherit from
that in all other classes.

Signed-off-by: Philipp Hahn <hahn univention de>
---
 docs/apibuild.py |   48 ++++++++++++++++++++++++++++++------------------
 1 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/docs/apibuild.py b/docs/apibuild.py
index 53b3421..d335ab1 100755
--- a/docs/apibuild.py
+++ b/docs/apibuild.py
@@ -173,8 +173,30 @@ class identifier:
         if conditionals != None:
             self.set_conditionals(conditionals)
 
-class index:
+class base(object):
+    """Base class providing common methods for printing messages."""
+    def __init__(self):
+        self.no_error = False
+
+    def warning(self, msg):
+        """Print warning message."""
+        global warnings
+        warnings = warnings + 1
+        if self.no_error:
+            return
+        print msg
+
+    def stop_error(self):
+        """Stop printing error messages."""
+        self.no_error = True
+
+    def start_error(self):
+        """Re-start printing error messages."""
+        self.no_error = False
+
+class index(base):
     def __init__(self, name = "noname"):
+        base.__init__(self)
         self.name = name
         self.identifiers = {}
         self.functions = {}
@@ -366,10 +388,11 @@ class index:
             self.analyze_dict("typedefs", self.typedefs)
             self.analyze_dict("macros", self.macros)
 
-class CLexer:
+class CLexer(base):
     """A lexer for the C language, tokenize the input by reading and
        analyzing it line by line"""
     def __init__(self, input):
+        base.__init__(self)
         self.input = input
         self.tokens = []
         self.line = ""
@@ -572,9 +595,10 @@ class CLexer:
         self.last = tok
         return tok
 
-class CParser:
+class CParser(base):
     """The C module parser"""
     def __init__(self, filename, idx = None):
+        base.__init__(self)
         self.filename = filename
         if len(filename) > 2 and filename[-2:] == '.h':
             self.is_header = 1
@@ -590,19 +614,12 @@ class CParser:
         self.last_comment = ""
         self.comment = None
         self.collect_ref = 0
-        self.no_error = 0
         self.conditionals = []
         self.defines = []
 
     def collect_references(self):
         self.collect_ref = 1
 
-    def stop_error(self):
-        self.no_error = 1
-
-    def start_error(self):
-        self.no_error = 0
-
     def lineno(self):
         return self.lexer.getlineno()
 
@@ -623,12 +640,6 @@ class CParser:
             self.index.add_ref(name, None, module, static, type, self.lineno(),
                                info, extra, self.conditionals)
 
-    def warning(self, msg):
-        global warnings
-        warnings = warnings + 1
-        if self.no_error:
-            return
-        print msg
 
     def error(self, msg, token=-1):
         if self.no_error:
@@ -1825,9 +1836,10 @@ class CParser:
         return self.index
 
 
-class docBuilder:
+class docBuilder(base):
     """A documentation builder"""
     def __init__(self, name, path='.', directories=['.'], includes=[]):
+        base.__init__(self)
         self.name = name
         self.path = path
         self.directories = directories
@@ -2363,7 +2375,7 @@ def rebuild():
                              ["src", "src/util", "include/libvirt"],
                              [])
     else:
-        self.warning("rebuild() failed, unable to guess the module")
+        base().warning("rebuild() failed, unable to guess the module")
         return None
     builder.scan()
     builder.analyze()
-- 
1.7.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]