[librsvg: 13/22] LoadFlags: renamed from LoadOptions
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/22] LoadFlags: renamed from LoadOptions
- Date: Tue, 8 Jan 2019 17:54:18 +0000 (UTC)
commit 661c723001343b41d4382dbd58e60616321948c8
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 7 21:22:55 2019 -0600
LoadFlags: renamed from LoadOptions
LoadOptions: new struct with a flags field; this will also hold the
base_uri soon.
rsvg_internals/src/handle.rs | 40 ++++++++++++++++++++++++++++------------
rsvg_internals/src/xml2_load.rs | 2 +-
2 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/rsvg_internals/src/handle.rs b/rsvg_internals/src/handle.rs
index 830d40c7..d860411c 100644
--- a/rsvg_internals/src/handle.rs
+++ b/rsvg_internals/src/handle.rs
@@ -79,7 +79,7 @@ pub struct RsvgPositionData {
/// We communicate these to/from the C code with a guint <-> u32,
/// and this struct provides to_flags() and from_flags() methods.
#[derive(Default, Copy, Clone)]
-pub struct LoadOptions {
+pub struct LoadFlags {
/// Whether to turn off size limits in libxml2
pub unlimited_size: bool,
@@ -87,6 +87,16 @@ pub struct LoadOptions {
pub keep_image_data: bool,
}
+pub struct LoadOptions {
+ pub flags: LoadFlags,
+}
+
+impl LoadOptions {
+ fn new(flags: LoadFlags) -> LoadOptions {
+ LoadOptions { flags }
+ }
+}
+
#[derive(Copy, Clone, PartialEq)]
pub enum LoadState {
Start,
@@ -100,7 +110,7 @@ pub struct Handle {
base_url: RefCell<Option<Url>>,
base_url_cstring: RefCell<Option<CString>>, // needed because the C api returns *const char
svg: RefCell<Option<Rc<Svg>>>,
- load_options: Cell<LoadOptions>,
+ load_flags: Cell<LoadFlags>,
load_state: Cell<LoadState>,
load: RefCell<Option<LoadContext>>,
size_closure: *mut RsvgSizeClosure,
@@ -115,7 +125,7 @@ impl Handle {
base_url: RefCell::new(None),
base_url_cstring: RefCell::new(None),
svg: RefCell::new(None),
- load_options: Cell::new(LoadOptions::default()),
+ load_flags: Cell::new(LoadFlags::default()),
load_state: Cell::new(LoadState::Start),
load: RefCell::new(None),
size_closure: ptr::null_mut(),
@@ -170,7 +180,7 @@ impl Handle {
cancellable: Option<gio::Cancellable>,
) -> Result<(), LoadingError> {
*self.svg.borrow_mut() = Some(Rc::new(Svg::load_from_stream(
- self.load_options.get(),
+ LoadOptions::new(self.load_flags.get()),
handle,
stream,
cancellable,
@@ -188,7 +198,10 @@ impl Handle {
if self.load_state.get() == LoadState::Start {
self.load_state.set(LoadState::Loading);
- self.load = RefCell::new(Some(LoadContext::new(handle, self.load_options.get())));
+ self.load = RefCell::new(Some(LoadContext::new(
+ handle,
+ LoadOptions::new(self.load_flags.get()),
+ )));
}
assert!(self.load_state.get() == LoadState::Loading);
@@ -509,12 +522,15 @@ const RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA: u32 = 1 << 1;
pub fn get_load_options(handle: *const RsvgHandle) -> LoadOptions {
let rhandle = get_rust_handle(handle);
- rhandle.load_options.get()
+
+ LoadOptions {
+ flags: rhandle.load_flags.get(),
+ }
}
-impl LoadOptions {
+impl LoadFlags {
pub fn from_flags(flags: u32) -> Self {
- LoadOptions {
+ LoadFlags {
unlimited_size: (flags & RSVG_HANDLE_FLAG_UNLIMITED) != 0,
keep_image_data: (flags & RSVG_HANDLE_FLAG_KEEP_IMAGE_DATA) != 0,
}
@@ -565,7 +581,7 @@ pub fn load_extern(load_options: &LoadOptions, aurl: &AllowedUrl) -> Result<*con
let res = rsvg_handle_new_from_gfile_sync(
file.to_glib_none().0,
- load_options.to_flags(),
+ load_options.flags.to_flags(),
ptr::null(),
ptr::null_mut(),
);
@@ -617,7 +633,7 @@ pub fn load_image_to_surface(
let surface = SharedImageSurface::from_pixbuf(&pixbuf)?.into_image_surface()?;
- if rhandle.load_options.get().keep_image_data {
+ if rhandle.load_flags.get().keep_image_data {
if let Some(mime_type) = data.content_type {
extern "C" {
fn cairo_surface_set_mime_data(
@@ -773,14 +789,14 @@ pub unsafe extern "C" fn rsvg_handle_rust_get_dpi_y(raw_handle: *const Handle) -
pub unsafe extern "C" fn rsvg_handle_rust_get_flags(raw_handle: *const Handle) -> u32 {
let rhandle = &*raw_handle;
- rhandle.load_options.get().to_flags()
+ rhandle.load_flags.get().to_flags()
}
#[no_mangle]
pub unsafe extern "C" fn rsvg_handle_rust_set_flags(raw_handle: *const Handle, flags: u32) {
let rhandle = &*raw_handle;
- rhandle.load_options.set(LoadOptions::from_flags(flags));
+ rhandle.load_flags.set(LoadFlags::from_flags(flags));
}
#[no_mangle]
diff --git a/rsvg_internals/src/xml2_load.rs b/rsvg_internals/src/xml2_load.rs
index 60d44bb7..961ebd76 100644
--- a/rsvg_internals/src/xml2_load.rs
+++ b/rsvg_internals/src/xml2_load.rs
@@ -191,7 +191,7 @@ unsafe extern "C" fn sax_get_parameter_entity_cb(
fn set_xml_parse_options(parser: xmlParserCtxtPtr, load_options: &LoadOptions) {
let mut options: libc::c_int = XML_PARSE_NONET | XML_PARSE_BIG_LINES;
- if load_options.unlimited_size {
+ if load_options.flags.unlimited_size {
options |= XML_PARSE_HUGE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]