mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Move geckolib/properties.mako.rs to style/properties/gecko.mako.rs
This commit is contained in:
parent
2c1f7c8a85
commit
db3607471f
8 changed files with 107 additions and 157 deletions
57
components/style/gecko_glue.rs
Normal file
57
components/style/gecko_glue.rs
Normal file
|
@ -0,0 +1,57 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* 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/. */
|
||||
|
||||
#![allow(unsafe_code)]
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::mem::{forget, transmute};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub struct ArcHelpers<GeckoType, ServoType> {
|
||||
phantom1: PhantomData<GeckoType>,
|
||||
phantom2: PhantomData<ServoType>,
|
||||
}
|
||||
|
||||
|
||||
impl<GeckoType, ServoType> ArcHelpers<GeckoType, ServoType> {
|
||||
pub fn with<F, Output>(raw: *mut GeckoType, cb: F) -> Output
|
||||
where F: FnOnce(&Arc<ServoType>) -> Output {
|
||||
debug_assert!(!raw.is_null());
|
||||
|
||||
let owned = unsafe { Self::into(raw) };
|
||||
let result = cb(&owned);
|
||||
forget(owned);
|
||||
result
|
||||
}
|
||||
|
||||
pub fn maybe_with<F, Output>(maybe_raw: *mut GeckoType, cb: F) -> Output
|
||||
where F: FnOnce(Option<&Arc<ServoType>>) -> Output {
|
||||
let owned = if maybe_raw.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { Self::into(maybe_raw) })
|
||||
};
|
||||
|
||||
let result = cb(owned.as_ref());
|
||||
forget(owned);
|
||||
|
||||
result
|
||||
}
|
||||
|
||||
pub unsafe fn into(ptr: *mut GeckoType) -> Arc<ServoType> {
|
||||
transmute(ptr)
|
||||
}
|
||||
|
||||
pub fn from(owned: Arc<ServoType>) -> *mut GeckoType {
|
||||
unsafe { transmute(owned) }
|
||||
}
|
||||
|
||||
pub unsafe fn addref(ptr: *mut GeckoType) {
|
||||
Self::with(ptr, |arc| forget(arc.clone()));
|
||||
}
|
||||
|
||||
pub unsafe fn release(ptr: *mut GeckoType) {
|
||||
let _ = Self::into(ptr);
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@ pub mod error_reporting;
|
|||
pub mod font_face;
|
||||
#[cfg(feature = "gecko")] pub mod gecko_conversions;
|
||||
#[cfg(feature = "gecko")] pub mod gecko_values;
|
||||
#[cfg(feature = "gecko")] pub mod gecko_glue;
|
||||
pub mod keyframes;
|
||||
pub mod logical_geometry;
|
||||
pub mod matching;
|
||||
|
@ -116,6 +117,12 @@ pub mod properties {
|
|||
include!(concat!(env!("OUT_DIR"), "/properties.rs"));
|
||||
}
|
||||
|
||||
#[cfg(feature = "gecko")]
|
||||
#[allow(unsafe_code)]
|
||||
pub mod gecko_properties {
|
||||
include!(concat!(env!("OUT_DIR"), "/gecko_properties.rs"));
|
||||
}
|
||||
|
||||
macro_rules! reexport_computed_values {
|
||||
( $( $name: ident )+ ) => {
|
||||
/// Types for [computed values][computed].
|
||||
|
|
|
@ -18,7 +18,7 @@ import data
|
|||
|
||||
|
||||
def main():
|
||||
usage = "Usage: %s [ servo | gecko ] [ style-crate | geckolib | html ]" % sys.argv[0]
|
||||
usage = "Usage: %s [ servo | gecko ] [ style-crate | html ]" % sys.argv[0]
|
||||
if len(sys.argv) < 3:
|
||||
abort(usage)
|
||||
product = sys.argv[1]
|
||||
|
@ -30,10 +30,10 @@ def main():
|
|||
rust = render(os.path.join(BASE, "properties.mako.rs"), product=product, data=properties)
|
||||
if output == "style-crate":
|
||||
write(os.environ["OUT_DIR"], "properties.rs", rust)
|
||||
if output == "geckolib":
|
||||
template = os.path.join(BASE, "..", "..", "..", "ports", "geckolib", "properties.mako.rs")
|
||||
rust = render(template, data=properties)
|
||||
write(os.environ["OUT_DIR"], "properties.rs", rust)
|
||||
if product == "gecko":
|
||||
template = os.path.join(BASE, "gecko.mako.rs")
|
||||
rust = render(template, data=properties)
|
||||
write(os.environ["OUT_DIR"], "gecko_properties.rs", rust)
|
||||
elif output == "html":
|
||||
write_html(properties)
|
||||
|
||||
|
|
1304
components/style/properties/gecko.mako.rs
Normal file
1304
components/style/properties/gecko.mako.rs
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue