chore: rename ctx to cx
This commit is contained in:
1 parent
23c14078bb
commit
81382e7044
99 files changed
+789
-664
No files matched your search
@@ -133,7 +133,7 @@ impl ToTokens for FunctionComponent {
|
||||
}
|
||||
|
||||
impl<'a> FC for #function_name<'a> {
|
||||
fn render(ctx: Context<'_>, props: &#function_name<'a>) -> VNode {
|
||||
fn render(cx: Context<'_>, props: &#function_name<'a>) -> VNode {
|
||||
let #function_name {
|
||||
..
|
||||
} = props;
|
||||
@@ -150,12 +150,12 @@ impl ToTokens for FunctionComponent {
|
||||
// name: &'a str
|
||||
// }
|
||||
|
||||
// pub fn component<'a>(ctx: &'a Context<'a, Props>) -> VNode<'a> {
|
||||
// pub fn component<'a>(cx: &'a Context<'a, Props>) -> VNode<'a> {
|
||||
// // Destructure the props into the parent scope
|
||||
// // todo: handle expansion of lifetimes
|
||||
// let Props {
|
||||
// name
|
||||
// } = ctx.props;
|
||||
// } = cx.props;
|
||||
|
||||
// #block
|
||||
// }
|
||||
|
||||
@@ -39,7 +39,7 @@ impl Parse for HtmlRender {
|
||||
return input.parse::<LitStr>()?.parse::<HtmlRender>();
|
||||
}
|
||||
|
||||
// let ctx: Ident = s.parse()?;
|
||||
// let cx: Ident = s.parse()?;
|
||||
// s.parse::<Token![,]>()?;
|
||||
// if elements are in an array, return a bumpalo::collections::Vec rather than a Node.
|
||||
let kind = if input.peek(token::Bracket) {
|
||||
@@ -64,8 +64,8 @@ impl ToTokens for HtmlRender {
|
||||
|
||||
// create a lazy tree that accepts a bump allocator
|
||||
let final_tokens = quote! {
|
||||
dioxus::prelude::LazyNodes::new(move |ctx| {
|
||||
let bump = &ctx.bump();
|
||||
dioxus::prelude::LazyNodes::new(move |cx| {
|
||||
let bump = &cx.bump();
|
||||
|
||||
#new_toks
|
||||
})
|
||||
@@ -152,10 +152,10 @@ struct Element {
|
||||
|
||||
impl ToTokens for ToToksCtx<&Element> {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||
// let ctx = self.ctx;
|
||||
// let cx = self.cx;
|
||||
let name = &self.inner.name.to_string();
|
||||
tokens.append_all(quote! {
|
||||
dioxus::builder::ElementBuilder::new(ctx, #name)
|
||||
dioxus::builder::ElementBuilder::new(cx, #name)
|
||||
});
|
||||
for attr in self.inner.attrs.iter() {
|
||||
self.recurse(attr).to_tokens(tokens);
|
||||
|
||||
@@ -61,8 +61,8 @@ pub fn html_template(s: TokenStream) -> TokenStream {
|
||||
/// ```ignore
|
||||
///
|
||||
/// #[fc]
|
||||
/// fn Example(ctx: Context, name: &str) -> VNode {
|
||||
/// ctx.render(rsx! { h1 {"hello {name}"} })
|
||||
/// fn Example(cx: Context, name: &str) -> VNode {
|
||||
/// cx.render(rsx! { h1 {"hello {name}"} })
|
||||
/// }
|
||||
/// ```
|
||||
#[proc_macro_attribute]
|
||||
|
||||
@@ -120,14 +120,14 @@ impl ToTokens for Component {
|
||||
|
||||
let childs = &self.children;
|
||||
let children = quote! {
|
||||
ChildrenList::new(__ctx)
|
||||
ChildrenList::new(__cx)
|
||||
#( .add_child(#childs) )*
|
||||
.finish()
|
||||
};
|
||||
|
||||
tokens.append_all(quote! {
|
||||
dioxus::builder::virtual_child(
|
||||
__ctx,
|
||||
__cx,
|
||||
#name,
|
||||
#builder,
|
||||
#key_token,
|
||||
|
||||
@@ -68,7 +68,7 @@ impl ToTokens for Element {
|
||||
let name = &self.name.to_string();
|
||||
|
||||
tokens.append_all(quote! {
|
||||
dioxus::builder::ElementBuilder::new(__ctx, #name)
|
||||
dioxus::builder::ElementBuilder::new(__cx, #name)
|
||||
});
|
||||
|
||||
for attr in self.attrs.iter() {
|
||||
@@ -221,13 +221,13 @@ impl ToTokens for ElementAttr {
|
||||
}
|
||||
AttrType::Event(event) => {
|
||||
tokens.append_all(quote! {
|
||||
.add_listener(dioxus::events::on::#nameident(__ctx, #event))
|
||||
.add_listener(dioxus::events::on::#nameident(__cx, #event))
|
||||
});
|
||||
}
|
||||
AttrType::EventTokens(event) => {
|
||||
//
|
||||
tokens.append_all(quote! {
|
||||
.add_listener(dioxus::events::on::#nameident(__ctx, #event))
|
||||
.add_listener(dioxus::events::on::#nameident(__cx, #event))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ impl ToTokens for Fragment {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream2) {
|
||||
let childs = &self.children;
|
||||
let children = quote! {
|
||||
ChildrenList::new(__ctx)
|
||||
ChildrenList::new(__cx)
|
||||
#( .add_child(#childs) )*
|
||||
.finish()
|
||||
};
|
||||
tokens.append_all(quote! {
|
||||
// #key_token,
|
||||
dioxus::builder::vfragment(
|
||||
__ctx,
|
||||
__cx,
|
||||
None,
|
||||
#children
|
||||
)
|
||||
|
||||
@@ -81,14 +81,14 @@ impl ToTokens for RsxRender {
|
||||
} else {
|
||||
let childs = &self.roots;
|
||||
let children = quote! {
|
||||
ChildrenList::new(__ctx)
|
||||
ChildrenList::new(__cx)
|
||||
#( .add_child(#childs) )*
|
||||
.finish()
|
||||
};
|
||||
quote! {
|
||||
// #key_token,
|
||||
dioxus::builder::vfragment(
|
||||
__ctx,
|
||||
__cx,
|
||||
None,
|
||||
#children
|
||||
)
|
||||
@@ -96,17 +96,17 @@ impl ToTokens for RsxRender {
|
||||
};
|
||||
|
||||
match &self.custom_context {
|
||||
// The `in ctx` pattern allows directly rendering
|
||||
// The `in cx` pattern allows directly rendering
|
||||
Some(ident) => out_tokens.append_all(quote! {
|
||||
#ident.render(dioxus::prelude::LazyNodes::new(move |__ctx|{
|
||||
let bump = &__ctx.bump();
|
||||
#ident.render(dioxus::prelude::LazyNodes::new(move |__cx|{
|
||||
let bump = &__cx.bump();
|
||||
#inner
|
||||
}))
|
||||
}),
|
||||
// Otherwise we just build the LazyNode wrapper
|
||||
None => out_tokens.append_all(quote! {
|
||||
dioxus::prelude::LazyNodes::new(move |__ctx|{
|
||||
let bump = &__ctx.bump();
|
||||
dioxus::prelude::LazyNodes::new(move |__cx|{
|
||||
let bump = &__cx.bump();
|
||||
#inner
|
||||
})
|
||||
}),
|
||||
|
||||
@@ -46,7 +46,7 @@ impl Parse for RsxTemplate {
|
||||
|
||||
// let new_stream = TokenStream::from(t.to_s)
|
||||
|
||||
// let ctx: Ident = s.parse()?;
|
||||
// let cx: Ident = s.parse()?;
|
||||
// s.parse::<Token![,]>()?;
|
||||
// if elements are in an array, return a bumpalo::collections::Vec rather than a Node.
|
||||
// let kind = if s.peek(token::Bracket) {
|
||||
@@ -72,8 +72,8 @@ impl ToTokens for RsxTemplate {
|
||||
|
||||
// // create a lazy tree that accepts a bump allocator
|
||||
// let final_tokens = quote! {
|
||||
// dioxus::prelude::LazyNodes::new(move |ctx| {
|
||||
// let bump = &ctx.bump();
|
||||
// dioxus::prelude::LazyNodes::new(move |cx| {
|
||||
// let bump = &cx.bump();
|
||||
|
||||
// #new_toks
|
||||
// })
|
||||
|
||||
Reference in new issue
Block a user