Change definition-list format to carry more information.

This commit is contained in:
Eric S. Raymond 2008-03-16 10:28:07 +00:00
parent 3b9705905b
commit 4a5a030151
2 changed files with 29 additions and 20 deletions

View file

@ -295,7 +295,7 @@ class CrossRef:
# It's a WML file, scan for macro definitions
dfp = open(filename)
state = "outside"
latch_unit = in_base_unit = False
latch_unit = in_base_unit = in_theme = False
for (n, line) in enumerate(dfp):
if warnlevel > 1:
print `line`[1:-1]
@ -355,22 +355,27 @@ class CrossRef:
else:
print "%s: unbalanced #undef on %s" \
% (Reference(namespace, filename, n+1), name)
elif '[unit]' in line:
latch_unit = True
elif '[/unit]' in line:
latch_unit = False
elif '[base_unit]' in line:
in_base_unit = True
elif '[/base_unit]' in line:
in_base__unit = True
elif latch_unit and not in_base_unit and "id" in line:
m = CrossRef.tag_parse.search(line)
if m and m.group(1) == "id":
uid = m.group(2)
if uid not in self.unit_ids:
self.unit_ids[uid] = []
self.unit_ids[uid].append(Reference(namespace, filename, n+1))
latch_unit= False
if state == 'outside':
if '[unit_type]' in line:
latch_unit = True
elif '[/unit_type]' in line:
latch_unit = False
elif '[base_unit]' in line:
in_base_unit = True
elif '[/base_unit]' in line:
in_base__unit = True
elif '[theme]' in line:
in_theme = True
elif '[/theme]' in line:
in_base__unit = True
elif latch_unit and not in_base_unit and not in_theme and "id" in line:
m = CrossRef.tag_parse.search(line)
if m and m.group(1) == "id":
uid = m.group(2)
if uid not in self.unit_ids:
self.unit_ids[uid] = []
self.unit_ids[uid].append(Reference(namespace, filename, n+1))
latch_unit= False
dfp.close()
elif filename.endswith(".def"):
# It's a list of names to be considered defined

View file

@ -178,7 +178,7 @@ class CrossRefLister(CrossRef):
for ref in value:
print "%s: exported=%s" % (ref, self.exports(ref.namespace))
def typelist(self, branch):
"Dump actual and formal aruments for macros in specified file"
"Dump actual and formal arguments for macros in specified file"
already_seen = []
sorted = self.xref.keys()
sorted.sort()
@ -198,13 +198,17 @@ class CrossRefLister(CrossRef):
for name in sorted:
for defn in self.xref[name]:
if not pred or pred(name, defn):
print name
print "macro", name, " ".join(map(lambda x: "%s=%s" % (x, formaltype(x)), defn.args))
sorted = self.fileref.keys()
sorted.sort()
for name in sorted:
defloc = self.fileref[name]
if not pred or pred(name, defloc):
print name
print "resource", name
sorted = self.unit_ids.keys()
sorted.sort()
for uid in sorted:
print "unit", uid
def unchecked(self, fp):
"List all macro definitions with untyped formals."
unchecked = []