I'm currently working on a macro for writting R plugins faster.
Currently, these things are needed:
- Like other normal
proc-macro
, perform token switchings. - After compile end, save meta informations obtained from the prevoius step.
- Write R wrappers.
- Decide whether adding a
#![no_std]
attribute.
Currently, 4. might be done with #![proc_macro]
, but since the proc macro will read things such as #[prelude_import]
and yield warnings, thus I am just planning to write a 'read' macro and a 'done' macro, read for functions and 'done' located at the end of the file, exporting meta informations.
and here comes the question: are proc macros executing in order?
#[read]
fn foo(){}
mod bar{
#[read]
fn bar(){}
}
mod baz{
#[read]
fn baz(){}
}
done!{}
// for rextendr, here would be
// i_forgot_the_name!{
// fn foo;
// mod bar; // I'm not sure whether it is the correct grammar for rextendr
// fn bar;
// mod baz;
// fn baz;
//}
// this could generate a slice `const META: &[Meta]=&[("foo\0".as_ptr() as *const c_char, foo as *const c_void, 0),(...),...,(ptr::null(),ptr::null(),0)]` //the tuple is named and has #[repr(C)], I omit the name
Is there some feature that could ensure done
is executed after all the #[read]
finishes?
Should I writting a multi-threading logic to prevent potential data racing in proc_macro?
What's more, is there a safe folder that could always write to? Currently proc_macro is not safe(since it could read and write everywhere) Will there some directory that proc_macro could always output to?
(Sorry for so much trouble in these days.)