[librsvg: 6/43] Convert all the "identifiers" properties to CssParseError
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 6/43] Convert all the "identifiers" properties to CssParseError
- Date: Sat, 21 Dec 2019 02:30:00 +0000 (UTC)
commit c269c128fd72885c02c88475cfe46ffd153666f6
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Dec 19 19:32:45 2019 -0600
Convert all the "identifiers" properties to CssParseError
rsvg_internals/src/properties.rs | 38 +++++++++++++++++------------------
rsvg_internals/src/property_macros.rs | 16 +++++++--------
2 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/rsvg_internals/src/properties.rs b/rsvg_internals/src/properties.rs
index 7eb88d50..aaec6e15 100644
--- a/rsvg_internals/src/properties.rs
+++ b/rsvg_internals/src/properties.rs
@@ -237,22 +237,22 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
Ok(ParsedProperty::ClipPath(parse_input(input)?)),
expanded_name!(svg "clip-rule") =>
- Ok(ParsedProperty::ClipRule(parse_input(input)?)),
+ Ok(ParsedProperty::ClipRule(parse_input_to_parse_error(input)?)),
expanded_name!(svg "color") =>
Ok(ParsedProperty::Color(parse_input(input)?)),
expanded_name!(svg "color-interpolation-filters") =>
- Ok(ParsedProperty::ColorInterpolationFilters(parse_input(input)?)),
+ Ok(ParsedProperty::ColorInterpolationFilters(parse_input_to_parse_error(input)?)),
expanded_name!(svg "direction") =>
- Ok(ParsedProperty::Direction(parse_input(input)?)),
+ Ok(ParsedProperty::Direction(parse_input_to_parse_error(input)?)),
expanded_name!(svg "display") =>
- Ok(ParsedProperty::Display(parse_input(input)?)),
+ Ok(ParsedProperty::Display(parse_input_to_parse_error(input)?)),
expanded_name!(svg "enable-background") =>
- Ok(ParsedProperty::EnableBackground(parse_input(input)?)),
+ Ok(ParsedProperty::EnableBackground(parse_input_to_parse_error(input)?)),
expanded_name!(svg "fill") =>
Ok(ParsedProperty::Fill(parse_input(input)?)),
@@ -261,7 +261,7 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
Ok(ParsedProperty::FillOpacity(parse_input(input)?)),
expanded_name!(svg "fill-rule") =>
- Ok(ParsedProperty::FillRule(parse_input(input)?)),
+ Ok(ParsedProperty::FillRule(parse_input_to_parse_error(input)?)),
expanded_name!(svg "filter") =>
Ok(ParsedProperty::Filter(parse_input(input)?)),
@@ -279,13 +279,13 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
Ok(ParsedProperty::FontSize(parse_input(input)?)),
expanded_name!(svg "font-stretch") =>
- Ok(ParsedProperty::FontStretch(parse_input(input)?)),
+ Ok(ParsedProperty::FontStretch(parse_input_to_parse_error(input)?)),
expanded_name!(svg "font-style") =>
- Ok(ParsedProperty::FontStyle(parse_input(input)?)),
+ Ok(ParsedProperty::FontStyle(parse_input_to_parse_error(input)?)),
expanded_name!(svg "font-variant") =>
- Ok(ParsedProperty::FontVariant(parse_input(input)?)),
+ Ok(ParsedProperty::FontVariant(parse_input_to_parse_error(input)?)),
expanded_name!(svg "font-weight") =>
Ok(ParsedProperty::FontWeight(parse_input(input)?)),
@@ -320,10 +320,10 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
Ok(ParsedProperty::Opacity(parse_input(input)?)),
expanded_name!(svg "overflow") =>
- Ok(ParsedProperty::Overflow(parse_input(input)?)),
+ Ok(ParsedProperty::Overflow(parse_input_to_parse_error(input)?)),
expanded_name!(svg "shape-rendering") =>
- Ok(ParsedProperty::ShapeRendering(parse_input(input)?)),
+ Ok(ParsedProperty::ShapeRendering(parse_input_to_parse_error(input)?)),
expanded_name!(svg "stop-color") =>
Ok(ParsedProperty::StopColor(parse_input(input)?)),
@@ -341,10 +341,10 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
Ok(ParsedProperty::StrokeDashoffset(parse_input(input)?)),
expanded_name!(svg "stroke-linecap") =>
- Ok(ParsedProperty::StrokeLinecap(parse_input(input)?)),
+ Ok(ParsedProperty::StrokeLinecap(parse_input_to_parse_error(input)?)),
expanded_name!(svg "stroke-linejoin") =>
- Ok(ParsedProperty::StrokeLinejoin(parse_input(input)?)),
+ Ok(ParsedProperty::StrokeLinejoin(parse_input_to_parse_error(input)?)),
expanded_name!(svg "stroke-miterlimit") =>
Ok(ParsedProperty::StrokeMiterlimit(parse_input(input)?)),
@@ -356,22 +356,22 @@ pub fn parse_property<'i>(prop_name: &QualName, input: &mut Parser<'i, '_>, acce
Ok(ParsedProperty::StrokeWidth(parse_input(input)?)),
expanded_name!(svg "text-anchor") =>
- Ok(ParsedProperty::TextAnchor(parse_input(input)?)),
+ Ok(ParsedProperty::TextAnchor(parse_input_to_parse_error(input)?)),
expanded_name!(svg "text-decoration") =>
Ok(ParsedProperty::TextDecoration(parse_input_to_parse_error(input)?)),
expanded_name!(svg "text-rendering") =>
- Ok(ParsedProperty::TextRendering(parse_input(input)?)),
+ Ok(ParsedProperty::TextRendering(parse_input_to_parse_error(input)?)),
expanded_name!(svg "unicode-bidi") =>
- Ok(ParsedProperty::UnicodeBidi(parse_input(input)?)),
+ Ok(ParsedProperty::UnicodeBidi(parse_input_to_parse_error(input)?)),
expanded_name!(svg "visibility") =>
- Ok(ParsedProperty::Visibility(parse_input(input)?)),
+ Ok(ParsedProperty::Visibility(parse_input_to_parse_error(input)?)),
expanded_name!(svg "writing-mode") =>
- Ok(ParsedProperty::WritingMode(parse_input(input)?)),
+ Ok(ParsedProperty::WritingMode(parse_input_to_parse_error(input)?)),
_ => Err(ValueErrorKind::UnknownProperty)?
}
@@ -633,7 +633,7 @@ impl SpecifiedValues {
// "inherit" value. So, we don't call parse_one_presentation_attribute()
// for it, but rather call its parser directly.
self.xml_space =
- SpecifiedValue::Specified(XmlSpace::parse_str(value).attribute(attr)?);
+
SpecifiedValue::Specified(XmlSpace::parse_str_to_parse_error(value).attribute(attr)?);
}
_ => self.parse_one_presentation_attribute(attr, value)?,
diff --git a/rsvg_internals/src/property_macros.rs b/rsvg_internals/src/property_macros.rs
index 2a79bdeb..4bffee1e 100644
--- a/rsvg_internals/src/property_macros.rs
+++ b/rsvg_internals/src/property_macros.rs
@@ -45,12 +45,12 @@ macro_rules! make_property {
impl_default!($name, $name::$default);
impl_property!($computed_values_type, $name, $inherits_automatically);
- impl crate::parsers::Parse for $name {
- fn parse(parser: &mut ::cssparser::Parser<'_, '_>) -> Result<$name,
crate::error::ValueErrorKind> {
- parse_identifiers!(
+ impl crate::parsers::ParseToParseError for $name {
+ fn parse_to_parse_error<'i>(parser: &mut ::cssparser::Parser<'i, '_>) -> Result<$name,
crate::error::CssParseError<'i>> {
+ Ok(parse_identifiers!(
parser,
$($str_prop => $name::$variant,)+
- ).map_err(|_| crate::error::ValueErrorKind::parse_error("parse error"))
+ )?)
}
}
};
@@ -175,11 +175,11 @@ macro_rules! impl_property {
mod tests {
use super::*;
- use crate::parsers::Parse;
+ use crate::parsers::{Parse, ParseToParseError};
use cssparser::RGBA;
#[test]
- fn check_generated_property() {
+ fn check_identifiers_property() {
make_property! {
(),
Foo,
@@ -194,8 +194,8 @@ mod tests {
assert_eq!(<Foo as Default>::default(), Foo::Def);
assert_eq!(<Foo as Property<()>>::inherits_automatically(), true);
- assert!(<Foo as Parse>::parse_str("blargh").is_err());
- assert_eq!(<Foo as Parse>::parse_str("bar"), Ok(Foo::Bar));
+ assert!(<Foo as ParseToParseError>::parse_str_to_parse_error("blargh").is_err());
+ assert_eq!(<Foo as ParseToParseError>::parse_str_to_parse_error("bar"), Ok(Foo::Bar));
}
#[test]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]