Skip to content

Commit

Permalink
Bug 1412486: Update bindgen. r=xidorn
Browse files Browse the repository at this point in the history
Constified enums are default now. I think I want to introduce an option to
bindgen to allow setting the default enum behavior, but it doesn't need to block
this.

The ServoBindings.toml changes are somewhat hacky, but that's because of
rust-lang/rust-bindgen#1125.

Also, the fixups now need to account for whitespace, since quote generates stuff
like root :: nsString, and we don't rustfmt the bindings if there's no rustfmt
installed.

MozReview-Commit-ID: FZOvZnfYXj5
  • Loading branch information
emilio committed Oct 30, 2017
1 parent 860a30c commit 633cd51
Showing 1 changed file with 79 additions and 11 deletions.
90 changes: 79 additions & 11 deletions layout/style/ServoBindings.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,81 @@ bitfield-enums = [
"nsRestyleHint",
"OriginFlags",
]
constified-enums = [
"UpdateAnimationsTasks",
"ParsingMode",
"ThemeWidgetType",
"ServoTraversalFlags",
# FIXME: use proper namespaces and such when
# https://github.com/rust-lang-nursery/rust-bindgen/issues/1125
# is fixed.
rusty-enums = [
"nsCompatibility",
"EffectCompositor_CascadeLevel",
"SheetType",
"CallerType",
"IterationCompositeOperation",
"CompositeOperation",
"InheritTarget",
"SheetParsingMode",
"FontFamilyType",
"nsStyleContentType",
"nsStyleSVGOpacitySource",
"nsStyleUnit",
"nsCSSKeyword",
"nsIDocument_DocumentTheme",
"nsIDocument_Type",
"nsCSSUnit",
"nsCSSPropertyID",
"nsCSSCounterDesc",
"nsMediaExpression_Range",
"nsMediaFeature_RangeType",
"nsMediaFeature_ValueType",
"nsresult",
"nsAtom_AtomKind",
"nsStyleImageLayers_LayerType",
"nsStyleImageOrientation_Angles",
"nsTimingFunction_Type",
"ServoElementSnapshotFlags",
"Side",
"PlaybackDirection",
"FillMode",
"HalfCorner",
"URLMatchingFunction",
"StyleDisplay",
"StyleFloatEdge",
"StyleShapeRadius",
"StyleWindowDragging",
"StyleOrient",
"StyleBoxSizing",
"StyleClear",
"StyleFloat",
"StyleUserModify",
"StyleUserInput",
"StyleBoxDirection",
"StyleTextJustify",
"StyleHyphens",
"StyleGeometryBox",
"StyleFillRule",
"StyleShapeSourceType",
"StyleBasicShapeType",
"nsStyleImageLayers_Size_DimensionType",
"StyleStackSizing",
"StyleBoxPack",
"StyleBoxOrient",
"StyleBoxAlign",
"StyleUserFocus",
"StyleUserSelect",
"StyleImageLayerRepeat",
"StyleBoxDecorationBreak",
"StyleRuleInclusion",
"StyleGridTrackBreadth",
"nsStyleImageType",
"StyleWhiteSpace",
"nsStyleSVGPaintType",
"nsStyleSVGFallbackType",
# ".*Style.*",
"nsINode_BooleanFlag",
"CSSPseudoElementType",
"CSSPseudoClassType",
"LookAndFeel_ColorID",
"LookAndFeel_FontID",
"MatrixTransformOperator",
]
constified-enum-variants = [
{ enum = "nsCSSPropertyID", variants = ["eCSSProperty_COUNT.*"] },
Expand Down Expand Up @@ -272,7 +342,6 @@ whitelist-types = [
"nsStyleVariables",
"nsStyleVisibility",
"nsStyleXUL",
"nsTArray",
"nsTArrayHeader",
"Position",
"PropertyValuePair",
Expand Down Expand Up @@ -311,7 +380,6 @@ opaque-types = [
# We want everything but FontVariation and Float to be opaque but we don't
# have negative regexes.
"mozilla::gfx::(.{0,4}|.{6,12}|.{14,}|([^F][^o][^n][^t][^V][^a][^r][^i][^a][^t][^i][^o][^n])|([^F][^l][^o][^a][^t]))",
"FallibleTArray",
"mozilla::dom::Sequence",
"mozilla::dom::Optional",
"mozilla::dom::OwningNodeOrString_Value",
Expand Down Expand Up @@ -361,8 +429,8 @@ mapped-generic-types = [
{ generic = false, gecko = "ServoStyleContextStrong", servo = "::gecko_bindings::sugar::ownership::Strong<::properties::ComputedValues>" },
]
fixups = [
{ pat = "\\broot::nsString\\b", rep = "::nsstring::nsStringRepr" },
{ pat = "\\broot::nsTString<u16>", rep = "::nsstring::nsStringRepr" },
{ pat = "\\broot\\s*::\\s*nsString\\b", rep = "::nsstring::nsStringRepr" },
{ pat = "\\broot\\s*::\\s*nsTString\\s*<\\s*u16\\s*>", rep = "::nsstring::nsStringRepr" },
]

[bindings]
Expand Down Expand Up @@ -568,7 +636,7 @@ servo-borrow-types = [
]
fixups = [
# Remap the templated string type to the helper type
{ pat = "\\bnsTString<u16>", rep = "nsString" },
{ pat = "\\bnsTString\\s*<\\s*u16\\s*>", rep = "nsString" },
# hack for gecko-owned string
{ pat = "\\b<nsString\\b", rep = "<nsStringRepr" },
{ pat = "<\\s*nsString\\s*", rep = "<nsStringRepr" },
]

0 comments on commit 633cd51

Please sign in to comment.