@@ -5,13 +5,13 @@ use crate::util::{
55} ;
66use proc_macro2:: { Span , TokenStream } ;
77use quote:: { quote, quote_spanned, ToTokens } ;
8- use std:: collections:: HashMap ;
98use std:: str:: FromStr ;
9+ use std:: { borrow:: Borrow , collections:: HashMap } ;
1010use syn:: {
1111 parse:: { Parse , ParseStream , Result as ParsingResult } ,
1212 parse_quote,
1313 spanned:: Spanned ,
14- Attribute , AttributeArgs , Ident , Item , LitStr , Meta , NestedMeta , Result , Token ,
14+ Attribute , AttributeArgs , Ident , Item , LitStr , Meta , NestedMeta , Result , Token , Type ,
1515} ;
1616use syn_ext:: ext:: * ;
1717
@@ -690,11 +690,18 @@ where
690690 let item_meta = MemberItemMeta :: from_attr ( ident. clone ( ) , & item_attr) ?;
691691
692692 let py_name = item_meta. member_name ( ) ?;
693+ let member_kind = match item_meta. member_kind ( ) ? {
694+ Some ( s) => match s. as_str ( ) {
695+ "bool" => quote ! ( :: rustpython_vm:: builtins:: descriptor:: MemberKind :: Bool ) ,
696+ _ => unreachable ! ( ) ,
697+ } ,
698+ _ => quote ! ( :: rustpython_vm:: builtins:: descriptor:: MemberKind :: ObjectEx ) ,
699+ } ;
693700 let tokens = {
694701 quote_spanned ! { ident. span( ) =>
695702 class. set_str_attr(
696703 #py_name,
697- ctx. new_member( #py_name, Self :: #ident, None , class) ,
704+ ctx. new_member( #py_name, #member_kind , Self :: #ident, None , class) ,
698705 ctx,
699706 ) ;
700707 }
@@ -983,7 +990,7 @@ impl SlotItemMeta {
983990struct MemberItemMeta ( ItemMetaInner ) ;
984991
985992impl ItemMeta for MemberItemMeta {
986- const ALLOWED_NAMES : & ' static [ & ' static str ] = & [ "magic" ] ;
993+ const ALLOWED_NAMES : & ' static [ & ' static str ] = & [ "magic" , "type" ] ;
987994
988995 fn from_inner ( inner : ItemMetaInner ) -> Self {
989996 Self ( inner)
@@ -1000,6 +1007,11 @@ impl MemberItemMeta {
10001007 let name = inner. item_name ( ) ;
10011008 Ok ( if magic { format ! ( "__{}__" , name) } else { name } )
10021009 }
1010+
1011+ fn member_kind ( & self ) -> Result < Option < String > > {
1012+ let inner = self . inner ( ) ;
1013+ inner. _optional_str ( "type" )
1014+ }
10031015}
10041016
10051017struct ExtractedImplAttrs {
0 commit comments