rsvg_g_warning(): Mechanism to call g_warning() from Rust

parent fb985fc4
......@@ -158,3 +158,15 @@ rsvg_css_parse_color_ (const char *str)
{
return rsvg_css_parse_color (str);
}
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.
*/
void
rsvg_g_warning_from_c(const char *msg)
{
g_warning ("%s", msg);
}
......@@ -3,6 +3,8 @@ use libc;
use std::ffi::CStr;
use std::str;
use glib::translate::*;
// In paint servers (patterns, gradients, etc.), we have an
// Option<String> for fallback names. This is a utility function to
// clone one of those.
......@@ -35,3 +37,13 @@ pub fn clamp<T: PartialOrd>(val: T, low: T, high: T) -> T {
val
}
}
extern "C" {
fn rsvg_g_warning_from_c(msg: *const libc::c_char);
}
pub fn rsvg_g_warning(msg: &str) {
unsafe {
rsvg_g_warning_from_c(msg.to_glib_none().0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment