[librsvg: 1/10] Add rsvg_g_critical_from_c()



commit a80397b4fef404dbb5f127365bcc9a4eaefc13e6
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Jul 23 14:19:23 2019 -0500

    Add rsvg_g_critical_from_c()

 librsvg/rsvg-base.c        | 15 ++++++++++++---
 rsvg_internals/src/util.rs | 15 +++++++++++++++
 2 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/librsvg/rsvg-base.c b/librsvg/rsvg-base.c
index 5ccc98ea..809a6dd7 100644
--- a/librsvg/rsvg-base.c
+++ b/librsvg/rsvg-base.c
@@ -136,14 +136,23 @@ rsvg_css_parse_color_ (const char *str)
     return rsvg_css_parse_color (str);
 }
 
+/* These functions exist just so that we can effectively call g_warning() or
+ * g_critical() from Rust, since glib-rs doesn't bind the g_log functions yet.
+ */
 G_GNUC_INTERNAL
 void rsvg_g_warning_from_c(const char *msg);
 
-/* This function exists just so that we can effectively call g_warning() from Rust,
- * since glib-rs doesn't bind the g_log functions yet.
- */
+G_GNUC_INTERNAL
+void rsvg_g_critical_from_c(const char *msg);
+
 void
 rsvg_g_warning_from_c(const char *msg)
 {
     g_warning ("%s", msg);
 }
+
+void
+rsvg_g_critical_from_c(const char *msg)
+{
+    g_critical ("%s", msg);
+}
diff --git a/rsvg_internals/src/util.rs b/rsvg_internals/src/util.rs
index 17d2c2ae..e10d301b 100644
--- a/rsvg_internals/src/util.rs
+++ b/rsvg_internals/src/util.rs
@@ -55,3 +55,18 @@ pub fn rsvg_g_warning(_msg: &str) {
     // meaningful error code, but the C API isn't - so they issues a
     // g_warning() instead.
 }
+
+#[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]