def getFunction(elem): syms = [] name = getters.getName(elem) include = getters.getLocation(elem) params = getters.getParamDesc(elem, getters.getParams(elem)) briefDesc = getters.getBriefDesc(elem) detailedDesc = getters.getFunctionDetailedDesc(elem) returnType = getters.getType(elem) exceptions = getters.getExceptions(elem) returnDesc = getters.getReturnDesc(elem) returnValues = getters.getRetvals(elem) funcProto = buildPrototype(returnType + " " + name + "(", briefDesc) for param in params: proto = param.type + " " + param.name funcProto.prototype += proto + ", " funcProto.addParameter( buildParameter(prototype=proto, description=param.desc)) for ex in exceptions: funcProto.addException( buildException(linkedSymbol=ex.typename, description=ex.description)) if len(params) != 0: funcProto.prototype = funcProto.prototype[:-2] funcProto.prototype += ")" funcProto.addParameter( buildParameter(prototype="return", description=returnDesc)) syms.append( buildFunction(path=name, prototypeObj=funcProto, importString=include)) return syms
def getEnum(elem): syms = [] name = getters.getName(elem) include = getters.getLocation(elem) params = getters.getEnumParams(elem) briefDesc = getters.getBriefDesc(elem) detailedDesc = getters.getDetailedDesc(elem) enumProto = buildPrototype("enum " + name + " { ", briefDesc) for param in params: if param.initializer != "": proto = param.name + param.initializer else: proto = param.name enumProto.prototype += proto + ", " enumProto.addParameter( buildParameter(prototype=proto, description=param.desc)) if len(params) != 0: enumProto.prototype = enumProto.prototype[:-2] enumProto.prototype += " }" enumSym = buildVariable(path=name, prototypeObj=enumProto, importString=include) syms.append(enumSym) return syms
def getClass(classRoot): syms = [] name = getters.getCompoundName(classRoot) name = name[name.find('::') + 2:] include = getters.getLocation(classRoot.find("compounddef")) briefDesc = getters.getBriefDesc(classRoot.find("compounddef")) classProto = buildPrototype("class " + name, briefDesc) classSym = buildClass(path=name, prototypeObj=classProto, importString=include) for elem in classRoot.iter('memberdef'): kind = elem.get('kind') if kind == 'variable': varSyms = getVariable(elem) for varSym in varSyms: classSym.addMember(name + "/" + varSym.path) syms.append(varSym) if kind == 'function': funcSyms = getFunction(elem) for funcSym in funcSyms: classSym.addMember(name + "/" + funcSym.path) syms.append(funcSym) syms.append(classSym) return syms
def parseVariable(root): syms = [] proto = root.get("prot") if (root.get("static") == "yes"): proto = proto + " static" t = root.find("type") tname = "" if (t.find("ref") != None): tname = t.find("ref").text else: tname = root.find("type").text tt = root.find("argsstring").text if (tt == None): logError( "A terrible error in Python XML has been detected: XML lib returned None when the node exists" ) tt = "" proto = proto + " " + tname + " " + root.find("name").text + tt briefDesc = getters.getBriefDesc(root) detailedDesc = getters.getDetailedDesc(root) desc = briefDesc if (len(detailedDesc) > 0): desc = detailedDesc syms.append(buildVariable("", buildPrototype(proto, desc))) return (syms)
def parseTypedef(root): syms = [] proto = root.get("prot") + " " proto = proto + root.find("definition").text syms.append( buildTypedef(path="", prototypeObj=buildPrototype( prototype=proto, description=getters.getDetailedDesc(root)))) return (syms)
def getVariable(elem): syms = [] name = getters.getName(elem) include = getters.getLocation(elem) vtype = getters.getType(elem) value = getters.getInitializer(elem) briefDesc = getters.getBriefDesc(elem) varProto = buildPrototype(name, briefDesc) syms.append( buildVariable(path=name, prototypeObj=varProto, importString=include)) return syms
def getUnion(fileName): root = ET.parse(fileName).getroot() syms = [] name = getters.getCompoundName(root) include = getters.getLocation(root.find("compounddef")) briefDesc = getters.getBriefDesc(root.find("compounddef")) detailedDesc = getters.getDetailedDesc(root.find("compounddef")) unionProto = buildPrototype("struct " + name, briefDesc) unionSym = buildUnion(path=name, prototypeObj=unionProto, importString=include) for elem in root.iter("memberdef"): ename = getters.getName(elem) etype = getters.getType(elem) edesc = getters.getDetailedDesc(elem) proto = buildPrototype(etype + " " + ename, edesc) syms.append( buildVariable(path=(name + "/" + ename), prototypeObj=proto)) unionSym.addMember(name + "/" + ename) syms.append(unionSym) return syms
def getDefine(define): syms = [] name = getters.getName(define) include = getters.getLocation(define) initializer = getters.getInitializer(define) params = getters.getParamDesc(define, getters.getParams(define)) briefDesc = getters.getBriefDesc(define) detailedDesc = getters.getDetailedDesc(define) defineProto = buildPrototype("#define " + name + " " + initializer, briefDesc) syms.append( buildDefine(path=name, prototypeObj=defineProto, importString=include)) return syms
def getTypedef(elem): syms = [] tdType = getters.getType(elem) include = getters.getLocation(elem) try: if elem.find("argsstring").text: tmp = strOp.epurStr(elem.find("argsstring").text) else: return syms tdType = strOp.epurStr(tdType + tmp) except Exception as error: useful.printExceptionVerbose(error) pass tdName = getters.getName(elem) briefDesc = getters.getBriefDesc(elem) detailedDesc = getters.getDetailedDesc(elem) typedefProto = buildPrototype("typedef " + tdName + " " + tdType, briefDesc) syms.append( buildTypedef(path=tdName, prototypeObj=typedefProto, importString=include)) return syms
def parseClass(root): #Obtain generic information about the class cpdef = root.find("compounddef") name = cpdef.find("compoundname").text path = name.replace("::", "/") classProto = cpdef.get("prot") + " " importStr = cpdef.find("location").get("file") isAbstract = cpdef.get("abstract") if (isAbstract == "yes"): classProto = classProto + "abstract " classProto = classProto + "class " + name briefDesc = getters.getBriefDesc(cpdef) detailedDesc = getters.getDetailedDesc(cpdef) description = briefDesc if (len(detailedDesc) > 0): description = detailedDesc templatePars = [] tlist = cpdef.find("templateparamlist") if (tlist != None): for elem in tlist.iter('param'): v = variableClass() v.type = elem.find("type") if (elem.find("declname") == None): #Found bug in Doxygen logWarning( "A terrible error has occured in Doxygen: template is corrupted, attempting restore..." ) txt = v.type.text vals = txt.split(" ") if (len(vals) < 2): logError("Unable to restore corrupted template!") continue v.type = vals[0] v.name = vals[1] logInfo("Successfully restored corrupted template!") else: if (v.type.find("ref") != None): v.ref = v.type.find("ref").get("refid") if (resolveReference(v.ref) != None): v.ref = resolveReference(v.ref).path v.type = v.type.find("ref").text else: v.type = v.type.text v.name = elem.find("declname").text if (elem.find("defval") != None): v.value = elem.find("defval").text templatePars.append(v) if (len(templatePars) > 0): prefix = "template <" for v in templatePars: prefix = prefix + v.type + " " + v.name if (v.value != None and len(v.value) > 0): prefix = prefix + " = " + v.value prefix = prefix + ", " prefix = prefix[:-2] prefix = prefix + ">" classProto = prefix + classProto templatePars = getters.getParamDesc(cpdef, templatePars) #Build a symbol for the class proto = buildPrototype(prototype=classProto, description=description) for v in templatePars: proto.addParameter( buildParameter(prototype=v.type + " " + v.name, description=v.desc)) cl = buildClass(path=path, prototypeObj=proto, importString=importStr) syms = [] for elem in root.iter('memberdef'): kind = elem.get('kind') pp3b = path + "/" + elem.find("name").text cl.addMember(pp3b) syms1 = [] if (kind in kindTable): syms1 = kindTable[kind](elem) for s in syms1: s.typename = "member " + s.typename s.path = pp3b syms.append(s) for elem in root.iter('innerclass'): pp3b = elem.text.replace("::", "/") cl.addMember(pp3b) syms.append(cl) return (syms)