Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/macros/src/impl_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub enum ParsedAttribute {
},
Constructor,
This,
Abstract,
}

#[derive(Default, Debug, FromMeta)]
Expand Down Expand Up @@ -212,6 +213,7 @@ pub fn parse_attribute(attr: &Attribute) -> Result<Option<ParsedAttribute>> {
"public" => ParsedAttribute::Visibility(Visibility::Public),
"protected" => ParsedAttribute::Visibility(Visibility::Protected),
"private" => ParsedAttribute::Visibility(Visibility::Private),
"abstract_method" => ParsedAttribute::Abstract,
"rename" => {
let ident = if let Meta::List(list) = meta {
if let Some(NestedMeta::Lit(lit)) = list.nested.first() {
Expand Down
8 changes: 8 additions & 0 deletions crates/macros/src/method.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub struct Method {
pub optional: Option<String>,
pub output: Option<(String, bool)>,
pub _static: bool,
pub _abstract: bool,
pub visibility: Visibility,
}

Expand Down Expand Up @@ -81,6 +82,7 @@ pub fn parser(
let mut visibility = Visibility::Public;
let mut as_prop = None;
let mut identifier = None;
let mut is_abstract = false;
let mut is_constructor = false;
let docs = get_docs(&input.attrs);

Expand All @@ -90,6 +92,7 @@ pub fn parser(
ParsedAttribute::Default(list) => defaults = list,
ParsedAttribute::Optional(name) => optional = Some(name),
ParsedAttribute::Visibility(vis) => visibility = vis,
ParsedAttribute::Abstract => is_abstract = true,
ParsedAttribute::Rename(ident) => identifier = Some(ident),
ParsedAttribute::Property { prop_name, ty } => {
if as_prop.is_some() {
Expand Down Expand Up @@ -211,6 +214,7 @@ pub fn parser(
optional,
output: get_return_type(struct_ty, &input.sig.output)?,
_static: matches!(method_type, MethodType::Static),
_abstract: is_abstract,
visibility,
};

Expand Down Expand Up @@ -447,6 +451,10 @@ impl Method {
flags.push(quote! { Static });
}

if self._abstract {
flags.push(quote! { Abstract });
}

flags
.iter()
.map(|flag| quote! { ::ext_php_rs::flags::MethodFlags::#flag })
Expand Down