Commit e69b08ae authored by Gaurav Kukreja's avatar Gaurav Kukreja

Also annotating function signatures in header files

Signed-off-by: Gaurav Kukreja's avatarGaurav Kukreja <gaurav@gauravk.in>
parent 32c43004
......@@ -196,6 +196,39 @@ def annotateVarFuncDecl(listISCFileNames, listISCFunctions, listGlobalVariables,
annot)
continue
m = re_FuncDeclStart.match(line)
if m is not None:
currFunctionName = m.group("name")
currFuncRetType = m.group("retType")
assert(m.group("openBrace") is not None)
logging.debug(" Function : " + currFunctionName)
funcISC = find(lambda fn: fn.functionName == currFunctionName,
listISCFunctions)
if funcISC.listParams:
# Create a list of new parameters for the annotated function signature
# Add <name>_addr parameter for each param that is a pointer
newFuncParamsList = []
for param in funcISC.listParams:
newFuncParamsList.append(param.type + param.name + param.len)
if param.isPointer:
newFuncParamsList.append("unsigned long " + param.name + "_addr")
# create the new annotation
annotatedFuncDecl = currFuncRetType + " " + currFunctionName + " ("
for param in newFuncParamsList[:-1]:
annotatedFuncDecl = annotatedFuncDecl + param + ", "
annotatedFuncDecl = annotatedFuncDecl + newFuncParamsList[-1] + ")"
annot = Annotation(annotatedFuncDecl,
ISCFileName,
lineNum,
replace = True)
addAnnotationToDict(dictAnnotVarFuncDecl,
lineNum,
annot)
continue
m = re_BlockEndRBrace.match(line)
if m is not None and inFunction == 1:
inFunction = 0
......
......@@ -15,5 +15,4 @@ struct adpcm_state {
#define ARGS(x) ()
#endif
void adpcm_coder ARGS((short [], char [], int, struct adpcm_state *));
void adpcm_decoder ARGS((char [], short [], int, struct adpcm_state *));
void adpcm_coder (short [], char [], int, struct adpcm_state *);
......@@ -36,6 +36,8 @@ FuncParams = "(?:(?:%s)(?:\s*,\s*(?:%s))*)" % (VarSpec_, VarSpec_)
RetTypes = "(?:%s)|void" % (DataTypes)
re_FuncDefStart = re.compile("\s*(?P<retType>%s)?\s*(?P<name>\w*)\s*\((?P<params>%s)?(?:(?P<endComma>,)|(?P<openBrace>\)\s*\{))" % (RetTypes, FuncParams))
re_FuncDefArgLine = re.compile("\s*(?P<params>%s)(?:(?P<endComma>,)|(?P<openBrace>\)\s*\{))" % (FuncParams))
re_FuncDeclStart = re.compile("\s*(?P<retType>%s)?\s*(?P<name>\w*)\s*\((?P<params>%s)?(?:(?P<endComma>,)|(?P<openBrace>\)\s*;))" % (RetTypes, FuncParams))
# Label
re_Label = re.compile("\s*(?P<label>\w*):")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment