#[macro_export]
macro_rules! glib_wrapper {
(
$(#[$attr:meta])*
pub struct $name:ident(Boxed<$ffi_name:path>);
match fn {
copy => |$copy_arg:ident| $copy_expr:expr,
free => |$free_arg:ident| $free_expr:expr,
}
) => {
$crate::glib_boxed_wrapper!([$($attr)*] $name, $ffi_name, @copy $copy_arg $copy_expr,
@free $free_arg $free_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Boxed<$ffi_name:path>);
match fn {
copy => |$copy_arg:ident| $copy_expr:expr,
free => |$free_arg:ident| $free_expr:expr,
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_boxed_wrapper!([$($attr)*] $name, $ffi_name, @copy $copy_arg $copy_expr,
@free $free_arg $free_expr, @get_type $get_type_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Boxed<$ffi_name:path>);
match fn {
copy => |$copy_arg:ident| $copy_expr:expr,
free => |$free_arg:ident| $free_expr:expr,
init => |$init_arg:ident| $init_expr:expr,
clear => |$clear_arg:ident| $clear_expr:expr,
}
) => {
$crate::glib_boxed_wrapper!([$($attr)*] $name, $ffi_name, @copy $copy_arg $copy_expr,
@free $free_arg $free_expr, @init $init_arg $init_expr, @clear $clear_arg $clear_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Boxed<$ffi_name:path>);
match fn {
copy => |$copy_arg:ident| $copy_expr:expr,
free => |$free_arg:ident| $free_expr:expr,
init => |$init_arg:ident| $init_expr:expr,
clear => |$clear_arg:ident| $clear_expr:expr,
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_boxed_wrapper!([$($attr)*] $name, $ffi_name, @copy $copy_arg $copy_expr,
@free $free_arg $free_expr, @init $init_arg $init_expr, @clear $clear_arg $clear_expr,
@get_type $get_type_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Shared<$ffi_name:path>);
match fn {
ref => |$ref_arg:ident| $ref_expr:expr,
unref => |$unref_arg:ident| $unref_expr:expr,
}
) => {
$crate::glib_shared_wrapper!([$($attr)*] $name, $ffi_name, @ref $ref_arg $ref_expr,
@unref $unref_arg $unref_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Shared<$ffi_name:path>);
match fn {
ref => |$ref_arg:ident| $ref_expr:expr,
unref => |$unref_arg:ident| $unref_expr:expr,
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_shared_wrapper!([$($attr)*] $name, $ffi_name, @ref $ref_arg $ref_expr,
@unref $unref_arg $unref_expr, @get_type $get_type_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $rust_class_name:ident>);
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $crate::wrapper::Void, $rust_class_name, @get_type $get_type_expr, @extends [], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $ffi_class_name:path, $rust_class_name:ident>);
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name, $rust_class_name, @get_type $get_type_expr, @extends [], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $rust_class_name:ident>) @extends $($extends:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $crate::wrapper::Void, $rust_class_name,
@get_type $get_type_expr, @extends [$($extends),+], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $ffi_class_name:path, $rust_class_name:ident>) @extends $($extends:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name, $rust_class_name,
@get_type $get_type_expr, @extends [$($extends),+], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $rust_class_name:ident>) @implements $($implements:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $crate::wrapper::Void, $rust_class_name,
@get_type $get_type_expr, @extends [], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $ffi_class_name:path, $rust_class_name:ident>) @implements $($implements:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name, $rust_class_name,
@get_type $get_type_expr, @extends [], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $rust_class_name:ident>) @extends $($extends:path),+, @implements $($implements:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $crate::wrapper::Void, $rust_class_name,
@get_type $get_type_expr, @extends [$($extends),+], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path, $ffi_class_name:path, $rust_class_name:ident>) @extends $($extends:path),+, @implements $($implements:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name, $rust_class_name,
@get_type $get_type_expr, @extends [$($extends),+], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Interface<$ffi_name:path>);
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, $ffi_name, @get_type $get_type_expr, @requires []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Interface<$ffi_name:path>) @requires $($requires:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, $ffi_name, @get_type $get_type_expr, @requires [$($requires),+]);
};
}
pub type Void = ();