[librsvg: 30/43] Convert FunctionType to CssParseError



commit 748ac7ca4ecdba4dd4ee1366fe99781cff1de618
Author: Federico Mena Quintero <federico gnome org>
Date:   Fri Dec 20 18:29:40 2019 -0600

    Convert FunctionType to CssParseError

 rsvg_internals/src/filters/component_transfer.rs | 23 +++++++++++------------
 1 file changed, 11 insertions(+), 12 deletions(-)
---
diff --git a/rsvg_internals/src/filters/component_transfer.rs 
b/rsvg_internals/src/filters/component_transfer.rs
index 2aa21b57..7c73461a 100644
--- a/rsvg_internals/src/filters/component_transfer.rs
+++ b/rsvg_internals/src/filters/component_transfer.rs
@@ -8,7 +8,7 @@ use crate::drawing_ctx::DrawingCtx;
 use crate::error::*;
 use crate::node::{NodeResult, NodeTrait, NodeType, RsvgNode};
 use crate::number_list::{NumberList, NumberListLength};
-use crate::parsers::{Parse, ParseValue};
+use crate::parsers::{ParseToParseError, ParseValueToParseError};
 use crate::property_bag::PropertyBag;
 use crate::surface_utils::{
     iterators::Pixels, shared_surface::SharedImageSurface, ImageSurfaceDataExt, Pixel,
@@ -60,17 +60,16 @@ enum FunctionType {
     Gamma,
 }
 
-impl Parse for FunctionType {
-    fn parse<'i>(parser: &mut Parser<'i, '_>) -> Result<FunctionType, ValueErrorKind> {
-        parse_identifiers!(
+impl ParseToParseError for FunctionType {
+    fn parse_to_parse_error<'i>(parser: &mut Parser<'i, '_>) -> Result<Self, CssParseError<'i>> {
+        Ok(parse_identifiers!(
             parser,
             "identity" => FunctionType::Identity,
             "table" => FunctionType::Table,
             "discrete" => FunctionType::Discrete,
             "linear" => FunctionType::Linear,
             "gamma" => FunctionType::Gamma,
-        )
-        .map_err(|_| ValueErrorKind::parse_error("parse error"))
+        )?)
     }
 }
 
@@ -209,7 +208,7 @@ macro_rules! func_x {
                 for (attr, value) in pbag.iter() {
                     match attr.expanded() {
                         expanded_name!(svg "type") => {
-                            self.function_type = attr.parse(value)?
+                            self.function_type = attr.parse_to_parse_error(value)?
                         }
                         expanded_name!(svg "tableValues") => {
                             let NumberList(v) =
@@ -217,11 +216,11 @@ macro_rules! func_x {
                                 .attribute(attr)?;
                             self.table_values = v;
                         }
-                        expanded_name!(svg "slope") => self.slope = attr.parse(value)?,
-                        expanded_name!(svg "intercept") => self.intercept = attr.parse(value)?,
-                        expanded_name!(svg "amplitude") => self.amplitude = attr.parse(value)?,
-                        expanded_name!(svg "exponent") => self.exponent = attr.parse(value)?,
-                        expanded_name!(svg "offset") => self.offset = attr.parse(value)?,
+                        expanded_name!(svg "slope") => self.slope = attr.parse_to_parse_error(value)?,
+                        expanded_name!(svg "intercept") => self.intercept = 
attr.parse_to_parse_error(value)?,
+                        expanded_name!(svg "amplitude") => self.amplitude = 
attr.parse_to_parse_error(value)?,
+                        expanded_name!(svg "exponent") => self.exponent = attr.parse_to_parse_error(value)?,
+                        expanded_name!(svg "offset") => self.offset = attr.parse_to_parse_error(value)?,
 
                         _ => (),
                     }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]