[librsvg: 9/16] Generate PropertyId with the make_properties macro
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 9/16] Generate PropertyId with the make_properties macro
- Date: Thu, 26 Mar 2020 00:18:03 +0000 (UTC)
commit 5dfd397a397afcfe4680d1f0bc20c02b7d510019
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Mar 25 13:14:57 2020 -0600
Generate PropertyId with the make_properties macro
rsvg_internals/src/properties.rs | 75 ++++++++--------------------------------
1 file changed, 15 insertions(+), 60 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 6863584e..1f85c7eb 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -56,65 +56,6 @@ where
}
}
-/// Used to match `ParsedProperty` to their discriminant
-///
-/// The `PropertyId::UnsetProperty` can be used as a sentinel value, as
-/// it does not match any `ParsedProperty` discriminant; it is really the
-/// number of valid values in this enum.
-#[repr(u8)]
-#[derive(Copy, Clone, PartialEq)]
-enum PropertyId {
- BaselineShift,
- ClipPath,
- ClipRule,
- Color,
- ColorInterpolationFilters,
- Direction,
- Display,
- EnableBackground,
- Fill,
- FillOpacity,
- FillRule,
- Filter,
- FloodColor,
- FloodOpacity,
- FontFamily,
- FontSize,
- FontStretch,
- FontStyle,
- FontVariant,
- FontWeight,
- LetterSpacing,
- LightingColor,
- Marker,
- MarkerEnd,
- MarkerMid,
- MarkerStart,
- Mask,
- Opacity,
- Overflow,
- ShapeRendering,
- StopColor,
- StopOpacity,
- Stroke,
- StrokeDasharray,
- StrokeDashoffset,
- StrokeLinecap,
- StrokeLinejoin,
- StrokeOpacity,
- StrokeMiterlimit,
- StrokeWidth,
- TextAnchor,
- TextDecoration,
- TextRendering,
- UnicodeBidi,
- Visibility,
- WritingMode,
- XmlLang,
- XmlSpace,
- UnsetProperty,
-}
-
impl PropertyId {
fn as_u8(&self) -> u8 {
*self as u8
@@ -325,6 +266,20 @@ macro_rules! make_properties {
$($long_field:ident: $long_name:ident,)+
}
}=> {
+ /// Used to match `ParsedProperty` to their discriminant
+ ///
+ /// The `PropertyId::UnsetProperty` can be used as a sentinel value, as
+ /// it does not match any `ParsedProperty` discriminant; it is really the
+ /// number of valid values in this enum.
+ #[repr(u8)]
+ #[derive(Copy, Clone, PartialEq)]
+ enum PropertyId {
+ $($short_name,)+
+ $($long_name,)+
+
+ UnsetProperty,
+ }
+
/// Embodies "which property is this" plus the property's value
#[derive(Clone)]
pub enum ParsedProperty {
@@ -344,7 +299,7 @@ macro_rules! make_properties {
fn get_property_id(&self) -> PropertyId {
match *self {
$(ParsedProperty::$long_name(_) => PropertyId::$long_name,)+
- $(ParsedProperty::$short_name(_) => PropertyId::$short_name,)+
+ $(ParsedProperty::$short_name(_) => PropertyId::$short_name,)+
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]