Debian Codegraph @

src/properties.rs

raw symbols SCIP
1 // Take a look at the license at the top of the repository in the LICENSE file.
2
3 use craterust-analyzer cargo glib-macros 0.22.6 crate/::utilsrust-analyzer cargo glib-macros 0.22.6 utils/::crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().;
4 use proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#;
5 use proc_macro2rust-analyzer cargo proc-macro2 1.0.106 crate/::TokenStreamrust-analyzer cargo proc-macro2 1.0.106 TokenStream# as TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream#;
6 use quoterust-analyzer cargo quote 1.0.44 crate/::format_identrust-analyzer cargo quote 1.0.44 format/format_ident!;
7 use quoterust-analyzer cargo quote 1.0.44 crate/::{quoterust-analyzer cargo quote 1.0.44 quote!, quote_spannedrust-analyzer cargo quote 1.0.44 quote_spanned!};
8 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#;
9 use synrust-analyzer cargo syn 2.0.117 crate/::Tokenrust-analyzer cargo syn 2.0.117 token/Token!;
10 use synrust-analyzer cargo syn 2.0.117 crate/::extrust-analyzer cargo syn 2.0.117 ext/::IdentExtrust-analyzer cargo syn 2.0.117 ext/IdentExt#;
11 use synrust-analyzer cargo syn 2.0.117 crate/::parenthesizedrust-analyzer cargo syn 2.0.117 group/parenthesized!;
12 use synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::Parserust-analyzer cargo syn 2.0.117 parse/Parse#;
13 use synrust-analyzer cargo syn 2.0.117 crate/::punctuatedrust-analyzer cargo syn 2.0.117 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#;
14 use synrust-analyzer cargo syn 2.0.117 crate/::spannedrust-analyzer cargo syn 2.0.117 spanned/::Spannedrust-analyzer cargo syn 2.0.117 spanned/Spanned#;
15 use synrust-analyzer cargo syn 2.0.117 crate/::{Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#, LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#, parse_quote_spannedrust-analyzer cargo syn 2.0.117 parse_quote/parse_quote_spanned!};
16
17 pub struct PropsMacroInputrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput# {
18 wrapper_tyrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#wrapper_ty.: synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#,
19 ext_traitrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#ext_trait.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#>>,
20 identrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#ident.: synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#,
21 propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#>,
22 }
23
24 pub struct PropertiesAttrsrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs# {
25 wrapper_tyrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs#wrapper_ty.: synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#,
26 // None => no ext trait,
27 // Some(None) => derive the ext trait from the wrapper type,
28 // Some(Some(ident)) => use the given ext trait Ident
29 ext_traitrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs#ext_trait.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#>>,
30 }
31
32 impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for PropertiesAttrsrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs# {
33 fn parserust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropertiesAttrs][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropertiesAttrs][Parse]> {
34 let mut wrapper_ty = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
35 let mut ext_trait = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
36
37 while !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().input.is_emptyrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]is_empty().() {
38 let ident = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
39 if ident rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq()."wrapper_type" {
40 let _eq = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().::<Tokenrust-analyzer cargo syn 2.0.117 token/Token!![=]>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
41 wrapper_ty = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
42 } else if ident rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq()."ext_trait" {
43 if input.peekrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]peek().(Tokenrust-analyzer cargo syn 2.0.117 token/Token!![=]) {
44 let _eq = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().::<Tokenrust-analyzer cargo syn 2.0.117 token/Token!![=]>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
45 let ident = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().::<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
46 ext_trait = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ident));
47 } else {
48 ext_trait = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
49 }
50 }
51 if input.peekrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]peek().(Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]) {
52 input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().::<Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]>()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
53 }
54 }
55
56 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropertiesAttrs][Parse] {
57 wrapper_tyrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs#wrapper_ty.: wrapper_ty.ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| {
58 synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(input.spanrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]span().(), "missing #[properties(wrapper_type = ...)]")
59 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
60 ext_traitrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs#ext_trait.,
61 })
62 }
63 }
64
65 impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for PropsMacroInputrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput# {
66 fn parserust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropsMacroInput][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropsMacroInput][Parse]> {
67 let derive_input: synrust-analyzer cargo syn 2.0.117 crate/::DeriveInputrust-analyzer cargo syn 2.0.117 derive/DeriveInput# = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
68 let attrs = derive_input
69 .attrsrust-analyzer cargo syn 2.0.117 derive/DeriveInput#attrs.
70 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
71 .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|x| x.pathrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]path().().is_identrust-analyzer cargo syn 2.0.117 path/impl#[Path]is_ident().("properties"))
72 .ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| {
73 synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(
74 derive_input.spanrust-analyzer cargo syn 2.0.117 spanned/impl#[T][Spanned]span().(),
75 "missing #[properties(wrapper_type = ...)]",
76 )
77 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
78 let attrs: PropertiesAttrsrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs# = attrs.parse_argsrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]parse_args().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
79 let props: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_> = match derive_input.datarust-analyzer cargo syn 2.0.117 derive/DeriveInput#data. {
80 synrust-analyzer cargo syn 2.0.117 crate/::Datarust-analyzer cargo syn 2.0.117 derive/Data#::Structrust-analyzer cargo syn 2.0.117 derive/Data#Struct#(struct_data) => parse_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/parse_fields().(struct_data.fieldsrust-analyzer cargo syn 2.0.117 derive/DataStruct#fields.)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
81 _ => {
82 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(
83 derive_input.spanrust-analyzer cargo syn 2.0.117 spanned/impl#[T][Spanned]span().(),
84 "Properties can only be derived on structs",
85 ));
86 }
87 };
88 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropsMacroInput][Parse] {
89 wrapper_tyrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#wrapper_ty.: attrs.wrapper_tyrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs#wrapper_ty.,
90 ext_traitrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#ext_trait.: attrs.ext_traitrust-analyzer cargo glib-macros 0.22.6 properties/PropertiesAttrs#ext_trait.,
91 identrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#ident.: derive_input.identrust-analyzer cargo syn 2.0.117 derive/DeriveInput#ident.,
92 propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.,
93 })
94 }
95 }
96
97 enum MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn# {
98 Customrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Custom#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>),
99 Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#,
100 }
101
102 impl stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>> for MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn# {
103 fn fromrust-analyzer cargo glib-macros 0.22.6 properties/impl#[MaybeCustomFn][`From<Option<syn::Expr>>`]from().(item: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>) -> Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[MaybeCustomFn][`From<Option<syn::Expr>>`] {
104 match item {
105 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(expr) => Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[MaybeCustomFn][`From<Option<syn::Expr>>`]::Customrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Custom#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(expr)),
106 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[MaybeCustomFn][`From<Option<syn::Expr>>`]::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#,
107 }
108 }
109 }
110
111 enum PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr# {
112 // builder(required_params).parameter(value)
113 // becomes
114 // Builder(Punctuated(required_params), Optionals(TokenStream))
115 Builderrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Builder#(Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#, Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]>, TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream#),
116
117 // ident
118 Nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Nullable#,
119
120 // ident [= expr]
121 Getrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Get#(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>),
122 Setrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Set#(Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>),
123
124 // ident = expr
125 OverrideClassrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#OverrideClass#(synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#),
126 OverrideInterfacerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#OverrideInterface#(synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#),
127
128 // ident = expr
129 Typerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Type#(synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#),
130
131 // This will get translated from `ident = value` to `.ident(value)`
132 // and will get appended after the `builder(...)` call.
133 // ident [= expr]
134 BuilderFieldrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#BuilderField#((synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>)),
135
136 // ident = ident
137 Memberrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Member#(synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#),
138
139 // ident = "literal"
140 Namerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Name#(synrust-analyzer cargo syn 2.0.117 crate/::LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#),
141
142 // ident
143 Defaultrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Default#,
144 }
145
146 impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr# {
147 fn parserust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropAttr][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropAttr][Parse]> {
148 let name = input.callrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]call().(synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#::parse_anyrust-analyzer cargo syn 2.0.117 ext/impl#[Ident][IdentExt]parse_any().)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
149 let name_str = name.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().();
150
151 let res = if input.peekrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]peek().(Tokenrust-analyzer cargo syn 2.0.117 token/Token!![=]) {
152 let _assign_token: Tokenrust-analyzer cargo syn 2.0.117 token/Token!![=] = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
153 // name = expr | type | ident
154 match &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().name_str {
155 "name" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Namerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Name#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
156 "get" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Getrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Get#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)),
157 "set" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Setrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Set#(Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)),
158 "override_class" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::OverrideClassrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#OverrideClass#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
159 "override_interface" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::OverrideInterfacerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#OverrideInterface#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
160 "type" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Typerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Type#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
161 "member" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Memberrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Member#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
162 // Special case "default = ..." and map it to .default_value(...)
163 "default" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::BuilderFieldrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#BuilderField#((
164 synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#::newrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]new().("default_value", name.spanrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]span().()),
165 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().),
166 )),
167 _ => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::BuilderFieldrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#BuilderField#((name, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().))),
168 }
169 } else if input.peekrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]peek().(synrust-analyzer cargo syn 2.0.117 crate/::tokenrust-analyzer cargo syn 2.0.117 token/::Parenrust-analyzer cargo syn 2.0.117 token/Paren().) {
170 match &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().name_str {
171 "builder" => {
172 let content;
173 parenthesizedrust-analyzer cargo syn 2.0.117 group/parenthesized!!(content in input);
174 let required = content.parse_terminatedrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse_terminated().(synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#::parserust-analyzer cargo syn 2.0.117 expr/parsing/impl#[Expr][Parse]parse()., Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,])?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
175 let rest: TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream# = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
176 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Builderrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Builder#(required, rest)
177 }
178 _ => {
179 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(
180 name.spanrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]span().(),
181 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Unsupported attribute list {name_str}(...)"),
182 ));
183 }
184 }
185 } else {
186 // attributes with only the identifier name
187 match &*rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Deref]deref().name_str {
188 "nullable" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Nullable#,
189 "get" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Getrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Get#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
190 "set" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Setrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Set#(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#),
191 "readwrite" | "read_only" | "write_only" => {
192 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(
193 name.spanrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]span().(),
194 formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!(
195 "{name} is a flag managed by the Properties macro. \
196 Use `get` and `set` to manage read and write access to a property",
197 ),
198 ));
199 }
200 "default" => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Default#,
201 _ => PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::BuilderFieldrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#BuilderField#((name, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#)),
202 }
203 };
204 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(res)
205 }
206 }
207
208 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
209 struct ReceivedAttrsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs# {
210 nullablerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#nullable.: bool,
211 getrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#get.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#>,
212 setrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#set.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#>,
213 override_classrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#override_class.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#>,
214 override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#override_interface.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#>,
215 tyrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#ty.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#>,
216 memberrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#member.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#>,
217 namerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#name.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#>,
218 builderrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#builder.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#, Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]>, TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream#)>,
219 builder_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#builder_fields.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>>,
220 use_defaultrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#use_default.: bool,
221 }
222
223 impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for ReceivedAttrsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs# {
224 fn parserust-analyzer cargo glib-macros 0.22.6 properties/impl#[ReceivedAttrs][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[ReceivedAttrs][Parse]> {
225 let attrs = synrust-analyzer cargo syn 2.0.117 crate/::punctuatedrust-analyzer cargo syn 2.0.117 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#::<PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#, Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]>::parse_terminatedrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
226 let this = attrs.into_iterrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().().foldrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#fold().(Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[ReceivedAttrs][Parse]::defaultrust-analyzer cargo glib-macros 0.22.6 properties/impl#[ReceivedAttrs][Default]default().(), |mut this, attr| {
227 this.set_from_attrrust-analyzer cargo glib-macros 0.22.6 properties/impl#[ReceivedAttrs]set_from_attr().(attr);
228 this
229 });
230
231 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(this)
232 }
233 }
234
235 impl ReceivedAttrsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs# {
236 fn set_from_attrrust-analyzer cargo glib-macros 0.22.6 properties/impl#[ReceivedAttrs]set_from_attr().(&mut self, attr: PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#) {
237 match attr {
238 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Nullable# => self.nullablerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#nullable. = true,
239 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Getrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Get#(some_fn) => self.getrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#get. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(some_fn.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
240 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Setrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Set#(some_fn) => self.setrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#set. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(some_fn.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
241 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Namerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Name#(lit) => self.namerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#name. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(lit),
242 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::OverrideClassrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#OverrideClass#(ty) => self.override_classrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#override_class. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ty),
243 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::OverrideInterfacerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#OverrideInterface#(ty) => self.override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#override_interface. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ty),
244 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Typerust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Type#(ty) => self.tyrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#ty. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ty),
245 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Memberrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Member#(member) => self.memberrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#member. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(member),
246 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Builderrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Builder#(required_params, optionals) => {
247 self.builderrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#builder. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#((required_params, optionals))
248 }
249 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::BuilderFieldrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#BuilderField#((ident, expr)) => {
250 self.builder_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#builder_fields..insertrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]insert().(ident, expr);
251 }
252 PropAttrrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/PropAttr#Default# => {
253 self.use_defaultrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#use_default. = true;
254 }
255 }
256 }
257 }
258
259 // It's a cleaned up version of `ReceivedAttrs` where some missing attributes get a default,
260 // generated value.
261 struct PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc# {
262 attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.: proc_macro2rust-analyzer cargo proc-macro2 1.0.106 crate/::Spanrust-analyzer cargo proc-macro2 1.0.106 Span#,
263 field_identrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#field_ident.: synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#,
264 tyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#ty.: synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#,
265 namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.: synrust-analyzer cargo syn 2.0.117 crate/::LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#,
266 commentsrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#comments.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#>,
267 override_classrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_class.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#>,
268 override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_interface.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#>,
269 nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#nullable.: bool,
270 getrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#get.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#>,
271 setrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#set.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#>,
272 memberrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#member.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#>,
273 builderrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#builder.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<(Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#, Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]>, TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream#)>,
274 builder_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#builder_fields.: BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#, Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#>>,
275 is_construct_onlyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#is_construct_only.: bool,
276 use_defaultrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#use_default.: bool,
277 }
278
279 impl PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc# {
280 fn newrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]new().(
281 attrs_span: proc_macro2rust-analyzer cargo proc-macro2 1.0.106 crate/::Spanrust-analyzer cargo proc-macro2 1.0.106 Span#,
282 field_ident: synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#,
283 field_ty: synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#,
284 comments: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#>,
285 attrs: ReceivedAttrsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#,
286 ) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]> {
287 let ReceivedAttrsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs# {
288 nullablerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#nullable.,
289 getrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#get.,
290 mut setrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#set.,
291 override_classrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#override_class.,
292 override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#override_interface.,
293 tyrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#ty.,
294 memberrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#member.,
295 namerust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#name.,
296 builderrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#builder.,
297 builder_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#builder_fields.,
298 use_defaultrust-analyzer cargo glib-macros 0.22.6 properties/ReceivedAttrs#use_default.,
299 } = attrs;
300
301 let is_construct_only = builder_fields.iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().anyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#any().(|(k, _)| *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().k rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq()."construct_only");
302 if is_construct_only && set.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
303 // Insert a default internal setter automatically
304 set = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#);
305 }
306
307 if get.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() && set.is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().() {
308 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(
309 attrs_span,
310 "No `get` or `set` specified: at least one is required.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
311 ));
312 }
313
314 if override_class.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() && override_interface.is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() {
315 return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().(
316 attrs_span,
317 "Both `override_class` and `override_interface` specified.".to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(),
318 ));
319 }
320
321 // Fill needed, but missing, attributes with calculated default values
322 let name = name.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| {
323 synrust-analyzer cargo syn 2.0.117 crate/::LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#::newrust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]new().(
324 &field_ident.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().().trim_matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim_matches().('_').replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('_', "-"),
325 field_ident.spanrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]span().(),
326 )
327 });
328 let ty = ty.unwrap_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_else().(|| field_ty.clonerust-analyzer cargo syn 2.0.117 gen/clone/impl#[`crate::Type`][Clone]clone().());
329
330 // Now that everything is set and safe, return the final property description
331 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc] {
332 attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.,
333 field_identrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#field_ident.,
334 tyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#ty.,
335 namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.,
336 commentsrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#comments.,
337 override_classrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_class.,
338 override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_interface.,
339 nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#nullable.,
340 getrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#get.,
341 setrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#set.,
342 memberrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#member.,
343 builderrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#builder.,
344 builder_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#builder_fields.,
345 is_construct_onlyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#is_construct_only.,
346 use_defaultrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#use_default.,
347 })
348 }
349 fn is_overridingrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]is_overriding().(&self) -> bool {
350 self.override_classrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_class..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() || self.override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_interface..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().()
351 }
352 }
353
354 fn expand_param_specrust-analyzer cargo glib-macros 0.22.6 properties/expand_param_spec().(prop: &PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream# {
355 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
356 let PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc# {
357 tyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#ty.,
358 namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.,
359 builderrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#builder.,
360 use_defaultrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#use_default.,
361 ..
362 } = prop;
363 let stripped_name = strip_raw_prefix_from_namerust-analyzer cargo glib-macros 0.22.6 properties/strip_raw_prefix_from_name().(name);
364
365 match (&prop.override_classrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_class., &prop.override_interfacerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#override_interface.) {
366 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => {
367 return quoterust-analyzer cargo quote 1.0.44 quote!!(#crate_ident::ParamSpecOverride::for_class::<#c>(#stripped_name));
368 }
369 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i)) => {
370 return quoterust-analyzer cargo quote 1.0.44 quote!!(#crate_ident::ParamSpecOverride::for_interface::<#i>(#stripped_name));
371 }
372 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) => {
373 unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("Both `override_class` and `override_interface` specified")
374 }
375 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => (),
376 };
377
378 let rw_flags = match (&prop.getrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#get., &prop.setrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#set.) {
379 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) => quoterust-analyzer cargo quote 1.0.44 quote!!(.readwrite()),
380 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => quoterust-analyzer cargo quote 1.0.44 quote!!(.read_only()),
381 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(_)) => quoterust-analyzer cargo quote 1.0.44 quote!!(.write_only()),
382 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#) => unreachablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/unreachable!!("No `get` or `set` specified"),
383 };
384
385 let builder_call = builder
386 .as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()
387 .clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<&T>`]cloned().()
388 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|(mut required_params, chained_methods)| {
389 let name_expr = synrust-analyzer cargo syn 2.0.117 crate/::ExprLitrust-analyzer cargo syn 2.0.117 expr/ExprLit# {
390 attrsrust-analyzer cargo syn 2.0.117 expr/ExprLit#attrs.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![],
391 litrust-analyzer cargo syn 2.0.117 expr/ExprLit#lit.: synrust-analyzer cargo syn 2.0.117 crate/::Litrust-analyzer cargo syn 2.0.117 lit/Lit#::Strrust-analyzer cargo syn 2.0.117 lit/Lit#Str#(stripped_name.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().()),
392 };
393 required_params.insertrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]insert().(0, name_expr.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
394 let required_params = required_params.iterrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]iter().();
395
396 quoterust-analyzer cargo quote 1.0.44 quote!!((#(#required_params,)*)#chained_methods)
397 })
398 .unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(quoterust-analyzer cargo quote 1.0.44 quote!!((#stripped_name)));
399
400 let builder_fields = prop.builder_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#builder_fields..iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/impl#[`BTreeMap<K, V, A>`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(k, v)| quoterust-analyzer cargo quote 1.0.44 quote!!(.#k(#v)));
401
402 let span = prop.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
403
404 // Figure out if we should use the default version or the one that explicitly sets the `Default` value.
405 let (trait_name, fn_name) = if *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().use_default {
406 (
407 quoterust-analyzer cargo quote 1.0.44 quote!!(HasParamSpecDefaulted),
408 quoterust-analyzer cargo quote 1.0.44 quote!!(param_spec_builder_defaulted),
409 )
410 } else {
411 (quoterust-analyzer cargo quote 1.0.44 quote!!(HasParamSpec), quoterust-analyzer cargo quote 1.0.44 quote!!(param_spec_builder))
412 };
413
414 quote_spannedrust-analyzer cargo quote 1.0.44 quote_spanned!! {span=>
415 <<#ty as #crate_ident::property::Property>::Value as #crate_ident::#trait_name>
416 ::#fn_name() #builder_call
417 #rw_flags
418 #(#builder_fields)*
419 .build()
420 }
421 }
422
423 fn expand_properties_fnrust-analyzer cargo glib-macros 0.22.6 properties/expand_properties_fn().(props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream# {
424 let n_props = props.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().();
425 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
426 let param_specs = props.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(expand_param_specrust-analyzer cargo glib-macros 0.22.6 properties/expand_param_spec().);
427 quoterust-analyzer cargo quote 1.0.44 quote!!(
428 fn derived_properties() -> &'static [#crate_ident::ParamSpec] {
429 use #crate_ident::prelude::ParamSpecBuilderExt;
430 static PROPERTIES: ::std::sync::OnceLock<[#crate_ident::ParamSpec; #n_props]> = ::std::sync::OnceLock::new();
431 PROPERTIES.get_or_init(|| [
432 #(#param_specs,)*
433 ])
434 }
435 )
436 }
437
438 fn expand_property_fnrust-analyzer cargo glib-macros 0.22.6 properties/expand_property_fn().(props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream# {
439 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
440 let match_branch_get = props.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|p| {
441 let PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc# {
442 namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.,
443 field_identrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#field_ident.,
444 memberrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#member.,
445 getrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#get.,
446 tyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#ty.,
447 ..
448 } = p;
449
450 let enum_ident = name_to_enum_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_enum_ident().(name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().());
451 let span = p.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
452 get.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|get| {
453 let body = match (member, get) {
454 (_, MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Customrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Custom#(expr)) => quoterust-analyzer cargo quote 1.0.44 quote!!(
455 DerivedPropertiesEnum::#enum_ident => {
456 let value: <#ty as #crate_ident::property::Property>::Value = (#expr)(&self);
457 ::std::convert::From::from(value)
458 }
459 ),
460 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#) => quoterust-analyzer cargo quote 1.0.44 quote!!(
461 DerivedPropertiesEnum::#enum_ident =>
462 #crate_ident::property::PropertyGet::get(&self.#field_ident, |v| ::std::convert::From::from(v))
463
464 ),
465 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(member), MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#) => quoterust-analyzer cargo quote 1.0.44 quote!!(
466 DerivedPropertiesEnum::#enum_ident =>
467 #crate_ident::property::PropertyGet::get(&self.#field_ident, |v| ::std::convert::From::from(&v.#member))
468
469 ),
470 };
471 quote_spannedrust-analyzer cargo quote 1.0.44 quote_spanned!!(span=> #body)
472 })
473 });
474 quoterust-analyzer cargo quote 1.0.44 quote!!(
475 fn derived_property(
476 &self,
477 id: usize,
478 pspec: &#crate_ident::ParamSpec
479 ) -> #crate_ident::Value {
480 let prop: DerivedPropertiesEnum = std::convert::TryFrom::try_from(id-1)
481 .unwrap_or_else(|_| panic!("property not defined {}", pspec.name()));
482 match prop {
483 #(#match_branch_get,)*
484 _ => panic!("missing getter for property {}", pspec.name()),
485 }
486 }
487 )
488 }
489
490 fn expand_set_property_fnrust-analyzer cargo glib-macros 0.22.6 properties/expand_set_property_fn().(props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream# {
491 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
492 let match_branch_set = props.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().flat_maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flat_map().(|p| {
493 let PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc# {
494 namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.,
495 field_identrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#field_ident.,
496 memberrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#member.,
497 setrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#set.,
498 tyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#ty.,
499 ..
500 } = p;
501 let stripped_name = strip_raw_prefix_from_namerust-analyzer cargo glib-macros 0.22.6 properties/strip_raw_prefix_from_name().(name);
502 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
503 let enum_ident = name_to_enum_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_enum_ident().(name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().());
504 let span = p.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
505 let expect = quoterust-analyzer cargo quote 1.0.44 quote!!(.unwrap_or_else(
506 |err| panic!(
507 "Invalid conversion from `glib::value::Value` to `{}` inside setter for property `{}`: {:?}",
508 ::std::any::type_name::<<#ty as #crate_ident::property::Property>::Value>(), #stripped_name, err
509 )
510 ));
511 set.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|set| {
512 let body = match (member, set) {
513 (_, MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Customrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Custom#(expr)) => quoterust-analyzer cargo quote 1.0.44 quote!!(
514 DerivedPropertiesEnum::#enum_ident => {
515 (#expr)(&self, #crate_ident::Value::get(value)#expect);
516 }
517 ),
518 (Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#) => quoterust-analyzer cargo quote 1.0.44 quote!!(
519 DerivedPropertiesEnum::#enum_ident => {
520 #crate_ident::property::PropertySet::set(
521 &self.#field_ident,
522 #crate_ident::Value::get(value)#expect
523 );
524 }
525 ),
526 (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(member), MaybeCustomFnrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#::Defaultrust-analyzer cargo glib-macros 0.22.6 properties/MaybeCustomFn#Default#) => quoterust-analyzer cargo quote 1.0.44 quote!!(
527 DerivedPropertiesEnum::#enum_ident => {
528 #crate_ident::property::PropertySetNested::set_nested(
529 &self.#field_ident,
530 move |v| v.#member = #crate_ident::Value::get(value)#expect
531 );
532 }
533 ),
534 };
535 quote_spannedrust-analyzer cargo quote 1.0.44 quote_spanned!!(span=> #body)
536 })
537 });
538 quoterust-analyzer cargo quote 1.0.44 quote!!(
539 #[allow(unreachable_code)]
540 fn derived_set_property(&self,
541 id: usize,
542 value: &#crate_ident::Value,
543 pspec: &#crate_ident::ParamSpec
544 ){
545 let prop: DerivedPropertiesEnum = std::convert::TryFrom::try_from(id-1)
546 .unwrap_or_else(|_| panic!("property not defined {}", pspec.name()));
547 match prop {
548 #(#match_branch_set,)*
549 _ => panic!("missing setter for property {}", pspec.name()),
550 }
551 }
552 )
553 }
554
555 fn parse_fieldsrust-analyzer cargo glib-macros 0.22.6 properties/parse_fields().(fields: synrust-analyzer cargo syn 2.0.117 crate/::Fieldsrust-analyzer cargo syn 2.0.117 data/Fields#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#>> {
556 let mut properties = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
557
558 for field in fields.into_iterrust-analyzer cargo syn 2.0.117 data/impl#[Fields][IntoIterator]into_iter().() {
559 let synrust-analyzer cargo syn 2.0.117 crate/::Fieldrust-analyzer cargo syn 2.0.117 data/Field# {
560 identrust-analyzer cargo syn 2.0.117 data/Field#ident., attrsrust-analyzer cargo syn 2.0.117 data/Field#attrs., tyrust-analyzer cargo syn 2.0.117 data/Field#ty., ..
561 } = field;
562 // Store the comments until the next `#[property]` we see and then attach them to it.
563 let mut comments: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#> = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
564 for prop_attr in attrs.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() {
565 if prop_attr.pathrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]path().().is_identrust-analyzer cargo syn 2.0.117 path/impl#[Path]is_ident().("doc") {
566 comments.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(prop_attr.clonerust-analyzer cargo syn 2.0.117 gen/clone/impl#[`crate::Attribute`][Clone]clone().());
567 } else if prop_attr.pathrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]path().().is_identrust-analyzer cargo syn 2.0.117 path/impl#[Path]is_ident().("property") {
568 let span = prop_attr.spanrust-analyzer cargo syn 2.0.117 spanned/impl#[T][Spanned]span().();
569 let existing_comments = comments;
570 comments = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
571 properties.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#::newrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]new().(
572 span,
573 ident.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().clonerust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][Clone]clone().(),
574 ty.clonerust-analyzer cargo syn 2.0.117 gen/clone/impl#[`crate::Type`][Clone]clone().(),
575 existing_comments,
576 prop_attr.parse_argsrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]parse_args().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().,
577 )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().);
578 }
579 }
580 }
581
582 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(properties)
583 }
584
585 /// Converts a glib property name to a correct rust ident
586 fn name_to_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_ident().(name: &synrust-analyzer cargo syn 2.0.117 crate/::LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#) -> synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident# {
587 format_identrust-analyzer cargo quote 1.0.44 format/format_ident!!("{}", name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().().replacerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str]replace().('-', "_"))
588 }
589
590 /// Strips out raw identifier prefix (`r#`) from literal string items
591 fn strip_raw_prefix_from_namerust-analyzer cargo glib-macros 0.22.6 properties/strip_raw_prefix_from_name().(name: &LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#) -> LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr# {
592 LitStrrust-analyzer cargo syn 2.0.117 lit/LitStr#::newrust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]new().(
593 name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().().strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("r#").unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().()),
594 name.spanrust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]span().(),
595 )
596 }
597
598 /// Splits the comments for a property between the getter and setter
599 ///
600 /// The return tuple is the attributes to copy over into the getter and setter
601 /// respectively.
602 fn arrange_property_commentsrust-analyzer cargo glib-macros 0.22.6 properties/arrange_property_comments().(comments: &[Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#]) -> (Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#>, Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<&Attributerust-analyzer cargo syn 2.0.117 attr/Attribute#>) {
603 let mut untagged = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
604 let mut getter = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
605 let mut setter = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![];
606 let mut saw_section = false;
607
608 // We start with no tags so if the programmer doesn't split the comments we can still arrange them.
609 let mut current_section = &mut untagged;
610 for attr in comments {
611 if let synrust-analyzer cargo syn 2.0.117 crate/::Metarust-analyzer cargo syn 2.0.117 attr/Meta#::NameValuerust-analyzer cargo syn 2.0.117 attr/Meta#NameValue#(meta) = &attr.metarust-analyzer cargo syn 2.0.117 attr/Attribute#meta.
612 && let synrust-analyzer cargo syn 2.0.117 crate/::Exprrust-analyzer cargo syn 2.0.117 expr/Expr#::Litrust-analyzer cargo syn 2.0.117 expr/Expr#Lit#(expr) = &meta.valuerust-analyzer cargo syn 2.0.117 attr/MetaNameValue#value.
613 && let synrust-analyzer cargo syn 2.0.117 crate/::Litrust-analyzer cargo syn 2.0.117 lit/Lit#::Strrust-analyzer cargo syn 2.0.117 lit/Lit#Str#(lit_str) = &expr.litrust-analyzer cargo syn 2.0.117 expr/ExprLit#lit.
614 {
615 // Now that we have the one line of comment, see if we need
616 // to switch a particular section to be the active one (via
617 // the header syntax) or add the current line to the active
618 // section.
619 match lit_str.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().().trimrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]trim().() {
620 "# Getter" => {
621 current_section = &mut getter;
622 saw_section = true;
623 }
624 "# Setter" => {
625 current_section = &mut setter;
626 saw_section = true;
627 }
628 _ => current_section.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(attr),
629 }
630 }
631 }
632
633 // If no sections were defined then we put the same in both
634 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().saw_section {
635 return (untagged.clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][Clone]clone().(), untagged);
636 }
637
638 (getter, setter)
639 }
640
641 fn expand_impl_getset_propertiesrust-analyzer cargo glib-macros 0.22.6 properties/expand_impl_getset_properties().(props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<synrust-analyzer cargo syn 2.0.117 crate/::ImplItemFnrust-analyzer cargo syn 2.0.117 item/ImplItemFn#> {
642 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
643 let defs = props.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|p| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().p.is_overridingrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]is_overriding().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| {
644 let name = &p.namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.;
645 let stripped_name = strip_raw_prefix_from_namerust-analyzer cargo glib-macros 0.22.6 properties/strip_raw_prefix_from_name().(name);
646 let ident = name_to_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_ident().(name);
647 let ty = &p.tyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#ty.;
648
649 let (getter_docs, setter_docs) = arrange_property_commentsrust-analyzer cargo glib-macros 0.22.6 properties/arrange_property_comments().(&p.commentsrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#comments.);
650
651 let getter = p.getrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#get..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().().thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| {
652 let span = p.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
653 parse_quote_spannedrust-analyzer cargo syn 2.0.117 parse_quote/parse_quote_spanned!!(span=>
654 #(#getter_docs)*
655 #[must_use]
656 #[allow(dead_code)]
657 pub fn #ident(&self) -> <#ty as #crate_ident::property::Property>::Value {
658 self.property::<<#ty as #crate_ident::property::Property>::Value>(#stripped_name)
659 }
660 )
661 });
662
663 let setter = (p.setrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#set..is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().() && !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().p.is_construct_onlyrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#is_construct_only.).thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| {
664 let ident = format_identrust-analyzer cargo quote 1.0.44 format/format_ident!!("set_{}", ident);
665 let target_ty = quoterust-analyzer cargo quote 1.0.44 quote!!(<<#ty as #crate_ident::property::Property>::Value as #crate_ident::prelude::HasParamSpec>::SetValue);
666 let set_ty = if p.nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#nullable. {
667 quoterust-analyzer cargo quote 1.0.44 quote!!(::core::option::Option<impl std::borrow::Borrow<#target_ty>>)
668 } else {
669 quoterust-analyzer cargo quote 1.0.44 quote!!(impl std::borrow::Borrow<#target_ty>)
670 };
671 let upcasted_borrowed_value = if p.nullablerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#nullable. {
672 quoterust-analyzer cargo quote 1.0.44 quote!!(
673 value.as_ref().map(|v| std::borrow::Borrow::borrow(v))
674 )
675 } else {
676 quoterust-analyzer cargo quote 1.0.44 quote!!(
677 std::borrow::Borrow::borrow(&value)
678 )
679 };
680 let span = p.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
681 parse_quote_spannedrust-analyzer cargo syn 2.0.117 parse_quote/parse_quote_spanned!!(span=>
682 #(#setter_docs)*
683 #[allow(dead_code)]
684 pub fn #ident<'a>(&self, value: #set_ty) {
685 self.set_property_from_value(#stripped_name, &::std::convert::From::from(#upcasted_borrowed_value))
686 }
687 )
688 });
689
690 [getter, setter]
691 });
692 defs.flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().() // flattens []
693 .flattenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#flatten().() // removes None
694 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
695 }
696
697 fn expand_impl_connect_prop_notifyrust-analyzer cargo glib-macros 0.22.6 properties/expand_impl_connect_prop_notify().(props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<synrust-analyzer cargo syn 2.0.117 crate/::ImplItemFnrust-analyzer cargo syn 2.0.117 item/ImplItemFn#> {
698 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
699 let connection_fns = props.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|p| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().p.is_overridingrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]is_overriding().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| -> synrust-analyzer cargo syn 2.0.117 crate/::ImplItemFnrust-analyzer cargo syn 2.0.117 item/ImplItemFn# {
700 let name = &p.namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.;
701 let stripped_name = strip_raw_prefix_from_namerust-analyzer cargo glib-macros 0.22.6 properties/strip_raw_prefix_from_name().(name);
702 let fn_ident = format_identrust-analyzer cargo quote 1.0.44 format/format_ident!!("connect_{}_notify", name_to_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_ident().(name));
703 let span = p.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
704 let doc = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Listen for notifications of a change in the `{}` property", name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().());
705 parse_quote_spannedrust-analyzer cargo syn 2.0.117 parse_quote/parse_quote_spanned!!(span=>
706 #[doc = #doc]
707 #[allow(dead_code)]
708 pub fn #fn_ident<F: Fn(&Self) + 'static>(&self, f: F) -> #crate_ident::SignalHandlerId {
709 self.connect_notify_local(::core::option::Option::Some(#stripped_name), move |this, _| {
710 f(this)
711 })
712 }
713 )
714 });
715 connection_fns.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
716 }
717
718 fn expand_impl_notify_proprust-analyzer cargo glib-macros 0.22.6 properties/expand_impl_notify_prop().(wrapper_type: &synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#, props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<synrust-analyzer cargo syn 2.0.117 crate/::ImplItemFnrust-analyzer cargo syn 2.0.117 item/ImplItemFn#> {
719 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
720 let emit_fns = props.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().filterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#filter().(|p| !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().p.is_overridingrust-analyzer cargo glib-macros 0.22.6 properties/impl#[PropDesc]is_overriding().()).maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| -> synrust-analyzer cargo syn 2.0.117 crate/::ImplItemFnrust-analyzer cargo syn 2.0.117 item/ImplItemFn# {
721 let name = strip_raw_prefix_from_namerust-analyzer cargo glib-macros 0.22.6 properties/strip_raw_prefix_from_name().(&p.namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name.);
722 let fn_ident = format_identrust-analyzer cargo quote 1.0.44 format/format_ident!!("notify_{}", name_to_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_ident().(&name));
723 let span = p.attrs_spanrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#attrs_span.;
724 let enum_ident = name_to_enum_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_enum_ident().(name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().());
725 let doc = formatrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/format!!("Notify listeners of a change in the `{}` property", name.valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().());
726 parse_quote_spannedrust-analyzer cargo syn 2.0.117 parse_quote/parse_quote_spanned!!(span=>
727 #[doc = #doc]
728 #[allow(dead_code)]
729 pub fn #fn_ident(&self) {
730 self.notify_by_pspec(
731 &<<#wrapper_type as #crate_ident::object::ObjectSubclassIs>::Subclass
732 as #crate_ident::subclass::object::DerivedObjectProperties>::derived_properties()
733 [DerivedPropertiesEnum::#enum_ident as usize]
734 );
735 }
736 )
737 });
738 emit_fns.collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<_>>()
739 }
740
741 fn name_to_enum_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_enum_ident().(name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#) -> synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident# {
742 let mut name = name.strip_prefixrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]strip_prefix().("r#").unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(&name).to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().();
743 let mut slice = name.as_mut_strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]as_mut_str().();
744 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(i) = slice.findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]find().('-') {
745 let (head, tail) = slice.split_at_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split_at_mut().(i);
746 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = head.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get_mut().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
747 c.make_ascii_uppercaserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]make_ascii_uppercase().();
748 }
749 slice = &mut tail[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().1..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().;
750 }
751 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(c) = slice.get_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]get_mut().(0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#1) {
752 c.make_ascii_uppercaserust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]make_ascii_uppercase().();
753 }
754 let enum_member: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = name.splitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/impl#[str]split().('-').collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
755 format_identrust-analyzer cargo quote 1.0.44 format/format_ident!!("{}", enum_member)
756 }
757
758 fn expand_properties_enumrust-analyzer cargo glib-macros 0.22.6 properties/expand_properties_enum().(props: &[PropDescrust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#]) -> TokenStream2rust-analyzer cargo proc-macro2 1.0.106 TokenStream# {
759 if props.is_emptyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]is_empty().() {
760 quoterust-analyzer cargo quote 1.0.44 quote!! {
761 #[derive(Debug, Copy, Clone)]
762 enum DerivedPropertiesEnum {}
763 impl std::convert::TryFrom<usize> for DerivedPropertiesEnum {
764 type Error = usize;
765
766 fn try_from(item: usize) -> ::core::result::Result<Self, <Self as std::convert::TryFrom<usize>>::Error> {
767 ::core::result::Result::Err(item)
768 }
769 }
770 }
771 } else {
772 let properties: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#> = props
773 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
774 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| {
775 let name: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String# = p.namerust-analyzer cargo glib-macros 0.22.6 properties/PropDesc#name..valuerust-analyzer cargo syn 2.0.117 lit/impl#[LitStr]value().();
776
777 name_to_enum_identrust-analyzer cargo glib-macros 0.22.6 properties/name_to_enum_ident().(name)
778 })
779 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
780 let props = properties.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().();
781 let indices = 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#properties.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
782 quoterust-analyzer cargo quote 1.0.44 quote!! {
783 #[repr(usize)]
784 #[derive(Debug, Copy, Clone)]
785 enum DerivedPropertiesEnum {
786 #(#props,)*
787 }
788 impl std::convert::TryFrom<usize> for DerivedPropertiesEnum {
789 type Error = usize;
790
791 fn try_from(item: usize) -> ::core::result::Result<Self, <Self as std::convert::TryFrom<usize>>::Error> {
792 match item {
793 #(#indices => ::core::result::Result::Ok(Self::#properties),)*
794 _ => ::core::result::Result::Err(item)
795 }
796 }
797 }
798 }
799 }
800 }
801
802 pub fn impl_derive_propsrust-analyzer cargo glib-macros 0.22.6 properties/impl_derive_props().(input: PropsMacroInputrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#) -> TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream# {
803 let struct_ident = &input.identrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#ident.;
804 let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().();
805 let wrapper_type = input.wrapper_tyrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#wrapper_ty.;
806 let fn_properties = expand_properties_fnrust-analyzer cargo glib-macros 0.22.6 properties/expand_properties_fn().(&input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
807 let fn_property = expand_property_fnrust-analyzer cargo glib-macros 0.22.6 properties/expand_property_fn().(&input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
808 let fn_set_property = expand_set_property_fnrust-analyzer cargo glib-macros 0.22.6 properties/expand_set_property_fn().(&input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
809 let getset_properties = expand_impl_getset_propertiesrust-analyzer cargo glib-macros 0.22.6 properties/expand_impl_getset_properties().(&input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
810 let connect_prop_notify = expand_impl_connect_prop_notifyrust-analyzer cargo glib-macros 0.22.6 properties/expand_impl_connect_prop_notify().(&input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
811 let notify_prop = expand_impl_notify_proprust-analyzer cargo glib-macros 0.22.6 properties/expand_impl_notify_prop().(&wrapper_type, &input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
812 let properties_enum = expand_properties_enumrust-analyzer cargo glib-macros 0.22.6 properties/expand_properties_enum().(&input.propsrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#props.);
813
814 let rust_interface = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ext_trait) = input.ext_traitrust-analyzer cargo glib-macros 0.22.6 properties/PropsMacroInput#ext_trait. {
815 let trait_ident = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(ext_trait) = ext_trait {
816 ext_trait
817 } else {
818 format_identrust-analyzer cargo quote 1.0.44 format/format_ident!!(
819 "{}PropertiesExt",
820 wrapper_type.segmentsrust-analyzer cargo syn 2.0.117 path/Path#segments..lastrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().identrust-analyzer cargo syn 2.0.117 path/PathSegment#ident.
821 )
822 };
823 let fns_without_visibility_modifier = getset_properties
824 .into_iterrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][IntoIterator]into_iter().()
825 .chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(connect_prop_notify)
826 .chainrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#chain().(notify_prop)
827 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|mut item| {
828 item.visrust-analyzer cargo syn 2.0.117 item/ImplItemFn#vis. = synrust-analyzer cargo syn 2.0.117 crate/::Visibilityrust-analyzer cargo syn 2.0.117 restriction/Visibility#::Inheritedrust-analyzer cargo syn 2.0.117 restriction/Visibility#Inherited#;
829 item
830 });
831 quoterust-analyzer cargo quote 1.0.44 quote!! {
832 pub trait #trait_ident: #crate_ident::prelude::IsA<#wrapper_type> {
833 #(#fns_without_visibility_modifier)*
834 }
835 impl<T: #crate_ident::prelude::IsA<#wrapper_type>> #trait_ident for T {}
836 }
837 } else {
838 quoterust-analyzer cargo quote 1.0.44 quote!! {
839 #[allow(dead_code)]
840 impl #wrapper_type {
841 #(#getset_properties)*
842 #(#connect_prop_notify)*
843 #(#notify_prop)*
844 }
845 }
846 };
847
848 let expanded = quoterust-analyzer cargo quote 1.0.44 quote!! {
849 #properties_enum
850
851 impl #crate_ident::subclass::object::DerivedObjectProperties for #struct_ident {
852 #fn_properties
853 #fn_property
854 #fn_set_property
855 }
856
857 #rust_interface
858 };
859 proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#::fromrust-analyzer cargo proc-macro2 1.0.106 impl#[`proc_macro::TokenStream`][`From<TokenStream>`]from().(expanded)
860 }