-
Notifications
You must be signed in to change notification settings - Fork 804
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c4b19c7
commit 9cc57c7
Showing
21 changed files
with
250 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
use proc_macro2::{Span, TokenStream}; | ||
use quote::{quote_spanned, ToTokens}; | ||
|
||
pub enum Deprecation { | ||
NameAttribute, | ||
PyfnNameArgument, | ||
} | ||
|
||
impl Deprecation { | ||
fn ident(&self, span: Span) -> syn::Ident { | ||
let string = match self { | ||
Deprecation::NameAttribute => "NAME_ATTRIBUTE", | ||
Deprecation::PyfnNameArgument => "PYFN_NAME_ARGUMENT", | ||
}; | ||
syn::Ident::new(string, span) | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct Deprecations(Vec<(Deprecation, Span)>); | ||
|
||
impl Deprecations { | ||
pub fn new() -> Self { | ||
Deprecations(Vec::new()) | ||
} | ||
|
||
pub fn push(&mut self, deprecation: Deprecation, span: Span) { | ||
self.0.push((deprecation, span)) | ||
} | ||
} | ||
|
||
impl ToTokens for Deprecations { | ||
fn to_tokens(&self, tokens: &mut TokenStream) { | ||
for (deprecation, span) in &self.0 { | ||
let ident = deprecation.ident(*span); | ||
quote_spanned!( | ||
*span => | ||
let _ = pyo3::impl_::deprecations::#ident; | ||
) | ||
.to_tokens(tokens) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ mod utils; | |
|
||
mod attributes; | ||
mod defs; | ||
mod deprecations; | ||
mod from_pyobject; | ||
mod konst; | ||
mod method; | ||
|
Oops, something went wrong.