mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
style: Define atom type in nsGkAtomList.h.
Differential Revision: https://phabricator.services.mozilla.com/D3282
This commit is contained in:
parent
064252437b
commit
cc3c059bfc
1 changed files with 11 additions and 9 deletions
|
@ -39,7 +39,7 @@ def msvc32_symbolify(source, ident):
|
||||||
|
|
||||||
|
|
||||||
class GkAtomSource:
|
class GkAtomSource:
|
||||||
PATTERN = re.compile('^(GK_ATOM)\(([^,]*),[^"]*"([^"]*)"\)',
|
PATTERN = re.compile('^(GK_ATOM)\(([^,]*),[^"]*"([^"]*)",\s*([^)]*)\)',
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
FILE = "include/nsGkAtomList.h"
|
FILE = "include/nsGkAtomList.h"
|
||||||
CLASS = "nsGkAtoms"
|
CLASS = "nsGkAtoms"
|
||||||
|
@ -47,7 +47,7 @@ class GkAtomSource:
|
||||||
|
|
||||||
|
|
||||||
class CSSPseudoElementsAtomSource:
|
class CSSPseudoElementsAtomSource:
|
||||||
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\(([^,]*),[^"]*"([^"]*)",',
|
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\(([^,]*),[^"]*"([^"]*)",()',
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
FILE = "include/nsCSSPseudoElementList.h"
|
FILE = "include/nsCSSPseudoElementList.h"
|
||||||
CLASS = "nsCSSPseudoElements"
|
CLASS = "nsCSSPseudoElements"
|
||||||
|
@ -57,7 +57,7 @@ class CSSPseudoElementsAtomSource:
|
||||||
|
|
||||||
|
|
||||||
class CSSAnonBoxesAtomSource:
|
class CSSAnonBoxesAtomSource:
|
||||||
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\(([^,]*),[^"]*"([^"]*)"\)', # NOQA: E501
|
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\(([^,]*),[^"]*"([^"]*)"()\)', # NOQA: E501
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
FILE = "include/nsCSSAnonBoxList.h"
|
FILE = "include/nsCSSAnonBoxList.h"
|
||||||
CLASS = "nsCSSAnonBoxes"
|
CLASS = "nsCSSAnonBoxes"
|
||||||
|
@ -79,12 +79,13 @@ def map_atom(ident):
|
||||||
|
|
||||||
|
|
||||||
class Atom:
|
class Atom:
|
||||||
def __init__(self, source, macro_name, ident, value):
|
def __init__(self, source, macro_name, ident, value, ty):
|
||||||
self.ident = "{}_{}".format(source.CLASS, ident)
|
self.ident = "{}_{}".format(source.CLASS, ident)
|
||||||
self.original_ident = ident
|
self.original_ident = ident
|
||||||
self.value = value
|
self.value = value
|
||||||
self.source = source
|
self.source = source
|
||||||
self.macro = macro_name
|
self.macro = macro_name
|
||||||
|
self.ty = ty
|
||||||
if self.is_anon_box():
|
if self.is_anon_box():
|
||||||
assert self.is_inheriting_anon_box() or self.is_non_inheriting_anon_box()
|
assert self.is_inheriting_anon_box() or self.is_non_inheriting_anon_box()
|
||||||
|
|
||||||
|
@ -101,7 +102,7 @@ class Atom:
|
||||||
return msvc64_symbolify(self.source, self.original_ident)
|
return msvc64_symbolify(self.source, self.original_ident)
|
||||||
|
|
||||||
def type(self):
|
def type(self):
|
||||||
return self.source.TYPE
|
return self.ty
|
||||||
|
|
||||||
def capitalized(self):
|
def capitalized(self):
|
||||||
return self.original_ident[0].upper() + self.original_ident[1:]
|
return self.original_ident[0].upper() + self.original_ident[1:]
|
||||||
|
@ -128,7 +129,8 @@ def collect_atoms(objdir):
|
||||||
with open(path) as f:
|
with open(path) as f:
|
||||||
content = f.read()
|
content = f.read()
|
||||||
for result in source.PATTERN.finditer(content):
|
for result in source.PATTERN.finditer(content):
|
||||||
atoms.append(Atom(source, result.group(1), result.group(2), result.group(3)))
|
ty = result.group(4) or source.TYPE
|
||||||
|
atoms.append(Atom(source, result.group(1), result.group(2), result.group(3), ty))
|
||||||
return atoms
|
return atoms
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,9 +221,9 @@ def write_atom_macro(atoms, file_name):
|
||||||
f.write(PRELUDE)
|
f.write(PRELUDE)
|
||||||
f.write(IMPORTS)
|
f.write(IMPORTS)
|
||||||
|
|
||||||
for source in SOURCES:
|
for ty in sorted(set([atom.type() for atom in atoms])):
|
||||||
if source.TYPE != "nsStaticAtom":
|
if ty != "nsStaticAtom":
|
||||||
f.write("pub enum {} {{}}\n\n".format(source.TYPE))
|
f.write("pub enum {} {{}}\n\n".format(ty))
|
||||||
|
|
||||||
f.write(UNSAFE_STATIC)
|
f.write(UNSAFE_STATIC)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue