More macro argument type checking. No mismatches in mainline.

This commit is contained in:
Eric S. Raymond 2010-02-15 14:32:20 +00:00
parent 9763823c87
commit 380c8e86e7
6 changed files with 34 additions and 27 deletions

View file

@ -52,12 +52,12 @@
villages_per_scout=0
#enddef
#define RANDOM THING
#define RANDOM THING_VALUE
# Macro to quickly pick a random value (in the $random variable, to avoid
# cluttering up savegames with such temporary variables).
[set_variable]
name=random
rand={THING}
rand={THING_VALUE}
[/set_variable]
#enddef
@ -413,7 +413,7 @@
{CLEAR_VARIABLE TIME_ACTIONS_time_end}
#enddef
#define RECRUIT_UNIT_VARIATIONS SIDE TYPE VARIATIONS
#define RECRUIT_UNIT_VARIATIONS SIDE TYPE VARIATIONS_VALUE
# Allows a side to seemingly recruit variations of a given unit, such as the
# the Walking Corpse.
#
@ -429,7 +429,7 @@
type={TYPE}
[/filter]
{VARIABLE_OP recruited_unit_random_variation rand {VARIATIONS}}
{VARIABLE_OP recruited_unit_random_variation rand {VARIATIONS_VALUE}}
[if]
[variable]
@ -566,9 +566,8 @@
[/else]
[/if]
[/event]
#enddef
#define SCATTER_UNITS NUMBER TYPES PADDING_RADIUS SLF UNIT
#enddef
#define SCATTER_UNITS NUMBER TYPES PADDING_RADIUS FILTER UNIT_WML
# Scatters the given kind of units randomly on a given area on the map.
#
# An example which scatters some loyal elves on forest hexes in
@ -601,7 +600,7 @@
#! )}
[store_locations]
{SLF}
{FILTER}
variable=possible_unit_locations
[/store_locations]
@ -635,7 +634,7 @@
[unit]
type=$unit_type_table[$unit_type_table_i].type
x,y=$possible_unit_locations[$random_subscript].x,$possible_unit_locations[$random_subscript].y
{UNIT}
{UNIT_WML}
[/unit]
[store_locations]

View file

@ -54,7 +54,7 @@
#enddef
#Macro for Single Hex with double overlay
#define SHEX_DOUBLE TYPE FLAG PROB TILE1 TILE2
#define SHEX_DOUBLE TYPE FLAG PROB TILE1_NAME TILE2_NAME
[terrain_graphics]
map="
, *
@ -73,17 +73,17 @@
probability={PROB}
[image]
name={TILE1}
name={TILE1_NAME}
base=90,146
[/image]
[image]
name={TILE2}
name={TILE2_NAME}
base=90,146
[/image]
[/terrain_graphics]
#enddef
#define SHEX_LAYER TYPE FLAG LAYER PROB TILE
#define SHEX_LAYER TYPE FLAG LAYER PROB TILE_NAME
[terrain_graphics]
map="
, *
@ -102,7 +102,7 @@
probability={PROB}
[image]
name={TILE}
name={TILE_NAME}
layer={LAYER}
base=90,146
[/image]

View file

@ -26,7 +26,9 @@
[/terrain_graphics]
#enddef
#define SINGLE_FOREST_TILE_RESTRICTED TERRAINLIST RESTRICTING PROB IMAGESTEM
#define SINGLE_FOREST_TILE_RESTRICTED TERRAINLIST ADJACENT PROB IMAGESTEM
# The ADJACENT argument here was originally RESTRICTING.
# It's been changed in order to allow wmlscope to do better type checking.
[terrain_graphics]
map="
, 2
@ -43,7 +45,7 @@
[tile]
pos=2
type={RESTRICTING}
type={ADJACENT}
[/tile]
probability={PROB}
@ -58,9 +60,11 @@
[/terrain_graphics]
#enddef
#define SIMPLE_FOREST_TERRAIN TERRAINLIST RESTRICTING IMAGESTEM
{SINGLE_FOREST_TILE_RESTRICTED {TERRAINLIST} {RESTRICTING} 50 {IMAGESTEM}-small-2}
{SINGLE_FOREST_TILE_RESTRICTED {TERRAINLIST} {RESTRICTING} 100 {IMAGESTEM}-small}
#define SIMPLE_FOREST_TERRAIN TERRAINLIST ADJACENT IMAGESTEM
# The ADJACENT argument here was originally RESTRICTING.
# It's been changed in order to allow wmlscope to do better type checking.
{SINGLE_FOREST_TILE_RESTRICTED {TERRAINLIST} {ADJACENT} 50 {IMAGESTEM}-small-2}
{SINGLE_FOREST_TILE_RESTRICTED {TERRAINLIST} {ADJACENT} 100 {IMAGESTEM}-small}
{SINGLE_FOREST_TILE {TERRAINLIST} 25 {IMAGESTEM}-4}
{SINGLE_FOREST_TILE {TERRAINLIST} 33 {IMAGESTEM}-3}
{SINGLE_FOREST_TILE {TERRAINLIST} 50 {IMAGESTEM}-2}

