Impprove reporting of type mismatches. Fix a few more formal args.
This commit is contained in:
parent
a600ade30e
commit
fc045b288e
5 changed files with 25 additions and 15 deletions
|
@ -65,12 +65,12 @@
|
|||
[/unit]
|
||||
#enddef
|
||||
|
||||
#define UNDEAD_INTEL TYPE DESCRIPTION USER_DESCRIPTION PROFILE SIDE X Y
|
||||
#define UNDEAD_INTEL TYPE DESCRIPTION USER_DESCRIPTION STRING SIDE X Y
|
||||
[unit]
|
||||
type={TYPE}
|
||||
description={DESCRIPTION}
|
||||
user_description={USER_DESCRIPTION}
|
||||
profile={PROFILE}
|
||||
profile={STRING}
|
||||
side={SIDE}
|
||||
x={X}
|
||||
y={Y}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#textdomain wesnoth-multiplayer
|
||||
[multiplayer]
|
||||
#define UNIT_STONE TYPE NAME X Y
|
||||
#define UNIT_STONE TYPE USER_DESCRIPTION X Y
|
||||
type={TYPE}
|
||||
user_description={NAME}
|
||||
user_description={USER_DESCRIPTION}
|
||||
x={X}
|
||||
y={Y}
|
||||
unrenamable=yes
|
||||
|
@ -119,7 +119,7 @@ Marksman known as Dragonbane
|
|||
[/unit]
|
||||
|
||||
[unit]
|
||||
{UNIT_STONE "Direwolf Rider" _"Blum Duk" 10 17}
|
||||
{UNIT_STONE "Direwolf Rider" (_"Blum Duk") 10 17}
|
||||
|
||||
unit_description=_ "Blum Duk was renowned among his goblin clan for having tamed one of the Dire Wolves of the mountains, and he had the courage to match. His leadership and skills alone were what kept the area's goblins alive despite human and elvish menaces. Rumor had it that his wolf had slain fifty men and a hundred Elves.
|
||||
Thus, when he heard of the awful monster that was inhabiting the area, it was only natural that he ride out alone to face it. All the other goblins expected him to slay the creature easily and drag back its carcass to feast on.
|
||||
|
|
|
@ -1042,9 +1042,9 @@
|
|||
[/terrain_mask]
|
||||
#enddef
|
||||
|
||||
#define WEATHER_ALERT MESSAGE RED GREEN BLUE
|
||||
#define WEATHER_ALERT TEXT RED GREEN BLUE
|
||||
[print]
|
||||
text= {MESSAGE}
|
||||
text= {TEXT}
|
||||
duration=120
|
||||
size=26
|
||||
red={RED}
|
||||
|
|
|
@ -62,15 +62,19 @@ def isresource(filename):
|
|||
|
||||
def formaltype(f):
|
||||
# Deduce the expected type of the formal
|
||||
if f in ("SIDE", "X", "Y"):
|
||||
if f in ("SIDE", "X", "Y", "AMOUNT", "RED", "GREEN", "BLUE", "NUMBER", "TURN", "RADIUS"):
|
||||
ftype = "numeric"
|
||||
elif f in ("XSPAN", "YSPAN", "SPAN"):
|
||||
elif f in ("POSITION",):
|
||||
ftype = "position"
|
||||
elif f in ("XSPAN", "YSPAN"):
|
||||
ftype = "span"
|
||||
elif f in ("RANGE",):
|
||||
ftype = "range"
|
||||
elif f in ("TYPE", "DESCRIPTION", "USER_DESCRIPTION", "TERRAIN"):
|
||||
elif f in ("NAME", "VAR"):
|
||||
ftype = "name"
|
||||
elif f in ("TYPE", "DESCRIPTION", "USER_DESCRIPTION", "TERRAIN", "TEXT"):
|
||||
ftype = "string"
|
||||
elif f.endswith("IMAGE"):
|
||||
elif f.endswith("IMAGE") or f == "PROFILE":
|
||||
ftype = "image"
|
||||
elif f in ("FILTER",):
|
||||
ftype = "filter"
|
||||
|
@ -82,6 +86,8 @@ def actualtype(a):
|
|||
# Deduce the type of the actual
|
||||
if a.isdigit() or a.startswith("-") and a[1:].isdigit():
|
||||
atype = "numeric"
|
||||
elif re.match(r"[0-9]+,[0-9]+\Z", a):
|
||||
atype = "position"
|
||||
elif re.match(r"([0-9]+\-[0-9]+,?|[0-9]+,?)+\Z", a):
|
||||
atype = "span"
|
||||
elif a in ("melee", "ranged"):
|
||||
|
@ -90,8 +96,12 @@ def actualtype(a):
|
|||
atype = None # Can't tell -- it's a macro expansion
|
||||
elif a.endswith(".png") or a.endswith(".jpg"):
|
||||
atype = "image"
|
||||
elif a.startswith('"') and a.endswith('"'):
|
||||
atype = "stringliteral"
|
||||
elif "=" in a:
|
||||
atype = "filter"
|
||||
elif not ' ' in a:
|
||||
atype = "name"
|
||||
else:
|
||||
atype = "string"
|
||||
return atype
|
||||
|
@ -106,9 +116,9 @@ def argmatch(formals, actuals):
|
|||
# in which a more restricted actual type matches a more general
|
||||
# formal one. Then we have a fallback rule checking for type
|
||||
# equality or wildcarding.
|
||||
if atype == "numeric" and ftype == "span":
|
||||
if atype in ("numeric", "position") and ftype == "span":
|
||||
pass
|
||||
elif atype == "image" and ftype == "string":
|
||||
elif atype in ("name", "stringliteral") and ftype == "string":
|
||||
pass
|
||||
elif atype != ftype and ftype is not None and atype is not None:
|
||||
return False
|
||||
|
|
|
@ -139,10 +139,10 @@ class CrossRefLister(CrossRef):
|
|||
if mismatched:
|
||||
print "# Mismatched references:"
|
||||
for (n, m) in mismatched:
|
||||
print "%s: macro %s(%s) has signature (%s) mismatches:" % (m, n, ", ".join(m.args), ", ".join(map(lambda x: str(formaltype(x)), m.args)))
|
||||
print "%s: macro %s(%s) has mismatches:" % (m, n, ", ".join(map(lambda x: "%s=%s" % (x, formaltype(x)), m.args)))
|
||||
for (file, refs) in m.references.items():
|
||||
for (ln, args) in refs:
|
||||
print '"%s", line %d: %s(%s) with signature (%s)' % (file, ln, n, ", ".join(args), ", ".join(map(lambda x: str(actualtype(x)), args)))
|
||||
print '"%s", line %d: %s(%s) with signature (%s)' % (file, ln, n, ", ".join(args), ", ".join(map(lambda f, a: "%s=%s" % (f, actualtype(a)), m.args, args)))
|
||||
def deflist(self, pred=None):
|
||||
"List all resource definitions."
|
||||
sorted = self.xref.keys()
|
||||
|
|
Loading…
Add table
Reference in a new issue