[librsvg: 5/8] Move rsvg_g_warning() and rsvg_g_critical() to c_api.rs



commit d8495a0fbd44b91c707ecae2b8e2050231471ee5
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Aug 26 13:24:13 2019 +0300

    Move rsvg_g_warning() and rsvg_g_critical() to c_api.rs

 rsvg_internals/src/c_api.rs | 39 ++++++++++++++++++++++++++++++++++++++-
 rsvg_internals/src/util.rs  | 41 -----------------------------------------
 2 files changed, 38 insertions(+), 42 deletions(-)
---
diff --git a/rsvg_internals/src/c_api.rs b/rsvg_internals/src/c_api.rs
index 1afc80ce..005e0cab 100644
--- a/rsvg_internals/src/c_api.rs
+++ b/rsvg_internals/src/c_api.rs
@@ -36,7 +36,6 @@ use crate::error::{set_gerror, DefsLookupErrorKind, LoadingError, RenderingError
 use crate::handle::{Handle, LoadOptions};
 use crate::length::RsvgLength;
 use crate::structure::IntrinsicDimensions;
-use crate::util::{rsvg_g_critical, rsvg_g_warning};
 
 mod handle_flags {
     // The following is entirely stolen from the auto-generated code
@@ -1504,6 +1503,44 @@ fn warn_on_invalid_id(e: RenderingError) -> RenderingError {
     e
 }
 
+#[cfg(feature = "c-library")]
+pub fn rsvg_g_warning(msg: &str) {
+    unsafe {
+        extern "C" {
+            fn rsvg_g_warning_from_c(msg: *const libc::c_char);
+        }
+
+        rsvg_g_warning_from_c(msg.to_glib_none().0);
+    }
+}
+
+#[cfg(not(feature = "c-library"))]
+pub fn rsvg_g_warning(_msg: &str) {
+    // This, and rsvg_g_critical() below, are intended to be called
+    // from Rust code which is directly called from the C API.  When
+    // this crate is being built as part of the c-library, the purpose
+    // of the functions is to call the corresponding glib macros to
+    // print a warning or a critical error message.  When this crate
+    // is being built as part of the standalone Rust crate, they do
+    // nothing, since the Rust code is able to propagate an error code
+    // all the way to the crate's public API.
+}
+
+#[cfg(feature = "c-library")]
+pub fn rsvg_g_critical(msg: &str) {
+    unsafe {
+        extern "C" {
+            fn rsvg_g_critical_from_c(msg: *const libc::c_char);
+        }
+
+        rsvg_g_critical_from_c(msg.to_glib_none().0);
+    }
+}
+
+#[cfg(not(feature = "c-library"))]
+pub fn rsvg_g_critical(_msg: &str) {
+}
+
 #[cfg(test)]
 mod tests {
     use super::*;
diff --git a/rsvg_internals/src/util.rs b/rsvg_internals/src/util.rs
index 0bb4a9bf..6637bdef 100644
--- a/rsvg_internals/src/util.rs
+++ b/rsvg_internals/src/util.rs
@@ -4,9 +4,6 @@ use std::borrow::Cow;
 use std::ffi::CStr;
 use std::str;
 
-#[cfg(feature = "c-library")]
-use glib::translate::*;
-
 /// Converts a `char *` which is known to be valid UTF-8 into a `&str`
 ///
 /// The usual `from_glib_none(s)` allocates an owned String.  The
@@ -36,41 +33,3 @@ pub fn clamp<T: PartialOrd>(val: T, low: T, high: T) -> T {
         val
     }
 }
-
-#[cfg(feature = "c-library")]
-pub fn rsvg_g_warning(msg: &str) {
-    unsafe {
-        extern "C" {
-            fn rsvg_g_warning_from_c(msg: *const libc::c_char);
-        }
-
-        rsvg_g_warning_from_c(msg.to_glib_none().0);
-    }
-}
-
-#[cfg(not(feature = "c-library"))]
-pub fn rsvg_g_warning(_msg: &str) {
-    // This, and rsvg_g_critical() below, are intended to be called
-    // from Rust code which is directly called from the C API.  When
-    // this crate is being built as part of the c-library, the purpose
-    // of the functions is to call the corresponding glib macros to
-    // print a warning or a critical error message.  When this crate
-    // is being built as part of the standalone Rust crate, they do
-    // nothing, since the Rust code is able to propagate an error code
-    // all the way to the crate's public API.
-}
-
-#[cfg(feature = "c-library")]
-pub fn rsvg_g_critical(msg: &str) {
-    unsafe {
-        extern "C" {
-            fn rsvg_g_critical_from_c(msg: *const libc::c_char);
-        }
-
-        rsvg_g_critical_from_c(msg.to_glib_none().0);
-    }
-}
-
-#[cfg(not(feature = "c-library"))]
-pub fn rsvg_g_critical(_msg: &str) {
-}


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