Hash :
963d2ae4
Author :
Date :
2002-01-20T22:08:18
cleanup patch from Anthony Jones fix the headers to avoid in make scan * SAX.c: cleanup patch from Anthony Jones * doc/Makefile.am: fix the headers to avoid in make scan * parserInternals.c xpath.c include/libxml/*.h: cleanup of the includes, * vs Ptr and general cleanup * parsedecl.py: first version of a script to extract the module interfaces, the goal will be to provide .decl or XML specification of the interfaces to build wrappers. Daniel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
#!/usr/bin/python -u
#
# tries to parse the output of gtk-doc declaration files and make
# something usable from them
#
import sys
import string
input = open('doc/libxml-decl.txt')
macros = []
structs = []
typedefs = []
enums = {}
functions = {}
private_functions = {}
types = {}
def extractTypes(raw, function):
global types
tokens = string.split(raw)
type = ''
for token in tokens:
if type != '':
type = type + ' ' + token
else:
type = token
if types.has_key(type):
types[type].append(function)
else:
types[type] = [function]
return type
def parseMacro():
global input
global macros
line = input.readline()[:-1]
while line != "</MACRO>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
line = input.readline()[:-1]
macros.append(name)
def parseStruct():
global input
global structs
line = input.readline()[:-1]
while line != "</STRUCT>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
line = input.readline()[:-1]
structs.append(name)
def parseTypedef():
global input
global typedefs
line = input.readline()[:-1]
while line != "</TYPEDEF>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
line = input.readline()[:-1]
typedefs.append(name)
def parseEnum():
global input
global enums
line = input.readline()[:-1]
consts = []
while line != "</ENUM>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
elif string.find(line, 'enum') >= 0:
pass
elif string.find(line, '{') >= 0:
pass
elif string.find(line, '}') >= 0:
pass
elif string.find(line, ';') >= 0:
pass
else:
comment = string.find(line, '/*')
if comment >= 0:
line = line[0:comment]
decls = string.split(line, ",")
for decl in decls:
val = string.split(decl, "=")[0]
tokens = string.split(val)
if len(tokens) >= 1:
token = tokens[0]
if string.find(string.letters, token[0]) >= 0:
consts.append(token)
line = input.readline()[:-1]
enums[name] = consts
def parseStaticFunction():
global input
global private_functions
line = input.readline()[:-1]
type = None
signature = None
while line != "</USER_FUNCTION>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
elif line[0:9] == "<RETURNS>" and line[-10:] == "</RETURNS>":
type = extractTypes(line[9:-10], name)
else:
signature = line
line = input.readline()[:-1]
args = string.split(signature, ",")
sig = []
for arg in args:
l = string.split(arg)
sig.append(extractTypes(l[0], name))
private_functions[name] = (type , sig)
def parseFunction():
global input
global functions
line = input.readline()[:-1]
type = None
signature = None
while line != "</FUNCTION>":
if line[0:6] == "<NAME>" and line[-7:] == "</NAME>":
name = line[6:-7]
elif line[0:9] == "<RETURNS>" and line[-10:] == "</RETURNS>":
type = extractTypes(line[9:-10], name)
else:
signature = line
line = input.readline()[:-1]
args = string.split(signature, ",")
sig = []
for arg in args:
l = string.split(arg)
sig.append(extractTypes(l[0], name))
functions[name] = (type , sig)
while 1:
line = input.readline()
if not line:
break
line = line[:-1]
if line == "<MACRO>":
parseMacro()
elif line == "<ENUM>":
parseEnum()
elif line == "<FUNCTION>":
parseFunction()
elif line == "<STRUCT>":
parseStruct()
elif line == "<TYPEDEF>":
parseTypedef()
elif line == "<USER_FUNCTION>":
parseStaticFunction()
elif len(line) >= 1 and line[0] == "<":
print "unhandled %s" % (line)
print "Parsed: %d macros. %d structs, %d typedefs, %d enums" % (
len(macros), len(structs), len(typedefs), len(enums))
c = 0
for enum in enums.keys():
consts = enums[enum]
c = c + len(consts)
print " %d constants, %d functions and %d private functions" % (
c, len(functions.keys()), len(private_functions.keys()))
print "The functions uses %d different types" % (len(types.keys()))
for type in types.keys():
if string.find(type, '*') >= 0 or (type[0:3] != 'xml' and
type[0:4] != 'html' and type[0:4] != 'docb'):
# print " %s : %s" % (type, types[type])
print " %s" % (type)