#[macro_export]
macro_rules! wrapper {
(
$(#[$attr:meta])*
pub struct $name:ident(Boxed<$ffi_name:ty>);
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:ty>);
match fn {
copy => |$copy_arg:ident| $copy_expr:expr,
free => |$free_arg:ident| $free_expr:expr,
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_boxed_wrapper!([$($attr)*] $name, $ffi_name, @copy $copy_arg $copy_expr,
@free $free_arg $free_expr, @type_ $get_type_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Boxed<$ffi_name:ty>);
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:ty>);
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,
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,
@type_ $get_type_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Shared<$ffi_name:ty>);
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:ty>);
match fn {
ref => |$ref_arg:ident| $ref_expr:expr,
unref => |$unref_arg:ident| $unref_expr:expr,
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_shared_wrapper!([$($attr)*] $name, $ffi_name, @ref $ref_arg $ref_expr,
@unref $unref_arg $unref_expr, @type_ $get_type_expr);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty>);
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, std::os::raw::c_void, @type_ $get_type_expr, @extends [], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty, $ffi_class_name:ty>);
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name, @type_ $get_type_expr, @extends [], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty>) @extends $($extends:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, std::os::raw::c_void,
@type_ $get_type_expr, @extends [$($extends),+], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty, $ffi_class_name:ty>) @extends $($extends:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name,
@type_ $get_type_expr, @extends [$($extends),+], @implements []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty>) @implements $($implements:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, std::os::raw::c_void,
@type_ $get_type_expr, @extends [], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty, $ffi_class_name:ty>) @implements $($implements:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name,
@type_ $get_type_expr, @extends [], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty>) @extends $($extends:path),+, @implements $($implements:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, std::os::raw::c_void,
@type_ $get_type_expr, @extends [$($extends),+], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:ty, $ffi_class_name:ty>) @extends $($extends:path),+, @implements $($implements:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, $ffi_name, $ffi_class_name,
@type_ $get_type_expr, @extends [$($extends),+], @implements [$($implements),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(ObjectSubclass<$subclass:ty>);
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, <$subclass as $crate::subclass::types::ObjectSubclass>::Instance, <$subclass as $crate::subclass::types::ObjectSubclass>::Class,
@type_ $crate::translate::IntoGlib::into_glib(<$subclass as $crate::subclass::types::ObjectSubclassType>::type_()),
@extends [], @implements []);
unsafe impl $crate::object::ObjectSubclassIs for $name {
type Subclass = $subclass;
}
};
(
$(#[$attr:meta])*
pub struct $name:ident(ObjectSubclass<$subclass:ty>) @implements $($implements:path),+;
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, <$subclass as $crate::subclass::types::ObjectSubclass>::Instance, <$subclass as $crate::subclass::types::ObjectSubclass>::Class,
@type_ $crate::translate::IntoGlib::into_glib(<$subclass as $crate::subclass::types::ObjectSubclassType>::type_()),
@extends [], @implements [$($implements),+]);
unsafe impl $crate::object::ObjectSubclassIs for $name {
type Subclass = $subclass;
}
};
(
$(#[$attr:meta])*
pub struct $name:ident(ObjectSubclass<$subclass:ty>) @extends $($extends:path),+;
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, <$subclass as $crate::subclass::types::ObjectSubclass>::Instance, <$subclass as $crate::subclass::types::ObjectSubclass>::Class,
@type_ $crate::translate::IntoGlib::into_glib(<$subclass as $crate::subclass::types::ObjectSubclassType>::type_()),
@extends [$($extends),+], @implements []);
unsafe impl $crate::object::ObjectSubclassIs for $name {
type Subclass = $subclass;
}
};
(
$(#[$attr:meta])*
pub struct $name:ident(ObjectSubclass<$subclass:ty>) @extends $($extends:path),+, @implements $($implements:path),+;
) => {
$crate::glib_object_wrapper!(@object [$($attr)*] $name, <$subclass as $crate::subclass::types::ObjectSubclass>::Instance, <$subclass as $crate::subclass::types::ObjectSubclass>::Class,
@type_ $crate::translate::IntoGlib::into_glib(<$subclass as $crate::subclass::types::ObjectSubclassType>::type_()),
@extends [$($extends),+], @implements [$($implements),+]);
unsafe impl $crate::object::ObjectSubclassIs for $name {
type Subclass = $subclass;
}
};
(
$(#[$attr:meta])*
pub struct $name:ident(Interface<$ffi_name:ty>);
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, $ffi_name, std::os::raw::c_void, @type_ $get_type_expr, @requires []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Interface<$ffi_name:ty>) @requires $($requires:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, $ffi_name, std::os::raw::c_void, @type_ $get_type_expr, @requires [$($requires),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Interface<$ffi_name:ty, $ffi_class_name:ty>);
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, $ffi_name, $ffi_class_name, @type_ $get_type_expr, @requires []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Interface<$ffi_name:ty, $ffi_class_name:ty>) @requires $($requires:path),+;
match fn {
type_ => || $get_type_expr:expr,
}
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, $ffi_name, $ffi_class_name, @type_ $get_type_expr, @requires [$($requires),+]);
};
(
$(#[$attr:meta])*
pub struct $name:ident(ObjectInterface<$iface_name:ty>);
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, std::os::raw::c_void, $iface_name,
@type_ $crate::translate::IntoGlib::into_glib(<$iface_name as $crate::subclass::interface::ObjectInterfaceType>::type_()),
@requires []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(ObjectInterface<$iface_name:ty>) @requires $($requires:path),+;
) => {
$crate::glib_object_wrapper!(@interface [$($attr)*] $name, std::os::raw::c_void, $iface_name,
@type_ $crate::translate::IntoGlib::into_glib(<$iface_name as $crate::subclass::interface::ObjectInterfaceType>::type_()),
@requires [$($requires),+]);
};
}