Bug 1576703 - Update cbindgen. r=boris

This cleans up the pattern of "Use a private dtor so that the helper functions
do the right thing" by enabling it everywhere using:

  https://github.com/eqrion/cbindgen/pull/377

It also caught some uninitialized value issues.

I think they're mostly harmless since we zero-initialize our structs:

https://searchfox.org/mozilla-central/rev/325c1a707819602feff736f129cb36055ba6d94f/servo/components/style/properties/gecko.mako.rs#632

And since we override the clip rect, which is the other bit of code that was
failing to build with this change.

Differential Revision: https://phabricator.services.mozilla.com/D43491

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-08-26 23:18:46 +00:00
parent ce631c35ff
commit c17fdaaa27
19 changed files with 15 additions and 142 deletions

View File

@ -15,7 +15,7 @@ option(env='CBINDGEN', nargs=1, when=cbindgen_is_needed,
def check_cbindgen_version(cbindgen, fatal=False):
log.debug("trying cbindgen: %s" % cbindgen)
cbindgen_min_version = Version('0.9.0')
cbindgen_min_version = Version('0.9.1')
# cbindgen x.y.z
version = Version(check_cmd_output(cbindgen, '--version').strip().split(" ")[1])

View File

@ -629,7 +629,7 @@ Maybe<StyleComputedFontStretchRange> FontFace::GetFontStretch() const {
}
Maybe<StyleComputedFontStyleDescriptor> FontFace::GetFontStyle() const {
StyleComputedFontStyleDescriptor descriptor;
auto descriptor = StyleComputedFontStyleDescriptor::Normal();
if (!Servo_FontFaceRule_GetFontStyle(GetData(), &descriptor)) {
return Nothing();
}

View File

@ -205,7 +205,7 @@ void FontFaceSet::ParseFontShorthandForMatching(
const nsAString& aFont, RefPtr<SharedFontList>& aFamilyList,
FontWeight& aWeight, FontStretch& aStretch, FontSlantStyle& aStyle,
ErrorResult& aRv) {
StyleComputedFontStyleDescriptor style;
auto style = StyleComputedFontStyleDescriptor::Normal();
float stretch;
float weight;

View File

@ -1152,7 +1152,9 @@ void Gecko_CopyImageValueFrom(nsStyleImage* aImage,
void Gecko_InitializeImageCropRect(nsStyleImage* aImage) {
MOZ_ASSERT(aImage);
aImage->SetCropRect(MakeUnique<nsStyleImage::CropRect>());
auto zero = StyleNumberOrPercentage::Number(0);
aImage->SetCropRect(MakeUnique<nsStyleImage::CropRect>(
nsStyleImage::CropRect{zero, zero, zero, zero}));
}
void Gecko_SetCursorArrayLength(nsStyleUI* aStyleUI, size_t aLen) {

View File

@ -542,6 +542,7 @@ nsChangeHint nsStyleOutline::CalcDifference(
nsStyleList::nsStyleList(const Document& aDocument)
: mListStylePosition(NS_STYLE_LIST_STYLE_POSITION_OUTSIDE),
mQuotes(StyleQuotes::Auto()),
mImageRegion(StyleClipRectOrAuto::Auto()),
mMozListReversed(StyleMozListReversed::False) {
MOZ_COUNT_CTOR(nsStyleList);
MOZ_ASSERT(NS_IsMainThread());
@ -2698,6 +2699,9 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
mScrollSnapType(
{StyleScrollSnapAxis::Both, StyleScrollSnapStrictness::None}),
mLineClamp(0),
mRotate(StyleRotate::None()),
mTranslate(StyleTranslate::None()),
mScale(StyleScale::None()),
mBackfaceVisibility(NS_STYLE_BACKFACE_VISIBILITY_VISIBLE),
mTransformStyle(NS_STYLE_TRANSFORM_STYLE_FLAT),
mTransformBox(StyleGeometryBox::BorderBox),

View File

@ -198,8 +198,6 @@ impl TextDecorationsInEffect {
}
/// Computed value for the text-emphasis-style property
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(Clone, Debug, MallocSizeOf, PartialEq, ToCss, ToResolvedValue)]
#[allow(missing_docs)]
#[repr(C, u8)]

View File

@ -34,8 +34,6 @@ pub struct GenericBoxShadow<Color, SizeLength, BlurShapeLength, ShapeLength> {
pub use self::GenericBoxShadow as BoxShadow;
/// A generic value for a single `filter`.
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[animation(no_bound(U))]
#[derive(

View File

@ -185,8 +185,6 @@ impl Parse for GridLine<specified::Integer> {
/// avoid re-implementing it for the computed type.
///
/// <https://drafts.csswg.org/css-grid/#typedef-track-breadth>
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,
@ -230,8 +228,6 @@ impl<L> TrackBreadth<L> {
/// generic only to avoid code bloat. It only takes `<length-percentage>`
///
/// <https://drafts.csswg.org/css-grid/#typedef-track-size>
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Clone,
Debug,
@ -494,8 +490,6 @@ impl<L: ToCss, I: ToCss> ToCss for TrackRepeat<L, I> {
}
/// Track list values. Can be <track-size> or <track-repeat>
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,
@ -729,8 +723,6 @@ impl ToCss for LineNameList {
}
/// Variants for `<grid-template-rows> | <grid-template-columns>`
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,

View File

@ -9,7 +9,6 @@ use cssparser::Parser;
use style_traits::ParseError;
/// The fallback of an SVG paint server value.
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,
@ -43,8 +42,6 @@ pub use self::GenericSVGPaintFallback as SVGPaintFallback;
/// An SVG paint value
///
/// <https://www.w3.org/TR/SVG2/painting.html#SpecifyingPaint>
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[animation(no_bound(Url))]
#[derive(
Animate,
@ -84,8 +81,6 @@ impl<C, U> Default for SVGPaint<C, U> {
///
/// Whereas the spec only allows PaintServer to have a fallback, Gecko lets the
/// context properties have a fallback as well.
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[animation(no_bound(U))]
#[derive(
Animate,

View File

@ -151,7 +151,6 @@ fn is_same<N: PartialEq>(x: &N, y: &N) -> bool {
)]
#[repr(C, u8)]
/// A single operation in the list of a `transform` value
/// cbindgen:derive-tagged-enum-copy-constructor=true
pub enum GenericTransformOperation<Angle, Number, Length, Integer, LengthPercentage>
where
Angle: Zero,

View File

@ -5,8 +5,6 @@
//! Generic types for url properties.
/// An image url or none, used for example in list-style-image
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,

View File

@ -1091,8 +1091,6 @@ bitflags! {
)]
#[repr(C, u8)]
/// Set of variant alternates
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
pub enum VariantAlternates {
/// Enables display of stylistic alternates
#[css(function)]

View File

@ -126,8 +126,6 @@ pub struct QuoteList(
/// Specified and computed `quotes` property: `auto`, `none`, or a list
/// of characters.
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Clone,
Debug,

View File

@ -15,7 +15,6 @@ use style_traits::{ParseError, StyleParseErrorKind};
/// The offset-path value.
///
/// https://drafts.fxtf.org/motion-1/#offset-path-property
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(
Animate,
Clone,

View File

@ -707,8 +707,6 @@ fn is_name_code_point(c: char) -> bool {
/// The syntax of this property also provides a visualization of the structure
/// of the grid, making the overall layout of the grid container easier to
/// understand.
///
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[repr(C, u8)]
#[derive(
Clone,

View File

@ -132,7 +132,6 @@ impl ToComputedValue for LineHeight {
}
/// A generic value for the `text-overflow` property.
/// cbindgen:derive-tagged-enum-copy-constructor=true
#[derive(Clone, Debug, Eq, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem)]
#[repr(C, u8)]
pub enum TextOverflowSide {

View File

@ -48,6 +48,8 @@ bitflags = true
derive_helper_methods = true
derive_const_casts = true
derive_tagged_enum_destructor = true
derive_tagged_enum_copy_constructor = true
private_default_tagged_enum_constructor = true
cast_assert_name = "MOZ_ASSERT"
[export]
@ -331,15 +333,6 @@ renaming_overrides_prefixing = true
inline bool IsNone() const;
"""
"Quotes" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleQuotes() {}
public:
"""
# TODO(emilio): Add hooks to cbindgen to be able to generate MOZ_MUST_USE_TYPE
# or MOZ_MUST_USE on the functions.
"Owned" = """
@ -519,47 +512,12 @@ renaming_overrides_prefixing = true
bool HasPercent() const;
"""
"GenericTransformOperation" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericTransformOperation() {}
public:
"""
"GenericUrlOrNone" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericUrlOrNone() {}
public:
"""
"Angle" = """
inline static StyleAngle Zero();
inline float ToDegrees() const;
inline double ToRadians() const;
"""
"OffsetPath" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleOffsetPath() {}
public:
"""
"TextOverflowSide" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleTextOverflowSide() {}
public:
"""
"TextOverflow" = """
StyleTextOverflow()
: first(StyleTextOverflowSide::Clip()),
@ -618,15 +576,6 @@ renaming_overrides_prefixing = true
bool IsOpaque() const;
"""
"GridTemplateAreas" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGridTemplateAreas() {}
public:
"""
"GenericGridLine" = """
// Returns the `auto` value.
inline StyleGenericGridLine();
@ -636,52 +585,16 @@ renaming_overrides_prefixing = true
"""
"GenericTrackBreadth" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericTrackBreadth() {}
public:
inline bool HasPercent() const;
"""
"GenericTrackSize" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericTrackSize() {}
public:
// Implemented in nsGridContainerFrame.cpp
inline const StyleGenericTrackBreadth<L>& GetMin() const;
inline const StyleGenericTrackBreadth<L>& GetMax() const;
"""
"GenericSVGPaintKind" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericSVGPaintKind() {}
public:
"""
"GenericSVGPaintFallback" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericSVGPaintFallback() {}
public:
"""
"GenericGridTemplateComponent" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleGenericGridTemplateComponent() {}
public:
inline Maybe<size_t> RepeatAutoIndex() const;
inline const StyleGenericTrackRepeat<L, I>* GetRepeatAutoValue() const;
inline bool HasRepeatAuto() const;
@ -689,24 +602,6 @@ renaming_overrides_prefixing = true
inline Span<const StyleGenericTrackListValue<L, I>> TrackListValues() const;
"""
"TextEmphasisStyle" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleTextEmphasisStyle() {}
public:
"""
"VariantAlternates" = """
private:
// Private default constructor without initialization so that the helper
// constructor functions still work as expected. They take care of
// initializing the fields properly.
StyleVariantAlternates() {}
public:
"""
"GenericClipRect" = """
// Get the layout rect, replacing auto right / bottom values for aAutoSize.
inline nsRect ToLayoutRect(nscoord aAutoSize = NS_MAXSIZE) const;

View File

@ -256,12 +256,12 @@ wine-3.0.3:
sig-url: "{url}.sign"
key-path: build/unix/build-gcc/DA23579A74D4AD9AF9D3F945CEFAC8EAAF17519D.key
cbindgen-0.9.0:
cbindgen-0.9.1:
description: cbindgen source code
fetch:
type: git
repo: https://github.com/eqrion/cbindgen
revision: e19526e00b3fe6921b881682147a1fe5d6b64124
revision: 8e4db4c17fbdc0cfa9b98cfe9d47ca6263858def
cctools-port:
description: cctools-port source code

View File

@ -14,7 +14,7 @@ job-defaults:
fetch:
# If you update this, make sure to update the minimum version in
# build/moz.configure/bindgen.configure as well.
- cbindgen-0.9.0
- cbindgen-0.9.1
linux64-cbindgen:
treeherder: