Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
Kayak UI 0.11
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Microhacks
Bevy Forks
Kayak UI 0.11
Commits
2b2bc436
Commit
2b2bc436
authored
3 years ago
by
MrGVSV
Browse files
Options
Downloads
Patches
Plain Diff
Removed unneeded code
parent
289059e2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kayak_render_macros/src/function_component.rs
+0
-133
0 additions, 133 deletions
kayak_render_macros/src/function_component.rs
kayak_render_macros/src/widget_attributes.rs
+1
-59
1 addition, 59 deletions
kayak_render_macros/src/widget_attributes.rs
with
1 addition
and
192 deletions
kayak_render_macros/src/function_component.rs
+
0
−
133
View file @
2b2bc436
...
@@ -63,139 +63,6 @@ pub fn create_function_widget(f: syn::ItemFn, _widget_arguments: WidgetArguments
...
@@ -63,139 +63,6 @@ pub fn create_function_widget(f: syn::ItemFn, _widget_arguments: WidgetArguments
let
kayak_core
=
get_core_crate
();
let
kayak_core
=
get_core_crate
();
// TODO: See if this is still needed. If not, remove it
// let mut input_names: Vec<_> = inputs
// .iter()
// .filter_map(|argument| match argument {
// syn::FnArg::Typed(typed) => {
// let typed_info = typed.ty.to_token_stream().to_string();
// let attr_info = typed.pat.to_token_stream().to_string();
// if (typed_info.contains("KayakContext") && !typed_info.contains("Fn"))
// || (attr_info.contains("styles") && typed_info.contains("Style"))
// {
// None
// } else {
// Some(typed)
// }
// }
// syn::FnArg::Receiver(rec) => {
// emit_error!(rec.span(), "Don't use `self` on widgets");
// None
// }
// })
// .map(|value| {
// let pat = &value.pat;
// quote!(#pat)
// })
// .collect();
//
// let mut input_block_names: Vec<_> = inputs
// .iter()
// .filter(|input| {
// let input = (quote! { #input }).to_string();
// !(input.contains("parent_styles")
// || (input.contains("KayakContext") && !input.contains("Fn")))
// })
// .map(|item| quote! { #item })
// .collect();
// input_block_names.iter_mut().for_each(|input| {
// let input_string = (quote! { #input }).to_string();
// if input_string.contains("children : Children") {
// *input = quote! {
// #[derivative(Debug = "ignore", PartialEq = "ignore")]
// pub children: Children
// };
// } else if input_string.contains("on_event : Option < OnEvent >") {
// *input = quote! {
// #[derivative(Debug = "ignore", PartialEq = "ignore")]
// pub on_event: Option<#kayak_core::OnEvent>
// };
// } else {
// *input = quote! {
// pub #input
// }
// }
// });
// let focusable_default = if widget_arguments.focusable {
// "Some(true)"
// } else {
// "None"
// };
//
// let missing_struct_inputs = vec![
// (
// vec![
// "styles : Option < Style >",
// "styles : Option< kayak_ui :: core :: styles :: Style >",
// ],
// quote! {
// #[derivative(Default(value="None"))]
// pub styles: Option<#kayak_core::styles::Style>
// },
// ),
// (
// vec!["children : Children"],
// quote! {
// #[derivative(Default(value="None"), Debug = "ignore", PartialEq = "ignore")]
// pub children: #kayak_core::Children
// },
// ),
// (
// vec![
// "on_event : Option < OnEvent >",
// "on_event : Option < kayak_ui :: core :: OnEvent >",
// "on_event : Option <\nkayak_ui :: core :: OnEvent >",
// ],
// quote! {
// #[derivative(Default(value="None"), Debug = "ignore", PartialEq = "ignore")]
// pub on_event: Option<#kayak_core::OnEvent>
// },
// ),
// (
// vec!["focusable : Option < bool >"],
// quote! {
// #[derivative(Default(value=#focusable_default))]
// pub focusable: Option<bool>
// },
// ),
// ];
// for (names, token) in missing_struct_inputs {
// if !input_block_names.iter().any(|block_name| {
// names
// .iter()
// .any(|name| block_name.to_string().contains(name))
// }) {
// input_block_names.push(token);
// } else {
// }
// }
// let inputs_block = quote!(
// #(#input_block_names),*
// );
//
// if !input_names
// .iter()
// .any(|item_name| item_name.to_string().contains("children"))
// {
// input_names.push(quote! {
// children
// });
// }
// let inputs_reading_ref = if inputs.len() == 0 {
// quote! {
// let #struct_name { children, styles, .. } = self;
// }
// } else {
// quote!(
// let #struct_name { #(#input_names),*, styles, .. } = self;
// #(let #input_names = #input_names.clone();)*
// )
// };
TokenStream
::
from
(
quote!
{
TokenStream
::
from
(
quote!
{
#[derive(Default,
Debug,
PartialEq,
Clone)]
#[derive(Default,
Debug,
PartialEq,
Clone)]
#
vis
struct
#
struct_name
#
impl_generics
{
#
vis
struct
#
struct_name
#
impl_generics
{
...
...
This diff is collapsed.
Click to expand it.
kayak_render_macros/src/widget_attributes.rs
+
1
−
59
View file @
2b2bc436
use
proc_macro2
::{
Ident
,
TokenStream
};
use
proc_macro2
::{
Ident
,
TokenStream
};
use
proc_macro_error
::
emit_error
;
use
proc_macro_error
::
emit_error
;
use
quote
::
{
quote
,
ToTokens
}
;
use
quote
::
quote
;
use
std
::
collections
::
HashSet
;
use
std
::
collections
::
HashSet
;
use
syn
::{
use
syn
::{
ext
::
IdentExt
,
ext
::
IdentExt
,
...
@@ -70,64 +70,6 @@ pub struct CustomWidgetAttributes<'a, 'c> {
...
@@ -70,64 +70,6 @@ pub struct CustomWidgetAttributes<'a, 'c> {
children
:
&
'c
Children
,
children
:
&
'c
Children
,
}
}
// TODO: This impl may not be needed anymore. If so, it should be removed
impl
<
'a
,
'c
>
ToTokens
for
CustomWidgetAttributes
<
'a
,
'c
>
{
fn
to_tokens
(
&
self
,
tokens
:
&
mut
proc_macro2
::
TokenStream
)
{
let
mut
attrs
:
Vec
<
_
>
=
self
.attributes
.iter
()
.map
(|
attribute
|
{
let
ident
=
attribute
.ident
();
let
value
=
attribute
.value_tokens
();
quote!
{
#
ident
:
#
value
}
})
.collect
();
{
let
children_tuple
=
self
.children
.as_option_of_tuples_tokens
();
attrs
.push
(
quote!
{
children
:
#
children_tuple
});
}
// let missing = vec![
// ("styles", quote! { styles: None }),
// ("on_event", quote! { on_event: None }),
// ];
//
// for missed in missing {
// if !self.attributes.iter().any(|attribute| {
// attribute
// .ident()
// .to_token_stream()
// .to_string()
// .contains(missed.0)
// }) {
// attrs.push(missed.1);
// }
// }
let
quoted
=
if
attrs
.len
()
==
0
{
quote!
({
..
Default
::
default
()
})
}
else
{
if
!
self
.attributes
.iter
()
.any
(|
attribute
|
attribute
.ident
()
.to_token_stream
()
.to_string
()
==
"styles"
)
{
quote!
({
#
(
#
attrs
),
*
,
..
Default
::
default
()
})
}
else
{
quote!
({
#
(
#
attrs
),
*
,
..
Default
::
default
()
})
}
};
quoted
.to_tokens
(
tokens
);
}
}
impl
<
'a
,
'c
>
CustomWidgetAttributes
<
'a
,
'c
>
{
impl
<
'a
,
'c
>
CustomWidgetAttributes
<
'a
,
'c
>
{
/// Assign this widget's attributes to the given ident
/// Assign this widget's attributes to the given ident
///
///
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment