Feat: clean up code

This commit is contained in:
Jonathan Kelley committed 2021-02-24 01:32:50 -05:00
1 parent 5204862bc2
commit 83451372aa
16 files changed
+67 -72

No files matched your search

+7 -7
View File
@@ -19,11 +19,11 @@
//!
//!
use std::ops::{Deref, DerefMut};
use bumpalo::Bump;
use crate::innerlude::{Listener, VirtualDom};
use crate::innerlude::{Listener};
/// The `Edit` represents a single modifcation of the renderer tree.
///
@@ -73,7 +73,7 @@ pub struct EditMachine<'src> {
}
impl<'b> EditMachine<'b> {
pub fn new(bump: &'b Bump) -> Self {
pub fn new(_bump: &'b Bump) -> Self {
Self {
traversal: Traversal::new(),
next_temporary: 0,
@@ -206,7 +206,7 @@ impl<'a> EditMachine<'a> {
self.emitter.push(Edit::InsertBefore {})
}
pub fn ensure_string(&mut self, string: &str) -> StringKey {
pub fn ensure_string(&mut self, _string: &str) -> StringKey {
todo!()
// self.strings.ensure_string(string, &self.emitter)
}
@@ -308,7 +308,7 @@ impl<'a> EditMachine<'a> {
self.forcing_new_listeners = previous;
}
pub fn new_event_listener(&mut self, listener: &Listener) {
pub fn new_event_listener(&mut self, _listener: &Listener) {
debug_assert!(self.traversal_is_committed());
todo!("Event listener not wired up yet");
// debug!("emit: new_event_listener({:?})", listener);
@@ -330,14 +330,14 @@ impl<'a> EditMachine<'a> {
todo!("Event listener not wired up yet");
// let (a, b) = listener.get_callback_parts();
// debug_assert!(a != 0);
let event_id = self.ensure_string(listener.event);
let _event_id = self.ensure_string(listener.event);
// self.emitter.update_event_listener(event_id.into(), a, b);
}
pub fn remove_event_listener(&mut self, event: &str) {
debug_assert!(self.traversal_is_committed());
// debug!("emit: remove_event_listener({:?})", event);
let event_id = self.ensure_string(event);
let _event_id = self.ensure_string(event);
todo!("Event listener not wired up yet");
// self.emitter.remove_event_listener(event_id.into());
}
+1 -5
View File
@@ -2,10 +2,6 @@
//! for components to be used within Nodes.
//!
use std::fmt::Debug;
use crate::innerlude::*;
/// The `Component` trait refers to any struct or funciton that can be used as a component
/// We automatically implement Component for FC<T>
// pub trait Component {
@@ -39,8 +35,8 @@ use crate::innerlude::*;
#[cfg(test)]
mod tests {
use super::*;
use crate::prelude::bumpalo::Bump;
use crate::prelude::*;
fn test_static_fn<'a, P>(b: &'a Bump, r: FC<P>) -> VNode<'a> {
todo!()
+8 -8
View File
@@ -1,5 +1,5 @@
use crate::prelude::*;
use crate::{innerlude::Scope, nodes::VNode};
use crate::{nodes::VNode};
use bumpalo::Bump;
use hooks::Hook;
use std::{
@@ -76,18 +76,18 @@ impl<'a> Context<'a> {
// pub fn view(self, lazy_nodes: impl for<'b> FnOnce(&'b Bump) -> VNode<'b> + 'a + 'p) -> DomTree {
// pub fn view<'p>(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a + 'p) -> DomTree {
// pub fn view(self, lazy_nodes: impl FnOnce(&'a Bump) -> VNode<'a> + 'a) -> VNode<'a> {
let g = lazy_nodes(self.bump);
let _g = lazy_nodes(self.bump);
DomTree {}
}
pub fn callback(&self, f: impl Fn(()) + 'a) {}
pub fn callback(&self, _f: impl Fn(()) + 'a) {}
/// Create a suspended component from a future.
///
/// When the future completes, the component will be renderered
pub fn suspend(
&self,
fut: impl Future<Output = impl FnOnce(&'a Bump) -> VNode<'a>>,
_fut: impl Future<Output = impl FnOnce(&'a Bump) -> VNode<'a>>,
) -> VNode<'a> {
todo!()
}
@@ -119,7 +119,7 @@ pub mod hooks {
runner: impl FnOnce(&'a mut InternalHookState) -> Output,
// The closure that cleans up whatever mess is left when the component gets torn down
// TODO: add this to the "clean up" group for when the component is dropped
cleanup: impl FnOnce(InternalHookState),
_cleanup: impl FnOnce(InternalHookState),
) -> Output {
let raw_hook = {
let idx = self.idx.load(std::sync::atomic::Ordering::Relaxed);
@@ -186,9 +186,9 @@ mod context_api {
//! a failure of implementation.
//!
//!
use super::*;
use std::{marker::PhantomPinned, mem::swap, ops::Deref};
use std::{ops::Deref};
pub struct RemoteState<T> {
inner: *const T,
@@ -229,7 +229,7 @@ Context should *never* be dangling!. If a Context is torn down, so should anythi
impl<'a> super::Context<'a> {
// impl<'a, P> super::Context<'a, P> {
pub fn use_context<I, O>(&'a self, narrow: impl Fn(&'_ I) -> &'_ O) -> RemoteState<O> {
pub fn use_context<I, O>(&'a self, _narrow: impl Fn(&'_ I) -> &'_ O) -> RemoteState<O> {
todo!()
}
}
+3 -3
View File
@@ -950,7 +950,7 @@ impl<'a> DiffMachine<'a> {
// When this function returns, the change list stack is in the same state.
pub fn remove_all_children(&mut self, old: &[VNode<'a>]) {
debug_assert!(self.change_list.traversal_is_committed());
for child in old {
for _child in old {
// registry.remove_subtree(child);
}
// Fast way to remove all children: set the node's textContent to an empty
@@ -984,7 +984,7 @@ impl<'a> DiffMachine<'a> {
// [... parent]
pub fn remove_self_and_next_siblings(&mut self, old: &[VNode<'a>]) {
debug_assert!(self.change_list.traversal_is_committed());
for child in old {
for _child in old {
// registry.remove_subtree(child);
}
self.change_list.remove_self_and_next_siblings();
@@ -1001,7 +1001,7 @@ enum KeyedPrefixResult {
}
mod support {
use super::*;
// // Get or create the template.
// //
+2 -2
View File
@@ -88,7 +88,7 @@ pub mod builder {
// types used internally that are important
pub(crate) mod innerlude {
// pub(crate) use crate::component::Properties;
use crate::context::hooks::Hook;
pub(crate) use crate::context::Context;
pub(crate) use crate::error::{Error, Result};
use crate::nodes;
@@ -102,7 +102,7 @@ pub(crate) mod innerlude {
pub type FC<P> = for<'scope> fn(Context<'scope>, &'scope P) -> DomTree;
mod fc2 {
use super::*;
}
// pub type FC<'a, P: 'a> = for<'scope> fn(Context<'scope>, &'scope P) -> DomTree;
// pub type FC<P> = for<'scope, 'r> fn(Context<'scope>, &'scope P) -> DomTree;
+2 -2
View File
@@ -335,7 +335,7 @@ where
/// .finish();
/// ```
#[inline]
pub fn on(mut self, event: &'a str, callback: impl Fn(()) + 'a) -> Self
pub fn on(self, _event: &'a str, _callback: impl Fn(()) + 'a) -> Self
// pub fn on<F>(mut self, event: &'a str, callback: impl Fn(()) -> () + 'static) -> Self
// F: Fn(()) + 'static,
// F: Fn(()) + 'a,
@@ -1081,7 +1081,7 @@ pub fn on<'a, 'b, F: 'static>(
}
}
pub fn virtual_child<'a, T>(bump: &'a Bump, props: T, f: crate::innerlude::FC<T>) -> VNode<'a> {
pub fn virtual_child<'a, T>(_bump: &'a Bump, _props: T, _f: crate::innerlude::FC<T>) -> VNode<'a> {
todo!()
// VNode::Component()
}
+7 -7
View File
@@ -3,7 +3,7 @@
//!
//! These VNodes should be *very* cheap and *very* fast to construct - building a full tree should be insanely quick.
use std::marker::PhantomData;
use bumpalo::Bump;
pub use vcomponent::VComponent;
@@ -97,7 +97,7 @@ mod vnode {
mod velement {
use super::*;
use std::{collections::HashMap, fmt::Debug};
use std::{fmt::Debug};
#[derive(Debug)]
pub struct VElement<'a> {
@@ -133,7 +133,7 @@ mod velement {
impl<'a> VElement<'a> {
// The tag of a component MUST be known at compile time
pub fn new(tag: &'a str) -> Self {
pub fn new(_tag: &'a str) -> Self {
todo!()
// VElement {
// tag,
@@ -265,9 +265,9 @@ mod vtext {
/// Only supports the functional syntax
mod vcomponent {
use crate::innerlude::FC;
use std::{any::TypeId, fmt, future::Future, marker::PhantomData};
use std::{marker::PhantomData};
use super::VNode;
#[derive(Debug)]
pub struct VComponent<'src> {
@@ -279,8 +279,8 @@ mod vcomponent {
impl<'a> VComponent<'a> {
pub fn new<P>(caller: FC<P>, props: P) -> Self {
let caller = caller as *const ();
let props = Box::new(props);
let _caller = caller as *const ();
let _props = Box::new(props);
todo!()
// Self {
+3 -3
View File
@@ -3,7 +3,7 @@ use crate::innerlude::*;
use crate::nodes::VNode;
use bumpalo::Bump;
use generational_arena::Index;
use owning_ref::StableAddress;
use std::{
any::TypeId,
borrow::{Borrow, BorrowMut},
@@ -105,7 +105,7 @@ impl Scope {
/// Update this component's props with a new set of props, remotely
///
///
pub(crate) fn update_props<'a, P>(&self, new_props: P) -> crate::error::Result<()> {
pub(crate) fn update_props<'a, P>(&self, _new_props: P) -> crate::error::Result<()> {
Ok(())
}
@@ -133,7 +133,7 @@ impl Scope {
// these lifetimes could be very broken, so we need to dynamically manage them
let caller = std::mem::transmute::<*const (), FC<PLocked>>(self.caller);
let props = self.props.downcast_ref::<PLocked>().unwrap();
let nodes: DomTree = caller(ctx, props);
let _nodes: DomTree = caller(ctx, props);
todo!("absorb domtree into self")
// let nodes: VNode<'bump> = caller(ctx, props);
+7 -8
View File
@@ -2,12 +2,11 @@
use crate::{
changelist::{self, EditList},
dodriodiff::DiffMachine,
nodes::VNode,
};
use crate::{events::EventTrigger, innerlude::*};
use any::Any;
use bumpalo::Bump;
use changelist::EditMachine;
use generational_arena::{Arena, Index};
use std::{
any::{self, TypeId},
@@ -107,7 +106,7 @@ impl VirtualDom {
let EventTrigger {
component_id,
listener_id,
event,
event: _,
} = evt;
let component = self
@@ -159,13 +158,13 @@ impl VirtualDom {
fn process_lifecycle(&mut self, LifecycleEvent { event_type }: LifecycleEvent) -> Result<()> {
match event_type {
// Component needs to be mounted to the virtual dom
LifecycleType::Mount { to, under, props } => {}
LifecycleType::Mount { to: _, under: _, props: _ } => {}
// The parent for this component generated new props and the component needs update
LifecycleType::PropsChanged { props, component } => {}
LifecycleType::PropsChanged { props: _, component: _ } => {}
// Component was messaged via the internal subscription service
LifecycleType::Callback { component } => {}
LifecycleType::Callback { component: _ } => {}
}
Ok(())
@@ -216,7 +215,7 @@ pub enum LifecycleType {
impl LifecycleEvent {
fn index(&self) -> Option<Index> {
match &self.event_type {
LifecycleType::Mount { to, under, props } => None,
LifecycleType::Mount { to: _, under: _, props: _ } => None,
LifecycleType::PropsChanged { component, .. }
| LifecycleType::Callback { component } => Some(component.clone()),