-
Notifications
You must be signed in to change notification settings - Fork 76
Feat/interface impl #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feat/interface impl #533
Changes from all commits
27d96cd
9ed4ad8
eabefe9
263a086
aa2290a
cec3b92
d5443b5
458d019
2f85f73
aba640f
f99b28a
75ce70e
04fdc10
9b13b24
19a902d
9c45dd8
d354e48
e67f974
b7d2273
473f628
855b49a
500a7f7
34580c9
fa449e5
c0dcacd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,40 @@ impl<'a> Function<'a> { | |
format_ident!("_internal_{}", &self.ident) | ||
} | ||
|
||
pub fn abstract_function_builder(&self) -> TokenStream { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make new builder, cause for interface we don't need a CallType |
||
let name = &self.name; | ||
let (required, not_required) = self.args.split_args(self.optional.as_ref()); | ||
|
||
// `entry` impl | ||
let required_args = required | ||
.iter() | ||
.map(TypedArg::arg_builder) | ||
.collect::<Vec<_>>(); | ||
let not_required_args = not_required | ||
.iter() | ||
.map(TypedArg::arg_builder) | ||
.collect::<Vec<_>>(); | ||
|
||
let returns = self.build_returns(); | ||
let docs = if self.docs.is_empty() { | ||
quote! {} | ||
} else { | ||
let docs = &self.docs; | ||
quote! { | ||
.docs(&[#(#docs),*]) | ||
} | ||
}; | ||
|
||
quote! { | ||
::ext_php_rs::builders::FunctionBuilder::new_abstract(#name) | ||
#(.arg(#required_args))* | ||
.not_required() | ||
#(.arg(#not_required_args))* | ||
#returns | ||
#docs | ||
} | ||
} | ||
|
||
/// Generates the function builder for the function. | ||
pub fn function_builder(&self, call_type: CallType) -> TokenStream { | ||
let name = &self.name; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,13 @@ pub fn get_docs(attrs: &[Attribute]) -> Result<Vec<String>> { | |
}) | ||
.collect::<Result<Vec<_>>>() | ||
} | ||
|
||
pub trait CleanPhpAttr { | ||
fn clean_php(&mut self); | ||
} | ||
|
||
impl CleanPhpAttr for Vec<Attribute> { | ||
fn clean_php(&mut self) { | ||
self.retain(|attr| !attr.path().is_ident("php")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just tired write retain for php everywhere)) |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,7 +125,7 @@ struct ParsedImpl<'a> { | |
} | ||
|
||
#[derive(Debug, Eq, Hash, PartialEq)] | ||
enum MethodModifier { | ||
pub enum MethodModifier { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make public to not duplicate |
||
Abstract, | ||
Static, | ||
} | ||
|
@@ -141,7 +141,7 @@ impl quote::ToTokens for MethodModifier { | |
} | ||
|
||
#[derive(Debug)] | ||
struct FnBuilder { | ||
pub struct FnBuilder { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make public to not duplicate |
||
/// Tokens which represent the `FunctionBuilder` for this function. | ||
pub builder: TokenStream, | ||
/// The visibility of this method. | ||
|
@@ -151,13 +151,13 @@ struct FnBuilder { | |
} | ||
|
||
#[derive(Debug)] | ||
struct Constant<'a> { | ||
pub struct Constant<'a> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make public to not duplicate |
||
/// Name of the constant in PHP land. | ||
name: String, | ||
pub name: String, | ||
/// Identifier of the constant in Rust land. | ||
ident: &'a syn::Ident, | ||
pub ident: &'a syn::Ident, | ||
/// Documentation for the constant. | ||
docs: Vec<String>, | ||
pub docs: Vec<String>, | ||
} | ||
|
||
impl<'a> ParsedImpl<'a> { | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make pub cause not see necessary to duplicate