Skip to content

Commit

Permalink
style: Generate static atom hash in StaticAtoms.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
heycam authored and emilio committed Aug 18, 2018
1 parent f86e9a4 commit cc18975
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions components/style/gecko/regen_atoms.py
Expand Up @@ -24,7 +24,8 @@
"""[1:] # NOQA: E501


PATTERN = re.compile('^GK_ATOM\(([^,]*),[^"]*"([^"]*)",\s*([^,]*),\s*([^)]*)\)',
# Matches lines like `GK_ATOM(foo, "foo", 0x12345678, nsStaticAtom, PseudoElementAtom)`.
PATTERN = re.compile('^GK_ATOM\(([^,]*),[^"]*"([^"]*)",\s*(0x[0-9a-f]+),\s*([^,]*),\s*([^)]*)\)',
re.MULTILINE)
FILE = "include/nsGkAtomList.h"
CLASS = "nsGkAtoms"
Expand Down Expand Up @@ -52,10 +53,11 @@ def map_atom(ident):


class Atom:
def __init__(self, ident, value, ty, atom_type):
def __init__(self, ident, value, hash, ty, atom_type):
self.ident = "{}_{}".format(CLASS, ident)
self.original_ident = ident
self.value = value
self.hash = hash
# The Gecko type: "nsStaticAtom", "nsICSSPseudoElement", or "nsIAnonBoxPseudo"
self.ty = ty
# The type of atom: "Atom", "PseudoElement", "NonInheritingAnonBox",
Expand Down Expand Up @@ -104,7 +106,8 @@ def collect_atoms(objdir):
with open(path) as f:
content = f.read()
for result in PATTERN.finditer(content):
atoms.append(Atom(result.group(1), result.group(2), result.group(3), result.group(4)))
atoms.append(Atom(result.group(1), result.group(2), result.group(3),
result.group(4), result.group(5)))
return atoms


Expand Down

0 comments on commit cc18975

Please sign in to comment.