#[macro_export]
macro_rules! c {
() => {};
(#include < $i:ident .h> $($rest:tt)*) => {c!{$($rest)*}};
(#include $l:tt $($rest:tt)*) => {c!{$($rest)*}};
(raw $body:tt $($rest:tt)*) => {c!{$($rest)*}};
(C_PARAM $name:ident : $t:ty as $ct:tt) => {
$name: $t
};
(C_PARAM $name:ident : $t:ty as $ct:tt , $($rest:tt)*) => {
$name: $t ,
c!{C_PARAM $($rest)*}
};
($(#[$m:meta])*
fn $id:ident ( $($name:ident : $t:ty as $ct:tt),* ) -> $rt:ty as $rct:tt $body:tt $($rest:tt)*) => {
extern "C"
{
$(#[$m])*
pub fn $id ( $($name : $t),* ) -> $rt ;
}
c!{$($rest)*}
};
($(#[$m:meta])*
fn $id:ident ( $($name:ident : $t:ty as $ct:tt),* ) $body:tt $($rest:tt)*) => {
extern "C"
{
$(#[$m])*
pub fn $id ( $($name : $t),* ) ;
}
c!{$($rest)*}
};
($(#[$m:meta])*
struct $id:ident { $($i:ident : $t:ty as $c:tt ,)* } $($rest:tt)*) => {
$(#[$m])*
#[repr(C)]
struct $id
{
$($i : $t ,)*
}
c!{$($rest)*}
};
($(#[$m:meta])*
enum $id:ident { $($i:ident ,)* } $($rest:tt)*) => {
$(#[$m])*
#[repr(C)]
enum $id
{
$($i ,)*
}
c!{$($rest)*}
};
}