mirror of
https://github.com/servo/servo.git
synced 2025-08-15 10:25:32 +01:00
Introduce nsStaticAtom.
It's a sub-class of nsAtom, useful for cases where you know you are dealing exclusively with static atoms. The nice thing about it is that you can use raw nsStaticAtom pointers instead of RefPtr<>. (In fact, the AddRef/Release implementations ensure that we'll crash if we use RefPtr<nsStaticAtom>.)
This commit is contained in:
parent
de7595f16f
commit
5866b820e0
5 changed files with 12525 additions and 12503 deletions
|
@ -20,7 +20,7 @@ PRELUDE = """
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* Autogenerated file created by components/style/binding_tools/regen_atoms.py, DO NOT EDIT DIRECTLY */
|
||||
/* Autogenerated file created by components/style/gecko/binding_tools/regen_atoms.py, DO NOT EDIT DIRECTLY */
|
||||
"""[1:]
|
||||
|
||||
|
||||
|
@ -42,14 +42,14 @@ class GkAtomSource:
|
|||
PATTERN = re.compile('^(GK_ATOM)\((.+),\s*"(.*)"\)')
|
||||
FILE = "include/nsGkAtomList.h"
|
||||
CLASS = "nsGkAtoms"
|
||||
TYPE = "nsAtom"
|
||||
TYPE = "nsStaticAtom"
|
||||
|
||||
|
||||
class CSSPseudoElementsAtomSource:
|
||||
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\((.+),\s*"(.*)",')
|
||||
FILE = "include/nsCSSPseudoElementList.h"
|
||||
CLASS = "nsCSSPseudoElements"
|
||||
# NB: nsICSSPseudoElement is effectively the same as a nsAtom, but we need
|
||||
# NB: nsICSSPseudoElement is effectively the same as a nsStaticAtom, but we need
|
||||
# this for MSVC name mangling.
|
||||
TYPE = "nsICSSPseudoElement"
|
||||
|
||||
|
@ -163,14 +163,14 @@ class FileAvoidWrite(BytesIO):
|
|||
self.close()
|
||||
|
||||
|
||||
IMPORTS = ("\nuse gecko_bindings::structs::nsAtom;"
|
||||
IMPORTS = ("\nuse gecko_bindings::structs::nsStaticAtom;"
|
||||
"\nuse string_cache::Atom;\n\n")
|
||||
|
||||
ATOM_TEMPLATE = (" #[link_name = \"{link_name}\"]\n"
|
||||
" pub static {name}: *mut {type};")
|
||||
|
||||
UNSAFE_STATIC = ("#[inline(always)]\n"
|
||||
"pub unsafe fn atom_from_static(ptr: *mut nsAtom) -> Atom {\n"
|
||||
"pub unsafe fn atom_from_static(ptr: *mut nsStaticAtom) -> Atom {\n"
|
||||
" Atom::from_static(ptr)\n"
|
||||
"}\n\n")
|
||||
|
||||
|
@ -220,7 +220,7 @@ def write_atom_macro(atoms, file_name):
|
|||
f.write(IMPORTS)
|
||||
|
||||
for source in SOURCES:
|
||||
if source.TYPE != "nsAtom":
|
||||
if source.TYPE != "nsStaticAtom":
|
||||
f.write("pub enum {} {{}}\n\n".format(source.TYPE))
|
||||
|
||||
f.write(UNSAFE_STATIC)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue