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 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 getDefine(define): name = getters.getName(define) params = getters.getParamDesc(define, getters.getParams(define)) briefDesc = getters.getBriefDesc(define) detailedDesc = getters.getDetailedDesc(define) return buildDefine(path=name, prototypeObj=buildDefinePrototype( name, briefDesc, detailedDesc, params), importString=define.find("location").get("file"))
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 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)
def parseFunction(root): protoPrefix = root.get("prot") if (root.get("static") == "yes"): protoPrefix = protoPrefix + " static" if (root.get("explicit") == "yes"): protoPrefix = protoPrefix + " explicit" if (root.get("inline") == "yes"): protoPrefix = protoPrefix + " inline" virt = root.get("virt") protoSuffix = "" if (root.get("const") == "yes"): protoSuffix = protoSuffix + " const" if (virt == "virtual"): protoPrefix = protoPrefix + " virtual" elif (virt == "pure-virtual"): protoPrefix = protoPrefix + " virtual" protoSuffix = protoSuffix + " = 0" name = getters.getName(root) params = getters.getParamDesc(root, getters.getParams(root)) briefDesc = getters.getBriefDesc(root) tlist = root.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 params.append(v) detailedDesc = getters.getDetailedDesc(root) returnType = root.find("type") if (returnType.find("ref") != None): returnType = returnType.find("ref").text else: returnType = returnType.text if (returnType == None): #XML lib of python is bugged logError( "A terrible error in Python XML has been detected: XML lib returned None when the node exists" ) returnType = "" returnDesc = getters.getReturnDesc(root) exceptions = getters.getExceptions(root) func = buildFunctionPrototype(protoPrefix, protoSuffix, name, returnType, briefDesc, detailedDesc, params, returnDesc, exceptions) func = buildFunction("", func) if (returnType == ""): func.typename = "constructor" return ([func])