cargo fmt

parent 63e92e6e
......@@ -14,9 +14,12 @@ struct GLogField {
// type GLogFunc = unsafe extern "C" fn(domain: *const c_char, flags: c_int, message: *const c_char,
// user: gpointer);
type GLogWriterFunc =
unsafe extern "C" fn(flags: c_int, fields: *const GLogField, nr_fields: size_t, user: gpointer)
-> c_int;
type GLogWriterFunc = unsafe extern "C" fn(
flags: c_int,
fields: *const GLogField,
nr_fields: size_t,
user: gpointer,
) -> c_int;
extern "C" {
// fn g_log_set_always_fatal(flags: ::libc::c_int) -> ::libc::c_int;
......
......@@ -14,7 +14,7 @@ impl<'this> ToTokens for AncestorExtGlibWrapperTokens<'this> {
fn to_tokens(&self, tokens: &mut TokenStream) {
let rust_type = self.0.instance();
if let Some(ffi_type) = self.0.explicit_ffi() {
tokens.extend(quote!{ #rust_type => #ffi_type });
tokens.extend(quote! { #rust_type => #ffi_type });
} else {
rust_type.to_tokens(tokens);
}
......
......@@ -88,9 +88,9 @@ impl<'ast, T: Boilerplate<'ast>> BoilerplateExt<'ast> for T {
anc.to_glib_wrapper_tokens().into_token_stream()
});
if self.ancestors().len() > 0 {
quote!{ : [#(#ancestors),* ] }
quote! { : [#(#ancestors),* ] }
} else {
quote!{}
quote! {}
}
};
......
......@@ -57,11 +57,11 @@ pub fn instance_slot_trampolines<'this, 'ast: 'this>(
let receiver_instance = match parent_names {
Some(parent_names) => {
let ffi = parent_names.instance_ffi();
quote!{ #ffi }
quote! { #ffi }
}
None => {
let ffi = names.instance_ffi();
quote!{ #ffi }
quote! { #ffi }
}
};
quote! {
......
......@@ -19,7 +19,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>> ToTokens
let private_struct = self.gen_private_struct();
let new_instance = self.gen_new_instance();
tokens.extend(quote!{
tokens.extend(quote! {
#instance_struct
#impl_super_instance
#impl_instance_ffi
......@@ -87,7 +87,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>> Instance<'lt,
crate::gen::properties::property_getter(self.boilerplate.properties().iter());
let property_setter =
crate::gen::properties::property_setter(self.boilerplate.properties().iter());
quote!{
quote! {
#(#property_setter)*
#(#property_getter)*
}
......@@ -107,7 +107,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>> Instance<'lt,
let instance_init_finalize = self.get_impl_instance_init_finalize();
let property_getset = self.gen_impl_getset_property();
quote!{
quote! {
impl #instance_ffi {
#[allow(dead_code)] // not used if no virtual methods
pub(super) fn get_vtable(&self) -> &#vtable {
......@@ -196,7 +196,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>> Instance<'lt,
let init_priv_with_default = self.gen_init_priv_with_default();
let free_instance_private = self.gen_free_instance_private();
quote!{
quote! {
// Instance struct and private data initialization, called from GObject
unsafe extern "C" fn init(obj: *mut gobject_ffi::GTypeInstance, _klass: glib_ffi::gpointer) {
#[allow(unused_variables)] // not used if no private
......@@ -226,7 +226,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>> Instance<'lt,
let instance_ffi = self.boilerplate.names().instance_ffi();
let callback_guard = crate::glib_utils::glib_callback_guard();
quote!{
quote! {
unsafe extern "C" fn set_property(obj: *mut gobject_ffi::GObject,
property_id: u32,
value: *mut gobject_ffi::GValue,
......
......@@ -31,7 +31,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>> ToTokens
let gen_get_type = self.gen_get_type();
let gen_test_get_type = Test::new(self.boilerplate);
tokens.extend(quote!{
tokens.extend(quote! {
#gen_struct_def
#gen_priv_def
......@@ -78,7 +78,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
let properties = if properties_field_len > 1 {
quote! { properties: [*const gobject_ffi::GParamSpec; #properties_field_len], }
} else {
quote!{}
quote! {}
};
let names = crate::gen::signals::signal_id_names(self.boilerplate.signals());
let signal_id_names = &names;
......@@ -121,7 +121,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
let properties = if properties_field_len > 1 {
quote! { properties: [0 as *const gobject_ffi::GParamSpec; #properties_field_len], }
} else {
quote!{}
quote! {}
};
quote! {
static mut PRIV: PrivateStatic = PrivateStatic {
......@@ -178,7 +178,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
let properties = self.boilerplate.new_properties();
// If there are no properties, then there is nothing to install
if properties.len() == 0 {
return quote!{};
return quote! {};
}
match self.boilerplate.fundamental_type() {
::glib::Type::BaseObject => crate::gen::properties::properties_registration(properties),
......@@ -287,7 +287,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
}
let private = self.boilerplate.names().instance_private();
quote!{
quote! {
if mem::size_of::<#private>() > 0 {
PRIV.private_offset = gobject_ffi::g_type_add_instance_private(
g_object_id,
......@@ -307,7 +307,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
let parent_instance = self.boilerplate.parent_names().instance();
let add_instance_private = self.gen_add_instance_private();
quote!{
quote! {
fn get_type_inner() -> usize
{
let class_size = mem::size_of::<#vtable>();
......@@ -342,7 +342,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
let instance_owned = instance.to_string();
let instance_name_literal =
crate::gen::cstringliteral::CStringLiteral(instance_owned.as_str());
quote!{
quote! {
fn get_type_inner() -> usize
{
let class_size = mem::size_of::<#vtable>();
......@@ -367,7 +367,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
let callback_guard = crate::glib_utils::glib_callback_guard();
let get_type_fn_name = self.boilerplate.names().get_type_fn();
let get_type_inner = self.gen_get_type_inner();
quote!{
quote! {
#[no_mangle]
pub unsafe extern "C" fn #get_type_fn_name() -> glib_ffi::GType {
#callback_guard
......
......@@ -63,6 +63,6 @@ impl<'ast> PropertyGenExt<'ast> for Property<'ast> {
fn gen_register_override(index: usize, property: &Property<'ast>) -> TokenStream {
let name = property.name.to_string();
let index = index + 1;
quote!{ gobject_ffi::g_object_class_override_property(gobject_class, #index, ::std::ffi::CString::new(#name).unwrap().as_ptr()) }
quote! { gobject_ffi::g_object_class_override_property(gobject_class, #index, ::std::ffi::CString::new(#name).unwrap().as_ptr()) }
}
}
......@@ -129,7 +129,7 @@ impl<'lt, 'ast: 'lt, Boilerplate: boilerplate::Boilerplate<'ast>>
fn gen_external_methods(&self) -> TokenStream {
let imp_extern_methods =
crate::gen::imp::extern_methods(&self.boilerplate.names(), &self.boilerplate.slots());
quote!{ #(#imp_extern_methods)* }
quote! { #(#imp_extern_methods)* }
}
}
......
......@@ -21,7 +21,7 @@ pub fn signal_emit_methods_declaration<'ast>(
fn #emit_name(#(#rust_params),*) -> #rust_return_ty;
}
});
quote!{ #(#signals)* }
quote! { #(#signals)* }
}
pub fn signal_emit_methods<'ast>(signals: impl Iterator<Item = &'ast Signal<'ast>>) -> TokenStream {
......@@ -34,7 +34,7 @@ pub fn signal_emit_methods<'ast>(signals: impl Iterator<Item = &'ast Signal<'ast
let return_gtype = signal.sig.output.to_gtype_path();
let (initialize_return_value, convert_return_value_to_rust) = match rust_return_ty {
Ty::Unit => (quote!{}, quote! { () }),
Ty::Unit => (quote! {}, quote! { () }),
_ => (
quote! {
......@@ -75,7 +75,7 @@ pub fn signal_emit_methods<'ast>(signals: impl Iterator<Item = &'ast Signal<'ast
}
}
});
quote!{ #(#signals)* }
quote! { #(#signals)* }
}
pub fn signal_id_names<'ast>(signals: impl Iterator<Item = &'ast Signal<'ast>>) -> Vec<Ident> {
......
......@@ -32,7 +32,7 @@ impl<'ast> SlotExt for Slot<'ast> {
}
.signal_definition();
quote!{
quote! {
#sig;
}
}
......@@ -47,7 +47,7 @@ impl<'ast> SlotExt for Slot<'ast> {
};
let sig = sig.signal_definition();
quote!{
quote! {
#sig #body
}
}
......@@ -80,7 +80,7 @@ impl<'ast> SlotInnerExt for VirtualMethod<'ast> {
let name = &self.sig.name;
let args = self.sig.input_args_to_glib_types();
let instance_ffi = names.instance_ffi();
let ret = quote!{ret};
let ret = quote! {ret};
let ret_from_glib_fn = self.sig.ret_from_glib_fn(&ret);
quote! { {
let ffi: *mut #instance_ffi = <Self as glib::translate::ToGlibPtr<'_, *mut #instance_ffi>>::to_glib_none(self).0;
......
......@@ -18,28 +18,28 @@ pub fn tokens_GObjectClassFfi() -> TokenStream {
pub fn tokens_glib_type(gtype: &::glib::Type) -> TokenStream {
match gtype {
::glib::Type::Invalid => quote!{ ::gobject_class::glib::Type::Invalid },
::glib::Type::Unit => quote!{ ::gobject_class::glib::Type::Unit },
::glib::Type::BaseInterface => quote!{ ::gobject_class::glib::Type::BaseInterface },
::glib::Type::I8 => quote!{ ::gobject_class::glib::Type::I8 },
::glib::Type::U8 => quote!{ ::gobject_class::glib::Type::U8 },
::glib::Type::Bool => quote!{ ::gobject_class::glib::Type::Bool},
::glib::Type::I32 => quote!{ ::gobject_class::glib::Type::I32 },
::glib::Type::U32 => quote!{ ::gobject_class::glib::Type::U32 },
::glib::Type::ILong => quote!{ ::gobject_class::glib::Type::ILong },
::glib::Type::ULong => quote!{ ::gobject_class::glib::Type::ULong },
::glib::Type::I64 => quote!{ ::gobject_class::glib::Type::I64 },
::glib::Type::U64 => quote!{ ::gobject_class::glib::Type::U64 },
::glib::Type::BaseEnum => quote!{ ::gobject_class::glib::Type::BaseEnum },
::glib::Type::BaseFlags => quote!{ ::gobject_class::glib::Type::BaseFlags },
::glib::Type::F32 => quote!{ ::gobject_class::glib::Type::F32 },
::glib::Type::F64 => quote!{ ::gobject_class::glib::Type::F64 },
::glib::Type::String => quote!{ ::gobject_class::glib::Type::String },
::glib::Type::Pointer => quote!{ ::gobject_class::glib::Type::Pointer },
::glib::Type::BaseBoxed => quote!{ ::gobject_class::glib::Type::BaseBoxed },
::glib::Type::BaseParamSpec => quote!{ ::gobject_class::glib::Type::BaseParamSpec },
::glib::Type::BaseObject => quote!{ ::gobject_class::glib::Type::BaseObject },
::glib::Type::Variant => quote!{ ::gobject_class::glib::Type::Variant },
::glib::Type::Invalid => quote! { ::gobject_class::glib::Type::Invalid },
::glib::Type::Unit => quote! { ::gobject_class::glib::Type::Unit },
::glib::Type::BaseInterface => quote! { ::gobject_class::glib::Type::BaseInterface },
::glib::Type::I8 => quote! { ::gobject_class::glib::Type::I8 },
::glib::Type::U8 => quote! { ::gobject_class::glib::Type::U8 },
::glib::Type::Bool => quote! { ::gobject_class::glib::Type::Bool},
::glib::Type::I32 => quote! { ::gobject_class::glib::Type::I32 },
::glib::Type::U32 => quote! { ::gobject_class::glib::Type::U32 },
::glib::Type::ILong => quote! { ::gobject_class::glib::Type::ILong },
::glib::Type::ULong => quote! { ::gobject_class::glib::Type::ULong },
::glib::Type::I64 => quote! { ::gobject_class::glib::Type::I64 },
::glib::Type::U64 => quote! { ::gobject_class::glib::Type::U64 },
::glib::Type::BaseEnum => quote! { ::gobject_class::glib::Type::BaseEnum },
::glib::Type::BaseFlags => quote! { ::gobject_class::glib::Type::BaseFlags },
::glib::Type::F32 => quote! { ::gobject_class::glib::Type::F32 },
::glib::Type::F64 => quote! { ::gobject_class::glib::Type::F64 },
::glib::Type::String => quote! { ::gobject_class::glib::Type::String },
::glib::Type::Pointer => quote! { ::gobject_class::glib::Type::Pointer },
::glib::Type::BaseBoxed => quote! { ::gobject_class::glib::Type::BaseBoxed },
::glib::Type::BaseParamSpec => quote! { ::gobject_class::glib::Type::BaseParamSpec },
::glib::Type::BaseObject => quote! { ::gobject_class::glib::Type::BaseObject },
::glib::Type::Variant => quote! { ::gobject_class::glib::Type::Variant },
::glib::Type::Other(x) => quote! { ::gobject_class::glib::Type::Other(#x) },
}
}
......
......@@ -608,7 +608,7 @@ impl<'a> ToTokens for FnArg<'a> {
impl<'a> ToTokens for Ty<'a> {
fn to_tokens(&self, tokens: &mut TokenStream) {
match *self {
Ty::Unit => tokens.extend(quote!{ () }),
Ty::Unit => tokens.extend(quote! { () }),
Ty::Char(ref tok) => tok.to_tokens(tokens),
Ty::Bool(ref tok) => tok.to_tokens(tokens),
Ty::Integer(ref t) => t.to_tokens(tokens),
......
......@@ -163,7 +163,7 @@ impl PropertyAttributes {
pub fn flags_tokens(&self) -> TokenStream {
// gobject_ffi
let flags = self.flags();
quote!{ #flags }
quote! { #flags }
}
pub fn blurb(&self) -> &Option<Lit> {
......
......@@ -13,9 +13,12 @@ struct GLogField {
// type GLogFunc = unsafe extern "C" fn(domain: *const c_char, flags: c_int, message: *const c_char,
// user: gpointer);
type GLogWriterFunc =
unsafe extern "C" fn(flags: c_int, fields: *const GLogField, nr_fields: size_t, user: gpointer)
-> c_int;
type GLogWriterFunc = unsafe extern "C" fn(
flags: c_int,
fields: *const GLogField,
nr_fields: size_t,
user: gpointer,
) -> c_int;
extern "C" {
// fn g_log_set_always_fatal(flags: ::libc::c_int) -> ::libc::c_int;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment