Skip to content

Remove callback guard #38

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 23, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ version = "4.0"
work_mode = "normal"
target_path = "."
generate_safety_asserts = true
single_version_file = true

external_libraries = [
"Gio",
"Gtk",
Expand Down
3 changes: 1 addition & 2 deletions check_init_asserts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ while (/^(\N*)\V*fn\s+(\w+)\s*(<[^(]+>)?\s*(\([^{;]+)\{\N*\n^(\N*)$/gms) {
$first_line =~ /^\s*(
assert_initialized_main_thread |
assert_not_initialized |
skip_assert_initialized |
callback_guard
skip_assert_initialized
)!\(\)/x) {
print "$ARGV: $name$signature\n";
$e = 1
Expand Down
2 changes: 1 addition & 1 deletion gir
Submodule gir updated 61 files
+140 −225 Cargo.lock
+13 −8 Cargo.toml
+20 −1 README.md
+36 −19 src/analysis/bounds.rs
+1 −1 src/analysis/child_properties.rs
+1 −0 src/analysis/conversion_type.rs
+4 −4 src/analysis/ffi_type.rs
+26 −24 src/analysis/function_parameters.rs
+156 −59 src/analysis/functions.rs
+34 −5 src/analysis/imports.rs
+3 −4 src/analysis/mod.rs
+6 −1 src/analysis/object.rs
+35 −11 src/analysis/out_parameters.rs
+74 −0 src/analysis/override_string_type.rs
+3 −1 src/analysis/properties.rs
+3 −2 src/analysis/ref_mode.rs
+10 −6 src/analysis/return_value.rs
+9 −1 src/analysis/rust_type.rs
+2 −1 src/analysis/trampolines.rs
+109 −0 src/case.rs
+2 −2 src/codegen/alias.rs
+1 −1 src/codegen/child_properties.rs
+1 −1 src/codegen/constants.rs
+1 −1 src/codegen/doc/mod.rs
+7 −6 src/codegen/enums.rs
+7 −6 src/codegen/flags.rs
+223 −7 src/codegen/function.rs
+3 −5 src/codegen/function_body_chunk.rs
+1 −1 src/codegen/functions.rs
+45 −22 src/codegen/general.rs
+11 −13 src/codegen/mod.rs
+19 −6 src/codegen/object.rs
+1 −1 src/codegen/properties.rs
+2 −2 src/codegen/record.rs
+2 −2 src/codegen/signal.rs
+2 −1 src/codegen/sys/ffi_type.rs
+2 −2 src/codegen/sys/functions.rs
+13 −13 src/codegen/sys/lib_.rs
+3 −1 src/codegen/sys/mod.rs
+2 −5 src/codegen/sys/statics.rs
+19 −10 src/codegen/sys/tests.rs
+1 −2 src/codegen/trampoline.rs
+1 −0 src/codegen/trampoline_from_glib.rs
+132 −78 src/config/config.rs
+39 −0 src/config/derives.rs
+13 −36 src/config/error.rs
+3 −5 src/config/external_libraries.rs
+51 −14 src/config/functions.rs
+16 −10 src/config/gobjects.rs
+3 −0 src/config/mod.rs
+1 −2 src/config/parsable.rs
+20 −0 src/config/string_type.rs
+57 −0 src/lib.rs
+92 −15 src/library.rs
+1 −1 src/library_postprocessing.rs
+52 −65 src/main.rs
+0 −1 src/nameutil.rs
+65 −50 src/parser.rs
+4 −4 src/version.rs
+81 −43 src/xmlparser.rs
+5 −0 tests/sys/gir-secret.toml
2 changes: 1 addition & 1 deletion gir-files
2 changes: 2 additions & 0 deletions gir-webkit2.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ work_mode = "sys"
min_cfg_version="2.4"
library = "WebKit2"
version = "4.0"
single_version_file = "."

external_libraries = [
"Gtk",
"GLib",
Expand Down
5 changes: 2 additions & 3 deletions src/auto/authentication_request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(any(feature = "v2_2", feature = "dox"))]
Expand Down Expand Up @@ -142,7 +142,6 @@ impl<O: IsA<AuthenticationRequest> + IsA<glib::object::Object>> AuthenticationRe
#[cfg(any(feature = "v2_2", feature = "dox"))]
unsafe extern "C" fn cancelled_trampoline<P>(this: *mut ffi::WebKitAuthenticationRequest, f: glib_ffi::gpointer)
where P: IsA<AuthenticationRequest> {
callback_guard!();
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&AuthenticationRequest::from_glib_borrow(this).downcast_unchecked())
}
4 changes: 2 additions & 2 deletions src/auto/back_forward_list.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use BackForwardListItem;
Expand Down
4 changes: 2 additions & 2 deletions src/auto/back_forward_list_item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use ffi;
Expand Down
6 changes: 2 additions & 4 deletions src/auto/color_chooser_request.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use ffi;
Expand Down Expand Up @@ -128,14 +128,12 @@ impl<O: IsA<ColorChooserRequest> + IsA<glib::object::Object>> ColorChooserReques
#[cfg(any(feature = "v2_8", feature = "dox"))]
unsafe extern "C" fn finished_trampoline<P>(this: *mut ffi::WebKitColorChooserRequest, f: glib_ffi::gpointer)
where P: IsA<ColorChooserRequest> {
callback_guard!();
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&ColorChooserRequest::from_glib_borrow(this).downcast_unchecked())
}

unsafe extern "C" fn notify_rgba_trampoline<P>(this: *mut ffi::WebKitColorChooserRequest, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
where P: IsA<ColorChooserRequest> {
callback_guard!();
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&ColorChooserRequest::from_glib_borrow(this).downcast_unchecked())
}
4 changes: 2 additions & 2 deletions src/auto/context_menu.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use ContextMenuItem;
Expand Down
4 changes: 2 additions & 2 deletions src/auto/context_menu_item.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use ContextMenu;
Expand Down
218 changes: 206 additions & 12 deletions src/auto/cookie_manager.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use CookieAcceptPolicy;
use CookiePersistentStorage;
use Error;
use ffi;
#[cfg(feature = "futures")]
use futures_core;
use gio;
use gio_ffi;
use glib;
use glib::object::Downcast;
use glib::object::IsA;
Expand All @@ -26,17 +31,45 @@ glib_wrapper! {
}
}

pub trait CookieManagerExt {
pub trait CookieManagerExt: Sized {
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn add_cookie<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cookie: /*Ignored*/&mut soup::Cookie, cancellable: P, callback: Q);

//#[cfg(feature = "futures")]
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn add_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>>;

#[cfg_attr(feature = "v2_16", deprecated)]
fn delete_all_cookies(&self);

//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn delete_cookie<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cookie: /*Ignored*/&mut soup::Cookie, cancellable: P, callback: Q);

//#[cfg(feature = "futures")]
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn delete_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>>;

#[cfg_attr(feature = "v2_16", deprecated)]
fn delete_cookies_for_domain(&self, domain: &str);

//fn get_accept_policy<'a, 'b, P: Into<Option<&'a gio::Cancellable>>, Q: Into<Option<&'b /*Ignored*/gio::AsyncReadyCallback>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, cancellable: P, callback: Q, user_data: R);
fn get_accept_policy<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<CookieAcceptPolicy, Error>) + Send + 'static>(&self, cancellable: P, callback: Q);

#[cfg(feature = "futures")]
fn get_accept_policy_future(&self) -> Box_<futures_core::Future<Item = (Self, CookieAcceptPolicy), Error = (Self, Error)>>;

//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn get_cookies<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result</*Ignored*/Vec<soup::Cookie>, Error>) + Send + 'static>(&self, uri: &str, cancellable: P, callback: Q);

//#[cfg_attr(feature = "v2_16", deprecated)]
//fn get_domains_with_cookies<'a, 'b, P: Into<Option<&'a gio::Cancellable>>, Q: Into<Option<&'b /*Ignored*/gio::AsyncReadyCallback>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, cancellable: P, callback: Q, user_data: R);
//#[cfg(feature = "futures")]
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn get_cookies_future(&self, uri: &str) -> Box_<futures_core::Future<Item = (Self, /*Ignored*/Vec<soup::Cookie>), Error = (Self, Error)>>;

#[cfg_attr(feature = "v2_16", deprecated)]
fn get_domains_with_cookies<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<Vec<String>, Error>) + Send + 'static>(&self, cancellable: P, callback: Q);

#[cfg_attr(feature = "v2_16", deprecated)]
#[cfg(feature = "futures")]
fn get_domains_with_cookies_future(&self) -> Box_<futures_core::Future<Item = (Self, Vec<String>), Error = (Self, Error)>>;

fn set_accept_policy(&self, policy: CookieAcceptPolicy);

Expand All @@ -45,27 +78,189 @@ pub trait CookieManagerExt {
fn connect_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}

impl<O: IsA<CookieManager> + IsA<glib::object::Object>> CookieManagerExt for O {
impl<O: IsA<CookieManager> + IsA<glib::object::Object> + Clone + 'static> CookieManagerExt for O {
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn add_cookie<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cookie: /*Ignored*/&mut soup::Cookie, cancellable: P, callback: Q) {
// unsafe { TODO: call ffi::webkit_cookie_manager_add_cookie() }
//}

//#[cfg(feature = "futures")]
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn add_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>> {
//use gio::GioFuture;
//use send_cell::SendCell;

//let cookie = cookie.clone();
//GioFuture::new(self, move |obj, send| {
// let cancellable = gio::Cancellable::new();
// let send = SendCell::new(send);
// let obj_clone = SendCell::new(obj.clone());
// obj.add_cookie(
// &cookie,
// Some(&cancellable),
// move |res| {
// let obj = obj_clone.into_inner();
// let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
// let _ = send.into_inner().send(res);
// },
// );

// cancellable
//})
//}

fn delete_all_cookies(&self) {
unsafe {
ffi::webkit_cookie_manager_delete_all_cookies(self.to_glib_none().0);
}
}

//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn delete_cookie<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<(), Error>) + Send + 'static>(&self, cookie: /*Ignored*/&mut soup::Cookie, cancellable: P, callback: Q) {
// unsafe { TODO: call ffi::webkit_cookie_manager_delete_cookie() }
//}

//#[cfg(feature = "futures")]
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn delete_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>> {
//use gio::GioFuture;
//use send_cell::SendCell;

//let cookie = cookie.clone();
//GioFuture::new(self, move |obj, send| {
// let cancellable = gio::Cancellable::new();
// let send = SendCell::new(send);
// let obj_clone = SendCell::new(obj.clone());
// obj.delete_cookie(
// &cookie,
// Some(&cancellable),
// move |res| {
// let obj = obj_clone.into_inner();
// let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
// let _ = send.into_inner().send(res);
// },
// );

// cancellable
//})
//}

fn delete_cookies_for_domain(&self, domain: &str) {
unsafe {
ffi::webkit_cookie_manager_delete_cookies_for_domain(self.to_glib_none().0, domain.to_glib_none().0);
}
}

//fn get_accept_policy<'a, 'b, P: Into<Option<&'a gio::Cancellable>>, Q: Into<Option<&'b /*Ignored*/gio::AsyncReadyCallback>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, cancellable: P, callback: Q, user_data: R) {
// unsafe { TODO: call ffi::webkit_cookie_manager_get_accept_policy() }
fn get_accept_policy<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<CookieAcceptPolicy, Error>) + Send + 'static>(&self, cancellable: P, callback: Q) {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
unsafe extern "C" fn get_accept_policy_trampoline<Q: FnOnce(Result<CookieAcceptPolicy, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
{
let mut error = ptr::null_mut();
let ret = ffi::webkit_cookie_manager_get_accept_policy_finish(_source_object as *mut _, res, &mut error);
let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) };
let callback: Box<Box<Q>> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = get_accept_policy_trampoline::<Q>;
unsafe {
ffi::webkit_cookie_manager_get_accept_policy(self.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _);
}
}

#[cfg(feature = "futures")]
fn get_accept_policy_future(&self) -> Box_<futures_core::Future<Item = (Self, CookieAcceptPolicy), Error = (Self, Error)>> {
use gio::GioFuture;
use send_cell::SendCell;

GioFuture::new(self, move |obj, send| {
let cancellable = gio::Cancellable::new();
let send = SendCell::new(send);
let obj_clone = SendCell::new(obj.clone());
obj.get_accept_policy(
Some(&cancellable),
move |res| {
let obj = obj_clone.into_inner();
let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
let _ = send.into_inner().send(res);
},
);

cancellable
})
}

//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn get_cookies<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result</*Ignored*/Vec<soup::Cookie>, Error>) + Send + 'static>(&self, uri: &str, cancellable: P, callback: Q) {
// unsafe { TODO: call ffi::webkit_cookie_manager_get_cookies() }
//}

//fn get_domains_with_cookies<'a, 'b, P: Into<Option<&'a gio::Cancellable>>, Q: Into<Option<&'b /*Ignored*/gio::AsyncReadyCallback>>, R: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(&self, cancellable: P, callback: Q, user_data: R) {
// unsafe { TODO: call ffi::webkit_cookie_manager_get_domains_with_cookies() }
//#[cfg(feature = "futures")]
//#[cfg(any(feature = "v2_20", feature = "dox"))]
//fn get_cookies_future(&self, uri: &str) -> Box_<futures_core::Future<Item = (Self, /*Ignored*/Vec<soup::Cookie>), Error = (Self, Error)>> {
//use gio::GioFuture;
//use send_cell::SendCell;

//let uri = String::from(uri);
//GioFuture::new(self, move |obj, send| {
// let cancellable = gio::Cancellable::new();
// let send = SendCell::new(send);
// let obj_clone = SendCell::new(obj.clone());
// obj.get_cookies(
// &uri,
// Some(&cancellable),
// move |res| {
// let obj = obj_clone.into_inner();
// let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
// let _ = send.into_inner().send(res);
// },
// );

// cancellable
//})
//}

fn get_domains_with_cookies<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<Vec<String>, Error>) + Send + 'static>(&self, cancellable: P, callback: Q) {
let cancellable = cancellable.into();
let cancellable = cancellable.to_glib_none();
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
unsafe extern "C" fn get_domains_with_cookies_trampoline<Q: FnOnce(Result<Vec<String>, Error>) + Send + 'static>(_source_object: *mut gobject_ffi::GObject, res: *mut gio_ffi::GAsyncResult, user_data: glib_ffi::gpointer)
{
let mut error = ptr::null_mut();
let ret = ffi::webkit_cookie_manager_get_domains_with_cookies_finish(_source_object as *mut _, res, &mut error);
let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) };
let callback: Box<Box<Q>> = Box::from_raw(user_data as *mut _);
callback(result);
}
let callback = get_domains_with_cookies_trampoline::<Q>;
unsafe {
ffi::webkit_cookie_manager_get_domains_with_cookies(self.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _);
}
}

