Skip to content

Commit

Permalink
Support multi lines declarations in the parsing of the Fx header files
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sylvestre committed Oct 27, 2017
1 parent d21657a commit 9afeae1
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions components/style/gecko/regen_atoms.py
Expand Up @@ -39,14 +39,14 @@ def msvc32_symbolify(source, ident):


class GkAtomSource:
PATTERN = re.compile('^(GK_ATOM)\((.+),\s*"(.*)"\)')
PATTERN = re.compile('^(GK_ATOM)\(([^,]*),[^"]*"([^"]*)"\)', re.MULTILINE)
FILE = "include/nsGkAtomList.h"
CLASS = "nsGkAtoms"
TYPE = "nsStaticAtom"


class CSSPseudoElementsAtomSource:
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\((.+),\s*"(.*)",')
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\(([^,]*),[^"]*"([^"]*)",', re.MULTILINE)
FILE = "include/nsCSSPseudoElementList.h"
CLASS = "nsCSSPseudoElements"
# NB: nsICSSPseudoElement is effectively the same as a nsStaticAtom, but we need
Expand All @@ -55,7 +55,7 @@ class CSSPseudoElementsAtomSource:


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"
CLASS = "nsCSSAnonBoxes"
TYPE = "nsICSSAnonBoxPseudo"
Expand Down Expand Up @@ -123,10 +123,9 @@ def collect_atoms(objdir):
path = os.path.abspath(os.path.join(objdir, source.FILE))
print("cargo:rerun-if-changed={}".format(path))
with open(path) as f:
for line in f.readlines():
result = re.match(source.PATTERN, line)
if result:
atoms.append(Atom(source, result.group(1), result.group(2), result.group(3)))
content = f.read()
for result in source.PATTERN.finditer(content):
atoms.append(Atom(source, result.group(1), result.group(2), result.group(3)))
return atoms


Expand Down

0 comments on commit 9afeae1

Please sign in to comment.