[librsvg: 35/51] Operator: simplify parsing
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 35/51] Operator: simplify parsing
- Date: Thu, 19 Dec 2019 01:50:58 +0000 (UTC)
commit f4705c100daaea445269bfc9001371dcffbf594d
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 17 21:11:34 2019 -0600
Operator: simplify parsing
rsvg_internals/src/filters/composite.rs | 31 +++++++++++--------------------
1 file changed, 11 insertions(+), 20 deletions(-)
---
diff --git a/rsvg_internals/src/filters/composite.rs b/rsvg_internals/src/filters/composite.rs
index 1fff2231..4ce7e3a2 100644
--- a/rsvg_internals/src/filters/composite.rs
+++ b/rsvg_internals/src/filters/composite.rs
@@ -1,9 +1,9 @@
use cairo::{self, ImageSurface};
-use cssparser::{CowRcStr, Parser, Token};
+use cssparser::Parser;
use markup5ever::{expanded_name, local_name, namespace_url, ns};
use crate::drawing_ctx::DrawingCtx;
-use crate::error::{AttributeResultExt, ValueErrorKind};
+use crate::error::*;
use crate::node::{NodeResult, NodeTrait, RsvgNode};
use crate::parsers::{self, Parse, ParseValue};
use crate::property_bag::PropertyBag;
@@ -213,24 +213,15 @@ impl FilterEffect for FeComposite {
impl Parse for Operator {
fn parse(parser: &mut Parser<'_, '_>) -> Result<Self, ValueErrorKind> {
- let loc = parser.current_source_location();
-
- parser
- .expect_ident()
- .and_then(|cow| match cow.as_ref() {
- "over" => Ok(Operator::Over),
- "in" => Ok(Operator::In),
- "out" => Ok(Operator::Out),
- "atop" => Ok(Operator::Atop),
- "xor" => Ok(Operator::Xor),
- "arithmetic" => Ok(Operator::Arithmetic),
- _ => Err(
- loc.new_basic_unexpected_token_error(Token::Ident(CowRcStr::from(
- cow.as_ref().to_string(),
- ))),
- ),
- })
- .map_err(|_| ValueErrorKind::Value("invalid operator value".to_string()))
+ parse_identifiers!(
+ parser,
+ "over" => Operator::Over,
+ "in" => Operator::In,
+ "out" => Operator::Out,
+ "atop" => Operator::Atop,
+ "xor" => Operator::Xor,
+ "arithmetic" => Operator::Arithmetic,
+ ).map_err(|_: ParseError| ValueErrorKind::parse_error("parse error"))
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]