View file

@ -1,9 +1,9 @@
#textdomain wesnoth-anl
#define CONDITION VAR TEST VALUE
#define CONDITION VAR TEST_NAME VALUE
[variable]
name={VAR}
{TEST}={VALUE}
{TEST_NAME}={VALUE}
[/variable]
#enddef
@ -43,9 +43,9 @@
[/removeitem]
#enddef
#define PLAY_SOUND SOUND_FILE
#define PLAY_SOUND SOUND
[sound]
name={SOUND_FILE}
name={SOUND}
[/sound]
#enddef

View file

@ -13,14 +13,14 @@
[/gold]
#enddef
#define ANL_SHOW_IF TYPE LETTERS
#define ANL_SHOW_IF TYPE TERRAIN_PATTERN
[show_if]
[have_unit]
side=$side_number
x,y=$x1,$y1
type={TYPE}
[filter_location]
terrain={LETTERS}
terrain={TERRAIN_PATTERN}
[/filter_location]
[/have_unit]
[/show_if]

View file

@ -145,7 +145,7 @@ def formaltype(f):
# Deduce the expected type of the formal
if f.startswith("_"):
f = f[1:]
if f in ("SIDE", "X", "Y", "RED", "GREEN", "BLUE", "TURN", "RADIUS", "PROB", "LAYER", "TIME") or f.endswith("_SIDE") or f.endswith("NUMBER") or f.endswith("AMOUNT") or f.endswith("COST") or f.endswith("_X") or f.endswith("_Y") or f.endswith("_INCREMENT") or f.endswith("_FACTOR") or f.endswith("_TIME") or f.endswith("_SIZE"):
if f in ("SIDE", "X", "Y", "RED", "GREEN", "BLUE", "TURN", "PROB", "LAYER", "TIME") or f.endswith("_SIDE") or f.endswith("NUMBER") or f.endswith("AMOUNT") or f.endswith("COST") or f.endswith("RADIUS") or f.endswith("_X") or f.endswith("_Y") or f.endswith("_INCREMENT") or f.endswith("_FACTOR") or f.endswith("_TIME") or f.endswith("_SIZE"):
ftype = "numeric"
elif f in ("POSITION",) or f.endswith("_POSITION") or f == "BASE":
ftype = "position"
@ -157,9 +157,11 @@ def formaltype(f):
ftype = "range"
elif f in ("ALIGN",):
ftype = "alignment"
elif f in ("TYPES",):
ftype = "types"
elif f == "TERRAIN":
ftype = "terrain_code"
elif f.startswith("ADJACENT") or f.startswith("TERRAINLIST") or f == "TERRAIN_PATTERN":
elif f.startswith("ADJACENT") or f.startswith("TERRAINLIST") or f.endswith("TERRAIN_PATTERN"):
ftype = "terrain_pattern"
elif f in ("NAME", "VAR", "IMAGESTEM", "ID", "FLAG") or f.endswith("_NAME") or f.endswith("_ID"):
ftype = "name"
@ -247,6 +249,8 @@ def argmatch(formals, actuals):
pass
elif atype in ("terrain_code", "shortname", "name") and ftype == "terrain_pattern":
pass
elif atype in ("string", "shortname", "name") and ftype == "types":
pass
elif atype != ftype and ftype is not None and atype is not None:
return False
return True