Skip to content

Commit 52e41f0

Browse files
committed
feat: Add attribute macro for interface
1 parent 161ac10 commit 52e41f0

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

crates/macros/src/interface.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use crate::prelude::*;
2+
use proc_macro2::TokenStream;
3+
use quote::quote;
4+
use syn::TraitItem;
5+
6+
pub fn parser(args: TokenStream, input: TraitItem) -> Result<TokenStream> {
7+
Ok(quote! {()})
8+
}

crates/macros/src/lib.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,15 @@ mod fastcall;
66
mod function;
77
mod helpers;
88
mod impl_;
9+
mod interface;
910
mod module;
1011
mod syn_ext;
1112
mod zval;
1213

1314
use proc_macro::TokenStream;
1415
use syn::{
1516
parse_macro_input, DeriveInput, ItemConst, ItemFn, ItemForeignMod, ItemImpl, ItemStruct,
17+
TraitItem,
1618
};
1719

1820
extern crate proc_macro;
@@ -201,6 +203,23 @@ pub fn php_class(args: TokenStream, input: TokenStream) -> TokenStream {
201203
.into()
202204
}
203205

206+
///
207+
/// Declare trait as php interface class entry
208+
/// ```rust,no_run,ignore
209+
/// #[php_interface]
210+
/// trait SomeInterface {
211+
///
212+
/// }
213+
/// ```
214+
#[proc_macro_attribute]
215+
pub fn php_interface(args: TokenStream, input: TokenStream) -> TokenStream {
216+
let input = parse_macro_input!(input as TraitItem);
217+
218+
interface::parser(args.into(), input)
219+
.unwrap_or_else(|e| e.to_compile_error())
220+
.into()
221+
}
222+
204223
/// # `#[php_function]` Attribute
205224
///
206225
/// Used to annotate functions which should be exported to PHP. Note that this

0 commit comments

Comments
 (0)