Beat wmlscope into not complaining about multiple definitions...

...of the carryover macros (they're conditionalized, but wmlscope
cannot know this).
This commit is contained in:
Eric S. Raymond 2008-09-30 01:09:12 +00:00
parent 71b25fa5e0
commit c014cbe185
3 changed files with 28 additions and 0 deletions

View file

@ -1,5 +1,8 @@
#textdomain wesnoth
# These aren't actually macros, but they need to go somewhere anyway.
# The wmlscope pragmas prevent spurious complaints about multiple definitions
#ifdef EASYNEWCARRYOVER
#define EASY
#enddef
@ -7,6 +10,8 @@
#enddef
#endif
# wmlscope: start ignoring
#ifdef NORMALNEWCARRYOVER
#define NORMAL
#enddef
@ -21,6 +26,8 @@
#enddef
#endif
# wmlscope: stop ignoring
# These are used in scenarios, to include the carryover-defining keys into
# [endlevel]s and to show the carryover details in the objectives dialog.
@ -42,10 +49,12 @@
20% of finishing gold carried over to the next scenario."
#enddef
#else
# wmlscope: start ignoring
#define NEW_GOLD_CARRYOVER_NOTE_40
""
#enddef
#define NEW_GOLD_CARRYOVER_NOTE_20
""
#enddef
# wmlscope: stop ignoring
#endif

View file

@ -305,6 +305,7 @@ class CrossRef:
self.noxref = False
self.properties = {}
self.unit_ids = {}
ignoreflag = False
if warnlevel >=2:
print "*** Beginning definition-gathering pass..."
for (namespace, filename) in self.filelist.generator():
@ -335,6 +336,18 @@ class CrossRef:
if namespace not in self.properties:
self.properties[namespace] = {}
self.properties[namespace][prop] = value
if "# wmlscope: start ignoring" in line:
if warnlevel:
print '"%s", line %d: starting ignoring' \
% (filename, n+1)
ignoreflag = True
elif "# wmlscope: stop ignoring" in line:
if warnlevel:
print '"%s", line %d: stopping ignoring' \
% (filename, n+1)
ignoreflag = False
elif ignoreflag:
continue
if line.strip().startswith("#define"):
tokens = line.split()
name = tokens[1]

View file

@ -31,6 +31,12 @@
# somewhere. wmlscope will complain when it sees a nam,espace with no export
# property, then treat it as non-exporting.
#
# You can tell wmlscope to ignore stretches of config files
# with the following magic comments?
#
# # wmlscope: start ignoring
# # wmlscope: stop ignoring
#
# This tool does catch one kind of implicit reference: if an attack name
# is specified but no icon is given, the attack icon will default to
# a name generated from the attack name. This behavior can be suppressed