#[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,
}
) => {
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,
}
) => {
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(Shared<$ffi_name:path>);
match fn {
ref => |$ref_arg:ident| $ref_expr:expr,
unref => |$unref_arg:ident| $unref_expr:expr,
}
) => {
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,
}
) => {
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>);
match fn {
get_type => || $get_type_expr:expr,
}
) => {
glib_object_wrapper!([$($attr)*] $name, $ffi_name, @get_type $get_type_expr, []);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path>): [$($implements:tt)+];
match fn {
get_type => || $get_type_expr:expr,
}
) => {
glib_object_wrapper!([$($attr)*] $name, $ffi_name, @get_type $get_type_expr,
@implements $($implements)+);
};
(
$(#[$attr:meta])*
pub struct $name:ident(Object<$ffi_name:path>): $($implements:path),+;
match fn {
get_type => || $get_type_expr:expr,
}
) => {
glib_object_wrapper!([$($attr)*] $name, $ffi_name, @get_type $get_type_expr,
[$($implements),+]);
};
}
pub trait Wrapper {
type GlibType: 'static;
}
pub trait UnsafeFrom<T> {
unsafe fn from(t: T) -> Self;
}