diff options
author | Xidorn Quan <me@upsuper.org> | 2016-11-03 15:01:46 +1100 |
---|---|---|
committer | Xidorn Quan <me@upsuper.org> | 2016-11-03 15:01:46 +1100 |
commit | e8a3d935ad0ffccb1ca64359364f53e9ee66b44c (patch) | |
tree | d1c8119ab0f180bb834a354effb32209a7bf031f /components/style/binding_tools | |
parent | eb3bbc6bb9fafd8c65433d4564dceafbb7d5511f (diff) | |
download | servo-e8a3d935ad0ffccb1ca64359364f53e9ee66b44c.tar.gz servo-e8a3d935ad0ffccb1ca64359364f53e9ee66b44c.zip |
Add static atoms for CSS properties from Gecko
Diffstat (limited to 'components/style/binding_tools')
-rwxr-xr-x | components/style/binding_tools/regen_atoms.py | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/components/style/binding_tools/regen_atoms.py b/components/style/binding_tools/regen_atoms.py index 6fe30f73507..5af58417b3d 100755 --- a/components/style/binding_tools/regen_atoms.py +++ b/components/style/binding_tools/regen_atoms.py @@ -32,14 +32,14 @@ def msvc32_symbolify(source, ident): class GkAtomSource: - PATTERN = re.compile('^GK_ATOM\((.+),\s*"(.*)"\)') + PATTERN = re.compile('^GK_ATOM\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M) FILE = "dist/include/nsGkAtomList.h" CLASS = "nsGkAtoms" TYPE = "nsIAtom" class CSSPseudoElementsAtomSource: - PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((.+),\s*"(.*)",') + PATTERN = re.compile('^CSS_PSEUDO_ELEMENT\((?P<ident>.+),\s*"(?P<value>.*)",', re.M) FILE = "dist/include/nsCSSPseudoElementList.h" CLASS = "nsCSSPseudoElements" # NB: nsICSSPseudoElement is effectively the same as a nsIAtom, but we need @@ -48,16 +48,24 @@ class CSSPseudoElementsAtomSource: class CSSAnonBoxesAtomSource: - PATTERN = re.compile('^CSS_ANON_BOX\((.+),\s*"(.*)"\)') + PATTERN = re.compile('^CSS_ANON_BOX\((?P<ident>.+),\s*"(?P<value>.*)"\)', re.M) FILE = "dist/include/nsCSSAnonBoxList.h" CLASS = "nsCSSAnonBoxes" TYPE = "nsICSSAnonBoxPseudo" +class CSSPropsAtomSource: + PATTERN = re.compile('^CSS_PROP_[A-Z]+\(\s*(?P<value>[^,]+),\s*(?P<ident>[^,]+)', re.M) + FILE = "dist/include/nsCSSPropList.h" + CLASS = "nsCSSProps" + TYPE = "nsICSSProperty" + + SOURCES = [ GkAtomSource, CSSPseudoElementsAtomSource, CSSAnonBoxesAtomSource, + CSSPropsAtomSource, ] @@ -95,10 +103,14 @@ def collect_atoms(objdir): atoms = [] for source in SOURCES: with open(os.path.join(objdir, source.FILE)) 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))) + content = f.read() + found = set() + for match in source.PATTERN.finditer(content): + ident = match.group('ident') + if ident in found: + continue + found.add(ident) + atoms.append(Atom(source, ident, match.group('value'))) return atoms |