Checker percentage calc was wrong, also cleanup
This commit is contained in:
@@ -41,7 +41,7 @@ defs_precalc = {
|
|||||||
|
|
||||||
"glColor3dv": {0: 3},
|
"glColor3dv": {0: 3},
|
||||||
"glColor4dv": {0: 4},
|
"glColor4dv": {0: 4},
|
||||||
|
|
||||||
"glVertex2fv": {0: 2},
|
"glVertex2fv": {0: 2},
|
||||||
"glVertex3fv": {0: 3},
|
"glVertex3fv": {0: 3},
|
||||||
"glVertex4fv": {0: 4},
|
"glVertex4fv": {0: 4},
|
||||||
@@ -50,27 +50,27 @@ defs_precalc = {
|
|||||||
"glEvalCoord1dv": {0: 1},
|
"glEvalCoord1dv": {0: 1},
|
||||||
"glEvalCoord2fv": {0: 2},
|
"glEvalCoord2fv": {0: 2},
|
||||||
"glEvalCoord2dv": {0: 2},
|
"glEvalCoord2dv": {0: 2},
|
||||||
|
|
||||||
"glRasterPos2dv": {0: 2},
|
"glRasterPos2dv": {0: 2},
|
||||||
"glRasterPos3dv": {0: 3},
|
"glRasterPos3dv": {0: 3},
|
||||||
"glRasterPos4dv": {0: 4},
|
"glRasterPos4dv": {0: 4},
|
||||||
|
|
||||||
"glRasterPos2fv": {0: 2},
|
"glRasterPos2fv": {0: 2},
|
||||||
"glRasterPos3fv": {0: 3},
|
"glRasterPos3fv": {0: 3},
|
||||||
"glRasterPos4fv": {0: 4},
|
"glRasterPos4fv": {0: 4},
|
||||||
|
|
||||||
"glRasterPos2sv": {0: 2},
|
"glRasterPos2sv": {0: 2},
|
||||||
"glRasterPos3sv": {0: 3},
|
"glRasterPos3sv": {0: 3},
|
||||||
"glRasterPos4sv": {0: 4},
|
"glRasterPos4sv": {0: 4},
|
||||||
|
|
||||||
"glTexCoord2fv": {0: 2},
|
"glTexCoord2fv": {0: 2},
|
||||||
"glTexCoord3fv": {0: 3},
|
"glTexCoord3fv": {0: 3},
|
||||||
"glTexCoord4fv": {0: 4},
|
"glTexCoord4fv": {0: 4},
|
||||||
|
|
||||||
"glTexCoord2dv": {0: 2},
|
"glTexCoord2dv": {0: 2},
|
||||||
"glTexCoord3dv": {0: 3},
|
"glTexCoord3dv": {0: 3},
|
||||||
"glTexCoord4dv": {0: 4},
|
"glTexCoord4dv": {0: 4},
|
||||||
|
|
||||||
"glNormal3fv": {0: 3},
|
"glNormal3fv": {0: 3},
|
||||||
"glNormal3dv": {0: 3},
|
"glNormal3dv": {0: 3},
|
||||||
"glNormal3bv": {0: 3},
|
"glNormal3bv": {0: 3},
|
||||||
@@ -84,17 +84,17 @@ import sys
|
|||||||
|
|
||||||
if 0:
|
if 0:
|
||||||
# Examples with LLVM as the root dir: '/dsk/src/llvm'
|
# Examples with LLVM as the root dir: '/dsk/src/llvm'
|
||||||
|
|
||||||
# path containing 'clang/__init__.py'
|
# path containing 'clang/__init__.py'
|
||||||
CLANG_BIND_DIR = "/dsk/src/llvm/tools/clang/bindings/python"
|
CLANG_BIND_DIR = "/dsk/src/llvm/tools/clang/bindings/python"
|
||||||
|
|
||||||
# path containing libclang.so
|
# path containing libclang.so
|
||||||
CLANG_LIB_DIR = "/opt/llvm/lib"
|
CLANG_LIB_DIR = "/opt/llvm/lib"
|
||||||
else:
|
else:
|
||||||
import os
|
import os
|
||||||
CLANG_BIND_DIR = os.environ.get("CLANG_BIND_DIR")
|
CLANG_BIND_DIR = os.environ.get("CLANG_BIND_DIR")
|
||||||
CLANG_LIB_DIR = os.environ.get("CLANG_LIB_DIR")
|
CLANG_LIB_DIR = os.environ.get("CLANG_LIB_DIR")
|
||||||
|
|
||||||
if CLANG_BIND_DIR is None:
|
if CLANG_BIND_DIR is None:
|
||||||
print("$CLANG_BIND_DIR python binding dir not set")
|
print("$CLANG_BIND_DIR python binding dir not set")
|
||||||
if CLANG_LIB_DIR is None:
|
if CLANG_LIB_DIR is None:
|
||||||
@@ -128,7 +128,7 @@ def function_parm_wash_tokens(parm):
|
|||||||
CursorKind.VAR_DECL, # XXX, double check this
|
CursorKind.VAR_DECL, # XXX, double check this
|
||||||
CursorKind.FIELD_DECL,
|
CursorKind.FIELD_DECL,
|
||||||
)
|
)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Return tolens without trailing commads and 'const'
|
Return tolens without trailing commads and 'const'
|
||||||
"""
|
"""
|
||||||
@@ -136,14 +136,14 @@ def function_parm_wash_tokens(parm):
|
|||||||
tokens = [t for t in parm.get_tokens()]
|
tokens = [t for t in parm.get_tokens()]
|
||||||
if not tokens:
|
if not tokens:
|
||||||
return tokens
|
return tokens
|
||||||
|
|
||||||
#if tokens[-1].kind == To
|
# if tokens[-1].kind == To
|
||||||
# remove trailing char
|
# remove trailing char
|
||||||
if tokens[-1].kind == TokenKind.PUNCTUATION:
|
if tokens[-1].kind == TokenKind.PUNCTUATION:
|
||||||
if tokens[-1].spelling in (",", ")", ";"):
|
if tokens[-1].spelling in (",", ")", ";"):
|
||||||
tokens.pop()
|
tokens.pop()
|
||||||
#else:
|
# else:
|
||||||
# print(tokens[-1].spelling)
|
# print(tokens[-1].spelling)
|
||||||
|
|
||||||
t_new = []
|
t_new = []
|
||||||
for t in tokens:
|
for t in tokens:
|
||||||
@@ -157,17 +157,17 @@ def function_parm_wash_tokens(parm):
|
|||||||
ok = False # __restrict
|
ok = False # __restrict
|
||||||
elif t_kind in (TokenKind.COMMENT, ):
|
elif t_kind in (TokenKind.COMMENT, ):
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
# Use these
|
# Use these
|
||||||
elif t_kind in (TokenKind.LITERAL,
|
elif t_kind in (TokenKind.LITERAL,
|
||||||
TokenKind.PUNCTUATION,
|
TokenKind.PUNCTUATION,
|
||||||
TokenKind.IDENTIFIER):
|
TokenKind.IDENTIFIER):
|
||||||
# use but ignore
|
# use but ignore
|
||||||
pass
|
pass
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Unknown!", t_kind, t_spelling)
|
print("Unknown!", t_kind, t_spelling)
|
||||||
|
|
||||||
# if its OK we will add
|
# if its OK we will add
|
||||||
if ok:
|
if ok:
|
||||||
t_new.append(t)
|
t_new.append(t)
|
||||||
@@ -176,9 +176,9 @@ def function_parm_wash_tokens(parm):
|
|||||||
|
|
||||||
def parm_size(node_child):
|
def parm_size(node_child):
|
||||||
tokens = function_parm_wash_tokens(node_child)
|
tokens = function_parm_wash_tokens(node_child)
|
||||||
|
|
||||||
# print(" ".join([t.spelling for t in tokens]))
|
# print(" ".join([t.spelling for t in tokens]))
|
||||||
|
|
||||||
# NOT PERFECT CODE, EXTRACT SIZE FROM TOKENS
|
# NOT PERFECT CODE, EXTRACT SIZE FROM TOKENS
|
||||||
if len(tokens) >= 3: # foo [ 1 ]
|
if len(tokens) >= 3: # foo [ 1 ]
|
||||||
if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and
|
if ((tokens[-3].kind == TokenKind.PUNCTUATION and tokens[-3].spelling == "[") and
|
||||||
@@ -201,7 +201,7 @@ def function_get_arg_sizes(node):
|
|||||||
for i, node_child in enumerate(node_parms):
|
for i, node_child in enumerate(node_parms):
|
||||||
|
|
||||||
# print(node_child.kind, node_child.spelling)
|
# print(node_child.kind, node_child.spelling)
|
||||||
#print(node_child.type.kind, node_child.spelling)
|
# print(node_child.type.kind, node_child.spelling)
|
||||||
if node_child.type.kind == TypeKind.CONSTANTARRAY:
|
if node_child.type.kind == TypeKind.CONSTANTARRAY:
|
||||||
pointee = node_child.type.get_pointee()
|
pointee = node_child.type.get_pointee()
|
||||||
size = parm_size(node_child)
|
size = parm_size(node_child)
|
||||||
@@ -228,14 +228,14 @@ def lookup_function_size_def(func_id):
|
|||||||
|
|
||||||
|
|
||||||
def file_check_arg_sizes(tu):
|
def file_check_arg_sizes(tu):
|
||||||
|
|
||||||
# main checking function
|
# main checking function
|
||||||
def validate_arg_size(node):
|
def validate_arg_size(node):
|
||||||
"""
|
"""
|
||||||
Loop over args and validate sizes for args we KNOW the size of.
|
Loop over args and validate sizes for args we KNOW the size of.
|
||||||
"""
|
"""
|
||||||
assert node.kind == CursorKind.CALL_EXPR
|
assert node.kind == CursorKind.CALL_EXPR
|
||||||
|
|
||||||
if 0:
|
if 0:
|
||||||
print("---",
|
print("---",
|
||||||
" <~> ".join(
|
" <~> ".join(
|
||||||
@@ -243,15 +243,15 @@ def file_check_arg_sizes(tu):
|
|||||||
for C in node.get_children()]
|
for C in node.get_children()]
|
||||||
))
|
))
|
||||||
# print(node.location)
|
# print(node.location)
|
||||||
|
|
||||||
# first child is the function call, skip that.
|
# first child is the function call, skip that.
|
||||||
children = list(node.get_children())
|
children = list(node.get_children())
|
||||||
|
|
||||||
if not children:
|
if not children:
|
||||||
return # XXX, look into this, happens on C++
|
return # XXX, look into this, happens on C++
|
||||||
|
|
||||||
func = children[0]
|
func = children[0]
|
||||||
|
|
||||||
# get the func declaration!
|
# get the func declaration!
|
||||||
# works but we can better scan for functions ahead of time.
|
# works but we can better scan for functions ahead of time.
|
||||||
if 0:
|
if 0:
|
||||||
@@ -263,29 +263,29 @@ def file_check_arg_sizes(tu):
|
|||||||
print("AA", " ".join([t.spelling for t in node.get_tokens()]))
|
print("AA", " ".join([t.spelling for t in node.get_tokens()]))
|
||||||
else:
|
else:
|
||||||
args_size_definition = () # dummy
|
args_size_definition = () # dummy
|
||||||
|
|
||||||
# get the key
|
# get the key
|
||||||
tok = list(func.get_tokens())
|
tok = list(func.get_tokens())
|
||||||
if tok:
|
if tok:
|
||||||
func_id = tok[0].spelling
|
func_id = tok[0].spelling
|
||||||
args_size_definition = lookup_function_size_def(func_id)
|
args_size_definition = lookup_function_size_def(func_id)
|
||||||
|
|
||||||
if not args_size_definition:
|
if not args_size_definition:
|
||||||
return
|
return
|
||||||
|
|
||||||
children = children[1:]
|
children = children[1:]
|
||||||
for i, node_child in enumerate(children):
|
for i, node_child in enumerate(children):
|
||||||
children = list(node_child.get_children())
|
children = list(node_child.get_children())
|
||||||
|
|
||||||
# skip if we dont have an index...
|
# skip if we dont have an index...
|
||||||
size_def = args_size_definition.get(i, -1)
|
size_def = args_size_definition.get(i, -1)
|
||||||
|
|
||||||
if size_def == -1:
|
if size_def == -1:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#print([c.kind for c in children])
|
# print([c.kind for c in children])
|
||||||
# print(" ".join([t.spelling for t in node_child.get_tokens()]))
|
# print(" ".join([t.spelling for t in node_child.get_tokens()]))
|
||||||
|
|
||||||
if len(children) == 1:
|
if len(children) == 1:
|
||||||
arg = children[0]
|
arg = children[0]
|
||||||
if arg.kind in (CursorKind.DECL_REF_EXPR,
|
if arg.kind in (CursorKind.DECL_REF_EXPR,
|
||||||
@@ -295,10 +295,10 @@ def file_check_arg_sizes(tu):
|
|||||||
dec = arg.get_definition()
|
dec = arg.get_definition()
|
||||||
if dec:
|
if dec:
|
||||||
size = parm_size(dec)
|
size = parm_size(dec)
|
||||||
|
|
||||||
# size == 0 is for 'float *a'
|
# size == 0 is for 'float *a'
|
||||||
if size != -1 and size != 0:
|
if size != -1 and size != 0:
|
||||||
|
|
||||||
# nice print!
|
# nice print!
|
||||||
if 0:
|
if 0:
|
||||||
print("".join([t.spelling for t in func.get_tokens()]),
|
print("".join([t.spelling for t in func.get_tokens()]),
|
||||||
@@ -349,8 +349,8 @@ def recursive_arg_sizes(node, ):
|
|||||||
args_sizes = node
|
args_sizes = node
|
||||||
else:
|
else:
|
||||||
args_sizes = function_get_arg_sizes(node)
|
args_sizes = function_get_arg_sizes(node)
|
||||||
#if args_sizes:
|
# if args_sizes:
|
||||||
# print(node.spelling, args_sizes)
|
# print(node.spelling, args_sizes)
|
||||||
_defs[node.spelling] = args_sizes
|
_defs[node.spelling] = args_sizes
|
||||||
# print("adding", node.spelling)
|
# print("adding", node.spelling)
|
||||||
for c in node.get_children():
|
for c in node.get_children():
|
||||||
|
@@ -70,7 +70,7 @@ def main():
|
|||||||
|
|
||||||
def my_process(i, c, cmd):
|
def my_process(i, c, cmd):
|
||||||
if not USE_QUIET:
|
if not USE_QUIET:
|
||||||
percent = 100.0 * (i / (len(check_commands) - 1))
|
percent = 100.0 * (i / len(check_commands))
|
||||||
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
@@ -61,7 +61,7 @@ def main():
|
|||||||
|
|
||||||
def my_process(i, c, cmd):
|
def my_process(i, c, cmd):
|
||||||
if not USE_QUIET:
|
if not USE_QUIET:
|
||||||
percent = 100.0 * (i / (len(check_commands) - 1))
|
percent = 100.0 * (i / len(check_commands))
|
||||||
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
@@ -59,7 +59,7 @@ def main():
|
|||||||
|
|
||||||
def my_process(i, c, cmd):
|
def my_process(i, c, cmd):
|
||||||
if not USE_QUIET:
|
if not USE_QUIET:
|
||||||
percent = 100.0 * (i / (len(check_commands) - 1))
|
percent = 100.0 * (i / len(check_commands))
|
||||||
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
@@ -89,7 +89,7 @@ def main():
|
|||||||
|
|
||||||
def my_process(i, c, cmd):
|
def my_process(i, c, cmd):
|
||||||
if not USE_QUIET:
|
if not USE_QUIET:
|
||||||
percent = 100.0 * (i / (len(check_commands) - 1))
|
percent = 100.0 * (i / len(check_commands))
|
||||||
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
|
||||||
|
|
||||||
sys.stdout.write("%s %s\n" % (percent_str, c))
|
sys.stdout.write("%s %s\n" % (percent_str, c))
|
||||||
|
Reference in New Issue
Block a user