[librsvg] impl Parse for cairo::Matrix; remove property_bag::transform_or_none()



commit 1ce008c7d0efed475ee567c42253d70845f3071a
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Sep 4 21:13:25 2017 -0500

    impl Parse for cairo::Matrix; remove property_bag::transform_or_none()
    
    We can now use the normal property_bag::parse_or_none() insted.

 rust/src/gradient.rs     |    2 +-
 rust/src/pattern.rs      |    2 +-
 rust/src/property_bag.rs |   10 ----------
 rust/src/transform.rs    |   12 ++++++++++++
 4 files changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/rust/src/gradient.rs b/rust/src/gradient.rs
index ac2b2bf..2010377 100644
--- a/rust/src/gradient.rs
+++ b/rust/src/gradient.rs
@@ -557,7 +557,7 @@ impl NodeTrait for NodeGradient {
         // Attributes common to linear and radial gradients
 
         g.common.units    = property_bag::parse_or_none (pbag, "gradientUnits", ())?;
-        g.common.affine   = property_bag::transform_or_none (pbag, "gradientTransform")?;
+        g.common.affine   = property_bag::parse_or_none (pbag, "gradientTransform", ())?;
         g.common.spread   = property_bag::parse_or_none (pbag, "spreadMethod", ())?;
         g.common.fallback = property_bag::lookup (pbag, "xlink:href");
 
diff --git a/rust/src/pattern.rs b/rust/src/pattern.rs
index a3b31e8..67a0eb6 100644
--- a/rust/src/pattern.rs
+++ b/rust/src/pattern.rs
@@ -205,7 +205,7 @@ impl NodeTrait for NodePattern {
 
         p.preserve_aspect_ratio = property_bag::parse_or_none (pbag, "preserveAspectRatio", ())?;
 
-        p.affine = property_bag::transform_or_none (pbag, "patternTransform")?;
+        p.affine = property_bag::parse_or_none (pbag, "patternTransform", ())?;
 
         p.fallback = property_bag::lookup (pbag, "xlink:href");
 
diff --git a/rust/src/property_bag.rs b/rust/src/property_bag.rs
index 271be08..88bf484 100644
--- a/rust/src/property_bag.rs
+++ b/rust/src/property_bag.rs
@@ -97,13 +97,3 @@ pub fn parse_or_value<T> (pbag: *const RsvgPropertyBag, key: &'static str, data:
         Err (e)       => Err (e)
     }
 }
-
-pub fn transform_or_none (pbag: *const RsvgPropertyBag, key: &'static str) -> Result <Option<cairo::Matrix>, 
NodeError> {
-    if let Some (s) = lookup (pbag, key) {
-        parse_transform (&s)
-            .map (|v| Some (v))
-            .map_err (|e| NodeError::attribute_error (key, e))
-    } else {
-        Ok (None)
-    }
-}
diff --git a/rust/src/transform.rs b/rust/src/transform.rs
index 42fe60f..98dabb1 100644
--- a/rust/src/transform.rs
+++ b/rust/src/transform.rs
@@ -3,6 +3,7 @@ use ::glib::translate::*;
 use ::glib_sys;
 use ::libc;
 
+#[cfg(test)]
 use std::f64::consts::*;
 
 use cairo::MatrixTrait;
@@ -11,6 +12,16 @@ use parse_transform::*;
 
 use error::*;
 use parsers::ParseError;
+use parsers::Parse;
+
+impl Parse for cairo::Matrix {
+    type Data = ();
+    type Err = AttributeError;
+
+    fn parse (s: &str, _: ()) -> Result<cairo::Matrix, AttributeError> {
+        parse_transform (s)
+    }
+}
 
 pub fn parse_transform (s: &str) -> Result <cairo::Matrix, AttributeError> {
     let r = parse_TransformList (s);
@@ -27,6 +38,7 @@ pub fn parse_transform (s: &str) -> Result <cairo::Matrix, AttributeError> {
     }
 }
 
+#[cfg(test)]
 fn make_rotation_matrix (angle_degrees: f64, tx: f64, ty: f64) -> cairo::Matrix {
     let angle = angle_degrees * PI / 180.0;
 


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