Support multi lines declarations in the parsing of the Fx header files

For example, in dom/base/nsGkAtomList.h, we currently have:
GK_ATOM(mouseWheel, "mouseWheel")  // For discrete wheel events (e.g. not OSX magic mouse)
but if we change to
GK_ATOM(mouseWheel,
        "mouseWheel")  // For discrete wheel events (e.g. not OSX magic mouse)
The parser didn't handle the declaration
This commit is contained in:
Sylvestre Ledru 2017-10-27 15:59:12 +02:00
parent d21657a9e5
commit 6d6a68b5b1

View file

@ -39,14 +39,16 @@ def msvc32_symbolify(source, ident):
class GkAtomSource: class GkAtomSource:
PATTERN = re.compile('^(GK_ATOM)\((.+),\s*"(.*)"\)') PATTERN = re.compile('^(GK_ATOM)\(([^,]*),[^"]*"([^"]*)"\)',
re.MULTILINE)
FILE = "include/nsGkAtomList.h" FILE = "include/nsGkAtomList.h"
CLASS = "nsGkAtoms" CLASS = "nsGkAtoms"
TYPE = "nsStaticAtom" TYPE = "nsStaticAtom"
class CSSPseudoElementsAtomSource: class CSSPseudoElementsAtomSource:
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\((.+),\s*"(.*)",') PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\(([^,]*),[^"]*"([^"]*)",',
re.MULTILINE)
FILE = "include/nsCSSPseudoElementList.h" FILE = "include/nsCSSPseudoElementList.h"
CLASS = "nsCSSPseudoElements" CLASS = "nsCSSPseudoElements"
# NB: nsICSSPseudoElement is effectively the same as a nsStaticAtom, but we need # NB: nsICSSPseudoElement is effectively the same as a nsStaticAtom, but we need
@ -55,7 +57,8 @@ class CSSPseudoElementsAtomSource:
class CSSAnonBoxesAtomSource: class CSSAnonBoxesAtomSource:
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\((.+),\s*"(.*)"\)') PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\(([^,]*),[^"]*"([^"]*)"\)',
re.MULTILINE)
FILE = "include/nsCSSAnonBoxList.h" FILE = "include/nsCSSAnonBoxList.h"
CLASS = "nsCSSAnonBoxes" CLASS = "nsCSSAnonBoxes"
TYPE = "nsICSSAnonBoxPseudo" TYPE = "nsICSSAnonBoxPseudo"
@ -123,10 +126,9 @@ def collect_atoms(objdir):
path = os.path.abspath(os.path.join(objdir, source.FILE)) path = os.path.abspath(os.path.join(objdir, source.FILE))
print("cargo:rerun-if-changed={}".format(path)) print("cargo:rerun-if-changed={}".format(path))
with open(path) as f: with open(path) as f:
for line in f.readlines(): content = f.read()
result = re.match(source.PATTERN, line) for result in source.PATTERN.finditer(content):
if result: atoms.append(Atom(source, result.group(1), result.group(2), result.group(3)))
atoms.append(Atom(source, result.group(1), result.group(2), result.group(3)))
return atoms return atoms