Skip to content

Commit 7656b08

Browse files
authored
Merge pull request #38 from EPashkin/remove_callback_guard
Remove callback guard
2 parents e38a61d + d3c6076 commit 7656b08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1009
-451
lines changed

Gir.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ version = "4.0"
55
work_mode = "normal"
66
target_path = "."
77
generate_safety_asserts = true
8+
single_version_file = true
9+
810
external_libraries = [
911
"Gio",
1012
"Gtk",

check_init_asserts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ while (/^(\N*)\V*fn\s+(\w+)\s*(<[^(]+>)?\s*(\([^{;]+)\{\N*\n^(\N*)$/gms) {
1010
$first_line =~ /^\s*(
1111
assert_initialized_main_thread |
1212
assert_not_initialized |
13-
skip_assert_initialized |
14-
callback_guard
13+
skip_assert_initialized
1514
)!\(\)/x) {
1615
print "$ARGV: $name$signature\n";
1716
$e = 1

gir

Submodule gir updated 61 files

gir-webkit2.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ work_mode = "sys"
33
min_cfg_version="2.4"
44
library = "WebKit2"
55
version = "4.0"
6+
single_version_file = "."
7+
68
external_libraries = [
79
"Gtk",
810
"GLib",

src/auto/authentication_request.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
#[cfg(any(feature = "v2_2", feature = "dox"))]
@@ -142,7 +142,6 @@ impl<O: IsA<AuthenticationRequest> + IsA<glib::object::Object>> AuthenticationRe
142142
#[cfg(any(feature = "v2_2", feature = "dox"))]
143143
unsafe extern "C" fn cancelled_trampoline<P>(this: *mut ffi::WebKitAuthenticationRequest, f: glib_ffi::gpointer)
144144
where P: IsA<AuthenticationRequest> {
145-
callback_guard!();
146145
let f: &&(Fn(&P) + 'static) = transmute(f);
147146
f(&AuthenticationRequest::from_glib_borrow(this).downcast_unchecked())
148147
}

src/auto/back_forward_list.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
use BackForwardListItem;

src/auto/back_forward_list_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
use ffi;

src/auto/color_chooser_request.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

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

136135
unsafe extern "C" fn notify_rgba_trampoline<P>(this: *mut ffi::WebKitColorChooserRequest, _param_spec: glib_ffi::gpointer, f: glib_ffi::gpointer)
137136
where P: IsA<ColorChooserRequest> {
138-
callback_guard!();
139137
let f: &&(Fn(&P) + 'static) = transmute(f);
140138
f(&ColorChooserRequest::from_glib_borrow(this).downcast_unchecked())
141139
}

src/auto/context_menu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
use ContextMenuItem;

src/auto/context_menu_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
use ContextMenu;

src/auto/cookie_manager.rs

Lines changed: 206 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
use CookieAcceptPolicy;
66
use CookiePersistentStorage;
7+
use Error;
78
use ffi;
9+
#[cfg(feature = "futures")]
10+
use futures_core;
11+
use gio;
12+
use gio_ffi;
813
use glib;
914
use glib::object::Downcast;
1015
use glib::object::IsA;
@@ -26,17 +31,45 @@ glib_wrapper! {
2631
}
2732
}
2833

29-
pub trait CookieManagerExt {
34+
pub trait CookieManagerExt: Sized {
35+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
36+
//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);
37+
38+
//#[cfg(feature = "futures")]
39+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
40+
//fn add_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>>;
41+
3042
#[cfg_attr(feature = "v2_16", deprecated)]
3143
fn delete_all_cookies(&self);
3244

45+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
46+
//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);
47+
48+
//#[cfg(feature = "futures")]
49+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
50+
//fn delete_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>>;
51+
3352
#[cfg_attr(feature = "v2_16", deprecated)]
3453
fn delete_cookies_for_domain(&self, domain: &str);
3554

36-
//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);
55+
fn get_accept_policy<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<CookieAcceptPolicy, Error>) + Send + 'static>(&self, cancellable: P, callback: Q);
56+
57+
#[cfg(feature = "futures")]
58+
fn get_accept_policy_future(&self) -> Box_<futures_core::Future<Item = (Self, CookieAcceptPolicy), Error = (Self, Error)>>;
59+
60+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
61+
//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);
3762

38-
//#[cfg_attr(feature = "v2_16", deprecated)]
39-
//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);
63+
//#[cfg(feature = "futures")]
64+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
65+
//fn get_cookies_future(&self, uri: &str) -> Box_<futures_core::Future<Item = (Self, /*Ignored*/Vec<soup::Cookie>), Error = (Self, Error)>>;
66+
67+
#[cfg_attr(feature = "v2_16", deprecated)]
68+
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);
69+
70+
#[cfg_attr(feature = "v2_16", deprecated)]
71+
#[cfg(feature = "futures")]
72+
fn get_domains_with_cookies_future(&self) -> Box_<futures_core::Future<Item = (Self, Vec<String>), Error = (Self, Error)>>;
4073

4174
fn set_accept_policy(&self, policy: CookieAcceptPolicy);
4275

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

48-
impl<O: IsA<CookieManager> + IsA<glib::object::Object>> CookieManagerExt for O {
81+
impl<O: IsA<CookieManager> + IsA<glib::object::Object> + Clone + 'static> CookieManagerExt for O {
82+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
83+
//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) {
84+
// unsafe { TODO: call ffi::webkit_cookie_manager_add_cookie() }
85+
//}
86+
87+
//#[cfg(feature = "futures")]
88+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
89+
//fn add_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>> {
90+
//use gio::GioFuture;
91+
//use send_cell::SendCell;
92+
93+
//let cookie = cookie.clone();
94+
//GioFuture::new(self, move |obj, send| {
95+
// let cancellable = gio::Cancellable::new();
96+
// let send = SendCell::new(send);
97+
// let obj_clone = SendCell::new(obj.clone());
98+
// obj.add_cookie(
99+
// &cookie,
100+
// Some(&cancellable),
101+
// move |res| {
102+
// let obj = obj_clone.into_inner();
103+
// let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
104+
// let _ = send.into_inner().send(res);
105+
// },
106+
// );
107+
108+
// cancellable
109+
//})
110+
//}
111+
49112
fn delete_all_cookies(&self) {
50113
unsafe {
51114
ffi::webkit_cookie_manager_delete_all_cookies(self.to_glib_none().0);
52115
}
53116
}
54117

118+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
119+
//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) {
120+
// unsafe { TODO: call ffi::webkit_cookie_manager_delete_cookie() }
121+
//}
122+
123+
//#[cfg(feature = "futures")]
124+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
125+
//fn delete_cookie_future(&self, cookie: /*Ignored*/&mut soup::Cookie) -> Box_<futures_core::Future<Item = (Self, ()), Error = (Self, Error)>> {
126+
//use gio::GioFuture;
127+
//use send_cell::SendCell;
128+
129+
//let cookie = cookie.clone();
130+
//GioFuture::new(self, move |obj, send| {
131+
// let cancellable = gio::Cancellable::new();
132+
// let send = SendCell::new(send);
133+
// let obj_clone = SendCell::new(obj.clone());
134+
// obj.delete_cookie(
135+
// &cookie,
136+
// Some(&cancellable),
137+
// move |res| {
138+
// let obj = obj_clone.into_inner();
139+
// let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
140+
// let _ = send.into_inner().send(res);
141+
// },
142+
// );
143+
144+
// cancellable
145+
//})
146+
//}
147+
55148
fn delete_cookies_for_domain(&self, domain: &str) {
56149
unsafe {
57150
ffi::webkit_cookie_manager_delete_cookies_for_domain(self.to_glib_none().0, domain.to_glib_none().0);
58151
}
59152
}
60153

61-
//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) {
62-
// unsafe { TODO: call ffi::webkit_cookie_manager_get_accept_policy() }
154+
fn get_accept_policy<'a, P: Into<Option<&'a gio::Cancellable>>, Q: FnOnce(Result<CookieAcceptPolicy, Error>) + Send + 'static>(&self, cancellable: P, callback: Q) {
155+
let cancellable = cancellable.into();
156+
let cancellable = cancellable.to_glib_none();
157+
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
158+
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)
159+
{
160+
let mut error = ptr::null_mut();
161+
let ret = ffi::webkit_cookie_manager_get_accept_policy_finish(_source_object as *mut _, res, &mut error);
162+
let result = if error.is_null() { Ok(from_glib(ret)) } else { Err(from_glib_full(error)) };
163+
let callback: Box<Box<Q>> = Box::from_raw(user_data as *mut _);
164+
callback(result);
165+
}
166+
let callback = get_accept_policy_trampoline::<Q>;
167+
unsafe {
168+
ffi::webkit_cookie_manager_get_accept_policy(self.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _);
169+
}
170+
}
171+
172+
#[cfg(feature = "futures")]
173+
fn get_accept_policy_future(&self) -> Box_<futures_core::Future<Item = (Self, CookieAcceptPolicy), Error = (Self, Error)>> {
174+
use gio::GioFuture;
175+
use send_cell::SendCell;
176+
177+
GioFuture::new(self, move |obj, send| {
178+
let cancellable = gio::Cancellable::new();
179+
let send = SendCell::new(send);
180+
let obj_clone = SendCell::new(obj.clone());
181+
obj.get_accept_policy(
182+
Some(&cancellable),
183+
move |res| {
184+
let obj = obj_clone.into_inner();
185+
let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
186+
let _ = send.into_inner().send(res);
187+
},
188+
);
189+
190+
cancellable
191+
})
192+
}
193+
194+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
195+
//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) {
196+
// unsafe { TODO: call ffi::webkit_cookie_manager_get_cookies() }
63197
//}
64198

65-
//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) {
66-
// unsafe { TODO: call ffi::webkit_cookie_manager_get_domains_with_cookies() }
199+
//#[cfg(feature = "futures")]
200+
//#[cfg(any(feature = "v2_20", feature = "dox"))]
201+
//fn get_cookies_future(&self, uri: &str) -> Box_<futures_core::Future<Item = (Self, /*Ignored*/Vec<soup::Cookie>), Error = (Self, Error)>> {
202+
//use gio::GioFuture;
203+
//use send_cell::SendCell;
204+
205+
//let uri = String::from(uri);
206+
//GioFuture::new(self, move |obj, send| {
207+
// let cancellable = gio::Cancellable::new();
208+
// let send = SendCell::new(send);
209+
// let obj_clone = SendCell::new(obj.clone());
210+
// obj.get_cookies(
211+
// &uri,
212+
// Some(&cancellable),
213+
// move |res| {
214+
// let obj = obj_clone.into_inner();
215+
// let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
216+
// let _ = send.into_inner().send(res);
217+
// },
218+
// );
219+
220+
// cancellable
221+
//})
67222
//}
68223

224+
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) {
225+
let cancellable = cancellable.into();
226+
let cancellable = cancellable.to_glib_none();
227+
let user_data: Box<Box<Q>> = Box::new(Box::new(callback));
228+
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)
229+
{
230+
let mut error = ptr::null_mut();
231+
let ret = ffi::webkit_cookie_manager_get_domains_with_cookies_finish(_source_object as *mut _, res, &mut error);
232+
let result = if error.is_null() { Ok(FromGlibPtrContainer::from_glib_full(ret)) } else { Err(from_glib_full(error)) };
233+
let callback: Box<Box<Q>> = Box::from_raw(user_data as *mut _);
234+
callback(result);
235+
}
236+
let callback = get_domains_with_cookies_trampoline::<Q>;
237+
unsafe {
238+
ffi::webkit_cookie_manager_get_domains_with_cookies(self.to_glib_none().0, cancellable.0, Some(callback), Box::into_raw(user_data) as *mut _);
239+
}
240+
}
241+
242+
#[cfg(feature = "futures")]
243+
fn get_domains_with_cookies_future(&self) -> Box_<futures_core::Future<Item = (Self, Vec<String>), Error = (Self, Error)>> {
244+
use gio::GioFuture;
245+
use send_cell::SendCell;
246+
247+
GioFuture::new(self, move |obj, send| {
248+
let cancellable = gio::Cancellable::new();
249+
let send = SendCell::new(send);
250+
let obj_clone = SendCell::new(obj.clone());
251+
obj.get_domains_with_cookies(
252+
Some(&cancellable),
253+
move |res| {
254+
let obj = obj_clone.into_inner();
255+
let res = res.map(|v| (obj.clone(), v)).map_err(|v| (obj.clone(), v));
256+
let _ = send.into_inner().send(res);
257+
},
258+
);
259+
260+
cancellable
261+
})
262+
}
263+
69264
fn set_accept_policy(&self, policy: CookieAcceptPolicy) {
70265
unsafe {
71266
ffi::webkit_cookie_manager_set_accept_policy(self.to_glib_none().0, policy.to_glib());
@@ -89,7 +284,6 @@ impl<O: IsA<CookieManager> + IsA<glib::object::Object>> CookieManagerExt for O {
89284

90285
unsafe extern "C" fn changed_trampoline<P>(this: *mut ffi::WebKitCookieManager, f: glib_ffi::gpointer)
91286
where P: IsA<CookieManager> {
92-
callback_guard!();
93287
let f: &&(Fn(&P) + 'static) = transmute(f);
94288
f(&CookieManager::from_glib_borrow(this).downcast_unchecked())
95289
}

src/auto/credential.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// This file was generated by gir (https://github.com/gtk-rs/gir @ 6855214)
2-
// from gir-files (https://github.com/gtk-rs/gir-files @ 3fde76b)
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
33
// DO NOT EDIT
44

55
#[cfg(any(feature = "v2_2", feature = "dox"))]

0 commit comments

Comments
 (0)