#[cfg(feature = "futures")]
fn get_domains_with_cookies_future(&self) -> Box_<futures_core::Future<Item = (Self, Vec<String>), Error = (Self, Error)>> {
use gio::GioFuture;
use send_cell::SendCell;

GioFuture::new(self, move |obj, send| {
let cancellable = gio::Cancellable::new();
let send = SendCell::new(send);
let obj_clone = SendCell::new(obj.clone());
obj.get_domains_with_cookies(
Some(&cancellable),
move |res| {
let obj = obj_clone.into_inner();
let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
let _ = send.into_inner().send(res);
},
);

cancellable
})
}

fn set_accept_policy(&self, policy: CookieAcceptPolicy) {
unsafe {
ffi::webkit_cookie_manager_set_accept_policy(self.to_glib_none().0, policy.to_glib());
Expand All @@ -89,7 +284,6 @@ impl<O: IsA<CookieManager> + IsA<glib::object::Object>> CookieManagerExt for O {

unsafe extern "C" fn changed_trampoline<P>(this: *mut ffi::WebKitCookieManager, f: glib_ffi::gpointer)
where P: IsA<CookieManager> {
callback_guard!();
let f: &&(Fn(&P) + 'static) = transmute(f);
f(&CookieManager::from_glib_borrow(this).downcast_unchecked())
}
4 changes: 2 additions & 2 deletions src/auto/credential.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

#[cfg(any(feature = "v2_2", feature = "dox"))]
Expand Down
Loading