style: Simplify a bit our generated bindings by getting rid of FooBorrowed and FooBorrowedMut.

This reduces a lot the boilerplate that's needed in order to add simple binding
functions.

This starts using &Foo and Option<&Foo> instead, and as a result we need to
remove the servo_function_signatures test, which is a bit unfortunate.

I think it's worth though, this causes problems on some platforms (see bug
1534844), and messing up the functions signature is not something that I've ever
seen (other than bug 1308234, which already had all the FooBorrowed mess which
I'm removing).

Also, cbindgen understands references and Option<&Foo>, so it will be the way to
go in the future.

After this patch we can also remove HasSimpleFFI, but I've kept it for now since
I still use it in a few places, and this patch is quite big on its own.

Differential Revision: https://phabricator.services.mozilla.com/D24092
This commit is contained in:
Emilio Cobos Álvarez 2019-03-21 17:00:27 +00:00
parent d4635f1d12
commit 14b176019c
9 changed files with 68 additions and 150 deletions

View file

@ -66,16 +66,25 @@ use crate::values::generics::url::UrlOrNone;
pub mod style_structs {
% for style_struct in data.style_structs:
pub use super::${style_struct.gecko_struct_name} as ${style_struct.name};
unsafe impl Send for ${style_struct.name} {}
unsafe impl Sync for ${style_struct.name} {}
% endfor
}
/// FIXME(emilio): This is completely duplicated with the other properties code.
pub type ComputedValuesInner = crate::gecko_bindings::structs::ServoComputedData;
pub type ComputedValuesInner = structs::ServoComputedData;
#[repr(C)]
pub struct ComputedValues(crate::gecko_bindings::structs::mozilla::ComputedStyle);
pub struct ComputedValues(structs::mozilla::ComputedStyle);
impl ComputedValues {
#[inline]
pub (crate) fn as_gecko_computed_style(&self) -> &structs::ComputedStyle {
&self.0
}
pub fn new(
pseudo: Option<<&PseudoElement>,
custom_properties: Option<Arc<CustomPropertiesMap>>,
@ -929,7 +938,7 @@ transform_functions = [
debug_assert!(!${item}${index + 1}.0.is_empty());
% endif
${css_value_setters[item] % (
"bindings::Gecko_CSSValue_GetArrayItem(gecko_value, %d)" % (index + 1),
"(&mut *bindings::Gecko_CSSValue_GetArrayItem(gecko_value, %d))" % (index + 1),
item + str(index + 1)
)};
% endfor
@ -980,7 +989,7 @@ transform_functions = [
% endif
<%
getter = css_value_getters[item] % (
"bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, %d)" % (index + 1)
"(&*bindings::Gecko_CSSValue_GetArrayItemConst(gecko_value, %d))" % (index + 1)
)
%>
${getter},
@ -989,6 +998,7 @@ transform_functions = [
},
</%def>
#[allow(unused_parens)]
fn set_single_transform_function(
servo_value: &values::computed::TransformOperation,
gecko_value: &mut structs::nsCSSValue /* output */
@ -1031,6 +1041,7 @@ pub fn convert_transform(
output.set_move(list);
}
#[allow(unused_parens)]
fn clone_single_transform_function(
gecko_value: &structs::nsCSSValue
) -> values::computed::TransformOperation {