1
1
#![ feature( once_cell_get_mut) ]
2
- #![ feature( macro_metavar_expr_concat) ]
2
+ // #![feature(macro_metavar_expr_concat)]
3
3
#![ allow( static_mut_refs) ]
4
4
5
5
#[ doc( include = "../README.md" ) ]
@@ -26,10 +26,29 @@ pub mod macros {
26
26
27
27
#[ macro_export]
28
28
macro_rules! with_vftable {
29
- ( $name: ident, $( fn $func: ident( $( $var: ident: $var_ty: ty) ,* ) $( -> $func_r: ty) ?) ,* , $( pub $field: ident: $field_ty: ty) ,* , ) => {
29
+ // todo: wait for macro_metavar_expr_concat to be stable [https://github.com/rust-lang/rust/issues/124225]
30
+ // ($name:ident, $(fn $func:ident($($var:ident: $var_ty:ty),*)$(-> $func_r:ty)?),*, $(pub $field:ident: $field_ty:ty),*,) => {
31
+ // #[derive(Debug)]
32
+ // #[repr(C)]
33
+ // pub struct ${concat($name, Vtbl)} {
34
+ // $(
35
+ // pub $func: extern "C" fn($($var: $var_ty,)*)$( -> $func_r)?,
36
+ // )*
37
+ // }
38
+ //
39
+ // #[derive(Debug)]
40
+ // #[repr(C)]
41
+ // pub struct $name {
42
+ // pub vtbl: *const ${concat($name, Vtbl)},
43
+ // $(
44
+ // pub $field: $field_ty,
45
+ // )*
46
+ // }
47
+ // };
48
+ ( $name: ident, $vtbl: ident, $( fn $func: ident( $( $var: ident: $var_ty: ty) ,* ) $( -> $func_r: ty) ?) ,* , $( pub $field: ident: $field_ty: ty) ,* $( , ) ?) => {
30
49
#[ derive( Debug ) ]
31
50
#[ repr( C ) ]
32
- pub struct ${ concat ( $name , Vtbl ) } {
51
+ pub struct $vtbl {
33
52
$(
34
53
pub $func: extern "C" fn ( $( $var: $var_ty, ) * ) $( -> $func_r) ?,
35
54
) *
@@ -38,7 +57,7 @@ pub mod macros {
38
57
#[ derive( Debug ) ]
39
58
#[ repr( C ) ]
40
59
pub struct $name {
41
- pub vtbl: * const ${ concat ( $name , Vtbl ) } ,
60
+ pub vtbl: * const $vtbl ,
42
61
$(
43
62
pub $field: $field_ty,
44
63
) *
0 commit comments