-
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
916a9b3
1339422
e58870a
54a6342
bf69599
0011922
a158b80
dddb8c9
4aefe77
fbf9339
0b05226
9644e65
047c716
f746909
c2ed4b1
a39a670
8dbac98
8b84db4
241c624
4a4bebf
b98feae
c76d0b5
2e2adec
3f709ab
ec20edb
9e9410b
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