[librsvg] Export rsvg_xml_space_normalize() from Rust to C
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] Export rsvg_xml_space_normalize() from Rust to C
- Date: Thu, 7 Dec 2017 17:21:16 +0000 (UTC)
commit 62a7689d17976e7aabcb5560422252d9713f39fa
Author: Federico Mena Quintero <federico gnome org>
Date: Thu Dec 7 11:00:09 2017 -0600
Export rsvg_xml_space_normalize() from Rust to C
rsvg-text.c | 9 +++++++++
rust/src/lib.rs | 4 ++++
rust/src/space.rs | 11 +++++++++++
3 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/rsvg-text.c b/rsvg-text.c
index e0d56c9..1186a87 100644
--- a/rsvg-text.c
+++ b/rsvg-text.c
@@ -36,6 +36,15 @@
/* what we use for text rendering depends on what cairo has to offer */
#include <pango/pangocairo.h>
+/* Keep in sync with rust/src/space.rs:XmlSpace */
+typedef enum {
+ XML_SPACE_DEFAULT,
+ XML_SPACE_PRESERVE
+} XmlSpace;
+
+/* Implemented in rust/src/space.rs */
+extern char *rsvg_xml_space_normalize (XmlSpace mode, const char *s);
+
typedef struct _RsvgNodeText RsvgNodeText;
struct _RsvgNodeText {
diff --git a/rust/src/lib.rs b/rust/src/lib.rs
index e39726e..f3cd46e 100644
--- a/rust/src/lib.rs
+++ b/rust/src/lib.rs
@@ -117,6 +117,10 @@ pub use shapes::{
rsvg_node_rect_new,
};
+pub use space::{
+ rsvg_xml_space_normalize,
+};
+
pub use stop::{
rsvg_node_stop_new
};
diff --git a/rust/src/space.rs b/rust/src/space.rs
index 56f7d2e..f1e5c1c 100644
--- a/rust/src/space.rs
+++ b/rust/src/space.rs
@@ -1,3 +1,7 @@
+use libc;
+use glib::translate::*;
+
+#[repr(C)]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum XmlSpace {
Default,
@@ -82,6 +86,13 @@ fn normalize_preserve(s: &str) -> String {
.collect()
}
+#[no_mangle]
+pub extern fn rsvg_xml_space_normalize(mode: XmlSpace, s: *const libc::c_char) -> *const libc::c_char {
+ let rs = unsafe { String::from_glib_none (s) };
+
+ xml_space_normalize(mode, &rs).to_glib_full()
+}
+
#[cfg(test)]
mod tests {
use super::*;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]