logo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
use proc_macro2::TokenStream as TokenStream2;
use quote::{quote, quote_spanned};

use super::{Property, PropertyName, PropertyType, ReturnedWidget, Tracker, Widget, WidgetFunc};

/// Utility methods and functions.
mod util;

/// Generate struct fields.
mod struct_fields;

/// Initialize widgets.
mod init_widgets;

/// Intialize property values.
mod init_properties;

/// Connect events.
mod connect;

/// Fields of the returned widget sturct.
mod return_fields;

/// View stream (mainly for watch!).
mod view;

/// Additional view stream for track!.
mod track;

/// Connect the widgets.
mod connect_widgets;

/// Connect components and widgets.
mod connect_components;

/// Connect to parent properties.
mod parent;

impl Widget {
    pub fn widget_assignment(&self) -> TokenStream2 {
        let w_name = &self.name;

        let ref_token = &self.ref_token;
        let deref_token = &self.deref_token;

        let out_stream = quote! { #ref_token #deref_token #w_name };

        if let Some(wrapper) = &self.wrapper {
            quote_spanned! {
                wrapper.span() => #wrapper(#out_stream)
            }
        } else {
            out_stream
        }
    }
}