summaryrefslogtreecommitdiff
path: root/tools/validateinterfaces.py
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-11-14 19:54:07 +0300
committerAndrei Karas <akaras@inbox.ru>2014-12-02 14:23:49 +0300
commit16ef092d770f78637f336d926865c3f86eafc365 (patch)
tree414a771d16ca134f65ca50fdab5352c5cd6f2878 /tools/validateinterfaces.py
parentd4e0689858b294260c610e77c27812797bbf26c0 (diff)
downloadhercules-16ef092d770f78637f336d926865c3f86eafc365.tar.gz
hercules-16ef092d770f78637f336d926865c3f86eafc365.tar.bz2
hercules-16ef092d770f78637f336d926865c3f86eafc365.tar.xz
hercules-16ef092d770f78637f336d926865c3f86eafc365.zip
in validateinterfaces.py tool add support for checking not added functions to initerfaces.
Diffstat (limited to 'tools/validateinterfaces.py')
-rwxr-xr-xtools/validateinterfaces.py50
1 files changed, 44 insertions, 6 deletions
diff --git a/tools/validateinterfaces.py b/tools/validateinterfaces.py
index a4222adb5..a26e30ad2 100755
--- a/tools/validateinterfaces.py
+++ b/tools/validateinterfaces.py
@@ -26,7 +26,7 @@ def searchStructStart(r, ifname):
return True
return False
-def readCFile(cFile):
+def readCFile(tracker, cFile):
methods = Set()
shortIfName = ""
with open(cFile, "r") as r:
@@ -38,7 +38,7 @@ def readCFile(cFile):
ifname = m.group("name1")
if searchDefault(r, ifname) == False:
return (None, shortIfName, methods)
- lineRe = re.compile("(?P<ifname>[a-z_]+)->(?P<method>[\w_]+) ")
+ lineRe = re.compile("(?P<ifname>[a-z_]+)->(?P<method>[\w_]+)[ ][=][ ](?P<fullmethod>[^;]+);")
for line in r:
# print "cline2: " + line
test = line.strip()
@@ -55,10 +55,12 @@ def readCFile(cFile):
shortIfName = m.group("ifname")
# print "{2}: add {0}, from: {1}".format(m.group("method"), line, ifname)
methods.add(m.group("method"))
+ tracker.interfaces.add(ifname);
+ tracker.fullmethods.add(m.group("fullmethod"));
return (ifname, shortIfName, methods)
return (None, shortIfName, methods)
-def readHFile(hFile, ifname):
+def readHFile(tracker, hFile, ifname):
methods = Set()
with open(hFile, "r") as r:
if searchStructStart(r, ifname) == False:
@@ -75,15 +77,16 @@ def readHFile(hFile, ifname):
if m != None:
# print "{2}: add {0}, from: {1}".format(m.group("method"), line, ifname)
methods.add(m.group("method"))
+ tracker.fullmethods.add(ifname + "_" + m.group("method"))
return methods
def checkIfFile(tracker, cFile, hFile):
- data = readCFile(cFile)
+ data = readCFile(tracker, cFile)
cMethods = data[2]
ifname = data[0]
shortIfName = data[1]
if len(cMethods) > 0:
- hMethods = readHFile(hFile, ifname)
+ hMethods = readHFile(tracker, hFile, ifname)
for method in hMethods:
tracker.arr[ifname + "_" + method] = list()
tracker.methods.add(ifname + "_" + method)
@@ -116,7 +119,7 @@ def checkChr(ch):
return False
def checkFile(tracker, cFile):
- print "Checking: " + cFile
+# print "Checking: " + cFile
with open(cFile, "r") as r:
for line in r:
parts = re.findall(r'[\w_]+', line)
@@ -156,10 +159,40 @@ def reportMethods(tracker):
print "\n"
+def checkLostFile(tracker, cFile):
+# print "Checking: " + cFile
+ methodRe = re.compile("^([\w0-9* _]*)([ ]|[*])(?P<ifname>[a-z_]+)_(?P<method>[\w_]+)(|[ ])[(]")
+ with open(cFile, "r") as r:
+ for line in r:
+ if line.find("(") < 1 or len(line) < 3 or line[0] == "\t" or line[0] == " " or line.find("_defaults") > 0:
+ continue
+ m = methodRe.search(line)
+ if m != None:
+ name = "{0}_{1}".format(m.group("ifname"), m.group("method"))
+ if m.group("ifname") not in tracker.interfaces:
+ continue
+ if name not in tracker.fullmethods:
+# print "src : " + line
+ print name
+
+def processLostDir(tracker, srcDir):
+ files = os.listdir(srcDir)
+ for file1 in files:
+ if file1[0] == '.' or file1 == "..":
+ continue
+ cPath = os.path.abspath(srcDir + os.path.sep + file1)
+ if not os.path.isfile(cPath):
+ processLostDir(tracker, cPath)
+ elif file1[-2:] == ".c":
+ checkLostFile(tracker, cPath)
+
tracker = Tracker()
tracker.arr = dict()
tracker.methods = Set()
+tracker.fullmethods = Set()
+tracker.interfaces = Set()
tracker.retCode = 0
+
if len(sys.argv) > 1 and sys.argv[1] == "silent":
processIfDir(tracker, "../src/char");
processIfDir(tracker, "../src/map");
@@ -171,6 +204,11 @@ else:
processIfDir(tracker, "../src/map");
processIfDir(tracker, "../src/login");
processIfDir(tracker, "../src/common");
+ print "Checking not added functions to initerfaces"
+ processLostDir(tracker, "../src/char");
+ processLostDir(tracker, "../src/map");
+ processLostDir(tracker, "../src/login");
+ processLostDir(tracker, "../src/common");
print "Checking interfaces usage"
processDir(tracker, "../src/char");
processDir(tracker, "../src/map");