[librsvg] property_bag.rs: Remove the C API. Yay!
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg] property_bag.rs: Remove the C API. Yay!
- Date: Wed, 5 Dec 2018 19:11:54 +0000 (UTC)
commit 32ef3ba45ac8d95c91410e7dfde6aeddcc306fbb
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Dec 5 09:59:39 2018 -0600
property_bag.rs: Remove the C API. Yay!
librsvg/rsvg-private.h | 25 --------
rsvg_internals/src/lib.rs | 8 ---
rsvg_internals/src/property_bag.rs | 117 +------------------------------------
3 files changed, 1 insertion(+), 149 deletions(-)
---
diff --git a/librsvg/rsvg-private.h b/librsvg/rsvg-private.h
index 536128ff..0b5adc7e 100644
--- a/librsvg/rsvg-private.h
+++ b/librsvg/rsvg-private.h
@@ -113,31 +113,6 @@ struct RsvgHandlePrivate {
RsvgHandleRust *rust_handle;
};
-/* Implemented in rust/src/property_bag.rs */
-G_GNUC_INTERNAL
-RsvgPropertyBag rsvg_property_bag_new (const char **atts);
-
-/* Implemented in rust/src/property_bag.rs */
-G_GNUC_INTERNAL
-void rsvg_property_bag_free (RsvgPropertyBag bag);
-
-typedef struct RsvgPropertyBagIter *RsvgPropertyBagIter;
-
-/* Implemented in rust/src/property_bag.rs */
-G_GNUC_INTERNAL
-RsvgPropertyBagIter *rsvg_property_bag_iter_begin (RsvgPropertyBag bag);
-
-/* Implemented in rust/src/property_bag.rs */
-G_GNUC_INTERNAL
-gboolean rsvg_property_bag_iter_next (RsvgPropertyBagIter *iter,
- const char **out_key,
- RsvgAttribute *out_attr,
- const char **out_value);
-
-/* Implemented in rust/src/property_bag.rs */
-G_GNUC_INTERNAL
-void rsvg_property_bag_iter_end (RsvgPropertyBagIter *iter);
-
G_GNUC_INTERNAL
GdkPixbuf *rsvg_cairo_surface_to_pixbuf (cairo_surface_t *surface);
diff --git a/rsvg_internals/src/lib.rs b/rsvg_internals/src/lib.rs
index 4d897f7a..763fb623 100644
--- a/rsvg_internals/src/lib.rs
+++ b/rsvg_internals/src/lib.rs
@@ -61,14 +61,6 @@ pub use io::rsvg_get_input_stream_for_loading;
pub use node::rsvg_node_unref;
-pub use property_bag::{
- rsvg_property_bag_free,
- rsvg_property_bag_iter_begin,
- rsvg_property_bag_iter_end,
- rsvg_property_bag_iter_next,
- rsvg_property_bag_new,
-};
-
pub use structure::rsvg_node_svg_get_size;
pub use xml::{
diff --git a/rsvg_internals/src/property_bag.rs b/rsvg_internals/src/property_bag.rs
index d11a8b14..07a6de39 100644
--- a/rsvg_internals/src/property_bag.rs
+++ b/rsvg_internals/src/property_bag.rs
@@ -1,11 +1,7 @@
use libc;
-use glib::translate::*;
-use glib_sys;
-
use std::ffi::{CStr, CString};
use std::ops::Deref;
-use std::ptr;
use std::slice;
use std::str::{self, FromStr};
@@ -138,69 +134,12 @@ impl<'a> Iterator for PropertyBagCStrIter<'a> {
}
}
-#[no_mangle]
-pub extern "C" fn rsvg_property_bag_new<'a>(
- atts: *const *const libc::c_char,
-) -> *const PropertyBag<'a> {
- let pbag = unsafe { PropertyBag::new_from_key_value_pairs(atts) };
- Box::into_raw(Box::new(pbag))
-}
-
-#[no_mangle]
-pub extern "C" fn rsvg_property_bag_free(pbag: *mut PropertyBag<'_>) {
- unsafe {
- let _ = Box::from_raw(pbag);
- }
-}
-
-#[no_mangle]
-pub extern "C" fn rsvg_property_bag_iter_begin(
- pbag: *const PropertyBag<'_>,
-) -> *mut PropertyBagCStrIter<'_> {
- assert!(!pbag.is_null());
- let pbag = unsafe { &*pbag };
-
- Box::into_raw(Box::new(pbag.cstr_iter()))
-}
-
-#[no_mangle]
-pub extern "C" fn rsvg_property_bag_iter_next(
- iter: *mut PropertyBagCStrIter<'_>,
- out_key: *mut *const libc::c_char,
- out_attr: *mut Attribute,
- out_value: *mut *const libc::c_char,
-) -> glib_sys::gboolean {
- assert!(!iter.is_null());
- let iter = unsafe { &mut *iter };
-
- if let Some((key, attr, val)) = iter.next() {
- unsafe {
- *out_key = key.as_ptr();
- *out_attr = attr;
- *out_value = val.as_ptr();
- }
- true.to_glib()
- } else {
- unsafe {
- *out_key = ptr::null();
- *out_value = ptr::null();
- }
- false.to_glib()
- }
-}
-
-#[no_mangle]
-pub extern "C" fn rsvg_property_bag_iter_end(iter: *mut PropertyBagCStrIter<'_>) {
- assert!(!iter.is_null());
-
- unsafe { Box::from_raw(iter) };
-}
-
#[cfg(test)]
mod tests {
use super::*;
use std::ffi::CString;
use std::mem;
+ use std::ptr;
#[test]
fn empty_property_bag() {
@@ -247,58 +186,4 @@ mod tests {
assert!(had_rx);
assert!(had_ry);
}
-
- #[test]
- fn property_bag_can_iterate_from_c() {
- let pairs = [
- CString::new("rx").unwrap(),
- CString::new("1").unwrap(),
- CString::new("ry").unwrap(),
- CString::new("2").unwrap(),
- ];
-
- let mut v = Vec::new();
-
- for x in &pairs {
- v.push(x.as_ptr() as *const libc::c_char);
- }
-
- v.push(ptr::null());
-
- let pbag = unsafe { PropertyBag::new_from_key_value_pairs(v.as_ptr()) };
-
- let mut had_rx: bool = false;
- let mut had_ry: bool = false;
-
- let iter = rsvg_property_bag_iter_begin(&pbag as *const PropertyBag);
-
- let mut key = unsafe { mem::uninitialized() };
- let mut att = unsafe { mem::uninitialized() };
- let mut val = unsafe { mem::uninitialized() };
-
- while from_glib(rsvg_property_bag_iter_next(
- iter,
- &mut key as *mut _,
- &mut att as *mut _,
- &mut val as *mut _,
- )) {
- let k = unsafe { CStr::from_ptr(key).to_str_utf8() };
- let v = unsafe { CStr::from_ptr(val).to_str_utf8() };
-
- if k == "rx" {
- assert!(att == Attribute::Rx);
- assert!(v == "1");
- had_rx = true;
- } else if k == "ry" {
- assert!(att == Attribute::Ry);
- assert!(v == "2");
- had_ry = true;
- }
- }
-
- rsvg_property_bag_iter_end(iter);
-
- assert!(had_rx);
- assert!(had_ry);
- }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]