Allow #[pyimpl(with(PyRef))]

This commit is contained in:
Jeong YunWon committed 2020-09-25 02:46:07 +09:00
1 parent 1a168b9803
commit 1f309322d7
1 file changed
+18 -9
+18 -9
View File
@@ -686,18 +686,27 @@ fn extract_impl_attrs(attr: AttributeArgs) -> std::result::Result<ExtractedImplA
NestedMeta::Meta(Meta::List(syn::MetaList { path, nested, .. })) => {
if path_eq(&path, "with") {
for meta in nested {
match meta {
NestedMeta::Meta(Meta::Path(path)) => {
withs.push(quote! {
<Self as #path>::__extend_py_class(ctx, class);
});
with_slots.push(quote! {
<Self as #path>::__extend_slots(slots);
});
}
let path = match meta {
NestedMeta::Meta(Meta::Path(path)) => path,
meta => {
bail_span!(meta, "#[pyimpl(with(...))] arguments should be paths")
}
};
if path_eq(&path, "PyRef") {
// special handling for PyRef
withs.push(quote! {
PyRef::<Self>::impl_extend_class(ctx, class);
});
with_slots.push(quote! {
PyRef::<Self>::extend_slots(slots);
});
} else {
withs.push(quote! {
<Self as #path>::__extend_py_class(ctx, class);
});
with_slots.push(quote! {
<Self as #path>::__extend_slots(slots);
});
}
}
} else if path_eq(&path, "flags") {